From 06f50ed77949cee495a1d8d98fec16648a5c8ea9 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 15 May 2023 12:31:46 +0100 Subject: Added OPL3 support --- example.asm | 262 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 251 insertions(+), 11 deletions(-) (limited to 'example.asm') diff --git a/example.asm b/example.asm index 992823f..468db3a 100644 --- a/example.asm +++ b/example.asm @@ -7,7 +7,8 @@ .equ INT_VECT 0xff00 ; setup an int handler so we - ; can use the frame int to sync + ; can use the frame interrupt to sync + ; and play sounds in background ld a, >INT_VECT ld x, -1 ; -1 -> 1 @@ -96,11 +99,23 @@ turn: inc b and b, 15 ld [sp + 2], b - ret + ; play an effect when we turn + ; alternating two sounds + + ld x, effect + ld y, [a : x] + xor y, 3 + ld [a : x], y + + call sound_queue_effect + ret - ; fill frame-buffer - ; in: reg b color +; +; fill frame-buffer +; +; in: reg b color fill_screen: ld a, 0xbf ld x, 0 @@ -116,11 +131,10 @@ fill_loop: jmp fill_loop ret -int_handler: - iret - - ; draw sprite - ; in: coordinates in px, py +; +; Draw the sprite +; +; in: coordinates in px, py draw_sprite: ; blitter in settings mode ld x, 128 @@ -167,3 +181,229 @@ incy: py: .db 64 +effect: + .db 1 + +; +; Our int handler plays / stops sounds +; +int_handler: + push a + push b + push x + push y + call sound_play + pop y + pop x + pop b + pop a + iret + +; +; Queue a sound effect to be played +; +; in: y sound index (1 based) +sound_queue_effect: + ; can't be interrupted + sif + + ld a, >sound_efx + ld x, sound_queue + ld y, sound_queue + ld y, sound_queue + ld y,