You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
2.9 KiB
124 lines
2.9 KiB
#include "uniquake.h"
|
|
|
|
#include "../../code/quakedef.h"
|
|
|
|
typedef struct unity_syscalls_s
|
|
{
|
|
void *target;
|
|
|
|
void(*SysPrint)(void *target, const char *msg);
|
|
void(*SysError)(void *target, const char *msg);
|
|
void(*SysQuit)(void *target);
|
|
double(*SysFloatTime)(void *target);
|
|
|
|
int(*SysFileOpenRead)(void *target, char *path, int *hndl);
|
|
int(*SysFileOpenWrite)(void *target, char *path);
|
|
void(*SysFileClose)(void *target, int handle);
|
|
void(*SysFileSeek)(void *target, int handle, int position);
|
|
int(*SysFileRead)(void *target, int handle, void *dest, int count);
|
|
int(*SysFileWrite)(void *target, int handle, void *data, int count);
|
|
int(*SysFileTime)(void *target, char *path);
|
|
void(*SysMkDir)(void *target, char *path);
|
|
} unity_syscalls_t;
|
|
|
|
const unity_syscalls_t *unity_syscalls;
|
|
|
|
void Sys_Error(char *error, ...)
|
|
{
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start(argptr, error);
|
|
vsprintf(text, error, argptr);
|
|
va_end(argptr);
|
|
|
|
unity_syscalls->SysError(unity_syscalls->target, text);
|
|
}
|
|
|
|
void Sys_Printf(char *fmt, ...)
|
|
{
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start(argptr, fmt);
|
|
vsprintf(text, fmt, argptr);
|
|
va_end(argptr);
|
|
|
|
unity_syscalls->SysPrint(unity_syscalls->target, text);
|
|
}
|
|
|
|
void Sys_Quit(void)
|
|
{
|
|
unity_syscalls->SysQuit(unity_syscalls->target);
|
|
}
|
|
|
|
double Sys_FloatTime(void)
|
|
{
|
|
return unity_syscalls->SysFloatTime(unity_syscalls->target);
|
|
}
|
|
|
|
int Sys_FileOpenRead(char *path, int *hndl)
|
|
{
|
|
int t, retval;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
retval = unity_syscalls->SysFileOpenRead(unity_syscalls->target, path, hndl);
|
|
VID_ForceLockState(t);
|
|
return retval;
|
|
}
|
|
|
|
int Sys_FileOpenWrite(char *path)
|
|
{
|
|
int t, retval;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
retval = unity_syscalls->SysFileOpenWrite(unity_syscalls->target, path);
|
|
VID_ForceLockState(t);
|
|
return retval;
|
|
}
|
|
|
|
void Sys_FileClose(int handle)
|
|
{
|
|
int t;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
unity_syscalls->SysFileClose(unity_syscalls->target, handle);
|
|
VID_ForceLockState(t);
|
|
}
|
|
|
|
void Sys_FileSeek(int handle, int position)
|
|
{
|
|
int t;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
unity_syscalls->SysFileSeek(unity_syscalls->target, handle, position);
|
|
VID_ForceLockState(t);
|
|
}
|
|
|
|
int Sys_FileRead(int handle, void *dest, int count)
|
|
{
|
|
int t, retval;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
retval = unity_syscalls->SysFileRead(unity_syscalls->target, handle, dest, count);
|
|
VID_ForceLockState(t);
|
|
return retval;
|
|
}
|
|
|
|
int Sys_FileWrite(int handle, void *data, int count)
|
|
{
|
|
int t, retval;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
retval = unity_syscalls->SysFileWrite(unity_syscalls->target, handle, data, count);
|
|
VID_ForceLockState(t);
|
|
return retval;
|
|
}
|
|
|
|
int Sys_FileTime(char *path)
|
|
{
|
|
int t, retval;
|
|
t = VID_ForceUnlockedAndReturnState();
|
|
retval = unity_syscalls->SysFileTime(unity_syscalls->target, path);
|
|
VID_ForceLockState(t);
|
|
return retval;
|
|
}
|
|
|
|
void Sys_mkdir(char *path)
|
|
{
|
|
unity_syscalls->SysMkDir(unity_syscalls->target, path);
|
|
}
|