[Decompilation] [th05] snd_bgm_measure(), snd_delay_until_measure()
Umm… but this can't be in the same translation unit as frame_delay(),
because OP.EXE has cdg_put_nocolors() inbetween, which means we'd have
to compile it twice.
What probably happened there: ZUN originally wrote this in C when
frame_delay() was still next to it, then generated ASM from it,
tinkered with that, and ultimately only linked that ASM into the final
game, with the NOPCALL still in there. That might very well be the one
temporary NOPCALL workaround we can never get rid of…
Oh well, at least we got lucky with the padding, and can keep the
cdg_put_nocolors() decompilation from the last commit.
Part of P0133, funded by [Anonymous].
2021-01-08 18:20:04 +00:00
|
|
|
#pragma codeseg SHARED_
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "platform.h"
|
2021-02-07 20:03:00 +00:00
|
|
|
#include "x86real.h"
|
[Decompilation] [th05] snd_bgm_measure(), snd_delay_until_measure()
Umm… but this can't be in the same translation unit as frame_delay(),
because OP.EXE has cdg_put_nocolors() inbetween, which means we'd have
to compile it twice.
What probably happened there: ZUN originally wrote this in C when
frame_delay() was still next to it, then generated ASM from it,
tinkered with that, and ultimately only linked that ASM into the final
game, with the NOPCALL still in there. That might very well be the one
temporary NOPCALL workaround we can never get rid of…
Oh well, at least we got lucky with the padding, and can keep the
cdg_put_nocolors() decompilation from the last commit.
Part of P0133, funded by [Anonymous].
2021-01-08 18:20:04 +00:00
|
|
|
#include "libs/kaja/kaja.h"
|
|
|
|
#include "th02/hardware/frmdelay.h"
|
|
|
|
#include "th05/snd/snd.h"
|
|
|
|
#include "th02/snd/measure.hpp"
|
|
|
|
}
|
|
|
|
|
|
|
|
int snd_bgm_measure(void)
|
|
|
|
{
|
|
|
|
if(!snd_is_active()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return snd_get_song_measure();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pascal snd_delay_until_measure(int measure, unsigned int frames_if_no_bgm)
|
|
|
|
{
|
|
|
|
int measure_cur;
|
|
|
|
do {
|
|
|
|
measure_cur = snd_bgm_measure();
|
|
|
|
if(measure_cur < 0) {
|
|
|
|
/* TODO: Replace with the decompiled call
|
|
|
|
* frame_delay(frames_if_no_bgm);
|
|
|
|
* once the segmentation allows us to, if ever */
|
|
|
|
__asm {
|
|
|
|
push frames_if_no_bgm; nop; push cs; call near ptr frame_delay;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while(measure_cur < measure);
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma codestring "\x00"
|