📄 ppu.cpp
字号:
case SNES_MOUSE: if (!Settings.SwapJoypads && ++PPU.MouseSpeed [0] > 2) PPU.MouseSpeed [0] = 0; break; } return (0x00); } int ind = Settings.SwapJoypads ? 0 : 1; if (IPPU.Controller == SNES_MULTIPLAYER5) { if (Memory.FillRAM [0x4201] & 0x80) { byte = ((IPPU.Joypads[ind] >> (PPU.Joypad2ButtonReadPos ^ 15)) & 1) | (((IPPU.Joypads[2] >> (PPU.Joypad2ButtonReadPos ^ 15)) & 1) << 1); PPU.Joypad2ButtonReadPos++; return (byte); } else { byte = ((IPPU.Joypads[3] >> (PPU.Joypad3ButtonReadPos ^ 15)) & 1) | (((IPPU.Joypads[4] >> (PPU.Joypad3ButtonReadPos ^ 15)) & 1) << 1); PPU.Joypad3ButtonReadPos++; return (byte); } } else if(IPPU.Controller ==SNES_JUSTIFIER || IPPU.Controller ==SNES_JUSTIFIER_2) { uint8 rv; rv=(1&(justifiers>>in_bit)); in_bit++; in_bit%=32; return rv; } return ((IPPU.Joypads[ind] >> (PPU.Joypad2ButtonReadPos++ ^ 15)) & 1); } default:#ifdef DEBUGGER missing.unknowncpu_read = Address; if (Settings.TraceUnknownRegisters) { sprintf (String, "Unknown register read: $%04X\n", Address); S9xMessage (S9X_TRACE, S9X_PPU_TRACE, String); }#endif return OpenBus; }// return (Memory.FillRAM [Address]); } else switch (Address) { case 0x4200: case 0x4201: case 0x4202: case 0x4203: case 0x4204: case 0x4205: case 0x4206: case 0x4207: case 0x4208: case 0x4209: case 0x420a: case 0x420b: case 0x420c: case 0x420d: case 0x420e: case 0x420f: return OpenBus; case 0x4210:#ifdef CPU_SHUTDOWN CPU.WaitAddress = CPU.PCAtOpcodeStart;#endif byte = Memory.FillRAM[0x4210]; Memory.FillRAM[0x4210] = Model->_5A22; //SNEeSe returns 2 for 5A22 version. return ((byte&0x80)|(OpenBus&0x70)|Model->_5A22); case 0x4211: byte = (CPU.IRQActive & (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE)) ? 0x80 : 0; // Super Robot Wars Ex ROM bug requires this. byte |= CPU.Cycles >= Settings.HBlankStart ? 0x40 : 0; CLEAR_IRQ_SOURCE (PPU_V_BEAM_IRQ_SOURCE | PPU_H_BEAM_IRQ_SOURCE); // Maybe? Register Scan indicated open bus... byte |= OpenBus&0x3f; return (byte); case 0x4212: // V-blank, h-blank and joypads being read flags (read-only)#ifdef CPU_SHUTDOWN CPU.WaitAddress = CPU.PCAtOpcodeStart;#endif return (REGISTER_4212()|(OpenBus&0x3E)); case 0x4213: // I/O port input - returns 0 wherever $4201 is 0, and 1 elsewhere // unless something else pulls it down (i.e. a gun) return Memory.FillRAM[0x4213]; case 0x4214: case 0x4215: // Quotient of divide result case 0x4216: case 0x4217: // Multiplcation result (for multiply) or remainder of // divison. return (Memory.FillRAM[Address]); case 0x4218: case 0x4219: case 0x421a: case 0x421b: case 0x421c: case 0x421d: case 0x421e: case 0x421f: // Joypads 1-4 button and direction state. return (Memory.FillRAM [Address]); case 0x4300: case 0x4310: case 0x4320: case 0x4330: case 0x4340: case 0x4350: case 0x4360: case 0x4370: // DMA direction, address type, fixed flag, return (Memory.FillRAM[Address]); case 0x4301: case 0x4311: case 0x4321: case 0x4331: case 0x4341: case 0x4351: case 0x4361: case 0x4371: return (Memory.FillRAM[Address]); case 0x4302: case 0x4312: case 0x4322: case 0x4332: case 0x4342: case 0x4352: case 0x4362: case 0x4372: return (Memory.FillRAM[Address]); case 0x4303: case 0x4313: case 0x4323: case 0x4333: case 0x4343: case 0x4353: case 0x4363: case 0x4373: return (Memory.FillRAM[Address]); case 0x4304: case 0x4314: case 0x4324: case 0x4334: case 0x4344: case 0x4354: case 0x4364: case 0x4374: return (Memory.FillRAM[Address]); case 0x4305: case 0x4315: case 0x4325: case 0x4335: case 0x4345: case 0x4355: case 0x4365: case 0x4375: return (Memory.FillRAM[Address]); case 0x4306: case 0x4316: case 0x4326: case 0x4336: case 0x4346: case 0x4356: case 0x4366: case 0x4376: return (Memory.FillRAM[Address]); case 0x4307: case 0x4317: case 0x4327: case 0x4337: case 0x4347: case 0x4357: case 0x4367: case 0x4377: return (DMA[(Address >> 4) & 7].IndirectBank); case 0x4308: case 0x4318: case 0x4328: case 0x4338: case 0x4348: case 0x4358: case 0x4368: case 0x4378: return (Memory.FillRAM[Address]); case 0x4309: case 0x4319: case 0x4329: case 0x4339: case 0x4349: case 0x4359: case 0x4369: case 0x4379: return (Memory.FillRAM[Address]); case 0x430A: case 0x431A: case 0x432A: case 0x433A: case 0x434A: case 0x435A: case 0x436A: case 0x437A: { int d = (Address & 0x70) >> 4; if (IPPU.HDMA & (1 << d)) { return (DMA[d].LineCount); } return (Memory.FillRAM[Address]); } case 0x430F: case 0x431F: case 0x432F: case 0x433F: case 0x434F: case 0x435F: case 0x436F: case 0x437F: Address &= ~4; // Convert 43xF to 43xB /* fall through */ case 0x430B: case 0x431B: case 0x432B: case 0x433B: case 0x434B: case 0x435B: case 0x436B: case 0x437B: // Unknown, but they seem to be RAM-ish return (Memory.FillRAM[Address]); default:#ifdef DEBUGGER missing.unknowncpu_read = Address; if (Settings.TraceUnknownRegisters) { sprintf (String, "Unknown register read: $%04X\n", Address); S9xMessage (S9X_TRACE, S9X_PPU_TRACE, String); } #endif if(Address>= 0x4800&&Settings.SPC7110) return S9xGetSPC7110(Address); if(Address>=0x4800&&Address<=0x4807&&Settings.SDD1) { return Memory.FillRAM[Address]; } return OpenBus; }// return (Memory.FillRAM[Address]);}void S9xResetPPU (){ PPU.BGMode = 0; PPU.BG3Priority = 0; PPU.Brightness = 0; PPU.VMA.High = 0; PPU.VMA.Increment = 1; PPU.VMA.Address = 0; PPU.VMA.FullGraphicCount = 0; PPU.VMA.Shift = 0; for (uint8 B = 0; B != 4; B++) { PPU.BG[B].SCBase = 0; PPU.BG[B].VOffset = 0; PPU.BG[B].HOffset = 0; PPU.BG[B].BGSize = 0; PPU.BG[B].NameBase = 0; PPU.BG[B].SCSize = 0; PPU.ClipCounts[B] = 0; PPU.ClipWindowOverlapLogic [B] = CLIP_OR; PPU.ClipWindow1Enable[B] = FALSE; PPU.ClipWindow2Enable[B] = FALSE; PPU.ClipWindow1Inside[B] = TRUE; PPU.ClipWindow2Inside[B] = TRUE; } PPU.ClipCounts[4] = 0; PPU.ClipCounts[5] = 0; PPU.ClipWindowOverlapLogic[4] = PPU.ClipWindowOverlapLogic[5] = CLIP_OR; PPU.ClipWindow1Enable[4] = PPU.ClipWindow1Enable[5] = FALSE; PPU.ClipWindow2Enable[4] = PPU.ClipWindow2Enable[5] = FALSE; PPU.ClipWindow1Inside[4] = PPU.ClipWindow1Inside[5] = TRUE; PPU.ClipWindow2Inside[4] = PPU.ClipWindow2Inside[5] = TRUE; PPU.CGFLIP = 0; int c; for (c = 0; c < 256; c++) { IPPU.Red [c] = (c & 7) << 2; IPPU.Green [c] = ((c >> 3) & 7) << 2; IPPU.Blue [c] = ((c >> 6) & 2) << 3; PPU.CGDATA [c] = IPPU.Red [c] | (IPPU.Green [c] << 5) | (IPPU.Blue [c] << 10); } PPU.FirstSprite = 0; PPU.LastSprite = 127; for (int Sprite = 0; Sprite < 128; Sprite++) { PPU.OBJ[Sprite].HPos = 0; PPU.OBJ[Sprite].VPos = 0; PPU.OBJ[Sprite].VFlip = 0; PPU.OBJ[Sprite].HFlip = 0; PPU.OBJ[Sprite].Priority = 0; PPU.OBJ[Sprite].Palette = 0; PPU.OBJ[Sprite].Name = 0; PPU.OBJ[Sprite].Size = 0; } PPU.OAMPriorityRotation = 0; PPU.OAMWriteRegister = 0; PPU.RangeTimeOver = 0; PPU.OpenBus1 = 0; PPU.OpenBus2 = 0; PPU.OAMFlip = 0; PPU.OAMTileAddress = 0; PPU.OAMAddr = 0; PPU.IRQVBeamPos = 0; PPU.IRQHBeamPos = 0; PPU.VBeamPosLatched = 0; PPU.HBeamPosLatched = 0; PPU.HBeamFlip = 0; PPU.VBeamFlip = 0; PPU.HVBeamCounterLatched = 0; PPU.MatrixA = PPU.MatrixB = PPU.MatrixC = PPU.MatrixD = 0; PPU.CentreX = PPU.CentreY = 0; PPU.Joypad1ButtonReadPos = 0; PPU.Joypad2ButtonReadPos = 0; PPU.Joypad3ButtonReadPos = 0; PPU.CGADD = 0; PPU.FixedColourRed = PPU.FixedColourGreen = PPU.FixedColourBlue = 0; PPU.SavedOAMAddr = 0; PPU.ScreenHeight = SNES_HEIGHT; PPU.WRAM = 0; PPU.BG_Forced = 0; PPU.ForcedBlanking = TRUE; PPU.OBJThroughMain = FALSE; PPU.OBJThroughSub = FALSE; PPU.OBJSizeSelect = 0; PPU.OBJNameSelect = 0; PPU.OBJNameBase = 0; PPU.OBJAddition = FALSE; PPU.OAMReadFlip = 0; PPU.BGnxOFSbyte = 0; ZeroMemory (PPU.OAMData, 512 + 32); PPU.VTimerEnabled = FALSE; PPU.HTimerEnabled = FALSE; PPU.HTimerPosition = Settings.H_Max + 1; PPU.Mosaic = 0; PPU.BGMosaic [0] = PPU.BGMosaic [1] = FALSE; PPU.BGMosaic [2] = PPU.BGMosaic [3] = FALSE; PPU.Mode7HFlip = FALSE; PPU.Mode7VFlip = FALSE; PPU.Mode7Repeat = 0; PPU.Window1Left = 1; PPU.Window1Right = 0; PPU.Window2Left = 1; PPU.Window2Right = 0; PPU.RecomputeClipWindows = TRUE; PPU.CGFLIPRead = 0; PPU.Need16x8Mulitply = FALSE; PPU.MouseSpeed[0] = PPU.MouseSpeed[1] = 0; IPPU.ColorsChanged = TRUE; IPPU.HDMA = 0; IPPU.HDMAStarted = FALSE; IPPU.MaxBrightness = 0; IPPU.LatchedBlanking = 0; IPPU.OBJChanged = TRUE; IPPU.RenderThisFrame = TRUE; IPPU.DirectColourMapsNeedRebuild = TRUE; IPPU.FrameCount = 0; IPPU.RenderedFramesCount = 0; IPPU.DisplayedRenderedFrameCount = 0; IPPU.SkippedFrames = 0; IPPU.FrameSkip = 0; ZeroMemory (IPPU.TileCached [TILE_2BIT], MAX_2BIT_TILES); ZeroMemory (IPPU.TileCached [TILE_4BIT], MAX_4BIT_TILES); ZeroMemory (IPPU.TileCached [TILE_8BIT], MAX_8BIT_TILES);#ifdef CORRECT_VRAM_READS IPPU.VRAMReadBuffer = 0; // XXX: FIXME: anything better?#else IPPU.FirstVRAMRead = FALSE;#endif IPPU.Interlace = FALSE; IPPU.InterlaceSprites = FALSE; IPPU.DoubleWidthPixels = FALSE; IPPU.DoubleHeightPixels = FALSE; IPPU.RenderedScreenWidth = SNES_WIDTH; IPPU.RenderedScreenHeight = SNES_HEIGHT; IPPU.XB = NULL; for (c = 0; c < 256; c++) IPPU.ScreenColors [c] = c; S9xFixColourBrightness (); IPPU.PreviousLine = IPPU.CurrentLine = 0; IPPU.Joypads[0] = IPPU.Joypads[1] = IPPU.Joypads[2] = 0; IPPU.Joypads[3] = IPPU.Joypads[4] = 0; IPPU.SuperScope = 0; IPPU.Mouse[0] = IPPU.Mouse[1] = 0; IPPU.PrevMouseX[0] = IPPU.PrevMouseX[1] = 256 / 2; IPPU.PrevMouseY[0] = IPPU.PrevMouseY[1] = 224 / 2; if (Settings.ControllerOption == 0) IPPU.Controller = SNES_MAX_CONTROLLER_OPTIONS - 1; else IPPU.Controller = Settings.ControllerOption - 1; S9xNextController (); for (c = 0; c < 2; c++) memset (&IPPU.Clip [c], 0, sizeof (struct ClipData)); if (Settings.MouseMaster) { S9xProcessMouse (0); S9xProcessMouse (1); } for (c = 0; c < 0x8000; c += 0x100) { if ( !Settings.SuperFX ) { memset (&Memory.FillRAM [c], c >> 8, 0x100); } else if ( (unsigned)c < 0x3000 || (unsigned)c >= 0x3300 ) { /* Don't overwrite SFX pvRegisters at 0x3000-0x32FF, * they were set in FxReset. */ memset (&Memory.FillRAM [c], c >> 8, 0x100); } } ZeroMemory (&Memory.FillRAM [0x2100], 0x100); ZeroMemory (&Memory.FillRAM [0x4200], 0x100); ZeroMemory (&Memory.FillRAM [0x4000], 0x100); // For BS Suttehakkun 2... ZeroMemory (&Memory.FillRAM [0x1000], 0x1000); Memory.FillRAM[0x4201]=Memory.FillRAM[0x4213]=0xFF;}void S9xSoftResetPPU (){ PPU.BGMode = 0; PPU.BG3Priority = 0; PPU.Brightness = 0; PPU.VMA.High = 0; PPU.VMA.Increment = 1; PPU.VMA.Address = 0; PPU.VMA.FullGraphicCount = 0; PPU.VMA.Shift = 0; for (uint8 B = 0; B != 4; B++) { PPU.BG[B].SCBase = 0; PPU.BG[B].VOffset = 0; PPU.BG[B].HOffset = 0; PPU.BG[B].BGSize = 0; PPU.BG[B].NameBase = 0; PPU.BG[B].SCSize = 0; PPU.ClipCounts[B] = 0; PPU.ClipWindowOverlapLogic [B] = CLIP_OR; PPU.ClipWindow1Enable[B] = FALSE; PPU.ClipWindow2Enable[B] = FALSE; PPU.ClipWindow1Inside[B] = TRUE; PPU.ClipWindow2Inside[B] = TRUE; } PPU.ClipCounts[4] = 0; PPU.ClipCounts[5] = 0; PPU.ClipWindowOverlapLogic[4] = PPU.ClipWindowOverlapLogic[5] = CLIP_OR; PPU.ClipWindow1Enable[4] = PPU.ClipWindow1Enable[5] = FALSE; PPU.ClipWindow2Enable[4] = PPU.ClipWindow2Enable[5] = FALSE; PPU.ClipWindow1Inside[4] = PPU.ClipWindow1Inside[5] = TRUE; PPU.ClipWindow2Inside[4] = PPU.ClipWindow2Inside[5] = TRUE; PPU.CGFLIP = 0; int c; for (c = 0; c < 256; c++) { IPPU.Red [c] = (c & 7) << 2; IPPU.Green [c] = ((c >> 3) & 7) << 2; IPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -