
The Space Invaders TRS-80 'Bootleg' Project
Old News
21st October 2003
Space Invaders is now playable in the correct orientation on xtrs
unthrottled (-noautodelay). Unfortunately the graphics routines are now
too slow for the game - I'm hoping I can optimise them but I'm not sure
at this stage how successful I'll be. There's also the problem now that
because the graphics routines take up so much time, they're getting
interrupted and as a result the screen gets garbled at times. This will
only get worse when the interrupt frequency is doubled. I'm afraid
things don't look too promising atm - it's evident now that I
under-estimated the CPU grunt required to rotate the display.
18th October 2003
I've modified the generic ROM loader to dump the screen in the
correct orientation. Just need to update the SI graphics patches now!
17th October 2003
New downloads...
16th October 2003
Curiosity got the better of me... wrote a generic ROM loader which
patches only RST8 and hooks a routine to dump the SI hardware screen to
the TRS-80 hires board every alternate RST8 interrupt. When used with a
patched xtrs I can test new roms in about 5 minutes. No luck with Space
Invaders Pt II for some reaon, but Lunar Rescue was another story...
My small ASM program now becomes the SI ROM loader. It sets up the
Model 4 hardware, moves the SI ROM image into low memory, patches the
addresses that require patching, and jumps to $0000 to start executing
the game.
15th October 2003
Rescued the Model 4P from the garage this morning. What a sorry
site! Drive 0 died (prevents the 4P from even powering up!) after about
2 mins - but not before I saw that booting into 80x24 mode (TRSDOS 6)
sent the video crazy. Drive 1 didn't want to work either, so I removed
them both. Took a look at my options for booting from the serial port. Created an Intel hex file for Space Invaders and booted the 4P over the serial port...
The screen went nuts, which meant it was, at least, running my code.
Returned to xtrs and made a version that runs in 512x192 mode (SI
doesn't quite fit) but would hopefully let me see what was happening.
Re-generated the hex file and rebooted... I was greeted by the Space Invaders attract mode! Still have some problems with the hires board, but I can play a game, albeit at 50% speed.
When I get the chance I'll upload a binary image and tools/instructions
for creating an Intel hex record for serial booting Space Invaders on
the 4P.
14th October 2003
Today I ran SI on an unmodified
xtrs! It runs off the RTC interrupt @60Hz, so it runs at half-speed. A
1-line patch to xtrs enables it to run at full speed. In theory, SI
should now run on a real Model 4/4P - albeit at 50%. Hopefully I can
confirm this tomorrow, if my poor old 4P can still read my diskettes
and I can find a way to transfer the files to the machine (I don't have
a 5 1/4" drive on my PC).
That just leaves the screen rotation.
New download soon...
13th October 2003
Just a couple of quick notes. Last night I left SI running for a
few hours. When I returned I noticed a few stray pixels on the display.
I realise now that there is an added complication using the TRS-80
hires graphics - namely the use of registers for the graphics data. If
the patched code gets interrupted, there is a very small (but non-zero)
chance that the registers will be set for a graphics operation, but the
interrupt routine jumps to another patched graphics routine and changes
the register. I could mask interrupts around all the graphics routines,
but without an easy way (IIRC) to determine if interrupts are
enabled/disabled it would be a pain. At this stage I'm not sure it's
worth the effort and extra CPU cycles!?!
Out of curisoity I had a quick look at the other 8080 arcade games that
run on the same hardware. Most of them are (IMHO) complete rubbish,
although Space Invaders Part II and Lunar Rescue are notable
exceptions. I had a very quick glimpse at the SI2 code and was pleased
(and a little surprised) to see that it appears to use the same RAM
locations for the same variables as SI - so it may be possible to find
the relevant routines to patch without doing a disassembly at all. If
I've still got any enthusiasm left after I finish SI, I may attempt to
port SI2 as well! Lunar Rescue OTOH would probably amount to a much
greater effort.
Update: I've implemented the
shift register in software. That's everything done now except the
interrupts and the screen rotation. I'll clean up the code and prepare
it to use the EXINT which I'll emulate in xtrs - the ONLY patch required to xtrs now!
I did notice something weird, although I could be imagining it. The
game does seem 'harder' than it should be - the bombing frequency
appears to be quite a lot more than the original game. I'll have to
check the delay loops for the bombing AI - they may not use the
interrupt timing and may be running at twice normal speed.
Getting really ambitious now - I started to wonder if Pacman was
possible!?! 3MHz, 8 sprites, would have to be a monochrome version of
course, but I *think* it can be done!?!
12th October 2003
All of the graphics routines have been patched - a little more code
than I realised! I'm still yet to implement the graphics shift register
- that's my next task. But the game appears to run perfectly with xtrs
throttled (-noautodelay), and although there's still more processing to
do in the graphics routines I'm confident the 4MHz CPU will more than
make up for the extra cycles required.
See the downloads section for a preview version that runs on a modified xtrs.
11th October 2003
This is a screenshot of xtrs running SI with option -scale 1,1. Much closer to the aspect ratio of the real game.
To fix the graphics I emulated the graphics shift register in xtrs - just to see what it was going to look like!
I also realised that I was running xtrs unthrottled - but everything in
the game was running at the correct speed. I revisited the timing
routines and reminded myself that the ticker runs off the RST8
interrupt so the game runs at the correct speed, irrespective of the
CPU speed. This is good news as the Model 4 Z80 runs at twice the speed
of the SI 8080.
I've patched most of the input routines to read from the TRS-80 keyboard - I can coin-up and actually play a game!
I've also started to patch the graphics routines. I can now see all the
attract mode screens, minus the demo, in 'real-time'. These routines
don't use the shifter on the bitmaps. The shifter routines are next on
my list. That'll just leave the rotation issue - a re-write in part of
the graphics patches but all my code - no more patches to the SI ROM.
10th October 2003
I hooked RST8 directly to my SI loader and had it dump the SI video
RAM every half-second and let it run. To my disappointment, it wasn't
getting much further than before once interrupts were enabled. Even
without my hooks, the interrupt routines were starving the mainline
code of CPU - something I couldn't understand since the CPU was running
at twice the speed of the SI CPU. Decreasing the interrupt frequency
had no effect. Then I realised the problem...
I wasn't acknowledging the (modified) RTC interrupt. Because SI knew
nothing about it, I patched xtrs to acknowledge the interrupt
immediately before vectoring. I ran it again and was greeted by the
complete SI attract mode loop running, including the demo, updated
every half-second. The demo itself had corrupt graphics due to the
shifter not being implemented, but it was definitely recognisable.
There's no doubt now that this is going to work - the attract mode and
demo exercises about 90% of the SI ROM code.
9th October 2003
I added a routine to my SI loader to dump the SI video RAM to the
Model 4P hires board. The ROM was patched to jump to this routine at
the point interrupts were enabled. Now I could see the SI output
directly on the TRS-80 screen. Due to the
vastly different aspect ratio of the respective video screens, it
appears squashed and quite obviously rotated, which I expected. The
final version will be rotated and pixel-doubled across the TRS-80
screen which should produce a pleasing aspect ratio and leave room for
some text on the right-hand side of the display.
8th October 2003
The SI ROM image appears to execute at least up until the point that
interrupts are enabled. By this point in the code, the text for the
scores at the top of the screen, and the credits shown at the bottom of
the screen, have been written to video RAM without the use of the
graphics shift register hardware, which I haven't implemented. So in
theory, I should be able to see this text if I decode the video RAM.
I modified the xtrs debugger memory dump command to also dump the
memory contents to a binary file in order to capture the contents of
the SI video memory ($2400-$3FFF). I then transferred the file to
windows and wrote a small C program to convert the file to a 24-bit
.RAW image, which I then loaded into Paintshop Pro. I was pleased with
the results.
So the ROM was running properly up until interrupts were disabled.
September/October 2003
Annotated disassembly of the original arcade Space Invaders ROM image about 99% complete.
The xtrs emulator installed and configured for development.
LDOS 6.3, Miosys C and MRAS assembler installed onto virtual disk
images. All this software, together with pdf versions of the
documentation, was downloaded from Tim Mann's site.
Imported the Space Invaders ROM image onto a virtual LDOS disk image.
Wrote a small Miosys C program to read the binary file into high memory
so I could use the LDOS DUMP command to create a loadable /CMD file of
the ROM image.
After familiarising myself with the Model 4 hardware and the MRAS
assembler, wrote a small ASM program to setup the Model 4 memory map as
required, and hooked the RTC interrupt to display something on the
Model 4 screen mapped to $F800.
Modified xtrs to generate RST8/RST10 interrupts alternatively for the
RTC interrupt after an IM0 instruction is executed. Also increased the
RTC interrupt frequency to 120Hz. This allows me to boot LDOS and run
with normal interrupts (except the frequency) until my program executes
an IM0 instruction. Modified my ASM program to hook both interrupts and
display something on the screen. xtrs should now be ready to start
running the SI ROM.
My small ASM program now becomes the SI ROM loader. It sets up the
Model 4 hardware, moves the SI ROM image into low memory, patches the
addresses that require patching, and jumps to $0000 to start executing
the game.
email: msmcdoug@optushome.com.au