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 "../NstSoundPlayer.hpp"
27 #include "NstBoardJalecoJf17.hpp"
28 
29 namespace Nes
30 {
31 	namespace Core
32 	{
33 		namespace Boards
34 		{
35 			namespace Jaleco
36 			{
37 				#ifdef NST_MSVC_OPTIMIZE
38 				#pragma optimize("s", on)
39 				#endif
40 
Jf17(const Context & c)41 				Jf17::Jf17(const Context& c)
42 				:
43 				Board (c),
44 				sound (Sound::Player::Create(*c.apu,c.chips,L"D7756C",board == Type::JALECO_JF17 ? Sound::Player::GAME_MOERO_PRO_TENNIS : Sound::Player::GAME_UNKNOWN,32))
45 				{
46 				}
47 
~Jf17()48 				Jf17::~Jf17()
49 				{
50 					Sound::Player::Destroy( sound );
51 				}
52 
SubReset(bool)53 				void Jf17::SubReset(bool)
54 				{
55 					Map( 0x8000U, 0xFFFFU, &Jf17::Poke_8000 );
56 				}
57 
58 				#ifdef NST_MSVC_OPTIMIZE
59 				#pragma optimize("", on)
60 				#endif
61 
62 				NES_POKE_AD(Jf17,8000)
63 				{
64 					data = GetBusData(address,data);
65 
66 					if (data & 0x40)
67 					{
68 						ppu.Update();
69 						chr.SwapBank<SIZE_8K,0x0000>( data & 0xF );
70 					}
71 
72 					if (data & 0x80)
73 						prg.SwapBank<SIZE_16K,0x0000>( data & 0xF );
74 
75 					if (sound && (data & 0x30) == 0x20)
76 						sound->Play( address & 0x1F );
77 				}
78 			}
79 		}
80 	}
81 }
82