1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-26 13:18:31 +00:00

Moved Creativision's playsound() into a separate file.

It won't waste space in a cartridge if it isn't used.
This commit is contained in:
Greg King
2021-05-30 13:30:08 -04:00
parent f636d4e634
commit af3d4581d3
3 changed files with 69 additions and 61 deletions
+40
View File
@@ -0,0 +1,40 @@
; void __fastcall__ bios_playsound (void *a, unsigned char b);
.export _bios_playsound
.import popax
.include "creativision.inc"
songptr := $00 ; Points to current tune data
volptr := $04 ; Points to current volume table
;* Creativision Sound Player
;* Based on BIOS song player.
;*
;* Pass a pointer to a set of note triples, terminated with a tempo byte;
;* and pass the length of the triples and tempo (max 255).
;*
;* Note: tune data must be stored backwards.
_bios_playsound:
php
pha ; Save tune length
sei
lda #<$FCD5 ; BIOS decreasing-volume table
ldx #>$FCD5
sta volptr
stx volptr+1
jsr popax ; Get tune array pointer
sta songptr
stx songptr+1
pla
tay
dey ; Point to tempo byte
jmp BIOS_PLAY_SONG ; Let BIOS do its thing
+3 -40
View File
@@ -1,27 +1,18 @@
; void __fastcall__ psg_outb (unsigned char b);
; void __fastcall__ psg_delay (unsigned char b);
; void __fastcall__ bios_playsound (void *a, unsigned char b);
; void psg_silence (void);
.export _psg_outb, _psg_silence, _psg_delay
.export _bios_playsound
.import popax
.include "creativision.inc"
songptr := $00 ; Points to current tune data
volptr := $04 ; Points to current volume table
_psg_outb:
;* Let BIOS output the value.
jmp $FE77
;* Let BIOS output the value.
_psg_outb := BIOS_POKE_PSG
_psg_silence:
jmp $FE54
_psg_silence := BIOS_QUIET_PSG
_psg_delay:
@@ -37,31 +28,3 @@ l3: sbc #1
dey
bne l1
rts
;* Creativision Sound Player
;* Based on BIOS song player.
;*
;* Pass a pointer to a set of note triples, terminated with a tempo byte;
;* and pass the length of the triples and tempo (max 255).
;*
;* Note: tune data must be stored backwards.
_bios_playsound:
php
pha ; Save tune length
sei
lda #<$FCD5 ; A BIOS volume table
ldx #>$FCD5
sta volptr
stx volptr+1
jsr popax ; Get tune array pointer
sta songptr
stx songptr+1
pla
tay
dey ; Point to tempo byte
jmp $FBED ; Let BIOS do its thing