mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th04/th05] vector1_at(), vector2_at()
Almost undecompilable, until you remember that you can inhibit the optimization of keeping a function parameter in a register by having an `inline` function take a reference. Yet another function that wouldn't have decompiled that nicely if we had restricted us to C… Part of P0136, funded by [Anonymous].
This commit is contained in:
parent
252c13d383
commit
0263439fac
|
@ -152,17 +152,17 @@ bin\th05\res_kso.com: th05\res_kso.cpp
|
|||
$**
|
||||
| masters.lib
|
||||
|
||||
bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp bin\th05\musicp_c.obj bin\th05\musicp_a.obj bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initop.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj th05\cdg_p_nc.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj
|
||||
bin\th05\op.exe: th05\op010.cpp bin\th05\op.obj th05\op011.cpp th05\m_char.cpp bin\th05\vector.obj bin\th05\musicp_c.obj bin\th05\musicp_a.obj bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initop.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj th05\cdg_p_nc.cpp bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj
|
||||
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=5 -DBINARY='O' -3 -Z -nbin\th05\ -eOP.EXE @&&|
|
||||
$**
|
||||
|
|
||||
|
||||
bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp th05\main013.cpp bin\hfliplut.obj bin\th05\bullet.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp th05\main034.cpp
|
||||
bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\main011.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp th05\main013.cpp bin\hfliplut.obj bin\th05\bullet.obj bin\th05\vector.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp th05\main034.cpp
|
||||
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&|
|
||||
$**
|
||||
|
|
||||
|
||||
bin\th05\maine.exe: bin\th05\maine.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj
|
||||
bin\th05\maine.exe: bin\th05\maine.obj th05\maine011.cpp th05\regist.cpp th05\staff.cpp bin\th05\vector.obj bin\th05\bgimager.obj bin\th05\snd_load.obj bin\th05\snd_kaja.obj bin\th05\pi_cpp_1.obj bin\th05\pi_asm_1.obj bin\th05\pi_cpp_2.obj bin\th05\pi_asm_2.obj bin\th05\initmain.obj bin\th05\input_s.obj bin\th05\inp_h_w.obj bin\th05\snd_dlym.obj bin\th05\frmdelay.obj bin\th04\cdg_load.obj bin\th05\egcrect.obj bin\hfliplut.obj
|
||||
$(CC) $(CFLAGS) $(LARGE_LFLAGS) -DGAME=5 -DBINARY='E' -Z -nbin\th05\ -eMAINE.EXE @&&|
|
||||
$**
|
||||
|
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
#pragma codeseg SHARED_
|
||||
#pragma option -3
|
||||
|
||||
extern "C" {
|
||||
#include <stddef.h>
|
||||
#include "platform.h"
|
||||
#include "pc98.h"
|
||||
#include "master.hpp"
|
||||
#include "th01/math/subpixel.hpp"
|
||||
#include "th01/math/vector.hpp"
|
||||
#include "th04/math/vector.hpp"
|
||||
|
||||
#define polar_by_offset(radius, table, offset) ( \
|
||||
static_cast<long>(radius) * *reinterpret_cast<const short *>( \
|
||||
reinterpret_cast<const int8_t*>(table) + offset \
|
||||
))
|
||||
|
||||
static inline pixel_t polar_x_fast_unsafe(
|
||||
pixel_t center, pixel_t &radius, size_t table_offset
|
||||
) {
|
||||
return ((polar_by_offset(radius, CosTable8, table_offset) >> 8) + center);
|
||||
}
|
||||
|
||||
static inline pixel_t polar_y_fast_unsafe(
|
||||
pixel_t center, pixel_t &radius, size_t table_offset
|
||||
) {
|
||||
return ((polar_by_offset(radius, SinTable8, table_offset) >> 8) + center);
|
||||
}
|
||||
|
||||
#undef polar_by_offset
|
||||
|
||||
int pascal vector1_at(int origin, int length, int angle)
|
||||
{
|
||||
return (((static_cast<long>(length) * angle) >> 8) + origin);
|
||||
}
|
||||
|
||||
void pascal vector2_at(
|
||||
SPPoint near &ret,
|
||||
subpixel_t origin_x,
|
||||
subpixel_t origin_y,
|
||||
subpixel_t length,
|
||||
int angle
|
||||
)
|
||||
{
|
||||
_BX = angle;
|
||||
#if (GAME == 5)
|
||||
_BH ^= _BH;
|
||||
#endif
|
||||
_BX += _BX; // *= sizeof(short)
|
||||
ret.x.v = polar_x_fast_unsafe(origin_x, length, _BX);
|
||||
ret.y.v = polar_y_fast_unsafe(origin_y, length, _BX);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@ int pascal near vector2_near(
|
|||
SPPoint near &ret, unsigned char angle, int length
|
||||
);
|
||||
|
||||
int pascal vector2_at(
|
||||
void pascal vector2_at(
|
||||
SPPoint near &ret,
|
||||
subpixel_t origin_x,
|
||||
subpixel_t origin_y,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "th04/math/vector.cpp"
|
|
@ -0,0 +1 @@
|
|||
#include "th04/math/vector.cpp"
|
|
@ -10559,8 +10559,8 @@ include th04/formats/cdg_put_noalpha.asm
|
|||
include th04/snd/se.asm
|
||||
include th04/formats/cdg_put.asm
|
||||
include th02/exit.asm
|
||||
include th04/math/vector1_at.asm
|
||||
include th04/math/vector2_at.asm
|
||||
extern VECTOR1_AT:proc
|
||||
extern VECTOR2_AT:proc
|
||||
extern SND_LOAD:proc
|
||||
extern SND_KAJA_INTERRUPT:proc
|
||||
extern GAME_INIT_MAIN:proc
|
||||
|
|
|
@ -7533,8 +7533,7 @@ include th04/formats/cdg_put_noalpha.asm
|
|||
include th04/snd/se.asm
|
||||
include th04/hardware/bgimage.asm
|
||||
include th02/exit.asm
|
||||
include th04/math/vector1_at.asm
|
||||
include th04/math/vector2_at.asm
|
||||
extern VECTOR2_AT:proc
|
||||
extern BGIMAGE_PUT_RECT:proc
|
||||
extern SND_LOAD:proc
|
||||
extern SND_KAJA_INTERRUPT:proc
|
||||
|
|
|
@ -2535,8 +2535,7 @@ include th04/snd/se.asm
|
|||
include th04/hardware/bgimage.asm
|
||||
include th04/formats/cdg_put.asm
|
||||
include th02/exit.asm
|
||||
include th04/math/vector1_at.asm
|
||||
include th04/math/vector2_at.asm
|
||||
extern VECTOR1_AT:proc
|
||||
extern _piano_render:proc
|
||||
extern _piano_setup_and_put_initial:proc
|
||||
extern BGIMAGE_PUT_RECT:proc
|
||||
|
|
Loading…
Reference in New Issue