File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,8 @@ const unsigned int VirtualMachine::instruction_arg_count[] = {
8383 1 , // OP_CALL_PROCEDURE
8484 0 , // OP_ADD_ARG
8585 1 , // OP_READ_ARG
86- 0 // OP_BREAK_ATOMIC
86+ 0 , // OP_BREAK_ATOMIC
87+ 0 // OP_WARP
8788};
8889;
8990
@@ -222,13 +223,15 @@ unsigned int *VirtualMachine::run(unsigned int *pos)
222223 &&do_call_procedure,
223224 &&do_add_arg,
224225 &&do_read_arg,
225- &&do_break_atomic
226+ &&do_break_atomic,
227+ &&do_warp
226228 };
227229 unsigned int *loopStart;
228230 unsigned int *loopEnd;
229231 size_t loopCount;
230232 m_atEnd = false ;
231233 m_atomic = true ;
234+ m_warp = false ;
232235 DISPATCH ();
233236
234237do_halt:
@@ -324,13 +327,13 @@ do_loop_end : {
324327 pos = l.start ;
325328 else
326329 m_loops.pop_back ();
327- if (!m_atomic) {
330+ if (!m_atomic && !m_warp ) {
328331 m_engine->breakFrame ();
329332 return pos;
330333 }
331334 DISPATCH ();
332335 } else {
333- if (!m_atomic) {
336+ if (!m_atomic && !m_warp ) {
334337 m_engine->breakFrame ();
335338 return pos - 1 ;
336339 }
@@ -683,15 +686,18 @@ do_exec : {
683686 m_procedureArgTree.clear ();
684687 m_procedureArgs = nullptr ;
685688 m_nextProcedureArgs = nullptr ;
686- if (!m_atomic)
689+ if (!m_atomic && !m_warp )
687690 m_engine->breakFrame ();
688691 if (m_goBack) {
689692 m_goBack = false ;
690693 pos -= instruction_arg_count[OP_EXEC] + 1 ;
691694 m_freeExecRegs = ret;
692695 } else
693696 FREE_REGS (ret);
694- return pos;
697+ if (m_warp)
698+ DISPATCH ();
699+ else
700+ return pos;
695701 }
696702 FREE_REGS (ret);
697703 DISPATCH ();
@@ -723,4 +729,8 @@ do_exec : {
723729do_break_atomic:
724730 m_atomic = false ;
725731 DISPATCH ();
732+
733+ do_warp:
734+ m_warp = true ;
735+ DISPATCH ();
726736}
Original file line number Diff line number Diff line change @@ -73,7 +73,8 @@ enum Opcode
7373 OP_CALL_PROCEDURE, /* ! Calls the procedure (custom block) with the index in the argument. */
7474 OP_ADD_ARG, /* !< Adds a procedure (custom block) argument with the value from the last register. */
7575 OP_READ_ARG, /* !< Reads the procedure (custom block) argument with the index in the argument and stores the value in the last register. */
76- OP_BREAK_ATOMIC /* !< Breaks current frame at the end of the loop. */
76+ OP_BREAK_ATOMIC, /* !< Breaks current frame at the end of the loop. */
77+ OP_WARP /* ! Runs the script without screen refresh. */
7778};
7879
7980}
@@ -116,9 +117,12 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
116117 * \param[in] savePos Changes the return value of savePos().
117118 * \param[in] breakAtomic Whether to break the frame after stopping the script.
118119 * \param[in] goBack Whether to go back so that the current instruction can run again in the future.
120+ * \note Nothing will happen if the script is set to run without screen refresh.
119121 */
120122 void stop (bool savePos = true , bool breakAtomic = false , bool goBack = false )
121123 {
124+ if (m_warp)
125+ return ;
122126 m_stop = true ;
123127 m_savePos = savePos;
124128 m_atomic = !breakAtomic;
@@ -153,6 +157,7 @@ class LIBSCRATCHCPP_EXPORT VirtualMachine
153157 std::vector<Value> *m_procedureArgs = nullptr ;
154158 std::vector<Value> *m_nextProcedureArgs = nullptr ;
155159 bool m_atomic;
160+ bool m_warp;
156161 bool m_stop = false ;
157162 bool m_savePos = true ;
158163 bool m_goBack = false ;
You can’t perform that action at this time.
0 commit comments