8-Bit Software Online Conversion

Life - Listing

10REM HexLife - Machine Code version 20REM by M.Bobrowski for 8-BS 30: 40PROCassemble 50CALL&900:END 60: 70DEF PROCassemble 80oswrch=&FFEE:osword=&FFF1 90osbyte=&FFF4 100left=&70:right=&72:down=&74:up=&76 110x=&78:y=&7A:colour=&7C:nextcol=&7D 120count=&7E:gen=&7F:px=&80:py=&82 130pix=&84:col=&85:bx=&86:by=&88 140: 150FOR pass=0 TO 2 STEP 2 160P%=&900 170[OPT pass 180.init 190LDA #0:STA &06:LDA #&30:STA &07 200LDY #0 210.initloop 220LDA initdata,Y 230JSR oswrch 240INY:CPY #30:BNE initloop 250: 260½set variables for design 270LDA #624 MOD 256:STA px 280LDA #624 DIV 256:STA px+1 290LDX #3 300.outer 310TXA:PHA 320LDA #496 MOD 256:STA py 330LDA #496 DIV 256:STA py+1 340LDY #3 350.inner 360LDA #3:STA col:JSR plot 370CLC:LDA py:ADC #16:STA py 380LDA py+1:ADC #0:STA py+1 390DEY:BNE inner 400CLC:LDA px:ADC #16:STA px 410LDA px+1:ADC #0:STA px+1 420PLA:TAX 430DEX:BNE outer 440½end of initial design 450: 460½set initial values for main loop 470LDA #576 MOD 256:STA left:STA up 480LDA #576 DIV 256:STA left+1:STA up+ 1 490LDA #704 MOD 256:STA right 500LDA #704 DIV 256:STA right+1 510LDA #448 MOD 256:STA down 520LDA #448 DIV 256:STA down+1 530LDA #0:STA gen:STA colour 540: 550.main 560INC gen:LDA gen:CMP #15:BEQ exit 570JSR pgen 580INC colour:LDA colour:CMP #3:BNE no tblack 590LDA #0:STA colour 600.notblack 610LDA colour:STA nextcol:INC nextcol 620JSR subroutine 630SEC:LDA left:SBC #32:STA left 640LDA left+1:SBC #0:STA left+1 650CLC:LDA right:ADC #32:STA right 660LDA right+1:ADC #0:STA right+1 670CLC:LDA up:ADC #32:STA up 680LDA up+1:ADC #0:STA up+1 690SEC:LDA down:SBC #32:STA down 700LDA down+1:SBC #0:STA down+1 710JMP main 720: 730.exit 740LDX #6 750.exitloop 760LDA exitdata,X:JSR oswrch 770DEX:BPL exitloop 780RTS 790: 800.subroutine 810LDA left:STA x:LDA left+1:STA x+1 820.xloop 830LDA down:STA y:LDA down+1:STA y+1 840.yloop 850LDA &FF:ROL A:BCC notesc 860LDA #&7E:JSR osbyte 870BRK:EQUB 17:EQUS "Escape":BRK 880.notesc 890LDA #0:STA count 900½x-32 910SEC:LDA x:SBC #32:STA px 920LDA x+1:SBC #0:STA px+1 930½y-16 940SEC:LDA y:SBC #16:STA py 950LDA y+1:SBC #0:STA py+1 960JSR readpixel:JSR examine 970½y+16 980CLC:LDA y:ADC #16:STA py 990LDA y+1:ADC #0:STA py+1 1000JSR readpixel:JSR examine 1010½x+32 1020CLC:LDA x:ADC #32:STA px 1030LDA x+1:ADC #0:STA px+1 1040½y-16 1050SEC:LDA y:SBC #16:STA py 1060LDA y+1:SBC #0:STA py+1 1070JSR readpixel:JSR examine 1080½y+16 1090CLC:LDA y:ADC #16:STA py 1100LDA y+1:ADC #0:STA py+1 1110JSR readpixel:JSR examine 1120½x 1130LDA x:STA px:LDA x+1:STA px+1 1140½y-32 1150SEC:LDA y:SBC #32:STA py 1160LDA y+1:SBC #0:STA py+1 1170JSR readpixel:JSR examine 1180½y+32 1190CLC:LDA y:ADC #32:STA py 1200LDA y+1:ADC #0:STA py+1 1210JSR readpixel:JSR examine 1220½end of inner loops 1230: 1240½point(x,y) 1250LDA y:STA py:LDA y+1:STA py+1 1260JSR readpixel 1270CMP nextcol:BEQ black 1280LDA count:CMP #1:BEQ notblack2 1290CMP #3:BEQ notblack2 1300CMP #5:BEQ notblack2 1310JMP notplot 1320.notblack2 1330LDA pix:CMP #0:BNE notplot 1340LDA nextcol:CMP #4:BEQ black 1350STA col:JMP coord 1360.black 1370LDA #0:STA col 1380.coord 1390LDA x:STA px:LDA x+1:STA px+1 1400LDA y:STA py:LDA y+1:STA py+1 1410JSR plot 1420.notplot 1430½check yloop condition 1440CLC:LDA y:ADC #16:STA y 1450LDA y+1:ADC #0:STA y+1 1460CMP up+1:BNE notyend 1470LDA y:CMP up:BEQ yloopend 1480.notyend:JMP yloop 1490.yloopend 1500CLC:LDA x:ADC #16:STA x 1510LDA x+1:ADC #0:STA x+1 1520LDA x:CMP right:BNE notequal:CLC 1530.notequal 1540LDA x+1:SBC right+1:BCS xloopend 1550JMP xloop 1560.xloopend 1570RTS 1580: 1590.readpixel 1600LDX #px:LDY #0 1610LDA #9:JSR osword 1620LDA pix 1630RTS 1640: 1650.examine 1660CMP #0:BEQ endk 1670CMP nextcol:BEQ endk 1680INC count 1690.endk 1700RTS 1710: 1720.plot 1730LDA #18:JSR oswrch:LDA #0:JSR oswrc h:LDA col:JSR oswrch 1740LDA #25:JSR oswrch:LDA #4:JSR oswrc h 1750SEC:LDA px:SBC #4:STA bx 1760LDA px+1:SBC #0:STA bx+1 1770LDA bx:JSR oswrch:LDA bx+1:JSR oswr ch 1780SEC:LDA py:SBC #4:STA by 1790LDA py+1:SBC #0:STA by+1 1800LDA by:JSR oswrch:LDA by+1:JSR oswr ch 1810LDX #0 1820.plotloop 1830LDA plotdata,X:JSR oswrch 1840INX:CPX #18:BNE plotloop 1850RTS 1860: 1870.pgen 1880PHA:LDA #31:JSR oswrch:LDA #0:JSR o swrch 1890LDA #31:JSR oswrch:PLA:CMP #10:BCC digit 1900LDA #49:JSR oswrch:SEC:LDA gen:SBC #10 1910.digit 1920CLC:ADC #48:JMP oswrch 1930: 1940.initdata 1950EQUB 22:EQUB 1 1960EQUW 23:EQUW 8202:EQUW 0:EQUD 0 1970EQUB 19:EQUB 1:EQUW 3:EQUW 0 1980EQUB 19:EQUB 2:EQUW 5:EQUW 0 1990EQUB 19:EQUB 3:EQUW 6:EQUW 0 2000.plotdata 2010EQUB 25:EQUB 0:EQUW 8:EQUW 0 2020EQUB 25:EQUB 81:EQUW -8:EQUW 8 2030EQUB 25:EQUB 81:EQUW 8:EQUW 0 2040.exitdata 2050EQUB 7:EQUB 30:EQUB 32:EQUB 32 2060EQUB 31:EQUB 0:EQUB 31 2070: 2080] 2090NEXT:ENDPROC