📄 printer.asm
字号:
clr (ILH).IL13 ;clear TC6 request (ILH:bit4)
set (EIRH).EF13 ;set TC6 enable (EIRH:bit4)
ld (TC2CR),0y00101110 ;TC2CK(011)=fc/2^3 0.5us TC2S(1):start TC2M(0):timer mode
ei
; call dbr_disp_clear ;DBR clear(real display data)
; call bl_off
call vft_disable
ret
;V4.14============================================================
print_int_check:
ld wa,F_INIREQ
test (F_INIREQ>>4).a ;bit -reverse-> jump status
j t,print_need_int ;if jump status is 1 -> branch
ld wa,F_INIREQ
clr (F_INIREQ>>4).a
call prn_init ;V4.14
print_need_int: ;V4.14
ret ;V4.14
;---------------------------------------------------------------------------------
; Space Print / 1-Line Print
print:
call print_int_check ;V4.14
;V4.14 @BBC (F_INIREQ,print_need_int) ;V4.08
;V4.14 @CLB (F_INIREQ) ;V4.10
;V4.14 call prn_init ;V4.08
;V4.14print_need_int: ;V4.08
ld wa,F_REDBAK
clr (F_REDBAK>>4).a
ld wa,P_RED
test (P_RED>>4).a ;bit -reverse-> jump status
j t,prnl_top0 ;if jump status is 1 -> branch
ld wa,F_REDBAK
set (F_REDBAK>>4).a
ld wa,P_RED
clr (P_RED>>4).a
prnl_top0:
ld wa,F_FEED
test (F_FEED>>4).a ;bit -reverse-> jump status
j f,prnl_top0 ;if jump status is 0 -> branch
ld wa,SW_LTP
test (SW_LTP>>4).a ;bit -reverse-> jump status
j f,prnl_top1 ;if jump status is 0 -> branch
di
ld wa,F_EXFED
test (F_EXFED>>4).a ;bit -reverse-> jump status
j t,prnl_top1 ;if jump status is 1 -> branch
ei
prnl_top01:
ld wa,F_EXFED
test (F_EXFED>>4).a ;bit -reverse-> jump status
j f,prnl_top01 ;if jump status is 0 -> branch
prnl_top02:
ld wa,F_RUSH
test (F_RUSH>>4).a ;bit -reverse-> jump status
j t,prnl_top02 ;if jump status is 1 -> branch
ld wa,F_PRINT
set (F_PRINT>>4).a
ld wa,F_PRREQ
set (F_PRREQ>>4).a
j prnl_top10
prnl_top1:
di
ld wa,F_PRREQ
set (F_PRREQ>>4).a
ld wa,F_PRINT
test (F_PRINT>>4).a ;bit -reverse-> jump status
j f,prnl_x1 ;if jump status is 0 -> branch
ld (STEP_CT),0 ;MT step count clear (0~52)
ld wa,F_PRINT
set (F_PRINT>>4).a
ld wa,F_RUSH
test (F_RUSH>>4).a ;bit -reverse-> jump status
j t,prnl_x0 ;if jump status is 1 -> branch
prnl_top10:
ld wa,F_RUSH
clr (F_RUSH>>4).a
di ;
ld (TC2CR),0y00001110 ;TC2CK(011)=fc/2^3 TC2S(0):stop TC2M(0):timer mode
clr (EIRH).EF13 ;clear TC2 enable (EIRH:bit4)
ldw (TC2DRL),STP_NORM ;set TC2DR
ld (TC2CR),0y00001110 ;TC2CK(011)=fc/2^3 TC2S(0):stop TC2M(0):timer mode
clr (ILH).IL13 ;clear TC6 request (ILH:bit4)
set (EIRH).EF13 ;set TC6 enable (EIRH:bit4)
ld (TC2CR),0y00101110 ;TC2CK(011)=fc/2^3 0.5us TC2S(1):start TC2M(0):timer mode
ei ;
j prnl_x1
prnl_x0:
ei
call start_up ;MT driver enable, motor start, dbr clear BL off
prnl_x1:
di ;V4.07
ld wa,F_LARGP
clr (F_LARGP>>4).a
ld wa,F_ENLARG
test (F_ENLARG>>4).a ;bit -reverse-> jump status
j t,prnl_x1x ;if jump status is 1 -> branch
ld wa,F_LARGP
set (F_LARGP>>4).a
ld wa,F_ENLARG
clr (F_ENLARG>>4).a
prnl_x1x: ;V4.07
ei
and (P4DR),0y11111100 ;AIN1,AIN0 must set '0' for AD convert
ld (ADCCR1),0y00100000 ;AD conv. stop s/w start AIN enable select AIN0(P40)
ld (ADCCR2),0y00011000 ;Rudder connect when AD convert only, ACK=312/fc (19.5us convert time 16MHz)
set (ADCCR1).7 ;AD convert start
ld wa,SW_LTP
test (SW_LTP>>4).a ;bit -reverse-> jump status
j f,prnl_x2 ;if jump status is 0 -> branch
ld wa,F_RVREQ
test (F_RVREQ>>4).a ;bit -reverse-> jump status
j t,prnl_x2 ;if jump status is 1 -> branch
ld wa,F_RVREQ
clr (F_RVREQ>>4).a
ld wa,F_RVSE
set (F_RVSE>>4).a
dec (PHASE_CT)
prnl_x2:
ld (LINE_PTR),0 ;the line location of font(0~19)
ld (LINE_PTR_BK),0 ;V4.03
loop02d:
ld cf,(ADCDR2).5 ;EOCF=1?
j cc,loop02d
ld a,(ADCDR1) ;get AD convert value
cmp a,224
j lt,prnl_01
ld a,223
prnl_01:
sub a,77
j cc,prnl_02
ld a,0
prnl_02:
ld w,0 ;V4.05
shrc a
test (FLG_MODE).0
j t,prnl_02x
ld c,a
ld hl,temp_table
ld a,(hl+c)
ld (HD_TEMP),a ;keep head temparature
jp prnl_02y ;V4.16
prnl_02x:
shlc a ;V4.04
add wa,lg_temp_table ;V4.05
ld de,wa ;V4.05
ld wa,(de) ;V4.05
ld (HD_TEMP),wa
prnl_02y:
ld wa,F_BHLD
clr (F_BHLD>>4).a
;--------------------------------------------------------------
prnl_00:
call prnbuf_to_dot ;PRN_BUF(1line data)--> DOT_LINE
prnl_11:
ld wa,F_BHLD
test (F_BHLD>>4).a ;bit -reverse-> jump status
j f,prnl_11 ;if jump status is 0 -> branch
ld wa,F_BHLD
set (F_BHLD>>4).a
call font_tx ; 1 dotline(288dots)---> shift registor of printer
inc (LINE_PTR_BK) ;V4.03
ld wa,F_LARGP
test (F_LARGP>>4).a ;bit -reverse-> jump status
j t,prn1_11_y ;if jump status is 1 -> branch
cmp (LINE_PTR_BK),3 ;V4.03
j eq,prn1_11_x ;V4.03
cmp (LINE_PTR_BK),7 ;V4.03
j eq,prn1_11_x ;V4.03
cmp (LINE_PTR_BK),11 ;V4.03
j eq,prn1_11_x ;V4.03
cmp (LINE_PTR_BK),15 ;V4.03
j eq,prn1_11_x ;V4.03
cmp (LINE_PTR_BK),19 ;V4.03
j eq,prn1_11_x ;V4.03
cmp (LINE_PTR_BK),23 ;V4.03
j eq,prn1_11_x ;V4.03
prn1_11_y: ;V4.03
inc (LINE_PTR) ;
prn1_11_x: ;V4.03
cmp (LINE_PTR),20 ; last line?
j lt,prnl_00 ;no
;--------------------------------------------------------------
prnl_90:
ld wa,F_PRREQ
test (F_PRREQ>>4).a ;bit -reverse-> jump status
j f,prnl_90 ;if jump status is 0 -> branch
ret
;
;1line dot(288dots) transmit.....................................................
font_tx:
and (P1DR),0y10111111
nop
or (P1DR),0y11000000 ;P17(CK: Hi-z), P16(EEIN: Hi-z)
ld (SIOCR1),0y01001100 ;SIOS=0, SIOINH=1 to abort and initial "SIOSR", SIOM=00(8bit Tx),SIODIR=1 LSB, SCK=fc/2^4
ld (SIOCR2),0y00000000
ld (DOT_CT),0 ;total dot q'ty of 1line
ld hl,DOT_LINE ;
ld c,0
ld e,(hl+c) ;5
ld (SIOBUF),e ;5
ld (SIOCR1),0y10001100 ;SIOS=1 SIOINH=0 SIOM=00(8bit Tx) SIODIR=1 SCK=fc/2^4
j font_tx_12
font_tx_1:
ld cf,(SIOSR).6 ;check shift end flag
j cs,font_tx_1
; or (P1DR),0y11000000 ;P17(CK: Hi-z), P16(EEIN: Hi-z)
ld e,(hl+c) ;5
ld (SIOBUF),e ;5
font_tx_12:
ld d,0
add de,dotcnt_tbl ;4
ld a,(de) ;3
add a,(DOT_CT) ;5
j cs,font_tx_2 ;2
ld (DOT_CT),a ;5
font_tx_2:
inc c ;1
cmp c,36 ;3
j lt,font_tx_1 ;4
; ----
; 42 cycle = 21us *transration speed = 16us/1byte
ld (SIOCR1),0y00001100 ;SIOS=0, SIOINH=1 to abort and initial "SIOSR", SIOM=00(8bit Tx) SCK=fc/2^4
or (P1DR),0y11000000 ;P17(CK: Hi-z), P16(EEIN: Hi-z)
ret
sio_int:
reti
;----------------------------------------------------------------------
; PRN_BUF(1line data)-> DOT_LINE
;
prnbuf_to_dot:
ld c,0 ;reg.c <-- location of PRN_BUF(0~23)
ld ix,DOT_LINE ;reg.ix <-- address of DOT_LINE (+0 to +35)
prn_dot_00:
ld hl,PRN_BUF ;
ld a,(hl+c) ;get 1digit character reg.a reg.w
call font_dot ;get font data -> reg.wa dddd dddd dddd 0000
ld cf,c.0 ;
j cs,prn_dot_20 ;odd digit? yes->
ld (ix),wa ;DOT_LINE <-- font data (+0 <-- reg.a +1 <-- reg.w)
inc ix
j prn_dot_30
prn_dot_20:
swap a
ld b,a
and b,0xf0
or b,(ix)
ld (ix),b
inc ix
swap w
and a,0x0f
or a,w
ld (ix),a
inc ix
or w,(ix)
prn_dot_30:
inc c
cmp c,PRN_MAX
j lt,prn_dot_00
ret
;
;------------------------------------------------------------------------
; Get font data
; In: Reg.a <- ascii code reg.a reg.w
; Out: Reg.wa <- Font data dddd dddd dddd 0000
font_dot:
;V4.02 sub a,0x20
;V4.02 j cc,font_dot_1
;V4.02 ld a,0
;V4.02font_dot_1:
ld b,a ;reg.b <- save character code
;V4.02 cmp a,0x10
;V4.02 j lt,font_dot_3
;V4.02 cmp a,0x1a
cmp a,10 ;V4.02 to check the digitals
j ge,font_dot_3 ;not idgit-->
;numeric (10h to 19h)
;3.00 @BBS (F_SMALLNUM,font_dot_11) ;
;V4.02 @BBS (F_REDBAK,font_dot_12)
ld wa,F_REDBAK
test (F_REDBAK>>4).a ;bit -reverse-> jump status
j t,font_dot_3 ;if jump status is 1 -> branch
ld a,b
;V4.02 j font_dot_3
;3.00font_dot_11:
;3.00 ld de,font_snum
;3.00 j font_dot_13
font_dot_12:
ld de,font_bnum
font_dot_13:
;V4.02 sub b,0x10
;V4.02 ld a,b
j font_dot_4
font_dot_3:
ld a,b
ld de,font_data
font_dot_4:
ld w,20*2 ;20 x 2 bytes / 1font data
mul w,a
add de,wa
ld a,(LINE_PTR)
shlc a
ld w,0
add de,wa
ld wa,(de)
ret
;==============================================================================
; Timer6Interrupt (STEPPING MT / phase chopping control)
;==============================================================================
;Stepping MT drive........................................................
tm2_int:
push wa
push bc
push de
push hl
push ix
push iy
ld (TC2CR),0y00001110 ;TC2CK(011)=fc/2^3 TC2S(0):stop TC2M(0):timer mode
clr (EIRH).EF13 ;clear TC2 enable (EIRH:bit4)
ld wa,F_STBDLY
test (F_STBDLY>>4).a ;bit -reverse-> jump status
j t,timer_y_000 ;if jump status is 1 -> branch
ld wa,F_CHPOFF
test (F_CHPOFF>>4).a ;bit -reverse-> jump status
j t,timery_0 ;if jump status is 1 -> branch
ld wa,F_CHPOFF
clr (F_CHPOFF>>4).a
and (P4DR),0y11111100 ;AIN1,AIN0 must set '0' for AD convert
or (P4DR),0y00011000 ;P44P43 set '1'(ENA1,ENA2)
ldw (TC2DRL),STP_CPON ;set TC2DR
j tm2_exit
timery_0:
ld wa,F_CHPOFF
set (F_CHPOFF>>4).a
and (P4DR),0y11100100 ;AIN1,AIN0 must set '0' for AD convert,P44P43 set '0'(ENA1,ENA2)
ldw (TC2DRL),STP_CPOF ;set TC2DR
j tm2_exit
;chopping process for long strobe pulse.....
timery_add: ;Step Time + ADD(300us) + ON(300us)
; @SEB (F_CHPOFF) ;Next phase ON(= 300us)
; @T2_SET (STP_CPON) ;set 300us
ld wa,F_CHPOFF
set (F_CHPOFF>>4).a
and (P4DR),0y11100100 ;AIN1,AIN0 must set '0' for AD convert,P44P43 set '0'(ENA1,ENA2)
ldw (TC2DRL),STP_CPOF ;set TC2DR
tm2_exit:
ld (TC2CR),0y00001110 ;TC2CK(011)=fc/2^3 TC2S(0):stop TC2M(0):timer mode
clr (ILH).IL13 ;clear TC6 request (ILH:bit4)
set (EIRH).EF13 ;set TC6 enable (EIRH:bit4)
ld (TC2CR),0y00101110 ;TC2CK(011)=fc/2^3 0.5us TC2S(1):start TC2M(0):timer mode
pop iy
pop ix
pop hl
pop de
pop bc
pop wa
reti
;
;--------------------------------------------------------------------------------------
timer_y_000:
ld wa,F_PRINT
test (F_PRINT>>4).a ;bit -reverse-> jump status
j f,timer_y_prn ;if jump status is 0 -> branch
ld wa,F_FEED
test (F_FEED>>4).a ;bit -reverse-> jump status
j f,timer_y_feed ;if jump status is 0 -> branch
ld wa,F_INIT
test (F_INIT>>4).a ;bit -reverse-> jump status
j f,timer_y_init ;if jump status is 0 -> branch
;finish rush step --> complete printing
and (P4DR),0y11111000 ;AIN1,AIN0 must set '0' for AD convert, P42(VPR) set'0'
clr (F_PCONT+2).6 ;IO_MT equ (F_PCONT+2<<4)+6
and (P4DR),0y11100100 ;AIN1,AIN0 must set '0' for AD convert,P44P43 set '0'(ENA1,ENA2)
ld (SIOCR1),0y00001100 ;SIOS=0, SIOINH=1 to abort and initial "SIOSR", SIOM=00(8bit Tx) SCK=fc/2^4
or (P1DR),0y11000000 ;P17(CK: Hi-z), P16(EEIN: Hi-z)
ld wa,P_MOVE
clr (P_MOVE>>4).a
ld wa,F_RUSH
clr (F_RUSH>>4).a
ld wa,F_REVCAN
test (F_REVCAN>>4).a ;bit -reverse-> jump status
j f,timer_y_exit ;if jump status is 0 -> branch
; call tempdbr_to_dbr ;copy temporally edit area -> real DBR
; call bl_on
call vft_enable
j timer_y_exit
;
timer_y_init:
ld wa,SW_LTP
test (SW_LTP>>4).a ;bit -reverse-> jump status
j f,ltp_timer_y_init ;if jump status is 0 -> branch
inc (STEP_CT)
cmp (STEP_CT),16
j lt,timer_y_i2
ld wa,F_INIT
clr (F_INIT>>4).a
j timer_y_rush ;---> Motor stop Rush
timer_y_i2:
call phase_out
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -