Assignment
In class we wrote some programs to draw sprites on the screen. Here is some sample code to draw arrows, rocks and characters:
( hello-sprites.tal )
( devices )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|20 @Screen &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
( macros )
%GET-WIDTH { .Screen/width DEI2 }
%GET-HEIGHT { .Screen/height DEI2 }
%GO-X { .Screen/x DEO2 }
%GO-Y { .Screen/y DEO2 }
( main program )
|0100
( set system colors )
#2ce9 .System/r DEO2
#01c0 .System/g DEO2
#2ce5 .System/b DEO2
( set x,y coordinates to 0,0 )
#0000 GO-X
#0000 GO-Y
( set sprite address )
;arrow .Screen/addr DEO2
( draw 1bpp sprite in the background )
( pointing up and left )
( using color1 for the outline )
#21 .Screen/sprite DEO
( draw it again in the top right corner )
GET-WIDTH #0008 SUB2 GO-X
( pointing up and right )
#31 .Screen/sprite DEO
( TODO draw arrow pointing at other two corners )
( draw character in middle of screen )
GET-WIDTH #0002 DIV2 GO-X
GET-HEIGHT #0002 DIV2 GO-Y
;character .Screen/addr DEO2
#01 .Screen/sprite DEO
( TODO: draw rocks in center of each edge )
BRK
@arrow [ 0102 0488 d0e0 f0f8 ]
@rock [ 3c4e 9ffd f962 3c00 ]
@character [ 3c7e 5a7f 1b3c 5a18 ]
- Draw arrows pointing at the bottom left and bottom right corners of the screen.
- Draw rocks in the middle of the top, right, bottom and left edges of the screen.