mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-28 15:26:12 +00:00
Update GP32 port. It still doesn't work very well...
svn-id: r22584
This commit is contained in:
parent
7eede3c510
commit
f38af30d6a
@ -28,7 +28,7 @@ CFLAGS = -marm -march=armv4t -mtune=arm920 -mapcs \
|
||||
-mno-thumb-interwork \
|
||||
-I$(GPSDK)/include \
|
||||
-g \
|
||||
-O2 \
|
||||
-O \
|
||||
-fomit-frame-pointer
|
||||
# -ffast-math \
|
||||
# -fshort-double
|
||||
|
@ -46,8 +46,64 @@ public:
|
||||
|
||||
virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
||||
virtual AbstractFilesystemNode *parent() const;
|
||||
virtual AbstractFilesystemNode *child(const String &name) const;
|
||||
};
|
||||
|
||||
#define MAX_PATH_SIZE 256
|
||||
|
||||
const char gpRootPath[] = "gp:\\";
|
||||
//char gpCurrentPath[MAX_PATH_SIZE] = "gp:\\"; // must end with '\'
|
||||
|
||||
int gpMakePath(const char *path, char *convPath) {
|
||||
// copy root or current directory
|
||||
const char *p;
|
||||
if ((*path == '/') || (*path == '\\')) {
|
||||
path++;
|
||||
p = gpRootPath;
|
||||
while (*p)
|
||||
*convPath++ = *p++;
|
||||
}// else
|
||||
// p = gpCurrentPath;
|
||||
|
||||
//while (*p)
|
||||
// *convPath++ = *p++;
|
||||
|
||||
// add filenames/directories. remove "." & "..", replace "/" with "\"
|
||||
do {
|
||||
switch (*path) {
|
||||
case 0:
|
||||
case '/':
|
||||
case '\\':
|
||||
if (*(convPath - 1) == '\\') {
|
||||
// already ends with '\'
|
||||
} else if ((*(convPath - 2) == '\\') && (*(convPath - 1) == '.')) {
|
||||
convPath--; // remove '.' and end with '\'
|
||||
} else if ((*(convPath - 3) == '\\') && (*(convPath - 2) == '.') && (*(convPath - 1) == '.')) {
|
||||
convPath -= 3; // remove "\.."
|
||||
if (*(convPath - 1) == ':')
|
||||
*convPath++ = '\\'; // "gp:" -> "gp:\"
|
||||
else
|
||||
while (*(convPath - 1) != '\\')
|
||||
convPath--; // remove one directory and end with '\'
|
||||
} else {
|
||||
*convPath++ = '\\'; // just add '\'
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
*convPath++ = *path;
|
||||
break;
|
||||
}
|
||||
} while (*path++);
|
||||
|
||||
*convPath = '\\';
|
||||
|
||||
// *--convPath = 0; // remove last '\' and null-terminate
|
||||
*convPath = 0; // remove last '\' and null-terminate
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
||||
return AbstractFilesystemNode::getRoot();
|
||||
}
|
||||
@ -68,13 +124,19 @@ GP32FilesystemNode::GP32FilesystemNode() {
|
||||
}
|
||||
|
||||
GP32FilesystemNode::GP32FilesystemNode(const String &path) {
|
||||
_path = path;
|
||||
const char *dsplName = NULL, *pos = path.c_str();
|
||||
const char *dsplName = NULL, *pos = NULL;
|
||||
char convPath[256];
|
||||
|
||||
gpMakePath(path.c_str(), convPath);
|
||||
|
||||
_path = convPath;
|
||||
|
||||
pos = convPath;
|
||||
while (*pos)
|
||||
if (*pos++ == '\\')
|
||||
dsplName = pos;
|
||||
|
||||
BP("path name: %s", path.c_str());
|
||||
|
||||
BP("FS: path name: %s", path.c_str());
|
||||
|
||||
if (strcmp(path.c_str(), "gp:\\") == 0) {
|
||||
_isRoot = true;
|
||||
@ -89,9 +151,13 @@ bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
||||
assert(_isDirectory);
|
||||
|
||||
GPDIRENTRY dirEntry;
|
||||
GPFILEATTR attr;
|
||||
|
||||
GP32FilesystemNode entry;
|
||||
|
||||
uint32 read;
|
||||
|
||||
if (mode == AbstractFilesystemNode::kListAll)
|
||||
if (mode == FilesystemNode::kListAll)
|
||||
LP("listDir(kListAll)");
|
||||
else
|
||||
LP("listDir(kListDirectoriesOnly)");
|
||||
@ -102,19 +168,16 @@ bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
||||
while (GpDirEnumList(listDir.c_str(), startIdx++, 1, &dirEntry, &read) == SM_OK) {
|
||||
if (dirEntry.name[0] == '.')
|
||||
continue;
|
||||
GP32FilesystemNode entry;
|
||||
entry._displayName = dirEntry.name;
|
||||
entry._path = _path;
|
||||
entry._path += dirEntry.name;
|
||||
|
||||
GPFILEATTR attr;
|
||||
String fileName(entry._path);
|
||||
GpFileAttr(fileName.c_str(), &attr);
|
||||
entry._isDirectory = attr.attr & (1<<4);
|
||||
GpFileAttr(entry._path.c_str(), &attr);
|
||||
entry._isDirectory = attr.attr & (1 << 4);
|
||||
|
||||
// Honor the chosen mode
|
||||
if ((mode == kListFilesOnly && entry._isDirectory) ||
|
||||
(mode == kListDirectoriesOnly && !entry._isDirectory))
|
||||
if ((mode == FilesystemNode::kListFilesOnly && entry._isDirectory) ||
|
||||
(mode == FilesystemNode::kListDirectoriesOnly && !entry._isDirectory))
|
||||
continue;
|
||||
|
||||
if (entry._isDirectory)
|
||||
@ -126,58 +189,45 @@ bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
AbstractFilesystemNode *GP32FilesystemNode::parent() const {
|
||||
if (_isRoot)
|
||||
return new GP32FilesystemNode(this);
|
||||
|
||||
GP32FilesystemNode *p = new GP32FilesystemNode();
|
||||
|
||||
const char *slash = NULL;
|
||||
const char *cnt = _path.c_str();
|
||||
|
||||
while (*cnt) {
|
||||
if (*cnt == '\\')
|
||||
slash = cnt;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
p->_path = String(_path.c_str(), slash - _path.c_str());
|
||||
p->_isDirectory = true;
|
||||
p->_displayName = slash + 1;
|
||||
return p;
|
||||
}
|
||||
*/
|
||||
|
||||
const char *lastPathComponent(const Common::String &str) {
|
||||
const char *start = str.c_str();
|
||||
const char *cur = start + str.size() - 2;
|
||||
|
||||
while (cur > start && *cur != '\\') { //ph0x
|
||||
while (cur > start && *cur != '\\') {
|
||||
--cur;
|
||||
}
|
||||
|
||||
return cur+1;
|
||||
return cur + 1;
|
||||
}
|
||||
|
||||
AbstractFilesystemNode *GP32FilesystemNode::parent() const {
|
||||
if(_isRoot)
|
||||
return 0;
|
||||
|
||||
GP32FilesystemNode *p = new GP32FilesystemNode();
|
||||
|
||||
// Root node is its own parent. Still we can't just return this
|
||||
// as the GUI code will call delete on the old node.
|
||||
if (_path != "gp:\\") {
|
||||
if (_path.size() > 4) {
|
||||
const char *start = _path.c_str();
|
||||
const char *end = lastPathComponent(_path);
|
||||
|
||||
p->_path = Common::String(start, end - start);
|
||||
p->_path = String(start, end - start);
|
||||
p->_isDirectory = true;
|
||||
p->_displayName = lastPathComponent(p->_path);
|
||||
p->_isRoot = true;
|
||||
} else {
|
||||
p->_isRoot = false;
|
||||
p->_path = _path;
|
||||
p->_displayName = _displayName;
|
||||
}
|
||||
p->_isDirectory = true;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
AbstractFilesystemNode *GP32FilesystemNode::child(const String &name) const {
|
||||
// FIXME: Pretty lame implementation! We do no error checking to speak
|
||||
// of, do not check if this is a special node, etc.
|
||||
assert(_isDirectory);
|
||||
String newPath(_path);
|
||||
if (_path.lastChar() != '\\')
|
||||
newPath += '\\';
|
||||
newPath += name;
|
||||
GP32FilesystemNode *p = new GP32FilesystemNode(newPath);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ void writeConfigVars() {
|
||||
g_vars.fmQuality = currentSetting[2];
|
||||
g_vars.sampleRate = sampleTable[currentSetting[3]];
|
||||
|
||||
if (!file.open("scummvm.cfg", Common::File::kFileWriteMode, "gp:\\gpetc\\")) {
|
||||
if (!file.open("gp:\\gpetc\\scummvm.cfg", Common::File::kFileWriteMode)) {
|
||||
return;
|
||||
}
|
||||
file.writeByte(currentSetting[0]);
|
||||
@ -64,14 +64,14 @@ void writeConfigVars() {
|
||||
|
||||
void readConfigVars() {
|
||||
Common::File file;
|
||||
if (!file.exists("scummvm.cfg", "gp:\\gpetc\\")) {
|
||||
if (!file.exists("gp:\\gpetc\\scummvm.cfg")) {
|
||||
currentSetting[0] = 2;
|
||||
currentSetting[1] = 5;
|
||||
currentSetting[2] = 1;
|
||||
currentSetting[3] = 1;
|
||||
writeConfigVars();
|
||||
} else {
|
||||
if (!file.open("scummvm.cfg", Common::File::kFileReadMode, "gp:\\gpetc\\")) {
|
||||
if (!file.open("gp:\\gpetc\\scummvm.cfg", Common::File::kFileReadMode)) {
|
||||
return;
|
||||
}
|
||||
currentSetting[0] = file.readByte();
|
||||
|
@ -136,12 +136,12 @@ void OSystem_GP32::initSize(uint width, uint height) {
|
||||
}
|
||||
|
||||
int16 OSystem_GP32::getHeight() {
|
||||
NP("OSys::getHeight()");
|
||||
//NP("OSys::getHeight()");
|
||||
return _screenHeight;
|
||||
}
|
||||
|
||||
int16 OSystem_GP32::getWidth() {
|
||||
NP("OSys::getWidth()");
|
||||
//NP("OSys::getWidth()");
|
||||
return _screenWidth;
|
||||
}
|
||||
|
||||
@ -209,6 +209,7 @@ void OSystem_GP32::copyRectToScreen(const byte *src, int pitch, int x, int y, in
|
||||
void OSystem_GP32::updateScreen() {
|
||||
uint16 *buffer;
|
||||
//TODO: adjust shakePos
|
||||
NP("updateScreen");
|
||||
|
||||
// draw gamescreen
|
||||
buffer = &_tmpScreen[240 - _screenHeight];
|
||||
@ -244,13 +245,12 @@ void OSystem_GP32::updateScreen() {
|
||||
gpd_drawPixel16(_tmpScreen, mX + x, mY + y, _currentPalette[_mouseBuf[y * _mouseWidth + x]]);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: draw softkeyboard
|
||||
|
||||
gp_flipScreen();
|
||||
_hwScreen = frameBuffer1;
|
||||
_tmpScreen = frameBuffer2;
|
||||
//memcpy(_hwScreen, _tmpScreen, LCD_WIDTH * LCD_HEIGHT * sizeof(uint16));
|
||||
//TODO: draw softkeyboard
|
||||
//gp_flipScreen();
|
||||
//_hwScreen = frameBuffer1;
|
||||
//_tmpScreen = frameBuffer2;
|
||||
memcpy(_hwScreen, _tmpScreen, LCD_WIDTH * LCD_HEIGHT * sizeof(uint16));
|
||||
}
|
||||
|
||||
void OSystem_GP32::setShakePos(int shakeOffset) {
|
||||
@ -258,11 +258,13 @@ void OSystem_GP32::setShakePos(int shakeOffset) {
|
||||
}
|
||||
|
||||
void OSystem_GP32::showOverlay() {
|
||||
NP("OSys::showOverlay()");
|
||||
_overlayVisible = true;
|
||||
clearOverlay();
|
||||
}
|
||||
|
||||
void OSystem_GP32::hideOverlay() {
|
||||
NP("OSys::hideOverlay()");
|
||||
_overlayVisible = false;
|
||||
clearOverlay();
|
||||
_forceFull = true;
|
||||
@ -295,6 +297,7 @@ void OSystem_GP32::grabOverlay(OverlayColor *buf, int pitch)
|
||||
}
|
||||
|
||||
void OSystem_GP32::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
|
||||
NP("OSys::copyRectToOverlay()");
|
||||
OverlayColor *dst = (OverlayColor *)_overlayBuffer + y * _overlayWidth + x;
|
||||
do {
|
||||
memcpy(dst, buf, w * sizeof(uint16));
|
||||
@ -304,12 +307,12 @@ void OSystem_GP32::copyRectToOverlay(const OverlayColor *buf, int pitch, int x,
|
||||
}
|
||||
|
||||
int16 OSystem_GP32::getOverlayHeight() {
|
||||
NP("OSys::getOverlayHeight()");
|
||||
//NP("OSys::getOverlayHeight()");
|
||||
return getHeight();
|
||||
}
|
||||
|
||||
int16 OSystem_GP32::getOverlayWidth() {
|
||||
NP("OSys::getOverlayWidth()");
|
||||
//NP("OSys::getOverlayWidth()");
|
||||
return getWidth();
|
||||
}
|
||||
|
||||
@ -343,7 +346,7 @@ void OSystem_GP32::warpMouse(int x, int y) {
|
||||
}
|
||||
|
||||
void OSystem_GP32::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
|
||||
//NP("OSys::setMouseCursor()");
|
||||
NP("OSys::setMouseCursor()");
|
||||
_mouseWidth = w;
|
||||
_mouseHeight = h;
|
||||
|
||||
@ -443,6 +446,7 @@ void OSystem_GP32::fillMouseEvent(Event &event, int x, int y) {
|
||||
}
|
||||
|
||||
bool OSystem_GP32::pollEvent(Event &event) {
|
||||
NP("OSys::pollEvent()");
|
||||
GP32BtnEvent ev;
|
||||
|
||||
handleKbdMouse();
|
||||
@ -629,20 +633,20 @@ void OSystem_GP32::setTimerCallback(TimerProc callback, int interval) {
|
||||
}
|
||||
|
||||
OSystem::MutexRef OSystem_GP32::createMutex() {
|
||||
NP("OSys::createMutex()");
|
||||
// NP("OSys::createMutex()");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OSystem_GP32::lockMutex(MutexRef mutex) {
|
||||
NP("OSys::lockMutex()");
|
||||
// NP("OSys::lockMutex()");
|
||||
}
|
||||
|
||||
void OSystem_GP32::unlockMutex(MutexRef mutex) {
|
||||
NP("OSys::unlockMutex()");
|
||||
// NP("OSys::unlockMutex()");
|
||||
}
|
||||
|
||||
void OSystem_GP32::deleteMutex(MutexRef mutex) {
|
||||
NP("OSys::deleteMutex()");
|
||||
// NP("OSys::deleteMutex()");
|
||||
}
|
||||
|
||||
bool OSystem_GP32::setSoundCallback(SoundProc proc, void *param) {
|
||||
@ -650,8 +654,8 @@ bool OSystem_GP32::setSoundCallback(SoundProc proc, void *param) {
|
||||
|
||||
GPSOUNDBUF gpSoundBuf;
|
||||
|
||||
ConfMan.set("FM_medium_quality", (g_vars.fmQuality == FM_QUALITY_MED));
|
||||
ConfMan.set("FM_high_quality", (g_vars.fmQuality == FM_QUALITY_HI));
|
||||
ConfMan.setBool("FM_medium_quality", (g_vars.fmQuality == FM_QUALITY_MED));
|
||||
ConfMan.setBool("FM_high_quality", (g_vars.fmQuality == FM_QUALITY_HI));
|
||||
//ConfMan.set("output_rate", (int)g_vars.sampleRate);
|
||||
|
||||
if (ConfMan.hasKey("output_rate"))
|
||||
|
@ -57,7 +57,7 @@ void _dprintf(const char *s, ...) {
|
||||
|
||||
if (debnext == DEBUG_MAX)
|
||||
debnext = 0;
|
||||
gp_fillRect(frameBuffer1, 0, 243 - (DEBUG_MAX * 8) - 4, 320, (DEBUG_MAX * 10), 0);
|
||||
gp_fillRect(frameBuffer1, 0, 243 - (DEBUG_MAX * 8) - 4, 320, (DEBUG_MAX * 8), 0);
|
||||
|
||||
for (deb = debnext, deba = 0; deb < DEBUG_MAX; deb++, deba++) {
|
||||
//gp_fillRect(frameBuffer1, 0, (243 - (DEBUG_MAX * 8) - 4) + 8 * deba, 320, 8, 0);
|
||||
@ -73,80 +73,17 @@ void _dprintf(const char *s, ...) {
|
||||
|
||||
//////////////////
|
||||
//File functions
|
||||
// FOR LATER USE
|
||||
/*
|
||||
#define SM_PATH_SIZE 256
|
||||
|
||||
const char smRootPath[] = "gp:\\";
|
||||
char smCurrentPath[SM_PATH_SIZE] = "gp:\\"; // must end with '\'
|
||||
|
||||
int smMakePath(const char *path, char *smPath) {
|
||||
// copy root or current directory
|
||||
{
|
||||
const char *p;
|
||||
if ((*path == '/') || (*path == '\\'))
|
||||
{
|
||||
path++;
|
||||
p = smRootPath;
|
||||
}
|
||||
else
|
||||
p = smCurrentPath;
|
||||
while (*p) *smPath++ = *p++;
|
||||
}
|
||||
|
||||
// add filenames/directories. remove "." & ".."
|
||||
do
|
||||
{
|
||||
switch (*path)
|
||||
{
|
||||
case 0:
|
||||
case '/':
|
||||
case '\\':
|
||||
if (*(smPath-1) == '\\')
|
||||
{
|
||||
// already ends with '\'
|
||||
}
|
||||
else if ((*(smPath-1) == '.') && (*(smPath-2) == '\\'))
|
||||
{
|
||||
smPath--; // remove '.' and end with '\'
|
||||
}
|
||||
else if ((*(smPath-1) == '.') && (*(smPath-2) == '.') && (*(smPath-3) == '\\'))
|
||||
{
|
||||
smPath -= 3; // remove "\.."
|
||||
if (*(smPath-1) == ':') *smPath++ = '\\'; // "dev0:" -> "dev0:\"
|
||||
else while (*(smPath-1) != '\\') smPath--; // remove one directory and end with '\'
|
||||
}
|
||||
else
|
||||
{
|
||||
*smPath++ = '\\'; // just add '\'
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
*smPath++ = *path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (*path++);
|
||||
|
||||
*smPath = '\\';
|
||||
|
||||
// *--smPath = 0; // remove last '\' and null-terminate
|
||||
*smPath = 0; // remove last '\' and null-terminate
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
GPFILE *gp_fopen(const char *fileName, const char *openMode) {
|
||||
//FIXME: allocation, mode, malloc -> new
|
||||
uint32 mode;
|
||||
GPFILE *file;
|
||||
ERR_CODE err;
|
||||
char s[256];
|
||||
char tempPath[256];
|
||||
|
||||
if (!strchr(fileName, '.')) {
|
||||
sprintf(s, "%s.", fileName);
|
||||
fileName = s;
|
||||
sprintf(tempPath, "%s.", fileName);
|
||||
fileName = tempPath;
|
||||
}
|
||||
|
||||
file = (GPFILE *)malloc(sizeof(GPFILE));
|
||||
@ -388,14 +325,21 @@ void gp_free(void *block) {
|
||||
// GP32 stuff
|
||||
//////////////////////////////////////////////////
|
||||
static char usedMemStr[16];
|
||||
int gUsedMem = 0;
|
||||
int gUsedMem = 1024 * 1024;
|
||||
|
||||
//#define CLEAN_MEMORY_WITH_0xE7
|
||||
//#define CHECK_FREE_MEMORY
|
||||
|
||||
void *operator new(size_t size) {
|
||||
// printf("BP:operator new(%d)", size);
|
||||
void *ptr = malloc(size);
|
||||
|
||||
void *ptr = memset(malloc(size), 0xE7, size);
|
||||
|
||||
#if 0
|
||||
#if defined(CLEAN_MEMORY_WITH_0xE7)
|
||||
if(ptr != NULL) {
|
||||
memset(ptr, 0xE7, size);
|
||||
}
|
||||
#endif
|
||||
#if defined(CHECK_FREE_MEMORY)
|
||||
// Check free memory.
|
||||
gUsedMem = ((int)(ptr) + size) - 0xc000000;
|
||||
|
||||
@ -404,7 +348,7 @@ void *operator new(size_t size) {
|
||||
gp_fillRect(frameBuffer1, 0, 0, 64, 12, 0);
|
||||
gp_textOut(frameBuffer1, 0, 0, usedMemStr, 0xfffff);
|
||||
#endif
|
||||
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ bool gp_pollButtonEvent(GP32BtnEvent *ev) {
|
||||
}
|
||||
|
||||
eventQueue.get(ev);
|
||||
// GPDEBUG("Event poll %d %d", ev->type, ev->button);
|
||||
GPDEBUG("Event poll %d %d", ev->type, ev->button);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user