Sega CD General

Nothing Left But Faith

There's nothing left but faith
Member
Messages
77
A Bug with SCDPQ/SCDPQL (US Model 1/2 BIOS, Possibly More)

So, these 2 BIOS functions are supposed to retrieve the P and Q subcode data for the current sector being processed. But, there is a bug that causes slight corruption, at least in the US model 1/2 BIOS revisions. I have no idea if this was fixed in any other revisions, but this bug exists here.

According to the manual, this is the expected result:

QDWvZN3.png


Note the "P" flag entry. That's the P subcode flag. Everything else is from the Q subcode data.

As it is stated, there are 3 Q subcode data modes that dictate what the data contains and how it's arranged. Mode 1 basically describes the current track/sector, mode 2 describes the catalogue number, and mode 3 describes the ISRC code. The "P" flag's location depends on this mode, due to the varying data lengths, and the BIOS tries to take that into account, but fails. Let's see what it does...

Code:
                move.b  0(a1),d1                        ; Get Q subcode data mode
                andi.b  #$F,d1
                cmpi.b  #1,d1                           ; Is it mode 1?
                beq.s   .Mode1                          ; If so, branch
                cmpi.b  #2,d1                           ; Is it mode 2?
                beq.s   .Mode1                          ; If so, branch (BUG: WRONG LABEL!)
                cmpi.b  #3,d1                           ; Is it mode 3?
                beq.s   .Mode1                          ; If so, branch (BUG: WRONG LABEL!)
                bra.s   .StoredPFlag                    ; If it's none of the above, skip
               
; ---------------------------------------------------------------------------

.Mode1:
                move.b  d0,6(a1)                        ; Store P subcode flag for mode 1
                bra.s   .StoredPFlag

; ---------------------------------------------------------------------------

.Mode2:
                ; UNREFERENCED!
                move.b  d0,8(a1)                        ; Store P subcode flag for mode 2
                bra.s   .StoredPFlag

; ---------------------------------------------------------------------------

.Mode3:
                ; UNREFERENCED!
                move.b  8(a1),d1                        ; Store P subcode flag for mode 3
                andi.b  #$F0,d1
                andi.b  #$F,d0
                or.b    d1,d0
                move.b  d0,8(a1)

; ---------------------------------------------------------------------------

.StoredPFlag:

Oh dear.

Yeah, looks like they just copied and pasted the checks for modes 2 and 3... but forgot to change the label to go to the correct code. As a result, if you wanted to get the catalogue number or ISRC code for whatever reason, I hope you enjoy it being slightly corrupted!
 

Nothing Left But Faith

There's nothing left but faith
Member
Messages
77
There is a weird claim by one the Sega CD's tech bulletins that states that the Z80 cannot access PSG:

4VgkzQS.png


However, there, so far from what I've seen, has been no evidence to support this (in fact, there's evidence for the opposite), and really, it makes no sense. The Sega CD doesn't really mess around much with the Genesis side of things. It doesn't even touch the Z80 or VDP/PSG, as far as I know, and just exist in the expansion and I/O spaces. The only thing I can think of at all is how the PSG is part of the VDP, and thus the Z80 accesses it through the 68000 bus, so maybe there's some kind of edge case? Paranoia? I don't know...
 

Rivet

Member
Messages
25
I've been told that there's many things (like jump tables pointing to some general routines, I've heard that Nemesis compression would be one) in the Sega CD's BIOS that is carried across revisions that could be used when creating your own programs. Is there any good reference for what can be used?
 
Top