English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. Blitz Basic (http://eab.abime.net/forumdisplay.php?f=126)
-   -   Playing CD audio tracks on CD32 (http://eab.abime.net/showthread.php?t=86481)

witchmaster 21 March 2017 20:00

Playing CD audio tracks on CD32
 
Hi! Does anybody have any experience in playing CD audio on the CD32 or CD-Rom device using BB2? There is a RI library called RICompactDisk and there is an example player but I can't get it to work in WinUAE...

spudje 22 March 2017 00:14

CD32 comes with a build in CD player if you insert an audio CD. I would assume WinUAE with correct config also emulates this functionality.

Daedalus 22 March 2017 01:30

I think he's looking to control the CD from his own Blitz Basic program. I'm afraid I don't really know how to do it - I tried a number of different ways of doing it on my A1200 here but never made it work with the Blitz libraries. It should be perfectly possible to do it "manually" though, by building your own SCSI requests and sending them to cd.device. But that was too much effort for me so I never got that far.

witchmaster 22 March 2017 13:08

Quote:

Originally Posted by spudje (Post 1148258)
CD32 comes with a build in CD player if you insert an audio CD. I would assume WinUAE with correct config also emulates this functionality.

Thanks spudje but I want to figure out how to control the CD audio playback from within a game like Daedalus assumed below.

Quote:

Originally Posted by Daedalus (Post 1148264)
I think he's looking to control the CD from his own Blitz Basic program. I'm afraid I don't really know how to do it - I tried a number of different ways of doing it on my A1200 here but never made it work with the Blitz libraries. It should be perfectly possible to do it "manually" though, by building your own SCSI requests and sending them to cd.device. But that was too much effort for me so I never got that far.

Ok thanks, that's unfortunate. I guess I will have to look into sending requests to cd.device then...

Amigajay 22 March 2017 13:10

You could try asking JOTD or Earok, they were looking into controlling CD audio with the CD32 pad within a game, not directly BB related, but Earok has dabbled in that too.

witchmaster 22 March 2017 15:46

Quote:

Originally Posted by Amigajay (Post 1148327)
You could try asking JOTD or Earok, they were looking into controlling CD audio with the CD32 pad within a game, not directly BB related, but Earok has dabbled in that too.

Thanks, I will ask! :)

By the way, is the cd.device included in the extended ROM on the CD32? I can't find it on any of my CD32 CDs.

Daedalus 22 March 2017 15:50

Yep, cd.device is in the CD32 extended ROM (and I think the CDTV extended ROM too).

spudje 22 March 2017 21:17

Oh sorry, I read bb2 as aos39 with boing bag 1 & 2. :)

witchmaster 22 March 2017 23:37

Quote:

Originally Posted by spudje (Post 1148395)
Oh sorry, I read bb2 as aos39 with boing bag 1 & 2. :)

No worries, I appreciate you taking the time to reply. :)

But good news (for me at least), I managed to get CD audio playing using the CompactDisk library functions in WinUAE emulating the CD32, haven't tested on my hardware CD32 yet though. The functions need to be called in Amiga/QAmiga mode. Switching to Blitz mode instantly after starting playback caused the playback not to start, having a delay before switching back to Blitz mode seems to work. This still needs more testing but anyway here is the code for future references.

Code:

; CD32 CD Audio test

; CDStatus bit definitions
#CDSTSB_CLOSED      = 0  ; Drive door is closed
#CDSTSB_DISK        = 1  ; A disk has been detected
#CDSTSB_SPIN        = 2  ; Disk is spinning (motor is on)
#CDSTSB_TOC        = 3  ; Table of contents read.  Disk is valid.
#CDSTSB_CDROM      = 4  ; Track 1 contains CD-ROM data
#CDSTSB_PLAYING    = 5  ; Audio is playing
#CDSTSB_PAUSED      = 6  ; Pause mode (pauses on play command)
#CDSTSB_SEARCH      = 7  ; Search mode (Fast Forward/Fast Reverse)
#CDSTSB_DIRECTION  = 8  ; Search direction (0 = Forward, 1 = Reverse)

; Print at location with colour
Statement PrintAt{x.w, y.w, col.b, text$}
  Locate x,y : Colour col : Print text$
End Statement

; Initialize
BLITZ                                  ; Go into blitz mode
Slice 0,44,320,200,$fff8,4,8,16,320,320 ; Create a slice
BitMap 0, 320, 200, 4                  ; Create a bitmap
Show 0                                  ; Show the bitmap in the slice
BitMapOutput 0                          ; Output print commands to bitmap 0
PalRGB 0,1,15,15,15                    ; Set colour index 1 to white
PalRGB 0,2,15,0,0                      ; Set colour index 2 to red
PalRGB 0,3,0,15,0                      ; Set colour index 3 to green
Use Palette 0                          ; Use palette must be called after changing the colors with PalRGB
Colour 1                                ; Set color index used for printing

; Global variables
device$ = "cd.device"
unit = 0
cd_available = False

; Print header
PrintAt{0,0,1,"CD32 CD Audio Playback Test"}

; Open the cd.device and print the result
If OpenCD(device$, unit) = 0
  PrintAt{0,1,2,"Could not open cd.device!"}
Else
  PrintAt{0,1,3,"cd.device opened successfully!"}
  cd_available = True
EndIf

; Go into QAmiga mode and read CD status and TOC
QAMIGA
cds=CDStatus
If (cds BitTst #CDSTSB_TOC)
 
  Delay_ 50 ; Wait a sec
  CDReadTOC ; Read the TOC
  PrintAt{0,2,3,"TOC was successfully read!"}
 
  ; Calculate total playing time (all tracks) and print to screen
  totalsecs=0
  For h=1 To CDNumTracks
    totalsecs+CDTrackLength(h)
  Next h
  Locate 0,3 : Colour 1 : Print "Tracks: ", CDNumTracks, ", Total length of tracks: ", totalsecs, " seconds"
 
  ; Play track nr. 2 and play all remaining tracks (Track nr. 1 is data)
  CDPlayTrack 2,(CDNumTracks-2)
 
  PrintAt{0,4,1,"Playing Track 1..."}
 
Else ; fail
  PrintAt{0,2,2,"Reading of TOC failed!"}
EndIf

; We need to wait a sec before going into Blitz mode, otherwise playing does not start
Delay_ 50

; Go back to Blitz mode after starting Audio CD playback
BLITZ
PrintAt{0,5,1,"Switched to Blitz mode!"}

Repeat
  ; Just wait for a mouse click
Until Joyb(0)>0

QAMIGA
; Close cd.device before exiting
If cd_available = True
  CDStop
  Delay_ 50
  CloseCD
End If


Daedalus 23 March 2017 10:52

Excellent work, I must try it myself and see if I can get it working on my setup. Thanks for sharing!

witchmaster 24 March 2017 00:02

Quote:

Originally Posted by Daedalus (Post 1148482)
Excellent work, I must try it myself and see if I can get it working on my setup. Thanks for sharing!

But of course, hope you get it working!

earok shared his wisdom about the CD32 library by Acid. I got an example from him that I modified a little. Both this and the previous example are working on a real CD32, I have confirmed this and now I have a few coasters as a bonus. The playback needs to be started in Amiga / QAmiga modes but then when switching to Blitz, the audio is still playing. Anyway here is an example using the Acid library:

Code:

; CD32 CD Audio test
; Based on source code by earok on EAB
; The Acid CD32 library is needed for this example to work:
; http://www.david-mcminn.co.uk/blitz-2000/archives/libraries/acid.html
; CD32 functions can't be used in BLITZ mode, you can switch to Blitz mode after calling PlayCD32

DEFTYPE .w

; When using the CD32 functions, a delay is needed before switching back to CD32 mode
; From my experiments on a real CD32, a delay of 10 was too short 50 seems to work
#BLITZ_DELAY = 50
#CD32_PLAY    = 1
#CD32_LTRIGGER = 2
#CD32_RTRIGGER = 4
#CD32_GREEN    = 8
#CD32_YELLOW  = 16
#CD32_RED      = 32
#CD32_BLUE    = 64

; Initialize
BLITZ                                  ; Go into blitz mode
Slice 0,44,320,200,$fff8,4,8,16,320,320 ; Create a slice
BitMap 0, 320, 200, 4                  ; Create a bitmap
Show 0                                  ; Show the bitmap in the slice
BitMapOutput 0                          ; Output print commands to bitmap 0
PalRGB 0,1,15,15,15                    ; Set colour index 1 to white
Use Palette 0                          ; Use palette must be called after changing the colors with PalRGB
Colour 1                                ; Set color index used for printing

QAMIGA

If InitCD32 ; InitCD32 must be called before using any CD32 functions
  Locate 0,0 : Print "CD32 initialized!"
Else
  Locate 0,0 : Print "Could not init CD32!"
EndIf

Delay_ #BLITZ_DELAY
BLITZ

ypos = 1
looping=true
track=2 ; Track nr. 1 is the data track

While looping

  Option = GameB(1)

  If JoyDown
    If Option=0
      JoyDown=False
    EndIf
  Else
    If Option > 0

      If Option & #CD32_GREEN ;Green plays track
        QAMIGA
        PlayCD32 track
        Delay_ #BLITZ_DELAY
        BLITZ
        ypos+1
        Locate 0,ypos : Print "Playing track nr. ",track
        track+1 ; Simply switch between tracks 2 and 3
        If track>3
          track=2
        EndIf
      EndIf

      If Option & #CD32_YELLOW ;Yellow stops the music
        QAMIGA
        StopCD32
        Delay_ #BLITZ_DELAY
        BLITZ
      EndIf
     
      If Option & #CD32_RED ; Red exits the loop and ends the program
        looping = False
      EndIf

      JoyDown=True
      Option=0

    EndIf
  EndIf

  VWait

Wend

QAMIGA
StopCD32
Delay_ 50
End


xArtx 29 April 2017 06:28

HI :) What exactly does InitCD32 in BASIC do?

I have tried deleting cd.device from ROM, and loading it with LoadModule instead.
Then using the Version command, the cd.device that was loaded form HDD is found,
but the cd drive itself never works after that.


All times are GMT +2. The time now is 16:00.

Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.

Page generated in 0.05527 seconds with 10 queries