[Maintenance] Fix another bunch of accumulated typos and dead code

Part of P0216, funded by JonathKane.
This commit is contained in:
nmlgc 2022-08-15 12:53:06 +02:00
parent 3123c9d3fd
commit 690b4df14b
28 changed files with 51 additions and 64 deletions

View File

@ -21,9 +21,10 @@ actual intent will already be helpful. *Any* name is better than
## Rule #1
**`master` must never introduce code changes that change the decompressed
program image, or the unordered set of relocations, of any original game
binary, as compared using [mzdiff].** The only allowed exceptions are:
**`master` must never introduce code that changes the decompressed program
image, or the unordered set of relocations, of any original game binary, as
compared using [mzdiff].** The only allowed exceptions are:
1) different encodings of identical x86 instructions within code segments
2) padding with `00` bytes at the end of the file.
@ -281,7 +282,7 @@ These cases should gradually be removed as development goes along, though.
here" or "this code would read really nicely if this functionality was
encapsulated in a method". (Sometimes, you will have little choice, in
fact!) Despite Turbo C++'s notoriously outdated C++ implementation, [there
are quite a lot of possibilites for abstractions that inline perfectly][1].
are quite a lot of possibilities for abstractions that inline perfectly][1].
Subpixels, as seen in 9d121c7, are the prime example here. Don't overdo it,
though use classes where they meaningfully enhance the original procedural
code, not to replace it with an overly nested, "enterprise-y" class

View File

@ -41,7 +41,7 @@ where the scalar-type variable is declared in relation to them.
| | |
|-|-|
| `ADD [m8], imm8` | Only achievable through a C++ method operating on a member? |
| `MOV AX, [m16]`<br />`ADD AL, [m8]` | Same `m[16]` must be returned from an inlined function to avoid the optimization of it being directly shortened to 8 bits. |
| `MOV AX, [m16]`<br />`ADD AL, [m8]` | Same `[m16]` must be returned from an inlined function to avoid the optimization of it being directly shortened to 8 bits. |
| `MOV AL, [m8]`<br />`ADD AL, imm8`<br />`MOV [m8], AL` | Opposite; *not* an inlined function |
| `CWD`<br />`SUB AX, DX`<br />`SAR AX, 1` | `AX / 2`, `AX` is *int* |
| `MOV [new_var], AX`<br />`CWD`<br />`XOR AX, DX`<br />`SUB AX, DX` | `abs(AX)`, defined in `<stdlib.h>`. `AX` is *int* |
@ -527,8 +527,8 @@ Inhibited by:
// Second declaration of [v]. Even though it's assigned to the same stack
// offset, the second `PUSH c` call will still be emitted separately.
// Thus, jump optimization only reuses the `CALL use` instruction.
// Move the `int v;` declaraion to the beginning of the function to avoid
// this.
// Move the `int v;` declaration to the beginning of the function to
// avoid this.
int v = set_v();
use(v);
}

View File

@ -152,7 +152,7 @@ inline void poked_eax(Decomp_GS *sgm, Decomp_DI *off, uint8_t op) {
template <class T> inline T keep_0(T x) {
if(x == 0) {
extern void *near address_0;
return reinterpret_cast<pixel_t>(&address_0);
return reinterpret_cast<T>(&address_0);
}
return x;
}

View File

@ -496,7 +496,7 @@ void verdict_title_calculate_and_render(void)
else if(skill >= 40) { level = 3; }
else if(skill >= 20) { level = 2; }
else if(skill >= 0) { level = 1; }
else /* */ { level = 0; }
else /* */ { level = 0; }
graph_printf_fx(
(VERDICT_LEFT - VERDICT_TITLE_LEFT_OFFSET + VERDICT_TITLE_PADDED_W),
@ -534,7 +534,7 @@ void verdict_animate_and_regist(void)
verdict_line_render1(2, VERDICT_RANK"%s", RANKS[rank]);
// Should really all be %10lu (with the superflous right-padding removed
// Should really all be %10lu (with the superfluous right-padding removed
// from the strings) if you're already using `long`s here. Scoreplayers
// can definitely reach 8 digits.
verdict_line_render1(3, VERDICT_SCORE_HIGHEST"%7lu", score_highest);

View File

@ -1,7 +1,8 @@
#define SCOREDAT_MAGIC "HISCORE"
#define SCOREDAT_PLACES 10
#define SCOREDAT_NAME_KANJI 8
// Actually creates slightly different assembly compared to sizeof() on a
// Actually creates slightly different assembly compared to sizeof() on an
// int8_t array!
#define SCOREDAT_NAME_BYTES (SCOREDAT_NAME_KANJI * 2)
#define SCOREDAT_NAMES_SIZE (SCOREDAT_PLACES * SCOREDAT_NAME_BYTES)

View File

@ -248,9 +248,9 @@ void z_palette_set_all_show(const Palette4& pal)
void z_palette_set_show(int col, int r, int g, int b)
{
r = clamp_min(clamp_max(r, RGB4::max()), 0);
g = clamp_min(clamp_max(g, RGB4::max()), 0);
b = clamp_min(clamp_max(b, RGB4::max()), 0);
r = clamp_min(clamp_max(r, RGB4::max()), RGB4::min());
g = clamp_min(clamp_max(g, RGB4::max()), RGB4::min());
b = clamp_min(clamp_max(b, RGB4::max()), RGB4::min());
z_Palettes[col].c.r = r;
z_Palettes[col].c.g = g;
@ -937,7 +937,7 @@ void z_palette_fade_from(
#define RESPAL_ID "pal98 grb"
// MASTER.MAN suggests that GBR ordering is some sort of standard on PC-98.
// MASTER.MAN suggests that GRB ordering is some sort of standard on PC-98.
// It does match the order of the hardware's palette register ports, after
// all. (0AAh = green, 0ACh = red, 0AEh = blue)
struct grb_t {

View File

@ -133,7 +133,7 @@ void graph_putfwnum_fx(
// to
// (⌊left/8⌋*8 + ⌊(right-left)/8⌋*8, bottom)
// from the VRAM page that was previously set as the accessed one via a call
// to graph_accesspage_func() to the same position on the opposite page.
// to graph_accesspage_func() to the same position on the opposite page.
void graph_copy_byterect_from_accessed_page_to_other(
screen_x_t left, vram_y_t top, screen_x_t right, vram_y_t bottom
);

View File

@ -1,9 +1,9 @@
// Performs a very slow, unoptimized, 2× nearest-neighbor scale of the
// rectangle from
// (⌊left_1/8⌋*8, top_1) - (⌊left_1/8⌋*8 + ⌊w_1/16⌋*16, top_1 + h_1)
// on plane #1 to
// on VRAM page 1 to
// (⌊left_0/8⌋*8, top_0) - (⌊left_1/8⌋*8 + ⌊w_1/16⌋*32, top_1 + h_1*2)
// on plane #0.
// on VRAM page 0.
void graph_2xscale_byterect_1_to_0_slow(
screen_x_t left_0, vram_y_t top_0,
screen_x_t left_1, vram_y_t top_1, pixel_t w_1, pixel_t h_1

View File

@ -40,7 +40,7 @@ void z_palette_black_in(void);
void z_palette_white_in(void);
// Fades all hardware colors from their value in z_Palettes to #000 or #FFF,
// without modifiying z_Palettes.
// without modifying z_Palettes.
void z_palette_black_out(void);
void z_palette_white_out(void);

View File

@ -40,7 +40,7 @@ public:
void putkanji_for_5_rows(jis_t jis_kanji, int atrb);
// This is always called at the (0-based) line 21, and therefore always
// ends up writing into the second TRAM page. Luckily, that page is used,
// ends up writing into the second TRAM page. Luckily, that page is unused,
// and no code cares about it...
void putkanji_until_end(jis_t jis_kanji, int atrb) {
putkanji_for_5_rows(jis_kanji, atrb);

View File

@ -189,7 +189,7 @@ void kikuri_load(void)
pellet_interlace = true;
Pellets.unknown_seven = 7;
palette_copy(boss_palette, z_Palettes, i, j);
palette_copy(boss_palette, z_Palettes, i, j); // = boss_palette_snap
for(i = 0; i < TEAR_COUNT; i++) {
tear_anim_frame[i] = 0;
@ -383,7 +383,7 @@ void pascal near ripple_update_and_render(
// code below does, by symmetrically moving out from the center to the
// left and right edges. But then, unblitting every successive ripple
// column by rounding its X coordinate down and up to the nearest word will
// also cause half of the previously drawn column to be unblitted. This is
// also cause half of the previously drawn column to be unblitted. This is
// exactly why most ripple animations show up with weird empty 8-pixel-wide
// stripes on the inside (→ non-word-aligned X positions), while some do
// show up fine (→ word-aligned X positions).
@ -1052,7 +1052,7 @@ entrance_rings_still_active:
}
z_palette_set_all_show(z_Palettes);
}
if(frame_half % 2) { // That's why we've renamed the variable
if(frame_half % 2) { // That's why we've renamed the variable
frame_delay(1);
}
#undef frame_half

View File

@ -48,11 +48,13 @@ static const pixel_t GIRL_H = 96;
static const pixel_t BAT_W = 48;
static const pixel_t BAT_H = 32;
static const pixel_t BASE_CENTER_X = PLAYFIELD_CENTER_X;
static const pixel_t BASE_CENTER_Y = (PLAYFIELD_TOP + ((PLAYFIELD_H / 21) * 5));
static const screen_x_t BASE_CENTER_X = PLAYFIELD_CENTER_X;
static const screen_y_t BASE_CENTER_Y = (
PLAYFIELD_TOP + ((PLAYFIELD_H / 21) * 5)
);
static const pixel_t BASE_LEFT = (BASE_CENTER_X - (GIRL_W / 2));
static const pixel_t BASE_TOP = (BASE_CENTER_Y - (GIRL_H / 2));
static const screen_x_t BASE_LEFT = (BASE_CENTER_X - (GIRL_W / 2));
static const screen_y_t BASE_TOP = (BASE_CENTER_Y - (GIRL_H / 2));
// -----------
enum elis_colors_t {
@ -770,7 +772,7 @@ int pattern_11_lasers_across(void)
(((boss_phase_frame - 70) / INTERVAL) * (PLAYFIELD_W / 10))
);
}
target_y = RES_Y;
target_y = PLAYFIELD_BOTTOM;
shootout_laser_safe(boss_phase_frame / INTERVAL).spawn(
girl_lefteye_x(),
girl_lefteye_y(),

View File

@ -44,7 +44,7 @@
#include "th01/main/bullet/laser_s.hpp"
#include "th01/main/hud/hp.hpp"
static const char* unused_entrace_letters_maybe[] = { "ANGEL", "OF", "DEATH" };
static const char* unused_entrance_letters_maybe[] = { "ANGEL", "OF", "DEATH" };
// Coordinates
// -----------
@ -513,7 +513,7 @@ void konngara_setup(void)
face_direction = FD_CENTER;
}
// Happens to be entirely protected to double frees. Yes, this matters.
// Happens to be entirely protected from double frees. Yes, this matters.
void konngara_free(void)
{
konngara_ent_free();

View File

@ -1975,8 +1975,8 @@ void near pattern_vertical_stacks_from_bottom_then_random_rain_from_top(void)
PLAYFIELD_CENTER_X, FACE_CENTER_Y, (DEBRIS_W / 4)
> rays;
// ZUN bug: Leaving this uninitalized indeed implies vortex sprites for the
// first 5 frames, until this actually reaches C_DEBRIS...
// ZUN bug: Leaving this uninitialized indeed implies vortex sprites for
// the first 5 frames, until this actually reaches C_DEBRIS...
static vortex_or_debris_cel_t debris_cel;
unsigned char angle;

View File

@ -80,7 +80,7 @@ enum boss_id_t {
};
static const pixel_t SINGYOKU_W = 96;
// Actually required publically, as singyoku_defeat_animate_and_select_route()
// Actually required publicly, as singyoku_defeat_animate_and_select_route()
// is part of the regular boss defeat translation unit.
static const pixel_t SINGYOKU_H = 96;

View File

@ -38,13 +38,6 @@ void grcg_whiteline(screen_y_t y)
grcg_off();
}
struct defeat_anim_t {
int frame;
int components_done;
screen_y_t bottom;
screen_y_t top;
};
#define defeat_animate( \
start_y, line_distance, whiteout_interval, whitein_interval \
) \

View File

@ -366,7 +366,7 @@ public:
// boilerplate coordinate functions.
//
// (Due to CBossEntity unfortunately having a non-inlined default constructor,
// we can't ever directly declare instance of this template without emitting
// we can't ever directly declare instances of this template without emitting
// another constructor for this class.)
template <pixel_t W, pixel_t H> struct CBossEntitySized : public CBossEntity {
pixel_t w_static() const {

View File

@ -87,7 +87,7 @@ void boss_hit_update_and_render(
// *this* as a wild unexpected palette change from out of nowhere.
//
// (For examples, see Mima's pattern_hop_and_fire_chase_pellets(), and
// Konngara's konngara_load_and_entrance())
// Konngara's konngara_load_and_entrance().)
boss_palette_show();
invincibility_frame = 0;

View File

@ -6,7 +6,9 @@
void boss_palette_snap(void)
{
boss_palette_snap_inlined();
int col;
int comp;
palette_copy(boss_palette, z_Palettes, col, comp);
}
void boss_palette_show(void)

View File

@ -3,12 +3,6 @@
// MODDERS: Merge with the [stage_palette].
extern Palette4 boss_palette;
#define boss_palette_snap_inlined() { \
int col; \
int comp; \
palette_copy(boss_palette, z_Palettes, col, comp); \
}
// Overwrites [boss_palette] with [z_Palettes].
void boss_palette_snap(void);

View File

@ -2,7 +2,7 @@ static const int SHOOTOUT_LASER_COUNT = 10;
/// Q24.8 fixed-point format
/// ------------------------
/// This format matches the precision of master.lib's [SinTable8] and
// This format matches the precision of master.lib's [SinTable8] and
// [CosTable8] lookup tables, and directly maps its values to the range of
// [-1.0, +1.0].

View File

@ -27,8 +27,8 @@ void hud_lives_put(int prev);
void hud_bombs_put(int prev);
/// Background
/// ----------
// Loads the first plane from the .GRF file with the given [fn] into [hud_bg],
// and sets [hud_bg_size] to its size in bytes. Always returns 0.
// (The "caller" is "supposed" to delete[] [hud_bg]… which the original game

View File

@ -171,8 +171,8 @@ void harryup_animate(void)
for(i = 0; i < 5; i++) {
tram_x16_row_put_red(row, tram_cursor, x, glyphs[i].byte[glyph_y]);
}
// 5 halfwidth glyphs scaled a factor of 16 just happen to exactly fit
// into one TRAM row, so we're already at the next one here.
// 5 halfwidth glyphs scaled by a factor of 16 just happen to exactly
// fit into one TRAM row, so we're already at the next one here.
glyph_y++;
}

View File

@ -300,8 +300,8 @@ void pascal stage_num_animate(unsigned int stage_num)
for(i = 0; i < 5; i++) {
tram_x16_row_put_red(row, tram_cursor, x, glyphs[i].byte[glyph_y]);
}
// 5 halfwidth glyphs scaled a factor of 16 just happen to exactly fit
// into one TRAM row, so we're already at the next one here.
// 5 halfwidth glyphs scaled by a factor of 16 just happen to exactly
// fit into one TRAM row, so we're already at the next one here.
glyph_y++;
}
tram_cursor.putkanji_until_end(' ', TX_BLACK);

View File

@ -532,7 +532,7 @@ inline void option_quit(bool &initialized) {
initialized = false;
}
// Circumventing 16-bit promition inside comparisons between two 8-bit values
// Circumventing 16-bit promotion inside comparisons between two 8-bit values
// in Borland C++'s C++ mode...
inline char option_rank_max() { return RANK_LUNATIC; }
inline char option_bgm_max() { return SND_BGM_MIDI; }

View File

@ -15,10 +15,6 @@ extern "C" {
#include "th04/main/bullet/bullet.hpp"
#include "th04/main/gather.hpp"
inline void far* bullet_template_as_ptr(void) {
return &bullet_template;
}
void pascal near set_bullet_template_to_gather_template(gather_t near &gather)
{
// MODDERS: bullet_template = gather.bullet_template;

View File

@ -728,8 +728,6 @@ void near exalice_hexagrams_update_and_render(void)
}
exalice_grcg_hexagram_put(set.radius[0].v, set.angle[0]);
grcg_off();
#undef state
}
void pascal near exalice_bg_render(void)

View File

@ -153,10 +153,10 @@ void pascal near reimu_stars_update_and_render(void)
trail += ((REIMU_STAR_NODE_COUNT - 1) - 2);
// trail == [6 | 14 | 22 | 30 | 38 | 46]
/* */ reimu_star_put(trail, 6);
/* */ reimu_star_put(trail, 6);
trail -= 2; reimu_star_put(trail, 6);
trail -= 2; reimu_star_put(trail, 6);
/* */ reimu_star_put(head, 7);
/* */ reimu_star_put(head, 7);
// trail == [2 | 10 | 18 | 26 | 34 | 42]