'
' Reading the Cookie Jar
'
cookie$=SPACE$(4) ! 4-byte buffer to store the name of the Cookie
adrcj%=LPEEK(&H5A0) ! Cookie Jar's Address
IF adrcj%0 ! If there's a Cookie Jar
REPEAT ! Scan the Cookie Jar
cookie%=LPEEK(adrcj%)
BMOVE V:cookie%,V:cookie$,4
IF cookie$="PSND"
xbios.vector&=DPEEK(adrcj%+4)
psnd.ver$=STR$(PEEK(adrcj%+6))+"."+STR$(PEEK(adrcj%+7))
psnd!=TRUE
ENDIF
ADD adrcj%,8
UNTIL cookie%=0
ENDIF
This program reads the Cookie Jar and looks for the "PSND" cookie. Then it stores the Xbios Vector in xbios.vector&
(16-bit integer) and saves the version number in a string called psnd.ver$. If you prefer to get a numerical value,
just replace:
psnd.ver$=STR$(PEEK(adrcj%+6))+"."+STR$(PEEK(adrcj%+7))by:
psnd.ver&=PEEK(adrcj%+6)+(PEEK(adrcj%+7)/100)
'
' a0="PSND" Cookie address
'
move.w 4(a0),Xbios_vector
Xbios_vector now contains the XBIOS function number of ProSOUND.| Octet | Version number Hi-byte |
Version number Low-byte |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Bit | 15 | 14 | 13 | 12 | 11 | 10 | 09 | 08 | 07 | 06 | 05 | 04 | 03 | 02 | 01 | 00 |
| Binary value |
0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 |
| Hexadecimal value |
$02 | $3E | ||||||||||||||
| Decimal value |
2 | 62 | ||||||||||||||
| Version number |
2.62 | |||||||||||||||
| Number | Name | Description |
|---|---|---|
| 1 | Replay Once | Replays a 8-bit unsigned sample. |
| 2 | Replay Loop | Replays a 8-bit unsigned sample in loop mode. |
| 3 | Replay Frame | Replays several 8-bits unsigned samples. |
| 4 | Stop Replay | Stops the replay. |
| 5 | Convert S-M 8 Bits | Converts a Stereo unsigned 8 bits sample to 8-bit unsigned mono format. |
| 6 | Change Preset | Allows you to modify the free frequency preset (#15). |
| 7 | Convert S-M 16 Bits | Converts a Stereo 16 signed bits sample to 16-bit signed mono format. |
| 8 | Sign/Unsign 8 Bits | Signs or unsigns a 8 bits unsigned sample. |
| 9 | Resample 8 Bits | Resample a 8 Bits unsigned sample to a new rate. |
| 10 | Convert Intel/Motorola | Switches a 16 bits signed sample to Intel or Motorola format. |
| 11 | Replay Once 16 | Replays a 16-bit signed sample. |
| 12 | Replay Loop 16 | Replays a 16-bit signed sample in loop mode. |
| 13 | Replay Frame 16 | Replays several 16-bit signed samples. |
| 14 | Maximize 8 Bits | Amplifies the volume of a 8 Bits unsigned sample to the max, with no distortions. |
| 15 | Maximize 16 Bits | Amplifies the volume of a 16 Bits signed sample to the max, with no distortions. |
| Nb | Filter | Filtering functions. Unimplemented yet. |
trap #14
lea nb(sp),sp
move.l d0,a1
wait_end
tst.l (a1)
bne wait_end
trap #14
lea nb(sp),sp
move.l (a0),a1
move.b (a1),dn ; sample
move.l #sample_start,-(sp) ; Sample start address
move.l #sample_end,-(sp) ; Sample end address
move.w #Frequency,-(sp) ; Replay frequency
move.w #1,-(sp) ; Function #1
move.w Xbios_vector,-(sp) ; XBIOS Vector
trap #14 ; Call to XBIOS
lea 14(sp),sp ; Clear the stack
tst.l d0 ; D0=-1 in case of error
bmi error
move.l d0,a1
; Your code...
tst.l (a1)
beq end ; No more data to replay...
5.2 - Replay Loop
move.l #sample_start,-(sp) ; Sample start address
move.l #sample_end,-(sp) ; Sample end address
move.w #Frequence,-(sp) ; Replay frequency
move.w #2,-(sp) ; Function #2
move.w Xbios_vector,-(sp) ; XBIOS Vector
trap #14 ; Call to XBIOS
lea 14(sp),sp ; Clear the stack
tst.l d0 ; D0=-1 in case of error
bmi error
move.l d0,a1 ; Address containing the number
; of samples remaining to replay
5.3 - Replay Frame
move.l #frame_adress,-(sp) ; Frame address
move.w #Frequency,-(sp) ; The frequency used for all samples
move.w #3,-(sp) ; Fonction #3
move.w Xbios_vector,-(sp) ; XBIOS Vector
trap #14 ; Call to XBIOS
lea 10(sp),sp ; Clear the stack
Let's see now how is made the Frame. All values are long words (4 bytes), so the sequence for
coding a sample has a length of 12 bytes.| Offset | 1st long word (Offset+0) |
2nd long word (Offset+4) |
3rd long word (Offset+8) |
|---|---|---|---|
| 0 | Start 1 | End 1 | Nb 1 |
| 12 | Start 2 | End 2 | Nb 2 |
| 24 | Start 3 | End 3 | Nb 3 |
| ... | |||
| ? | Restart | Not Used | -1 |
| Start X | Start adress of sample #X. |
|---|---|
| End X | End address of sample #X. |
| Nb X | The number of loops assigned to the sample #X before processing the next sample. |
| Restart | Tells ProSOUND where in the Frame it must go after replaying all samples. This value must be a multiple of 12, since it must point out to the offset of the start address of a sample. |
| -1 | This value marks the end of the Frame. |
move.w #4,-(sp) ; Function #4
move.w Xbios_vector,-(sp)
trap #14
addq.l #4,sp
5.5 - Convert S-M 8/16 Bits
move.l #sample_start,-(sp)
move.l #sample_end,-(sp)
move.l #Buffer,-(sp)
move.w #5 or #7,-(sp) 8 bits unsigned = 5
move.w Xbios_vector,-(sp) 16 bits signed = 7
trap #14
lea 16(sp),sp
5.6 - Change Preset| Byte #0 | Pre-divide value of Timer A |
|---|---|
| Byte #1 | Divide value of Timer A |
| Value | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| Pre-divide by | 4 | 10 | 16 | 50 | 64 | 100 | 200 |
move.w #Val,-(sp)
move.w #6,-(sp) ; function #6
move.w Xbios_vector,-(sp)
trap #14
addq.l #6,sp
5.7 - Sign/Unsign
move.l #sample_start,-(sp)
move.l #sample_end,-(sp)
move.l #Buffer,-(sp)
move.w #8,-(sp)
move.w Xbios_vector,-(sp)
trap #14
lea 16(sp),sp
5.8 - Resample 8/16 Bits
move.l #sample_start,-(sp)
move.l #sample_end,-(sp)
move.l #Buffer,-(sp)
move.w #freq_start,-(sp) ex : 11025
move.w #freq_dest,-(sp) ex : 12800
move.w #9 or #16,-(sp) 8 bits unsigned = 9
move.w Xbios_vector,-(sp) 16 bits signed = 16
trap #14
lea 20(sp),sp
5.9 - Convert Intel/Motorola
move.l #sample_start,-(sp)
move.l #sample_end,-(sp)
move.l #buffer,-(sp)
move.w #10,-(sp)
move.w Xbios_vector,-(sp)
trap #14
lea 16(sp),sp
5.10 - The 16-bit Replay functions
move.l #sample_start,-(sp)
move.l #sample_end,-(sp)
move.l #buffer,-(sp)
move.w #14 ou #15 ,-(sp) 8 Bits unsigned = 14
move.w Xbios_vector,-(sp) 16 Bits signed = 15
trap #14
lea 16(sp),sp
5.12 - Filter| Value | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| Frequency (Hz) |
8 192 | 9 600 | 11 170 | 12 288 | 12 538 | 12 800 | 16 384 | 24 576 |
| Value | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Frequency (Hz) |
25 600 | 30 720 | 38 400 | 40 960 | 49 152 | 51 200 | 61 440 | Free Preset |