DT's gonna love this
Just a small example of how some small changes can save some big space...Code:DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines DEFINE LCD_DBIT 4 'Define first pin of portb connected to LCD DB4 DEFINE LCD_RSREG PORTB 'Define PIC port used for RS line of LCD DEFINE LCD_RSBIT 3 'Define Portb pin used for RS connection DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD DEFINE LCD_EBIT 0 'Define PortB pin used for E connection DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD DEFINE LCD_LINES 2 'Define using a 2 line LCD DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands DEFINE LCD_DATAUS 50 'Define delay time between data sent. CMCON=7 : CVRCON=0 : ButStart var Portc.0 : ButStop var Portc.1 ButReset var Portc.2 : Butup var portc.3 : Butdwn var portc.4 BannerOffset var BYTE : CounterA var BYTE : CounterB var BYTE CounterC var BYTE : DataA var BYTE : Hours var BYTE Hundredths var BYTE : Minutes var BYTE : OverflowError var BIT : RunningFlag var BIT Seconds var BYTE : SetupTimeOut var WORD : TMR1Cal var BYTE : IHOURS VAR BYTE IMINUTES VAR BYTE : TIMER VAR BYTE : TMR1CalAR var Byte : TMR1RunOn var WORD Data @0,0 ' Advance/Retard Indicator Data 0 ' Calibration Value Data "Spec-ops.nl Tactical Game Aid - Enter Game Length" TMR1CalMax con 100 : TMR1Preset con $D910 : TRISA=0 : TRISB=0 : TRISC=31 ADCON0=192 : ADCON1=7 : OPTION_REG.7=0 : RunningFlag=0 : Pause 1000 gosub clearlcd : BannerOffset=2 : Gosub DisplayBanner : Pause 2000 For CounterA=0 to 33 : BannerOffset=2+CounterA : Gosub DisplayBanner : Pause 350 Next CounterA : Pause 4000 MAINMENU: PAUSE 1000 MAINMENUA: gosub selectmenu : gosub setline2 : LCDOut "COUNTDOWN" PAUSE 100 : IF BUTSTART=0 THEN MENUA IF BUTUP=0 THEN MAINMENUB GOTO MAINMENUA MAINMENUB: gosub selectmenu : gosub setline2 : LCDOut " COUNT UP" PAUSE 100 : IF BUTDWN=0 THEN MAINMENU IF BUTSTART=0 THEN TIMER=1 : PAUSE 20 IF BUTSTART=0 THEN GOTO BEGINNING ENDIF ENDIF PAUSE 50 : GOTO MAINMENUB MenuA: PAUSE 1000 : TIMER=0 MENUCD: gosub clearlcd : LCDOUT " Preset 1" : gosub show30minutes : pause 100 IF BUTSTART=0 THEN preset1 IF BUTDWN=0 THEN CUSTOMA IF BUTUP=0 THEN PRESET2 IF BUTRESET=0 THEN MAINMENU GOTO MENUCD CUSTOMA: PAUSE 1000 CUSTOMB: gosub clearlcd : LCDOUT "CUSTOM TIME" : gosub setline2 LCDOut "ENTER A CUSTOM TIME" : PAUSE 100 IF BUTSTART=0 THEN CUSTOM IF BUTDWN=0 THEN PRESET2 IF BUTUP=0 THEN MENUCD IF BUTRESET=0 THEN MAINMENU PAUSE 50 : GOTO CUSTOMB PRESET1: PAUSE 1000 PRESET1A: gosub acceptpreset1 : gosub show30minutes : PAUSE 100 IF BUTSTART=0 THEN PRESET1set IF BUTRESET=0 THEN MENUCD GOTO PRESET1A PRESET1SET: IHOURS=0 : IMINUTES=30 : PAUSE 50 : GOTO CONTINUE PRESET2: PAUSE 1000 PRESET2A: gosub clearlcd : LCDOUT " Preset 2" : gosub show45minutes PAUSE 100 IF BUTSTART=0 THEN PRESET2A IF BUTUP=0 THEN CUSTOMA IF BUTDWN=0 THEN menuCD IF BUTRESET=0 THEN MAINMENU GOTO PRESET2A PRESET2B: PAUSE 1000 PRESET2C: gosub acceptpreset2 : gosub show45minutes : PAUSE 100 IF BUTSTART=0 THEN PRESET2SET IF BUTRESET=0 THEN MENUCD GOTO PRESET2C PRESET2SET: IHOURS=0 : IMINUTES=45 : PAUSE 50 : GOTO CONTINUE CUSTOM: PAUSE 1000 : IHOURS=0 : IMINUTES=3 HOURSI: If Butup=0 then IHOURS=IHOURS+1 If BUTDWN=0 THEN IHOURS=IHOURS-1 IF BUTSTART=0 THEN MINSA IF BUTRESET=0 THEN MENUA pause 50 : GOSUB TIMESETUP : GOTO HOURSI MINSA: PAUSE 1000 MINSI: IF BUTUP=0 THEN IMINUTES=IMINUTES+1 IF BUTDWN=0 THEN IMINUTES=IMINUTES-1 IF BUTRESET=0 THEN HOURSI IF BUTSTART=0 THEN CONTINUE PAUSE 50 : GOSUB TIMESETUP : GOTO MINSI timesetup: pause 50 : gosub clearlcd : LCDOUT "GAME LENGTH" : gosub showhoursminutes : PAUSE 50 : REturn Continue: gosub clearlcd : LCDOUT "Settings Saved" : gosub showhoursminutes pause 6000 BEGINNING: Gosub SetTimer ' Set the Timer for next 10mS Interrupt IF TIMER=1 THEN On Interrupt goto TickCountUP ELSE On Interrupt goto TickCount ENDIF PIE1.0=1 : INTCON.6=1 : INTCON.7=1 ' Enable Global Interrupts DisplayReset: gosub clearlcd : Read 0,TMR1CalAR : Read 1,TMR1Cal : Hundredths=0 Seconds=0 : Minutes=IMINUTES Hours=IHOURS : OverflowError=0 Enable DisplayLoop: If ButStart=0 then RunningFlag=1 If ButStop=0 then RunningFlag=0 LCDOut $FE,$80,DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds,".",DEC2 Hundredths If OverflowError=1 then If Seconds.0=1 then LCDOut $FE,$8C,"ERR" else LCDOut $FE,$8C," " endif endif If RunningFlag=1 then goto DisplayLoop If ButReset=1 then goto DisplayLoop Disable ResetClock: LCDOut $FE,1,"Reset OK" : Pause 1000 : Seconds=1 While Seconds < 5 Pause 1000 : If ButReset=1 then goto DisplayReset Seconds=Seconds+1 Wend SetUpTimeout=0 Calibration: LCDOut $FE,1,"Calibrate: " While ButReset=0:Wend ' Wait for User to release finger CalibrationLoop: LCDOut $FE,$8B If TMR1Cal=0 then LCDOut " " else If TMR1CalAR=0 then LCDOut "+" else LCDOut "-" endif endif LCDOut #TMR1Cal," " If TMR1CalAR=0 then If ButStart=0 then Gosub CalAdvance If ButStop=0 then Gosub CalRetard else If ButStart=0 then Gosub CalRetard If ButStop=0 then Gosub CalAdvance endif If ButReset=0 then Write 0,TMR1CalAR : PAUSE 10 : Write 1,TMR1Cal : PAUSE 10 LCDOut $FE,1,"Have a Nice Day" : Pause 1000 Goto DisplayReset endif SetupTimeout=SetupTimeout+1 : If SetupTimeout>200 then goto DisplayReset Pause 100 : Goto CalibrationLoop CalAdvance: SetupTimeout=0 If TMR1Cal=>TMR1CalMax then TMR1Cal=TMR1cALmAX : TMR1CalAR=TMR1CalAR^1 else TMR1Cal=TMR1Cal+1 endif Return CalRetard: SetupTimeout=0 If TMR1Cal=0 then TMR1Cal=1 : TMR1CalAR=TMR1CalAR^1 else TMR1Cal=TMR1Cal-1 endif Return DisplayBanner: CounterC=BannerOffset+15 : gosub setline1 : For CounterB=BannerOffset to CounterC Read CounterB,DataA : LCDOut DataA : Next CounterB : Return SetTimer: T1CON.0=0 : TMR1RunOn.Highbyte=TMR1H : TMR1RunOn.Lowbyte=TMR1L : TMR1RunOn=TMR1Preset+TMR1RunOn If TMR1CalAR=0 then ' Calibration ADVANCE (add) or RETARD (subtract) TMR1RunOn=TMR1RunOn+TMR1Cal else TMR1RunOn=TMR1RunOn-TMR1Cal endif TMR1H=TMR1RunOn.Highbyte : TMR1L=TMR1RunOn.Lowbyte : T1CON.0=1 : PIR1.0=0 Return TickCount: Gosub SetTimer ' Set the Timer for next 10mS Interrupt If RunningFlag=1 then ' If timing actually enabled... then... IF HUNDREDTHS=0 THEN IF SECONDS=0 THEN IF MINUTES=0 THEN IF HOURS=0 THEN GOTO TIMEUP ENDIF ENDIF ENDIF ENDIF If seconds=0 then hundredths=0 else Hundredths=Hundredths-1 If Hundredths=0 then Hundredths=99 : seconds=seconds-1 endif endif If minutes>0 then If Seconds=0 then Seconds=59 : minutes=minutes-1 endif endif If hours>0 then If Minutes=0 then Minutes=59 : hours=hours-1 endif endif If Hours>99 then Hours=0 : OverFlowError=1 endif endif Resume timeup: gosub setline2 : LCDOUT "Time is up" : GOTO timeup TickCountUP: Gosub SetTimer ' Set the Timer for next 10mS Interrupt If RunningFlag=1 then ' If timing actually enabled... then... Hundredths=Hundredths+1 If Hundredths>99 then Hundredths=0 Seconds=Seconds+1 If Seconds>59 then Seconds=0 Minutes=Minutes+1 If Minutes>59 then Minutes=0 Hours=Hours+1 If Hours>99 then Hours=0 OverFlowError=1 endif endif endif endif endif Resume clearlcd: lcdout $fe,1 : return setline1: lcdout $fe,$80 : return setline2: lcdout $fe,$c0 : return selectmenu: gosub clearlcd : LCDOUT " SELECT MENU" : return acceptpreset: gosub clearlcd : lcdout "Accept Preset ?" : return acceptpreset1: gosub acceptpreset : lcdout $fe , $8e , "1" : return acceptpreset2: gosub acceptpreset : lcdout $fe , $8e , "2" : return show30minutes: gosub setline2 : lcdout "00:30:00.00" : return show45minutes: gosub show30minutes : lcdout $fe , $c3 , "45" : return showhoursminutes: LCDOut $FE,$C0,DEC2 IHours,":",DEC2 IMinutes,":00.00" : return End




Bookmarks