mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th01] Pellet speed modification
Category: Function comment spells out entire function code because its effects are impossible to summarize Part of P0160, funded by Yanga.
This commit is contained in:
parent
2f9304781f
commit
ea0997ab38
|
@ -178,7 +178,9 @@ inline subpixel_t base_speed_for_rank(void)
|
||||||
|
|
||||||
#define speed_set(speed) \
|
#define speed_set(speed) \
|
||||||
speed += base_speed_for_rank(); \
|
speed += base_speed_for_rank(); \
|
||||||
speed += ((resident->pellet_speed * speed) / to_sp(2.5f)); \
|
/* Note that ((subpixel * pellet_speed_t) / pellet_speed_t) still gives a
|
||||||
|
/* correct subpixel result. */ \
|
||||||
|
speed += ((resident->pellet_speed * speed) / PELLET_SPEED_MULTIPLIER); \
|
||||||
if(speed < to_sp(1.0f)) { \
|
if(speed < to_sp(1.0f)) { \
|
||||||
speed = to_sp(1.0f); \
|
speed = to_sp(1.0f); \
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "th01/main/bullet/pellet_s.hpp"
|
||||||
|
|
||||||
|
void pellet_speed_lower(pellet_speed_t max, pellet_speed_t negative_delta)
|
||||||
|
{
|
||||||
|
if(resident->pellet_speed > max) {
|
||||||
|
resident->pellet_speed = max;
|
||||||
|
} else {
|
||||||
|
resident->pellet_speed += negative_delta;
|
||||||
|
}
|
||||||
|
if(resident->pellet_speed < PELLET_SPEED_LOWER_MIN) {
|
||||||
|
resident->pellet_speed = PELLET_SPEED_LOWER_MIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pellet_speed_raise(pellet_speed_t delta)
|
||||||
|
{
|
||||||
|
resident->pellet_speed += delta;
|
||||||
|
if(resident->pellet_speed > PELLET_SPEED_RAISE_MAX) {
|
||||||
|
resident->pellet_speed = PELLET_SPEED_RAISE_MAX;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#define PELLET_SPEED_LOWER_MIN to_pellet_speed(-0.375f)
|
||||||
|
#define PELLET_SPEED_RAISE_MAX to_pellet_speed(0.5f)
|
||||||
|
|
||||||
|
// Clamps the resident speed of newly fired pellets to the given maximum value
|
||||||
|
// if it's higher, then raises (sic) it by [negative_delta], down to a minimum
|
||||||
|
// of [PELLET_SPEED_LOWER_MIN].
|
||||||
|
void pellet_speed_lower(pellet_speed_t max, pellet_speed_t negative_delta);
|
||||||
|
|
||||||
|
inline void pellet_speed_lower(float max, float negative_delta) {
|
||||||
|
pellet_speed_lower(to_pellet_speed(max), to_pellet_speed(negative_delta));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raises the resident speed of newly fired pellets by [delta], up to a
|
||||||
|
// maximum of [PELLET_SPEED_RAISE_MAX].
|
||||||
|
void pellet_speed_raise(pellet_speed_t delta);
|
||||||
|
|
||||||
|
inline void pellet_speed_raise(float delta) {
|
||||||
|
pellet_speed_raise(to_pellet_speed(delta));
|
||||||
|
}
|
|
@ -2,3 +2,9 @@
|
||||||
* -----
|
* -----
|
||||||
* 3rd part of code segment #1 of TH01's REIIDEN.EXE
|
* 3rd part of code segment #1 of TH01's REIIDEN.EXE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
#include "th01/common.h"
|
||||||
|
#include "th01/resident.hpp"
|
||||||
|
|
||||||
|
#include "th01/main/bullet/pellet_s.cpp"
|
||||||
|
|
|
@ -9,6 +9,17 @@ typedef enum {
|
||||||
MODE_DEBUG = 3
|
MODE_DEBUG = 3
|
||||||
} mode_t;
|
} mode_t;
|
||||||
|
|
||||||
|
// Much like subpixels, pellet speeds are stored pre-multiplied by 40 to allow
|
||||||
|
// an effective resolution of 0.025 pixels to be losslessly stored in an
|
||||||
|
// integer. This pre-multiplication is reverted by the pellet spawning
|
||||||
|
// functions.
|
||||||
|
typedef int pellet_speed_t;
|
||||||
|
|
||||||
|
static const pellet_speed_t PELLET_SPEED_MULTIPLIER = 40;
|
||||||
|
|
||||||
|
#define to_pellet_speed(pixel_v) \
|
||||||
|
static_cast<pellet_speed_t>(pixel_v * PELLET_SPEED_MULTIPLIER)
|
||||||
|
|
||||||
#define RES_ID "ReiidenConfig"
|
#define RES_ID "ReiidenConfig"
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char id[sizeof(RES_ID)];
|
char id[sizeof(RES_ID)];
|
||||||
|
@ -23,7 +34,7 @@ typedef struct {
|
||||||
char snd_need_init;
|
char snd_need_init;
|
||||||
char unused_2;
|
char unused_2;
|
||||||
char mode;
|
char mode;
|
||||||
int pellet_speed;
|
pellet_speed_t pellet_speed;
|
||||||
long rand;
|
long rand;
|
||||||
long score;
|
long score;
|
||||||
long continues_total;
|
long continues_total;
|
||||||
|
|
|
@ -1276,65 +1276,8 @@ sub_C942 endp
|
||||||
main_012_TEXT ends
|
main_012_TEXT ends
|
||||||
|
|
||||||
main_013_TEXT segment byte public 'CODE' use16
|
main_013_TEXT segment byte public 'CODE' use16
|
||||||
|
extern @pellet_speed_lower$qii:proc
|
||||||
; =============== S U B R O U T I N E =======================================
|
extern @pellet_speed_raise$qi:proc
|
||||||
|
|
||||||
; Attributes: bp-based frame
|
|
||||||
|
|
||||||
sub_CBBE proc far
|
|
||||||
|
|
||||||
arg_0 = word ptr 6
|
|
||||||
arg_2 = word ptr 8
|
|
||||||
|
|
||||||
push bp
|
|
||||||
mov bp, sp
|
|
||||||
mov dx, [bp+arg_0]
|
|
||||||
les bx, _resident
|
|
||||||
cmp es:[bx+reiidenconfig_t.bullet_speed], dx
|
|
||||||
jle short loc_CBD4
|
|
||||||
mov es:[bx+reiidenconfig_t.bullet_speed], dx
|
|
||||||
jmp short loc_CBDF
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
loc_CBD4:
|
|
||||||
les bx, _resident
|
|
||||||
mov ax, [bp+arg_2]
|
|
||||||
add es:[bx+reiidenconfig_t.bullet_speed], ax
|
|
||||||
|
|
||||||
loc_CBDF:
|
|
||||||
les bx, _resident
|
|
||||||
cmp es:[bx+reiidenconfig_t.bullet_speed], -15
|
|
||||||
jge short loc_CBF0
|
|
||||||
mov es:[bx+reiidenconfig_t.bullet_speed], -15
|
|
||||||
|
|
||||||
loc_CBF0:
|
|
||||||
pop bp
|
|
||||||
retf
|
|
||||||
sub_CBBE endp
|
|
||||||
|
|
||||||
|
|
||||||
; =============== S U B R O U T I N E =======================================
|
|
||||||
|
|
||||||
; Attributes: bp-based frame
|
|
||||||
|
|
||||||
sub_CBF2 proc far
|
|
||||||
|
|
||||||
arg_0 = word ptr 6
|
|
||||||
|
|
||||||
push bp
|
|
||||||
mov bp, sp
|
|
||||||
les bx, _resident
|
|
||||||
mov ax, [bp+arg_0]
|
|
||||||
add es:[bx+reiidenconfig_t.bullet_speed], ax
|
|
||||||
cmp es:[bx+reiidenconfig_t.bullet_speed], 20
|
|
||||||
jle short loc_CC0D
|
|
||||||
mov es:[bx+reiidenconfig_t.bullet_speed], 20
|
|
||||||
|
|
||||||
loc_CC0D:
|
|
||||||
pop bp
|
|
||||||
retf
|
|
||||||
sub_CBF2 endp
|
|
||||||
|
|
||||||
|
|
||||||
; =============== S U B R O U T I N E =======================================
|
; =============== S U B R O U T I N E =======================================
|
||||||
|
|
||||||
|
@ -1390,9 +1333,7 @@ loc_CD2E:
|
||||||
mov al, es:[bx+reiidenconfig_t.start_lives_extra]
|
mov al, es:[bx+reiidenconfig_t.start_lives_extra]
|
||||||
add al, 2
|
add al, 2
|
||||||
mov es:[bx+reiidenconfig_t.rem_lives], al
|
mov es:[bx+reiidenconfig_t.rem_lives], al
|
||||||
push 0FFFBFFFEh
|
call @pellet_speed_lower$qii c, large (-2 and 0FFFFh) or (-5 shl 16)
|
||||||
call sub_CBBE
|
|
||||||
add sp, 4
|
|
||||||
|
|
||||||
loc_CD52:
|
loc_CD52:
|
||||||
call _input_sense stdcall, 0
|
call _input_sense stdcall, 0
|
||||||
|
@ -1717,8 +1658,7 @@ sub_D02F proc far
|
||||||
push 0Fh
|
push 0Fh
|
||||||
call _mdrv2_se_play
|
call _mdrv2_se_play
|
||||||
pop cx
|
pop cx
|
||||||
push 1
|
call @pellet_speed_raise$qi stdcall, 1
|
||||||
call sub_CBF2
|
|
||||||
pop cx
|
pop cx
|
||||||
|
|
||||||
loc_D076:
|
loc_D076:
|
||||||
|
@ -3059,8 +2999,7 @@ loc_DC64:
|
||||||
div ebx
|
div ebx
|
||||||
cmp edx, 0
|
cmp edx, 0
|
||||||
jnz short loc_DC9D
|
jnz short loc_DC9D
|
||||||
push 1
|
call @pellet_speed_raise$qi stdcall, 1
|
||||||
call sub_CBF2
|
|
||||||
pop cx
|
pop cx
|
||||||
|
|
||||||
loc_DC9D:
|
loc_DC9D:
|
||||||
|
@ -6368,8 +6307,7 @@ sub_1938A proc far
|
||||||
call sub_192D6
|
call sub_192D6
|
||||||
cmp _stage_timer, 0
|
cmp _stage_timer, 0
|
||||||
jnz short loc_193B8
|
jnz short loc_193B8
|
||||||
push 2
|
call @pellet_speed_raise$qi stdcall, 2
|
||||||
call sub_CBF2
|
|
||||||
pop cx
|
pop cx
|
||||||
nopcall @harryup_animate$qv
|
nopcall @harryup_animate$qv
|
||||||
pop bp
|
pop bp
|
||||||
|
@ -6581,8 +6519,7 @@ loc_19FB0:
|
||||||
jz short loc_19FDB
|
jz short loc_19FDB
|
||||||
mov byte_35B46, 2
|
mov byte_35B46, 2
|
||||||
mov _input_bomb, 0
|
mov _input_bomb, 0
|
||||||
push 1
|
call @pellet_speed_raise$qi stdcall, 1
|
||||||
call sub_CBF2
|
|
||||||
jmp loc_1AC29
|
jmp loc_1AC29
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -8450,13 +8387,7 @@ loc_1B01F:
|
||||||
|
|
||||||
loc_1B028:
|
loc_1B028:
|
||||||
call sub_193BA
|
call sub_193BA
|
||||||
|
call @pellet_speed_lower$qii c, large 0 or (-2 shl 16)
|
||||||
loc_1B02D:
|
|
||||||
push 0FFFE0000h
|
|
||||||
|
|
||||||
loc_1B033:
|
|
||||||
call sub_CBBE
|
|
||||||
add sp, 4
|
|
||||||
pop di
|
pop di
|
||||||
pop si
|
pop si
|
||||||
leave
|
leave
|
||||||
|
|
Loading…
Reference in New Issue