Mercurial > repos > blastem
comparison vdp.h @ 1640:3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 16 Nov 2018 19:56:24 -0800 |
parents | f27142c48567 |
children | bc9bb4e5856f |
comparison
equal
deleted
inserted
replaced
1639:93518786f882 | 1640:3602f3b20072 |
---|---|
17 #define VRAM_SIZE (64*1024) | 17 #define VRAM_SIZE (64*1024) |
18 #define BORDER_LEFT 13 | 18 #define BORDER_LEFT 13 |
19 #define BORDER_RIGHT 14 | 19 #define BORDER_RIGHT 14 |
20 #define HORIZ_BORDER (BORDER_LEFT+BORDER_RIGHT) | 20 #define HORIZ_BORDER (BORDER_LEFT+BORDER_RIGHT) |
21 #define LINEBUF_SIZE (320+HORIZ_BORDER) //H40 + full border | 21 #define LINEBUF_SIZE (320+HORIZ_BORDER) //H40 + full border |
22 #define SCROLL_BUFFER_SIZE 32 | |
22 #define BORDER_BOTTOM 13 //TODO: Replace with actual value | 23 #define BORDER_BOTTOM 13 //TODO: Replace with actual value |
23 #define MAX_DRAWS 40 | 24 #define MAX_DRAWS 40 |
24 #define MAX_DRAWS_H32 32 | 25 #define MAX_DRAWS_H32 32 |
25 #define MAX_DRAWS_H32_MODE4 8 | 26 #define MAX_DRAWS_H32_MODE4 8 |
26 #define MAX_SPRITES_LINE 20 | 27 #define MAX_SPRITES_LINE 20 |
154 VDP_DEBUG_COMPOSITE, | 155 VDP_DEBUG_COMPOSITE, |
155 VDP_NUM_DEBUG_TYPES | 156 VDP_NUM_DEBUG_TYPES |
156 }; | 157 }; |
157 | 158 |
158 typedef struct { | 159 typedef struct { |
159 fifo_entry fifo[FIFO_SIZE]; | 160 system_header *system; |
160 int32_t fifo_write; | 161 //pointer to current line in framebuffer |
161 int32_t fifo_read; | 162 uint32_t *output; |
162 uint32_t address; | 163 uint32_t *done_output; |
163 uint32_t serial_address; | 164 //pointer to current framebuffer |
164 uint8_t cd; | 165 uint32_t *fb; |
165 uint8_t flags; | 166 uint32_t *debug_fbs[VDP_NUM_DEBUG_TYPES]; |
166 uint8_t regs[VDP_REGS]; | 167 uint32_t output_pitch; |
168 uint32_t debug_fb_pitch[VDP_NUM_DEBUG_TYPES]; | |
169 fifo_entry fifo[FIFO_SIZE]; | |
170 int32_t fifo_write; | |
171 int32_t fifo_read; | |
172 uint32_t address; | |
173 uint32_t serial_address; | |
174 uint32_t colors[CRAM_SIZE*4]; | |
175 uint32_t debugcolors[1 << (3 + 1 + 1 + 1)];//3 bits for source, 1 bit for priority, 1 bit for shadow, 1 bit for hilight | |
176 uint16_t cram[CRAM_SIZE]; | |
177 uint32_t frame; | |
178 uint8_t cd; | |
179 uint8_t flags; | |
180 uint8_t regs[VDP_REGS]; | |
167 //cycle count in MCLKs | 181 //cycle count in MCLKs |
168 uint32_t cycles; | 182 uint32_t cycles; |
169 uint32_t pending_vint_start; | 183 uint32_t pending_vint_start; |
170 uint32_t pending_hint_start; | 184 uint32_t pending_hint_start; |
171 uint8_t *vdpmem; | 185 uint16_t vsram[VSRAM_SIZE]; |
186 uint16_t vscroll_latch[2]; | |
187 uint16_t vcounter; | |
188 uint16_t inactive_start; | |
189 uint16_t border_top; | |
190 uint16_t border_bot; | |
191 uint16_t hscroll_a; | |
192 uint16_t hscroll_b; | |
193 uint16_t h40_lines; | |
194 uint16_t output_lines; | |
195 sprite_draw sprite_draw_list[MAX_DRAWS]; | |
196 sprite_info sprite_info_list[MAX_SPRITES_LINE]; | |
197 uint8_t sat_cache[SAT_CACHE_SIZE]; | |
198 uint16_t col_1; | |
199 uint16_t col_2; | |
200 uint16_t hv_latch; | |
201 uint16_t prefetch; | |
202 uint16_t test_port; | |
172 //stores 2-bit palette + 4-bit palette index + priority for current sprite line | 203 //stores 2-bit palette + 4-bit palette index + priority for current sprite line |
173 uint8_t *linebuf; | 204 uint8_t linebuf[LINEBUF_SIZE]; |
174 //pointer to current line in framebuffer | 205 uint8_t hslot; //hcounter/2 |
175 uint32_t *output; | 206 uint8_t sprite_index; |
176 uint32_t *done_output; | 207 uint8_t sprite_draws; |
177 uint32_t *fb; | 208 int8_t slot_counter; |
178 uint32_t *debug_fbs[VDP_NUM_DEBUG_TYPES]; | 209 int8_t cur_slot; |
179 uint32_t debug_fb_pitch[VDP_NUM_DEBUG_TYPES]; | 210 uint8_t max_sprites_frame; |
180 system_header *system; | 211 uint8_t max_sprites_line; |
181 uint16_t cram[CRAM_SIZE]; | 212 uint8_t fetch_tmp[2]; |
182 uint32_t colors[CRAM_SIZE*4]; | 213 uint8_t v_offset; |
183 uint32_t debugcolors[1 << (3 + 1 + 1 + 1)];//3 bits for source, 1 bit for priority, 1 bit for shadow, 1 bit for hilight | 214 uint8_t hint_counter; |
184 uint16_t vsram[VSRAM_SIZE]; | 215 uint8_t flags2; |
185 uint16_t vscroll_latch[2]; | 216 uint8_t double_res; |
186 uint32_t output_pitch; | 217 uint8_t buf_a_off; |
187 uint32_t frame; | 218 uint8_t buf_b_off; |
188 uint16_t vcounter; | 219 uint8_t debug; |
189 uint16_t inactive_start; | 220 uint8_t debug_pal; |
190 uint16_t border_top; | 221 uint8_t pending_byte; |
191 uint16_t border_bot; | 222 uint8_t state; |
192 uint16_t hscroll_a; | 223 uint8_t cur_buffer; |
193 uint16_t hscroll_b; | 224 uint8_t tmp_buf_a[SCROLL_BUFFER_SIZE]; |
194 uint16_t h40_lines; | 225 uint8_t tmp_buf_b[SCROLL_BUFFER_SIZE]; |
195 uint16_t output_lines; | 226 uint8_t enabled_debuggers; |
196 sprite_draw sprite_draw_list[MAX_DRAWS]; | 227 uint8_t debug_fb_indices[VDP_NUM_DEBUG_TYPES]; |
197 sprite_info sprite_info_list[MAX_SPRITES_LINE]; | 228 uint8_t debug_modes[VDP_NUM_DEBUG_TYPES]; |
198 uint8_t sat_cache[SAT_CACHE_SIZE]; | 229 uint8_t vdpmem[]; |
199 uint16_t col_1; | |
200 uint16_t col_2; | |
201 uint16_t hv_latch; | |
202 uint16_t prefetch; | |
203 uint16_t test_port; | |
204 uint8_t hslot; //hcounter/2 | |
205 uint8_t sprite_index; | |
206 uint8_t sprite_draws; | |
207 int8_t slot_counter; | |
208 int8_t cur_slot; | |
209 uint8_t max_sprites_frame; | |
210 uint8_t max_sprites_line; | |
211 uint8_t fetch_tmp[2]; | |
212 uint8_t v_offset; | |
213 uint8_t hint_counter; | |
214 uint8_t flags2; | |
215 uint8_t double_res; | |
216 uint8_t buf_a_off; | |
217 uint8_t buf_b_off; | |
218 uint8_t debug; | |
219 uint8_t debug_pal; | |
220 uint8_t pending_byte; | |
221 uint8_t state; | |
222 uint8_t cur_buffer; | |
223 uint8_t *tmp_buf_a; | |
224 uint8_t *tmp_buf_b; | |
225 uint8_t enabled_debuggers; | |
226 uint8_t debug_fb_indices[VDP_NUM_DEBUG_TYPES]; | |
227 uint8_t debug_modes[VDP_NUM_DEBUG_TYPES]; | |
228 } vdp_context; | 230 } vdp_context; |
229 | 231 |
230 | 232 |
231 | 233 |
232 void init_vdp_context(vdp_context * context, uint8_t region_pal); | 234 vdp_context *init_vdp_context(uint8_t region_pal); |
233 void vdp_free(vdp_context *context); | 235 void vdp_free(vdp_context *context); |
234 void vdp_run_context_full(vdp_context * context, uint32_t target_cycles); | 236 void vdp_run_context_full(vdp_context * context, uint32_t target_cycles); |
235 void vdp_run_context(vdp_context * context, uint32_t target_cycles); | 237 void vdp_run_context(vdp_context * context, uint32_t target_cycles); |
236 //runs from current cycle count to VBLANK for the current mode, returns ending cycle count | 238 //runs from current cycle count to VBLANK for the current mode, returns ending cycle count |
237 uint32_t vdp_run_to_vblank(vdp_context * context); | 239 uint32_t vdp_run_to_vblank(vdp_context * context); |