1000 ;
1010 ; LINE AUTOMATA GENERATOR
1020 ; USING ACE C INTERFACE
1030 ; SETAUTO(RULE,PATT,RADIUS,MIDFLG)
1040 ; RULE,PATT=STRING POINTERS
1050 ; RADIUS,MIDFLG=INTEGER
1060 ; SETS UP AUTOMATA
1070 ; RUNAUTO() - GENERATES 1 SCREEN
1080 ;
1090 ; LAST MODIFIED 2-11-92
1100 ;
1110  *= $7000
1120 ;
1130  JMP SETAUTO
1140  JMP RUNAUTO
1150 ;
1160 RULEPTR = $F0  ;MUST PERSIST
1170 PATTPTR = $F2  ;BETWEEN CALLS
1180 TEMP    = $D8
1190 LINECNT = $D9
1200 PNTR1   = $DA
1210 PNTR2   = $DC
1220 BYADR   = $E0
1230 OLDBY   = $E2
1240 NEWBY   = $E3
1250 PXCOL   = $E6
1260 PXNUM   = $E7
1270 SAVMSC  = $58
1280 ;
1290 ARR1    = $7800
1300 ARR1S   = $7830
1310 ARR2    = $7900
1320 ARR2S   = $7930
1330 ;
1340 RADIUS  .BYTE 0
1350 MIDFLG  .BYTE 0
1360 BASE    .BYTE 0,0
1370 ;
1380 ; GET PARAMETERS...
1390 ;
1400 SETAUTO LDY #0
1410  LDA ($C6),Y
1420  STA RULEPTR
1430  INY
1440  LDA ($C6),Y
1450  STA RULEPTR+1
1460  INY
1470  LDA ($C6),Y
1480  STA PATTPTR
1490  INY
1500  LDA ($C6),Y
1510  STA PATTPTR+1
1520  INY
1530  LDA ($C6),Y
1540  STA RADIUS
1550  INY
1560  INY
1570  LDA ($C6),Y
1580  STA MIDFLG
1590 ;
1600 ; GET START OF BITMAP
1610 ;
1620  LDA SAVMSC
1630  STA BASE
1640  LDA SAVMSC+1
1650  STA BASE+1
1660 ;
1670 ; INITIALIZE STARTING PATTERN
1680 ;
1690 INITPAT LDA #0
1700  TAY
1710 INIT010 STA ARR1,Y
1720  STA ARR2,Y
1730  INY
1740  BNE INIT010
1750 INIT020 LDA (PATTPTR),Y
1760  STA ARR1S,Y
1770  INY
1780  CPY #160
1790  BNE INIT020
1800  RTS  ;BACK TO C
1810 ;
1820 ; GENERATE AUTOMATON...
1830 ;
1840 RUNAUTO LDA #0
1850  STA LINECNT
1860 ;
1870 ; LOOP 192 TIMES
1880 ;
1890 LOOP    LDX #0
1900 GEN010  LDA ARR1S,X
1910  STA ARR2S,X
1920  LDY LINECNT
1930  JSR PLOT
1940  INX
1950  CPX #160
1960  BNE GEN010
1970  LDX #48
1980 GEN030  TXA
1990  SEC
2000  SBC RADIUS
2010  TAY
2020  TXA
2030  CLC
2040  ADC RADIUS
2050  ADC #1
2060  STA TEMP
2070  LDA #0
2080 GEN040  CLC
2090  ADC ARR2,Y
2100  INY
2110  CPY TEMP
2120  BNE GEN040
2130  LDY #0
2140  CPY MIDFLG
2150  BEQ GEN050
2160  SEC
2170  SBC ARR2,X
2180 GEN050  TAY
2190  LDA (RULEPTR),Y
2200  STA ARR1,X
2210  INX
2220  CPX #208
2230  BNE GEN030
2240 ;
2242  LDA 764
2243  CMP #$1C
2244  BEQ GEN090  ; GET OUT IF [ESC]
2250  INC LINECNT
2260  LDA LINECNT
2270  CMP #192
2280  BNE LOOP
2290 GEN090 RTS ; BACK TO C
2300 ;
2310 ; PLOT PIXEL X,Y COLOR A
2320 ; PRESERVE X REGISTER
2330 ;
2340 PLOT    STA PXCOL
2350  TXA
2360  PHA ; SAVE X REG
2370  AND #3
2380  STA PXNUM
2390  TYA
2400  STA BYADR
2410  STA PNTR2
2420  LDA #0
2430  STA BYADR+1
2440  STA PNTR2+1
2450  LDY #5
2460 PLOT1   ASL BYADR
2470  ROL BYADR+1
2480  DEY
2490  BNE PLOT1
2500  LDY #3
2510 PLOT2   ASL PNTR2
2520  ROL PNTR2+1
2530  DEY
2540  BNE PLOT2
2550  CLC
2560  LDA BYADR
2570  ADC PNTR2
2580  STA BYADR
2590  LDA BYADR+1
2600  ADC PNTR2+1
2610  STA BYADR+1
2620  CLC
2630  LDA BYADR
2640  ADC BASE
2650  STA BYADR
2660  LDA BYADR+1
2670  ADC BASE+1
2680  STA BYADR+1
2690  TXA
2700  LSR A
2710  LSR A
2720  CLC
2730  ADC BYADR
2740  STA BYADR
2750  LDA #0
2760  ADC BYADR+1
2770  STA BYADR+1
2780  LDY #0
2790  LDA (BYADR),Y
2800  STA OLDBY
2810  LDY PXNUM
2820  LDA BITMASK,Y
2830  TAX
2840  AND OLDBY
2850  STA OLDBY
2860  TXA
2870  EOR #255
2880  STA NEWBY
2890  LDY PXCOL
2900  LDA COLMASK,Y
2910  AND NEWBY
2920  ORA OLDBY
2930  LDY #0
2940  STA (BYADR),Y
2950  PLA
2960  TAX
2970  RTS
2980 ;
2990 ; TABLES
3000 ;
3010 BITMASK .BYTE 63
3020  .BYTE 207
3030  .BYTE 243
3040  .BYTE 252
3050 COLMASK .BYTE 0
3060  .BYTE 85
3070  .BYTE 170
3080  .BYTE 255
3090 ;
3100 ; THE END
3110 ;