mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2026-01-06 23:19:20 +11:00
161 lines
2.9 KiB
ArmAsm
161 lines
2.9 KiB
ArmAsm
.rtmodel version,"1"
|
|
.rtmodel core,"6502"
|
|
|
|
.extern _Vfp
|
|
.extern _Vsp
|
|
.extern _Zp
|
|
|
|
;;; I/O ports
|
|
IO_SPK: .equ 0xC030
|
|
|
|
;;; Monitor routines
|
|
MON_WAIT .equ 0xFCA8
|
|
|
|
;;; snd_beep
|
|
;;; Generates a sound of configurable duration and pitch
|
|
;;; See https://github.com/tilleul/apple2/blob/master/2liners/the%20art%20of%202-liners/SCRN_PLOT_your_sound_routine.md
|
|
;;; Parameters:
|
|
;;; - duration [A]: duration of the sound
|
|
;;; - pitch [_Zp[0]]: sound pitch
|
|
;;;
|
|
;;; Returns: Nothing
|
|
snd_beep:
|
|
P_PITCH$: .equ _Zp+0
|
|
tax ; Move accumulator with duration into register x
|
|
-- ldy zp:P_PITCH$ ; Load the pitch from zp
|
|
lda IO_SPK ; Toggle the speaker
|
|
- dey
|
|
bne -
|
|
dex ; Decrement the time left
|
|
bne -- ; Back at loading the pitch if we need to go on
|
|
rts
|
|
|
|
snd_beep_lower:
|
|
P_PITCH$: .equ _Zp+0
|
|
tax ; Move accumulator with duration into register x
|
|
-- ldy zp:P_PITCH$ ; Load the pitch from zp
|
|
lda IO_SPK ; Toggle the speaker
|
|
- dey
|
|
nop
|
|
nop
|
|
nop
|
|
bne -
|
|
dex ; Decrement the time left
|
|
bne -- ; Back at loading the pitch if we need to go on
|
|
rts
|
|
|
|
snd_mod_button:
|
|
P_PITCH$: .equ _Zp+0
|
|
lda #0xAA
|
|
sta zp:P_PITCH$
|
|
lda #0x25
|
|
jsr snd_beep_lower
|
|
lda #0xCC
|
|
sta zp:P_PITCH$
|
|
lda #0x0A
|
|
jsr snd_beep_lower
|
|
rts
|
|
|
|
snd_start:
|
|
P_PITCH$: .equ _Zp+0
|
|
lda #0xCC
|
|
sta zp:P_PITCH$
|
|
lda #0x99
|
|
jsr snd_beep_lower
|
|
lda #0xAA
|
|
sta zp:P_PITCH$
|
|
lda #0x80
|
|
jsr snd_beep_lower
|
|
lda #0x88
|
|
sta zp:P_PITCH$
|
|
lda #0xff
|
|
jsr snd_beep_lower
|
|
rts
|
|
|
|
snd_sad_scale:
|
|
T_IDX$: .equ _Zp+1
|
|
P_PITCH$: .equ _Zp+0
|
|
ldy #6
|
|
- lda __sad_scale_pitches,y
|
|
sta zp:P_PITCH$
|
|
lda #0x90
|
|
sty zp:T_IDX$
|
|
jsr snd_beep_lower
|
|
ldy zp:T_IDX$
|
|
dey
|
|
bpl -
|
|
rts
|
|
|
|
__sad_scale_pitches:
|
|
.byte 0xFF
|
|
.byte 0xFF
|
|
.byte 0xFF
|
|
.byte 0xCC
|
|
.byte 0xAA
|
|
.byte 0x88
|
|
.byte 0x88
|
|
|
|
snd_festive:
|
|
T_IDX$: .equ _Zp+1
|
|
P_PITCH$: .equ _Zp+0
|
|
ldy #10
|
|
- lda __festive_pitches,y
|
|
sta zp:P_PITCH$
|
|
lda __festive_duration,y
|
|
sty zp:T_IDX$
|
|
jsr snd_beep
|
|
ldy zp:T_IDX$
|
|
|
|
lda __festive_wait,y
|
|
jsr MON_WAIT ; Call the monitor wait routine
|
|
|
|
dey
|
|
bpl -
|
|
rts
|
|
|
|
__festive_pitches:
|
|
.byte 0xEE
|
|
.byte 0xCC
|
|
.byte 0xAA
|
|
.byte 0x99
|
|
.byte 0xAA
|
|
.byte 0xCC
|
|
.byte 0xCC
|
|
.byte 0x88
|
|
.byte 0xAA
|
|
.byte 0xCC
|
|
.byte 0xCC
|
|
|
|
__festive_duration:
|
|
.byte 0xFF
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
.byte 0x80
|
|
|
|
__festive_wait:
|
|
.byte 0x70
|
|
.byte 0x70
|
|
.byte 0x70
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
.byte 0xA0
|
|
|
|
;;; Declaration of public symbols
|
|
.public snd_beep
|
|
.public snd_beep_lower
|
|
.public snd_sad_scale
|
|
.public snd_festive
|
|
.public snd_mod_button
|
|
.public snd_start
|