📄 video.c
字号:
#define tile_8bpp_draw_base_color16(index) \ tile_8bpp_draw_base_alpha(index) \#define tile_8bpp_draw_base_color32(index) \ tile_8bpp_draw_base_alpha(index) \#define tile_8bpp_draw_base(index, op, op_param, alpha_op) \ tile_8bpp_pixel_op_##op(op_param); \ tile_8bpp_draw_base_##alpha_op(index) \// Transparent (layered) writes should only replace what is there if the// pixel is not transparent (zero)#define tile_8bpp_draw_transparent(index, op, op_param, alpha_op) \ tile_8bpp_pixel_op_##op(op_param); \ if(current_pixel) \ { \ tile_expand_transparent_##alpha_op(index); \ } \#define tile_8bpp_draw_copy(index, op, op_param, alpha_op) \ tile_8bpp_pixel_op_##op(op_param); \ if(current_pixel) \ { \ tile_expand_copy(index); \ } \// Get the current tile from the map in 8bpp mode#define get_tile_8bpp() \ current_tile = *map_ptr; \ tile_ptr = tile_base + ((current_tile & 0x3FF) * 64) \// Draw half of a tile in 8bpp mode, for base renderer#define tile_8bpp_draw_four_noflip(index, combine_op, alpha_op) \ tile_8bpp_draw_##combine_op(index + 0, mask, 0, alpha_op); \ tile_8bpp_draw_##combine_op(index + 1, shift_mask, 8, alpha_op); \ tile_8bpp_draw_##combine_op(index + 2, shift_mask, 16, alpha_op); \ tile_8bpp_draw_##combine_op(index + 3, shift, 24, alpha_op) \// Like the above, but draws the half-tile horizontally flipped#define tile_8bpp_draw_four_flip(index, combine_op, alpha_op) \ tile_8bpp_draw_##combine_op(index + 3, mask, 0, alpha_op); \ tile_8bpp_draw_##combine_op(index + 2, shift_mask, 8, alpha_op); \ tile_8bpp_draw_##combine_op(index + 1, shift_mask, 16, alpha_op); \ tile_8bpp_draw_##combine_op(index + 0, shift, 24, alpha_op) \#define tile_8bpp_draw_four_base(index, alpha_op, flip_op) \ tile_8bpp_draw_four_##flip_op(index, base, alpha_op) \// Draw half of a tile in 8bpp mode, for transparent renderer; as an// optimization the entire thing is checked against zero (in transparent// capable renders it is more likely for the pixels to be transparent than// opaque)#define tile_8bpp_draw_four_transparent(index, alpha_op, flip_op) \ if(current_pixels != 0) \ { \ tile_8bpp_draw_four_##flip_op(index, transparent, alpha_op); \ } \#define tile_8bpp_draw_four_copy(index, alpha_op, flip_op) \ if(current_pixels != 0) \ { \ tile_8bpp_draw_four_##flip_op(index, copy, alpha_op); \ } \// Helper macro for drawing 8bpp tiles clipped against the edge of the screen#define partial_tile_8bpp(combine_op, alpha_op) \ for(i = 0; i < partial_tile_run; i++) \ { \ tile_8bpp_draw_##combine_op(0, mask, 0, alpha_op); \ current_pixels >>= 8; \ advance_dest_ptr_##combine_op(1); \ } \// Draws 8bpp tiles clipped against the left side of the screen,// partial_tile_offset indicates how much clipped in it is, partial_tile_run// indicates how much it should draw.#define partial_tile_right_noflip_8bpp(combine_op, alpha_op) \ if(partial_tile_offset >= 4) \ { \ current_pixels = *((u32 *)(tile_ptr + 4)) >> \ ((partial_tile_offset - 4) * 8); \ partial_tile_8bpp(combine_op, alpha_op); \ } \ else \ { \ partial_tile_run -= 4; \ current_pixels = *((u32 *)tile_ptr) >> (partial_tile_offset * 8); \ partial_tile_8bpp(combine_op, alpha_op); \ current_pixels = *((u32 *)(tile_ptr + 4)); \ tile_8bpp_draw_four_##combine_op(0, alpha_op, noflip); \ advance_dest_ptr_##combine_op(4); \ } \// Draws 8bpp tiles clipped against both the left and right side of the// screen, IE, runs of less than 8 - partial_tile_offset.#define partial_tile_mid_noflip_8bpp(combine_op, alpha_op) \ if(partial_tile_offset >= 4) \ { \ current_pixels = *((u32 *)(tile_ptr + 4)) >> \ ((partial_tile_offset - 4) * 8); \ partial_tile_8bpp(combine_op, alpha_op); \ } \ else \ { \ current_pixels = *((u32 *)tile_ptr) >> (partial_tile_offset * 8); \ if((partial_tile_offset + partial_tile_run) > 4) \ { \ u32 old_run = partial_tile_run; \ partial_tile_run = 4 - partial_tile_offset; \ partial_tile_8bpp(combine_op, alpha_op); \ partial_tile_run = old_run - partial_tile_run; \ current_pixels = *((u32 *)(tile_ptr + 4)); \ partial_tile_8bpp(combine_op, alpha_op); \ } \ else \ { \ partial_tile_8bpp(combine_op, alpha_op); \ } \ } \// Draws 8bpp tiles clipped against the right side of the screen,// partial_tile_run indicates how much there is to draw.#define partial_tile_left_noflip_8bpp(combine_op, alpha_op) \ if(partial_tile_run >= 4) \ { \ current_pixels = *((u32 *)tile_ptr); \ tile_8bpp_draw_four_##combine_op(0, alpha_op, noflip); \ advance_dest_ptr_##combine_op(4); \ tile_ptr += 4; \ partial_tile_run -= 4; \ } \ \ current_pixels = *((u32 *)(tile_ptr)); \ partial_tile_8bpp(combine_op, alpha_op) \// Draws a non-clipped (complete) 8bpp tile.#define tile_noflip_8bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr); \ tile_8bpp_draw_four_##combine_op(0, alpha_op, noflip); \ current_pixels = *((u32 *)(tile_ptr + 4)); \ tile_8bpp_draw_four_##combine_op(4, alpha_op, noflip) \// Like the above versions but draws flipped tiles.#define partial_tile_flip_8bpp(combine_op, alpha_op) \ for(i = 0; i < partial_tile_run; i++) \ { \ tile_8bpp_draw_##combine_op(0, shift, 24, alpha_op); \ current_pixels <<= 8; \ advance_dest_ptr_##combine_op(1); \ } \#define partial_tile_right_flip_8bpp(combine_op, alpha_op) \ if(partial_tile_offset >= 4) \ { \ current_pixels = *((u32 *)tile_ptr) << ((partial_tile_offset - 4) * 8); \ partial_tile_flip_8bpp(combine_op, alpha_op); \ } \ else \ { \ partial_tile_run -= 4; \ current_pixels = *((u32 *)(tile_ptr + 4)) << \ ((partial_tile_offset - 4) * 8); \ partial_tile_flip_8bpp(combine_op, alpha_op); \ current_pixels = *((u32 *)tile_ptr); \ tile_8bpp_draw_four_##combine_op(0, alpha_op, flip); \ advance_dest_ptr_##combine_op(4); \ } \#define partial_tile_mid_flip_8bpp(combine_op, alpha_op) \ if(partial_tile_offset >= 4) \ { \ current_pixels = *((u32 *)tile_ptr) << ((partial_tile_offset - 4) * 8); \ partial_tile_flip_8bpp(combine_op, alpha_op); \ } \ else \ { \ current_pixels = *((u32 *)(tile_ptr + 4)) << \ ((partial_tile_offset - 4) * 8); \ \ if((partial_tile_offset + partial_tile_run) > 4) \ { \ u32 old_run = partial_tile_run; \ partial_tile_run = 4 - partial_tile_offset; \ partial_tile_flip_8bpp(combine_op, alpha_op); \ partial_tile_run = old_run - partial_tile_run; \ current_pixels = *((u32 *)(tile_ptr)); \ partial_tile_flip_8bpp(combine_op, alpha_op); \ } \ else \ { \ partial_tile_flip_8bpp(combine_op, alpha_op); \ } \ } \#define partial_tile_left_flip_8bpp(combine_op, alpha_op) \ if(partial_tile_run >= 4) \ { \ current_pixels = *((u32 *)(tile_ptr + 4)); \ tile_8bpp_draw_four_##combine_op(0, alpha_op, flip); \ advance_dest_ptr_##combine_op(4); \ tile_ptr -= 4; \ partial_tile_run -= 4; \ } \ \ current_pixels = *((u32 *)(tile_ptr + 4)); \ partial_tile_flip_8bpp(combine_op, alpha_op) \#define tile_flip_8bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)(tile_ptr + 4)); \ tile_8bpp_draw_four_##combine_op(0, alpha_op, flip); \ current_pixels = *((u32 *)tile_ptr); \ tile_8bpp_draw_four_##combine_op(4, alpha_op, flip) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -