Gilbert Francois Duivesteijn
If you want your program to run something in sync with the refresh rate of the screen, you can use the vblank interrupt. The way to call your function at the interrupt is to use the hook which is a fixed memory address, where 5 bytes are reserved for every hook. Normally they are filled with RET but you can replace these bytes with e.g. a
JP addr command that points to your function.
This page MSX Wiki: System hooks gives an overview of all possible hooks.
A recommended way to use hooks is:
jp addrinstruction at the place of the hook, pointing to your subroutine. End the hook with
The example below is a minimal example, that gives a BEEP every second on a 50Hz machine. The HTIMI hook is used, which is triggered at the refresh rate of the screen (VBLANK).
Compile with VASM
or with Glass
On the MSX, load and run with: