[comp.sources.atari.st] v02i084: colorca -- Cellular automata in color

koreth@panarthea.ebay.sun.com (Steven Grimm) (10/02/89)

Submitted-by: clong@topaz.rutgers.edu (Chris Long)
Posting-number: Volume 2, Issue 84
Archive-name: colorca

Here's a little CA (cellular automaton) program written by me and
a friend many moons ago.  I've included one version for color low-res,
and another for color high-res (better known as low- and med-res,
respectively).  I've also included my desktop.inf, which seems to set
the colors rather nicely for the med-res version.  Have fun!  If you
liked this program, let me know.

BTW, let it run.  Just when you think it's reached a steady-state,
it'll do something completely unexpected.

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
#	Run the following text with /bin/sh to create:
#	  COLORCAH.S
#	  COLORCAL.S
#
sed 's/^X//' << 'SHAR_EOF' > COLORCAH.S &&
X* A color one-dimensional cellular automata program by Chris Long and
X* John Balsley.  Program is old (this was the second program we wrote
X* for the ST; the first was ye typical "hello" program), and can probably
X* be speeded up and improved with a miniscule amount of thought and
X* effort.  Designed to be used in high-res; particularly nice against
X* a black background.
X
Xintin   equ     8
Xptsin   equ     12
X
Xinit    equ     $a000
Xsetpix  equ     $a001
Xgetpix  equ     $a002
X
X	dc.w	init
X	move.l	intin(a0),a3
X	move.l	ptsin(a0),a4
X
X	lea.l	frame1,a5
X	move.b	#1,(a5)
X	move.b	#1,201(a5)
X	clr	cycles
X
Xnxtscr	lea.l	frame1,a5
X	lea.l	frame2,a6
X	adda.l	#1,a6
X
X	move	cycles,(a4)
X	move	#0,2(a4)
X	clr	d5
X
Xnxtcll1	move.b	(a5)+,d5
X	add.b	1(a5),d5
X
X	cmpi	#15,d5
X	blt	alive1
X
X	move.b	#0,(a6)+
X	move	#0,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll1
X	jmp	out1
X
Xalive1	move.b	d5,(a6)+
X	move	d5,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll1
X
Xout1	addq	#1,cycles
X	lea.l	frame2,a5
X	lea.l	frame1,a6
X	adda.l	#1,a6
X
X	move	cycles,(a4)
X	move	#0,2(a4)
X	clr	d5
X
Xnxtcll2	move.b	(a5)+,d5
X	add.b	1(a5),d5
X
X	cmpi	#15,d5
X	blt	alive2
X
X	move.b	#0,(a6)+
X	move	#0,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll2
X	jmp	out2
X
Xalive2	move.b	d5,(a6)+
X	move	d5,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll2
X
Xout2	addq	#1,cycles
X	cmpi	#640,cycles
X	bne	nxtscr
X	clr	cycles
X	jmp	nxtscr
X
Xcycles	ds.w	1
Xframe1	ds.b	202
Xframe2	ds.b	202
X
X	end
SHAR_EOF
chmod 0600 COLORCAH.S || echo "restore of COLORCAH.S fails"
sed 's/^X//' << 'SHAR_EOF' > COLORCAL.S &&
X* A color one-dimensional cellular automata program by Chris Long and
X* John Balsley.  Program is old (this was the second program we wrote
X* for the ST; the first was ye typical "hello" program), and can probably
X* be speeded up and improved with a miniscule amount of thought and
X* effort.  Designed to be used in low-res.
X
Xintin   equ     8
Xptsin   equ     12
X
Xinit    equ     $a000
Xsetpix  equ     $a001
Xgetpix  equ     $a002
X
X	dc.w	init
X	move.l	intin(a0),a3
X	move.l	ptsin(a0),a4
X
X	lea.l	frame1,a5
X	move.b	#1,(a5)
X	move.b	#1,201(a5)
X	clr	cycles
X
Xnxtscr	lea.l	frame1,a5
X	lea.l	frame2,a6
X	adda.l	#1,a6
X
X	move	cycles,(a4)
X	move	#0,2(a4)
X	clr	d5
X
Xnxtcll1	move.b	(a5)+,d5
X	add.b	1(a5),d5
X
X	cmpi	#15,d5
X	blt	alive1
X
X	move.b	#0,(a6)+
X	move	#0,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll1
X	jmp	out1
X
Xalive1	move.b	d5,(a6)+
X	move	d5,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll1
X
Xout1	addq	#1,cycles
X	lea.l	frame2,a5
X	lea.l	frame1,a6
X	adda.l	#1,a6
X
X	move	cycles,(a4)
X	move	#0,2(a4)
X	clr	d5
X
Xnxtcll2	move.b	(a5)+,d5
X	add.b	1(a5),d5
X
X	cmpi	#15,d5
X	blt	alive2
X
X	move.b	#0,(a6)+
X	move	#0,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll2
X	jmp	out2
X
Xalive2	move.b	d5,(a6)+
X	move	d5,(a3)
X	dc.w	$a001
X	addq	#1,2(a4)
X	cmpi	#200,2(a4)
X	bne	nxtcll2
X
Xout2	addq	#1,cycles
X	cmpi	#320,cycles
X	bne	nxtscr
X	clr	cycles
X	jmp	nxtscr
X
Xcycles	ds.w	1
Xframe1	ds.b	202
Xframe2	ds.b	202
X
X	end
SHAR_EOF
chmod 0600 COLORCAL.S || echo "restore of COLORCAL.S fails"
exit 0