Mercurial > repos > blastem
comparison vdp.h @ 1931:374a5ae694e8 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 18 Apr 2020 11:42:53 -0700 |
parents | 039553703c20 |
children | c3c62dbf1ceb |
comparison
equal
deleted
inserted
replaced
1843:13abdc98379e | 1931:374a5ae694e8 |
---|---|
14 #define VDP_REGS 24 | 14 #define VDP_REGS 24 |
15 #define CRAM_SIZE 64 | 15 #define CRAM_SIZE 64 |
16 #define SHADOW_OFFSET CRAM_SIZE | 16 #define SHADOW_OFFSET CRAM_SIZE |
17 #define HIGHLIGHT_OFFSET (SHADOW_OFFSET+CRAM_SIZE) | 17 #define HIGHLIGHT_OFFSET (SHADOW_OFFSET+CRAM_SIZE) |
18 #define MODE4_OFFSET (HIGHLIGHT_OFFSET+CRAM_SIZE) | 18 #define MODE4_OFFSET (HIGHLIGHT_OFFSET+CRAM_SIZE) |
19 #define VSRAM_SIZE 40 | 19 #define MIN_VSRAM_SIZE 40 |
20 #define MAX_VSRAM_SIZE 64 | |
20 #define VRAM_SIZE (64*1024) | 21 #define VRAM_SIZE (64*1024) |
21 #define BORDER_LEFT 13 | 22 #define BORDER_LEFT 13 |
22 #define BORDER_RIGHT 14 | 23 #define BORDER_RIGHT 14 |
23 #define HORIZ_BORDER (BORDER_LEFT+BORDER_RIGHT) | 24 #define HORIZ_BORDER (BORDER_LEFT+BORDER_RIGHT) |
24 #define LINEBUF_SIZE (320+HORIZ_BORDER) //H40 + full border | 25 #define LINEBUF_SIZE (320+HORIZ_BORDER) //H40 + full border |
25 #define SCROLL_BUFFER_SIZE 32 | 26 #define SCROLL_BUFFER_SIZE 32 |
26 #define BORDER_BOTTOM 13 //TODO: Replace with actual value | 27 #define BORDER_BOTTOM 13 //TODO: Replace with actual value |
27 #define MAX_DRAWS 40 | |
28 #define MAX_DRAWS_H32 32 | |
29 #define MAX_DRAWS_H32_MODE4 8 | 28 #define MAX_DRAWS_H32_MODE4 8 |
30 #define MAX_SPRITES_LINE 20 | 29 #define MAX_SPRITES_LINE 20 |
31 #define MAX_SPRITES_LINE_H32 16 | 30 #define MAX_SPRITES_LINE_H32 16 |
32 #define MAX_SPRITES_FRAME 80 | 31 #define MAX_SPRITES_FRAME 80 |
33 #define MAX_SPRITES_FRAME_H32 64 | 32 #define MAX_SPRITES_FRAME_H32 64 |
131 typedef struct { | 130 typedef struct { |
132 uint16_t address; | 131 uint16_t address; |
133 int16_t x_pos; | 132 int16_t x_pos; |
134 uint8_t pal_priority; | 133 uint8_t pal_priority; |
135 uint8_t h_flip; | 134 uint8_t h_flip; |
135 uint8_t width; | |
136 uint8_t height; | |
136 } sprite_draw; | 137 } sprite_draw; |
137 | 138 |
138 typedef struct { | 139 typedef struct { |
139 uint8_t size; | 140 uint8_t size; |
140 uint8_t index; | 141 uint8_t index; |
171 uint32_t debug_fb_pitch[VDP_NUM_DEBUG_TYPES]; | 172 uint32_t debug_fb_pitch[VDP_NUM_DEBUG_TYPES]; |
172 fifo_entry fifo[FIFO_SIZE]; | 173 fifo_entry fifo[FIFO_SIZE]; |
173 int32_t fifo_write; | 174 int32_t fifo_write; |
174 int32_t fifo_read; | 175 int32_t fifo_read; |
175 uint32_t address; | 176 uint32_t address; |
177 uint32_t address_latch; | |
176 uint32_t serial_address; | 178 uint32_t serial_address; |
177 uint32_t colors[CRAM_SIZE*4]; | 179 uint32_t colors[CRAM_SIZE*4]; |
178 uint32_t debugcolors[1 << (3 + 1 + 1 + 1)];//3 bits for source, 1 bit for priority, 1 bit for shadow, 1 bit for hilight | 180 uint32_t debugcolors[1 << (3 + 1 + 1 + 1)];//3 bits for source, 1 bit for priority, 1 bit for shadow, 1 bit for hilight |
179 uint16_t cram[CRAM_SIZE]; | 181 uint16_t cram[CRAM_SIZE]; |
180 uint32_t frame; | 182 uint32_t frame; |
183 uint32_t vsram_size; | |
181 uint8_t cd; | 184 uint8_t cd; |
185 uint8_t cd_latch; | |
182 uint8_t flags; | 186 uint8_t flags; |
183 uint8_t regs[VDP_REGS]; | 187 uint8_t regs[VDP_REGS]; |
184 //cycle count in MCLKs | 188 //cycle count in MCLKs |
185 uint32_t cycles; | 189 uint32_t cycles; |
186 uint32_t pending_vint_start; | 190 uint32_t pending_vint_start; |
187 uint32_t pending_hint_start; | 191 uint32_t pending_hint_start; |
188 uint16_t vsram[VSRAM_SIZE]; | 192 uint32_t top_offset; |
193 uint16_t vsram[MAX_VSRAM_SIZE]; | |
189 uint16_t vscroll_latch[2]; | 194 uint16_t vscroll_latch[2]; |
190 uint16_t vcounter; | 195 uint16_t vcounter; |
191 uint16_t inactive_start; | 196 uint16_t inactive_start; |
192 uint16_t border_top; | 197 uint16_t border_top; |
193 uint16_t border_bot; | 198 uint16_t border_bot; |
194 uint16_t hscroll_a; | 199 uint16_t hscroll_a; |
200 uint16_t hscroll_a_fine; | |
195 uint16_t hscroll_b; | 201 uint16_t hscroll_b; |
202 uint16_t hscroll_b_fine; | |
196 uint16_t h40_lines; | 203 uint16_t h40_lines; |
197 uint16_t output_lines; | 204 uint16_t output_lines; |
198 sprite_draw sprite_draw_list[MAX_DRAWS]; | 205 sprite_draw sprite_draw_list[MAX_SPRITES_LINE]; |
199 sprite_info sprite_info_list[MAX_SPRITES_LINE]; | 206 sprite_info sprite_info_list[MAX_SPRITES_LINE]; |
200 uint8_t sat_cache[SAT_CACHE_SIZE]; | 207 uint8_t sat_cache[SAT_CACHE_SIZE]; |
201 uint16_t col_1; | 208 uint16_t col_1; |
202 uint16_t col_2; | 209 uint16_t col_2; |
203 uint16_t hv_latch; | 210 uint16_t hv_latch; |
210 uint8_t hslot; //hcounter/2 | 217 uint8_t hslot; //hcounter/2 |
211 uint8_t sprite_index; | 218 uint8_t sprite_index; |
212 uint8_t sprite_draws; | 219 uint8_t sprite_draws; |
213 int8_t slot_counter; | 220 int8_t slot_counter; |
214 int8_t cur_slot; | 221 int8_t cur_slot; |
222 uint8_t sprite_x_offset; | |
215 uint8_t max_sprites_frame; | 223 uint8_t max_sprites_frame; |
216 uint8_t max_sprites_line; | 224 uint8_t max_sprites_line; |
217 uint8_t fetch_tmp[2]; | 225 uint8_t fetch_tmp[2]; |
218 uint8_t v_offset; | 226 uint8_t v_offset; |
219 uint8_t hint_counter; | 227 uint8_t hint_counter; |
227 uint8_t tmp_buf_a[SCROLL_BUFFER_SIZE]; | 235 uint8_t tmp_buf_a[SCROLL_BUFFER_SIZE]; |
228 uint8_t tmp_buf_b[SCROLL_BUFFER_SIZE]; | 236 uint8_t tmp_buf_b[SCROLL_BUFFER_SIZE]; |
229 uint8_t enabled_debuggers; | 237 uint8_t enabled_debuggers; |
230 uint8_t debug_fb_indices[VDP_NUM_DEBUG_TYPES]; | 238 uint8_t debug_fb_indices[VDP_NUM_DEBUG_TYPES]; |
231 uint8_t debug_modes[VDP_NUM_DEBUG_TYPES]; | 239 uint8_t debug_modes[VDP_NUM_DEBUG_TYPES]; |
240 uint8_t pushed_frame; | |
232 uint8_t vdpmem[]; | 241 uint8_t vdpmem[]; |
233 } vdp_context; | 242 } vdp_context; |
234 | 243 |
235 | 244 |
236 | 245 |
237 vdp_context *init_vdp_context(uint8_t region_pal); | 246 vdp_context *init_vdp_context(uint8_t region_pal, uint8_t has_max_vsram); |
238 void vdp_free(vdp_context *context); | 247 void vdp_free(vdp_context *context); |
239 void vdp_run_context_full(vdp_context * context, uint32_t target_cycles); | 248 void vdp_run_context_full(vdp_context * context, uint32_t target_cycles); |
240 void vdp_run_context(vdp_context * context, uint32_t target_cycles); | 249 void vdp_run_context(vdp_context * context, uint32_t target_cycles); |
241 //runs from current cycle count to VBLANK for the current mode, returns ending cycle count | 250 //runs from current cycle count to VBLANK for the current mode, returns ending cycle count |
242 uint32_t vdp_run_to_vblank(vdp_context * context); | 251 uint32_t vdp_run_to_vblank(vdp_context * context); |
252 uint16_t vdp_control_port_read(vdp_context * context); | 261 uint16_t vdp_control_port_read(vdp_context * context); |
253 uint16_t vdp_data_port_read(vdp_context * context); | 262 uint16_t vdp_data_port_read(vdp_context * context); |
254 uint8_t vdp_data_port_read_pbc(vdp_context * context); | 263 uint8_t vdp_data_port_read_pbc(vdp_context * context); |
255 void vdp_latch_hv(vdp_context *context); | 264 void vdp_latch_hv(vdp_context *context); |
256 uint16_t vdp_hv_counter_read(vdp_context * context); | 265 uint16_t vdp_hv_counter_read(vdp_context * context); |
257 uint16_t vdp_test_port_read(vdp_context * context); | |
258 void vdp_adjust_cycles(vdp_context * context, uint32_t deduction); | 266 void vdp_adjust_cycles(vdp_context * context, uint32_t deduction); |
259 uint32_t vdp_next_hint(vdp_context * context); | 267 uint32_t vdp_next_hint(vdp_context * context); |
260 uint32_t vdp_next_vint(vdp_context * context); | 268 uint32_t vdp_next_vint(vdp_context * context); |
261 uint32_t vdp_next_vint_z80(vdp_context * context); | 269 uint32_t vdp_next_vint_z80(vdp_context * context); |
262 uint32_t vdp_next_nmi(vdp_context *context); | 270 uint32_t vdp_next_nmi(vdp_context *context); |