Star Wars gone done 'bin on a diet.
A leaner, slimmed down Star Wars program ROM that outwardly looks and plays exactly the same as every other Rev2 ROM Star Wars machine out there. Except this Star Wars Lite code removes some unimportant code/data and leaves a significant 6030 bytes of free memory space.
Space to do things in like extra code or data. Memory space to play in!
Basically I've removed all the code in Star Wars that runs the diagnostic test mode and the accounting screens, along with tidying up some of the suspected unused code and data that was left in the original ROMs.
So apart from the one the attract screens text being messed up, it plays like Star Wars. If I remove the attract screens next I could recover another good chunk of free space for even more code or data. Quite what yet I have no idea, but it's a place to start.
I made some notes what I'd done over the past two days so I knew what I did in future. I'll paste them below to the handful of folks who may be interested:
21/03/2015 Copy latest disassembly to StarWarsLite folder
To assemble use command line:
..AS09 -l -s -n StarWars.asm
This turns on list file, generates Motorola S19 output and turns off optimisations to keep output same as original.
Strip out Test Mode and Accounting screen functions, but use extra org's to keep function calls working from Hi page memory.
Strip out text that is obviously used in test mode/accounting screens. Strip out pointers to that text from table. Fortunately test/accounting text was at end of pointer table.
Works/plays OK in MAME at this point, but attract screen 2 (Obi Wan is gone but..) has text shifted in wrong places. Suspect I've removed pointer/data to text offsets.
Find and remove calls to accounting screen and test mode when service switch is on. $64F4, $650C, $D7A6, $F2CC
Hi page code calls two functions, one to get random numbers ($CE45), and another to check and wait on Math hardware ($CDBA).
Next I moved the function code for Gen_Random and Math_Run_Start to the top of ROM ($FFDF and $FFE9 respectively), just before the interrupt vectors, rather than being in the middle of other code at $CDBA and $CE45. I re-assemble the Hi Page code to use these new addresses.
This way I can change the main code in future without having to keep re-assembling the Hi Page code.
This now stops working in MAME. Doh! Looking at the IRQ interrupt code I spot:
IRQ:
ldx $A,s ; Get calling address
cmpx #$6000 ; Bounds check for return address in ROM
bcc loc_EF5E
swi
loc_EF5E: ; Only allow IRQ calls from lower in ROM than BADIRQ function
cmpx #BADIRQ
bcs loc_EF64
swi
loc_EF64:
BADIRQ is located at $EF54 as a trap in case the program crashes, and sticks in a loop until the watchdog resets the game.
BADIRQ:
$EF54 bra BADIRQ
So the IRQ interrupt code checks that the calling address is above $6000 (ie in ROM space) and also disallows calls from above the IRQ code address. This is normally the test mode code that I've now removed.
Commenting out the check works and the game appears to run again in MAME... I say appears to as it runs attract mode OK and plays through easy level space, trench, explosion, space, then resets when first bunkers/towers level is reached. Clearly there's something else been altered!
Looked at the Hi Page code and did a search on all text 'jsr' so I could look at all the subrioutine calls. Didn't take long, though it was pretty much the last jsr that was still hardcoded to jsr $CE45. Changed it to jsr Gen_Random label, that is now set to new location at $FFDF. Now plays properly through bunkers/towers stage.
Took out some other suspected unused data areas at $95BD, $AA25, $B34C ("Hally was the whipcracker text" and an other copyright text), $CE4F ("DURFEY GOT WIRED" text).
Took out unused function at $D8F7
That leaves $178E (6030) bytes free from $E850
Realised that removing accounting/test setup screen means can't alter game difficulty, seems to ignore DIPswitch settings in favour of what NOVRAM holds. Still got more accounting NOVRAM functions to find that could probably be removed.