1 //render.cpp 2 debugvirtual inline void render_line_mode0(); 3 debugvirtual inline void render_line_mode1(); 4 debugvirtual inline void render_line_mode2(); 5 debugvirtual inline void render_line_mode3(); 6 debugvirtual inline void render_line_mode4(); 7 debugvirtual inline void render_line_mode5(); 8 debugvirtual inline void render_line_mode6(); 9 debugvirtual inline void render_line_mode7(); 10 11 //cache.cpp 12 enum { COLORDEPTH_4 = 0, COLORDEPTH_16 = 1, COLORDEPTH_256 = 2 }; 13 enum { TILE_2BIT = 0, TILE_4BIT = 1, TILE_8BIT = 2 }; 14 15 struct pixel_t { 16 //bgr555 color data for main/subscreen pixels: 0x0000 = transparent / use palette color # 0 17 //needs to be bgr555 instead of palette index for direct color mode ($2130 bit 0) to work 18 uint16 src_main, src_sub; 19 //indicates source of palette # for main/subscreen (BG1-4, OAM, or back) 20 uint8 bg_main, bg_sub; 21 //color_exemption -- true when bg == OAM && palette index >= 192, disables color add/sub effects 22 uint8 ce_main, ce_sub; 23 //priority level of src_n. to set src_n, 24 //the priority of the pixel must be >pri_n 25 uint8 pri_main, pri_sub; 26 } pixel_cache[256]; 27 28 uint8 *bg_tiledata[3]; 29 uint8 *bg_tiledata_state[3]; //0 = valid, 1 = dirty 30 31 template<unsigned color_depth> void render_bg_tile(uint16 tile_num); 32 inline void flush_pixel_cache(); 33 void alloc_tiledata_cache(); 34 void flush_tiledata_cache(); 35 void free_tiledata_cache(); 36 37 //windows.cpp 38 struct window_t { 39 uint8 main[256], sub[256]; 40 } window[6]; 41 42 void build_window_table(uint8 bg, bool mainscreen); 43 void build_window_tables(uint8 bg); 44 45 //bg.cpp 46 struct { 47 uint16 tw, th; //tile width, height 48 uint16 mx, my; //screen mask x, y 49 uint16 scx, scy; //sc index offsets 50 } bg_info[4]; 51 void update_bg_info(); 52 53 template<unsigned bg> uint16 bg_get_tile(uint16 x, uint16 y); 54 template<unsigned mode, unsigned bg, unsigned color_depth> void render_line_bg(uint8 pri0_pos, uint8 pri1_pos); 55 56 //oam.cpp 57 struct sprite_item { 58 uint8 width, height; 59 uint16 x, y; 60 uint8 character; 61 bool use_nameselect; 62 bool vflip, hflip; 63 uint8 palette; 64 uint8 priority; 65 } sprite_list[128]; 66 bool sprite_list_valid; 67 unsigned active_sprite; 68 69 uint8 oam_itemlist[32]; 70 struct oam_tileitem { 71 uint16 x, y, pri, pal, tile; 72 bool hflip; 73 } oam_tilelist[34]; 74 75 enum { OAM_PRI_NONE = 4 }; 76 uint8 oam_line_pal[256], oam_line_pri[256]; 77 78 void build_sprite_list(); 79 bool is_sprite_on_scanline(); 80 void load_oam_tiles(); 81 void render_oam_tile(int tile_num); 82 void render_line_oam_rto(); 83 void render_line_oam(uint8 pri0_pos, uint8 pri1_pos, uint8 pri2_pos, uint8 pri3_pos); 84 85 //mode7.cpp 86 template<unsigned bg> void render_line_mode7(uint8 pri0_pos, uint8 pri1_pos); 87 88 //addsub.cpp 89 inline uint16 addsub(uint32 x, uint32 y, bool halve); 90 91 //line.cpp 92 inline uint16 get_palette(uint8 index); 93 inline uint16 get_direct_color(uint8 p, uint8 t); 94 inline uint16 get_pixel_normal(uint32 x); 95 inline uint16 get_pixel_swap(uint32 x); 96 void render_line_output(); 97 void render_line_clear(); 98