removing now unneeded dir from package
[drnoksnes] / sa1cpu.cpp
1 /*
2  * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
3  *
4  * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5  *                           Jerremy Koot (jkoot@snes9x.com)
6  *
7  * Super FX C emulator code 
8  * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
9  *                           Gary Henderson.
10  * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
11  *
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).
15  *
16  * DOS port code contains the works of other authors. See headers in
17  * individual files.
18  *
19  * Snes9x homepage: http://www.snes9x.com
20  *
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.
25  *
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.
29  *
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.
33  *
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
36  * in future versions.
37  *
38  * Super NES and Super Nintendo Entertainment System are trademarks of
39  * Nintendo Co., Limited and its subsidiary companies.
40  */
41
42 #include "snes9x.h"
43
44 #ifdef USE_SA1
45
46 #include "memmap.h"
47 #include "debug.h"
48 #include "missing.h"
49 #include "ppu.h"
50 #include "cpuexec.h"
51 #include "sa1.h"
52
53 #define CPU SA1
54 #define ICPU SA1
55
56 #undef Registers
57
58 #define Registers SA1Registers
59 #define S9xGetByte S9xSA1GetByte
60 #define S9xGetWord S9xSA1GetWord
61 #define S9xSetByte S9xSA1SetByte
62 #define S9xSetWord S9xSA1SetWord
63 #define S9xSetPCBase S9xSA1SetPCBase
64 #define S9xOpcodesM1X1 S9xSA1OpcodesM1X1
65 #define S9xOpcodesM1X0 S9xSA1OpcodesM1X0
66 #define S9xOpcodesM0X1 S9xSA1OpcodesM0X1
67 #define S9xOpcodesM0X0 S9xSA1OpcodesM0X0
68 #define S9xOpcode_IRQ S9xSA1Opcode_IRQ
69 #define S9xOpcode_NMI S9xSA1Opcode_NMI
70 #define S9xUnpackStatus S9xSA1UnpackStatus
71 #define S9xPackStatus S9xSA1PackStatus
72 #define S9xFixCycles S9xSA1FixCycles
73
74 #if 0
75 #define Immediate8 SA1Immediate8
76 #define Immediate16 SA1Immediate16
77 #define Relative SA1Relative
78 #define RelativeLong SA1RelativeLong
79 #define AbsoluteIndexedIndirect SA1AbsoluteIndexedIndirect
80 #define AbsoluteIndirectLong SA1AbsoluteIndirectLong
81 #define AbsoluteIndirect SA1AbsoluteIndirect
82 #define Absolute SA1Absolute
83 #define AbsoluteLong SA1AbsoluteLong
84 #define Direct SA1Direct
85 #define DirectIndirectIndexed SA1DirectIndirectIndexed
86 #define DirectIndirectIndexedLong SA1DirectIndirectIndexedLong
87 #define DirectIndexedIndirect SA1DirectIndexedIndirect
88 #define DirectIndexedX SA1DirectIndexedX
89 #define DirectIndexedY SA1DirectIndexedY
90 #define AbsoluteIndexedX SA1AbsoluteIndexedX
91 #define AbsoluteIndexedY SA1AbsoluteIndexedY
92 #define AbsoluteLongIndexedX SA1AbsoluteLongIndexedX
93 #define DirectIndirect SA1DirectIndirect
94 #define DirectIndirectLong SA1DirectIndirectLong
95 #define StackRelative SA1StackRelative
96 #define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed
97 #endif
98
99 //#undef CPU_SHUTDOWN
100 #undef VAR_CYCLES
101 #define SA1_OPCODES
102
103 #include "65c816ops.inc"
104
105 void S9xSA1MainLoop ()
106 {
107     int i;
108
109 #if 0
110     if (SA1.Flags & NMI_FLAG)
111     {
112                 SA1.Flags &= ~NMI_FLAG;
113                 if (SA1.WaitingForInterrupt)
114                 {
115                         SA1.WaitingForInterrupt = FALSE;
116                         SA1.PC++;
117                 }
118                 S9xSA1Opcode_NMI ();
119     }
120 #endif
121     if (SA1.Flags & IRQ_PENDING_FLAG)
122     {
123                 if (SA1.IRQActive)
124                 {
125                         if (SA1.WaitingForInterrupt)
126                         {
127                                 SA1.WaitingForInterrupt = FALSE;
128                                 SA1.PC++;
129                         }
130                         if (!SA1CheckFlag (IRQ))
131                                 S9xSA1Opcode_IRQ ();
132                 }
133                 else
134                         SA1.Flags &= ~IRQ_PENDING_FLAG;
135     }
136 #ifdef DEBUGGER
137     if (SA1.Flags & TRACE_FLAG)
138     {
139                 for (i = 0; i < 3 && SA1.Executing; i++)
140                 {
141                         S9xSA1Trace ();
142 #ifdef CPU_SHUTDOWN
143                     SA1.PCAtOpcodeStart = SA1.PC;
144 #endif
145                     (*SA1.S9xOpcodes [*SA1.PC++].S9xOpcode)();
146                 }
147                 return;
148     }
149 #endif
150         for (i = 0; i < 3 && SA1.Executing; i++)
151         {
152 #ifdef CPU_SHUTDOWN
153                 SA1.PCAtOpcodeStart = SA1.PC;
154 #endif
155                 (*SA1.S9xOpcodes [*SA1.PC++].S9xOpcode)();
156         }
157 }
158
159 #endif
160