mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Define a VRAM byte mask constant
Less visual noise. Part of P0198, funded by Lmocinemod and Ember2528.
This commit is contained in:
parent
8fce97ea1c
commit
00d4b4ab30
1
pc98.h
1
pc98.h
|
@ -70,6 +70,7 @@ typedef unsigned int utram_y_t;
|
|||
/// Graphics
|
||||
/// --------
|
||||
#define BYTE_DOTS 8
|
||||
#define BYTE_MASK (BYTE_DOTS - 1)
|
||||
#define RES_X 640
|
||||
#define RES_Y 400
|
||||
#define ROW_SIZE (RES_X / BYTE_DOTS)
|
||||
|
|
|
@ -367,7 +367,7 @@ void z_palette_show(void)
|
|||
void z_grcg_pset(screen_x_t x, vram_y_t y, int col)
|
||||
{
|
||||
grcg_setcolor_rmw(col);
|
||||
VRAM_SBYTE(B, vram_offset_mulshift(x, y)) = (0x80 >> (x & (BYTE_DOTS - 1)));
|
||||
VRAM_SBYTE(B, vram_offset_mulshift(x, y)) = (0x80 >> (x & BYTE_MASK));
|
||||
grcg_off_func();
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ int z_graph_readdot(screen_x_t x, vram_y_t y)
|
|||
{
|
||||
int ret;
|
||||
vram_offset_t vram_offset = vram_offset_mulshift(x, y);
|
||||
sdots16_t mask = (0x80 >> (x & (BYTE_DOTS - 1)));
|
||||
sdots16_t mask = (0x80 >> (x & BYTE_MASK));
|
||||
|
||||
#define test(plane, vram_offset, mask, bit) \
|
||||
if(VRAM_SBYTE(plane, vram_offset) & mask) { \
|
||||
|
@ -421,8 +421,8 @@ void graph_r_hline(screen_x_t left, screen_x_t right, vram_y_t y, int col)
|
|||
|
||||
vram_row = (dots8_t *)(MK_FP(SEG_PLANE_B, vram_offset_muldiv(left, y)));
|
||||
full_bytes_to_put = (right / BYTE_DOTS) - (left / BYTE_DOTS);
|
||||
left_pixels = 0xFF >> (left & (BYTE_DOTS - 1));
|
||||
right_pixels = 0xFF << ((BYTE_DOTS - 1) - (right & (BYTE_DOTS - 1)));
|
||||
left_pixels = 0xFF >> (left & BYTE_MASK);
|
||||
right_pixels = 0xFF << (BYTE_MASK - (right & BYTE_MASK));
|
||||
|
||||
if(!graph_r_unput) {
|
||||
grcg_setcolor_rmw(col);
|
||||
|
@ -465,8 +465,8 @@ void graph_r_vline(screen_x_t x, vram_y_t top, vram_y_t bottom, int col)
|
|||
return;
|
||||
}
|
||||
vram_row_offset = vram_offset_shift(x, top);
|
||||
pattern = graph_r_pattern >> (x & (BYTE_DOTS - 1));
|
||||
pattern |= graph_r_pattern << (16 - (x & (BYTE_DOTS - 1)));
|
||||
pattern = graph_r_pattern >> (x & BYTE_MASK);
|
||||
pattern |= graph_r_pattern << (16 - (x & BYTE_MASK));
|
||||
|
||||
grcg_setcolor_rmw(col);
|
||||
for(y = top; y <= bottom; y++) {
|
||||
|
@ -571,8 +571,8 @@ void graph_r_line(
|
|||
y_vram = y_cur; \
|
||||
x_vram = (x_cur >> 3); \
|
||||
} \
|
||||
pixels |= (graph_r_pattern >> (x_cur & (BYTE_DOTS - 1))); \
|
||||
pixels |= (graph_r_pattern << (16 - (x_cur & (BYTE_DOTS - 1)))); \
|
||||
pixels |= (graph_r_pattern >> (x_cur & BYTE_MASK)); \
|
||||
pixels |= (graph_r_pattern << (16 - (x_cur & BYTE_MASK))); \
|
||||
error -= plotted_len; \
|
||||
step_var += step_increment; \
|
||||
if(error < 0) { \
|
||||
|
@ -688,8 +688,8 @@ void z_grcg_boxfill(
|
|||
vram_row = (dots8_t *)(MK_FP(SEG_PLANE_B, vram_offset_mulshift(left, top)));
|
||||
for(y = top; y <= bottom; y++) {
|
||||
full_bytes_to_put = (right >> 3) - (left >> 3);
|
||||
left_pixels = 0xFF >> (left & (BYTE_DOTS - 1));
|
||||
right_pixels = 0xFF << ((BYTE_DOTS - 1) - (right & (BYTE_DOTS - 1)));
|
||||
left_pixels = 0xFF >> (left & BYTE_MASK);
|
||||
right_pixels = 0xFF << (BYTE_MASK - (right & BYTE_MASK));
|
||||
|
||||
if(full_bytes_to_put == 0) {
|
||||
vram_row[0] = (left_pixels & right_pixels);
|
||||
|
|
|
@ -1625,7 +1625,7 @@ void near particles2x2_wavy_unput_update_render()
|
|||
|
||||
wave_left = polar_y(left[i], 16, age[i]);
|
||||
vo = vram_offset_shift(wave_left, top[i]);
|
||||
first_bit = (wave_left & (BYTE_DOTS - 1));
|
||||
first_bit = (wave_left & BYTE_MASK);
|
||||
|
||||
// Unblit
|
||||
graph_accesspage_func(1); particle2x2_snap(dots, vo, first_bit);
|
||||
|
@ -1639,7 +1639,7 @@ void near particles2x2_wavy_unput_update_render()
|
|||
// Recalculate VRAM offset and clip
|
||||
wave_left = polar_y(left[i], 16, age[i]);
|
||||
vo = vram_offset_shift(wave_left, top[i]);
|
||||
first_bit = (wave_left & (BYTE_DOTS - 1));
|
||||
first_bit = (wave_left & BYTE_MASK);
|
||||
if(age[i] >= 100) {
|
||||
col[i] = 0;
|
||||
continue;
|
||||
|
|
|
@ -157,7 +157,7 @@ void CBossEntity::put_1line(
|
|||
vram_word_amount_t bos_word_x;
|
||||
size_t bos_p = 0;
|
||||
vram_y_t intended_y;
|
||||
char first_bit = (left & (BYTE_DOTS - 1));
|
||||
char first_bit = (left & BYTE_MASK);
|
||||
char other_shift = ((1 * BYTE_DOTS) - first_bit);
|
||||
|
||||
bos_image_t &bos = bos_entity_images[bos_slot].image[image];
|
||||
|
@ -276,7 +276,7 @@ void CBossEntity::unput_and_put_1line(
|
|||
vram_word_amount_t bos_word_x;
|
||||
size_t bos_p = 0;
|
||||
vram_y_t intended_y;
|
||||
char first_bit = (left & (BYTE_DOTS - 1));
|
||||
char first_bit = (left & BYTE_MASK);
|
||||
char other_shift = ((2 * BYTE_DOTS) - first_bit);
|
||||
Planar<dots16_t> bg_masked;
|
||||
dots16_t mask_unaligned;
|
||||
|
|
|
@ -107,7 +107,7 @@ void CShootoutLaser::hittest_and_render(void)
|
|||
// sSHOOTOUT_LASER[preshift][(ray_i_left.to_pixel()...)].
|
||||
// (Or actually, how about throwing away that sprite altogether?)
|
||||
dots |= sSHOOTOUT_LASER[0][
|
||||
preshift + (ray_i_left.to_pixel() & (BYTE_DOTS - 1))
|
||||
preshift + (ray_i_left.to_pixel() & BYTE_MASK)
|
||||
];
|
||||
|
||||
if(put_flag == SL_RAY_UNPUT) {
|
||||
|
|
|
@ -65,10 +65,10 @@ void shape_ellipse_arc_put(
|
|||
) {
|
||||
grcg_put(cache_vram_offset, cache_dots, 8);
|
||||
}
|
||||
cache_dots = ((0x80) >> (cur_x & (BYTE_DOTS - 1)));
|
||||
cache_dots = (0x80 >> (cur_x & BYTE_MASK));
|
||||
cache_vram_offset = vram_offset;
|
||||
} else {
|
||||
cache_dots |= ((0x80) >> (cur_x & (BYTE_DOTS - 1)));
|
||||
cache_dots |= (0x80 >> (cur_x & BYTE_MASK));
|
||||
}
|
||||
}
|
||||
grcg_off();
|
||||
|
|
|
@ -14,7 +14,7 @@ void pascal near pellet_render(screen_x_t left, vram_y_t top)
|
|||
_DX >>= 2;
|
||||
_DI = _AX + _DX;
|
||||
|
||||
_SI = reinterpret_cast<uint16_t>(sPELLET[0][left & (BYTE_DOTS - 1)]);
|
||||
_SI = reinterpret_cast<uint16_t>(sPELLET[0][left & BYTE_MASK]);
|
||||
_CX = 8;
|
||||
put_loop: {
|
||||
asm { movsw; }
|
||||
|
|
Loading…
Reference in New Issue