mirror of https://github.com/nmlgc/ReC98.git
![]() `cPtrSize` is simply the wrong constant for calculating parameter offsets on the stack, because it corresponds to the memory model's default distance, not the function's distance. Luckily, ARG has a RETURNS clause, and if you declare all parameters in there, ARG won't emit that pesky and unnecessary `ENTER 0, 0` instruction. Big discovery right there! Sadly, ARG is unusable for ZUN's silly functions that keep the base pointer in BX. TASM declares the resulting equates as `[BP+offset]`, and it's apparently impossible to only get `offset` out of such an equate later. So, rather than staying with numbers, let's reimplement ARG for these functions instead. This way, we can even abstract away the stack clear size for the `RET` instructions. It's a bit rough around the edges though, forcing you to explicitly specify the function distance, and to pass the parameters in reverse order compared to the C declaration (thankfully, all of these use the PASCAL calling convention). It also doesn't work with more complex types yet. But certainly better than numbers. Part of P0134, funded by [Anonymous]. |
||
---|---|---|
.. | ||
boss | ||
bullet | ||
enemy | ||
hud | ||
item | ||
player | ||
pointnum | ||
stage | ||
custom.h | ||
custom[bss].asm | ||
laser_render_hittest.asm | ||
lasers[bss].asm | ||
lasers_control.asm | ||
lasers_render[bss].asm | ||
lasers_update_render.asm | ||
playperf.hpp | ||
playperf_adjust_speed.asm | ||
select_for_playchar.asm |