Hamazing/source/framework/framework_scripting.asm
chrisly42 9c48c11cd1 Big "squashed" update to latest version of Framework.
- Bugfix: WaitForFrame was completely broken. Now also caters for race-condition that would have waited one extra frame.
- Bugfix: InitPart would overwrite innocent memory (reported by Gigabates and Losso)
- Bugfix: Palette LERP had wrong bias.
- Removed extra paths in include statement, use default include paths instead
- Added Raspberry Casket no-jitter background calc mode (FW_MUSIC_PLAYER_CHOICE = 6)
- Updated Raspberry Casket to V2.0 presto branch (WIP)
- Removed fw_FrameCounterLong, use fw_FrameCounter-2 for debug purposes
- Support for blue noise palette LERPing (like in Is Real). Provide your own blue noise table (4 KB), stuff it into fw_BlueNoiseTablePtr, set FW_PALETTE_LERP_SUPPORT to 2
- Music tick routine is now replaceable during runtime (fw_MusicTickRoutine)
- Support for softints and audio interrupts
- LMB exit can also be disabled dynamically when using FW_LMB_EXIT_SUPPORT = 2 and fw_DisableLMBExit != 0
- Added LSP Micro support and LSP Nano (custom format that uses note pitches instead of periods)
- Minor other things
2024-09-15 17:43:33 +02:00

91 lines
2.9 KiB
NASM

;--------------------------------------------------------------------
; Install a script
;
; Routines of the script will be executed via CheckScript once the
; given relative frame numbers (from the point in time this routine
; is called) have been reached (or passed).
;
; A script is built in this way:
; dc.w <framenumber>,<routinetocall>-*
; dc.w <framenumber>,<routinetocall>-*
;
; The script is terminated with a zero word.
;
; In : a0 = script pointer
;
fw_InstallScript:
PUTMSG 10,<"%d: Script at %p installed">,fw_FrameCounter-2(a6),a0
move.l a0,fw_ScriptPointer(a6)
move.w fw_FrameCounter(a6),fw_ScriptFrameOffset(a6)
rts
;--------------------------------------------------------------------
; Checks the script for execution
;
; Checkes if a script is installed and another cue is due to the
; current frame counter, executes it and advances the script pointer.
;
fw_CheckScript:
move.l fw_ScriptPointer(a6),d0
bne.s .cont
rts
.cont move.l d0,a0
move.w (a0)+,d0
add.w fw_ScriptFrameOffset(a6),d0
cmp.w fw_FrameCounter(a6),d0
bgt.s .exit
move.w (a0)+,d0
move.l a0,fw_ScriptPointer(a6)
pea -2(a0,d0.w)
PUTMSG 10,<"%d: Script hit %p">,fw_FrameCounter-2(a6),(sp)
tst.w (a0)
bne.s .exit
PUTMSG 10,<"Script terminated.">
clr.l fw_ScriptPointer(a6)
.exit rts
IF FW_MUSIC_SUPPORT
;--------------------------------------------------------------------
; Install a music-frame based script
;
; Routines of the script will be executed via CheckMusicScript once
; the given absolute music frame numbers have been reached (or passed).
;
; A script is built in this way:
; dc.w <musicframenumber>,<routinetocall>-*
; dc.w <musicframenumber>,<routinetocall>-*
;
; The script is terminated with a zero word.
;
; In : a0 = script pointer
;
fw_InstallMusicScript:
PUTMSG 10,<"%d: MusicScript at %p installed">,fw_FrameCounter-2(a6),a0
move.l a0,fw_MusicScriptPointer(a6)
rts
;--------------------------------------------------------------------
; Checks the music script for execution
;
; Checkes if a music script is installed and another cue is due to the
; current frame counter, executes it and advances the script pointer.
;
fw_CheckMusicScript:
move.l fw_MusicScriptPointer(a6),d0
bne.s .cont
rts
.cont move.l d0,a0
move.w (a0)+,d0
cmp.w fw_MusicFrameCount(a6),d0
bgt.s .exit
move.w (a0)+,d0
move.l a0,fw_MusicScriptPointer(a6)
pea -2(a0,d0.w)
PUTMSG 10,<"%d: MusicScript (%d) hit %p">,fw_FrameCounter-2(a6),fw_MusicFrameCount-2(a6),(sp)
tst.w (a0)
bne.s .exit
PUTMSG 10,<"MusicScript terminated.">
clr.l fw_MusicScriptPointer(a6)
.exit rts
ENDC