From 5d6f148e1b30ece2dd219d90fedc9abc36075317 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Tue, 31 Dec 2019 17:50:40 -0800 Subject: [PATCH] Reorganize project file structure - Create separate directories for source and header files. - Build code shared between xsystem4 and aindump as a static library. - Create header dirs gfx/ system4/ and vm/ - Make CG.c/h usable without a running VM --- .gitignore | 3 +- README.md | 13 +- audio.h => include/audio.h | 0 cJSON.h => include/cJSON.h | 0 debugger.h => include/debugger.h | 0 effect.h => include/effect.h | 0 file.h => include/file.h | 0 gfx_core.h => include/gfx/gfx.h | 2 +- gfx_private.h => include/gfx/private.h | 2 +- graphics.h => include/gfx/types.h | 0 ini.h => include/ini.h | 0 input.h => include/input.h | 0 little_endian.h => include/little_endian.h | 0 queue.h => include/queue.h | 0 sact.h => include/sact.h | 4 +- savedata.h => include/savedata.h | 0 system4.h => include/system4.h | 0 ain.h => include/system4/ain.h | 8 +- ald.h => include/system4/ald.h | 0 cg.h => include/system4/cg.h | 7 +- .../system4/instructions.h | 0 qnt.h => include/system4/qnt.h | 5 +- s2utbl.h => include/system4/s2utbl.h | 0 vm_string.h => include/system4/string.h | 3 +- utfsjis.h => include/system4/utfsjis.h | 0 vm.h => include/vm.h | 1 + heap.h => include/vm/heap.h | 0 page.h => include/vm/page.h | 2 +- meson.build | 59 +------ ain.c => src/ain.c | 8 +- aindump.c => src/aindump.c | 27 ++- ald.c => src/ald.c | 2 +- audio.c => src/audio.c | 2 +- cJSON.c => src/cJSON.c | 0 cg.c => src/cg.c | 32 ++-- debug-ffi.c => src/debug-ffi.c | 4 +- debug-ffi.stub => src/debug-ffi.stub | 4 +- debugger.c => src/debugger.c | 7 +- draw.c => src/draw.c | 4 +- effect.c => src/effect.c | 2 +- file.c => src/file.c | 0 src/format.c | 160 ++++++++++++++++++ heap.c => src/heap.c | 5 +- {hll => src/hll}/ACXLoader.c | 3 +- {hll => src/hll}/AliceLogo.c | 0 {hll => src/hll}/AliceLogo2.c | 0 {hll => src/hll}/AliceLogo3.c | 0 {hll => src/hll}/Confirm2.c | 0 {hll => src/hll}/DrawGraph.c | 5 +- {hll => src/hll}/DrawPluginManager.c | 0 {hll => src/hll}/File.c | 10 +- {hll => src/hll}/Math.c | 1 - {hll => src/hll}/MsgLogManager.c | 0 {hll => src/hll}/MsgSkip.c | 0 {hll => src/hll}/OutputLog.c | 3 +- {hll => src/hll}/PlayMovie.c | 0 {hll => src/hll}/SACT2.c | 22 ++- {hll => src/hll}/SystemServiceEx.c | 2 +- {hll => src/hll}/hll.h | 8 +- ini.c => src/ini.c | 0 input.c => src/input.c | 4 +- instructions.c => src/instructions.c | 2 +- src/meson.build | 69 ++++++++ page.c => src/page.c | 8 +- qnt.c => src/qnt.c | 8 +- resume.c => src/resume.c | 5 +- sact_graphics.c => src/sact_graphics.c | 19 ++- savedata.c => src/savedata.c | 10 +- string.c => src/string.c | 142 +--------------- system.c => src/system.c | 2 +- system4.c => src/system4.c | 9 +- text.c => src/text.c | 6 +- utfsjis.c => src/utfsjis.c | 4 +- video.c => src/video.c | 8 +- vm.c => src/vm.c | 18 +- 75 files changed, 399 insertions(+), 335 deletions(-) rename audio.h => include/audio.h (100%) rename cJSON.h => include/cJSON.h (100%) rename debugger.h => include/debugger.h (100%) rename effect.h => include/effect.h (100%) rename file.h => include/file.h (100%) rename gfx_core.h => include/gfx/gfx.h (99%) rename gfx_private.h => include/gfx/private.h (96%) rename graphics.h => include/gfx/types.h (100%) rename ini.h => include/ini.h (100%) rename input.h => include/input.h (100%) rename little_endian.h => include/little_endian.h (100%) rename queue.h => include/queue.h (100%) rename sact.h => include/sact.h (98%) rename savedata.h => include/savedata.h (100%) rename system4.h => include/system4.h (100%) rename ain.h => include/system4/ain.h (98%) rename ald.h => include/system4/ald.h (100%) rename cg.h => include/system4/cg.h (90%) rename instructions.h => include/system4/instructions.h (100%) rename qnt.h => include/system4/qnt.h (98%) rename s2utbl.h => include/system4/s2utbl.h (100%) rename vm_string.h => include/system4/string.h (93%) rename utfsjis.h => include/system4/utfsjis.h (100%) rename vm.h => include/vm.h (98%) rename heap.h => include/vm/heap.h (100%) rename page.h => include/vm/page.h (99%) rename ain.c => src/ain.c (99%) rename aindump.c => src/aindump.c (94%) rename ald.c => src/ald.c (99%) rename audio.c => src/audio.c (99%) rename cJSON.c => src/cJSON.c (100%) rename cg.c => src/cg.c (83%) rename debug-ffi.c => src/debug-ffi.c (99%) rename debug-ffi.stub => src/debug-ffi.stub (98%) rename debugger.c => src/debugger.c (97%) rename draw.c => src/draw.c (99%) rename effect.c => src/effect.c (99%) rename file.c => src/file.c (100%) create mode 100644 src/format.c rename heap.c => src/heap.c (98%) rename {hll => src/hll}/ACXLoader.c (98%) rename {hll => src/hll}/AliceLogo.c (100%) rename {hll => src/hll}/AliceLogo2.c (100%) rename {hll => src/hll}/AliceLogo3.c (100%) rename {hll => src/hll}/Confirm2.c (100%) rename {hll => src/hll}/DrawGraph.c (99%) rename {hll => src/hll}/DrawPluginManager.c (100%) rename {hll => src/hll}/File.c (97%) rename {hll => src/hll}/Math.c (99%) rename {hll => src/hll}/MsgLogManager.c (100%) rename {hll => src/hll}/MsgSkip.c (100%) rename {hll => src/hll}/OutputLog.c (95%) rename {hll => src/hll}/PlayMovie.c (100%) rename {hll => src/hll}/SACT2.c (98%) rename {hll => src/hll}/SystemServiceEx.c (98%) rename {hll => src/hll}/hll.h (96%) rename ini.c => src/ini.c (100%) rename input.c => src/input.c (98%) rename instructions.c => src/instructions.c (99%) create mode 100644 src/meson.build rename page.c => src/page.c (99%) rename qnt.c => src/qnt.c (99%) rename resume.c => src/resume.c (99%) rename sact_graphics.c => src/sact_graphics.c (97%) rename savedata.c => src/savedata.c (98%) rename string.c => src/string.c (75%) rename system.c => src/system.c (98%) rename system4.c => src/system4.c (98%) rename text.c => src/text.c (99%) rename utfsjis.c => src/utfsjis.c (98%) rename video.c => src/video.c (99%) rename vm.c => src/vm.c (99%) diff --git a/.gitignore b/.gitignore index 364ff39..6188a99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build -*.ain \ No newline at end of file +*.ain +.dir-locals.el \ No newline at end of file diff --git a/README.md b/README.md index bc656ac..a99f618 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ xsystem4 xsystem4 is an implementation of AliceSoft's System 4 game engine for unix-like operating systems. -NOTE: This is a work in progress. Very little is implemented so far. +NOTE: This is a work in progress. Some simple ADV games run more or less okay, + but most games are not fully working or have game-breaking bug when run + with xsystem4. Building -------- @@ -18,7 +20,10 @@ xsystem4 uses the meson build system. Running ------- -You will need to create an AIN file using the System 4 SDK compiler. Then simply -pass it to the system4 executable. +You can run a game by passing the path to its "System40.ini" to the xsystem4 +executable. - build/system4 ???.ain + build/src/xsystem4 /path/to/System40.ini + +For now, xsystem4 needs to be run in the top-level project directory (i.e. the +directory that contains this README file). This will change in the future. diff --git a/audio.h b/include/audio.h similarity index 100% rename from audio.h rename to include/audio.h diff --git a/cJSON.h b/include/cJSON.h similarity index 100% rename from cJSON.h rename to include/cJSON.h diff --git a/debugger.h b/include/debugger.h similarity index 100% rename from debugger.h rename to include/debugger.h diff --git a/effect.h b/include/effect.h similarity index 100% rename from effect.h rename to include/effect.h diff --git a/file.h b/include/file.h similarity index 100% rename from file.h rename to include/file.h diff --git a/gfx_core.h b/include/gfx/gfx.h similarity index 99% rename from gfx_core.h rename to include/gfx/gfx.h index 42d416e..b0353ef 100644 --- a/gfx_core.h +++ b/include/gfx/gfx.h @@ -21,7 +21,7 @@ #include #include #include -#include "graphics.h" +#include "gfx/types.h" struct cg; struct text_metrics; diff --git a/gfx_private.h b/include/gfx/private.h similarity index 96% rename from gfx_private.h rename to include/gfx/private.h index 30e9ab3..296dba1 100644 --- a/gfx_private.h +++ b/include/gfx/private.h @@ -1,4 +1,4 @@ -/* gfx_private.h SDL/OpenGL only private data +/* gfx/private.h SDL/OpenGL only private data * * Copyright (C) 2019 Nunuhara Cabbage * Copyright (C) 2000- Fumihiko Murata diff --git a/graphics.h b/include/gfx/types.h similarity index 100% rename from graphics.h rename to include/gfx/types.h diff --git a/ini.h b/include/ini.h similarity index 100% rename from ini.h rename to include/ini.h diff --git a/input.h b/include/input.h similarity index 100% rename from input.h rename to include/input.h diff --git a/little_endian.h b/include/little_endian.h similarity index 100% rename from little_endian.h rename to include/little_endian.h diff --git a/queue.h b/include/queue.h similarity index 100% rename from queue.h rename to include/queue.h diff --git a/sact.h b/include/sact.h similarity index 98% rename from sact.h rename to include/sact.h index 5c818c8..9edaf25 100644 --- a/sact.h +++ b/include/sact.h @@ -21,8 +21,8 @@ #include #include #include "queue.h" -#include "graphics.h" -#include "gfx_core.h" +#include "gfx/gfx.h" +#include "gfx/types.h" struct string; union vm_value; diff --git a/savedata.h b/include/savedata.h similarity index 100% rename from savedata.h rename to include/savedata.h diff --git a/system4.h b/include/system4.h similarity index 100% rename from system4.h rename to include/system4.h diff --git a/ain.h b/include/system4/ain.h similarity index 98% rename from ain.h rename to include/system4/ain.h index 1f4d8b4..e317d47 100644 --- a/ain.h +++ b/include/system4/ain.h @@ -21,9 +21,8 @@ #include #include -#include "vm_string.h" - -struct ain; +struct string; +union vm_value; enum ain_error { AIN_SUCCESS, @@ -153,8 +152,6 @@ struct ain_hll_argument { int32_t data_type; }; -union vm_value; - struct ain_hll_function { char *name; union vm_value (*fun)(union vm_value *args); @@ -231,6 +228,5 @@ const char *ain_strerror(int error); const char *ain_strtype(struct ain *ain, enum ain_data_type type, int struct_type); struct ain *ain_open(const char *path, int *error); void ain_free(struct ain *ain); -void vm_execute_ain(struct ain *program); #endif /* SYSTEM4_AIN_H */ diff --git a/ald.h b/include/system4/ald.h similarity index 100% rename from ald.h rename to include/system4/ald.h diff --git a/cg.h b/include/system4/cg.h similarity index 90% rename from cg.h rename to include/system4/cg.h index 03ed4f7..9874991 100644 --- a/cg.h +++ b/include/system4/cg.h @@ -22,6 +22,8 @@ #include #include +struct ald_archive; + /* * Available CG formats */ @@ -51,9 +53,8 @@ struct cg { void *pixels; }; -bool cg_exists(int no); -bool cg_get_metrics(int no, struct cg_metrics *dst); -struct cg *cg_load(int no); +bool cg_get_metrics(struct ald_archive *ar, int no, struct cg_metrics *dst); +struct cg *cg_load(struct ald_archive *ar, int no); void cg_free(struct cg *cg); #endif /* SYSTEM4_CG_H */ diff --git a/instructions.h b/include/system4/instructions.h similarity index 100% rename from instructions.h rename to include/system4/instructions.h diff --git a/qnt.h b/include/system4/qnt.h similarity index 98% rename from qnt.h rename to include/system4/qnt.h index c786fce..a8cb1af 100644 --- a/qnt.h +++ b/include/system4/qnt.h @@ -28,8 +28,9 @@ #include #include -#include -#include "cg.h" + +struct cg; +struct cg_metrics; struct qnt_header { int hdr_size; // header size diff --git a/s2utbl.h b/include/system4/s2utbl.h similarity index 100% rename from s2utbl.h rename to include/system4/s2utbl.h diff --git a/vm_string.h b/include/system4/string.h similarity index 93% rename from vm_string.h rename to include/system4/string.h index c949dc1..8282bb4 100644 --- a/vm_string.h +++ b/include/system4/string.h @@ -46,6 +46,7 @@ struct string *string_format(struct string *fmt, union vm_value arg); // mutators void string_append(struct string **a, const struct string *b); +void string_append_cstr(struct string **a, const char *b, size_t b_size); void string_push_back(struct string **s, int c); void string_pop_back(struct string **s); void string_erase(struct string **s, int index); @@ -55,7 +56,7 @@ int string_find(const struct string *haystack, const struct string *needle); // characters int string_get_char(const struct string *str, int i); -void string_set_char(struct string **_s, int i, unsigned int c); +void string_set_char(struct string **s, int i, unsigned int c); // C strings int int_to_cstr(char *buf, size_t size, int v, int figures, bool zero_pad, bool zenkaku); diff --git a/utfsjis.h b/include/system4/utfsjis.h similarity index 100% rename from utfsjis.h rename to include/system4/utfsjis.h diff --git a/vm.h b/include/vm.h similarity index 98% rename from vm.h rename to include/vm.h index 810ed4a..e595158 100644 --- a/vm.h +++ b/include/vm.h @@ -107,6 +107,7 @@ int vm_string_ref(struct string *s); int vm_copy_page(struct page *page); union vm_value vm_copy(union vm_value v, enum ain_data_type type); +void vm_execute_ain(struct ain *program); void vm_call(int fno, int struct_page); int vm_time(void); diff --git a/heap.h b/include/vm/heap.h similarity index 100% rename from heap.h rename to include/vm/heap.h diff --git a/page.h b/include/vm/page.h similarity index 99% rename from page.h rename to include/vm/page.h index 9d927e8..5153cef 100644 --- a/page.h +++ b/include/vm/page.h @@ -19,7 +19,7 @@ #include #include -#include "ain.h" +#include "system4/ain.h" #include "vm.h" struct ain_variable; diff --git a/meson.build b/meson.build index 9ac29a7..ceffa9b 100644 --- a/meson.build +++ b/meson.build @@ -1,50 +1,7 @@ -project('system4', 'c', default_options : ['c_std=c11']) +project('system4', 'c', + default_options : ['c_std=c11']) add_project_arguments('-D_DEFAULT_SOURCE', language : 'c') -system4 = ['ain.c', - 'instructions.c', - 'string.c', - 'system.c', - 'utfsjis.c', -] - -xsystem4 = ['ald.c', - 'audio.c', - 'cJSON.c', - 'cg.c', - 'draw.c', - 'effect.c', - 'file.c', - 'heap.c', - 'ini.c', - 'input.c', - 'page.c', - 'qnt.c', - 'resume.c', - 'sact_graphics.c', - 'savedata.c', - 'system4.c', - 'text.c', - 'video.c', - 'vm.c', - - 'hll/ACXLoader.c', - 'hll/AliceLogo.c', - 'hll/AliceLogo2.c', - 'hll/AliceLogo3.c', - 'hll/Confirm2.c', - 'hll/DrawGraph.c', - 'hll/DrawPluginManager.c', - 'hll/File.c', - 'hll/Math.c', - 'hll/MsgLogManager.c', - 'hll/MsgSkip.c', - 'hll/OutputLog.c', - 'hll/PlayMovie.c', - 'hll/SACT2.c', - 'hll/SystemServiceEx.c', -] - zlib = dependency('zlib') libm = meson.get_compiler('c').find_library('m', required: false) sdl2 = dependency('sdl2') @@ -52,14 +9,8 @@ sdl2ttf = dependency('SDL2_ttf') sdl2mixer = dependency('SDL2_mixer') gl = dependency('GL') glew = dependency('glew') -xsystem4_deps = [libm, zlib, sdl2, sdl2ttf, sdl2mixer, gl, glew] - chibi = dependency('chibi-scheme', required : get_option('debugger')) -if chibi.found() - xsystem4_deps += chibi - xsystem4 += 'debugger.c' - add_project_arguments('-DDEBUGGER_ENABLED', language : 'c') -endif -executable('system4', xsystem4 + system4, dependencies: xsystem4_deps, c_args : ['-Wno-unused-parameter']) -executable('aindump', ['aindump.c'] + system4, dependencies: [libm, zlib]) +incdir = include_directories('include') + +subdir('src') diff --git a/ain.c b/src/ain.c similarity index 99% rename from ain.c rename to src/ain.c index 8d6f2c0..c71fca8 100644 --- a/ain.c +++ b/src/ain.c @@ -24,11 +24,11 @@ #include #include -#include "system4.h" -#include "ain.h" #include "little_endian.h" -#include "instructions.h" -#include "vm_string.h" +#include "system4.h" +#include "system4/ain.h" +#include "system4/instructions.h" +#include "system4/string.h" static const char *errtab[AIN_MAX_ERROR] = { [AIN_SUCCESS] = "Success", diff --git a/aindump.c b/src/aindump.c similarity index 94% rename from aindump.c rename to src/aindump.c index 81803e0..f2b9d35 100644 --- a/aindump.c +++ b/src/aindump.c @@ -19,11 +19,12 @@ #include #include #include -#include "system4.h" -#include "ain.h" -#include "instructions.h" #include "little_endian.h" -#include "utfsjis.h" +#include "system4.h" +#include "system4/ain.h" +#include "system4/instructions.h" +#include "system4/string.h" +#include "system4/utfsjis.h" static void usage(void) { @@ -50,6 +51,11 @@ static void print_sjis(const char *s) free(u); } +static void ain_dump_version(struct ain *ain) +{ + printf("AIN VERSION %d\n", ain->version); +} + static void ain_dump_code(struct ain *ain) { for (size_t i = 0; i < ain->code_size;) { @@ -141,7 +147,7 @@ static void ain_dump_messages(struct ain *ain) { for (int i = 0; i < ain->nr_messages; i++) { print_sjis(ain->messages[i]->text); - printf("\n---\n"); + //printf("\n---\n"); } } @@ -176,7 +182,7 @@ static void ain_dump_strings(struct ain *ain) { for (int i = 0; i < ain->nr_strings; i++) { print_sjis(ain->strings[i]->text); - printf("\n---\n"); + //printf("\n---\n"); } } @@ -219,6 +225,7 @@ static void ain_dump_enums(struct ain *ain) int main(int argc, char *argv[]) { + bool dump_version = false; bool dump_code = false; bool dump_functions = false; bool dump_globals = false; @@ -236,6 +243,7 @@ int main(int argc, char *argv[]) while (1) { static struct option long_options[] = { { "help", no_argument, 0, 'h' }, + { "ain-version", no_argument, 0, 'a' }, { "code", no_argument, 0, 'c' }, { "functions", no_argument, 0, 'f' }, { "globals", no_argument, 0, 'g' }, @@ -251,7 +259,7 @@ int main(int argc, char *argv[]) int option_index = 0; int c; - c = getopt_long(argc, argv, "hcfgomlse", long_options, &option_index); + c = getopt_long(argc, argv, "hacfgomlse", long_options, &option_index); if (c == -1) break; @@ -259,6 +267,9 @@ int main(int argc, char *argv[]) case 'h': usage(); return 0; + case 'a': + dump_version = true; + break; case 'c': dump_code = true; break; @@ -308,6 +319,8 @@ int main(int argc, char *argv[]) return 1; } + if (dump_version) + ain_dump_version(ain); if (dump_structures) ain_dump_structures(ain); if (dump_functypes) diff --git a/ald.c b/src/ald.c similarity index 99% rename from ald.c rename to src/ald.c index b46e0a3..f044979 100644 --- a/ald.c +++ b/src/ald.c @@ -26,7 +26,7 @@ #include #include #include "little_endian.h" -#include "ald.h" +#include "system4/ald.h" static const char *errtab[ALD_MAX_ERROR] = { [ALD_SUCCESS] = "Success", diff --git a/audio.c b/src/audio.c similarity index 99% rename from audio.c rename to src/audio.c index 851e7e0..eb32826 100644 --- a/audio.c +++ b/src/audio.c @@ -16,9 +16,9 @@ #include #include -#include "ald.h" #include "audio.h" #include "system4.h" +#include "system4/ald.h" #define AUDIO_SLOT_ALLOC_STEP 256 diff --git a/cJSON.c b/src/cJSON.c similarity index 100% rename from cJSON.c rename to src/cJSON.c diff --git a/cg.c b/src/cg.c similarity index 83% rename from cg.c rename to src/cg.c index 63d4446..d06d0bd 100644 --- a/cg.c +++ b/src/cg.c @@ -17,17 +17,10 @@ #include #include #include -#include #include "system4.h" -#include "ald.h" -#include "cg.h" -#include "qnt.h" -#include "graphics.h" - -bool cg_exists(int no) -{ - return ald[ALDFILE_CG] && ald_data_exists(ald[ALDFILE_CG], no); -} +#include "system4/ald.h" +#include "system4/cg.h" +#include "system4/qnt.h" /* * Identify cg format @@ -42,11 +35,11 @@ static enum cg_type check_cgformat(uint8_t *data) return ALCG_UNKNOWN; } -bool cg_get_metrics(int no, struct cg_metrics *dst) +bool cg_get_metrics(struct ald_archive *ar, int no, struct cg_metrics *dst) { struct archive_data *dfile; - if (!(dfile = ald_get(ald[ALDFILE_CG], no))) + if (!(dfile = ald_get(ar, no))) return false; switch (check_cgformat(dfile->data)) { @@ -62,20 +55,15 @@ bool cg_get_metrics(int no, struct cg_metrics *dst) return true; } -static void _cg_free(struct cg *cg) -{ - if (!cg) - return; - free(cg->pixels); -} - /* * Free CG data * cg: object to free */ void cg_free(struct cg *cg) { - _cg_free(cg); + if (!cg) + return; + free(cg->pixels); free(cg); } @@ -84,13 +72,13 @@ void cg_free(struct cg *cg) * no: file no ( >= 0) * return: cg object(extracted) */ -struct cg *cg_load(int no) +struct cg *cg_load(struct ald_archive *ar, int no) { struct cg *cg; struct archive_data *dfile; int type; - if (!(dfile = ald_get(ald[ALDFILE_CG], no))) { + if (!(dfile = ald_get(ar, no))) { WARNING("Failed to load CG %d", no); return NULL; } diff --git a/debug-ffi.c b/src/debug-ffi.c similarity index 99% rename from debug-ffi.c rename to src/debug-ffi.c index 510cc61..6b04286 100644 --- a/debug-ffi.c +++ b/src/debug-ffi.c @@ -2,9 +2,9 @@ #include -#include "ain.h" +#include "system4/ain.h" -#include "page.h" +#include "vm/page.h" #include "vm.h" /* diff --git a/debug-ffi.stub b/src/debug-ffi.stub similarity index 98% rename from debug-ffi.stub rename to src/debug-ffi.stub index e47a0bc..5bb362e 100644 --- a/debug-ffi.stub +++ b/src/debug-ffi.stub @@ -13,8 +13,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, see . -(c-include "ain.h") -(c-include "page.h") +(c-include "system4/ain.h") +(c-include "vm/page.h") (c-include "vm.h") (define-c-const int (type/void AIN_VOID)) diff --git a/debugger.c b/src/debugger.c similarity index 97% rename from debugger.c rename to src/debugger.c index a222869..401b2ba 100644 --- a/debugger.c +++ b/src/debugger.c @@ -17,10 +17,11 @@ #include #include -#include "heap.h" -#include "page.h" -#include "utfsjis.h" +#include "system4/string.h" +#include "system4/utfsjis.h" #include "vm.h" +#include "vm/heap.h" +#include "vm/page.h" struct variable { enum ain_data_type data_type; diff --git a/draw.c b/src/draw.c similarity index 99% rename from draw.c rename to src/draw.c index b2a2db8..7421bde 100644 --- a/draw.c +++ b/src/draw.c @@ -17,8 +17,8 @@ #include #include #include -#include "gfx_core.h" -#include "gfx_private.h" +#include "gfx/gfx.h" +#include "gfx/private.h" #include "system4.h" #ifndef M_PI diff --git a/effect.c b/src/effect.c similarity index 99% rename from effect.c rename to src/effect.c index 24540d0..e710db3 100644 --- a/effect.c +++ b/src/effect.c @@ -16,7 +16,7 @@ #include #include "effect.h" -#include "gfx_core.h" +#include "gfx/gfx.h" #include "sact.h" #include "system4.h" diff --git a/file.c b/src/file.c similarity index 100% rename from file.c rename to src/file.c diff --git a/src/format.c b/src/format.c new file mode 100644 index 0000000..41aa56e --- /dev/null +++ b/src/format.c @@ -0,0 +1,160 @@ +/* Copyright (C) 2019 Nunuhara Cabbage + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include +#include +#include "system4.h" +#include "system4/string.h" +#include "vm.h" +#include "vm/heap.h" + +#define DIGIT_MAX 512 + +enum fmt_type { + FMT_VOID, + FMT_INT, + FMT_FLOAT, + FMT_STRING, + FMT_CHAR, + FMT_BOOL +}; + +struct fmt_spec { + enum fmt_type type; + int precision; + int padding; + bool zero_pad; + bool zenkaku; +}; + +static int read_number(const char **_fmt) +{ + int n = 0; + const char *fmt = *_fmt; + while (*fmt && *fmt >= '0' && *fmt <= '9') { + n *= 10; + n += *fmt - '0'; + fmt++; + } + *_fmt = fmt; + return n; +} + +static void parse_fmt_spec(const char **_fmt, struct fmt_spec *spec) +{ + const char *fmt = *_fmt; + memset(spec, 0, sizeof(struct fmt_spec)); + spec->precision = 6; + while (*fmt) { + switch (*fmt) { + case 'd': + spec->type = FMT_INT; + goto end; + case 'D': + spec->type = FMT_INT; + spec->zenkaku = true; + goto end; + case 'f': + spec->type = FMT_FLOAT; + goto end; + case 'F': + spec->type = FMT_FLOAT; + spec->zenkaku = true; + goto end; + case 's': + spec->type = FMT_STRING; + goto end; + case 'c': + spec->type = FMT_CHAR; + goto end; + case 'b': + spec->type = FMT_BOOL; + goto end; + case '0': + spec->zero_pad = true; + fmt++; + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + spec->padding = read_number(&fmt); + break; + case '.': + fmt++; + spec->precision = read_number(&fmt); + break; + default: + goto warn; + } + } +warn: + WARNING("Invalid format specifier: %s", *_fmt); +end: + *_fmt = ++fmt; +} + +static void append_fmt(struct string **s, struct fmt_spec *spec, union vm_value arg) +{ + int len; + char buf[DIGIT_MAX] = { [DIGIT_MAX-1] = '\0' }; + switch (spec->type) { + case FMT_VOID: + return; + case FMT_INT: + len = int_to_cstr(buf, DIGIT_MAX, arg.i, spec->padding, spec->zero_pad, spec->zenkaku); + string_append_cstr(s, buf, len); + break; + case FMT_FLOAT: + len = float_to_cstr(buf, DIGIT_MAX, arg.f, spec->padding, spec->zero_pad, spec->precision, spec->zenkaku); + string_append_cstr(s, buf, len); + break; + case FMT_STRING: + string_append(s, heap[arg.i].s); + break; + case FMT_CHAR: + string_push_back(s, arg.i); + break; + case FMT_BOOL: + if (arg.i) + string_append_cstr(s, "true", 4); + else + string_append_cstr(s, "false", 5); + break; + } +} + +struct string *string_format(struct string *fmt, union vm_value arg) +{ + struct string *out = string_ref(&EMPTY_STRING); + for (const char *s = fmt->text; *s; s++) { + if (*s == '%') { + struct fmt_spec spec; + string_append_cstr(&out, fmt->text, s - fmt->text); + s++; + parse_fmt_spec(&s, &spec); + append_fmt(&out, &spec, arg); + string_append_cstr(&out, s, strlen(s)); + break; + } + } + return out; +} diff --git a/heap.c b/src/heap.c similarity index 98% rename from heap.c rename to src/heap.c index e8ecbaf..d96f75d 100644 --- a/heap.c +++ b/src/heap.c @@ -15,9 +15,10 @@ */ #include -#include "page.h" -#include "heap.h" +#include "system4/string.h" #include "vm.h" +#include "vm/heap.h" +#include "vm/page.h" #define INITIAL_HEAP_SIZE 4096 #define HEAP_ALLOC_STEP 4096 diff --git a/hll/ACXLoader.c b/src/hll/ACXLoader.c similarity index 98% rename from hll/ACXLoader.c rename to src/hll/ACXLoader.c index 311527f..b89b0c7 100644 --- a/hll/ACXLoader.c +++ b/src/hll/ACXLoader.c @@ -18,7 +18,8 @@ #include #include #include "hll.h" -#include "../little_endian.h" +#include "little_endian.h" +#include "system4/string.h" struct acx_file { int compressed_size; diff --git a/hll/AliceLogo.c b/src/hll/AliceLogo.c similarity index 100% rename from hll/AliceLogo.c rename to src/hll/AliceLogo.c diff --git a/hll/AliceLogo2.c b/src/hll/AliceLogo2.c similarity index 100% rename from hll/AliceLogo2.c rename to src/hll/AliceLogo2.c diff --git a/hll/AliceLogo3.c b/src/hll/AliceLogo3.c similarity index 100% rename from hll/AliceLogo3.c rename to src/hll/AliceLogo3.c diff --git a/hll/Confirm2.c b/src/hll/Confirm2.c similarity index 100% rename from hll/Confirm2.c rename to src/hll/Confirm2.c diff --git a/hll/DrawGraph.c b/src/hll/DrawGraph.c similarity index 99% rename from hll/DrawGraph.c rename to src/hll/DrawGraph.c index 856d604..993f1c9 100644 --- a/hll/DrawGraph.c +++ b/src/hll/DrawGraph.c @@ -15,8 +15,9 @@ */ #include "hll.h" -#include "../sact.h" -#include "../graphics.h" +#include "sact.h" +#include "gfx/types.h" +#include "system4/string.h" #define TEX(sp_no) sact_get_texture(sp_no) diff --git a/hll/DrawPluginManager.c b/src/hll/DrawPluginManager.c similarity index 100% rename from hll/DrawPluginManager.c rename to src/hll/DrawPluginManager.c diff --git a/hll/File.c b/src/hll/File.c similarity index 97% rename from hll/File.c rename to src/hll/File.c index ba4ef67..670cf17 100644 --- a/hll/File.c +++ b/src/hll/File.c @@ -16,14 +16,16 @@ #include #include +#include #include #include #include #include "hll.h" -#include "../file.h" -#include "../heap.h" -#include "../savedata.h" -#include "../system4.h" +#include "file.h" +#include "savedata.h" +#include "system4.h" +#include "system4/string.h" +#include "vm/heap.h" static FILE *current_file = NULL; static char *file_contents = NULL; diff --git a/hll/Math.c b/src/hll/Math.c similarity index 99% rename from hll/Math.c rename to src/hll/Math.c index 9069dd7..abec50b 100644 --- a/hll/Math.c +++ b/src/hll/Math.c @@ -21,7 +21,6 @@ #define M_PI (3.14159265358979323846) #endif -#include "../system4.h" #include "hll.h" static inline float deg2rad(float deg) diff --git a/hll/MsgLogManager.c b/src/hll/MsgLogManager.c similarity index 100% rename from hll/MsgLogManager.c rename to src/hll/MsgLogManager.c diff --git a/hll/MsgSkip.c b/src/hll/MsgSkip.c similarity index 100% rename from hll/MsgSkip.c rename to src/hll/MsgSkip.c diff --git a/hll/OutputLog.c b/src/hll/OutputLog.c similarity index 95% rename from hll/OutputLog.c rename to src/hll/OutputLog.c index 4210b9e..40cd0ef 100644 --- a/hll/OutputLog.c +++ b/src/hll/OutputLog.c @@ -16,7 +16,8 @@ #include #include "hll.h" -#include "../utfsjis.h" +#include "system4/string.h" +#include "system4/utfsjis.h" hll_warn_unimplemented(OutputLog, Create, 0) diff --git a/hll/PlayMovie.c b/src/hll/PlayMovie.c similarity index 100% rename from hll/PlayMovie.c rename to src/hll/PlayMovie.c diff --git a/hll/SACT2.c b/src/hll/SACT2.c similarity index 98% rename from hll/SACT2.c rename to src/hll/SACT2.c index 6472d20..e343e78 100644 --- a/hll/SACT2.c +++ b/src/hll/SACT2.c @@ -17,14 +17,15 @@ #include #include #include "hll.h" -#include "../audio.h" -#include "../cg.h" -#include "../input.h" -#include "../queue.h" -#include "../gfx_core.h" -#include "../sact.h" -#include "../system4.h" -#include "../vm.h" +#include "audio.h" +#include "input.h" +#include "queue.h" +#include "gfx/gfx.h" +#include "sact.h" +#include "system4.h" +#include "system4/ald.h" +#include "system4/cg.h" +#include "system4/string.h" // int Init(imain_system pIMainSystem, int nCGCacheSize) hll_defun_inline(Init, sact_Init()); @@ -413,7 +414,10 @@ hll_defun_inline(Key_IsDown, (handle_events(), key_is_down(a[0].i))); // int Timer_Get(void) hll_defun_inline(Timer_Get, vm_time()); // int CG_IsExist(int nCG) -hll_defun_inline(CG_IsExist, cg_exists(a[0].i - 1)); +hll_defun(CG_IsExist, args) +{ + hll_return(ald[ALDFILE_CG] && ald_data_exists(ald[ALDFILE_CG], args[0].i - 1)); +} // int CG_GetMetrics(int nCG, ref struct cm) hll_defun_inline(CG_GetMetrics, sact_CG_GetMetrics(a[0].i - 1, heap[a[1].i].page->values)); // int CSV_Load(string pIStringFileName) diff --git a/hll/SystemServiceEx.c b/src/hll/SystemServiceEx.c similarity index 98% rename from hll/SystemServiceEx.c rename to src/hll/SystemServiceEx.c index 712bf97..b8dd1e8 100644 --- a/hll/SystemServiceEx.c +++ b/src/hll/SystemServiceEx.c @@ -15,7 +15,7 @@ */ #include "hll.h" -#include "../gfx_core.h" +#include "gfx/gfx.h" // int GetUpdateResult() hll_unimplemented(SystemServiceEx, GetUpdateResult); diff --git a/hll/hll.h b/src/hll/hll.h similarity index 96% rename from hll/hll.h rename to src/hll/hll.h index ff9e31a..f264d8f 100644 --- a/hll/hll.h +++ b/src/hll/hll.h @@ -21,10 +21,10 @@ * DSL for implementing libraries. */ -#include "../vm.h" -#include "../heap.h" -#include "../page.h" -#include "../system4.h" +#include "vm.h" +#include "vm/heap.h" +#include "vm/page.h" +#include "system4.h" #define hll_defun(fname, args) \ static union vm_value _hllfun_ ## fname(possibly_unused union vm_value *args); \ diff --git a/ini.c b/src/ini.c similarity index 100% rename from ini.c rename to src/ini.c diff --git a/input.c b/src/input.c similarity index 98% rename from input.c rename to src/input.c index 563fee2..6699c9a 100644 --- a/input.c +++ b/src/input.c @@ -16,7 +16,7 @@ #include #include "system4.h" -#include "gfx_private.h" +#include "gfx/private.h" #include "input.h" #include "vm.h" @@ -95,6 +95,8 @@ void handle_events(void) } break; case SDL_KEYDOWN: + if (e.key.keysym.scancode == SDL_SCANCODE_F9) + vm_stack_trace(); key_event(&e.key, true); break; case SDL_KEYUP: diff --git a/instructions.c b/src/instructions.c similarity index 99% rename from instructions.c rename to src/instructions.c index aa69c37..1f6959f 100644 --- a/instructions.c +++ b/src/instructions.c @@ -19,7 +19,7 @@ #include #include "system4.h" -#include "instructions.h" +#include "system4/instructions.h" // JMP = instruction that modifies the instruction pointer // OP = everything else diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..ad571a3 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,69 @@ +# sources for libsys4.a +system4 = ['ain.c', + 'ald.c', + 'cg.c', + 'instructions.c', + 'qnt.c', + 'string.c', + 'system.c', + 'utfsjis.c', +] + +# sources for xsystem4 +xsystem4 = ['audio.c', + 'cJSON.c', + 'draw.c', + 'effect.c', + 'file.c', + 'format.c', + 'heap.c', + 'ini.c', + 'input.c', + 'page.c', + 'resume.c', + 'sact_graphics.c', + 'savedata.c', + 'system4.c', + 'text.c', + 'video.c', + 'vm.c', + + 'hll/ACXLoader.c', + 'hll/AliceLogo.c', + 'hll/AliceLogo2.c', + 'hll/AliceLogo3.c', + 'hll/Confirm2.c', + 'hll/DrawGraph.c', + 'hll/DrawPluginManager.c', + 'hll/File.c', + 'hll/Math.c', + 'hll/MsgLogManager.c', + 'hll/MsgSkip.c', + 'hll/OutputLog.c', + 'hll/PlayMovie.c', + 'hll/SACT2.c', + 'hll/SystemServiceEx.c', +] + +xsystem4_deps = [libm, zlib, sdl2, sdl2ttf, sdl2mixer, gl, glew] +if chibi.found() + xsystem4_deps += chibi + xsystem4 += 'debugger.c' + add_project_arguments('-DDEBUGGER_ENABLED', language : 'c') +endif + +libsys4 = static_library('sys4', system4, + dependencies : [libm, zlib], + include_directories : incdir) + +executable('xsystem4', xsystem4, + dependencies : xsystem4_deps, + c_args : ['-Wno-unused-parameter'], + include_directories : incdir, + link_with : libsys4) + +executable('aindump', ['aindump.c'], + dependencies : [libm, zlib], + include_directories : incdir, + link_with : libsys4) + diff --git a/page.c b/src/page.c similarity index 99% rename from page.c rename to src/page.c index ed2d3ca..36b49fd 100644 --- a/page.c +++ b/src/page.c @@ -16,11 +16,11 @@ #include #include "system4.h" -#include "ain.h" -#include "heap.h" -#include "page.h" +#include "system4/ain.h" +#include "system4/string.h" #include "vm.h" -#include "vm_string.h" +#include "vm/heap.h" +#include "vm/page.h" #define NR_CACHES 8 #define CACHE_SIZE 64 diff --git a/qnt.c b/src/qnt.c similarity index 99% rename from qnt.c rename to src/qnt.c index 7e33c01..570ac2e 100644 --- a/qnt.c +++ b/src/qnt.c @@ -32,14 +32,12 @@ */ #include +#include #include -#include - #include "little_endian.h" -#include "cg.h" -#include "qnt.h" #include "system4.h" -#include "gfx_core.h" +#include "system4/cg.h" +#include "system4/qnt.h" /* zlib の展開バッファで、幅×高さ×3に、さらにどれくらい余裕をとるか diff --git a/resume.c b/src/resume.c similarity index 99% rename from resume.c rename to src/resume.c index 50cdd15..3cab86b 100644 --- a/resume.c +++ b/src/resume.c @@ -22,10 +22,11 @@ #include #include "cJSON.h" #include "file.h" -#include "heap.h" -#include "page.h" #include "savedata.h" +#include "system4/string.h" #include "vm.h" +#include "vm/heap.h" +#include "vm/page.h" /* * Save/load VM images as JSON. diff --git a/sact_graphics.c b/src/sact_graphics.c similarity index 97% rename from sact_graphics.c rename to src/sact_graphics.c index 3f00566..88f5303 100644 --- a/sact_graphics.c +++ b/src/sact_graphics.c @@ -14,15 +14,16 @@ * along with this program; if not, see . */ -#include "system4.h" -#include "sact.h" #include "audio.h" -#include "cg.h" #include "input.h" -#include "gfx_core.h" +#include "gfx/gfx.h" +#include "sact.h" +#include "system4.h" +#include "system4/ald.h" +#include "system4/cg.h" +#include "system4/string.h" +#include "system4/utfsjis.h" #include "vm.h" -#include "vm_string.h" -#include "utfsjis.h" static struct sact_sprite *create_sprite(int sp_no, int width, int height, int r, int g, int b, int a); @@ -124,7 +125,7 @@ int sact_SetWP(int cg_no) return 1; } - struct cg *cg = cg_load(cg_no - 1); + struct cg *cg = cg_load(ald[ALDFILE_CG], cg_no - 1); if (!cg) return 0; @@ -210,7 +211,7 @@ int sact_SP_SetCG(int sp_no, int cg_no) WARNING("Failed to create sprite"); return 0; } - struct cg *cg = cg_load(cg_no - 1); + struct cg *cg = cg_load(ald[ALDFILE_CG], cg_no - 1); if (!cg) return 0; gfx_init_texture_with_cg(&sp->texture, cg); @@ -433,7 +434,7 @@ int sact_SP_IsPtIn(int sp_no, int x, int y) int sact_CG_GetMetrics(int cg_no, union vm_value *cgm) { struct cg_metrics metrics; - if (!cg_get_metrics(cg_no, &metrics)) + if (!cg_get_metrics(ald[ALDFILE_CG], cg_no, &metrics)) return 0; cgm[0].i = metrics.w; cgm[1].i = metrics.h; diff --git a/savedata.c b/src/savedata.c similarity index 98% rename from savedata.c rename to src/savedata.c index ede3f58..9a20e82 100644 --- a/savedata.c +++ b/src/savedata.c @@ -15,15 +15,17 @@ */ #include +#include #include #include -#include "system4.h" -#include "ain.h" #include "cJSON.h" -#include "heap.h" -#include "page.h" #include "savedata.h" +#include "system4.h" +#include "system4/ain.h" +#include "system4/string.h" #include "vm.h" +#include "vm/heap.h" +#include "vm/page.h" static int current_global; diff --git a/string.c b/src/string.c similarity index 75% rename from string.c rename to src/string.c index 65689d5..22d9eba 100644 --- a/string.c +++ b/src/string.c @@ -18,11 +18,9 @@ #include #include #include -#include "heap.h" #include "system4.h" -#include "utfsjis.h" -#include "vm.h" -#include "vm_string.h" +#include "system4/string.h" +#include "system4/utfsjis.h" struct string EMPTY_STRING = { .cow = true, @@ -298,95 +296,6 @@ void string_set_char(struct string **_str, int i, unsigned int c) #define DIGIT_MAX 512 -enum fmt_type { - FMT_VOID, - FMT_INT, - FMT_FLOAT, - FMT_STRING, - FMT_CHAR, - FMT_BOOL -}; - -struct fmt_spec { - enum fmt_type type; - int precision; - int padding; - bool zero_pad; - bool zenkaku; -}; - -static int read_number(const char **_fmt) -{ - int n = 0; - const char *fmt = *_fmt; - while (*fmt && *fmt >= '0' && *fmt <= '9') { - n *= 10; - n += *fmt - '0'; - fmt++; - } - *_fmt = fmt; - return n; -} - -static void parse_fmt_spec(const char **_fmt, struct fmt_spec *spec) -{ - const char *fmt = *_fmt; - memset(spec, 0, sizeof(struct fmt_spec)); - spec->precision = 6; - while (*fmt) { - switch (*fmt) { - case 'd': - spec->type = FMT_INT; - goto end; - case 'D': - spec->type = FMT_INT; - spec->zenkaku = true; - goto end; - case 'f': - spec->type = FMT_FLOAT; - goto end; - case 'F': - spec->type = FMT_FLOAT; - spec->zenkaku = true; - goto end; - case 's': - spec->type = FMT_STRING; - goto end; - case 'c': - spec->type = FMT_CHAR; - goto end; - case 'b': - spec->type = FMT_BOOL; - goto end; - case '0': - spec->zero_pad = true; - fmt++; - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - spec->padding = read_number(&fmt); - break; - case '.': - fmt++; - spec->precision = read_number(&fmt); - break; - default: - goto warn; - } - } -warn: - WARNING("Invalid format specifier: %s", *_fmt); -end: - *_fmt = ++fmt; -} - static int number_han2zen(char *buf, size_t size) { char *tmp = xmalloc(size*2); @@ -472,50 +381,3 @@ int float_to_cstr(char *buf, size_t size, float v, int figures, bool zero_pad, i } return i; } - -static void append_fmt(struct string **s, struct fmt_spec *spec, union vm_value arg) -{ - int len; - char buf[DIGIT_MAX] = { [DIGIT_MAX-1] = '\0' }; - switch (spec->type) { - case FMT_VOID: - return; - case FMT_INT: - len = int_to_cstr(buf, DIGIT_MAX, arg.i, spec->padding, spec->zero_pad, spec->zenkaku); - string_append_cstr(s, buf, len); - break; - case FMT_FLOAT: - len = float_to_cstr(buf, DIGIT_MAX, arg.f, spec->padding, spec->zero_pad, spec->precision, spec->zenkaku); - string_append_cstr(s, buf, len); - break; - case FMT_STRING: - string_append(s, heap[arg.i].s); - break; - case FMT_CHAR: - string_push_back(s, arg.i); - break; - case FMT_BOOL: - if (arg.i) - string_append_cstr(s, "true", 4); - else - string_append_cstr(s, "false", 5); - break; - } -} - -struct string *string_format(struct string *fmt, union vm_value arg) -{ - struct string *out = string_ref(&EMPTY_STRING); - for (const char *s = fmt->text; *s; s++) { - if (*s == '%') { - struct fmt_spec spec; - string_append_cstr(&out, fmt->text, s - fmt->text); - s++; - parse_fmt_spec(&s, &spec); - append_fmt(&out, &spec, arg); - string_append_cstr(&out, s, strlen(s)); - break; - } - } - return out; -} diff --git a/system.c b/src/system.c similarity index 98% rename from system.c rename to src/system.c index 897aa35..3d3b3c3 100644 --- a/system.c +++ b/src/system.c @@ -20,7 +20,7 @@ #include #include "system4.h" -#include "utfsjis.h" +#include "system4/utfsjis.h" mem_alloc void *_xmalloc(size_t size, const char *func) { diff --git a/system4.c b/src/system4.c similarity index 98% rename from system4.c rename to src/system4.c index 527be0d..a1906c4 100644 --- a/system4.c +++ b/src/system4.c @@ -20,13 +20,14 @@ #include #include #include -#include "system4.h" -#include "ain.h" -#include "ald.h" #include "debugger.h" #include "file.h" #include "ini.h" -#include "utfsjis.h" +#include "system4.h" +#include "system4/ain.h" +#include "system4/ald.h" +#include "system4/utfsjis.h" +#include "vm.h" struct config config = { .game_name = NULL, diff --git a/text.c b/src/text.c similarity index 99% rename from text.c rename to src/text.c index 26bf266..2c9ac16 100644 --- a/text.c +++ b/src/text.c @@ -17,9 +17,9 @@ #include #include #include "system4.h" -#include "gfx_core.h" -#include "graphics.h" -#include "utfsjis.h" +#include "gfx/gfx.h" +#include "gfx/types.h" +#include "system4/utfsjis.h" /* * NOTE: There are two different text rendering APIs: SACT2 and DrawGraph. diff --git a/utfsjis.c b/src/utfsjis.c similarity index 98% rename from utfsjis.c rename to src/utfsjis.c index 93e73d0..e0cd50d 100644 --- a/utfsjis.c +++ b/src/utfsjis.c @@ -26,8 +26,8 @@ #include #include -#include "utfsjis.h" -#include "s2utbl.h" +#include "system4/utfsjis.h" +#include "system4/s2utbl.h" // Convert a character-index to a byte-index for a given SJIS string. int sjis_index(const char *_src, int index) diff --git a/video.c b/src/video.c similarity index 99% rename from video.c rename to src/video.c index 675138d..d419fe3 100644 --- a/video.c +++ b/src/video.c @@ -20,11 +20,11 @@ #include #include -#include "system4.h" -#include "gfx_core.h" -#include "gfx_private.h" -#include "cg.h" +#include "gfx/gfx.h" +#include "gfx/private.h" #include "file.h" +#include "system4.h" +#include "system4/cg.h" /* * Transform from the window coordinate system -> clip-space. diff --git a/vm.c b/src/vm.c similarity index 99% rename from vm.c rename to src/vm.c index ed7ed05..4cb1ebd 100644 --- a/vm.c +++ b/src/vm.c @@ -22,18 +22,18 @@ #include #include // for system.MsgBox -#include "system4.h" -#include "vm.h" -#include "vm_string.h" -#include "page.h" -#include "ain.h" +#include "debugger.h" #include "file.h" -#include "heap.h" -#include "instructions.h" #include "little_endian.h" #include "savedata.h" -#include "utfsjis.h" -#include "debugger.h" +#include "system4.h" +#include "system4/ain.h" +#include "system4/instructions.h" +#include "system4/string.h" +#include "system4/utfsjis.h" +#include "vm.h" +#include "vm/heap.h" +#include "vm/page.h" #define INITIAL_STACK_SIZE 4096 #define HLL_MAX_ARGS 64