diff --git a/pc98.h b/pc98.h index f832a876..85c2e34c 100644 --- a/pc98.h +++ b/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) diff --git a/th01/hardware/graph.cpp b/th01/hardware/graph.cpp index 495e25a8..42097bdb 100644 --- a/th01/hardware/graph.cpp +++ b/th01/hardware/graph.cpp @@ -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); diff --git a/th01/main/boss/b20m.cpp b/th01/main/boss/b20m.cpp index 94f5a19c..fd4ac03c 100644 --- a/th01/main/boss/b20m.cpp +++ b/th01/main/boss/b20m.cpp @@ -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; diff --git a/th01/main/boss/entity_a.cpp b/th01/main/boss/entity_a.cpp index 02738500..e374aa6d 100644 --- a/th01/main/boss/entity_a.cpp +++ b/th01/main/boss/entity_a.cpp @@ -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 bg_masked; dots16_t mask_unaligned; diff --git a/th01/main/bullet/laser_s.cpp b/th01/main/bullet/laser_s.cpp index c7bffa82..34bc68ca 100644 --- a/th01/main/bullet/laser_s.cpp +++ b/th01/main/bullet/laser_s.cpp @@ -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) { diff --git a/th01/main/shape.cpp b/th01/main/shape.cpp index 9383fa3b..ef03cb0b 100644 --- a/th01/main/shape.cpp +++ b/th01/main/shape.cpp @@ -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(); diff --git a/th02/main/bullet/pellet_r.cpp b/th02/main/bullet/pellet_r.cpp index 982cd611..01ed7602 100644 --- a/th02/main/bullet/pellet_r.cpp +++ b/th02/main/bullet/pellet_r.cpp @@ -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(sPELLET[0][left & (BYTE_DOTS - 1)]); + _SI = reinterpret_cast(sPELLET[0][left & BYTE_MASK]); _CX = 8; put_loop: { asm { movsw; }