added AIM-65

This commit is contained in:
Martin Hoffmann-Vetter 2014-02-13 22:40:56 -08:00 committed by Michael Steil
parent df1bc2a243
commit 440442981d
27 changed files with 391 additions and 40 deletions

19
aim65.cfg Normal file
View File

@ -0,0 +1,19 @@
MEMORY {
ZP: start = $0000, size = $0100, type = rw;
BASROM: start = $B000, size = $2000, fill = no, file = %O;
DUMMY: start = $0000, size = $00FF, file = "";
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
HEADER: load = BASROM, type = ro;
VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro;
ERROR: load = BASROM, type = ro;
CODE: load = BASROM, type = ro;
CHRGET: load = BASROM, type = ro;
INIT: load = BASROM, type = ro;
EXTRA: load = BASROM, type = ro;
DUMMY: load = DUMMY; # don't include
}

5
aim65_extra.s Normal file
View File

@ -0,0 +1,5 @@
.segment "EXTRA"
LCFFA:
jsr CHRGOT
jmp LB89D

18
aim65_iscntc.s Normal file
View File

@ -0,0 +1,18 @@
.segment "CODE"
ISCNTC:
lda DRA2
pha
lda #$7f
sta DRA2
pha
pla
lda DRB2
rol a
pla
sta DRA2
bcs RET2
jsr GETKEY
lda #$03
cmp #$03
;!!! runs into "STOP"

51
aim65_loadsave.s Normal file
View File

@ -0,0 +1,51 @@
.segment "CODE"
SAVE:
pha
jsr WHEREO
jsr OUTSP
lda #$ff
jmp LB4BF
MONRDKEY:
lda INFLG
jsr COUT5
bne LOAD2
jmp INALL
LOAD2:
jmp CUREAD
MONCOUT:
pha
lda OUTFLG
jsr COUT5
bne COUT3
pla
jmp OUTALL
COUT3:
pla
cmp #LF
beq COUT6
cmp #CR
beq COUT4
jmp OUTPUT
COUT4:
jsr CRCK
lda #CR
rts
COUT5:
cmp #$54
beq COUT6
cmp #$55
beq COUT6
cmp #$4C
COUT6:
rts
MONRDKEY2:
jsr ROONEK
tya
beq COUT5
jmp GETKY

View File

@ -19,6 +19,9 @@ KBD := 1
.elseif .def(microtan)
MICROTAN := 1
.include "defines_microtan.s"
.elseif .def(aim65)
AIM65 := 1
.include "defines_aim65.s"
.endif
.ifdef CONFIG_2C
@ -42,6 +45,7 @@ CONFIG_10A := 1
.ifdef CONFIG_SMALL
BYTES_FP := 4
CONFIG_SMALL_ERROR := 1
.else
BYTES_FP := 5
.endif
@ -60,6 +64,9 @@ MAX_EXPON = 10
.endif
STACK := $0100
.ifndef STACK2
STACK2 := STACK
.endif
.ifdef INPUTBUFFER
.if INPUTBUFFER >= $0100

59
defines_aim65.s Normal file
View File

@ -0,0 +1,59 @@
; configuration
CONFIG_2A := 1
CONFIG_NULL := 1
CONFIG_PRINT_CR := 1 ; print CR when line end reached
CONFIG_SAFE_NAMENOTFOUND := 1
CONFIG_SCRTCH_ORDER := 1
CONFIG_PEEK_SAVE_LINNUM := 1
CONFIG_SMALL_ERROR := 1
; zero page
ZP_START1 = $00
ZP_START2 = $10
ZP_START3 = $06
ZP_START4 = $5E
;extra ZP variables
USR := $03
TXPSV := LASTOP
NULL := IQERR
; inputbuffer
INPUTBUFFER := $0016
;extra stack
STACK2 := $0200
; constants
STACK_TOP := $FD
SPACE_FOR_GOSUB := $44
NULL_MAX := $F2 ; probably different in original version; the image I have seems
CRLF_1 := CR
CRLF_2 := LF
WIDTH := 20
WIDTH2 := 10
; memory layout
RAMSTART2 := $0211
; monitor functions
PRIFLG := $A411
INFLG := $A412
OUTFLG := $A413
DRA2 := $A480
DRB2 := $A482
DU13 := $E520
PSLS := $E7DC
LOAD := $E848
WHEREO := $E871
OUTPUT := $E97A
INALL := $E993
OUTALL := $E9BC
CRCK := $EA24
GETKEY := $EC40
GETKY := $EC43
ROONEK := $ECEF
CUREAD := $FE83

View File

@ -1,6 +1,6 @@
init_error_table
.ifdef CONFIG_SMALL
.ifdef CONFIG_SMALL_ERROR
define_error ERR_NOFOR, "NF"
define_error ERR_SYNTAX, "SN"
define_error ERR_NOGOSUB, "RG"

View File

@ -19,3 +19,7 @@
.ifdef MICROTAN
.include "microtan_extra.s"
.endif
.ifdef AIM65
.include "aim65_extra.s"
.endif

30
float.s
View File

@ -1428,7 +1428,7 @@ FOUT1:
bpl L3C73
lda #$2D
L3C73:
sta $FF,y
sta STACK2-1,y
sta FACSIGN
sty STRNG2
iny
@ -1509,12 +1509,12 @@ L3CDF:
ldy STRNG2
lda #$2E
iny
sta $FF,y
sta STACK2-1,y
txa
beq L3CF0
lda #$30
iny
sta $FF,y
sta STACK2-1,y
L3CF0:
sty STRNG2
; ----------------------------------------------------------------------------
@ -1564,12 +1564,12 @@ L3D23:
iny
tax
and #$7F
sta $FF,y
sta STACK2-1,y
dec INDX
bne L3D3E
lda #$2E
iny
sta $FF,y
sta STACK2-1,y
L3D3E:
sty STRNG2
ldy VARPNT
@ -1591,7 +1591,7 @@ L3D3E:
LDD96:
ldy STRNG2
L3D4E:
lda $FF,y
lda STACK2-1,y
dey
cmp #$30
beq L3D4E
@ -1609,9 +1609,9 @@ L3D5B:
tax
lda #$2D
L3D6B:
sta STACK+1,y
sta STACK2+1,y
lda #$45
sta STACK,y
sta STACK2,y
txa
ldx #$2F
sec
@ -1620,20 +1620,20 @@ L3D77:
sbc #$0A
bcs L3D77
adc #$3A
sta STACK+3,y
sta STACK2+3,y
txa
sta STACK+2,y
sta STACK2+2,y
lda #$00
sta STACK+4,y
sta STACK2+4,y
beq L3D94
FOUT4:
sta $FF,y
sta STACK2-1,y
L3D8F:
lda #$00
sta STACK,y
sta STACK2,y
L3D94:
lda #$00
ldy #$01
lda #<STACK2
ldy #>STACK2
rts
; ----------------------------------------------------------------------------

View File

@ -299,6 +299,7 @@ LE68E:
rts
.endif
.ifndef AIM65
.if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS)
; CBM1 has the keyword removed,
; but the code is still here
@ -319,3 +320,4 @@ CLEAR:
bne RET1
jmp CLEARC
.endif
.endif

View File

@ -3,3 +3,8 @@
jmp LE68C
.byte $00,$13,$56
.endif
.ifdef AIM65
jmp COLD_START
jmp RESTART
.word AYINT,GIVAYF
.endif

69
init.s
View File

@ -10,11 +10,13 @@ FNDLIN2:
PR_WRITTEN_BY:
.ifndef KBD
.ifndef CONFIG_CBM_ALL
.ifndef AIM65
lda #<QT_WRITTEN_BY
ldy #>QT_WRITTEN_BY
jsr STROUT
.endif
.endif
.endif
COLD_START:
.ifdef KBD
lda #<LFD81
@ -34,6 +36,8 @@ COLD_START:
.endif
.ifdef CONFIG_NO_INPUTBUFFER_ZP
ldx #$FB
.elseif .def(AIM65)
ldx #$FE
.endif
txs
.ifndef CONFIG_CBM_ALL
@ -41,6 +45,7 @@ COLD_START:
ldy #>COLD_START
sta GORESTART+1
sty GORESTART+2
.ifndef AIM65
sta GOSTROUT+1
sty GOSTROUT+2
lda #<AYINT
@ -51,12 +56,18 @@ COLD_START:
ldy #>GIVAYF
sta GOGIVEAYF
sty GOGIVEAYF+1
.endif
.endif
lda #$4C
.ifdef CONFIG_CBM_ALL
sta JMPADRS
.endif
sta GORESTART
.ifdef AIM65
sta JMPADRS
sta ATN
sta GOSTROUT
.else
.ifndef CONFIG_CBM_ALL
sta GOSTROUT
sta JMPADRS
@ -64,6 +75,7 @@ COLD_START:
.if (!.def(CONFIG_RAM)) && (!.def(CONFIG_CBM_ALL))
sta USR
.endif
.endif
.ifndef CONFIG_RAM
.ifdef APPLE
@ -73,16 +85,23 @@ COLD_START:
lda #<IQERR
ldy #>IQERR
.endif
.ifdef AIM65
sta ATN+1
sty ATN+2
sta GOSTROUT+1
sty GOSTROUT+2
.else
sta USR+1
sty USR+2
.endif
.endif
.ifndef CBM1
lda #WIDTH
sta Z17
lda #WIDTH2
sta Z18
.endif
.endif /* KBD */
.endif
; All non-CONFIG_SMALL versions of BASIC have
; the same bug here: While the number of bytes
@ -125,19 +144,23 @@ L4098:
sta CURDVC
.endif
sta LASTPT+1
.ifndef AIM65
.if .defined(CONFIG_NULL) || .defined(CONFIG_PRINTNULLS)
sta Z15
.endif
.endif
.ifndef CONFIG_11
sta POSX
.endif
pha
sta Z14
.ifndef CBM2
.ifndef AIM65
.ifndef MICROTAN
lda #$03
sta DSCLEN
.endif
.endif
.ifndef CONFIG_11
lda #$2C
sta LINNUM+1
@ -168,8 +191,10 @@ L4098:
stx TXTPTR
sty TXTPTR+1
jsr CHRGET
.ifndef AIM65
cmp #$41
beq PR_WRITTEN_BY
.endif
tay
bne L40EE
.endif
@ -202,6 +227,12 @@ L40D7:
; optimized version of the CBM1 code
bmi L40FA
.endif
.if .def(AIM65)
; AIM65: hard RAM top limit is $A000
lda LINNUM+1
cmp #$A0
beq L40FA
.endif
L40DD:
.ifdef CONFIG_2
lda #$55 ; 01010101 / 10101010
@ -236,7 +267,7 @@ L40FA:
ldy LINNUM+1
sta MEMSIZ
sty MEMSIZ+1
.ifndef MICROTAN
.if !(.def(MICROTAN) || .def(AIM65))
sta FRETOP
sty FRETOP+1
.endif
@ -267,10 +298,18 @@ L4106:
L2829:
sta Z17
L4129:
.ifdef AIM65
sbc #$0A
.else
sbc #$0E
.endif
bcs L4129
eor #$FF
.ifdef AIM65
sbc #$08
.else
sbc #$0C
.endif
clc
adc Z17
sta Z18
@ -355,6 +394,12 @@ L4192:
.endif
.ifdef CONFIG_CBM_ALL
jmp RESTART
.elseif .def(AIM65)
lda #<CRDO
ldy #>CRDO
sta GORESTART+1
sty GORESTART+2
jmp RESTART
.else
lda #<STROUT
ldy #>STROUT
@ -379,6 +424,7 @@ QT_WANT:
.endif
QT_WRITTEN_BY:
.ifndef CONFIG_CBM_ALL
.ifndef AIM65
.ifdef APPLE
asc80 "COPYRIGHT 1977 BY MICROSOFT CO"
.byte CR,0
@ -391,11 +437,15 @@ QT_WRITTEN_BY:
.endif
.byte CR,LF,0
.endif
.endif
QT_MEMORY_SIZE:
.byte "MEMORY SIZE"
.byte 0
QT_TERMINAL_WIDTH:
.byte "TERMINAL WIDTH"
.ifndef AIM65
.byte "TERMINAL "
.endif
.byte "WIDTH"
.byte 0
.endif
QT_BYTES_FREE:
@ -418,6 +468,9 @@ QT_BASIC:
.ifdef MICROTAN
.byte "MICROTAN BASIC"
.endif
.ifdef AIM65
.byte " AIM 65 BASIC V1.1"
.endif
.ifdef CBM1
.byte $13 ; HOME
.byte "*** COMMODORE BASIC ***"
@ -435,9 +488,15 @@ QT_BASIC:
.byte CR,LF
.ifdef MICROTAN
.byte "(C) 1980 MICROSOFT"
.elseif .def(AIM65)
.byte 0
.byte "(C) 1978 MICROSOFT"
.else
.byte "COPYRIGHT 1977 BY MICROSOFT CO."
.endif
.byte CR,LF,0
.byte CR,LF
.ifndef AIM65
.byte 0
.endif
.endif
.endif
.endif /* KBD */

View File

@ -6,7 +6,15 @@ L2420:
jsr OUTDO
.endif
dex
.ifdef AIM65
bmi L2423
jsr PSLS
jmp INLIN2
LB35F:
jsr OUTDO
.else
bpl INLIN2
.endif
L2423:
.ifdef OSI
jsr OUTDO
@ -39,6 +47,13 @@ L0C32:
ldx #$00
INLIN2:
jsr GETLN
.ifdef AIM65
cmp #$1A
bne INLINAIM
jsr DU13
jmp INLIN
INLINAIM:
.endif
.ifndef CONFIG_NO_LINE_EDITING
cmp #$07
beq L2443
@ -47,14 +62,25 @@ INLIN2:
beq L2453
.ifndef CONFIG_NO_LINE_EDITING
cmp #$20
.ifdef AIM65
bcc L244E
.else
bcc INLIN2
.endif
.ifdef MICROTAN
cmp #$80
.else
.ifdef AIM65
cmp #$7F
beq L2420
.endif
cmp #$7D
.endif
bcs INLIN2
cmp #$40 ; @
.ifdef AIM65
beq LB35F
.else
beq L2423
.ifdef MICROTAN
cmp #$7F ; DEL
@ -62,6 +88,7 @@ INLIN2:
cmp #$5F ; _
.endif
beq L2420
.endif
L2443:
.ifdef MICROTAN
cpx #$4F
@ -73,6 +100,9 @@ L2443:
sta INPUTBUFFER,x
inx
.ifdef OSI
.byte $2C
.elseif .def(AIM65)
.byte $2C
.else
bne INLIN2
@ -80,6 +110,7 @@ L2443:
L244C:
.ifndef CONFIG_NO_LINE_EDITING
lda #$07 ; BEL
L244E:
jsr OUTDO
bne INLIN2
.endif
@ -115,7 +146,7 @@ GETLN:
nop
and #$7F
.endif
.endif /* APPLE */
.endif
.ifdef APPLE
RDKEY:
jsr LFD0C
@ -130,4 +161,4 @@ RDKEY:
pla
L2465:
rts
.endif /* KBD */
.endif

10
input.s
View File

@ -111,6 +111,11 @@ LCAE0:
INPUT:
.ifndef KBD
lsr Z14
.endif
.ifdef AIM65
lda PRIFLG
sta ZBE
jsr LCFFA
.endif
cmp #$22
bne L2A9E
@ -231,6 +236,8 @@ PROCESS_INPUT_ITEM:
bvc L2AF0
.ifdef MICROTAN
jsr MONRDKEY2
.elseif .def(AIM65)
jsr MONRDKEY2
.else
jsr MONRDKEY
.endif
@ -392,6 +399,9 @@ INPDONE:
jmp SETDA
L2B94:
ldy #$00
.ifdef AIM65
jsr LB8B1
.endif
lda (INPTR),y
beq L2BA1
.ifdef CONFIG_FILE

View File

@ -20,4 +20,7 @@
.ifdef MICROTAN
.include "microtan_iscntc.s"
.endif
.ifdef AIM65
.include "aim65_iscntc.s"
.endif
;!!! runs into "STOP"

View File

@ -9,3 +9,6 @@
.ifdef MICROTAN
.include "microtan_loadsave.s"
.endif
.ifdef AIM65
.include "aim65_loadsave.s"
.endif

View File

@ -2,7 +2,7 @@ if [ ! -d tmp ]; then
mkdir tmp
fi
for i in cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan; do
for i in cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan aim65; do
echo $i
ca65 -D $i msbasic.s -o tmp/$i.o &&

View File

@ -30,6 +30,7 @@ OKPRT:
rts
nop
.else
.ifndef AIM65
QT_OK:
.ifdef CONFIG_CBM_ALL
.byte CR,LF,"READY.",CR,LF
@ -43,14 +44,14 @@ QT_OK:
.endif
.byte 0
.endif
.endif
QT_BREAK:
.ifdef KBD
.byte CR,LF," Brk"
.byte 0
.byte $54,$D0 ; ???
.elseif .def(MICROTAN)
.elseif .def(MICROTAN) || .def(AIM65)
.byte CR,LF," BREAK"
.byte 0
.else

10
misc1.s
View File

@ -203,7 +203,17 @@ L2963:
iny
lda (DSCPTR),y
sta (FORPNT),y
RET5:
rts
.ifdef AIM65
LB89D:
cmp #$21
bne RET5
lda #$80
sta PRIFLG
jmp CHRGET
.endif
.ifdef CONFIG_FILE
PRINTH:
jsr CMD

BIN
orig/aim65.bin Normal file

Binary file not shown.

2
poke.s
View File

@ -115,4 +115,4 @@ L362C:
beq L362C
RTS3:
rts
.endif /* KBD */
.endif

28
print.s
View File

@ -1,5 +1,16 @@
.segment "CODE"
.ifdef AIM65
PRINT:
lda PRIFLG
sta ZBE
jsr L297E
LB8B1:
lda ZBE
sta PRIFLG
rts
.endif
PRSTRING:
jsr STRPRT
L297E:
@ -8,10 +19,16 @@ L297E:
; ----------------------------------------------------------------------------
; "PRINT" STATEMENT
; ----------------------------------------------------------------------------
.ifndef AIM65
PRINT:
.endif
beq CRDO
PRINT2:
beq L29DD
.ifdef AIM65
jsr LB89D
beq L29DD
.endif
cmp #TOKEN_TAB
beq L29F5
cmp #TOKEN_SPC
@ -119,6 +136,10 @@ PRINTNULLS:
lda #$00
sta POSX
eor #$FF
.elseif .def(AIM65)
lda #$00
sta POSX
eor #$FF
.else
.if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS)
.ifdef CONFIG_FILE
@ -167,7 +188,7 @@ L29EA:
.endif
sec
L29EB:
.ifdef CONFIG_CBM_ALL
.if .def(CONFIG_CBM_ALL) || .def(AIM65)
sbc #$0A
.else
.ifdef KBD
@ -327,7 +348,10 @@ LCA6A:
lda POSX
cmp Z17
bne L2A4C
.ifdef APPLE
.ifdef AIM65
lda #$00
sta POSX
.elseif .def(APPLE)
nop ; PATCH!
nop ; don't print CR
nop

View File

@ -32,12 +32,12 @@ LC366:
jsr OUTQUES
L2329:
lda ERROR_MESSAGES,x
.ifndef CONFIG_SMALL
.ifndef CONFIG_SMALL_ERROR
pha
and #$7F
.endif
jsr OUTDO
.ifdef CONFIG_SMALL
.ifdef CONFIG_SMALL_ERROR
lda ERROR_MESSAGES+1,x
.ifdef KBD
and #$7F
@ -79,6 +79,7 @@ LE28E:
bpl RESTART
.else
lsr Z14
.ifndef AIM65
lda #<QT_OK
ldy #>QT_OK
.ifdef CONFIG_CBM_ALL
@ -86,6 +87,9 @@ LE28E:
.else
jsr GOSTROUT
.endif
.else
jsr GORESTART
.endif
L2351:
jsr INLIN
.endif
@ -639,9 +643,20 @@ LIST:
L25A6:
jsr CRDO
.else
.ifdef AIM65
pha
lda #$00
LB4BF:
sta INPUTFLG
pla
.endif
.ifdef MICROTAN
php
jmp LE21C ; patch
LC57E:
.elseif .def(AIM65)
php
jsr LINGET
LC57E:
.else
bcc L2581
@ -652,12 +667,12 @@ L2581:
jsr LINGET
.endif
jsr FNDLIN
.ifdef MICROTAN
.if .def(MICROTAN) || .def(AIM65)
plp
beq L2598
.endif
jsr CHRGOT
.ifdef MICROTAN
.if .def(MICROTAN) || .def(AIM65)
beq L25A6
.else
beq L2598
@ -665,7 +680,7 @@ L2581:
cmp #TOKEN_MINUS
bne L2520
jsr CHRGET
.ifdef MICROTAN
.if .def(MICROTAN) || .def(AIM65)
beq L2598
jsr LINGET
beq L25A6
@ -675,7 +690,7 @@ L2581:
bne L2520
.endif
L2598:
.ifndef MICROTAN
.if !(.def(MICROTAN) || .def(AIM65))
pla
pla
lda LINNUM
@ -686,7 +701,7 @@ L2598:
sta LINNUM
sta LINNUM+1
L25A6:
.ifdef MICROTAN
.if .def(MICROTAN) || .def(AIM65)
pla
pla
.endif
@ -749,12 +764,22 @@ LA519:
lda (LOWTRX),y
stx LOWTRX
sta LOWTRX+1
.ifdef MICROTAN
.if .def(MICROTAN) || .def(AIM65)
bne L25A6X
.else
bne L25A6
.endif
L25E5:
.ifdef AIM65
lda INPUTFLG
beq L25E5a
jsr CRDO
jsr CRDO
lda #$1a
jsr OUTDO
jsr $e50a
L25E5a:
.endif
jmp RESTART
L25E8:
bpl L25CE

View File

@ -5,7 +5,7 @@ if [ ! -d orig ]; then
exit;
fi
for i in cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan; do
for i in cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan aim65; do
echo $i
ca65 -D $i msbasic.s -o tmp/$i.o &&

View File

@ -9,9 +9,13 @@ STR:
pla
pla
LD353:
lda #$FF
ldy #$00
lda #<(STACK2-1)
ldy #>(STACK2-1)
.if STACK2 > $0100
bne STRLIT
.else
beq STRLIT
.endif
; ----------------------------------------------------------------------------
; GET SPACE AND MAKE DESCRIPTOR FOR STRING WHOSE
@ -85,6 +89,9 @@ L32B6:
.ifdef CONFIG_NO_INPUTBUFFER_ZP
beq LD399
cmp #>INPUTBUFFER
.elseif .def(AIM65)
beq LD399
cmp #$01
.endif
bne PUTNEW
LD399:

2
trig.s
View File

@ -130,6 +130,7 @@ MICROSOFT:
.endif
.endif
.ifndef AIM65
; ----------------------------------------------------------------------------
; "ATN" FUNCTION
; ----------------------------------------------------------------------------
@ -199,3 +200,4 @@ POLY_ATN:
.if .def(CONFIG_11A) && (!.def(CONFIG_2))
.byte $00 ; XXX
.endif
.endif

View File

@ -180,6 +180,12 @@ SGNCPR = STRNG1
FACEXTENSION = STRNG1+1
STRNG2:
.res 2
.ifdef AIM65
ATN:
.res 3
ZBE:
.res 1
.endif
CHRGET:
TXTPTR = <(GENERIC_TXTPTR-GENERIC_CHRGET + CHRGET)
CHRGOT = <(GENERIC_CHRGOT-GENERIC_CHRGET + CHRGET)