| 1 | /*************************************************************************** |
| 2 | zn.c - description |
| 3 | ------------------- |
| 4 | begin : Sat Jan 31 2004 |
| 5 | copyright : (C) 2004 by Pete Bernert |
| 6 | email : BlackDove@addcom.de |
| 7 | ***************************************************************************/ |
| 8 | /*************************************************************************** |
| 9 | * * |
| 10 | * This program is free software; you can redistribute it and/or modify * |
| 11 | * it under the terms of the GNU General Public License as published by * |
| 12 | * the Free Software Foundation; either version 2 of the License, or * |
| 13 | * (at your option) any later version. See also the license.txt file for * |
| 14 | * additional informations. * |
| 15 | * * |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | #define _IN_ZN |
| 19 | |
| 20 | #include "externals.h" |
| 21 | |
| 22 | // --------------------------------------------------- // |
| 23 | // - psx gpu plugin interface prototypes-------------- // |
| 24 | // --------------------------------------------------- // |
| 25 | |
| 26 | long GPUopen(unsigned long *disp, const char *CapText, const char *CfgFile); |
| 27 | |
| 28 | void CALLBACK GPUdisplayText(char * pText); |
| 29 | void CALLBACK GPUdisplayFlags(uint32_t dwFlags); |
| 30 | void CALLBACK GPUmakeSnapshot(void); |
| 31 | long CALLBACK GPUinit(); |
| 32 | long CALLBACK GPUclose(); |
| 33 | long CALLBACK GPUshutdown(); |
| 34 | void CALLBACK GPUcursor(int iPlayer,int x,int y); |
| 35 | void CALLBACK GPUupdateLace(void); |
| 36 | uint32_t CALLBACK GPUreadStatus(void); |
| 37 | void CALLBACK GPUwriteStatus(uint32_t gdata); |
| 38 | void CALLBACK GPUreadDataMem(uint32_t * pMem, int iSize); |
| 39 | uint32_t CALLBACK GPUreadData(void); |
| 40 | void CALLBACK GPUwriteDataMem(uint32_t * pMem, int iSize); |
| 41 | void CALLBACK GPUwriteData(uint32_t gdata); |
| 42 | void CALLBACK GPUsetMode(uint32_t gdata); |
| 43 | long CALLBACK GPUgetMode(void); |
| 44 | long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr); |
| 45 | long CALLBACK GPUconfigure(void); |
| 46 | void CALLBACK GPUabout(void); |
| 47 | long CALLBACK GPUtest(void); |
| 48 | long CALLBACK GPUfreeze(uint32_t ulGetFreezeData,void * pF); |
| 49 | void CALLBACK GPUgetScreenPic(unsigned char * pMem); |
| 50 | void CALLBACK GPUshowScreenPic(unsigned char * pMem); |
| 51 | |
| 52 | void CALLBACK GPUkeypressed(int keycode); |
| 53 | |
| 54 | |
| 55 | // --------------------------------------------------- // |
| 56 | // - zn gpu interface -------------------------------- // |
| 57 | // --------------------------------------------------- // |
| 58 | |
| 59 | uint32_t dwGPUVersion=0; |
| 60 | int iGPUHeight=512; |
| 61 | int iGPUHeightMask=511; |
| 62 | int GlobalTextIL=0; |
| 63 | int iTileCheat=0; |
| 64 | |
| 65 | // --------------------------------------------------- // |
| 66 | // --------------------------------------------------- // |
| 67 | // --------------------------------------------------- // |
| 68 | |
| 69 | typedef struct GPUOTAG |
| 70 | { |
| 71 | uint32_t Version; // Version of structure - currently 1 |
| 72 | long hWnd; // Window handle |
| 73 | uint32_t ScreenRotation; // 0 = 0CW, 1 = 90CW, 2 = 180CW, 3 = 270CW = 90CCW |
| 74 | uint32_t GPUVersion; // 0 = a, 1 = b, 2 = c |
| 75 | const char* GameName; // NULL terminated string |
| 76 | const char* CfgFile; // NULL terminated string |
| 77 | } GPUConfiguration_t; |
| 78 | |
| 79 | // --------------------------------------------------- // |
| 80 | // --------------------------------------------------- // |
| 81 | // --------------------------------------------------- // |
| 82 | |
| 83 | void CALLBACK ZN_GPUdisplayFlags(uint32_t dwFlags) |
| 84 | { |
| 85 | GPUdisplayFlags(dwFlags); |
| 86 | } |
| 87 | |
| 88 | // --------------------------------------------------- // |
| 89 | |
| 90 | void CALLBACK ZN_GPUmakeSnapshot(void) |
| 91 | { |
| 92 | GPUmakeSnapshot(); |
| 93 | } |
| 94 | |
| 95 | // --------------------------------------------------- // |
| 96 | |
| 97 | long CALLBACK ZN_GPUinit() |
| 98 | { // we always set the vram size to 2MB, if the ZN interface is used |
| 99 | iGPUHeight=1024; |
| 100 | iGPUHeightMask=1023; |
| 101 | |
| 102 | return GPUinit(); |
| 103 | } |
| 104 | |
| 105 | // --------------------------------------------------- // |
| 106 | |
| 107 | long CALLBACK ZN_GPUopen(void * vcfg) |
| 108 | { |
| 109 | GPUConfiguration_t * cfg=(GPUConfiguration_t *)vcfg; |
| 110 | long lret; |
| 111 | |
| 112 | if(!cfg) return -1; |
| 113 | if(cfg->Version!=1) return -1; |
| 114 | |
| 115 | lret = GPUopen(&cfg->hWnd, cfg->GameName, cfg->CfgFile); |
| 116 | |
| 117 | |
| 118 | /* |
| 119 | if(!lstrcmp(cfg->GameName,"kikaioh") || |
| 120 | !lstrcmp(cfg->GameName,"sr2j") || |
| 121 | !lstrcmp(cfg->GameName,"rvschool_a")) |
| 122 | iTileCheat=1; |
| 123 | */ |
| 124 | |
| 125 | // some ZN games seem to erase the cluts with a 'white' TileS... strange.. |
| 126 | // I've added a cheat to avoid this issue. We can set it globally (for |
| 127 | // all ZiNc games) without much risk |
| 128 | |
| 129 | iTileCheat=1; |
| 130 | |
| 131 | dwGPUVersion=cfg->GPUVersion; |
| 132 | |
| 133 | return lret; |
| 134 | } |
| 135 | |
| 136 | // --------------------------------------------------- // |
| 137 | |
| 138 | long CALLBACK ZN_GPUclose() |
| 139 | { |
| 140 | return GPUclose(); |
| 141 | } |
| 142 | |
| 143 | // --------------------------------------------------- // |
| 144 | |
| 145 | long CALLBACK ZN_GPUshutdown() |
| 146 | { |
| 147 | return GPUshutdown(); |
| 148 | } |
| 149 | |
| 150 | // --------------------------------------------------- // |
| 151 | |
| 152 | void CALLBACK ZN_GPUupdateLace(void) |
| 153 | { |
| 154 | GPUupdateLace(); |
| 155 | } |
| 156 | |
| 157 | // --------------------------------------------------- // |
| 158 | |
| 159 | uint32_t CALLBACK ZN_GPUreadStatus(void) |
| 160 | { |
| 161 | return GPUreadStatus(); |
| 162 | } |
| 163 | |
| 164 | // --------------------------------------------------- // |
| 165 | |
| 166 | void CALLBACK ZN_GPUwriteStatus(uint32_t gdata) |
| 167 | { |
| 168 | GPUwriteStatus(gdata); |
| 169 | } |
| 170 | |
| 171 | // --------------------------------------------------- // |
| 172 | |
| 173 | long CALLBACK ZN_GPUdmaSliceOut(uint32_t *baseAddrL, uint32_t addr, uint32_t iSize) |
| 174 | { |
| 175 | GPUreadDataMem(baseAddrL+addr,iSize); |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | // --------------------------------------------------- // |
| 180 | |
| 181 | uint32_t CALLBACK ZN_GPUreadData(void) |
| 182 | { |
| 183 | return GPUreadData(); |
| 184 | } |
| 185 | |
| 186 | // --------------------------------------------------- // |
| 187 | |
| 188 | void CALLBACK ZN_GPUsetMode(uint32_t gdata) |
| 189 | { |
| 190 | GPUsetMode(gdata); |
| 191 | } |
| 192 | |
| 193 | // --------------------------------------------------- // |
| 194 | |
| 195 | long CALLBACK ZN_GPUgetMode(void) |
| 196 | { |
| 197 | return GPUgetMode(); |
| 198 | } |
| 199 | |
| 200 | // --------------------------------------------------- // |
| 201 | |
| 202 | long CALLBACK ZN_GPUdmaSliceIn(uint32_t *baseAddrL, uint32_t addr, uint32_t iSize) |
| 203 | { |
| 204 | GPUwriteDataMem(baseAddrL+addr,iSize); |
| 205 | return 0; |
| 206 | } |
| 207 | // --------------------------------------------------- // |
| 208 | |
| 209 | void CALLBACK ZN_GPUwriteData(uint32_t gdata) |
| 210 | { |
| 211 | GPUwriteDataMem(&gdata,1); |
| 212 | } |
| 213 | |
| 214 | // --------------------------------------------------- // |
| 215 | |
| 216 | long CALLBACK ZN_GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) |
| 217 | { |
| 218 | return GPUdmaChain(baseAddrL,addr); |
| 219 | } |
| 220 | |
| 221 | // --------------------------------------------------- // |
| 222 | |
| 223 | long CALLBACK ZN_GPUtest(void) |
| 224 | { |
| 225 | return GPUtest(); |
| 226 | } |
| 227 | |
| 228 | // --------------------------------------------------- // |
| 229 | |
| 230 | long CALLBACK ZN_GPUfreeze(uint32_t ulGetFreezeData,void * pF) |
| 231 | { |
| 232 | return GPUfreeze(ulGetFreezeData,pF); |
| 233 | } |
| 234 | |
| 235 | // --------------------------------------------------- // |
| 236 | |
| 237 | void CALLBACK ZN_GPUgetScreenPic(unsigned char * pMem) |
| 238 | { |
| 239 | GPUgetScreenPic(pMem); |
| 240 | } |
| 241 | |
| 242 | // --------------------------------------------------- // |
| 243 | |
| 244 | void CALLBACK ZN_GPUshowScreenPic(unsigned char * pMem) |
| 245 | { |
| 246 | GPUshowScreenPic(pMem); |
| 247 | } |
| 248 | |
| 249 | // --------------------------------------------------- // |
| 250 | |
| 251 | void CALLBACK ZN_GPUkeypressed(int keycode) |
| 252 | { |
| 253 | GPUkeypressed(keycode); |
| 254 | } |
| 255 | |