New kid on the TZX block

Say Hello... tell us your what you know, and what you're interested in learning!
Forum rules
Please say hello... tell us what systems & CPU's you can program, and what you're interested in learning!
Post Reply
mrcook
Posts: 10
Joined: Thu Apr 25, 2019 8:14 pm

New kid on the TZX block

Post by mrcook » Mon May 06, 2019 9:17 pm

Hi, my name is Michael.

I started out on the ZX81 and ZX Spectrum back in the day, progressing to the Amstrad CPC, then Amiga 500, and 1200.

Although I dabbled with BASIC on those machines, I never tried learning assembly. I remember thinking it would be way too hard to learn :/ Once I'd moved on to the PC in '94, assembly was a thing of the past.

I'd messed around with emulators ever since I got the PC, so those old arcade and speccy games always brought back fond memories, but with it also curiosity about how they were coded. Sometime around 2015 I started trying to find out more info and it was this that led me to Richard Dymond's excellent Skoolkit project where I found his Manic Miner disassembly!

I figured a good way to learn assembly would be to try porting Manic Miner to the C language. After a few months I had a working game, albeit without sound. I'd learned a lot about how assembly worked along with improving my basic C coding skills.

After this I started wondering how on earth did Richard manage to disassemble the game and started thinking about giving it a go myself. After false starts with both Cyclone and Chuckie Egg, I decided to change to a game that held more importance for me, and as a bonus it was only a 16K game. That was Jetpac!

I finished my disassembly at the end of 2018 and because I'd been watching Keith's videos for most of the year, I fancied trying to fix up Jetpac to run on multiple systems like he was doing in his vids.

My first task was to do some refactoring to try and make the game a little easier to run on different systems; things like removing the self-modifying code and de-optimising some of the more cryptic stuff -- the game now needs a 48K speccy!

I took break for a little while but a couple of weeks ago I started working on this again - setting up a build toolchain and moving away from the Pasmo assembler to VASM. Perhaps the first system I'll try will be the Amstrad CPC.

I don't know if I'll ever finish this project, but it's been a blast demystifying my childhood!

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: New kid on the TZX block

Post by akuyou » Mon May 06, 2019 9:34 pm

Fascinating stuff!
I've never looked at a large scale 'disassembly project' - I've looked at bits of other peoples source code to try to get clues, or when I'm in a bind (like wav playing on the sam coupe)

I've always been of the opinion "If I can't make it myself, I won't be able to understand someone else's code", but your experience seems to be counter to that... Do you think you've learned more/faster by starting with other peoples code? or is it just that's the way you prefer to learn?

So now you're porting Jetpac to the CPC? That certainly sounds a great project.... good luck with it!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

mrcook
Posts: 10
Joined: Thu Apr 25, 2019 8:14 pm

Re: New kid on the TZX block

Post by mrcook » Mon May 06, 2019 9:52 pm

akuyou wrote: Mon May 06, 2019 9:34 pm Do you think you've learned more/faster by starting with other peoples code? or is it just that's the way you prefer to learn?
Hmm, probably not :-)

I suppose it's easier because the scope of the project is well defined, and something like porting ASM->C is quite binary -- as opposed to developing a game which requires lots of invention, game design, balancing, etc., as well as the coding itself.

I spent over 250 hours working on the port. It was interesting, but I'm sure I would have learned a lot more in that time actually writing a game from scratch.

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: New kid on the TZX block

Post by akuyou » Mon May 06, 2019 11:00 pm

Interesting!... I'm of the firm opinion that the best way to learn anything is "Whatever way you enjoy", because keeping up motivation is critical to achieving any result when it comes to learning, I learned a lot of my Japanese from games and comics, because I could read them for hours and days without it feeling like study.

If you ever felt like it, I think it would make a fascinating video if you were to take a small part of the disassembled code, and discussed how you worked out what it did, and made any improvements (like proper labels, symbol definitions etc)... It's not something I can do, because as I say, I've never done any disassembly of this kind.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

mrcook
Posts: 10
Joined: Thu Apr 25, 2019 8:14 pm

Re: New kid on the TZX block

Post by mrcook » Tue May 07, 2019 7:34 pm

"Whatever way you enjoy", because keeping up motivation is critical
Agreed.

When I say I disassembled Jetpac I mean more than just taking the machine code and producing opcodes. It's the annotations (labels, variables, etc.) and the comments explaining the functionality that I consider to be the real value. There's always improvements to be made but I feel I have a pretty well documented source code. I actually emailed Rare to ask for permission to release the code to github, but alas I never heard back from them.

Here's a taster:

Code: Select all

; Collect Rocket module or fuel pod.
; Module is collected after player collides with it.
; Input:IX Rocket module object.
CollectRocketItem:
  set 1,(ix+$04)          ; Module "state"
  call ActorFindDestroy   ; Returns DE
  ld bc,POINTS_ROCKET     ;
  call AddPointsToScore   ;
  call SfxFuelCollect     ;
  ld hl,(jetman_pos_x)    ; Jetman Y,X position
  ld (ix+$01),l           ; Update module X position
  ld (ix+$02),h           ; Update module Y position
  call ActorUpdatePosDir  ;
  call ActorGetSpriteAddressPosX ; Update actor and draw sprite
  jp ColourizeSprite      ;
I have thought about doing a video cast for some of this stuff but I never seem to have got around to it. For a little while now I've been working on a presentation I'd like to give at work. Perhaps after I've done that I might consider a video or two....or the whole experience may scare me off completely! Let's see.

User avatar
akuyou
Posts: 563
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: New kid on the TZX block

Post by akuyou » Tue May 07, 2019 9:35 pm

Yes, that looks very well commented and easy to read!

I think it would be quite interesting to hear how you did that if you did ever decide to do a video.

Great stuff!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Post Reply

Return to “Introductions”