📄 video.c
字号:
// Operations for isolating 4bpp tiles in a 32bit block#define tile_4bpp_pixel_op_mask(op_param) \ current_pixel = current_pixels & 0x0F \#define tile_4bpp_pixel_op_shift_mask(shift) \ current_pixel = (current_pixels >> shift) & 0x0F \#define tile_4bpp_pixel_op_shift(shift) \ current_pixel = current_pixels >> shift \#define tile_4bpp_pixel_op_none(op_param) \// Draws a single 4bpp pixel as base, normal renderer; checks to see if the// pixel is zero because if so the current palette should not be applied.// These ifs can be replaced with a lookup table, may or may not be superior// this way, should be benchmarked. The lookup table would be from 0-255// identity map except for multiples of 16, which would map to 0.#define tile_4bpp_draw_base_normal(index) \ if(current_pixel) \ { \ current_pixel |= current_palette; \ tile_expand_base_normal(index); \ } \ else \ { \ tile_expand_base_normal(index); \ } \#define tile_4bpp_draw_base_alpha(index) \ if(current_pixel) \ { \ current_pixel |= current_palette; \ tile_expand_base_alpha(index); \ } \ else \ { \ tile_expand_base_bg(index); \ } \#define tile_4bpp_draw_base_color16(index) \ tile_4bpp_draw_base_alpha(index) \#define tile_4bpp_draw_base_color32(index) \ tile_4bpp_draw_base_alpha(index) \#define tile_4bpp_draw_base(index, op, op_param, alpha_op) \ tile_4bpp_pixel_op_##op(op_param); \ tile_4bpp_draw_base_##alpha_op(index) \// Draws a single 4bpp pixel as layered, if not transparent.#define tile_4bpp_draw_transparent(index, op, op_param, alpha_op) \ tile_4bpp_pixel_op_##op(op_param); \ if(current_pixel) \ { \ current_pixel |= current_palette; \ tile_expand_transparent_##alpha_op(index); \ } \#define tile_4bpp_draw_copy(index, op, op_param, alpha_op) \ tile_4bpp_pixel_op_##op(op_param); \ if(current_pixel) \ { \ current_pixel |= current_palette; \ tile_expand_copy(index); \ } \// Draws eight background pixels in transparent mode, for alpha or normal// renderers.#define tile_4bpp_draw_eight_base_zero(value) \ dest_ptr[0] = value; \ dest_ptr[1] = value; \ dest_ptr[2] = value; \ dest_ptr[3] = value; \ dest_ptr[4] = value; \ dest_ptr[5] = value; \ dest_ptr[6] = value; \ dest_ptr[7] = value \// Draws eight background pixels for the alpha renderer, basically color zero// with the background flag high.#define tile_4bpp_draw_eight_base_zero_alpha() \ tile_4bpp_draw_eight_base_zero(bg_combine) \#define tile_4bpp_draw_eight_base_zero_color16() \ tile_4bpp_draw_eight_base_zero_alpha() \#define tile_4bpp_draw_eight_base_zero_color32() \ tile_4bpp_draw_eight_base_zero_alpha() \// Draws eight background pixels for the normal renderer, just a bunch of// zeros.#define tile_4bpp_draw_eight_base_zero_normal() \ current_pixel = palette[0]; \ tile_4bpp_draw_eight_base_zero(current_pixel) \// Draws eight 4bpp pixels.#define tile_4bpp_draw_eight_noflip(combine_op, alpha_op) \ tile_4bpp_draw_##combine_op(0, mask, 0, alpha_op); \ tile_4bpp_draw_##combine_op(1, shift_mask, 4, alpha_op); \ tile_4bpp_draw_##combine_op(2, shift_mask, 8, alpha_op); \ tile_4bpp_draw_##combine_op(3, shift_mask, 12, alpha_op); \ tile_4bpp_draw_##combine_op(4, shift_mask, 16, alpha_op); \ tile_4bpp_draw_##combine_op(5, shift_mask, 20, alpha_op); \ tile_4bpp_draw_##combine_op(6, shift_mask, 24, alpha_op); \ tile_4bpp_draw_##combine_op(7, shift, 28, alpha_op) \// Draws eight 4bpp pixels in reverse order (for hflip).#define tile_4bpp_draw_eight_flip(combine_op, alpha_op) \ tile_4bpp_draw_##combine_op(7, mask, 0, alpha_op); \ tile_4bpp_draw_##combine_op(6, shift_mask, 4, alpha_op); \ tile_4bpp_draw_##combine_op(5, shift_mask, 8, alpha_op); \ tile_4bpp_draw_##combine_op(4, shift_mask, 12, alpha_op); \ tile_4bpp_draw_##combine_op(3, shift_mask, 16, alpha_op); \ tile_4bpp_draw_##combine_op(2, shift_mask, 20, alpha_op); \ tile_4bpp_draw_##combine_op(1, shift_mask, 24, alpha_op); \ tile_4bpp_draw_##combine_op(0, shift, 28, alpha_op) \// Draws eight 4bpp pixels in base mode, checks if all are zero, if so draws// the appropriate background pixels.#define tile_4bpp_draw_eight_base(alpha_op, flip_op) \ if(current_pixels != 0) \ { \ tile_4bpp_draw_eight_##flip_op(base, alpha_op); \ } \ else \ { \ tile_4bpp_draw_eight_base_zero_##alpha_op(); \ } \// Draws eight 4bpp pixels in transparent (layered) mode, checks if all are// zero and if so draws nothing.#define tile_4bpp_draw_eight_transparent(alpha_op, flip_op) \ if(current_pixels != 0) \ { \ tile_4bpp_draw_eight_##flip_op(transparent, alpha_op); \ } \#define tile_4bpp_draw_eight_copy(alpha_op, flip_op) \ if(current_pixels != 0) \ { \ tile_4bpp_draw_eight_##flip_op(copy, alpha_op); \ } \// Gets the current tile in 4bpp mode, also getting the current palette and// the pixel block.#define get_tile_4bpp() \ current_tile = *map_ptr; \ current_palette = (current_tile >> 12) << 4; \ tile_ptr = tile_base + ((current_tile & 0x3FF) * 32); \// Helper macro for drawing clipped 4bpp tiles.#define partial_tile_4bpp(combine_op, alpha_op) \ for(i = 0; i < partial_tile_run; i++) \ { \ tile_4bpp_draw_##combine_op(0, mask, 0, alpha_op); \ current_pixels >>= 4; \ advance_dest_ptr_##combine_op(1); \ } \// Draws a 4bpp tile clipped against the left edge of the screen.// partial_tile_offset is how far in it's clipped, partial_tile_run is// how many to draw.#define partial_tile_right_noflip_4bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr) >> (partial_tile_offset * 4); \ partial_tile_4bpp(combine_op, alpha_op) \// Draws a 4bpp tile clipped against both edges of the screen, same as right.#define partial_tile_mid_noflip_4bpp(combine_op, alpha_op) \ partial_tile_right_noflip_4bpp(combine_op, alpha_op) \// Draws a 4bpp tile clipped against the right edge of the screen.// partial_tile_offset is how many to draw.#define partial_tile_left_noflip_4bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr); \ partial_tile_4bpp(combine_op, alpha_op) \// Draws a complete 4bpp tile row (not clipped)#define tile_noflip_4bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr); \ tile_4bpp_draw_eight_##combine_op(alpha_op, noflip) \// Like the above, but draws flipped tiles.#define partial_tile_flip_4bpp(combine_op, alpha_op) \ for(i = 0; i < partial_tile_run; i++) \ { \ tile_4bpp_draw_##combine_op(0, shift, 28, alpha_op); \ current_pixels <<= 4; \ advance_dest_ptr_##combine_op(1); \ } \#define partial_tile_right_flip_4bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr) << (partial_tile_offset * 4); \ partial_tile_flip_4bpp(combine_op, alpha_op) \#define partial_tile_mid_flip_4bpp(combine_op, alpha_op) \ partial_tile_right_flip_4bpp(combine_op, alpha_op) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -