Skip to content

Commit

Permalink
[Maintenance] Reorganize gaiji definitions
Browse files Browse the repository at this point in the history
Part of P0089, funded by [Anonymous] and Blue Bolt.
  • Loading branch information
nmlgc committed May 3, 2020
1 parent 5531ed9 commit 8b58e19
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 109 deletions.
47 changes: 47 additions & 0 deletions th02/gaiji/boldfont.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// In TH02, ZUN messed up and swapped M and N in MIKOFT.BFT for both regular
// and bold fonts. Therefore, other code shouldn't really use the
// straightforward solution of just adding char literals to a defined start
// offset, as it may suggest that this also works for M and N (which it
// doesn't). This was fixed in later games.
#if (GAME == 2)
# define gb_MN_BUG gb_N_, gb_M_
#else
# define gb_MN_BUG gb_M_, gb_N_
#endif

#define gaiji_boldfont(start) \
gb_0_ = start, \
gb_1_, \
gb_2_, \
gb_3_, \
gb_4_, \
gb_5_, \
gb_6_, \
gb_7_, \
gb_8_, \
gb_9_, \
gb_A_, \
gb_B_, \
gb_C_, \
gb_D_, \
gb_E_, \
gb_F_, \
gb_G_, \
gb_H_, \
gb_I_, \
gb_J_, \
gb_K_, \
gb_L_, \
gb_MN_BUG, \
gb_O_, \
gb_P_, \
gb_Q_, \
gb_R_, \
gb_S_, \
gb_T_, \
gb_U_, \
gb_V_, \
gb_W_, \
gb_X_, \
gb_Y_, \
gb_Z_
36 changes: 36 additions & 0 deletions th02/gaiji/gaiji.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ReC98
// -----
// Gaiji available to TH02

#include "th02/gaiji/boldfont.h"

typedef enum {
gs_YINYANG = 0x02, // ☯
gs_BOMB, // ◉? ⦿? 🎯? 🖸? Or simply 💣?

gaiji_boldfont(0xA0),

gb_SP = 0xCF,
gs_BULLET = 0xDA, // •
gs_PERIOD, // .
gs_EXCLAMATION, // !
gs_QUESTION, // ?
gs_ELLIPSIS, // …
gs_COPYRIGHT, // ©
gs_HEART, // 🎔
gs_SKULL, // 💀
gs_GHOST, // 👻
gs_SIDDHAM_HAM, // Siddhaṃ seed syllable HĀṂ (I don't even)
gs_SPACE, // ␠
gs_ARROW_LEFT, // ←
gs_ARROW_RIGHT, // →
gs_END, // "End"

// Unused 32x16 rank sprites
gs_EA, gs_SY, // "Ea", "sy"
gs_NOR, gs_MAL, // "Nor, "mal"
gs_HA, gs_RD, // "Ha, "rd"
gs_LUN, gs_ATIC, // "Lun", "atic"

gs_ALL, // "All"
} gaiji_th02_t;
7 changes: 4 additions & 3 deletions th02/maine_04.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "th02/th02.h"
#include "th02/gaiji/gaiji.h"
#include "th02/score.h"
#include "th02/score.c"
#include "th02/scoreenc.c"
Expand Down Expand Up @@ -49,7 +50,7 @@ void pascal score_points_put(unsigned y, long points, unsigned atrb)
for(x = 26; x < 26 + (8 * 2); x += 2) {
result = (points / divisor) % 10;
divisor /= 10;
digit = result + GB_DIGITS;
digit = result + gb_0_;
if(result) {
putting = 1;
}
Expand Down Expand Up @@ -84,15 +85,15 @@ void pascal near scores_put(int place_to_highlight)
gaiji_putsa(10, 6+i, (const char*)hi.score.g_name[i], atrb);
score_points_put(6+i, hi.score.points[i], atrb);
if(hi.score.stage[i] != STAGE_ALL) {
gaiji_putca(44, 6+i, hi.score.stage[i] + GB_DIGITS, atrb);
gaiji_putca(44, 6+i, hi.score.stage[i] + gb_0_, atrb);
} else {
gaiji_putca(44, 6+i, gs_ALL, atrb);
}
}
for(i = 0; i < SCOREDAT_PLACES; i++) {
ATRB_SET(i);
if(i != 9) {
gaiji_putca(6, 6+i, GB_DIGITS+i+1, atrb);
gaiji_putca(6, 6+i, gb_1_ + i, atrb);
} else {
gaiji_putca(4, 15, gb_1_, atrb);
gaiji_putca(6, 15, gb_0_, atrb);
Expand Down
9 changes: 5 additions & 4 deletions th02/op_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "th02/formats/cfg.h"
#include "th02/formats/pi.h"
#include "th02/snd/snd.h"
#include "th02/gaiji/gaiji.h"

#pragma option -d -a2

Expand Down Expand Up @@ -465,14 +466,14 @@ void pascal near option_put(int sel, unsigned int atrb)
graph_gaiji_puts(380, 276, 16, gbcBGM_MODE[snd_bgm_mode], 0);
} else if(sel == 2) {
gaiji_putsa(24, 18, gbPLAYER, atrb);
gaiji_putca(49, 18, lives + 1 + GB_DIGITS, atrb);
gaiji_putca(49, 18, lives + 1 + gb_0_, atrb);
graph_copy_rect_1_to_0(392, 292, 32, 16);
graph_gaiji_putc(396, 292, lives + 1 + GB_DIGITS, 0);
graph_gaiji_putc(396, 292, lives + 1 + gb_0_, 0);
} else if(sel == 3) {
gaiji_putsa(24, 19, gbBOMB, atrb);
gaiji_putca(49, 19, bombs + GB_DIGITS, atrb);
gaiji_putca(49, 19, bombs + gb_0_, atrb);
graph_copy_rect_1_to_0(392, 308, 32, 16);
graph_gaiji_putc(396, 308, bombs + GB_DIGITS, 0);
graph_gaiji_putc(396, 308, bombs + gb_0_, 0);
} else if(sel == 4) {
text_putsa(24, 20, PERF_TITLE, atrb);
text_putsa(45, 20, PERF_OPTIONS[resident->perf], atrb);
Expand Down
9 changes: 5 additions & 4 deletions th02/op_04.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <mbctype.h>
#include <mbstring.h>
#include "th02/th02.h"
#include "th02/gaiji/gaiji.h"

char rank = RANK_NORMAL;
int8_t rank_padding = 0;
Expand Down Expand Up @@ -34,15 +35,15 @@ unsigned int score_duration;
// Slightly differs from the same function in MAINE.EXE!
void pascal near score_points_put(unsigned y, long points, unsigned atrb)
{
unsigned digit = GB_DIGITS;
unsigned digit = gb_0_;
long divisor = 10000000;
long result;
char putting = 0;
int i;
for(i = 0; i < 8; i++) {
result = divisor ? (points / divisor) % 10 : points % 10;
divisor /= 10;
digit = result + GB_DIGITS;
digit = result + gb_0_;
if(result) {
putting = 1;
}
Expand Down Expand Up @@ -104,7 +105,7 @@ void pascal near scores_put(int place_to_highlight)
gaiji_putsa(12, 7+i, hi.score.g_name[i], atrb);
score_points_put(7+i, hi.score.points[i], atrb);
if(hi.score.stage[i] != STAGE_ALL) {
gaiji_putca(44, 7+i, hi.score.stage[i] + GB_DIGITS, atrb);
gaiji_putca(44, 7+i, hi.score.stage[i] + gb_0_, atrb);
} else {
gaiji_putca(44, 7+i, gs_ALL, atrb);
}
Expand All @@ -114,7 +115,7 @@ void pascal near scores_put(int place_to_highlight)
for(i = 0; i < SCOREDAT_PLACES; i++) {
ATRB_SET(i);
if(i != 9) {
gaiji_putca(9, 7+i, GB_DIGITS+i+1, atrb);
gaiji_putca(9, 7+i, gb_1_ + i, atrb);
} else {
gaiji_putca(8, 16, gb_1_, atrb);
gaiji_putca(10, 16, gb_0_, atrb);
Expand Down
79 changes: 0 additions & 79 deletions th02/th02.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,85 +44,6 @@ void pascal mptn_free(void);
void pascal graph_copy_rect_1_to_0(int x, int y, int w, int h);
// -------

// Gaiji characters
// ----------------
/* ZUN messed up and swapped M and N in MIKOFT.BFT for both regular and bold
* fonts. Therefore, other code shouldn't really use the straightforward
* solution of just adding char literals to a defined start offset, as it may
* suggest that this also works for M and N (which it doesn't). So...
*/
typedef enum {
GB_DIGITS = 160,
gb_0_ = GB_DIGITS,
gb_1_,
gb_2_,
gb_3_,
gb_4_,
gb_5_,
gb_6_,
gb_7_,
gb_8_,
gb_9_,

GB_LETTERS = 105,
gb_A_ = GB_LETTERS + 'A',
gb_B_,
gb_C_,
gb_D_,
gb_E_,
gb_F_,
gb_G_,
gb_H_,
gb_I_,
gb_J_,
gb_K_,
gb_L_,
gb_M_ = GB_LETTERS + 'N',
gb_N_ = GB_LETTERS + 'M',
gb_O_ = GB_LETTERS + 'O',
gb_P_,
gb_Q_,
gb_R_,
gb_S_,
gb_T_,
gb_U_,
gb_V_,
gb_W_,
gb_X_,
gb_Y_,
gb_Z_,

gb_SP = 207,
} gaiji_bold_t;

typedef enum {
gs_YINYANG = 2, // ☯
gs_BOMB, // ◉? ⦿? 🎯? 🖸? Or simply 💣?
gs_BULLET = 218, // •
gs_PERIOD, // .
gs_EXCLAMATION, // !
gs_QUESTION, // ?
gs_ELLIPSIS, // …
gs_COPYRIGHT, // ©
gs_HEART, // 🎔
gs_SKULL, // 💀
gs_GHOST, // 👻
gs_SIDDHAM_HAM, // Siddhaṃ seed syllable HĀṂ (I don't even)
gs_SPACE, // ␠
gs_ARROW_LEFT, // ←
gs_ARROW_RIGHT, // →
gs_END, // "End"

// Unused 32x16 rank sprites
gs_EA, gs_SY, // "Ea", "sy"
gs_NOR, gs_MAL, // "Nor, "mal"
gs_HA, gs_RD, // "Ha, "rd"
gs_LUN, gs_ATIC, // "Lun", "atic"

gs_ALL, // "All"
} gaiji_symbols_t;
// ----------------

typedef enum {
INPUT_UP = 0x1,
INPUT_DOWN = 0x2,
Expand Down
1 change: 1 addition & 0 deletions th02/zun_res3.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "th02/th02.h"
#include "th02/gaiji/gaiji.h"

extern scoredat_section_t hi;
extern const char *SCOREDAT_FN;
Expand Down
20 changes: 20 additions & 0 deletions th03/gaiji/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Enemy health / dream / power bars, with the given width in pixels.
#define gaiji_bar(start) \
g_BAR_01W = start, \
g_BAR_02W, \
g_BAR_03W, \
g_BAR_04W, \
g_BAR_05W, \
g_BAR_06W, \
g_BAR_07W, \
g_BAR_08W, \
g_BAR_09W, \
g_BAR_10W, \
g_BAR_11W, \
g_BAR_12W, \
g_BAR_13W, \
g_BAR_14W, \
g_BAR_15W, \
g_BAR_16W

#define BAR_GAIJI_MAX 16
15 changes: 0 additions & 15 deletions th03/gaiji/bar.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
; Enemy health / dream / power bars
G_BAR = 020h
g_BAR_01W = 020h
g_BAR_02W = 021h
Expand All @@ -18,17 +17,3 @@ g_BAR_15W = 02Eh
g_BAR_16W = 02Fh

BAR_GAIJI_MAX = 16

if GAME ge 4
; 8 regular bar cell sprites with 16 pixels filled in TH04. TH05 has *MAX♡
; drawn on the last three.
g_BAR_MAX = 030h
g_BAR_MAX_0 = 030h
g_BAR_MAX_1 = 031h
g_BAR_MAX_2 = 032h
g_BAR_MAX_3 = 033h
g_BAR_MAX_4 = 034h
g_BAR_MAX_5 = 035h
g_BAR_MAX_6 = 036h
g_BAR_MAX_7 = 037h
endif
11 changes: 8 additions & 3 deletions th03/gaiji/gaiji.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// -----
// Gaiji available to TH03

// 1P/2P selection cursor
#define gc_GAIJI_W 2
#include "th03/gaiji/bar.h"

typedef enum {
// 1P/2P selection cursor
#define gc_GAIJI_W 2

gc_P1_TOP_1 = 0x12,
gc_P1_TOP_2 = 0x13,
gc_P1_BOTTOM_1 = 0x14,
Expand All @@ -13,4 +16,6 @@ typedef enum {
gc_P2_TOP_2 = 0x17,
gc_P2_BOTTOM_1 = 0x18,
gc_P2_BOTTOM_2 = 0x19,
} gaiji_cursor_t;
gaiji_bar(0x20),
gaiji_boldfont(0xA0),
} gaiji_th03_t;
14 changes: 14 additions & 0 deletions th04/gaiji/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "th03/gaiji/bar.h"

// A completely filled, 128-pixel bar, stored in 8 consecutive gaiji
// characters. TH05 has *MAX♡ drawn on the last three.
#define G_BAR_MAX(sprite)
#define gaiji_bar_max(start) \
g_BAR_MAX_0 = start, \
g_BAR_MAX_1, \
g_BAR_MAX_2, \
g_BAR_MAX_3, \
g_BAR_MAX_4, \
g_BAR_MAX_5, \
g_BAR_MAX_6, \
g_BAR_MAX_7
11 changes: 11 additions & 0 deletions th04/gaiji/bar.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include th03/gaiji/bar.inc

g_BAR_MAX = 030h
g_BAR_MAX_0 = 030h
g_BAR_MAX_1 = 031h
g_BAR_MAX_2 = 032h
g_BAR_MAX_3 = 033h
g_BAR_MAX_4 = 034h
g_BAR_MAX_5 = 035h
g_BAR_MAX_6 = 036h
g_BAR_MAX_7 = 037h
17 changes: 17 additions & 0 deletions th04/gaiji/gaiji.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ReC98
// -----
// Gaiji available to TH04

#include "th02/gaiji/boldfont.h"
#include "th04/gaiji/bar.h"

typedef enum {
g_EMPTY = 0x02,
gaiji_bar(0x20),
gaiji_bar_max(0x30),
gaiji_boldfont(0xA0),
gs_DOT = 0xC4,
gs_ALL = 0xE9,
g_HISCORE_STAGE_EMPTY = 0xEF,
g_NONE = 0xFF,
} gaiji_th04_t;
Loading

0 comments on commit 8b58e19

Please sign in to comment.