Skip to content

Latest commit

 

History

History
59 lines (50 loc) · 2.32 KB

017_using_wait.md

File metadata and controls

59 lines (50 loc) · 2.32 KB

Example 017 - Using WAIT

Prints hello world with a delay between each character.

Opcodes:

Pseudocode:

STR 'hello world'

LOOP:
  NUM 0 NUM 1 ROLL STROUT // push null terminator, swap it behind current char, print the char
  NUM 500 TIME WAIT // Wait 500ms

  DUPE NUM 0 EQ NOT // Check if we reached the null terminator
  IF: // IP moves left
    NOOP // move IP back to start of loop body
  ELSE: // IP moves right
    BREAK // Exit the loop. Not a real instruction in DS
    STR '\nDONE' STROUT

DominoScript:

. 0—2 1—2 0—6 1—2 0—3 1—2 1—3 1—2 1—3 1—2 1—6 1—0 4
                                                  |
6 6—6 0—0 2—0 2—1 3—1 2—1 2—2 2—1 6—1 2—1 0—3 2—1 4
|                                                  
6 . . . . . . . . . . . . . . . . . . . . . . . . .
                                                   
6 6—6 6—6 6—6 6—6 6—6 6—6 1 0—2 1—0 1—3 1—1 2—5 1—1
|                         |                        
6 . . . . . . . . . . . . 4 . . . . . . . . . . . 4
                                                  |
6 . 0—1 0 . 1—3 1 . 2—3 2—0 . . . . . . . . . . . 2
|       |       |                                  
6 . 0 . 1 . 0 . 3 . 0 . . . . . . . . . . . . . . 1
    |       |       |                             |
6 . 0 . 0 . 2 . 4 . 0 . . . . . . . . . . . . . . 1
|       |       |                                  
6 . 1 . 4 . 1 . 6 . 1 . . . . . . . . . . . . . . 4
    |       |       |                             |
6—6 0 . 5—3 0 . 0—3 0 . . . . . . 3—5 0—0 6—2 1—1 1

Notes:

I'd recommend using this way of slowing down execution for game loops as well. You can likely get away with a constant delay if the main loop isn't taking too long to execute. If it does, you'd use WAIT together with TIME to dynamically adjust the delay based on how long the loop took to execute.