96 |
|
struct native_op_t { |
97 |
|
uint32 tvect; |
98 |
|
uint32 func; |
99 |
+ |
SheepRoutineDescriptor *desc; |
100 |
|
}; |
101 |
|
static native_op_t native_op[NATIVE_OP_MAX]; |
102 |
|
|
128 |
|
#else |
129 |
|
#error "FIXME: define NativeOp for your platform" |
130 |
|
#endif |
131 |
+ |
// FIXME: add GetResource() and friends for completeness |
132 |
|
DEFINE_NATIVE_OP(NATIVE_PATCH_NAME_REGISTRY, DoPatchNameRegistry); |
133 |
|
DEFINE_NATIVE_OP(NATIVE_VIDEO_INSTALL_ACCEL, VideoInstallAccel); |
134 |
|
DEFINE_NATIVE_OP(NATIVE_VIDEO_VBL, VideoVBL); |
150 |
|
DEFINE_NATIVE_OP(NATIVE_MAKE_EXECUTABLE, MakeExecutable); |
151 |
|
#undef DEFINE_NATIVE_OP |
152 |
|
#endif |
153 |
+ |
|
154 |
+ |
// Initialize routine descriptors (if TVECT exists) |
155 |
+ |
for (int i = 0; i < NATIVE_OP_MAX; i++) { |
156 |
+ |
uint32 tvect = native_op[i].tvect; |
157 |
+ |
if (tvect) |
158 |
+ |
native_op[i].desc = new SheepRoutineDescriptor(0, tvect); |
159 |
+ |
} |
160 |
+ |
|
161 |
|
return true; |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
/* |
166 |
+ |
* Delete generated thunks |
167 |
+ |
*/ |
168 |
+ |
|
169 |
+ |
void ThunksExit(void) |
170 |
+ |
{ |
171 |
+ |
for (int i = 0; i < NATIVE_OP_MAX; i++) { |
172 |
+ |
SheepRoutineDescriptor *desc = native_op[i].desc; |
173 |
+ |
if (desc) |
174 |
+ |
delete desc; |
175 |
+ |
} |
176 |
+ |
} |
177 |
+ |
|
178 |
+ |
|
179 |
+ |
/* |
180 |
|
* Return the native function descriptor (TVECT) |
181 |
|
*/ |
182 |
|
|
203 |
|
|
204 |
|
|
205 |
|
/* |
206 |
+ |
* Return the routine descriptor address of the native function |
207 |
+ |
*/ |
208 |
+ |
|
209 |
+ |
uint32 NativeRoutineDescriptor(int selector) |
210 |
+ |
{ |
211 |
+ |
assert(selector < NATIVE_OP_MAX); |
212 |
+ |
SheepRoutineDescriptor * const desc = native_op[selector].desc; |
213 |
+ |
assert(desc != 0); |
214 |
+ |
return desc->addr(); |
215 |
+ |
} |
216 |
+ |
|
217 |
+ |
|
218 |
+ |
/* |
219 |
|
* Execute native code from EMUL_OP routine (real mode switch) |
220 |
|
*/ |
221 |
|
|
222 |
|
void ExecuteNative(int selector) |
223 |
|
{ |
187 |
– |
SheepRoutineDescriptor desc(0, NativeTVECT(selector)); |
224 |
|
M68kRegisters r; |
225 |
< |
Execute68k(desc.addr(), &r); |
225 |
> |
Execute68k(NativeRoutineDescriptor(selector), &r); |
226 |
|
} |