AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
155 stars 26 forks source link

CDTV interrupt 2 issue #166

Closed rveilleux closed 7 months ago

rveilleux commented 1 year ago

While working on my game prototype, I might have discovered that when testing on a CDTV (in winUAE), the ACE engine doesn't work: I've tested using germz ADF from the game's website to make sure it wasn't something specific (since I modified the engine on a few places). I discovered that int2Handler, which handles the INTF_PORTS interrupts, for CIA A (CIAICRF_SERIAL for keyboard, CIAICRB_TIMER_A for timers), that apparently the CDTV hardware also uses that interrupt for the CD. (When debugging it, it appears as if the int2Handler is triggered continuously, which freezes the ACE engine/game.).

I was able to 'fix' it on my customized ACE engine by disabling INTF_PORTS interrupts and using VERTB to "poll" keyboard. Probably not an ideal solution since perhaps I could miss some keypresses.

I just wanted to at least inform you about the situation. The real proper way to handle it is probably to have an IntServer and let OS handle the CD interrupt instead of masking them.

tehKaiN commented 1 year ago

Well, up to this point noone tested ACE on CDTV, so it's kinda expected that something went wrong.

I'd approach it differently - figure out how to disable/enable CD drive DMA (?) and turn it off when OS gets disabled.

Polling keyboard is kinda risky - keyboard controller queues keypresses to be sent to CIA via serial interface and it sends another keypress only if previous one is successfully read, as signalized by specific handshake. If you won't read them in time, the queue will overflow, in which case the keyboard controller will reset the Amiga. IIRC the queue is 8-keypess long, should be very difficult to trigger overflow at the span of a single frame, but I think not impossible on keyboard-heavy multiplayer game.

Re leaving OS functional - yes, this should be an option, but only as a choice, because OS tends to eat away random amount of frame time while it's alive.

I'll try to dig up some docs on how CDTV works and how to handle its hardware properly.

tehKaiN commented 1 year ago

I've found this thingy https://eab.abime.net/showthread.php?t=89836 - looks like a candidate for easy fix, just add to systemUse/Unuse

I'll also ask alpine9000 if there's some more work to do to handle cdtv properly

rveilleux commented 1 year ago

Oh wow this is amazing and exactly what we need: I'll try to implement and submit it as a pull request if you agree.

I wonder how many games don't work on the cdtv just because of that..

Rem.

On Nov 1, 2022, at 5:29 AM, KaiN @.***> wrote:

 I've found this thingy https://eab.abime.net/showthread.php?t=89836 - looks like a candidate for easy fix, just add to systemUse/Unuse

I'll also ask alpine9000 if there's some more work to do to handle cdtv properly

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

tehKaiN commented 1 year ago

Great! Lemme know if that works!, Also, I think it's best to wrap it into separate function, kinda like its' done with systemFlushIo(), perhaps with the arg CMD_START/CMD_STOP.