deleting unneeded files and adding sa1cpu
[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 #include "snes9x.h"
42 #include "memmap.h"
43 #include "ppu.h"
44 #include "cpuexec.h"
45
46 #include "sa1.h"
47 #define CPU SA1
48 #define ICPU SA1ICPU\r
49 //#define ICPU SA1
50 #define Registers SA1Registers
51 #define S9xGetByte S9xSA1GetByte
52 #define S9xGetWord S9xSA1GetWord
53 #define S9xSetByte S9xSA1SetByte
54 #define S9xSetWord S9xSA1SetWord
55 #define S9xSetPCBase S9xSA1SetPCBase
56 #define S9xOpcodesM1X1 S9xSA1OpcodesM1X1
57 #define S9xOpcodesM1X0 S9xSA1OpcodesM1X0
58 #define S9xOpcodesM0X1 S9xSA1OpcodesM0X1
59 #define S9xOpcodesM0X0 S9xSA1OpcodesM0X0
60 #define S9xOpcode_IRQ S9xSA1Opcode_IRQ
61 #define S9xOpcode_NMI S9xSA1Opcode_NMI
62 #define S9xUnpackStatus S9xSA1UnpackStatus
63 #define S9xPackStatus S9xSA1PackStatus
64 #define S9xFixCycles S9xSA1FixCycles\r
65 //CSNES Not even used\r
66 /*
67 #define Immediate8 SA1Immediate8
68 #define Immediate16 SA1Immediate16
69 #define Relative SA1Relative
70 #define RelativeLong SA1RelativeLong
71 #define AbsoluteIndexedIndirect SA1AbsoluteIndexedIndirect
72 #define AbsoluteIndirectLong SA1AbsoluteIndirectLong
73 #define AbsoluteIndirect SA1AbsoluteIndirect
74 #define Absolute SA1Absolute
75 #define AbsoluteLong SA1AbsoluteLong
76 #define Direct SA1Direct
77 #define DirectIndirectIndexed SA1DirectIndirectIndexed
78 #define DirectIndirectIndexedLong SA1DirectIndirectIndexedLong
79 #define DirectIndexedIndirect SA1DirectIndexedIndirect
80 #define DirectIndexedX SA1DirectIndexedX
81 #define DirectIndexedY SA1DirectIndexedY
82 #define AbsoluteIndexedX SA1AbsoluteIndexedX
83 #define AbsoluteIndexedY SA1AbsoluteIndexedY
84 #define AbsoluteLongIndexedX SA1AbsoluteLongIndexedX
85 #define DirectIndirect SA1DirectIndirect
86 #define DirectIndirectLong SA1DirectIndirectLong
87 #define StackRelative SA1StackRelative
88 #define StackRelativeIndirectIndexed SA1StackRelativeIndirectIndexed\r
89 */
90
91 //#undef CPU_SHUTDOWN
92 #undef VAR_CYCLES
93 #define SA1_OPCODES
94
95 #include "cpuops.cpp"
96
97 void S9xSA1MainLoop ()
98 {
99     int i;
100
101 #if 0
102     if (SA1.Flags & NMI_FLAG)
103     {
104                 SA1.Flags &= ~NMI_FLAG;
105                 if (SA1.WaitingForInterrupt)
106                 {
107                         SA1.WaitingForInterrupt = FALSE;
108                         SA1.PC++;
109                 }
110                 S9xSA1Opcode_NMI ();
111     }
112 #endif
113     if (SA1.Flags & IRQ_PENDING_FLAG)
114     {
115                 if (SA1.IRQActive)
116                 {
117                         if (SA1.WaitingForInterrupt)
118                         {
119                                 SA1.WaitingForInterrupt = FALSE;
120                                 SA1.PC++;
121                         }
122                         if (!SA1CheckFlag (IRQ))
123                                 S9xSA1Opcode_IRQ ();
124                 }
125                 else
126                         SA1.Flags &= ~IRQ_PENDING_FLAG;
127     }
128 #ifdef DEBUGGER
129     if (SA1.Flags & TRACE_FLAG)
130     {
131                 for (i = 0; i < 3 && SA1.Executing; i++)
132                 {
133                         S9xSA1Trace ();
134 #ifdef CPU_SHUTDOWN
135                     SA1.PCAtOpcodeStart = SA1.PC;
136 #endif
137                     (*SA1.S9xOpcodes [*SA1.PC++].S9xOpcode) (&SA1Registers, &SA1ICPU, &SA1);
138                 }
139     }
140     else
141 #endif
142             for (i = 0; i < 3 && SA1.Executing; i++)
143                 {
144 #ifdef CPU_SHUTDOWN
145                         SA1.PCAtOpcodeStart = SA1.PC;
146 #endif
147                         (*SA1ICPU.S9xOpcodes [*SA1.PC++].S9xOpcode) (&SA1Registers, &SA1ICPU, &SA1);
148                 }
149 }