(Or how I learnt assembler on PC)
The first time I saw Tim Clarkes MARS program on PC, I was puzzled. I was still coding on Atari ST, and that was the first time a PC program impressed me so much.
It was better than everything I had ever seen on PC. And since I already was in love with fractal terrains for some years, I was just puzzlingly amazed !
I wanted to, I had to do the same. Problem : it was quite difficult to code the same kind of things on Atari, where the video memory organisation is a real pain. The only possible alternative was to code something similar on PC as well, but I had never coded on PC before. So what ? MARS was a very little exe, and I wasnt frightened by a little disassembly session. So I ran Turbo Debugguer on that little neat exe, and started to examine the code. PC assembly is quite similar to 68000, so understanding the asm mnemonics wasnt much of a problem. The real difficulty was : how the hell could I dump disassembled code to disk with that dumb Turbo Debugguer ?! I didnt know, and I still dont know, Ive never ever found how I could do that. It was quite a problem, because understanding the whole thing just by looking at the code was er, not possible, to say the least.
Im sometimes quite fond of brute-force solutions. And Im not easily frightened.
I took a piece of paper.
I took a pencil.
And I copied all the disassembled code down to the paper. I swear ! It was long. It was boring. It was painful. Some hours later, I had the code dumped. Actually not as big as what I had imagined. The job wasnt over anyway, I still had to recopy it on PC, compile it, and make it run. I took some more hours to copy it back, and again some more time to fix the compilation errors. Of course, you just cant imagine recompiling Turbo Debuggued code without minor changes. I had never used Tasm before, which explains why it took me some hours to fix all that junk. Finally I succeeded in compiling the damn thing. I ran it
and of course it pitifully crashed. Black screen. Over. Reboot. Ok, I wasnt naive enough to imagine it would be so easy. I really started looking at the code with deep interest, made some changes, traced it multiple times. What can I say ? It took me two days without sleeping, and I cant summarize them easily. I had to locate the recursive midpoint code, the part responsible for the skymap, the part responsible for drawing the voxels (always nice to write an unrolled REPT 200 / ..drawing code / ENDM on a paper, dont you think ?) but it finally worked ! I had the exact same Mars program running, and after two days commenting every line of the original source, I just knew it by heart. I also had learnt a lot about PC assembly in the process, and was really proud of that little hack.
My disassembled-recompiled version is made of blue (the original looks, of course, like the Red Planet), and I called it Neptune.
Nowadays I just think I was mad, but those are really nice memories.