[Decompilation] Add separate types for 1bpp planar pixel lines

This commit is contained in:
nmlgc 2019-12-12 15:01:13 +01:00
parent 9cb6cc527a
commit 59bbe313ad
7 changed files with 51 additions and 42 deletions

27
ReC98.h
View File

@ -79,29 +79,38 @@ typedef void ( far pascal * far farfunc_t_far)(void);
// PC-98 VRAM planes
// -----------------
// Planar 1bpp types, describing horizontal lines of 8, 16, or 32 pixels.
typedef uint8_t planar8_t;
typedef uint16_t planar16_t;
typedef uint32_t planar32_t;
// ... and the same for the rare cases where ZUN's code used signed types.
typedef int8_t splanar8_t;
typedef int16_t splanar16_t;
typedef int32_t splanar32_t;
typedef enum {
PL_B, PL_R, PL_G, PL_E, PL_COUNT
} vram_plane_t;
typedef struct {
char B, R, G, E;
planar8_t B, R, G, E;
} vram_planar_8_pixels_t;
typedef struct {
int B, R, G, E;
planar16_t B, R, G, E;
} vram_planar_16_pixels_t;
// Since array subscripts create slightly different assembly in places, we
// offer both variants.
extern char *VRAM_PLANE[PL_COUNT];
extern char *VRAM_PLANE_B;
extern char *VRAM_PLANE_G;
extern char *VRAM_PLANE_R;
extern char *VRAM_PLANE_E;
extern planar8_t *VRAM_PLANE[PL_COUNT];
extern planar8_t *VRAM_PLANE_B;
extern planar8_t *VRAM_PLANE_G;
extern planar8_t *VRAM_PLANE_R;
extern planar8_t *VRAM_PLANE_E;
#define PLANE_DWORD_BLIT(dst, src) \
for(p = 0; p < PLANE_SIZE; p += 4) { \
*(long*)((dst) + p) = *(long*)((src) + p); \
for(p = 0; p < PLANE_SIZE; p += (int)sizeof(planar32_t)) { \
*(planar32_t*)((dst) + p) = *(planar32_t*)((src) + p); \
}
#define VRAM_OFFSET(x, y) ((x) >> 3) + (y << 6) + (y << 4)

View File

@ -1,8 +1,8 @@
void scale_2x(unsigned long *dst32, int src16)
void scale_2x(planar32_t *dst32, splanar16_t src16)
{
unsigned long mask = 1;
unsigned long srcex = 0;
unsigned long dst_local;
planar32_t mask = 1;
planar32_t srcex = 0;
planar32_t dst_local;
int i;
srcex = src16;
@ -24,7 +24,7 @@ void graph_slow_2xscale_rect_1_to_0(int x0, int y0, int x1, int y1, int w1, int
int col16;
int row;
vram_planar_16_pixels_t px16;
int px16_nonzero;
planar16_t px16_nonzero;
for(row = 0; row < h1; row++) {
int p0 = row_p0;
@ -32,32 +32,32 @@ void graph_slow_2xscale_rect_1_to_0(int x0, int y0, int x1, int y1, int w1, int
for(col16 = 0; col16 < w1 / 16; col16++) {
int scale_p;
graph_accesspage(1);
px16.B = *(int*)(VRAM_PLANE_B + p1);
px16.R = *(int*)(VRAM_PLANE_R + p1);
px16.G = *(int*)(VRAM_PLANE_G + p1);
px16.E = *(int*)(VRAM_PLANE_E + p1);
px16.B = *(planar16_t*)(VRAM_PLANE_B + p1);
px16.R = *(planar16_t*)(VRAM_PLANE_R + p1);
px16.G = *(planar16_t*)(VRAM_PLANE_G + p1);
px16.E = *(planar16_t*)(VRAM_PLANE_E + p1);
px16_nonzero = px16.B | px16.R | px16.G | px16.E;
for(scale_p = 0; scale_p < ROW_SIZE * 2; scale_p += ROW_SIZE) {
unsigned long dst32;
unsigned long px32_nonzero;
planar32_t dst32;
planar32_t px32_nonzero;
graph_accesspage(0);
scale_2x(&px32_nonzero, px16_nonzero);
grcg_setcolor_rmw(0);
*(long*)(VRAM_PLANE_B + p0 + scale_p) = px32_nonzero;
*(planar32_t*)(VRAM_PLANE_B + p0 + scale_p) = px32_nonzero;
grcg_off();
scale_2x(&dst32, px16.B);
*(long*)(VRAM_PLANE_B + p0 + scale_p) |= dst32;
*(planar32_t*)(VRAM_PLANE_B + p0 + scale_p) |= dst32;
scale_2x(&dst32, px16.R);
*(long*)(VRAM_PLANE_R + p0 + scale_p) |= dst32;
*(planar32_t*)(VRAM_PLANE_R + p0 + scale_p) |= dst32;
scale_2x(&dst32, px16.G);
*(long*)(VRAM_PLANE_G + p0 + scale_p) |= dst32;
*(planar32_t*)(VRAM_PLANE_G + p0 + scale_p) |= dst32;
scale_2x(&dst32, px16.E);
*(long*)(VRAM_PLANE_E + p0 + scale_p) |= dst32;
*(planar32_t*)(VRAM_PLANE_E + p0 + scale_p) |= dst32;
}
p1 += 2;
p0 += 4;

View File

@ -24,7 +24,7 @@ void egc_copy_rect_1_to_0(int x, int y, int w, int h)
int row;
int col;
int row_p;
int bits;
planar16_t bits;
int p;
x_end += w;
@ -33,8 +33,8 @@ void egc_copy_rect_1_to_0(int x, int y, int w, int h)
egc_start_copy();
for(row = 0; row < h; row++) {
for(col = x_floor, p = row_p; col < x_end; p += 2, col += 16) {
graph_accesspage(1); bits = *(int*)(VRAM_PLANE_B + p);
graph_accesspage(0); *(int*)(VRAM_PLANE_B + p) = bits;
graph_accesspage(1); bits = *(planar16_t*)(VRAM_PLANE_B + p);
graph_accesspage(0); *(planar16_t*)(VRAM_PLANE_B + p) = bits;
}
row_p += 640 / 8;
}

View File

@ -4,15 +4,15 @@
void graph_putsa_fx(int x, int y, int fx, const unsigned char *str)
{
uint16_t codepoint;
unsigned int glyph_row;
planar16_t glyph_row;
unsigned char far *vram;
int fullwidth;
int first_bit;
int weight = (fx >> 4) & 3;
int spacing = (fx >> 6) & 7;
int line;
unsigned int glyph[GLYPH_HEIGHT];
register unsigned int glyph_row_orig;
planar16_t glyph[GLYPH_HEIGHT];
register planar16_t glyph_row_orig;
grcg_setcolor(GC_RMW, fx);
OUTB(0x68, 0xB); // CG ROM dot access

View File

@ -26,15 +26,15 @@ void pascal graph_copy_rect_1_to_0(int x, int y, int w, int h)
if(row_p >= 0) {
vram_planar_16_pixels_t p16;
graph_accesspage(1);
p16.B = *(int*)(VRAM_PLANE_B + p);
p16.R = *(int*)(VRAM_PLANE_R + p);
p16.G = *(int*)(VRAM_PLANE_G + p);
p16.E = *(int*)(VRAM_PLANE_E + p);
p16.B = *(planar16_t*)(VRAM_PLANE_B + p);
p16.R = *(planar16_t*)(VRAM_PLANE_R + p);
p16.G = *(planar16_t*)(VRAM_PLANE_G + p);
p16.E = *(planar16_t*)(VRAM_PLANE_E + p);
graph_accesspage(0);
*(int*)(VRAM_PLANE_B + p) = p16.B;
*(int*)(VRAM_PLANE_R + p) = p16.R;
*(int*)(VRAM_PLANE_G + p) = p16.G;
*(int*)(VRAM_PLANE_E + p) = p16.E;
*(planar16_t*)(VRAM_PLANE_B + p) = p16.B;
*(planar16_t*)(VRAM_PLANE_R + p) = p16.R;
*(planar16_t*)(VRAM_PLANE_G + p) = p16.G;
*(planar16_t*)(VRAM_PLANE_E + p) = p16.E;
}
}
row_p += ROW_SIZE;

View File

@ -68,7 +68,7 @@ void darken_pic_at(int x, int y)
grcg_setcolor(GC_RMW, 0);
for(row = 0; row < 144; row++, row_p += 640 / 8) {
for(col = 0; col < 192 / 8; col += 2) {
*(int*)(VRAM_PLANE_B + row_p + col) =
*(planar16_t*)(VRAM_PLANE_B + row_p + col) =
row & 1 ? 0xAAAA : 0x5555
;
}

View File

@ -16,7 +16,7 @@
#define PIANO_VRAM_W ((PIANO_OCTAVES * PIANO_OCTAVE_W) / 8)
// Sprite data
extern const unsigned char PIANO_KEYS_BLACK[PIANO_VRAM_W];
extern const planar8_t PIANO_KEYS_BLACK[PIANO_VRAM_W];
/// --------
// Using the same naming convention as for the gaiji characters...
@ -38,7 +38,7 @@ typedef enum {
#define PIANO_LABEL_FONT_W 8
#define PIANO_LABEL_FONT_H 8
extern const unsigned char PIANO_LABEL_FONT[pl_COUNT][PIANO_LABEL_FONT_H];
extern const planar8_t PIANO_LABEL_FONT[pl_COUNT][PIANO_LABEL_FONT_H];
#define PIANO_LABEL_DIST_X 32
#define PIANO_LABEL_DIST_Y 4