Merge branch 'master' of github.com:nunuhara/xsystem4

This commit is contained in:
Nunuhara Cabbage
2023-03-07 18:21:21 -08:00
8 changed files with 17 additions and 28 deletions
+1
View File
@@ -106,6 +106,7 @@ union vm_value vm_copy(union vm_value v, enum ain_data_type type);
int vm_execute_ain(struct ain *program);
void vm_call(int fno, int struct_page);
int vm_time(void);
void vm_sleep(int ms);
void hll_call(int libno, int fno);
bool library_exists(int libno);
-1
View File
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <libgen.h>
#include <dirent.h>
#include <limits.h>
#include <assert.h>
+2 -1
View File
@@ -408,6 +408,7 @@ HLL_LIBRARY(DrawDungeon,
DRAW_DUNGEON_EXPORTS
);
HLL_WARN_UNIMPLEMENTED( , void, DrawDungeon14, SetRasterScroll, int surface, int type);
HLL_WARN_UNIMPLEMENTED( , void, DrawDungeon14, SetRasterAmp, int nSurface, float fAmp);
HLL_WARN_UNIMPLEMENTED( , void, DrawDungeon14, SetLapFilter, int surface, int type, int r, int g, int b);
@@ -431,7 +432,7 @@ HLL_LIBRARY(DrawDungeon14,
HLL_EXPORT(Init, DrawDungeon14_Init),
DRAW_DUNGEON_EXPORTS,
HLL_EXPORT(GetWalked, dungeon_get_walked),
HLL_TODO_EXPORT(SetRasterScroll, DrawDungeon14_SetRasterScroll),
HLL_EXPORT(SetRasterScroll, DrawDungeon14_SetRasterScroll),
HLL_EXPORT(SetRasterAmp, DrawDungeon14_SetRasterAmp),
HLL_EXPORT(SetLapFilter, DrawDungeon14_SetLapFilter),
HLL_EXPORT(GetDrawMapObjectFlag, DrawDungeon14_GetDrawMapObjectFlag),
+2 -7
View File
@@ -14,12 +14,11 @@
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
#include <time.h>
#include "system4/string.h"
#include "hll.h"
#include "input.h"
#include "vm.h"
static void handle_events_throttled(void)
{
@@ -28,11 +27,7 @@ static void handle_events_throttled(void)
static int count;
if (++count == 30) {
count = 0;
struct timespec ts = {
.tv_sec = 0,
.tv_nsec = 10000000L
};
nanosleep(&ts, NULL);
vm_sleep(10);
}
handle_events();
}
+2 -5
View File
@@ -17,6 +17,7 @@
#include <time.h>
#include "hll.h"
#include "vm.h"
HLL_WARN_UNIMPLEMENTED(1, int, Timer, Init, void *imainsystem);
@@ -28,11 +29,7 @@ static int Timer_Get(void)
static void Timer_Wait(int time)
{
struct timespec ts = {
.tv_sec = time / 1000,
.tv_nsec = (time % 1000) * 1000000L
};
nanosleep(&ts, NULL);
vm_sleep(time);
}
static void Timer_GetDayTime(int *year, int *month, int *day_of_week, int *day,
+3 -8
View File
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <libgen.h>
#include <dirent.h>
#include <ctype.h>
#include <getopt.h>
@@ -265,7 +264,7 @@ static bool config_init_with_ini(const char *ini_path)
if (!config.ain_filename)
ERROR("No AIN filename specified in %s", ini_path);
char *tmp = strdup(ini_path);
config.game_dir = strdup(dirname(tmp));
config.game_dir = strdup(path_dirname(tmp));
free(tmp);
config_init();
return true;
@@ -285,12 +284,8 @@ static bool config_init_with_dir(const char *dir)
static void config_init_with_ain(const char *ain_path)
{
char *basename_tmp = strdup(ain_path);
char *dirname_tmp = strdup(ain_path);
config.ain_filename = strdup(basename(basename_tmp));
config.game_dir = strdup(dirname(dirname_tmp));
free(basename_tmp);
free(dirname_tmp);
config.ain_filename = strdup(path_basename(ain_path));
config.game_dir = strdup(path_dirname(ain_path));
config_init();
}
+6 -5
View File
@@ -570,11 +570,7 @@ static void system_call(enum syscall_code code)
}
case SYS_SLEEP: {// system.Sleep(int nSleep)
int ms = stack_pop().i;
struct timespec ts = {
.tv_sec = ms / 1000,
.tv_nsec = (ms % 1000) * 1000000L
};
nanosleep(&ts, NULL);
vm_sleep(ms);
break;
}
case SYS_RESUME_READ_COMMENT: {// system.ResumeReadComment(string szKeyName, string szFileName, ref array@string aszComment)
@@ -2374,6 +2370,11 @@ int vm_time(void)
return (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
}
void vm_sleep(int ms)
{
SDL_Delay(ms);
}
_Noreturn void vm_exit(int code)
{
vm_free();