mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-12-25 02:29:49 +00:00
Make sure 68k procedures are stored on 16-bit word boundaries.
This commit is contained in:
parent
1b0e88041e
commit
76a5e63bd2
@ -35,8 +35,10 @@
|
||||
// Are we using a PPC emulator or the real thing?
|
||||
#ifdef __POWERPC__
|
||||
#define EMULATED_PPC 0
|
||||
#define WORDS_BIGENDIAN 1
|
||||
#else
|
||||
#define EMULATED_PPC 1
|
||||
#undef WORDS_BIGENDIAN
|
||||
#endif
|
||||
|
||||
#define POWERPC_ROM 1
|
||||
|
@ -487,17 +487,17 @@ static void do_getscrap(void **handle, uint32 type, int32 offset)
|
||||
}
|
||||
|
||||
// Add new data to clipboard
|
||||
static uint8 proc[] = {
|
||||
0x59, 0x8f, // subq.l #4,sp
|
||||
0xa9, 0xfc, // ZeroScrap()
|
||||
0x2f, 0x3c, 0, 0, 0, 0, // move.l #length,-(sp)
|
||||
0x2f, 0x3c, 0, 0, 0, 0, // move.l #type,-(sp)
|
||||
0x2f, 0x3c, 0, 0, 0, 0, // move.l #outbuf,-(sp)
|
||||
0xa9, 0xfe, // PutScrap()
|
||||
0x58, 0x8f, // addq.l #4,sp
|
||||
M68K_RTS >> 8, M68K_RTS
|
||||
static uint16 proc[] = {
|
||||
PW(0x598f), // subq.l #4,sp
|
||||
PW(0xa9fc), // ZeroScrap()
|
||||
PW(0x2f3c), 0, 0, // move.l #length,-(sp)
|
||||
PW(0x2f3c), 0, 0, // move.l #type,-(sp)
|
||||
PW(0x2f3c), 0, 0, // move.l #outbuf,-(sp)
|
||||
PW(0xa9fe), // PutScrap()
|
||||
PW(0x588f), // addq.l #4,sp
|
||||
PW(M68K_RTS)
|
||||
};
|
||||
uint32 proc_area = (uint32)proc; // FIXME: make sure 32-bit relocs are used
|
||||
uint32 proc_area = (uint32)proc;
|
||||
WriteMacInt32(proc_area + 6, data.size());
|
||||
WriteMacInt32(proc_area + 12, type);
|
||||
WriteMacInt32(proc_area + 18, scrap_area);
|
||||
|
@ -267,10 +267,10 @@ void EmulOp(M68kRegisters *r, uint32 pc, int selector)
|
||||
#endif
|
||||
|
||||
// Patch DebugStr()
|
||||
static const uint8 proc[] = {
|
||||
M68K_EMUL_OP_DEBUG_STR >> 8, M68K_EMUL_OP_DEBUG_STR & 0xff,
|
||||
0x4e, 0x74, // rtd #4
|
||||
0x00, 0x04
|
||||
static const uint16 proc[] = {
|
||||
PW(M68K_EMUL_OP_DEBUG_STR),
|
||||
PW(0x4e74), // rtd #4
|
||||
PW(0x0004)
|
||||
};
|
||||
WriteMacInt32(0x1dfc, (uint32)proc);
|
||||
break;
|
||||
|
@ -90,6 +90,13 @@ static inline void *Mac2Mac_memcpy(uint32 dest, uint32 src, size_t n) {return me
|
||||
* 680x0 and PPC emulation
|
||||
*/
|
||||
|
||||
// 68k procedure helper to write a big endian 16-bit word
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define PW(W) W
|
||||
#else
|
||||
#define PW(X) ((((X) >> 8) & 0xff) | (((X) & 0xff) << 8))
|
||||
#endif
|
||||
|
||||
struct M68kRegisters;
|
||||
extern void Execute68k(uint32, M68kRegisters *r); // Execute 68k subroutine from EMUL_OP routine, must be ended with RTS
|
||||
extern void Execute68kTrap(uint16 trap, M68kRegisters *r); // Execute 68k A-Trap from EMUL_OP routine
|
||||
|
@ -169,18 +169,18 @@ void *FindLibSymbol(char *lib_str, char *sym_str)
|
||||
M68kRegisters r;
|
||||
|
||||
// Find shared library
|
||||
static const uint8 proc1[] = {
|
||||
0x55, 0x8f, // subq.l #2,a7
|
||||
0x2f, 0x08, // move.l a0,-(a7)
|
||||
0x2f, 0x3c, 0x70, 0x77, 0x70, 0x63, // move.l #'pwpc',-(a7)
|
||||
0x2f, 0x3c, 0x00, 0x00, 0x00, 0x01, // move.l #kReferenceCFrag,-(a7)
|
||||
0x2f, 0x09, // move.l a1,-(a7)
|
||||
0x2f, 0x0a, // move.l a2,-(a7)
|
||||
0x2f, 0x0b, // move.l a3,-(a7)
|
||||
0x3f, 0x3c, 0x00, 0x01, // (GetSharedLibrary)
|
||||
0xaa, 0x5a, // CFMDispatch
|
||||
0x30, 0x1f, // move.w (a7)+,d0
|
||||
M68K_RTS >> 8, M68K_RTS & 0xff
|
||||
static const uint16 proc1[] = {
|
||||
PW(0x558f), // subq.l #2,a7
|
||||
PW(0x2f08), // move.l a0,-(a7)
|
||||
PW(0x2f3c), PW(0x7077), PW(0x7063), // move.l #'pwpc',-(a7)
|
||||
PW(0x2f3c), PW(0x0000), PW(0x0001), // move.l #kReferenceCFrag,-(a7)
|
||||
PW(0x2f09), // move.l a1,-(a7)
|
||||
PW(0x2f0a), // move.l a2,-(a7)
|
||||
PW(0x2f0b), // move.l a3,-(a7)
|
||||
PW(0x3f3c), PW(0x0001), // (GetSharedLibrary)
|
||||
PW(0xaa5a), // CFMDispatch
|
||||
PW(0x301f), // move.w (a7)+,d0
|
||||
PW(M68K_RTS)
|
||||
};
|
||||
r.a[0] = lib.addr();
|
||||
r.a[1] = conn_id.addr();
|
||||
@ -192,16 +192,16 @@ void *FindLibSymbol(char *lib_str, char *sym_str)
|
||||
return NULL;
|
||||
|
||||
// Find symbol
|
||||
static const uint8 proc2[] = {
|
||||
0x55, 0x8f, // subq.l #2,a7
|
||||
0x2f, 0x00, // move.l d0,-(a7)
|
||||
0x2f, 0x08, // move.l a0,-(a7)
|
||||
0x2f, 0x09, // move.l a1,-(a7)
|
||||
0x2f, 0x0a, // move.l a2,-(a7)
|
||||
0x3f, 0x3c, 0x00, 0x05, // (FindSymbol)
|
||||
0xaa, 0x5a, // CFMDispatch
|
||||
0x30, 0x1f, // move.w (a7)+,d0
|
||||
M68K_RTS >> 8, M68K_RTS & 0xff
|
||||
static const uint16 proc2[] = {
|
||||
PW(0x558f), // subq.l #2,a7
|
||||
PW(0x2f00), // move.l d0,-(a7)
|
||||
PW(0x2f08), // move.l a0,-(a7)
|
||||
PW(0x2f09), // move.l a1,-(a7)
|
||||
PW(0x2f0a), // move.l a2,-(a7)
|
||||
PW(0x3f3c), PW(0x0005), // (FindSymbol)
|
||||
PW(0xaa5a), // CFMDispatch
|
||||
PW(0x301f), // move.w (a7)+,d0
|
||||
PW(M68K_RTS)
|
||||
};
|
||||
r.d[0] = conn_id.value();
|
||||
r.a[0] = sym.addr();
|
||||
|
Loading…
Reference in New Issue
Block a user