Jetpac annotated disassembly released

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
cmal
Manic Miner
Posts: 630
Joined: Fri Jun 05, 2020 1:05 am
Location: California

Re: Jetpac annotated disassembly released

Post by cmal »

Great job MrCook. I'm looking forward to delving into the disassembly. I once tried to disassemble Starquake with the Spectacular debugger and pen & paper and got absolutely lost!
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Jetpac annotated disassembly released

Post by Seven.FFF »

Quazar wrote: Mon Jul 06, 2020 8:40 pm ... why did Ultimate do this unneeded instruction all the time, just causes problems ;)

They had some cross-development system which allowed them to assemble the code on another computer, and send it up to the wire to the Spectrum, and then remotely debug from the other computer. Port $7d, being unused on the 16K and 48K Spectrums before the 128K models were invented, was how they interfaced and controlled the Spectrum side of the debug hardware. It only started causing problems when the 128K model was invented.

They really shouldn't have left the debug instructions in the release versions of the games though, if they were practicing defensive coding (they weren't). A while back I did a similar thing with the Parasys remote debug hardware. The code I left in checks the serial port to see if there is a byte ready to be received. Without a debugger attached there should never be any bytes to be received, but I found if I left my game running overnight, sometimes there was random electrical noise picked up that caused the code to wait for a byte that never arrived, so my game would very occasionally hang.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Jetpac annotated disassembly released

Post by Ast A. Moore »

Seven.FFF wrote: Mon Jul 06, 2020 9:12 pm I found if I left my game running overnight . . .
Holy smokes, Robin. That’s some rigorous software testing right there. :D
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
Quazar
Drutt
Posts: 31
Joined: Tue Jun 16, 2020 2:28 pm
Contact:

Re: Jetpac annotated disassembly released

Post by Quazar »

Seven.FFF wrote: Mon Jul 06, 2020 9:12 pm They had some cross-development system which allowed them to assemble the code on another computer, and send it up to the wire to the Spectrum, and then remotely debug from the other computer. Port $7d, being unused on the 16K and 48K Spectrums before the 128K models were invented, was how they interfaced and controlled the Spectrum side of the debug hardware. It only started causing problems when the 128K model was invented.
Ah ha! Thanks for explaining!
Quazar - Developing for the SAM Coupé for 30+ Years!
Hardware, Software, 'SAM Revival' magazine -> www.samcoupe.com
Plus hardware for the ZX Spectrum, RC2014 and other general retro peripherals.
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

Re: Jetpac annotated disassembly released

Post by XoRRoX »

[mention]mrcook[/mention] Wow - very nice :D Thanks so much for doing and sharing this 8-)

Seeing recent comments regarding the out ($fd),a, could you update the listing to reflect this so others aren't thrown off by it?
Nienn Heskil
Microbot
Posts: 134
Joined: Tue Jun 09, 2020 6:14 am
Contact:

Re: Jetpac annotated disassembly released

Post by Nienn Heskil »

Seven.FFF wrote: Mon Jul 06, 2020 9:12 pm Port $7d, being unused on the 16K and 48K Spectrums before the 128K models were invented, was how they interfaced and controlled the Spectrum side of the debug hardware.
Doubt it. They use OUT (#FD),A in very specific spots - reading the keyboard, just before an IN A,(#FE), with 'A' holding the keyrow byte. You can see this picture in all of their early games (Tranz Am, Jetpac, Cookie, Pssst, Jetman, even Knight Lore). It seems more likely that they simply had incorrect info in regards to how keyboard reading is done on the Spectrum, thinking you were first supposed to OUTput the keyrow byte to #FD.
mrcook
Drutt
Posts: 46
Joined: Tue Jun 09, 2020 7:31 pm

Re: Jetpac annotated disassembly released

Post by mrcook »

Thanks for all the feedback!

I should clarify that before I started this disassembly I had no prior experience with assembly on any system. This project was a way for me to learn a little more about it so there's likely plenty of mistakes and misunderstanding on my part :)

Quazar wrote: Mon Jul 06, 2020 8:40 pmI'm stumped by your description of this OUT in various places
I just thought it was another way to read the keyboard, and figured the brothers knew what they were doing :P

Seven.FFF wrote: Mon Jul 06, 2020 9:12 pmThey had some cross-development system which allowed them to assemble the code on another computer, and send it up to the wire to the Spectrum, and then remotely debug from the other computer.
Considering this was 1982/83 I'd be surprised if they had any kind of remote debugging. I'm sure it'd be just a case of squirt the code to the speccy, manual test, rinse and repeat.

Nienn Heskil wrote: Tue Jul 07, 2020 6:52 amThey use OUT (#FD),A in very specific spots - reading the keyboard, just before an IN A,(#FE), with 'A' holding the keyrow byte. You can see this picture in all of their early games (Tranz Am, Jetpac, Cookie, Pssst, Jetman, even Knight Lore). It seems more likely that they simply had incorrect info in regards to how keyboard reading is done on the Spectrum, thinking you were first supposed to OUTput the keyrow byte to #FD.
Sounds plausible considering there would have been very little developer docs around at the time. It also seems there are differing ideas on what this OUT is doing so I'll leave the annotations as-is for now, until there is a definitive answer.

XoRRoX wrote: Tue Jul 07, 2020 4:30 amSeeing recent comments regarding the out ($fd),a, could you update the listing to reflect this so others aren't thrown off by it?
I don't see any option for editing posts on this forum, but I will try to clarify the README on github.

Cheers,
Michael
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

Re: Jetpac annotated disassembly released

Post by XoRRoX »

[mention]mrcook[/mention]
I meant the source listing on github;)
User avatar
uglifruit
Manic Miner
Posts: 703
Joined: Thu Jan 17, 2019 12:41 pm
Location: Leicester
Contact:

Re: Jetpac annotated disassembly released

Post by uglifruit »

[mention]mrcook[/mention] This is very interesting.
How hard would it be to reassemble Jetpac into uncontended memory, I wonder - and would there be an appreciable speed boost.
CLEAR 23855
User avatar
D-Type
Drutt
Posts: 3
Joined: Fri Aug 06, 2021 11:14 pm
Location: Zurich, Switzerland

Re: Jetpac annotated disassembly released

Post by D-Type »

Is the HTML disassembly hosted online anywhere or do I have to install SkoolKit? (Which I don't really want to do, but if needs must I will. I'm currently using dasmfw for 8-bit reverse engineering, but it's Motorola/6502 family.)

Thanks!
P*h*i*l*l*i*p EEaattoon in real life
mrcook
Drutt
Posts: 46
Joined: Tue Jun 09, 2020 7:31 pm

Re: Jetpac annotated disassembly released

Post by mrcook »

D-Type wrote: Fri Aug 06, 2021 11:34 pm Is the HTML disassembly hosted online anywhere
I never generated the HTML stuff. Except for a few formatting niceties I think opening the .skool file in an editor is more useful, and easy to navigate.

You don't need to install Skoolkit, unless you really want those HTML docs, or need to build a tape file.
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Jetpac annotated disassembly released

Post by Joefish »

uglifruit wrote: Fri Oct 30, 2020 2:18 pm @mrcook This is very interesting.
How hard would it be to reassemble Jetpac into uncontended memory, I wonder - and would there be an appreciable speed boost.
The cartridge version is effectively running from uncontended memory (the ROM space). I don't know if that appears to run any faster, or has been deliberately slowed down. May be worth comparing the code from the cartridge with that from the cassette version.
mrcook
Drutt
Posts: 46
Joined: Tue Jun 09, 2020 7:31 pm

Re: Jetpac annotated disassembly released

Post by mrcook »

Joefish wrote: Mon Sep 13, 2021 12:52 pm The cartridge version is effectively running from uncontended memory (the ROM space).
The whole game is copied to RAM first. Here's the loader from the start of the ROM:

Code: Select all

$0000 di
$0001 ld a,$3f
$0003 ld i,a
$0005 ld sp,$5cf0
$0008 im 1
$000a ld hl,$2000
$000d ld de,$4000
$0010 ld bc,$1b00
$0013 ldir
$0015 xor a
$0016 out ($fe),a
$0018 out ($fd),a
$001a in a,($fe)
$001c cpl
$001d and $1f
$001f jr z,$c01a
$0021 ld hl,$004d
$0024 ld de,$6000
$0027 ld bc,$2000
$002a ldir
$002c jp $6000
First the splash screen, then the game code.

The game also utilises self-modifiying code (the NewActor routine at address $6971), so needs to live in RAM.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Jetpac annotated disassembly released

Post by Alessandro »

I like these Skoolkit disassemblies when they come as formatted HTML and are available with decimal numerals. Much easier to read and to understand for Assembly semi-literates like yours truly :mrgreen:
User avatar
Lethargeek
Manic Miner
Posts: 743
Joined: Wed Dec 11, 2019 6:47 am

Re: Jetpac annotated disassembly released

Post by Lethargeek »

Alessandro wrote: Mon Sep 13, 2021 3:11 pm I like these Skoolkit disassemblies when they come as formatted HTML and are available with decimal numerals. Much easier to read and to understand for Assembly semi-literates like yours truly :mrgreen:
blasphemer! loathsome decimal heresy (except counters) in z80 disassembly must be eradicated with fire! :evil:
User avatar
popeymon
Drutt
Posts: 11
Joined: Fri Jan 31, 2020 11:28 am

Re: Jetpac annotated disassembly released

Post by popeymon »

I will definitely be looking at this Jetpac disassembly.

If you hadn't done any assembler before, you took on a big challenge!

I am doing a disassembly using SkoolKit of Horace Goes Skiing. The READ_KEYBOARD routine disassembly is https://popeymongames.co.uk/2021/04/23/ ... -at-28234/.

And you've given me an idea to consider using GitHub to publish it. I was just going to put it on my PopeyMon website and add to the above, using some other tools that other SkoolKit users have used.

But GitHub is another option. Not something I've used and I need to weight up the pros and cons of using it, and making it readable for non-coders (sort of).
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Jetpac annotated disassembly released

Post by Alessandro »

Lethargeek wrote: Mon Sep 13, 2021 3:29 pm blasphemer! loathsome decimal heresy (except counters) in z80 disassembly must be eradicated with fire! :evil:
Hey! The Taliban are coming! :P
User avatar
Mpk
Dynamite Dan
Posts: 1008
Joined: Tue Feb 09, 2021 8:10 am

Re: Jetpac annotated disassembly released

Post by Mpk »

There's a whole bunch of disassemblies at https://skoolkit.ca/disassemblies/ Speaking as a shameless code voyeur it'd be great to have everyone's disassemblies in one place.

Maybe there's some sort of Spectrum Computing site that could host them all, if skoolkit.ca isn't appropriate.
User avatar
Morkin
Bugaboo
Posts: 3276
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Jetpac annotated disassembly released

Post by Morkin »

Mpk wrote: Mon Sep 13, 2021 6:51 pm There's a whole bunch of disassemblies at https://skoolkit.ca/disassemblies/ Speaking as a shameless code voyeur it'd be great to have everyone's disassemblies in one place.

Maybe there's some sort of Spectrum Computing site that could host them all, if skoolkit.ca isn't appropriate.
I noticed that the one I finished recently for Avalon was automatically put in the game's entry as 'source code - remote link' alongside Steve's Graftgold site link. I guess others may go onto ZXDB as links in the same way?

I've also noticed how people keep their disassemblies in different formats. GitHub seems to be quite popular (I'm not sure how to use it TBH). Others are Skoolkit's standard HTML page output, hosted on people's sites. I guess the main problem is that over the years sites can disappear.

I did add an .asm file for download on request as well - to be honest I wasn't sure what the best format is for a single disassembly file. Is it an .asm file or something else?

Of course, as Alessandro has now mentioned it ;) , there's always the additional discussion about whether it should be in decimal or hex... :lol:
My Speccy site: thirdharmoniser.com
User avatar
Mpk
Dynamite Dan
Posts: 1008
Joined: Tue Feb 09, 2021 8:10 am

Re: Jetpac annotated disassembly released

Post by Mpk »

Morkin wrote: Mon Sep 13, 2021 10:00 pmas now mentioned it ;) , there's always the additional discussion about whether it should be in decimal or hex... :lol:
The skoolkit format ones have a link at the bottom to switch to Hex/Dec, so that solves that issue.

The multiple site problem is why I think it'd be peachy if they could get hosted here somehow, as surely this site will remain forever? And github's just a chore for all involved.
User avatar
Einar Saukas
Bugaboo
Posts: 3143
Joined: Wed Nov 15, 2017 2:48 pm

Re: Jetpac annotated disassembly released

Post by Einar Saukas »

Morkin wrote: Mon Sep 13, 2021 10:00 pm I noticed that the one I finished recently for Avalon was automatically put in the game's entry as 'source code - remote link'
Notice it's also marked as "Source code repository - Disassembled".

Morkin wrote: Mon Sep 13, 2021 10:00 pm I guess others may go onto ZXDB as links in the same way?
All disassemblies are stored in ZXDB this way.

If I missed anything, please let me know!
mrcook
Drutt
Posts: 46
Joined: Tue Jun 09, 2020 7:31 pm

Re: Jetpac annotated disassembly released

Post by mrcook »

Alessandro wrote: Mon Sep 13, 2021 3:11 pm I like these Skoolkit disassemblies when they ... are available with decimal numerals. Much easier to read and to understand for Assembly semi-literates like yours truly
I understand what you mean, I used dcimal numbers for my first forays into disassembly. The thing is, assembly language starts to make way more sense when work in hex numbers. It honestly doesn't take too much time to get your head around it, and your dis/assembly efforts will be rewarded for it.
mrcook
Drutt
Posts: 46
Joined: Tue Jun 09, 2020 7:31 pm

Re: Jetpac annotated disassembly released

Post by mrcook »

Mpk wrote: Mon Sep 13, 2021 6:51 pm Maybe there's some sort of Spectrum Computing site that could host them all, if skoolkit.ca isn't appropriate.
I did bring together a bunch of old disassemblies (some from wayback machine, some I had in my own backups, some existing sites), I converted them to Skoolkit format (some I even reverse engineered from HTML only to .skool files!) and put them on github here: https://github.com/mrcook/zx-spectrum-games

I did think out adding more, but wasn't sure if the owners would be happy with that.

I would personally recommend uploading your disasemblies to a site like Github/Gitlab/etc. Other sites, even personal ones, often disapear or are updated with some new framework (Wordpress, or whatever the latest cool is) and often files like this just disapear. Sure, Github could disappear too, but at this stage it'll probably outlive all of us.

The Skoolkit HTML sites are fine, but anyone serious about understanding how a game works really needs to see the plain ASM/skool source code files.
User avatar
Mpk
Dynamite Dan
Posts: 1008
Joined: Tue Feb 09, 2021 8:10 am

Re: Jetpac annotated disassembly released

Post by Mpk »

This is awesome, I hadn't seen some of these before. I was playing around with AticAtac & skoolkit last night, but I see now it's already been done.
The Skoolkit HTML sites are fine, but anyone serious about understanding how a game works really needs to see the plain ASM/skool source code files.
I'm not sure what is missing from the HTML sites though, compared with the .skool files. Isn't the content the same, just easier to read/browse in the html?
User avatar
SkoolKid
Manic Miner
Posts: 407
Joined: Wed Nov 15, 2017 3:07 pm

Re: Jetpac annotated disassembly released

Post by SkoolKid »

Mpk wrote: Mon Sep 13, 2021 10:11 pm The skoolkit format ones have a link at the bottom to switch to Hex/Dec, so that solves that issue.
Just to clear up a possible misconception: the base-switching links in the page footers is not an automatic feature of SkoolKit - which explains why only the disassemblies I've written and published actually have them. :P

I have now documented how to add base-switching links to your own disassembly, though:

https://skoolkit.readthedocs.io/en/late ... -switching

That 'Base switching' section will be in the manual for 8.6, but the instructions should still work for earlier versions of SkoolKit as well (if you grab bases.ref and bases.py from the GitHub repo).
SkoolKit - disassemble a game today
Pyskool - a remake of Skool Daze and Back to Skool
Post Reply