Path: blob/main/misc/emulator/xnes/snes9x/fxemu.cpp
28515 views
/***********************************************************************************1Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.23(c) Copyright 1996 - 2002 Gary Henderson ([email protected]),4Jerremy Koot ([email protected])56(c) Copyright 2002 - 2004 Matthew Kendora78(c) Copyright 2002 - 2005 Peter Bortas ([email protected])910(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)1112(c) Copyright 2001 - 2006 John Weidman ([email protected])1314(c) Copyright 2002 - 2006 funkyass ([email protected]),15Kris Bleakley ([email protected])1617(c) Copyright 2002 - 2010 Brad Jorsch ([email protected]),18Nach ([email protected]),1920(c) Copyright 2002 - 2011 zones ([email protected])2122(c) Copyright 2006 - 2007 nitsuja2324(c) Copyright 2009 - 2011 BearOso,25OV2262728BS-X C emulator code29(c) Copyright 2005 - 2006 Dreamer Nom,30zones3132C4 x86 assembler and some C emulation code33(c) Copyright 2000 - 2003 _Demo_ ([email protected]),34Nach,35zsKnight ([email protected])3637C4 C++ code38(c) Copyright 2003 - 2006 Brad Jorsch,39Nach4041DSP-1 emulator code42(c) Copyright 1998 - 2006 _Demo_,43Andreas Naive ([email protected]),44Gary Henderson,45Ivar ([email protected]),46John Weidman,47Kris Bleakley,48Matthew Kendora,49Nach,50neviksti ([email protected])5152DSP-2 emulator code53(c) Copyright 2003 John Weidman,54Kris Bleakley,55Lord Nightmare ([email protected]),56Matthew Kendora,57neviksti5859DSP-3 emulator code60(c) Copyright 2003 - 2006 John Weidman,61Kris Bleakley,62Lancer,63z80 gaiden6465DSP-4 emulator code66(c) Copyright 2004 - 2006 Dreamer Nom,67John Weidman,68Kris Bleakley,69Nach,70z80 gaiden7172OBC1 emulator code73(c) Copyright 2001 - 2004 zsKnight,74pagefault ([email protected]),75Kris Bleakley76Ported from x86 assembler to C by sanmaiwashi7778SPC7110 and RTC C++ emulator code used in 1.39-1.5179(c) Copyright 2002 Matthew Kendora with research by80zsKnight,81John Weidman,82Dark Force8384SPC7110 and RTC C++ emulator code used in 1.52+85(c) Copyright 2009 byuu,86neviksti8788S-DD1 C emulator code89(c) Copyright 2003 Brad Jorsch with research by90Andreas Naive,91John Weidman9293S-RTC C emulator code94(c) Copyright 2001 - 2006 byuu,95John Weidman9697ST010 C++ emulator code98(c) Copyright 2003 Feather,99John Weidman,100Kris Bleakley,101Matthew Kendora102103Super FX x86 assembler emulator code104(c) Copyright 1998 - 2003 _Demo_,105pagefault,106zsKnight107108Super FX C emulator code109(c) Copyright 1997 - 1999 Ivar,110Gary Henderson,111John Weidman112113Sound emulator code used in 1.5-1.51114(c) Copyright 1998 - 2003 Brad Martin115(c) Copyright 1998 - 2006 Charles Bilyue'116117Sound emulator code used in 1.52+118(c) Copyright 2004 - 2007 Shay Green ([email protected])119120SH assembler code partly based on x86 assembler code121(c) Copyright 2002 - 2004 Marcus Comstedt ([email protected])1221232xSaI filter124(c) Copyright 1999 - 2001 Derek Liauw Kie Fa125126HQ2x, HQ3x, HQ4x filters127(c) Copyright 2003 Maxim Stepin ([email protected])128129NTSC filter130(c) Copyright 2006 - 2007 Shay Green131132GTK+ GUI code133(c) Copyright 2004 - 2011 BearOso134135Win32 GUI code136(c) Copyright 2003 - 2006 blip,137funkyass,138Matthew Kendora,139Nach,140nitsuja141(c) Copyright 2009 - 2011 OV2142143Mac OS GUI code144(c) Copyright 1998 - 2001 John Stiles145(c) Copyright 2001 - 2011 zones146147148Specific ports contains the works of other authors. See headers in149individual files.150151152Snes9x homepage: http://www.snes9x.com/153154Permission to use, copy, modify and/or distribute Snes9x in both binary155and source form, for non-commercial purposes, is hereby granted without156fee, providing that this license information and copyright notice appear157with all copies and any derived work.158159This software is provided 'as-is', without any express or implied160warranty. In no event shall the authors be held liable for any damages161arising from the use of this software or it's derivatives.162163Snes9x is freeware for PERSONAL USE only. Commercial users should164seek permission of the copyright holders first. Commercial use includes,165but is not limited to, charging money for Snes9x or software derived from166Snes9x, including Snes9x or derivatives in commercial game bundles, and/or167using Snes9x as a promotion for your commercial product.168169The copyright holders request that bug fixes and improvements to the code170should be forwarded to them so everyone can benefit from the modifications171in future versions.172173Super NES and Super Nintendo Entertainment System are trademarks of174Nintendo Co., Limited and its subsidiary companies.175***********************************************************************************/176177178#include "snes9x.h"179#include "memmap.h"180#include "fxinst.h"181#include "fxemu.h"182183static void FxReset (struct FxInfo_s *);184static void fx_readRegisterSpace (void);185static void fx_writeRegisterSpace (void);186static void fx_updateRamBank (uint8);187static void fx_dirtySCBR (void);188static bool8 fx_checkStartAddress (void);189static uint32 FxEmulate (uint32);190static void FxCacheWriteAccess (uint16);191static void FxFlushCache (void);192193194void S9xInitSuperFX (void)195{196memset((uint8 *) &GSU, 0, sizeof(struct FxRegs_s));197}198199void S9xResetSuperFX (void)200{201// FIXME: Snes9x can't execute CPU and SuperFX at a time. Don't ask me what is 0.417 :P202SuperFX.speedPerLine = (uint32) (0.417 * 10.5e6 * ((1.0 / (float) Memory.ROMFramesPerSecond) / ((float) (Timings.V_Max))));203SuperFX.oneLineDone = FALSE;204SuperFX.vFlags = 0;205CPU.IRQExternal = FALSE;206FxReset(&SuperFX);207}208209void S9xSetSuperFX (uint8 byte, uint16 address)210{211switch (address)212{213case 0x3030:214if ((Memory.FillRAM[0x3030] ^ byte) & FLG_G)215{216Memory.FillRAM[0x3030] = byte;217if (byte & FLG_G)218{219if (!SuperFX.oneLineDone)220{221S9xSuperFXExec();222SuperFX.oneLineDone = TRUE;223}224}225else226FxFlushCache();227}228else229Memory.FillRAM[0x3030] = byte;230231break;232233case 0x3031:234Memory.FillRAM[0x3031] = byte;235break;236237case 0x3033:238Memory.FillRAM[0x3033] = byte;239break;240241case 0x3034:242Memory.FillRAM[0x3034] = byte & 0x7f;243break;244245case 0x3036:246Memory.FillRAM[0x3036] = byte & 0x7f;247break;248249case 0x3037:250Memory.FillRAM[0x3037] = byte;251break;252253case 0x3038:254Memory.FillRAM[0x3038] = byte;255fx_dirtySCBR();256break;257258case 0x3039:259Memory.FillRAM[0x3039] = byte;260break;261262case 0x303a:263Memory.FillRAM[0x303a] = byte;264break;265266case 0x303b:267break;268269case 0x303c:270Memory.FillRAM[0x303c] = byte;271fx_updateRamBank(byte);272break;273274case 0x303f:275Memory.FillRAM[0x303f] = byte;276break;277278case 0x301f:279Memory.FillRAM[0x301f] = byte;280Memory.FillRAM[0x3000 + GSU_SFR] |= FLG_G;281if (!SuperFX.oneLineDone)282{283S9xSuperFXExec();284SuperFX.oneLineDone = TRUE;285}286287break;288289default:290Memory.FillRAM[address] = byte;291if (address >= 0x3100)292FxCacheWriteAccess(address);293294break;295}296}297298uint8 S9xGetSuperFX (uint16 address)299{300uint8 byte;301302byte = Memory.FillRAM[address];303304if (address == 0x3031)305{306CPU.IRQExternal = FALSE;307Memory.FillRAM[0x3031] = byte & 0x7f;308}309310return (byte);311}312313void S9xSuperFXExec (void)314{315if ((Memory.FillRAM[0x3000 + GSU_SFR] & FLG_G) && (Memory.FillRAM[0x3000 + GSU_SCMR] & 0x18) == 0x18)316{317FxEmulate((Memory.FillRAM[0x3000 + GSU_CLSR] & 1) ? SuperFX.speedPerLine * 2 : SuperFX.speedPerLine);318319uint16 GSUStatus = Memory.FillRAM[0x3000 + GSU_SFR] | (Memory.FillRAM[0x3000 + GSU_SFR + 1] << 8);320if ((GSUStatus & (FLG_G | FLG_IRQ)) == FLG_IRQ)321CPU.IRQExternal = TRUE;322}323}324325static void FxReset (struct FxInfo_s *psFxInfo)326{327// Clear all internal variables328memset((uint8 *) &GSU, 0, sizeof(struct FxRegs_s));329330// Set default registers331GSU.pvSreg = GSU.pvDreg = &R0;332333// Set RAM and ROM pointers334GSU.pvRegisters = psFxInfo->pvRegisters;335GSU.nRamBanks = psFxInfo->nRamBanks;336GSU.pvRam = psFxInfo->pvRam;337GSU.nRomBanks = psFxInfo->nRomBanks;338GSU.pvRom = psFxInfo->pvRom;339GSU.vPrevScreenHeight = ~0;340GSU.vPrevMode = ~0;341342// The GSU can't access more than 2mb (16mbits)343if (GSU.nRomBanks > 0x20)344GSU.nRomBanks = 0x20;345346// Clear FxChip register space347memset(GSU.pvRegisters, 0, 0x300);348349// Set FxChip version Number350GSU.pvRegisters[0x3b] = 0;351352// Make ROM bank table353for (int i = 0; i < 256; i++)354{355uint32 b = i & 0x7f;356357if (b >= 0x40)358{359if (GSU.nRomBanks > 1)360b %= GSU.nRomBanks;361else362b &= 1;363364GSU.apvRomBank[i] = &GSU.pvRom[b << 16];365}366else367{368b %= GSU.nRomBanks * 2;369GSU.apvRomBank[i] = &GSU.pvRom[(b << 16) + 0x200000];370}371}372373// Make RAM bank table374for (int i = 0; i < 4; i++)375{376GSU.apvRamBank[i] = &GSU.pvRam[(i % GSU.nRamBanks) << 16];377GSU.apvRomBank[0x70 + i] = GSU.apvRamBank[i];378}379380// Start with a nop in the pipe381GSU.vPipe = 0x01;382383// Set pointer to GSU cache384GSU.pvCache = &GSU.pvRegisters[0x100];385386fx_readRegisterSpace();387}388389static void fx_readRegisterSpace (void)390{391static uint32 avHeight[] = { 128, 160, 192, 256 };392static uint32 avMult[] = { 16, 32, 32, 64 };393394uint8 *p;395int n;396397GSU.vErrorCode = 0;398399// Update R0-R15400p = GSU.pvRegisters;401for (int i = 0; i < 16; i++)402{403GSU.avReg[i] = *p++;404GSU.avReg[i] += ((uint32) (*p++)) << 8;405}406407// Update other registers408p = GSU.pvRegisters;409GSU.vStatusReg = (uint32) p[GSU_SFR];410GSU.vStatusReg |= ((uint32) p[GSU_SFR + 1]) << 8;411GSU.vPrgBankReg = (uint32) p[GSU_PBR];412GSU.vRomBankReg = (uint32) p[GSU_ROMBR];413GSU.vRamBankReg = ((uint32) p[GSU_RAMBR]) & (FX_RAM_BANKS - 1);414GSU.vCacheBaseReg = (uint32) p[GSU_CBR];415GSU.vCacheBaseReg |= ((uint32) p[GSU_CBR + 1]) << 8;416417// Update status register variables418GSU.vZero = !(GSU.vStatusReg & FLG_Z);419GSU.vSign = (GSU.vStatusReg & FLG_S) << 12;420GSU.vOverflow = (GSU.vStatusReg & FLG_OV) << 16;421GSU.vCarry = (GSU.vStatusReg & FLG_CY) >> 2;422423// Set bank pointers424GSU.pvRamBank = GSU.apvRamBank[GSU.vRamBankReg & 0x3];425GSU.pvRomBank = GSU.apvRomBank[GSU.vRomBankReg];426GSU.pvPrgBank = GSU.apvRomBank[GSU.vPrgBankReg];427428// Set screen pointers429GSU.pvScreenBase = &GSU.pvRam[USEX8(p[GSU_SCBR]) << 10];430n = (int) (!!(p[GSU_SCMR] & 0x04));431n |= ((int) (!!(p[GSU_SCMR] & 0x20))) << 1;432GSU.vScreenHeight = GSU.vScreenRealHeight = avHeight[n];433GSU.vMode = p[GSU_SCMR] & 0x03;434435if (n == 3)436GSU.vScreenSize = (256 / 8) * (256 / 8) * 32;437else438GSU.vScreenSize = (GSU.vScreenHeight / 8) * (256 / 8) * avMult[GSU.vMode];439440if (GSU.vPlotOptionReg & 0x10) // OBJ Mode (for drawing into sprites)441GSU.vScreenHeight = 256;442443if (GSU.pvScreenBase + GSU.vScreenSize > GSU.pvRam + (GSU.nRamBanks * 65536))444GSU.pvScreenBase = GSU.pvRam + (GSU.nRamBanks * 65536) - GSU.vScreenSize;445446GSU.pfPlot = fx_PlotTable[GSU.vMode];447GSU.pfRpix = fx_PlotTable[GSU.vMode + 5];448449fx_OpcodeTable[0x04c] = GSU.pfPlot;450fx_OpcodeTable[0x14c] = GSU.pfRpix;451fx_OpcodeTable[0x24c] = GSU.pfPlot;452fx_OpcodeTable[0x34c] = GSU.pfRpix;453454fx_computeScreenPointers();455456//fx_backupCache();457}458459static void fx_writeRegisterSpace (void)460{461uint8 *p;462463p = GSU.pvRegisters;464for (int i = 0; i < 16; i++)465{466*p++ = (uint8) GSU.avReg[i];467*p++ = (uint8) (GSU.avReg[i] >> 8);468}469470// Update status register471if (USEX16(GSU.vZero) == 0)472SF(Z);473else474CF(Z);475476if (GSU.vSign & 0x8000)477SF(S);478else479CF(S);480481if (GSU.vOverflow >= 0x8000 || GSU.vOverflow < -0x8000)482SF(OV);483else484CF(OV);485486if (GSU.vCarry)487SF(CY);488else489CF(CY);490491p = GSU.pvRegisters;492p[GSU_SFR] = (uint8) GSU.vStatusReg;493p[GSU_SFR + 1] = (uint8) (GSU.vStatusReg >> 8);494p[GSU_PBR] = (uint8) GSU.vPrgBankReg;495p[GSU_ROMBR] = (uint8) GSU.vRomBankReg;496p[GSU_RAMBR] = (uint8) GSU.vRamBankReg;497p[GSU_CBR] = (uint8) GSU.vCacheBaseReg;498p[GSU_CBR + 1] = (uint8) (GSU.vCacheBaseReg >> 8);499500//fx_restoreCache();501}502503// Update RamBankReg and RAM Bank pointer504static void fx_updateRamBank (uint8 byte)505{506// Update BankReg and Bank pointer507GSU.vRamBankReg = (uint32) byte & (FX_RAM_BANKS - 1);508GSU.pvRamBank = GSU.apvRamBank[byte & 0x3];509}510511// SCBR write seen. We need to update our cached screen pointers512static void fx_dirtySCBR (void)513{514GSU.vSCBRDirty = TRUE;515}516517static bool8 fx_checkStartAddress (void)518{519// Check if we start inside the cache520if (GSU.bCacheActive && R15 >= GSU.vCacheBaseReg && R15 < (GSU.vCacheBaseReg + 512))521return (TRUE);522523/*524// Check if we're in an unused area525if (GSU.vPrgBankReg < 0x40 && R15 < 0x8000)526return (FALSE);527*/528529if (GSU.vPrgBankReg >= 0x60 && GSU.vPrgBankReg <= 0x6f)530return (FALSE);531532if (GSU.vPrgBankReg >= 0x74)533return (FALSE);534535// Check if we're in RAM and the RAN flag is not set536if (GSU.vPrgBankReg >= 0x70 && GSU.vPrgBankReg <= 0x73 && !(SCMR & (1 << 3)))537return (FALSE);538539// If not, we're in ROM, so check if the RON flag is set540if (!(SCMR & (1 << 4)))541return (FALSE);542543return (TRUE);544}545546// Execute until the next stop instruction547static uint32 FxEmulate (uint32 nInstructions)548{549uint32 vCount;550551// Read registers and initialize GSU session552fx_readRegisterSpace();553554// Check if the start address is valid555if (!fx_checkStartAddress())556{557CF(G);558fx_writeRegisterSpace();559/*560GSU.vIllegalAddress = (GSU.vPrgBankReg << 24) | R15;561return (FX_ERROR_ILLEGAL_ADDRESS);562*/563564return (0);565}566567// Execute GSU session568CF(IRQ);569570/*571if (GSU.bBreakPoint)572vCount = fx_run_to_breakpoint(nInstructions);573else574*/575vCount = fx_run(nInstructions);576577// Store GSU registers578fx_writeRegisterSpace();579580// Check for error code581if (GSU.vErrorCode)582return (GSU.vErrorCode);583else584return (vCount);585}586587void fx_computeScreenPointers (void)588{589if (GSU.vMode != GSU.vPrevMode || GSU.vPrevScreenHeight != GSU.vScreenHeight || GSU.vSCBRDirty)590{591GSU.vSCBRDirty = FALSE;592593// Make a list of pointers to the start of each screen column594switch (GSU.vScreenHeight)595{596case 128:597switch (GSU.vMode)598{599case 0:600for (int i = 0; i < 32; i++)601{602GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);603GSU.x[i] = i << 8;604}605606break;607608case 1:609for (int i = 0; i < 32; i++)610{611GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);612GSU.x[i] = i << 9;613}614615break;616617case 2:618case 3:619for (int i = 0; i < 32; i++)620{621GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);622GSU.x[i] = i << 10;623}624625break;626}627628break;629630case 160:631switch (GSU.vMode)632{633case 0:634for (int i = 0; i < 32; i++)635{636GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);637GSU.x[i] = (i << 8) + (i << 6);638}639640break;641642case 1:643for (int i = 0; i < 32; i++)644{645GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);646GSU.x[i] = (i << 9) + (i << 7);647}648649break;650651case 2:652case 3:653for (int i = 0; i < 32; i++)654{655GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);656GSU.x[i] = (i << 10) + (i << 8);657}658659break;660}661662break;663664case 192:665switch (GSU.vMode)666{667case 0:668for (int i = 0; i < 32; i++)669{670GSU.apvScreen[i] = GSU.pvScreenBase + (i << 4);671GSU.x[i] = (i << 8) + (i << 7);672}673674break;675676case 1:677for (int i = 0; i < 32; i++)678{679GSU.apvScreen[i] = GSU.pvScreenBase + (i << 5);680GSU.x[i] = (i << 9) + (i << 8);681}682683break;684685case 2:686case 3:687for (int i = 0; i < 32; i++)688{689GSU.apvScreen[i] = GSU.pvScreenBase + (i << 6);690GSU.x[i] = (i << 10) + (i << 9);691}692693break;694}695696break;697698case 256:699switch (GSU.vMode)700{701case 0:702for (int i = 0; i < 32; i++)703{704GSU.apvScreen[i] = GSU.pvScreenBase + ((i & 0x10) << 9) + ((i & 0xf) << 8);705GSU.x[i] = ((i & 0x10) << 8) + ((i & 0xf) << 4);706}707708break;709710case 1:711for (int i = 0; i < 32; i++)712{713GSU.apvScreen[i] = GSU.pvScreenBase + ((i & 0x10) << 10) + ((i & 0xf) << 9);714GSU.x[i] = ((i & 0x10) << 9) + ((i & 0xf) << 5);715}716717break;718719case 2:720case 3:721for (int i = 0; i < 32; i++)722{723GSU.apvScreen[i] = GSU.pvScreenBase + ((i & 0x10) << 11) + ((i & 0xf) << 10);724GSU.x[i] = ((i & 0x10) << 10) + ((i & 0xf) << 6);725}726727break;728}729730break;731}732733GSU.vPrevMode = GSU.vMode;734GSU.vPrevScreenHeight = GSU.vScreenHeight;735}736}737738// Write access to the cache739static void FxCacheWriteAccess (uint16 vAddress)740{741/*742if (!GSU.bCacheActive)743{744uint8 v = GSU.pvCache[GSU.pvCache[vAddress & 0x1ff];745fx_setCache();746GSU.pvCache[GSU.pvCache[vAddress & 0x1ff] = v;747}748*/749750if ((vAddress & 0x00f) == 0x00f)751GSU.vCacheFlags |= 1 << ((vAddress & 0x1f0) >> 4);752}753754static void FxFlushCache (void)755{756GSU.vCacheFlags = 0;757GSU.vCacheBaseReg = 0;758GSU.bCacheActive = FALSE;759//GSU.vPipe = 0x1;760}761762void fx_flushCache (void)763{764//fx_restoreCache();765GSU.vCacheFlags = 0;766GSU.bCacheActive = FALSE;767}768769/*770static void fx_setCache (void)771{772uint32 c;773774GSU.bCacheActive = TRUE;775GSU.pvRegisters[0x3e] &= 0xf0;776777c = (uint32) GSU.pvRegisters[0x3e];778c |= ((uint32) GSU.pvRegisters[0x3f]) << 8;779if (c == GSU.vCacheBaseReg)780return;781782GSU.vCacheBaseReg = c;783GSU.vCacheFlags = 0;784785if (c < (0x10000 - 512))786{787const uint8 *t = &ROM(c);788memcpy(GSU.pvCache, t, 512);789}790else791{792const uint8 *t1, *t2;793uint32 i = 0x10000 - c;794795t1 = &ROM(c);796t2 = &ROM(0);797memcpy(GSU.pvCache, t1, i);798memcpy(&GSU.pvCache[i], t2, 512 - i);799}800}801*/802803/*804static void fx_backupCache (void)805{806uint32 v = GSU.vCacheFlags;807uint32 c = USEX16(GSU.vCacheBaseReg);808809if (v)810{811for (int i = 0; i < 32; i++)812{813if (v & 1)814{815if (c < (0x10000 - 16))816{817uint8 *t = &GSU.pvPrgBank[c];818memcpy(&GSU.avCacheBackup[i << 4], t, 16);819memcpy(t, &GSU.pvCache[i << 4], 16);820}821else822{823uint8 *t1, *t2;824uint32 a = 0x10000 - c;825826t1 = &GSU.pvPrgBank[c];827t2 = &GSU.pvPrgBank[0];828memcpy(&GSU.avCacheBackup[i << 4], t1, a);829memcpy(t1, &GSU.pvCache[i << 4], a);830memcpy(&GSU.avCacheBackup[(i << 4) + a], t2, 16 - a);831memcpy(t2, &GSU.pvCache[(i << 4) + a], 16 - a);832}833}834835c = USEX16(c + 16);836v >>= 1;837}838}839}840*/841842/*843static void fx_restoreCache()844{845uint32 v = GSU.vCacheFlags;846uint32 c = USEX16(GSU.vCacheBaseReg);847848if (v)849{850for (int i = 0; i < 32; i++)851{852if (v & 1)853{854if (c < (0x10000 - 16))855{856uint8 *t = &GSU.pvPrgBank[c];857memcpy(t, &GSU.avCacheBackup[i << 4], 16);858memcpy(&GSU.pvCache[i << 4], t, 16);859}860else861{862uint8 *t1, *t2;863uint32 a = 0x10000 - c;864865t1 = &GSU.pvPrgBank[c];866t2 = &GSU.pvPrgBank[0];867memcpy(t1, &GSU.avCacheBackup[i << 4], a);868memcpy(&GSU.pvCache[i << 4], t1, a);869memcpy(t2, &GSU.avCacheBackup[(i << 4) + a], 16 - a);870memcpy(&GSU.pvCache[(i << 4) + a], t2, 16 - a);871}872}873874c = USEX16(c + 16);875v >>= 1;876}877}878}879*/880881// Breakpoints882/*883static void FxBreakPointSet (uint32 vAddress)884{885GSU.bBreakPoint = TRUE;886GSU.vBreakPoint = USEX16(vAddress);887}888*/889890/*891static void FxBreakPointClear (void)892{893GSU.bBreakPoint = FALSE;894}895*/896897// Step by step execution898/*899static uint32 FxStepOver (uint32 nInstructions)900{901uint32 vCount;902903fx_readRegisterSpace();904905if (!fx_checkStartAddress())906{907CF(G);908#if 0909GSU.vIllegalAddress = (GSU.vPrgBankReg << 24) | R15;910return (FX_ERROR_ILLEGAL_ADDRESS);911#else912return (0);913#endif914}915916if (PIPE >= 0xf0)917GSU.vStepPoint = USEX16(R15 + 3);918else919if ((PIPE >= 0x05 && PIPE <= 0x0f) || (PIPE >= 0xa0 && PIPE <= 0xaf))920GSU.vStepPoint = USEX16(R15 + 2);921else922GSU.vStepPoint = USEX16(R15 + 1);923924vCount = fx_step_over(nInstructions);925926fx_writeRegisterSpace();927928if (GSU.vErrorCode)929return (GSU.vErrorCode);930else931return (vCount);932}933*/934935// Errors936/*937static int FxGetErrorCode (void)938{939return (GSU.vErrorCode);940}941*/942943/*944static int FxGetIllegalAddress (void)945{946return (GSU.vIllegalAddress);947}948*/949950// Access to internal registers951/*952static uint32 FxGetColorRegister (void)953{954return (GSU.vColorReg & 0xff);955}956*/957958/*959static uint32 FxGetPlotOptionRegister (void)960{961return (GSU.vPlotOptionReg & 0x1f);962}963*/964965/*966static uint32 FxGetSourceRegisterIndex (void)967{968return (GSU.pvSreg - GSU.avReg);969}970*/971972/*973static uint32 FxGetDestinationRegisterIndex (void)974{975return (GSU.pvDreg - GSU.avReg);976}977*/978979// Get the byte currently in the pipe980/*981static uint8 FxPipe (void)982{983return (GSU.vPipe);984}985*/986987988