[Maintenance] [th01] Start a new header file for text layer functions

What's most ridiculous about this is that ZUN had already reimplemented
master.lib text mode functions (th01/hardware/ztext.c). He simply never
used anything from there.

Part of P0167, funded by Ember2528.
This commit is contained in:
nmlgc 2021-11-01 18:01:03 +01:00
parent 6e7ab07659
commit 5ed7f7150a
2 changed files with 30 additions and 23 deletions

27
th01/hardware/text.h Normal file
View File

@ -0,0 +1,27 @@
// Fills the text layer with spaces.
// PORTERS: Implement better, and more consistently.
#define text_fill_space(esc_move_topleft, space, tmp_x, tmp_y) { \
printf(esc_move_topleft); \
for(tmp_y = 0; tmp_y < (RES_Y / GLYPH_H); tmp_y++) { \
for(tmp_x = 0; tmp_x < (RES_X / GLYPH_HALF_W); tmp_x++) { \
printf(space); \
} \
} \
}
// Fills the text layer with opaque black.
// MODDERS: This should maybe reset the current text mode color.
#define text_fill_black( \
esc_color_bg_black_fg_black, esc_move_topleft, space, tmp_x, tmp_y \
) { \
printf(esc_color_bg_black_fg_black); \
text_fill_space(esc_move_topleft, space, tmp_x, tmp_y); \
}
// Fills the text layer with transparent spaces. Yes, this overwrites the
// perfectly suitable master.lib function with the same name.
#define text_clear_sloppy(tmp_x, tmp_y) { \
printf("\x1B[0m"); /* Reset text mode color */ \
/* (yes, this escape sequence is actually 1-based) */ \
text_fill_space("\x1B[1;1H", " ", tmp_x, tmp_y); \
}

View File

@ -20,6 +20,7 @@ extern "C" {
#include "th01/hardware/egc.h"
#include "th01/hardware/scrollup.hpp"
#include "th01/hardware/input.hpp"
#include "th01/hardware/text.h"
#include "th01/snd/mdrv2.h"
#include "th01/main/playfld.hpp"
#include "th01/formats/grp.h"
@ -1800,35 +1801,14 @@ void konngara_main(void)
// reimplementation of the original functionality into DOSBox-X.
// --------------------------------------------------------------------
#define y i
#define x j
printf("\x1B)3"); // Enter graph mode
printf("\x1B[16;40m"); // Set black foreground and background text color
printf("\x1B[0;0H"); // Move text cursor to (0, 0)
for(y = 0; y < (RES_Y / GLYPH_H); y++) {
for(x = 0; x < (RES_X / GLYPH_HALF_W); x++) {
printf(" ");
}
}
text_fill_black("\x1B[16;40m", "\x1B[0;0H", " ", j, i);
grp_put_palette_show(SCROLL_BG_FN);
z_palette_set_black(j, i);
printf("\x1B)0"); // Back to regular kanji mode
printf("\x1B[0m"); // Reset text mode color
printf("\x1B[1;1H"); // Move text cursor to (0, 0)
// (yes, this escape sequence is actually 1-based)
for(y = 0; y < (RES_Y / GLYPH_H); y++) {
for(x = 0; x < (RES_X / GLYPH_HALF_W); x++) {
printf(" ");
}
}
#undef x
#undef y
text_clear_sloppy(j, i);
// --------------------------------------------------------------------
// Final scroll