1 //////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // Nestopia - NES/Famicom emulator written in C++ 4 // 5 // Copyright (C) 2003-2008 Martin Freij 6 // 7 // This file is part of Nestopia. 8 // 9 // Nestopia is free software; you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation; either version 2 of the License, or 12 // (at your option) any later version. 13 // 14 // Nestopia is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with Nestopia; if not, write to the Free Software 21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 // 23 //////////////////////////////////////////////////////////////////////////////////////// 24 25 #include "NstBoard.hpp" 26 #include "NstBoardRcm.hpp" 27 28 namespace Nes 29 { 30 namespace Core 31 { 32 namespace Boards 33 { 34 namespace Rcm 35 { 36 #ifdef NST_MSVC_OPTIMIZE 37 #pragma optimize("s", on) 38 #endif 39 SubReset(const bool hard)40 void Gs2015::SubReset(const bool hard) 41 { 42 Map( 0x8000U, 0xFFFFU, &Gs2015::Poke_8000 ); 43 44 if (hard) 45 prg.SwapBank<SIZE_32K,0x0000>(0); 46 } 47 SubReset(const bool hard)48 void Gs2013::SubReset(const bool hard) 49 { 50 Map( 0x6000U, 0x7FFFU, &Gs2013::Peek_6000 ); 51 Map( 0x8000U, 0xFFFFU, &Gs2013::Poke_8000 ); 52 53 if (hard) 54 { 55 wrk.SwapBank<SIZE_8K,0x0000>( 0x1F ); 56 prg.SwapBank<SIZE_32K,0x0000>( ~0U ); 57 } 58 } 59 SubReset(const bool hard)60 void Gs2004::SubReset(const bool hard) 61 { 62 Map( 0x6000U, 0x7FFFU, &Gs2004::Peek_6000 ); 63 Map( 0x8000U, 0xFFFFU, PRG_SWAP_32K ); 64 65 if (hard) 66 { 67 wrk.SwapBank<SIZE_8K,0x0000>( ~0U ); 68 prg.SwapBank<SIZE_32K,0x0000>( prg.Source().Size() / SIZE_32K - 1 ); 69 } 70 } 71 SubReset(const bool hard)72 void TetrisFamily::SubReset(const bool hard) 73 { 74 Map( 0x8000U, 0xFFFFU, &TetrisFamily::Poke_8000 ); 75 76 if (hard) 77 prg.SwapBank<SIZE_32K,0x0000>(0); 78 } 79 80 #ifdef NST_MSVC_OPTIMIZE 81 #pragma optimize("", on) 82 #endif 83 84 NES_PEEK_A(Gs2013,6000) 85 { 86 return wrk[0][address - 0x6000]; 87 } 88 89 NES_PEEK_A(Gs2004,6000) 90 { 91 return wrk[0][address - 0x6000]; 92 } 93 94 NES_POKE_D(Gs2013,8000) 95 { 96 prg.SwapBank<SIZE_32K,0x0000>( (data & 0x8) ? (data & 0x9) : (data & 0x7) ); 97 } 98 99 NES_POKE_A(Gs2015,8000) 100 { 101 ppu.Update(); 102 prg.SwapBank<SIZE_32K,0x0000>( address ); 103 chr.SwapBank<SIZE_8K,0x0000>( address >> 1 ); 104 } 105 106 NES_POKE_A(TetrisFamily,8000) 107 { 108 ppu.SetMirroring( (address & 0x80) ? Ppu::NMT_H : Ppu::NMT_V ); 109 110 switch (address & 0x30) 111 { 112 case 0x00: 113 case 0x30: 114 115 prg.SwapBank<SIZE_32K,0x0000>( address & 0xF ); 116 break; 117 118 case 0x20: 119 case 0x10: 120 121 address = (address << 1 & 0x1E) | (address >> 4 & 0x02); 122 prg.SwapBanks<SIZE_16K,0x0000>( address, address ); 123 break; 124 } 125 } 126 } 127 } 128 } 129 } 130