aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/PalmOS/Src/native/pace.h
blob: 37b903b2c3905b59ad4577e46560196ce3ef0644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

#ifndef PACE_H
#define PACE_H

#include <PceNativeCall.h>
//#include "endianutils.h"

// local definition of the emulation state structure
typedef struct {
	UInt32 instr;
	UInt32 regData[8];
	UInt32 regAddress[8];
	UInt32 regPC;
} EmulStateType;

typedef struct {
	EmulStateType *emulStateP;
	Call68KFuncType *call68KFuncP;
} GlobalsType;

extern GlobalsType global;

// TODO : check this, already defined in ARMlet_Runtime
//extern EmulStateType	*g_emulStateP;
//extern Call68KFuncType	*g_call68KFuncP;
#define g_emulStateP	global.emulStateP
#define g_call68KFuncP	global.call68KFuncP


#ifdef __cplusplus
#	define PACE_CLASS_WRAPPER(rv)		extern "C" rv
#else
#	define PACE_CLASS_WRAPPER(rv)		rv
#endif
#define PACE_CALLBACK_PTR			g_call68KFuncP
#define PACE_EMULSTATE				g_emulStateP

#define ALIGN_4BYTE(addr) (((UInt32)(addr) + 3) & 0xFFFFFFFC)

/****** TAKEN FROM PACEInteface.cpp (ARMlet_Runtime) ******/
// local definition of the emulation state structure

#define PACE_PARAMS_INIT()						\
	UInt8 params[] = {

#define PACE_PARAMS_ADD8(param)					\
	(UInt8)(param),								\
	0,

#define PACE_PARAMS_ADD16(param)				\
	(UInt8)((UInt16)(param) >> 8),				\
	(UInt8)(param),

#define PACE_PARAMS_ADD32(param)				\
	(UInt8)((UInt32)(param) >> 24),				\
	(UInt8)((UInt32)(param) >> 16),				\
	(UInt8)((UInt32)(param) >> 8),				\
	(UInt8)(param),

#define PACE_PARAMS_END()						\
	};

// PIN
#define PACE_PIN_EXEC_NP(pinTrap, returnType)	\
	PACE_EMULSTATE->regData[2] = pinTrap;		\
	return ((returnType)((PACE_CALLBACK_PTR)(	\
		static_cast<void *>(PACE_EMULSTATE),	\
		PceNativeTrapNo(sysTrapPinsDispatch),	\
		NULL, 0)));

#define PACE_PIN_EXEC(pinTrap, returnType)		\
	PACE_EMULSTATE->regData[2] = pinTrap;		\
	return ((returnType)((PACE_CALLBACK_PTR)(	\
		static_cast<void *>(PACE_EMULSTATE),	\
		PceNativeTrapNo(sysTrapPinsDispatch),	\
		&params,								\
		sizeof(params))));

#endif