📄 video.c
字号:
#define partial_tile_left_flip_4bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr); \ partial_tile_flip_4bpp(combine_op, alpha_op) \#define tile_flip_4bpp(combine_op, alpha_op) \ current_pixels = *((u32 *)tile_ptr); \ tile_4bpp_draw_eight_##combine_op(alpha_op, flip) \// Draws a single (partial or complete) tile from the tilemap, flipping// as necessary.#define single_tile_map(tile_type, combine_op, color_depth, alpha_op) \ get_tile_##color_depth(); \ if(current_tile & 0x800) \ tile_ptr += vertical_pixel_flip; \ \ if(current_tile & 0x400) \ { \ tile_type##_flip_##color_depth(combine_op, alpha_op); \ } \ else \ { \ tile_type##_noflip_##color_depth(combine_op, alpha_op); \ } \// Draws multiple sequential tiles from the tilemap, hflips and vflips as// necessary.#define multiple_tile_map(combine_op, color_depth, alpha_op) \ for(i = 0; i < tile_run; i++) \ { \ single_tile_map(tile, combine_op, color_depth, alpha_op); \ advance_dest_ptr_##combine_op(8); \ map_ptr++; \ } \// Draws a partial tile from a tilemap clipped against the left edge of the// screen.#define partial_tile_right_map(combine_op, color_depth, alpha_op) \ single_tile_map(partial_tile_right, combine_op, color_depth, alpha_op); \ map_ptr++ \// Draws a partial tile from a tilemap clipped against both edges of the// screen.#define partial_tile_mid_map(combine_op, color_depth, alpha_op) \ single_tile_map(partial_tile_mid, combine_op, color_depth, alpha_op) \// Draws a partial tile from a tilemap clipped against the right edge of the// screen.#define partial_tile_left_map(combine_op, color_depth, alpha_op) \ single_tile_map(partial_tile_left, combine_op, color_depth, alpha_op) \// Advances a non-flipped 4bpp obj to the next tile.#define obj_advance_noflip_4bpp() \ tile_ptr += 32 \// Advances a non-flipped 8bpp obj to the next tile.#define obj_advance_noflip_8bpp() \ tile_ptr += 64 \// Advances a flipped 4bpp obj to the next tile.#define obj_advance_flip_4bpp() \ tile_ptr -= 32 \// Advances a flipped 8bpp obj to the next tile.#define obj_advance_flip_8bpp() \ tile_ptr -= 64 \// Draws multiple sequential tiles from an obj, flip_op determines if it should// be flipped or not (set to flip or noflip)#define multiple_tile_obj(combine_op, color_depth, alpha_op, flip_op) \ for(i = 0; i < tile_run; i++) \ { \ tile_##flip_op##_##color_depth(combine_op, alpha_op); \ obj_advance_##flip_op##_##color_depth(); \ advance_dest_ptr_##combine_op(8); \ } \// Draws an obj's tile clipped against the left side of the screen#define partial_tile_right_obj(combine_op, color_depth, alpha_op, flip_op) \ partial_tile_right_##flip_op##_##color_depth(combine_op, alpha_op); \ obj_advance_##flip_op##_##color_depth() \// Draws an obj's tile clipped against both sides of the screen#define partial_tile_mid_obj(combine_op, color_depth, alpha_op, flip_op) \ partial_tile_mid_##flip_op##_##color_depth(combine_op, alpha_op) \// Draws an obj's tile clipped against the right side of the screen#define partial_tile_left_obj(combine_op, color_depth, alpha_op, flip_op) \ partial_tile_left_##flip_op##_##color_depth(combine_op, alpha_op) \// Extra variables specific for 8bpp/4bpp tile renderers.#define tile_extra_variables_8bpp() \#define tile_extra_variables_4bpp() \ u32 current_palette \// Byte lengths of complete tiles and tile rows in 4bpp and 8bpp.#define tile_width_4bpp 4#define tile_size_4bpp 32#define tile_width_8bpp 8#define tile_size_8bpp 64// Render a single scanline of text tiles#define tile_render(color_depth, combine_op, alpha_op) \{ \ u32 vertical_pixel_offset = (vertical_offset % 8) * \ tile_width_##color_depth; \ u32 vertical_pixel_flip = \ ((tile_size_##color_depth - tile_width_##color_depth) - \ vertical_pixel_offset) - vertical_pixel_offset; \ tile_extra_variables_##color_depth(); \ u8 *tile_base = vram + (((bg_control >> 2) & 0x03) * (1024 * 16)) + \ vertical_pixel_offset; \ u32 pixel_run = 256 - (horizontal_offset % 256); \ u32 current_tile; \ \ map_base += ((vertical_offset % 256) / 8) * 32; \ partial_tile_offset = (horizontal_offset % 8); \ \ if(pixel_run >= end) \ { \ if(partial_tile_offset) \ { \ partial_tile_run = 8 - partial_tile_offset; \ if(end < partial_tile_run) \ { \ partial_tile_run = end; \ partial_tile_mid_map(combine_op, color_depth, alpha_op); \ return; \ } \ else \ { \ end -= partial_tile_run; \ partial_tile_right_map(combine_op, color_depth, alpha_op); \ } \ } \ \ tile_run = end / 8; \ multiple_tile_map(combine_op, color_depth, alpha_op); \ \ partial_tile_run = end % 8; \ \ if(partial_tile_run) \ { \ partial_tile_left_map(combine_op, color_depth, alpha_op); \ } \ } \ else \ { \ if(partial_tile_offset) \ { \ partial_tile_run = 8 - partial_tile_offset; \ partial_tile_right_map(combine_op, color_depth, alpha_op); \ } \ \ tile_run = (pixel_run - partial_tile_run) / 8; \ multiple_tile_map(combine_op, color_depth, alpha_op); \ map_ptr = second_ptr; \ end -= pixel_run; \ tile_run = end / 8; \ multiple_tile_map(combine_op, color_depth, alpha_op); \ \ partial_tile_run = end % 8; \ if(partial_tile_run) \ { \ partial_tile_left_map(combine_op, color_depth, alpha_op); \ } \ } \} \#define render_scanline_dest_normal u16#define render_scanline_dest_alpha u32#define render_scanline_dest_alpha_obj u32#define render_scanline_dest_color16 u16#define render_scanline_dest_color32 u32#define render_scanline_dest_partial_alpha u32#define render_scanline_dest_copy_tile u16#define render_scanline_dest_copy_bitmap u16// If rendering a scanline that is not a target A then there's no point in// keeping what's underneath it because it can't blend with it.#define render_scanline_skip_alpha(bg_type, combine_op) \ if((pixel_combine & 0x00000200) == 0) \ { \ render_scanline_##bg_type##_##combine_op##_color32(layer, \ start, end, scanline); \ return; \ } \#define render_scanline_extra_variables_base_normal(bg_type) \#define render_scanline_extra_variables_transparent_normal(bg_type) \#define render_scanline_extra_variables_base_alpha(bg_type) \ u32 bg_combine = color_combine_mask(5); \ u32 pixel_combine = color_combine_mask(layer) | (bg_combine << 16); \ render_scanline_skip_alpha(bg_type, base) \#define render_scanline_extra_variables_base_color() \ u32 bg_combine = color_combine_mask(5); \ u32 pixel_combine = color_combine_mask(layer) \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -