2018-12-03 12:26:02 +01:00
|
|
|
/*****************************************************************************\
|
|
|
|
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
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
#ifndef _CPUEXEC_H_
|
|
|
|
#define _CPUEXEC_H_
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
#include "ppu.h"
|
2018-11-12 00:57:16 +01:00
|
|
|
#ifdef DEBUGGER
|
|
|
|
#include "debug.h"
|
|
|
|
#endif
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
struct SOpcodes
|
|
|
|
{
|
|
|
|
void (*S9xOpcode) (void);
|
2008-08-06 03:09:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2008-08-06 03:09:59 +02:00
|
|
|
};
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
extern struct SICPU ICPU;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
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];
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
void S9xMainLoop (void);
|
|
|
|
void S9xReset (void);
|
|
|
|
void S9xSoftReset (void);
|
2010-01-27 23:08:56 +01:00
|
|
|
void S9xDoHEventProcessing (void);
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static inline void S9xUnpackStatus (void)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
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;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static inline void S9xPackStatus (void)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
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);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2010-01-27 23:08:56 +01:00
|
|
|
static inline void S9xFixCycles (void)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
if (CheckEmulation())
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
ICPU.S9xOpcodes = S9xOpcodesE1;
|
|
|
|
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
else
|
2010-01-27 23:08:56 +01:00
|
|
|
if (CheckMemory())
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
if (CheckIndex())
|
|
|
|
{
|
|
|
|
ICPU.S9xOpcodes = S9xOpcodesM1X1;
|
|
|
|
ICPU.S9xOpLengths = S9xOpLengthsM1X1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ICPU.S9xOpcodes = S9xOpcodesM1X0;
|
|
|
|
ICPU.S9xOpLengths = S9xOpLengthsM1X0;
|
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-27 23:08:56 +01:00
|
|
|
if (CheckIndex())
|
|
|
|
{
|
|
|
|
ICPU.S9xOpcodes = S9xOpcodesM0X1;
|
|
|
|
ICPU.S9xOpLengths = S9xOpLengthsM0X1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ICPU.S9xOpcodes = S9xOpcodesM0X0;
|
|
|
|
ICPU.S9xOpLengths = S9xOpLengthsM0X0;
|
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|