Tdata ___ Issue# 4
Total Page:16
File Type:pdf, Size:1020Kb
tdata ___ _ Issue# 4 finished, stop the program arrl jump to tle life program, 0100 Either load (J), 01, 00 at cxm or use option 00 of Super Monitor to execute at CXEO. This will display the initial arrl then generations. The calculates about 33 generations each By minute en t:re 30x48 grid. Ray 1\tLly The program requires a minimum of lK bytes of This program is based on the "Life" game memory, arrl an 1861 graphics chip. 1le devised by Chirles <bnway, ard described in t:re arrl subroutines are oo pages 00 arrl 01, arrl the <kto!:x;>r, 1970 isStE of "Scientific American" (p. two generatioos in storage at any given time are 120). The game is initialized by placifl\ into a on pages 02 an:i 03. grid a pattern of "cells" (i.e., bits on the video display). The cclls then live, reproduce, arrl die to these three "genetic laws": fuw The Program Y.brks 1. Survivals - every cell with 2 or 3 neighbors survives to tre rext generation: 2. Deaths - an Each bit in memory has eight nearest isolated cell, or rne overcrowded with 4 or more reighbors, ruml:x;>red as follows: neighbors, will not survive to the next gereration: 3. Births - an empty grid location with exactly 3 reighbors will contain a cell in the rext generation. Frcxn a tome canputerist's point of view, the object of the game is to devise patterns that will evolve into as spectacular a series of succeeding gererations as possible. fuw to Run t:re Program where t:re shaded block is the hit beifl\ tested. Consider rext a coltnn of three bytes in memory, pointed to by R(S), R(6), and R(7): First, tre pattern (first generation) must be drawn on the display. Jump to the "Pattern Initialization Program" at 006G. Eitrer load 30, 60, at (XXX) arrl press arrl release "R" arrl ''G'' or use Q.Jest Super Monitor to execute at 0000. Page 02 will be erased arrl displayed. It is divided into six columns of bytes (see diagram \Uler 'ibw the" Program Works"). First, tte lEe keY}Bl enter tre column in which you want to regin by typing the data on tre rex keY}Bl ani arrl releasirg 'T' where M(R(6)) contains the particular bit urrler (01--ai). Next, enter the data for the drawirl!,. test. 'There are three generalized positions for 'The data will be entered into the display this bit: left errl of byte (L), middle of byte vertically. Each column is 30 bytes deep; wren (M), or right errl of byte (R). 'The routine for you reach tle bottom, Q turn:; on. You can tren the rumber of of a given bit enter another column rumber arrl continue the is thus divided into three sectiorn, deperrling drawing, if desired. When the is oo whetrer the bit is in L, M, or R. C£RII1C CllJB llB:VU: ClUS CIB1R: ClUS Cl13r.IAC ClUS liHIAC Cl.US Page 2 "Subroutire to Set Next Generation" at 002C J (DC instruction), whose job it is to set the The starting diagram (first generation) is bits for th2 lEtt generaticn, deperrling en the made Cl1 page 02. The top and oottom lines of state of the bits in the first. The bits in tre arrl tre page, tre far left ani right column of OOKt generatien are pointed to by M(R(9)). 'fu.!y bytes, are kept blank (for ease are set by placing M(R(9)) into the accumulator R(5), R(6), and R(7) are initialized to the after havirg set DF to 0 or 1, shifting DF into upper left corner: tre byte, and oock into M(R(9)). J 01 02 03 04 05 06 For each byte, the procedure is to test the leftmost bit (0136-{)156), the middle six bits (by passing through the loop 0157-0184 six times), and the rightmost bit (0185-01A2). The current generaticn pointers (R(5)-R(7)) ani rext generation p:>inter (R(9)) are then incremented J appropriately, arrl a test is made to see if the process is finished (0 1A4-Q 1B A.). If so, then with the solid bit at '1.:' in M(R(6)) the tre rexr generation is dispJayed arrl made into first ore unier test. the current genPrc,tion, and vice versa. The neighbors are counted by placing the 0185 appropriate bytes into the Data Register, • 0100 Count right the i.OOividual en or off bits into DF, bit's arrl incrementing R(B).O for each ore that is on neighbors (by calling the subroutine at 0050 with a DE 0\32 instruction). After tre neighbors, the 01A2 state of the bit under test in M(R(6)) is Se't nexT gtMUM"at I Oft determined (by shiftirg into DF). If it is on, J then Q is turred en. A branch is then m00e to bit. 01,&.3 01J6 __..... _ __, 0060 lncreaent Count lett display bit's pointers 11elghbors 0092 01 --...1.---., Set next g-ere't I ot1 bit Erase m 01, Count 111ld bit's Mlghbors 0177 Set next s-eretlon bit Set reglsttM"s to upper lett bit In-terchange OOBE 02 & 03 pointers P.O. Box 4430, Santa Clara, CA 95054 QUESTDATA COSMAC CLUB Page 3 REGISTER INITIALIZATION STATUS QUO (I() CHANGES TO NEXT GENl Atm COOE COMMENT CODE CCH4ENT 0000 co 004C 31 48 If Q•1, go 0001 00 60 Lo!ld 0060 11t set next first then 0100 generation (see text) bit to 1 0003 F8 01 BD A5 004E 30 3B E I se, set to 0 0007 F8 19 AD OOOA F8 02 50 85 86 67 SUBROUT I NE TO COUNT NE I GHBffiS 0010 FS 11 A7 0013 FS 00 AS BE BC 0050 03 Return 0018 F8 09 A6 A9 005 1 38 50 If OF • O, 001C F8 31 AC return o0 1f r8 03 B9 0053 18 30 50 EI se Increment 0022 F8 51 AE count, return 0025 co 01 36 Return to ma in program STANDARD VIDEO ROUTINE ro DISPLAY I PAGE OF MEMCRY REGISTER ASSIGNMENTS AOOR COOE COfo'MENT RC5>-Polnts to ne ighbors #1-3 of current generation. 0060 90 Bl 82 83 84 RC6>-Polnts to bit under test, 11nd neighbors 14 and 5. 0065 F8 91 A3 fH1>-Polnts to neighbors 16-8 of current gener!ltlon. 0068 F8 8F A2 RC9l-Polnts to next generetlon. 006B F8 71 AI RCBl.O-Hotds count of neighbors. 006E 03 72 70 RCC>-Polnts to subroutine to set next generation. 0071 22 78 22 52 RCDl-Polnts to location In video routine which 0075 C4 C4 C4 contains page of memory be ing displayed. This 0078 F8 02 BO page Is lnltillllzed l!lt 02 for the first gen- 0078 F8 00 AO eration. 007E 80 E2 RCEl-Points to subroutine to count neighbors of bit. 0080 E2 20 AO 0083 E2 20 AO SUBROUTINE TO SET NEXT GENERATION 0086 E2 20 AO 0089 3C 7E AOOR CODE COI+lENT 0086 30 6F 0080 00 00 00 00 002C 7A F8 00 AB Turn 0 oft, 0091 E2 61 reset neighbor count to 00 ERASE PAGES 02 AND 03 0030 0.3 Return to ml!l in program AOOO CODE CO""'ENT 00.31 8B FB 02 32 4C it neighbors=02 go to Status 0093 E5 X = 5 Quo 0094 F8 03 85 0036 86 FF 02 33 43 If count> I, go 0097 F8 FF A5 R(5) points to test if =3 area to be erased SET NEXT GENERATION 8 IT TO 0 009A F8 00 73 Enter 00, wor k your way down 95 Continue erasing ADDR CODE COI+lENT 0090 FB 01 unti I you hit 00.38 F8 00 F6 Set OF to 0 page 01 003E 09 7E 59 30 2C Sh Ift OF into OOAO 3A 9A MCR(9)), return ENTER DATA INTO DESIRED COLUMN TEST FCR MORE THAN 3 NEIGI-EORS ADffi COOE CCH4ENT ADDR CODE CCH4ENT OOA2 F8 02 B5 R(5) points to coiiJnn "0" 004.3 8B 70 03 Test for count = >03 0209 0046 3B 3B It so, set next OOA5 F8 08 A5 genera-tion To 0 00A8 E6 X = 6 OOA9 FB 00 86 OOAC FB FF A6 M(R(6)) s-tores SET GENERATION BIT TO 1 input dat-a from keys COfo'MENT OOAF 7B 0 on to prompt- AODR CODE entry of des ired coiiJnn I 0048 F8 FF Set OF to 1 004A 30 30 Go shifT OF into M(R(9)) QUESTDATA COSMAC CLUB P.O. Box 4430, Santa Clara, CA 95054 Page 4 J AOOR CODE AOCR CODE COI+1ENT 0000 3F BO Enter col ,..nl, 0128 30 Of Push l 0120 00 00 00 00 Stack area 0002 6C 64 26 7A Store and display 0131 E2 61 Turn on TV col,..n I, turn 0133 co 00 03 Go i n i t i a I i ze 0 off reg !sters 0006 8S F4 AS Add column I to J RCSJ.O ROUTINE FOR LEFTMOST BIT 00139 37 89 Release I 0008 E5 Reset X to 5 AOOR CODE COI+IENT OOBC 3F BC Enter data tor pattern, push I 0136 05 FE DE Shift neighbor OOOE 6C 64 Write data Into 12 into DF, display area, count it on R(X)+l 0139 FE DE Shift neighbor J OOCO 85 fC 07 AS R(XJ +7 to point #3 into OF, to next byte down count it on c a l umn 0138 07 A: DE FE DE IIIith OOC4 F6 F6 F6 FB IF You're at bottom neighbors 17 if RI Xl.O>=FB an d 8 (IF i t shifted) 0140 25 05 F6 DE 15 Repeat with OOC9 37 C9 Re lease I neighbor #1, OOCB 3A ElC Not yet at restore R<Sl bottom? 0145 26 06 F6 DE 16 Repeat with OOCD 30 A2 l f yes, go neighbor 14, se I ect another restore R(6) column 014A 27 07 F6 DE 17 Repeat with Super Monitor Entry Point tor Data Entry neighbor 16, DODO F8 60 Make RO point restore R(7J 0002 AO to program.