;Box painter
:INIT
break on
cls
$tlr =10
$tlc =10
$brw =20
$brc =20
$quit = q
$x=10
$y=10
$string = "+"
$grid = "2,2,39,79 "
$quit = "q"
$minX = val(substr("$grid",1,instr("$grid",",")-1))
$grid = substr("$grid",len("$minx")+2,len("$grid"))
$miny = val(substr("$grid",1,instr("$grid",",")-1))
$grid = substr("$grid",len("$minx")+2,len("$grid"))
$MaxX = val(substr("$grid",1,instr("$grid",",")-1))
$maxy = val(substr("$grid",len("$maxX")+2,len("$grid")))
:MAIN
GOSUB "DISPLAY_INIT"
GOSUB "MARK"
GOSUB "DRAW_BOX"
EXIT
ISPLAY_INIT
?"PLease input your box type from the selction below"
?" 1. SINGLE"
?" 2. DOUBLE"
?" 3. FULL"
?" 4. GRID"
?
get $boxtype
Select
Case $boxtype ="1"
$boxtype = "single"
Case $boxtype ="2"
$boxtype = "double"
Case $boxtype ="3"
$boxtype = "full"
Case $boxtype = "4"
$boxtype = "grid"
ENDSELECT
?"move your starting point around to display screen location"
?"using the number pad, and press 'p' to mark the top left of your box"
? " 7 8 9"
? " 4 6"
? " 1 2 3"
? " Press 'c' and then a function key F1 - F7 to change the colour of the box"
?"press any key but Q to start. press Q to quit"
RETURN
:MARK
get $move
cls
box($minx,$miny,$maxX,$maxY,"+-+|+-+| ")
gosub "check_area"
gosub "display"
while $move <> $quit
get $move
Select
Case $move ="p"
RETURN
Case $move ="4"
gosub "wipe"
$y = $y - 1
gosub "check_area"
gosub "display"
Case $move ="6"
gosub "wipe"
$y = $y + 1
gosub "check_area"
gosub "display"
case $move ="8"
gosub "wipe"
$x = $x -1
gosub "check_area"
gosub "display"
Case $move ="2"
gosub "wipe"
$x = $x + 1
gosub "check_area"
gosub "display"
Case $move ="7"
gosub "wipe"
$x = $x -1
$y = $y - 1
gosub "check_area"
gosub "display"
Case $move ="9"
gosub "wipe"
$x = $x -1
$y = $y + 1
gosub "check_area"
gosub "display"
Case $move ="3"
gosub "wipe"
$y = $y + 1
$x = $x + 1
gosub "check_area"
gosub "display"
Case $move ="1"
gosub "wipe"
$y = $y - 1
$x = $x + 1
gosub "check_area"
gosub "display"
endselect
loop
RETURN
RAW_BOX
;CLS
AT($x,$y)
$string
$brw = $x
$brc = $y
while $move <> $quit
get $move
Select
case $move ="c"
gosub "colour_ch"
case $move ="4"
gosub "box_wipe"
$brc = $brc - 1
gosub "box_check"
gosub "box_paint"
Case $move ="6"
gosub "box_wipe"
$brc = $brc + 1
gosub "box_check"
gosub "box_paint"
case $move ="8"
gosub "box_wipe"
$brw = $brw -1
gosub "box_check"
gosub "box_paint"
Case $move ="2"
gosub "box_wipe"
$brw = $brw + 1
gosub "box_check"
gosub "box_paint"
Case $move ="7"
gosub "box_wipe"
$brw = $brw -1
$brc = $brc - 1
gosub "box_check"
gosub "box_paint"
Case $move ="9"
gosub "box_wipe"
$brw = $brw -1
$brc = $brc + 1
gosub "box_check"
gosub "box_paint"
Case $move ="3"
gosub "box_wipe"
$brc = $brc + 1
$brw = $brw + 1
gosub "box_check"
gosub "box_paint"
Case $move ="1"
gosub "box_wipe"
$brc = $brc - 1
$brw = $brw + 1
gosub "box_check"
gosub "box_paint"
endselect
loop
RETURN
:check_area
if $x = $minX
play "1d 400f"
$x = $x+1
endif
if $y = $miny
play "1d 400f"
$y = $y+1
endif
if $x = $maxX
play "1d 400f"
$x = $x-1
endif
if $y = $maxY - (len("$string")-1)
play "1d 400f"
$y = $y-1
endif
return
:wipe
$count = 0
while $count <> len("$string")
at($x,$y + $count) " "
$count = $count + 1
loop
at (1,1) " "
RETURN
:check_area
if $x = $minX
play "1d 400f"
$x = $x+1
endif
if $y = $miny
play "1d 400f"
$y = $y+1
endif
if $x = $maxX
play "1d 400f"
$x = $x-1
endif
if $y = $maxY - (len("$string")-1)
play "1d 400f"
$y = $y-1
endif
return
:display
at ($x,$y)
$string
at (1,1)
"$x"+","+"$y"
RETURN
:colour_ch
get $color
Select
Case @error = 59
color b+/n
gosub "box_paint"
Case @error = 60
color g+/n
gosub "box_paint"
Case @error = 61
color c+/n
gosub "box_paint"
Case @error = 62
color r+/n
gosub "box_paint"
Case @error = 63
color m+/n
gosub "box_paint"
Case @error = 64
color y+/n
gosub "box_paint"
case @error = 65
color w+/n
gosub "box_paint"
endselect
Return
:box_wipe
BOX($x,$y,$brw,$brc," ")
RETURN
:box_check
if $brw = $maxX
play "1d 400f"
$brw = $brw-1
endif
if $brc = $maxY
play "1d 400f"
$brc = $brc-1
endif
return
:box_paint
BOX($x,$y,$brw,$brc,$boxtype)
AT (1,1)
"$brw" + "," + "$brc"
RETURN
:colour_ch
get $color
Select
Case @error = 59
color b+/n
gosub "box_paint"
Case @error = 60
color g+/n
gosub "box_paint"
Case @error = 61
color c+/n
gosub "box_paint"
Case @error = 62
color r+/n
gosub "box_paint"
Case @error = 63
color m+/n
gosub "box_paint"
Case @error = 64
color y+/n
gosub "box_paint"
case @error = 65
color w+/n
gosub "box_paint"
endselect
Return