diff --git a/th01/end/end.cpp b/th01/end/end.cpp index 02cd45ef..0d0d058f 100644 --- a/th01/end/end.cpp +++ b/th01/end/end.cpp @@ -26,7 +26,7 @@ extern "C" { #include "th01/end/type.hpp" #include "th01/end/vars.hpp" #include "th01/shiftjis/end.hpp" -#include "th01/shiftjis/regist.hpp" +#include "th01/shiftjis/scoredat.hpp" #include "th01/shiftjis/title.hpp" // > rendering text to VRAM, where it wouldn't be limited to the byte grid @@ -597,9 +597,9 @@ void verdict_animate_and_regist(void) grp_palette_settone(50); regist_colors_set(); if(end_flag == ES_MAKAI) { - regist(score, SCOREDAT_CLEARED_MAKAI, REGIST_ROUTE_CLEAR); + regist(score, SCOREDAT_CLEARED_MAKAI, SCOREDAT_ROUTE_CLEAR); } else { - regist(score, SCOREDAT_CLEARED_JIGOKU, REGIST_ROUTE_CLEAR); + regist(score, SCOREDAT_CLEARED_JIGOKU, SCOREDAT_ROUTE_CLEAR); } end_resident_clear(); } diff --git a/th01/fuuin_02.cpp b/th01/fuuin_02.cpp index 2d011c55..703126d3 100644 --- a/th01/fuuin_02.cpp +++ b/th01/fuuin_02.cpp @@ -21,6 +21,8 @@ extern "C" { #include "th01/hardware/graph.h" #include "th01/hardware/input.hpp" } +#include "th01/shiftjis/fns.hpp" +#include "th01/shiftjis/regist.hpp" #include "th01/hiscore/scoredat.hpp" #include "th01/hardware/grppfnfx.cpp" @@ -67,18 +69,13 @@ void input_sense(bool16 reset_repeat) extern unsigned char rank; -extern const char SCOREDAT_ERROR_NOT_FOUND[]; -extern const char SCOREDAT_ERROR_INVALID[]; -extern const char FOPEN_RB[]; -extern const char FOPEN_WB[]; - #define scoredat_declare() FILE *fp; #define scoredat_cli() disable() #define scoredat_sti() enable() #define scoredat_error(str) printf(str) #define scoredat_exist(fn) !access(fn, 0) -#define scoredat_create(fn) (fp = fopen(fn, FOPEN_WB)) -#define scoredat_ropen(fn) (fp = fopen(fn, FOPEN_RB)) +#define scoredat_create(fn) (fp = fopen(fn, "wb")) +#define scoredat_ropen(fn) (fp = fopen(fn, "rb")) #define scoredat_read(buf, size) read(fileno(fp), buf, size) #define scoredat_write(buf, size) write(fileno(fp), buf, size) #define scoredat_close() fclose(fp) @@ -87,20 +84,15 @@ extern const char FOPEN_WB[]; #include "th01/hiscore/score_nm.cpp" #define graph_putkanji_fx_declare() -#define graph_putkanji_fx(left, top, fx, fmt_instance, kanji) \ - extern const char ALPHABET_KANJI_FMT_##fmt_instance[]; \ - graph_printf_fx( \ - left, top, fx, \ - ALPHABET_KANJI_FMT_##fmt_instance, kanji >> 8, kanji & 0xFF \ - ) +#define graph_putkanji_fx(left, top, fx, kanji) { \ + graph_printf_fx(left, top, fx, "%c%c", (kanji >> 8), (kanji & 0xFF)); \ +} -#define graph_printf_s_fx(left, top, fx, fmt_instance, str) \ - extern const char REGIST_STRING_FMT_##fmt_instance[]; \ - graph_printf_fx(left, top, fx, REGIST_STRING_FMT_##fmt_instance, str); +#define graph_printf_s_fx(left, top, fx, str) \ + graph_printf_fx(left, top, fx, "%s", str); #define regist_route_put(left, top, fx, char_1, char_2) \ - extern const char REGIST_ROUTE_FMT[]; \ - graph_printf_fx(left, top, fx, REGIST_ROUTE_FMT, char_1, char_2); + graph_printf_fx(left, top, fx, "%c%c", char_1, char_2); #define regist_input_timeout_declare() #define regist_input_timeout_reset() @@ -111,8 +103,9 @@ inline void regist_bg_put(const int16_t stage) { } #define regist_title_put(left, stage, ranks, fx) { \ - extern const char REGIST_TITLE_FMT[]; \ - graph_printf_fx(left, TITLE_TOP, fx, REGIST_TITLE_FMT, ranks[rank]); \ + graph_printf_fx( \ + left, TITLE_TOP, fx, REGIST_TITLE_WITH_SPACE "%s", ranks[rank] \ + ); \ } #include "th01/hiscore/regist.cpp" diff --git a/th01/hardware/grppfnfx.cpp b/th01/hardware/grppfnfx.cpp index 207f5560..8aa9be57 100644 --- a/th01/hardware/grppfnfx.cpp +++ b/th01/hardware/grppfnfx.cpp @@ -1,9 +1,4 @@ -struct hack { const char* NUM[10]; }; // XXX -#if (BINARY == 'M') #include "th01/shiftjis/fwnum.hpp" -#else -extern const hack FULLWIDTH_NUMERALS; -#endif void graph_putfwnum_fx( screen_x_t left, vram_y_t top, int16_t col_and_fx, int digits, @@ -15,7 +10,7 @@ void graph_putfwnum_fx( int digit; int digit_prev; unsigned long divisor = 1; - const hack FW = FULLWIDTH_NUMERALS; + const char* FULLWIDTH_NUMERAL[10] = FULLWIDTH_NUMERALS; for(divisor_i = 0; divisor_i < digits; divisor_i++) { divisor *= 10; @@ -33,7 +28,7 @@ void graph_putfwnum_fx( put = true; } if(put && ((digit != digit_prev) || !num_prev)) { - graph_putsa_fx(x, top, col_and_fx, FW.NUM[digit]); + graph_putsa_fx(x, top, col_and_fx, FULLWIDTH_NUMERAL[digit]); } x += GLYPH_FULL_W; } while(divisor > 1); diff --git a/th01/hardware/grppfnfx[data].asm b/th01/hardware/grppfnfx[data].asm deleted file mode 100644 index dfc67343..00000000 --- a/th01/hardware/grppfnfx[data].asm +++ /dev/null @@ -1,11 +0,0 @@ -aFW_0 db '0',0 -aFW_1 db '1',0 -aFW_2 db '2',0 -aFW_3 db '3',0 -aFW_4 db '4',0 -aFW_5 db '5',0 -aFW_6 db '6',0 -aFW_7 db '7',0 -aFW_8 db '8',0 -aFW_9 db '9',0 - evendata diff --git a/th01/hardware/grppfnfx_ptrs[data].asm b/th01/hardware/grppfnfx_ptrs[data].asm deleted file mode 100644 index 8201cb75..00000000 --- a/th01/hardware/grppfnfx_ptrs[data].asm +++ /dev/null @@ -1,3 +0,0 @@ -public _FULLWIDTH_NUMERALS -_FULLWIDTH_NUMERALS label dword - dd aFW_0, aFW_1, aFW_2, aFW_3, aFW_4, aFW_5, aFW_6, aFW_7, aFW_8, aFW_9 diff --git a/th01/hiscore/alphabet_syms[data].asm b/th01/hiscore/alphabet_syms[data].asm deleted file mode 100644 index 0e27f099..00000000 --- a/th01/hiscore/alphabet_syms[data].asm +++ /dev/null @@ -1,4 +0,0 @@ -public _ALPHABET_SYMS -_ALPHABET_SYMS label word - dw '!', '?', '#', '&', '*', '§', '☆', '◆', '∞' - dw '∴', '♂', '♀', '…', '“', '”', '/', '.', '・' diff --git a/th01/hiscore/regist.cpp b/th01/hiscore/regist.cpp index 7e37d6ef..bb1a6868 100644 --- a/th01/hiscore/regist.cpp +++ b/th01/hiscore/regist.cpp @@ -89,20 +89,19 @@ inline pixel_t left_for(int kanji_id) { return (((kanji_id % KANJI_PER_ROW) * KANJI_PADDED_W) + MARGIN_W); } -#define alphabet_putca_fx(top_for_0, i, fx, fmt_instance, kanji) \ +#define alphabet_putca_fx(top_for_0, i, fx, kanji) { \ graph_putkanji_fx( \ - left_for(i), (top_for_0 + relative_top_for(i)), fx, fmt_instance, kanji \ - ); + left_for(i), (top_for_0 + relative_top_for(i)), fx, kanji \ + ); \ +} -#define alphabet_putsa_fx(top_for_0, i, fx, str) \ - extern const char str[]; \ - graph_printf_fx(left_for(i), (top_for_0 + relative_top_for(i)), fx, str); +#define alphabet_putsa_fx(top_for_0, i, fx, str) { \ + graph_printf_fx(left_for(i), (top_for_0 + relative_top_for(i)), fx, str); \ +} #define A_TO_Z_COUNT 26 #define NUM_COUNT 10 -// TODO: Should be derived via `sizeof()` once the array is declared here. -#define SYM_COUNT 18 -extern const uint16_t ALPHABET_SYMS[]; +static const int SYM_COUNT = (sizeof(ALPHABET_SYMS) / sizeof(uint16_t)); // Rows #define LOWER_TOP (ALPHABET_TOP) @@ -120,10 +119,6 @@ extern const uint16_t ALPHABET_SYMS[]; #define RIGHT_LEFT left_for(LEFT_COLUMN + 1) #define ENTER_LEFT left_for(LEFT_COLUMN + 2) -inline uint16_t kanji_swap(uint16_t kanji) { - return (kanji << 8) | (kanji >> 8); -} - inline unsigned char kanji_hi(int16_t kanji) { return (kanji >> 8); } @@ -140,12 +135,11 @@ void alphabet_put_initial() int i; graph_putkanji_fx_declare(); - kanji = kanji_swap('b'); + kanji = KANJI_b; for(i = 1; i < A_TO_Z_COUNT; i++) { - alphabet_putca_fx(LOWER_TOP, i, col_and_fx, 0, kanji); + alphabet_putca_fx(LOWER_TOP, i, col_and_fx, kanji); kanji++; } - extern const char ALPHABET_A[]; graph_putsa_fx( MARGIN_W, LOWER_TOP, @@ -153,20 +147,20 @@ void alphabet_put_initial() ALPHABET_A ); - kanji = kanji_swap('A'); + kanji = KANJI_A; for(i = 0; i < A_TO_Z_COUNT; i++) { - alphabet_putca_fx(UPPER_TOP, i, col_and_fx, 1, kanji); + alphabet_putca_fx(UPPER_TOP, i, col_and_fx, kanji); kanji++; } for(i = 0; i < SYM_COUNT; i++) { kanji = ALPHABET_SYMS[i]; - alphabet_putca_fx(SYM_TOP, i, col_and_fx, 2, kanji); + alphabet_putca_fx(SYM_TOP, i, col_and_fx, kanji); } - kanji = kanji_swap('0'); + kanji = KANJI_0; for(i = 0; i < NUM_COUNT; i++) { - alphabet_putca_fx(NUM_TOP, i, col_and_fx, 3, kanji); + alphabet_putca_fx(NUM_TOP, i, col_and_fx, kanji); kanji++; } alphabet_putsa_fx(NUM_TOP, i, col_and_fx, ALPHABET_SPACE); i = LEFT_COLUMN; @@ -192,29 +186,7 @@ void regist_put_initial( const scoredat_name_z_t names_z[SCOREDAT_PLACES] ) { - struct hack { - unsigned char byte[SCOREDAT_NAME_BYTES + 1]; - }; - extern const hack REGIST_NAME_BLANK; - extern const char REGIST_HEADER_PLACE[]; - extern const char REGIST_HEADER_NAME[]; - extern const char REGIST_HEADER_SCORE[]; - extern const char REGIST_HEADER_STAGE_ROUTE[]; - extern const char REGIST_PLACE_0[]; - extern const char REGIST_PLACE_1[]; - extern const char REGIST_PLACE_2[]; - extern const char REGIST_PLACE_3[]; - extern const char REGIST_PLACE_4[]; - extern const char REGIST_PLACE_5[]; - extern const char REGIST_PLACE_6[]; - extern const char REGIST_PLACE_7[]; - extern const char REGIST_PLACE_8[]; - extern const char REGIST_PLACE_9[]; - extern const char REGIST_STAGE_MAKAI[]; - extern const char REGIST_STAGE_JIGOKU[]; - extern const char REGIST_STAGE_ROUTE_DASH[]; - - hack name = REGIST_NAME_BLANK; + const unsigned char name_blank[SCOREDAT_NAME_BYTES + 1] = REGIST_NAME_BLANK; graph_accesspage_func(0); @@ -259,7 +231,7 @@ void regist_put_initial( table_name_left(0), top, col_and_fx_text, - (i == entered_place) ? name.byte : names_z[i].byte + (i == entered_place) ? name_blank : names_z[i].byte ); graph_putfwnum_fx( table_score_left(0), @@ -313,22 +285,19 @@ void regist_put_initial( #define alphabet_left_to_column(left) \ ((left - left_for(0)) / KANJI_PADDED_W) -#define alphabet_left_to_kanji(left, kanji_at_0) \ - (alphabet_left_to_column(left) + kanji_swap(kanji_at_0)) - #define alphabet_if(kanji, left, top, on_space, on_left, on_right, on_enter) \ if(top == LOWER_TOP) { \ - kanji = alphabet_left_to_kanji(left, 'a'); \ + kanji = (KANJI_a + alphabet_left_to_column(left)); \ } else if(top == LOWER2_TOP) { \ - kanji = alphabet_left_to_kanji(left, 'a') + KANJI_PER_ROW; \ + kanji = (KANJI_a + alphabet_left_to_column(left)) + KANJI_PER_ROW; \ } else if(top == UPPER_TOP) { \ - kanji = alphabet_left_to_kanji(left, 'A'); \ + kanji = (KANJI_A + alphabet_left_to_column(left)); \ } else if(top == UPPER2_TOP) { \ - kanji = alphabet_left_to_kanji(left, 'A') + KANJI_PER_ROW; \ + kanji = (KANJI_A + alphabet_left_to_column(left)) + KANJI_PER_ROW; \ } else if(top == SYM_TOP) { \ kanji = ALPHABET_SYMS[alphabet_left_to_column(left)]; \ } else if(top == NUM_TOP && left < SPACE_LEFT) { \ - kanji = alphabet_left_to_kanji(left, '0'); \ + kanji = (KANJI_0 + alphabet_left_to_column(left)); \ } else if((top == NUM_TOP) && (left == SPACE_LEFT)) { \ on_space \ } else if((top == NUM_TOP) && (left == LEFT_LEFT)) { \ @@ -341,12 +310,6 @@ void regist_put_initial( void alphabet_put_at(screen_x_t left, screen_y_t top, bool16 is_selected) { - // Placement matters with -O-! - extern const char ALPHABET_SPACE_0[]; - extern const char ALPHABET_LEFT_0[]; - extern const char ALPHABET_RIGHT_0[]; - extern const char ALPHABET_ENTER_0[]; - int16_t kanji = '\0'; egc_copy_rect_1_to_0_16(left, top, KANJI_PADDED_W, GLYPH_H); @@ -356,24 +319,25 @@ void alphabet_put_at(screen_x_t left, screen_y_t top, bool16 is_selected) )); alphabet_if(kanji, left, top, - { graph_printf_fx(left, top, col_and_fx, ALPHABET_SPACE_0); }, - { graph_printf_fx(left, top, col_and_fx, ALPHABET_LEFT_0); }, - { graph_printf_fx(left, top, col_and_fx, ALPHABET_RIGHT_0); }, - { graph_printf_fx(left, top, col_and_fx, ALPHABET_ENTER_0); } + { graph_printf_fx(left, top, col_and_fx, ALPHABET_SPACE); }, + { graph_printf_fx(left, top, col_and_fx, ALPHABET_LEFT); }, + { graph_printf_fx(left, top, col_and_fx, ALPHABET_RIGHT); }, + { graph_printf_fx(left, top, col_and_fx, ALPHABET_ENTER); } ); if(kanji != '\0') { graph_putkanji_fx_declare(); - graph_putkanji_fx(left, top, col_and_fx, 4, kanji); + graph_putkanji_fx(left, top, col_and_fx, kanji); } } #if (BINARY == 'M') - extern bool regist_jump_to_enter; + bool regist_jump_to_enter = false; #endif -#define set_kanji_at(name, pos, kanji) \ - name.byte[(pos * 2) + 0] = kanji_hi(kanji); \ - name.byte[(pos * 2) + 1] = kanji_lo(kanji); +#define set_kanji_at(name, pos, kanji) { \ + name[(pos * 2) + 0] = kanji_hi(kanji); \ + name[(pos * 2) + 1] = kanji_lo(kanji); \ +} int regist_on_shot( screen_x_t left, @@ -383,21 +347,17 @@ int regist_on_shot( ) { int16_t kanji = '\0'; - struct hack { - unsigned char byte[SCOREDAT_NAME_BYTES + 1]; - }; - extern const hack REGIST_NAME_SPACES; - hack cursor_str = REGIST_NAME_SPACES; + unsigned char cursor_str[SCOREDAT_NAME_BYTES + 1] = REGIST_NAME_SPACES; alphabet_if(kanji, left, top, - { kanji = kanji_swap(' '); }, + { kanji = KANJI_SP; }, { clamp_dec(entered_name_cursor, 0); }, { clamp_inc(entered_name_cursor, (SCOREDAT_NAME_KANJI - 1)); }, { return 1; } ); if(kanji != '\0') { - set_kanji_at(entered_name, entered_name_cursor, kanji); + set_kanji_at(entered_name.byte, entered_name_cursor, kanji); #if (BINARY == 'M') if(entered_name_cursor == (SCOREDAT_NAME_KANJI - 1)) { regist_jump_to_enter = true; @@ -418,17 +378,12 @@ int regist_on_shot( entered_name_left, entered_name_top, (COL_REGIST_SELECTED | FX_WEIGHT_BOLD), - 0, entered_name.byte ); - set_kanji_at(cursor_str, entered_name_cursor, kanji_swap('_')); + set_kanji_at(cursor_str, entered_name_cursor, KANJI_UNDERSCORE); graph_printf_s_fx( - entered_name_left, - entered_name_top, - COL_REGIST_SELECTED, - 1, - cursor_str.byte + entered_name_left, entered_name_top, COL_REGIST_SELECTED, cursor_str ); return 0; } @@ -561,27 +516,15 @@ regist_input_ret_t regist_on_input( void scoredat_save(void) { - extern const char SCOREDAT_FN_EASY_2[]; - extern const char SCOREDAT_FN_NORMAL_2[]; - extern const char SCOREDAT_FN_HARD_2[]; - extern const char SCOREDAT_FN_LUNATIC_2[]; - extern const char SCOREDAT_FOPEN_WB[]; - - struct hack { - char x[sizeof(SCOREDAT_MAGIC)]; - }; - #undef SCOREDAT_MAGIC - extern const hack SCOREDAT_MAGIC; - FILE* fp; - const hack magic = SCOREDAT_MAGIC; + const char magic[sizeof(SCOREDAT_MAGIC)] = SCOREDAT_MAGIC; // ZUN bloat char fn[16]; - scoredat_fn(fn, 2); + scoredat_fn(fn); - if( (fp = fopen(fn, SCOREDAT_FOPEN_WB)) == nullptr) { + if( (fp = fopen(fn, "wb")) == nullptr) { return; } - write(fileno(fp), magic.x, sizeof(SCOREDAT_MAGIC) - 1); + write(fileno(fp), magic, sizeof(SCOREDAT_MAGIC) - 1); for(int i = 0; i < SCOREDAT_NAMES_SIZE; i++) { scoredat_names[i] = scoredat_name_byte_encode(scoredat_names[i]); } @@ -648,13 +591,8 @@ void regist( int32_t score, int16_t stage, const char route[SCOREDAT_ROUTE_LEN + 1] ) { - struct hack { - const char *r[4]; - }; - extern const hack REGIST_TITLE_RANKS; - scoredat_name_z_t names[SCOREDAT_PLACES]; - const hack RANKS = REGIST_TITLE_RANKS; + const char* RANKS[RANK_COUNT] = REGIST_TITLE_RANKS; long place; regist_bg_put(stage); @@ -664,7 +602,7 @@ void regist( regist_title_put( TITLE_BACK_LEFT, stage, - RANKS.r, + RANKS, (COL_REGIST_REGULAR | FX_WEIGHT_BOLD | FX_CLEAR_BG) ); // On page 1, the title should now at (TITLE_BACK_LEFT, TITLE_BACK_TOP) if diff --git a/th01/hiscore/regist[data].asm b/th01/hiscore/regist[data].asm deleted file mode 100644 index 8db47469..00000000 --- a/th01/hiscore/regist[data].asm +++ /dev/null @@ -1,79 +0,0 @@ -public _ALPHABET_A -public _ALPHABET_SPACE, _ALPHABET_LEFT, _ALPHABET_RIGHT, _ALPHABET_ENTER - -if BINARY eq 'E' - public _ALPHABET_KANJI_FMT_0, _ALPHABET_KANJI_FMT_1 - public _ALPHABET_KANJI_FMT_2, _ALPHABET_KANJI_FMT_3 - _ALPHABET_KANJI_FMT_0 db '%c%c',0 - _ALPHABET_A db 'a',0 - _ALPHABET_KANJI_FMT_1 db '%c%c',0 - _ALPHABET_KANJI_FMT_2 db '%c%c',0 - _ALPHABET_KANJI_FMT_3 db '%c%c',0 -else - _ALPHABET_A db 'a',0 -endif -_ALPHABET_SPACE db 'SP',0 -_ALPHABET_LEFT db '←',0 -_ALPHABET_RIGHT db '→',0 -_ALPHABET_ENTER db '終',0 - -public _REGIST_HEADER_PLACE, _REGIST_HEADER_NAME -public _REGIST_HEADER_SCORE, _REGIST_HEADER_STAGE_ROUTE -public _REGIST_PLACE_0, _REGIST_PLACE_1, _REGIST_PLACE_2, _REGIST_PLACE_3 -public _REGIST_PLACE_4, _REGIST_PLACE_5, _REGIST_PLACE_6, _REGIST_PLACE_7 -public _REGIST_PLACE_8, _REGIST_PLACE_9 -public _REGIST_STAGE_MAKAI, _REGIST_STAGE_JIGOKU, _REGIST_STAGE_ROUTE_DASH -_REGIST_HEADER_PLACE db ' 霊 位 ',0 -_REGIST_HEADER_NAME db '  名  前  ',0 -_REGIST_HEADER_SCORE db '  得  点  ',0 -_REGIST_HEADER_STAGE_ROUTE db 'ステージ・ルート',0 -_REGIST_PLACE_0 db ' 靈 神 ',0 -_REGIST_PLACE_1 db '太元帥明王',0 -_REGIST_PLACE_2 db ' 天 仙 ',0 -_REGIST_PLACE_3 db ' 神 仙 ',0 -_REGIST_PLACE_4 db ' 地 仙 ',0 -_REGIST_PLACE_5 db ' 人 仙 ',0 -_REGIST_PLACE_6 db ' 仙 女 ',0 -_REGIST_PLACE_7 db '陰 陽 師',0 -_REGIST_PLACE_8 db '靈 媒 師',0 -_REGIST_PLACE_9 db '修 業 者',0 -_REGIST_STAGE_MAKAI db '魔界',0 -_REGIST_STAGE_JIGOKU db '地獄',0 -_REGIST_STAGE_ROUTE_DASH db '−',0 -if BINARY eq 'E' - public _REGIST_ROUTE_FMT - _REGIST_ROUTE_FMT db '%c%c',0 - - public _ALPHABET_SPACE_0, _ALPHABET_LEFT_0 - public _ALPHABET_RIGHT_0, _ALPHABET_ENTER_0, _ALPHABET_KANJI_FMT_4 - public _REGIST_STRING_FMT_0, _REGIST_STRING_FMT_1 - _ALPHABET_SPACE_0 db 'SP',0 - _ALPHABET_LEFT_0 db '←',0 - _ALPHABET_RIGHT_0 db '→',0 - _ALPHABET_ENTER_0 db '終',0 - _ALPHABET_KANJI_FMT_4 db '%c%c',0 - _REGIST_STRING_FMT_0 db '%s',0 - _REGIST_STRING_FMT_1 db '%s',0 - _SCOREDAT_FN_EASY_2 db 'REYHIES.DAT',0 - _SCOREDAT_FN_NORMAL_2 db 'REYHINO.DAT',0 - _SCOREDAT_FN_HARD_2 db 'REYHIHA.DAT',0 - _SCOREDAT_FN_LUNATIC_2 db 'REYHILU.DAT',0 -endif -public _SCOREDAT_FOPEN_WB -_SCOREDAT_FOPEN_WB db 'wb',0 -_REGIST_TITLE_RANK_EASY db ' イージー ',0 -_REGIST_TITLE_RANK_NORMAL db ' ノーマル ',0 -_REGIST_TITLE_RANK_HARD db ' ハード  ',0 -_REGIST_TITLE_RANK_LUNATIC db 'ルナティック',0 - -if BINARY eq 'E' - public _REGIST_TITLE_FMT - _REGIST_TITLE_FMT db '東方靈異伝 強者の記録 %s',0 -else - public _REGIST_BG_NOT_CLEARED, _REGIST_BG_CLEARED - public _REGIST_TITLE_1, _REGIST_TITLE_2 - _REGIST_BG_NOT_CLEARED db 'game_o.grp',0 - _REGIST_BG_CLEARED db 'endm_a.grp',0 - _REGIST_TITLE_1 db '東方靈異伝 強者の記録 ',0 - _REGIST_TITLE_2 db '東方靈異伝 強者の記録',0 -endif diff --git a/th01/hiscore/regist_name[data].asm b/th01/hiscore/regist_name[data].asm deleted file mode 100644 index 600f9dc7..00000000 --- a/th01/hiscore/regist_name[data].asm +++ /dev/null @@ -1,15 +0,0 @@ -public _REGIST_NAME_BLANK, _REGIST_NAME_SPACES, _SCOREDAT_MAGIC -_REGIST_NAME_BLANK db '________',0 -if BINARY eq 'M' - public _regist_jump_to_enter - _regist_jump_to_enter db 0 -endif -_REGIST_NAME_SPACES db '        ',0 -_SCOREDAT_MAGIC db 'HISCORE',0 - -public _REGIST_TITLE_RANKS -_REGIST_TITLE_RANKS label dword - dd _REGIST_TITLE_RANK_EASY - dd _REGIST_TITLE_RANK_NORMAL - dd _REGIST_TITLE_RANK_HARD - dd _REGIST_TITLE_RANK_LUNATIC diff --git a/th01/hiscore/scorelod.cpp b/th01/hiscore/scorelod.cpp index 8ecb9269..8de9ccb6 100644 --- a/th01/hiscore/scorelod.cpp +++ b/th01/hiscore/scorelod.cpp @@ -1,23 +1,13 @@ -extern const char SCOREDAT_ROUTE_NONE[]; -extern char scoredat_name_default[]; -extern const char SCOREDAT_MAGIC_0[]; -extern const char SCOREDAT_MAGIC_1[]; -extern const char SCOREDAT_FN_EASY_0[]; -extern const char SCOREDAT_FN_EASY_1[]; -extern const char SCOREDAT_FN_NORMAL_0[]; -extern const char SCOREDAT_FN_NORMAL_1[]; -extern const char SCOREDAT_FN_HARD_0[]; -extern const char SCOREDAT_FN_HARD_1[]; -extern const char SCOREDAT_FN_LUNATIC_0[]; -extern const char SCOREDAT_FN_LUNATIC_1[]; +#include "th01/shiftjis/scoredat.hpp" -#define scoredat_fn(buf, inst) \ +#define scoredat_fn(buf) { \ switch(rank) { \ - case RANK_EASY: strcpy(fn, SCOREDAT_FN_EASY_##inst); break; \ - case RANK_NORMAL: strcpy(fn, SCOREDAT_FN_NORMAL_##inst); break; \ - case RANK_HARD: strcpy(fn, SCOREDAT_FN_HARD_##inst); break; \ - case RANK_LUNATIC: strcpy(fn, SCOREDAT_FN_LUNATIC_##inst); break; \ - } + case RANK_EASY: strcpy(fn, SCOREDAT_FN_EASY); break; \ + case RANK_NORMAL: strcpy(fn, SCOREDAT_FN_NORMAL); break; \ + case RANK_HARD: strcpy(fn, SCOREDAT_FN_HARD); break; \ + case RANK_LUNATIC: strcpy(fn, SCOREDAT_FN_LUNATIC); break; \ + } \ +} int8_t scoredat_name_byte_encode(int8_t byte) { @@ -35,18 +25,17 @@ void scoredat_recreate() { int i; int16_t stage; - const char *route; + const char *route = SCOREDAT_ROUTE_NONE; int32_t score; scoredat_declare(); + // Will be name-encoded, and therefore modified in the .data section! - char *name; - const char *magic; + char *name = scoredat_name_default; + + const char *magic = SCOREDAT_MAGIC; char fn[16]; - route = SCOREDAT_ROUTE_NONE; - name = scoredat_name_default; - magic = SCOREDAT_MAGIC_0; - scoredat_fn(fn, 0); + scoredat_fn(fn); scoredat_cli(); if(scoredat_create(fn) == 0) { @@ -88,7 +77,7 @@ int scoredat_load() char fn[16]; scoredat_declare(); - scoredat_fn(fn, 1); + scoredat_fn(fn); if(!scoredat_exist(fn)) { scoredat_recreate(); } @@ -101,7 +90,7 @@ int scoredat_load() } scoredat_read(buf.magic, sizeof(buf.magic)); // Who cares about the last three bytes anyway, right. - if(memcmp(buf.magic, SCOREDAT_MAGIC_1, 4)) { + if(memcmp(buf.magic, SCOREDAT_MAGIC, 4)) { scoredat_close(); scoredat_error(SCOREDAT_ERROR_INVALID); scoredat_sti(); diff --git a/th01/hiscore/scorelod[data].asm b/th01/hiscore/scorelod[data].asm deleted file mode 100644 index ed97b942..00000000 --- a/th01/hiscore/scorelod[data].asm +++ /dev/null @@ -1,43 +0,0 @@ -public _SCOREDAT_ROUTE_NONE, _scoredat_name_default -public _SCOREDAT_MAGIC_0, _SCOREDAT_MAGIC_1 -public _SCOREDAT_FN_EASY_0, _SCOREDAT_FN_EASY_1, _SCOREDAT_FN_EASY_2 -public _SCOREDAT_FN_NORMAL_0, _SCOREDAT_FN_NORMAL_1, _SCOREDAT_FN_NORMAL_2 -public _SCOREDAT_FN_HARD_0, _SCOREDAT_FN_HARD_1, _SCOREDAT_FN_HARD_2 -public _SCOREDAT_FN_LUNATIC_0, _SCOREDAT_FN_LUNATIC_1, _SCOREDAT_FN_LUNATIC_2 - -_SCOREDAT_ROUTE_NONE db '無',0 -_scoredat_name_default db '東方★靈異伝  ',0 - -if BINARY eq 'E' - public _FOPEN_WB, _FOPEN_RB - public _SCOREDAT_ERROR_NOT_FOUND, _SCOREDAT_ERROR_INVALID - _SCOREDAT_MAGIC_0 db 'HISCORE',0 - _SCOREDAT_FN_EASY_0 db 'REYHIES.DAT',0 - _SCOREDAT_FN_NORMAL_0 db 'REYHINO.DAT',0 - _SCOREDAT_FN_HARD_0 db 'REYHIHA.DAT',0 - _SCOREDAT_FN_LUNATIC_0 db 'REYHILU.DAT',0 - _FOPEN_WB db 'wb',0 - _SCOREDAT_FN_EASY_1 db 'REYHIES.DAT',0 - _SCOREDAT_FN_NORMAL_1 db 'REYHINO.DAT',0 - _SCOREDAT_FN_HARD_1 db 'REYHIHA.DAT',0 - _SCOREDAT_FN_LUNATIC_1 db 'REYHILU.DAT',0 - _FOPEN_RB db 'rb',0 - _SCOREDAT_ERROR_NOT_FOUND db 'ファイルがみつかんない',0 - _SCOREDAT_MAGIC_1 db 'HISCORE',0 - _SCOREDAT_ERROR_INVALID db 'ファイルが違う!',0 -else - _SCOREDAT_MAGIC_1 label byte - _SCOREDAT_MAGIC_0 db 'HISCORE',0 - _SCOREDAT_FN_EASY_2 label byte - _SCOREDAT_FN_EASY_1 label byte - _SCOREDAT_FN_EASY_0 db 'REYHIES.DAT',0 - _SCOREDAT_FN_NORMAL_2 label byte - _SCOREDAT_FN_NORMAL_1 label byte - _SCOREDAT_FN_NORMAL_0 db 'REYHINO.DAT',0 - _SCOREDAT_FN_HARD_2 label byte - _SCOREDAT_FN_HARD_1 label byte - _SCOREDAT_FN_HARD_0 db 'REYHIHA.DAT',0 - _SCOREDAT_FN_LUNATIC_2 label byte - _SCOREDAT_FN_LUNATIC_1 label byte - _SCOREDAT_FN_LUNATIC_0 db 'REYHILU.DAT',0 -endif diff --git a/th01/main_19.cpp b/th01/main_19.cpp index 032c800e..995ac364 100644 --- a/th01/main_19.cpp +++ b/th01/main_19.cpp @@ -22,6 +22,8 @@ extern "C" { #include "th01/hardware/input.hpp" #include "th01/hardware/graph.h" } +#include "th01/shiftjis/fns.hpp" +#include "th01/shiftjis/regist.hpp" #include "th01/hiscore/scoredat.hpp" extern char rank; @@ -58,13 +60,12 @@ void pascal near str_from_kanji(char str[3], uint16_t kanji) } #define graph_putkanji_fx_declare() char kanji_str[3]; -#define graph_putkanji_fx(left, top, col_and_fx, fmt_instance, kanji) \ +#define graph_putkanji_fx(left, top, col_and_fx, kanji) { \ str_from_kanji(kanji_str, kanji); \ - graph_putsa_fx(left, top, col_and_fx, kanji_str); + graph_putsa_fx(left, top, col_and_fx, kanji_str); \ +} #define graph_printf_fx graph_putsa_fx - -#define graph_printf_s_fx(left, top, col_and_fx, fmt_instance, str) \ - graph_putsa_fx(left, top, col_and_fx, str); +#define graph_printf_s_fx graph_putsa_fx #define regist_route_put(left, top, col_and_fx, char_1, char_2) \ unsigned char route[sizeof(twobyte_t) + 1]; \ @@ -73,11 +74,6 @@ void pascal near str_from_kanji(char str[3], uint16_t kanji) route[1] = char_2; \ graph_putsa_fx(left, top, col_and_fx, route); \ -#define ALPHABET_SPACE_0 ALPHABET_SPACE -#define ALPHABET_LEFT_0 ALPHABET_LEFT -#define ALPHABET_RIGHT_0 ALPHABET_RIGHT -#define ALPHABET_ENTER_0 ALPHABET_ENTER - // A completely hidden timeout that force-enters a high score name after // 1000... *keyboard inputs*? Not frames? Why. Like, how do even you // realistically get to such a number. @@ -89,14 +85,12 @@ void pascal near str_from_kanji(char str[3], uint16_t kanji) #define regist_input_timeout_if_reached(then) if(timeout > 1000) then #define regist_bg_put(stage) { \ - extern const char REGIST_BG_NOT_CLEARED[]; \ - extern const char REGIST_BG_CLEARED[]; \ z_graph_clear_0(); \ z_palette_black(); \ graph_accesspage_func(1); \ \ if(stage < SCOREDAT_NOT_CLEARED) { \ - grp_put_palette_show(REGIST_BG_NOT_CLEARED); \ + grp_put_palette_show("game_o.grp"); \ } else { \ grp_put(REGIST_BG_CLEARED); \ } \ @@ -105,14 +99,18 @@ void pascal near str_from_kanji(char str[3], uint16_t kanji) } #define regist_title_put(left, stage, ranks, col_and_fx) { \ - extern const char REGIST_TITLE_1[]; \ - extern const char REGIST_TITLE_2[]; \ if(stage < SCOREDAT_NOT_CLEARED) { \ - graph_putsa_fx(left + 0, TITLE_BACK_TOP, col_and_fx, REGIST_TITLE_1); \ - graph_putsa_fx(left + 192, TITLE_BACK_TOP, col_and_fx, ranks[rank]); \ + graph_putsa_fx( \ + left, TITLE_BACK_TOP, col_and_fx, REGIST_TITLE_WITH_SPACE \ + ); \ + graph_putsa_fx( \ + (left + REGIST_TITLE_W), TITLE_BACK_TOP, col_and_fx, ranks[rank] \ + ); \ } else { \ - graph_putsa_fx(left + 0, TITLE_TOP, col_and_fx, REGIST_TITLE_2); \ - graph_putsa_fx(left + 192, TITLE_TOP, col_and_fx, ranks[rank]); \ + graph_putsa_fx(left, TITLE_TOP, col_and_fx, REGIST_TITLE); \ + graph_putsa_fx( \ + (left + REGIST_TITLE_W), TITLE_TOP, col_and_fx, ranks[rank] \ + ); \ } \ } diff --git a/th01/shiftjis/fns.hpp b/th01/shiftjis/fns.hpp index 941f242f..94a318a7 100644 --- a/th01/shiftjis/fns.hpp +++ b/th01/shiftjis/fns.hpp @@ -1,3 +1,10 @@ +#define REGIST_BG_CLEARED "endm_a.grp" + +#define SCOREDAT_FN_EASY "REYHIES.DAT" +#define SCOREDAT_FN_NORMAL "REYHINO.DAT" +#define SCOREDAT_FN_HARD "REYHIHA.DAT" +#define SCOREDAT_FN_LUNATIC "REYHILU.DAT" + #define SE_FN "zigoku.mde" #define PTN_STG_CARDFLIP_FN "stg.ptn" #define PTN_STG_BOSS_FN "stg_b.ptn" diff --git a/th01/shiftjis/fwnum.hpp b/th01/shiftjis/fwnum.hpp index 77034beb..81b0c6f1 100644 --- a/th01/shiftjis/fwnum.hpp +++ b/th01/shiftjis/fwnum.hpp @@ -1,3 +1,3 @@ -const hack FULLWIDTH_NUMERALS = { - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" +#define FULLWIDTH_NUMERALS { \ + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" \ }; diff --git a/th01/shiftjis/regist.hpp b/th01/shiftjis/regist.hpp index 047c6d4e..bf62d6b5 100644 --- a/th01/shiftjis/regist.hpp +++ b/th01/shiftjis/regist.hpp @@ -1 +1,59 @@ -#define REGIST_ROUTE_CLEAR "完" +#include "th01/shiftjis/title.hpp" + +#define REGIST_TITLE GAME_TITLE " 強者の記録" +#define REGIST_TITLE_WITH_SPACE REGIST_TITLE " " +#define REGIST_TITLE_RANKS { \ + " イージー ", \ + " ノーマル ", \ + " ハード  ", \ + "ルナティック", \ +} + +static const pixel_t REGIST_TITLE_W = shiftjis_w(REGIST_TITLE_WITH_SPACE); + +#define REGIST_HEADER_PLACE " 霊 位 " +#define REGIST_HEADER_NAME "  名  前  " +#define REGIST_HEADER_SCORE "  得  点  " +#define REGIST_HEADER_STAGE_ROUTE "ステージ・ルート" +#define REGIST_PLACE_0 " 靈 神 " +#define REGIST_PLACE_1 "太元帥明王" +#define REGIST_PLACE_2 " 天 仙 " +#define REGIST_PLACE_3 " 神 仙 " +#define REGIST_PLACE_4 " 地 仙 " +#define REGIST_PLACE_5 " 人 仙 " +#define REGIST_PLACE_6 " 仙 女 " +#define REGIST_PLACE_7 "陰 陽 師" +#define REGIST_PLACE_8 "靈 媒 師" +#define REGIST_PLACE_9 "修 業 者" +#define REGIST_NAME_SPACES "        " +#define REGIST_NAME_BLANK "________" +#define REGIST_STAGE_ROUTE_DASH "−" +#define REGIST_STAGE_MAKAI "魔界" +#define REGIST_STAGE_JIGOKU "地獄" + +#define ALPHABET_A "a" +#define ALPHABET_SPACE "SP" +#define ALPHABET_LEFT "←" +#define ALPHABET_RIGHT "→" +#define ALPHABET_ENTER "終" + +// ZUN bloat: Storing fullwidth characters as regular 16-bit big-endian +// integers would have worked just fine. +#define kanji_to_le(kanji) ( \ + (static_cast(kanji) << 8) | (static_cast(kanji) >> 8) \ +) + +#define KANJI_A kanji_to_le('A') +#define KANJI_a kanji_to_le('a') +#define KANJI_b kanji_to_le('b') +#define KANJI_0 kanji_to_le('0') +#define KANJI_SP kanji_to_le(' ') +#define KANJI_UNDERSCORE kanji_to_le('_') + +const uint16_t ALPHABET_SYMS[] = { + kanji_to_le('!'), kanji_to_le('?'), kanji_to_le('#'), kanji_to_le('&'), + kanji_to_le('*'), kanji_to_le('§'), kanji_to_le('☆'), kanji_to_le('◆'), + kanji_to_le('∞'), kanji_to_le('∴'), kanji_to_le('♂'), kanji_to_le('♀'), + kanji_to_le('…'), kanji_to_le('“'), kanji_to_le('”'), kanji_to_le('/'), + kanji_to_le('.'), kanji_to_le('・'), +}; diff --git a/th01/shiftjis/scoredat.hpp b/th01/shiftjis/scoredat.hpp new file mode 100644 index 00000000..108c1976 --- /dev/null +++ b/th01/shiftjis/scoredat.hpp @@ -0,0 +1,8 @@ +#define SCOREDAT_ROUTE_NONE "無" +#define SCOREDAT_ROUTE_CLEAR "完" + +// Will be name-encoded, and therefore modified in the .data section! +#define scoredat_name_default "東方★靈異伝  " + +#define SCOREDAT_ERROR_NOT_FOUND "ファイルがみつかんない" +#define SCOREDAT_ERROR_INVALID "ファイルが違う!" diff --git a/th01_fuuin.asm b/th01_fuuin.asm index bf6d16c1..215b04d5 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -229,12 +229,6 @@ arg0 db 'op',0 db 0 include th01/hardware/input_main_end[data].asm dd 0 -include th01/hiscore/alphabet_syms[data].asm -include th01/hardware/grppfnfx_ptrs[data].asm -include th01/hiscore/regist_name[data].asm -include th01/hardware/grppfnfx[data].asm -include th01/hiscore/scorelod[data].asm -include th01/hiscore/regist[data].asm ; th01/hardware/palette[data].asm extern _z_Palettes:rgb_t:COLOR_COUNT diff --git a/th01_reiiden.asm b/th01_reiiden.asm index fd32a12e..8d1c2062 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -4802,11 +4802,6 @@ aVavpvnvvbxvovm db ' aB@b@vrvsvVfvd db '  STAGE',0 aVavnvmvtvrb@vo db 'BONUS Point',0 aVgvivfb@vyb@vj db 'Hit Z Key',0 - db 0 -include th01/hiscore/alphabet_syms[data].asm -include th01/hiscore/regist_name[data].asm -include th01/hiscore/scorelod[data].asm -include th01/hiscore/regist[data].asm extern _arc_key:byte extern _ptn_sloppy_unput_before_alpha_pu:byte