snes9xgx/source/snes9x/cpuexec.h

104 lines
2.3 KiB
C
Raw Normal View History

/*****************************************************************************\
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
This file is licensed under the Snes9x License.
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
2009-11-30 09:14:38 +01:00
#ifndef _CPUEXEC_H_
#define _CPUEXEC_H_
2010-01-27 23:08:56 +01:00
#include "ppu.h"
#ifdef DEBUGGER
#include "debug.h"
#endif
2010-01-27 23:08:56 +01:00
struct SOpcodes
{
void (*S9xOpcode) (void);
};
struct SICPU
{
2010-01-27 23:08:56 +01:00
struct SOpcodes *S9xOpcodes;
uint8 *S9xOpLengths;
uint8 _Carry;
uint8 _Zero;
uint8 _Negative;
uint8 _Overflow;
uint32 ShiftedPB;
uint32 ShiftedDB;
uint32 Frame;
uint32 FrameAdvanceCount;
};
2010-01-27 23:08:56 +01:00
extern struct SICPU ICPU;
2010-01-27 23:08:56 +01:00
extern struct SOpcodes S9xOpcodesE1[256];
extern struct SOpcodes S9xOpcodesM1X1[256];
extern struct SOpcodes S9xOpcodesM1X0[256];
extern struct SOpcodes S9xOpcodesM0X1[256];
extern struct SOpcodes S9xOpcodesM0X0[256];
extern struct SOpcodes S9xOpcodesSlow[256];
extern uint8 S9xOpLengthsM1X1[256];
extern uint8 S9xOpLengthsM1X0[256];
extern uint8 S9xOpLengthsM0X1[256];
extern uint8 S9xOpLengthsM0X0[256];
void S9xMainLoop (void);
void S9xReset (void);
void S9xSoftReset (void);
2010-01-27 23:08:56 +01:00
void S9xDoHEventProcessing (void);
2010-01-27 23:08:56 +01:00
static inline void S9xUnpackStatus (void)
{
2010-01-27 23:08:56 +01:00
ICPU._Zero = (Registers.PL & Zero) == 0;
ICPU._Negative = (Registers.PL & Negative);
ICPU._Carry = (Registers.PL & Carry);
ICPU._Overflow = (Registers.PL & Overflow) >> 6;
}
2010-01-27 23:08:56 +01:00
static inline void S9xPackStatus (void)
{
2010-01-27 23:08:56 +01:00
Registers.PL &= ~(Zero | Negative | Carry | Overflow);
Registers.PL |= ICPU._Carry | ((ICPU._Zero == 0) << 1) | (ICPU._Negative & 0x80) | (ICPU._Overflow << 6);
}
2010-01-27 23:08:56 +01:00
static inline void S9xFixCycles (void)
{
2010-01-27 23:08:56 +01:00
if (CheckEmulation())
{
2010-01-27 23:08:56 +01:00
ICPU.S9xOpcodes = S9xOpcodesE1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
}
else
2010-01-27 23:08:56 +01:00
if (CheckMemory())
{
2010-01-27 23:08:56 +01:00
if (CheckIndex())
{
ICPU.S9xOpcodes = S9xOpcodesM1X1;
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
}
else
{
ICPU.S9xOpcodes = S9xOpcodesM1X0;
ICPU.S9xOpLengths = S9xOpLengthsM1X0;
}
}
else
{
2010-01-27 23:08:56 +01:00
if (CheckIndex())
{
ICPU.S9xOpcodes = S9xOpcodesM0X1;
ICPU.S9xOpLengths = S9xOpLengthsM0X1;
}
else
{
ICPU.S9xOpcodes = S9xOpcodesM0X0;
ICPU.S9xOpLengths = S9xOpLengthsM0X0;
}
}
}
#endif