And I finally had some time to work on my emulator.
I fixed some issues with my interrupt code (and I actually forgot to generate the normal vblank interrupt and only did the vblank-STAT one... :blush: ) and added timers.
That was enough to get some games running. Then I found a really nasty bug that was actually caused by the reference I was using:
The size of ld (ff00+C),A and ld A,(ff00+C) was stated as 2 bytes, but it is only one byte large.
I found this one by debugging the seemingly different issue of missing sprites in pokemon.
Pokemon does something like this on startup:
This copies a small routine to HRAM which then updates the OAM each vblank via DMA.
By using the wrong instruction size, the inc c was skipped each time and everything except the ret at the end of the routine was overwritten.
So the emulator unwillingly removed the sprite code from pokemon. That was 'fun' to debug...
lain:
Now quite some games I tested run more or less perfect: Mario Land 1/2, Pokemon Red/Blue/Green/Yellow, Kirby's Dream Land 1/2, Harvest Moon, Tetris, Metroid II...
Pokemon Gold/Silver has some weird graphical issues but is otherwise playable. Zelda runs but sections of the map are corrupted and the sprite colors look off.
I looked into adding sound, but I will also consider using Blargg's library for the time being as it looks like quite a big task...
I fixed some issues with my interrupt code (and I actually forgot to generate the normal vblank interrupt and only did the vblank-STAT one... :blush: ) and added timers.
That was enough to get some games running. Then I found a really nasty bug that was actually caused by the reference I was using:
The size of ld (ff00+C),A and ld A,(ff00+C) was stated as 2 bytes, but it is only one byte large.
I found this one by debugging the seemingly different issue of missing sprites in pokemon.
Pokemon does something like this on startup:
Code:
ld hl,source
loop:
ldi a,(hl)
ld (ff00+c),a
inc c
dec b
jr nz loop
By using the wrong instruction size, the inc c was skipped each time and everything except the ret at the end of the routine was overwritten.
So the emulator unwillingly removed the sprite code from pokemon. That was 'fun' to debug...
Now quite some games I tested run more or less perfect: Mario Land 1/2, Pokemon Red/Blue/Green/Yellow, Kirby's Dream Land 1/2, Harvest Moon, Tetris, Metroid II...
Pokemon Gold/Silver has some weird graphical issues but is otherwise playable. Zelda runs but sections of the map are corrupted and the sprite colors look off.
I looked into adding sound, but I will also consider using Blargg's library for the time being as it looks like quite a big task...
Attachments
-
2013-10-30.21:57:17.png1.6 KB · Views: 124
-
2013-10-30.21:58:45.png1.2 KB · Views: 128
-
2013-10-30.22:02:01.png1.6 KB · Views: 119
-
2013-10-30.22:11:06.png2.1 KB · Views: 110
-
2013-10-30.21:59:52.png1.8 KB · Views: 129
-
2013-10-30.23:07:53.png1.7 KB · Views: 113
-
2013-10-30.22:05:07.png2.7 KB · Views: 114
-
2013-10-30.23:11:24.png1.7 KB · Views: 125