M src/Application.asm +17 -0
@@ 4,6 4,8 @@
Application: MACRO
cli:
CLI
+ vblankHandler:
+ VBlankHandler
synthesizer:
Synthesizer
size:
@@ 64,6 66,10 @@ Application_Construct:
call CLI_Construct
pop ix
push ix
+ call Application_GetVBlankHandler
+ call VBlankHandler_Construct
+ pop ix
+ push ix
call Application_GetSynthesizer
call Synthesizer_Construct
pop ix
@@ 77,6 83,10 @@ Application_Destruct:
call Synthesizer_Destruct
pop ix
push ix
+ call Application_GetVBlankHandler
+ call VBlankHandler_Destruct
+ pop ix
+ push ix
call Application_GetCLI
call CLI_Destruct
pop ix
@@ 90,6 100,13 @@ Application_GetCLI:
ret
; ix = this
+; ix <- vblank handler
+Application_GetVBlankHandler:
+ ld de,Application.vblankHandler
+ add ix,de
+ ret
+
+; ix = this
; ix <- synthesizer
Application_GetSynthesizer:
ld de,Application.synthesizer
M src/COM.asm +1 -0
@@ 42,6 42,7 @@ COM_Main:
INCLUDE "Application.asm"
INCLUDE "CLI.asm"
INCLUDE "Hook.asm"
+ INCLUDE "VBlankHandler.asm"
INCLUDE "MidiIn.asm"
INCLUDE "MSXMidi.asm"
INCLUDE "MSXMusic.asm"
A => src/VBlankHandler.asm +42 -0
@@ 0,0 1,42 @@
+;
+; Minimal VBlank interrupt handler
+;
+VBlankHandler: MACRO
+ hook:
+ Hook 38H, Entry, OldHook
+ Entry:
+ push af
+ in a,(99H)
+ rlca
+ jr nc,NotVBlank
+ push hl
+ ld hl,(JIFFY)
+ inc hl
+ ld (JIFFY),hl
+ pop hl
+ pop af
+ ei
+ ret
+ NotVBlank:
+ pop af
+ OldHook:
+ ds 5
+ ENDM
+
+; ix = this
+VBlankHandler_Construct:
+ push ix
+ ld de,VBlankHandler.hook
+ add ix,de
+ call Hook_Install
+ pop ix
+ ret
+
+; ix = this
+VBlankHandler_Destruct:
+ push ix
+ ld de,VBlankHandler.hook
+ add ix,de
+ call Hook_Uninstall
+ pop ix
+ ret