Post by Carl on Mar 13, 2013 18:44:28 GMT
L+R control the speed and space will quit at any time.
You get some interesing effects when it is at its fastest, I am sure you can get faint colour, maybe its just me!
this will contain flashing images, be advised.
The bonus parts can be added and run on top of the first parts or you can load the whole lot in, run this part with 50 bonus.
You get some interesing effects when it is at its fastest, I am sure you can get faint colour, maybe its just me!
this will contain flashing images, be advised.
The bonus parts can be added and run on top of the first parts or you can load the whole lot in, run this part with 50 bonus.
here is the listing with anotation
: cdata <builds does> ; create the udgs for a lit and unlit bulb
2 base ! tells FIG that the next code is binary
cdata udgs
10100101 c,
01011010 c,
00111100 c,
01111110 c,
01111110 c,
01111110 c,
01111110 c,
00011000 c, ( on)
10100101 c,
01011010 c,
00011000 c,
00100100 c,
01000010 c,
01000010 c,
00100100 c,
00011000 c, ( off)
decimal tells fig that next data is base 10
udgs vram 600 + 3 8 * cmove push the above udgs into vram memory.
: xy@ 25 * + vram + ; xy fetches chars to display on y x coordinates.
: top 0 do i 0 xy@ 1 swap ic! loop ; this will draw a row of udgs ( the bulb) on the top row, on demand
0 var on sets on at zero
0 var off sets off at zero
2000 var ss sets ss ( the speed) to 2000
: wait 0 do loop ; wait is defined at an indefinite loop
: alty draws with xy@ lit bulbs every other sprite on the top row from 0
0 0 xy@ 0 swap ic!
2 0 xy@ 0 swap ic!
4 0 xy@ 0 swap ic!
6 0 xy@ 0 swap ic!
8 0 xy@ 0 swap ic!
10 0 xy@ 0 swap ic!
12 0 xy@ 0 swap ic!
14 0 xy@ 0 swap ic!
16 0 xy@ 0 swap ic!
18 0 xy@ 0 swap ic!
20 0 xy@ 0 swap ic!
22 0 xy@ 0 swap ic!
24 0 xy@ 0 swap ic! ;
: altx draws with xy@ lit bulbs every other sprite on the top row from 1
1 0 xy@ 0 swap ic!
3 0 xy@ 0 swap ic!
5 0 xy@ 0 swap ic!
7 0 xy@ 0 swap ic!
9 0 xy@ 0 swap ic!
11 0 xy@ 0 swap ic!
13 0 xy@ 0 swap ic!
15 0 xy@ 0 swap ic!
17 0 xy@ 0 swap ic!
19 0 xy@ 0 swap ic!
21 0 xy@ 0 swap ic!
23 0 xy@ 0 swap ic!
25 0 xy@ 32 swap ic! ;
: dokeys inkey dokeys asks the fig to look for.........
dup 9 = if ss @ 200 - ss ! then 'left' call up ss ( 2000) then take 200 from it.
dup 8 = if ss @ 200 + ss ! then 'right' calls up ss value and adds 200 to it
32 = if quit then ; 'space' quits
: how at p ." Lights demo, use L/R to alter the speed, space quits " the word how will print this text on demand at the variable 'p'
: altgo 25 top altx ss @ wait 25 top alty ss @ wait ; altgo will do top 25 times then overwrite with altx call up the speen value and loop that with wait then display alty call up the speed and wait again.
: dash 0 do i altgo drop loop ; dash will loop altgo but leave the last value from the stack ( the programme runs better when this top values is dropped)
: run cls p 0 do i dokeys 2000 dash drop loop ; run clears the screen runs p ( prints the instructions!) scans the keyboard for left, right or space runs the dash loop 2000 times kicks out the last value on the stack then loops to dokey again 2000 times.
======== bonus pack ============
: xox xox displays lit-unlit-lit bulb at on's location
0 vram on @ ic! litbulb here
1 vram on @ 1+ + ic! unlit here ( the last location plus one)
0 vram on @ 2+ + ic! lit here ( the first location plus 2)
1 vram on @ 1- + ic! ; unlit here ( the first location minus 1 ( ensures overwrite of the lit sprite when animated)
: x 0 vram on @ + ic! ; x is a lit bulb to be displayed at on
: o 1 vram on @ + ic! ; o it an unlit bulb to be displayed at on
: xoxo xoxo displays lit-unlit-lit-unlit
0 vram on @ ic! see xox
1 vram on @ 1+ + ic!
0 vram on @ 2+ + ic!
1 vram on @ 3 + + ic! ;
: allon 0 do i 25 xy@ 0 swap ic! loop ; allon word will display a row of lit sprites
: disbulb 1 vram off @ + ic! 0 vram on @ + ic! on @ off ! ; disbulb puts lit bulb in place of an unlit bulb and a unlit bulb in the place of the last lit bulb
: lightscroll 0 do 1 dissbulb on @ 1 + on ! ss @ wait drop loop ; lightscroll loops the above pauses with the value of wait then loop around
: backwards 0 do i on @ 1 - on ! disbulb drop loop ; Backwards reverses disbulb
: wipe 0 do i on @ 1 + on ! x ss @ wait drop loop ; wipe executes the x word and loops the set ammonut later in the prog.
: clean 0 do i on @ 1 - on ! o ss @ wait drop loop ; clean displays unlit bulbs from the value of on and loops ( this only works with wipe first)
: onefwd 0 do i disbulb on @ 1 + on ! ss @ wait drop loop ; onefwd displays a lit sprite using disbulb
: onebkwd 0 do i on @ 1 - on ! disbulb ss @ wait drop loop ; reverse of the above
: twofwd 0 do i on @ 1 + on ! xox ss @ wait drop loop ; two fwd uses the xox as onefwd
: twobck 0 do i on @ 1 - on ! xoxo ss @ wait drop loop ; twoback uses xoxo as twobck but extra sprite is used to clean up
: demtwo cls how 25 top 0 do i 25 lightscroll 25 backwards dokey 22 twofwd 22 twobck 24 wipe 24 clean loop ; initiates the loops n times ( 25 in this case) (22 for blocks of spries xox and oxox) for one pass
: bonus 0 do i 1 demtwo drop loop ; bonus runs the demtwo word n times