comparison src/vdp.h @ 43:6e7bfe83d2b0

Changed the design to vastly simplify the video hardware and support a 23-bit address space on the CPU
author Michael Pavone <pavone@retrodev.com>
date Sat, 27 Aug 2016 22:38:31 -0700
parents 083347ccd508
children
comparison
equal deleted inserted replaced
42:a64e11e48a41 43:6e7bfe83d2b0
1 #ifndef VDP_H_ 1 #ifndef VDP_H_
2 #define VDP_H_ 2 #define VDP_H_
3 3
4 typedef struct { 4 typedef struct {
5 uint16_t source;
6 uint16_t x;
7 uint8_t hflip;
8 uint8_t palpriority;
9 } sprite_draw;
10
11 typedef struct {
12 uint16_t *framebuffer; 5 uint16_t *framebuffer;
13 uint8_t *drawbuffer;
14 uint8_t *readbuffer;
15 uint32_t cycles; 6 uint32_t cycles;
16 uint32_t clock_inc; 7 uint32_t clock_inc;
17 int pitch; 8 int pitch;
18 9
19 uint16_t fifo;
20 uint16_t dest_offset;
21 uint16_t status; 10 uint16_t status;
22 11
23 uint16_t vcounter; 12 uint16_t vcounter;
24 uint16_t hcounter; 13 uint16_t hcounter;
25 14
26 uint16_t vscroll;
27 uint16_t hscroll;
28 15
29 uint16_t draw_source; 16 uint8_t vram[128*1024];
30 uint16_t draw_dest; 17 uint16_t cram[256];
31 18
19 uint16_t start_offset;
32 20
33 uint16_t vram[32*512]; 21 uint8_t top_skip;
34 uint8_t linebuffers[328*2]; 22 uint8_t bottom_skip;
35 uint16_t sram[64*2]; 23 uint8_t pal_select;
36 uint16_t cram[64];
37 24
38 sprite_draw sprite_draws[40]; 25 uint8_t pal_write_index;
39 26 uint8_t pal_write_count;
40 uint8_t fifo_dest;
41 uint8_t draw_counter;
42 uint8_t hflip;
43 uint8_t palpriority;
44 uint8_t current_draw;
45 } vdp; 27 } vdp;
46 28
47 enum {
48 FIFO_DEST_INVALID,
49 FIFO_DEST_VRAM,
50 FIFO_DEST_SRAM,
51 FIFO_DEST_CRAM
52 };
53
54 #define VDP_STATUS_FIFO 1
55 #define VDP_STATUS_VRAM 2
56 #define VDP_STATUS_SRAM 4
57 #define VDP_STATUS_ENABLED 8
58 #define VDP_STATUS_SPRITE_SCAN 16
59 #define VDP_STATUS_PENDING_VINT 32
60 29
61 void vdp_init(vdp *context, uint32_t clock_div); 30 void vdp_init(vdp *context, uint32_t clock_div);
62 void vdp_run(vdp *context, uint32_t target); 31 void vdp_run(vdp *context, uint32_t target);
63 void vdp_write_address(vdp *context, uint16_t value); 32 void vdp_write_mode(vdp *context, uint16_t value);
64 void vdp_write_data(vdp *context, uint16_t value); 33 void vdp_write_cram(vdp *context, uint16_t value);
65 void vdp_write_hscroll(vdp *context, uint16_t value);
66 uint32_t vdp_next_interrupt(vdp *context); 34 uint32_t vdp_next_interrupt(vdp *context);
67 void vdp_ack_interrupt(vdp *context); 35 void vdp_ack_interrupt(vdp *context);
68 uint8_t vdp_interrupt_pending(vdp *context); 36 uint8_t vdp_interrupt_pending(vdp *context);
37 uint8_t *vdp_get_back_buffer(vdp *context);
69 38
70 #endif //VDP_H_ 39 #endif //VDP_H_