ys2-intro/loader/samples/minexample/sfx.asm

87 lines
1.1 KiB
NASM
Raw Normal View History

2025-11-13 11:07:39 -05:00
sfx_init = sfx
sfx_play = sfx+3
.proc sfx
init:
jmp real_init
play:
lda sfx_done
bne @skip_update
dec tick
lda tick
bne @skip_update
@update_loop:
jsr load_sfx_byte
cmp #$80
bcs @update_loop_end
tay
jsr load_sfx_byte
sta $d400, y
jmp @update_loop
@update_loop_end:
cmp #$ff
bne :+++
ldx sfx_num
bne :+
lda #1
jmp real_init
:
cpx #2
bcs :+
lda #2
jmp real_init
:
sta sfx_done
rts
:
and #$7f
sta tick
@skip_update:
rts
real_init:
sta sfx_num
asl
tax
lda sfx_list, x
sta sfx_byte_SMC+1
lda sfx_list+1, x
sta sfx_byte_SMC+2
lda sfx_num
cmp #2
beq :++
ldx #$18
lda #0
:
sta $d400, x
dex
bpl :-
:
lda #0
sta sfx_index
sta sfx_done
lda #1
sta tick
rts
load_sfx_byte:
ldx sfx_index
sfx_byte_SMC:
lda $1000, x
inx
stx sfx_index
rts
sfx_index: .res 1
tick: .res 1
sfx_done: .res 1
sfx_num: .res 1
sfx_list:
.word sfx0, sfx1, sfx1+$29
sfx0:
.incbin "sfx_badguy.bin"
sfx1:
.incbin "sfx_badguy_amb.bin"
.endproc