cb4a513a |
1 | // TODO... |
2 | |
3 | #include "../PicoInt.h" |
4 | |
d1df8786 |
5 | #define rot_comp Pico_mcd->rot_comp |
6 | |
7 | static int Table_Rot_Time[] = |
8 | { |
9 | 0x00054000, 0x00048000, 0x00040000, 0x00036000, //; 008-032 ; briefing - sprite |
10 | 0x0002E000, 0x00028000, 0x00024000, 0x00022000, //; 036-064 ; arbre souvent |
11 | 0x00021000, 0x00020000, 0x0001E000, 0x0001B800, //; 068-096 ; map thunderstrike |
12 | 0x00019800, 0x00017A00, 0x00015C00, 0x00013E00, //; 100-128 ; logo défoncé |
13 | |
14 | 0x00012000, 0x00011800, 0x00011000, 0x00010800, //; 132-160 ; briefing - map |
15 | 0x00010000, 0x0000F800, 0x0000F000, 0x0000E800, //; 164-192 |
16 | 0x0000E000, 0x0000D800, 0x0000D000, 0x0000C800, //; 196-224 |
17 | 0x0000C000, 0x0000B800, 0x0000B000, 0x0000A800, //; 228-256 ; batman visage |
18 | |
19 | 0x0000A000, 0x00009F00, 0x00009E00, 0x00009D00, //; 260-288 |
20 | 0x00009C00, 0x00009B00, 0x00009A00, 0x00009900, //; 292-320 |
21 | 0x00009800, 0x00009700, 0x00009600, 0x00009500, //; 324-352 |
22 | 0x00009400, 0x00009300, 0x00009200, 0x00009100, //; 356-384 |
23 | |
24 | 0x00009000, 0x00008F00, 0x00008E00, 0x00008D00, //; 388-416 |
25 | 0x00008C00, 0x00008B00, 0x00008A00, 0x00008900, //; 420-448 |
26 | 0x00008800, 0x00008700, 0x00008600, 0x00008500, //; 452-476 |
27 | 0x00008400, 0x00008300, 0x00008200, 0x00008100, //; 480-512 |
28 | }; |
29 | |
30 | |
31 | #if 1*0 |
32 | typedef struct |
33 | { |
34 | unsigned int Reg_58; // Stamp_Size |
35 | unsigned int Reg_5A; |
36 | unsigned int Reg_5C; |
37 | unsigned int Reg_5E; |
38 | unsigned int Reg_60; |
39 | unsigned int Reg_62; |
40 | unsigned int Reg_64; // V_Dot |
41 | unsigned int Reg_66; |
42 | |
43 | unsigned int Stamp_Map_Adr; |
44 | unsigned int Buffer_Adr; |
45 | unsigned int Vector_Adr; |
46 | unsigned int Jmp_Adr; |
47 | unsigned int Float_Part; |
48 | unsigned int Draw_Speed; |
49 | |
50 | unsigned int XS; |
51 | unsigned int YS; |
52 | unsigned int DXS; |
53 | unsigned int DYS; |
54 | unsigned int XD; |
55 | unsigned int YD; |
56 | unsigned int XD_Mul; |
57 | unsigned int H_Dot; |
58 | } Rot_Comp; |
59 | #endif |
cb4a513a |
60 | |
61 | static void gfx_cd_start(void) |
62 | { |
d1df8786 |
63 | int upd_len; |
64 | |
65 | dprintf("gfx_cd_start()"); |
66 | |
67 | upd_len = (rot_comp.Reg_62 >> 3) & 0x3f; |
68 | upd_len = Table_Rot_Time[upd_len]; |
69 | |
70 | rot_comp.Draw_Speed = rot_comp.Float_Part = upd_len; |
71 | |
72 | rot_comp.Reg_58 |= 0x8000; // Stamp_Size, we start a new GFX operation |
73 | |
74 | gfx_cd_update(); |
75 | } |
76 | |
77 | |
78 | static void gfx_completed(void) |
79 | { |
80 | rot_comp.Reg_58 &= 0x7fff; // Stamp_Size |
81 | rot_comp.Reg_64 = 0; |
cb4a513a |
82 | if (Pico_mcd->s68k_regs[0x33] & (1<<1)) |
83 | { |
84 | dprintf("gfx_cd irq 1"); |
85 | SekInterruptS68k(1); |
86 | } |
87 | } |
88 | |
d1df8786 |
89 | |
90 | //static void gfx_do(void) |
91 | //{ |
92 | //} |
93 | |
94 | |
cb4a513a |
95 | void gfx_cd_update(void) |
96 | { |
d1df8786 |
97 | unsigned char *V_Dot = (unsigned char *) &rot_comp.Reg_64; |
98 | int jobs; |
99 | |
100 | dprintf("gfx_cd_update, Reg_64 = %04x", rot_comp.Reg_64); |
101 | |
102 | if (!*V_Dot) |
103 | { |
104 | // ... |
105 | gfx_completed(); |
106 | return; |
107 | } |
108 | |
109 | jobs = rot_comp.Float_Part >> 16; |
110 | |
111 | if (!jobs) |
112 | { |
113 | rot_comp.Float_Part += rot_comp.Draw_Speed; |
114 | return; |
115 | } |
116 | |
117 | rot_comp.Float_Part &= 0xffff; |
118 | rot_comp.Float_Part += rot_comp.Draw_Speed; |
119 | |
120 | while (jobs--) |
121 | { |
122 | // jmp [Jmp_Adr]: |
123 | (*V_Dot)--; // dec byte [V_Dot] |
124 | |
125 | if (!*V_Dot) |
126 | { |
127 | // GFX_Completed: |
128 | gfx_completed(); |
129 | return; |
130 | } |
131 | } |
cb4a513a |
132 | } |
133 | |
134 | |
135 | unsigned int gfx_cd_read(unsigned int a) |
136 | { |
d1df8786 |
137 | unsigned int d = 0; |
138 | |
139 | switch (a) { |
140 | case 0x58: d = rot_comp.Reg_58; break; |
141 | case 0x5A: d = rot_comp.Reg_5A; break; |
142 | case 0x5C: d = rot_comp.Reg_5C; break; |
143 | case 0x5E: d = rot_comp.Reg_5E; break; |
144 | case 0x60: d = rot_comp.Reg_60; break; |
145 | case 0x62: d = rot_comp.Reg_62; break; |
146 | case 0x64: d = rot_comp.Reg_64; break; |
147 | case 0x66: break; |
148 | default: dprintf("gfx_cd_read: unexpected address: %02x", a); break; |
149 | } |
150 | |
151 | dprintf("gfx_cd_read(%02x) = %04x", a, d); |
cb4a513a |
152 | |
cb4a513a |
153 | return 0; |
154 | } |
155 | |
156 | void gfx_cd_write(unsigned int a, unsigned int d) |
157 | { |
158 | dprintf("gfx_cd_write(%x, %04x)", a, d); |
159 | |
160 | switch (a) { |
d1df8786 |
161 | case 0x58: // .Reg_Stamp_Size |
162 | rot_comp.Reg_58 = d & 7; |
163 | return; |
164 | |
165 | case 0x5A: // .Reg_Stamp_Adr |
166 | rot_comp.Reg_5A = d & 0xffe0; |
167 | return; |
168 | |
169 | case 0x5C: // .Reg_IM_VCell_Size |
170 | rot_comp.Reg_5C = d & 0x1f; |
171 | return; |
172 | |
173 | case 0x5E: // .Reg_IM_Adr |
174 | rot_comp.Reg_5E = d & 0xFFF8; |
175 | return; |
176 | |
177 | case 0x60: // .Reg_IM_Offset |
178 | rot_comp.Reg_60 = d & 0x3f; |
179 | return; |
180 | |
181 | case 0x62: // .Reg_IM_HDot_Size |
182 | rot_comp.Reg_62 = d & 0x1ff; |
183 | return; |
184 | |
185 | case 0x64: // .Reg_IM_VDot_Size |
186 | rot_comp.Reg_64 = d & 0xff; // V_Dot, must be 32bit? |
187 | return; |
188 | |
189 | case 0x66: // .Reg_Vector_Adr |
190 | rot_comp.Reg_66 = d & 0xfffe; |
cb4a513a |
191 | if (Pico_mcd->s68k_regs[3]&4) return; // can't do tanformations in 1M mode |
192 | gfx_cd_start(); |
193 | return; |
d1df8786 |
194 | |
195 | default: dprintf("gfx_cd_write: unexpected address: %02x", a); return; |
cb4a513a |
196 | } |
197 | } |
198 | |
d1df8786 |
199 | |