Consolemu
|
Delays in Assembly
Posted: Wed Aug 23, 2000 2:09 am
|
Since assembly code is so blindly fast, is there anyway I could delay or slow the system down? I tried to type the delay by counting each VSync but I dunno whether I'm reading the VDP port wrong or the system is just incredibly fast. I'm setting register C to $20, reading bit7 from port $BF and decrementing register C every VSync. I will make it jump back and wait for VSync until register C equals 0 or Zero Flag is set.
Chris :o)
|
- Site Admin
- Joined: 25 Oct 1999
- Posts: 2029
- Location: Monterey, California
|
Posted: Wed Aug 23, 2000 4:03 am
|
Quote > Since assembly code is so blindly fast, is there anyway I could delay or slow the system down? I tried to type the delay by counting each VSync but I dunno whether I'm reading the VDP port wrong or the system is just incredibly fast. I'm setting register C to $20, reading bit7 from port $BF and decrementing register C every VSync. I will make it jump back and wait for VSync until register C equals 0 or Zero Flag is set.
That should give you about a half second delay. The speed of the emulated CPU shouldn't matter at this point, since Vsync time is constant.
This sounds like a bug elsewhere. This would be a good time to fire up brsms in the debugger mode and trace your execution. Check to see that your loop which polls $bf for a sign of vsync is really waiting around a long time before it finally lets you through. If it lets you through the first time then you know there's a bit in the part that checks for bit 7. Double check with your z80 manuals and if still stumped after experimenting with it a little, post the routine here.
|
Nyef
|
Posted: Wed Aug 23, 2000 1:32 pm
|
Quote > Since assembly code is so blindly fast, is there anyway I could delay or slow the system down? I tried to type the delay by counting each VSync but I dunno whether I'm reading the VDP port wrong or the system is just incredibly fast. I'm setting register C to $20, reading bit7 from port $BF and decrementing register C every VSync. I will make it jump back and wait for VSync until register C equals 0 or Zero Flag is set.
Why are you spinwaiting on a port? Why not hook the interrupt, and have the handler decrement your counter?
Seriously, almost every game in existance hooks the interrupt...
Quote > Chris :o)
--Nyef
|