Debian Codegraph @

mednafen/pce_fast/vdc.h

raw symbols SCIP
1 #ifndef _PCE_VDC_H
2 #define _PCE_VDC_H
3
4 #define REGSETP(_reg, _data, _msb) { _reg &= 0xFF << ((_msb) ? 0 : 8); _reg |= (_data) << ((_msb) ? 8 : 0); }
5 #define REGGETP(_reg, _msb) ((_reg >> ((_msb) ? 8 : 0)) & 0xFF)
6
7 #define VDC_DEBUG(x)
8 //printf("%s: %d\n", x, vdc->display_counter);
9 #define VDC_UNDEFINED(x) { }
10 //{ printf("%s: %d\n", x, vdc->display_counter); }
11
12 static const uint8 vram_inc_tab[4] = { 1, 32, 64, 128 };
13
14 typedef struct
15 {
16 uint8 priority[2];
17 uint16 winwidths[2];
18 uint8 st_mode;
19 } vpc_t;
20
21 extern vpc_t vpc;
22
23 static const int VRAM_Size = 0x8000;
24 static const int VRAM_SizeMask = VRAM_Size - 1; //0x7FFF;
25 static const int VRAM_BGTileNoMask = VRAM_SizeMask / 16; //0x7FF;
26
27 typedef struct
28 {
29 uint8 CR;
30
31 bool lc263; // 263 line count if set, 262 if not
32 bool bw; // Black and White
33 uint8 dot_clock; // Dot Clock(5, 7, or 10 MHz = 0, 1, 2)
34 uint16 color_table[0x200];
35 uint16 color_table_cache[0x200];
36 uint16 ctaddress;
37 } vce_t;
38
39 extern vce_t vce;
40
41 typedef struct
42 {
43 int16 y;
44 uint16 height;
45 uint16 x;
46 uint16 no;
47 uint16 flags;
48 bool cgmode;
49 } SAT_Cache_t;
50
51 typedef struct
52 {
53 uint32 display_counter;
54
55 int32 sat_dma_slcounter;
56
57 uint8 select;
58 uint16 MAWR; // Memory Address Write Register
59 uint16 MARR; // Memory Address Read Register
60
61 uint16 CR; // Control Register
62 uint16 RCR; // Raster Compare Register
63 uint16 BXR; // Background X-Scroll Register
64 uint16 BYR; // Background Y-Scroll Register
65 uint16 MWR; // Memory Width Register
66
67 uint16 HSR; // Horizontal Sync Register
68 uint16 HDR; // Horizontal Display Register
69 uint16 VSR;
70 uint16 VDR;
71
72 uint16 VCR;
73 uint16 DCR;
74 uint16 SOUR;
75 uint16 DESR;
76 uint16 LENR;
77 uint16 SATB;
78
79 uint32 RCRCount;
80
81 uint16 read_buffer;
82 uint8 write_latch;
83 uint8 status;
84
85 uint16 DMAReadBuffer;
86 bool DMAReadWrite;
87 bool DMARunning;
88 bool SATBPending;
89 bool burst_mode;
90
91 uint32 BG_YOffset;
92 uint32 BG_XOffset;
93
94
95
96 int SAT_Cache_Valid; // 64 through 128, depending on the number of 32-pixel-wide sprites.
97 SAT_Cache_t SAT_Cache[128]; //64];
98
99 uint16 SAT[0x100];
100
101 uint16 VRAM[65536]; //VRAM_Size];
102 uint64 bg_tile_cache[65536][8]; // Tile, y, x
103 uint8 spr_tile_cache[1024][16][16]; // Tile, y, x
104 uint8 spr_tile_clean[1024]; //VRAM_Size / 64];
105 } vdc_t;
106
107 extern vdc_t *vdc;
108
109
110 void VDC_SetPixelFormat(void);
111 void VDC_RunFrame(EmulateSpecStruct *espec, bool IsHES);
112 void VDC_SetLayerEnableMask(uint64 mask);
113
114 DECLFW(VDC_Write);
115 DECLFW(VDC_Write_ST);
116
117 DECLFR(VCE_Read);
118
119 static INLINE uint8 VDC_Read(unsigned int A, bool SGX)
120 {
121 uint8 ret = 0;
122 int msb = A & 1;
123 int chip = 0;
124
125 {
126 A &= 0x3;
127 }
128
129 switch(A)
130 {
131 case 0x0: ret = vdc->status;
132
133 vdc->status &= ~0x3F;
134
135 HuC6280_IRQEnd(MDFN_IQIRQ1); // Clear VDC IRQ line
136
137 break;
138
139 case 0x2:
140 case 0x3:
141 ret = REGGETP(vdc->read_buffer, msb);
142 if(vdc->select == 0x2) // VRR - VRAM Read Register
143 {
144 if(msb)
145 {
146 vdc->MARR += vram_inc_tab[(vdc->CR >> 11) & 0x3];
147
148 if(vdc->MARR >= VRAM_Size)
149 VDC_UNDEFINED("Unmapped VRAM VRR read");
150 vdc->read_buffer = vdc->VRAM[vdc->MARR & VRAM_SizeMask];
151 }
152 }
153 break;
154 }
155
156 //if(HuCPU.isopread && (A == 1 || A == 3)) //(A == 2 || A == 3)) // && A == 1)
157 if(A == 1)
158 {
159 //if(vdc->display_counter >= (VDS + VSW) && vdc->display_counter < (VDS + VSW + VDW + 1) && vce.dot_clock > 0)
160 if(vce.dot_clock > 0)
161 ret = 0x40;
162 //printf("%d %d %02x\n", vdc->display_counter, vce.dot_clock, ret);
163 //ret = 0x40;
164 }
165 return(ret);
166 }
167
168 DECLFW(VCE_Write);
169
170 void VDC_Init(int sgx) MDFN_COLD;
171 void VDC_Close(void) MDFN_COLD;
172 void VDC_Reset(void) MDFN_COLD;
173 void VDC_Power(void) MDFN_COLD;
174
175 int VDC_StateAction(StateMem *sm, int load, int data_only);
176
177 #endif