svn-id: r5759
This commit is contained in:
Peter Moraliyski 2002-11-30 15:34:37 +00:00
parent ae7310ff28
commit f9a833abf0
13 changed files with 2663 additions and 0 deletions

35
backends/gp32/build.rules Normal file
View File

@ -0,0 +1,35 @@
# Makefile for GP32 development using devkitadv under Win32
# Written 2002 by Christian Nowak <chnowak@web.de>
# Modified by ph0x (ph0x@freemail.hu)
# devkitadv base dir
CCBASE=c:/devkitadv
CXX = $(CCBASE)/bin/g++
CFLAGS = -mcpu=arm9tdmi \
-mtune=arm9tdmi \
-mapcs \
-O2 \
-fomit-frame-pointer \
-finline-functions \
-fno-exceptions \
-fno-common \
-fno-builtin \
-fshort-enums \
-ffast-math \
-fshort-double \
-fallow-single-precision \
-ffreestanding \
-fexpensive-optimizations \
-mstructure-size-boundary=32 \
-mno-thumb-interwork \
-I$(CCBASE)/arm-agb-elf/include/gp32 \
-Wno-multichar
DEFINES = -D__GP32__ -DNONSTANDARD_PORT
LNKSCRIPT =$(CCBASE)/arm-agb-elf/lib/lnkscript
LDFLAGS = -Wl,-T $(LNKSCRIPT)
LIBS += -lgpgraphic -lgpmem -lgpos -lgpstdlib -lgpstdio -lgpsound -lgpfont
INCLUDES += -Ibackends/gp32
MODULES += backends/gp32
OBJS += $(CCBASE)/arm-agb-elf/lib/gpstart/gpstart.o backends/gp32/gp32.o backends/gp32/gpdebug.o

52
backends/gp32/dirent.h Normal file
View File

@ -0,0 +1,52 @@
/* Header is not present in Windows CE SDK */
/* It would not be a bad idea to take this thing from gcc distro and port
it properly. For now only required part is ported. */
struct dirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
char* d_name; /* File name. */
/* NOTE: The name in the dirent structure points to the name in the
* finddata_t structure in the DIR. */
};
/*
* This is an internal data structure. Good programmers will not use it
* except as an argument to one of the functions below.
*/
typedef struct
{
/* disk transfer area for this dir */
/* struct _finddata_t dd_dta; */
/* dirent struct to return from dir (NOTE: this makes this thread
* safe as long as only one thread uses a particular DIR struct at
* a time) */
struct dirent dd_dir;
/* _findnext handle */
long dd_handle;
/*
* Status of search:
* 0 = not started yet (next entry to read is first entry)
* -1 = off the end
* positive = 0 based index of next entry
*/
short dd_stat;
/* given path for dir with search pattern (struct is extended) */
char dd_name[1];
} DIR;
DIR* opendir (const char*);
struct dirent* readdir (DIR*);
int closedir (DIR*);
/*
void rewinddir (DIR*);
long telldir (DIR*);
void seekdir (DIR*, long);
*/

328
backends/gp32/emudebug.cpp Normal file
View File

@ -0,0 +1,328 @@
//////////////////////////////////////////////////////////////////////////////
// emudebug.cpp //
//////////////////////////////////////////////////////////////////////////////
/*
EmuDebug by Rafael Vuijk (aka Dark Fader)
see emudebug.txt for more info
*/
//////////////////////////////////////////////////////////////////////////////
// Includes //
//////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
#include <conio.h>
//////////////////////////////////////////////////////////////////////////////
// Pragmas //
//////////////////////////////////////////////////////////////////////////////
#pragma comment(lib, "user32")
//////////////////////////////////////////////////////////////////////////////
// Defines //
//////////////////////////////////////////////////////////////////////////////
#define VER "1.02"
//////////////////////////////////////////////////////////////////////////////
// Variables //
//////////////////////////////////////////////////////////////////////////////
// set in InitDebug
HWND hDebugWnd = 0;
HWND hEmuWnd = 0;
HANDLE hProcess = 0;
// set in ScanBuffer
void *debugBufferBeginAddr = 0;
void *debugBufferEndAddr = 0;
void *debugBufferDataAddr = 0;
int debugBufferDataSize = 0;
char *debugBufferData = 0; // temp. data
// default options
int minDebugBufferSize = 31;
int maxDebugBufferSize = 16*1024;
int pollInterval = 10;
int priorityClass = NORMAL_PRIORITY_CLASS;
char windowClass[256] = "BOYCOTTADVANCE"; // :)
char windowTitle[256] = "BoycottAdvance - ";
bool waitForKey = false;
//////////////////////////////////////////////////////////////////////////////
// InitDebug //
//////////////////////////////////////////////////////////////////////////////
int InitDebug()
{
// minimize debug window
//ShowWindow(hDebugWnd, SW_MINIMIZE); //ph0x
restart:
printf("Searching debugging target...");
char *pWindowClass = windowClass[0] ? windowClass : 0;
char *pWindowTitle = windowTitle[0] ? windowTitle : 0;
// loop
while (1)
{
hEmuWnd = FindWindow(pWindowClass, pWindowTitle);
//if (!hEmuWnd) { printf("Can't find window!\n"); return -1; }
if (hEmuWnd) break;
if (kbhit() && (getch() == 27)) return -1; // abort?
Sleep(20);
}
DWORD processId = 0;
GetWindowThreadProcessId(hEmuWnd, &processId);
if (!processId) { printf("Can't get process ID!\n"); return -1; }
hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, processId);
if (!hProcess) { printf("Can't open process!\n"); return -1; }
SetPriorityClass(hProcess, priorityClass); // set process priority class
printf(" done.\n");
int bufferSize = 1*1024*1024; // start with 1MB or so
char *buffer = new char[bufferSize]; // temp ReadProcessMemory buffer
if (!waitForKey) printf("Searching debug buffer...");
// loop
while (1)
{
if (waitForKey)
{
printf("Press any key to begin searching for debug buffer...");
getch();
printf("\n");
printf("Searching debug buffer...");
}
DWORD exitCode;
if (!GetExitCodeProcess(hProcess, &exitCode)) { printf("\n"); goto restart; }
if (exitCode != STILL_ACTIVE) { printf("\n"); goto restart; }
bool something = false; // some data found?
MEMORY_BASIC_INFORMATION mbi;
unsigned int addr;
for (addr=0; VirtualQueryEx(hProcess, (void*)addr, &mbi, sizeof(mbi)); addr = (unsigned int)mbi.BaseAddress + mbi.RegionSize)
{
//printf("base=%08X, size=%d, protect=%08X, type=%08X\n", mbi.BaseAddress, mbi.RegionSize, mbi.Protect, mbi.Type);
if (mbi.Type == MEM_PRIVATE) // type=00020000
if (mbi.Protect == PAGE_READWRITE) // protect=00000004
{
if (mbi.RegionSize > bufferSize)
{
delete buffer;
bufferSize = mbi.RegionSize * 3/2;
buffer = new char[bufferSize];
}
if (ReadProcessMemory(hProcess, mbi.BaseAddress, buffer, mbi.RegionSize, NULL))
{
something = true;
for (unsigned int i=0; i<mbi.RegionSize; i += minDebugBufferSize-2)
{
if (buffer[i] == ' ') // might be somewhere in the buffer
{
//printf("scan left\n");
// scan to left
int left = i;
while (buffer[left] == ' ') if (--left <= 0) { continue; } // nothing left
if (buffer[left] != '{') { continue; } // nope, wrong start
//printf("scan right\n");
// scan to right
int right = i;
while (buffer[right] == ' ') if (++right >= mbi.RegionSize) { i = right; continue; } // nothing left
if (buffer[right] != '}') { i = right; continue; } // nope, wrong end
// alloc new temp. debug buffer with max debug buffer length
debugBufferDataSize = right - left + 1;
//printf("debugBufferDataSize = %d\n", debugBufferDataSize);
if (
(debugBufferDataSize >= minDebugBufferSize) && // minimum size
(debugBufferDataSize <= maxDebugBufferSize) && // maximum size
(*(unsigned int *)(buffer + left - 8) == 0xEDEBEDEB) && // start
(*(unsigned int *)(buffer + left - 4) == 0xEDEBEDEB) // end
)
{
// remember addresses
debugBufferBeginAddr = (void *)((int)mbi.BaseAddress + left - 8);
debugBufferEndAddr = (void *)((int)mbi.BaseAddress + left - 4);
debugBufferDataAddr = (void *)((int)mbi.BaseAddress + left - 0);
// allocate temporary buffer
if (debugBufferData) delete debugBufferData;
debugBufferData = new char[debugBufferDataSize];
// start debugging
int n = 0;
WriteProcessMemory(hProcess, debugBufferBeginAddr, &n, sizeof(n), NULL);
WriteProcessMemory(hProcess, debugBufferEndAddr, &n, sizeof(n), NULL);
// show done
printf(" done.\n");
delete buffer;
//printf("base=%08X, size=%d, protect=%08X, type=%08X\n", mbi.BaseAddress, mbi.RegionSize, mbi.Protect, mbi.Type);
// do things to activate/show debugger
ShowWindow(hEmuWnd, SW_RESTORE); //ph0x
SetActiveWindow(hEmuWnd); //ph0x
SetForegroundWindow(hEmuWnd); //ph0x
FlashWindow(hDebugWnd, TRUE);
SetWindowPos(hDebugWnd, HWND_TOP, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE);
return 0; // ok
}
} // ' '
} // for
} // ReadProcessMemory
else
{
// can't read memory anymore
//printf("\n"); goto restart;
}
//printf("\n");
} // type
} // for VirtualQueryEx
if (waitForKey) printf("\n");
//if (!addr) { printf("\n"); goto restart; } // no VirtualQueryEx data
//if (!something) { printf("\n"); goto restart; } // invalid process or something
if (kbhit() && (getch() == 27)) break; // abort
Sleep(20);
} // while
delete buffer;
return -1;
}
//////////////////////////////////////////////////////////////////////////////
// ShowHelp //
//////////////////////////////////////////////////////////////////////////////
void ShowHelp()
{
printf("EmuDebug "VER" by Rafael Vuijk (aka Dark Fader)\n\n");
printf("Flags:\n");
printf(" -h -? Show this help.\n");
printf(" -b Set emulator process to below priority class.\n");
printf(" -i Set emulator process to idle priority class.\n");
printf(" -p<n> Set polling interval in milliseconds.\n");
printf(" -c[<n>] Window class name to find. Default: \"BOYCOTTADVANCE\".\n");
printf(" You can use MS Spy++ or something to find this.\n");
printf(" -t[<n>] Window title name to find. Default: \"BoycottAdvance - \".\n");
printf(" -s<n> Set mininum debug buffer size to look for.\n");
printf(" -k Wait for a key to commence searching.\n");
printf("\n");
printf("Some 'good' working examples:\n");
printf(" emudebug -i -p100 -s127\n");
printf(" emudebug -p20 -k -b -c\"\" -t\"VGBA-Windows 1.1r\" -s63\n");
}
//////////////////////////////////////////////////////////////////////////////
// main //
//////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
// check parameters
for (int a=1; a<argc; a++)
{
if (argv[a][0] == '-')
switch (argv[a][1])
{
case 'h': case '?': ShowHelp(); return 0;
case 'i': priorityClass = IDLE_PRIORITY_CLASS; break;
//case 'b': priorityClass = BELOW_NORMAL_PRIORITY_CLASS; break; //ph0x
case 'p': pollInterval = strtoul(argv[a]+2, NULL, 0); break;
case 'c': strcpy(windowClass, argv[a]+2); break;
case 't': strcpy(windowTitle, argv[a]+2); break;
case 's': minDebugBufferSize = strtoul(argv[a]+2, NULL, 0); break;
case 'k': waitForKey = true; break;
default: printf("Unknown uption: %c\n", argv[a][1]); break;
}
}
// find debug window
SetConsoleTitle("EmuDebug Console");
hDebugWnd = FindWindow(NULL, "EmuDebug Console");
// search for debug buffer
if (InitDebug()) return -1;
// do debug console
int boostPollInterval = pollInterval;
while (1)
{
// check keyboard input
if (kbhit())
{
char c = getch();
if (c == 27) // escape
{
// try to close emulator & minimize debug window
SendMessage(hEmuWnd, WM_CLOSE, 0, 0);
SendMessage(hDebugWnd, WM_CLOSE, 0, 0); //ph0x
//SetWindowPos(hDebugWnd, HWND_TOP, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOMOVE|SWP_NOSIZE);
//ShowWindow(hDebugWnd, SW_MINIMIZE); //ph0x
}
}
// get begin/end from debug buffer
int end = 0;
if (!ReadProcessMemory(hProcess, (void *)debugBufferEndAddr, &end, sizeof(end), NULL))
{
// re-init debug after failure
if (InitDebug()) break;
continue;
}
int begin = 0;
ReadProcessMemory(hProcess, (void *)debugBufferBeginAddr, &begin, sizeof(begin), NULL);
// some data?
if (begin != end)
{
unsigned int nextBegin;
while (1) //begin != end)
{
int begin = end;
ReadProcessMemory(hProcess, (void *)debugBufferBeginAddr, &begin, sizeof(begin), NULL);
if (begin == end) break; // no more data
nextBegin = begin + 1;
if (nextBegin >= debugBufferDataSize) nextBegin = 0;
char c;
ReadProcessMemory(hProcess, (void *)((int)debugBufferDataAddr + begin), &c, 1, NULL);
putchar(c);
begin = nextBegin;
WriteProcessMemory(hProcess, debugBufferBeginAddr, &begin, sizeof(begin), NULL);
}
// boost poll interval
boostPollInterval /= 2;
}
else
{
// slow down again
if (boostPollInterval == 0) boostPollInterval = 1; else boostPollInterval *= 2;
if (boostPollInterval > pollInterval) boostPollInterval = pollInterval;
}
// poll interval
Sleep(boostPollInterval);
}
// clean up
if (debugBufferData) delete debugBufferData;
CloseHandle(hProcess);
return 0;
}

View File

@ -0,0 +1,35 @@
EmuDebug by Rafael Vuijk (aka Dark Fader)
Console debug output for emulators.
GBA apps must use the new debug library found in MyLib
Usage
-----
Please run program with '-h' parameter to get possible options.
How it works
------------
1) PC searches the debug buffer in emulators memory.
begin & end init value is 0xEDEBEDEB, must reset to 0 to start debugging
data all spaces except first and last character, which are '{' & '}'
2) GBA waits for begin/end to become something else than init value
3) GBA reads any characters until begin & end index are equal again
History
-------
v1.02
minimizes window & pop-ups when debugging
escape closes emulator window
rotating buffer, so incompatable with older versions but who cares :)
v1.01
waits for emulator at startup
reconnects to new emulator instance
window class/title options
poll interval boosting
option for minimum buffersize
wait for key before searching option
v1.00
'protocol' defined
searches buffer in Boycott Advance
console output

1555
backends/gp32/gp32.cpp Normal file

File diff suppressed because it is too large Load Diff

203
backends/gp32/gp32.h Normal file
View File

@ -0,0 +1,203 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
#include "common/system.h"
#include "common/scummsys.h"
#include "common/stdafx.h"
#include "common/engine.h"
#include "scumm/saveload.h"
#include "common/scaler.h"
extern "C" {
#include "gpdebug.h"
}
#include "gpsdl.h" // hehe :)
class OSystem_GP32 : public OSystem {
public:
// Set colors of the palette
void set_palette(const byte *colors, uint start, uint num);
// Set the size of the video bitmap.
// Typically, 320x200
void init_size(uint w, uint h);
// Draw a bitmap to screen.
// The screen will not be updated to reflect the new bitmap
void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h);
// Moves the screen content around by the given amount of pixels
// but only the top height pixel rows, the rest stays untouched
void move_screen(int dx, int dy, int height);
// Update the dirty areas of the screen
void update_screen();
// Either show or hide the mouse cursor
bool show_mouse(bool visible);
// Set the position of the mouse cursor
void set_mouse_pos(int x, int y);
// Set the bitmap that's used when drawing the cursor.
void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y);
// Shaking is used in SCUMM. Set current shake position.
void set_shake_pos(int shake_pos);
// Get the number of milliseconds since the program was started.
uint32 get_msecs();
// Delay for a specified amount of milliseconds
void delay_msecs(uint msecs);
// Create a thread
void *create_thread(ThreadProc *proc, void *param);
// Get the next event.
// Returns true if an event was retrieved.
bool poll_event(Event *event);
// Set the function to be invoked whenever samples need to be generated
// Format is the sample type format.
// Only 16-bit signed mode is needed for simon & scumm
bool set_sound_proc(void *param, SoundProc *proc, byte format);
// Get or set a property
uint32 property(int param, Property *value);
// Poll cdrom status
// Returns true if cd audio is playing
bool poll_cdrom();
// Play cdrom audio track
void play_cdrom(int track, int num_loops, int start_frame, int end_frame);
// Stop cdrom audio track
void stop_cdrom();
// Update cdrom audio status
void update_cdrom();
// Add a new callback timer
void set_timer(int timer, int (*callback)(int));
// Mutex handling
void *create_mutex(void);
void lock_mutex(void *mutex);
void unlock_mutex(void *mutex);
void delete_mutex(void *mutex);
// Quit
void quit();
// Overlay
void show_overlay();
void hide_overlay();
void clear_overlay();
void grab_overlay(int16 *buf, int pitch);
void copy_rect_overlay(const int16 *buf, int pitch, int x, int y, int w, int h);
static OSystem *create(int gfx_mode, bool full_screen);
private:
typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
uint8 *dstPtr, uint32 dstPitch, int width, int height);
SDL_Surface *sdl_tmpscreen; // temporary screen (for scalers/overlay)
SDL_Surface *sdl_hwscreen; // hardware screen
bool _overlay_visible;
ScalerProc *_scaler_proc;
int TMP_SCREEN_WIDTH;
//uint msec_start;
//uint32 get_ticks();
///OSystem_GP32(); // eh?
/// ~OSystem_GP32();
// unseen game screen
SDL_Surface *_screen;
int _screenWidth, _screenHeight;
// CD Audio
///SDL_CD *_cdrom;
int cd_track, cd_num_loops, cd_start_frame, cd_end_frame;
uint32 cd_end_time, cd_stop_time, cd_next_second;
enum {
DF_WANT_RECT_OPTIM = 1 << 0,
DF_UPDATE_EXPAND_1_PIXEL = 1 << 3
};
bool _forceFull; // Force full redraw on next update_screen
int _scaleFactor;
int _mode;
bool _full_screen;
uint32 _mode_flags;
enum {
NUM_DIRTY_RECT = 100,
MAX_MOUSE_W = 40,
MAX_MOUSE_H = 40,
MAX_SCALING = 3
};
// Dirty rect managment
SDL_Rect _dirty_rect_list[100];
int _num_dirty_rects;
uint32 *_dirty_checksums;
bool cksum_valid;
int CKSUM_NUM;
// Keyboard mouse emulation
struct KbdMouse {
int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count;
uint32 last_time, delay_time, x_down_time, y_down_time;
} km;
struct MousePos {
int16 x, y, w, h;
};
bool _mouseVisible;
bool _mouseDrawn;
byte *_mouseData;
byte *_mouseBackup;
MousePos _mouse_cur_state;
MousePos _mouse_old_state;
int16 _mouseHotspotX;
int16 _mouseHotspotY;
// Shake mode
int _currentShakePos;
int _newShakePos;
// Palette data
SDL_Color *_currentPalette;
uint _paletteDirtyStart, _paletteDirtyEnd;
void add_dirty_rgn_auto(const byte *buf);
void mk_checksums(const byte *buf);
static void fill_sound(void *userdata, Uint8 * stream, int len);
void add_dirty_rect(int x, int y, int w, int h);
void draw_mouse();
void undraw_mouse();
void load_gfx_mode();
void unload_gfx_mode();
void hotswap_gfx_mode();
void get_screen_image(byte *buf);
void setup_icon();
void kbd_mouse();
static OSystem_GP32 *create();
};

125
backends/gp32/gpdebug.c Normal file
View File

@ -0,0 +1,125 @@
//////////////////////////////////////////////////////////////////////////////
// debug_emu.cpp //
//////////////////////////////////////////////////////////////////////////////
/*
debug support for EmuDebug console v1.2+
*/
//////////////////////////////////////////////////////////////////////////////
// Includes //
//////////////////////////////////////////////////////////////////////////////
#include "gpdebug.h"
//////////////////////////////////////////////////////////////////////////////
// Defines //
//////////////////////////////////////////////////////////////////////////////
#define debugBufferData ((volatile char *)debugBufferAddr + 8)
#define debugBufferBegin REG4((int)debugBufferAddr + 0) // read
#define debugBufferEnd REG4((int)debugBufferAddr + 4) // write
#define debugBufferDataSize 256
#define debugBufferSize (8 + debugBufferDataSize)
//////////////////////////////////////////////////////////////////////////////
// Variables //
//////////////////////////////////////////////////////////////////////////////
static int debugging = 0;
static void * volatile debugBufferAddr;
char debugBuffer[debugBufferDataSize]; // instead of malloc
//////////////////////////////////////////////////////////////////////////////
// __putchar //
//////////////////////////////////////////////////////////////////////////////
void __putchar(int c)
{
unsigned int nextEnd;
if (!debugging) return;
do
{
nextEnd = debugBufferEnd + 1;
if (nextEnd >= debugBufferDataSize) nextEnd = 0;
} while (nextEnd == debugBufferBegin); // full?
debugBufferData[debugBufferEnd] = c;
debugBufferEnd = nextEnd;
}
//////////////////////////////////////////////////////////////////////////////
// __getchar //
//////////////////////////////////////////////////////////////////////////////
int __getchar()
{
//if (!debugging) return -1;
return -1;
}
//////////////////////////////////////////////////////////////////////////////
// __kbhit //
//////////////////////////////////////////////////////////////////////////////
int __kbhit()
{
//if (!debugging) return false;
return 0;
}
//////////////////////////////////////////////////////////////////////////////
// __gets //
//////////////////////////////////////////////////////////////////////////////
char * __gets(char *s)
{
char *p = s;
if (!debugging) return 0;
while (1)
{
int c = getchar();
if (c >= 0) *p++ = c;
if (c == 0) return s;
}
return s;
}
//////////////////////////////////////////////////////////////////////////////
// __puts //
//////////////////////////////////////////////////////////////////////////////
int __puts(const char *s)
{
if (!debugging) return 0;
while (*s) putchar(*s++);
return 0;
/*
while (debugBufferAddr[0]) {} // wait until buffer is clear
int r = sprintf(debugBufferAddr+1, "%s", s);
debugBufferAddr[0] = r;
return r;
*/
}
//////////////////////////////////////////////////////////////////////////////
// __printf //
//////////////////////////////////////////////////////////////////////////////
int __printf(char *fmt, ...)
{
char s[256];
int r;
va_list marker;
if (!debugging) return 0;
va_start(marker, fmt);
r = vsprintf(s, fmt, marker);
va_end(marker);
puts(s);
return r;
}
//////////////////////////////////////////////////////////////////////////////
// InitDebug //
//////////////////////////////////////////////////////////////////////////////
void InitDebug()
{
debugBufferAddr = debugBuffer;
//debugBufferAddr = malloc(debugBufferSize);
debugBufferBegin = debugBufferEnd = 0xEDEBEDEB;
memset((void *)debugBufferData, ' ', debugBufferDataSize);
debugBufferData[0] = '{'; debugBufferData[debugBufferDataSize - 1] = '}';
while (debugBufferBegin && debugBufferEnd) { } // wait for debugger
debugging = 1;
}

49
backends/gp32/gpdebug.h Normal file
View File

@ -0,0 +1,49 @@
//////////////////////////////////////////////////////////////////////////////
// debug.h //
//////////////////////////////////////////////////////////////////////////////
#ifndef _GP_DEBUG_H
#define _GP_DEBUG_H
/*
Debug library
Note: include debug.h after stdio.h and conio.h!!!
*/
//////////////////////////////////////////////////////////////////////////////
// Includes //
//////////////////////////////////////////////////////////////////////////////
#include "gpregs.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
//////////////////////////////////////////////////////////////////////////////
// Defines //
//////////////////////////////////////////////////////////////////////////////
// public
#define dprintf __printf //ph0x ..redefine rest?
#undef getchar
#define getchar __getchar
#undef putchar
#define putchar(c) __putchar(c)
#define gets(s) __gets(s)
#define puts(s) __puts(s) // fixme?
#define kbhit() __kbhit() // uncomment?
// function -> constructor & class instance
//#define INIT(fn) class fn##_Init { public: fn##_Init() { fn(); } } fn##_init
//#define INIT1(fn,param1) class fn##_Init { public: fn##_Init() { fn(param1); } } fn##_init
//////////////////////////////////////////////////////////////////////////////
// Prototypes //
//////////////////////////////////////////////////////////////////////////////
extern void InitDebug(void); // auto-initialized
extern int __kbhit(void);
extern void __putchar(int c);
extern int __getchar(void); // non-blocking
extern int __printf(char *fmt, ...);
extern int __puts(const char *s);
extern char * __gets(char *s);
#endif // _DEBUG_H

69
backends/gp32/gpregs.h Normal file
View File

@ -0,0 +1,69 @@
//////////////////////////////////////////////////////////////////////////////
// GP32.h //
//////////////////////////////////////////////////////////////////////////////
#ifndef _GP32_H
#define _GP32_H
/*
GP32 stuff
just a bunch of includes
*/
//////////////////////////////////////////////////////////////////////////////
// Includes //
//////////////////////////////////////////////////////////////////////////////
/*
#include "24x.h"
#include "gpdef.h"
#include "gpos_def.h"
#include "gpmem.h"
#include "gpstdio.h"
#include "gpstdlib.h"
#include "gpmm.h"
#include "gpgraphic.h"
#include "gpfont.h"
#include "gpsockdef.h"
#include "gpcomm.h"
#include "gpnetlib.h"
*/
//////////////////////////////////////////////////////////////////////////////
// Defines //
//////////////////////////////////////////////////////////////////////////////
// C++ bools
//typedef int bool;
#define false 0
#define true 1
typedef unsigned char u8;
typedef volatile u8 vu8;
typedef signed char s8;
typedef volatile s8 vs8;
typedef unsigned short u16;
typedef volatile u16 vu16;
typedef signed short s16;
typedef volatile s16 vs16;
typedef unsigned int u32;
typedef volatile u32 vu32;
typedef signed int s32;
typedef volatile s32 vs32;
// memory/register typecasting
#define MEM1(addr) ( (u8 *)(addr))
#define MEM2(addr) ( (u16*)(addr))
#define MEM4(addr) ( (u32*)(addr))
#define REG1(addr) (*(vu8 *)(addr))
#define REG2(addr) (*(vu16*)(addr))
#define REG4(addr) (*(vu32*)(addr))
#define RPTR(addr) (*(void **)(addr))
// array length
#define lengthof(id) (sizeof(id) / sizeof((id)[0]))
//////////////////////////////////////////////////////////////////////////////
// Typedefs //
//////////////////////////////////////////////////////////////////////////////
#endif // _GP32_H

82
backends/gp32/gpsdl.h Normal file
View File

@ -0,0 +1,82 @@
/* Useful data types */
#define Sint16 s16
#define Uint16 u16
#define Uint32 u32
#define Uint8 u8
typedef struct {
Sint16 x, y;
Uint16 w, h;
} SDL_Rect;
typedef struct {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 unused;
} SDL_Color;
typedef struct {
int ncolors;
SDL_Color *colors;
} SDL_Palette;
/* Everything in the pixel format structure is read-only */
typedef struct SDL_PixelFormat {
SDL_Palette *palette;
Uint8 BitsPerPixel;
Uint8 BytesPerPixel;
Uint8 Rloss;
Uint8 Gloss;
Uint8 Bloss;
Uint8 Aloss;
Uint8 Rshift;
Uint8 Gshift;
Uint8 Bshift;
Uint8 Ashift;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
/* RGB color key information */
Uint32 colorkey;
/* Alpha value information (per-surface alpha) */
Uint8 alpha;
} SDL_PixelFormat;
typedef struct SDL_Surface {
Uint32 flags; /* Read-only */
SDL_PixelFormat *format; /* Read-only */
int w, h; /* Read-only */
Uint16 pitch; /* Read-only */
void *pixels; /* Read-write */
int offset; /* Private */
/* Hardware-specific surface info */
struct private_hwdata *hwdata;
/* clipping information */
SDL_Rect clip_rect; /* Read-only */
Uint32 unused1; /* for binary compatibility */
/* Allow recursive locks */
Uint32 locked; /* Private */
/* info for fast blit mapping to other surfaces */
/// struct SDL_BlitMap *map; /* Private */
/* format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /* Private */
/* Reference count -- used when freeing surface */
int refcount; /* Read-mostly */
} SDL_Surface;
#define SDL_SWSURFACE 0x00000000
#define SDL_HWSURFACE 0x00000001
#define SDL_FULLSCREEN 0x80000000
// EOF

78
backends/gp32/portdefs.h Normal file
View File

@ -0,0 +1,78 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
extern "C" {
#include "h/gpfont.h"
#include "h/gpfont_port.h"
#include "h/gpgraphic.h"
#include "h/gpmm.h"
#include "h/gpmem.h"
#include "h/gpos_def.h"
#include "h/gpstdio.h"
#include "h/gpstdlib.h"
#include "h/gpdef.h"
#include "h/defines.h"
}
extern int gpprintf(const char *fmt, ...);
#define printf gpprintf
extern void *gpmalloc(size_t size);
extern void *gpcalloc(size_t nitems, size_t size);
extern void gpfree(void *block);
#define malloc gpmalloc
#define calloc gpcalloc //gm_calloc
#define free gpfree
/*#define memset gm_memset
#define memcopy gm_memcopy
#define strcpy gm_strcpy // uncomment?
#define strncpy gm_strncpy
#define strcat gm_strcat
#define sprintf gm_sprintf*/
#define assert(e) ((e) ? 0 : (printf("!AS: " #e " (%s, %d)\n", __FILE__, __LINE__)))
#define ASSERT assert
#define ENDLESSLOOP while (1)
#define FILE F_HANDLE
#define stderr NULL // hack...
#define stdout stderr
#define stdin stderr
extern FILE *gpfopen(const char *filename, const char *mode);
extern int gpfclose(FILE *stream);
extern int gpfseek(FILE *stream, long offset, int whence);
extern size_t gpfread(void *ptr, size_t size, size_t n, FILE *stream);
extern size_t gpfwrite(const void *ptr, size_t size, size_t n, FILE*stream);
extern long gpftell(FILE *stream);
extern void gpclearerr(FILE *stream);
extern int gpfeof(FILE *stream);
extern char *gpfgets(char *s, int n, FILE *stream);
extern int gpfflush(FILE *stream);
#define fopen gpfopen
#define fclose gpfclose
#define fseek gpfseek
#define fread gpfread
#define fwrite gpfwrite
#define ftell gpftell
#define clearerr gpclearerr
#define feof gpfeof
#define fgets gpfgets
extern int gpfprintf(FILE *stream, const char *fmt, ...);
#define fprintf gpfprintf
#define fflush gpfflush
extern void gphalt(int code=0);
#define exit gphalt
//#define error printf
#define time(x) (0) // fixme! (SIMON)
// EOF

29
backends/gp32/readme.txt Normal file
View File

@ -0,0 +1,29 @@
ScummVM port for GamePark 32
============================
Compiling instructions:
1. download and install Fenix's devkit advance (see Windows.txt)
2. get chn's gp32 devkit and install it (see readme-gp32.txt)
3. In Makefile change the line: build.rules: to
$(CP) backends/gp32/build.rules build.rules
4. run make
* In case you have installed devkitadv to a different directory
than it's default, you'll have to modify build.rules in backend/gp32/
To-do:
- add sound support
- make more friendly build.rules ? :)
For the latest source release visit the official ScummVM page:
http://www.scummvm.org/
You can get the precompiled gp32 executable (fxe) from my site:
http://people.inf.elte.hu/ph0x
Thanks to the following people for their help:
Endy, khalek and the rest ScummVM team members,
Jeff, DarkFader, Inopia, groepaz, chn, FireFly, #gp32dev
ph0x (ph0x@freemail.hu)

23
backends/gp32/stat.h Normal file
View File

@ -0,0 +1,23 @@
/* Header is not present in Windows CE SDK */
#include <sys/types.h>
struct stat {
_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
_dev_t st_rdev;
_off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define _S_IFDIR 0040000 /* directory */
#define S_IFDIR _S_IFDIR
int stat(const char *, struct stat *);