diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc19c41e..678624bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/Research/Borland C++ decompilation.md b/Research/Borland C++ decompilation.md index 84b7b6f8..f6e8aed2 100644 --- a/Research/Borland C++ decompilation.md +++ b/Research/Borland C++ decompilation.md @@ -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]`
`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]`
`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]`
`ADD AL, imm8`
`MOV [m8], AL` | Opposite; *not* an inlined function | | `CWD`
`SUB AX, DX`
`SAR AX, 1` | `AX / 2`, `AX` is *int* | | `MOV [new_var], AX`
`CWD`
`XOR AX, DX`
`SUB AX, DX` | `abs(AX)`, defined in ``. `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); } diff --git a/decomp.hpp b/decomp.hpp index 3a70ce8b..d09ea73d 100644 --- a/decomp.hpp +++ b/decomp.hpp @@ -152,7 +152,7 @@ inline void poked_eax(Decomp_GS *sgm, Decomp_DI *off, uint8_t op) { template inline T keep_0(T x) { if(x == 0) { extern void *near address_0; - return reinterpret_cast(&address_0); + return reinterpret_cast(&address_0); } return x; } diff --git a/th01/end/end.cpp b/th01/end/end.cpp index 36e59e13..c676b027 100644 --- a/th01/end/end.cpp +++ b/th01/end/end.cpp @@ -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); diff --git a/th01/formats/scoredat.hpp b/th01/formats/scoredat.hpp index 26cbefc1..0cf49aab 100644 --- a/th01/formats/scoredat.hpp +++ b/th01/formats/scoredat.hpp @@ -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) diff --git a/th01/hardware/graph.cpp b/th01/hardware/graph.cpp index 980d1604..4cd1c6d4 100644 --- a/th01/hardware/graph.cpp +++ b/th01/hardware/graph.cpp @@ -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 { diff --git a/th01/hardware/graph.h b/th01/hardware/graph.h index 25220814..6928cca2 100644 --- a/th01/hardware/graph.h +++ b/th01/hardware/graph.h @@ -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 ); diff --git a/th01/hardware/grp2xscs.hpp b/th01/hardware/grp2xscs.hpp index 7eb67f37..a6015da0 100644 --- a/th01/hardware/grp2xscs.hpp +++ b/th01/hardware/grp2xscs.hpp @@ -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 diff --git a/th01/hardware/palette.h b/th01/hardware/palette.h index e1cc6a81..1242c8f8 100644 --- a/th01/hardware/palette.h +++ b/th01/hardware/palette.h @@ -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); diff --git a/th01/hardware/tram_x16.hpp b/th01/hardware/tram_x16.hpp index aaeb84e5..549cfa4f 100644 --- a/th01/hardware/tram_x16.hpp +++ b/th01/hardware/tram_x16.hpp @@ -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); diff --git a/th01/main/boss/b15j.cpp b/th01/main/boss/b15j.cpp index 1b2cd01f..070f8543 100644 --- a/th01/main/boss/b15j.cpp +++ b/th01/main/boss/b15j.cpp @@ -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 diff --git a/th01/main/boss/b15m.cpp b/th01/main/boss/b15m.cpp index 2d0ef9ae..b6f1e17e 100644 --- a/th01/main/boss/b15m.cpp +++ b/th01/main/boss/b15m.cpp @@ -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(), diff --git a/th01/main/boss/b20j.cpp b/th01/main/boss/b20j.cpp index 32362024..4bb926aa 100644 --- a/th01/main/boss/b20j.cpp +++ b/th01/main/boss/b20j.cpp @@ -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(); diff --git a/th01/main/boss/b20m.cpp b/th01/main/boss/b20m.cpp index 635b4627..43d636c9 100644 --- a/th01/main/boss/b20m.cpp +++ b/th01/main/boss/b20m.cpp @@ -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; diff --git a/th01/main/boss/boss.hpp b/th01/main/boss/boss.hpp index c8ec944a..68059242 100644 --- a/th01/main/boss/boss.hpp +++ b/th01/main/boss/boss.hpp @@ -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; diff --git a/th01/main/boss/defeat.cpp b/th01/main/boss/defeat.cpp index e12ebb7b..62412c7e 100644 --- a/th01/main/boss/defeat.cpp +++ b/th01/main/boss/defeat.cpp @@ -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 \ ) \ diff --git a/th01/main/boss/entity_a.hpp b/th01/main/boss/entity_a.hpp index ff679495..bb41f0f5 100644 --- a/th01/main/boss/entity_a.hpp +++ b/th01/main/boss/entity_a.hpp @@ -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 struct CBossEntitySized : public CBossEntity { pixel_t w_static() const { diff --git a/th01/main/boss/hit.cpp b/th01/main/boss/hit.cpp index 4b382458..56c66269 100644 --- a/th01/main/boss/hit.cpp +++ b/th01/main/boss/hit.cpp @@ -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; diff --git a/th01/main/boss/palette.cpp b/th01/main/boss/palette.cpp index 96521b41..128692c4 100644 --- a/th01/main/boss/palette.cpp +++ b/th01/main/boss/palette.cpp @@ -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) diff --git a/th01/main/boss/palette.hpp b/th01/main/boss/palette.hpp index 8d3ab8cb..8c8d8d74 100644 --- a/th01/main/boss/palette.hpp +++ b/th01/main/boss/palette.hpp @@ -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); diff --git a/th01/main/bullet/laser_s.hpp b/th01/main/bullet/laser_s.hpp index 20dedbe2..c936a686 100644 --- a/th01/main/bullet/laser_s.hpp +++ b/th01/main/bullet/laser_s.hpp @@ -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]. diff --git a/th01/main/hud/hud.hpp b/th01/main/hud/hud.hpp index acc6423a..2c176c26 100644 --- a/th01/main/hud/hud.hpp +++ b/th01/main/hud/hud.hpp @@ -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 diff --git a/th01/main/stage/timer.cpp b/th01/main/stage/timer.cpp index 00e1e4a5..63b1d172 100644 --- a/th01/main/stage/timer.cpp +++ b/th01/main/stage/timer.cpp @@ -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++; } diff --git a/th01/main_01.cpp b/th01/main_01.cpp index 0f51774c..8fc71db2 100644 --- a/th01/main_01.cpp +++ b/th01/main_01.cpp @@ -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); diff --git a/th02/op_01.cpp b/th02/op_01.cpp index 324473fd..62250a32 100644 --- a/th02/op_01.cpp +++ b/th02/op_01.cpp @@ -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; } diff --git a/th04/main/gather.cpp b/th04/main/gather.cpp index 5b492721..402bbf90 100644 --- a/th04/main/gather.cpp +++ b/th04/main/gather.cpp @@ -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; diff --git a/th05/main/boss/render.cpp b/th05/main/boss/render.cpp index 93aac573..492564c4 100644 --- a/th05/main/boss/render.cpp +++ b/th05/main/boss/render.cpp @@ -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) diff --git a/th05/main/player/bombanim.cpp b/th05/main/player/bombanim.cpp index 9ee328be..b470b45f 100644 --- a/th05/main/player/bombanim.cpp +++ b/th05/main/player/bombanim.cpp @@ -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]