2VM-6912

ScratchIt

Table of Contents

Rendering Commands

cls [c]

Clear Screen

ups

Update Screen - refresh display

⚠️ IMPORTANT: NO arguments! ONLY this command can update the screen display!
cls 0
rsp 10 10 1       ~~ renders to buffer ~~
rtxt 20 20 F "HI" ~~ renders to buffer ~~
ups               ~~ NOW it shows on screen! ~~

rp x y c

Render Pixel - draw a pixel

rtxt x y c txt

Render Text - display text

rsp x y id

Render Sprite - draw a sprite

rcl x y w h c

Render Rectangle - draw a rectangle

Coordinate System

Reference Point: TOP-LEFT CORNER (0,0)

Applies to EVERYTHING:

X grows RIGHT → (0 to 95)
Y grows DOWN ↓ (0 to 71)
rsp 0 0 1      ~~ sprite at top-left corner ~~
rsp 88 64 2    ~~ sprite at bottom-right (96-8=88, 72-8=64) ~~
rtxt 0 0 F "HI"  ~~ text at top-left corner ~~

System - Clock & Execution

cks v

Clock Speed - clock rate

Examples:

Higher value → faster!
Lower value → slower!

lpt v

Lines Per Tick - lines per clock tick

Use high lpt for initialization, low for game loop!

slp v

Sleep - wait/pause

⚠️ IMPORTANT: Waiting (even small values like 0.05) interrupts multi-line execution!

Variables

stv var v

Set Variable - set a variable

Examples:

stv score 0              ~~ create/set score to 0 ~~
stv px 40                ~~ create/set px to 40 ~~
stv name "2Axis Studio"  ~~ create/set name to "2Axis Studio" ~~
stv alive true           ~~ create/set alive to true ~~
stv hp fv:hp - 10        ~~ set hp to hp-10 ~~
stv is_low fv:hp < 20    ~~ set is_low to comparison result (true/false) ~~

fv:name

Fetch Variable - get variable value

Math Operations

Available operators in arguments:

Examples:

stv hp fv:hp - 10
stv score fv:score + 100
stv x fv:x * 2
stv speed fv:speed / 2
stv background_x fv:background_x % 96

Comparisons (return true/false)

Available operators:

Direct use in jumps:

jlif fv:score = 100 50
jlif fv:hp < 20 30
jlif fv:level > 10 40

Use in variables (boolean):

stv is_low_hp fv:hp < 20
stv has_won fv:score = 100
jlif fv:is_low_hp 50

Jumps - Conditional Branching

jlif bool line

Jump Line If - jump to line if TRUE

Examples:

jlif fv:hp < 20 50       ~~ if hp < 20, jump to line 50 ~~
jlif fv:score = 100 30   ~~ if score == 100, jump to line 30 ~~
jlif true 10             ~~ always jumps to line 10 ~~

jlifn bool line

Jump Line If Not - jump to line if NOT TRUE

Examples:

jlifn ci:up 10           ~~ if up arrow NOT pressed, jump to 10 ~~
jlifn fv:alive 99        ~~ if alive == false, jump to 99 ~~

jmp line

Jump - unconditional jump

⚠️ IMPORTANT JUMP RULE:
The DESTINATION of a jump (where it lands) MUST be an empty line!
stv hp 10
jlif fv:hp < 20 4
stv color 7         ~~ line 3 - continues normally ~~
                    ~~ line 4 - EMPTY (jump target) ~~
stv color 4         ~~ line 5 - executes ~~

Labels - Code Organization

lbl n

Label - marks the start of a label

rtn n

Return - ends a label

jif bool lbl

Jump If to label - jumps to label if condition TRUE

⚠️ LABEL AND STACK RULES:

❌ FORBIDDEN:
✅ ALLOWED:

Example CORRECT (loop inside label):

lbl game
  cls 0                ~~ line 2 ~~
  stv hp fv:hp - 1
  ups
  slp 0.05
  jlif true 2          ~~ loop inside label(remember that it needs to end) ~~

rtn game

Example with TEMPORARY exit:

lbl game
  cls 0                    ~~ line 2 ~~
  stv hp fv:hp - 1
  jlif fv:hp < 0 10        ~~ ✅ exits temporarily ~~
                           ~~ line 5 ~~
  ups
  slp 0.05
  jlif true 2              ~~ loop ~~

rtn game                   ~~ line 9 - end label ~~
                           ~~ line 10 - empty ~~
cls 4                      ~~ line 11 - outside label ~~
rtxt 20 28 7 "GAME OVER!"
ups
slp 2
jlif true 2                ~~ ✅ returns to label and ends it ~~
LABELS = code organization, NOT loops!
LOOPS = jumps to line numbers inside label!

Sound

psw wave freq vol ms

Play Sound Wave - play a sound wave

Examples:

psw sine 440 100 200     ~~ sine wave, 440Hz (A4), volume 100, 200ms ~~
psw square 880 50 500    ~~ square wave, 880Hz, volume 50, 500ms ~~
psw triangle 220 75 1000 ~~ triangle wave, 220Hz, volume 75, 1 second ~~
psw noise 110 80 400     ~~ noise, 110Hz, volume 80, 400ms ~~

Input - Keyboard

ci:name

Check Input - check if key is pressed

Example:

jlifn ci:up 10    ~~ if up NOT pressed, jump ~~

Technical Specifications

Screen

Colors (16 colors - hex 0-F)

Sprites

Font

🎉 End of Documentation 🎉

Happy coding with 2VM-6912!

Copyright © 2026 2Axis Studio. All rights reserved.