2 * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
4 * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5 * Jerremy Koot (jkoot@snes9x.com)
7 * Super FX C emulator code
8 * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
10 * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
12 * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13 * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14 * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
16 * DOS port code contains the works of other authors. See headers in
19 * Snes9x homepage: http://www.snes9x.com
21 * Permission to use, copy, modify and distribute Snes9x in both binary and
22 * source form, for non-commercial purposes, is hereby granted without fee,
23 * providing that this license information and copyright notice appear with
24 * all copies and any derived work.
26 * This software is provided 'as-is', without any express or implied
27 * warranty. In no event shall the authors be held liable for any damages
28 * arising from the use of this software.
30 * Snes9x is freeware for PERSONAL USE only. Commercial users should
31 * seek permission of the copyright holders first. Commercial use includes
32 * charging money for Snes9x or software derived from Snes9x.
34 * The copyright holders request that bug fixes and improvements to the code
35 * should be forwarded to them so everyone can benefit from the modifications
38 * Super NES and Super Nintendo Entertainment System are trademarks of
39 * Nintendo Co., Limited and its subsidiary companies.
46 extern uint8 APUROM[64];
49 INLINE uint8 S9xAPUGetByteZ (uint8 Address)
51 if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM)
53 if (Address >= 0xf4 && Address <= 0xf7)
55 #ifdef SPC700_SHUTDOWN
56 IAPU.WaitAddress2 = IAPU.WaitAddress1;
57 IAPU.WaitAddress1 = IAPU.PC;
59 return (IAPU.RAM [Address]);
63 #ifdef SPC700_SHUTDOWN
64 IAPU.WaitAddress2 = IAPU.WaitAddress1;
65 IAPU.WaitAddress1 = IAPU.PC;
67 uint8 t = IAPU.RAM [Address];
68 IAPU.RAM [Address] = 0;
73 return (S9xGetAPUDSP ());
75 return (IAPU.RAM [Address]);
78 return (IAPU.DirectPage [Address]);
81 INLINE void S9xAPUSetByteZ (uint8 val, uint8 Address)
83 if (Address >= 0xf0 && IAPU.DirectPage == IAPU.RAM)
88 if (Address >= 0xf4 && Address <= 0xf7)
89 APU.OutPorts [Address - 0xf4] = val;
92 S9xSetAPUControl (val);
96 IAPU.RAM [Address] = val;
100 APU.TimerTarget [Address - 0xfa] = 0x100;
102 APU.TimerTarget [Address - 0xfa] = val;
107 IAPU.DirectPage [Address] = val;
110 INLINE uint8 S9xAPUGetByte (uint32 Address)
114 if (Address <= 0xff && Address >= 0xf0)
116 if (Address >= 0xf4 && Address <= 0xf7)
118 #ifdef SPC700_SHUTDOWN
119 IAPU.WaitAddress2 = IAPU.WaitAddress1;
120 IAPU.WaitAddress1 = IAPU.PC;
122 return (IAPU.RAM [Address]);
126 return (S9xGetAPUDSP ());
129 #ifdef SPC700_SHUTDOWN
130 IAPU.WaitAddress2 = IAPU.WaitAddress1;
131 IAPU.WaitAddress1 = IAPU.PC;
133 uint8 t = IAPU.RAM [Address];
134 IAPU.RAM [Address] = 0;
137 return (IAPU.RAM [Address]);
140 return (IAPU.RAM [Address]);
143 INLINE void S9xAPUSetByte (uint8 val, uint32 Address)
147 if (Address <= 0xff && Address >= 0xf0)
152 if (Address >= 0xf4 && Address <= 0xf7)
153 APU.OutPorts [Address - 0xf4] = val;
156 S9xSetAPUControl (val);
160 IAPU.RAM [Address] = val;
164 APU.TimerTarget [Address - 0xfa] = 0x100;
166 APU.TimerTarget [Address - 0xfa] = val;
173 if (Address >= 0x2500 && Address <= 0x2504)
174 printf ("%06d %04x <- %02x\n", ICPU.Scanline, Address, val);
175 if (Address == 0x26c6)
177 extern FILE *apu_trace;
179 APU.Flags |= TRACE_FLAG;
180 CPU.Flags |= TRACE_FLAG;
181 if (apu_trace == NULL)
182 apu_trace = fopen ("aputrace.log", "wb");
184 trace = fopen ("trace.log", "wb");
185 printf ("TRACING SWITCHED ON\n");
188 if (Address < 0xffc0)
189 IAPU.RAM [Address] = val;
192 APU.ExtraRAM [Address - 0xffc0] = val;
194 IAPU.RAM [Address] = val;