|
I'm trying to make an emulator, and I'm stuck! I can display the title screens of some games (like Nuts & Milk, Digdug and Popeye) but it stops there, and I get flooded with invalid opcodes. Even the Super Mario title screen loads up with wrong scroll values, and hangs after (i.e. the coin isn't changing colors).
I traced this event and it supposedly happens when a BRK instruction is encountered. Here's my BRK function, is there anything wrong with it?
Related defines : #define setBflag() (P|=0x10) #define setIflag() (P|=0x04)
The break function : void brk00(void){ PC++; ram[0x100+S--] = (unsigned char)(PC>>8); ram[0x100+S--] = (unsigned char)(PC&0xff); setBflag(); ram[0x100+S--] = P; setIflag(); PC = ram[0xfffe]+(ram[0xffff]<<8); cyclenum+=7; }
This (almost) always jumps to $FFF0 and executes repeated amounts of trash to lead into another BRK (thus overflowing my stack eventually).
If you have the time, please get a copy of the (broken) emulator at http://savet3hsmileys.tripod.com/testnes.zip . I have added a trace and trace-until-vblank feature to help find this bug(?), and if you don't mind, please try it do tell me what problem you find. An additional note is that I use 29667 clock cycles per frame. Is that ok?a
Also, I did not implement mirroring in the 6502 ram (it's implemented in the PPU VRAM). Will that cause some problems? And about writing & reading to NES registers ($2000 and the like), should I detect a write and a read at every access (i.e. asl or lsr on a register as a write and eor'ing it as a read) or should I only monitor sta,stx,sty and lda,ldx,ldy commands?
Another thing, about NES sound. I'm just learning how to make sounds in DOS. What should I try to study for emulating NES sound? I found some tutorials on Diret Playback, single cycle DMA, and auto-init DMA, and they look REALLY complicated, so I'd like to ask you experts here on which one I should study for NES sound emulation.
Finally, I've seen some emulators run games on the same speed an slooow computers, just that the graphics get jumpy. From what I've gathered, this is done through frame skipping. Can anyone link me to a some information on it?
I REALLY like to program, and even if there a kajillion NES emulators out there, I'd really like to complete mine, so please help. I could use all the help I can get. Sorry if I asked too many questions.
*thinks* And NES movies, got any info on file format for it? (NESticle or Famtasia)
Der Wille zur Macht Chikara e no Ishi "The Will To Power"
|