CDDA oddities

Ask anything your want about Mega/SegaCD programming.

Moderator: Mask of Destiny

Post Reply
Bitybity
Interested
Posts: 36
Joined: Wed Dec 07, 2011 2:09 am

CDDA oddities

Post by Bitybity » Tue Aug 27, 2013 3:04 am

Hello everyone.

Directly to the point: Since months ago, I noticed that CDDA doesn't play with USA 1.10 BIOS, only after going to the BIOS setup settings; if the BIOS sequence is inmediately skipped, it works entirely normal.

With JAP BIOS, the CDDA simply doesn't play (though the LED keeps turned on)

I have absolutely no clue about what is really happening, since I do exactly what the manual/macros states.

Any ideas? Thanks

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Aug 27, 2013 6:28 pm

Let's go over the basics to make sure you didn't miss something...

First you init the drive:

Code: Select all

        lea     drive_init_parms(pc),a0
        move.w  #0x0010,d0              /* DRVINIT */
        jsr     0x5F22.w                /* call CDBIOS function */

        move.w  #0x0089,d0              /* CDCSTOP - stop reading data */
        jsr     0x5F22.w                /* call CDBIOS function */

...

        .align  2
drive_init_parms:
        .byte   0x01, 0xFF              /* first track (1), last track (all) */
Then you fetch the disc info:

Code: Select all

        move.w  #0x0081,d0              /* CDBSTAT */
        jsr     0x5F22.w                /* call CDBIOS function */
        move.w  0(a0),0x8020.w          /* BIOS status word */
        move.w  16(a0),0x8022.w         /* First song number, Last song number */
        move.w  18(a0),0x8024.w         /* Drive version, Flag */
Assuming you find a disc, then fetch the track info for the track you wish to play/read:

Code: Select all

        move.w  0x8010.w,d1             /* track number */
        move.w  #0x0083,d0              /* CDBTOCREAD */
        jsr     0x5F22.w                /* call CDBIOS function */
        move.l  d0,0x8020.w             /* MMSSFFTN */
        move.b  d1,0x8024.w             /* track type */
Assuming it's an audio track, we then play it:

Code: Select all

        move.w  #0x0002,d0              /* MSCSTOP - stop playing */
        jsr     0x5F22.w                /* call CDBIOS function */

        move.w  0x8010.w,d1             /* track number */
        move.w  #0x0011,d0              /* MSCPLAY - play from track on */
        move.b  0x8012.w,d2             /* flag */
        bmi.b   2f
        beq.b   1f
        move.w  #0x0013,d0              /* MSCPLAYR - play with repeat */
        bra.b   2f
1:
        move.w  #0x0012,d0              /* MSCPLAY1 - play once */
2:
        lea     track_number(pc),a0
        move.w  d1,(a0)
        jsr     0x5F22.w                /* call CDBIOS function */

...

track_number:
        .word   0
If you wonder why I'm using the communication registers for everything, the code is from my Wolf32X mode 1 source. The MD side is controlling the CD side through the comm regs, getting info back through the comm registers. If you are using this all on the CD side, just use global vars in ram instead of the comm regs.

HCKTROX
Interested
Posts: 27
Joined: Wed Mar 24, 2010 1:15 am
Location: Chile

Post by HCKTROX » Tue Aug 27, 2013 11:22 pm

(I'm BityBity, just using this old account because I can't access to my other)

Thanks a lot with this! Works fine everywhere it's tested. I have been fighting against this bug since months ago. You made my day

Thanks a lot.
skype: hcktrox

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Aug 28, 2013 2:23 am

You're welcome. I had to work that out myself when doing the CDDA support for Wolf32X, and I'm always happy to share coding tips. If you need tips on reading data sectors and handling ISO9660, I've got that, too.
8)

Post Reply