msbasic/init.s

465 lines
9.4 KiB
ArmAsm
Raw Normal View History

2008-10-13 00:27:11 +00:00
.segment "INIT"
.ifdef KBD
2008-10-13 11:05:37 +00:00
FNDLIN2:
2008-10-13 00:27:11 +00:00
php
jmp FNDLIN
.endif
2008-10-13 11:05:37 +00:00
; ----------------------------------------------------------------------------
2008-10-13 00:27:11 +00:00
COLD_START:
.ifdef KBD
2008-10-18 13:06:52 +00:00
lda #<LFD81
2008-10-13 00:27:11 +00:00
sta $03A0
2008-10-18 13:06:52 +00:00
lda #>LFD81
2008-10-13 00:27:11 +00:00
sta $03A1
lda #$20
sta $0480
lda $0352
sta $04
lda $0353
sta $05
.else
2008-10-15 05:00:23 +00:00
.ifndef CONFIG_CBM_ALL
2008-10-13 00:27:11 +00:00
lda #<QT_WRITTEN_BY
ldy #>QT_WRITTEN_BY
jsr STROUT
2008-10-15 05:00:23 +00:00
.endif
2008-10-13 00:27:11 +00:00
COLD_START2:
2008-10-15 05:00:23 +00:00
.ifndef CBM2
2008-10-13 00:27:11 +00:00
ldx #$FF
stx CURLIN+1
2008-10-15 05:00:23 +00:00
.endif
2008-10-18 05:18:45 +00:00
.ifdef CONFIG_NO_INPUTBUFFER_ZP
2008-10-13 00:27:11 +00:00
ldx #$FB
2008-10-15 05:00:23 +00:00
.endif
2008-10-13 00:27:11 +00:00
txs
2008-10-15 05:00:23 +00:00
.ifndef CONFIG_CBM_ALL
2008-10-13 00:27:11 +00:00
lda #<COLD_START2
ldy #>COLD_START2
2008-10-16 07:12:27 +00:00
sta GORESTART+1
sty GORESTART+2
sta GOSTROUT+1
sty GOSTROUT+2
2008-10-13 00:27:11 +00:00
lda #<AYINT
ldy #>AYINT
2008-10-16 06:53:45 +00:00
sta GOAYINT
sty GOAYINT+1
2008-10-13 00:27:11 +00:00
lda #<GIVAYF
ldy #>GIVAYF
sta GOGIVEAYF
sty GOGIVEAYF+1
2008-10-15 05:00:23 +00:00
.endif
2008-10-13 00:27:11 +00:00
lda #$4C
2008-10-15 05:00:23 +00:00
.ifdef CONFIG_CBM_ALL
2008-10-13 00:27:11 +00:00
sta JMPADRS
2008-10-16 07:12:27 +00:00
.endif
sta GORESTART
.ifndef CONFIG_CBM_ALL
sta GOSTROUT
2008-10-13 00:27:11 +00:00
sta JMPADRS
2008-10-15 05:00:23 +00:00
.endif
2008-10-18 12:33:14 +00:00
.if (!.def(CONFIG_RAM)) && (!.def(CONFIG_CBM_ALL))
2008-10-13 00:27:11 +00:00
sta USR
2008-10-15 05:00:23 +00:00
.endif
2008-10-18 07:41:34 +00:00
.ifndef CONFIG_RAM
2008-10-15 05:00:23 +00:00
.ifdef APPLE
lda #<USR_FUNC
ldy #>USR_FUNC
.else
lda #<IQERR
ldy #>IQERR
.endif
sta USR+1
sty USR+2
.endif
2008-10-18 12:49:03 +00:00
.ifndef CBM1
2008-10-18 12:33:14 +00:00
lda #WIDTH
2008-10-13 00:27:11 +00:00
sta Z17
2008-10-18 12:49:03 +00:00
lda #WIDTH2
2008-10-13 00:27:11 +00:00
sta Z18
2008-10-15 05:00:23 +00:00
.endif
.endif /* KBD */
2008-10-18 06:59:14 +00:00
; All non-CONFIG_SMALL versions of BASIC have
; the same bug here: While the number of bytes
; to be copied is correct for CONFIG_SMALL,
; it is one byte short on non-CONFIG_SMALL:
; It seems the "ldx" value below has been
; hardcoded. So on these configurations,
; the last byte of GENERIC_RNDSEED, which
; is 5 bytes instead of 4, does not get copied -
; which is nothing major, because it is just
; the least significant 8 bits of the mantissa
; of the random number seed.
; KBD added three bytes to CHRGET and removed
; the random number seed, but only adjusted
; the number of bytes by adding 3 - this
; copies four bytes too many, which is no
; problem.
2008-10-13 00:27:11 +00:00
.ifdef CONFIG_SMALL
2008-10-16 06:53:45 +00:00
.ifdef KBD
2008-10-13 00:27:11 +00:00
ldx #GENERIC_CHRGET_END-GENERIC_CHRGET+4
2008-10-16 06:53:45 +00:00
.else
2008-10-13 00:27:11 +00:00
ldx #GENERIC_CHRGET_END-GENERIC_CHRGET
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
.else
ldx #GENERIC_CHRGET_END-GENERIC_CHRGET-1 ; XXX
.endif
L4098:
lda GENERIC_CHRGET-1,x
sta STRNG2+1,x
dex
bne L4098
2008-10-13 20:26:42 +00:00
.ifdef CONFIG_2
2008-10-13 00:27:11 +00:00
lda #$03
sta DSCLEN
.endif
.ifndef KBD
txa
sta SHIFTSIGNEXT
2008-10-16 06:53:45 +00:00
.ifdef CONFIG_CBM_ALL
2008-10-13 00:27:11 +00:00
sta Z03
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
sta LASTPT+1
2008-10-16 06:53:45 +00:00
.if .defined(CONFIG_NULL) || .defined(CONFIG_PRINTNULLS)
2008-10-13 00:27:11 +00:00
sta Z15
2008-10-16 06:53:45 +00:00
.endif
.ifndef CONFIG_11
2008-10-13 09:34:49 +00:00
sta POSX
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
pha
sta Z14
2008-10-16 09:11:38 +00:00
.ifdef CBM2
2008-10-13 00:27:11 +00:00
inx
stx $01FD
stx $01FC
2008-10-16 06:53:45 +00:00
.else
.ifndef MICROTAN
2008-10-13 00:27:11 +00:00
lda #$03
sta DSCLEN
2008-10-16 06:53:45 +00:00
.endif
2008-10-16 08:31:42 +00:00
.ifndef CONFIG_11
2008-10-13 00:27:11 +00:00
lda #$2C
sta LINNUM+1
2008-10-16 08:31:42 +00:00
.endif
2008-10-13 00:27:11 +00:00
jsr CRDO
2008-10-16 08:31:42 +00:00
.endif
.ifdef APPLE
2008-10-13 00:27:11 +00:00
lda #$01
sta $01FD
sta $01FC
2008-10-16 08:31:42 +00:00
.endif
2008-10-13 00:27:11 +00:00
ldx #TEMPST
stx TEMPPT
.ifndef CONFIG_CBM_ALL
lda #<QT_MEMORY_SIZE
ldy #>QT_MEMORY_SIZE
jsr STROUT
2008-10-16 06:53:45 +00:00
.ifdef APPLE
2008-10-13 00:27:11 +00:00
jsr INLINX
2008-10-16 06:53:45 +00:00
.else
2008-10-13 00:27:11 +00:00
jsr NXIN
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
cmp #$41
beq COLD_START
tay
bne L40EE
.endif
2008-10-16 09:04:00 +00:00
.ifndef CBM2
2008-10-13 00:27:11 +00:00
lda #<RAMSTART2
.endif
ldy #>RAMSTART2
2008-10-13 20:26:42 +00:00
.ifdef CONFIG_2
2008-10-15 05:00:23 +00:00
sta TXTTAB
sty TXTTAB+1
2008-10-13 00:27:11 +00:00
.endif
sta LINNUM
sty LINNUM+1
2008-10-16 09:04:00 +00:00
.ifdef CBM2
2008-10-13 00:27:11 +00:00
tay
.else
ldy #$00
.endif
L40D7:
inc LINNUM
bne L40DD
inc LINNUM+1
.ifdef CBM1
2008-10-18 06:59:14 +00:00
lda LINNUM+1
2008-10-13 00:27:11 +00:00
cmp #$80
beq L40FA
.endif
2008-10-16 09:11:38 +00:00
.ifdef CBM2
2008-10-13 00:27:11 +00:00
bmi L40FA
.endif
L40DD:
2008-10-13 20:26:42 +00:00
.ifdef CONFIG_2
2008-10-13 00:27:11 +00:00
lda #$55
.else
lda #$92
.endif
sta (LINNUM),y
cmp (LINNUM),y
bne L40FA
asl a
sta (LINNUM),y
cmp (LINNUM),y
.ifdef CONFIG_CBM_ALL
beq L40D7
.else
2008-10-16 06:53:45 +00:00
.ifdef CONFIG_SMALL
2008-10-13 00:27:11 +00:00
beq L40D7
bne L40FA
2008-10-16 06:53:45 +00:00
.else
2008-10-13 00:27:11 +00:00
bne L40FA
beq L40D7
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
L40EE:
jsr CHRGOT
jsr LINGET
tay
beq L40FA
jmp SYNERR
.endif
L40FA:
lda LINNUM
ldy LINNUM+1
sta MEMSIZ
sty MEMSIZ+1
2008-10-14 09:23:44 +00:00
.ifndef MICROTAN
2008-10-13 00:27:11 +00:00
sta FRETOP
sty FRETOP+1
2008-10-14 09:23:44 +00:00
.endif
2008-10-13 00:27:11 +00:00
L4106:
.ifndef CONFIG_CBM_ALL
2008-10-16 06:53:45 +00:00
.ifdef APPLE
2008-10-13 00:27:11 +00:00
lda #$FF
jmp L2829
.word STROUT ; PATCH!
jsr NXIN
2008-10-16 06:53:45 +00:00
.else
2008-10-13 00:27:11 +00:00
lda #<QT_TERMINAL_WIDTH
ldy #>QT_TERMINAL_WIDTH
jsr STROUT
jsr NXIN
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
tay
beq L4136
jsr LINGET
lda LINNUM+1
bne L4106
lda LINNUM
cmp #$10
bcc L4106
L2829:
sta Z17
L4129:
sbc #$0E
bcs L4129
eor #$FF
sbc #$0C
clc
adc Z17
sta Z18
.endif
2008-10-18 07:34:16 +00:00
L4136:
2008-10-18 07:41:34 +00:00
.ifdef CONFIG_RAM
2008-10-13 00:27:11 +00:00
lda #<QT_WANT
ldy #>QT_WANT
jsr STROUT
jsr NXIN
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
ldx #<RAMSTART1
ldy #>RAMSTART1
cmp #'Y'
beq L4183
cmp #'A'
beq L4157
cmp #'N'
bne L4136
L4157:
ldx #<IQERR
ldy #>IQERR
2008-10-18 07:36:56 +00:00
stx UNFNC_ATN
sty UNFNC_ATN+1
2008-10-18 07:34:16 +00:00
ldx #<ATN ; overwrite starting
ldy #>ATN ; with ATN
2008-10-13 00:27:11 +00:00
cmp #'A'
beq L4183
ldx #<IQERR
ldy #>IQERR
2008-10-18 07:36:56 +00:00
stx UNFNC_COS
sty UNFNC_COS+1
stx UNFNC_TAN
sty UNFNC_TAN+1
stx UNFNC_SIN
sty UNFNC_SIN+1
2008-10-18 07:34:16 +00:00
ldx #<SIN_COS_TAN_ATN ; overwrite
ldy #>SIN_COS_TAN_ATN ; all of trig.s
2008-10-13 00:27:11 +00:00
L4183:
.else
ldx #<RAMSTART2
ldy #>RAMSTART2
.endif
stx TXTTAB
sty TXTTAB+1
ldy #$00
tya
sta (TXTTAB),y
inc TXTTAB
2008-10-16 09:11:38 +00:00
.ifndef CBM2
2008-10-13 00:27:11 +00:00
bne L4192
inc TXTTAB+1
L4192:
2008-10-15 05:00:23 +00:00
.endif
.if CONFIG_SCRTCH_ORDER = 1
jsr SCRTCH
2008-10-13 00:27:11 +00:00
.endif
lda TXTTAB
ldy TXTTAB+1
jsr REASON
2008-10-16 09:11:38 +00:00
.ifdef CBM2
2008-10-13 00:27:11 +00:00
lda #<QT_BASIC
ldy #>QT_BASIC
jsr STROUT
.else
jsr CRDO
.endif
lda MEMSIZ
sec
sbc TXTTAB
tax
lda MEMSIZ+1
sbc TXTTAB+1
jsr LINPRT
lda #<QT_BYTES_FREE
ldy #>QT_BYTES_FREE
jsr STROUT
2008-10-15 05:00:23 +00:00
.if CONFIG_SCRTCH_ORDER = 2
2008-10-13 00:27:11 +00:00
jsr SCRTCH
.endif
.ifdef CONFIG_CBM_ALL
jmp RESTART
.else
lda #<STROUT
ldy #>STROUT
2008-10-16 07:12:27 +00:00
sta GOSTROUT+1
sty GOSTROUT+2
2008-10-16 06:53:45 +00:00
.if CONFIG_SCRTCH_ORDER = 3
2008-10-15 05:00:23 +00:00
jsr SCRTCH
2008-10-16 06:53:45 +00:00
.endif
2008-10-13 00:27:11 +00:00
lda #<RESTART
ldy #>RESTART
2008-10-16 07:12:27 +00:00
sta GORESTART+1
sty GORESTART+2
jmp (GORESTART+1)
2008-10-13 00:27:11 +00:00
.endif
2008-10-15 05:00:23 +00:00
2008-10-18 07:41:34 +00:00
.if .def(CONFIG_RAM) || .def(OSI)
; OSI is compiled for ROM, but but includes
; this unused string
2008-10-13 00:27:11 +00:00
QT_WANT:
.byte "WANT SIN-COS-TAN-ATN"
.byte $00
.endif
QT_WRITTEN_BY:
.ifndef CONFIG_CBM_ALL
.ifdef APPLE
asc80 "COPYRIGHT 1977 BY MICROSOFT CO"
.byte $0D,$00
.else
.byte $0D,$0A,$0C
.ifdef CONFIG_SMALL
.byte "WRITTEN BY RICHARD W. WEILAND."
.else
.byte "WRITTEN BY WEILAND & GATES"
.endif
.byte $0D,$0A,$00
.endif
QT_MEMORY_SIZE:
.byte "MEMORY SIZE"
.byte $00
QT_TERMINAL_WIDTH:
.byte "TERMINAL WIDTH"
.byte $00
.endif
QT_BYTES_FREE:
.byte " BYTES FREE"
2008-10-17 05:27:27 +00:00
.ifdef CBM1
.elseif .def(CBM2)
2008-10-13 00:27:11 +00:00
.byte $0D,$00
2008-10-17 05:27:27 +00:00
.elseif .def(APPLE)
2008-10-13 00:27:11 +00:00
.byte $00
2008-10-17 05:27:27 +00:00
.else
.byte $0D,$0A,$0D,$0A
2008-10-13 00:27:11 +00:00
.endif
QT_BASIC:
.ifdef OSI
.byte "OSI 6502 BASIC VERSION 1.0 REV 3.2"
.endif
.ifdef KIM
.byte "MOS TECH 6502 BASIC V1.1"
.endif
2008-10-15 05:00:23 +00:00
.ifdef MICROTAN
.byte "MICROTAN BASIC"
.endif
2008-10-13 00:27:11 +00:00
.ifdef CBM1
.byte $13
.byte "*** COMMODORE BASIC ***"
.byte $11,$11,$11,$00
.endif
.ifdef CBM2
.byte "### COMMODORE BASIC ###"
.byte $0D,$0D,$00
.endif
.ifdef APPLE
.byte $0A,$0D,$0A
.byte "APPLE BASIC V1.1"
.endif
.ifndef CONFIG_CBM_ALL
.byte $0D,$0A
2008-10-15 05:00:23 +00:00
.ifdef MICROTAN
.byte "(C) 1980 MICROSOFT" ; E1F2 28 43 29 20 31 39 38 30 (C) 1980
.else
2008-10-13 00:27:11 +00:00
.byte "COPYRIGHT 1977 BY MICROSOFT CO."
2008-10-15 05:00:23 +00:00
.endif
2008-10-13 00:27:11 +00:00
.byte $0D,$0A,$00
.endif
.endif /* KBD */
2008-10-13 08:07:53 +00:00
2008-10-13 10:42:49 +00:00
.segment "EXTRA"
2008-10-13 08:07:53 +00:00
2008-10-13 10:42:49 +00:00
.ifdef OSI
.include "osi_extra.s"
.endif
.ifdef KIM
.include "kim_extra.s"
.endif
2008-10-13 08:07:53 +00:00
2008-10-13 00:27:11 +00:00
.ifdef CONFIG_CBM1_PATCHES
2008-10-13 08:07:53 +00:00
.include "cbm1_patches.s"
2008-10-13 00:27:11 +00:00
.endif
2008-10-13 08:07:53 +00:00
2008-10-13 00:27:11 +00:00
.ifdef KBD
2008-10-13 10:42:49 +00:00
.include "kbd_extra.s"
2008-10-13 00:27:11 +00:00
.endif
2008-10-13 10:42:49 +00:00
2008-10-13 00:27:11 +00:00
.ifdef APPLE
2008-10-13 10:42:49 +00:00
.include "apple_extra.s"
2008-10-15 05:28:25 +00:00
.endif
.ifdef MICROTAN
.include "microtan_extra.s"
2008-10-13 00:27:11 +00:00
.endif