Mercurial > repos > blastem
comparison vdp.h @ 20:f664eeb55cb4
Mostly broken VDP core and savestate viewer
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 08 Dec 2012 02:00:54 -0800 |
parents | |
children | 72ce60cb1711 |
comparison
equal
deleted
inserted
replaced
19:4717146a7606 | 20:f664eeb55cb4 |
---|---|
1 #ifndef VDP_H_ | |
2 #define VDP_H_ | |
3 | |
4 #include <stdint.h> | |
5 #include <stdio.h> | |
6 | |
7 #define VDP_REGS 24 | |
8 #define CRAM_SIZE 64 | |
9 #define VSRAM_SIZE 40 | |
10 #define VRAM_SIZE (64*1024) | |
11 #define LINEBUF_SIZE 320 | |
12 #define FRAMEBUF_ENTRIES 320*224 | |
13 #define FRAMEBUF_SIZE (FRAMEBUF_ENTRIES*sizeof(uint16_t)) | |
14 #define MAX_DRAWS 40 | |
15 #define MAX_SPRITES_LINE 20 | |
16 | |
17 enum { | |
18 REG_MODE_1=0, | |
19 REG_MODE_2, | |
20 REG_SCROLL_A, | |
21 REG_WINDOW, | |
22 REG_SCROLL_B, | |
23 REG_SAT, | |
24 REG_BG_COLOR, | |
25 REG_HINT=0xA, | |
26 REG_MODE_3, | |
27 REG_MODE_4, | |
28 REG_HSCROLL, | |
29 REG_AUTOINC=0xF, | |
30 REG_SCROLL, | |
31 REG_WINDOW_H, | |
32 REG_WINDOW_V | |
33 } vdp_regs; | |
34 | |
35 typedef struct { | |
36 uint16_t address; | |
37 int16_t x_pos; | |
38 uint8_t pal_priority; | |
39 uint8_t h_flip; | |
40 } sprite_draw; | |
41 | |
42 typedef struct { | |
43 uint8_t size; | |
44 uint8_t index; | |
45 int16_t y; | |
46 } sprite_info; | |
47 | |
48 typedef struct { | |
49 //cycle count in MCLKs | |
50 uint32_t cycles; | |
51 uint8_t *vdpmem; | |
52 //stores 2-bit palette + 4-bit palette index + priority for current sprite line | |
53 uint8_t *linebuf; | |
54 //stores 12-bit color + shadow/highlight bits | |
55 uint16_t *framebuf; | |
56 uint16_t cram[CRAM_SIZE]; | |
57 uint16_t vsram[VSRAM_SIZE]; | |
58 uint8_t latched_mode; | |
59 uint16_t hscroll_a; | |
60 uint16_t hscroll_b; | |
61 uint8_t sprite_index; | |
62 uint8_t sprite_draws; | |
63 uint8_t slot_counter; | |
64 uint8_t regs[VDP_REGS]; | |
65 sprite_draw sprite_draw_list[MAX_DRAWS]; | |
66 sprite_info sprite_info_list[MAX_SPRITES_LINE]; | |
67 uint16_t col_1; | |
68 uint16_t col_2; | |
69 uint8_t v_offset; | |
70 uint8_t *tmp_buf_a; | |
71 uint8_t *tmp_buf_b; | |
72 } vdp_context; | |
73 | |
74 void init_vdp_context(vdp_context * context); | |
75 void vdp_run_context(vdp_context * context, uint32_t target_cycles); | |
76 //runs from current cycle count to VBLANK for the current mode, returns ending cycle count | |
77 uint32_t vdp_run_to_vblank(vdp_context * context); | |
78 void vdp_load_savestate(vdp_context * context, FILE * state_file); | |
79 | |
80 #endif //VDP_H_ |