| Line 57... |
Line 57... |
TXTUNF EQU 0x701
|
TXTUNF EQU 0x701
|
VARBGN EQU 0x702
|
VARBGN EQU 0x702
|
LOPVAR EQU 0x703
|
LOPVAR EQU 0x703
|
STKGOS EQU 0x704
|
STKGOS EQU 0x704
|
CURRNT EQU 0x705
|
CURRNT EQU 0x705
|
BUFFER EQU 0x406
|
BUFFER EQU 0x706
|
BUFLEN EQU 84
|
BUFLEN EQU 84
|
LOPPT EQU 0x760
|
LOPPT EQU 0x760
|
LOPLN EQU 0x761
|
LOPLN EQU 0x761
|
LOPINC EQU 0x762
|
LOPINC EQU 0x762
|
LOPLMT EQU 0x763
|
LOPLMT EQU 0x763
|
| Line 92... |
Line 92... |
jmp BYEBYE ; Jump to monitor, DOS, etc.
|
jmp BYEBYE ; Jump to monitor, DOS, etc.
|
;
|
;
|
; Modifiable system constants:
|
; Modifiable system constants:
|
;
|
;
|
align 4
|
align 4
|
TXTBGN dw 0x04080000 ;TXT ;beginning of program memory
|
;THRD_AREA dw 0x04000000 ; threading switch area 0x04000000-0x40FFFFF
|
ENDMEM dw 0x05FFDFF8 ; end of available memory
|
;bitmap dw 0x04100000 ; bitmap graphics memory 0x04100000-0x417FFFF
|
STACKOFFS dw 0x05FFDFF8 ; stack offset - leave a little room for the BIOS
|
TXTBGN dw 0x04180000 ;TXT ;beginning of program memory
|
|
ENDMEM dw 0x057FFFFF ; end of available memory
|
|
STACKOFFS dw 0x058FFFFF ; stack offset - leave a little room for the BIOS stacks
|
;
|
;
|
; The main interpreter starts here:
|
; The main interpreter starts here:
|
;
|
;
|
; Usage
|
; Usage
|
; r1 = temp
|
; r1 = temp
|
; r8 = text buffer pointer
|
; r8 = text buffer pointer
|
; r12 = end of text in text buffer
|
; r12 = end of text in text buffer
|
;
|
;
|
align 4
|
align 4
|
|
message "CSTART"
|
public CSTART:
|
public CSTART:
|
; First save off the link register and OS sp value
|
; First save off the link register and OS sp value
|
tsx
|
tsx
|
stx OSSP
|
stx OSSP
|
ldx STACKOFFS>>2 ; initialize stack pointer
|
ldx STACKOFFS>>2 ; initialize stack pointer
|
txs
|
txs
|
stz CursorRow ; set screen output
|
jsr RequestIOFocus
|
stz CursorCol
|
jsr HomeCursor
|
|
lda #0 ; turn off keyboard echoing
|
|
jsr SetKeyboardEcho
|
stz CursorFlash
|
stz CursorFlash
|
stz pos
|
|
ldx #0x10000020 ; black chars, yellow background
|
ldx #0x10000020 ; black chars, yellow background
|
; stx charToPrint
|
; stx charToPrint
|
jsr ClearScreen
|
jsr ClearScreen
|
lda #msgInit ; tell who we are
|
lda #msgInit ; tell who we are
|
jsr PRMESG
|
jsr PRMESG
|
| Line 185... |
Line 189... |
beq ST6
|
beq ST6
|
ST7:
|
ST7:
|
ld r1,r9 ; r1 = pointer to next line
|
ld r1,r9 ; r1 = pointer to next line
|
ld r2,r13 ; pointer to line to be deleted
|
ld r2,r13 ; pointer to line to be deleted
|
ldy TXTUNF ; points to top of save area
|
ldy TXTUNF ; points to top of save area
|
jsr MVUP ; move up to delete
|
sub r1,r3,r9 ; r1 = length to move TXTUNF-pointer to next line
|
stx TXTUNF ; update the end pointer
|
; dea ; count is one less
|
|
ld r2,r9 ; r2 = pointer to next line
|
|
ld r3,r13 ; r3 = pointer to line to delete
|
|
push r4
|
|
ST8:
|
|
ld r4,(x)
|
|
st r4,(y)
|
|
inx
|
|
iny
|
|
dea
|
|
bne ST8
|
|
pop r4
|
|
; mvn
|
|
; jsr MVUP ; move up to delete
|
|
sty TXTUNF ; update the end pointer
|
; we moved the lines of text after the line being
|
; we moved the lines of text after the line being
|
; deleted down, so the pointer to the next line
|
; deleted down, so the pointer to the next line
|
; needs to be reset
|
; needs to be reset
|
ld r9,r13
|
ld r9,r13
|
bra ST4
|
bra ST4
|
| Line 259... |
Line 277... |
; The end of the character table is a 0 byte which corresponds
|
; The end of the character table is a 0 byte which corresponds
|
; to the default routine in the execution table, which is
|
; to the default routine in the execution table, which is
|
; executed if none of the other table items are matched.
|
; executed if none of the other table items are matched.
|
;
|
;
|
; Character-matching tables:
|
; Character-matching tables:
|
|
message "TAB1"
|
TAB1:
|
TAB1:
|
db "LIS",'T'+0x80 ; Direct commands
|
db "LIS",'T'+0x80 ; Direct commands
|
db "LOA",'D'+0x80
|
db "LOA",'D'+0x80
|
db "NE",'W'+0x80
|
db "NE",'W'+0x80
|
db "RU",'N'+0x80
|
db "RU",'N'+0x80
|
| Line 382... |
Line 400... |
;*
|
;*
|
; r3 = match flag (trashed)
|
; r3 = match flag (trashed)
|
; r9 = text table
|
; r9 = text table
|
; r10 = exec table
|
; r10 = exec table
|
; r11 = trashed
|
; r11 = trashed
|
|
message "DIRECT"
|
DIRECT:
|
DIRECT:
|
ld r9,#TAB1
|
ld r9,#TAB1
|
ld r10,#TAB1_1
|
ld r10,#TAB1_1
|
EXEC:
|
EXEC:
|
jsr IGNBLK ; ignore leading blanks
|
jsr IGNBLK ; ignore leading blanks
|
| Line 421... |
Line 440... |
bit #$80 ; test for bit 7 set
|
bit #$80 ; test for bit 7 set
|
beq EXLP ; if not, go back for more
|
beq EXLP ; if not, go back for more
|
EXGO:
|
EXGO:
|
; execute the appropriate routine
|
; execute the appropriate routine
|
lb r1,1,r10 ; get the low mid order byte
|
lb r1,1,r10 ; get the low mid order byte
|
asl
|
asl r1,r1,#8
|
asl
|
|
asl
|
|
asl
|
|
asl
|
|
asl
|
|
asl
|
|
asl
|
|
orb r1,r1,0,r10 ; get the low order byte
|
orb r1,r1,0,r10 ; get the low order byte
|
or r1,r1,#$FFFF0000 ; add in ROM base
|
or r1,r1,#$FFFF0000 ; add in ROM base
|
jmp (r1)
|
jmp (r1)
|
|
|
|
|
| Line 1417... |
Line 1429... |
jsr EXPR2 ; do a second
|
jsr EXPR2 ; do a second
|
plx
|
plx
|
rts
|
rts
|
|
|
; ::=(+ or -)(+ or -)(...
|
; ::=(+ or -)(+ or -)(...
|
|
message "EXPR2"
|
EXPR2:
|
EXPR2:
|
ldy #'-'
|
ldy #'-'
|
ld r4,#XP21
|
ld r4,#XP21
|
jsr TSTC ; negative sign?
|
jsr TSTC ; negative sign?
|
lda #0 ; yes, fake '0-'
|
lda #0 ; yes, fake '0-'
|
| Line 2112... |
Line 2124... |
; 'PUSHA' stacks for 'FOR' loop variable save area onto the stack
|
; 'PUSHA' stacks for 'FOR' loop variable save area onto the stack
|
;
|
;
|
; Note: a single zero word is stored on the stack in the
|
; Note: a single zero word is stored on the stack in the
|
; case that no FOR loops need to be saved. This needs to be
|
; case that no FOR loops need to be saved. This needs to be
|
; done because PUSHA / POPA is called all the time.
|
; done because PUSHA / POPA is called all the time.
|
|
message "POPA"
|
POPA:
|
POPA:
|
ply
|
ply
|
pla
|
pla
|
sta LOPVAR ; restore LOPVAR, but zero means no more
|
sta LOPVAR ; restore LOPVAR, but zero means no more
|
beq PP1
|
beq PP1
|
| Line 2242... |
Line 2254... |
jsr GOOUT
|
jsr GOOUT
|
lda #LF
|
lda #LF
|
jsr GOOUT
|
jsr GOOUT
|
rts
|
rts
|
|
|
; 'PRTNUM' prints the 32 bit number in r3, leading blanks are added if
|
; 'PRTNUM' prints the 32 bit number in r1, leading blanks are added if
|
; needed to pad the number of spaces to the number in r4.
|
; needed to pad the number of spaces to the number in r2.
|
; However, if the number of digits is larger than the no. in
|
; However, if the number of digits is larger than the no. in
|
; r4, all digits are printed anyway. Negative sign is also
|
; r2, all digits are printed anyway. Negative sign is also
|
; printed and counted in, positive sign is not.
|
; printed and counted in, positive sign is not.
|
;
|
;
|
; r1 = number to print
|
; r1 = number to print
|
; r2 = number of digits
|
; r2 = number of digits
|
; Register Usage
|
; Register Usage
|
| Line 2273... |
Line 2285... |
div r1,r1,r3 ; r1 /= 10 divide by 10
|
div r1,r1,r3 ; r1 /= 10 divide by 10
|
add r2,r2,#'0' ; convert remainder to ascii
|
add r2,r2,#'0' ; convert remainder to ascii
|
stx (r7) ; and store in buffer
|
stx (r7) ; and store in buffer
|
inc r7
|
inc r7
|
dec r5 ; decrement width
|
dec r5 ; decrement width
|
beq PN6 ; safty, prevents infinte loop on div fail
|
|
cmp #0
|
cmp #0
|
bne PN1
|
bne PN1
|
PN6:
|
PN6:
|
cmp r5,r0
|
cmp r5,r0
|
bcc PN4 ; test pad count, skip padding if not needed
|
bmi PN4 ; test pad count, skip padding if not needed
|
beq PN4
|
beq PN4
|
PN3:
|
PN3:
|
lda #' ' ; display the required leading spaces
|
lda #' ' ; display the required leading spaces
|
jsr GOOUT
|
jsr GOOUT
|
dec r5
|
dec r5
|
| Line 2532... |
Line 2543... |
; 'CHKIO' checks the input. If there's no input, it will return
|
; 'CHKIO' checks the input. If there's no input, it will return
|
; to the caller with the r1=0. If there is input, the input byte is in r1.
|
; to the caller with the r1=0. If there is input, the input byte is in r1.
|
; However, if a control-C is read, 'CHKIO' will warm-start BASIC and will
|
; However, if a control-C is read, 'CHKIO' will warm-start BASIC and will
|
; not return to the caller.
|
; not return to the caller.
|
;
|
;
|
|
message "CHKIO"
|
CHKIO:
|
CHKIO:
|
jsr GOIN ; get input if possible
|
jsr GOIN ; get input if possible
|
cmp #0
|
cmp #0
|
beq CHKRET2 ; if Zero, no input
|
beq CHKRET2 ; if Zero, no input
|
cmp #CTRLC
|
cmp #CTRLC
|
| Line 2605... |
Line 2617... |
|
|
; ===== Input a character from the console into register R1 (or
|
; ===== Input a character from the console into register R1 (or
|
; return Zero status if there's no character available).
|
; return Zero status if there's no character available).
|
;
|
;
|
INCH:
|
INCH:
|
jsr KeybdCheckForKeyDirect
|
; jsr KeybdCheckForKeyDirect
|
cmp #0
|
; cmp #0
|
|
; beq INCH1
|
|
jsr KeybdGetChar
|
|
cmp #-1
|
beq INCH1
|
beq INCH1
|
jmp KeybdGetCharDirect
|
rts
|
INCH1:
|
INCH1:
|
|
ina ; return a zero for no-char
|
rts
|
rts
|
|
|
;*
|
;*
|
;* ===== Input a character from the host into register r1 (or
|
;* ===== Input a character from the host into register r1 (or
|
;* return Zero status if there's no character available).
|
;* return Zero status if there's no character available).
|
| Line 2636... |
Line 2652... |
jmp SerialPutChar ; call boot rom routine
|
jmp SerialPutChar ; call boot rom routine
|
|
|
|
|
_cls
|
_cls
|
jsr ClearScreen
|
jsr ClearScreen
|
stz CursorRow
|
jsr HomeCursor
|
stz CursorCol
|
|
jmp FINISH
|
jmp FINISH
|
|
|
_wait10
|
_wait10
|
rts
|
rts
|
_getATAStatus
|
_getATAStatus
|
| Line 2655... |
Line 2670... |
|
|
|
|
; ===== Return to the resident monitor, operating system, etc.
|
; ===== Return to the resident monitor, operating system, etc.
|
;
|
;
|
BYEBYE:
|
BYEBYE:
|
|
jsr ReleaseIOFocus
|
ldx OSSP
|
ldx OSSP
|
txs
|
txs
|
rts
|
rts
|
|
|
; MOVE.B #228,D7 return to Tutor
|
; MOVE.B #228,D7 return to Tutor
|