More fixes

This commit is contained in:
UnknownShadow200 2024-06-03 18:15:17 +10:00
parent bccf27f29f
commit 2fe99c24ac
4 changed files with 38 additions and 95 deletions

2
.gitignore vendored
View File

@ -120,6 +120,8 @@ TestResult.xml
[Rr]eleasePS/ [Rr]eleasePS/
dlldata.c dlldata.c
retro68scripts/
*_i.c *_i.c
*_p.c *_p.c
*_i.h *_i.h

View File

@ -117,15 +117,8 @@ cc_uint64 Stopwatch_Measure(void) {
cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) {
if (end < beg) return 0; if (end < beg) return 0;
return end - beg; return end - beg;
//return (end - beg) / 1000;
} }
void Stopwatch_Init(void) {
//TODO
cc_uint64 doSomething = Stopwatch_Measure();
}
/*########################################################################################################################* /*########################################################################################################################*
*-----------------------------------------------------Directory/File------------------------------------------------------* *-----------------------------------------------------Directory/File------------------------------------------------------*
@ -144,54 +137,40 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
static cc_result File_Do(cc_file* file, const cc_string* path, int mode) {
char str[NATIVE_STR_LEN];
String_EncodeUtf8(str, path);
*file = open(str, mode, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
return *file == -1 ? errno : 0;
}
cc_result File_Open(cc_file* file, const cc_string* path) { cc_result File_Open(cc_file* file, const cc_string* path) {
return File_Do(file, path, O_RDONLY); return ERR_NOT_SUPPORTED;
} }
cc_result File_Create(cc_file* file, const cc_string* path) { cc_result File_Create(cc_file* file, const cc_string* path) {
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC); return ERR_NOT_SUPPORTED;
} }
cc_result File_OpenOrCreate(cc_file* file, const cc_string* path) { cc_result File_OpenOrCreate(cc_file* file, const cc_string* path) {
return File_Do(file, path, O_RDWR | O_CREAT); return ERR_NOT_SUPPORTED;
} }
cc_result File_Read(cc_file file, void* data, cc_uint32 count, cc_uint32* bytesRead) { cc_result File_Read(cc_file file, void* data, cc_uint32 count, cc_uint32* bytesRead) {
*bytesRead = read(file, data, count); return ERR_NOT_SUPPORTED;
return *bytesRead == -1 ? errno : 0;
} }
cc_result File_Write(cc_file file, const void* data, cc_uint32 count, cc_uint32* bytesWrote) { cc_result File_Write(cc_file file, const void* data, cc_uint32 count, cc_uint32* bytesWrote) {
*bytesWrote = write(file, data, count); return ERR_NOT_SUPPORTED;
return *bytesWrote == -1 ? errno : 0;
} }
cc_result File_Close(cc_file file) { cc_result File_Close(cc_file file) {
return close(file) == -1 ? errno : 0; return ERR_NOT_SUPPORTED;
} }
cc_result File_Seek(cc_file file, int offset, int seekType) { cc_result File_Seek(cc_file file, int offset, int seekType) {
static cc_uint8 modes[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; return ERR_NOT_SUPPORTED;
return lseek(file, offset, modes[seekType]) == -1 ? errno : 0;
} }
cc_result File_Position(cc_file file, cc_uint32* pos) { cc_result File_Position(cc_file file, cc_uint32* pos) {
*pos = lseek(file, 0, SEEK_CUR); return ERR_NOT_SUPPORTED;
return *pos == -1 ? errno : 0;
} }
cc_result File_Length(cc_file file, cc_uint32* len) { cc_result File_Length(cc_file file, cc_uint32* len) {
struct stat st; return ERR_NOT_SUPPORTED;
if (fstat(file, &st) == -1) { *len = -1; return errno; }
*len = st.st_size; return 0;
} }
@ -309,40 +288,25 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
/*########################################################################################################################* /*########################################################################################################################*
*-----------------------------------------------------Process/Module------------------------------------------------------* *-----------------------------------------------------Process/Module------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
cc_bool Process_OpenSupported = true; cc_bool Process_OpenSupported = false;
static cc_result Process_RawStart(const char* path, char** argv) {
// TODO
return ERR_NOT_SUPPORTED;
}
static cc_result Process_RawGetExePath(char* path, int* len);
/*
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
char raw[GAME_MAX_CMDARGS][NATIVE_STR_LEN];
char path[NATIVE_STR_LEN];
int i, j, len = 0;
char* argv[15];
cc_result res = Process_RawGetExePath(path, &len);
if (res) return res;
path[len] = '\0';
argv[0] = path;
for (i = 0, j = 1; i < numArgs; i++, j++) {
String_EncodeUtf8(raw[i], &args[i]);
argv[j] = raw[i];
}
argv[j] = NULL;
return Process_RawStart(path, argv);
}
*/
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE]; static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
static int gameNumArgs; static int gameNumArgs;
static cc_bool gameHasArgs;
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
int count = gameNumArgs;
for (int i = 0; i < count; i++)
{
args[i] = String_FromRawArray(gameArgs[i]);
}
// clear arguments so after game is closed, launcher is started
gameNumArgs = 0;
return count;
}
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
return 0;
}
cc_result Process_StartGame2(const cc_string* args, int numArgs) { cc_result Process_StartGame2(const cc_string* args, int numArgs) {
for (int i = 0; i < numArgs; i++) for (int i = 0; i < numArgs; i++)
@ -350,8 +314,6 @@ cc_result Process_StartGame2(const cc_string* args, int numArgs) {
String_CopyToRawArray(gameArgs[i], &args[i]); String_CopyToRawArray(gameArgs[i], &args[i]);
} }
Platform_LogConst("START CLASSICUBE");
gameHasArgs = true;
gameNumArgs = numArgs; gameNumArgs = numArgs;
return 0; return 0;
} }
@ -442,16 +404,10 @@ cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
} }
#endif #endif
static void Platform_InitSpecific(void) {
Platform_SingleProcess = true;
}
void Platform_Init(void) { void Platform_Init(void) {
printf("Macintosh ClassiCube has started to init.\n"); // Test, just to see if it's actually *running* at all. puts("Init phase 1");
Platform_LoadSysFonts(); Platform_LoadSysFonts();
Stopwatch_Init(); puts("Init phase 2");
Platform_ReadonlyFilesystem = true;
} }
cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) { cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
@ -461,23 +417,4 @@ cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) { cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
return ERR_NOT_SUPPORTED; return ERR_NOT_SUPPORTED;
} }
/*########################################################################################################################*
*-----------------------------------------------------Configuration-------------------------------------------------------*
*#########################################################################################################################*/
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
int i, count;
argc--; argv++; /* skip executable path argument */
count = min(argc, GAME_MAX_CMDARGS);
for (i = 0; i < count; i++) {
args[i] = String_FromReadonly(argv[i]);
}
return count;
}
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
return 0;
}
#endif #endif

View File

@ -24,14 +24,17 @@ static cc_bool launcherMode;
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_PreInit(void) { } void Window_PreInit(void) { }
void Window_Init(void) { void Window_Init(void) {
puts("Init phase 3");
InitGraf(&qd.thePort); InitGraf(&qd.thePort);
InitFonts(); InitFonts();
InitWindows(); InitWindows();
InitMenus(); InitMenus();
InitDialogs(NULL); InitDialogs(NULL);
InitCursor(); InitCursor();
puts("Init phase 4");
FlushEvents(everyEvent, 0); FlushEvents(everyEvent, 0);
puts("Init phase 5");
Rect r = qd.screenBits.bounds; Rect r = qd.screenBits.bounds;
DisplayInfo.x = r.left; DisplayInfo.x = r.left;
@ -41,6 +44,7 @@ void Window_Init(void) {
DisplayInfo.ScaleX = 1.0f; DisplayInfo.ScaleX = 1.0f;
DisplayInfo.ScaleY = 1.0f; DisplayInfo.ScaleY = 1.0f;
puts("Init phase 6");
} }
void Window_Free(void) { } void Window_Free(void) { }

View File

@ -141,7 +141,7 @@ static int MapNativeKey(SDL_Keycode k) {
case SDLK_BACKSPACE: return CCKEY_BACKSPACE; case SDLK_BACKSPACE: return CCKEY_BACKSPACE;
case SDLK_TAB: return CCKEY_TAB; case SDLK_TAB: return CCKEY_TAB;
case SDLK_SPACE: return CCKEY_SPACE; case SDLK_SPACE: return CCKEY_SPACE;
case SDLK_QUOTE: return CCKEY_QUOTE; case SDLK_APOSTROPHE: return CCKEY_QUOTE;
case SDLK_EQUALS: return CCKEY_EQUALS; case SDLK_EQUALS: return CCKEY_EQUALS;
case SDLK_COMMA: return CCKEY_COMMA; case SDLK_COMMA: return CCKEY_COMMA;
case SDLK_MINUS: return CCKEY_MINUS; case SDLK_MINUS: return CCKEY_MINUS;
@ -151,7 +151,7 @@ static int MapNativeKey(SDL_Keycode k) {
case SDLK_LEFTBRACKET: return CCKEY_LBRACKET; case SDLK_LEFTBRACKET: return CCKEY_LBRACKET;
case SDLK_BACKSLASH: return CCKEY_BACKSLASH; case SDLK_BACKSLASH: return CCKEY_BACKSLASH;
case SDLK_RIGHTBRACKET: return CCKEY_RBRACKET; case SDLK_RIGHTBRACKET: return CCKEY_RBRACKET;
case SDLK_BACKQUOTE: return CCKEY_TILDE; case SDLK_GRAVE: return CCKEY_TILDE;
case SDLK_CAPSLOCK: return CCKEY_CAPSLOCK; case SDLK_CAPSLOCK: return CCKEY_CAPSLOCK;
case SDLK_PRINTSCREEN: return CCKEY_PRINTSCREEN; case SDLK_PRINTSCREEN: return CCKEY_PRINTSCREEN;
case SDLK_SCROLLLOCK: return CCKEY_SCROLLLOCK; case SDLK_SCROLLLOCK: return CCKEY_SCROLLLOCK;