2021-05-29 12:37:38 +00:00
|
|
|
; void __fastcall__ psg_outb (unsigned char b);
|
2021-05-14 23:12:59 +00:00
|
|
|
; void __fastcall__ psg_delay (unsigned char b);
|
|
|
|
; void __fastcall__ bios_playsound (void *a, unsigned char b);
|
2021-05-29 12:37:38 +00:00
|
|
|
; void psg_silence (void);
|
2013-12-05 11:40:44 +00:00
|
|
|
|
2021-05-14 23:12:59 +00:00
|
|
|
|
|
|
|
.export _psg_outb, _psg_silence, _psg_delay
|
|
|
|
.export _bios_playsound
|
|
|
|
|
|
|
|
.import popax
|
|
|
|
|
2017-02-01 18:46:04 +00:00
|
|
|
.include "creativision.inc"
|
|
|
|
|
2021-05-14 23:12:59 +00:00
|
|
|
|
|
|
|
songptr := $00 ; Points to current tune data
|
|
|
|
volptr := $04 ; Points to current volume table
|
|
|
|
|
2013-12-05 11:40:44 +00:00
|
|
|
_psg_outb:
|
2021-05-14 23:12:59 +00:00
|
|
|
;* Let BIOS output the value.
|
|
|
|
jmp $FE77
|
2013-12-05 11:40:44 +00:00
|
|
|
|
2017-02-01 18:46:04 +00:00
|
|
|
|
2013-12-05 11:40:44 +00:00
|
|
|
_psg_silence:
|
2021-05-14 23:12:59 +00:00
|
|
|
jmp $FE54
|
2017-02-01 18:46:04 +00:00
|
|
|
|
|
|
|
|
2013-12-05 11:40:44 +00:00
|
|
|
_psg_delay:
|
2017-02-01 18:46:04 +00:00
|
|
|
tay
|
2021-05-14 23:12:59 +00:00
|
|
|
l1: lda #200
|
|
|
|
l2: sbc #1
|
|
|
|
bne l2
|
2017-02-01 18:46:04 +00:00
|
|
|
|
2021-05-14 23:12:59 +00:00
|
|
|
lda #200
|
|
|
|
l3: sbc #1
|
|
|
|
bne l3
|
2017-02-01 18:46:04 +00:00
|
|
|
|
|
|
|
dey
|
2021-05-14 23:12:59 +00:00
|
|
|
bne l1
|
2017-02-01 18:46:04 +00:00
|
|
|
rts
|
|
|
|
|
2013-12-05 11:40:44 +00:00
|
|
|
|
|
|
|
;* Creativision Sound Player
|
2021-05-14 23:12:59 +00:00
|
|
|
;* 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).
|
2013-12-05 11:40:44 +00:00
|
|
|
;*
|
2021-05-14 23:12:59 +00:00
|
|
|
;* Note: tune data must be stored backwards.
|
2013-12-05 11:40:44 +00:00
|
|
|
|
|
|
|
_bios_playsound:
|
2021-05-14 23:12:59 +00:00
|
|
|
php
|
|
|
|
pha ; Save tune length
|
2017-02-01 18:46:04 +00:00
|
|
|
sei
|
|
|
|
|
2021-05-14 23:12:59 +00:00
|
|
|
lda #<$FCD5 ; A BIOS volume table
|
|
|
|
ldx #>$FCD5
|
|
|
|
sta volptr
|
|
|
|
stx volptr+1
|
2017-02-01 18:46:04 +00:00
|
|
|
|
2021-05-14 23:12:59 +00:00
|
|
|
jsr popax ; Get tune array pointer
|
|
|
|
sta songptr
|
|
|
|
stx songptr+1
|
2017-02-01 18:46:04 +00:00
|
|
|
|
|
|
|
pla
|
2021-05-14 23:12:59 +00:00
|
|
|
tay
|
|
|
|
dey ; Point to tempo byte
|
|
|
|
jmp $FBED ; Let BIOS do its thing
|