diff --git a/game_compatibility.md b/game_compatibility.md index b8cac64..d8ee7a4 100644 --- a/game_compatibility.md +++ b/game_compatibility.md @@ -77,7 +77,7 @@ issues, please let me know or open a pull request to update this table. | ランス・クエスト | Supported | | | ランス・クエスト マグナム | Supported | | | 母娘乱館 | Unknown | | -| パステルチャイム3 バインドシーカー | Unsupported | | +| パステルチャイム3 バインドシーカー | Supported | | | どらぺこ! ~おねだりドラゴンとおっぱい勇者~ | Unsupported | | | ランス01 光をもとめて | Supported | | | Rance 01 - Quest for Hikari (EN) | Supported | | diff --git a/include/audio.h b/include/audio.h index 23bc1d5..10d5d90 100644 --- a/include/audio.h +++ b/include/audio.h @@ -78,6 +78,8 @@ int wav_get_volume(int id); int bgm_get_volume(int id); int wav_get_time_length(int id); int bgm_get_time_length(int id); +int wav_get_data_length(int no); +int bgm_get_data_length(int no); int wav_get_group_num(int id); //int bgm_get_group_num(int id); int wav_prepare_from_file(int id, char *filename); diff --git a/include/sact.h b/include/sact.h index 90a1754..139973a 100644 --- a/include/sact.h +++ b/include/sact.h @@ -118,6 +118,8 @@ bool sact_DX_GetUsePower2Texture(void); void sact_DX_SetUsePower2Texture(bool use); extern struct text_style text_sprite_ts; +int StoatSpriteEngine_SP_SetDrawMethod(int sp_no, int method); +int StoatSpriteEngine_SP_GetDrawMethod(int sp_no); bool StoatSpriteEngine_SP_SetTextSprite(int sp_no, struct string *text); void StoatSpriteEngine_SP_SetTextSpriteType(int type); void StoatSpriteEngine_SP_SetTextSpriteSize(int size); diff --git a/src/audio.c b/src/audio.c index fee9b48..9f29b7e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -361,6 +361,18 @@ static int audio_get_time_length(struct id_pool *pool, int id) int wav_get_time_length(int id) { return audio_get_time_length(&wav, id); } int bgm_get_time_length(int id) { return audio_get_time_length(&bgm, id); } +static int audio_get_data_length(enum asset_type type, int no) { + struct channel *ch = channel_open(type, no); + if (!ch) + return 0; + int len = channel_get_time_length(ch); + channel_close(ch); + return len; +} + +int wav_get_data_length(int no) { return audio_get_data_length(ASSET_SOUND, no); } +int bgm_get_data_length(int no) { return audio_get_data_length(ASSET_BGM, no); } + static int audio_get_data_no(struct id_pool *pool, int id) { struct channel *ch = id_pool_get(pool, id); diff --git a/src/hll/ChipmunkSpriteEngine.c b/src/hll/ChipmunkSpriteEngine.c index 1134c56..b44f96d 100644 --- a/src/hll/ChipmunkSpriteEngine.c +++ b/src/hll/ChipmunkSpriteEngine.c @@ -314,7 +314,7 @@ HLL_LIBRARY(ChipmunkSpriteEngine, HLL_EXPORT(SP_SetMultipleColor, ChipmunkSpriteEngine_SP_SetMultipleColor), HLL_EXPORT(SP_SetAddColor, ChipmunkSpriteEngine_SP_SetAddColor), HLL_EXPORT(SP_SetShow, sact_SP_SetShow), - HLL_EXPORT(SP_SetDrawMethod, sact_SP_SetDrawMethod), + HLL_EXPORT(SP_SetDrawMethod, StoatSpriteEngine_SP_SetDrawMethod), HLL_EXPORT(SP_SetSurfaceArea, ChipmunkSpriteEngine_SP_SetSurfaceArea), HLL_EXPORT(SP_GetSurfaceArea, ChipmunkSpriteEngine_SP_GetSurfaceArea), HLL_EXPORT(SP_SetSpriteTransformMode, ChipmunkSpriteEngine_SP_SetSpriteTransformMode), @@ -330,7 +330,7 @@ HLL_LIBRARY(ChipmunkSpriteEngine, HLL_EXPORT(SP_GetZ, sact_SP_GetZ), HLL_EXPORT(SP_GetBlendRate, sact_SP_GetBlendRate), HLL_EXPORT(SP_GetShow, sact_SP_GetShow), - HLL_EXPORT(SP_GetDrawMethod, sact_SP_GetDrawMethod), + HLL_EXPORT(SP_GetDrawMethod, StoatSpriteEngine_SP_GetDrawMethod), HLL_EXPORT(SP_RenderView, ChipmunkSpriteEngine_SP_RenderView), HLL_EXPORT(SP_IsPtIn, sact_SP_IsPtIn), HLL_EXPORT(SP_IsPtInRect, sact_SP_IsPtInRect), diff --git a/src/hll/KiwiSoundEngine.c b/src/hll/KiwiSoundEngine.c index ab9100a..c512f48 100644 --- a/src/hll/KiwiSoundEngine.c +++ b/src/hll/KiwiSoundEngine.c @@ -23,7 +23,6 @@ HLL_WARN_UNIMPLEMENTED( , void, KiwiSoundEngine, SetGlobalFocus, possibly_unused //int KiwiSoundEngine_Sound_GetGroupNum(int nCh); //static bool KiwiSoundEngine_Sound_PrepareFromFile(int ch, struct string *filename); -//static int KiwiSoundEngine_Sound_GetDataLength(int data_number); static int KiwiSoundEngine_GetMasterGroup(void) { @@ -93,7 +92,7 @@ HLL_LIBRARY(KiwiSoundEngine, HLL_TODO_EXPORT(Sound_GetGroupNum, KiwiSoundEngine_Sound_GetGroupNum), HLL_EXPORT(Sound_GetGroupNumFromDataNum, wav_get_group_num_from_data_num), HLL_TODO_EXPORT(Sound_PrepareFromFile, KiwiSoundEngine_Sound_PrepareFromFile), - HLL_TODO_EXPORT(Sound_GetDataLength, KiwiSoundEngine_Sound_GetDataLength), + HLL_EXPORT(Sound_GetDataLength, wav_get_data_length), HLL_EXPORT(GetMasterGroup, KiwiSoundEngine_GetMasterGroup), HLL_EXPORT(GetBGMGroup, KiwiSoundEngine_GetBGMGroup), HLL_EXPORT(GetSEGroup, KiwiSoundEngine_GetSEGroup), diff --git a/src/hll/StoatSpriteEngine.c b/src/hll/StoatSpriteEngine.c index d455621..ba9db64 100644 --- a/src/hll/StoatSpriteEngine.c +++ b/src/hll/StoatSpriteEngine.c @@ -45,7 +45,7 @@ HLL_WARN_UNIMPLEMENTED( , void, StoatSpriteEngine, SetVolumeMixerMasterGroupNum, HLL_WARN_UNIMPLEMENTED( , void, StoatSpriteEngine, SetVolumeMixerSEGroupNum, int n); HLL_WARN_UNIMPLEMENTED( , void, StoatSpriteEngine, SetVolumeMixerBGMGroupNum, int n); -static int StoatSpriteEngine_SP_SetDrawMethod(int sp_no, int method) +int StoatSpriteEngine_SP_SetDrawMethod(int sp_no, int method) { struct sact_sprite *sp = sact_get_sprite(sp_no); if (!sp) return 0; @@ -59,7 +59,7 @@ static int StoatSpriteEngine_SP_SetDrawMethod(int sp_no, int method) } } -static int StoatSpriteEngine_SP_GetDrawMethod(int sp_no) +int StoatSpriteEngine_SP_GetDrawMethod(int sp_no) { struct sact_sprite *sp = sact_try_get_sprite(sp_no); if (!sp) return DRAW_METHOD_NORMAL; diff --git a/src/page.c b/src/page.c index 0a0ab70..7bd5e22 100644 --- a/src/page.c +++ b/src/page.c @@ -292,7 +292,7 @@ struct page *alloc_array(int rank, union vm_value *dimensions, enum ain_data_typ data_type = unref_array_type(data_type); enum ain_data_type type = array_type(data_type); - struct page *page = alloc_page(ARRAY_PAGE, data_type, dimensions->i); + struct page *page = alloc_page(ARRAY_PAGE, data_type, max(0, dimensions->i)); page->array.struct_type = struct_type; page->array.rank = rank; diff --git a/src/vm.c b/src/vm.c index 76b4fd1..261d05a 100644 --- a/src/vm.c +++ b/src/vm.c @@ -559,7 +559,13 @@ static void system_call(enum syscall_code code) case SYS_EXISTS_FILE: { // system.ExistsFile(string szFileName) int str = stack_pop().i; char *path = gamedir_path(heap_get_string(str)->text); - stack_push(file_exists(path)); + int len = strlen(path); + // Return true for directories, but false if the path ends with a directory separator. + if (len > 0 && (path[len-1] == '/' || path[len-1] == '\\')) { + stack_push(0); + } else { + stack_push(file_exists(path)); + } heap_unref(str); free(path); break; diff --git a/test/Run/test.ain b/test/Run/test.ain index 93f2e6a..2aa664b 100644 Binary files a/test/Run/test.ain and b/test/Run/test.ain differ diff --git a/test/Source/arrays.jaf b/test/Source/arrays.jaf index 4952b7a..b8104a6 100755 --- a/test/Source/arrays.jaf +++ b/test/Source/arrays.jaf @@ -292,6 +292,13 @@ void test_array_push_struct_with_ref(void) // Returning from this function should not double-free i. } +void test_array_alloc_neg(void) +{ + array@int ar; + ar.Alloc(-4); + test_bool("ar.Alloc(-4); ar.Empty()", ar.Empty(), true); +} + void test_arrays(void) { test_array_set(); @@ -312,4 +319,5 @@ void test_arrays(void) test_array_sort_custom_string(); test_array_constructors(); test_array_push_struct_with_ref(); + test_array_alloc_neg(); } diff --git a/test/Source/main.jaf b/test/Source/main.jaf index 411d234..965218e 100755 --- a/test/Source/main.jaf +++ b/test/Source/main.jaf @@ -84,6 +84,10 @@ int main(void) test_arrays(); test_end("arrays"); + test_start("system"); + test_system(); + test_end("system"); + test_start("Math.dll"); test_math(); test_end("Math.dll"); diff --git a/test/Source/system.jaf b/test/Source/system.jaf new file mode 100644 index 0000000..6fe3876 --- /dev/null +++ b/test/Source/system.jaf @@ -0,0 +1,8 @@ +// -*-mode: C; coding: sjis; -*- + +void test_system(void) +{ + string savedir = system.GetSaveFolderName(); + test_equal("system.ExistFile(savedir) == 1", system.ExistFile(savedir), 1); + test_equal("system.ExistFile(savedir + \"\\\\\") == 1", system.ExistFile(savedir + "\\"), 0); +} diff --git a/test/Source/test.inc b/test/Source/test.inc index 5ae260a..258b5a0 100755 --- a/test/Source/test.inc +++ b/test/Source/test.inc @@ -4,6 +4,7 @@ Source = { "arithmetic.jaf", "strings.jaf", "structs.jaf", +"system.jaf", "arrays.jaf", "math.jaf" }