1 /* Copyright 2003-2005 Guillaume Duhamel 2 Copyright 2004-2006 Theo Berkau 3 4 This file is part of Yabause. 5 6 Yabause is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 Yabause is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Yabause; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef VDP2_H 22 #define VDP2_H 23 24 #include "memory.h" 25 /* This include is not *needed*, it's here to avoid breaking ports */ 26 #include "osdcore.h" 27 28 extern u8 * Vdp2Ram; 29 extern u8 * Vdp2ColorRam; 30 31 u8 FASTCALL Vdp2RamReadByte(u32); 32 u16 FASTCALL Vdp2RamReadWord(u32); 33 u32 FASTCALL Vdp2RamReadLong(u32); 34 void FASTCALL Vdp2RamWriteByte(u32, u8); 35 void FASTCALL Vdp2RamWriteWord(u32, u16); 36 void FASTCALL Vdp2RamWriteLong(u32, u32); 37 38 u8 FASTCALL Vdp2ColorRamReadByte(u32); 39 u16 FASTCALL Vdp2ColorRamReadWord(u32); 40 u32 FASTCALL Vdp2ColorRamReadLong(u32); 41 void FASTCALL Vdp2ColorRamWriteByte(u32, u8); 42 void FASTCALL Vdp2ColorRamWriteWord(u32, u16); 43 void FASTCALL Vdp2ColorRamWriteLong(u32, u32); 44 45 u8 FASTCALL Sh2Vdp2RamReadByte(SH2_struct *, u32); 46 u16 FASTCALL Sh2Vdp2RamReadWord(SH2_struct *, u32); 47 u32 FASTCALL Sh2Vdp2RamReadLong(SH2_struct *, u32); 48 void FASTCALL Sh2Vdp2RamWriteByte(SH2_struct *, u32, u8); 49 void FASTCALL Sh2Vdp2RamWriteWord(SH2_struct *, u32, u16); 50 void FASTCALL Sh2Vdp2RamWriteLong(SH2_struct *, u32, u32); 51 52 u8 FASTCALL Sh2Vdp2ColorRamReadByte(SH2_struct *, u32); 53 u16 FASTCALL Sh2Vdp2ColorRamReadWord(SH2_struct *, u32); 54 u32 FASTCALL Sh2Vdp2ColorRamReadLong(SH2_struct *, u32); 55 void FASTCALL Sh2Vdp2ColorRamWriteByte(SH2_struct *, u32, u8); 56 void FASTCALL Sh2Vdp2ColorRamWriteWord(SH2_struct *, u32, u16); 57 void FASTCALL Sh2Vdp2ColorRamWriteLong(SH2_struct *, u32, u32); 58 59 typedef struct { 60 u16 TVMD; // 0x25F80000 61 u16 EXTEN; // 0x25F80002 62 u16 TVSTAT; // 0x25F80004 63 u16 VRSIZE; // 0x25F80006 64 u16 HCNT; // 0x25F80008 65 u16 VCNT; // 0x25F8000A 66 u16 RAMCTL; // 0x25F8000E 67 u16 CYCA0L; // 0x25F80010 68 u16 CYCA0U; // 0x25F80012 69 u16 CYCA1L; // 0x25F80014 70 u16 CYCA1U; // 0x25F80016 71 u16 CYCB0L; // 0x25F80018 72 u16 CYCB0U; // 0x25F8001A 73 u16 CYCB1L; // 0x25F8001C 74 u16 CYCB1U; // 0x25F8001E 75 u16 BGON; // 0x25F80020 76 u16 MZCTL; // 0x25F80022 77 u16 SFSEL; // 0x25F80024 78 u16 SFCODE; // 0x25F80026 79 u16 CHCTLA; // 0x25F80028 80 u16 CHCTLB; // 0x25F8002A 81 u16 BMPNA; // 0x25F8002C 82 u16 BMPNB; // 0x25F8002E 83 u16 PNCN0; // 0x25F80030 84 u16 PNCN1; // 0x25F80032 85 u16 PNCN2; // 0x25F80034 86 u16 PNCN3; // 0x25F80036 87 u16 PNCR; // 0x25F80038 88 u16 PLSZ; // 0x25F8003A 89 u16 MPOFN; // 0x25F8003C 90 u16 MPOFR; // 0x25F8003E 91 u16 MPABN0; // 0x25F80040 92 u16 MPCDN0; // 0x25F80042 93 u16 MPABN1; // 0x25F80044 94 u16 MPCDN1; // 0x25F80046 95 u16 MPABN2; // 0x25F80048 96 u16 MPCDN2; // 0x25F8004A 97 u16 MPABN3; // 0x25F8004C 98 u16 MPCDN3; // 0x25F8004E 99 u16 MPABRA; // 0x25F80050 100 u16 MPCDRA; // 0x25F80052 101 u16 MPEFRA; // 0x25F80054 102 u16 MPGHRA; // 0x25F80056 103 u16 MPIJRA; // 0x25F80058 104 u16 MPKLRA; // 0x25F8005A 105 u16 MPMNRA; // 0x25F8005C 106 u16 MPOPRA; // 0x25F8005E 107 u16 MPABRB; // 0x25F80060 108 u16 MPCDRB; // 0x25F80062 109 u16 MPEFRB; // 0x25F80064 110 u16 MPGHRB; // 0x25F80066 111 u16 MPIJRB; // 0x25F80068 112 u16 MPKLRB; // 0x25F8006A 113 u16 MPMNRB; // 0x25F8006C 114 u16 MPOPRB; // 0x25F8006E 115 u16 SCXIN0; // 0x25F80070 116 u16 SCXDN0; // 0x25F80072 117 u16 SCYIN0; // 0x25F80074 118 u16 SCYDN0; // 0x25F80076 119 120 #ifdef WORDS_BIGENDIAN 121 union { 122 struct { 123 u32 I:16; // 0x25F80078 124 u32 D:16; // 0x25F8007A 125 } part; 126 u32 all; 127 } ZMXN0; 128 129 union { 130 struct { 131 u32 I:16; // 0x25F8007C 132 u32 D:16; // 0x25F8007E 133 } part; 134 u32 all; 135 } ZMYN0; 136 #else 137 union { 138 struct { 139 u32 D:16; // 0x25F8007A 140 u32 I:16; // 0x25F80078 141 } part; 142 u32 all; 143 } ZMXN0; 144 145 union { 146 struct { 147 u32 D:16; // 0x25F8007E 148 u32 I:16; // 0x25F8007C 149 } part; 150 u32 all; 151 } ZMYN0; 152 #endif 153 154 u16 SCXIN1; // 0x25F80080 155 u16 SCXDN1; // 0x25F80082 156 u16 SCYIN1; // 0x25F80084 157 u16 SCYDN1; // 0x25F80086 158 159 #ifdef WORDS_BIGENDIAN 160 union { 161 struct { 162 u32 I:16; // 0x25F80088 163 u32 D:16; // 0x25F8008A 164 } part; 165 u32 all; 166 } ZMXN1; 167 168 union { 169 struct { 170 u32 I:16; // 0x25F8008C 171 u32 D:16; // 0x25F8008E 172 } part; 173 u32 all; 174 } ZMYN1; 175 #else 176 union { 177 struct { 178 u32 D:16; // 0x25F8008A 179 u32 I:16; // 0x25F80088 180 } part; 181 u32 all; 182 } ZMXN1; 183 184 union { 185 struct { 186 u32 D:16; // 0x25F8008E 187 u32 I:16; // 0x25F8008C 188 } part; 189 u32 all; 190 } ZMYN1; 191 #endif 192 193 u16 SCXN2; // 0x25F80090 194 u16 SCYN2; // 0x25F80092 195 u16 SCXN3; // 0x25F80094 196 u16 SCYN3; // 0x25F80096 197 u16 ZMCTL; // 0x25F80098 198 u16 SCRCTL; // 0x25F8009A 199 #ifdef WORDS_BIGENDIAN 200 union { 201 struct { 202 u32 U:16; // 0x25F8009C 203 u32 L:16; // 0x25F8009E 204 } part; 205 u32 all; 206 } VCSTA; 207 208 union { 209 struct { 210 u32 U:16; // 0x25F800A0 211 u32 L:16; // 0x25F800A2 212 } part; 213 u32 all; 214 } LSTA0; 215 216 union { 217 struct { 218 u32 U:16; // 0x25F800A4 219 u32 L:16; // 0x25F800A6 220 } part; 221 u32 all; 222 } LSTA1; 223 224 union { 225 struct { 226 u32 U:16; // 0x25F800A8 227 u32 L:16; // 0x25F800AA 228 } part; 229 u32 all; 230 } LCTA; 231 #else 232 union { 233 struct { 234 u32 L:16; // 0x25F8009E 235 u32 U:16; // 0x25F8009C 236 } part; 237 u32 all; 238 } VCSTA; 239 240 union { 241 struct { 242 u32 L:16; // 0x25F800A2 243 u32 U:16; // 0x25F800A0 244 } part; 245 u32 all; 246 } LSTA0; 247 248 union { 249 struct { 250 u32 L:16; // 0x25F800A6 251 u32 U:16; // 0x25F800A4 252 } part; 253 u32 all; 254 } LSTA1; 255 256 union { 257 struct { 258 u32 L:16; // 0x25F800AA 259 u32 U:16; // 0x25F800A8 260 } part; 261 u32 all; 262 } LCTA; 263 #endif 264 265 u16 BKTAU; // 0x25F800AC 266 u16 BKTAL; // 0x25F800AE 267 u16 RPMD; // 0x25F800B0 268 u16 RPRCTL; // 0x25F800B2 269 u16 KTCTL; // 0x25F800B4 270 u16 KTAOF; // 0x25F800B6 271 u16 OVPNRA; // 0x25F800B8 272 u16 OVPNRB; // 0x25F800BA 273 #ifdef WORDS_BIGENDIAN 274 union { 275 struct { 276 u32 U:16; // 0x25F800BC 277 u32 L:16; // 0x25F800BE 278 } part; 279 u32 all; 280 } RPTA; 281 #else 282 union { 283 struct { 284 u32 L:16; // 0x25F800BE 285 u32 U:16; // 0x25F800BC 286 } part; 287 u32 all; 288 } RPTA; 289 #endif 290 u16 WPSX0; // 0x25F800C0 291 u16 WPSY0; // 0x25F800C2 292 u16 WPEX0; // 0x25F800C4 293 u16 WPEY0; // 0x25F800C6 294 u16 WPSX1; // 0x25F800C8 295 u16 WPSY1; // 0x25F800CA 296 u16 WPEX1; // 0x25F800CC 297 u16 WPEY1; // 0x25F800CE 298 u16 WCTLA; // 0x25F800D0 299 u16 WCTLB; // 0x25F800D2 300 u16 WCTLC; // 0x25F800D4 301 u16 WCTLD; // 0x25F800D6 302 #ifdef WORDS_BIGENDIAN 303 union { 304 struct { 305 u32 U:16; // 0x25F800D8 306 u32 L:16; // 0x25F800DA 307 } part; 308 u32 all; 309 } LWTA0; 310 311 union { 312 struct { 313 u32 U:16; // 0x25F800DC 314 u32 L:16; // 0x25F800DE 315 } part; 316 u32 all; 317 } LWTA1; 318 #else 319 union { 320 struct { 321 u32 L:16; // 0x25F800D8 322 u32 U:16; // 0x25F800DA 323 } part; 324 u32 all; 325 } LWTA0; 326 327 union { 328 struct { 329 u32 L:16; // 0x25F800DC 330 u32 U:16; // 0x25F800DE 331 } part; 332 u32 all; 333 } LWTA1; 334 #endif 335 336 337 u16 SPCTL; // 0x25F800E0 338 u16 SDCTL; // 0x25F800E2 339 u16 CRAOFA; // 0x25F800E4 340 u16 CRAOFB; // 0x25F800E6 341 u16 LNCLEN; // 0x25F800E8 342 u16 SFPRMD; // 0x25F800EA 343 u16 CCCTL; // 0x25F800EC 344 u16 SFCCMD; // 0x25F800EE 345 u16 PRISA; // 0x25F800F0 346 u16 PRISB; // 0x25F800F2 347 u16 PRISC; // 0x25F800F4 348 u16 PRISD; // 0x25F800F6 349 u16 PRINA; // 0x25F800F8 350 u16 PRINB; // 0x25F800FA 351 u16 PRIR; // 0x25F800FC 352 u16 CCRSA; // 0x25F80100 353 u16 CCRSB; // 0x25F80102 354 u16 CCRSC; // 0x25F80104 355 u16 CCRSD; // 0x25F80106 356 u16 CCRNA; // 0x25F80108 357 u16 CCRNB; // 0x25F8010A 358 u16 CCRR; // 0x25F8010C 359 u16 CCRLB; // 0x25F8010E 360 u16 CLOFEN; // 0x25F80110 361 u16 CLOFSL; // 0x25F80112 362 u16 COAR; // 0x25F80114 363 u16 COAG; // 0x25F80116 364 u16 COAB; // 0x25F80118 365 u16 COBR; // 0x25F8011A 366 u16 COBG; // 0x25F8011C 367 u16 COBB; // 0x25F8011E 368 } Vdp2; 369 370 extern Vdp2 * Vdp2Regs; 371 372 typedef struct { 373 int ColorMode; 374 } Vdp2Internal_struct; 375 376 extern Vdp2Internal_struct Vdp2Internal; 377 extern u64 lastticks; 378 extern int vdp2_is_odd_frame; 379 extern Vdp2 Vdp2Lines[270]; 380 381 struct CellScrollData 382 { 383 u32 data[88];//(352/8) * 2 screens 384 }; 385 386 extern struct CellScrollData cell_scroll_data[270]; 387 388 // struct for Vdp2 part that shouldn't be saved 389 typedef struct { 390 int disptoggle; 391 } Vdp2External_struct; 392 393 extern Vdp2External_struct Vdp2External; 394 395 int Vdp2Init(void); 396 void Vdp2DeInit(void); 397 void Vdp2Reset(void); 398 void Vdp2VBlankIN(void); 399 void Vdp2HBlankIN(void); 400 void Vdp2HBlankOUT(void); 401 void Vdp2VBlankOUT(void); 402 void Vdp2SendExternalLatch(int hcnt, int vcnt); 403 void SpeedThrottleEnable(void); 404 void SpeedThrottleDisable(void); 405 406 u8 FASTCALL Vdp2ReadByte(u32); 407 u16 FASTCALL Vdp2ReadWord(u32); 408 u32 FASTCALL Vdp2ReadLong(u32); 409 void FASTCALL Vdp2WriteByte(u32, u8); 410 void FASTCALL Vdp2WriteWord(u32, u16); 411 void FASTCALL Vdp2WriteLong(u32, u32); 412 413 u8 FASTCALL Sh2Vdp2ReadByte(SH2_struct *, u32); 414 u16 FASTCALL Sh2Vdp2ReadWord(SH2_struct *, u32); 415 u32 FASTCALL Sh2Vdp2ReadLong(SH2_struct *, u32); 416 void FASTCALL Sh2Vdp2WriteByte(SH2_struct *, u32, u8); 417 void FASTCALL Sh2Vdp2WriteWord(SH2_struct *, u32, u16); 418 void FASTCALL Sh2Vdp2WriteLong(SH2_struct *, u32, u32); 419 420 int Vdp2SaveState(FILE *fp); 421 int Vdp2LoadState(FILE *fp, int version, int size); 422 423 void ToggleNBG0(void); 424 void ToggleNBG1(void); 425 void ToggleNBG2(void); 426 void ToggleNBG3(void); 427 void ToggleRBG0(void); 428 void ToggleFullScreen(void); 429 void EnableAutoFrameSkip(void); 430 void DisableAutoFrameSkip(void); 431 432 Vdp2 * Vdp2RestoreRegs(int line, Vdp2* lines); 433 434 #endif 435