msbasic/print.s

384 lines
6.8 KiB
ArmAsm
Raw Normal View History

2008-10-13 02:14:07 +00:00
.segment "CODE"
PRSTRING:
jsr STRPRT
L297E:
jsr CHRGOT
; ----------------------------------------------------------------------------
; "PRINT" STATEMENT
; ----------------------------------------------------------------------------
PRINT:
beq CRDO
PRINT2:
beq L29DD
cmp #TOKEN_TAB
beq L29F5
cmp #TOKEN_SPC
2008-10-13 20:26:42 +00:00
.ifdef CONFIG_2
2008-10-13 08:55:33 +00:00
clc ; also AppleSoft II
2008-10-13 02:14:07 +00:00
.endif
beq L29F5
cmp #','
2008-10-13 08:55:33 +00:00
; Pre-KIM had no CLC. KIM added the CLC
; here. Post-KIM moved the CLC up...
2008-10-13 02:14:07 +00:00
.ifdef KIM
clc
.endif
beq L29DE
cmp #$3B
beq L2A0D
jsr FRMEVL
bit VALTYP
bmi PRSTRING
jsr FOUT
jsr STRLIT
2008-10-13 08:55:33 +00:00
.ifndef CONFIG_NO_CR
2008-10-13 02:14:07 +00:00
ldy #$00
lda (FAC_LAST-1),y
clc
2008-10-13 09:34:49 +00:00
adc POSX
2008-10-13 08:55:33 +00:00
.ifdef KBD
2008-10-13 02:14:07 +00:00
cmp #$28
2008-10-13 08:55:33 +00:00
.else
2008-10-13 02:14:07 +00:00
cmp Z17
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 02:14:07 +00:00
bcc L29B1
jsr CRDO
L29B1:
.endif
jsr STRPRT
.ifdef KBD
jmp L297E
2008-10-13 09:12:45 +00:00
.else
jsr OUTSP
bne L297E ; branch always
.endif
2008-10-13 08:55:33 +00:00
2008-10-13 09:12:45 +00:00
.ifdef KBD
2008-10-13 08:55:33 +00:00
; PATCHES
2008-10-13 02:14:07 +00:00
LE86C:
pla
jmp CONTROL_C_TYPED
LE870:
jsr GETBYT
txa
LE874:
beq LE878
bpl LE8F2
LE878:
jmp IQERR
2008-10-13 09:12:45 +00:00
; PATCHES
.endif
.ifndef KBD
2008-10-13 02:14:07 +00:00
L29B9:
2008-10-13 08:55:33 +00:00
.ifdef CBM2
2008-10-13 02:14:07 +00:00
lda #$00
sta INPUTBUFFER,x
ldx #<(INPUTBUFFER-1)
ldy #>(INPUTBUFFER-1)
2008-10-13 08:55:33 +00:00
.else
.ifndef APPLE
2008-10-13 02:14:07 +00:00
ldy #$00
sty INPUTBUFFER,x
ldx #LINNUM+1
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 20:44:36 +00:00
.ifdef MICROTAN
2008-10-16 07:42:48 +00:00
bne CRDO2
2008-10-13 20:44:36 +00:00
.endif
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 09:12:45 +00:00
.ifdef CONFIG_FILE
2008-10-13 02:14:07 +00:00
lda Z03
bne L29DD
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 09:12:45 +00:00
.endif
2008-10-13 02:14:07 +00:00
CRDO:
2008-10-13 09:12:45 +00:00
.if .def(CONFIG_PRINTNULLS) && .def(CONFIG_FILE)
2008-10-13 02:14:07 +00:00
lda Z03
bne LC9D8
sta $05
LC9D8:
2008-10-13 09:12:45 +00:00
.endif
lda #CRLF_1
.ifndef CONFIG_CBM_ALL
2008-10-13 09:34:49 +00:00
sta POSX
2008-10-13 09:12:45 +00:00
.endif
2008-10-13 02:14:07 +00:00
jsr OUTDO
2008-10-16 07:42:48 +00:00
CRDO2:
2008-10-13 09:12:45 +00:00
lda #CRLF_2
2008-10-13 02:14:07 +00:00
jsr OUTDO
2008-10-13 09:12:45 +00:00
2008-10-13 02:14:07 +00:00
PRINTNULLS:
2008-10-13 09:12:45 +00:00
.ifdef KBD
lda #$00
sta $10
eor #$FF
.else
2008-10-13 08:55:33 +00:00
.if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS)
.ifdef CONFIG_FILE
; Although there is no statement for it,
; CBM1 had NULL support and ignores
2008-10-17 06:31:11 +00:00
; it when not targeting the screen,
2008-10-13 08:55:33 +00:00
; CBM2 dropped it completely.
2008-10-13 02:14:07 +00:00
lda Z03
bne L29DD
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 02:14:07 +00:00
txa
pha
ldx Z15
beq L29D9
lda #$00
L29D3:
jsr OUTDO
dex
bne L29D3
L29D9:
2008-10-13 09:34:49 +00:00
stx POSX
2008-10-13 02:14:07 +00:00
pla
tax
2008-10-13 08:55:33 +00:00
.else
.ifdef APPLE
2008-10-13 02:14:07 +00:00
lda #$00
sta $50
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 02:14:07 +00:00
eor #$FF
2008-10-13 08:55:33 +00:00
.endif
2008-10-13 02:14:07 +00:00
.endif
L29DD:
rts
L29DE:
2008-10-13 09:34:49 +00:00
lda POSX
.ifndef CONFIG_NO_CR
.ifdef KBD
2008-10-13 02:14:07 +00:00
cmp #$1A
2008-10-13 09:34:49 +00:00
.else
2008-10-13 02:14:07 +00:00
cmp Z18
2008-10-13 09:34:49 +00:00
.endif
2008-10-13 02:14:07 +00:00
bcc L29EA
jsr CRDO
jmp L2A0D
L29EA:
.endif
sec
L29EB:
.ifdef CONFIG_CBM_ALL
sbc #$0A
.else
2008-10-13 09:34:49 +00:00
.ifdef KBD
2008-10-13 02:14:07 +00:00
sbc #$0D
2008-10-13 09:34:49 +00:00
.else
2008-10-13 02:14:07 +00:00
sbc #$0E
2008-10-13 09:34:49 +00:00
.endif
2008-10-13 02:14:07 +00:00
.endif
bcs L29EB
eor #$FF
adc #$01
bne L2A08
L29F5:
2008-10-13 09:34:49 +00:00
.ifdef CONFIG_11A
2008-10-13 02:14:07 +00:00
php
.else
pha
.endif
jsr GTBYTC
2008-10-13 09:34:49 +00:00
cmp #')'
2008-10-13 10:18:55 +00:00
.ifdef CONFIG_11A
2008-10-13 20:26:42 +00:00
.ifdef CONFIG_2
2008-10-13 10:18:55 +00:00
bne SYNERR4
.else
jne SYNERR
.endif
plp
bcc L2A09
.else
.ifdef APPLE
2008-10-13 02:14:07 +00:00
beq L1185
jmp SYNERR
L1185:
2008-10-13 10:18:55 +00:00
.else
2008-10-13 02:14:07 +00:00
bne SYNERR4
2008-10-13 10:18:55 +00:00
.endif
2008-10-13 02:14:07 +00:00
pla
cmp #TOKEN_TAB
2008-10-13 10:18:55 +00:00
.ifdef APPLE
2008-10-13 02:14:07 +00:00
bne L2A09
2008-10-13 10:18:55 +00:00
.else
2008-10-13 02:14:07 +00:00
bne L2A0A
2008-10-13 10:18:55 +00:00
.endif
2008-10-13 02:14:07 +00:00
.endif
txa
2008-10-13 09:34:49 +00:00
sbc POSX
2008-10-13 02:14:07 +00:00
bcc L2A0D
.ifndef CONFIG_11
beq L2A0D
.endif
L2A08:
tax
.ifdef CONFIG_11
L2A09:
inx
.endif
L2A0A:
.ifndef CONFIG_11
jsr OUTSP
.endif
dex
.ifndef CONFIG_11
bne L2A0A
.else
bne L2A13
.endif
L2A0D:
jsr CHRGET
jmp PRINT2
.ifdef CONFIG_11
L2A13:
jsr OUTSP
bne L2A0A
.endif
; ----------------------------------------------------------------------------
; PRINT STRING AT (Y,A)
; ----------------------------------------------------------------------------
STROUT:
jsr STRLIT
; ----------------------------------------------------------------------------
; PRINT STRING AT (FACMO,FACLO)
; ----------------------------------------------------------------------------
STRPRT:
jsr FREFAC
tax
ldy #$00
inx
L2A22:
dex
beq L29DD
lda (INDEX),y
jsr OUTDO
iny
cmp #$0D
bne L2A22
jsr PRINTNULLS
jmp L2A22
; ----------------------------------------------------------------------------
OUTSP:
2008-10-13 10:18:55 +00:00
.ifdef CONFIG_FILE
.ifndef CONFIG_SPC_IS_CRSR_RIGHT
lda Z03
2008-10-13 02:14:07 +00:00
beq LCA40
lda #$20
.byte $2C
LCA40:
2008-10-13 10:18:55 +00:00
.endif
lda #$1D ; CRSR RIGHT
2008-10-13 02:14:07 +00:00
.else
lda #$20
.endif
.byte $2C
OUTQUES:
lda #$3F
; ----------------------------------------------------------------------------
; PRINT CHAR FROM (A)
; ----------------------------------------------------------------------------
OUTDO:
.ifndef KBD
bit Z14
bmi L2A56
.endif
2008-10-17 06:31:11 +00:00
.if .def(CONFIG_PRINT_CR) || .def(CBM1)
2008-10-13 02:14:07 +00:00
pha
.endif
.ifdef CBM1
2008-10-13 10:18:55 +00:00
cmp #$1D ; CRSR RIGHT
2008-10-13 02:14:07 +00:00
beq LCA6A
2008-10-13 10:18:55 +00:00
cmp #$9D ; CRSR LEFT
2008-10-13 02:14:07 +00:00
beq LCA5A
2008-10-13 10:18:55 +00:00
cmp #$14 ; DEL
2008-10-13 02:14:07 +00:00
bne LCA64
LCA5A:
2008-10-13 10:18:55 +00:00
lda POSX
2008-10-13 02:14:07 +00:00
beq L2A4E
lda Z03
bne L2A4E
2008-10-13 10:18:55 +00:00
dec POSX
2008-10-13 02:14:07 +00:00
LCA64:
and #$7F
.endif
.ifndef CBM2
cmp #$20
bcc L2A4E
.endif
LCA6A:
.ifdef CONFIG_CBM1_PATCHES
lda Z03
jsr PATCH6
nop
.endif
.ifdef CONFIG_PRINT_CR
2008-10-13 09:34:49 +00:00
lda POSX
2008-10-13 02:14:07 +00:00
cmp Z17
bne L2A4C
2008-10-13 10:18:55 +00:00
.ifdef APPLE
2008-10-13 02:14:07 +00:00
nop ; PATCH!
nop ; don't print CR
nop
2008-10-13 10:18:55 +00:00
.else
2008-10-13 02:14:07 +00:00
jsr CRDO
2008-10-13 10:18:55 +00:00
.endif
2008-10-13 02:14:07 +00:00
L2A4C:
.endif
.ifndef CONFIG_CBM_ALL
2008-10-13 09:34:49 +00:00
inc POSX
2008-10-13 02:14:07 +00:00
.endif
L2A4E:
2008-10-17 06:31:11 +00:00
.if .def(CONFIG_PRINT_CR) || .def(CBM1)
2008-10-13 02:14:07 +00:00
pla
.endif
2008-10-16 08:21:21 +00:00
.ifdef CONFIG_MONCOUT_DESTROYS_Y
2008-10-13 02:14:07 +00:00
sty DIMFLG
.endif
2008-10-13 10:18:55 +00:00
.ifdef CONFIG_IO_MSB
2008-10-13 02:14:07 +00:00
ora #$80
.endif
jsr MONCOUT
2008-10-13 10:18:55 +00:00
.ifdef CONFIG_IO_MSB
2008-10-13 02:14:07 +00:00
and #$7F
.endif
2008-10-16 08:21:21 +00:00
.ifdef CONFIG_MONCOUT_DESTROYS_Y
2008-10-13 02:14:07 +00:00
ldy DIMFLG
.endif
.ifdef OSI
nop
nop
nop
nop
.endif
L2A56:
and #$FF
LE8F2:
rts
2008-10-13 10:18:55 +00:00
; ----------------------------------------------------------------------------
; ???
; ----------------------------------------------------------------------------
2008-10-13 02:14:07 +00:00
.ifdef KBD
LE8F3:
pha
lda $047F
clc
beq LE900
lda #$00
sta $047F
sec
LE900:
pla
rts
.endif