Post by Carl on Mar 13, 2013 18:40:29 GMT
By Julian Skidmore on
groups.google.com/forum/#!topic/fignition/cU7XLlPe0ZQ
hex 0FF80 var udgs
8080 , 8080 , 80FF ,
0FF01 , 101 , 101 , 1FF ,
0FF88 , A288 , A288 ,
A2FF , 0FF91 , 2591 ,
2591 , 25FF , 0FF99 ,
0B3E6 , 0CC99 , 0B3FF ,
0FF99 , 03367 , 0CD99 ,
033FF , 0FF80 , FF80 ,
0FF80 , FFFF , FF01 ,
FF01 , 0FF01 , 0FFFF ,
decimal
udgs vram 608 + 64 cmove
0 var playstate
1 const loselife
2 const newround
3 const quitgame
22 const maxBall
0 var sc 0 var hisc
0 var lives 0 var speed
0 var level
2 const brickwidth
0 var bricks
27 const wallCh
0 var batx 23 const baty
0 var dx 0 var dy
0 var x 0 var y
sysvars 11 + const joy
: .Bricks 44 bricks !
4 0 do
1 level @ 4 + i + at
i 2 * 257 + 23 1 do
dup emit dup 1+ emit
brickwidth +loop
drop loop ;
: emits 0 do dup emit
loop drop ;
: .Walls 0 1 at
wallCh 24 emits
24 1 do
0 i at wallCh emit
23 i at wallCh emit
loop ;
: bat ( -- joy) joy
ic@ batx @ over 1 and
over 1 > and if
dup 3 + baty at space
1 - then
over 4 and over
19 < and if
dup baty at space
1+ then
dup baty at 19 4 emits
batx ! ;
: bounce ( addr -- )
dup @ minus swap ! ;
( ox oy nx ny)
: hitSides?
>r
dup maxBall 1 - > if
dup maxBall - -
dx bounce
else
dup 2 < if
dup 1 - -
dx bounce
then
then
r>
dup 3 < if dup 2 - -
dy bounce
then ;
( x y -- video address )
: vpos
25 * + vram + ;
: score 1 >> 5 swap -
sc @ + dup sc !
0 0 at ." SC:" . ;
( ox oy nx ny)
: hitBrick?
2dup vpos ic@ ( .. c )
dup 0 > over 9 < and
if score over 1- 1 or
over at space space
bricks @ 1- dup 0= if
newround playstate !
then bricks !
dy bounce
else drop then ;
: hitBat? ( ox oy nx ny)
over batx @ - 4 u< over
baty 1- = and if over
batx @ - 2 - dup 0< +
1+ dx ! dy bounce
then ;
: hitFloor? ( o:xy n:xy)
dup baty > if 1-
loselife playstate !
then ;
: ball x @ y @ over dx @
+ over dy @ +
hitSides? hitFloor?
hitBrick? hitBat?
over x ! dup y !
>r >r at space
r> r> at 28 emit ;
: pause
clock i@ +
begin
dup clock i@ - 0<
until drop ;
: showhi 9 0 at
." Hi:" hisc @ . ;
: play ( newround?-- )
18 0 at ." L:" level @
. ." I:" lives @ 1 .r
if 1 level +! -1 speed
+! cls .Bricks .Walls
then 10 score
showhi 5 x ! 12 y ! -1
dx ! 1 dy ! 10 batx !
begin bat drop ball
speed @ pause
playstate @ until ;
: endplay
playstate @
dup loselife = if
-1 lives +!
1 baty at 23 spaces
then newround = ;
: init
speed ! 0 level !
3 lives ! 0 sc ! ;
: brikky
init 1
begin play endplay
0 playstate !
lives @ 0< until drop
sc @ hisc @ max hisc !
showhi ;
Brikky is fairly conventionally written, though there's no instructions :-( Press SW1 to go left and SW3 to go right. The main brikky command expects a speed, so you run it with, e.g.
8 brikky
groups.google.com/forum/#!topic/fignition/cU7XLlPe0ZQ
hex 0FF80 var udgs
8080 , 8080 , 80FF ,
0FF01 , 101 , 101 , 1FF ,
0FF88 , A288 , A288 ,
A2FF , 0FF91 , 2591 ,
2591 , 25FF , 0FF99 ,
0B3E6 , 0CC99 , 0B3FF ,
0FF99 , 03367 , 0CD99 ,
033FF , 0FF80 , FF80 ,
0FF80 , FFFF , FF01 ,
FF01 , 0FF01 , 0FFFF ,
decimal
udgs vram 608 + 64 cmove
0 var playstate
1 const loselife
2 const newround
3 const quitgame
22 const maxBall
0 var sc 0 var hisc
0 var lives 0 var speed
0 var level
2 const brickwidth
0 var bricks
27 const wallCh
0 var batx 23 const baty
0 var dx 0 var dy
0 var x 0 var y
sysvars 11 + const joy
: .Bricks 44 bricks !
4 0 do
1 level @ 4 + i + at
i 2 * 257 + 23 1 do
dup emit dup 1+ emit
brickwidth +loop
drop loop ;
: emits 0 do dup emit
loop drop ;
: .Walls 0 1 at
wallCh 24 emits
24 1 do
0 i at wallCh emit
23 i at wallCh emit
loop ;
: bat ( -- joy) joy
ic@ batx @ over 1 and
over 1 > and if
dup 3 + baty at space
1 - then
over 4 and over
19 < and if
dup baty at space
1+ then
dup baty at 19 4 emits
batx ! ;
: bounce ( addr -- )
dup @ minus swap ! ;
( ox oy nx ny)
: hitSides?
>r
dup maxBall 1 - > if
dup maxBall - -
dx bounce
else
dup 2 < if
dup 1 - -
dx bounce
then
then
r>
dup 3 < if dup 2 - -
dy bounce
then ;
( x y -- video address )
: vpos
25 * + vram + ;
: score 1 >> 5 swap -
sc @ + dup sc !
0 0 at ." SC:" . ;
( ox oy nx ny)
: hitBrick?
2dup vpos ic@ ( .. c )
dup 0 > over 9 < and
if score over 1- 1 or
over at space space
bricks @ 1- dup 0= if
newround playstate !
then bricks !
dy bounce
else drop then ;
: hitBat? ( ox oy nx ny)
over batx @ - 4 u< over
baty 1- = and if over
batx @ - 2 - dup 0< +
1+ dx ! dy bounce
then ;
: hitFloor? ( o:xy n:xy)
dup baty > if 1-
loselife playstate !
then ;
: ball x @ y @ over dx @
+ over dy @ +
hitSides? hitFloor?
hitBrick? hitBat?
over x ! dup y !
>r >r at space
r> r> at 28 emit ;
: pause
clock i@ +
begin
dup clock i@ - 0<
until drop ;
: showhi 9 0 at
." Hi:" hisc @ . ;
: play ( newround?-- )
18 0 at ." L:" level @
. ." I:" lives @ 1 .r
if 1 level +! -1 speed
+! cls .Bricks .Walls
then 10 score
showhi 5 x ! 12 y ! -1
dx ! 1 dy ! 10 batx !
begin bat drop ball
speed @ pause
playstate @ until ;
: endplay
playstate @
dup loselife = if
-1 lives +!
1 baty at 23 spaces
then newround = ;
: init
speed ! 0 level !
3 lives ! 0 sc ! ;
: brikky
init 1
begin play endplay
0 playstate !
lives @ 0< until drop
sc @ hisc @ max hisc !
showhi ;
Brikky is fairly conventionally written, though there's no instructions :-( Press SW1 to go left and SW3 to go right. The main brikky command expects a speed, so you run it with, e.g.
8 brikky