home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_23_1988_Transactor_Publishing.d64
/
automata.src
< prev
next >
Wrap
Text File
|
2023-02-26
|
5KB
|
291 lines
; *******************
; ** **
; ** cellular **
; ** automata **
; ** **
; *******************
;
;
;
; geometric computer
; artforms
;
; for the
; commodore 64 & 128
;
; by ian adam
; vancouver bc
;
; march 1987
;
;
; the screen image is plotted 1
; line at a time. each pixel
; depends on the sum of the 3
; pixels above, using a preset
; code supplied by the user.
;
zp = $a6 ;8 bytes temporary
rows = $a6
column = $a7
bits = $a8
aval = $a9
bval = $aa
adread = $fa ;read address
adwrit = $fc ;write address
output = $fe
screen = $2000
bsout = $ffd2
;
*=$1700 ;same for both
;
codes *=*+10 ;these are the rules
; for plotting pixels (10 bytes)
;
; *************************
; ** **
; ** start plotting here **
; ** **
; *************************
;
*=$170c ;friendly address (5900)
;
; set up pointers
;
ldy #>screen ;set addresses
sty adread+1
sty adwrit+1
ldy #$01
sty adwrit ;write to $2001
dey
sty adread ;read $2000
;
ldx #$c7
stx rows ;199 rows to do
;
; setup for each row
;
startr ldx #$27 ;40 bytes per line
stx column
;
; aval is pixel above & left
; bval represents pixel above
; cval is pixel above & right
;
sty aval ;aval = 0 to start row
;
; prepare one byte at a time
;
startc lda (adread),y ;get byte above
sta bits
;
lda column
beq get1st
;note: we need the first pixel
;from the next byte to the right,
;to be cval for the 4th pixel of
;this byte. on the last screen
;block of a row, counter 'column'
;will be zero. in this case,
;a 0 will be put into variable
;cval for the last pixel in the
;row. if not the last block, then
;get a pixel from the next block:
;
ldy #8
lda (adread),y
;
get1st asl a
rol bits ;extra pixel into bits
rol a
rol bits
rol a ;and 1st pixel rolls
and #3 ;into a, then
sta bval ;...into bval
;
; pixel loop for one byte
;
ldy #4 ;4 pixels
pxloop lda #0
rol bits ;get one pixel
rol a
rol bits
rol a
pha ;this pixel is cval
;
adc bval ;form sum of 3 pixels
adc aval ;(carry is clear)
tax
;
lda bval ;shift records over
sta aval
pla ;get cval back
sta bval
;
lda codes,x ;get new colour value
asl output ;make room in byte, &
asl output
ora output ;put pixel in stream
sta output
;
dey ;move to next pixel
bne pxloop
;
; finished pixel loop for
; byte, so output the result:
;
sta (adwrit),y
;
; update addresses:
;
clc
dec column ;where on screen?
bpl oldrow
;
; here because end of row, so
;
; update pointers to start next row
;
ldx #2 ;do adwrit first
newrw1 lda adread,x
and #7
cmp #7 ;check if bottom of block
beq newlin
;
sec ;next pixel row, subtract 311
lda adread,x
sbc #$37
sta adread,x
lda adread+1,x
sbc #1
sta adread+1,x
bne newrw2
;
newlin inc adread,x ;if bottom of
bne newrw2 ;block, just add 1
inc adread+1,x
;
newrw2 dex ;now do adread
dex
beq newrw1
;
dec rows ;ready for next row
bne startr
rts
;
; here because in middle of row
;
; so move to next byte
;
oldrow ldx #2 ;start with adwrit
;
oldrw2 lda adread,x ;mid column so
adc #8 ;move over one byte
sta adread,x
bcc oldrw3
inc adread+1,x
clc
;
oldrw3 dex
dex
beq oldrw2 ;now do adread
jmp startc ;start next column
;
;
; **********************
; ** **
; ** screen dump here **
; ** **
; **********************
;
rowout = adwrit
colout = adwrit+1
;
messag .byt 27,65,8,13,10,27,75,64,1
;
; 27,65,8 sets graphics linefeed
; 13,10 is carriage return & lf
; 27,75,64,1 for 320 graphics bytes
; change these for other printers
;
;
; printer is already accessed as
; CMD file by BASIC program
;
;
* = $17ac ;6060 is a friendly start
;
; set up pointer
;
ldy #>screen ;set screen address
sty adread+1
ldy #$00
sty adread
ldy #$19
sty rowout ;25 rows to do
;
; set up for row of 320 bytes
;
oprow ldy #0
linmsg lda messag,y
jsr bsout
iny
cpy #9
bne linmsg
;
ldy #$28 ;output 40 columns
sty colout
;
block ldy #7 ;one block of 8 bytes
bytelp lda (adread),y
;
; reorient bytes 90 degrees
;
; screen bytes are horizontal
; printer bytes are vertical
;
ldx #7
rotate rol a ;one bit into each
ror zp,x ; of 8 bytes
;change ror to rol if your
;printer does graphics inverted
;
dex
bpl rotate
;
dey
bpl bytelp
;
; move pointer 8 bytes
; for next screen block
;
lda #7
tax
sec
adc adread
sta adread
bcc oploop
inc adread+1
;
; output 8 bytes
;
oploop lda zp,x
jsr bsout
dex
bpl oploop
;
; update counters
;
dec colout ;next column
bne block
;
dec rowout ;next row
bne oprow
;
rts
;
; BASIC takes care of unlistening
; and closing printer file.
;
.end