diff --git a/Makefile.mak b/Makefile.mak index 7cca29f2..8a4206b7 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -48,7 +48,7 @@ bin\th01\op.exe: bin\piloadc.obj bin\th01\opd.obj th01\op_01.cpp bin\th01\op.obj $** | -bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiidend.obj th01\main_01.cpp bin\th01\reiiden.obj bin\th01\frmdelay.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj bin\th01\vplanset.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\f_imgd.obj bin\th01\grz.obj bin\th01\reiidenm.obj th01\main_09.cpp th01\bullet_l.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\scrollup.cpp th01\egcrows.cpp th01\pgtrans.cpp th01\2x_main.cpp th01\egcwave.cpp th01\grph1to0.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_17.cpp th01\main_18.cpp th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp bin\th01\pf.obj th01\main_23.cpp th01\main_24.cpp th01\main_25.cpp th01\main_26.cpp th01\main_27.cpp th01\main_28.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp +bin\th01\reiiden.exe: bin\piloadc.obj th01\main_var.cpp th01\main_01.cpp bin\th01\reiiden.obj bin\th01\frmdelay.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj bin\th01\vplanset.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\f_imgd.obj bin\th01\grz.obj bin\th01\reiidenm.obj th01\main_09.cpp th01\bullet_l.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\scrollup.cpp th01\egcrows.cpp th01\pgtrans.cpp th01\2x_main.cpp th01\egcwave.cpp th01\grph1to0.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_17.cpp th01\main_18.cpp th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp bin\th01\pf.obj th01\main_23.cpp th01\main_24.cpp th01\main_25.cpp th01\main_26.cpp th01\main_27.cpp th01\main_28.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp $(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -d -DGAME=1 -DBINARY='M' -nbin\th01\ -eREIIDEN.EXE @&&| $** | diff --git a/Tupfile b/Tupfile index cf1ea5ae..96e3d102 100644 --- a/Tupfile +++ b/Tupfile @@ -65,7 +65,6 @@ BMP2ARR = bin\\Pipeline\\bmp2arr.exe : th01_op_data.asm |> !as |> bin\\th01\\opd.obj : th01_op.asm |> !as |> bin\\th01\\op.obj : th01_op_master.asm |> !as |> bin\\th01\\opm.obj -: th01_reiiden_data.asm |> !as |> bin\\th01\\reiidend.obj : th01_reiiden.asm |> !as |> bin\\th01\\reiiden.obj : th01_reiiden_master.asm |> !as |> bin\\th01\\reiidenm.obj : th01_fuuin.asm |> !as |> bin\\th01\\fuuin.obj diff --git a/Tupfile.bat b/Tupfile.bat index 66bb307f..93127c07 100644 --- a/Tupfile.bat +++ b/Tupfile.bat @@ -28,7 +28,6 @@ tasm32 /m /mx /kh32768 /t zuncom\cstmstub.asm bin\zuncom\cstmstub.obj tasm32 /m /mx /kh32768 /t th01_op_data.asm bin\th01\opd.obj tasm32 /m /mx /kh32768 /t th01_op.asm bin\th01\op.obj tasm32 /m /mx /kh32768 /t th01_op_master.asm bin\th01\opm.obj -tasm32 /m /mx /kh32768 /t th01_reiiden_data.asm bin\th01\reiidend.obj tasm32 /m /mx /kh32768 /t th01_reiiden.asm bin\th01\reiiden.obj tasm32 /m /mx /kh32768 /t th01_reiiden_master.asm bin\th01\reiidenm.obj tasm32 /m /mx /kh32768 /t th01_fuuin.asm bin\th01\fuuin.obj diff --git a/th01/hiscore/hiscore[bss].asm b/th01/hiscore/hiscore[bss].asm deleted file mode 100644 index d01b8490..00000000 --- a/th01/hiscore/hiscore[bss].asm +++ /dev/null @@ -1,8 +0,0 @@ -public _scoredat_names, _scoredat_routes, _scoredat_stages, _scoredat_score -public _entered_name_left, _entered_name_top -_scoredat_names dd ? -_scoredat_routes dd ? -_scoredat_stages dd ? -_entered_name_left dw ? -_entered_name_top dw ? -_scoredat_score dd ? diff --git a/th01/main/bullet/pellets[bss].asm b/th01/main/bullet/pellets[bss].asm deleted file mode 100644 index 07e73bb0..00000000 --- a/th01/main/bullet/pellets[bss].asm +++ /dev/null @@ -1,66 +0,0 @@ -PELLET_COUNT = 100 - -PM_REGULAR = 0 -PM_GRAVITY = 1 -PM_SLING_AIMED = 2 -PM_BOUNCE_FROM_TOP_THEN_GRAVITY = 3 -PM_FALL_STRAIGHT_FROM_TOP_THEN_REGULAR = 4 -PM_SPIN = 5 -PM_CHASE = 6 - -PG_NONE = 0 -PG_1 = 1 -PG_1_AIMED = 12 -PG_2_SPREAD_WIDE = 13 -PG_2_SPREAD_NARROW = 14 -PG_3_SPREAD_WIDE = 15 -PG_3_SPREAD_NARROW = 16 -PG_4_SPREAD_WIDE = 17 -PG_4_SPREAD_NARROW = 18 -PG_5_SPREAD_WIDE = 19 -PG_5_SPREAD_NARROW = 20 -PG_AIMED_SPREADS = 21 -PG_2_SPREAD_WIDE_AIMED = 21 -PG_2_SPREAD_NARROW_AIMED = 22 -PG_3_SPREAD_WIDE_AIMED = 23 -PG_3_SPREAD_NARROW_AIMED = 24 -PG_4_SPREAD_WIDE_AIMED = 25 -PG_4_SPREAD_NARROW_AIMED = 26 -PG_5_SPREAD_WIDE_AIMED = 27 -PG_5_SPREAD_NARROW_AIMED = 28 -PG_1_RANDOM_NARROW_AIMED = 29 -PG_1_RANDOM_WIDE = 30 - -pellet_t struc - PELLET_moving db ? - PELLET_motion_type db ? - PELLET_cur_left dw ? - PELLET_cur_top dw ? - PELLET_spin_center Point - PELLET_prev_left dw ? - PELLET_prev_top dw ? - PELLET_from_group dw ? - PELLET_velocity Point - PELLET_spin_velocity Point - PELLET_not_rendered dw ? - PELLET_age dw ? - PELLET_speed dw ? - PELLET_decay_frame dw ? - PELLET_cloud_frame dw ? - PELLET_cloud_left dw ? - PELLET_cloud_top dw ? - PELLET_angle dw ? - PELLET_sling_direction dw ? -pellet_t ends - -CPellets struc - pellets pellet_t PELLET_COUNT dup() - PELLET_alive_count dw ? - PELLET_unknown_zero dw 10 dup(?) - PELLET_unknown_seven dw ? - PELLET_interlace_field dw ? - PELLET_spawn_with_cloud db ? -CPellets ends - -public _Pellets -_Pellets CPellets diff --git a/th01/main/debug.cpp b/th01/main/debug.cpp index 3f068e56..fa35f65d 100644 --- a/th01/main/debug.cpp +++ b/th01/main/debug.cpp @@ -115,9 +115,9 @@ void debug_show_game(void) void debug_vars(void) { - extern long memory_check_cycle; - extern int heapcheck_ret_prev; // ZUN bloat - extern screen_x_t player_left_prev; + static long memory_check_cycle; + static int heapcheck_ret_prev; // ZUN bloat + static screen_x_t player_left_prev; memory_check_cycle++; if((memory_check_cycle % 1000) == 100) { diff --git a/th01/main/player/anim[bss].asm b/th01/main/player/anim[bss].asm deleted file mode 100644 index 45d6d1d4..00000000 --- a/th01/main/player/anim[bss].asm +++ /dev/null @@ -1,16 +0,0 @@ -PLAYER_ANIM_IMAGES_PER_SLOT = 32 - -CPlayerAnim struc - PA_alpha dd PLAYER_ANIM_IMAGES_PER_SLOT dup(?) - PA_B dd PLAYER_ANIM_IMAGES_PER_SLOT dup(?) - PA_R dd PLAYER_ANIM_IMAGES_PER_SLOT dup(?) - PA_G dd PLAYER_ANIM_IMAGES_PER_SLOT dup(?) - PA_E dd PLAYER_ANIM_IMAGES_PER_SLOT dup(?) - PA_vram_w dw ? - PA_h dw ? - PA_bos_image_count dw ? -CPlayerAnim ends - -public _player_48x48, _player_48x32 -_player_48x48 CPlayerAnim -_player_48x32 CPlayerAnim diff --git a/th01/main/player/bomb.cpp b/th01/main/player/bomb.cpp index 765d181e..e313f318 100644 --- a/th01/main/player/bomb.cpp +++ b/th01/main/player/bomb.cpp @@ -34,20 +34,15 @@ bool16 bomb_update_and_render(int frame) KEYFRAME_DONE = 140, }; - #define palette_flash_peak_ bomb_palette_flash_peak_ - #define palette_flash_bright bomb_palette_flash_bright - #define white_to_blue_speed bomb_white_to_blue_speed - #define entity bomb_entity - extern const Palette4 palette_flash_peak_; - // Only uses its V_WHITE value. MODDERS: Reduce to a single RGB4 value. - extern Palette4 palette_white; + // ZUN bloat: Only uses its V_WHITE value. + static Palette4 palette_white; - extern Palette4 palette_flash_bright; - extern uint4_t white_to_blue_speed; + static Palette4 palette_flash_bright; + static uint4_t white_to_blue_speed; - extern struct { + static struct { screen_x_t left[(KUJI_COUNT * KUJI_RINGS) + 9]; // yup, 9 extra screen_y_t top[(KUJI_COUNT * KUJI_RINGS) + 9]; // yup, 9 extra unsigned char angle; // should be local @@ -75,7 +70,24 @@ bool16 bomb_update_and_render(int frame) #define col i #define comp j - Palette4 palette_flash_peak = palette_flash_peak_; + Palette4 palette_flash_peak = { + 0xF, 0xF, 0xF, // 0 + 0xD, 0xD, 0xF, // 1 + 0xD, 0xD, 0xF, // 2 + 0xD, 0xD, 0xF, // 3 + 0xD, 0xD, 0xF, // 4 + 0xD, 0xD, 0xF, // 5 + 0xD, 0xD, 0xF, // 6 + 0xF, 0xF, 0xF, // 7 (V_WHITE) + 0xD, 0xD, 0xF, // 8 + 0xD, 0xD, 0xF, // 9 + 0xD, 0xD, 0xF, // 10 + 0xD, 0xD, 0xF, // 11 + 0xD, 0xD, 0xF, // 12 + 0xD, 0xD, 0xF, // 13 + 0xD, 0xD, 0xF, // 14 + 0x6, 0x6, 0xF, // 15 + }; player_invincible = true; if(frame == 0) { @@ -232,10 +244,4 @@ bool16 bomb_update_and_render(int frame) #undef comp #undef col - - #undef entity - #undef white_to_blue_speed - #undef palette_flash_bright - #undef palette_white - #undef bomb_palette_flash_peak_ } diff --git a/th01/main/player/gameover.cpp b/th01/main/player/gameover.cpp index 372cb217..883d4775 100644 --- a/th01/main/player/gameover.cpp +++ b/th01/main/player/gameover.cpp @@ -7,14 +7,11 @@ void player_gameover_animate(void) EFFECT_SPEED = 8, }; - struct hack { bool16 x[EFFECT_COUNT]; }; // XXX - extern const struct hack PLAYER_GAMEOVER_EFFECT_CLIPPED; - int i; int j; screen_x_t left[EFFECT_COUNT]; screen_y_t top[EFFECT_COUNT]; - struct hack clipped = PLAYER_GAMEOVER_EFFECT_CLIPPED; + bool16 clipped[EFFECT_COUNT] = { false }; #define frame j @@ -36,16 +33,18 @@ void player_gameover_animate(void) z_vsync_wait_and_scrollup(RES_Y - ((j % 2) * 8)); for(i = 0; i < EFFECT_COUNT; i++) { // ZUN bug: Indexing [clipped] with [frame] rather than [i], - // leading to a out-of-bounds read from frame 5 on. - if(!clipped.x[frame]) { - // Sloppy unblitting is actually a good choice here, since - // Reimu's sprite has also been blitted to VRAM page 1 above, - // and we're inside a blocking animation anyway. But this ends - // up unblitting a rectangle around Reimu with a constant - // height of 32 pixels and only growing on the X axis… OK. It - // probably wasn't meant to "correctly" unblit each effect - // sprite as you would usually expect, as that would look - // rather wimpy in comparison. + // leading to a out-of-bounds read from frame 5 on. In the original + // game, this ends up accessing [top] and [left], whose positions + // can never be 0. + if(!clipped[frame]) { + // ZUN quirk: Sloppy unblitting is actually a good choice here, + // since Reimu's sprite has also been blitted to VRAM page 1 + // above, and we're inside a blocking animation anyway. But + // this ends up unblitting a rectangle around Reimu with a + // constant height of 32 pixels and only growing on the X + // axis... Then again, it probably wasn't meant to "correctly" + // unblit each effect sprite as you would usually expect, as + // that would look rather wimpy in comparison. ptn_sloppy_unput_16(left[i], player_top); } } @@ -73,9 +72,9 @@ void player_gameover_animate(void) (left[i] >= (PLAYFIELD_RIGHT - PTN_W)) || (left[i] < PLAYFIELD_LEFT) ) { - clipped.x[i] = true; + clipped[i] = true; } - if(!clipped.x[i]) { + if(!clipped[i]) { ptn_put_8(left[i], top[i], (PTN_MISS_EFFECT + (frame % 2))); } } diff --git a/th01/main/player/inv_spr.cpp b/th01/main/player/inv_spr.cpp index 3d4a6c4a..bf93a255 100644 --- a/th01/main/player/inv_spr.cpp +++ b/th01/main/player/inv_spr.cpp @@ -8,12 +8,11 @@ static const int INVINCIBILITY_SPRITES_DONE = 0xFF; void invincibility_sprites_update_and_render(bool16 invincible) { int i; - extern struct { + static struct { int frame[INVINCIBILITY_SPRITE_COUNT]; screen_x_t left[INVINCIBILITY_SPRITE_COUNT]; vram_y_t top[INVINCIBILITY_SPRITE_COUNT]; - } invincibility_sprites; - #define sprites invincibility_sprites + } sprites; if(!invincible) { if(sprites.frame[0] == INVINCIBILITY_SPRITES_DONE) { @@ -59,5 +58,4 @@ void invincibility_sprites_update_and_render(bool16 invincible) } sprites.frame[i]++; } - #undef sprites } diff --git a/th01/main/player/inv_spr[bss].asm b/th01/main/player/inv_spr[bss].asm deleted file mode 100644 index 4d8fff9c..00000000 --- a/th01/main/player/inv_spr[bss].asm +++ /dev/null @@ -1,7 +0,0 @@ -INVINCIBILITY_SPRITE_COUNT = 8 - -public _invincibility_sprites -_invincibility_sprites label - dw INVINCIBILITY_SPRITE_COUNT dup (?) - dw INVINCIBILITY_SPRITE_COUNT dup (?) - dw INVINCIBILITY_SPRITE_COUNT dup (?) diff --git a/th01/main/player/player.hpp b/th01/main/player/player.hpp index 4adc0832..428e8654 100644 --- a/th01/main/player/player.hpp +++ b/th01/main/player/player.hpp @@ -10,6 +10,11 @@ static const int PLAYER_MISS_INVINCIBILITY_FRAMES = 150; extern screen_x_t player_left; static const screen_y_t player_top = (PLAYFIELD_BOTTOM - PLAYER_H); +extern bool player_deflecting; +extern bool player_sliding; +extern bool player_is_hit; +extern bool16 player_invincible; +extern int player_invincibility_time; inline screen_x_t player_center_x(void) { return (player_left + (PLAYER_W / 2)); @@ -70,12 +75,6 @@ inline void player_reset(void) { // to calling this function. void player_miss_animate_and_update(void); -extern bool player_deflecting; -extern bool player_sliding; -extern bool player_is_hit; -extern bool16 player_invincible; -extern int player_invincibility_time; - extern int lives; extern int cardcombo_cur; extern int cardcombo_max; diff --git a/th01/main/player/player[bss].asm b/th01/main/player/player[bss].asm deleted file mode 100644 index 11ca57b7..00000000 --- a/th01/main/player/player[bss].asm +++ /dev/null @@ -1,12 +0,0 @@ -PLAYER_W = 32 -PLAYER_H = 32 - -PLAYER_LEFT_MIN = (PLAYFIELD_LEFT) -PLAYER_LEFT_MAX = (PLAYFIELD_RIGHT - PLAYER_W) - -PLAYER_LEFT_START = (PLAYFIELD_CENTER_X - (PLAYER_W / 2)) - -public _player_invincibility_time, _player_left -_player_invincibility_time dw ? -_player_left dw ? -_player_top = (PLAYFIELD_BOTTOM - PLAYER_H) diff --git a/th01/main/player/shot.hpp b/th01/main/player/shot.hpp index 00b24f59..799e54ab 100644 --- a/th01/main/player/shot.hpp +++ b/th01/main/player/shot.hpp @@ -11,6 +11,23 @@ struct CShots { bool moving[SHOT_COUNT]; unsigned char decay_frame[SHOT_COUNT]; + CShots() { + unknown[0] = 0x50; + unknown[1] = 0x60; + unknown[2] = 0x70; + + // ZUN bloat: Why no loop? + static_assert(SHOT_COUNT == 8); + moving[0] = false; + moving[1] = false; + moving[2] = false; + moving[3] = false; + moving[4] = false; + moving[5] = false; + moving[6] = false; + moving[7] = false; + } + void add(screen_x_t new_left, screen_y_t new_top); void unput_and_reset(void); void unput_update_render(void); diff --git a/th01/main/player/shot[bss].asm b/th01/main/player/shot[bss].asm deleted file mode 100644 index 9b483b0a..00000000 --- a/th01/main/player/shot[bss].asm +++ /dev/null @@ -1,12 +0,0 @@ -SHOT_COUNT = 8 - -CShots struc - SHOT_left dw SHOT_COUNT dup(?) - SHOT_top dw SHOT_COUNT dup(?) - SHOT_unknown dw SHOT_COUNT dup(?) - SHOT_moving db SHOT_COUNT dup(?) - SHOT_decay_frame db SHOT_COUNT dup(?) -CShots ends - -public _Shots -_Shots CShots diff --git a/th01/main/stage/stageobj.cpp b/th01/main/stage/stageobj.cpp index 83bdd961..565bf75e 100644 --- a/th01/main/stage/stageobj.cpp +++ b/th01/main/stage/stageobj.cpp @@ -25,11 +25,6 @@ // Globals // ------- -struct stage_t { - StupidBytewiseWrapperAround dat; - int8_t padding[5]; -}; - // ZUN bloat: The scene data is immediately converted to an internal // representation anyway. This could have easily been a local variable… then // again, storing it in global data is what gives negative "glitch stages" diff --git a/th01/main/stage/stageobj.hpp b/th01/main/stage/stageobj.hpp index ce7fe1dd..abf69a1a 100644 --- a/th01/main/stage/stageobj.hpp +++ b/th01/main/stage/stageobj.hpp @@ -167,6 +167,13 @@ void obstacles_update_and_render(bool16 reset); // Initialization // -------------- +#ifdef DECOMP_HPP + struct stage_t { + StupidBytewiseWrapperAround dat; + int8_t padding[5]; + }; +#endif + // Copies all stage objects from VRAM page 0 to VRAM page 1. void stageobjs_copy_0_to_1(int stage_id); diff --git a/th01/main/vars.cpp b/th01/main/vars.cpp new file mode 100644 index 00000000..f2fcc6cc --- /dev/null +++ b/th01/main/vars.cpp @@ -0,0 +1,13 @@ +#include "platform.h" +#include "th01/formats/cfg.hpp" +#include "th01/main/vars.hpp" +#include "th01/main/stage/stages.hpp" +#include "th01/main/stage/timer.hpp" + +int8_t rank = CFG_RANK_DEFAULT; +int8_t bgm_mode = CFG_BGM_MODE_DEFAULT; +int8_t bombs = CFG_BOMBS_DEFAULT; +int8_t lives_extra = CFG_LIVES_EXTRA_DEFAULT; + +int8_t stage_num = 0; +bool bgm_change_blocked = false; diff --git a/th01/main/vars.hpp b/th01/main/vars.hpp index f6a62972..94eeda70 100644 --- a/th01/main/vars.hpp +++ b/th01/main/vars.hpp @@ -1,20 +1,22 @@ #include "th01/rank.h" +// Not *really* a cfg_options_t, since you'd expect that structure to contain +// the immutable contents of REIIDEN.CFG. However, [bombs] is in fact the +// *current* bomb count, and the .CFG value is saved to [credit_bombs]... extern int8_t rank; // ACTUAL TYPE: rank_t extern int8_t bgm_mode; // ACTUAL TYPE: bool extern int8_t bombs; extern int8_t credit_bombs; +extern int8_t stage_num; +extern bool bgm_change_blocked; + // Current gameplay frame plus resident_t::rand, without any frame_delay(). // Displayed as "rand" in the debug output, but can't be /* ZUN symbol */'d // like that, due to obviously colliding with the C standard library function. extern unsigned long frame_rand; extern int8_t lives_extra; - -extern int8_t stage_num; extern bool first_stage_in_scene; - extern uint32_t score; - extern int8_t game_cleared; // ACTUAL TYPE: bool diff --git a/th01/main_01.cpp b/th01/main_01.cpp index f95b766e..0f51774c 100644 --- a/th01/main_01.cpp +++ b/th01/main_01.cpp @@ -28,7 +28,6 @@ #include "th01/hardware/frmdelay.h" #include "th01/hardware/graph.h" #include "th01/hardware/grppsafx.h" -#include "th01/hardware/input.hpp" #include "th01/hardware/palette.h" #include "th01/hardware/text.h" #include "th01/hardware/tram_x16.hpp" @@ -66,17 +65,73 @@ #include "th01/shiftjis/fns.hpp" #include "th01/shiftjis/scoredat.hpp" -int8_t temporary_padding = 0; - // Random state that mostly doesn't belong here // -------------------------------------------- -extern bool bgm_change_blocked; -extern int16_t unused_5; -extern int bomb_doubletap_frames_unused; -extern int unnecessary_copy_of_the_initial_value_of_extend_next; // ZUN bloat +static int8_t unused_1 = 0; // ZUN bloat +const char* RANKS[RANK_COUNT] = { "EASY", "NORMAL", "HARD", "LUNATIC" }; +bool timer_initialized = false; +static int8_t unused_2 = 0; // ZUN bloat +bool first_stage_in_scene = true; -extern struct { +#include "th01/hardware/input_mf.cpp" + +static int8_t unused_3 = 0; // ZUN bloat +bool player_deflecting = false; +bool bomb_damaging = false; +bool player_sliding = false; +uint32_t score = 0; +uint32_t score_bonus = 0; +unsigned long bomb_frames = 0; +long continues_total = 0; +static int16_t unused_4 = 0; // ZUN bloat +bool16 mode_test = false; +int bomb_doubletap_frames = 0; +int bomb_doubletap_frames_unused = 0; +bool16 test_damage = false; +static int unused_5 = 0; // ZUN bloat +static int unused_6 = 0; // ZUN bloat +bool16 player_invincible = false; +static int unused_7 = 0; // ZUN bloat +orb_velocity_x_t orb_velocity_x = OVX_0; +int orb_rotation_frame = 0; +int lives = 4; +bool16 stage_cleared = false; + +int8_t credit_bombs; +int8_t player_swing_deflection_frames; +unsigned long frame_rand; +uint32_t coreleft_prev; +bool stage_wait_for_shot_to_begin; + +bool mode_debug; +unsigned long frames_since_start_of_binary; + +int player_invincibility_time; +screen_x_t player_left; +int cardcombo_cur = 0; +bool16 orb_in_portal = false; +int cardcombo_max = 0; +int extend_next = 1; +int unnecessary_copy_of_the_initial_value_of_extend_next = 1; + +screen_x_t orb_cur_left; +screen_y_t orb_cur_top; +screen_x_t orb_prev_left = ORB_LEFT_START; +screen_y_t orb_prev_top = ORB_TOP_START; +int orb_frames_outside_portal = 0; +double orb_velocity_y = 0.0; +double orb_force = 0.0; +int orb_force_frame; + +stage_t scene_stage[STAGES_PER_SCENE]; +CPlayerAnim player_48x48; +CPlayerAnim player_48x32; +CPellets Pellets; +CShots Shots; +static int32_t unused_8; // ZUN bloat + +struct { // Specifies whether PTN_SLOT_STG contains the full set of sprites required // for card-flipping stages (`false`), or the trimmed-down version for boss // stages (`true`). @@ -97,7 +152,7 @@ extern struct { has_reduced_sprites = true; } } -} ptn_slot_stg; +} ptn_slot_stg = { false }; // -------------------------------------------- inline void bomb_doubletap_update(uint8_t& pressed, uint8_t& other) { @@ -112,7 +167,7 @@ inline void bomb_doubletap_update(uint8_t& pressed, uint8_t& other) { void input_sense(bool16 reset_repeat) { - extern uint8_t input_prev[16]; + static uint8_t input_prev[16]; int group_1, group_2, group_3, group_4; if(reset_repeat == true) { @@ -374,7 +429,7 @@ void pellet_destroy_score_delta_commit(void) pellet_destroy_score_delta = 0; } -extern int8_t boss_id; // ACTUAL TYPE: boss_id_t +int8_t boss_id = BID_NONE; // ACTUAL TYPE: boss_id_t void boss_free(void) { diff --git a/th01/main_var.cpp b/th01/main_var.cpp new file mode 100644 index 00000000..629b51e4 --- /dev/null +++ b/th01/main_var.cpp @@ -0,0 +1 @@ +#include "th01/main/vars.cpp" diff --git a/th01/th01.inc b/th01/th01.inc index f9529823..ce493634 100644 --- a/th01/th01.inc +++ b/th01/th01.inc @@ -61,40 +61,6 @@ reiidenconfig_t struc ; (sizeof=0x4B) p_value dw ? reiidenconfig_t ends -; Text -; ---- -FX_CLEAR_BG = 200h -FX_UNDERLINE = 400h -FX_REVERSE = 800h -; ---- - -; Playfield -; --------- -PLAYFIELD_LEFT = 0 -PLAYFIELD_TOP = 64 -PLAYFIELD_RIGHT = RES_X -PLAYFIELD_BOTTOM = RES_Y - -PLAYFIELD_W = (PLAYFIELD_RIGHT - PLAYFIELD_LEFT) -PLAYFIELD_H = (PLAYFIELD_BOTTOM - PLAYFIELD_TOP) - -PLAYFIELD_CENTER_X = (((PLAYFIELD_RIGHT - PLAYFIELD_LEFT) / 2) + PLAYFIELD_LEFT) -; --------- - -; Player -; ------ -MISS_INVINCIBILITY_FRAMES = 150 - -ORB_W = 32 -ORB_H = 32 - -ORB_LEFT_MAX = (PLAYFIELD_RIGHT - ORB_W) -ORB_TOP_MAX = (PLAYFIELD_BOTTOM - ORB_H) - -ORB_LEFT_START = (ORB_LEFT_MAX - 8) - ORB_TOP_START = ( ORB_TOP_MAX - 88) -; ------ - ; VRAM colors ; ----------- V_WHITE = 7 diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 70e8ceea..710cf433 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -16,13 +16,9 @@ .386 .model use16 large _TEXT -BINARY = 'M' - include ReC98.inc include th01/th01.inc -STAGES_PER_SCENE = 5 - ; =========================================================================== ; Segment type: Pure code @@ -61,256 +57,6 @@ include libs/master.lib/isqrt.asm include libs/master.lib/random.asm _TEXT ends -; =========================================================================== - -; Segment type: Pure code -main_01_TEXT segment byte public 'CODE' use16 - assume cs:main_01_TEXT - ;org 2 - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_E319 proc far - push bp - mov bp, sp - call @CPellets@$bctr$qv c, offset _Pellets, ds - mov _Shots.SHOT_unknown[0 * word], 50h - mov _Shots.SHOT_unknown[1 * word], 60h - mov _Shots.SHOT_unknown[2 * word], 70h - - @@i = 0 - rept SHOT_COUNT - mov _Shots.SHOT_moving[@@i], 0 - @@i = @@i + 1 - endm - - pop bp - retf -sub_E319 endp -main_01_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -frmdelay_TEXT segment byte public 'CODE' use16 -frmdelay_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -vsync_TEXT segment byte public 'CODE' use16 -vsync_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -ztext_TEXT segment byte public 'CODE' use16 -ztext_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -initexit_TEXT segment byte public 'CODE' use16 -initexit_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -graph_TEXT segment byte public 'CODE' use16 -graph_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -SHARED segment byte public 'CODE' use16 -SHARED ends - -; =========================================================================== - -; Segment type: Pure code -PTN_GRP_GRZ segment byte public 'CODE' use16 -PTN_GRP_GRZ ends - -; =========================================================================== - -; Segment type: Pure code -main_09_TEXT segment byte public 'CODE' use16 -main_09_TEXT ends - -; =========================================================================== - -BULLET_L_TEXT segment byte public 'CODE' use16 -BULLET_L_TEXT ends - -; =========================================================================== - -main_11_TEXT segment byte public 'CODE' use16 -main_11_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -resstuff_TEXT segment byte public 'CODE' use16 -resstuff_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -GRAPH_EX_TEXT segment byte public 'CODE' use16 -GRAPH_EX_TEXT ends - -; =========================================================================== - -main_14_TEXT segment byte public 'CODE' use16 -main_14_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_15_TEXT segment byte public 'CODE' use16 -main_15_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -mdrv2_TEXT segment byte public 'CODE' use16 -mdrv2_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_17_TEXT segment byte public 'CODE' use16 -main_17_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_18_TEXT segment byte public 'CODE' use16 -main_18_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_19_TEXT segment byte public 'CODE' use16 -main_19_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_20_TEXT segment byte public 'CODE' use16 -main_20_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_21_TEXT segment byte public 'CODE' use16 -main_21_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -PF_TEXT segment byte public 'CODE' use16 -PF_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_23_TEXT segment byte public 'CODE' use16 -main_23_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_24_TEXT segment byte public 'CODE' use16 -main_24_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_25_TEXT segment byte public 'CODE' use16 -main_25_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_26_TEXT segment byte public 'CODE' use16 -main_26_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_27_TEXT segment byte public 'CODE' use16 -main_27_TEXT ends - -; =========================================================================== - -main_28_TEXT segment byte public 'CODE' use16 -main_28_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_29_TEXT segment byte public 'CODE' use16 -main_29_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_30_TEXT segment byte public 'CODE' use16 -main_30_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_31_TEXT segment byte public 'CODE' use16 -main_31_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_32_TEXT segment byte public 'CODE' use16 -main_32_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_33_TEXT segment byte public 'CODE' use16 -main_33_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_34_TEXT segment byte public 'CODE' use16 -main_34_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_35_TEXT segment byte public 'CODE' use16 -main_35_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_36_TEXT segment byte public 'CODE' use16 -main_36_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_37_TEXT segment byte public 'CODE' use16 -main_37_TEXT ends - -; =========================================================================== - -; Segment type: Pure code -main_38_TEXT segment byte public 'CODE' use16 - extern @CPellets@$bctr$qv:proc -main_38_TEXT ends - .data ; libs/master.lib/tx[data].asm @@ -367,77 +113,8 @@ IDLEN EQU 10 ; libs/master.lib/rand[data].asm extern random_seed:dword -_INIT_ segment word public 'INITDATA' use16 - db 1 - db 20h - dd sub_E319 -_INIT_ ends - .data? -CEntities macro name:req, count:req - public name - name label byte - dw count dup(?) ; left - dw count dup(?) ; top -endm - -public _credit_bombs, _player_swing_deflection_frames -_credit_bombs db ? -_player_swing_deflection_frames db ? -public _frame_rand, _coreleft_prev, _stage_wait_for_shot_to_begin -_frame_rand dd ? -_coreleft_prev dd ? -_stage_wait_for_shot_to_begin db ? -public _mode_debug, _frames_since_start_of_binary -_mode_debug db ? -_frames_since_start_of_binary dd ? -include th01/main/player/player[bss].asm -public _orb_cur_left, _orb_cur_top, _orb_force_frame -_orb_cur_left dw ? -_orb_cur_top dw ? -_orb_force_frame dw ? - -PTN_W = 32 -PTN_H = 32 -STAGEOBJ_W = PTN_W -STAGEOBJ_H = PTN_H -STAGEOBJS_X = (PLAYFIELD_W / STAGEOBJ_W) -STAGEOBJS_Y = (PLAYFIELD_H / STAGEOBJ_H) - -STAGEOBJS_COUNT = (STAGEOBJS_X * STAGEOBJS_Y) -STAGEDAT_STAGE_SIZE = ((STAGEOBJS_COUNT) + (STAGEOBJS_COUNT / 4) + 5) - -public _scene_stage -_scene_stage db (STAGEDAT_STAGE_SIZE * STAGES_PER_SCENE) dup(?) - -include th01/main/player/anim[bss].asm -include th01/main/bullet/pellets[bss].asm -include th01/main/player/shot[bss].asm - db 4 dup(?) -public _input_prev, _palette_white, _bomb_palette_flash_bright -public _bomb_white_to_blue_speed -_input_prev db 16 dup (?) - -_palette_white palette_t -_bomb_palette_flash_bright palette_t -_bomb_white_to_blue_speed db ? - -KUJI_COUNT = 9 -KUJI_RINGS = 2 - -public _bomb_entity -_bomb_entity label byte - dw ((KUJI_COUNT * KUJI_RINGS) + 9) dup (?) ; left - dw ((KUJI_COUNT * KUJI_RINGS) + 9) dup (?) ; top - db ? ; angle - -include th01/main/player/inv_spr[bss].asm -public _memory_check_cycle, _heapcheck_ret_prev, _player_left_prev -_memory_check_cycle dd ? -_heapcheck_ret_prev dw ? -_player_left_prev dw ? - ; libs/master.lib/pal[bss].asm extern Palettes:rgb_t:COLOR_COUNT diff --git a/th01_reiiden_data.asm b/th01_reiiden_data.asm deleted file mode 100644 index 193e4181..00000000 --- a/th01_reiiden_data.asm +++ /dev/null @@ -1,115 +0,0 @@ -; Remaining non-literal data defined in segment #1 of TH01's REIIDEN.EXE - - .386 - .model use16 large - -include pc98.inc -include th01/th01.inc -include th01/formats/cfg.inc - - .data - -; Not *really* a cfg_options_t, since you'd expect that structure to contain -; the immutable contents of REIIDEN.CFG. However, [bombs] is in fact the -; *current* bomb count, and the .CFG value is saved to [credit_bombs]... -public _rank, _bgm_mode, _bombs, _lives_extra, _stage_num -public _bgm_change_blocked -_rank db CFG_RANK_DEFAULT -_bgm_mode db CFG_BGM_MODE_DEFAULT -_bombs db CFG_BOMBS_DEFAULT -_lives_extra db CFG_LIVES_EXTRA_DEFAULT -_stage_num db 0 -_bgm_change_blocked db 0 - db 0 -public _RANKS, _first_stage_in_scene, _timer_initialized -_RANKS label dword - dd aEasy ; "EASY" - dd aNormal ; "NORMAL" - dd aHard ; "HARD" - dd aLunatic ; "LUNATIC" -_timer_initialized db 0 - db 0 -_first_stage_in_scene db 1 - db 0 - -public _input_up, _input_down, _input_lr, _input_shot, _input_strike, _input_ok -public _input_bomb, _player_is_hit, _paused, _input_mem_enter, _input_mem_leave -_input_lr db 0 -_input_mem_enter db 0 -_input_mem_leave db 0 -_input_shot db 0 -_player_is_hit db 0 -_input_bomb db 0 -_paused db 0 -_input_ok db 0 -_input_strike db 0 -_input_up db 0 -_input_down db 0 - db 0 -public _player_deflecting, _bomb_damaging, _player_sliding -_player_deflecting db 0 -_bomb_damaging db 0 -_player_sliding db 0 -public _score, _score_bonus, _bomb_frames, _continues_total, _mode_test -_score dd 0 -_score_bonus dd 0 -_bomb_frames dd 0 -_continues_total dd 0 - dw 0 -_mode_test dw 0 -public _bomb_doubletap_frames, _bomb_doubletap_frames_unused, _test_damage -public _unused_5, _player_invincible, _orb_velocity_x, _lives, _stage_cleared -public _orb_rotation_frame -_bomb_doubletap_frames dw 0 -_bomb_doubletap_frames_unused dw 0 -_test_damage dw 0 -_unused_5 dw 0 - dw 0 -_player_invincible dw 0 - dw 0 -_orb_velocity_x dw 0 -_orb_rotation_frame dw 0 -_lives dw 4 -_stage_cleared dw 0 -public _cardcombo_cur, _orb_in_portal, _cardcombo_max, _extend_next -public _unnecessary_copy_of_the_initial_ -_cardcombo_cur dw 0 -_orb_in_portal dw 0 -_cardcombo_max dw 0 -_extend_next dw 1 -_unnecessary_copy_of_the_initial_ dw 1 -public _orb_prev_left, _orb_prev_top, _orb_frames_outside_portal -public _orb_velocity_y, _orb_force -_orb_prev_left dw ORB_LEFT_START -_orb_prev_top dw ORB_TOP_START -_orb_frames_outside_portal dw 0 -_orb_velocity_y dq 0.0 -_orb_force dq 0.0 -public _ptn_slot_stg, _bomb_palette_flash_peak_ -_ptn_slot_stg db 0 -label _bomb_palette_flash_peak_ byte - db 0Fh, 0Fh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Fh, 0Fh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 0Dh, 0Dh, 0Fh - db 06h, 06h, 0Fh -public _PLAYER_GAMEOVER_EFFECT_CLIPPED, _boss_id -_PLAYER_GAMEOVER_EFFECT_CLIPPED dw 5 dup (0) -_boss_id db 0 -aEasy db 'EASY',0 -aNormal db 'NORMAL',0 -aHard db 'HARD',0 -aLunatic db 'LUNATIC' - - end