; AKTIVUJ WDG MOV WDTRST,#01Eh MOV WDTRST,#0E1h MOV CLKREG,#01 MOV IE,#000h ; VYMAZU RAM MOV R0,#0FFh sss: %L(CL): MOV @R0,#0 DJNZ R0,%L(CL) ; INICIALIZACE ZASOBNIKU MOV SP,#STACKINIT ; INIC. ZASOBNIKU ; PREDNASTAVIM SI PREDDELIC PRO 10ms MOV DIV10MS,#nbr10ms MOV DIV100MS,#10 ;10 x 10 = 100ms MOV BLINKTLACTMR,#2 ; NASTAVENI CASOVACE BLIKACKY ; OTESTUJ, ZDA JE PARAMETR 12 (ZOBRAZENI VYPADKU KOMUNIKACE) NENULOVY MOV DPTR,#P11 ; NEJPRVE NACTI, JESTLI MAS POVOLENE ZOBRAZENI TEXTU CALL GET_BIT_PARM MOV TDEFECT,C ; ULOZ MOV DPTR,#P12 CALL TEST_PARM ANL C,TDEFECT ; Cy = 1 TEHDY, POKUD EXISTUJE NEJAKY TEXT A JE POVOLENO JEHO ZOBRAZENI ORL C,F0 MOV TDEFECT,C ; PRIZNAK = 1, POKUD JE NEJAKY TEXT NEBO JE BITMAPA ; OTESTUJ, ZDA JE PARAMETR 14 (ZOBRAZENI POZARNI JIZDY) NENULOVY MOV DPTR,#P13 ; NEJPRVE NACTI, JESTLI MAS POVOLENE ZOBRAZENI TEXTU CALL GET_BIT_PARM MOV TFIRE,C ; ULOZ MOV DPTR,#P14 CALL TEST_PARM ANL C,TFIRE ; Cy = 1 TEHDY, POKUD EXISTUJE NEJAKY TEXT A JE POVOLENO JEHO ZOBRAZENI ORL C,F0 MOV TFIRE,C ; PRIZNAK = 1, POKUD JE NEJAKY TEXT NEBO JE BITMAPA ; OTESTUJ, ZDA JE PARAMETR 10 (ZOBRAZENI PRETIZENO) NENULOVY MOV DPTR,#P09 ; NEJPRVE NACTI, JESTLI MAS POVOLENE ZOBRAZENI TEXTU CALL GET_BIT_PARM MOV TOVERLOAD,C ; ULOZ MOV DPTR,#P10 CALL TEST_PARM ANL C,TOVERLOAD ; Cy = 1 TEHDY, POKUD EXISTUJE NEJAKY TEXT A JE POVOLENO JEHO ZOBRAZENI ORL C,F0 MOV TOVERLOAD,C ; PRIZNAK = 1, POKUD JE NEJAKY TEXT NEBO JE BITMAPA ; OTESTUJ, ZDA JE PARAMETR 19 (ZOBRAZENI REVIZE) NENULOVY MOV DPTR,#P18 ; NEJPRVE NACTI, JESTLI MAS POVOLENE ZOBRAZENI TEXTU CALL GET_BIT_PARM MOV TREVIZE,C ; ULOZ MOV DPTR,#P19 CALL TEST_PARM ANL C,TREVIZE ; Cy = 1 TEHDY, POKUD EXISTUJE NEJAKY TEXT A JE POVOLENO JEHO ZOBRAZENI ORL C,F0 MOV TREVIZE,C ; PRIZNAK = 1, POKUD JE NEJAKY TEXT NEBO JE BITMAPA ; OTESTUJ, ZDA JE PARAMETR 24 (ZOBRAZENI REKLAMY) NENULOVY MOV DPTR,#P23 ; NEJPRVE NACTI, JESTLI MAS POVOLENE ZOBRAZENI TEXTU CALL GET_BIT_PARM MOV TREKLAMA,C ; ULOZ MOV DPTR,#P24 CALL TEST_PARM ANL C,TREKLAMA ; Cy = 1 TEHDY, POKUD EXISTUJE NEJAKY TEXT A JE POVOLENO JEHO ZOBRAZENI ORL C,F0 MOV TREKLAMA,C ; PRIZNAK = 1, POKUD JE NEJAKY TEXT NEBO JE BITMAPA ; NACTI ROTACI DISPLEJE MOV DPTR,#P15 ; ULOZ DO DPTR DANY PARAMETR CALL GET_BIT_PARM MOV ROTATEDISP,C MOV DPTR,#P21 CALL GET_BIT_PARM MOV PROTOKOL,C ; NACTI TYP KOMUNIKACNIHO PROTOKOLU ORL POS,#maskPosRefr ; NASTAV PRIZNAK ZMENY, AT SE NECO ZOBRAZI PO RESTARTU ;------------------------------------------------------------------------------- ; NASTAVIM SI JEDNOTLIVE FLAGY A JEDEME ... ;------------------------------------------------------------------------------- MOV PCON,#10000000b ; | ||||-- IDL idle mode ; | |||--- PD power-down mode ; | ||---- GF0 general purpose flag ; | |----- GF1 general purpose flag ; |--------- SMOD baud rate doubling MOV TH1,#TTIMER1INT ; RYCHLOST NASTAVENA NA 9600 BAUDU ; NASTAVENI CITACE/CASOVACE 2 MOV RCAP2L,#LOW(TTIMER2INT) MOV RCAP2H,#HIGH(TTIMER2INT) MOV TH2,#HIGH(TTIMER2INT) MOV TL2,#LOW(TTIMER2INT) ; TMOD2 JE PO RESETU = 0 MOV T2MOD,#0 ; NASTARTUJ CASOVAC MOV T2CON,#00000100b ; TR2 = 1 MOV TMOD,#00100001b ; ||||||||-- timer 0 mode 00 - 8 bit,prescaler ; |||||| 01 - 16 bit ; |||||| 10 - 8 bit,auto-reload ; |||||| 11 - 2 x 8 bit ; ||||||---- timer 0 C/T# (counter / timer) ; ||||| 0 - timer ; ||||| 1 - counter ; |||||----- timer 0 GATE gating control ; |||| 1 - gating on ; |||| 0 - gating off ; ||||------ timer 1 mode 00 - 8 bit,prescaler ; || 01 - 16 bit ; || 10 - 8 bit,auto-reload ; || 11 - 2 x 8 bit ; ||-------- timer 1 C/T# (counter / timer) ; | 0 - timer ; | 1 - counter ; |--------- timer 1 GATE gating control ; 1 - gating on ; 0 - gating off MOV SCON,#01010000b ; ||||||||-- RI receiver interrupt ; |||||||--- TI trasmitter interrupt ; ||||||---- RB8 receiver bit 8 ; |||||----- TB8 trasmitter bit 8 ; ||||------ REN receiver enable ; |||------- SM2 multiprocessor feature ; ||-------- SM0,1 serial mode ; 00 - shift register, fixed ; 01 - 8-bit UART, variable ; 10 - 9-bit UART, fixed ; 11 - 9-bit UART, variable MOV TCON,#01100000b ; ||||||||--; IT0 INT0 trigger 0 - low level ; ||||||| 1 - falling edge ; |||||||--- IE0 INT0 edge flag ; ||||||---- IT1 INT1 trigger ; |||||----- IE1 INT1 edge flag ; ||||------ TR0 timer 0 run control bit ; |||------- TF0 timer 0 overflow flag ; ||-------- TR1 timer 1 run control bit ; |--------- TF1 timer 1 overflow flag ; MOV TL0,#LOW(TTIMER0INT) ; DOROVNEJ NA SPRAVNOU HODNOTU MOV TH0,#HIGH(TTIMER0INT+7) MOV IE, #10110010B ; INICIALIZACE PRERUSENI ; | ||||||-- EX0 external INT0 ; | |||||--- ET0 timer 0 interrupt ; | ||||---- EX1 external INT1 ; | |||----- ET1 timer 1 interrupt ; | ||------ ES serial interrupt ; | |------- ET2 timer 2 interrupt ; |--------- EA all interrupts MOV IP, #00110000b ; ||||||-- PX0 external INT0 level ; |||||--- PT0 timer 0 interrupt level ; ||||---- PX1 external INT1 level ; |||----- PT1 timer 1 interrupt level ; ||------ PS serial interrupt level ; |------- PT2 timer 2 interrupt level ; NASTAV WATCHDOG - 0.5s MOV WDTCON,#11100101b ; ||||||||-- WDTEN ; |||||||--- WSWRST ; ||||||---- HWDT ; |||||----- DISRTO ; ||||------ WDIDLE ; |||------- PS2, PS1, PS0 set wdg timer CALL SERIAL_INIT ; INICIALIZUJ SERIOVOU LINKU CALL LCD_INIT ; INICIALIZUJ LCD ;CALL FLASH_INIT ; INICIALIZUJ FLASH CALL MSP3_INIT ; INICIALIZUJ MSP3 MOV OUTSOLD,#0FFh MOV MINTMR,#0FFH ; VLOZ PRODLEVU MIN. CASOVACE ;******************************************************************************* ;******************** HLAVNI SMYCKA PROGRAMU ********************** ;******************************************************************************* MainLoop: %IF(%DEBUG EQ 0)THEN ( ; === KOSTICKA PRO PEJSKA CALL WdgReset ; OBSLUZ WDG )FI ; === KVULI MERENI TRVANI PRUCHODU SMYCKOU %IF(0)THEN ( ; === HLIDEJ DOBU NECINNOSTI VE STAVECH >= VERSION MOV A,STAV %CMP(A,#SHOW_VERSION) JC %L(_CONT0) ; JE-LI STAV < VERSION, NIC NETESTUJ MOV A,MINTMR ; NACTI CASOVAC MOV B,STAV MOV STAV,#INIT_POSITION ; POKUD TI DOJEDE CASOVAC,TAK SKOC DO STAVU ZOBRAZENI POLOHY JZ %L(_CONT0) ; JSI DLOUHO VE STAVU NECINNOSTI -> ZACNI ZOBRAZOVAT POLOHU MOV STAV,B ; JESTE CASUJEC, POKRACUJ V AKTUALNIM STAVU MOV R0,#KEYS+valKeyUP MOV A,@R0 JB ACC.bitKeyPress,%L(SETTMR) MOV R0,#KEYS+valKeyDN MOV A,@R0 JB ACC.bitKeyPress,%L(SETTMR) MOV R0,#KEYS+valKeyMode MOV A,@R0 JB ACC.bitKeyPress,%L(SETTMR) MOV MAXTMR,#0 ; NULUJ CASOVAC DELKY STISKU TLACITEK SJMP %L(_CONT0) %L(SETTMR): MOV A,MAXTMR %CJE(A,#255,%L(_CONT0)) ; POKUD TI UZ PRETEKL CITAC DELKY STISKU TLACITKA,TAK UZ CASOVAC CINNOSTI NEOBNOVUJ, ; MUZES MIT ZAMACKLE TLACITKO INC MAXTMR ; OBNOV CASOVAC MOV MINTMR,#0FFH ; VLOZ PRODLEVU MIN. CASOVACE %L(_CONT0): )FI ; === OVLADEJ SYSTEMOVOU LED - RID DLE STAVU SYSTEMU MOV A,STAV %CMP(A,#SHOW_VERSION) JNC %L(MENU_LED) ; === NORMALNI STAV - ROZLIS VYPADEK KOMUNIKACE A VSE V PORADKU MOV A,SERTIM JZ %L(ERR_COM) MOV A,SYSTIMH ANL A,#0FH %CMP(A,#1) CPL C SJMP %L(WRITE_LED) %L(ERR_COM): MOV A,SYSTIMH MOV C,ACC.0 SJMP %L(WRITE_LED) ; === JSI V MENU - INDIKUJ DLE TOHO NA SYSLED %L(MENU_LED): MOV A,SYSTIMH MOV C,ACC.2 %L(WRITE_LED): MOV A,#O_SYSLED MOV F0,C CALL SET_OUTP ; === OVLADEJ VYSTUPY CALL OUT_MANAGE ; **************************************************************************** ; ** ; ** DETEKUJ DATA Z UARTU ; ** ; **************************************************************************** CALL DETECT_HDR JNC %L(NXT0) ;PRINTINT(#0,#20,#3,A,0) ; VYPIS AKTUALNI VYSTUP ;MOV STAV,#WRITE_E2ROM ;JMP %L(STATE_START) %IF(1)THEN ( ; REAGUJ NA SPECIFICKE ZPRAVY %CJE(A,#6,%L(SEND_ANS_PING)) %CJE(A,#7,%L(SEND_ANS_VERSION)) %CJE(A,#10,%L(SEND_ANS_RESTART)) )FI %CMP(A,#STATE_TAB_LEN) JNC %L(NXT0_) ; POKUD JE HODNOTA MIMO, ZADNY STAV NEPREPINEJ A UVOLNI PRIJEM MOV DISPLIGHT,#4 ; POKUD PRISLA NEJAKA ZPRAVA, NASTAV JAS NA MAXIMUM MOV DPTR,#%L(STATE_TABLE) MOVC A,@A+DPTR MOV STAV,A ; ZMEN STAV PODLE ZPRAVY JMP %L(STATE_START) ; SKOC ROVNOU NA ZACATEK STAVOVEHO AUTOMATU %IF(1)THEN ( ; === ODESLI PRIMOU ODPOVED NA DOTAZ %L(SEND_ANS_RESTART): ; ZASTAV PROGRAM, WATCHDOG BY MEL RESETOVAT JEDNOTKU MOV DPTR,#RESTART_MSG CALL ZERO_MSG JNZ %L(NXT0_) ; V TELE ZPRAVY MUSI BYT 2x0,JINAK NIC NEDELEJ CALL SEND_DATA %L(HALT): SJMP %L(HALT) %L(SEND_ANS_PING): MOV DPTR,#PING_MSG CALL ZERO_MSG JNZ %L(NXT0_) ; V TELE ZPRAVY MUSI BYT 2x0,JINAK NIC NEDELEJ SJMP %L(SEND) %L(SEND_ANS_VERSION): MOV DPTR,#VERSION_ERR CALL ZERO_MSG JNZ %L(SEND) ; V TELE ZPRAVY MUSI BYT 2x0,JINAK NIC NEDELEJ MOV DPTR,#VERSION_MSG CALL SEND_DATA ; === ODESLI POZADOVANE DATA JB WRITE,$ ; DOKUD ZAPISUJES PREDCHOZI DATA,NIC NEDELEJ MOV CRC8,#0 MOV A,#_MODEL CALL SEND_BYTE2 MOV A,#_VERSION CALL SEND_BYTE2 MOV A,#_REVISION CALL SEND_BYTE2 MOV A,CRC8 CALL SEND_BYTE2 SJMP %L(NXT0_) %L(SEND): CALL SEND_DATA SJMP %L(NXT0_) )FI ; === STAVOVA TABULKA %L(STATE_TABLE): DB 00h ; NONE DB PROGRAM_FLASH DB ERASE_FLASH DB ERASE_SECTOR DB SEND_FLASH DB 00H DB 00H ; PING DB 00H ; SW_VERSION DB WRITE_E2ROM DB READ_E2ROM DB 00H ; RESTART STATE_TAB_LEN EQU $ - %L(STATE_TABLE) %L(NXT0_): CLR HDR_RCVD %L(NXT0): MOV A,STAV ; === KVULI KONFIG. STAVUM NASTAV SVIT NA MAXIMUM - JINAK TO NEHEZKY BLIKALO %CMP(A,#ERASE_FLASH) %JNC(%L(STATE_START)) %IF(0)THEN ( ; OSETRI STAV, KDY PRIJIMAS PARAMETRY PO UARTU JNB PARM_RCVD,%L(NXT00) ; NECO PRISLO - PREJDI DO STAVU UKLADANI PARAMETRU MOV STAV,#SAVE_PARMS JMP %L(STATE_START) %L(NXT00): )FI ;MOV A,BUFFLEN ;JZ %L(NXT1) ; POKUD MAS NEJAKE DATA V BUFFERU, TAK JE ZPRACUJ - ABY TE NIC NEZDRZOVALO, PREJDI DO DUMMY STAVU ;MOV STAV,#DUMMY_STATE ;CALL CLR_LCD ;JMP %L(STATE_START) %L(NXT1): ;MOV PCKGCNT_LO,#0 ;MOV PCKGCNT_HI,#0 JNB PROTOKOL,%L(00) CALL TESTSBITS CALL RWCALLS ;CALL DECODEDDATA %L(00): ; KDYZ NENI PRIZNAK, NIC NENASTAVUJ JNB POWERSAVE,%L(SET_LIGHT) ; NACTU SI JAK SE BUDE SETRIT SVIT DISPLEJE (VYPNUTI / POWERSAVE) MOV R0,#0 MOV DPTR,#P16 ; VYPINANI DISPLEJE CALL ParGetParm MOV B,#3 DIV AB ;MOV DISPPSAVE,B MOV A,B CJNE A,#0,%L(POWSA) %L(SET_LIGHT): ; JAKA BUDE SVITIVOST? - NACTU SI DO RAM MOV R0,#0 MOV DPTR,#P01 ; NACTU SI SVIT DISPLEJE CALL ParGetParm MOV DISPLIGHT,A SJMP %L(POWSX) %L(POWSA): CJNE A,#1,%L(POWSAVE) ; 1 = vypnuti displeje pri POWERSAVE MOV DISPLIGHT,#0 ; VYPNI DISPLEJ SJMP %L(POWSX) %L(POWSAVE): ;neni ani 0 ani 1 -> je 2 = snizeni intenzity MOV DISPLIGHT,#1 ; MINIMALNI SVIT DISPLEJE %L(POWSX): ; === TOZ TAK SI GONGNEM ; PRISEL GONG ZE SERIOVKY? JNB GONGSER,%L(GSERXN) ; BUDE? CLR GONGSER ; KAZDOPADNE UZ JE TO VYRIZENO MOV A,POS ANL A,#maskPosValue DEC A MOV R0,A MOV DPTR,#P04 ; TAK JAK JE S TIM GONGEM V TOMO PATRE? CALL ParGetParm JZ %L(GSERXN) JB GONGDONEL,%L(GSERX) MOV R0,#0 MOV DPTR,#P17 ; Jaka bude delka gongu? CALL ParGetParm MOV GONGTIM,A ; SPUSTIM GONG SETB GONGDONEL JMP %L(GSERX) %L(GSERXN): CLR GONGDONEL %L(GSERX): JNB OVERLOAD,%L(OVERN) ; JE PRETIZENO MOV R0,#0 MOV DPTR,#P08 CALL ParGetParm JZ %L(OVERX) JB GONGDONEP,%L(OVERX) ; JE NASTAVEN GONG PRI PRETIZENI (P08) MOV R0,#0 MOV DPTR,#P17 ; Jaka bude delka gongu? CALL ParGetParm MOV GONGTIM,A ; SPUSTIM GONG SETB GONGDONEP JMP %L(OVERX) %L(OVERN): ; NENI PRETIZENO CLR GONGDONEP %L(OVERX): ; TAK JAK JSME S TIM GONGEM? MOV A,GONGTIM ; JESTE MAM GONGAT? JZ %L(GNE) MOV A,#O_GONG SETB F0 ; AKTIVUJ VYSTUP GONG CALL SET_OUTP JMP %L(GX) %L(GNE): MOV A,#O_GONG CLR F0 ; DEAKTIVUJ CALL SET_OUTP %L(GX): CALL SETGNGTLAC ; OVLADANI VYSTUPU GONGU TLACITKA ; === SKOK PODLE STAVU NA PRISLUSNY PODPROGRAM %L(STATE_START): MOV A,STAV CJNE A,#LASTSTAV,$+3 %JNC(RESET) ; NEPLATNY STAV! MOV DPTR,#TABSTAV ADD A,ACC ; 2*A MOV B,A MOVC A,@A+DPTR XCH A,B ; HIGH BYTE ADRESY INC A MOVC A,@A+DPTR ; LOW BYTE MOV DPL,A MOV DPH,B CLR A JMP @A+DPTR ; VYKONEJ DLE STAVU ;==================== DEFINICE STAVOVEHO AUTOMATU ============================= ;=== DEFINICE HLAVICKY - ZACATKU %*DEFINE(STAVDEF(NAME)) (%SET(STAVCNT,%STAVCNT+1) ; === STAV %STAVCNT === %IF (%LEN(%NAME) GT 0) THEN (%NAME EQU %STAVCNT S_%NAME: %RESLOCAL ) FI ASTAV SET %STAVCNT _STAVL%RSTR(%STAVCNT,3): MOV STAV,#ASTAV ) ;=== DEFINICE UKONCENI - VYSKOCENI ZE STAVU %*DEFINE(BREAK) ( ;JMP MainStavExit JMP MainLoop ) ;=== DEFINICE UKONCENI - KONCE STAVU %*DEFINE(ENDSTAV) ( %L(%STAVCNT%(X)): ;JMP MainStavExit JMP MainLoop ) ; === INICIALIZACE %SET(STAVCNT,-1) ; ============================================================================== ; ============================ STAVOVY AUTOMAT ================================= ; ============================================================================== ; INICIALIZACE %STAVDEF(INIT) %PRINT(#20,#0,'RESET..',RES_HDR) MOV SHIFTCNT1,#100 ; PRED VYHODNOCENIM CEKEJ 500ms CALL KeyInit %IF(%NO_COMPILE EQ 1)THEN ( MOV TEMP,#0 ; ZJISTI, JESTLI UZ TAM MAS NECO ZAPSANE MOV DPTR,#0EFFFh MOV R2,#7 CALL FLASH_BYTERD JZ %L(WAIT) MOV R3,#0 CALL FLASH_BYTEWR %STAVDEF() MOV A,TEMP CALL GET_TRANS_CHAR_ ; PREVED OBSAH ACC NA ZOBRAZITELNE ZNAKY MOV R0,A MOV A,#0 %CJE(R0,#' ',%L(DO1_)) MOV A,R0 ADD A,#-32 MOV B,#OFFSET ; V Acc MAS HODNOTU ZNAKU MUL AB ; BUDES NASOBIT HODNOTOU OFFSETU (DELKA DANEHO ZNAKU V BAJTECH) ADD A,#LOW(BASE) MOV DPL,A MOV A,B ADDC A,#HIGH(BASE) MOV DPH,A %L(DO0_): MOV R2,#7 ; NASTAV STRANKU ;MOV R6,#RES_Y ; SET RESOLUTION ;MOV R5,#RES_X CALL GET_CHAR_DUMMYPIX MOV A,R3 SWAP A ORL A,R4 %L(DO1_): MOV DPH,#0F1h MOV DPL,TEMP MOV R2,#7 MOV R3,A CALL FLASH_BYTEWR INC TEMP MOV A,TEMP %CMP(A,#99) JNC %L(WAIT) %ENDSTAV %L(WAIT): )FI %STAVDEF() MOV A,SHIFTCNT1 JNZ %L(KX) MOV R0,#KEYS+valKeyDn CALL KeyGet JNC %L(K1) MOV STAV,#BEGIN_TEST SJMP %L(KX) %L(K1): MOV R0,#KEYS+valKeyUp CALL KeyGet JNC %L(K2) MOV STAV,#SHOW_VERSION SJMP %L(KX) %L(K2): MOV R0,#KEYS+valKeyMode CALL KeyGet JNC %L(K3) MOV STAV,#MENUSET SJMP %L(KX) %L(K3): MOV POS,#0 MOV POSOLD,POS MOV STAV,#INIT_POSITION %L(KX): %ENDSTAV ;******************************************************************** ; ZOBRAZENI POLOHY A SMEROVYCH SIPEK ;******************************************************************** BMPPOS EQU MENUPTR %IF(1)THEN ( REFRESH EQU DPL1 )FI %STAVDEF(INIT_POSITION) CALL LCD_INIT ORL POS,#maskPosRefr MOV A,ARROW ; UPDATUJ SMEROVE SIPKY SETB ACC.bitArrRefr MOV ARROW,A MOV POS_SCROLL,#98 %IF(1)THEN ( MOV REFRESH, #100 ; REFRESH PO 10s )FI %STAVDEF(_POSITION) %IF(1)THEN ( MOV A,REFRESH JNZ %L(END) MOV STAV,#INIT_POSITION %L(END): )FI ;=== JAK JE TO S NAPISY MIMO PROVOZ, PRETIZENO A POZARNI JIZDA? === CALL CheckFlags CJNE A,#valFlgFir,%L(FPSX) ; NENI POZARNI JIZDA - SKOC MOV B,A ; SCHOVAM MOV A,FPSCNT JZ %L(FPSR) ; JESTE TRVA PREPNUTI ZE ZOBRAZENI PJ? ; TAK JESTE NA CHVILI ZUSTAN TADY CLR A SJMP %L(FPSX) %L(FPSR): ; TAK UZ DOPOCITAL, TAKZE ZASE ZPATKY MOV A,B %L(FPSX): JZ %L(POS_NORM) ; NEJAKY TEN TEXT PRECE JEN BUDE... MOV STAV,#SFLAGS %BREAK %L(POS_NORM): ; ZJISTIM,JESTLI MAM NASTAVENE NEJAKE SIPKY - POKUD NE, BUDU KRESLIT POLOHU DOPROSTRED DISPLEJE %IF(0)THEN ( CLR TEMPBIT2 MOV R0,#0 %L(CYKL): MOV A,R0 PUSH ACC MOV DPTR,#P05 CALL ParGetParm MOV B,R0 %CMP(A,B) POP ACC MOV R0,A INC R0 ORL C,TEMPBIT2 ; V TEMPBIT2 BUDE ULOZEN PRIZNAK,JESTLI JE NEJAKA SIPKA NEBO NENI MOV TEMPBIT2,C CJNE R0,#4,%L(CYKL) )FI ;=== VYPIS SIPKY %L(AR_S): ;JNB(TEMPBIT2,%L(AR_X)) MOV A,ARROW ;;;;;;;;;;;;; ;JNB ACC.bitArrBlink,%L(ARB0) ;SETB ACC.bitArrRefr ;MOV ARROW,A ;;;;;;;;;;;;; %L(ARB0): %JNB (Acc.bitArrRefr,%L(AR_W)) CLR ACC.bitArrRefr MOV ARROW,A ; === NASTAVIM UKAZATEL NA TVAR SIPEK ;;;;;;;; JNB DKABNXTGO,%L(ARR_SET) ; MAS SELEKTOVAT SIPKY?? JB KABINA,%L(ARR_SET) MOV A,POS ; NACTI AKTUALNI POZICI ADD A,#-1 ; ODECTI "1" KVULI POZICI,KTEROU VYSILA RIDICI SYSTEM ANL A,#00011111b %CJE(A,PATRO,%L(ARR_SET)) MOV A,ARROW ANL A,#NOT maskArrValue ; SMAZ SIPKY - NEMAS JE ZOBRAZOVAT MOV ARROW,A %L(ARR_SET): ;;;;;;;;; ;MOV A,ARROW ;JNB ACC.bitArrBlink,%L(AR_BX) ;MOV A,SYSTIMH ;MOV C,ACC.BIT3 ; INTERVAL BLIKANI ;JNC %L(AR_BX) ;SJMP %L(AR_NO) ;;;;;;;;;; %L(AR_BX): MOV A,ARROW ANL A,#maskArrValue CJNE A,#valArrNone,%L(AR_1) ; ZHASNOUT ? %L(AR_NO): ;CLR SIPKADN ;CLR SIPKAUP MOV A,#O_ARRUP CLR F0 CALL SET_OUTP MOV A,#O_ARRDN CALL SET_OUTP ;JNB(TEMPBIT2,%L(AR_W)) MOV A,#NO_ARR CALL SHOW_ARROW ; SJMP %L(AR_W) %L(AR_1): CJNE A,#valArrUp,%L(AR_2) ; SIPKA NAHORU ? ; ;CLR SIPKADN ;SETB SIPKAUP MOV A,#O_ARRUP SETB F0 CALL SET_OUTP MOV A,#O_ARRDN CLR F0 CALL SET_OUTP MOV A,#ARR_UP CALL SHOW_ARROW ; SJMP %L(AR_W) %L(AR_2): CJNE A,#valArrDn,%L(AR_3) ; SIPKA DOLU ? ; ;CLR SIPKAUP ;SETB SIPKADN MOV A,#O_ARRUP CLR F0 CALL SET_OUTP MOV A,#O_ARRDN SETB F0 CALL SET_OUTP MOV A,#ARR_DN CALL SHOW_ARROW ; SJMP %L(AR_W) %L(AR_3): CJNE A,#valArrUD,%L(AR_W) ; OBE SIPKY ? ; ;SETB SIPKAUP ;SETB SIPKADN MOV A,#O_ARRUP SETB F0 CALL SET_OUTP MOV A,#O_ARRDN CALL SET_OUTP MOV A,#ARR_UD CALL SHOW_ARROW ; %L(AR_W): %L(AR_X): ;*********************************************************************** ; POKUD TO NEMAS POVOLENO, NEHAZEJ POLOHU NA STRED DISPLEJE MOV R0,#0 MOV DPTR,#P02 ; NACTU SI INTERVAL PRO POSUNUTI O BOD CALL ParGetParm JNZ %L(MID_POS) ; JE POVOLENO ZOBRAZOVAT POLOHU NA STREDU DISPLEJE? SETB TEMPBIT2 ; POLOHA VZDY V DRUHE POLOVINE DISPLEJE %L(MID_POS): %IF(0)THEN ( ;*********************************************************************** ; VYPIS POLOHU ; NACTU SI INTERVAL PRO ROLOVANI, KDYZ JE = 0, TAK NASTAV ODROLOVANO MOV R0,#0 MOV DPTR,#P02 ; NACTU SI INTERVAL PRO POSUNUTI O BOD CALL ParGetParm %JZ(%L(POS_ROL)) ; BUDE SE ROLOVAT? MOV A,POS %JNB(ACC.bitPosRefr,%L(POS_LX)) ; NENI ZMENA - NERES NIC S POLOHOU MOV A,POS_SCROLL %CJE(A,#98,%L(NEW)) SJMP %L(_START) %L(NEW): MOV POS_SCROLL,#0 MOV A,POS ANL A,#maskPosValue MOV B,POSOLD ANL B,#maskPosValue %CJE(A,B,%L(_START)) ; JSOU RUZNE - ZACNI SKROLOVAT MOV BMPPOS,#0 JNB ROTATEDISP,%L(_START) MOV BMPPOS,#63 %L(_START): MOV A,POS ANL A,#maskPosValue MOV B,POSOLD ANL B,#maskPosValue %LCJE(A,B,%L(DRAW_STAT)) ; POKUD SE ROVNAJI - ZOBRAZ STATICKOU POLOHU %CMP(A,B) MOV TEMPBIT,C ; ULOZ DO POMOCNEHO BITU - USETRIS PRACI SE ZASOBNIKEM ; UKLADAS SMER ROTACE SYMBOLU - SMER JIZDY %XRL(C,ROTATEDISP) MOV A,BMPPOS JNC %L(UP) CLR C SUBB A,POS_SCROLL SJMP %L(_DRAW) %L(UP): ADD A,POS_SCROLL %L(_DRAW): MOV B,A MOV A,POSOLD JNB ROTATEDISP,%L(OFF0_) ;*********************************************************************** SETB DENNY_CS1 CLR DENNY_CS2 %L(OFF0_): ;*********************************************************************** CALL SHOW_POSITION ; ZOBRAZ POLOHU - PREDCHOZI STAV MOV A,BMPPOS MOV C,TEMPBIT %XRL(C,ROTATEDISP) JNC %L(UP1) ADD A,#96 CLR C SUBB A,POS_SCROLL SJMP %L(_DRAW1) %L(UP1): ADD A,#-96 ADD A,POS_SCROLL %L(_DRAW1): MOV B,A ; NASTAV VYSLEDNOU POSUNUTOU POZICI MOV A,POS JNB ROTATEDISP,%L(OFF_) ;*********************************************************************** SETB DENNY_CS1 CLR DENNY_CS2 %L(OFF_): ;*********************************************************************** CALL SHOW_POSITION ; ZOBRAZ POLOHU - NOVOU ; === INKREMENTUJ POZICI INC POS_SCROLL INC POS_SCROLL ;*********************************************************************** MOV A,POS_SCROLL CJNE A,#98,%L(TST_END) ANL POS,#NOT maskPosRefr MOV POSOLD,POS %L(TST_END): SETB DENNY_CS1 SETB DENNY_CS2 SJMP %L(POS_LX) ; ********************************************************************** )FI %L(POS_ROL): ; TADY SE ZOBRAZUJI POUZE STATICKE SYMBOLY - NEROLUJI MOV A,POS JNB ACC.bitPosRefr,%L(POS_LX) ; NENI ZMENA - NERES NIC S POLOHOU %L(DRAW_STAT): ; TADY SKOCIS, POKUD BUDES CHTIT ZOBRAZIT STATICKOU POLOHU (NEROLOVAT) MOV POS_SCROLL,#98 CLR ACC.bitPosRefr MOV POS,A MOV POSOLD,A %L(R0): ; === ZJISTI, JESTLI MAS SMAZAT POLOHU NA STREDU DISPLEJE JB TEMPBIT2,%L(R1) MOV A,#32 MOV R0,#96 MOV R1,#0 MOV R2,#64 CALL FULLFILL_LCD MOV B,#63 ; NASTAV POLOHU JB ROTATEDISP,%L(DO) ; JE ROTOVANY DISPLEJ? MOV B,#0 ; NENI SJMP %L(DO) %L(R1): ; === VYMAZ PRISLUSNOU CAST DISPLEJE A NASTAV SOURADNICE VYKRESLENI ; SOURADNICE VRACI V B CALL CLEAR_AND_SET_POSITION %L(DO): JNB ROTATEDISP,%L(OFF1_) SETB DENNY_CS1 CLR DENNY_CS2 %L(OFF1_): MOV A,POS CALL SHOW_POSITION ; ZOBRAZ POLOHU %L(POS_LX): %IF(%NO_COMPILE EQ 1)THEN ( %STAVDEF() MOV R0,#KEYS+valKeyMode CALL KeyGet JNC %L(KX) DEC STAV %L(KX): )FI %ENDSTAV CLEAR_AND_SET_POSITION: JB ROTATEDISP,%L(DO_) ; JE ROTOVANY DISPLEJ? CLR CS1 SETB CS2 CALL CLR_LCD_ MOV B,#0 ; NENI SJMP %L(KX) %L(DO_): SETB CS1 CLR CS2 CALL CLR_LCD_ MOV B,#63 ; NASTAV POLOHU %L(KX): RET ;--------------------------- ZOBRAZENI PRIZNAKU -------------------------------- TXTON_LO EQU MENUPTR3 TXTON_HI EQU MENUPTR3_ ;******************************************************************************* %STAVDEF(SFLAGS) CALL CLR_LCD MOV FPSCNT,#nbrFTime ; KDYBY TO BYLA POZARNI JIZDA %STAVDEF(SFLAGS_) ; JESTE BUDE TRVAT VYPIS TEXTU DAL? CALL CheckFlags MOV B,A ; ZJISTI, JESTLI BYLA NEJAKA ZMENA VE FLAGOCH - NENASTAL ZAROVEN JINY STAV %CJE(A,FLAGS_OLD,%L(_NXT)) ; BYLA ZMENA - NEJPRVE SMAZ PREDCHOZI OBSAH MOV FLAGS_OLD,A MOV STAV,#SFLAGS %BREAK %L(_NXT): MOV FLAGS_OLD,A CJNE A,#valFlgFir,%L(FPSX) MOV A,FPSCNT JNZ %L(FPSX) ; TAK NA CHVILI SE ZNOVU PREPNI DO ZOBRAZENI POLOHY MOV FPSCNT,#nbrSTime ; TAK NA CHVILI SE ZNOVU PREPNI DO ZOBRAZENI POLOHY MOV B,#0 ; SMAZU PRIZNAK FIRE %L(FPSX): MOV A,B MOV R3,A ; ULOZIM SI FLAGY JNZ %L(SF0) ; UZ NENI CO VYPSAT - JDI ZPATKY K ZOBRAZENI POLOHY A SIPEK MOV STAV,#INIT_POSITION ; ; %BREAK %L(SF0): %L(SF_NZ): MOV B,STAV ; ULOZ AKTUALNI STAV ; NASTAVENI ADRES PRO ZPRACOVANI PARAMETRU + VYRIZENI STAVU, KDY NENI ZADNA HLASKA NEBO BITMAPA MOV A,R3 ; VYZVEDNU SI FLAGY ZNOVU CJNE A,#valFlgFir,%L(SF_F) MOV TXTON_LO,#LOW(P13) MOV TXTON_HI,#HIGH(P13) MOV DPTR,#P14 ; ADRESA PARAMETRU PRO POZARNI JIZDU %L(SF_F): CJNE A,#valFlgOvl,%L(SF_O) MOV TXTON_LO,#LOW(P09) MOV TXTON_HI,#HIGH(P09) MOV DPTR,#P10 ; ADRESA PARAMETRU PRO PRETIZENO %L(SF_O): CJNE A,#valFlgDef,%L(SF_R) MOV TXTON_LO,#LOW(P11) MOV TXTON_HI,#HIGH(P11) MOV DPTR,#P12 ; ADRESA PARAMETRU PRO MIMO PROVOZ %L(SF_R): CJNE A,#valFlgRev,%L(SF_R2) MOV TXTON_LO,#LOW(P18) MOV TXTON_HI,#HIGH(P18) MOV DPTR,#P19 ; ADRESA PARAMETRU PRO REVIZNI JIZDU %L(SF_R2): CJNE A,#valFlgReklam,%L(SF_D) MOV TXTON_LO,#LOW(P23) MOV TXTON_HI,#HIGH(P23) MOV DPTR,#P24 ; ADRESA PARAMETRU PRO REKLAMU %L(SF_D): CJNE A,#valFlgNco,%L(SF_N) MOV TXTON_LO,#LOW(P06) MOV TXTON_HI,#HIGH(P06) MOV DPTR,#P07 ; ADRESA PARAMETRU PRO NEKOMUNIKACI ;KDYZ NENI KOMUNIKACE, MUSIM SMAZAT PRIZNAKY, ABY PAK TO NEBLBLO CLR FIRE CLR OVERLOAD CLR DEFECT CLR REVIZE %L(SF_N): MOV STAV,B ; DEJ ZPATKY HODNOTU STAVU ; ULOZ ADRESU PARAMETRU PRO PRIPADNE ZOBRAZENI BEZICIHO TEXTU MOV ADDR_LO,DPL MOV ADDR_HI,DPH ;*********************************************************************** ; TADY OTESTUJ, JESTLI BUDES ZOBRAZOVAT NEJAKY TEXT MOV BMPCNT,#0 ; NULUJ POCITADLO BITMAP PRO ZOBRAZENI TEXTU PUSH DPL PUSH DPH MOV DPH,TXTON_HI MOV DPL,TXTON_LO MOV R0,#0 CALL ParGetParm JZ %L(NO_) MOV DPH,ADDR_HI MOV DPL,ADDR_LO MOV R0,#2 CALL ParGetParmRaw %CMP(A,#128) JNC %L(NO_) ORL BMPCNT,#80H ; NASTAV PRIZNAK TEXTU MOV STAV,#ROLL_TEXT ; PREJDI DO STAVU ROLOVANI TEXTU %L(NO_): POP DPH POP DPL ;*********************************************************************** ; NEJDRIV ZJISTI, JESTLI MAS NEJAKE BITMAPY MOV R0,#0 CALL ParGetParm MOV DPL,ADDR_LO MOV DPH,ADDR_HI ; ZJISTI, JESTLI NEVRACIS NULL MOV B,R0 %CMP(A,B) %JNC(%L(TEST_TEXT)) ; NENI ZADNA BITMAPA INC BMPCNT ; ZVYS O JEDNA - MAS BITMAPU ; JE NEJAKA BITMAPA - ZJISTI, JESTLI MAS JESTE DALSI PUSH ACC ; ULOZ POINTER NA BITMAPU MOV R0,#1 ; ZKUS NACIST DALSI BITMAPU CALL ParGetParm ; ZJISTI, JESTLI NEVRACIS NULL MOV B,R0 %CMP(A,B) POP B ; VYTAHNI ZE STACKU POINTER NA 1 BITMAPU %JC(%L(2BMP)) ;*********************************************************************** ; VYPOCET ADRESY 1 BITMAPY MOV A,R3 MOV R2,A ; ZADEJ STRANKU PARAMETRU MOV A,#2 MUL AB MOV DPH,A MOV DPL,#0 ; VYPOCITEJ ADRESU BITMAPY Z PARAMETRU MOV R5,#64 ; NASTAV ROZLISENI MOV R4,#64 ; ZOBRAZUJES POUZE JEDNU BITMAPU - DLE ROTACE DISPLEJE DEJ VZDY NA STRED JNB ROTATEDISP,%L(STD0) ; ZOBRAZ OTOCENE O 90 STUPNU MOV R7,#0 %IF(0)THEN ( MOV R6,#95 )ELSE ( MOV R6,#95 MOV A,BMPCNT JB ACC.7, %L(00) ; === NENI TEXT - BUDES ZOBRAZOVAT POLOHU!! MOV R6,#127 %L(00): )FI CLR C CALL SHOWBMPWND2ROT SJMP %L(SHOW_POS) %L(STD0): %IF(0)THEN ( MOV R6,#32 ; POKUD NEMAS ZADNY TEXT, ZOBRAZ BITMAPU NA STRED! MOV A,BMPCNT JNB ACC.7,%L(STD00) MOV R6,#0 )ELSE ( MOV R6,#0 )FI %L(STD00): MOV R7,#0 CALL SHOWBMPWND2 %L(SHOW_POS): %IF(1)THEN ( MOV A,BMPCNT JB ACC.7, %L(TEST_TEXT) MOV A,POS JNB ACC.bitPosRefr,%L(DO); NENI ZMENA - NERES NIC S POLOHOU CLR ACC.bitPosRefr MOV POS,A MOV POSOLD,A CALL CLEAR_AND_SET_POSITION %L(DO): ; === VYMAZ PRISLUSNOU CAST DISPLEJE A NASTAV SOURADNICE VYKRESLENI JB ROTATEDISP,%L(DO_) ; JE ROTOVANY DISPLEJ? MOV B,#0 ; NENI SJMP %L(KX) %L(DO_): MOV B,#63 ; NASTAV POLOHU %L(KX): JNB ROTATEDISP,%L(OFF1_) SETB DENNY_CS1 CLR DENNY_CS2 %L(OFF1_): SETB TEMPBIT2 MOV A,POS CALL SHOW_POSITION ; ZOBRAZ POLOHU )FI SJMP %L(TEST_TEXT) ;*********************************************************************** %L(2BMP): INC BMPCNT ; ZVYS ZASE JEDNA - MAS 2 BITMAPY ;*********************************************************************** ; ZOBRAZUJES OBE DVE BITMAPY XCH A,B ; DEJ 1 BITMAPU DO ACC A DRUHOU DO B PUSH B ; ULOZ MOV B,A MOV A,R3 MOV R2,A ; ZADEJ STRANKU PARAMETRU MOV A,#2 MUL AB MOV DPH,A MOV DPL,#0 ; VYPOCITEJ ADRESU BITMAPY Z PARAMETRU MOV R5,#64 ; NASTAV ROZLISENI MOV R4,#64 JNB ROTATEDISP,%L(STD1) ; ZOBRAZ OTOCENE O 90 STUPNU MOV R7,#0 MOV R6,#127 CLR C CALL SHOWBMPWND2ROT SJMP %L(NXTBMP) %L(STD1): MOV R7,#0 MOV R6,#0 CALL SHOWBMPWND2 %L(NXTBMP): ; V R2 STALE ZUSTAVA PLATNA ADRESA STRANKY VE FLASH POP ACC ; VYTAHNI ZE ZASOBNIKU ADRESU 2. BITMAPY MOV B,#2 MUL AB MOV DPH,A MOV DPL,#0 ; VYPOCITEJ ADRESU BITMAPY Z PARAMETRU MOV R5,#64 ; NASTAV ROZLISENI MOV R4,#64 JNB ROTATEDISP,%L(STD2) ; ZOBRAZ OTOCENE O 90 STUPNU MOV R7,#0 MOV R6,#63 CLR C CALL SHOWBMPWND2ROT SJMP %L(TEST_TEXT) %L(STD2): MOV R7,#0 MOV R6,#64 CALL SHOWBMPWND2 %IF(0)THEN ( %L(TEST_TEXT): ;*********************************************************************** ; TADY OTESTUJ, JESTLI BUDES ZOBRAZOVAT NEJAKY TEXT MOV DPH,TXTON_HI MOV DPL,TXTON_LO MOV R0,#0 CALL ParGetParm JZ %L(NO_TEXT) MOV DPH,ADDR_HI MOV DPL,ADDR_LO MOV R0,#2 CALL ParGetParm MOV B,R0 %CMP(A,B) JNC %L(NO_TEXT) MOV STAV,#ROLL_TEXT ; PREJDI DO STAVU ROLOVANI TEXTU ; === KONEC )FI %L(TEST_TEXT): %L(NO_TEXT): ANL BMPCNT,#7FH %ENDSTAV ;--------------------------- ROLOVANI TEXTU ------------------------------------ RES_X EQU 16 RES_Y EQU 24 OFFSET EQU 48 BASE EQU 8000h ADDR_LO EQU MENUPTR ADDR_HI EQU MENUPTR2 STR_LEN EQU MENUPTR3 STR_PTR EQU MENUPTR3_ TEXT_SCROLL EQU MENUPTR4 BMPCNT EQU TEMP2 ; POCET BITMAP SHIFT_NXTCH EQU TEMP3 AKTUAL_POS EQU TEMP4 ;******************************************************************************* %STAVDEF(ROLL_TEXT) ;*********************************************************************** ; ZJISTI DELKU RETEZCE MOV R0,#2 ; ZACNI CIST 3. BAJT Z PARAMETRU %L(CYKL): MOV A,R0 PUSH ACC ; ULOZ POINTER V PARAMETRU MOV DPL,ADDR_LO ; NACTI ADRESY PARAMETRU, ZE KTEREHO UDES CIST TEXT MOV DPH,ADDR_HI CALL ParGetParmRaw ;MOV B,R0 ; V R0 MAXIMALNI HODNOTA - EOL %CJE(A,#128,%L(END)) POP ACC MOV R0,A ; INKREMENTUJ POINTER INC R0 %CMP(R0,#23) ; ZJISTI,JESTLI UZ NEMAS MAX. DELKU RETEZCE JC %L(CYKL) ; POKUD ANO, SKONCI MOV A,R0 SJMP %L(_END) %L(END): POP ACC MOV R0,A %L(_END): CJNE A,#2,%L(POK) MOV STAV,#SFLAGS %BREAK %L(POK): MOV STR_LEN,R0 ; ULOZ DELKU RETEZCE MOV STR_PTR,#2 ; ZACNI NA NULE MOV TEXT_SCROLL,#128 ; ZACNI MIMO OBRAZ MOV SHIFT_NXTCH,#48 JNB ROTATEDISP,%L(R0) MOV SHIFT_NXTCH,#-16 MOV TEXT_SCROLL,#64 ; ZACNI MIMO OBRAZ %L(R0): %STAVDEF(ROLL_TEXT1) MOV AKTUAL_POS,#0 ;*********************************************************************** CALL CheckFlags JNZ %L(CONT) MOV STAV,#INIT_POSITION %BREAK %L(CONT): %CJE(A,FLAGS_OLD,%L(CONT1)) MOV STAV,#SFLAGS %BREAK %L(CONT1): ;*********************************************************************** ; POROVNEJ POCITADLO ZNAKU S CELKOVOU DELKOU ZOBRAZOVANEHO RETEZCE MOV A,STR_PTR %CMP(A,STR_LEN) JNC %L(00) ; JESTE NEJSI NA KONCI RETEZCE ; ZOBRAZUJES NA VYSKU? JB ROTATEDISP,%L(__00) ; ZOBRAZUJES VODOROVNE MOV A,BMPCNT ; KOLIK MAS ZOBRAZENYCH BITMAP? JZ %L(LONGTXT) ; ZADNOU - BUDES VYPISOVAT PO CELE DELCE MOV A,BMPCNT ; KOLIK MAS ZOBRAZENYCH BITMAP? XRL A,#2 ; MAS OBE DVE NASTAVENE - BUDES TAKY VYPISOVAT PO CELE DELCE JZ %L(LONGTXT) ; MAS POUZE JEDNU - BUDES PSAT JEN NA LEVOU PULKU MOV A,#64 SETB C SUBB A,SHIFT_NXTCH CJNE A,TEXT_SCROLL,%L(00) ; ZJISTI, JESTLI SES NEDOSTAL S POZICI ZA DANOU HRANICI SJMP %L(_00) ; ANO DOSTAL - 1 ZNAK JSEM VYSKROLOVAL - PRIDAM DALSI %L(LONGTXT): %L(__00): MOV A,#0 SETB C SUBB A,SHIFT_NXTCH CJNE A,TEXT_SCROLL,%L(00) %L(_00): INC STR_PTR ; 1 ZNAK JE MIMO ZOBRAZOVANOU PLOCHU - DOPLN NA KONCI ZOBRAZOVANEHO RETEZCE DALSIM MOV A,TEXT_SCROLL ADD A,SHIFT_NXTCH ; POSUN UKAZATEL V TEXTU ZPET KVULI PREDCHOZIMU ZNAKU MOV TEXT_SCROLL,A %L(00): MOV TEMP,STR_PTR ; ULOZ POZICI V RETEZCI MOV A,STR_PTR %CMP(A,STR_LEN) JC %L(DO0) %L(DO_END): MOV STAV,#ROLL_TEXT ;*********************************************************************** JNB FIRE,%L(BREAK) ; KDYZ DOROLUJES POZARNI JIZDU - PREPNI NA ZOBRAZENI POLOHY MOV STAV,#INIT_POSITION MOV FPSCNT,#nbrSTime %L(BREAK): %BREAK ;*********************************************************************** %L(DO0): MOV R4,#0 MOV R3,#0 MOV DPTR,#(' '-32)*OFFSET+BASE MOV A,TEMP %CMP(A,STR_LEN) JNC %L(DO0_) MOV DPL,ADDR_LO MOV DPH,ADDR_HI MOV R0,TEMP CALL ParGetParmRaw ; V ACC VRACI HODNOTU ZNAKU, V R0 VRACI "EOF" ;MOV B,R0 MOV R4,#0 MOV R3,#0 MOV DPTR,#(' '-32)*OFFSET+BASE %CJE(A,#128,%L(DO0_)) CALL GET_TRANS_CHAR ; PREVED OBSAH ACC NA ZOBRAZITELNE ZNAKY MOV R2,#7 ; NASTAV STRANKU ADD A,#-32 PUSH ACC MOV B,#OFFSET ; V Acc MAS HODNOTU ZNAKU MUL AB ; BUDES NASOBIT HODNOTOU OFFSETU (DELKA DANEHO ZNAKU V BAJTECH) ADD A,#LOW(BASE) MOV DPL,A MOV A,B ADDC A,#HIGH(BASE) MOV DPH,A POP ACC %CJE(A,#(' '-32),%L(NO_)) %CJE(A,#('!'-32),%L(NO_)) CALL GET_CHAR_DUMMYPIX %L(NO_): %L(DO0_): ; TADY SE RESI MEZERY MEZI JEDNOTLIVYMI ZNAKY MOV A,TEXT_SCROLL ADD A,AKTUAL_POS PUSH ACC MOV A,AKTUAL_POS ADD A,#16 ; SIRKA ZNAKU CLR C SUBB A,R4 SUBB A,R3 MOV AKTUAL_POS,A ; ZJISTI, JESTLI MAS VYPOCITAT NOVOU KONSTANTU PRO INKREMENTACI STR_PTR MOV A,TEMP CJNE A,STR_PTR,%L(NXT1) MOV SHIFT_NXTCH,AKTUAL_POS %L(NXT1): ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MOV B,R4 MOV R0,B MOV B,R3 MOV R1,B ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; POP ACC MOV R5,#RES_Y ; SET RESOLUTION MOV R4,#RES_X JNB ROTATEDISP,%L(DO0__) CLR C SUBB A,R3 MOV R7,A ; ZATIM PIS NA NULTY RADEK ; VE VYSLEDNE FUNKCI TADY BUDE JINA STRANKA MOV A,TEMP XRL A,#2 ADD A,#-1 %L(RES0): ;*********************************************************************** ;TESTUJ NA POCET ZOBRAZENYCH BITMAP A PODLE TOHO NASTAV SOURADNICE TEXTU MOV R6,#63 ; POKUD NENI ZADNA BITMAPA MOV A,BMPCNT JZ %L(01) MOV R6,#23 ; POKUD JSOU OBE DVE BITMAPY ZOBRAZENE %L(01): CALL SHOWBMPWND2ROT_ SJMP %L(CONTINUE) %L(DO0__): MOV R6,A ; ULOZ DO PRACOVNIHO REGISTRU ;*********************************************************************** ;TESTUJ NA POCET ZOBRAZENYCH BITMAP A PODLE TOHO NASTAV SOURADNICE TEXTU MOV R7,#16 ; POKUD NENI ZADNA BITMAPA MOV A,BMPCNT JZ %L(001) CLR DENNY_CS1 SETB DENNY_CS2 XRL A,#1 JZ %L(001) ; POKUD JE ZOBRAZENA JEDNA BITMAPA MOV R7,#40 ; POKUD JSOU OBE DVE BITMAPY ZOBRAZENE SETB DENNY_CS1 SETB DENNY_CS2 %L(001): ; VE VYSLEDNE FUNKCI TADY BUDE JINA STRANKA CALL SHOWBMPWND2_ %L(CONTINUE): MOV B,#64 JB ROTATEDISP,%L(000) ; DLE PRIZNAKU OTOCENI DISPLEJE PORES VYPISOVANY POCET ZNAKU MOV B,#128 %L(000): ; IKDYZ MAS TREBA ZOBRAZENE 2 BITMAPY, ALE POKUD ZACINAS CHOVEJ SE STEJNE, JAKO BYS MEL POUZE JEDINOU - ; JE TO KVULI DELSIM RETEZCUM - PROSTE TO PRESAHOVALO DO ZACATKU DISPLEJE -> AZ DO URCITE POZICE BUDU VYPISOVAT POUZE OMEZENY POCET ZNAKU INC TEMP MOV A,AKTUAL_POS ADD A,TEXT_SCROLL %CMP(A,B) JNC %L(DO1) JMP %L(DO0) %L(DO1): DEC TEXT_SCROLL ; ZARID POSUN %L(END): %IF(%DEBUG NE 0)THEN ( %STAVDEF() MOV R0,#KEYS+valKeyMode CALL KeyGet JNC %L(K1) DEC STAV %PRINTINT(#70,#0,#3,TEXT_SCROLL,1) %PRINTINT(#70,#1,#3,STR_PTR,1) ;PRINTINT(#70,#2,#3,TEMP5,1) %L(K1): )FI %ENDSTAV %IF(0)THEN ( ;******************************************************************** ; ZDE SE ULOZI PRICHOZI PARAMETR ;******************************************************************** %STAVDEF(SAVE_PARMS) CALL CLR_LCD ; SMAZ LCD %PRINT(#0,#0,'> PARAM',SPARM_TXT) %PRINTLINE(#0,#1) ;PRINT(#0,#2,'ADDR0=',ADDR_TXT1) %PRINT(#0,#2,'ADR=',ADDR_TXT2) %PRINT(#0,#3,'VAL=',VAL_TXT) %STAVDEF() JNB PARM_RCVD,%L(END) CLR PARM_RCVD ; TED ULOZ PARAMETR MOV R0,#RCVBUFF+1 MOV A,@R0 INC R0 MOV B,@R0 MOV R1,A MOV R0,#0;RCVBUFF+1 CALL DirectPutParm ;MOV R0,#RCVBUFF+1 ;MOV A,@R0 ;PRINTINT(#36,#2,#3,A,0) MOV R0,#RCVBUFF+1 MOV A,@R0 %PRINTINT(#24,#2,#3,A,0) MOV R0,#RCVBUFF+2 MOV A,@R0 %PRINTINT(#24,#3,#3,A,0) %L(END): MOV A,SERTIM JNZ %L(END_) JMP RESET %L(END_): %ENDSTAV )FI ;******************************************************************** ; SMAZ CELOU FLASH ;******************************************************************** %STAVDEF(ERASE_FLASH) CALL CLR_LCD CLR HDR_RCVD ; MUZES ZNOVU DEKODOVAT HLAVICKY MOV R0,#HEADER+1 MOV A,@R0 INC R0 ORL A,@R0 JNZ %L(KX) %PRINT(#0,#5,'D_FLASH',ERASE_LBL) CALL FLASH_ERASE ; ODESLI ZPRAVU MOV DPTR,#ERASEOK_MSG CALL SEND_DATA %L(KX): MOV STAV,#DUMMY_STATE %ENDSTAV ;******************************************************************** ; SMAZ VYBRANY SEKTOR VE FLASH ;******************************************************************** %STAVDEF(ERASE_SECTOR) CALL CLR_LCD CLR HDR_RCVD ; MUZES ZNOVU DEKODOVAT HLAVICKY MOV R0,#HEADER+1 MOV A,@R0 JNZ %L(KX) MOV R0,#HEADER+2 MOV A,@R0 %PRINTINT(#45,#5,#1,A,0) %PRINT(#0,#5,'D_SEC',ERASESEC_LBL) MOV R0,#HEADER+2 MOV A,@R0 CALL FLASH_ERASE_SEC ; V Cy VRACI, JESTLI MAZANI PROBEHLO USPESNE NEBO NE ; ODESLI ZPRAVU MOV DPTR,#ERASESECOK_MSG CALL SEND_DATA %L(KX): MOV STAV,#DUMMY_STATE MOV PCKGCNT_LO,#0 MOV PCKGCNT_HI,#0 %ENDSTAV ;******************************************************************** ; ZAPIS PRIJIMANE DATA DO FLASH ;******************************************************************** CRC8_2 EQU MENUPTR3 %STAVDEF(PROGRAM_FLASH) %PRINT(#0,#5,'>',DATAIN_TXT) MOV SHIFTCNT1,#200 MOV DATACNT,#0 MOV CRC8,#0 MOV CRC8_2,#0 %STAVDEF(PROGRAM_FLASH1) CALL POP_DATA JC %L(KX) MOV R3,A ; TED NACTI DATA ; POCITEJ PRUBEZNE CRC8 MOV B,CRC8 CALL CALCCRC8 MOV CRC8,B ; ZAPIS DATA MOV DPL,DATACNT MOV R0,#HEADER+1 MOV DPH,@R0 INC R0 MOV A,@R0 ; TED NACTI STRANKU MOV R2,A CALL FLASH_BYTEWR ; ZAPIS DO FLASH ; PROVED ZPETNE CTENI MOV DPL,DATACNT MOV R0,#HEADER+1 MOV DPH,@R0 INC R0 MOV A,@R0 ; TED NACTI STRANKU MOV R2,A CALL FLASH_BYTERD ; PRECTI Z FLASH ; POCITEJ PRUBEZNE CRC8 - V Acc MAS DATA NACTENA Z FLASH MOV B,CRC8_2 CALL CALCCRC8 MOV CRC8_2,B MOV SHIFTCNT1,#200 ; RESET TIMEOUT INC DATACNT MOV A,DATACNT JNZ %L(END) MOV TEMP4,#HIGH(DATAWROK_MSG) MOV TEMP5,#LOW(DATAWROK_MSG) MOV STAV,#SEND_ACK SJMP %L(END_) %L(KX): %L(END): %IF(%NO_COMPILE EQ 1)THEN ( ; TIMEOUT MOV A,SHIFTCNT1 JNZ %L(END_) ; ODESLI ZPRAVU MOV DPTR,#TIMEOUT_MSG CALL SEND_DATA CLR HDR_RCVD ; POVOL CTENI A ZPRACOVANI HLAVICEK MOV STAV,#DUMMY_STATE )FI %L(END_): %ENDSTAV %IF(%DEBUG NE 0)THEN ( ERR: %STAVDEF(ERR_) %PRINT(#0,#0,'BUFFER OVERFLOW',OV_ERR_TXT) %STAVDEF() %ENDSTAV )FI %STAVDEF(SEND_ACK) CALL BARGRAPH_DRAW %STAVDEF() CALL POP_DATA JC %L(END) ; JSOU DATA? PUSH ACC XRL A,CRC8 CLR C ADD A,#-1 ; V Cy MAS PRIZNAK TOHO, JESTLI JSOU DATA V PORADKU NEBO NECO NESEDI ; POKUD Cy=1,TAK ERROR MOV F0,C ; ULOZ PRIZNAK POP ACC ; ZJISTI JESTE,JESTLI TI CRC8 ZE ZPETNE PRECTENYCH DAT Z FLASH XRL A,CRC8_2 CLR C ADD A,#-1 ; V Cy MAS PRIZNAK TOHO, JESTLI JSOU DATA V PORADKU NEBO NECO NESEDI ; POKUD Cy=1,TAK ERROR ORL C,F0 ; ODESLI ZPRAVU %IF(0)THEN ( MOV DPTR,#DATAWRER_MSG JC %L(00) MOV DPTR,#DATAWROK_MSG %L(00): )ELSE ( MOV DPL,TEMP5 MOV DPH,TEMP4 JNC %L(00) ; POSUN SE NA CHYBOVOU ZPRAVU INC DPTR INC DPTR INC DPTR %L(00): )FI CALL SEND_DATA MOV STAV,#DUMMY_STATE CLR HDR_RCVD ; POVOL CTENI A ZPRACOVANI HLAVICEK %L(END): MOV A,SHIFTCNT1 JNZ %L(END0) CLR HDR_RCVD ; POVOL CTENI A ZPRACOVANI HLAVICEK MOV STAV,#INIT_POSITION %L(END0): %ENDSTAV BARGRAPH_DRAW: MOV A,PCKGCNT_LO MOV B,#128 DIV AB XCH A,B CALL SET_COLUMN MOV A,PCKGCNT_LO MOV B,#128 DIV AB PUSH ACC MOV A,PCKGCNT_HI MOV B,#128 DIV AB POP B ADD A,B CALL SET_PAGE MOV A,#0FFh CALL SENDLCDDATA ; iNDIKUJ JEN NA 1. POLOVINU MOV DPL,PCKGCNT_LO MOV DPH,PCKGCNT_HI INC DPTR MOV PCKGCNT_LO,DPL MOV PCKGCNT_HI,DPH RET ;******************************************************************** ; ZDE SE ODESLE 256 BAJTU Z FLASH ;******************************************************************** %STAVDEF(SEND_FLASH) MOV A,PCKGCNT_LO ORL A,PCKGCNT_HI JNZ %L(NO_CLR) CALL CLR_LCD %L(NO_CLR): %PRINT(#0,#5,'<',DATAOUT_TXT) MOV DATACNT,#0 MOV CRC8,#0 MOV A,#0 CALL SET_COLUMN MOV A,#0 CALL SET_PAGE ; POSLI ZPRAVU MOV DPTR,#DATARDOK_MSG CALL SEND_DATA JB WRITE,$ ; DOKUD ZAPISUJES,NIC NEODESILEJ MOV CRC8,#0 %STAVDEF() ; VSTUP: DPTR - DOLNICH 16 bitu adresy ; R2 - A18_A17_A16xxxxx - zbyle tri bity adresy MOV DPL,DATACNT MOV R0,#HEADER+1 MOV DPH,@R0 INC R0 MOV A,@R0 MOV R2,A CALL FLASH_BYTERD CALL SEND_BYTE2 INC DATACNT MOV A,DATACNT MOV B,#64 DIV AB SETB CS1 CLR CS2 CALL SET_PAGE %IF(%NO_COMPILE EQ 1)THEN ( MOV A,B MOV B,#2 DIV AB XCH A,B CALL SENDLCDDATA ; iNDIKUJ JEN NA 1. POLOVINU )FI MOV A,DATACNT JNZ %L(END) ; ODESLAL JSI POSLEDNI BAJT - POVOL OPET CTENI A VRAT SE DO DEFAULTNIHO STAVU MOV A,CRC8 CALL SEND_BYTE2 CLR HDR_RCVD MOV STAV,#DUMMY_STATE;INIT_POSITION CALL BARGRAPH_DRAW %L(END): %ENDSTAV %STAVDEF(DUMMY_STATE) MOV SHIFTCNT1,#200 ; 2 SEKUNDY POCKEJ, NEZ PREJDES DO STAVU INIT_POSITION MOV RETSTAV,#INIT_POSITION %STAVDEF(WAIT) MOV A,SHIFTCNT1 JNZ %L(END) MOV STAV,RETSTAV ; VRAT SE ZPET DO ZADANEHO STAVU MOV PCKGCNT_LO,#0 MOV PCKGCNT_HI,#0 %L(END): %ENDSTAV ;******************************************************************** ; JEDNA SE "NULOVOU" ZPRAVU? ;******************************************************************** ZERO_MSG: MOV R0,#HEADER+1 MOV A,@R0 INC R0 ORL A,@R0 RET ; CEKACI STAV PING_MSG: DB 06, 'O', 'K' RESTART_MSG: DB 10, 'O', 'K' VERSION_MSG: DB 07, 'O', 'K' VERSION_ERR: DB 07, 'E', 'R' %IF(%NO_COMPILE EQ 1)THEN ( TIMEOUT_MSG: DB 05, 'T', 'M' )FI ERASEOK_MSG: DB 02, 'O', 'K' ERASESECOK_MSG: DB 03, 'O', 'K' ERASESECER_MSG: DB 03, 'E', 'R' DATAWROK_MSG: DB 01, 'O', 'K' DATAWRER_MSG: DB 01, 'E', 'R' DATARDOK_MSG: DB 04, 'O', 'K' EEPROMRDOK_MSG: DB 09, 'O', 'K' EEPROMWROK_MSG: DB 08, 'O', 'K' EEPROMWRER_MSG: DB 08, 'E', 'R' ;******************************************************************** ; ZAPIS PRIJIMANE DATA DO EEPROM ;******************************************************************** %STAVDEF(WRITE_E2ROM) CALL CLR_LCD ; SMAZ LCD %PRINT(#0,#0,'>PAR',SPARM_TXT) MOV SHIFTCNT1,#200 MOV DATACNT,#0 MOV CRC8,#0 %STAVDEF(WRITE_E2ROM1) CALL POP_DATA JC %L(END) MOV R3,A ; TED NACTI DATA ; POCITEJ PRUBEZNE CRC8 MOV B,CRC8 CALL CALCCRC8 MOV CRC8,B MOV CRC8_2,B ; ZAPIS DATA MOV R1,#HEADER+1 MOV A,@R1 MOV B,#16 MUL AB ; STRANKUJES PO 16BAJTECH ADD A,DATACNT MOV R1,A ; PRICTI OFFSET MOV R0,#0 MOV B,R3 CALL DirectPutParm ; ZAPIS DATA DO EEPROM ;CLR TI ;MOV SBUF,A ;JNB TI,$ ;CLR TI MOV SHIFTCNT1,#200 ; RESET TIMEOUT INC DATACNT MOV A,DATACNT CJNE A,#16,%L(END) ;JNZ %L(END) MOV TEMP4,#HIGH(EEPROMWROK_MSG) MOV TEMP5,#LOW(EEPROMWROK_MSG) MOV STAV,#SEND_ACK SJMP %L(END_) %L(END): ;MOV A,SHIFTCNT1 ;JNZ %L(END_) ;CLR HDR_RCVD ; POVOL CTENI A ZPRACOVANI HLAVICEK ;MOV STAV,#INIT_POSITION %L(END_): %ENDSTAV ;******************************************************************** ; ZAPIS PRIJIMANE DATA DO EEPROM ;******************************************************************** %STAVDEF(READ_E2ROM) CALL CLR_LCD %PRINT(#0,#0,' POKUD A <> R0; F0 = 0 -> POKUD A = R0 ;******************************************************************************* SET_F0_IF_DIFF: SETB F0 ; PREDPOKLADEJ, ZE SE HODNOTY NEROVNAJI - V TOM PRIPADE VYPIS INVERTOVANE XRL A,R0 JNZ %L(_01) CLR F0 ; HODNOTY SE ROVNAJI - VYPIS NORMALNE %L(_01): RET STAN_HDR: DB 124+32,'S ',125+32,'= ',0 ;--------------------------- NASTAVENI CISELNYCH HODNOT SKUPINOVEHO PARAMETRU (ZATIM POUZE P04) --------------- %STAVDEF(MENUSET_STBYTES) %PUTCH(#42,#2,#' ',0) %PUTCH(#78,#2,#' ',0) %PRINT(#12,#4,#STAN_HDR,0) MOV R1,#0 MOV R2,#30 MOV R0,#MENUPTR2 CALL INC_PARM_VAL %STAVDEF(MENUSET_STBYTES2) %PRINTINT(#24,#4,#2,MENUPTR2,0) %PRINTINT(#55,#4,#3,MENUPTR3,0) MOV A,MENUPTR MOV R0,MENUPTR2 CALL GET_PARM_VAL ; VRACI ADRESU PARAMETRU MOV MENUPTR3,A MOV R1,#0 ; MIN. HODNOTA = 0 MOV R2,#30 ; MAX. HODNOTA = 30 (ROZSAH STANIC 0 - 30; HODNOTA 31 JE PRIRAZENA PRO NEZNAME PATRO) CALL KeyGetFirst CJNE A,#(valKeyNShort+valKeyUp),%L(K1) ; STISK TLACITKA UP MOV R0,#MENUPTR2 CALL INC_PARM_VAL SJMP %L(KX) %L(K1): CJNE A,#(valKeyNShort+valKeyDn),%L(K2) ; STISK TLACITKA DN MOV R0,#MENUPTR2 CALL DEC_PARM_VAL SJMP %L(KX) %L(K2): CJNE A,#(valKeyNShort+valKeyMode),%L(K3) ; STISK TLACITKA MODE MOV RETSTAV,#MENUSET_STBYTES MOV STAV,#MENUSET_BYTE %PUTCH(#12,#4,#' ',0) %PUTCH(#36,#4,#' ',0) SJMP %L(END) %L(K3): CJNE A,#(valKeyNLong+valKeyMode),%L(KX) ; ESC MOV STAV,#MENUSET_ ; VRAT SE ZPET NA HLAVNI MENU %PRINTCLEARLINE(#0,#4) SJMP %L(END) %L(KX): MOV STAV,#MENUSET_STBYTES2 %L(END): %ENDSTAV ; TAHLE FUNKCE PROSTE JEN VYTVORI SPECIFICKE MENU - POUZIVAM DVAKRAT V RUZNYCH STAVECH - TAK AT USETRIM TROCHU PROG.FLASH ; VSTUP: ACC: .... POCET PRVKU MAKE_BMP_MENU: ADD A,#2 ; PRIPOCTI 1 KVULI HLAVICCE A PRVNIMU SEPARATORU MOV TEMP,A %PRINTLINE(#0,A) %PRINTLINE(#0,#1) %PUTCH(#17,#0,#' ',1) %PUTCH(#23,#0,#'P',1) %PUTCH(#41,#0,#' ',1) MOV A,MENUPTR CALL GETMENU00 ; V Acc VRACI HODNOTU PARAMETRU %PRINTINT(#29,#0,#2,A,1) ; ZOBRAZ INVERZNE NAPIS PARAMETRU %PUTCH(#0,#2,#124+32,0) %PRINT(#6,#2,'BMP =',BMP_TITLE) %PUTCH(#54,#2,#125+32,0) MOV A,#2 MOV MENUPTR2,#0 MOV MENUPTR3,#0 %L(CYKL): PUSH ACC %PRINT(#6,A,#BMP_TITLE,0) POP ACC PUSH ACC MOV B,A CLR C SUBB A,#1 %PRINTINT(#24,B,#1,A,0) ; ZOBRAZ INVERZNE NAPIS PARAMETRU MOV A,MENUPTR MOV R0,MENUPTR2 CALL GET_PARM_VAL POP B PUSH B %PRINTINT(#36,B,#3,A,0) POP ACC INC A INC MENUPTR2 %CMP(A,TEMP) JC %L(CYKL) SETB CS2 CLR CS1 CALL CLR_LCD_ ; SMAZ PRAVOU POLOVINU - TAM BUDES VYKRESLOVAT BITMAPY MOV MENUPTR2,#0 MOV MENUPTR3,#0 RET SET_MENU_VAL: MOV A,MENUPTR MOV R0,MENUPTR2 CALL GET_PARM_VAL MOV MENUPTR3,A MOV A,MENUPTR2 ADD A,#2 MOV B,A %PRINTINT(#36,A,#3,MENUPTR3,0) RET %RESLOCAL SET_FOCUS_CHARS: MOV TEMP,B ; ULOZ POCET PRVKU MENU MOV A,MENUPTR2 ; UKAZATEL NA PRVEK MENU MOV B,#2 ; ZAKLADNI RADEK ; POKUD ACC=0, TAK NIC NEDELEJ JZ %L(END) ; NASTAV AKTUALNI UKAZATEL NA NOVOU HODNOTU MOV A,MENUPTR2 ADD A,#2 PUSH ACC %PUTCH(#0,A,#124+32,0) POP ACC PUSH ACC %PUTCH(#54,A,#125+32,0) POP ACC DEC A PUSH ACC ; SMAZ VSECHNY UKAZATELE NA HODNOTU, POKUD MAS NEJAKE %PUTCH(#54,A,#' ',0) POP ACC %PUTCH(#0,A,#' ',0) %L(END): RET ; VSTUP: V ACC POCET PRVKU MENU SHIFT_MENU_VAL: MOV TEMP,A MOV A,MENUPTR MOV R0,MENUPTR2 CALL GET_PARM_VAL PUSH ACC ; VYPOCITEJ, KAM ZAPISES HODNOTU MOV B,TEMP CALL SET_FOCUS_CHARS MOV A,MENUPTR2 ADD A,#2 MOV B,A POP ACC ; ZJISTI, JESTLI SE HODNOTY LISI MOV R0,MENUPTR3 CALL SET_F0_IF_DIFF MOV R1,#36 ; SOURADNICE X MOV R7,B ; SOURADNICE Y MOV R6,#3 ; POCET DIGITU MOV A,MENUPTR3 ; VLASTNI HODNOTA CALL _PRINT_INT ; A VYPIS NA DISPLEJ RET %RESLOCAL DRAW_PARM_BITMAP: ; === POKUD JSI NA MAXIMU, NIC NEZOBRAZUJ! MOV A,MENUPTR MOV R0,MENUPTR2 CALL GET_PARM_VAL MOV A,MENUPTR3 %CJE(A, AR2, %L(CLEAR_)) CLR C ADD A,ACC ; ADRESA V Acc*2 = DELKA BITMAPY 256 BAJTU JNC %L(DRAW) %L(CLEAR_): ; JSI MIMO - NEMAS NIC KRESLIT SETB CS2 CLR CS1 CALL CLR_LCD_ ; SMAZ PRAVOU POLOVINU - TAM BUDES VYKRESLOVAT BITMAPY SJMP %L(_END) %L(DRAW): MOV DPL,#0 MOV DPH,A MOV A,R3 ;SWAP A ;RL A MOV R2,A MOV R7,#0 MOV R6,#64;MENUPTR2;#36 MOV R5,#64 MOV R4,#64 CALL SHOWBMPWND2 %L(_END): RET ;--------------------------- NASTAVENI A VYBER BITMAP --------------- %STAVDEF(MENUSET_BMPTXT) %PRINT(#14,#5,'*TEXT*',TXT_TITLE) %PRINT(#23,#6,#DONT_SHOW,0) %STAVDEF(MENUSET_BMP) MOV A,TEMP4 CALL MAKE_BMP_MENU %STAVDEF(MENUSET_BMP1_) CALL SET_MENU_VAL %STAVDEF(MENUSET_BMP1) MOV A,TEMP4 CALL SHIFT_MENU_VAL CALL DRAW_PARM_BITMAP %STAVDEF() MOV A,MENUPTR MOV R0,MENUPTR2 CALL GET_PARM_VAL ; VRACI: V R1 MIN. HODNOTU, V R2 MAX. HODNOTU ; OBSLUHA TLACITEK UP A DN MOV TEMP,STAV ; ULOZ AKTUALNI STAV DO TEMPU MOV STAV,#MENUSET_BMP1 ; POKUD JE STISKLE TLACITKO, MEL BY SE AUTOMAT VRATIT DO TOHOTO STAVU CALL HANDLE_UD_KEYS MOV STAV,TEMP ; KLASICKA OBSLUHA TLACITEK %L(K2): CALL KeyGetFirst CJNE A,#(valKeyNShort+valKeyMode),%L(K3) ; STISK TLACITKA MODE MOV A,MENUPTR CALL GETMENU00 MOV DPH,R1 MOV DPL,R2 MOV R0,MENUPTR2 MOV A,MENUPTR3 CALL ParPutParm INC MENUPTR2 MOV SHIFTCNT1,#10 MOV STAV,#WAIT MOV RETSTAV,#MENUSET_BMP1_ ; VRAT SE ZPET NA HLAVNI MENU MOV A,MENUPTR2 %CMP(A,TEMP4) JC %L(END) ; POKUD ZOBRAZUJES VIC JAK 2 BITMAPY, TAK UZ NEMAS MISTO NA TEXTY - CILI SKONCI %CMP(A,#3) JNC %L(RET0) MOV MENUPTR2,#2 ; ASI EDITUJES 2BMP + TEXT -> PREJDI DO STAVU EDITACE TEXTU MOV RETSTAV,#MENUSET_TXT ; PREJDI DO STAVU EDITACE TEXTU SETB CS2 CLR CS1 CALL CLR_LCD_ SJMP %L(END) %L(K3): CJNE A,#(valKeyNLong+valKeyMode),%L(END) ; ESC %L(RET0): MOV STAV,#MENUSET_ ; VRAT SE ZPET NA HLAVNI MENU CALL CLR_LCD SJMP %L(END) %L(KX): MOV STAV,#MENUSET_BMP1 %L(END): %ENDSTAV %STAVDEF(MENUSET_TXT) %PUTCH(#0,#3,#' ',0) ; SMAZ SIPKY U PREDCHOZIHO PARAMETRU %PUTCH(#54,#3,#' ',0) %PRINTCLEARLINE(#0,#6) ; VYMAZ RADEK PRED TIM, NEZ TAM BUDES ZOBRAZOVAT TEXT ;INC MENUPTR2 ; POSUN SE NA DALSI BAJT PARAMETRU SETB CS2 CLR CS1 CALL CLR_LCD_ ; SMAZ PRAVOU POLOVINU - TAM BUDES VYKRESLOVAT BITMAPY %STAVDEF(MENUSET_TXT1) MOV MENUPTR4,MENUPTR2 %L(CYKL): MOV R0,MENUPTR4 MOV A,MENUPTR CALL GET_PARM_VAL_RAW ; VRACI: V R1 MIN. HODNOTU, V R2 MAX. HODNOTU PUSH ACC ; ZALOHUJ NACTENOU HODNOTU Z PARAMETRU MOV A,MENUPTR4 ; VYPOCITEJ OFFSET ZOBRAZENI PISMENA ADD A,#-2 ; ODECTI HODNOTU 2 MOV B,#6 MUL AB XCH A,B ; V B MAS AKTUALNI X-OVE SOURADNICE PRO ZOBR. AKT. ZNAKU POP ACC PUSH ACC CALL GET_TRANS_CHAR ; PREVED NA ZOBRAZITELNE ZNAKY ;ADD A,#32 %PUTCH(B,#6,A,0) POP ACC %CJE(A,#128,%L(NXT_STATE)) ; ZJISTI,JESTLI NEVRACIS ZNAK "EOF" INC MENUPTR4 MOV A,MENUPTR4 %CMP(A,#23) JC %L(CYKL) %L(NXT_STATE): MOV A,MENUPTR2 ; VYPOCITEJ OFFSET ZOBRAZENI PISMENA ADD A,#-2 ; ODECTI HODNOTU 2 MOV B,#6 MUL AB MOV MENUPTR4,A MOV R0,MENUPTR2 MOV A,MENUPTR CALL GET_PARM_VAL_RAW ; VRACI: V R1 MIN. HODNOTU, V R2 MAX. HODNOTU MOV MENUPTR3,A %STAVDEF() ; BLIKEJ KURZOREM MOV A,SYSTIMH ANL A,#04h JZ %L(KURZOR) MOV A,#' ' SJMP %L(_KURZOR) %L(KURZOR): MOV A,#126+32 %L(_KURZOR): %PUTCH(MENUPTR4,#7,A,0) MOV R0,MENUPTR2 MOV A,MENUPTR CALL GET_PARM_VAL_RAW ; VRACI: V R1 MIN. HODNOTU, V R2 MAX. HODNOTU ; ZJISTI, JESTLI SE HODNOTY LISI MOV R0,MENUPTR3 CALL SET_F0_IF_DIFF MOV A,MENUPTR3 ; VLASTNI HODNOTA CALL GET_TRANS_CHAR ; PREVED NA ZOBRAZITELNE ZNAKY PUSH ACC MOV R1,MENUPTR4 ; SOURADNICE X MOV R7,#6 ; SOURADNICE Y ;ADD A,#32 MOV R0,A CALL _PUTCHAR ; ZOBRAZ NAHLED VYBRANEHO ZNAKU POP ACC ADD A,#-32 MOV B,#OFFSET ; V Acc MAS HODNOTU ZNAKU MUL AB ; BUDES NASOBIT HODNOTOU OFFSETU (DELKA DANEHO ZNAKU V BAJTECH) ADD A,#LOW(BASE) MOV DPL,A MOV A,B ADDC A,#HIGH(BASE) MOV DPH,A MOV R2,#7 MOV R7,#16 MOV R6,#96 MOV R5,#24 MOV R4,#16 CALL SHOWBMPWND2 %L(DIFF_): MOV R1,#29 ; NASTAV MINIMUM NA PRVNI ZOBRAZITELNY ZNAK Z ASCII ;MOV R1,#0 MOV R2,#128 ; OBSLUHA TLACITEK UP A DN CALL HANDLE_UD_KEYS ; KLASICKA OBSLUHA TLACITEK %L(K2): CALL KeyGetFirst CJNE A,#(valKeyNShort+valKeyMode),%L(K5) ; STISK TLACITKA MODE ; REFRESH POSLEDNIHO ZOBRAZENEHO ZNAKU + SMAZANI KURZORU MOV B,MENUPTR4 MOV A,MENUPTR3 CALL GET_TRANS_CHAR ; PREVED NA ZOBRAZITELNE ZNAKY ;ADD A,#32 %PUTCH(B,#6,A,0) MOV B,MENUPTR4 %PUTCH(B,#7,#' ',0) MOV A,MENUPTR CALL GETMENU00 MOV DPH,R1 MOV DPL,R2 MOV R0,MENUPTR2 MOV A,MENUPTR3 CALL ParPutParm MOV A,MENUPTR4 ADD A,#6 MOV MENUPTR4,A INC MENUPTR2 MOV SHIFTCNT1,#10 MOV STAV,#WAIT MOV A,MENUPTR3 %CJE(A,#128,%L(K2_)) ; TESTUJ NA UKONCOVACI ZNAK MOV A,MENUPTR2 %CJE(A,#23,%L(K2_)) ; TESTUJ NA MAXIMALNI DELKU RETEZCE MOV RETSTAV,#MENUSET_TXT1 ; VRAT SE ZPET NA POCATECNI STAV MENUSET_TXT SJMP %L(END) %L(K2_): CALL CLR_LCD MOV RETSTAV,#MENUSET_ ; VRAT SE ZPET NA HLAVNI MENU SJMP %L(END) %L(K5): CJNE A,#(valKeyNLong+valKeyMode),%L(KX) ; ESC MOV STAV,#MENUSET_ ; VRAT SE ZPET NA HLAVNI MENU CALL CLR_LCD %L(KX): %L(END): %ENDSTAV %RESLOCAL ; ABYCH USETRIL PAMET PROGRAMU, TAK TADY MAM SPOLECNE OVLADANI TLACITEK U A D V MENU HANDLE_UD_KEYS: MOV R0,#KEYS+valKeyUP MOV A,@R0 ;MOV C,ACC.bitKeyPress ;JNC %L(K1) JNB ACC.bitKeyPress,%L(K1) ; DLOUHY STISK TLACITKA UP MOV R0,#MENUPTR3 CALL INC_PARM_VAL SJMP %L(DELAY) %L(K1): MOV R0,#KEYS+valKeyDN MOV A,@R0 ;MOV C,ACC.bitKeyPress ;JNC %L(END_H) JNB ACC.bitKeyPress,%L(END_H) ; DLOUHY STISK TLACITKA DN MOV R0,#MENUPTR3 CALL DEC_PARM_VAL %L(DELAY): POP DPL ; UVOLNI NAVRATOVOU ADRESU ZE ZASOBNIKU - UZ JI NEPOTREBUJES POP DPH MOV SHIFTCNT1,#10 ; KVULI RYCHLOSTI INKREMENTACE A DEKREMENTACE ZNAKU CHVILI POCKEJ MOV RETSTAV,STAV ; VRAT SE ZPET NA POCATECNI STAV MENUSET_TXT MOV STAV,#WAIT ;JMP MainStavExit JMP MainLoop %L(END_H): RET LCD2 EQU 64 ;-------- NASTAVENI A VYBER BITMAP PRO JEDNOTLIVE STANICE ----------- %STAVDEF(MENUSET_STBMP) %PRINTLINE(#0,#2) %PUTCH(#17,#1,#' ',1) %PUTCH(#23,#1,#'P',1) %PUTCH(#41,#1,#' ',1) MOV A,MENUPTR CALL GETMENU00 ; V Acc VRACI HODNOTU PARAMETRU %PRINTINT(#29,#1,#2,A,1) ; ZOBRAZ INVERZNE NAPIS PARAMETRU %PRINTLINE(#0,#4) %PUTCH(#17,#3,#124+32,0) %PUTCH(#23,#3,#'S',0) %PUTCH(#41,#3,#125+32,0) %L(_END): SETB CS2 CLR CS1 CALL CLR_LCD_ ; SMAZ PRAVOU POLOVINU - TAM BUDES VYKRESLOVAT BITMAPY %STAVDEF(MENUSET_STBMP2) MOV A,MENUPTR2 MOV B,#0 SETB TEMPBIT2 CALL SHOW_POSITION MOV R1,#29 MOV R7,#3 CLR F0 MOV A,MENUPTR2 JZ %L(CHAR) ; === PRI OSTATNICH STANICICH UKAZ CISLO MOV R6,#2 DEC A CALL _PRINT_INT SJMP %L(_CHAR) %L(CHAR): ; === PRI NEZNAMEM PATRE ZOBRAZ POUZE '??' MOV R0,#'?' CLR F0 CALL _PUTCHAR MOV R0,#'?' ;CLR F0 CALL _PUTCHAR %L(_CHAR): MOV A,MENUPTR2 ADD A,ACC MOV R0,A MOV A,MENUPTR CALL GET_PARM_VAL MOV MENUPTR3,A ; ULOZ HODNOTU PRVNI BITMAPY PUSH ACC ; ULOZ HODNOTU PRVNIHO PARAMETRU NA STACK %PRINTINT(#12,#5,#3,A,0) ; ZOBRAZ CISLO BITMAPY 1 MOV A,MENUPTR2 ADD A,ACC MOV R0,A MOV A,MENUPTR INC R0 CALL GET_PARM_VAL POP B XCH A,B %CMP(A,#128) JNC %L(_00) ; POKUD JE 1.PARAMETR VETSI NEZ 128 (64X64BITMAPY NEBO NIC), DRUHE CISLO UZ NEZOBRAZUJ XCH A,B %CMP(A,#192) JNC %L(_00) ; POKUD JE 1.PARAMETR VETSI NEZ 128 (64X64BITMAPY NEBO NIC), DRUHE CISLO UZ NEZOBRAZUJ %PRINTINT(#36,#5,#3,A,0) ; ZOBRAZ CISLO BITMAPY 2 %PUTCH(#30,#5,#'-',0) SJMP %L(__00) %L(_00): %PRINT(#30,#5,' ',DEL2BMP_TXT) %L(__00): ;*********************************************************************** %L(__END): MOV R1,#0 ; MIN PATRO MOV R2,#31 ; MAXPATRO ; NASTAV MIN A MAX CALL KeyGetFirst CJNE A,#(valKeyNShort+valKeyUp),%L(K1) ; STISK TLACITKA UP MOV R0,#MENUPTR2 CALL INC_PARM_VAL SJMP %L(KX) %L(K1): CJNE A,#(valKeyNShort+valKeyDn),%L(K2) ; STISK TLACITKA DN MOV R0,#MENUPTR2 CALL DEC_PARM_VAL SJMP %L(KX) %L(K2): CJNE A,#(valKeyNShort+valKeyMode),%L(K3) ; STISK TLACITKA MODE MOV STAV,#MENUSET_STBMP3 SJMP %L(KX) %L(K3): CJNE A,#(valKeyNLong+valKeyMode),%L(K4) ; ESC MOV STAV,#MENUSET_ ; VRAT SE ZPET NA HLAVNI MENU CALL CLR_LCD %L(K4): SJMP %L(END) %L(KX): SETB CS2 CLR CS1 CALL CLR_LCD_ %PRINTCLEARLINE(#0,#5) %L(END): %ENDSTAV %STAVDEF(MENUSET_STBMP3) MOV MENUPTR4,#0 ; UKAZATEL NA POZICI BITMAPY ; NEJDRIV VYMAZ SIPKY U OZNACENI STANICE %PUTCH(#17,#3,#' ',0) %PUTCH(#41,#3,#' ',0) ; VYPIS SIPKY U PRVNIHO CISLA %PUTCH(#6,#5,#124+32,0) %PUTCH(#30,#5,#125+32,0) MOV A,MENUPTR2 SETB TEMPBIT2 CALL SHOW_POSITION %IF(1)THEN ( MOV A,MENUPTR2 ADD A,ACC MOV R0,A MOV A,MENUPTR CALL GET_PARM_VAL MOV MENUPTR3,A ; NACTI HODNOTU, KTEROU MAS ULOZENOU V EEPROM )FI MOV A,MENUPTR2 ADD A,ACC INC A MOV R0,A MOV A,MENUPTR CALL GET_PARM_VAL MOV MENUPTR3_,A ; NACTI DALSI HODNOTU, KTEROU MAS ULOZENOU V EEPROM MOV A,MENUPTR3 %CMP(A,#128) JNC %L(NXT) ;CJE(A,#192,%L(NXT)) %PRINTINT(#36,#5,#3,MENUPTR3_,0) ; ZOBRAZ CISLO BITMAPY 2 %L(NXT): ;*********************************************************************** %L(_END): %STAVDEF(MENUSET_STBMP3_) MOV A,MENUPTR4 JZ %L(_A) ; POKUD EDITUJES DRUHY OBRAZEK, MAS POVOLENE POUZE HODNOTY MOV A,MENUPTR3 CJNE A,#191,%L(_A1) MOV MENUPTR3,#127 SJMP %L(_A) %L(_A1): CJNE A,#128,%L(_A) MOV MENUPTR3,#192 %L(_A): ; POKUD VYPISUJES HODNOTU PRVNI BITMAPY (ADRESU), TAK PODLE TETO HODNOTY ; BUDES RIDIT VYPIS DRUHE HODNOTY MOV A,MENUPTR4 JNZ %L(CONTINUE) MOV A,MENUPTR3 %CMP(A,#128) JNC %L(DEL_2TXT) %PRINTINT(#36,#5,#3,MENUPTR3_,0) SJMP %L(CONTINUE) %L(DEL_2TXT): %PRINT(#36,#5,#DEL2BMP_TXT,0) %L(CONTINUE): ; TADY PORES ZOBRAZOVANI OBOU BITMAP MOV R1,#36 MOV A,MENUPTR4 JNZ %L(SHOW_VAL1) ;ZOBRAZUJES DRUHY ZNAK? MOV R1,#12 %L(SHOW_VAL1): MOV R7,#5 MOV R6,#3 MOV A,MENUPTR3 CLR F0 CALL _PRINT_INT ;*********************************************************************** MOV A,MENUPTR4 %JNZ(%L(2BMP)) ; RES ZOBRAZENI 1. BITMAPY ; 1. ZJISTI, JESLI JE HODNOTA JINA NEZ 192 MOV A,MENUPTR3 XRL A,#192 JNZ %L(USR_BMP) ;MAS JINOU HODNOTU NEZ 192? ; NEMAM - ZOBRAZ STANDARD SETB CS2 CLR CS1 CALL CLR_LCD_ JMP %L(END_BMP) %L(USR_BMP): ; 2. ZJISTI, JESTLI NEMAS ZOBRAZIT VELKOU BITMAPU MOV A,MENUPTR3 %CMP(A,#128) JC %L(00) ADD A,#-128 ADD A,ACC ADD A,#128 CALL SHOWBMP_LARGE SJMP %L(END_BMP) %L(00): ; 3. ZJISTI, JESTLI MAS NA DRUHE POZICI NEJAKOU BITMAPU MOV A,MENUPTR3_ %CMP(A,#128) JNC %L(DRAW_) ; === ZOBRAZ OBE BITMAPY MOV A,MENUPTR3 CALL SHOWBMP_LEFT MOV A,MENUPTR3_ CALL SHOWBMP_RIGHT SJMP %L(END_BMP) %L(DRAW_): MOV A,MENUPTR3 CALL SHOWBMP_CENTER SJMP %L(END_BMP) ; MAS NAKRESLENO - POKRACUJ ZPRACOVANIM TLACITEK ;*********************************************************************** %L(2BMP): MOV A,MENUPTR3 %CMP(A,#192) JC %L(SHOW_2BMP) MOV A,MENUPTR3_ CALL SHOWBMP_CENTER SJMP %L(END_BMP) %L(SHOW_2BMP): MOV A,MENUPTR3 CALL SHOWBMP_RIGHT MOV A,MENUPTR3_ CALL SHOWBMP_LEFT SJMP %L(END_BMP) %L(01): %L(SHOW_POS): MOV A,MENUPTR2 MOV B,#0 SETB TEMPBIT2 CALL SHOW_POSITION ;*********************************************************************** %L(END_BMP): MOV R1,#0 ; NASTAV MINIMUM NA PRVNI ZOBRAZITELNY ZNAK Z ASCII MOV R2,#192 MOV RETSTAV,STAV MOV STAV,#CLR_DISP ; OBSLUHA TLACITEK UP A DN CALL HANDLE_UD_KEYS MOV STAV,RETSTAV ; KLASICKA OBSLUHA TLACITEK %L(K2): CALL KeyGetFirst %LCJNE(A,#(valKeyNShort+valKeyMode),%L(K3)) ; STISK TLACITKA MODE MOV A,MENUPTR CALL GETMENU00 MOV DPH,R1 MOV DPL,R2 MOV A,MENUPTR2 ADD A,ACC ADD A,MENUPTR4 MOV R0,A ; VYPOCITEJ, KAM ULOZIT NOVOU HODNOTU PARAMETRU MOV A,MENUPTR4 ADD A,#-1 MOV A,MENUPTR3 JNC %L(_WR) ; POKUD JE TO PRVNI BITMAPA, TAK ULOZ JAKOUKOLIV HODNOTU %CMP(A,#128) ; JESTLI JE PRVNI UKLADANY PARAMETR ROVEN NEBO VETSI NEZ 128,SKONCI JC %L(_WR) MOV A,#192 ; ZAPIS MAX. HODNOTU %L(_WR): CALL ParPutParm MOV A,MENUPTR3 %CMP(A,#128) ; JESTLI JE PRVNI UKLADANY PARAMETR ROVEN NEBO VETSI NEZ 128,SKONCI JNC %L(K2__) MOV A,MENUPTR4 JZ %L(K2_) ; ZKONTROLUJ, JESTLI JSI UZ PROSEL OBE CASTI %L(K2__): SJMP %L(_K3) %L(K2_): INC MENUPTR4 ; JESTE NASTAVUJES DRUHOU BITMAPU MOV A,MENUPTR3 MOV MENUPTR3,MENUPTR3_ ; OBE HODNOTY PROHOD - KVULI ZOBRAZENI MOV MENUPTR3_,A ; NEJDRIV VYMAZ SIPKY U PRVNIHO CISLA %PUTCH(#6,#5,#' ',0) ; VYPIS SIPKY U DRUHEHO CISLA %PUTCH(#30,#5,#124+32,0) %PUTCH(#54,#5,#125+32,0) SJMP %L(KX) %L(K3): CJNE A,#(valKeyNLong+valKeyMode),%L(K4) ; ESC %L(_K3): CALL CLR_LCD MOV STAV,#MENUSET_STBMP ; VRAT SE O UROVEN VYS ; === PO NAVRATU O UROVEN VYS MOV R1,#0 ; MIN PATRO MOV R2,#31 ; MAXPATRO MOV R0,#MENUPTR2 CALL INC_PARM_VAL SJMP %L(END) %L(K4): SJMP %L(END) %L(KX): SETB CS2 CLR CS1 CALL CLR_LCD_ %L(END): %ENDSTAV %STAVDEF(CLR_DISP) SETB CS2 CLR CS1 CALL CLR_LCD_ MOV STAV,#MENUSET_STBMP3_ %ENDSTAV ;******************************************************************** ; ZOBRAZI NA ZADANYCH SOURADNICICH BITMAPU ;******************************************************************** SHOWBMP_LARGE: MOV R6,#64 ; X MOV R7,#0 ; Y MOV R4,#64 SJMP %L(DRAW_BMP_) SHOWBMP_LEFT: MOV R6,#64 ; X MOV R7,#0 ; Y SJMP %L(DRAW_BMP) SHOWBMP_RIGHT: MOV R6,#96 MOV R7,#0 SJMP %L(DRAW_BMP) SHOWBMP_CENTER: MOV R6,#80 MOV R7,#0 %L(DRAW_BMP): MOV R4,#32 %L(DRAW_BMP_): MOV R5,#64 MOV R2,#0 MOV DPH,A MOV DPL,#0 CALL SHOWBMPWND2 RET ;* R7 ... POCATECNI BOD Y,OD KTEREHO VYKRESLUJES BITMAPU ;* R6 ... POCATECNI BOD X,OD KTEREHO VYKRESLUJES BITMAPU ;* ;* DPTR ... ADRESA BITMAPY ;* R2 ... STRANKA VE FLASHCE ;* ;* R5 ... RESOLUTION_Y (ZADAVS V PIXELECH) ;* R4 ... RESOLUTION_X ;* ;========================= KONEC STAVOVEHO AUTOMATU =========================== ; ============================================================================== LASTSTAV EQU %STAVCNT+1 ; === TABULKA ADDRES PODPROGRAMU STAVU TABSTAV: %SET(CNT,0) %REPEAT(%STAVCNT+1) (DW _STAVL%RSTR(%CNT,3) %SET(CNT,%CNT+1) ) ; === ZDE SE ODSKAKUJE PO KAZDEM PRUCHODU MainStavExit: ;JMP MainLoop %RESLOCAL ;******************************************************************************* ;* UROVEN PRERUSENI CASOVACE 0 ;* VSTUP : - ;* VRACI : - ;* MENI : - ;* STACK : 8 ;******************************************************************************* Timer0Us: PUSH PSW PUSH ACC PUSH DPL PUSH DPH PUSH AR0 PUSH AR1 PUSH B ; INDIKUJ TIMER0 INTERUPT ;SETB P1.6 ; RELOAD TIMER0 CLR TR0 ; ZASTAV NA CHVILI CASOVAC MOV TL0,#LOW(TTIMER0INT+7) ; DOROVNEJ NA SPRAVNOU HODNOTU MOV TH0,#HIGH(TTIMER0INT+7) SETB TR0 ; A OBNOV CASOVANI MOV A,STAV %CMP(A,#ERASE_FLASH) JNC %L(END_) ; JESTLI ZROVNA PRACUJES S EEPROMKOU NEBO FLASHKOU, TAK VESKEROU KOMUNIKACI IGNORUJ!! ;JB PROTOKOL,%L(MSP3) ; DLE PARAMETRU ZJISTI, KTERY PROTOKOL MAS PROVADET CALL MSP2_PROCESSING JNB PROTOKOL,%L(END_) ; DLE PARAMETRU ZJISTI, KTERY PROTOKOL MAS PROVADET ;SJMP %L(_END) %L(MSP3): ;MOV A,STAV ;CMP(A,#SHOW_VERSION) ;JNC %L(END_) ; JESTLI ZROVNA PRACUJES S EEPROMKOU NEBO FLASHKOU, TAK VESKEROU KOMUNIKACI IGNORUJ!! CALL MSP3_PROCESSING ; MSP3 + SERIOVE VOLBY ;SJMP %L(_END) %L(END_): ;SETB P3.6 ; POKUD NECO NASTAVUJES, NESMIS DRZET SBERNICI %L(_END): MOV A,DIV10MS JZ %L(T0_SC2) DEC DIV10MS SJMP %L(END) %L(T0_SC2): MOV DIV10MS,#nbr10ms ; RELOAD 10ms TMR MOV R0,#GONGDELAY CALL DEC_TMR MOV R0,#SHIFTCNT1 CALL DEC_TMR ;UPDATE TLACITEK SETB INP_MODE ; PIN JAKO VSTUP SETB INP_UP ; PIN JAKO VSTUP SETB INP_DN ; PIN JAKO VSTUP MOV R0,#KEYS MOV C,INP_MODE CALL KeyUpdate INC R0 MOV C,INP_UP CALL KeyUpdate INC R0 MOV C,INP_DN CALL KeyUpdate DEC DIV100MS MOV A,DIV100MS JNZ %L(T0_SCX) ; NENI TO JESTE 100ms MOV DIV100MS,#10 ; A UZ JE... INC SYSTIMH %IF(1)THEN ( ; === OBSLUZ REFRESH DISPLAYE MOV A,REFRESH JZ %L(T0_GT3) DEC REFRESH %L(T0_GT3): )FI ; DALSI DVA CASOVACE ;DEKREMENTACE CITACE PREPINANI: FIRE <-> POSITION MOV R0,#FPSCNT CALL DEC_TMR %L(VOLPRI): MOV R0,#VOLBYTMRNPRI CALL DEC_TMR ; VOLBY PRIORITNI MOV R0,#VOLBYTMRDPRI CALL DEC_TMR DEC BLINKTLACTMR MOV A,BLINKTLACTMR JNZ %L(LED_) CPL BLINKTLAC MOV BLINKTLACTMR,#2 %L(LED_): ; DEKREMENTACE CASOVACE VOLEB MOV R0,#VOLBYTMR ; NACTI CASOVAC VOLEB CALL DEC_TMR ;DEKREMENTACE PLATNOSTI KOMUNIKACE MOV R0,#SERTIM CALL DEC_TMR MOV R0,#SERTIM2 CALL DEC_TMR ;CASOVAC NECINNOSTI MENU MOV R0,#MINTMR CALL DEC_TMR MOV R0,#GONGTIM CALL DEC_TMR %L(T0_SCX): ; OVLADEJ PODSVICENI DISPLEJE %L(T0_CTX): %L(END): SETB WATCHTMR0 ; NASTAV PRIZNAK, ZE JSI TU BYL! %L(T0_KEYX): ; INDIKUJ TIMER0 INTERUPT ;CLR P1.6 ; SHOD PIN - MUZES TAK MERIT DELKU PRERUSENI POP B POP AR1 POP AR0 POP DPH POP DPL POP ACC POP PSW RETI DEC_TMR: MOV A,@R0 JZ %L(KO) DEC @R0 %L(KO): RET Timer2Us: PUSH PSW PUSH ACC CLR TF2 MOV TH2,#HIGH(TTIMER2INT) MOV TL2,#LOW(TTIMER2INT) ; SYSTEMOVY CASOVAC INC SYSTIML MOV A,SYSTIML ANL A,#003h ; SNIZENI INTENZITY SVITU DISPLEJE %CMP(A,DISPLIGHT) JNC %L(T0_001) CLR P3.5 SJMP %L(T0_SLX) %L(T0_001): SETB P3.5 %L(T0_SLX): SETB WATCHTMR2 ; NASTAV PRIZNAK, ZE JSI TU BYL! POP ACC POP PSW RETI %IF(0)THEN ( Timer2Us: PUSH PSW PUSH ACC PUSH B MOV TH2,#HIGH(TTIMER2INT) MOV TL2,#LOW(TTIMER2INT) CLR TF2 INC PWMTIMER INC SYSTIML MOV A,DISPLIGHT %CJE(A,#0,%L(T0_001)) ; NASLEDUJE RIZENI KROKU PODSVETLENI MOV A,SYSTIML CJNE A,#03Fh,%L(T0_ENDDL) MOV SYSTIML,#0 MOV A,DISPLIGHT ADD A,ACC ; DISPLIGHT * 2 MOV B,A MUL AB ; (DISPLIGHT*2)^2 MOV B,A MOV A,DISPLIGHTTEMP %CMP(A,B) JNC %L(T0_STM0) INC DISPLIGHTTEMP SJMP %L(T0_ENDDL) %L(T0_STM0): XCH A,B %CMP(A,B) JC %L(DEC) SJMP %L(T0_ENDDL) %L(DEC): DEC DISPLIGHTTEMP %L(T0_ENDDL): ; ZRUSENO PWM - VZDY BUDE POUZE 1 PULS - ZKRACOVAT SE BUDE STRIDA (PERIODA) MOV A,PWMTIMER JNZ %L(T0_001) %L(T0_SET): CLR P3.5 ; SVITI SJMP %L(T0_SLX) %L(T0_001): SETB P3.5 ; NESVITI %L(T0_SLX): MOV A,#64 CLR C SUBB A,DISPLIGHTTEMP MOV B,A MOV A,PWMTIMER ;CJNE A,B,%L(T0_SLX0) %CMP(A,B) JC %L(T0_SLX0) MOV PWMTIMER,#-1 %L(T0_SLX0): %IF(%DEBUG EQ 2)THEN ( MOV A,DISPLIGHT ADD A,ACC MOV B,A ; SYSTEMOVY CASOVAC INC SYSTIML MOV A,SYSTIML ANL A,#07h ; SNIZENI INTENZITY SVITU DISPLEJE %CMP(A,B) JNC %L(T0_001) CLR P3.5 SJMP %L(T0_SLX) %L(T0_001): SETB P3.5 %L(T0_SLX): )FI SETB WATCHTMR2 ; NASTAV PRIZNAK, ZE JSI TU BYL! %L(END_INT2): POP B POP ACC POP PSW RETI )FI %RESLOCAL ;******************************************************************************* ;* FUNKCE NASTAVUJE GONG PRO POTVRZENI VOLBY ;* VSTUP: - ;* VYSTUP: - ;* NICI: Acc,Cy,B,R0 ;******************************************************************************* SETGNGTLAC: JNB GONGTLACSTART,%L(ST) CLR GONGTLACSTART ; ZRUS PRIZNAK GONGU MOV GONGDELAY,#GngCalDelay ; SPUSTIM GONG MOV A,#O_GNGTL SETB F0 CALL SET_OUTP %L(ST): MOV A,GONGDELAY JNZ %L(_END) MOV A,#O_GNGTL CLR F0 CALL SET_OUTP %L(_END): RET ;******************************************************************************* ;* KONTROLA FLAGU A ZASLANI VYSLEDKU ;* VSTUP : - ;* VRACI : A - HODNOTA AKCE (0- NORMAL | 1- POZAR | 2- PRETIZ | 4- MIMO PROVOZ | 5- REVIZE) ;* MENI : A ;* STACK : 0 ;******************************************************************************* CheckFlags: ;=== KONTROLA KOMUNIKACE === MOV A,SERTIM JNZ %L(NOCX) ; KOMUNIKACE - NENI! ; ANL WCALLS,#NOT _WVOLBAN OR _WVOLBAD ; SMAZ VOLBY MOV A,#O_DN CLR F0 CALL SET_OUTP MOV A,#O_UP CALL SET_OUTP ; MOV A,#valFlgNco SJMP %L(CHFLX) %L(NOCX): ;=== KONTROLA REVIZNI JIZDY === JNB REVIZE,%L(REVIZEX) JNB TREVIZE,%L(REVIZEX) ; REVIZNI JIZDA - JE! ; ; MOV A,#valFlgRev SJMP %L(CHFLX) %L(REVIZEX): ;=== KONTROLA MIMO PROVOZ === JNB DEFECT,%L(DEFEX) JNB TDEFECT,%L(DEFEX) ; MIMO PROVOZ - JE! ; ; MOV A,#valFlgDef SJMP %L(CHFLX) %L(DEFEX): ;=== KONTROLA PRETIZENI === JNB OVERLOAD,%L(OVERX) JNB TOVERLOAD,%L(OVERX) ; PRETIZENO - JE! ; ; MOV A,#valFlgOvl SJMP %L(CHFLX) %L(OVERX): ;=== KONTROLA POZARNI JIZDY === JNB FIRE,%L(FIREX) JNB TFIRE,%L(FIREX) ; POZARNI JIZDA - JE! ; ; MOV A,#valFlgFir SJMP %L(CHFLX) %L(FIREX): MOV DPTR,#P16 MOV R0,#0 CALL ParGetParm %CMP(A,#3) JC %L(LCDOFFEX) ;=== KONTROLA VYPNUTI DISPLEJE - PRIZNAK REKLAMY === JNB POWERSAVE,%L(LCDOFFEX) JNB TREKLAMA,%L(LCDOFFEX) ; POUZE, KDYZ MAS AKTIVOVANY PRIZNAK ; POZARNI JIZDA - JE! ; ; MOV A,#valFlgReklam SJMP %L(CHFLX) %L(LCDOFFEX): ;=== NORMALNI REZIM - NIC SE NEDEJE ! === MOV A,#0 %L(CHFLX): RET %RESLOCAL ;******************************************************************************* ;* OBNOVI HW RESET ;* VSTUP : - ;* VRACI : - ;* MENI : A,C ;* STACK : 3 ;******************************************************************************* WdgReset: CLR EA ; ZJISTI, JESTLI JSI PROBEHL PRERUSENIMI MOV C,WATCHTMR0 %IF(%NO_COMPILE EQ 0)THEN ( ANL C,WATCHTMR2 )FI ; POKUD NEJSOU OBE DVE, TAK NEKRM PEJSKA JNC %L(END) CLR WATCHTMR0 ; SMAZ HLIDACI PRIZNAKY CLR WATCHTMR2 ; VSE OK - NAKRM PEJSKA MOV WDTRST,#01Eh ; AKTIVUJ WDG MOV WDTRST,#0E1h %L(END): SETB EA RET ;******************************************************************************* ;* INICIALIZACE TLACITEK ;* VSTUP : - ;* VRACI : - ;* MENI : - ;* STACK : 1 ;******************************************************************************* KeyInit: PUSH ACC MOV A,R0 MOV R0,#KEYS %L(KeyInit1): MOV @R0,#00 INC R0 CJNE R0,#(KEYS+KEYS_LEN),$+3 ; POZOR !!!!! - RO NESMI PRETECT JC %L(KeyInit1) MOV R0,A POP ACC RET ;******************************************************************************* ;* NACTE TLACITKA ;* VSTUP : R0 - UKAZATEL NA STATUS TLACITKA ;* C - STISK TLACITKA (C=0 - TLACITKO STISKLE) ;* VRACI : - ;* MENI : A,C ;* STACK : 4 ;******************************************************************************* KeyUpdate: MOV A,@R0 CLR ACC.bitKeyPress MOV @R0,A JC %L(KUpdateX) ; NENI STISKLA - SKOC MOV A,@R0 ANL A,#maskKeyValue ; JEN CITAC STISKU CJNE A,#nbrKeyMax,$+3 ; MUZU JESTE PRICITAT ? JNC %L(KUpdate1) ; NE - SKOC INC @R0 %L(KUpdate1): MOV A,@R0 ANL A,#maskKeyValue ; JEN CITAC STISKU CJNE A,#nbrKeyFilter,$+3 ; PLATNY STISK ? JC %L(KUpdateX) ; NE - SKOC MOV A,@R0 SETB ACC.bitKeyPress JB ACC.bitKeyLock,%L(KUpdate2) ; KLAVESA ZAMCENA - SKOC CALL KeyLockA ; ZAMCI VSECHNY (SEBE ULOZIM DALE) %L(KUpdate2): MOV @R0,A %L(KUpdateX): RET ;******************************************************************************* ;* VRATI UDALOST TLACITEK (PRVNI STISKLE TLACITKO) ;* VSTUP : - ;* VRACI : A - UDALOST (AKTUALNI) ;* C - STISK KLAVESY (C=1 : ANO) ;* MENI : A,B,C,R0 ;* STACK : 5 ;******************************************************************************* KeyGetFirst: MOV R0,#KEYS %L(KGetF01): MOV A,@R0 JB ACC.bitKeyLock,%L(KGetF02) CALL KeyGet SJMP %L(KGetFX) %L(KGetF02): INC R0 CJNE R0,#(KEYS+KEYS_LEN),$+3 ; POZOR !!!!! - RO NESMI PRETECT JC %L(KGetF01) MOV A,#valKeyNone %L(KGetFX): RET ;******************************************************************************* ;* VRATI UDALOST TLACITKA ;* VSTUP : R0 - UKAZATEL NA TLACITKO ;* ;* VRACI : A - UDALOST (AKTUALNI) ;* C - STISK KLAVESY (C=1 : ANO) ;* MENI : A,B,C ;* STACK : 3 ;******************************************************************************* KeyGet: MOV A,@R0 ANL A,#maskKeyValue CJNE A,#nbrKeyShort,$+3 JC %L(KGet1X) MOV A,R0 SUBB A,#KEYS MOV B,A MOV A,@R0 MOV C,ACC.bitKeyPress MOV A,#valKeyPLong JC %L(KGet11) MOV A,#valKeyNLong CALL KeyInit CLR C %L(KGet11): ORL A,B SJMP %L(KGetX) %L(KGet1X): CJNE A,#nbrKeyFilter,$+3 JC %L(KGet2X) MOV A,R0 SUBB A,#KEYS MOV B,A MOV A,@R0 MOV C,ACC.bitKeyPress MOV A,#valKeyPShort JC %L(KGet21) MOV A,#valKeyNShort CALL KeyInit CLR C %L(KGet21): ORL A,B SJMP %L(KGetX) %L(KGet2X): MOV A,#valKeyNone CLR C %L(KGetX): RET ;******************************************************************************* ;* ZAMCE VSECHNY TLACITKA ;* VSTUP : - ;* VRACI : - ;* MENI : C ;* STACK : 2 ;******************************************************************************* KeyLockA: PUSH ACC PUSH B MOV B,R0 MOV R0,#KEYS %L(KeyLock1): MOV A,@R0 SETB ACC.bitKeyLock MOV @R0,A INC R0 CJNE R0,#(KEYS+KEYS_LEN),$+3 ; POZOR !!!!! - RO NESMI PRETECT JC %L(KeyLock1) MOV R0,B POP B POP ACC RET ;******************************************************************************* ;* TABULKY PRIRAZENI VYSTUPU ;******************************************************************************* ;******************************************************************************* ;******************************************************************************* ;** POMOCNE FUNKCE PRO PRACI S MENU ;******************************************************************************* ;******************************************************************************* %RESLOCAL ;******************************************************************************* ;* INKREMENTUJE CISLO ULOZENE NA NEJAKE ADRESE A TESTUJE ZDA NEPREKROCI ZADANE MEZE ;* VSTUP : R0 = ADRESA BAJTU, VE KTEREM JE ULOZENA AKTUALNI HODNOTA ;* R2 = MAX. HODNOTA ;* R1 = MIN. HODNOTA ;* VYSTUP: R0 = NA ADRESE ULOZENE V REGISTRU JE AKTUALNI HODNOTA PO INKREMENTACI ;* MENI : A, B, C ;* STACK : 0 ;******************************************************************************* INC_PARM_VAL: INC @R0 MOV A,@R0 MOV B,R2 INC B %CMP(A,B) JNC %L(00) SJMP %L(END) %L(00): MOV A,R1 MOV @R0,A ; POKUD JE VETSI NEZ MAX., TAK POSUN NA HODNOTU MIN. %L(END): RET %RESLOCAL ;******************************************************************************* ;* DEKREMENTUJE CISLO ULOZENE NA NEJAKE ADRESE A TESTUJE ZDA NEPREKROCI ZADANE MEZE ;* VSTUP : R0 = ADRESA BAJTU, VE KTEREM JE ULOZENA AKTUALNI HODNOTA ;* R2 = MAX. HODNOTA ;* R1 = MIN. HODNOTA ;* VYSTUP: R0 = NA ADRESE ULOZENE V REGISTRU JE AKTUALNI HODNOTA PO DEKREMENTACI ;* MENI : A, B, C ;* STACK : 0 ;******************************************************************************* DEC_PARM_VAL: DEC @R0 MOV A,@R0 MOV B,R1 CJNE A,B,%L(01) SJMP %L(END) %L(01): JNC %L(02) %L(01_): MOV A,R2 MOV @R0,A ; POKUD JE MENSI NEZ MIN., TAK POSUN NA HODNOTU MAX. SJMP %L(END) %L(02): ; OTESTUJ JESTE MOZNOST, ZE JSI PODTEKL NA HODNOTU 255 MOV B,R2 INC B %CMP(A,B) JNC %L(01_) %L(END): RET ;******************************************************************************* ;* FUNKCE PREVEDE CISLO NA CHAR DLE PREVODNI TABULKY V BMP.A51 ;* VSTUP : A = CISLO Z PARAMETRU V ROZSAHU 29 - 128 ;* A = CISLO Z PARAMETRU V ROZSAHU 0 - 99 ;* VYSTUP: A = ODPOVIDAJICI ZNAK ;* MENI : A, B, C ;* STACK : 0 ;******************************************************************************* GET_TRANS_CHAR: ;IF(%NO_COMPILE NE 0)THEN ;( ADD A,#-29 ;ADD A,#-31 GET_TRANS_CHAR_: MOV DPTR,#TRANSLATE_DB MOVC A,@A+DPTR RET ;)FI ;******************************************************************************* ;******************************************************************************* ;** POMOCNE FUNKCE ;******************************************************************************* ;******************************************************************************* ;******************************************************************************* ;* ZJISTI, KOLIK PIXELU Z PRAVA A Z LEVA ZACINA ZNAK ;* VSTUPY: A .... HODNOTA ZNAKU ;* VYSTUPY: R4 .... POCET PIXELU Z PRAVA ;* R3 .... POCET PIXELI Z LEVA ;* Cy .... 0 - OK / 1 - ERR ;* MENI: ;* STACK: ;******************************************************************************* %RESLOCAL GET_DUMMYPIX: PUSH DPL PUSH DPH MOV DPH,#0F1H MOV DPL,A CALL FLASH_BYTERD MOV B,A ANL B,#0Fh MOV R4,B SWAP A ANL A,#0Fh MOV R3,A POP DPH POP DPL RET ;******************************************************************************* ;* ZJISTI, KOLIK PIXELU Z PRAVA A Z LEVA ZACINA ZNAK ;* VSTUPY: DPTR,R2 .... ADRESA ;* R5 .... ROZLISENI X ;* R6 .... ROZLISENI Y ;* VYSTUPY: R4 .... POCET PIXELU Z PRAVA ;* R3 .... POCET PIXELI Z LEVA ;* Cy .... 0 - OK / 1 - ERR ;* MENI: ;* STACK: ;******************************************************************************* %RESLOCAL GET_CHAR_DUMMYPIX: ; NEJDRIV TESTUJ Z LEVA MOV R6,#0 ; POCITADLO SLOUPCU %L(CYKL00): MOV R7,#3 ; POCITADLO RADKU %L(CYKL0): CALL GET_BYTE JC %L(END0) DJNZ R7,%L(CYKL0) INC R6 ; ZJISTI, JESTLI UZ JSI NEPREKROCIL ROZSAH ROZLISENI BITMAPY MOV A,R6 %CMP(A,#16) JC %L(CYKL00) ; UZ JSI PREKROCIL - OKAMZITE SKONCI S CHYBOU SETB C MOV R3,#0FFh MOV R4,#0FFh SJMP %L(END) %L(END0): MOV A,R6 MOV R3,A ; ULOZ NA VYSTUP %CMP(R3,#1) JC %L(END0_) DEC R3 %CMP(R3,#1) JC %L(END0_) DEC R3 ;CMP(R3,#1) ;JC %L(END0_) ;DEC R3 ; MAS POCET RADKU Z LEVA, PO KTERYCH TEPRVE ZACINA NEJAKY SYMBOL ; ZJISTI TO STEJNE, ALE Z PRAVA %L(END0_): MOV R6,#15 ; POCITADLO SLOUPCU %L(CYKL01): MOV R7,#3 ; POCITADLO RADKU %L(CYKL1): CALL GET_BYTE JC %L(END1) DJNZ R7,%L(CYKL1) DEC R6 ; ZJISTI, JESTLI UZ JSI NEPREKROCIL ROZSAH ROZLISENI BITMAPY MOV A,R6 JNZ %L(CYKL01) ; UZ JSI PREKROCIL - OKAMZITE SKONCI S CHYBOU SETB C SJMP %L(END) %L(END1): ; ULOZ VYSLEDEK NA VYSTUP MOV A,#16 CLR C SUBB A,R6 MOV R4,A CLR C DEC R4 %CMP(R4,#1) JC %L(END) DEC R4 %L(END): RET %RESLOCAL GET_BYTE: PUSH DPL PUSH DPH MOV A,R7 DEC A MOV B,#16 MUL AB ADD A,R6 XCH A,B ADDC A,#0 XCH A,B CLR C ADD A,DPL MOV DPL,A MOV A,B ADDC A,DPH MOV DPH,A CALL FLASH_BYTERD ADD A,#-1 ; POKUD JE V Acc NEJAKA HODNOTA, NASTAV Cy POP DPH POP DPL RET %RESLOCAL ARR_DN EQU 000h ARR_UP EQU 001h ARR_UD EQU 002h NO_ARR EQU 003h;0FFh ;******************************************************************************* ;* FUNKCE ZOBRAZUJE BITMAPU SIPEK ;* VSTUP: - Acc .... SIPKY ;* VYSTUP: - ;* NICI: Acc,Cy,B,R0 ;******************************************************************************* SHOW_ARROW: ADD A,#1 JZ %L(CLR_) DEC A MOV DPTR,#P05 ; NACTI ADRESY PARAMETRU, ZE KTEREHO UDES CIST TEXT MOV R0,A ; NACTI SIPKU CALL ParGetParm MOV B,R0 %CMP(A,B) ; MAS NASTAVENOU NEJAKOU BITMAPU? ;JNB TEMPBIT2,%L(END) ; POKUD NEMAS OPRAVDU NASTAVENOU ZADNOU SIPKU, TAK DALSI KROKY PRESKAKUJ JNC %L(CLR_) MOV DPL,#0 ; LO_BYTE = 0 ADD A,ACC ; HI_BYTE = ADRESA * 2 KVULI POSUNU O 512 BAJTU MOV DPH,A ; ADRESA BITMAPY KOMPLETNI MOV A,R3 MOV R2,A ; ZADEJ STRANKU MOV R5,#64 MOV R4,#64 ; NASTAV ROZLISENI SETB TEMPBIT2 JB ROTATEDISP,%L(ROT0) MOV R7,#0 MOV R6,#0 CALL SHOWBMPWND2 SJMP %L(END) %L(ROT0): MOV R7,#0 MOV R6,#127 CALL SHOWBMPWND2ROT SJMP %L(END) %L(CLR_): JB ROTATEDISP,%L(ROT1) SETB CS1 CLR CS2 SJMP %L(CLR__) %L(ROT1): SETB CS2 CLR CS1 %L(CLR__): CALL CLR_LCD_ ; SMAZ PRAVOU POLOVINU - TAM BUDES VYKRESLOVAT BITMAPY CLR TEMPBIT2 %L(END): MOV A,POS SETB ACC.bitPosRefr MOV POS,A RET %RESLOCAL ;******************************************************************************* ;* ZOBRAZI NA VYSTUP ZADANOU POLOHU ;* VSTUP : A = DEKADICKE CISLO(POLOHA) ;* B = STARTOVNI POZICE X (NEBO Y) - DLE TYPU ZOBRAZENI ;* MENI : A, B, C ;* STACK : 0 ;******************************************************************************* POSITION EQU TEMP2 ROT EQU TEMP LEFT EQU 0 RIGHT EQU 1 CENTER EQU 2 SHOWY0: ; ZJISTI,JESTLI MAS ROTOVANE ZOBRAZENI JB ROTATEDISP,%L(R2) MOV R6,#32 JNB B.0,%L(1) MOV R6,#64 %L(1): JNB B.1,%L(_1) MOV R6,#48 %L(_1): JNB TEMPBIT2,%L(02) MOV R6,#64 JNB B.0,%L(01) MOV R6,#96 SJMP %L(02) %L(01): JNB B.1,%L(02) MOV R6,#80 %L(02): MOV R7,POSITION CALL SHOWBMPWND2 RET %L(R2): SETB DENNY_CS1 CLR DENNY_CS2 JB TEMPBIT2,%L(011) SETB DENNY_CS1 SETB DENNY_CS2 %L(011): MOV R7,#0 JNB B.0,%L(11) MOV R7,#32 SJMP %L(12) %L(11): JNB B.1,%L(12) MOV R7,#16 %L(12): MOV R6,POSITION JB TEMPBIT2,%L(13) MOV A,R6 ADD A,#32 MOV R6,A %L(13): CLR C CALL SHOWBMPWND2ROT RET %IF(%NO_COMPILE EQ 0)THEN ( DEL_LINES: PUSH ACC MOV R4,#64 MOV R5,#8 MOV DPTR,#(' '-32) SHL 8 MOV R2,#0 ; === UPLNE NA PICU!!!! JB ROTATEDISP,%L(_90ST) MOV R6,#64 JB TEMPBIT,%L(001) ; === ROLUJU SE ZNAKEM SMEREM DOLU MOV A,POSITION;R7 ADD A,#-8 MOV R7,A CALL SHOWBMPWND2 SJMP %L(_END_) %L(001): MOV A,POSITION;R7 ADD A,#72 MOV R7,A MOV DPTR,#(' '-32) SHL 8 MOV R2,#0 ; === ROLUJU SE ZNAKEM SMEREM NAHORU CALL SHOWBMPWND2 SJMP %L(_END_) ; === OTOCENY DISPLEJ %L(_90ST): MOV R7,#0 JB TEMPBIT,%L(002) ; === ROLUJU SE ZNAKEM SMEREM DOLU MOV A,POSITION;R7 ADD A,#8 MOV R6,A CLR C CALL SHOWBMPWND2ROT SJMP %L(_END_) %L(002): MOV A,POSITION;R7 ADD A,#-64 MOV R6,A ; === ROLUJU SE ZNAKEM SMEREM NAHORU CLR C CALL SHOWBMPWND2ROT SETB DENNY_CS1 CLR DENNY_CS2 %L(_END_): POP ACC RET )FI ;* VSTUP : ;* B .... POCATECNI POLOHA NA DISPLEJI - ZALEZI NA NATOCENI! SHOW_POSITION: MOV POSITION,B ANL A,#1Fh CALL DEL_LINES ; VYMAZ RADKY PRED A ZA BITMAPOU KVULI STOPAM, KTERE ZUSTAVALY MOV R7,A ADD A,ACC ; VYNASOB 2x - KVULI DVOUZNAKU MOV R0,A ; ULOZ OFFSET - POLOHU DO R0 PUSH ACC ; ULOZ OFFSET PRO DALSI ZPRACOVANI MOV DPTR,#P03 ; ULOZ DO DPTR DANY PARAMETR CALL ParGetParm ; NACTI PARAMETR - V Acc BUDES MIT CISLO, KTERE UDAVA ; OFFSET NA STRANCE VE FLASH MOV B,R3 MOV R2,B ; ULOZ DO R2 ADRESU STRANKY VE FLASHCE, KDE SE NACHAZEJI PRISLUSNE BITMAPY MOV B,R0 %LCJNE(A,B,%L(_NXT0)); ZJISTI, JESTLI MAS NASTAVENE DEFAULTNI ZOBRAZENI ; POKUD DEFAULT, NEZOBRAZUJ NIC - MEZERU POP ACC JMP %L(END) %IF(%NO_COMPILE EQ 1)THEN ( %LCJNE(A,B,%L(_NXT0)); ZJISTI, JESTLI MAS NASTAVENE DEFAULTNI ZOBRAZENI ; DEFAULTNI ZOBRAZENI POP ACC ; VYTAHNI STACK MOV A,R7 ; ZJISTI, JAKOU MAS POLOHU JZ %L(_NEPOS) ; KDYZ POLOHA=0, TAK ZOBRAZUJ NEZNAME PATRO DEC A ;;;;;;;;;;;;;;;; CALL A2BCD ;;;;;;;;;;;;;;;; PUSH ACC ANL A,#0F0h JNZ %L(DESITKY) ; ZOBRAZUJ POUZE STANICE POD 10 POP ACC MOV B,#1;'0'-32 ADD A,B CLR C MOV DPH,A MOV DPL,#0 MOV R2,#0 MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV B,#CENTER CALL SHOWY0 JMP %L(END) %L(DESITKY): ; ZOBRAZUJES STANICE I NAD 10 POP ACC PUSH ACC ANL A,#0Fh MOV B,#1;'0'-32 ADD A,B MOV DPH,A MOV DPL,#0 MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV R2,#0 MOV B,#RIGHT CALL SHOWY0 POP ACC SWAP A ANL A,#0Fh MOV B,#1;'0'-32 ADD A,B MOV DPH,A MOV DPL,#0 MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV R2,#0 MOV B,#LEFT CALL SHOWY0 SJMP %L(END) %L(_NEPOS): ; DEFAULTNI ZOBRAZENI NEZNAMEHO PATRA MOV DPH,#12;'?'-32 ;PUSH DPH MOV DPL,#0 MOV R2,#0 MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV B,#CENTER CALL SHOWY0 SJMP %L(END) )FI %L(_NXT0): MOV R7,A ; ULOZ BITMAPU POP ACC ; VYTAHNI ZE STACKU OFFSET PRVNIHO ZNAKU ZE DVOU NEBO BITMAPU MOV R0,A MOV A,R7 ; BUDES ZOBRAZOVAT POUZE JEDEN ZNAK - NEBO JEDNU BITMAPU %CMP(A,#128) JNC %L(SPEC_BMP) INC R0 ; POSUN SE NA DRUHY ZNAK MOV DPTR,#P03 ; ULOZ DO DPTR DANY PARAMETR CALL ParGetParm ; NACTI PARAMETR - V Acc BUDES MIT CISLO, KTERE UDAVA ; OFFSET NA STRANCE VE FLASH MOV B,R0 CJNE A,B,%L(2ZN) MOV DPL,#0 MOV DPH,R7 ; NACTI ULOZENY OFFSET PRVNI BITMAPY MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV R2,#0 MOV B,#CENTER CALL SHOWY0 JMP %L(END) %L(SPEC_BMP): ADD A,#-128 ; ODECTI 128 ADD A,ACC ; VYNASOB 2X ADD A,#128 ; PRICTI 128 KVULI OFFSETU %L(SPEC_BMP_): MOV DPL,#0 MOV DPH,A ; NACTI ULOZENY OFFSET PRVNI BITMAPY MOV R2,#0 MOV R4,#64;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV B,#LEFT CALL SHOWY0 JMP %L(END) %L(2ZN): ; BUDES ZOBRAZOVAT DVA ZNAKY PUSH ACC MOV A,R7 ; ULOZ PRVNI BITMAPU MOV DPL,#0 MOV DPH,A MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV R2,#0 MOV B,#LEFT CALL SHOWY0 MOV DPL,#0 POP DPH MOV R2,#0 MOV R4,#32;* R4 ... RESOLUTION_X MOV R5,#64;* R5 ... RESOLUTION_Y MOV B,#RIGHT CALL SHOWY0 %L(END): RET ;******************************************************************************* ;* FUNKCE PREVADI CISLO V HEXA DO DEC ;* VSTUP: Acc ... HEXA CISLO ;* VYSTUP: Acc ... DESITKY ;* B ... JEDNOTKY ;* R0 ... STOVKY ;* NICI: Acc, Cy, B, R0, R1 ;******************************************************************************* A2DEC: MOV B,#100 DIV AB MOV R0,A ; ULOZ STOVKY MOV A,B MOV B,#10 DIV AB RET %RESLOCAL ;******************************************************************************* ;* HODNOTU V A (-99..99) PREVED DO BCD ;* VSTUP : A = DEKADICKE CISLO ;* VYSTUP: A = BCD CISLO ;* C = ZNAMENKO (1 = ZAPORNE CISLO) ;* MENI : A, B, C ;* STACK : 0 ;******************************************************************************* A2BCD: MOV B,#10 JB ACC.7,%L(M) DIV AB SWAP A ADD A,B CLR C RET ; TADY ZPRACUJ ZAPORNA CISLA %L(M): CPL A INC A DIV AB SWAP A ADD A,B SETB C RET ;******************************************************************************* ;* FUNKCE OTESTUJE OBSAH ZADANEHO BITMAP/TEXT PARAMETRU, ZDA NECO OBSAHUJE ;* VSTUP: DPTR ... ADRESA PARAMETRU ;* VYSTUP: F0 ... 0 - ZADNA BITMAPA/ 1 - JE BITMAPA ;* Cy ... 0 - ZADNY TEXT/ 1 - JE TEXT ;* NICI: Acc, Cy, B, R0, R1 ;******************************************************************************* TEST_PARM: ; ULOZ ADRESU PARAMETRU PUSH DPH PUSH DPL ; ZJISTI NEJDRIV, JESTLI MAS NEJAKY TEXT MOV R0,#3 CALL ParGetParm ; VRAT ZALOHU POP DPL POP DPH PUSH ACC ; ULOZ 1. VRACENY ZNAK ZOBRAZOVANEHO TEXTU MOV R0,#0 CALL ParGetParm MOV B,R0 %CMP(A,B) MOV F0,C ; ULOZ PRIZNAK BITMAPY POP ACC ; VYTAHNI ZE ZALOHY 1. ZNAK A OTESTUJ, ZDA NEJDE O "ENTER" %CMP(A,B) RET ;******************************************************************************* ;* FUNKCE VRACI HODNOTU PARAMETRU DLE RELATIVNIHO UKAZATELE ;* VSTUP: Acc ... RELATIVNI CISLO PARAMETRU V TABULCE ;* R0 ... POSUN V PARAMETRU ;* VYSTUP: Acc ... HODNOTA PARAMETRU ;* R2 ... MAX. HODNOTA ;* R1 ... MIN. HODNOTA ;* NICI: Acc, Cy, B, R0, R1, DPTR, .. ;******************************************************************************* GET_PARM_VAL_RAW: CALL GET_PARM_ADDR CALL ParGetParmRaw SJMP %L(END) GET_PARM_VAL: CALL GET_PARM_ADDR CALL ParGetParm %L(END): MOV B,R0 MOV R2,B RET GET_PARM_ADDR: PUSH AR0 ; ZALOHUJ R0 CALL GETMENU00 ; V DPTR VRACI POINTER NA POPIS PARAMETRU MOV DPL,R2 MOV DPH,R1 POP AR0 ; VRAT OFFSET RET ;******************************************************************************* ;* FUNKCE VRACI CISLO PARAMETRU A POINTER NA TEXT S POPISEM PARAMETRU ;* VSTUP: Acc ... RELATIVNI CISLO PARAMETRU V TABULCE ;* VYSTUP: Acc ... ABSOLUTNI CISLO PARAMETRU ;* B ..... TYP PARAMETRU ;* DPTR ... POINTER NA TEXT S POPISEM PARAMETRU ;* R2 ... LO_ADDR POINTER NA PARAMETR ;* R1 ... HI_BYTE POINTER NA PARAMETR ;* R3 ... LO_BYTE ADRESY MENUTAB ;* R4 ... HI_BYTE ADRESY MENUTAB ;* NICI: Acc, Cy, .. ;******************************************************************************* %RESLOCAL GETMENU00: MOV R1,A MOV R2,#0 MOV DPTR,#MENUCODE %L(CYKL): CLR A MOVC A,@A+DPTR ;MOV B,A ;ANL A,#MENUTYPE_MASK ; MASKUJ PREFIX PARAMETRU ;ANL B,#NOT MENUTYPE_MASK XCH A,R2 MOV B,R1 CLR F0 CJNE A,B,%L(TST) ; JE TO TENTO PARAMETR SETB F0 %L(TST): XCH A,R2 MOV B,A ANL A,#MENUTYPE_MASK ; MASKUJ PREFIX PARAMETRU ANL B,#NOT MENUTYPE_MASK JNB F0,%L(ADD) PUSH ACC ; ULOZ TYP PARAMETRU MOV R3,DPL ; ULOZ ADRESU NA PARAMETR V TABULCE MENUTAB MOV R4,DPH INC DPTR CLR A MOVC A,@A+DPTR PUSH ACC INC DPTR CLR A MOVC A,@A+DPTR MOV R1,A ; NACTI HIADDR POINTERU NA PARAMETR INC DPTR CLR A MOVC A,@A+DPTR MOV R2,A ; NACTI LOADDR POINTERU NA PARAMETR INC DPTR CLR A MOVC A,@A+DPTR XCH A,R0 INC DPTR CLR A MOVC A,@A+DPTR MOV DPL,A ; ZKOMPLETUJ ADRESU TEXTU MOV DPH,R0 POP ACC ; VRAT ZKUTECNE CISLO PARAMETRU POP B RET RET %L(ADD): MOV A,DPL ADD A,B MOV DPL,A CLR A ADDC A,DPH MOV DPH,A INC R2 SJMP %L(CYKL) ;******************************************************************************* ;* ;* R6 .... POCET DIGITU ;* ;******************************************************************************* %RESLOCAL _PRINT_INT: CALL A2DEC CJNE R6,#0,%L(01) SJMP %L(END) %L(01): CJNE R6,#1,%L(02) MOV A,B ADD A,#'0' MOV R0,A CALL _PUTCHAR SJMP %L(END) %L(02): CJNE R6,#2,%L(03) XCH A,B PUSH ACC ; ZALOHA JEDNOTKY XCH A,B ADD A,#'0' MOV R0,A CALL _PUTCHAR POP ACC ADD A,#'0' MOV R0,A CALL _PUTCHAR SJMP %L(END) %L(03): CJNE R6,#3,%L(END) XCH A,B PUSH ACC ; ZALOHA JEDNOTKY XCH A,B PUSH ACC ; ZALOHA DESITKY MOV A,R0 ADD A,#'0' ; VYPIS STOVKY MOV R0,A CALL _PUTCHAR POP ACC ADD A,#'0' MOV R0,A ; VYPIS DESITKY CALL _PUTCHAR POP ACC ADD A,#'0' MOV R0,A ; VYPIS JEDNOTKY CALL _PUTCHAR %L(END): RET STD_PARM: DB 124+32,' P00 ',125+32,0 ; DELKA 42 BODU ;******************************************************************** ; VRACI BITOVOU HODNOTU PARAMETRU ; VSTUP: DPTR .... ADRESA PARAMETRU ; VYSTUP: CY ..... HODNOTA PARAMETRU ;******************************************************************** GET_BIT_PARM: MOV R0,#0 CALL ParGetParm MOV C,ACC.0 RET END