OpenCores
URL https://opencores.org/ocsvn/ao68000/ao68000/trunk

Subversion Repositories ao68000

[/] [ao68000/] [trunk/] [tests/] [compare_with_winuae/] [winuae/] [ao.h] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 alfik
/*
2
 * Copyright 2010, Aleksander Osman, alfik@poczta.fm. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without modification, are
5
 * permitted provided that the following conditions are met:
6
 *
7
 *  1. Redistributions of source code must retain the above copyright notice, this list of
8
 *     conditions and the following disclaimer.
9
 *
10
 *  2. Redistributions in binary form must reproduce the above copyright notice, this list
11
 *     of conditions and the following disclaimer in the documentation and/or other materials
12
 *     provided with the distribution.
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 */
24
 
25
#ifndef __AO_H__
26
#define __AO_H__
27
 
28
#include <stdio.h>
29
#include <stdlib.h>
30
#include <stdarg.h>
31
#include <string.h>
32
#include <wchar.h>
33
#include <assert.h>
34
 
35
//from sysdeps.h -----------------------
36
 
37
#define ENUMDECL typedef enum
38
#define ENUMNAME(name) name
39
 
40
typedef unsigned char uae_u8;
41
typedef signed char uae_s8;
42
 
43
typedef unsigned short uae_u16;
44
typedef short uae_s16;
45
 
46
typedef unsigned int uae_u32;
47
typedef int uae_s32;
48
 
49
typedef uae_u32 uaecptr;
50
 
51
typedef wchar_t TCHAR;
52
 
53
#define CPU_EMU_SIZE 0
54
#define CYCLE_UNIT 512
55
 
56
#define STATIC_INLINE static __inline__ __attribute__ ((always_inline))
57
 
58
//-------------------------------------
59
 
60
#define _vsnprintf vsnprintf
61
#define xfree free
62
#define xmalloc malloc
63
#define _tcsncmp wcsncmp
64
#define _istspace iswspace
65
#define _tcscmp wcscmp
66
#define _tcslen wcslen
67
 
68
STATIC_INLINE char *ua (const TCHAR *str) {
69
        int len;
70
 
71
        len = wcslen(str);
72
        char *result = (char*)xmalloc(len);
73
 
74
        const wchar_t *ptr = str;
75
        wcsrtombs(result, &ptr, len, NULL);
76
        return result;
77
}
78
 
79
 
80
// z newcpu.h ----------
81
#define get_iword(o) get_wordi((uaecptr)((regs).pc_p + (o)))
82
 
83
#define REGPARAM
84
#define REGPARAM2
85
#define REGPARAM3
86
typedef unsigned long REGPARAM3 cpuop_func (uae_u32) REGPARAM;
87
typedef void REGPARAM3 cpuop_func_ce (uae_u32) REGPARAM;
88
 
89
struct cputbl {
90
        cpuop_func *handler;
91
        uae_u16 opcode;
92
};
93
 
94
typedef uae_u8 flagtype;
95
 
96
extern struct regstruct
97
{
98
        uae_u32 regs[16];
99
 
100
        uae_u32 pc;
101
        uae_u8 *pc_p;
102
        uae_u8 *pc_oldp;
103
 
104
        uae_u16 irc, ir;
105
        uae_u32 spcflags;
106
 
107
        uaecptr usp, isp, msp;
108
        uae_u16 sr;
109
        flagtype t1;
110
        flagtype t0;
111
        flagtype s;
112
        flagtype m;
113
        flagtype x;
114
        flagtype stopped;
115
        int intmask;
116
 
117
        uae_u32 vbr, sfc, dfc;
118
 
119
#ifdef FPUEMU
120
        fptype fp[8];
121
        fptype fp_result;
122
 
123
        uae_u32 fpcr, fpsr, fpiar;
124
        uae_u32 fpsr_highbyte;
125
#endif
126
#ifndef CPUEMU_68000_ONLY
127
        uae_u32 cacr, caar;
128
        uae_u32 itt0, itt1, dtt0, dtt1;
129
        uae_u32 tcr, mmusr, urp, srp, buscr;
130
        uae_u32 mmu_fslw, mmu_fault_addr;
131
        uae_u16 mmu_ssw;
132
        uae_u32 wb3_data;
133
        uae_u16 wb3_status;
134
        int mmu_enabled;
135
        int mmu_pagesize_8k;
136
        uae_u32 fault_pc;
137
#endif
138
 
139
        uae_u32 pcr;
140
        uae_u32 address_space_mask;
141
 
142
        uae_u8 panic;
143
        uae_u32 panic_pc, panic_addr;
144
 
145
        uae_u32 prefetch020data;
146
        uae_u32 prefetch020addr;
147
        int ce020memcycles;
148
 
149
} regs, lastint_regs, mmu_backup_regs;
150
 
151
#define m68k_dreg(r,num) ((r).regs[(num)])
152
#define m68k_areg(r,num) (((r).regs + 8)[(num)])
153
 
154
extern const int imm8_table[];
155
extern const int areg_byteinc[];
156
 
157
extern int movem_index1[256];
158
extern int movem_index2[256];
159
extern int movem_next[256];
160
 
161
//m68k.h
162
struct flag_struct {
163
    unsigned int c;
164
    unsigned int z;
165
    unsigned int n;
166
    unsigned int v;
167
    unsigned int x;
168
};
169
 
170
extern struct flag_struct regflags;
171
 
172
#define ZFLG (regflags.z)
173
#define NFLG (regflags.n)
174
#define CFLG (regflags.c)
175
#define VFLG (regflags.v)
176
#define XFLG (regflags.x)
177
 
178
static __inline__ int cctrue(const int cc)
179
{
180
    switch(cc){
181
     case 0: return 1;                       /* T */
182
     case 1: return 0;                       /* F */
183
     case 2: return !CFLG && !ZFLG;          /* HI */
184
     case 3: return CFLG || ZFLG;            /* LS */
185
     case 4: return !CFLG;                   /* CC */
186
     case 5: return CFLG;                    /* CS */
187
     case 6: return !ZFLG;                   /* NE */
188
     case 7: return ZFLG;                    /* EQ */
189
     case 8: return !VFLG;                   /* VC */
190
     case 9: return VFLG;                    /* VS */
191
     case 10:return !NFLG;                   /* PL */
192
     case 11:return NFLG;                    /* MI */
193
     case 12:return NFLG == VFLG;            /* GE */
194
     case 13:return NFLG != VFLG;            /* LT */
195
     case 14:return !ZFLG && (NFLG == VFLG); /* GT */
196
     case 15:return ZFLG || (NFLG != VFLG);  /* LE */
197
    }
198
    abort();
199
    return 0;
200
}
201
 
202
//newcpu.h
203
#define SET_CFLG(x) (CFLG = (x))
204
#define SET_NFLG(x) (NFLG = (x))
205
#define SET_VFLG(x) (VFLG = (x))
206
#define SET_ZFLG(x) (ZFLG = (x))
207
#define SET_XFLG(x) (XFLG = (x))
208
 
209
#define GET_CFLG() CFLG
210
#define GET_NFLG() NFLG
211
#define GET_VFLG() VFLG
212
#define GET_ZFLG() ZFLG
213
#define GET_XFLG() XFLG
214
 
215
#define CLEAR_CZNV() do { \
216
        SET_CFLG (0); \
217
        SET_ZFLG (0); \
218
        SET_NFLG (0); \
219
        SET_VFLG (0); \
220
} while (0)
221
 
222
#define COPY_CARRY() (SET_XFLG (GET_CFLG ()))
223
 
224
//...newcpu.h
225
 
226
#define m68k_incpc(o) ((regs).pc_p += (o))
227
 
228
#define get_cpu_model() 68000
229
 
230
#endif // __AO_H__
231
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.