mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Move miscellaneous low-level functions to system.[ch]
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "utfsjis.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
@@ -236,7 +235,7 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
|
||||
char mbuf[20];
|
||||
int cw, delta, wcnt;
|
||||
|
||||
wcnt = sdl_getTicks();
|
||||
wcnt = sys_get_ticks();
|
||||
|
||||
mbuf[0] = '\0';
|
||||
msg = get_char(msg, mbuf, sizeof(mbuf) -1);
|
||||
@@ -267,7 +266,7 @@ static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB
|
||||
needupdate = false;
|
||||
|
||||
// keywait
|
||||
delta = sdl_getTicks() - wcnt;
|
||||
delta = sys_get_ticks() - wcnt;
|
||||
if (delta < wSpeed) {
|
||||
if (sys_keywait(wSpeed - delta, KEYWAIT_NONCANCELABLE)) {
|
||||
|
||||
@@ -311,14 +310,14 @@ static int ntmsg_keywait() {
|
||||
night.waitkey = -1;
|
||||
|
||||
while (night.waitkey == -1 && !nact->is_quit) {
|
||||
int st = sdl_getTicks();
|
||||
int st = sys_get_ticks();
|
||||
int interval = 25;
|
||||
|
||||
if (!night.zhiding) {
|
||||
interval = night.sp[SPNO_MSG_KEYANIM]->u.anime.interval;
|
||||
hakanim(i++);
|
||||
}
|
||||
sys_keywait(interval - (sdl_getTicks() - st), KEYWAIT_NONCANCELABLE);
|
||||
sys_keywait(interval - (sys_get_ticks() - st), KEYWAIT_NONCANCELABLE);
|
||||
}
|
||||
|
||||
night.waittype = KEYWAIT_NONE;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "sprite.h"
|
||||
#include "gfx.h"
|
||||
#include "effect.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
効果つき画面更新
|
||||
@@ -55,12 +54,12 @@ void nt_sp_eupdate(int no, int time, int cancel) {
|
||||
struct effect *eff = effect_init(&rect, NULL, 0, 0, gfx_getDIB(), 0, 0, type);
|
||||
|
||||
int sttime, curtime;
|
||||
sttime = curtime = sdl_getTicks();
|
||||
sttime = curtime = sys_get_ticks();
|
||||
int edtime = curtime + time;
|
||||
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
effect_step(eff, (float)(curtime - sttime) / (edtime - sttime));
|
||||
int rest = 16 - (sdl_getTicks() - curtime);
|
||||
int rest = 16 - (sys_get_ticks() - curtime);
|
||||
int key = sys_keywait(rest, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
|
||||
if (cancel && key)
|
||||
break;
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "alk.h"
|
||||
#include "music.h"
|
||||
#include "gfx.h"
|
||||
#include "sdl_core.h"
|
||||
#include "input.h"
|
||||
#include "cg.h"
|
||||
#include "jpeg.h"
|
||||
@@ -53,9 +52,9 @@ static void ndd_run(int demonum) {
|
||||
if (mus)
|
||||
musbgm_play(mus, 0, 100, 0);
|
||||
|
||||
uint32_t start = sdl_getTicks();
|
||||
uint32_t start = sys_get_ticks();
|
||||
while (!nact->is_quit) {
|
||||
int i = (sdl_getTicks() - start) / (1000 / FPS);
|
||||
int i = (sys_get_ticks() - start) / (1000 / FPS);
|
||||
if (i >= alk->datanum)
|
||||
break;
|
||||
|
||||
@@ -70,7 +69,7 @@ static void ndd_run(int demonum) {
|
||||
WARNING("Cannot decode CG %d in %s", i, alk_path);
|
||||
}
|
||||
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sdl_getTicks() - start);
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sys_get_ticks() - start);
|
||||
if (wait_ms > 0) {
|
||||
if (sys_keywait(wait_ms, KEYWAIT_CANCELABLE))
|
||||
break;
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "input.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "randMT.h"
|
||||
|
||||
#define M_PIf ((float)M_PI)
|
||||
@@ -78,9 +77,9 @@ void sp_quake_screen(int type, int p1, int p2, int time, int cancel) {
|
||||
|
||||
if (type > 1) return;
|
||||
|
||||
sttime = sdl_getTicks();
|
||||
sttime = sys_get_ticks();
|
||||
edtime = time * 10 + sttime;
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
int adjx, adjy;
|
||||
|
||||
cb[type]((float)(curtime - sttime)/(edtime - sttime), p1, p2, &adjx, &adjy);
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "ags.h"
|
||||
#include "sdl_core.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
|
||||
@@ -44,7 +43,7 @@ static int eventCB_ANIM(sprite_t *sp, agsevent_t *e) {
|
||||
if (e->type != AGSEVENT_TIMER) return 0;
|
||||
|
||||
// 現在時刻の取得
|
||||
now = sdl_getTicks();
|
||||
now = sys_get_ticks();
|
||||
|
||||
// 指定時間までスキップ
|
||||
if ((now - sp->u.anime.starttime) < sp->u.anime.interval) return 0;
|
||||
@@ -85,7 +84,7 @@ void sp_anime_setup(sprite_t *sp) {
|
||||
int n = 0;
|
||||
|
||||
sp->u.anime.interval = 500; // デフォルトの間隔 0.5秒
|
||||
sp->u.anime.starttime = sdl_getTicks(); // 開始時刻
|
||||
sp->u.anime.starttime = sys_get_ticks(); // 開始時刻
|
||||
sp->u.anime.tick = 0; // カウンタ初期化
|
||||
|
||||
// アニメパターンはいくつあるか
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "sprite.h"
|
||||
#include "gfx.h"
|
||||
#include "effect.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
効果つき画面更新
|
||||
@@ -56,12 +55,12 @@ void sp_eupdate(int type, int time, int cancel) {
|
||||
struct effect *eff = effect_init(&rect, NULL, 0, 0, gfx_getDIB(), 0, 0, effect);
|
||||
|
||||
int sttime, curtime;
|
||||
sttime = curtime = sdl_getTicks();
|
||||
sttime = curtime = sys_get_ticks();
|
||||
int edtime = curtime + time * 10;
|
||||
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
effect_step(eff, (float)(curtime - sttime) / (edtime - sttime));
|
||||
int rest = 16 - (sdl_getTicks() - curtime);
|
||||
int rest = 16 - (sys_get_ticks() - curtime);
|
||||
int key = sys_keywait(rest, cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE);
|
||||
if (cancel && key)
|
||||
break;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "menu.h"
|
||||
#include "input.h"
|
||||
#include "nact.h"
|
||||
@@ -213,7 +212,7 @@ static void cb_waitkey_simple(agsevent_t *e) {
|
||||
switch (e->type) {
|
||||
case AGSEVENT_KEY_PRESS:
|
||||
if (e->code == KEY_Z) {
|
||||
cur = sdl_getTicks();
|
||||
cur = sys_get_ticks();
|
||||
if (!sact.zhiding) {
|
||||
slist_foreach(sact.sp_zhide, cb_defocused_zkey, &update);
|
||||
sact.zhiding = true;
|
||||
@@ -243,7 +242,7 @@ static void cb_waitkey_simple(agsevent_t *e) {
|
||||
case AGSEVENT_KEY_RELEASE:
|
||||
switch(e->code) {
|
||||
case KEY_Z:
|
||||
cur = sdl_getTicks();
|
||||
cur = sys_get_ticks();
|
||||
if (500 < (cur - sact.zofftime) || !sact.zdooff) {
|
||||
slist_foreach(sact.sp_zhide, cb_focused_zkey, &update);
|
||||
sact.zhiding = false;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "list.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
#include "input.h"
|
||||
@@ -67,7 +66,7 @@ static void hidesprite(sprite_t *sp) {
|
||||
スプライトがドロップされた時の各種処理を含む
|
||||
*/
|
||||
static bool waitcond(int endtime) {
|
||||
int curtime = sdl_getTicks();
|
||||
int curtime = sys_get_ticks();
|
||||
if (curtime >= endtime) return true;
|
||||
|
||||
if (sact.dropped) {
|
||||
@@ -144,7 +143,7 @@ void sp_keywait(int *vOK, int *vRND, int *vD01, int *vD02, int *vD03, int timeou
|
||||
}
|
||||
|
||||
// 終了時間の計算
|
||||
curtime = sdl_getTicks();
|
||||
curtime = sys_get_ticks();
|
||||
endtime = timeout < 0 ? INT_MAX : (curtime + timeout * 10);
|
||||
|
||||
// スプライトキー待ちメイン
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "nact.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -161,14 +160,14 @@ void spev_move_waitend(sprite_t *sp, int dx, int dy, int time) {
|
||||
sp->move.time = 0;
|
||||
|
||||
sact.movelist = slist_append(sact.movelist, sp);
|
||||
sact.movestarttime = sdl_getTicks();
|
||||
sact.movestarttime = sys_get_ticks();
|
||||
slist_foreach(sact.movelist, spev_move_setup, NULL);
|
||||
slist_free(sact.movelist);
|
||||
sact.movelist = NULL;
|
||||
|
||||
while (sp->move.moving) {
|
||||
nact->callback();
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +186,7 @@ void spev_wait4moving_sp() {
|
||||
|
||||
while (sp->move.moving) {
|
||||
nact->callback();
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ags.h"
|
||||
#include "nact.h"
|
||||
#include "input.h"
|
||||
@@ -268,7 +267,7 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
char mbuf[20], rbuf[20];
|
||||
int cw, delta, wcnt;
|
||||
|
||||
wcnt = sdl_getTicks();
|
||||
wcnt = sys_get_ticks();
|
||||
|
||||
mbuf[0] = rbuf[0] = '\0';
|
||||
msg = get_char(msg, mbuf, rbuf, sizeof(mbuf) -1);
|
||||
@@ -316,7 +315,7 @@ void smsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wF
|
||||
needupdate = false;
|
||||
|
||||
// keywait
|
||||
delta = sdl_getTicks() - wcnt;
|
||||
delta = sys_get_ticks() - wcnt;
|
||||
if (delta < wSpeed) {
|
||||
if (sys_keywait(wSpeed - delta, KEYWAIT_NONCANCELABLE)) {
|
||||
|
||||
@@ -420,7 +419,7 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
|
||||
sact.waitkey = -1;
|
||||
|
||||
while (sact.waitkey == -1 && !nact->is_quit) {
|
||||
int st = sdl_getTicks();
|
||||
int st = sys_get_ticks();
|
||||
int interval = 25;
|
||||
|
||||
// アニメパターンがある場合、その更新
|
||||
@@ -434,7 +433,7 @@ int smsg_keywait(int wNum1, int wNum2, int msglen) {
|
||||
update_mark(minfo[j].sp, minfo[j].cg);
|
||||
i++;
|
||||
}
|
||||
sys_keywait(interval - (sdl_getTicks() - st), KEYWAIT_NONCANCELABLE);
|
||||
sys_keywait(interval - (sys_get_ticks() - st), KEYWAIT_NONCANCELABLE);
|
||||
}
|
||||
|
||||
sact.waittype = KEYWAIT_NONE;
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "input.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
#include "randMT.h"
|
||||
|
||||
/*
|
||||
@@ -49,9 +48,9 @@ void sp_quake_sprite(int wType, int wAmplitudeX, int wAmplitudeY, int wCount, in
|
||||
int i = 0, key;
|
||||
SList *node;
|
||||
|
||||
edtime = wCount * 10 + sdl_getTicks();
|
||||
edtime = wCount * 10 + sys_get_ticks();
|
||||
|
||||
while ((curtime = sdl_getTicks()) < edtime) {
|
||||
while ((curtime = sys_get_ticks()) < edtime) {
|
||||
if (wType == 0) { // 全てのスプライトを同じように動かす
|
||||
int adjx = (int)(genrand() * wAmplitudeX/2);
|
||||
int adjy = (int)(genrand() * wAmplitudeY/2);
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "nact.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -63,7 +62,7 @@ static void tevent_callback(agsevent_t *e) {
|
||||
int update = 0;
|
||||
|
||||
// SP_MOVE の同期移動のためのカウンタの読み込み
|
||||
sact.movecurtime = sdl_getTicks();
|
||||
sact.movecurtime = sys_get_ticks();
|
||||
|
||||
for (node = sact.teventlisteners; node; node = node->next) {
|
||||
sprite_t *sp = (sprite_t *)node->data;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "system.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ags.h"
|
||||
#include "sact.h"
|
||||
#include "sprite.h"
|
||||
@@ -92,7 +91,7 @@ void sp_update_all(bool syncscreen) {
|
||||
// スプライト移動がある場合は移動開始
|
||||
if (sact.movelist) {
|
||||
// 移動開始時間を合わせる
|
||||
sact.movestarttime = sdl_getTicks();
|
||||
sact.movestarttime = sys_get_ticks();
|
||||
slist_foreach(sact.movelist, spev_move_setup, NULL);
|
||||
slist_free(sact.movelist);
|
||||
sact.movelist = NULL;
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "nact.h"
|
||||
#include "ags.h"
|
||||
#include "music.h"
|
||||
#include "sdl_core.h"
|
||||
#include "hacks.h"
|
||||
|
||||
#define SLOT 40
|
||||
@@ -451,7 +450,7 @@ static void PlayAnimeData() {
|
||||
dib = ags_getDIB();
|
||||
|
||||
for (loop = 0; loop < p1; loop++) {
|
||||
int cnt = sdl_getTicks();
|
||||
int cnt = sys_get_ticks();
|
||||
is_backcopied = false;
|
||||
|
||||
for (i = 0; i < SLOT; i++) {
|
||||
@@ -528,9 +527,9 @@ static void PlayAnimeData() {
|
||||
if (is_backcopied && !SDL_RectEmpty(&maprect))
|
||||
ags_updateArea(maprect.x, maprect.y, maprect.w, maprect.h);
|
||||
|
||||
int now = sdl_getTicks();
|
||||
int now = sys_get_ticks();
|
||||
if (now - cnt < interval) {
|
||||
sdl_sleep(interval - (now-cnt));
|
||||
sys_sleep(interval - (now-cnt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "system.h"
|
||||
#include "xsystem35.h"
|
||||
#include "modules.h"
|
||||
#include "sdl_core.h"
|
||||
#include "input.h"
|
||||
#include "menu.h"
|
||||
|
||||
@@ -54,7 +53,7 @@ static void OutputMessageBox(void) { /* 0 */
|
||||
char *title_utf8 = toUTF8(svar_get(title));
|
||||
char *msg_utf8 = toUTF8(svar_get(msg));
|
||||
|
||||
sdl_showMessageBox(MESSAGEBOX_INFO, title_utf8, msg_utf8);
|
||||
sys_show_message_box(MESSAGEBOX_INFO, title_utf8, msg_utf8);
|
||||
|
||||
free(title_utf8);
|
||||
free(msg_utf8);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "input.h"
|
||||
#include "bgm.h"
|
||||
#include "gfx.h"
|
||||
#include "sdl_core.h"
|
||||
#include "cg.h"
|
||||
#include "jpeg.h"
|
||||
|
||||
@@ -73,9 +72,9 @@ static void Run() {
|
||||
|
||||
musbgm_play(TDEMO_MUSIC_NO, 0, 100, 0);
|
||||
|
||||
uint32_t start = sdl_getTicks();
|
||||
uint32_t start = sys_get_ticks();
|
||||
while (!nact->is_quit) {
|
||||
int i = (sdl_getTicks() - start) / (1000 / FPS);
|
||||
int i = (sys_get_ticks() - start) / (1000 / FPS);
|
||||
if (i >= alk->datanum)
|
||||
break;
|
||||
|
||||
@@ -90,7 +89,7 @@ static void Run() {
|
||||
WARNING("Cannot decode CG %d", i);
|
||||
}
|
||||
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sdl_getTicks() - start);
|
||||
int wait_ms = (i + 1) * (1000 / FPS) - (sys_get_ticks() - start);
|
||||
if (wait_ms > 0) {
|
||||
if (sys_keywait(wait_ms, KEYWAIT_CANCELABLE))
|
||||
break;
|
||||
|
||||
@@ -89,6 +89,7 @@ target_sources(xsystem35 PRIVATE
|
||||
sdl_cursor.c
|
||||
sdl_event.c
|
||||
selection.c
|
||||
system.c
|
||||
texthook.c
|
||||
variable.c
|
||||
vsp.c
|
||||
|
||||
@@ -599,10 +599,10 @@ void ags_alpha_setPixel(int x, int y, int w, int h, uint8_t *b) {
|
||||
|
||||
void ags_runEffect(int duration_ms, bool cancelable, ags_EffectStepFunc step, void *arg) {
|
||||
unsigned wflags = cancelable ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE;
|
||||
int start = sdl_getTicks();
|
||||
for (int t = 0; t < duration_ms; t = sdl_getTicks() - start) {
|
||||
int start = sys_get_ticks();
|
||||
for (int t = 0; t < duration_ms; t = sys_get_ticks() - start) {
|
||||
step(arg, (float)t / duration_ms);
|
||||
int key = sys_keywait(start + t + 16 - sdl_getTicks(), wflags);
|
||||
int key = sys_keywait(start + t + 16 - sys_get_ticks(), wflags);
|
||||
if (cancelable && key) {
|
||||
nact->waitcancel_key = key;
|
||||
break;
|
||||
@@ -724,7 +724,7 @@ void ags_setCursorLocation(int x, int y, bool is_dibgeo, bool for_selection) {
|
||||
// navigation.
|
||||
sdl_setCursorInternalLocation(x, y);
|
||||
EM_ASM({ xsystem35.shell.showMouseMoveEffect($0, $1); }, x, y);
|
||||
sdl_sleep(cursor_move_time);
|
||||
sys_sleep(cursor_move_time);
|
||||
}
|
||||
#else
|
||||
if (nact->ags.mouse_warp_enabled) {
|
||||
@@ -736,12 +736,12 @@ void ags_setCursorLocation(int x, int y, bool is_dibgeo, bool for_selection) {
|
||||
int xi = ((dx*i*i*i) >> 9) - ((3*dx*i*i)>> 6) + ((3*dx*i) >> 3) + p.x;
|
||||
int yi = ((dy*i*i*i) >> 9) - ((3*dy*i*i)>> 6) + ((3*dy*i) >> 3) + p.y;
|
||||
sdl_setCursorLocation(xi, yi);
|
||||
sdl_sleep(cursor_move_time / 7);
|
||||
sys_sleep(cursor_move_time / 7);
|
||||
}
|
||||
sdl_setCursorLocation(x, y);
|
||||
} else if (!for_selection) {
|
||||
sdl_setCursorInternalLocation(x, y);
|
||||
sdl_sleep(cursor_move_time);
|
||||
sys_sleep(cursor_move_time);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "nact.h"
|
||||
#include "bgm.h"
|
||||
#include "bgi.h"
|
||||
#include "sdl_core.h"
|
||||
#include "system.h"
|
||||
|
||||
bool musbgm_init(DRIFILETYPE type, int base_no) {
|
||||
if (type == DRIFILE_BGM)
|
||||
@@ -84,6 +84,6 @@ void musbgm_wait(int no, int timeout) {
|
||||
for (int i = 0; i * 16 < timeout * 10; i++) {
|
||||
if (!musbgm_isplaying(no))
|
||||
break;
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "portab.h"
|
||||
#include "cdrom.h"
|
||||
#include "scheduler.h"
|
||||
#include "system.h"
|
||||
|
||||
static bool cdrom_init(char *playlist) {
|
||||
return true;
|
||||
|
||||
+2
-3
@@ -39,7 +39,6 @@
|
||||
#include "hankaku.h"
|
||||
#include "ags.h"
|
||||
#include "gfx.h"
|
||||
#include "sdl_core.h"
|
||||
#include "ald_manager.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "hacks.h"
|
||||
@@ -944,7 +943,7 @@ void commands2F5A() {
|
||||
char *t1;
|
||||
|
||||
t1 = toUTF8(sText);
|
||||
sdl_showMessageBox(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
sys_show_message_box(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
free(t1);
|
||||
|
||||
TRACE("strMessageBox %s:", sText);
|
||||
@@ -955,7 +954,7 @@ void commands2F5B() {
|
||||
char *t1;
|
||||
|
||||
t1 = toUTF8(svar_get(eNum));
|
||||
sdl_showMessageBox(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
sys_show_message_box(MESSAGEBOX_INFO, nact->game_title_utf8, t1);
|
||||
free(t1);
|
||||
|
||||
TRACE("strMessageBoxStr %d:", eNum);
|
||||
|
||||
+4
-5
@@ -27,7 +27,6 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include "portab.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "xsystem35.h"
|
||||
#include "scenario.h"
|
||||
@@ -760,7 +759,7 @@ void commandVA() { /* from Panyo */
|
||||
/* 開始 (p3=コマ数,0:無限(開始位置==終了位置のとき))*/
|
||||
inAnimation = true;
|
||||
VAcmd[p1].elaspCut = 0;
|
||||
VAcmd[p1].startTime = sdl_getTicks();
|
||||
VAcmd[p1].startTime = sys_get_ticks();
|
||||
VAcmd[p1].totalCut = p3;
|
||||
|
||||
if (p3 == 0) {
|
||||
@@ -784,7 +783,7 @@ void commandVA() { /* from Panyo */
|
||||
/* キー抜け無し ,p3=0は指定不可 */
|
||||
while(VAcmd[p1].state == VA_RUNNING) {
|
||||
va_animationAlone(p1);
|
||||
sdl_sleep(10);
|
||||
sys_sleep(10);
|
||||
}
|
||||
va_drawUnit(p1);
|
||||
va_updateUnit(p1);
|
||||
@@ -794,7 +793,7 @@ void commandVA() { /* from Panyo */
|
||||
VAcmd[p1].rewrite = true;
|
||||
while(VAcmd[p1].state == VA_RUNNING) {
|
||||
va_animationAlone(p1);
|
||||
sdl_sleep(10);
|
||||
sys_sleep(10);
|
||||
key = sys_getInputInfo();
|
||||
if (key != 0) {
|
||||
sysVar[0] = key;
|
||||
@@ -1003,7 +1002,7 @@ static void va_animationAlone(int i) {
|
||||
static void va_update() {
|
||||
bool proceeding = false;
|
||||
int i;
|
||||
int curTime = sdl_getTicks();
|
||||
int curTime = sys_get_ticks();
|
||||
|
||||
for (i = 0; i < VACMD_MAX; i++) {
|
||||
if (VAcmd[i].state == VA_RUNNING) {
|
||||
|
||||
+1
-2
@@ -31,7 +31,6 @@
|
||||
#include "input.h"
|
||||
#include "scenario.h"
|
||||
#include "cmd_check.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "music_cdrom.h"
|
||||
#include "hacks.h"
|
||||
@@ -75,7 +74,7 @@ static void rance4_Y3_IM_hack() {
|
||||
|
||||
int button_pressed = sys_getInputInfo();
|
||||
if (!button_pressed) {
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
count = 0;
|
||||
}
|
||||
commandIM();
|
||||
|
||||
+2
-3
@@ -28,7 +28,6 @@
|
||||
#include "portab.h"
|
||||
#include "xsystem35.h"
|
||||
#include "gfx.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "ags.h"
|
||||
#include "scenario.h"
|
||||
@@ -45,13 +44,13 @@ static struct {
|
||||
} counters[257]; // [0] for ZT 1-5, [1..256] for ZT 10-11
|
||||
|
||||
static void reset_counter(int num, int divisor, int offset) {
|
||||
counters[num].base = sdl_getTicks() - offset;
|
||||
counters[num].base = sys_get_ticks() - offset;
|
||||
counters[num].divisor = divisor;
|
||||
}
|
||||
|
||||
static uint32_t get_counter(int num) {
|
||||
scheduler_on_event(SCHEDULER_EVENT_TIMER_CHECK);
|
||||
return sdl_getTicks() - counters[num].base;
|
||||
return sys_get_ticks() - counters[num].base;
|
||||
}
|
||||
|
||||
void commandZC() {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "system.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "dri.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
static bool read_index(int volume, drifiles *d, FILE *fp) {
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
@@ -142,7 +141,7 @@ static void warn_missing_ald(drifiles *d, int no) {
|
||||
} else {
|
||||
snprintf(msgbuf, sizeof(msgbuf), "Cannot read resource #%d.", no);
|
||||
}
|
||||
sdl_showMessageBox(MESSAGEBOX_WARNING, "xsystem35", msgbuf);
|
||||
sys_show_message_box(MESSAGEBOX_WARNING, "xsystem35", msgbuf);
|
||||
}
|
||||
|
||||
dridata *dri_getdata(drifiles *d, int no) {
|
||||
|
||||
+8
-9
@@ -28,7 +28,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "gfx.h"
|
||||
#include "sdl_core.h"
|
||||
#include "input.h"
|
||||
#include "ags.h"
|
||||
#include "system.h"
|
||||
@@ -40,7 +39,7 @@ static bool ecp_cancel;
|
||||
#define EC_WAIT \
|
||||
if ((key |= sys_getInputInfo()) && ecp_cancel) break; \
|
||||
do { \
|
||||
int wait_ms = cnt - sdl_getTicks(); \
|
||||
int wait_ms = cnt - sys_get_ticks(); \
|
||||
if (wait_ms >= 16) \
|
||||
key = sys_keywait(wait_ms, ecp_cancel ? KEYWAIT_CANCELABLE : KEYWAIT_NONCANCELABLE); \
|
||||
} while (0)
|
||||
@@ -61,7 +60,7 @@ static int eCopyArea5(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
static int hx[16]={ 0,32,16,48, 0,32,16,48,16,48, 0,32,16,48, 0,32};
|
||||
static int hy[16]={ 0, 0,16,16,32,32,48,48, 0, 0,16,16,32,32,48,48};
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 16; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h -63); y += 64) {
|
||||
@@ -82,7 +81,7 @@ static int eCopyArea6(int dx, int dy, int w, int h, int opt) {
|
||||
int i, x, y, key = 0, cnt;
|
||||
int waitcnt = opt == 0 ? 30 : opt;
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 7; i++) {
|
||||
cnt += waitcnt;
|
||||
for (x = 0; x < (w -63); x += 64) {
|
||||
@@ -106,7 +105,7 @@ static int eCopyArea9(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
static int hintY[4] = {0,8,8,0};
|
||||
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 4; i++) {
|
||||
cnt+=waitcnt;
|
||||
for (y = 0; y < h -15; y+=16) {
|
||||
@@ -126,7 +125,7 @@ static int eCopyArea16(int dx, int dy, int w, int h, int opt) {
|
||||
int i, x, key = 0, cnt;
|
||||
int waitcnt = opt == 0 ? 30 : opt;
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 8; i++) {
|
||||
cnt += waitcnt;
|
||||
for (x = 0; x < (w -15); x += 16) {
|
||||
@@ -144,7 +143,7 @@ static int eCopyArea17(int dx, int dy, int w, int h, int opt) {
|
||||
int waitcnt = opt == 0 ? 30 : opt;
|
||||
|
||||
#define E17X 18
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < E17X; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h - E17X + 1); y += E17X) {
|
||||
@@ -160,7 +159,7 @@ static int eCopyArea22(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
int i, x, y, key = 0, cnt;
|
||||
int waitcnt = opt == 0 ? 80 : opt;
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 2; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h -3); y+=4) {
|
||||
@@ -185,7 +184,7 @@ static int eCopyArea23(int sx, int sy, int w, int h, int dx, int dy, int opt) {
|
||||
static int hintX[4] = {0,2,2,0};
|
||||
static int hintY[4] = {0,2,0,2};
|
||||
|
||||
cnt = sdl_getTicks();
|
||||
cnt = sys_get_ticks();
|
||||
for (i = 0; i < 4; i++) {
|
||||
cnt += waitcnt;
|
||||
for (y = 0; y < (h -3); y+=4) {
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include "system.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_private.h"
|
||||
#include "sdl_core.h"
|
||||
#include "scheduler.h"
|
||||
#include "font.h"
|
||||
#include "ags.h"
|
||||
#include "image.h"
|
||||
@@ -66,43 +64,6 @@ void gfx_updateScreen(void) {
|
||||
gfx_dirty = false;
|
||||
}
|
||||
|
||||
uint32_t sdl_getTicks(void) {
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
void sdl_sleep(int msec) {
|
||||
gfx_updateScreen();
|
||||
dbg_onsleep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_sleep(msec);
|
||||
#else
|
||||
SDL_Delay(msec);
|
||||
#endif
|
||||
scheduler_on_event(SCHEDULER_EVENT_SLEEP);
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_JS(void, wait_vsync, (void), {
|
||||
// We need a `return` here for JSPI support (ASYNCIFY=2).
|
||||
return Asyncify.handleSleep(function(wakeUp) {
|
||||
window.requestAnimationFrame(function() {
|
||||
wakeUp();
|
||||
});
|
||||
});
|
||||
});
|
||||
#endif
|
||||
|
||||
void sdl_wait_vsync() {
|
||||
gfx_updateScreen();
|
||||
dbg_onsleep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
wait_vsync();
|
||||
#else
|
||||
SDL_Delay(16);
|
||||
#endif
|
||||
scheduler_on_event(SCHEDULER_EVENT_SLEEP);
|
||||
}
|
||||
|
||||
/* off-screen の指定領域を Main Window へ転送 */
|
||||
void gfx_updateArea(SDL_Rect *rect, SDL_Point *dst) {
|
||||
SDL_Rect sw = {0, 0, main_surface->w, main_surface->h};
|
||||
|
||||
@@ -247,16 +247,6 @@ void gfx_setWindowSize(int w, int h) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void sdl_showMessageBox(enum messagebox_type type, const char* title_utf8, const char* message_utf8) {
|
||||
uint32_t flags = 0;
|
||||
switch (type) {
|
||||
case MESSAGEBOX_ERROR: flags = SDL_MESSAGEBOX_ERROR; break;
|
||||
case MESSAGEBOX_WARNING: flags = SDL_MESSAGEBOX_WARNING; break;
|
||||
case MESSAGEBOX_INFO: flags = SDL_MESSAGEBOX_INFORMATION; break;
|
||||
}
|
||||
SDL_ShowSimpleMessageBox(flags, title_utf8, message_utf8, gfx_window);
|
||||
}
|
||||
|
||||
void gfx_setIntegerScaling(bool enable) {
|
||||
SDL_RenderSetIntegerScale(gfx_renderer, enable);
|
||||
}
|
||||
|
||||
+5
-5
@@ -100,14 +100,14 @@ int sys_keywait(int msec, unsigned flags) {
|
||||
}
|
||||
|
||||
int key=0, n;
|
||||
int end = msec == INT_MAX ? INT_MAX : sdl_getTicks() + msec;
|
||||
int end = msec == INT_MAX ? INT_MAX : sys_get_ticks() + msec;
|
||||
while (!nact->is_quit &&
|
||||
!((flags & KEYWAIT_SKIPPABLE) && msgskip_isSkipping()) &&
|
||||
(n = end - sdl_getTicks()) > 0) {
|
||||
(n = end - sys_get_ticks()) > 0) {
|
||||
if (n <= 16)
|
||||
sdl_sleep(n);
|
||||
sys_sleep(n);
|
||||
else
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
nact->callback();
|
||||
key = sys_getInputInfo();
|
||||
cancel_yield(); // We just yielded!
|
||||
@@ -122,7 +122,7 @@ void sys_hit_any_key() {
|
||||
if (msgskip_isSkipping()) {
|
||||
if (msgskip_getFlags() & MSGSKIP_STOP_ON_CLICK && sys_getInputInfo())
|
||||
msgskip_activate(false);
|
||||
sdl_sleep(30);
|
||||
sys_sleep(30);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "portab.h"
|
||||
#include "windowframe.h"
|
||||
#include "sdl_core.h"
|
||||
#include "xsystem35.h"
|
||||
#include "message.h"
|
||||
#include "variable.h"
|
||||
@@ -140,7 +139,7 @@ void msg_putMessage(const char *m) {
|
||||
ags_updateArea(drawn.x, drawn.y, drawn.w, drawn.h);
|
||||
break;
|
||||
}
|
||||
sdl_sleep(nact->messagewait_time * 10);
|
||||
sys_sleep(nact->messagewait_time * 10);
|
||||
nact->callback();
|
||||
}
|
||||
} else {
|
||||
|
||||
+2
-3
@@ -34,7 +34,6 @@
|
||||
#include "dri.h"
|
||||
#include "music_pcm.h"
|
||||
#include "music_private.h"
|
||||
#include "sdl_core.h"
|
||||
#include "nact.h"
|
||||
#include "LittleEndian.h"
|
||||
#include "mmap.h"
|
||||
@@ -237,7 +236,7 @@ bool muspcm_start(int slot, int loop) {
|
||||
if (Mix_PlayChannel(slot, slots[slot].chunk, loop - 1) < 0)
|
||||
return false;
|
||||
|
||||
slots[slot].start_time = sdl_getTicks();
|
||||
slots[slot].start_time = sys_get_ticks();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -277,7 +276,7 @@ int muspcm_getpos(int slot) {
|
||||
if (!Mix_Playing(slot))
|
||||
return 0;
|
||||
|
||||
int pos = sdl_getTicks() - slots[slot].start_time;
|
||||
int pos = sys_get_ticks() - slots[slot].start_time;
|
||||
if (pos == 0)
|
||||
pos = 1; // because 0 means "not playing"
|
||||
|
||||
|
||||
+3
-4
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
#include "scheduler.h"
|
||||
#include "scenario.h"
|
||||
#include "sdl_core.h"
|
||||
#include "nact.h"
|
||||
#include "hacks.h"
|
||||
|
||||
@@ -87,13 +86,13 @@ void scheduler_on_event(enum scheduler_event event) {
|
||||
void scheduler_yield(void) {
|
||||
switch (game_id) {
|
||||
case GAME_AGAKE:
|
||||
sdl_sleep(6); // The slot game runs in a 6ms-cycle loop.
|
||||
sys_sleep(6); // The slot game runs in a 6ms-cycle loop.
|
||||
break;
|
||||
case GAME_PERSIOM:
|
||||
sdl_sleep(10); // The slot game runs in a 10ms-cycle loop.
|
||||
sys_sleep(10); // The slot game runs in a 10ms-cycle loop.
|
||||
break;
|
||||
default:
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +46,6 @@ extern void sdl_setAutoRepeat(bool enable);
|
||||
extern SDL_Point sdl_translateMouseCoords(int x, int y);
|
||||
|
||||
/* misc */
|
||||
enum messagebox_type {
|
||||
MESSAGEBOX_ERROR,
|
||||
MESSAGEBOX_WARNING,
|
||||
MESSAGEBOX_INFO,
|
||||
};
|
||||
extern uint32_t sdl_getTicks(void);
|
||||
extern void sdl_sleep(int msec);
|
||||
extern void sdl_wait_vsync();
|
||||
extern void sdl_showMessageBox(enum messagebox_type type, const char* title_utf8, const char* message_utf8);
|
||||
extern bool sdl_inputString(struct inputstring_param *);
|
||||
extern void sdl_post_debugger_command(void *data);
|
||||
extern void sdl_handle_event(SDL_Event *e);
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@
|
||||
#include "gfx_private.h"
|
||||
#include "menu.h"
|
||||
#include "nact.h"
|
||||
#include "system.h"
|
||||
|
||||
#define XMARGIN 3
|
||||
#define YMARGIN 2
|
||||
@@ -158,7 +159,7 @@ bool sdl_inputString(INPUTSTRING_PARAM *p) {
|
||||
while (!input->done) {
|
||||
sdl_getKeyInfo(); // message pump
|
||||
nact->callback();
|
||||
sdl_wait_vsync();
|
||||
sys_wait_vsync();
|
||||
}
|
||||
SDL_StopTextInput();
|
||||
sdl_custom_event_handler = NULL;
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (C) 2025 kichikuou <KichikuouChrome@gmail.com>
|
||||
*
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
#include <SDL.h>
|
||||
#include "debugger.h"
|
||||
#include "gfx.h"
|
||||
#include "gfx_private.h"
|
||||
#include "scheduler.h"
|
||||
#include "sdl_core.h"
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUGLEVEL 2
|
||||
#else
|
||||
#define DEBUGLEVEL 0
|
||||
#endif /* DEBUG */
|
||||
|
||||
static int debuglv = DEBUGLEVEL;
|
||||
|
||||
void sys_set_debug_level(int level) {
|
||||
debuglv = level;
|
||||
}
|
||||
|
||||
void sys_message(int lv, char *format, ...) {
|
||||
if (debuglv < lv)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
const int prio_table[] = {
|
||||
ANDROID_LOG_FATAL,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_VERBOSE,
|
||||
};
|
||||
int prio = prio_table[min(lv, 5)];
|
||||
__android_log_vprint(prio, "xsystem35", format, args);
|
||||
#else
|
||||
if (!dbg_console_vprintf(lv, format, args))
|
||||
vfprintf(stderr, format, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void sys_error(char *format, ...) {
|
||||
char buf[512];
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsnprintf(buf, sizeof buf, format, args);
|
||||
va_end(args);
|
||||
sys_show_message_box(MESSAGEBOX_ERROR, "xsystem35", buf);
|
||||
|
||||
sys35_remove();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void sys_exit(int code) {
|
||||
sys35_remove();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_ASM( xsystem35.shell.quit(); );
|
||||
sys_sleep(1000000000);
|
||||
#else
|
||||
exit(code);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t sys_get_ticks(void) {
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
void sys_sleep(int msec) {
|
||||
gfx_updateScreen();
|
||||
dbg_onsleep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_sleep(msec);
|
||||
#else
|
||||
SDL_Delay(msec);
|
||||
#endif
|
||||
scheduler_on_event(SCHEDULER_EVENT_SLEEP);
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_JS(void, wait_vsync, (void), {
|
||||
// We need a `return` here for JSPI support (ASYNCIFY=2).
|
||||
return Asyncify.handleSleep(function(wakeUp) {
|
||||
window.requestAnimationFrame(function() {
|
||||
wakeUp();
|
||||
});
|
||||
});
|
||||
});
|
||||
#endif
|
||||
|
||||
void sys_wait_vsync(void) {
|
||||
gfx_updateScreen();
|
||||
dbg_onsleep();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
wait_vsync();
|
||||
#else
|
||||
SDL_Delay(16);
|
||||
#endif
|
||||
scheduler_on_event(SCHEDULER_EVENT_SLEEP);
|
||||
}
|
||||
|
||||
void sys_show_message_box(enum messagebox_type type, const char* title_utf8, const char* message_utf8) {
|
||||
uint32_t flags = 0;
|
||||
switch (type) {
|
||||
case MESSAGEBOX_ERROR: flags = SDL_MESSAGEBOX_ERROR; break;
|
||||
case MESSAGEBOX_WARNING: flags = SDL_MESSAGEBOX_WARNING; break;
|
||||
case MESSAGEBOX_INFO: flags = SDL_MESSAGEBOX_INFORMATION; break;
|
||||
}
|
||||
SDL_ShowSimpleMessageBox(flags, title_utf8, message_utf8, gfx_window);
|
||||
}
|
||||
+18
-10
@@ -24,12 +24,25 @@
|
||||
#ifndef __SYSTEM__
|
||||
#define __SYSTEM__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
/* should define in somewhere */
|
||||
extern void sys_error(char *format, ...); /* show nessafe and exit system */
|
||||
extern void sys_exit(int code); /* exit system with code */
|
||||
extern void sys_message(int lv, char *format, ...); /* show various message */
|
||||
void sys_error(char *format, ...); /* show message and exit system */
|
||||
void sys_exit(int code); /* exit system with code */
|
||||
void sys_message(int lv, char *format, ...); /* show various message */
|
||||
|
||||
uint32_t sys_get_ticks(void);
|
||||
void sys_sleep(int msec);
|
||||
void sys_wait_vsync(void);
|
||||
|
||||
enum messagebox_type {
|
||||
MESSAGEBOX_ERROR,
|
||||
MESSAGEBOX_WARNING,
|
||||
MESSAGEBOX_INFO,
|
||||
};
|
||||
void sys_show_message_box(enum messagebox_type type, const char* title_utf8, const char* message_utf8);
|
||||
|
||||
void sys35_remove(void);
|
||||
|
||||
/*
|
||||
DEBUGLEVEL
|
||||
@@ -38,12 +51,7 @@ extern void sys_message(int lv, char *format, ...); /* show various message */
|
||||
1: warning only(output to terminal)
|
||||
2+: more message [devel relase default]
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUGLEVEL 2
|
||||
#else
|
||||
#define DEBUGLEVEL 0
|
||||
#endif /* DEBUG */
|
||||
void sys_set_debug_level(int level);
|
||||
|
||||
#define NOMEMERR() sys_error("Out of memory at %s()\n", __func__)
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ static void saveScreenshot(void) {
|
||||
if (!GetSaveFileName(&ofn))
|
||||
return;
|
||||
if (!save_screenshot(pathbuf)) {
|
||||
sdl_showMessageBox(MESSAGEBOX_ERROR, "xsystem35", SDL_GetError());
|
||||
sys_show_message_box(MESSAGEBOX_ERROR, "xsystem35", SDL_GetError());
|
||||
SDL_ClearError();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-58
@@ -43,10 +43,6 @@
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "win/dialog.h"
|
||||
#endif
|
||||
@@ -78,14 +74,11 @@
|
||||
static char *gameResourceFile = "xsystem35.gr";
|
||||
static void sys35_usage(bool verbose);
|
||||
static void sys35_init();
|
||||
static void sys35_remove();
|
||||
static void sys35_ParseOption(int *argc, char **argv);
|
||||
static void check_profile();
|
||||
|
||||
static const char *render_driver = NULL;
|
||||
|
||||
/* for debugging */
|
||||
static int debuglv = DEBUGLEVEL;
|
||||
enum {
|
||||
DEBUGGER_DISABLED,
|
||||
DEBUGGER_CUI,
|
||||
@@ -156,54 +149,6 @@ static void sys35_usage(bool verbose) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void sys_message(int lv, char *format, ...) {
|
||||
if (debuglv < lv)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
const int prio_table[] = {
|
||||
ANDROID_LOG_FATAL,
|
||||
ANDROID_LOG_ERROR,
|
||||
ANDROID_LOG_WARN,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_INFO,
|
||||
ANDROID_LOG_VERBOSE,
|
||||
};
|
||||
int prio = prio_table[min(lv, 5)];
|
||||
__android_log_vprint(prio, "xsystem35", format, args);
|
||||
#else
|
||||
if (!dbg_console_vprintf(lv, format, args))
|
||||
vfprintf(stderr, format, args);
|
||||
#endif
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void sys_error(char *format, ...) {
|
||||
char buf[512];
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
vsnprintf(buf, sizeof buf, format, args);
|
||||
va_end(args);
|
||||
sdl_showMessageBox(MESSAGEBOX_ERROR, "xsystem35", buf);
|
||||
|
||||
sys35_remove();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void sys_exit(int code) {
|
||||
sys35_remove();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
EM_ASM( xsystem35.shell.quit(); );
|
||||
sdl_sleep(1000000000);
|
||||
#else
|
||||
exit(code);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void sys35_init() {
|
||||
int i;
|
||||
|
||||
@@ -229,7 +174,7 @@ static void sys35_init() {
|
||||
msgskip_init(nact->files.msgskip);
|
||||
}
|
||||
|
||||
static void sys35_remove() {
|
||||
void sys35_remove(void) {
|
||||
dbg_quit();
|
||||
mus_exit();
|
||||
ags_remove();
|
||||
@@ -337,7 +282,7 @@ static void sys35_ParseOption(int *argc, char **argv) {
|
||||
nact->ags.noimagecursor = true;
|
||||
} else if (0 == strcmp(argv[i], "-debuglv")) {
|
||||
if (argv[i + 1] != NULL) {
|
||||
debuglv = argv[i + 1][0] - '0';
|
||||
sys_set_debug_level(argv[i + 1][0] - '0');
|
||||
}
|
||||
} else if (0 == strcmp(argv[i], "-version")) {
|
||||
puts(VERSION);
|
||||
@@ -523,7 +468,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
if (!initGameResource(&nact->files, gameResourceFile, savedir)) {
|
||||
#ifdef _WIN32
|
||||
sdl_showMessageBox(MESSAGEBOX_ERROR, "xsystem35", "Cannot find scenario file (*SA.ALD)");
|
||||
sys_show_message_box(MESSAGEBOX_ERROR, "xsystem35", "Cannot find scenario file (*SA.ALD)");
|
||||
exit(1);
|
||||
#else
|
||||
sys35_usage(true);
|
||||
|
||||
Reference in New Issue
Block a user