Prepare ARM support

svn-id: r12736
This commit is contained in:
Chris Apers 2004-02-05 14:02:24 +00:00
parent ef1b06d8b3
commit 6830942213
7 changed files with 216 additions and 1 deletions

View File

@ -0,0 +1,43 @@
#ifndef _ARMNATIVE_H_
#define _ARMNATIVE_H_
#ifdef WIN32
#include "testing/SimNative.h"
#include "testing/oscalls.h"
#endif
// functions
typedef unsigned long (*PnoProc)(void *userData68KP);
#define DECLARE(x) unsigned long x(void *userData68KP);
typedef struct {
UInt32 func;
void *dst;
void *src;
} DataOSysWideType , *DataOSysWidePtr;
typedef struct {
UInt32 func;
void *dst;
const void *buf;
UInt32 pitch, _offScreenPitch;
UInt32 w, h;
} DataOSysCopyRectType, *DataOSysCopyRectPtr;
DECLARE(OSystem_PALMOS_update_screen__wide_portrait)
DECLARE(OSystem_PALMOS_update_screen__wide_landscape)
DECLARE(OSystem_PALMOS_copy_rect)
// rsrc
#define ARMCODE_1 1000
// function indexes
enum {
kOSysWidePortrait = 0,
kOSysWideLandscape,
kOSysCopyRect
};
#endif

View File

@ -0,0 +1,60 @@
#include "PACEInterfaceLib.h"
#include "ArmNative.h"
// Linker still looks for ARMlet_Main as entry point, but the
// "ARMlet" name is now officially discouraged. Compare an
// contrast to "PilotMain" for 68K applications.
#define PNO_Main ARMlet_Main
// entry point
extern "C"
unsigned long PNO_Main(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP);
#ifndef WIN32
#pragma thumb off
asm void * __ARMlet_Take_Func_Addr__(void *f)
{
sub r0, r0, r10 // 0 convert pointer to zero-based address
ldr r12, [pc, #8] // 4 load zero-based address of this routine plus offset into r12
sub r12, pc, r12 // 8 compute start of PNO by subtracting this from PC
add r0, r0, r12 // 12 add PNO start to function pointer
bx lr // 16 return to caller
dcd __ARMlet_Take_Func_Addr__ + 16 // 20
}
#pragma thumb reset
#else
#define __ARMlet_Take_Func_Addr__(x) x
#endif
unsigned long PNO_Main(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP) {
/* const PnoProc call[] = {
(PnoProc)__ARMlet_Take_Func_Addr__(OSystem_PALMOS_update_screen__wide_portrait),
(PnoProc)__ARMlet_Take_Func_Addr__(OSystem_PALMOS_update_screen__wide_landscape),
//OSystem_PALMOS_copy_rect
};
*/
#ifndef WIN32
// needed before making any OS calls using the
// PACEInterface library
InitPACEInterface(emulStateP, call68KFuncP);
#else
global.call68KFuncP = call68KFuncP;
global.emulStateP = emulStateP;
global.userData68KP = userData68KP;
#endif
UInt32 run = ByteSwap32(*(UInt32 *)userData68KP);
switch (run) {
case 0:
OSystem_PALMOS_update_screen__wide_portrait(userData68KP);
break;
case 1:
OSystem_PALMOS_update_screen__wide_landscape(userData68KP);
break;
}
return 0;
// return call[run](userData68KP);
}

View File

@ -0,0 +1,27 @@
#include "PACEInterfaceLib.h"
#include "ArmNative.h"
#include "endianutils.h"
#include "../shared.h"
unsigned long OSystem_PALMOS_copy_rect(void *userData68KP) {
UInt8* dataP = (UInt8 *)userData68KP;
UInt8 *dst = (UInt8 *)ReadUnaligned32(dataP + 2); // ->dst
UInt8 *buf = (UInt8 *)ReadUnaligned32(dataP + 6); // ->buf
UInt32 pitch = ReadUnaligned32(dataP + 10); // ->pitch
UInt32 _offScreenPitch = ReadUnaligned32(dataP + 14); // ->_offScreenPitch
UInt32 w = ReadUnaligned32(dataP + 18); // ->w
UInt32 h = ReadUnaligned32(dataP + 22); // ->h
if (_offScreenPitch == pitch && pitch == w) {
MemMove(dst, buf, h * w);
} else {
do {
MemMove(dst, buf, w);
dst += _offScreenPitch;
buf += pitch;
} while (--h);
}
return 0;
}

View File

@ -0,0 +1,30 @@
#include "PACEInterfaceLib.h"
#include "ArmNative.h"
#include "endianutils.h"
#include "../shared.h"
unsigned long OSystem_PALMOS_update_screen__wide_landscape(void *userData68KP) {
DataOSysWidePtr dataP = (DataOSysWideType *)userData68KP;
Coord x, y;
UInt8 *dst = (UInt8 *)ReadUnaligned32(&(dataP->dst));
UInt8 *src = (UInt8 *)ReadUnaligned32(&(dataP->src));
for (y = 0; y < WIDE_HALF_HEIGHT; y++) {
for (x = 0; x < WIDE_HALF_WIDTH; x++) {
*dst++ = *src++;
*dst++ = *src;
*dst++ = *src++;
}
for (x = 0; x < WIDE_HALF_WIDTH; x++) {
*dst++ = *src++;
*dst++ = *src;
*dst++ = *src++;
}
MemMove(dst, dst - 480, 480);
dst += 480;
}
return 0;
}

View File

@ -0,0 +1,43 @@
#include "PACEInterfaceLib.h"
#include "ArmNative.h"
#include "endianutils.h"
#include "../shared.h"
unsigned long OSystem_PALMOS_update_screen__wide_portrait(void *userData68KP) {
DataOSysWidePtr dataP = (DataOSysWideType *)userData68KP;
Coord x, y;
UInt8 *dst = (UInt8 *)ReadUnaligned32(&(dataP->dst));
UInt8 *src1 = (UInt8 *)ReadUnaligned32(&(dataP->src));
UInt8 *src2 = src1;
for (x = 0; x < WIDE_HALF_WIDTH; x++)
{
for (y = 0; y < WIDE_HALF_HEIGHT; y++)
{
*dst++ = *src1;
src1 += WIDE_PITCH;
*dst++ = *src1;
*dst++ = *src1;
src1 += WIDE_PITCH;
}
src1 = --src2;
dst += 20; // we draw 200pix scaled to 1.5 = 300, screen width=320, so next is 20
for (y = 0; y < WIDE_HALF_HEIGHT; y++)
{
*dst++ = *src1;
src1 += WIDE_PITCH;
*dst++ = *src1;
*dst++ = *src1;
src1 += WIDE_PITCH;
}
src1 = --src2;
dst += 20;
MemMove(dst, dst - WIDE_PITCH, 300); // 300 = 200 x 1.5
dst += WIDE_PITCH;
}
return 0;
}

View File

@ -11,4 +11,4 @@ enum {
extern UInt8 gFormEditMode;
void EditGameFormDelete(Boolean direct);
#endif
#endif

View File

@ -0,0 +1,12 @@
#ifndef _SHARED_H_
#define _SHARED_H_
// OSystem : wide display
// consider ony 480x320 screens
// only avalaible for 320x200 games, so use values instead of vars
#define WIDE_PITCH 320 // pitch in portrait mode
#define WIDE_HALF_WIDTH 160 // 320 / 2
#define WIDE_HALF_HEIGHT 100 // 200 / 2
#endif