Page 1 of 1

CDDA oddities

Posted: Tue Aug 27, 2013 3:04 am
by Bitybity
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

Posted: Tue Aug 27, 2013 6:28 pm
by Chilly Willy
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.

Posted: Tue Aug 27, 2013 11:22 pm
by HCKTROX
(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.

Posted: Wed Aug 28, 2013 2:23 am
by Chilly Willy
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)