Tuesday, January 28, 2014

Star Rider PIF board completely emulated and disassembled

I've been continuing to reverse engineer the Star Rider PIF board and I think I'm basically done.  There is only one command that I don't understand and it appears to be entirely software-related so both Daphne and Dexter can support it without me understanding what it does or how it works.

Here's my wiki page with all of my notes: https://www.daphne-emu.com:9443/mediawiki/index.php/StarRiderNotes

An interesting I learned today: The STAND BY line actually flashes, which I never supposed.  Here is the function that waits for STAND BY to stop flashing:

ROM:FA75 WaitForStandByToStopBlinking:           ; CODE XREF: PR8210A_PLAY+39 P
ROM:FA75                                         ; PR8210A_REJECT+1D P ...
ROM:FA75                 pshs    cc,a,b
ROM:FA77                 orcc    #$10            ; disable IRQ'
ROM:FA79                 jsr     Sleep150Ms      ; sleeps for 150,208 cycles (from before the function is called til after it has returned)
ROM:FA7C                 lda     #$20 ; ' '
ROM:FA7E                 bita    PIA_B_DATA      ; test STAND BY
ROM:FA81                 beq     WhileStandbyIsHigh ; branch if STAND BY is inactive
ROM:FA83                 jsr     Sleep150Ms      ; sleeps for 150,208 cycles (from before the function is called til after it has returned)
ROM:FA86                 bita    PIA_B_DATA
ROM:FA89                 beq     WhileStandbyIsHigh ; This code checks to make sure that standby does not come active again after it sees that it was inactive.
ROM:FA89                                         ; If standby does come active again, this code will block indefinitely until it becomes inactive again.
ROM:FA89                                         ; (it is designed to check to make sure blinking activity has ceased)
ROM:FA8B                 jsr     Sleep150Ms      ; sleeps for 150,208 cycles (from before the function is called til after it has returned)
ROM:FA8E                 bita    PIA_B_DATA
ROM:FA91                 beq     WhileStandbyIsHigh ; This code checks to make sure that standby does not come active again after it sees that it was inactive.
ROM:FA91                                         ; If standby does come active again, this code will block indefinitely until it becomes inactive again.
ROM:FA91                                         ; (it is designed to check to make sure blinking activity has ceased)
ROM:FA93                 lda     #$86 ; 'å'      ; #$86 means that stand by has not gone inactive after a reasonable amount of delay
ROM:FA95                 jmp     OnFatalError    ; Everything here might be diagnostic type stuff or error code reporting type stuff
ROM:FA95                                         ; code 0x80 means CRC check failed
ROM:FA95                                         ; code 0x81 means RAM test failed
ROM:FA95                                         ; code 0x82 means IRQ test failed
ROM:FA95                                         ; code 0x85 means syncing to vsync/field failed
ROM:FA95                                         ; code 0x86 means STAND BY never went low before going high/low again
ROM:FA95                                         ; code 0x87 means we got an invalid FIRQ command
ROM:FA95                                         ; code 0x88 means we ran out of space in our array at 0x300 (see F2C5)
ROM:FA98 ; ---------------------------------------------------------------------------
ROM:FA98 
ROM:FA98 WhileStandbyIsHigh:                     ; CODE XREF: WaitForStandByToStopBlinking+C j
ROM:FA98                                         ; WaitForStandByToStopBlinking+14 j ...
ROM:FA98                 ldb     #$FF            ; This code checks to make sure that standby does not come active again after it sees that it was inactive.
ROM:FA98                                         ; If standby does come active again, this code will block indefinitely until it becomes inactive again.
ROM:FA98                                         ; (it is designed to check to make sure blinking activity has ceased)
ROM:FA9A 
ROM:FA9A WhileBIsLessThan10:                     ; CODE XREF: WaitForStandByToStopBlinking+30 j
ROM:FA9A                 incb
ROM:FA9B                 jsr     Sleep50Ms       ; this delays for 49,993 cycles (from $FA16 until the last RTS has finished)
ROM:FA9B                                         ; So about 50 milliseconds
ROM:FA9E                 bita    PIA_B_DATA      ; test STAND BY
ROM:FAA1                 bne     WhileStandbyIsHigh ; branch if STAND BY line is high
ROM:FAA3                 cmpb    #$A
ROM:FAA5                 blt     WhileBIsLessThan10
ROM:FAA7                 puls    b,a,cc
ROM:FAA9                 rts
ROM:FAA9 ; End of function WaitForStandByToStopBlinking

It may look super confusing but it's as clear as it's going to get :)

I still need to know when the FIELD and 4MS inputs come into the PIF board relative to the LM1881's vsync before I can know for sure how to make Dexter support this player.

No comments:

Post a Comment