Update file.cpp
[clinton/Virtual-Jaguar-Rx.git] / src / m68000 / cpudefs.h
CommitLineData
cf76e892
JPM
1//
2// Common definitions for the UAE 68000 core
3//
4// by James Hammons
5// (C) 2011 Underground Software
6//
7// This file is distributed under the GNU Public License, version 3 or at your
8// option any later version. Read the file GPLv3 for details.
9//
10
11#ifndef __CPUDEFS_H__
12#define __CPUDEFS_H__
13
14#include "sysdeps.h"
15
16/* Special flags */
17#define SPCFLAG_DEBUGGER 0x001
18#define SPCFLAG_STOP 0x002
19#define SPCFLAG_BUSERROR 0x004
20#define SPCFLAG_INT 0x008
21#define SPCFLAG_BRK 0x010
22#define SPCFLAG_EXTRA_CYCLES 0x020
23#define SPCFLAG_TRACE 0x040
24#define SPCFLAG_DOTRACE 0x080
25#define SPCFLAG_DOINT 0x100
26#define SPCFLAG_MFP 0x200
27#define SPCFLAG_EXEC 0x400
28#define SPCFLAG_MODE_CHANGE 0x800
29
30struct regstruct
31{
32 uint32_t regs[16];
33 uint32_t usp, isp;
34 uint16_t sr;
35 uint8_t s;
36 uint8_t stopped;
37 int intmask;
38 int intLevel;
39
40 unsigned int c;
41 unsigned int z;
42 unsigned int n;
43 unsigned int v;
44 unsigned int x;
45
46 uint32_t pc;
47 uint8_t * pc_p;
48 uint8_t * pc_oldp;
49
50 uint32_t spcflags;
51
52 uint32_t prefetch_pc;
53 uint32_t prefetch;
54
55 int32_t remainingCycles;
56 uint32_t interruptCycles;
57};
58
59extern struct regstruct regs, lastint_regs;
60
61#define m68k_dreg(r, num) ((r).regs[(num)])
62#define m68k_areg(r, num) (((r).regs + 8)[(num)])
63
64#define ZFLG (regs.z)
65#define NFLG (regs.n)
66#define CFLG (regs.c)
67#define VFLG (regs.v)
68#define XFLG (regs.x)
69
70/* Possible exceptions sources for M68000_Exception() and Exception() */
71#define M68000_EXC_SRC_CPU 1 /* Direct CPU exception */
72#define M68000_EXC_SRC_AUTOVEC 2 /* Auto-vector exception (e.g. VBL) */
73//#define M68000_EXC_SRC_INT_MFP 3 /* MFP interrupt exception */
74//#define M68000_EXC_SRC_INT_DSP 4 /* DSP interrupt exception */
75
76#define SET_CFLG(x) (CFLG = (x))
77#define SET_NFLG(x) (NFLG = (x))
78#define SET_VFLG(x) (VFLG = (x))
79#define SET_ZFLG(x) (ZFLG = (x))
80#define SET_XFLG(x) (XFLG = (x))
81
82#define GET_CFLG CFLG
83#define GET_NFLG NFLG
84#define GET_VFLG VFLG
85#define GET_ZFLG ZFLG
86#define GET_XFLG XFLG
87
88#define CLEAR_CZNV do { \
89 SET_CFLG(0); \
90 SET_ZFLG(0); \
91 SET_NFLG(0); \
92 SET_VFLG(0); \
93} while (0)
94
95#define COPY_CARRY (SET_XFLG(GET_CFLG))
96
97#endif // __CPUDEFS_H__