📄 key.asm
字号:
S_EUR equ 0x23 ;'K '(fcR)
;S_EUM equ 0x24 ;'K-'
S_EUROS equ 0x24 ;'Euro'
S_EUEQ equ 0x25 ;'Euro ='
S_COST equ 0x26 ;'C '
S_SELL equ 0x27 ;' S'
S_MARG equ 0x28 ;'M%'
S_TAXA equ 0x29 ;' T'
S_ICG equ 0x2a ;'G '
S_G equ 0x2a
S_ICM equ 0x2b ;' M '
S_M equ 0x2b
;V4.02S_LCL equ 0x2c ;home+waru 1450TE V1.01
;V4.02S_LCAS equ 0x2d ;home+* 1450TE V1.01
;V4.02S_FC equ 0x2e ;euro+ x 1450TE V1.01
;V4.02S_FCAS equ 0x2f ;euro+* 1450TE V1.01
S_DLTA equ 0x2c;V4.020x30 ;delta+' '
S_PER equ 0x2d;V4.020x31 ;delta+' '
;S_EQU_A equ ;0x32 ;
S_CPAY equ 0x2e;V4.020x32 ;P* V3.13
S_TXPL equ 0x2f;V4.020x33 ;TX+
S_TXMI equ 0x30;V4.020x34 ;TX-
S_TLMGT equ 0x31;V4.020x35 ;TL M+
S_TX1PL equ 0x32;V4.020x36 ;TX1+
S_TX1MI equ 0x33;V4.020x37 ;TX1-
S_TX2PL equ 0x34;V4.020x38 ;TX2+
S_TX2MI equ 0x35;V4.020x39 ;TX2-
S_TAX1 equ 0x36;V4.020x3a ;T1%
S_TAX2 equ 0x37;V4.020x3b ;T2%
;V4.02S_GPM equ 0x3c ;GPM(MU)
;V4.02S_GS equ 0x3d
;V4.02S_GT equ 0x3d ;GT
;V4.02S_GPL equ 0x3e ;G+ for sigama=% when TA mode V2.11
S_STAMN equ 0x55
S_STAS equ 0x56
S_STASTA equ 0x57
;V3.00S_GS equ 0x0f ;G dia GT subtotal
;V3.00S_GT equ 0x10 ;G * GT total
;V3.00S_PRM equ 0x11 ;- % percent minus
;V3.00S_PRP equ 0x12 ;+ % percent plus
;V3.00S_DLP equ 0x13 ;d + delta plus(for tax+)
;V3.00S_DLM equ 0x14 ;d - delta plus(for tax-)
;V3.00S_AM equ 0x15 ;A M time print
;V3.00S_PM equ 0x16 ;P M time print
;V3.00S_CST equ 0xb7;0x17 ;C * cost price
;V3.00S_SEL equ 0x26;0x18 ;S * selling price
;V3.00S_MAR equ 0xa1;0x19 ;M % margine %
;V3.00S_MU equ 0xa2;0x1a ;M _ mark up
;V3.00S_MUD equ 0x57;0x1b ;d * delta of mark up
;V3.00S_SET equ 0x27;0x1d ;_ * for rate,time set(* only)
;V3.00S_SHD equ 0x22;0x1c ;_ _ for #/D print(space)
;V3.00S_TLG equ 0x93;0x0a ;G + total key with GT position
;==============================================================================
;V3.00S_FED equ 0x00 ;fh+' '
;V3.00S_PWR equ 0x17 ;'C*'
;V3.00S_PLS equ 0x01 ;' +'
;V3.00S_MIN equ 0x02 ;' -'
;V3.00S_SPC equ 0x00 ;' '
;V3.00S_SHP equ 0x26 ;' <>'
;V3.00S_TL equ 0x22 ;' *'
;V3.00S_TLGT equ 0x3c ;'*+'
;V3.00S_TLMGT equ 0x3d ;'*+'
;V3.00S_ST equ 0x08 ;' <>'
;V3.00S_MUL equ 0x03 ;' X'
;V3.00S_DIV equ 0x04 ;' /'
;V3.00S_EQU equ 0x05 ;' ='
;V3.00S_AST equ 0x22 ;' *'
;V3.00S_CLR equ 0x07 ;'c '
;V3.00S_MTL equ 0x0e ;'M*'
;V3.00S_MST equ 0x0d ;'M<>'
;V3.00S_MPL equ 0x0b ;'M+'
;V3.00S_MMI equ 0x0c ;'M-'
;V3.00S_M2TL equ 0x10 ;'G*'
;V3.00S_STASTA equ 0x77 ;'**'
;V3.00S_M2ST equ 0x0f ;'G<>'
;V3.00S_STAS equ 0x76 ;'*S'
;V3.00S_M2PL equ 0x3e ;'G+'
;V3.00S_STAPL equ 0x73 ;'*+'
;V3.00S_PLSTA equ 0x37 ;'+*'
;V3.00S_M2MI equ 0x3f ;'G-'
;V3.00S_STAMN equ 0x70 ;'*-'
;V3.00S_M2TLV equ 0x97 ;'G*'
;V3.00S_M2STV equ 0x96 ;'G<>'
;V3.00S_M2PLV equ 0x3e ;'G+'
;V3.00S_M2MIV equ 0x3f ;'G-'
;V3.00S_PER equ 0x06 ;' %'
;V3.00S_STAPER equ 0x71 ;'*%'
;V3.00S_PRDS equ 0x01 ;'-%'
;V3.00S_PRAD equ 0x31 ;'+%'
;V3.00S_DLTAL equ 0x82 ;delta+' '
;V3.00S_DLTA equ 0x28 ;' "+delta V1.26
;V3.00S_PRDL equ 0x81 ;delta+'%'
;V3.00S_DLAS equ 0x87 ;delta+'*'
;V3.00S_PRMU equ 0x21 ;' %'
;V3.00S_MKUP equ 0xa2 ;'M '
;V3.00S_RVS equ 0x22 ;' '
;V3.00S_AVR equ 0x27 ;' *'
;V3.00S_ROOT equ 0x22 ;' '
;V3.00S_TAX equ 0x12 ;'% '
;V3.00S_PRN equ 0x62 ;'<> '
;V3.00S_EUR equ 0x22 ;' '
;V3.00S_EUEQ equ 0xc2 ;'= '
;V3.00S_COST equ 0x2b ;' C'
;V3.00S_SELL equ 0x26 ;' <>'
;V3.00S_M equ 0x2a ;' M'
;V3.00S_MARG equ 0xa1 ;'M%'
;V3.00S_PERMARG equ 0x1a ;'%M'
;V3.00S_TAXA equ 0x27 ;' *'
;V3.00S_ICG equ 0x29 ;' G'
;V3.00S_ICGV equ 0x29 ;' G'
;V3.00S_ICM equ 0x2a ;' M'
;V3.00S_ASM equ 0x7a ;'*M'
;V3.00S_ASC equ 0x7b ;'*C'
;V3.00S_ASDL equ 0x78 ;'*'+delta
;V3.00S_MIPL equ 0x03 ;'-+'
;V3.00S_MIMI equ 0x00 ;'--'
;V3.00S_MIST equ 0x06 ;'-S'
;V3.00S_MITL equ 0x07 ;'-T'
;V3.00S_EUROS equ 0x29 ;' euro'
;V3.00S_G equ 0x9f ;'G '
;V3.00S_GPL equ 0x93 ;'G+'
;V3.00S_GAST equ 0x97 ;'G*'
;==============================================================================
P_SPC equ 0x20 ;for print " "
;-----------------------------------------------------------
;interrupt enable flag set:
EF4 equ 4;(EIRL).4 /INT0
EF5 equ 5;(EIRL).5 INTTC1
EF6 equ 6;(EIRL).6 INT1
EF7 equ 7;(EIRL).7 INTTBT
EF8 equ 0;(EIRH).0 INTTC3
EF9 equ 1;(EIRH).1 INTSIO(High speed SIO interrupt)
EF10 equ 2;(EIRH).2 INTTC4
EF11 equ 3;(EIRH).3 INT3
EF12 equ 4;(EIRH).4 INT4
EF13 equ 5;(EIRH).5 INTTC2
EF14 equ 6;(EIRH).6 /INT5
EF15 equ 7;(EIRH).7 INTADC or INT2
;interrupt request flag set:
IL2 equ 2;(ILL).2 INTSWI
IL3 equ 3;(ILL).3 INTATRAP
IL4 equ 4;(ILL).4 /INT0
IL5 equ 5;(ILL).5 INTTC1
IL6 equ 6;(ILL).6 INT1
IL7 equ 7;(ILL).7 INTTB
IL8 equ 0;(ILH).0 INTTC3
IL9 equ 1;(ILH).1 INTSIO
IL10 equ 2;(ILH).2 INTTC4
IL11 equ 3;(ILH).3 INT3
IL12 equ 4;(ILH).4 INT4
IL13 equ 5;(ILH).5 INTTC2
IL14 equ 6;(ILH).6 /INT5
IL15 equ 7;(ILH).7 INTADC or /INT2
; DBR_LCD_RATE equ (0x0f33<<4)+5 ;LCD DBR matrix point for "RATE"
; DBR_LCD1235_RATE equ (0x0f33<<4)+3 ;LCD DBR matrix point for "RATE"
; DBR_LCD1297_RATE equ (0x0f33<<4)+4 ;LCD DBR matrix point for "RATE"
; DBR_LCD120_RATE equ (0x0f33<<4)+4 ;LCD DBR matrix point for "RATE"
; DBR_LCD1297_GT equ (0x0f32<<4)+2 ;LCD DBR matrix point for "GT"
; ;LCD_PRN equ (0x0f31<<4)+3 ;LCD DBR matrix point for "PRINT"
; ;LCD_FIN equ (0x0f30<<4)+3 ;LCD DEB matrix point for "FIN"
AUTOOFFTIME equ 31250;1500
$list
public init_scan,key_scan,key_get,init_keybuf,update_md,mdsw_update,initial_mdsw_update
public wait_100ms,wait_50ms,wait_xms
extern off_key,lcd_display_symbol,vft_enable,vft_disable,disp_to_dbr
ROM section code
;==============================================================================
; I/O port bit assignment for reference
;==============================================================================
;------------------------------------------------
;Port assignment (P7) key matrax scan; output low level if key pressed
;------------------------------------------------
;P90 Key matrix scan0 out ;HH______________________HH______________________
;P91 Key matrix scan1 out ;__HH______________________HH____________________
;P92 Key matrix scan2 out ;____HH______________________HH__________________
;P93 Key matrix scan3 out ;______HH______________________HH________________
;P94 Key matrix scan4 out ;________HH______________________HH______________
;P95 Key matrix scan5 out ;__________HH______________________HH____________
;P96 Key matrix scan6 out ;____________HH______________________HH__________
;P97 Key matrix scan7 out ;______________HH______________________HH________
;============================================================================
;Port assignment (P3) and P20, key scan return and slider return
;-----------------------------------------------
;key return
;P10 Key matrix return0 in ;valid senser with high level
;P11 Key matrix return1 in ;
;P12 Key matrix return2 in ;
;P13 Key matrix return3 in ;
;P15 Key matrix return4 in ;
;slider return
;P50 slide matrix return0 in ;valid senser with high level
;P51 slide matrix return1 in ;
;P52 slide matrix return2 in ;
;P53 slide matrix return3
RET_GT equ 0y00000001 ;V1.23 return for GT key
SCAN_GT equ 0x03 ;V1.23 scan for GT key
RET_IC equ 0y00001000 ;V1.23return for IC key
SCAN_IC equ 0x07 ;V1.23 scan for IC key
RET_RATE equ 0y00000001 ;return for RATE key
RETV1205_RATE equ 0y00000100 ;V1.28
SCAN_RATE equ 0x0a ;scan for RATE key
SCANV1205_RATE equ 0x05 ;V1.28
RET_FEED equ 0y00000001 ;return for FEED key
SCAN_FEED equ 0x0b ;scan for FEED key
RET_SET equ 0y00001000 ;return for set(time) key
SCAN_SET equ 0x0a ;scan for set(time) key
COLOR equ 3
;==============================================================================
; Key scan interrupt (set 800us interval for TC4)
;==============================================================================
init_scan:
ld (P9DR),0y00000000 ;data latch to 0 (for initial value)
or (P1DR),0y00111111 ;
ld (P5CR),0y00000000 ;
ld (P5DR),0y00000000 ;set P50-P53 as input port
;T4CR: bit7(TFF4) bit654(TC4CK) bit3(TC4S) bit210(TC4M)
clr (ILH).IL10 ;clear TC4 interrupt flag
ld (TC4DR),100 ;16MHz/2^7/100 = 125Hz(800us)
di ;V2.05
set (EIRH).EF10 ;TC4 interrupt enable
ei ;V2.05
ld (TC4CR),0y00000100
ld (TC4CR),0y00100100 ;TC4S=1(count start) TC4CK=001(select fc/2^7) TC4M=000(select 8bittimer mode)
ret
;==============================================================================
; Initialize key buffer pointer, counter
;==============================================================================
init_keybuf:
di
ld (KEY_CT),0 ;key counter clear
ld (KEY_WPTR),0 ;key bufeer write pointer clear
ld (KEY_RPTR),0 ;key buffer read pointer clear
ei
ret
;==============================================================================
; Get key code from key buffer
; out: reg.a <- key code
; KEYIN <- key code
; c clear: illegal key
; use register: c,hl
;==============================================================================
key_get:
ld c,(KEY_RPTR) ;key buffer read pointer-->c
ld hl,KEY_BUF ;key buffer start address-->hl
ld a,(hl+c) ;key code wanted-->a
ld (KEYIN),a ;key code in a-->register KEYIN
inc c ;prepared for next key code
and c,0x3f ;\recycle KEY_RPTR in key buffer(3fh)
ld (KEY_RPTR),c ;/
dec (KEY_CT) ;key counter decrease one
cmp a,K_MAX ;over the max key code? no, set c is OK
ret
;==============================================================================
; and update MDFLG,DP_POS from MDFLG_RT,DP_POS_RT
;==============================================================================
;MDFLG_0:
;SW_DP0 ;SW_DP1;SW_DP2;SW_DP3;SW_DP4;SW_DP5;SW_DP6;SW_ADM
;MDFLG_1:
;SW_SGT,SW_SGM,SW_SGG,SW_SGK,SW_GT,SW_MGT,SW_RNDUP,SW_RND54
;MDFLG_2:
;SW_SG,SW_ICPM,SW_IC,SW_NP,SW_OFF,SW_AC,SW_V15,SW_FEED,SW_A,SW_M2,SW_AMZ
;MDFLG_3:
;SW_DTST,SW_ADM12,SW_EUTX,SW_D14,SW_D10,SW_TA,SW_M2,SW_FIN
;MDFLG_01:no use
;MDFLG_11:no use
;MDFLG_21:no use
;------------------------------------------
;===========================================================
update_md:
ld a,(MDFLG_RT0) ;
ld (MDFLG_0),a
ld a,(MDFLG_RT1) ;
ld (MDFLG_1),a
ld a,(MDFLG_RT2) ;
ld (MDFLG_2),a
ld a,(MDFLG_RT3) ;
ld (MDFLG_3),a
ld a,(DP_POS_RT) ;
ld (DP_POS),a
ld wa,M_FX_SGM
test (M_FX_SGM>>4).a ;bit -reverse-> jump status
j t,to_fix_ac ;if jump status is 1 -> branch
to_fix_sgm: ;V2.06
ld wa,SW_SGM
set (SW_SGM>>4).a
to_fix_ac:
ld wa,M_FX_AC
test (M_FX_AC>>4).a ;bit -reverse-> jump status
j t,to_fix_m14 ;if jump status is 1 -> branch
ld wa,SW_AC
set (SW_AC>>4).a
to_fix_m14:
ld wa,M_FX_M14
test (M_FX_M14>>4).a ;bit -reverse-> jump status
j t,to_fix_54 ;if jump status is 1 -> branch
ld wa,M14
set (M14>>4).a
to_fix_54: ;V2.06
;V3.00 @BBC (M_FX_54,to_fix_sd) ;V2.06
;V3.00 @SEB (SW_RND54) ;V2.06
;V3.00to_fix_sd: ;V2.06
;V3.00 @BBC (M_FX_SD,to_set_icpm) ;V2.06
;V3.00 @SEB (SW_DTST) ;V2.06
;V3.00to_set_icpm:
;V3.00 @BBC (SW_V15,to_fix_end) ;V2.07
;V3.00 @BBC (F_ICPM,to_set_icpm_1) ;V2.07 to set IC_PM
;V3.00 @SEB (SW_ICPM_RT) ;V2.07
;V3.00 @SEB (SW_ICPM) ;V2.07
;V3.00 jp to_fix_end ;V2.07
;V3.00to_set_icpm_1:
;V3.00 @CLB (SW_ICPM_RT) ;V2.07
;V3.00 @CLB (SW_ICPM) ;V2.07
;V3.00to_fix_end:
ret
;V2.00disp_rate_blink:
;V2.00 ret
;==============================================================================
;auto switch off time check, 5 minutes=300000us. (AUTO_OFF_TIME)=300000/400=750
;==============================================================================
;V2.03auto_off_check: ;V1.08
;V2.03 @BBC (M_HAND,auto_off_check_end) ;V1.18
;V2.03 ld wa,(AUTO_OFF_TIM)
;V2.03 cmp wa,0
;V2.03 jr eq,auto_off_check_end
;V2.03 dec wa
;V2.03 ld (AUTO_OFF_TIM),wa
;V2.03 cmp wa,0
;V2.03 jr ne,auto_off_check_end
;V2.03 ld wa,AUTOOFFTIME ;750 x 400=300000us=5 minutes
;V2.03 ld (AUTO_OFF_TIM),wa
;V2.03 @SEB (F_WAKE)
;V2.03auto_off_check_end:
;V2.03 ret
;==============================================================================
;display backlight color control green, green+red=salmon pink
;==============================================================================
blink_vfd:
;V4.11 @BBS (F_OFF,blink_vfd_off) ;V2.06
;V4.11 @BBS (IO_MT,blink_vfd_off) ;V2.07
;V3.00 @BBS (RATE_PROG,blink_vfd_start)
;V3.00 @BBS (EURO_PROG,blink_vfd_start)
;V4.11 @BBS (IC_PROG,blink_vfd_start)
;V3.00 @BBS (RTC_SET,blink_vfd_start)
;V4.11 @CLB (F_BLINK) ;V2.10
;V4.11 ret
blink_vfd_start:
;V4.11 inc (BLK_CT)
;V4.11 inc (BLK_CT)
;V4.11 ld a,(BLK_CT)
;V4.11 and a,0x7f
;V4.11 cmp a,0x40
;V4.11 j ge,blink_vfd_on
;V4.11 @CLB (F_BLINK) ;V2.10
;V4.11 jp blink_vfd_end ;V2.10
blink_vfd_on:
;V4.11 @SEB (F_BLINK) ;V2.10
blink_vfd_end:
;V4.11 call disp_to_dbr ;V2.10
;V4.11 ret ;V2.10
blink_vfd_off: ;V2.10
;V4.11 call vft_disable ;V2.10
;V4.11 @CLB (F_BLINK) ;V2.10
ret ;V2.10
;------------------------------------V2.05
wait_100ms:
ld (DELAY_CT),125 ;800usx125 -> 100ms
j wait_xms
wait_50ms:
ld (DELAY_CT),62 ;800usx62-> 49.6ms
wait_xms:
cmp (DELAY_CT),0
j ne,wait_xms
ret
;==============================================================================
; Key scan interrupt
;==============================================================================
;V1.39aKON_TIM equ 2 ;judgement for key press (800us*12scan*2=19.2ms to 19.2ms+800*11scan=28ms)
;V1.34KOFF_TIM equ 4 ;judgement for key release (800us*12scan*4=38.4ms to 38.4ms+800*11scan=47.2ms)
;V1.39aKOFF_TIM equ 2
KON_TIM equ 1 ;V1.39a
KOFF_TIM equ 3 ;V1.39a
MD_TIM equ 15 ;judgement for mode sw moved (800us*12scan*15=144ms)
;MD_TIM equ 10 ;judgement for mode sw moved (392us*12scan*10=47.040ms)
key_scan:
push wa
push bc
push de
push hl
push ix
push iy
cmp (DELAY_CT),0
j eq,check_delay_time
dec (DELAY_CT)
check_delay_time:
ld wa,IO_MT
test (IO_MT>>4).a ;bit -reverse-> jump status
j t,key_scan00 ;if jump status is 1 -> branch
;V3.00 @RST_IN_ON(key_scan99) ;when print reset sign checked in, jump out
;V3.12 ei ;V3.00
key_scan00:
ld a,(EP_TIM) ;\
j z,key_scan_01 ;|during EEPROM reading and writing, skip to key scan end
dec (EP_TIM) ;|
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -