Jump to content
Milli Vee

Sound Help ... please

Recommended Posts

I really really really could use some help with understanding sound tables, their initialization etc on the CV so that I do not have to use my own custom sound routines in the new game I am working on now. Anyone?

 

This is what I have:

 

I call SND.Start to set up the tables:

SND.Start:
                ld      hl,SND.Song
                ld      b,1
                call    OS7.SoundInit
                ret

SND.Song:
                .dw     SND.Laser,CHANNEL0

SND.Laser:
                .db $40,$dd,$30,1
                .db $40,$b9,$30,1
                .db $40,$83,$30,1
                .db $40,$49,$30,1
                .db $40,$4f,$30,1
                .db $40,$53,$30,1
                .db $40,$59,$30,1
                .db $40,$5f,$30,1
                .db $40,$67,$30,1
                .db $40,$77,$30,1
                .db $40,$8b,$30,1
                .db $40,$8f,$30,1
                .db $40,$87,$30,1
                .db $40,$6f,$30,1
                .db $40,$77,$30,1
                .db $40,$91,$30,1
                .db $40,$a7,$30,1
                .db $40,$b9,$30,1
                .db $40,$cd,$30,1
                .db $40,$dd,$30,1
                .db $40,$e3,$30,1
                .db $50

The OS7.SoundInit routine and others are just my routines wrapping the OS7 call so that I can preserve registers:

 

                
; **************************************************************
;
; Start playing song B - do this to preserve registers
;
; **************************************************************

OS7.PlayIt:
                pushall
                call    PLAY_IT
                popall
                ret

; **************************************************************
;
; Play the next note of the song - do this to preserve registers
;
; **************************************************************

OS7.PlaySongs:
                pushall
                call    PLAY_SONGS
                popall
                ret

; **************************************************************
;
; Update sound table apply sweep effects - do this to preserve registers
;
; **************************************************************

OS7.SoundMan:
                pushall
                call    SOUND_MAN
                popall
                ret

; **************************************************************
;
; Initialize the sound tables to HL with B holding number of
; songs - do this to preserve registers
;
; **************************************************************

OS7.SoundInit:
                pushall
                call    SOUND_INIT
                popall
                ret

Now in my NMI I do this at the end:

 

                call    OS7.PlaySongs
                call    OS7.SoundMan

                in      a,(0bfh)                                ; Acknowledge interrupt to VDP
                exx                                             ; Restore registers
                ex      af,af'
                retn

and I do get some sound but it never comes back from the SoundMan routine. Here is the data structure:

 

CHANNEL0        .equ    LVL.PRIZEWAIT + 1                       ; 10 bytes used for channel 0 sound
CHANNEL1        .equ    CHANNEL0 + 10                           ; 10 bytes used for channel 1 sound
CHANNEL2        .equ    CHANNEL1 + 10                           ; 10 bytes used for channel 2 sound
CHANNEL3        .equ    CHANNEL2 + 10                           ; 10 bytes used for channel 3 sound

That actual address of CHANNEL0 is 07068h in RAM

 

Please someone help

Share this post


Link to post
Share on other sites

Ok key things is how the RAM tables are setup, here is a full example:

 

Code to initialise:

	; Initialise sound
      LD    B,SoundDataCount  ;Max number of active voices+effects
      LD    HL,SoundAddrs
      CALL  SOUND_INIT

 

Wrapper function for PLAY_IT:

;
; Play a sound, protects the calling routine from common
; registers being changed.
; B = Sound to play
SOUND:
    PUSH IX
    PUSH IY
    PUSH HL
    PUSH DE
    CALL PLAY_IT
    POP DE
    POP HL
    POP IY
    POP IX
    RET

 

My standard NMI:

;
; NMI routine
;
NMI:
      PUSH  AF
      PUSH  BC
      PUSH  DE
      PUSH  HL
      PUSH  IX
      PUSH  IY
      EX    AF,AF'
      PUSH  AF
      EXX
      PUSH  BC
      PUSH  DE
      PUSH  HL

      ; update our time counter
  LD HL,(TIME)
  DEC HL
  LD (TIME),HL

	;Now we can safely call any OS7 calls
      CALL  PLAY_SONGS  ;Update active music
      CALL  SOUND_MAN   ;Prepare for next go at music

      ; write sprite table
   CALL    SPRWRT
   LD A,(VDU_HOOK)
   CP 0cdh
   JR NZ,NMI2
   CALL VDU_HOOK
NMI2:
      CALL  TIME_MGR
 
	;Now restore everything
      POP   HL
      POP   DE
      POP   BC
      EXX
      POP   AF
      EX    AF,AF'
      POP   IY
      POP   IX
      POP   HL
      POP   DE
      POP   BC
 
      CALL  READ_REGISTER     ;Side effect allows another NMI to happen
 
      POP   AF
 
      RETN  ;Non maskable interrupt

 

Sound data area in ROM:

;**************************************************************************************************
; Sound and music data area
;**************************************************************************************************

; Shoot
shoot1:
    DB $c3,$30,$71,$0d,$32,$10,$14,$12   ; tone freq 1962,5Hz swept down - vol 12 swept down - len  4
    DB $90   ; end

; Explode
explode1:
    DB  002h,006h,20,01fh,041h
    DB  010h
    DW  00000h
 
enemyshoot:
  DB $81,$87,$30,$04,$12,$02  ; tone freq 828,6Hz swept down - vol 12 - length 6
  DB $81,$87,$50,$04,$12,$02  ; tone freq 828,6Hz swept down - vol 10 - length 6
  DB $81,$87,$70,$04,$12,$02  ; tone freq 828,6Hz swept down - vol 8 - length 6
  DB $90   ; end


bonus:
    DB 0c1h, 095h, 070h, 002h, 031h, 040h ; C5 035 V15
    DB 090h
    DW 0000
 
sfx_EXPLOSION3_0:
	DB $00,$00,$37,84
	DB $10
sfx_EXPLOSION3_3:
  DB $c0,$e7,$f3,1
  DB $c0,$d1,$f3,1
  DB $c0,$91,$f3,1
  DB $c0,$55,$f1,1
  DB $c0,$45,$f3,1
  DB $c0,$59,$f1,1
  DB $c0,$53,$f1,1
  DB $c0,$59,$f3,1
  DB $c0,$45,$f1,2
  DB $c0,$59,$f3,1
  DB $c0,$45,$f1,1
  DB $c0,$65,$f3,1
  DB $c0,$61,$f3,1
  DB $c0,$53,$f0,1
  DB $c0,$51,$f0,1
  DB $c0,$5b,$f3,1
  DB $c0,$4f,$f0,1
  DB $c0,$7b,$f3,1
  DB $c0,$77,$f3,1
  DB $c0,$53,$f0,1
  DB $c0,$47,$f0,1
  DB $c0,$77,$f3,2
  DB $c0,$47,$f0,2
  DB $c0,$7d,$f3,2
  DB $c0,$55,$f0,2
  DB $c0,$71,$f3,1
  DB $c0,$55,$f0,1
  DB $c0,$53,$f0,1
  DB $c0,$6d,$f3,1
  DB $c0,$63,$f3,1
  DB $c0,$5f,$f1,2
  DB $c0,$67,$f3,1
  DB $c0,$5f,$f1,2
  DB $c0,$91,$f3,1
  DB $c0,$9d,$f3,1
  DB $c0,$e7,$f3,1
  DB $c0,$d1,$f3,1
  DB $c0,$91,$f3,1
  DB $c0,$55,$f1,1
  DB $c0,$45,$f3,1
  DB $c0,$59,$f1,1
  DB $c0,$53,$f1,1
  DB $c0,$59,$f3,1
  DB $c0,$45,$f1,2
  DB $c0,$59,$f3,1
  DB $c0,$45,$f1,1
  DB $c0,$65,$f3,1
  DB $c0,$61,$f3,1
  DB $c0,$53,$f0,1
  DB $c0,$51,$f0,1
  DB $c0,$5b,$f3,1
  DB $c0,$4f,$f0,1
  DB $c0,$7b,$f3,1
  DB $c0,$77,$f3,1
  DB $c0,$53,$f0,1
  DB $c0,$47,$f0,1
  DB $c0,$77,$f3,2
  DB $c0,$47,$f0,2
  DB $c0,$7d,$f3,2
  DB $c0,$55,$f0,2
  DB $c0,$71,$f3,1
  DB $c0,$55,$f0,1
  DB $c0,$53,$f0,1
  DB $c0,$6d,$f3,1
  DB $c0,$63,$f3,1
  DB $c0,$5f,$f1,2
  DB $c0,$67,$f3,1
  DB $c0,$5f,$f1,2
  DB $c0,$91,$f3,1
  DB $c0,$9d,$f3,1
  DB $d0


;**************************************************************************************************
; Sound settings
;**************************************************************************************************
SoundDataCount:   EQU   7
Len_SoundDataArea:      EQU   10*SoundDataCount+1     ;7 data areas
SoundAddrs:
    DW    shoot1,SoundDataArea              ; 1 drop depth charge sound (Channel 1)
	DW  explode1,SoundDataArea+30         ; 2  enemy explode
	DW  bonus,SoundDataArea+20            ; 3  add bonus points
	DW  enemyshoot,SoundDataArea+10       ; 4  enemy shoot
    DW  sfx_EXPLOSION3_0,SoundDataArea+40 ; 5 Ship explosion
	DW  sfx_EXPLOSION3_3,SoundDataArea+50 ; 6 Ship explosion
    DW  0,0

 

And finally the RAM definition:

 

; Sound Data area - 7 songs
SoundDataArea: DS Len_SoundDataArea

 

Key here is which sound buffer you want each sound to use, so the explosion is triggered and plays on two different channels and buffers and will continue even if other sounds are played at the same time.

 

To trigger the explosion I would use the following code:

LD B,5
CALL SOUND
LD B,6
CALL SOUND

 

All the above is from the Colecovision version of Depth Charge.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...