Files
nand2tetris/Arkanoid/Rect.vm

174 lines
2.3 KiB
Plaintext

function Rect.new 0
push constant 5
call Memory.alloc 1
pop pointer 0
push argument 0
pop this 0
push argument 1
pop this 1
push argument 2
pop this 2
push argument 3
pop this 3
push constant 0
pop this 4
push pointer 0
return
function Rect.setPos 0
push argument 0
pop pointer 0
push pointer 0
call Rect.erase 1
pop temp 0
push argument 1
pop this 0
push argument 2
pop this 1
push constant 0
return
function Rect.draw 0
push argument 0
pop pointer 0
push this 4
push constant 1
eq
if-goto IF_TRUE0
goto IF_FALSE0
label IF_TRUE0
push pointer 0
call Rect.erase 1
pop temp 0
push constant 0
return
label IF_FALSE0
push constant 0
not
call Screen.setColor 1
pop temp 0
push this 0
push this 1
push this 0
push this 2
add
push this 1
push this 3
add
call Screen.drawRectangle 4
pop temp 0
push constant 0
return
function Rect.erase 0
push argument 0
pop pointer 0
push constant 0
call Screen.setColor 1
pop temp 0
push this 0
push this 1
push this 0
push this 2
add
push this 1
push this 3
add
call Screen.drawRectangle 4
pop temp 0
push constant 0
return
function Rect.moveLeft 0
push argument 0
pop pointer 0
push pointer 0
call Rect.erase 1
pop temp 0
push this 0
push argument 1
sub
pop this 0
push pointer 0
call Rect.draw 1
pop temp 0
push constant 0
return
function Rect.moveRight 0
push argument 0
pop pointer 0
push pointer 0
call Rect.erase 1
pop temp 0
push this 0
push argument 1
add
pop this 0
push pointer 0
call Rect.draw 1
pop temp 0
push constant 0
return
function Rect.moveUp 0
push argument 0
pop pointer 0
push pointer 0
call Rect.erase 1
pop temp 0
push this 1
push argument 1
sub
pop this 1
push pointer 0
call Rect.draw 1
pop temp 0
push constant 0
return
function Rect.moveDown 0
push argument 0
pop pointer 0
push pointer 0
call Rect.erase 1
pop temp 0
push this 1
push argument 1
add
pop this 1
push pointer 0
call Rect.draw 1
pop temp 0
push constant 0
return
function Rect.getLeft 0
push argument 0
pop pointer 0
push this 0
return
function Rect.getRight 0
push argument 0
pop pointer 0
push this 0
push this 2
add
return
function Rect.getTop 0
push argument 0
pop pointer 0
push this 1
return
function Rect.getBottom 0
push argument 0
pop pointer 0
push this 1
push this 3
add
return
function Rect.getHidden 0
push argument 0
pop pointer 0
push this 4
return
function Rect.setHidden 0
push argument 0
pop pointer 0
push argument 1
pop this 4
push constant 0
return