Files
nand2tetris/projects/11/Square/SquareGame.vm
2021-04-21 17:01:42 +03:00

191 lines
2.3 KiB
Plaintext

function SquareGame.new 0
push constant 2
call Memory.alloc 1
pop pointer 0
push constant 0
push constant 0
push constant 30
call Square.new 3
pop this 0
push constant 0
pop this 1
push pointer 0
return
function SquareGame.dispose 0
push argument 0
pop pointer 0
push this 0
call Square.dispose 1
pop temp 0
push pointer 0
call Memory.deAlloc 1
pop temp 0
push constant 0
return
function SquareGame.moveSquare 0
push argument 0
pop pointer 0
push this 1
push constant 1
eq
not
if-goto IF10
push this 0
call Square.moveUp 1
pop temp 0
goto IF11
label IF10
label IF11
push this 1
push constant 2
eq
not
if-goto IF20
push this 0
call Square.moveDown 1
pop temp 0
goto IF21
label IF20
label IF21
push this 1
push constant 3
eq
not
if-goto IF30
push this 0
call Square.moveLeft 1
pop temp 0
goto IF31
label IF30
label IF31
push this 1
push constant 4
eq
not
if-goto IF40
push this 0
call Square.moveRight 1
pop temp 0
goto IF41
label IF40
label IF41
push constant 5
call Sys.wait 1
pop temp 0
push constant 0
return
function SquareGame.run 2
push argument 0
pop pointer 0
push constant 0
pop local 1
label WHILE50
push local 1
not
not
if-goto WHILE51
label WHILE60
push local 0
push constant 0
eq
not
if-goto WHILE61
call Keyboard.keyPressed 0
pop local 0
push pointer 0
call SquareGame.moveSquare 1
pop temp 0
goto WHILE60
label WHILE61
push local 0
push constant 81
eq
not
if-goto IF70
push constant 0
not
pop local 1
goto IF71
label IF70
label IF71
push local 0
push constant 90
eq
not
if-goto IF80
push this 0
call Square.decSize 1
pop temp 0
goto IF81
label IF80
label IF81
push local 0
push constant 88
eq
not
if-goto IF90
push this 0
call Square.incSize 1
pop temp 0
goto IF91
label IF90
label IF91
push local 0
push constant 131
eq
not
if-goto IF100
push constant 1
pop this 1
goto IF101
label IF100
label IF101
push local 0
push constant 133
eq
not
if-goto IF110
push constant 2
pop this 1
goto IF111
label IF110
label IF111
push local 0
push constant 130
eq
not
if-goto IF120
push constant 3
pop this 1
goto IF121
label IF120
label IF121
push local 0
push constant 132
eq
not
if-goto IF130
push constant 4
pop this 1
goto IF131
label IF130
label IF131
label WHILE140
push local 0
push constant 0
eq
not
not
if-goto WHILE141
call Keyboard.keyPressed 0
pop local 0
push pointer 0
call SquareGame.moveSquare 1
pop temp 0
goto WHILE140
label WHILE141
goto WHILE50
label WHILE51
push constant 0
return