; ************************************************ ; Gun Fight at the MUN-88 Corale ; ; By Charles Robertson ; ; Based on program number 94 from Science Fair ; Microcomputer Trainer (Radio Shack) ; ; After running the program, the middle LEDs will ; rapidly blink on and off. When the lights stop ; blinking, the first player to fire (by changing ; the DIP switches number 1 or 8) will win. If ; you fire too soon, you will lose! ; ; ************************************************ TITLE Gun Fight MYSEG SEGMENT ASSUME cs:MYSEG, ds:MYSEG, es:MYSEG main: mav ax, cs ; Set up the segments mov ds, ax mov es, ax mov al, ffh ; Clear the contents on the LEDs out 30h, al mov bl, al ; store value of LEDs in BL in al, 30 ; Read the DIP switch (to detect change) mov ah, al ; Store value in AH rep2: mov dx, 2000h ; about 1/8th second rep1: in al, 30 ; Check to see if DIP has changed xor al, ah ; All bits should be the same (xor will be 0) jnz misfire ; Bits are not the same - user fired early dec dx jnz rep1 xor bl, 00011000 ; Change pattern on LEDs mov al, bl ; Fetch pattern from BL out 30h, al dec cx jnz rep2 mov al, 11100111 ; Show target pattern out 30H, al rep3: in al, 30h ; wait for a user to respond xor al, ah ; xor will be 0 until a DIP is switched jz rep3 cmp al, 10000000 ; Has player 1 won? je player1_wins player2_wins: mov al, 11100110 ; Player 2 wins jmp done player1_wins: mov al, 01100111 ; Player 1 wins jmp done misfire: cmp al, 10000000 ; Did player 1 misfire? je player1_loses player2_loses: mov al, 11111101 ; Player 2 fired too early jmp done player1_loses: mov al, 10111111 ; Player 2 fired too early jmp done done: out 30h, al ; Display final message int 6 MYSEG ENDS END main