;; Emacs Mode Selection Info: -*-mode: ASM; coding: iso-latin-1-dos;-*- * ;; ******************************************************************************************** ;; File Name: LookForBW ;; Auther: John L. Weinrich ;; Date: 01/31/03 ;; Useage 4004 TIC-TAC-TOE Game ;; Description: ;; ;; This routine is used for the 4004 TIC-TAC-TOE Game. ;; ;; Assumptions: ;; This assembly code and all the included files assume the following: ;; ;; RAM Memory: 2048 X 4 (8 RAM banks, 4 RAMs/bank, 4 registers/RAM, 16 Char/Reg) ;; 256 status characters. ;; 2 I/O Port ;; RAM1: SPEAKER PITCH/write ;; RAM2: SPEAKER LEVEL/write ;; ;; ROM Memory: 4096 X 8 (16 ROMs @ 256 locations ;; 11 I/O Ports (3 - R/W, 4- Read, 4 - Write) ;; ROM0: MISC/read ;; ROM0: MISC/write ;; ROM3: DISPLAY HIGH IN/read ;; ROM3: DISPLAY HIGH OUT/write ;; ROM4: DISPLAY LOW IN/read ;; ROM4: DISPLAY LOW OUT/write ;; ROM5: KEYBOARD HIGH INPUT/read ;; ROM6: KEYBOARD LOW INPUT/read ;; ROM7: MISC2/write ;; ROM8: PAGE/write ;; ROM9: RANDOM NUMBER GENERATOR/read ;; ROM10: FPGA VERSION/read ;; ;; See "4004 FPGA Design" and "4004 Software Design " documents for more detail information. ;; ;; Registers used: ;; Memory used: ;; Entrance parameters: ;; Exit parameters: ;; Labels used: ;; ******************************************************************************************** ;; Determine if 4004 is X or O ;; LookForBlock ldm RAM_BANK_0 ; Select RAM bank 0 dcl ; Send out RAM bank selection fim SRC_P,PLAYER_MARK_RAM ; Select player mark charactor src SRC_P ; Tell RAM of selection clb ; Make sure it is all clear rdm ; Get player mark charactor from RAM dac jcn NZ,CheckWinX ; Check for Block X jun CheckWinO ; O LookForWin ldm RAM_BANK_0 ; Select RAM bank 0 dcl ; Send out RAM bank selection fim SRC_P,PLAYER_MARK_RAM ; Select player mark charactor src SRC_P ; Tell RAM of selection clb ; Make sure it is all clear rdm ; Get player mark charactor from RAM dac jcn Z,CheckWinX ; Check for win X jun CheckWinO ; O ;; Check for opponent, 5,1,9 ;; If opponent, no win for this position CheckWinX jms Check5O ; Check opponent for position 5 jcn NZ,CheckX537 ; If opponent, no win 5,1,9 jms Check1O ; Check opponent for position 1 jcn NZ,CheckX537 ; If opponent, no win 5,1,9 jms Check9O ; Check opponent for position 9 jcn NZ,CheckX537 ; If opponent, no win 5,1,9 ;; There are three tests for the position 5,1,9; 5,1; 5,9; & 1,9 ;; Check for one open position, 5,1 CheckX51 jms Check5X ; Check for position 5 jcn Z,CheckX59 ; If none, not 5,1 jms Check1X ; Check for position 1 jcn Z,CheckX59 ; If none, not 5,1 fim UTILITY_1_P,POS9_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,1,9 win, mark position 9 ;; Check for one open position, 5,9 CheckX59 jms Check5X ; Check for position 5 jcn Z,CheckX19 ; If none, not 5,9 jms Check9X ; Check for position 9 jcn Z,CheckX19 ; If none, not 5,9 fim UTILITY_1_P,POS1_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,1,9 win, mark position 1 ;; Check for one open position, 1,9 CheckX19 jms Check1X ; Check for position 1 jcn Z,CheckX537 ; If none, not 1,9 jms Check9X ; Check for position 9 jcn Z,CheckX537 ; If none, not 1,9 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,1,9 win, mark position 5 ;; Check for opponent, 5,3,7 ;; If opponent, no win for this position CheckX537 jms Check5O ; Check opponent for position 5 jcn NZ,CheckX123 ; If opponent, no win 5,3,7 jms Check3O ; Check opponent for position 3 jcn NZ,CheckX123 ; If opponent, no win 5,3,7 jms Check7O ; Check opponent for position 7 jcn NZ,CheckX123 ; If opponent, no win 5,3,7 ;; There are three tests for the position 5,3,7; 5,3; 5,7; & 3,7 ;; Check for one open position, 5,3 CheckX53 jms Check5X ; Check for position 5 jcn Z,CheckX57 ; If none, not 5,3 jms Check3X ; Check for position 3 jcn Z,CheckX57 ; If none, not 5,3 fim UTILITY_1_P,POS7_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,3,7 win, mark position 7 ;; Check for one open position, 5,7 CheckX57 jms Check5X ; Check for position 5 jcn Z,CheckX37 ; If none, not 5,7 jms Check7X ; Check for position 7 jcn Z,CheckX37 ; If none, not 5,7 fim UTILITY_1_P,POS3_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,3,7 win, mark position 3 ;; Check for one open position, 3,7 CheckX37 jms Check3X ; Check for position 3 jcn Z,CheckX123 ; If none, not 3,7 jms Check7X ; Check for position 7 jcn Z,CheckX123 ; If none, not 3,7 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,3,7 win, mark position 5 ;; Check for opponent, 1,2,3 ;; If opponent, no win for this position CheckX123 jms Check1O ; Check opponent for position 1 jcn NZ,CheckX456 ; If opponent, no win 1,2,3 jms Check2O ; Check opponent for position 2 jcn NZ,CheckX456 ; If opponent, no win 1,2,3 jms Check3O ; Check opponent for position 3 jcn NZ,CheckX456 ; If opponent, no win 1,2,3 ;; There are three tests for the position 1,2,3; 1,2; 1,3; & 2,3 ;; Check for one open position, 1,2 CheckX12 jms Check1X ; Check for position 1 jcn Z,CheckX13 ; If none, not 1,2 jms Check2X ; Check for position 2 jcn Z,CheckX13 ; If none, not 1,2 fim UTILITY_1_P,POS3_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,2,3 win, mark position 3 ;; Check for one open position, 1,3 CheckX13 jms Check1X ; Check for position 1 jcn Z,CheckX23 ; If none, not 1,3 jms Check3X ; Check for position 3 jcn Z,CheckX23 ; If none, not 1,3 fim UTILITY_1_P,POS2_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,2,3 win, mark position 2 ;; Check for one open position, 2,3 CheckX23 jms Check2X ; Check for position 2 jcn Z,CheckX456 ; If none, not 2,3 jms Check3X ; Check for position 3 jcn Z,CheckX456 ; If none, not 2,3 fim UTILITY_1_P,POS1_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,2,3 win, mark position 1 ;; Check for opponent, 4,5,6 ;; If opponent, no win for this position CheckX456 jms Check4O ; Check opponent for position 1 jcn NZ,CheckX789 ; If opponent, no win 1,2,3 jms Check5O ; Check opponent for position 2 jcn NZ,CheckX789 ; If opponent, no win 1,2,3 jms Check6O ; Check opponent for position 3 jcn NZ,CheckX789 ; If opponent, no win 1,2,3 ;; There are three tests for the position 4,5,6; 4,5; 4,6; & 5,6 ;; Check for one open position, 4,5 CheckX45 jms Check4X ; Check for position 4 jcn Z,CheckX46 ; If none, not 4,5 jms Check5X ; Check for position 5 jcn Z,CheckX46 ; If none, not 4,5 fim UTILITY_1_P,POS6_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 4,5,6 win, mark position 6 ;; Check for one open position, 4,6 CheckX46 jms Check4X ; Check for position 4 jcn Z,CheckX56 ; If none, not 4,6 jms Check6X ; Check for position 6 jcn Z,CheckX56 ; If none, not 4,6 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 4,5,6 win, mark position 5 ;; Check for one open position, 5,6 CheckX56 jms Check5X ; Check for position 5 jcn Z,CheckX789 ; If none, not 5,6 jms Check6X ; Check for position 6 jcn Z,CheckX789 ; If none, not 5,6 fim UTILITY_1_P,POS4_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 4,5,6 win, mark position 4 ;; Check for opponent, 7,8,9 ;; If opponent, no win for this position CheckX789 jms Check7O ; Check opponent for position 7 jcn NZ,CheckNext1 ; If opponent, no win 7,8,9 jms Check8O ; Check opponent for position 8 jcn NZ,CheckNext1 ; If opponent, no win 7,8,9 jms Check9O ; Check opponent for position 9 jcn NZ,CheckNext1 ; If opponent, no win 7,8,9 ;; There are three tests for the position 7,8,9; 7,8; 7,9,; & 8,9 ;; Check for one open position, 7,8 CheckX78 jms Check7X ; Check for position 7 jcn Z,CheckX79 ; If none, not 7,8 jms Check8X ; Check for position 8 jcn Z,CheckX79 ; If none, not 7,8 fim UTILITY_1_P,POS9_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 7,8,9 win, mark position 9 ;; Check for one open position, 7,9 CheckX79 jms Check7X ; Check for position 7 jcn Z,CheckX89 ; If none, not 7,9 jms Check9X ; Check for position 9 jcn Z,CheckX89 ; If none, not 7,9 fim UTILITY_1_P,POS8_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 7,8,9 win, mark position 8 ;; Check for one open position, 8,9 CheckX89 jms Check8X ; Check for position 8 jcn Z,CheckNext1 ; If none, not 8,9 jms Check9X ; Check for position 9 jcn Z,CheckNext1 ; If none, not 8,9 fim UTILITY_1_P,POS7_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 7,8,9 win, mark position 7 CheckNext1 jun CheckX147 org LOOK_FOR_BW_LOCATION + 100H ;; Check for opponent, 1,4,7 ;; If opponent, no win for this position CheckX147 jms Check1O ; Check opponent for position 1 jcn NZ,CheckX258 ; If opponent, no win 1,4,7 jms Check4O ; Check opponent for position 4 jcn NZ,CheckX258 ; If opponent, no win 1,4,7 jms Check7O ; Check opponent for position 7 jcn NZ,CheckX258 ; If opponent, no win 1,4,7 ;; There are three tests for the position 1,4,7; 1,4; 1,7,; & 4,7 ;; Check for one open position, 1,4 CheckX14 jms Check1X ; Check for position 1 jcn Z,CheckX17 ; If none, not 1,4 jms Check4X ; Check for position 4 jcn Z,CheckX17 ; If none, not 1,4 fim UTILITY_1_P,POS7_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,4,7 win, mark position 7 ;; Check for one open position, 1,7 CheckX17 jms Check1X ; Check for position 1 jcn Z,CheckX47 ; If none, not 1,7 jms Check7X ; Check for position 7 jcn Z,CheckX47 ; If none, not 1,7 fim UTILITY_1_P,POS4_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,4,7 win, mark position 4 ;; Check for one open position, 4,7 CheckX47 jms Check4X ; Check for position 4 jcn Z,CheckX258 ; If none, not 4,7 jms Check7X ; Check for position 7 jcn Z,CheckX258 ; If none, not 4,7 fim UTILITY_1_P,POS1_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,4,7 win, mark position 1 ;; Check for opponent, 2,5,8 ;; If opponent, no win for this position CheckX258 jms Check2O ; Check opponent for position 2 jcn NZ,CheckX369 ; If opponent, no win 2,5,8 jms Check5O ; Check opponent for position 5 jcn NZ,CheckX369 ; If opponent, no win 2,5,8 jms Check8O ; Check opponent for position 8 jcn NZ,CheckX369 ; If opponent, no win 2,5,8 ;; There are three tests for the position 2,5,8; 2,5; 2,8,; & 4,8 ;; Check for one open position, 2,5 CheckX25 jms Check2X ; Check for position 2 jcn Z,CheckX28 ; If none, not 2,5 jms Check5X ; Check for position 5 jcn Z,CheckX28 ; If none, not 2,5 fim UTILITY_1_P,POS8_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 2,5,8 win, mark position 8 ;; Check for one open position, 2,8 CheckX28 jms Check2X ; Check for position 2 jcn Z,CheckX58 ; If none, not 2,8 jms Check8X ; Check for position 8 jcn Z,CheckX58 ; If none, not 2,8 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 2,5,8 win, mark position 5 ;; Check for one open position, 5,8 CheckX58 jms Check5X ; Check for position 5 jcn Z,CheckX369 ; If none, not 5,8 jms Check8X ; Check for position 8 jcn Z,CheckX369 ; If none, not 5,8 fim UTILITY_1_P,POS2_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 2,5,8 win, mark position 2 ;; Check for opponent, 3,6,9 ;; If opponent, no win for this position CheckX369 jms Check3O ; Check opponent for position 3 jcn NZ,NoWinX ; If opponent, no win 3,6,9 jms Check6O ; Check opponent for position 6 jcn NZ,NoWinX ; If opponent, no win 3,6,9 jms Check9O ; Check opponent for position 9 jcn NZ,NoWinX ; If opponent, no win 3,6,9 ;; There are three tests for the position 3,6,9; 3,6; 3,9,; & 6,9 ;; Check for one open position, 3,6 CheckX36 jms Check3X ; Check for position 3 jcn Z,CheckX39 ; If none, not 3,6 jms Check6X ; Check for position 6 jcn Z,CheckX39 ; If none, not 3,6 fim UTILITY_1_P,POS9_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 3,6,9 win, mark position 9 ;; Check for one open position, 3,9 CheckX39 jms Check3X ; Check for position 3 jcn Z,CheckX69 ; If none, not 3,9 jms Check9X ; Check for position 9 jcn Z,CheckX69 ; If none, not 3,9 fim UTILITY_1_P,POS6_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 3,6,9 win, mark position 6 ;; Check for one open position, 6,9 CheckX69 jms Check6X ; Check for position 6 jcn Z,NoWinX ; If none, not 6,9 jms Check9X ; Check for position 9 jcn Z,NoWinX ; If none, not 6,9 fim UTILITY_1_P,POS3_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 3,6,9 win, mark position 3 NoWinX bbl REPORT_FAILURE ;; Check for opponent, 5,1,9 ;; If opponent, no win for this position CheckWinO jms Check5X ; Check opponent for position 5 jcn NZ,CheckO537 ; If opponent, no win 5,1,9 jms Check1X ; Check opponent for position 1 jcn NZ,CheckO537 ; If opponent, no win 5,1,9 jms Check9X ; Check opponent for position 9 jcn NZ,CheckO537 ; If opponent, no win 5,1,9 ;; There are three tests for the position 5,1,9; 5,1; 5,9; & 1,9 ;; Check for one open position, 5,1 CheckO51 jms Check5O ; Check for position 5 jcn Z,CheckO59 ; If none, not 5,1 jms Check1O ; Check for position 1 jcn Z,CheckO59 ; If none, not 5,1 fim UTILITY_1_P,POS9_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,1,9 win, mark position 9 ;; Check for one open position, 5,9 CheckO59 jms Check5O ; Check for position 5 jcn Z,CheckO19 ; If none, not 5,9 jms Check9X ; Check for position 9 jcn Z,CheckO19 ; If none, not 5,9 fim UTILITY_1_P,POS1_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,1,9 win, mark position 1 ;; Check for one open position, 1,9 CheckO19 jms Check1O ; Check for position 1 jcn Z,CheckO537 ; If none, not 1,9 jms Check9O ; Check for position 9 jcn Z,CheckO537 ; If none, not 1,9 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,1,9 win, mark position 5 ;; Check for opponent, 5,3,7 ;; If opponent, no win for this position CheckO537 jms Check5X ; Check opponent for position 5 jcn NZ,CheckO123 ; If opponent, no win 5,3,7 jms Check3X ; Check opponent for position 3 jcn NZ,CheckO123 ; If opponent, no win 5,3,7 jms Check7X ; Check opponent for position 7 jcn NZ,CheckO123 ; If opponent, no win 5,3,7 ;; There are three tests for the position 5,3,7; 5,3; 5,7; & 3,7 ;; Check for one open position, 5,3 CheckO53 jms Check5O ; Check for position 5 jcn Z,CheckO57 ; If none, not 5,3 jms Check3O ; Check for position 3 jcn Z,CheckO57 ; If none, not 5,3 fim UTILITY_1_P,POS7_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,3,7 win, mark position 7 ;; Check for one open position, 5,7 CheckO57 jms Check5O ; Check for position 5 jcn Z,CheckO37 ; If none, not 5,7 jms Check7O ; Check for position 7 jcn Z,CheckO37 ; If none, not 5,7 fim UTILITY_1_P,POS3_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,3,7 win, mark position 3 ;; Check for one open position, 3,7 CheckO37 jms Check3O ; Check for position 3 jcn Z,CheckO123 ; If none, not 3,7 jms Check7O ; Check for position 7 jcn Z,CheckO123 ; If none, not 3,7 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 5,3,7 win, mark position 5 ;; Check for opponent, 1,2,3 ;; If opponent, no win for this position CheckO123 jms Check1X ; Check opponent for position 1 jcn NZ,CheckNext3 ; If opponent, no win 1,2,3 jms Check2X ; Check opponent for position 2 jcn NZ,CheckNext3 ; If opponent, no win 1,2,3 jms Check3X ; Check opponent for position 3 jcn NZ,CheckNext3 ; If opponent, no win 1,2,3 ;; There are three tests for the position 1,2,3; 1,2; 1,3; & 2,3 ;; Check for one open position, 1,2 CheckO12 jms Check1O ; Check for position 1 jcn Z,CheckNext2 ; If none, not 1,2 jms Check2O ; Check for position 2 jcn Z,CheckNext2 ; If none, not 1,2 fim UTILITY_1_P,POS3_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,2,3 win, mark position 3 CheckNext2 jun CheckO13 CheckNext3 jun CheckO456 org LOOK_FOR_BW_LOCATION + 200H ;; Check for one open position, 1,3 CheckO13 jms Check1O ; Check for position 1 jcn Z,CheckO23 ; If none, not 1,3 jms Check3O ; Check for position 3 jcn Z,CheckO23 ; If none, not 1,3 fim UTILITY_1_P,POS2_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,2,3 win, mark position 2 ;; Check for one open position, 2,3 CheckO23 jms Check2O ; Check for position 2 jcn Z,CheckO456 ; If none, not 2,3 jms Check3O ; Check for position 3 jcn Z,CheckO456 ; If none, not 2,3 fim UTILITY_1_P,POS1_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,2,3 win, mark position 1 ;; Check for opponent, 4,5,6 ;; If opponent, no win for this position CheckO456 jms Check4X ; Check opponent for position 1 jcn NZ,CheckO789 ; If opponent, no win 1,2,3 jms Check5X ; Check opponent for position 2 jcn NZ,CheckO789 ; If opponent, no win 1,2,3 jms Check6X ; Check opponent for position 3 jcn NZ,CheckO789 ; If opponent, no win 1,2,3 ;; There are three tests for the position 4,5,6; 4,5; 4,6; & 5,6 ;; Check for one open position, 4,5 CheckO45 jms Check4O ; Check for position 4 jcn Z,CheckO46 ; If none, not 4,5 jms Check5O ; Check for position 5 jcn Z,CheckO46 ; If none, not 4,5 fim UTILITY_1_P,POS6_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 4,5,6 win, mark position 6 ;; Check for one open position, 4,6 CheckO46 jms Check4O ; Check for position 4 jcn Z,CheckO56 ; If none, not 4,6 jms Check6O ; Check for position 6 jcn Z,CheckO56 ; If none, not 4,6 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 4,5,6 win, mark position 5 ;; Check for one open position, 5,6 CheckO56 jms Check5O ; Check for position 5 jcn Z,CheckO789 ; If none, not 5,6 jms Check6O ; Check for position 6 jcn Z,CheckO789 ; If none, not 5,6 fim UTILITY_1_P,POS4_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 4,5,6 win, mark position 4 ;; Check for opponent, 7,8,9 ;; If opponent, no win for this position CheckO789 jms Check7X ; Check opponent for position 7 jcn NZ,CheckO147 ; If opponent, no win 7,8,9 jms Check8X ; Check opponent for position 8 jcn NZ,CheckO147 ; If opponent, no win 7,8,9 jms Check9X ; Check opponent for position 9 jcn NZ,CheckO147 ; If opponent, no win 7,8,9 ;; There are three tests for the position 7,8,9; 7,8; 7,9,; & 8,9 ;; Check for one open position, 7,8 CheckO78 jms Check7O ; Check for position 7 jcn Z,CheckO79 ; If none, not 7,8 jms Check8O ; Check for position 8 jcn Z,CheckO79 ; If none, not 7,8 fim UTILITY_1_P,POS9_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 7,8,9 win, mark position 9 ;; Check for one open position, 7,9 CheckO79 jms Check7O ; Check for position 7 jcn Z,CheckO89 ; If none, not 7,9 jms Check9O ; Check for position 9 jcn Z,CheckO89 ; If none, not 7,9 fim UTILITY_1_P,POS8_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 7,8,9 win, mark position 8 ;; Check for one open position, 8,9 CheckO89 jms Check8O ; Check for position 8 jcn Z,CheckO147 ; If none, not 8,9 jms Check9O ; Check for position 9 jcn Z,CheckO147 ; If none, not 8,9 fim UTILITY_1_P,POS7_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 7,8,9 win, mark position 7 ;; Check for opponent, 1,4,7 ;; If opponent, no win for this position CheckO147 jms Check1X ; Check opponent for position 1 jcn NZ,CheckO258 ; If opponent, no win 1,4,7 jms Check4X ; Check opponent for position 4 jcn NZ,CheckO258 ; If opponent, no win 1,4,7 jms Check7X ; Check opponent for position 7 jcn NZ,CheckO258 ; If opponent, no win 1,4,7 ;; There are three tests for the position 1,4,7; 1,4; 1,7,; & 4,7 ;; Check for one open position, 1,4 CheckO14 jms Check1O ; Check for position 1 jcn Z,CheckO17 ; If none, not 1,4 jms Check4O ; Check for position 4 jcn Z,CheckO17 ; If none, not 1,4 fim UTILITY_1_P,POS7_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,4,7 win, mark position 7 ;; Check for one open position, 1,7 CheckO17 jms Check1O ; Check for position 1 jcn Z,CheckO47 ; If none, not 1,7 jms Check7O ; Check for position 7 jcn Z,CheckO47 ; If none, not 1,7 fim UTILITY_1_P,POS4_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,4,7 win, mark position 4 ;; Check for one open position, 4,7 CheckO47 jms Check4O ; Check for position 4 jcn Z,CheckO258 ; If none, not 4,7 jms Check7O ; Check for position 7 jcn Z,CheckO258 ; If none, not 4,7 fim UTILITY_1_P,POS1_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 1,4,7 win, mark position 1 ;; Check for opponent, 2,5,8 ;; If opponent, no win for this position CheckO258 jms Check2X ; Check opponent for position 2 jcn NZ,CheckO369 ; If opponent, no win 2,5,8 jms Check5X ; Check opponent for position 5 jcn NZ,CheckO369 ; If opponent, no win 2,5,8 jms Check8X ; Check opponent for position 8 jcn NZ,CheckO369 ; If opponent, no win 2,5,8 ;; There are three tests for the position 2,5,8; 2,5; 2,8,; & 4,8 ;; Check for one open position, 2,5 CheckO25 jms Check2O ; Check for position 2 jcn Z,CheckO28 ; If none, not 2,5 jms Check5O ; Check for position 5 jcn Z,CheckO28 ; If none, not 2,5 fim UTILITY_1_P,POS8_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 2,5,8 win, mark position 8 ;; Check for one open position, 2,8 CheckO28 jms Check2O ; Check for position 2 jcn Z,CheckO58 ; If none, not 2,8 jms Check8O ; Check for position 8 jcn Z,CheckO58 ; If none, not 2,8 fim UTILITY_1_P,POS5_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 2,5,8 win, mark position 5 ;; Check for one open position, 5,8 CheckO58 jms Check5O ; Check for position 5 jcn Z,CheckO369 ; If none, not 5,8 jms Check8O ; Check for position 8 jcn Z,CheckO369 ; If none, not 5,8 fim UTILITY_1_P,POS2_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 2,5,8 win, mark position 2 ;; Check for opponent, 3,6,9 ;; If opponent, no win for this position CheckO369 jms Check3X ; Check opponent for position 3 jcn NZ,NoWinO ; If opponent, no win 3,6,9 jms Check6X ; Check opponent for position 6 jcn NZ,NoWinO ; If opponent, no win 3,6,9 jms Check9X ; Check opponent for position 9 jcn NZ,NoWinO ; If opponent, no win 3,6,9 ;; There are three tests for the position 3,6,9; 3,6; 3,9,; & 6,9 ;; Check for one open position, 3,6 CheckO36 jms Check3O ; Check for position 3 jcn Z,CheckO39 ; If none, not 3,6 jms Check6O ; Check for position 6 jcn Z,CheckO39 ; If none, not 3,6 fim UTILITY_1_P,POS9_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 3,6,9 win, mark position 9 ;; Check for one open position, 3,9 CheckO39 jms Check3O ; Check for position 3 jcn Z,CheckO69 ; If none, not 3,9 jms Check9O ; Check for position 9 jcn Z,CheckO69 ; If none, not 3,9 fim UTILITY_1_P,POS6_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 3,6,9 win, mark position 6 ;; Check for one open position, 6,9 CheckO69 jms Check6O ; Check for position 6 jcn Z,NoWinO ; If none, not 6,9 jms Check9O ; Check for position 9 jcn Z,NoWinO ; If none, not 6,9 fim UTILITY_1_P,POS3_RAM ; Select RAM game board position bbl REPORT_SUCCESS ; 3,6,9 win, mark position 3 NoWinO bbl REPORT_FAILURE