ORG 0C900H CALL CS ; Clear the screen RETEX CALL KB ; The executive routine CPI 'C' ; branches to chase on C, JZ CH CPI 'H' ; Hic on H, JZ HI CPI 'O' ; Opps on 0, and JZ OP CPI 'L' ; Life on L. JZ LI JMP RETEX CH CALL CS ; Chase...Clear the screen. CALL INIT ; Place the bug LDA FO+1 ; at a random location MOV M,A ; on the screen. XCHG CALL INIT ; Place the turtle LDA FO ; at a random location MOV M,A ; on the screen. C1 CALL DL ; Wait a while. CALL KB ; Get input. MVI M,20H ; Put a space where you are, CALL MV ; then move. LDA FO+1 ; If the bug is there, CMP M ; you've got him. JZ HALT LDA FO ; Place turtle at new screen MOV M,A ; location. XCHG CALL RND ; The bug moves at random MVI M,20H ; Put a space where it was, CALL MV ; then move. LDA FO ; If turtle is there, CMP M ; the bugs been had. JZ HALT LDA FO+1 ; Place bug at new screen MOV M,A ; location. XCHG JMP C1 ; Do it all again HI CALL CS ; HIC...Clear the screen LXI H,0CE20H; Place the turtle at the H1 MVI M,7 ; center of the screen. CALL KB ; Should I return to the executive? CALL DL ; Wait awhile CALL RND ; Move the turtle at random MVI M,2AH CALL MV ; leaving asterisk behind JMP H1 ; Do it again. OP CALL CS ; Opps Clear the screen MVI B,0 ; Place turtle at the center LXI H,0CE20H; of the screen. O1 MOV A,M ; If you have been CPI 2AH ; here before, JZ HALT ; halt. MVI M,7 ; Put the turtle on the screen CALL DL ; wait awhile. O2 CALL KB ; Get input. JZ O4 ; If none, continue MOV B,A O4 MOV A,B ANI 0FH ; If it is a '0', don't move. JZ O2 MVI M,2AH ; place asterisk in old location CALL MV ; then move. JMP O1 ; Do it again HALT MVI M,4 ; Halt--Place ligtning bolt on the screen. JMP RETEX ; Return to the executive MV ANI 0FH ; Move CPI 6 JNZ M1 ; This routine uses the MVI A,1 ; curser move routines JMP M3 ; in SOLOS (PUP, PLEFT, PDOWN, M1 CPI 1 ; and PRIT) to move the JNZ M2 ; contents of the screen MVI A,6 ; 1ocation pointed to JMP M3 ; by the address contained M2 CPI 7 ; in the H & L registers. JNZ M3 MVI A,0CH ; The right 4 bits of the M3 MOV C,A ; accumulator are used CALL SVDA ; to determine the direction, MVI A,8 ; or combination of ANA C ; directions, of the move. CNZ 0C104H MVI A,1 ; up lf dn rt ANA C CNZ 0C115H MVI A,2 ; The ASCII code for ANA C ; all of the digits except CNZ 0C0CBH ; 6, 1, and 7 allows a MVI A,4 ; compass rose that ANA C ; agrees with the 10 key CNZ 0C10BH ; numeric pad. 6, 1 and CALL 0C11CH ; 7 are changed to agree. RET SVDA MOV A,L ; This routine assumes that ANI 3FH ; the contents of the H,L register STA 0C808H ; pair is a screen address. DAD H ; It then stores the 1ine DAD H ; number in the data storage MOV A,H ; location used by SOLOS ANI 0FH ; called LINE. Simiarly the ANI 0FH ; character position is stored STA 0C809H ; in NCHAR for use by RET ; PUP, PLEFT, PDOWN, and PRIT DL PUSH H ; Delay...Save address. LHLD 0C80AH ; Get data byte from SET INR L ; command: SPEED XRA A D1 DCX H ; Use it for a counter. CMP H JNZ D1 POP H ; Restore address RET KB CALL 0C02EH ; Get input from keyboard. RZ ; If none return. CPI 0DH ; If it is a CR restore the RNZ ; stack and return to the POP B ; executive JMP RETEX LI LXI D,0 ; Life L1 MOV L,E MOV A,D ; D,E points to 1K of RAM ANI 3 ; used as a scratch pad. ORI 0CCH ; H,L points to the screen MOV H,A ; location. PUSH D ; Save the pointer MVI C,0 ; initialize the counter DCX H CALL CT LXI D,0FFC0H; Count the neighbors DAD D ; of this location of CALL CT ; the screen in the INX H ; following order: CALL CT ; (5,4,7,8,9,6,3,2,1 on keypad) INX H CALL CT LXI D,40H DAD D CALL CT DAD D CALL CT DCX H CALL CT DCX H CALL CT INX H LXI D,0FFC0H DAD D POP D ; Restore RAM pointer. CALL RG ; Determine next generation INX D ; for this location and put MOV A,D ; it in the RAM. ANI 4 ; Do this to every screen JZ L1 ; location. CPY LXI H,0CC00H; Copy the next generation LXI D,0 ; as stored in the 1K of CO LDAX D ; scratch pad RAM MOV M,A ; to the screen. INX H INX D MOV A,H CPI 0D0H JNZ CO CALL DL ; Wait awhile. CALL KB ; Should I return to the exec.? JMP LI ; If not do another generation. RG MOV A,C ; Follow the rules of LIFE CPI 2 ; to determine the next JZ R3 ; generation for this JNC R1 ; location. R2 MVI A,20H STAX D RET R1 CPI 3 JNZ R2 MVI A,'*' STAX D RET R3 MOV A,M STAX D RET CT MOV A,M ; Counter CPI '*' RNZ ; If the neighbor is INR C RET ; an asterisk count it. INIT CALL RND ; Initialize. ANI 3FH ORI 0CCH ; determine a random MOV H,A ; screen location, CALL RND ; place the line MOV L,A ; number in the data RET ; storage of SOLOS STA 0C808H ; called LINE and CALL RND ; the position of the ANI 0FH ; character in NCHAR. STA 0C809H CALL SVDA RET RND PUSH H ; Random number generator LXI H,SH+3 ; from Peoples Computer MVI B,8 ; Company, MOV A,M ; For it to work propertly RTOP RLC ; the 4 data storage locations RLC ; should not be zero. RLC XRA M RAL RAL DCR L DCR L DCR L MOV A,M RAL MOV M,A INR L MOV A,M RAL MOV M,A INR L MOV A,M RAL MOV M,A INR L MOV A,M RAL MOV M,A DCR B JNZ RTOP POP H RET CS CALL 0C0D5H ; In SOLOS, the routine PERSE MVI A,20H ; erases the screen but leaves STA 0CC00H ; a cursor in the corner. RET ; Erase that too and return. FO DB 7 ; The turtle font. DB 0EH ; The bug font. SH DS 4 ; Storage for RND.