SMS Power! Logo Forums
Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Development - Music

 View topic - Vdp Interrupts?
Log in
Search
Memberlist
Membermap
Profile
Register
 Log in to check your private messages
Reply to topic    Forum Index - Development
Author Message
brom

Joined: 11 Jan 2006
Posts: 29
Location: Midlands, UK
Vdp Interrupts?
Post Posted:  Sun Jan 22, 2006 8:22 pm Reply with quote

Hey, I have a question about - Interrupts I think.

I've been debugging a few roms that seem to run in an endless loop (in my emulator).

Firstly, on Bock's "Happy Looser" demo - It gets stuck in a loop at 0x61C - 0x623,
I think it's waiting for an interrupt (Line interrupt = 192?) when it occurs it
writes 1 to 0xC002 else it writes 0 to 0xC002.

0x61C LD A,$C002
0x61F AND $FF
0x621 JR, Z, -7

Secondly in "Transbot", it's stuck in an endless loop at 0x27E2 - 0x27ED;
Again I'm sure it's waiting for the same kind of line interrupt:

0x27E9 LD HL,$C001
0x27EC LD A, HL
0x27ED OR A
0x27EE JR Z, -14

What I'm asking is, how is this emulated, when the VCount reaches a certain value
is a value pushed at $C000? Or am I just totally wrong..?

Thanks.
Brom.
Back to top

View user's profile Send private message
Maxim
Site Admin

Joined: 19 Oct 1999
Posts: 7546
Location: London, UK
Post Posted:  Sun Jan 22, 2006 9:13 pm Reply with quote

You're totally wrong :) Some of your posted code is invalid, and I'm expecting Bock to reply to explain what's going on in Happy Looser, so I'll leave it at that...

Last edited by Maxim on Sun Jan 22, 2006 9:31 pm; edited 1 time in total
Back to top

View user's profile Send private message Visit poster's website
Heliophobe
Site Admin

Joined: 25 Oct 1999
Posts: 2029
Location: Monterey, California
Post Posted:  Sun Jan 22, 2006 9:18 pm Reply with quote

What's happening is that in both games, the interrupt is either not being triggered (more likely), or something is not being emulated correctly inside of the interrupt handler. Without actually viewing the rest of the disassembly of either game I can say with near certainty that both roms have interrupt handlers that do their business and then set a flag in RAM (in these cases, $c001 or $c002) to let the main program know that the interrupt handler has occured so the main program can start calculating the action for the next frame.

In other words, it's not the VDP that sets a flag in RAM, but the program in the ROM.

So, chances are that it's a bug in your interrupt emulation. Do you have other commercial roms running in your emulator? If so, I presume your interrupt code is mostly functional and Transbot and Happy Looser both do something to cause the interrupt not to be triggered. Since they both use line interrupts, it might be that they set their "frame completed" flag in the line interrupt instead of the vertical blank interrupt.
Back to top

View user's profile Send private message Visit poster's website
Heliophobe
Site Admin

Joined: 25 Oct 1999
Posts: 2029
Location: Monterey, California
Post Posted:  Sun Jan 22, 2006 9:27 pm Reply with quote

Oh hey, you can get Happy Looser's source code (with comments) in the Productions and Bios section.

Okay, looks like Happy Looser does not set the 'frame done' flag in line interrupts (which would be odd). What might be happening is in here:

Quote:

.org $0038
interrupt:
di
exx
ex af, af'

in a, (VDP_STATUS) ; Read VDP status (mandatory)
and $80
jp z, interrupt_hblank
;jp interrupt_vblank


Check that the VDP_STATUS port (that's port $BF and its mirrors) returns a '0' in bit 7 when it's a line interrupt and a '1' when it's a vertical blank interrupt. Otherwise the interrrupt handler will always jump to the line interrupt handler and the flag will never be set.
Back to top

View user's profile Send private message Visit poster's website
Reply to topic    Forum Index - Development All times are GMT
Page 1 of 1

 

Script phpBB © 2001, 2005 phpBB Group



Back to the top of this page
Back to SMS Power!