English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 21 March 2017, 20:00   #1
witchmaster
Registered User

witchmaster's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 151
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...
witchmaster is offline  
AdSense AdSense  
Old 22 March 2017, 00:14   #2
spudje
Registered User

 
Join Date: Dec 2014
Location: Netherlands
Posts: 633
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.
spudje is offline  
Old 22 March 2017, 01:30   #3
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,336
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.
Daedalus is offline  
Old 22 March 2017, 13:08   #4
witchmaster
Registered User

witchmaster's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 151
Quote:
Originally Posted by spudje View Post
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 View Post
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...

Last edited by witchmaster; 22 March 2017 at 15:48.
witchmaster is offline  
Old 22 March 2017, 13:10   #5
Amigajay
醉拳
Amigajay's Avatar
 
Join Date: Jan 2010
Location: UK
Posts: 1,531
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.
Amigajay is online now  
Old 22 March 2017, 15:46   #6
witchmaster
Registered User

witchmaster's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 151
Quote:
Originally Posted by Amigajay View Post
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.
witchmaster is offline  
Old 22 March 2017, 15:50   #7
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,336
Yep, cd.device is in the CD32 extended ROM (and I think the CDTV extended ROM too).
Daedalus is offline  
Old 22 March 2017, 21:17   #8
spudje
Registered User

 
Join Date: Dec 2014
Location: Netherlands
Posts: 633
Oh sorry, I read bb2 as aos39 with boing bag 1 & 2.
spudje is offline  
Old 22 March 2017, 23:37   #9
witchmaster
Registered User

witchmaster's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 151
Quote:
Originally Posted by spudje View Post
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
witchmaster is offline  
Old 23 March 2017, 10:52   #10
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,336
Excellent work, I must try it myself and see if I can get it working on my setup. Thanks for sharing!
Daedalus is offline  
Old 24 March 2017, 00:02   #11
witchmaster
Registered User

witchmaster's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 151
Quote:
Originally Posted by Daedalus View Post
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

Last edited by witchmaster; 24 March 2017 at 08:00.
witchmaster is offline  
Old 29 April 2017, 06:28   #12
xArtx
Registered User
 
Join Date: Jun 2013
Location: Australia
Posts: 637
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.
xArtx is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
OSX (PPC) build and CD32 audio tracks snakecoils support.FS-UAE 9 28 March 2014 01:04
Playing CD-Audio tracks on Amiga from a BIN/CUE image Bamiga2002 support.Other 7 23 March 2013 02:45
Playing audio tracks on CD32 games BuckoA51 project.WHDLoad 7 27 June 2012 06:32
WHDLoad without CD32 audio tracks Another World project.WHDLoad 36 23 December 2008 03:12
Best CD32 audio tracks jotd Retrogaming General Discussion 28 15 May 2008 12:33

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:58.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.25560 seconds with 14 queries