From 551aba40da2864764279bed887f2fe5ac778beb2 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 18 Apr 2015 14:56:19 +0100 Subject: [PATCH] Importing bank-managing macros from skdisasm Currently used for banks where data is aligned to start of bank (MusicPoint1, MusicPoint2). --- s2.asm | 17 +++++------------ s2.macros.asm | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/s2.asm b/s2.asm index 22877291..c93e40d3 100644 --- a/s2.asm +++ b/s2.asm @@ -88027,15 +88027,15 @@ SndDAC_End ; --------------------------------------------------------------------------- ; Music pointers ; --------------------------------------------------------------------------- - align $8000 - ; loc_F0000: -MusicPoint1: +MusicPoint1: startBank MusPtr_Continue: rom_ptr_z80 Mus_Continue Mus_Continue: BINCLUDE "sound/music/Continue.bin" + finishBank + ; -------------------------------------------------------------------- ; Nemesis compressed art (20 blocks) ; Buzzer's fireball @@ -88166,11 +88166,8 @@ Snd_Sega_End: ; ------------------------------------------------------------------------------ ; Music pointers ; ------------------------------------------------------------------------------ - align $8000 -soundBankStart := * - ; loc_F8000: -MusicPoint2: +MusicPoint2: startBank MusPtr_CNZ_2P: rom_ptr_z80 Mus_CNZ_2P MusPtr_EHZ: rom_ptr_z80 Mus_EHZ MusPtr_MTZ: rom_ptr_z80 Mus_MTZ @@ -90136,11 +90133,7 @@ Sound70: dc.w $0000,$0101 dc.b $F2 - if * > soundBankStart + $8000 - fatal "soundBank must fit in $8000 bytes but was $\{*-soundBankStart}. Try moving something to the other bank." - else - ;message "soundBank has $\{$8000+soundBankStart-*} bytes free at end." - endif + finishBank ; end of 'ROM' if padToPowerOfTwo && (*)&(*-1) diff --git a/s2.macros.asm b/s2.macros.asm index 2dc53dae..0a110c57 100644 --- a/s2.macros.asm +++ b/s2.macros.asm @@ -92,6 +92,25 @@ rom_ptr_z80 macro addr dc.w z80_ptr(addr) endm +; aligns the start of a bank, and detects when the bank's contents is too large +; can also print the amount of free space in a bank with DebugSoundbanks set +startBank macro {INTLABEL} + align $8000 +__LABEL__ label * +soundBankStart := __LABEL__ +soundBankName := "__LABEL__" + endm + +DebugSoundbanks := 0 + +finishBank macro + if * > soundBankStart + $8000 + fatal "soundBank \{soundBankName} must fit in $8000 bytes but was $\{*-soundBankStart}. Try moving something to the other bank." + elseif (DebugSoundbanks<>0)&&(MOMPASS=1) + message "soundBank \{soundBankName} has $\{$8000+soundBankStart-*} bytes free at end." + endif + endm + ; macro to replace the destination with its absolute value abs macro destination tst.ATTRIBUTE destination