Mercurial > audlegacy
annotate Plugins/Input/console/Nsf_Emu.cpp @ 1218:aaf012a5529c trunk
[svn] - more Makefile conversion
author | nenolod |
---|---|
date | Wed, 14 Jun 2006 01:16:45 -0700 |
parents | c04dff121e1d |
children | c18d0da08fac |
rev | line source |
---|---|
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
1 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
2 // Game_Music_Emu 0.3.0. http://www.slack.net/~ant/ |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
3 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
4 #include "Nsf_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
5 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
6 #include <string.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
7 #include <stdio.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
8 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
9 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
10 #include "Nes_Vrc6_Apu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
11 #include "Nes_Namco_Apu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
12 #include "Nes_Fme7_Apu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
13 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
14 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
15 #include "blargg_endian.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
16 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
17 /* Copyright (C) 2003-2006 Shay Green. This module is free software; you |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
18 can redistribute it and/or modify it under the terms of the GNU Lesser |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
19 General Public License as published by the Free Software Foundation; either |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
20 version 2.1 of the License, or (at your option) any later version. This |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
21 module is distributed in the hope that it will be useful, but WITHOUT ANY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
22 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
23 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
24 more details. You should have received a copy of the GNU Lesser General |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
25 Public License along with this module; if not, write to the Free Software |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
27 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
28 #include BLARGG_SOURCE_BEGIN |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
29 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
30 #ifndef RUN_NES_CPU |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
31 #define RUN_NES_CPU( cpu, count ) cpu.run( count ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
32 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
33 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
34 #ifndef NSF_BEGIN_FRAME |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
35 #define NSF_BEGIN_FRAME() |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
36 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
37 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
38 const unsigned low_mem_size = 0x800; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
39 const unsigned page_size = 0x1000; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
40 const long ram_size = 0x10000; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
41 const nes_addr_t rom_begin = 0x8000; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
42 const nes_addr_t bank_select_addr = 0x5ff8; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
43 const nes_addr_t exram_addr = bank_select_addr - (bank_select_addr % Nes_Cpu::page_size); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
44 const int master_clock_divisor = 12; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
45 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
46 const int vrc6_flag = 0x01; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
47 const int namco_flag = 0x10; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
48 const int fme7_flag = 0x20; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
49 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
50 static BOOST::uint8_t unmapped_code [Nes_Cpu::page_size]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
51 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
52 Nes_Emu::equalizer_t const Nes_Emu::nes_eq = { -1.0, 80 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
53 Nes_Emu::equalizer_t const Nes_Emu::famicom_eq = { -15.0, 80 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
54 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
55 // ROM |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
56 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
57 int Nsf_Emu::read_code( Nsf_Emu* emu, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
58 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
59 return *emu->cpu.get_code( addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
60 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
61 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
62 void Nsf_Emu::write_exram( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
63 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
64 unsigned bank = addr - bank_select_addr; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
65 if ( bank < bank_count ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
66 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
67 if ( data < emu->total_banks ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
68 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
69 emu->cpu.map_code( (bank + 8) * page_size, page_size, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
70 &emu->rom [data * page_size] ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
71 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
72 else |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
73 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
74 dprintf( "Bank %d out of range (%d banks total)\n", |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
75 data, (int) emu->total_banks ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
76 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
77 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
78 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
79 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
80 // APU |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
81 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
82 int Nsf_Emu::read_snd( Nsf_Emu* emu, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
83 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
84 if ( addr == Nes_Apu::status_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
85 return emu->apu.read_status( emu->cpu.time() ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
86 return addr >> 8; // high byte of address stays on bus |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
87 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
88 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
89 void Nsf_Emu::write_snd( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
90 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
91 if ( unsigned (addr - Nes_Apu::start_addr) <= Nes_Apu::end_addr - Nes_Apu::start_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
92 emu->apu.write_register( emu->cpu.time(), addr, data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
93 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
94 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
95 int Nsf_Emu::pcm_read( void* emu, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
96 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
97 return ((Nsf_Emu*) emu)->cpu.read( addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
98 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
99 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
100 // Low Mem |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
101 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
102 int Nsf_Emu::read_low_mem( Nsf_Emu* emu, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
103 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
104 return emu->cpu.low_mem [addr]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
105 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
106 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
107 void Nsf_Emu::write_low_mem( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
108 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
109 emu->cpu.low_mem [addr] = data; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
110 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
111 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
112 // SRAM |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
113 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
114 int Nsf_Emu::read_sram( Nsf_Emu* emu, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
115 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
116 return emu->sram [addr & (sram_size - 1)]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
117 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
118 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
119 void Nsf_Emu::write_sram( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
120 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
121 emu->sram [addr & (sram_size - 1)] = data; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
122 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
123 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
124 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
125 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
126 // Namco |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
127 int Nsf_Emu::read_namco( Nsf_Emu* emu, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
128 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
129 if ( addr == Nes_Namco_Apu::data_reg_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
130 return emu->namco->read_data(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
131 return addr >> 8; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
132 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
133 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
134 void Nsf_Emu::write_namco( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
135 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
136 if ( addr == Nes_Namco_Apu::data_reg_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
137 emu->namco->write_data( emu->cpu.time(), data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
138 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
139 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
140 void Nsf_Emu::write_namco_addr( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
141 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
142 if ( addr == Nes_Namco_Apu::addr_reg_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
143 emu->namco->write_addr( data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
144 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
145 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
146 // VRC6 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
147 void Nsf_Emu::write_vrc6( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
148 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
149 unsigned reg = addr & (Nes_Vrc6_Apu::addr_step - 1); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
150 unsigned osc = unsigned (addr - Nes_Vrc6_Apu::base_addr) / Nes_Vrc6_Apu::addr_step; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
151 if ( osc < Nes_Vrc6_Apu::osc_count && reg < Nes_Vrc6_Apu::reg_count ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
152 emu->vrc6->write_osc( emu->cpu.time(), osc, reg, data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
153 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
154 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
155 // FME-7 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
156 void Nsf_Emu::write_fme7( Nsf_Emu* emu, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
157 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
158 switch ( addr & Nes_Fme7_Apu::addr_mask ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
159 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
160 case Nes_Fme7_Apu::latch_addr: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
161 emu->fme7->write_latch( data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
162 break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
163 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
164 case Nes_Fme7_Apu::data_addr: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
165 emu->fme7->write_data( emu->cpu.time(), data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
166 break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
167 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
168 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
169 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
170 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
171 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
172 // Unmapped |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
173 int Nsf_Emu::read_unmapped( Nsf_Emu*, nes_addr_t addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
174 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
175 dprintf( "Read unmapped $%.4X\n", (unsigned) addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
176 return (addr >> 8) & 0xff; // high byte of address stays on bus |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
177 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
178 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
179 void Nsf_Emu::write_unmapped( Nsf_Emu*, nes_addr_t addr, int data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
180 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
181 #ifdef NDEBUG |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
182 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
183 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
184 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
185 // some games write to $8000 and $8001 repeatedly |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
186 if ( addr == 0x8000 || addr == 0x8001 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
187 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
188 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
189 // probably namco sound mistakenly turned on in mck |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
190 if ( addr == 0x4800 || addr == 0xF800 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
191 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
192 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
193 // memory mapper? |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
194 if ( addr == 0xFFF8 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
195 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
196 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
197 dprintf( "write_unmapped( 0x%04X, 0x%02X )\n", (unsigned) addr, (unsigned) data ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
198 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
199 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
200 Nes_Emu::Nes_Emu( double gain_ ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
201 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
202 cpu.set_emu( this ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
203 play_addr = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
204 gain = gain_; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
205 apu.dmc_reader( pcm_read, this ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
206 vrc6 = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
207 namco = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
208 fme7 = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
209 Music_Emu::set_equalizer( nes_eq ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
210 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
211 // set unmapped code to illegal instruction |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
212 memset( unmapped_code, 0x32, sizeof unmapped_code ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
213 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
214 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
215 Nes_Emu::~Nes_Emu() |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
216 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
217 unload(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
218 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
219 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
220 void Nsf_Emu::unload() |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
221 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
222 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
223 delete vrc6; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
224 vrc6 = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
225 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
226 delete namco; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
227 namco = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
228 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
229 delete fme7; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
230 fme7 = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
231 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
232 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
233 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
234 rom.clear(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
235 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
236 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
237 const char** Nsf_Emu::voice_names() const |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
238 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
239 static const char* base_names [] = { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
240 "Square 1", "Square 2", "Triangle", "Noise", "DMC" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
241 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
242 static const char* namco_names [] = { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
243 "Square 1", "Square 2", "Triangle", "Noise", "DMC", |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
244 "Namco 5&7", "Namco 4&6", "Namco 1-3" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
245 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
246 static const char* vrc6_names [] = { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
247 "Square 1", "Square 2", "Triangle", "Noise", "DMC", |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
248 "VRC6 Square 1", "VRC6 Square 2", "VRC6 Saw" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
249 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
250 static const char* dual_names [] = { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
251 "Square 1", "Square 2", "Triangle", "Noise", "DMC", |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
252 "VRC6.1,N106.5&7", "VRC6.2,N106.4&6", "VRC6.3,N106.1-3" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
253 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
254 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
255 static const char* fme7_names [] = { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
256 "Square 1", "Square 2", "Triangle", "Noise", "DMC", |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
257 "Square 3", "Square 4", "Square 5" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
258 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
259 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
260 if ( namco ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
261 return vrc6 ? dual_names : namco_names; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
262 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
263 if ( vrc6 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
264 return vrc6_names; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
265 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
266 if ( fme7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
267 return fme7_names; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
268 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
269 return base_names; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
270 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
271 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
272 blargg_err_t Nsf_Emu::init_sound() |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
273 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
274 if ( exp_flags & ~(namco_flag | vrc6_flag | fme7_flag) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
275 return "NSF requires unsupported expansion audio hardware"; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
276 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
277 // map memory |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
278 cpu.reset( unmapped_code, read_unmapped, write_unmapped ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
279 cpu.map_memory( 0, low_mem_size, read_low_mem, write_low_mem ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
280 cpu.map_code( 0, low_mem_size, cpu.low_mem ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
281 cpu.map_memory( 0x4000, Nes_Cpu::page_size, read_snd, write_snd ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
282 cpu.map_memory( exram_addr, Nes_Cpu::page_size, read_unmapped, write_exram ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
283 cpu.map_memory( 0x6000, sram_size, read_sram, write_sram ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
284 cpu.map_code ( 0x6000, sram_size, sram ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
285 cpu.map_memory( rom_begin, ram_size - rom_begin, read_code, write_unmapped ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
286 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
287 set_voice_count( Nes_Apu::osc_count ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
288 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
289 double adjusted_gain = gain; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
290 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
291 #if NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
292 if ( exp_flags ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
293 return "NSF requires expansion audio hardware"; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
294 #else |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
295 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
296 if ( exp_flags ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
297 set_voice_count( Nes_Apu::osc_count + 3 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
298 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
299 // namco |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
300 if ( exp_flags & namco_flag ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
301 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
302 namco = BLARGG_NEW Nes_Namco_Apu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
303 BLARGG_CHECK_ALLOC( namco ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
304 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
305 adjusted_gain *= 0.75; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
306 cpu.map_memory( Nes_Namco_Apu::data_reg_addr, Nes_Cpu::page_size, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
307 read_namco, write_namco ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
308 cpu.map_memory( Nes_Namco_Apu::addr_reg_addr, Nes_Cpu::page_size, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
309 read_code, write_namco_addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
310 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
311 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
312 // vrc6 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
313 if ( exp_flags & vrc6_flag ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
314 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
315 vrc6 = BLARGG_NEW Nes_Vrc6_Apu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
316 BLARGG_CHECK_ALLOC( vrc6 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
317 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
318 adjusted_gain *= 0.75; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
319 for ( int i = 0; i < Nes_Vrc6_Apu::osc_count; i++ ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
320 cpu.map_memory( Nes_Vrc6_Apu::base_addr + i * Nes_Vrc6_Apu::addr_step, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
321 Nes_Cpu::page_size, read_code, write_vrc6 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
322 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
323 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
324 // fme7 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
325 if ( exp_flags & fme7_flag ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
326 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
327 fme7 = BLARGG_NEW Nes_Fme7_Apu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
328 BLARGG_CHECK_ALLOC( fme7 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
329 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
330 adjusted_gain *= 0.75; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
331 cpu.map_memory( fme7->latch_addr, ram_size - fme7->latch_addr, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
332 read_code, write_fme7 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
333 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
334 // to do: is gain adjustment even needed? other sound chip volumes should work |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
335 // naturally with the apu without change. |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
336 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
337 if ( namco ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
338 namco->volume( adjusted_gain ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
339 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
340 if ( vrc6 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
341 vrc6->volume( adjusted_gain ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
342 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
343 if ( fme7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
344 fme7->volume( adjusted_gain ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
345 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
346 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
347 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
348 apu.volume( adjusted_gain ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
349 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
350 return blargg_success; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
351 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
352 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
353 void Nsf_Emu::update_eq( blip_eq_t const& eq ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
354 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
355 apu.treble_eq( eq ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
356 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
357 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
358 if ( vrc6 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
359 vrc6->treble_eq( eq ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
360 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
361 if ( namco ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
362 namco->treble_eq( eq ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
363 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
364 if ( fme7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
365 fme7->treble_eq( eq ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
366 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
367 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
368 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
369 blargg_err_t Nsf_Emu::load( Data_Reader& in ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
370 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
371 header_t h; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
372 BLARGG_RETURN_ERR( in.read( &h, sizeof h ) ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
373 return load( h, in ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
374 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
375 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
376 blargg_err_t Nsf_Emu::load( const header_t& h, Data_Reader& in ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
377 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
378 header_ = h; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
379 unload(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
380 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
381 // check compatibility |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
382 if ( 0 != memcmp( header_.tag, "NESM\x1A", 5 ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
383 return "Not an NSF file"; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
384 if ( header_.vers != 1 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
385 return "Unsupported NSF format"; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
386 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
387 // sound and memory |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
388 exp_flags = header_.chip_flags; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
389 blargg_err_t err = init_sound(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
390 if ( err ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
391 return err; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
392 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
393 // set up data |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
394 nes_addr_t load_addr = get_le16( header_.load_addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
395 init_addr = get_le16( header_.init_addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
396 play_addr = get_le16( header_.play_addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
397 if ( !load_addr ) load_addr = rom_begin; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
398 if ( !init_addr ) init_addr = rom_begin; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
399 if ( !play_addr ) play_addr = rom_begin; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
400 if ( load_addr < rom_begin || init_addr < rom_begin ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
401 return "Invalid address in NSF"; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
402 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
403 // set up rom |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
404 total_banks = (in.remain() + load_addr % page_size + page_size - 1) / page_size; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
405 BLARGG_RETURN_ERR( rom.resize( total_banks * page_size ) ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
406 memset( rom.begin(), 0, rom.size() ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
407 err = in.read( &rom [load_addr % page_size], in.remain() ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
408 if ( err ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
409 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
410 unload(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
411 return err; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
412 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
413 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
414 // bank switching |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
415 int first_bank = (load_addr - rom_begin) / page_size; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
416 for ( int i = 0; i < bank_count; i++ ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
417 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
418 unsigned bank = i - first_bank; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
419 initial_banks [i] = (bank < (unsigned) total_banks) ? bank : 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
420 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
421 if ( header_.banks [i] ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
422 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
423 // bank-switched |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
424 memcpy( initial_banks, header_.banks, sizeof initial_banks ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
425 break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
426 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
427 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
428 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
429 // playback rate |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
430 unsigned playback_rate = get_le16( header_.ntsc_speed ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
431 unsigned standard_rate = 0x411A; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
432 double clock_rate = 1789772.72727; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
433 play_period = 262 * 341L * 4 + 2; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
434 pal_only = false; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
435 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
436 // use pal speed if there is no ntsc speed |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
437 if ( (header_.speed_flags & 3) == 1 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
438 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
439 pal_only = true; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
440 play_period = 33247 * master_clock_divisor; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
441 clock_rate = 1662607.125; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
442 standard_rate = 0x4E20; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
443 playback_rate = get_le16( header_.pal_speed ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
444 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
445 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
446 // use custom playback rate if not the standard rate |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
447 if ( playback_rate && playback_rate != standard_rate ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
448 play_period = long (clock_rate * playback_rate * master_clock_divisor / |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
449 1000000.0); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
450 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
451 // extra flags |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
452 int extra_flags = header_.speed_flags; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
453 #if !NSF_EMU_EXTRA_FLAGS |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
454 extra_flags = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
455 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
456 needs_long_frames = (extra_flags & 0x10) != 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
457 initial_pcm_dac = (extra_flags & 0x20) ? 0x3F : 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
458 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
459 set_track_count( header_.track_count ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
460 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
461 return setup_buffer( (long) (clock_rate + 0.5) ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
462 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
463 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
464 void Nsf_Emu::set_voice( int i, Blip_Buffer* buf, Blip_Buffer*, Blip_Buffer* ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
465 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
466 if ( i < Nes_Apu::osc_count ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
467 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
468 apu.osc_output( i, buf ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
469 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
470 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
471 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
472 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
473 if ( vrc6 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
474 vrc6->osc_output( i - Nes_Apu::osc_count, buf ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
475 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
476 if ( fme7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
477 fme7->osc_output( i - Nes_Apu::osc_count, buf ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
478 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
479 if ( namco ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
480 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
481 if ( i < 7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
482 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
483 i &= 1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
484 namco->osc_output( i + 4, buf ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
485 namco->osc_output( i + 6, buf ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
486 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
487 else |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
488 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
489 for ( int n = 0; n < namco->osc_count / 2; n++ ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
490 namco->osc_output( n, buf ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
491 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
492 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
493 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
494 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
495 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
496 void Nsf_Emu::start_track( int track ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
497 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
498 require( rom.size() ); // file must be loaded |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
499 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
500 Classic_Emu::start_track( track ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
501 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
502 // clear memory |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
503 memset( cpu.low_mem, 0, sizeof cpu.low_mem ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
504 memset( sram, 0, sizeof sram ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
505 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
506 // initial rom banks |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
507 for ( int i = 0; i < bank_count; ++i ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
508 cpu.write( bank_select_addr + i, initial_banks [i] ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
509 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
510 // reset sound |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
511 apu.reset( pal_only, initial_pcm_dac ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
512 apu.write_register( 0, 0x4015, 0x0F ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
513 apu.write_register( 0, 0x4017, needs_long_frames ? 0x80 : 0 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
514 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
515 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
516 if ( namco ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
517 namco->reset(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
518 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
519 if ( vrc6 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
520 vrc6->reset(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
521 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
522 if ( fme7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
523 fme7->reset(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
524 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
525 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
526 // reset cpu |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
527 cpu.r.pc = exram_addr; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
528 cpu.r.a = track; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
529 cpu.r.x = pal_only; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
530 cpu.r.y = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
531 cpu.r.sp = 0xFF; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
532 cpu.r.status = 0x04; // i flag |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
533 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
534 // first call |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
535 cpu_jsr( init_addr, -1 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
536 next_play = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
537 play_extra = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
538 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
539 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
540 void Nsf_Emu::cpu_jsr( nes_addr_t pc, int adj ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
541 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
542 unsigned addr = cpu.r.pc + adj; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
543 cpu.r.pc = pc; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
544 cpu.push_byte( addr >> 8 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
545 cpu.push_byte( addr ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
546 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
547 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
548 void Nsf_Emu::call_play() |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
549 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
550 cpu_jsr( play_addr, -1 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
551 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
552 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
553 blip_time_t Nsf_Emu::run_clocks( blip_time_t duration, bool* ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
554 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
555 // run cpu |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
556 cpu.set_time( 0 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
557 bool first_illegal = true; // avoid swamping output with illegal instruction errors |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
558 while ( cpu.time() < duration ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
559 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
560 // check for idle cpu |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
561 if ( cpu.r.pc == exram_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
562 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
563 if ( next_play > duration ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
564 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
565 cpu.set_time( duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
566 break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
567 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
568 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
569 if ( next_play > cpu.time() ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
570 cpu.set_time( next_play ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
571 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
572 nes_time_t period = (play_period + play_extra) / master_clock_divisor; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
573 play_extra = play_period - period * master_clock_divisor; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
574 next_play += period; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
575 call_play(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
576 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
577 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
578 Nes_Cpu::result_t result = RUN_NES_CPU( cpu, duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
579 if ( result == Nes_Cpu::result_badop && cpu.r.pc != exram_addr ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
580 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
581 if ( cpu.r.pc > 0xffff ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
582 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
583 cpu.r.pc &= 0xffff; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
584 dprintf( "PC wrapped around\n" ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
585 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
586 else |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
587 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
588 cpu.r.pc = (cpu.r.pc + 1) & 0xffff; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
589 cpu.set_time( cpu.time() + 4 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
590 log_error(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
591 if ( first_illegal ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
592 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
593 first_illegal = false; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
594 dprintf( "Bad opcode $%.2x at $%.4x\n", |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
595 (int) cpu.read( cpu.r.pc ), (int) cpu.r.pc ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
596 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
597 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
598 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
599 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
600 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
601 // end time frame |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
602 duration = cpu.time(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
603 next_play -= duration; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
604 if ( next_play < 0 ) // could go negative if routine is taking too long to return |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
605 next_play = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
606 apu.end_frame( duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
607 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
608 #if !NSF_EMU_APU_ONLY |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
609 if ( namco ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
610 namco->end_frame( duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
611 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
612 if ( vrc6 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
613 vrc6->end_frame( duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
614 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
615 if ( fme7 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
616 fme7->end_frame( duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
617 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
618 #endif |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
619 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
620 return duration; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
621 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
622 |