On Jan 3, 2:34 am, jc <
john.com...@gmail.com> wrote:
> Howerd, I've made some progress, getting your Conway's Life program
> working on clusterFix, except that the 'g' key doesn't actually get
> the game automatically playing; repeatedly hitting 'g' or space is
> necessary. The only thing I had to change was to make all the variable
> references yellow. Apparently arrayforth (or colorforth 2?) is much
> pickier about that than cf2005.
>
> The only other change I know for sure you need to make to get cf2010
> working with the clusterfix kernel is to redefine block to:
>
> : block [ offset ] @ +
> : blks $100 * ;
>
> (the fallthrough is of course necessary).
>
> Here is the Life that is almost working:
>
> {block 960}
> ( app conway's game of life) empt 962 load
> : cell 32 /mod adj adj over over at 16 u+ 16 + box ;
> : nocell drop ;
> : draw dup old @ 1 and jump nocell cell
> : cells [ 1023 ] for i draw -next ;
> : gen [ 1023 ] for i tick swap new ! -next [ 1023 ] for i new @ i
> old ! -next ;
> : loc [ row ] @ 32 * [ col ] @ + ;
> : cur loc dup old @ $ff * $ff0000 + color cell ;
> : back black screen $303010 color 40 40 at 583 dup box ;
> : g show back green cells gen keyboard ;
> : s gen show back blue cells cur keyboard ;
> : clear 1500 8 erase 16 [ row ] ! 16 [ col ] ! s ;
> : t loc old dup @ 1 or ( xor) swap ! ;
> : l $7ffffff [ col ] +! [ col ] @ 31 and [ col ] ! ;
> : u $7ffffff [ row ] +! [ row ] @ 31 and [ row ] ! ;
> : d 1 [ row ] +! [ row ] @ 31 and [ row ] ! ;
> : r 1 [ col ] +! [ col ] @ 31 and [ col ] ! ;
> : h pad nul nul accept nul nul nul nul nul l u d r nul nul nul nul
> glide glid2 glid3 glid4 clear s g t nul nul nul nul [ $2500 , 0 ,
> $110160c , 0 , $1c1b1a19 , $20d0815 , 0 , clear glide g h ]
>
> {block 961}
>
> : s ( stop)
> : g ( go)
> : t ( toggle the square)
> : ludr ( left up down right)
> : . ( press s to stop then draw a shape using ludr and t to toggle)
> : . ( then press g to go or s to single step)
> : 1234 ( create gliders which move to the four corners counting
> clockwise from the top left)
>
> {block 962}
> ( conway's game of life) var row [0x10] var col [0x10]
> : old [ 1500 block ] + ;
> : new [ 1504 block ] + ;
> : nul ;
> : pos swap 32 /mod swap ;
> : val 32 * + swap over old @ 1 and + ;
> : up pos swap 31 + 31 and val ;
> : dn pos swap 1 + 31 and val ;
> : lt pos 31 + 31 and swap val ;
> : rt pos 1 + 31 and swap val ;
> : n [ 0 ] ;
> : s dup old @ 1 and ;
> : y [ 1 ] ;
> : tick dup 0 up lt dn dn rt rt up up nip jump n n s y n n n n n
> : adj swap 17 * 40 + ;
> : st ( rc-) [ col ] @ + swap [ row ] @ + 32 * + old 1 swap ! ;
> : glide 0 2 st 0 1 st 0 0 st 1 0 st 2 1 st ;
> : glid2 0 0 st 0 1 st 0 2 st 1 2 st 2 1 st ;
> : glid3 0 2 st 1 2 st 2 2 st 2 1 st 1 0 st ;
> : glid4 0 0 st 1 0 st 2 0 st 2 1 st 1 2 st ;
Hi JC,
Hope this finds you well!
I've had some luck with this. Things to note about my changes:
At the bottom of the main block "h" before "g", that is, call the
keyboard before displaying.
Changing "g" into a loop that can be interrupted by "key?" and the
need for "pause" before using "key?".
The "s" display word becomes the "ok" word, if you will permit, and
therefore suppressing the "cur" cursor and changing the color of the
moving blocks happens there with a new variable "colr" and the jump
word "colour".
I've also moved "cell" and "nocell" to the next block to make room for
my new words, this meant moving "adj" above "cell". I've removed
"null" already in the system.
{block 960}
( app conway's game of life) empt 962 load var colr 0 / NEW VARIABLE
: draw dup old @ 1 and jump nocell cell
: cells [ 1023 ] for i draw -next ;
: gen [ 1023 ] for i tick swap new ! -next [ 1023 ] for i new @ i
old ! -next ;
: loc [ row ] @ 32 * [ col ] @ + ;
: cur loc dup old @ $ff * $ff0000 + color cell ;
: back black screen $303010 color 40 40 at 583 dup box ;
: colour [ colr ] @ jump green blue / NEW WORD and g and s CHANGED!
: g 0 [ colr ] ! gen pause key? g ;
: s 1 [ colr ] ! gen show back colour cells [ colr ] @ 0 or drop if
cur then keyboard ;
: clear 1500 8 erase 16 [ row ] ! 16 [ col ] ! s ;
: t loc old dup @ 1 or ( xor) swap ! ;
: l $7ffffff [ col ] +! [ col ] @ 31 and [ col ] ! ;
: u $7ffffff [ row ] +! [ row ] @ 31 and [ row ] ! ;
: d 1 [ row ] +! [ row ] @ 31 and [ row ] ! ;
: r 1 [ col ] +! [ col ] @ 31 and [ col ] ! ;
: h pad nul nul accept nul nul nul nul nul l u d r nul nul nul nul
glide glid2 glid3 glid4 clear s g t nul nul nul nul [ $2500 , 0 ,
$110160c , 0 , $1c1b1a19 , $20d0815 , 0 , clear glide h g ]
\ h AND g SWAPPED
{block 961}
: s ( stop)
: g ( go)
: t ( toggle the square)
: ludr ( left up down right)
: . ( press s to stop then draw a shape using ludr and t to toggle)
: . ( then press g to go or s to single step)
: 1234 ( create gliders which move to the four corners counting
clockwise from the top left)
{block 962}
( conway's game of life) var row [0x10] var col [0x10]
: adj swap 17 * 40 + ; / adj MOVED ABOVE cell
: cell 32 /mod adj adj over over at 16 u+ 16 + box ;
: nocell drop ; / cell and nocell MOVED HERE FOR ROOM ON PREV BLOCK
: old [ 1500 block ] + ;
: new [ 1504 block ] + ;
: pos swap 32 /mod swap ;
: val 32 * + swap over old @ 1 and + ;
: up pos swap 31 + 31 and val ;
: dn pos swap 1 + 31 and val ;
: lt pos 31 + 31 and swap val ;
: rt pos 1 + 31 and swap val ;
: n [ 0 ] ;
: s dup old @ 1 and ;
: y [ 1 ] ;
: tick dup 0 up lt dn dn rt rt up up nip jump n n s y n n n n n
: st ( rc-) [ col ] @ + swap [ row ] @ + 32 * + old 1 swap ! ;
: glide 0 2 st 0 1 st 0 0 st 1 0 st 2 1 st ;
: glid2 0 0 st 0 1 st 0 2 st 1 2 st 2 1 st ;
: glid3 0 2 st 1 2 st 2 2 st 2 1 st 1 0 st ;
: glid4 0 0 st 1 0 st 2 0 st 2 1 st 1 2 st ;
/ NO OTHER CHANGES
I hope this works for you.
I recall that in the past some versions of colorforth had a show word
that somehow did the display update loop for you. What I mean is that
'show' would allow one to create a word that would update the changes
in the display with out need of a specific display loop. I assume that
is how the versions that Howerd is using work. I recall trying LIFE
and it word just as you have it coded in Howerd's collection.
At any rate, this is no longer the case. "show" is a 'one-shot' word,
and while it will show the frame buffer to the screen, words like
"gen" above need to be looped to update the buffer.
In order to keep the custom keyboard on the screen the display loop
pauses and uses "key?" to pop out of the loop. I had to do something
similar to TETRIS earlier this week to get the custom keyboard to not
switch back to the editor/interpret keyboard. ( let me know if you
would like a copy of TETRIS)
"clear" calls "s" ( there are 2 "s" words in this program and in this
case I mean the second-display word) ... calls "s" and this is enough
to start the display and the keyboard, so no need for "g" to do so.
Again I hope this works for you as well as it does for me.
Thank you for inspiring me to include "LIFE" in my personal collection
and giving me an opportunity to hack it into action. :-)
Ray