Question
I have to make a tic tac toe game with led lights and am running into two problems. I have to have it so player
I have to make a tic tac toe game with led lights and am running into two problems. I have to have it so player 0 led's are flashing and I need the selection process to go smoother than just with one selector unless its on a timer. my code so far will be bellow please help weed out these problems or potential other problems you may see
;******************************************************************************
; This file is a basic template for creating relocatable assembly code for *
; a PIC18F1330. Copy this file into your project directory and modify or *
; add to it as needed. *
; *
; The PIC18FXXXX architecture allows two interrupt configurations. This *
; template code is written for priority interrupt levels and the IPEN bit *
; in the RCON register must be set to enable priority levels. If IPEN is *
; left in its default zero state, only the interrupt vector at 0x008 will *
; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not *
; be needed. *
; *
; Refer to the MPASM User's Guide for additional information on the *
; features of the assembler and linker. *
; *
;******************************************************************************
; *
; Filename: *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
;******************************************************************************
; *
; Files required: P18F1330.INC *
; *
;******************************************************************************
LIST P=18F1330, F=INHX32 ;directive to define processor and file format
#include
;******************************************************************************
;Configuration bits
;Microchip has changed the format for defining the configuration bits, please
;see the .inc file for futher details on notation. Below are a few examples.
; Oscillator Selection:
; CONFIG OSC = LP ;LP ; USED FOR SIM PROJECT, THIS IS A REAL PROJECT
CONFIG OSC = INTI01 ;ADDED FOR REAL PROJECT
CONFIG WDT = OFF ;ADDED FOR REAL PROJECT
;******************************************************************************
;Variable definitions
; These variables are only needed if low priority interrupts are used.
; More variables may be needed to store other special function registers used
; in the interrupt routines.
UDATA
WREG_TEMP RES 1 ;variable in RAM for context saving
STATUS_TEMP RES 1 ;variable in RAM for context saving
BSR_TEMP RES 1 ;variable in RAM for context saving
UDATA_ACS
EXAMPLE RES 1 ;example of a variable in access RAM
;******************************************************************************
;EEPROM data
; Data to be programmed into the Data EEPROM is defined here
DATA_EEPROM CODE 0xf00000
DE "Test Data",0,1,2,3,4,5
;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.
RESET_VECTOR CODE 0x0000
goto Main ;go to start of main code
;******************************************************************************
;High priority interrupt vector
; This code will start executing when a high priority interrupt occurs or
; when any interrupt occurs if interrupt priorities are not enabled.
HI_INT_VECTOR CODE 0x0008
bra HighInt ;go to high priority interrupt routine
;******************************************************************************
;Low priority interrupt vector
; This code will start executing when a low priority interrupt occurs.
; This code can be removed if low priority interrupts are not used.
LOW_INT_VECTOR CODE 0x0018
bra LowInt ;go to low priority interrupt routine
;******************************************************************************
;High priority interrupt routine
; The high priority interrupt code is placed here.
CODE
HighInt:
; *** high priority interrupt code goes here ***
retfie FAST
;******************************************************************************
;Low priority interrupt routine
; The low priority interrupt code is placed here.
; This code can be removed if low priority interrupts are not used.
LowInt:
movff STATUS,STATUS_TEMP ;save STATUS register
movff WREG,WREG_TEMP ;save working register
movff BSR,BSR_TEMP ;save BSR register
; *** low priority interrupt code goes here ***
movff BSR_TEMP,BSR ;restore BSR register
movff WREG_TEMP,WREG ;restore working register
movff STATUS_TEMP,STATUS ;restore STATUS register
retfie
;******************************************************************************
;Start of main program
; The main program code is placed here.
Main:
; *** main code goes here ***
MOVLW 7C
MOVWF OSCCON ;SET INTERNAL CLOCK TO 8MHz
BCF TRISB,0 ;SQUARE 0,0
BCF TRISB,1 ;SQUARE 0,1
BCF TRISB,2 ;SQUARE 0,2
BCF TRISB,3 ;SQUARE 1,0
BCF TRISB,4 ;SQUARE 1,1
BCF TRISB,5 ;SQUARE 1,2
BCF TRISB,6 ;SQUARE 2,0
BCF TRISB,7 ;SQUARE 2,1
BCF TRISA,0 ;SQUARE 2,2
BSF TRISA,3 ;SELECTOR SWITCH
BSF TRISA,1 ;X WIN LED
BSF TRISA,2 ;O WIN LED
// TICK TACK TOES
AAB BTFSS PORTA,3 ;TURN ON TO CHECK BOARD
BRA AAB
AAA BTFSS PORTB,0
BRA BBB
BTFSS PORTB,1
BRA BBB
BTFSC PORTB,2
BRA III
BBB BTFSS PORTB,3
BRA CCC
BTFSS PORTB,4
BRA CCC
BTFSC PORTB,5
BRA III
CCC BTFSS PORTB,6
BRA DDD
BTFSS PORTB,7
BRA DDD
BTFSC PORTA,0
BRA III
DDD BTFSS PORTB,0
BRA EEE
BTFSS PORTB,3
BRA EEE
BTFSC PORTB,6
BRA III
EEE BTFSS PORTB,1
BRA FFF
BTFSS PORTB,4
BRA FFF
BTFSC PORTB,7
BRA III
FFF BTFSS PORTB,2
BRA GGG
BTFSS PORTB,5
BRA GGG
BTFSC PORTA,0
BRA III
GGG BTFSS PORTB,0
BRA HHH
BTFSS PORTB,4
BRA HHH
BTFSC PORTA,0
BRA III
HHH BTFSS PORTB,2
BRA JJJ
BTFSS PORTB,4
BRA JJJ
BTFSS PORTB,6
BRA JJJ
III BSF PORTA,1 ;X HAS A WINNING LINE
MOVLW 2 ;DUMMY LINE
JJJ BTFSC PORTB,0
BRA KKK
BTFSC PORTB,1
BRA KKK
BTFSS PORTB,2
BRA RRR
KKK BTFSC PORTB,3
BRA LLL
BTFSC PORTB,4
BRA LLL
BTFSS PORTB,5
BRA RRR
LLL BTFSC PORTB,6
BRA MMM
BTFSC PORTB,7
BRA MMM
BTFSS PORTA,0
BRA RRR
MMM BTFSC PORTB,0
BRA NNN
BTFSC PORTB,3
BRA NNN
BTFSS PORTB,6
BRA RRR
NNN BTFSC PORTB,1
BRA OOO
BTFSC PORTB,4
BRA OOO
BTFSS PORTB,7
BRA RRR
OOO BTFSC PORTB,2
BRA PPP
BTFSC PORTB,5
BRA PPP
BTFSS PORTA,0
BRA RRR
PPP BTFSC PORTB,0
BRA QQQ
BTFSC PORTB,4
BRA QQQ
BTFSS PORTA,0
BRA RRR
QQQ BTFSC PORTB,2
BRA AAC
BTFSC PORTB,4
BRA AAC
BTFSC PORTB,6
BRA AAC
RRR BSF PORTA,2 ;O HAS A WINNNING LINE
MOVLW 1 ;DUMMY LINE
AAC BTFSC PORTA,3 ;TURN OFF TO JUMP TO WAIT UNTIL
BRA AAC ;TURN BACK ON
BRA AAB ;REDO BOARD WHEN OFF
;******************************************************************************
;End of program
END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started