I'm afraid that despite spending over two weeks on the original code, I've not made much progress. I have now named most of the variables and figured out what some of the main functions are, the problem however is that its very unstable to the point that I can't change the code much before it breaks.
During the year I went through the data within the code and replaced all hardcoded addresses with pointers, so everything should be using relative addresses. The stability issues could also be alignment related, as adding strategically placed NOP's gets it working again.
The next issue is the table sizes, there's various tables for the map, ships, ship map locations, particles, pre-calculated triangles for trees, ships, buildings etc. Some of these are embedded within the code, the majority are above the code. I've increased the size of these appropriately I believe, but there's definitely an issue with one of the tables above the code that's causing crashes. There may also be a crash caused by variables not being set, as it randomly crashes when starting a game.
That's the major issues. Minor issues I still need to resolve include:
- Increasing the plot range of Ships to match the landscape
- Correcting the plot range of particles
Optional things I'd like to look into:
- Increase the plot range of particles
- Alter the ship, alien ship and particle code to move them based on time from the last frame, instead of being fixed at 1/25th of a second
- Support different resolutions
- Support a 24bit palette
Then there's the ARM2/3 optimizations:
- Replacing the triangle based landscape plotting with a quadrilateral routine
- Optimizing the line fill routine
- (optional) Merge the object plot code (ships, buildings, trees) into the landscape routine, instead of pre-building a separate triangle plot list for them
I have however resolved what I believe to be all the legacy bugs/issues:
- Now requests the screen address
- The OS_Byte used for checking keys (which fixes the cheat mode)
- One of the functions had a typo on the exit LDM, which could corrupt the stack
- Selects the correct sounds, without the order of WaveSynth and Percussion needing to be swapped
- Speed regulation to 25fps
- Non-32bit code corrected
- Self-modifying code removed
Finally, I've got to figure out how to provide a way to patch the original Zarch. I've tried using David Pilling's !Refreshen to create a diff patch, but it fails to worth with Zarch. Unless I can find an alternative, I'll have to create a diff patcher from scratch.