mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Add a new typedef for unsigned Q4.4 values
Part of P0185, funded by [Anonymous], -Tom-, and Blue Bolt.
This commit is contained in:
parent
3850f8aafb
commit
360e07a413
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#define PIXEL_NONE (-999)
|
#define PIXEL_NONE (-999)
|
||||||
|
|
||||||
|
typedef uint8_t subpixel_length_8_t;
|
||||||
typedef int subpixel_t;
|
typedef int subpixel_t;
|
||||||
|
|
||||||
static const subpixel_t SUBPIXEL_FACTOR = 16;
|
static const subpixel_t SUBPIXEL_FACTOR = 16;
|
||||||
|
@ -24,8 +25,8 @@ inline subpixel_t to_sp(float pixel_v) {
|
||||||
return static_cast<subpixel_t>(pixel_v * SUBPIXEL_FACTOR);
|
return static_cast<subpixel_t>(pixel_v * SUBPIXEL_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char to_sp8(float pixel_v) {
|
inline subpixel_length_8_t to_sp8(float pixel_v) {
|
||||||
return static_cast<unsigned char>(to_sp(pixel_v));
|
return static_cast<subpixel_length_8_t>(to_sp(pixel_v));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class SubpixelType, class PixelType> class SubpixelBase {
|
template <class SubpixelType, class PixelType> class SubpixelBase {
|
||||||
|
@ -100,6 +101,6 @@ struct SPPoint : public SPPointBase<Subpixel> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 8-bit (Q4.4)
|
// 8-bit (Q4.4)
|
||||||
typedef SubpixelBase<unsigned char, unsigned char> SubpixelLength8;
|
typedef SubpixelBase<subpixel_length_8_t, subpixel_length_8_t> SubpixelLength8;
|
||||||
typedef SubpixelBase<char, char> Subpixel8;
|
typedef SubpixelBase<char, char> Subpixel8;
|
||||||
typedef SPPointBase<Subpixel8> SPPoint8;
|
typedef SPPointBase<Subpixel8> SPPoint8;
|
||||||
|
|
|
@ -21,7 +21,7 @@ void near tune_for_easy(void)
|
||||||
switch(tmpl.group) {
|
switch(tmpl.group) {
|
||||||
case BG_STACK:
|
case BG_STACK:
|
||||||
case BG_STACK_AIMED:
|
case BG_STACK_AIMED:
|
||||||
tmpl.delta.stack_speed -= (tmpl.delta.stack_speed / 4);
|
tmpl.delta.stack_speed.v -= (tmpl.delta.stack_speed.v / 4);
|
||||||
if(tmpl.count >= 2) {
|
if(tmpl.count >= 2) {
|
||||||
tmpl.count--;
|
tmpl.count--;
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,17 @@ void near tune_for_hard(void)
|
||||||
case BG_SINGLE_AIMED:
|
case BG_SINGLE_AIMED:
|
||||||
tmpl.group = BG_STACK_AIMED;
|
tmpl.group = BG_STACK_AIMED;
|
||||||
tmpl.count = 2;
|
tmpl.count = 2;
|
||||||
tmpl.delta.stack_speed = to_sp(0.375f);
|
tmpl.delta.stack_speed.set(0.375f);
|
||||||
break;
|
break;
|
||||||
case BG_SINGLE:
|
case BG_SINGLE:
|
||||||
tmpl.group = BG_STACK;
|
tmpl.group = BG_STACK;
|
||||||
tmpl.count = 2;
|
tmpl.count = 2;
|
||||||
tmpl.delta.stack_speed = to_sp(0.375f);
|
tmpl.delta.stack_speed.set(0.375f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BG_STACK:
|
case BG_STACK:
|
||||||
case BG_STACK_AIMED:
|
case BG_STACK_AIMED:
|
||||||
tmpl.delta.stack_speed += (tmpl.delta.stack_speed / 2);
|
tmpl.delta.stack_speed.v += (tmpl.delta.stack_speed.v / 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BG_SPREAD:
|
case BG_SPREAD:
|
||||||
|
@ -98,7 +98,7 @@ void near tune_for_lunatic(void)
|
||||||
|
|
||||||
case BG_STACK:
|
case BG_STACK:
|
||||||
case BG_STACK_AIMED:
|
case BG_STACK_AIMED:
|
||||||
tmpl.delta.stack_speed += (tmpl.delta.stack_speed / 2);
|
tmpl.delta.stack_speed.v += (tmpl.delta.stack_speed.v / 2);
|
||||||
tmpl.count++;
|
tmpl.count++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void pascal near bullet_template_tune_lunatic(void)
|
||||||
|
|
||||||
void pascal near bullets_add_regular_easy(void)
|
void pascal near bullets_add_regular_easy(void)
|
||||||
{
|
{
|
||||||
unsigned char speed;
|
subpixel_length_8_t speed;
|
||||||
unsigned char count;
|
unsigned char count;
|
||||||
|
|
||||||
if(bullet_zap.active) {
|
if(bullet_zap.active) {
|
||||||
|
@ -202,7 +202,7 @@ void pascal near bullets_add_regular_easy(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void keep_speed_from_being_mutated_when_calling(nearfunc_t_near func) {
|
inline void keep_speed_from_being_mutated_when_calling(nearfunc_t_near func) {
|
||||||
unsigned char speed = bullet_template.speed.v;
|
subpixel_length_8_t speed = bullet_template.speed.v;
|
||||||
func();
|
func();
|
||||||
bullet_template.speed.v = speed;
|
bullet_template.speed.v = speed;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ void near bullets_add_special_fixedspeed(void)
|
||||||
bool16 pascal near bullet_velocity_and_angle_set(int group_i)
|
bool16 pascal near bullet_velocity_and_angle_set(int group_i)
|
||||||
{
|
{
|
||||||
int angle = 0x00;
|
int angle = 0x00;
|
||||||
unsigned char speed;
|
subpixel_length_8_t speed;
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
// Due to this default, invalid group values lead to the spawn functions
|
// Due to this default, invalid group values lead to the spawn functions
|
||||||
|
@ -550,7 +550,7 @@ void pascal near bullets_add_regular_raw(void)
|
||||||
bullet->flag = 1;
|
bullet->flag = 1;
|
||||||
bullet->move_state = static_cast<bullet_move_state_t>(move_state);
|
bullet->move_state = static_cast<bullet_move_state_t>(move_state);
|
||||||
bullet->ax.slowdown_time = BMS_SLOWDOWN_FRAMES;
|
bullet->ax.slowdown_time = BMS_SLOWDOWN_FRAMES;
|
||||||
bullet->dx.slowdown_speed_delta = (
|
bullet->dx.slowdown_speed_delta.v = (
|
||||||
to_sp8(BMS_SLOWDOWN_BASE_SPEED) - bullet_template.speed
|
to_sp8(BMS_SLOWDOWN_BASE_SPEED) - bullet_template.speed
|
||||||
);
|
);
|
||||||
bullet_init_from_template(bullet, group_done, group_i, spawn_state);
|
bullet_init_from_template(bullet, group_done, group_i, spawn_state);
|
||||||
|
|
|
@ -138,8 +138,8 @@ struct bullet_t {
|
||||||
union {
|
union {
|
||||||
// Difference between [speed_final] and the BMS_SLOWDOWN_BASE_SPEED.
|
// Difference between [speed_final] and the BMS_SLOWDOWN_BASE_SPEED.
|
||||||
// Always positive for BMS_SLOWDOWN bullets.
|
// Always positive for BMS_SLOWDOWN bullets.
|
||||||
unsigned char slowdown_speed_delta; // with BMS_SLOWDOWN
|
SubpixelLength8 slowdown_speed_delta; // with BMS_SLOWDOWN
|
||||||
bullet_special_angle_t angle; // with BMS_SPECIAL
|
bullet_special_angle_t angle; // with BMS_SPECIAL
|
||||||
} dx;
|
} dx;
|
||||||
int patnum;
|
int patnum;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
typedef union {
|
typedef union {
|
||||||
unsigned char spread_angle;
|
unsigned char spread_angle;
|
||||||
// In subpixels, obviously, but pre-C++11 doesn't let us use any of the
|
SubpixelLength8 stack_speed;
|
||||||
// Subpixel classes with their custom assignment operators in a union...
|
|
||||||
unsigned char stack_speed;
|
|
||||||
} bullet_template_delta_t;
|
} bullet_template_delta_t;
|
||||||
|
|
||||||
// All _AIMED groups define the 0° [angle] as the current player position,
|
// All _AIMED groups define the 0° [angle] as the current player position,
|
||||||
|
|
|
@ -309,7 +309,7 @@ void bullets_update(void)
|
||||||
} else if(bullet->move_state == BMS_SLOWDOWN) {
|
} else if(bullet->move_state == BMS_SLOWDOWN) {
|
||||||
bullet->ax.slowdown_time--;
|
bullet->ax.slowdown_time--;
|
||||||
bullet->speed_cur.v = (bullet->speed_final.v + ((
|
bullet->speed_cur.v = (bullet->speed_final.v + ((
|
||||||
bullet->ax.slowdown_time * bullet->dx.slowdown_speed_delta
|
bullet->ax.slowdown_time * bullet->dx.slowdown_speed_delta.v
|
||||||
) / BMS_SLOWDOWN_FRAMES));
|
) / BMS_SLOWDOWN_FRAMES));
|
||||||
if(bullet->ax.slowdown_time == 0) {
|
if(bullet->ax.slowdown_time == 0) {
|
||||||
bullet->speed_cur = bullet->speed_final;
|
bullet->speed_cur = bullet->speed_final;
|
||||||
|
|
|
@ -50,7 +50,7 @@ clipped:
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!group_fixedspeed) {
|
if(!group_fixedspeed) {
|
||||||
bullet_template.speed = playperf_speedtune(bullet_template.speed);
|
bullet_template.speed.v = playperf_speedtune(bullet_template.speed.v);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "th04/main/playperf.hpp"
|
#include "th04/main/playperf.hpp"
|
||||||
|
|
||||||
// Returns [speed] tuned based on [playperf].
|
// Returns [speed] tuned based on [playperf].
|
||||||
SubpixelLength8 __fastcall near playperf_speedtune(unsigned char speed);
|
subpixel_length_8_t __fastcall near playperf_speedtune(
|
||||||
|
subpixel_length_8_t speed
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue