# HG changeset patch # User Thibaut GIRKA # Date 1258237911 -3600 # Node ID 6d9146f56ccf698dbbb691828aed5829bccd8684 # Parent c7bcc0ec22676e785d73df9f5d322a6c65155318 * Move some opcodes * Merge last changes from xclannad diff --git a/scn2k/scn2k_impl.cc b/scn2k/scn2k_impl.cc --- a/scn2k/scn2k_impl.cc +++ b/scn2k/scn2k_impl.cc @@ -392,13 +392,13 @@ fprintf(stderr," -> fall back to %d\n",s void Scn2k::ShowCursor(void) { HideCursor(); char key[1024]; - sprintf(key, "#MOUSE_CURSOR.%03d.NAME",mouse_type); + sprintf(key, "#MOUSE_CURSOR.%03d.NAME", mouse_type); const char* name = config->GetParaStr(key); if (name == NULL || name[0] == 0) mouse_surface = DEFAULT_MOUSECURSOR; - else { - mouse_surface = parent.Root().NewSurface(name, COLOR_MASK); - } - if (mouse_surface == NULL) mouse_surface = DEFAULT_MOUSECURSOR; + else + mouse_surface = parent.Root().NewSurface("toto", COLOR_MASK); + if (mouse_surface == NULL) + mouse_surface = DEFAULT_MOUSECURSOR; System::Main::SetCursor(mouse_surface, Rect(8, 8, 8+32, 8+32)); } diff --git a/scn2k/scn2k_text.cc b/scn2k/scn2k_text.cc --- a/scn2k/scn2k_text.cc +++ b/scn2k/scn2k_text.cc @@ -102,13 +102,19 @@ Text::Text(Event::Container& _event, Pic RegisterCommand(0, 3, 152, "msgClear", (CmdImpl) &Text::impl_msgClear); RegisterCommand(0, 2, 1, "select", (CmdImpl) &Text::impl_createSelect); - RegisterCommand(0, 2, 3, "select2?", (CmdImpl) &Text::impl_createSelect); //What difference with select? + RegisterCommand(0, 2, 3, "select2?", (CmdImpl) &Text::impl_createSelect); //FIXME: What difference with select? RegisterCommand(0, 4, 1000, "ShowBackground", (CmdImpl) &Text::impl_ShowBackground); RegisterCommand(0, 4, 1100, "SetSkipMode", (CmdImpl) &Text::impl_SetSkipMode); RegisterCommand(1, 4, 100, "wait", (CmdImpl) &Text::impl_Wait); RegisterCommand(1, 4, 111, "time", (CmdImpl) &Text::impl_Wait); RegisterCommand(1, 4, 121, "timeEx", (CmdImpl) &Text::impl_Wait); + + RegisterCommand(1, 4, 101, "waitC", (CmdImpl) &Text::impl_Wait); + RegisterCommand(1, 4, 112, "timeC", (CmdImpl) &Text::impl_Wait); + RegisterCommand(1, 4, 131, "GetClick", (CmdImpl) &Text::impl_GetClick); + + RegisterCommand(1, 4, 510, "ReadFrame", (CmdImpl) &Text::impl_ReadFrame); } Text::~Text() { @@ -728,51 +734,11 @@ void Text::Exec(Cmd& cmd) { CommandHandler::Exec(cmd); + //RegisterCommand(1, 4, 110, "ResetTimer", NULL); + //RegisterCommand(1, 4, 120, "ResetExTimer", NULL); if (cmd.cmd1 == 1 && cmd.cmd2 == 4) { /* ウェイト関連命令 */ - if (cmd.cmd3 == 0x65 || cmd.cmd3 == 0x70) { - eprintf("wait %dmsec(click stop)\n",cmd.args[0].value); - if (cmd.cmd3 == 0x70) wait_time = base_time + cmd.args[0].value; - else wait_time = old_time + cmd.args[0].value; - status = WAIT_CLICK; - cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 画像描画に戻る(skip時にテキストが描画されやすくするため) - } else if (cmd.cmd3 == 0x83) { - /* マウスがクリックされるまで待つ */ - eprintf("wait and get mouse pos at click\n"); - wait_time = old_time + 1000 * 1000; - status = WAIT_CLICK_MOUSEPOS; - wait_savedvar[0] = cmd.args[0]; - wait_savedvar[1] = cmd.args[1]; - cmd.clear(); - } else if (cmd.cmd3 == 0x1fe) { - eprintf("get timer value[%d]\n",cmd.args[0].value); - if (timer_var.find(cmd.args[0].value) == timer_var.end()) { - cmd.SetSysvar(0); - } else { - TimerAtom& atom = timer_var[cmd.args[0].value]; - if (atom.total_time <= 0) atom.total_time = 1; - int cur_tm = old_time - atom.start_time; - if (cur_tm < 0) cur_tm = atom.total_time; // エラーなら最終時間に合わせる - if (cur_tm > atom.total_time) cur_tm = atom.total_time; - // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit. - int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time); - cmd.SetSysvar(v); - } -/* From rldev-1.40, reallive.kfn -0x72 fun Timer (store) <1:Sys:00114, 1> ('counter') () -0x73 fun CmpTimer (store) <1:Sys:00115, 1> ('time') ('time', 'counter') -0x74 fun SetTimer <1:Sys:00116, 1> ('time') ('time', 'counter') - -0x78 fun ResetExTimer <1:Sys:00120, 1> ('counter') () -0x79 fun timeEx <1:Sys:00121, 1> ('time') ('time', 'counter') -0x7a fun timeExC (store) <1:Sys:00122, 1> ('time') ('time', 'counter') -0x7b fun timeExC2 (store) <1:Sys:00123, 1> ('time') ('time', 'counter') // UNDOCUMENTED -0x7c fun ExTimer (store) <1:Sys:00124, 1> ('counter') () -0x7d fun CmpExTimer (store) <1:Sys:00125, 1> ('time') ('time', 'counter') -0x7e fun SetExTimer <1:Sys:00126, 1> ('time') ('time', 'counter') -*/ - - } else if (cmd.cmd3 == 0x6e || cmd.cmd3 == 0x78) { // set basetime + if (cmd.cmd3 == 0x6e || cmd.cmd3 == 0x78) { // set basetime if (cmd.cmd4 == 1) { eprintf("set basetime\n"); base_time = old_time; diff --git a/scn2k/scn2k_text.h b/scn2k/scn2k_text.h --- a/scn2k/scn2k_text.h +++ b/scn2k/scn2k_text.h @@ -241,6 +241,8 @@ class Text : public CommandHandler { void impl_ShowBackground(Cmd& cmd); void impl_SetSkipMode(Cmd& cmd); void impl_Wait(Cmd& cmd); + void impl_GetClick(Cmd& cmd); + void impl_ReadFrame(Cmd& cmd); }; #endif diff --git a/scn2k/scn2k_textimpl.cc b/scn2k/scn2k_textimpl.cc --- a/scn2k/scn2k_textimpl.cc +++ b/scn2k/scn2k_textimpl.cc @@ -184,15 +184,48 @@ void Text::impl_SetSkipMode(Cmd& cmd) { void Text::impl_Wait(Cmd& cmd) { eprintf("wait %dmsec\n",cmd.args[0].value); + if (cmd.cmd3 == 100 && text != NULL) { /* 0x64 絖私賢緇<篏帥 */ text->StartText(text_stream); text->wid->Flush(); } - if (cmd.cmd3 == 111 || cmd.cmd3 == 121) - wait_time = base_time + cmd.args[0].value; //FIXME: second argument, counter + + if (cmd.cmd3 == 111 || cmd.cmd3 == 112 || cmd.cmd3 == 121) + wait_time = base_time + cmd.args[0].value; //FIXME: second argument, counter. See ReadFrame for this else wait_time = old_time + cmd.args[0].value; - status = WAIT; + + if (cmd.cmd3 == 101 || cmd.cmd3 == 112) + status = WAIT_CLICK; + else + status = WAIT; + cmd.cmd_type = CMD_WAITFRAMEUPDATE; // 糸祉祉(skip鴻祉) } + +void Text::impl_GetClick(Cmd& cmd) { + eprintf("wait and get mouse pos at click\n"); + wait_time = old_time + 1000 * 1000; + status = WAIT_CLICK_MOUSEPOS; + wait_savedvar[0] = cmd.args[0]; + wait_savedvar[1] = cmd.args[1]; + cmd.clear(); +} + +void Text::impl_ReadFrame(Cmd& cmd) { + eprintf("get timer value[%d]\n",cmd.args[0].value); + if (timer_var.find(cmd.args[0].value) == timer_var.end()) + cmd.SetSysvar(0); + else { + TimerAtom& atom = timer_var[cmd.args[0].value]; + if (atom.total_time <= 0) atom.total_time = 1; + int cur_tm = old_time - atom.start_time; + if (cur_tm < 0) cur_tm = atom.total_time; // 若腟 + if (cur_tm > atom.total_time) cur_tm = atom.total_time; + // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit. + int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time); + cmd.SetSysvar(v); + } +} +