JavaGear

Java Sega Master System & Game Gear Emulator






Saturday, November 24, 2001
 
I decided that the best way to detect problems with, and debug the Z80 engine would be to write a simple ZX Spectrum emulator (a popular home computer that uses the Z80, and is far less complex than the SMS).


It took me about 30 minutes to port an old Spectrum emulator I'd written to Java. I debugged some games that ran incorrectly, and found a problem with my INC (IX/IY) and DEC (IX/IY) instructions. They weren't using the offset byte. I corrected these, and lots of software that previously had problems began to run correctly.


Here we can see Sonic The Hedgehog 2 and Dynamic Dux. A lot of other titles now work including Double Dragon, Final Bubble Bobble, Gauntlet, Shinobi, Sonic Chaos, Sonic Spinball, Super OffRoad, Super Tetris and Teddy Boy.

I also made some good progress with the VDP emulation and implemented Vertical Tile Scrolling. It isn't perfect yet, but titles using vertical scrolling are at least playable now.


Tuesday, November 20, 2001
 
During the last week, I took a vacation to Switzerland, and implemented the following:
  • 8x16 Sprites
    Fixed the problem with sprites not displaying correctly.
  • Horizontal Tile Scrolling
    Now the clouds in Hang On behave correctly.
  • Z80 Enhancements
    Minor changes to the CPU core.
There *must* still be a few big bugs in the CPU core as a lot of ROMs still aren't working correctly. I will look into this, but progress is slow and hard!


Despite this, Lemmings is now working 100% correctly I believe!

Sunday, November 11, 2001
 
More good progress has been made over the past 5 days:
  • Interrupt Routines

  • These are now far more accurate. No Interrupts can take place after an EI instruction. The changes don't seem to have made a big difference with compatibility however.
  • Controller Support

  • Controller 1 is now fully implemented.
  • Z80 Bugfixes

  • Fixed a nasty bug in the OTIR instruction that was causing problems with homebrew Tetris. This took ages to track down!
  • Debugger Improvements

  • Solved a refreshing problem with the debugger window (the emulation window was hogging all the repainting time it seems). Also added greater functionality, but there's still more work to be done!
The immediate problems that are remaining relate to certain sprites not displaying 100% correctly. I think this is because I haven't emulated 8x16 and 16x16 sprites yet. Additionally, quite a few ROMs seem to go nuts and write over areas of memory where they shouldn't causing nasty crashes. I've started working on this problem, but I haven't got very far yet.

Monday, November 05, 2001
 
What a day! I have finally solved all my problems in one fell swoop. The sprite issue, and a host of others that I'd mentioned, was a result of a mammoth bug in the CPU core! I'd emulated the IX and IY registers incorrectly. I had permanently added the offset value (eg IX+d) to the register. The register itself is never actually altered in this way, and remains at the same value before and after the instruction. I noticed this after consulting a Z80 manual.

What are the results? Well - loads of stuff now works with sprites, even Sonic The Hedgehog runs! I haven't had time to check many titles yet, but I'll post some screenshots tomorrow.


Saturday, November 03, 2001
 
As promised, here is a screenshot of the debugger I've been working on. It's not much to look at, but should give you an idea of what I've been upto:


Also, I've implemented the page register hardware. This means that ROMs upto 512K can now be loaded! Here are two screenshots of titles that use paging:


I still have a lot of problems left to solve. At the top of my priority list is fixing sprites... as they don't seem to work properly in anything but the most simple demos. I've been puzzling over them towards the end of today, but have not made any progress. Despite this, I have rewritten my sprite rendering code, and it's a lot more tidy. Additionally, no commercial ROMs are fully working yet. I'm not too worried as I'm well ahead of schedule, but I need to do some serious bugfixing over the upcoming weeks.


Thursday, November 01, 2001
 
During the last couple of days I've been working on a debugger. I had scheduled this work to occur much later, but I decided it would be highly beneficial to complete it immediately. I'll post some screenshots soon, as I still have some work to do on it - but it seems to work fine. Current features include "execute x number of instructions", register view, flag view and opcode mnemonics.