annotate src/console/Spc_Cpu.cxx @ 3030:c442f8407dcb

Show playlist popup information reliably (Debian bug #460802)
author John Lindgren <john.lindgren@tds.net>
date Fri, 10 Apr 2009 01:46:08 -0400
parents c31e94fefd2a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
1 // Core SPC emulation: CPU, timers, SMP registers, memory
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
3 // snes_spc 0.9.0. http://www.slack.net/~ant/
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 #include "Snes_Spc.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
7 #include <string.h>
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
8
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
9 /* Copyright (C) 2004-2007 Shay Green. This module is free software; you
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 can redistribute it and/or modify it under the terms of the GNU Lesser
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 General Public License as published by the Free Software Foundation; either
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 version 2.1 of the License, or (at your option) any later version. This
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 module is distributed in the hope that it will be useful, but WITHOUT ANY
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
16 details. You should have received a copy of the GNU Lesser General Public
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
17 License along with this module; if not, write to the Free Software Foundation,
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
20 #include "blargg_source.h"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
22 #define RAM (m.ram.ram)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
23 #define REGS (m.smp_regs [0])
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
24 #define REGS_IN (m.smp_regs [1])
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
25
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
26 // (n ? n : 256)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
27 #define IF_0_THEN_256( n ) ((uint8_t) ((n) - 1) + 1)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
28
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
29 // Note: SPC_MORE_ACCURACY exists mainly so I can run my validation tests, which
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
30 // do crazy echo buffer accesses.
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
31 #ifndef SPC_MORE_ACCURACY
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
32 #define SPC_MORE_ACCURACY 0
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
33 #endif
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
34
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
35 #ifdef BLARGG_ENABLE_OPTIMIZER
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
36 #include BLARGG_ENABLE_OPTIMIZER
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
37 #endif
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
38
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
39
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
40 //// Timers
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
42 #if SPC_DISABLE_TEMPO
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
43 #define TIMER_DIV( t, n ) ((n) >> t->prescaler)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
44 #define TIMER_MUL( t, n ) ((n) << t->prescaler)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
45 #else
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
46 #define TIMER_DIV( t, n ) ((n) / t->prescaler)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
47 #define TIMER_MUL( t, n ) ((n) * t->prescaler)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
48 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
50 Snes_Spc::Timer* Snes_Spc::run_timer_( Timer* t, rel_time_t time )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
52 int elapsed = TIMER_DIV( t, time - t->next_time ) + 1;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
53 t->next_time += TIMER_MUL( t, elapsed );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
54
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
55 if ( t->enabled )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
56 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
57 int remain = IF_0_THEN_256( t->period - t->divider );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
58 int divider = t->divider + elapsed;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
59 int over = elapsed - remain;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
60 if ( over >= 0 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
61 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
62 int n = over / t->period;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
63 t->counter = (t->counter + 1 + n) & 0x0F;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
64 divider = over - n * t->period;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
65 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
66 t->divider = (uint8_t) divider;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
67 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
68 return t;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
69 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
70
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
71 inline Snes_Spc::Timer* Snes_Spc::run_timer( Timer* t, rel_time_t time )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
72 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
73 if ( time >= t->next_time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
74 t = run_timer_( t, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
75 return t;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
76 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
77
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
78
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
79 //// ROM
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
80
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
81 void Snes_Spc::enable_rom( int enable )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
83 if ( m.rom_enabled != enable )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
84 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
85 m.rom_enabled = enable;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
86 if ( enable )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
87 memcpy( m.hi_ram, &RAM [rom_addr], sizeof m.hi_ram );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
88 memcpy( &RAM [rom_addr], (enable ? m.rom : m.hi_ram), rom_size );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
89 // TODO: ROM can still get overwritten when DSP writes to echo buffer
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
90 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
92
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
94 //// DSP
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
96 #if SPC_LESS_ACCURATE
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
97 int const max_reg_time = 29;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
98
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
99 signed char const Snes_Spc::reg_times_ [256] =
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
100 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
101 -1, 0,-11,-10,-15,-11, -2, -2, 4, 3, 14, 14, 26, 26, 14, 22,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
102 2, 3, 0, 1,-12, 0, 1, 1, 7, 6, 14, 14, 27, 14, 14, 23,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
103 5, 6, 3, 4, -1, 3, 4, 4, 10, 9, 14, 14, 26, -5, 14, 23,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
104 8, 9, 6, 7, 2, 6, 7, 7, 13, 12, 14, 14, 27, -4, 14, 24,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
105 11, 12, 9, 10, 5, 9, 10, 10, 16, 15, 14, 14, -2, -4, 14, 24,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
106 14, 15, 12, 13, 8, 12, 13, 13, 19, 18, 14, 14, -2,-36, 14, 24,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
107 17, 18, 15, 16, 11, 15, 16, 16, 22, 21, 14, 14, 28, -3, 14, 25,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
108 20, 21, 18, 19, 14, 18, 19, 19, 25, 24, 14, 14, 14, 29, 14, 25,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
109
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
110 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
111 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
112 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
113 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
114 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
115 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
116 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
117 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
118 };
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
119
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
120 #define RUN_DSP( time, offset ) \
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
121 int count = (time) - (offset) - m.dsp_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
122 if ( count >= 0 )\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
123 {\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
124 int clock_count = (count & ~(clocks_per_sample - 1)) + clocks_per_sample;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
125 m.dsp_time += clock_count;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
126 dsp.run( clock_count );\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
127 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
128 #else
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
129 #define RUN_DSP( time, offset ) \
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
130 {\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
131 int count = (time) - m.dsp_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
132 if ( !SPC_MORE_ACCURACY || count )\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
133 {\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
134 assert( count > 0 );\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
135 m.dsp_time = (time);\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
136 dsp.run( count );\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
137 }\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
138 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
139 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
140
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
141 int Snes_Spc::dsp_read( rel_time_t time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
142 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
143 RUN_DSP( time, reg_times [REGS [r_dspaddr] & 0x7F] );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
144
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
145 int result = dsp.read( REGS [r_dspaddr] & 0x7F );
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
146
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
147 #ifdef SPC_DSP_READ_HOOK
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
148 SPC_DSP_READ_HOOK( spc_time + time, (REGS [r_dspaddr] & 0x7F), result );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
149 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
150
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
151 return result;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
152 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
153
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
154 inline void Snes_Spc::dsp_write( int data, rel_time_t time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
155 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
156 RUN_DSP( time, reg_times [REGS [r_dspaddr]] )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
157 #if SPC_LESS_ACCURATE
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
158 else if ( m.dsp_time == skipping_time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
159 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
160 int r = REGS [r_dspaddr];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
161 if ( r == Spc_Dsp::r_kon )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
162 m.skipped_kon |= data & ~dsp.read( Spc_Dsp::r_koff );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
163
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
164 if ( r == Spc_Dsp::r_koff )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
165 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
166 m.skipped_koff |= data;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
167 m.skipped_kon &= ~data;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
168 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
169 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
170 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
171
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
172 #ifdef SPC_DSP_WRITE_HOOK
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
173 SPC_DSP_WRITE_HOOK( m.spc_time + time, REGS [r_dspaddr], (uint8_t) data );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
174 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
175
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
176 if ( REGS [r_dspaddr] <= 0x7F )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
177 dsp.write( REGS [r_dspaddr], data );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
178 else if ( !SPC_MORE_ACCURACY )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
179 dprintf( "SPC wrote to DSP register > $7F\n" );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
180 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
181
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
182
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
183 //// Memory access extras
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
184
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
185 #if SPC_MORE_ACCURACY
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
186 #define MEM_ACCESS( time, addr ) \
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
187 {\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
188 if ( time >= m.dsp_time )\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
189 {\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
190 RUN_DSP( time, max_reg_time );\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
191 }\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
192 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
193 #elif !defined (NDEBUG)
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
194 // Debug-only check for read/write within echo buffer, since this might result in
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
195 // inaccurate emulation due to the DSP not being caught up to the present.
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
196
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
197 bool Snes_Spc::check_echo_access( int addr )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
199 if ( !(dsp.read( Spc_Dsp::r_flg ) & 0x20) )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
200 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
201 int start = 0x100 * dsp.read( Spc_Dsp::r_esa );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
202 int size = 0x800 * (dsp.read( Spc_Dsp::r_edl ) & 0x0F);
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
203 int end = start + (size ? size : 4);
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
204 if ( start <= addr && addr < end )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
205 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
206 if ( !m.echo_accessed )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
207 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
208 m.echo_accessed = 1;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
209 return true;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
210 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
211 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212 }
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
213 return false;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
215
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
216 #define MEM_ACCESS( time, addr ) check( !check_echo_access( (uint16_t) addr ) );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
217 #else
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
218 #define MEM_ACCESS( time, addr )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
219 #endif
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
220
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
221
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
222 //// CPU write
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
224 #if SPC_MORE_ACCURACY
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
225 static unsigned char const glitch_probs [3] [256] =
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
226 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
227 0xC3,0x92,0x5B,0x1C,0xD1,0x92,0x5B,0x1C,0xDB,0x9C,0x72,0x18,0xCD,0x5C,0x38,0x0B,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
228 0xE1,0x9C,0x74,0x17,0xCF,0x75,0x45,0x0C,0xCF,0x6E,0x4A,0x0D,0xA3,0x3A,0x1D,0x08,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
229 0xDB,0xA0,0x82,0x19,0xD9,0x73,0x3C,0x0E,0xCB,0x76,0x52,0x0B,0xA5,0x46,0x1D,0x09,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
230 0xDA,0x74,0x55,0x0F,0xA2,0x3F,0x21,0x05,0x9A,0x40,0x20,0x07,0x63,0x1E,0x10,0x01,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
231 0xDF,0xA9,0x85,0x1D,0xD3,0x84,0x4B,0x0E,0xCF,0x6F,0x49,0x0F,0xB3,0x48,0x1E,0x05,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
232 0xD8,0x77,0x52,0x12,0xB7,0x49,0x23,0x06,0xAA,0x45,0x28,0x07,0x7D,0x28,0x0F,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
233 0xCC,0x7B,0x4A,0x0E,0xB2,0x4F,0x24,0x07,0xAD,0x43,0x2C,0x06,0x86,0x29,0x11,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
234 0xAE,0x48,0x1F,0x0A,0x76,0x21,0x19,0x05,0x76,0x21,0x14,0x05,0x44,0x11,0x0B,0x01,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
235 0xE7,0xAD,0x96,0x23,0xDC,0x86,0x59,0x0E,0xDC,0x7C,0x5F,0x15,0xBB,0x53,0x2E,0x09,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
236 0xD6,0x7C,0x4A,0x16,0xBB,0x4A,0x25,0x08,0xB3,0x4F,0x28,0x0B,0x8E,0x23,0x15,0x08,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
237 0xCF,0x7F,0x57,0x11,0xB5,0x4A,0x23,0x0A,0xAA,0x42,0x28,0x05,0x7D,0x22,0x12,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
238 0xA6,0x49,0x28,0x09,0x82,0x2B,0x0D,0x04,0x7A,0x20,0x0F,0x04,0x3D,0x0F,0x09,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
239 0xD1,0x7C,0x4C,0x0F,0xAF,0x4E,0x21,0x09,0xA8,0x46,0x2A,0x07,0x85,0x1F,0x0E,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
240 0xA6,0x3F,0x26,0x07,0x7C,0x24,0x14,0x07,0x78,0x22,0x16,0x04,0x46,0x12,0x0A,0x02,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
241 0xA6,0x41,0x2C,0x0A,0x7E,0x28,0x11,0x05,0x73,0x1B,0x14,0x05,0x3D,0x11,0x0A,0x02,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
242 0x70,0x22,0x17,0x05,0x48,0x13,0x08,0x03,0x3C,0x07,0x0D,0x07,0x26,0x07,0x06,0x01,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
243
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
244 0xE0,0x9F,0xDA,0x7C,0x4F,0x18,0x28,0x0D,0xE9,0x9F,0xDA,0x7C,0x4F,0x18,0x1F,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
245 0xE6,0x97,0xD8,0x72,0x64,0x13,0x26,0x09,0xDC,0x67,0xA9,0x38,0x21,0x07,0x15,0x06,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
246 0xE9,0x91,0xD2,0x6B,0x63,0x14,0x2B,0x0E,0xD6,0x61,0xB7,0x41,0x2B,0x0E,0x10,0x09,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
247 0xCF,0x59,0xB0,0x2F,0x35,0x08,0x0F,0x07,0xB6,0x30,0x7A,0x21,0x17,0x07,0x09,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
248 0xE7,0xA3,0xE5,0x6B,0x65,0x1F,0x34,0x09,0xD8,0x6B,0xBE,0x45,0x27,0x07,0x10,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
249 0xDA,0x54,0xB1,0x39,0x2E,0x0E,0x17,0x08,0xA9,0x3C,0x86,0x22,0x16,0x06,0x07,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
250 0xD4,0x51,0xBC,0x3D,0x38,0x0A,0x13,0x06,0xB2,0x37,0x79,0x1C,0x17,0x05,0x0E,0x06,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
251 0xA7,0x31,0x74,0x1C,0x11,0x06,0x0C,0x02,0x6D,0x1A,0x38,0x10,0x0B,0x05,0x06,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
252 0xEB,0x9A,0xE1,0x7A,0x6F,0x13,0x34,0x0E,0xE6,0x75,0xC5,0x45,0x3E,0x0B,0x1A,0x05,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
253 0xD8,0x63,0xC1,0x40,0x3C,0x1B,0x19,0x06,0xB3,0x42,0x83,0x29,0x18,0x0A,0x08,0x04,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
254 0xD4,0x58,0xBA,0x43,0x3F,0x0A,0x1F,0x09,0xB1,0x33,0x8A,0x1F,0x1F,0x06,0x0D,0x05,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
255 0xAF,0x3C,0x7A,0x1F,0x16,0x08,0x0A,0x01,0x72,0x1B,0x52,0x0D,0x0B,0x09,0x06,0x01,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
256 0xCF,0x63,0xB7,0x47,0x40,0x10,0x14,0x06,0xC0,0x41,0x96,0x20,0x1C,0x09,0x10,0x05,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
257 0xA6,0x35,0x82,0x1A,0x20,0x0C,0x0E,0x04,0x80,0x1F,0x53,0x0F,0x0B,0x02,0x06,0x01,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
258 0xA6,0x31,0x81,0x1B,0x1D,0x01,0x08,0x08,0x7B,0x20,0x4D,0x19,0x0E,0x05,0x07,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
259 0x6B,0x17,0x49,0x07,0x0E,0x03,0x0A,0x05,0x37,0x0B,0x1F,0x06,0x04,0x02,0x07,0x01,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
260
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
261 0xF0,0xD6,0xED,0xAD,0xEC,0xB1,0xEB,0x79,0xAC,0x22,0x47,0x1E,0x6E,0x1B,0x32,0x0A,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
262 0xF0,0xD6,0xEA,0xA4,0xED,0xC4,0xDE,0x82,0x98,0x1F,0x50,0x13,0x52,0x15,0x2A,0x0A,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
263 0xF1,0xD1,0xEB,0xA2,0xEB,0xB7,0xD8,0x69,0xA2,0x1F,0x5B,0x18,0x55,0x18,0x2C,0x0A,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
264 0xED,0xB5,0xDE,0x7E,0xE6,0x85,0xD3,0x59,0x59,0x0F,0x2C,0x09,0x24,0x07,0x15,0x09,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
265 0xF1,0xD6,0xEA,0xA0,0xEC,0xBB,0xDA,0x77,0xA9,0x23,0x58,0x14,0x5D,0x12,0x2F,0x09,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
266 0xF1,0xC1,0xE3,0x86,0xE4,0x87,0xD2,0x4E,0x68,0x15,0x26,0x0B,0x27,0x09,0x15,0x02,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
267 0xEE,0xA6,0xE0,0x5C,0xE0,0x77,0xC3,0x41,0x67,0x1B,0x3C,0x07,0x2A,0x06,0x19,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
268 0xE4,0x75,0xC6,0x43,0xCC,0x50,0x95,0x23,0x35,0x09,0x14,0x04,0x15,0x05,0x0B,0x04,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
269 0xEE,0xD6,0xED,0xAD,0xEC,0xB1,0xEB,0x79,0xAC,0x22,0x56,0x14,0x5A,0x12,0x26,0x0A,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
270 0xEE,0xBB,0xE7,0x7E,0xE9,0x8D,0xCB,0x49,0x67,0x11,0x34,0x07,0x2B,0x0B,0x14,0x07,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
271 0xED,0xA7,0xE5,0x76,0xE3,0x7E,0xC4,0x4B,0x77,0x14,0x34,0x08,0x27,0x07,0x14,0x04,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
272 0xE7,0x8B,0xD2,0x4C,0xCA,0x56,0x9E,0x31,0x36,0x0C,0x11,0x07,0x14,0x04,0x0A,0x02,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
273 0xF0,0x9B,0xEA,0x6F,0xE5,0x81,0xC4,0x43,0x74,0x10,0x30,0x0B,0x2D,0x08,0x1B,0x06,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
274 0xE6,0x83,0xCA,0x48,0xD9,0x56,0xA7,0x23,0x3B,0x09,0x12,0x09,0x15,0x07,0x0A,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
275 0xE5,0x5F,0xCB,0x3C,0xCF,0x48,0x91,0x22,0x31,0x0A,0x17,0x08,0x15,0x04,0x0D,0x02,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
276 0xD1,0x43,0x91,0x20,0xA9,0x2D,0x54,0x12,0x17,0x07,0x09,0x02,0x0C,0x04,0x05,0x03,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
277 };
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
278 #endif
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
279
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
280 // divided into multiple functions to keep rarely-used functionality separate
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
281 // so often-used functionality can be optimized better by compiler
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
282
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
283 // If write isn't preceded by read, data has this added to it
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
284 int const no_read_before_write = 0x2000;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
285
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
286 void Snes_Spc::cpu_write_smp_reg_( int data, rel_time_t time, int addr )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
287 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
288 switch ( addr )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
290 case r_t0target:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
291 case r_t1target:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
292 case r_t2target: {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
293 Timer* t = &m.timers [addr - r_t0target];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
294 int period = IF_0_THEN_256( data );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
295 if ( t->period != period )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
296 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
297 t = run_timer( t, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
298 #if SPC_MORE_ACCURACY
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
299 // Insane behavior when target is written just after counter is
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
300 // clocked and counter matches new period and new period isn't 1, 2, 4, or 8
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
301 if ( t->divider == (period & 0xFF) &&
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
302 t->next_time == time + TIMER_MUL( t, 1 ) &&
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
303 ((period - 1) | ~0x0F) & period )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
304 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
305 //dprintf( "SPC pathological timer target write\n" );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
306
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
307 // If the period is 3, 5, or 9, there's a probability this behavior won't occur,
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
308 // based on the previous period
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
309 int prob = 0xFF;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
310 int old_period = t->period & 0xFF;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
311 if ( period == 3 ) prob = glitch_probs [0] [old_period];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
312 if ( period == 5 ) prob = glitch_probs [1] [old_period];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
313 if ( period == 9 ) prob = glitch_probs [2] [old_period];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
314
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
315 // The glitch suppresses incrementing of one of the counter bits, based on
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
316 // the lowest set bit in the new period
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
317 int b = 1;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
318 while ( !(period & b) )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
319 b <<= 1;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
320
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
321 if ( (rand() >> 4 & 0xFF) <= prob )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
322 t->divider = (t->divider - b) & 0xFF;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
323 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
324 #endif
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
325 t->period = period;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 }
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
327 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
329
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
330 case r_t0out:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
331 case r_t1out:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
332 case r_t2out:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
333 if ( !SPC_MORE_ACCURACY )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
334 dprintf( "SPC wrote to counter %d\n", (int) addr - r_t0out );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
335
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
336 if ( data < no_read_before_write / 2 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
337 run_timer( &m.timers [addr - r_t0out], time - 1 )->counter = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
338 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
340 // Registers that act like RAM
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
341 case 0x8:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
342 case 0x9:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
343 REGS_IN [addr] = (uint8_t) data;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
344 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
346 case r_test:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
347 if ( (uint8_t) data != 0x0A )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
348 dprintf( "SPC wrote to test register\n" );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
349 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
350
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
351 case r_control:
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
352 // port clears
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
353 if ( data & 0x10 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
354 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
355 REGS_IN [r_cpuio0] = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
356 REGS_IN [r_cpuio1] = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
357 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
358 if ( data & 0x20 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
359 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
360 REGS_IN [r_cpuio2] = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
361 REGS_IN [r_cpuio3] = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
362 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
363
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
364 // timers
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
365 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
366 for ( int i = 0; i < timer_count; i++ )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
367 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
368 Timer* t = &m.timers [i];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
369 int enabled = data >> i & 1;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
370 if ( t->enabled != enabled )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
371 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
372 t = run_timer( t, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
373 t->enabled = enabled;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
374 if ( enabled )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
375 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
376 t->divider = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
377 t->counter = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
378 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
379 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
380 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
381 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
382 enable_rom( data & 0x80 );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
383 break;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
384 }
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
385 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
386
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
387 void Snes_Spc::cpu_write_smp_reg( int data, rel_time_t time, int addr )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
388 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
389 if ( addr == r_dspdata ) // 99%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
390 dsp_write( data, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
391 else
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
392 cpu_write_smp_reg_( data, time, addr );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
393 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
394
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
395 void Snes_Spc::cpu_write_high( int data, int i, rel_time_t time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
396 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
397 if ( i < rom_size )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
398 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
399 m.hi_ram [i] = (uint8_t) data;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
400 if ( m.rom_enabled )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
401 RAM [i + rom_addr] = m.rom [i]; // restore overwritten ROM
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 316
diff changeset
402 }
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
403 else
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
404 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
405 assert( RAM [i + rom_addr] == (uint8_t) data );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
406 RAM [i + rom_addr] = cpu_pad_fill; // restore overwritten padding
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
407 cpu_write( data, i + rom_addr - 0x10000, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
408 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
409 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
410
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
411 int const bits_in_int = CHAR_BIT * sizeof (int);
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
412
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
413 void Snes_Spc::cpu_write( int data, int addr, rel_time_t time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
414 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
415 MEM_ACCESS( time, addr )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
416
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
417 // RAM
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
418 RAM [addr] = (uint8_t) data;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
419 int reg = addr - 0xF0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
420 if ( reg >= 0 ) // 64%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
421 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
422 // $F0-$FF
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
423 if ( reg < reg_count ) // 87%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
424 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
425 REGS [reg] = (uint8_t) data;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
426
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
427 // Ports
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
428 #ifdef SPC_PORT_WRITE_HOOK
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
429 if ( (unsigned) (reg - r_cpuio0) < port_count )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
430 SPC_PORT_WRITE_HOOK( m.spc_time + time, (reg - r_cpuio0),
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
431 (uint8_t) data, &REGS [r_cpuio0] );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
432 #endif
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
433
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
434 // Registers other than $F2 and $F4-$F7
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
435 //if ( reg != 2 && reg != 4 && reg != 5 && reg != 6 && reg != 7 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
436 // TODO: this is a bit on the fragile side
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
437 if ( ((~0x2F00 << (bits_in_int - 16)) << reg) < 0 ) // 36%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
438 cpu_write_smp_reg( data, time, reg );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
439 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
440 // High mem/address wrap-around
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
441 else
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
442 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
443 reg -= rom_addr - 0xF0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
444 if ( reg >= 0 ) // 1% in IPL ROM area or address wrapped around
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
445 cpu_write_high( data, reg, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
446 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
447 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
448 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
449
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
450
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
451 //// CPU read
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
452
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
453 inline int Snes_Spc::cpu_read_smp_reg( int reg, rel_time_t time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
454 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
455 int result = REGS_IN [reg];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
456 reg -= r_dspaddr;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
457 // DSP addr and data
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
458 if ( (unsigned) reg <= 1 ) // 4% 0xF2 and 0xF3
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
459 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
460 result = REGS [r_dspaddr];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
461 if ( (unsigned) reg == 1 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
462 result = dsp_read( time ); // 0xF3
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
463 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
464 return result;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
465 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
466
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
467 int Snes_Spc::cpu_read( int addr, rel_time_t time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
468 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
469 MEM_ACCESS( time, addr )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
470
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
471 // RAM
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
472 int result = RAM [addr];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
473 int reg = addr - 0xF0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
474 if ( reg >= 0 ) // 40%
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
475 {
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
476 reg -= 0x10;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
477 if ( (unsigned) reg >= 0xFF00 ) // 21%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
478 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
479 reg += 0x10 - r_t0out;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
480
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
481 // Timers
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
482 if ( (unsigned) reg < timer_count ) // 90%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
483 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
484 Timer* t = &m.timers [reg];
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
485 if ( time >= t->next_time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
486 t = run_timer_( t, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
487 result = t->counter;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
488 t->counter = 0;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
489 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
490 // Other registers
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
491 else if ( reg < 0 ) // 10%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
492 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
493 result = cpu_read_smp_reg( reg + r_t0out, time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
494 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
495 else // 1%
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
496 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
497 assert( reg + (r_t0out + 0xF0 - 0x10000) < 0x100 );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
498 result = cpu_read( reg + (r_t0out + 0xF0 - 0x10000), time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
499 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
500 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
501 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
502
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
503 return result;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
504 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
505
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
506
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
507 //// Run
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
508
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
509 // Prefix and suffix for CPU emulator function
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
510 #define SPC_CPU_RUN_FUNC \
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
511 BOOST::uint8_t* Snes_Spc::run_until_( time_t end_time )\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
512 {\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
513 rel_time_t rel_time = m.spc_time - end_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
514 assert( rel_time <= 0 );\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
515 m.spc_time = end_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
516 m.dsp_time += rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
517 m.timers [0].next_time += rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
518 m.timers [1].next_time += rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
519 m.timers [2].next_time += rel_time;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
520
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
521 #define SPC_CPU_RUN_FUNC_END \
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
522 m.spc_time += rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
523 m.dsp_time -= rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
524 m.timers [0].next_time -= rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
525 m.timers [1].next_time -= rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
526 m.timers [2].next_time -= rel_time;\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
527 assert( m.spc_time <= end_time );\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
528 return &REGS [r_cpuio0];\
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
529 }
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
530
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
531 int const cpu_lag_max = 12 - 1; // DIV YA,X takes 12 clocks
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
532
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
533 void Snes_Spc::end_frame( time_t end_time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
534 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
535 // Catch CPU up to as close to end as possible. If final instruction
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
536 // would exceed end, does NOT execute it and leaves m.spc_time < end.
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
537 if ( end_time > m.spc_time )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
538 run_until_( end_time );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
539
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
540 m.spc_time -= end_time;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
541 m.extra_clocks += end_time;
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
542
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
543 // Greatest number of clocks early that emulation can stop early due to
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
544 // not being able to execute current instruction without going over
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
545 // allowed time.
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
546 assert( -cpu_lag_max <= m.spc_time && m.spc_time <= 0 );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
547
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
548 // Catch timers up to CPU
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
549 for ( int i = 0; i < timer_count; i++ )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
550 run_timer( &m.timers [i], 0 );
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
551
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
552 // Catch DSP up to CPU
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
553 if ( m.dsp_time < 0 )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
554 {
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
555 RUN_DSP( 0, max_reg_time );
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
556 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
557
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
558 // Save any extra samples beyond what should be generated
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
559 if ( m.buf_begin )
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
560 save_extra();
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
561 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
562
1037
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
563 // Inclusion here allows static memory access functions and better optimization
c31e94fefd2a [svn] - upstream updates regarding handling of SPC700 instructions and runtime
nenolod
parents: 341
diff changeset
564 #include "Spc_Cpu.h"