diff --git a/Makefile.mak b/Makefile.mak index dbb674210..0a2cf4a78 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -109,8 +109,8 @@ $** | bin\th04\scoreupd.obj: th04\scoreupd.asm -bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj - $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='M' -nbin\th04\ -eMAIN.EXE @&&| +bin\th04\main.exe: bin\th04\main.obj bin\th04\scoreupd.obj th04\main011.cpp + $(CC) $(CFLAGS) -ml -DGAME=4 -DBINARY='M' -3 -Z -nbin\th04\ -eMAIN.EXE @&&| $** | @@ -128,7 +128,7 @@ bin\th05\op.exe: bin\th05\op.obj th05\op_01.cpp $** | -bin\th05\main.exe: bin\th05\main.obj th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main012.cpp +bin\th05\main.exe: bin\th05\main.obj th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main011.cpp th05\main012.cpp $(CC) $(CFLAGS) -ml -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&| $** | diff --git a/th02/main/playfld.h b/th02/main/playfld.h index 58fe6dc52..b39760cda 100644 --- a/th02/main/playfld.h +++ b/th02/main/playfld.h @@ -15,6 +15,8 @@ #define PLAYFIELD_TRAM_X (PLAYFIELD_X / 8) #define PLAYFIELD_TRAM_Y (PLAYFIELD_Y / 16) #define PLAYFIELD_TRAM_W (PLAYFIELD_W / 8) +#define PLAYFIELD_TRAM_CENTER_X \ + ((PLAYFIELD_X + (PLAYFIELD_W / 2)) / GLYPH_HALF_W) #define PLAYFIELD_TRAM_RIGHT (PLAYFIELD_RIGHT / 8) #define PLAYFIELD_TRAM_BOTTOM (PLAYFIELD_BOTTOM / 16) diff --git a/th04/formats/bb.h b/th04/formats/bb.h index efe180b84..ae86d8f40 100644 --- a/th04/formats/bb.h +++ b/th04/formats/bb.h @@ -10,6 +10,11 @@ void pascal near bb_stage_load(const char far* fn); #define BB_TXT_H 32 #define BB_TXT_VRAM_W (BB_TXT_W / 8) +#define BB_TXT_IN_SPRITE 16 +#define BB_TXT_IN_CELS 8 +#define BB_TXT_OUT_SPRITE 0 +#define BB_TXT_OUT_CELS 16 + // Puts the given TXT*.BB sprite at (⌊left/8⌋*8, top). Assumptions: // • ES is already be set to the beginning of a VRAM segment // • The GRCG is active, and set to the intended color diff --git a/th04/main/hud/popup.cpp b/th04/main/hud/popup.cpp new file mode 100644 index 000000000..72780cf92 --- /dev/null +++ b/th04/main/hud/popup.cpp @@ -0,0 +1,286 @@ +#include "ReC98.h" +#include "th03/math/subpixel.hpp" +#include "th04/gaiji/gaiji.h" +#include "th04/formats/bb.h" +#include "th04/hardware/grcg.h" +#include "th04/math/motion.hpp" +#include "th04/main/null.hpp" +#include "th04/main/playfld.h" +#include "th04/main/tile.hpp" +#include "th04/main/scroll.hpp" +#include "th04/main/hud/popup.hpp" +#include "th04/main/stage/stage.hpp" +#include "th04/main/item/items.hpp" + +#if (GAME == 4) + #include "th04/chars.h" +#endif + +// See tile.hpp for the reason this declaration is necessary +void pascal near tiles_invalidate_around( + subpixel_t center_y, subpixel_t center_x +); + +/// Stage and BGM titles +/// -------------------- +extern unsigned char popup_dissolve_sprite; +extern int stage_title_len; +extern int stage_bgm_title_len; +extern int boss_bgm_title_len; +#if (GAME == 5) + extern char *stage_title; + extern char *stage_bgm_title; + extern char *boss_bgm_title; +#else + extern unsigned char stage_title_id; + extern const char* BGM_TITLES[]; + extern const char* STAGE_TITLES[]; + #define stage_title (STAGE_TITLES[stage_title_id]) + #define stage_bgm_title (BGM_TITLES[bgm_title_id]) + #define boss_bgm_title stage_bgm_title +#endif +extern char gStage_1[8]; +extern const char gFINAL_STAGE[12]; +extern const char gEXTRA_STAGE[12]; + +#define STAGE_NUM_CENTER_Y 168 +#define STAGE_TITLE_CENTER_Y 200 +#define BGM_CENTER_Y 360 + +#define POPUP_FRAMES_UNTIL_OUT_DISSOLVE 192 + +#define vram_y_to_tram(y) (PLAYFIELD_TRAM_Y + (y / GLYPH_H)) + +#define STAGE_NUM_W ((sizeof(gStage_1) - 1) * GAIJI_TRAM_W) +#define STAGE_NUM_FE_W ((sizeof(gFINAL_STAGE) - 1) * GAIJI_TRAM_W) +#define STAGE_NUM_TRAM_LEFT (PLAYFIELD_TRAM_CENTER_X - (STAGE_NUM_W / 2)) +#define STAGE_NUM_FE_TRAM_LEFT (PLAYFIELD_TRAM_CENTER_X - (STAGE_NUM_FE_W / 2)) + +#define STAGE_NUM_TRAM_CENTER_Y (vram_y_to_tram(STAGE_NUM_CENTER_Y)) +#define STAGE_TITLE_TRAM_CENTER_Y (vram_y_to_tram(STAGE_TITLE_CENTER_Y)) +#define BGM_TRAM_CENTER_Y (vram_y_to_tram(BGM_CENTER_Y)) +#define BGM_TRAM_RIGHT (PLAYFIELD_TRAM_RIGHT - 1) + +inline int bgm_note_tram_left(int title_len) +{ + return ((BGM_TRAM_RIGHT - (GAIJI_TRAM_W + 1)) - title_len); +} +inline int bgm_title_tram_left(int title_len) +{ + return (BGM_TRAM_RIGHT - title_len); +} + +// Draws [popup_dissolve_sprite] onto the graphics RAM along a row of text +// with the given halfwidth length, starting at the given text RAM X column +// and playfield-space Y position. +// Assumes that the GRCG is active, and set to the intended color. +void pascal near popup_dissolve_put(int tram_left, subpixel_t top, int ank_len) +{ + int vram_left = tram_left; + int vram_right = ank_len; + + vram_left--; + vram_right += vram_left; + + vram_right *= GLYPH_HALF_W; + vram_left *= GLYPH_HALF_W; + top = scroll_subpixel_y_to_vram_seg1(top); + + _ES = SEG_PLANE_B; + while(vram_left < vram_right) { + bb_txt_put_8(vram_left, top, popup_dissolve_sprite); + vram_left += GLYPH_FULL_W; + } +} + +void pascal near popup_titles_invalidate(void) +{ + unsigned char frames = (popup_titles_frame + popup_boss_bgm_frame); + if(frames == 0) { + return; + } + if(frames >= POPUP_FRAMES_UNTIL_OUT_DISSOLVE || frames <= 34) { + tile_invalidate_box.x = PLAYFIELD_W; + tile_invalidate_box.y = BB_TXT_H; + tiles_invalidate_around_vram_xy(PLAYFIELD_W / 2, STAGE_NUM_CENTER_Y); + tiles_invalidate_around_vram_xy(PLAYFIELD_W / 2, STAGE_TITLE_CENTER_Y); + tiles_invalidate_around_vram_xy(PLAYFIELD_W / 2, BGM_CENTER_Y); + } +} + +inline void bgm_note_dissolve_put(const int& len) +{ + popup_dissolve_put( + bgm_note_tram_left(len), to_sp(BGM_CENTER_Y), GAIJI_TRAM_W + ); +} + +inline void bgm_title_dissolve_put(const int& len) +{ + popup_dissolve_put(bgm_title_tram_left(len), to_sp(BGM_CENTER_Y), len); +} + +#define bgm_string_put(str, len) \ + gaiji_putca(bgm_note_tram_left(len), BGM_TRAM_CENTER_Y, 3, TX_YELLOW); \ + text_putsa(bgm_title_tram_left(len), BGM_TRAM_CENTER_Y, str, TX_WHITE); + +inline void titles_dissolve_put(const int& bgm_len) +{ + grcg_setmode_rmw_seg1(); + + grcg_setcolor_direct_seg1(11); // Yellow + if(stage_id < 5) { + popup_dissolve_put( + STAGE_NUM_TRAM_LEFT, to_sp(STAGE_NUM_CENTER_Y), STAGE_NUM_W + ); + } else { + popup_dissolve_put( + STAGE_NUM_FE_TRAM_LEFT, to_sp(STAGE_NUM_CENTER_Y), STAGE_NUM_FE_W + ); + } + bgm_note_dissolve_put(bgm_len); + + grcg_setcolor_direct_seg1(15); // White + bgm_title_dissolve_put(bgm_len); + popup_dissolve_put( + (PLAYFIELD_TRAM_CENTER_X - (stage_title_len / 2)), + to_sp(STAGE_TITLE_CENTER_Y), + stage_title_len + ); + grcg_off(); +} + +#define titles_strings_put(bgm_str, bgm_len) \ + gStage_1[6] = (gb_1_ + stage_id); \ + if(stage_id == 5) { \ + gaiji_putsa( \ + STAGE_NUM_FE_TRAM_LEFT, \ + STAGE_NUM_TRAM_CENTER_Y, \ + gFINAL_STAGE, \ + TX_YELLOW \ + ); \ + } else if(stage_id == 6) { \ + gaiji_putsa( \ + STAGE_NUM_FE_TRAM_LEFT, \ + STAGE_NUM_TRAM_CENTER_Y, \ + gEXTRA_STAGE, \ + TX_YELLOW \ + ); \ + } else { \ + gaiji_putsa( \ + STAGE_NUM_TRAM_LEFT, STAGE_NUM_TRAM_CENTER_Y, gStage_1, TX_YELLOW \ + ); \ + } \ + text_putsa( \ + (PLAYFIELD_TRAM_CENTER_X - (stage_title_len / 2)), \ + STAGE_TITLE_TRAM_CENTER_Y, \ + stage_title, \ + TX_WHITE \ + ); \ + bgm_string_put(bgm_str, bgm_len); + +static inline void boss_bgm_dissolve_put(const int& bgm_len) +{ + grcg_setmode_rmw_seg1(); + + grcg_setcolor_direct_seg1(11); // Yellow + bgm_note_dissolve_put(bgm_len); + + grcg_setcolor_direct_seg1(15); // White + bgm_title_dissolve_put(bgm_len); + + grcg_off(); +} + +#define dissolve_in_update(frame) \ + if((frame & 3) == 0) { \ + if(frame != 0) { \ + popup_dissolve_sprite++; \ + if(popup_dissolve_sprite >= (BB_TXT_IN_SPRITE + BB_TXT_IN_CELS)) { \ + popup_dissolve_sprite = 0; \ + } \ + } \ + } + +#define dissolve_out_update(frame) \ + if(frame == POPUP_FRAMES_UNTIL_OUT_DISSOLVE) { \ + playfield_tram_wipe(); \ + popup_dissolve_sprite = BB_TXT_OUT_SPRITE; \ + } else { \ + if((frame & 1) == 0) { \ + popup_dissolve_sprite++; \ + } \ + } + +void pascal near popup_titles_update_and_render(void) +{ + #define frames popup_titles_frame + if(frames >= POPUP_FRAMES_UNTIL_OUT_DISSOLVE) { + dissolve_out_update(frames); + if(popup_dissolve_sprite >= (BB_TXT_OUT_SPRITE + BB_TXT_OUT_CELS)) { + if(frames & 1) { + overlay_text = nullfunc_near; + frames = 0; + popup_dissolve_sprite = 0; + return; + } + } else { + titles_dissolve_put(stage_bgm_title_len); + } + } else { + if(frames == 0) { + popup_dissolve_sprite = BB_TXT_IN_SPRITE; + #if (GAME == 4) + stage_title_id = (stage_id + 1); + bgm_title_id = ((stage_id * 2) + 1); + if(stage_id == 0 && playchar == PLAYCHAR_REIMU) { + stage_title_id = 0; + bgm_title_id = 0; + } + #endif + stage_title_len = strlen(stage_title); + stage_bgm_title_len = strlen(stage_bgm_title); + } + if(popup_dissolve_sprite >= BB_TXT_IN_SPRITE) { + if(popup_dissolve_sprite == (BB_TXT_IN_SPRITE + 6)) { + titles_strings_put(stage_bgm_title, stage_bgm_title_len); + } + titles_dissolve_put(stage_bgm_title_len); + dissolve_in_update(frames); + } + } + frames++; + #undef frames +} + +void pascal near popup_boss_bgm_update_and_render(void) +{ + #define frames popup_boss_bgm_frame + if(frames >= POPUP_FRAMES_UNTIL_OUT_DISSOLVE) { + dissolve_out_update(frames); + if(popup_dissolve_sprite >= (BB_TXT_OUT_SPRITE + BB_TXT_OUT_CELS)) { + if(frames & 1) { + overlay_text = nullfunc_near; + frames = 0; + return; + } + } else { + boss_bgm_dissolve_put(boss_bgm_title_len); + } + } else { + if(frames == 0) { + popup_dissolve_sprite = BB_TXT_IN_SPRITE; + boss_bgm_title_len = strlen(boss_bgm_title); + } + if(popup_dissolve_sprite >= BB_TXT_IN_SPRITE) { + if(popup_dissolve_sprite == (BB_TXT_IN_SPRITE + 6)) { + bgm_string_put(boss_bgm_title, boss_bgm_title_len); + } + boss_bgm_dissolve_put(boss_bgm_title_len); + dissolve_in_update(frames); + } + } + frames++; + #undef frames +} +/// -------------------- diff --git a/th04/main/hud/popup.hpp b/th04/main/hud/popup.hpp index 08d3d91fb..4a6745f49 100644 --- a/th04/main/hud/popup.hpp +++ b/th04/main/hud/popup.hpp @@ -15,3 +15,13 @@ extern nearfunc_t_near popup; extern unsigned long popup_bonus; void pascal near popup_update_and_render(void); + +/// Stage and BGM titles +/// -------------------- +extern unsigned char popup_boss_bgm_frame; +extern unsigned char popup_titles_frame; + +void pascal near popup_titles_invalidate(void); +void pascal near popup_titles_update_and_render(void); +void pascal near popup_boss_bgm_update_and_render(void); +/// -------------------- diff --git a/th04/main/hud/popup[bss].asm b/th04/main/hud/popup[bss].asm index cf1ea4cab..1a048f1f6 100644 --- a/th04/main/hud/popup[bss].asm +++ b/th04/main/hud/popup[bss].asm @@ -10,7 +10,7 @@ _boss_bgm_title_len dw ? public _popup_gaiji_len, _popup_id_cur, _popup_dest_reached, _popup_shiftbuf public _popup_cur_tram_x, _popup_dest_tram_x, _bgm_title_id, _popup_id_new -public _overlay_text, _popup, _popup_byte_unknown, _popup_bonus +public _overlay_text, _popup, _popup_titles_frame, _popup_bonus _popup_gaiji_len dw ? _popup_id_cur db ? _popup_dest_reached db ? @@ -28,6 +28,6 @@ _bgm_title_id db ? _popup_id_new db ? _overlay_text dw ? _popup dw ? -_popup_byte_unknown db ? +_popup_titles_frame db ? db ? _popup_bonus dd ? diff --git a/th04/main/hud/popup[data].asm b/th04/main/hud/popup[data].asm index 1ed69014f..f28e0aca2 100644 --- a/th04/main/hud/popup[data].asm +++ b/th04/main/hud/popup[data].asm @@ -1,6 +1,7 @@ -gStage_1 db 0BCh, 0BDh, 0AAh, 0B0h, 0AEh, 2, 0A1h, 0 -gFINAL_STAGE db 0AFh, 0B2h, 0B7h, 0AAh, 0B5h, 2, 0BCh, 0BDh, 0AAh, 0B0h, 0AEh, 0 -gEXTRA_STAGE db 0AEh, 0C1h, 0BDh, 0BBh, 0AAh, 2, 0BCh, 0BDh, 0AAh, 0B0h, 0AEh, 0 +public _gStage_1, _gFINAL_STAGE, _gEXTRA_STAGE +_gStage_1 db 0BCh, 0BDh, 0AAh, 0B0h, 0AEh, 2, 0A1h, 0 +_gFINAL_STAGE db 0AFh, 0B2h, 0B7h, 0AAh, 0B5h, 2, 0BCh, 0BDh, 0AAh, 0B0h, 0AEh, 0 +_gEXTRA_STAGE db 0AEh, 0C1h, 0BDh, 0BBh, 0AAh, 2, 0BCh, 0BDh, 0AAh, 0B0h, 0AEh, 0 gpHISCORE_ENTRY db 40h, 41h, 42h, 43h, 44h, 45h, 46h, 47h, 0 gpEXTEND db 48h, 49h, 4Ah, 4Bh, 4Ch, 0 gpBONUS db 58h, 59h, 5Ah, 5Bh, 0 @@ -19,3 +20,7 @@ _POPUP_STRINGS label dword if GAME eq 5 dd gpDREAMBONUS_MAX endif + +public _popup_dissolve_sprite +_popup_dissolve_sprite db 0 + evendata diff --git a/th04/main011.cpp b/th04/main011.cpp new file mode 100644 index 000000000..2707e9cd9 --- /dev/null +++ b/th04/main011.cpp @@ -0,0 +1,10 @@ +/* ReC98 + * ----- + * 2nd part of code segment #1 of TH04's MAIN.EXE + */ + +#pragma codeseg main_0_TEXT main_01 + +extern "C" { +#include "th04/main/hud/popup.cpp" +} diff --git a/th04_main.asm b/th04_main.asm index 964b051f4..dd27be848 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -2339,7 +2339,7 @@ include th04/main/tiles_invalidate_all.asm sub_CB58 proc near push bp mov bp, sp - call main_01:sub_10EED + call main_01:popup_titles_invalidate call main_01:player_invalidate call main_01:sub_10444 call main_01:enemies_invalidate @@ -2833,7 +2833,7 @@ loc_CF70: mov _bgm_title_id, 10h loc_CFAC: - mov _overlay_text, offset sub_11195 + mov _overlay_text, offset popup_boss_bgm_update_and_render mov al, 1 pop bp retn @@ -9931,7 +9931,7 @@ var_1 = byte ptr -1 les bx, _resident cmp es:[bx+resident_t.demo_num], 0 jnz short loc_10DC6 - mov _overlay_text, offset sub_10F36 + mov _overlay_text, offset popup_titles_update_and_render jmp short loc_10DDE ; --------------------------------------------------------------------------- @@ -9940,7 +9940,7 @@ loc_10DC6: call gaiji_putsa pascal, (18 shl 16) + 12, ds, offset gDEMO_PLAY, TX_YELLOW + TX_BLINK loc_10DDE: - mov _popup_byte_unknown, 0 + mov _popup_titles_frame, 0 jmp short loc_10E35 ; --------------------------------------------------------------------------- @@ -10070,438 +10070,12 @@ loc_10EA1: leave retn sub_10E39 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10EA5 proc near - -arg_0 = word ptr 4 -@@y = word ptr 6 -arg_4 = word ptr 8 - - push bp - mov bp, sp - push si - push di - mov si, [bp+arg_4] - mov di, [bp+arg_0] - dec si - add di, si - mov ax, 8 - imul di - mov di, ax - mov ax, 8 - imul si - mov si, ax - call main_01:scroll_subpixel_y_to_vram_seg1 pascal, [bp+@@y] - mov [bp+@@y], ax - mov ax, GRAM_400 - mov es, ax - assume es:nothing - jmp short loc_10EE3 -; --------------------------------------------------------------------------- - -loc_10ED1: - mov al, byte_22EF6 - mov ah, 0 - mov cx, ax - mov dx, [bp+@@y] - mov ax, si - call main_01:@bb_txt_put_8_raw - add si, 10h - -loc_10EE3: - cmp si, di - jl short loc_10ED1 - pop di - pop si - pop bp - retn 6 -sub_10EA5 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10EED proc near - -var_1 = byte ptr -1 - - enter 2, 0 - mov al, _popup_byte_unknown - add al, byte_22EA3 - mov [bp+var_1], al - cmp [bp+var_1], 0 - jz short locret_10F34 - cmp [bp+var_1], 0C0h - jnb short loc_10F0D - cmp [bp+var_1], 22h ; '"' - ja short locret_10F34 - -loc_10F0D: - mov _tile_invalidate_box.x, PLAYFIELD_W - mov _tile_invalidate_box.y, 32 - call main_01:tiles_invalidate_around pascal, large ((168 shl 4) shl 16) or (192 shl 4) - call main_01:tiles_invalidate_around pascal, large ((200 shl 4) shl 16) or (192 shl 4) - call main_01:tiles_invalidate_around pascal, large ((360 shl 4) shl 16) or (192 shl 4) - -locret_10F34: - leave - retn -sub_10EED endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_10F36 proc near - push bp - mov bp, sp - cmp _popup_byte_unknown, 0C0h - jb loc_10FED - cmp _popup_byte_unknown, 0C0h - jnz short loc_10F53 - call main_01:_playfield_tram_wipe - mov byte_22EF6, 0 - jmp short loc_10F5E -; --------------------------------------------------------------------------- - -loc_10F53: - test _popup_byte_unknown, 1 - jnz short loc_10F5E - inc byte_22EF6 - -loc_10F5E: - cmp byte_22EF6, 10h - jb short loc_10F80 - test _popup_byte_unknown, 1 - jz loc_1118F - mov _overlay_text, offset nullfunc_near - mov _popup_byte_unknown, 0 - mov byte_22EF6, 0 - pop bp - retn -; --------------------------------------------------------------------------- - -loc_10F80: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - cmp _stage_id, 5 - jnb short loc_10F99 - push 150A80h - push 0Eh - jmp short loc_10FA1 -; --------------------------------------------------------------------------- - -loc_10F99: - push 110A80h - push 16h - -loc_10FA1: - call main_01:sub_10EA5 - mov ax, 30h ; '0' - sub ax, _stage_bgm_title_len - push ax - push 16800002h - call main_01:sub_10EA5 - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _stage_bgm_title_len - push ax - push 1680h - push _stage_bgm_title_len - call main_01:sub_10EA5 - mov ax, _stage_title_len - cwd - sub ax, dx - sar ax, 1 - mov dx, 1Ch - sub dx, ax - push dx - push 0C80h - push _stage_title_len - call main_01:sub_10EA5 - GRCG_OFF_CLOBBERING dx - jmp loc_1118F -; --------------------------------------------------------------------------- - -loc_10FED: - cmp _popup_byte_unknown, 0 - jnz short loc_11057 - mov byte_22EF6, 10h - mov al, _stage_id - inc al - mov _stage_title_id, al - mov al, _stage_id - add al, al - inc al - mov _bgm_title_id, al - cmp _stage_id, 0 - jnz short loc_11023 - cmp _playchar, PLAYCHAR_REIMU - jnz short loc_11023 - mov _stage_title_id, 0 - mov _bgm_title_id, 0 - -loc_11023: - mov al, _stage_title_id - mov ah, 0 - shl ax, 2 - mov bx, ax - call _strlen c, large _STAGE_TITLES[bx] - mov _stage_title_len, ax - mov al, _bgm_title_id - mov ah, 0 - shl ax, 2 - mov bx, ax - call _strlen c, large _BGM_TITLES[bx] - mov _stage_bgm_title_len, ax - -loc_11057: - cmp byte_22EF6, 10h - jb loc_1118F - cmp byte_22EF6, 16h - jnz loc_11107 - mov al, _stage_id - add al, 0A1h - mov gStage_1+6, al - cmp _stage_id, 5 - jnz short loc_11084 - push (17 shl 16) + 11 - push ds - push offset gFINAL_STAGE - jmp short loc_110A1 -; --------------------------------------------------------------------------- - -loc_11084: - cmp _stage_id, 6 - jnz short loc_11097 - push (17 shl 16) + 11 - push ds - push offset gEXTRA_STAGE - jmp short loc_110A1 -; --------------------------------------------------------------------------- - -loc_11097: - push (21 shl 16) + 11 - push ds - push offset gStage_1 - -loc_110A1: - push TX_YELLOW - call gaiji_putsa - mov ax, _stage_title_len - cwd - sub ax, dx - sar ax, 1 - mov dx, 1Ch - sub dx, ax - push dx - push 13 - mov al, _stage_title_id - mov ah, 0 - shl ax, 2 - mov bx, ax - pushd _STAGE_TITLES[bx] - push TX_WHITE - call text_putsa - mov ax, 30h ; '0' - sub ax, _stage_bgm_title_len - call gaiji_putca pascal, ax, (23 shl 16) + 3, TX_YELLOW - mov ax, 33h ; '3' - sub ax, _stage_bgm_title_len - push ax - push 23 - mov al, _bgm_title_id - mov ah, 0 - shl ax, 2 - mov bx, ax - pushd _BGM_TITLES[bx] - push TX_WHITE - call text_putsa - -loc_11107: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - cmp _stage_id, 5 - jnb short loc_11120 - push 150A80h - push 0Eh - jmp short loc_11128 -; --------------------------------------------------------------------------- - -loc_11120: - push 110A80h - push 16h - -loc_11128: - call main_01:sub_10EA5 - mov ax, 30h ; '0' - sub ax, _stage_bgm_title_len - push ax - push 16800002h - call main_01:sub_10EA5 - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _stage_bgm_title_len - push ax - push 1680h - push _stage_bgm_title_len - call main_01:sub_10EA5 - mov ax, _stage_title_len - cwd - sub ax, dx - sar ax, 1 - mov dx, 1Ch - sub dx, ax - push dx - push 0C80h - push _stage_title_len - call main_01:sub_10EA5 - GRCG_OFF_CLOBBERING dx - test _popup_byte_unknown, 3 - jnz short loc_1118F - cmp _popup_byte_unknown, 0 - jz short loc_1118F - inc byte_22EF6 - cmp byte_22EF6, 18h - jb short loc_1118F - mov byte_22EF6, 0 - -loc_1118F: - inc _popup_byte_unknown - pop bp - retn -sub_10F36 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11195 proc near - push bp - mov bp, sp - cmp byte_22EA3, 0C0h - jb short loc_11211 - cmp byte_22EA3, 0C0h - jnz short loc_111B0 - call main_01:_playfield_tram_wipe - mov byte_22EF6, 0 - jmp short loc_111BB -; --------------------------------------------------------------------------- - -loc_111B0: - test byte_22EA3, 1 - jnz short loc_111BB - inc byte_22EF6 - -loc_111BB: - cmp byte_22EF6, 10h - jb short loc_111D8 - test byte_22EA3, 1 - jz loc_112D2 - mov _overlay_text, offset nullfunc_near - mov byte_22EA3, 0 - pop bp - retn -; --------------------------------------------------------------------------- - -loc_111D8: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - mov ax, 30h ; '0' - sub ax, _boss_bgm_title_len - push ax - push 16800002h - call main_01:sub_10EA5 - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _boss_bgm_title_len - push ax - push 1680h - push _boss_bgm_title_len - call main_01:sub_10EA5 - GRCG_OFF_CLOBBERING dx - jmp loc_112D2 -; --------------------------------------------------------------------------- - -loc_11211: - cmp byte_22EA3, 0 - jnz short loc_11237 - mov byte_22EF6, 10h - mov al, _bgm_title_id - mov ah, 0 - shl ax, 2 - mov bx, ax - call _strlen c, large _BGM_TITLES[bx] - mov _boss_bgm_title_len, ax - -loc_11237: - cmp byte_22EF6, 10h - jb loc_112D2 - cmp byte_22EF6, 16h - jnz short loc_1127E - mov ax, 30h ; '0' - sub ax, _boss_bgm_title_len - call gaiji_putca pascal, ax, (23 shl 16) + 3, TX_YELLOW - mov ax, 33h ; '3' - sub ax, _boss_bgm_title_len - push ax - push 23 - mov al, _bgm_title_id - mov ah, 0 - shl ax, 2 - mov bx, ax - pushd _BGM_TITLES[bx] - push TX_WHITE - call text_putsa - -loc_1127E: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - mov ax, 30h ; '0' - sub ax, _boss_bgm_title_len - push ax - push 16800002h - call main_01:sub_10EA5 - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _boss_bgm_title_len - push ax - push 1680h - push _boss_bgm_title_len - call main_01:sub_10EA5 - GRCG_OFF_CLOBBERING dx - test byte_22EA3, 3 - jnz short loc_112D2 - cmp byte_22EA3, 0 - jz short loc_112D2 - inc byte_22EF6 - cmp byte_22EF6, 18h - jb short loc_112D2 - mov byte_22EF6, 0 - -loc_112D2: - inc byte_22EA3 - pop bp - retn -sub_11195 endp main_0_TEXT ends + POPUP_TITLES_INVALIDATE procdesc near + POPUP_TITLES_UPDATE_AND_RENDER procdesc near + POPUP_BOSS_BGM_UPDATE_AND_RENDER procdesc near + main_01_TEXT segment byte public 'CODE' use16 include th04/main/hud/popup.asm @@ -32242,7 +31816,7 @@ loc_1E801: mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (48 shl 4) mov _bgm_title_id, 0Fh - mov _overlay_text, offset sub_11195 + mov _overlay_text, offset popup_boss_bgm_update_and_render call cdg_free pascal, 16 call bb_stage_free call cdg_load_single_noalpha pascal, 16, ds, offset aSt06bk2_cdg, 0 @@ -36348,14 +35922,12 @@ byte_22E9C db 0 _enemies_gone dw 0 _enemies_killed dw 0 byte_22EA2 db 0 -byte_22EA3 db 0 -public _popup_frame +public _popup_frame, _popup_boss_bgm_frame +_popup_boss_bgm_frame db 0 _popup_frame db 0 db 0 include th04/formats/bb_txt[data].asm include th04/main/hud/popup[data].asm -byte_22EF6 db 0 - db 0 public _PLAYFIELD_BLANK_ROW _PLAYFIELD_BLANK_ROW dd aPLAYFIELD_BLANK_ROW public _STAGE_TITLES, _BGM_TITLES diff --git a/th05/main011.cpp b/th05/main011.cpp new file mode 100644 index 000000000..99eff0bd6 --- /dev/null +++ b/th05/main011.cpp @@ -0,0 +1,10 @@ +/* ReC98 + * ----- + * 2nd part of code segment #1 of TH05's MAIN.EXE + */ + +#pragma codeseg main_0_TEXT main_01 + +extern "C" { +#include "th04/main/hud/popup.cpp" +} diff --git a/th05/main012.cpp b/th05/main012.cpp index af344c12d..1a82b3f62 100644 --- a/th05/main012.cpp +++ b/th05/main012.cpp @@ -1,6 +1,6 @@ /* ReC98 * ----- - * 2nd part of code segment #1 of TH05's MAIN.EXE + * 3rd part of code segment #1 of TH05's MAIN.EXE */ #pragma codeseg main_01_TEXT diff --git a/th05_main.asm b/th05_main.asm index d0f4c6f34..ba0c607af 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -1875,7 +1875,7 @@ include th04/main/tiles_invalidate_all.asm sub_BEE6 proc near push bp mov bp, sp - call sub_11A65 + call popup_titles_invalidate call player_invalidate call sub_123AD call enemies_invalidate @@ -5951,7 +5951,7 @@ sub_EE58 proc near mov _boss_update, eax mov ax, _boss_fg_render_func mov _boss_fg_render, ax - mov _overlay_text, offset sub_11CBB + mov _overlay_text, offset popup_boss_bgm_update_and_render mov al, 1 pop bp retn @@ -10062,7 +10062,7 @@ var_1 = byte ptr -1 jnz short loc_1193E loc_11936: - mov _overlay_text, offset sub_11AAE + mov _overlay_text, offset popup_titles_update_and_render jmp short loc_11956 ; --------------------------------------------------------------------------- @@ -10071,7 +10071,7 @@ loc_1193E: call gaiji_putsa pascal, (18 shl 16) + 12, ds, offset gDEMO_PLAY, TX_YELLOW + TX_BLINK loc_11956: - mov _popup_byte_unknown, 0 + mov _popup_titles_frame, 0 jmp short loc_119AD ; --------------------------------------------------------------------------- @@ -10201,387 +10201,12 @@ loc_11A19: leave retn sub_119B1 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11A1D proc near - -arg_0 = word ptr 4 -@@y = word ptr 6 -arg_4 = word ptr 8 - - push bp - mov bp, sp - push si - push di - mov si, [bp+arg_4] - mov di, [bp+arg_0] - dec si - add di, si - mov ax, 8 - imul di - mov di, ax - mov ax, 8 - imul si - mov si, ax - call scroll_subpixel_y_to_vram_seg1 pascal, [bp+@@y] - mov [bp+@@y], ax - mov ax, GRAM_400 - mov es, ax - assume es:nothing - jmp short loc_11A5B -; --------------------------------------------------------------------------- - -loc_11A49: - mov al, byte_228EC - mov ah, 0 - mov cx, ax - mov dx, [bp+@@y] - mov ax, si - call @bb_txt_put_8_raw - add si, 10h - -loc_11A5B: - cmp si, di - jl short loc_11A49 - pop di - pop si - pop bp - retn 6 -sub_11A1D endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11A65 proc near - -var_1 = byte ptr -1 - - enter 2, 0 - mov al, _popup_byte_unknown - add al, byte_2288B - mov [bp+var_1], al - cmp [bp+var_1], 0 - jz short locret_11AAC - cmp [bp+var_1], 0C0h - jnb short loc_11A85 - cmp [bp+var_1], 22h ; '"' - ja short locret_11AAC - -loc_11A85: - mov _tile_invalidate_box.x, PLAYFIELD_W - mov _tile_invalidate_box.y, 32 - call tiles_invalidate_around pascal, large ((168 shl 4) shl 16) or (192 shl 4) - call tiles_invalidate_around pascal, large ((200 shl 4) shl 16) or (192 shl 4) - call tiles_invalidate_around pascal, large ((360 shl 4) shl 16) or (192 shl 4) - -locret_11AAC: - leave - retn -sub_11A65 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11AAE proc near - push bp - mov bp, sp - cmp _popup_byte_unknown, 0C0h - jb loc_11B65 - cmp _popup_byte_unknown, 0C0h - jnz short loc_11ACB - call _playfield_tram_wipe - mov byte_228EC, 0 - jmp short loc_11AD6 -; --------------------------------------------------------------------------- - -loc_11ACB: - test _popup_byte_unknown, 1 - jnz short loc_11AD6 - inc byte_228EC - -loc_11AD6: - cmp byte_228EC, 10h - jb short loc_11AF8 - test _popup_byte_unknown, 1 - jz loc_11CB5 - mov _overlay_text, offset nullfunc_near - mov _popup_byte_unknown, 0 - mov byte_228EC, 0 - pop bp - retn -; --------------------------------------------------------------------------- - -loc_11AF8: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - cmp _stage_id, 5 - jnb short loc_11B11 - push 150A80h - push 0Eh - jmp short loc_11B19 -; --------------------------------------------------------------------------- - -loc_11B11: - push 110A80h - push 16h - -loc_11B19: - call sub_11A1D - mov ax, 30h ; '0' - sub ax, _stage_bgm_title_len - push ax - push 16800002h - call sub_11A1D - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _stage_bgm_title_len - push ax - push 1680h - push _stage_bgm_title_len - call sub_11A1D - mov ax, _stage_title_len - cwd - sub ax, dx - sar ax, 1 - mov dx, 1Ch - sub dx, ax - push dx - push 0C80h - push _stage_title_len - call sub_11A1D - GRCG_OFF_CLOBBERING dx - jmp loc_11CB5 -; --------------------------------------------------------------------------- - -loc_11B65: - cmp _popup_byte_unknown, 0 - jnz short loc_11B91 - mov byte_228EC, 10h - call _strlen c, large [_stage_title] - mov _stage_title_len, ax - call _strlen c, large [_stage_bgm_title] - mov _stage_bgm_title_len, ax - -loc_11B91: - cmp byte_228EC, 10h - jb loc_11CB5 - cmp byte_228EC, 16h - jnz loc_11C2D - mov al, _stage_id - add al, 0A1h - mov gStage_1+6, al - cmp _stage_id, 5 - jnz short loc_11BBE - push (17 shl 16) + 11 - push ds - push offset gFINAL_STAGE - jmp short loc_11BDB -; --------------------------------------------------------------------------- - -loc_11BBE: - cmp _stage_id, 6 - jnz short loc_11BD1 - push (17 shl 16) + 11 - push ds - push offset gEXTRA_STAGE - jmp short loc_11BDB -; --------------------------------------------------------------------------- - -loc_11BD1: - push (21 shl 16) + 11 - push ds - push offset gStage_1 - -loc_11BDB: - push TX_YELLOW - call gaiji_putsa - mov ax, _stage_title_len - cwd - sub ax, dx - sar ax, 1 - mov dx, 1Ch - sub dx, ax - call text_putsa pascal, dx, 13, _stage_title, TX_WHITE - mov ax, 30h ; '0' - sub ax, _stage_bgm_title_len - call gaiji_putca pascal, ax, (23 shl 16) + 3, TX_YELLOW - mov ax, 33h ; '3' - sub ax, _stage_bgm_title_len - call text_putsa pascal, ax, 23, _stage_bgm_title, TX_WHITE - -loc_11C2D: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - cmp _stage_id, 5 - jnb short loc_11C46 - push 150A80h - push 0Eh - jmp short loc_11C4E -; --------------------------------------------------------------------------- - -loc_11C46: - push 110A80h - push 16h - -loc_11C4E: - call sub_11A1D - mov ax, 30h ; '0' - sub ax, _stage_bgm_title_len - push ax - push 16800002h - call sub_11A1D - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _stage_bgm_title_len - push ax - push 1680h - push _stage_bgm_title_len - call sub_11A1D - mov ax, _stage_title_len - cwd - sub ax, dx - sar ax, 1 - mov dx, 1Ch - sub dx, ax - push dx - push 0C80h - push _stage_title_len - call sub_11A1D - GRCG_OFF_CLOBBERING dx - test _popup_byte_unknown, 3 - jnz short loc_11CB5 - cmp _popup_byte_unknown, 0 - jz short loc_11CB5 - inc byte_228EC - cmp byte_228EC, 18h - jb short loc_11CB5 - mov byte_228EC, 0 - -loc_11CB5: - inc _popup_byte_unknown - pop bp - retn -sub_11AAE endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_11CBB proc near - push bp - mov bp, sp - cmp byte_2288B, 0C0h - jb short loc_11D37 - cmp byte_2288B, 0C0h - jnz short loc_11CD6 - call _playfield_tram_wipe - mov byte_228EC, 0 - jmp short loc_11CE1 -; --------------------------------------------------------------------------- - -loc_11CD6: - test byte_2288B, 1 - jnz short loc_11CE1 - inc byte_228EC - -loc_11CE1: - cmp byte_228EC, 10h - jb short loc_11CFE - test byte_2288B, 1 - jz loc_11DE4 - mov _overlay_text, offset nullfunc_near - mov byte_2288B, 0 - pop bp - retn -; --------------------------------------------------------------------------- - -loc_11CFE: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - mov ax, 30h ; '0' - sub ax, _boss_bgm_title_len - push ax - push 16800002h - call sub_11A1D - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _boss_bgm_title_len - push ax - push 1680h - push _boss_bgm_title_len - call sub_11A1D - GRCG_OFF_CLOBBERING dx - jmp loc_11DE4 -; --------------------------------------------------------------------------- - -loc_11D37: - cmp byte_2288B, 0 - jnz short loc_11D53 - mov byte_228EC, 10h - call _strlen c, large [_boss_bgm_title] - mov _boss_bgm_title_len, ax - -loc_11D53: - cmp byte_228EC, 10h - jb loc_11DE4 - cmp byte_228EC, 16h - jnz short loc_11D90 - mov ax, 30h ; '0' - sub ax, _boss_bgm_title_len - call gaiji_putca pascal, ax, (23 shl 16) + 3, TX_YELLOW - mov ax, 33h ; '3' - sub ax, _boss_bgm_title_len - call text_putsa pascal, ax, 23, _boss_bgm_title, TX_WHITE - -loc_11D90: - call _grcg_setmode_rmw_seg1 - mov ah, GC_G - call _grcg_setcolor_direct_seg1_raw - mov ax, 30h ; '0' - sub ax, _boss_bgm_title_len - push ax - push 16800002h - call sub_11A1D - mov ah, 0Fh - call _grcg_setcolor_direct_seg1_raw - mov ax, 33h ; '3' - sub ax, _boss_bgm_title_len - push ax - push 1680h - push _boss_bgm_title_len - call sub_11A1D - GRCG_OFF_CLOBBERING dx - test byte_2288B, 3 - jnz short loc_11DE4 - cmp byte_2288B, 0 - jz short loc_11DE4 - inc byte_228EC - cmp byte_228EC, 18h - jb short loc_11DE4 - mov byte_228EC, 0 - -loc_11DE4: - inc byte_2288B - pop bp - retn -sub_11CBB endp main_0_TEXT ends + POPUP_TITLES_INVALIDATE procdesc near + POPUP_TITLES_UPDATE_AND_RENDER procdesc near + POPUP_BOSS_BGM_UPDATE_AND_RENDER procdesc near + main_01_TEXT segment byte public 'CODE' use16 include th04/main/hud/popup.asm @@ -21414,7 +21039,7 @@ loc_1AF66: loc_1AF85: call sub_F2B4 - mov _overlay_text, offset sub_11CBB + mov _overlay_text, offset popup_boss_bgm_update_and_render mov _boss_phase, 0 mov _boss_phase_frame, 0 mov _boss_fg_render, offset sub_10F12 @@ -29678,14 +29303,12 @@ off_22884 dw offset sub_1F776 dw offset sub_1F7BA dw offset sub_1F823 byte_2288A db 0 -byte_2288B db 0 -public _popup_frame +public _popup_frame, _popup_boss_bgm_frame +_popup_boss_bgm_frame db 0 _popup_frame db 0 db 0 include th04/formats/bb_txt[data].asm include th04/main/hud/popup[data].asm -byte_228EC db 0 - db 0 public _PLAYFIELD_BLANK_ROW _PLAYFIELD_BLANK_ROW dd aPLAYFIELD_BLANK_ROW include th04/strings/demoplay[data].asm @@ -29942,7 +29565,6 @@ byte_2CE56 db ? patnum_2CE64 dw ? fp_2CE66 dw ? fp_2CE68 dw ? - include th04/main/hud/popup[bss].asm public _stage_title, _stage_bgm_title, _boss_bgm_title