├── .gitignore ├── README.md ├── TODO.txt ├── aim65.cfg ├── aim65_extra.s ├── aim65_iscntc.s ├── aim65_loadsave.s ├── apple_extra.s ├── apple_iscntc.s ├── apple_loadsave.s ├── applesoft.cfg ├── array.s ├── bios.s ├── cbm1_patches.s ├── cbm_iscntc.s ├── cbmbasic1.cfg ├── cbmbasic2.cfg ├── chrget.s ├── defines.s ├── defines_aim65.s ├── defines_apple.s ├── defines_cbm1.s ├── defines_cbm2.s ├── defines_eater.s ├── defines_kbd.s ├── defines_kim.s ├── defines_microtan.s ├── defines_osi.s ├── defines_sym1.s ├── eater.cfg ├── eater_iscntc.s ├── error.s ├── eval.s ├── extra.s ├── float.s ├── flow1.s ├── flow2.s ├── header.s ├── init.s ├── inline.s ├── input.s ├── iscntc.s ├── kb9.cfg ├── kbd_extra.s ├── kbd_iscntc.s ├── kbd_loadsave.s ├── kbdbasic.cfg ├── kim_extra.s ├── kim_iscntc.s ├── kim_loadsave.s ├── lcd.s ├── loadsave.s ├── macros.s ├── make.sh ├── memory.s ├── message.s ├── microtan.cfg ├── microtan_extra.s ├── microtan_iscntc.s ├── microtan_loadsave.s ├── misc1.s ├── misc2.s ├── misc3.s ├── msbasic.s ├── orig ├── aim65.bin ├── applesoft.bin ├── cbmbasic1.bin ├── cbmbasic2.bin ├── kb9.bin ├── kbdbasic.bin ├── microtan.bin ├── osi.bin └── sym1.bin ├── osi.cfg ├── osi_iscntc.s ├── poke.s ├── print.s ├── program.s ├── regress.sh ├── rnd.s ├── string.s ├── sym1.cfg ├── sym1_iscntc.s ├── sym1_loadsave.s ├── token.s ├── trig.s ├── var.s ├── wozmon.s └── zeropage.s /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft BASIC for the Ben Eater 6502 project 2 | 3 | This code was forked from [mist64/msbasic](https://github.com/mist64/msbasic) and I've added the code from my YouTube videos describing how to port MSBASIC to my 6502 project. The latest commit will match the code from the latest video. 4 | 5 | But if you're following along with earlier videos, the "code" link below will take you to the code from that video: 6 | 7 | | | Video | Code | 8 | |--------------------------------|----------------------------------------------------------|--------------------| 9 | | ![Video thumbnail][thumbnail1] | [Running MSBASIC on my breadboard 6502 computer][video1] | [a15c8e0][commit1] | 10 | | ![Video thumbnail][thumbnail2] | [How input buffering works][video2] | [54ef9ac][commit2] | 11 | | ![Video thumbnail][thumbnail2] | [RS232 flow control][video3] | [c21542e][commit3] | 12 | | ![Video thumbnail][thumbnail4] | [Hacking Microsoft BASIC][video4] | [f41cac4][commit4] | 13 | | ![Video thumbnail][thumbnail5] | [Reverse engineering Microsoft BASIC][video5] | [master][commit5] | 14 | 15 | [thumbnail1]: https://i.ytimg.com/vi/XlbPnihCM0E/mqdefault.jpg 16 | [video1]: https://youtu.be/XlbPnihCM0E 17 | [commit1]: https://github.com/beneater/msbasic/tree/a15c8e0fdf620c800913cbb709df4042ab5c8dad 18 | 19 | 20 | [thumbnail2]: https://i.ytimg.com/vi/mpIFag8zSWo/mqdefault.jpg 21 | [video2]: https://youtu.be/mpIFag8zSWo 22 | [commit2]: https://github.com/beneater/msbasic/tree/54ef9ac51f4134ac537c7011802a2f81112a242b 23 | 24 | 25 | [thumbnail3]: https://i.ytimg.com/vi/LuKMVXWD7FY/mqdefault.jpg 26 | [video3]: https://youtu.be/LuKMVXWD7FY 27 | [commit3]: https://github.com/beneater/msbasic/tree/c21542e724b3da45ba3790405c2cf85e77bc1ad4 28 | 29 | [thumbnail4]: https://i.ytimg.com/vi/gOwi2p1pzVM/mqdefault.jpg 30 | [video4]: https://youtu.be/gOwi2p1pzVM 31 | [commit4]: https://github.com/beneater/msbasic/tree/f41cac4b064fa7c0bd20c8c33387b2a1c32a8da1 32 | 33 | [thumbnail5]: https://i.ytimg.com/vi/aVVKgwr_SfQ/mqdefault.jpg 34 | [video5]: https://youtu.be/aVVKgwr_SfQ 35 | [commit5]: https://github.com/beneater/msbasic/tree/master 36 | 37 | Below is the original README: 38 | 39 | # Microsoft BASIC for 6502 40 | 41 | This is a single integrated assembly source tree that can generate nine different versions of Microsoft BASIC for 6502. 42 | 43 | By running ./make.sh, this will generate all versions and compare them to the original files byte by byte. The CC65 compiler suite is need to build this project. 44 | 45 | These are the first ten (known) versions of Microsoft BASIC for 6502: 46 | 47 | | Name | Release | MS Version | ROM | 9digit | INPUTBUFFER | extensions | .define | 48 | | ------------------- |:--------:| ------------ |:----:|:------:|:------------:|:-----------:| ---------- | 49 | | Commodore BASIC 1 | 1977 | | Y | Y | ZP | CBM | | 50 | | OSI BASIC | 1977 | 1.0 REV 3.2 | Y | N | ZP | - | CONFIG_10A | 51 | | AppleSoft I | 1977 | 1.1 | N | Y | $0200 | Apple | CONFIG_11 | 52 | | KIM BASIC | 1977 | 1.1 | N | Y | ZP | - | CONFIG_11A | 53 | | AppleSoft II | 1978 | | Y | Y | $0200 | Apple | CONFIG_2 | 54 | | AIM-65 BASIC | 1978 | 1.1? | Y | N | ZP | AIM | CONFIG_2A | 55 | | SYM-1 BASIC | 1978 | 1.1? | Y | N | ZP | SYM | CONFIG_2A | 56 | | Commodore BASIC 2 | 1979 | | Y | Y | $0200 | CBM | CONFIG_2A | 57 | | KBD BASIC | 1982 | | Y | N | $0700 | KBD | CONFIG_2B | 58 | | MicroTAN | 1980 | | Y | Y | ZP | - | CONFIG_2C | 59 | 60 | (Note that this assembly source cannot (yet) build AppleSoft II.) 61 | 62 | This lists the versions in the order in which they were forked from the Microsoft source base. Commodore BASIC 1, as used on the original PET is the oldest known version of Microsoft BASIC for 6502. It contains some additions to Microsoft's version, like Commodore-style file I/O. 63 | 64 | The CONFIG_n defines specify what Microsoft-version the OEM version is based on. If CONFIG_2B is defined, for example, CONFIG_2A, CONFIG_2, CONFIG_11A, CONFIG_11 and CONFIG_10A will be defined as well, and all bugfixes up to version 2B will be enabled. 65 | 66 | The following symbols can be defined in addition: 67 | 68 | | Configuration Symbol | Description 69 | | --------------------------------- | -------------------------------------------------------------------------------- 70 | | CONFIG_CBM1_PATCHES | jump out into CBM1's binary patches instead of doing the right thing inline 71 | | CONFIG_CBM_ALL | add all Commodore-specific additions except file I/O 72 | | CONFIG_DATAFLG | ? 73 | | CONFIG_EASTER_EGG | include the CBM2 "WAIT 6502" easter egg 74 | | CONFIG_FILE | support Commodore PRINT#, INPUT#, GET#, CMD 75 | | CONFIG_IO_MSB | all I/O has bit #7 set 76 | | CONFIG_MONCOUT_DESTROYS_Y | Y needs to be preserved when calling MONCOUT 77 | | CONFIG_NO_CR | terminal doesn't need explicit CRs on line ends 78 | | CONFIG_NO_LINE_EDITING | disable support for Microsoft-style "@", "_", BEL etc. 79 | | CONFIG_NO_POKE | don't support PEEK, POKE and WAIT 80 | | CONFIG_NO_READ_Y_IS_ZERO_HACK | don't do a very volatile trick that saves one byte 81 | | CONFIG_NULL | support for the NULL statement 82 | | CONFIG_PEEK_SAVE_LINNUM | preserve LINNUM on a PEEK 83 | | CONFIG_PRINTNULLS | whether PRINTNULLS does anything 84 | | CONFIG_PRINT_CR | print CR when line end reached 85 | | CONFIG_RAM | optimizations for RAM version of BASIC, only use on 1.x 86 | | CONFIG_ROR_WORKAROUND | use workaround for buggy 6502s from 1975/1976; not safe for CONFIG_SMALL! 87 | | CONFIG_SAFE_NAMENOTFOUND | check both bytes of the caller's address in NAMENOTFOUND 88 | | CONFIG_SCRTCH_ORDER | where in the init code to call SCRTCH 89 | | CONFIG_SMALL | use 6 digit FP instead of 9 digit, use 2 character error messages, don't have GET 90 | | CONFIG_SMALL_ERROR | use 2 character error messages 91 | 92 | Changing symbol definitions can alter an existing base configuration, but it not guaranteed to assemble 93 | or work correctly. 94 | 95 | ## More Information 96 | 97 | More information on the differences of the respective versions can be found on this blog entry: [Create your own Version of Microsoft BASIC for 6502](http://www.pagetable.com/?p=46). 98 | 99 | ## License 100 | 101 | 2-clause BSD 102 | 103 | ## Credits 104 | 105 | * Main work by Michael Steil . 106 | * AIM-65 and SYM-1 by Martin Hoffmann-Vetter 107 | * Function names and all uppercase comments taken from Bob Sander-Cederlof's excellent [AppleSoft II disassembly](http://www.txbobsc.com/scsc/scdocumentor/). 108 | * [Applesoft lite](http://cowgod.org/replica1/applesoft/) by Tom Greene helped a lot, too. 109 | * Thanks to Joe Zbicak for help with Intellision Keyboard BASIC 110 | * This work is dedicated to the memory of my dear hacking pal Michael "acidity" Kollmann. 111 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | * convert messy init code into completely different 2 | files without ifdefs (not much in common!) 3 | * move all machine specific code into separate files 4 | * rename all labels that point to RTS to RTSn 5 | * add AppleSoft comments 6 | * look for all " $", i.e. (zeropage) constants, replace them 7 | with symbols 8 | * convert platform ifdefs in generic files into feature ifdefs or macros 9 | * reconstruct pre-CBM1, i.e. CBM1 without the patches 10 | * add some comments to every file 11 | -------------------------------------------------------------------------------- /aim65.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $B000, size = $2000, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /aim65_extra.s: -------------------------------------------------------------------------------- 1 | .segment "EXTRA" 2 | 3 | LCFFA: 4 | jsr CHRGOT 5 | jmp LB89D -------------------------------------------------------------------------------- /aim65_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | lda DRA2 4 | pha 5 | lda #$7f 6 | sta DRA2 7 | pha 8 | pla 9 | lda DRB2 10 | rol a 11 | pla 12 | sta DRA2 13 | bcs RET2 14 | 15 | jsr GETKEY 16 | lda #$03 17 | cmp #$03 18 | ;!!! runs into "STOP" -------------------------------------------------------------------------------- /aim65_loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | SAVE: 4 | pha 5 | jsr WHEREO 6 | jsr OUTSP 7 | lda #$ff 8 | jmp LB4BF 9 | 10 | MONRDKEY: 11 | lda INFLG 12 | jsr COUT5 13 | bne LOAD2 14 | jmp INALL 15 | LOAD2: 16 | jmp CUREAD 17 | 18 | MONCOUT: 19 | pha 20 | lda OUTFLG 21 | jsr COUT5 22 | bne COUT3 23 | pla 24 | jmp OUTALL 25 | 26 | COUT3: 27 | pla 28 | cmp #LF 29 | beq COUT6 30 | cmp #CR 31 | beq COUT4 32 | jmp OUTPUT 33 | COUT4: 34 | jsr CRCK 35 | lda #CR 36 | rts 37 | 38 | COUT5: 39 | cmp #$54 40 | beq COUT6 41 | cmp #$55 42 | beq COUT6 43 | cmp #$4C 44 | COUT6: 45 | rts 46 | 47 | MONRDKEY2: 48 | jsr ROONEK 49 | tya 50 | beq COUT5 51 | jmp GETKY 52 | -------------------------------------------------------------------------------- /apple_extra.s: -------------------------------------------------------------------------------- 1 | .segment "EXTRA" 2 | 3 | .byte 0,0,0 4 | L2900: 5 | jsr LFD6A 6 | stx $33 7 | ldx #$00 8 | L2907: 9 | lda $0200,x 10 | and #$7F 11 | cmp #$0D 12 | bne L2912 13 | lda #$00 14 | L2912: 15 | sta $0200,x 16 | inx 17 | bne L2907 18 | ldx $33 19 | rts 20 | PLT: 21 | jmp L29F0 22 | L291E: 23 | cmp #$47 24 | bne L2925 25 | jmp L29E0 26 | L2925: 27 | cmp #$43 28 | bne L292B 29 | beq L2988 30 | L292B: 31 | cmp #$50 32 | beq L2930 33 | inx 34 | L2930: 35 | stx $33 36 | L2932: 37 | jsr FRMEVL 38 | jsr ROUND_FAC 39 | jsr AYINT 40 | lda FAC+4 41 | ldx $33 42 | sta $0300,x 43 | dec $33 44 | bmi L294Dx 45 | lda #$2C 46 | jsr SYNCHR 47 | bpl L2932 48 | L294Dx: 49 | tay 50 | pla 51 | cmp #$43 52 | bne L2957 53 | tya 54 | jmp LF864 55 | L2957: 56 | cmp #$50 57 | bne L2962 58 | tya 59 | ldy $0301 60 | jmp LF800 61 | L2962: 62 | pha 63 | lda $0301 64 | sta $2C 65 | sta $2D 66 | pla 67 | cmp #$48 68 | bne L2978 69 | lda $0300 70 | ldy $0302 71 | jmp LF819 72 | L2978: 73 | cmp #$56 74 | beq L297F 75 | jmp SYNERR 76 | L297F: 77 | ldy $0300 78 | lda $0302 79 | jmp LF828 80 | L2988: 81 | dex 82 | beq L2930 83 | INLINX: 84 | jsr OUTQUES 85 | jsr OUTSP 86 | ldx #$80 87 | jmp INLIN1 88 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 89 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 90 | .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 91 | .byte 0,0,0,0,0,0,0,0,0,0 92 | USR_FUNC: 93 | jsr L29DA 94 | lda FAC+3 95 | sta FAC+5 96 | jmp (FAC+4) 97 | L29DA: 98 | jmp (GOAYINT) 99 | brk 100 | brk 101 | brk 102 | L29E0: 103 | pla 104 | jmp LFB40 105 | .byte 0,0,0,0,0,0,0,0,0,0,0,0 106 | L29F0: 107 | pha 108 | ldx #$01 109 | inc $B9 110 | bne L29F9 111 | inc $BA 112 | L29F9: 113 | jmp L291E 114 | .byte $00,$00,$00,$00,$41,$53,$21,$D2 115 | .byte $02,$FA,$00 116 | lda $12 117 | beq L2A0E 118 | jmp (GOGIVEAYF) 119 | L2A0E: 120 | jsr LF689 121 | .byte $15,$BC,$08,$10,$52,$45,$75,$10 122 | .byte $CD,$00,$55,$15,$9E,$08,$10,$4C 123 | .byte $45,$75,$10,$D4,$00,$55,$15,$0E 124 | .byte $08,$10,$89,$10,$75,$15,$1C,$08 125 | .byte $10,$1F,$10,$75,$00 126 | jmp (GOGIVEAYF) 127 | ; ---------------------------------------------------------------------------- 128 | .byte 0,0,0,0,0,0 129 | -------------------------------------------------------------------------------- /apple_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | lda $C000 4 | cmp #$83 5 | beq L0ECC 6 | rts 7 | L0ECC: 8 | jsr RDKEY 9 | cmp #$03 10 | ;!!! runs into "STOP" -------------------------------------------------------------------------------- /apple_loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | SAVE: 4 | jsr L0F42 5 | jsr LFECD 6 | jsr L0F51 7 | jmp LFECD 8 | LOAD: 9 | jsr L0F42 10 | jsr LFEFD 11 | jsr L0F51 12 | jsr LFEFD 13 | lda #QT_LOADED 15 | jsr STROUT 16 | jmp FIX_LINKS 17 | QT_LOADED: 18 | .byte 0 ; XXX PATCHED 19 | .byte "OADED" 20 | .byte 0 21 | L0F42: 22 | lda #$6C 23 | ldy #$00 24 | sta $3C 25 | sty $3D 26 | lda #$6E 27 | sta $3E 28 | sty $3F 29 | rts 30 | L0F51: 31 | lda $6A 32 | ldy $6B 33 | sta $3C 34 | sty $3D 35 | lda $6C 36 | ldy $6D 37 | sta $3E 38 | sty $3F 39 | rts 40 | -------------------------------------------------------------------------------- /applesoft.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $0800, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /array.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; COMPUTE ADDRESS OF FIRST VALUE IN ARRAY 5 | ; ARYPNT = (LOWTR) + #DIMS*2 + 5 6 | ; ---------------------------------------------------------------------------- 7 | GETARY: 8 | lda EOLPNTR 9 | asl a 10 | adc #$05 11 | adc LOWTR 12 | ldy LOWTR+1 13 | bcc L2FAF 14 | iny 15 | L2FAF: 16 | sta HIGHDS 17 | sty HIGHDS+1 18 | rts 19 | 20 | ; ---------------------------------------------------------------------------- 21 | NEG32768: 22 | .byte $90,$80,$00,$00 23 | 24 | .ifdef CONFIG_2C 25 | .byte $00; bugfix: short number 26 | .endif 27 | 28 | ; ---------------------------------------------------------------------------- 29 | ; EVALUATE NUMERIC FORMULA AT TXTPTR 30 | ; CONVERTING RESULT TO INTEGER 0 <= X <= 32767 31 | ; IN FAC+3,4 32 | ; ---------------------------------------------------------------------------- 33 | MAKINT: 34 | jsr CHRGET 35 | .ifdef CONFIG_2 36 | jsr FRMEVL 37 | .else 38 | jsr FRMNUM 39 | .endif 40 | 41 | ; ---------------------------------------------------------------------------- 42 | ; CONVERT FAC TO INTEGER 43 | ; MUST BE POSITIVE AND LESS THAN 32768 44 | ; ---------------------------------------------------------------------------- 45 | MKINT: 46 | .ifdef CONFIG_2 47 | jsr CHKNUM 48 | .endif 49 | lda FACSIGN 50 | bmi MI1 51 | 52 | ; ---------------------------------------------------------------------------- 53 | ; CONVERT FAC TO INTEGER 54 | ; MUST BE -32767 <= FAC <= 32767 55 | ; ---------------------------------------------------------------------------- 56 | AYINT: 57 | lda FAC 58 | cmp #$90 59 | bcc MI2 60 | lda #NEG32768 62 | jsr FCOMP 63 | MI1: 64 | bne IQERR 65 | MI2: 66 | jmp QINT 67 | 68 | ; ---------------------------------------------------------------------------- 69 | ; LOCATE ARRAY ELEMENT OR CREATE AN ARRAY 70 | ; ---------------------------------------------------------------------------- 71 | ARRAY: 72 | lda DIMFLG 73 | .ifndef CONFIG_SMALL 74 | ora VALTYP+1 75 | .endif 76 | pha 77 | lda VALTYP 78 | pha 79 | ldy #$00 80 | L2FDE: 81 | tya 82 | pha 83 | lda VARNAM+1 84 | pha 85 | lda VARNAM 86 | pha 87 | jsr MAKINT 88 | pla 89 | sta VARNAM 90 | pla 91 | sta VARNAM+1 92 | pla 93 | tay 94 | tsx 95 | lda STACK+2,x 96 | pha 97 | lda STACK+1,x 98 | pha 99 | lda FAC_LAST-1 100 | sta STACK+2,x 101 | lda FAC_LAST 102 | sta STACK+1,x 103 | iny 104 | jsr CHRGOT 105 | cmp #$2C 106 | beq L2FDE 107 | sty EOLPNTR 108 | jsr CHKCLS 109 | pla 110 | sta VALTYP 111 | pla 112 | .ifndef CONFIG_SMALL 113 | sta VALTYP+1 114 | and #$7F 115 | .endif 116 | sta DIMFLG 117 | ; ---------------------------------------------------------------------------- 118 | ; SEARCH ARRAY TABLE FOR THIS ARRAY NAME 119 | ; ---------------------------------------------------------------------------- 120 | ldx ARYTAB 121 | lda ARYTAB+1 122 | L301F: 123 | stx LOWTR 124 | sta LOWTR+1 125 | cmp STREND+1 126 | bne L302B 127 | cpx STREND 128 | beq MAKE_NEW_ARRAY 129 | L302B: 130 | ldy #$00 131 | lda (LOWTR),y 132 | iny 133 | cmp VARNAM 134 | bne L303A 135 | lda VARNAM+1 136 | cmp (LOWTR),y 137 | beq USE_OLD_ARRAY 138 | L303A: 139 | iny 140 | lda (LOWTR),y 141 | clc 142 | adc LOWTR 143 | tax 144 | iny 145 | lda (LOWTR),y 146 | adc LOWTR+1 147 | bcc L301F 148 | 149 | ; ---------------------------------------------------------------------------- 150 | ; ERROR: BAD SUBSCRIPTS 151 | ; ---------------------------------------------------------------------------- 152 | SUBERR: 153 | ldx #ERR_BADSUBS 154 | .byte $2C 155 | 156 | ; ---------------------------------------------------------------------------- 157 | ; ERROR: ILLEGAL QUANTITY 158 | ; ---------------------------------------------------------------------------- 159 | IQERR: 160 | ldx #ERR_ILLQTY 161 | JER: 162 | jmp ERROR 163 | 164 | ; ---------------------------------------------------------------------------- 165 | ; FOUND THE ARRAY 166 | ; ---------------------------------------------------------------------------- 167 | USE_OLD_ARRAY: 168 | ldx #ERR_REDIMD 169 | lda DIMFLG 170 | bne JER 171 | jsr GETARY 172 | lda EOLPNTR 173 | ldy #$04 174 | cmp (LOWTR),y 175 | bne SUBERR 176 | jmp FIND_ARRAY_ELEMENT 177 | 178 | ; ---------------------------------------------------------------------------- 179 | ; CREATE A NEW ARRAY, UNLESS CALLED FROM GETARYPT 180 | ; ---------------------------------------------------------------------------- 181 | MAKE_NEW_ARRAY: 182 | jsr GETARY 183 | jsr REASON 184 | lda #$00 185 | tay 186 | sta STRNG2+1 187 | ldx #BYTES_PER_ELEMENT 188 | .if .def(CONFIG_SMALL) && (!.def(CONFIG_2)) 189 | stx STRNG2 190 | .endif 191 | lda VARNAM 192 | sta (LOWTR),y 193 | .ifndef CONFIG_SMALL 194 | bpl L3078 195 | dex 196 | L3078: 197 | .endif 198 | iny 199 | lda VARNAM+1 200 | sta (LOWTR),y 201 | .if (!.def(CONFIG_SMALL)) || .def(CONFIG_2) 202 | bpl L3081 203 | dex 204 | .if !(.def(CONFIG_SMALL) && .def(CONFIG_2)) 205 | dex 206 | .endif 207 | L3081: 208 | stx STRNG2 209 | .endif 210 | lda EOLPNTR 211 | iny 212 | iny 213 | iny 214 | sta (LOWTR),y 215 | L308A: 216 | ldx #$0B 217 | lda #$00 218 | bit DIMFLG 219 | bvc L309A 220 | pla 221 | clc 222 | adc #$01 223 | tax 224 | pla 225 | adc #$00 226 | L309A: 227 | iny 228 | sta (LOWTR),y 229 | iny 230 | txa 231 | sta (LOWTR),y 232 | jsr MULTIPLY_SUBSCRIPT 233 | stx STRNG2 234 | sta STRNG2+1 235 | ldy INDEX 236 | dec EOLPNTR 237 | bne L308A 238 | adc HIGHDS+1 239 | bcs GME 240 | sta HIGHDS+1 241 | tay 242 | txa 243 | adc HIGHDS 244 | bcc L30BD 245 | iny 246 | beq GME 247 | L30BD: 248 | jsr REASON 249 | sta STREND 250 | sty STREND+1 251 | lda #$00 252 | inc STRNG2+1 253 | ldy STRNG2 254 | beq L30D1 255 | L30CC: 256 | dey 257 | sta (HIGHDS),y 258 | bne L30CC 259 | L30D1: 260 | dec HIGHDS+1 261 | dec STRNG2+1 262 | bne L30CC 263 | inc HIGHDS+1 264 | sec 265 | lda STREND 266 | sbc LOWTR 267 | ldy #$02 268 | sta (LOWTR),y 269 | lda STREND+1 270 | iny 271 | sbc LOWTR+1 272 | sta (LOWTR),y 273 | lda DIMFLG 274 | bne RTS9 275 | iny 276 | 277 | ; ---------------------------------------------------------------------------- 278 | ; FIND SPECIFIED ARRAY ELEMENT 279 | ; 280 | ; (LOWTR),Y POINTS AT # OF DIMS IN ARRAY DESCRIPTOR 281 | ; THE SUBSCRIPTS ARE ALL ON THE STACK AS INTEGERS 282 | ; ---------------------------------------------------------------------------- 283 | FIND_ARRAY_ELEMENT: 284 | lda (LOWTR),y 285 | sta EOLPNTR 286 | lda #$00 287 | sta STRNG2 288 | L30F6: 289 | sta STRNG2+1 290 | iny 291 | pla 292 | tax 293 | sta FAC_LAST-1 294 | pla 295 | sta FAC_LAST 296 | cmp (LOWTR),y 297 | bcc FAE2 298 | bne GSE 299 | iny 300 | txa 301 | cmp (LOWTR),y 302 | bcc FAE3 303 | ; ---------------------------------------------------------------------------- 304 | GSE: 305 | jmp SUBERR 306 | GME: 307 | jmp MEMERR 308 | ; ---------------------------------------------------------------------------- 309 | FAE2: 310 | iny 311 | FAE3: 312 | lda STRNG2+1 313 | ora STRNG2 314 | clc 315 | beq L3124 316 | jsr MULTIPLY_SUBSCRIPT 317 | txa 318 | adc FAC_LAST-1 319 | tax 320 | tya 321 | ldy INDEX 322 | L3124: 323 | adc FAC_LAST 324 | stx STRNG2 325 | dec EOLPNTR 326 | bne L30F6 327 | .if .def(CONFIG_SMALL) && (!.def(CONFIG_2)) 328 | asl STRNG2 329 | rol a 330 | bcs GSE 331 | asl STRNG2 332 | rol a 333 | bcs GSE 334 | tay 335 | lda STRNG2 336 | .else 337 | .ifdef CONFIG_11A 338 | sta STRNG2+1 339 | .endif 340 | ldx #BYTES_FP 341 | .ifdef CONFIG_SMALL 342 | lda VARNAM+1 343 | .else 344 | lda VARNAM 345 | .endif 346 | bpl L3135 347 | dex 348 | L3135: 349 | .ifdef CONFIG_SMALL 350 | stx RESULT+1 351 | .else 352 | lda VARNAM+1 353 | bpl L313B 354 | dex 355 | dex 356 | L313B: 357 | stx RESULT+2 358 | .endif 359 | lda #$00 360 | jsr MULTIPLY_SUBS1 361 | txa 362 | .endif 363 | adc HIGHDS 364 | sta VARPNT 365 | tya 366 | adc HIGHDS+1 367 | sta VARPNT+1 368 | tay 369 | lda VARPNT 370 | RTS9: 371 | rts 372 | 373 | ; ---------------------------------------------------------------------------- 374 | ; MULTIPLY (STRNG2) BY ((LOWTR),Y) 375 | ; LEAVING PRODUCT IN A,X. (HI-BYTE ALSO IN Y.) 376 | ; USED ONLY BY ARRAY SUBSCRIPT ROUTINES 377 | ; ---------------------------------------------------------------------------- 378 | MULTIPLY_SUBSCRIPT: 379 | sty INDEX 380 | lda (LOWTR),y 381 | sta RESULT_LAST-2 382 | dey 383 | lda (LOWTR),y 384 | MULTIPLY_SUBS1: 385 | sta RESULT_LAST-1 386 | lda #$10 387 | sta INDX 388 | ldx #$00 389 | ldy #$00 390 | L3163: 391 | txa 392 | asl a 393 | tax 394 | tya 395 | rol a 396 | tay 397 | bcs GME 398 | asl STRNG2 399 | rol STRNG2+1 400 | bcc L317C 401 | clc 402 | txa 403 | adc RESULT_LAST-2 404 | tax 405 | tya 406 | adc RESULT_LAST-1 407 | tay 408 | bcs GME 409 | L317C: 410 | dec INDX 411 | bne L3163 412 | rts 413 | 414 | -------------------------------------------------------------------------------- /bios.s: -------------------------------------------------------------------------------- 1 | .setcpu "65C02" 2 | .debuginfo 3 | 4 | .zeropage 5 | .org ZP_START0 6 | READ_PTR: .res 1 7 | WRITE_PTR: .res 1 8 | 9 | .segment "INPUT_BUFFER" 10 | INPUT_BUFFER: .res $100 11 | 12 | .segment "BIOS" 13 | 14 | ACIA_DATA = $5000 15 | ACIA_STATUS = $5001 16 | ACIA_CMD = $5002 17 | ACIA_CTRL = $5003 18 | PORTA = $6001 19 | DDRA = $6003 20 | 21 | LOAD: 22 | rts 23 | 24 | SAVE: 25 | rts 26 | 27 | 28 | ; Input a character from the serial interface. 29 | ; On return, carry flag indicates whether a key was pressed 30 | ; If a key was pressed, the key value will be in the A register 31 | ; 32 | ; Modifies: flags, A 33 | MONRDKEY: 34 | CHRIN: 35 | phx 36 | jsr BUFFER_SIZE 37 | beq @no_keypressed 38 | jsr READ_BUFFER 39 | jsr CHROUT ; echo 40 | pha 41 | jsr BUFFER_SIZE 42 | cmp #$B0 43 | bcs @mostly_full 44 | lda #$fe 45 | and PORTA 46 | sta PORTA 47 | @mostly_full: 48 | pla 49 | plx 50 | sec 51 | rts 52 | @no_keypressed: 53 | plx 54 | clc 55 | rts 56 | 57 | 58 | ; Output a character (from the A register) to the serial interface. 59 | ; 60 | ; Modifies: flags 61 | MONCOUT: 62 | CHROUT: 63 | pha 64 | sta ACIA_DATA 65 | lda #$FF 66 | @txdelay: dec 67 | bne @txdelay 68 | pla 69 | rts 70 | 71 | ; Initialize the circular input buffer 72 | ; Modifies: flags, A 73 | INIT_BUFFER: 74 | lda READ_PTR 75 | sta WRITE_PTR 76 | lda #$01 77 | sta DDRA 78 | lda #$fe 79 | and PORTA 80 | sta PORTA 81 | rts 82 | 83 | ; Write a character (from the A register) to the circular input buffer 84 | ; Modifies: flags, X 85 | WRITE_BUFFER: 86 | ldx WRITE_PTR 87 | sta INPUT_BUFFER,x 88 | inc WRITE_PTR 89 | rts 90 | 91 | ; Read a character from the circular input buffer and put it in the A register 92 | ; Modifies: flags, A, X 93 | READ_BUFFER: 94 | ldx READ_PTR 95 | lda INPUT_BUFFER,x 96 | inc READ_PTR 97 | rts 98 | 99 | ; Return (in A) the number of unread bytes in the circular input buffer 100 | ; Modifies: flags, A 101 | BUFFER_SIZE: 102 | lda WRITE_PTR 103 | sec 104 | sbc READ_PTR 105 | rts 106 | 107 | 108 | ; Interrupt request handler 109 | IRQ_HANDLER: 110 | pha 111 | phx 112 | lda ACIA_STATUS 113 | ; For now, assume the only source of interrupts is incoming data 114 | lda ACIA_DATA 115 | jsr WRITE_BUFFER 116 | jsr BUFFER_SIZE 117 | cmp #$F0 118 | bcc @not_full 119 | lda #$01 120 | ora PORTA 121 | sta PORTA 122 | @not_full: 123 | plx 124 | pla 125 | rti 126 | 127 | .include "wozmon.s" 128 | 129 | .segment "RESETVEC" 130 | .word $0F00 ; NMI vector 131 | .word RESET ; RESET vector 132 | .word IRQ_HANDLER ; IRQ vector 133 | 134 | -------------------------------------------------------------------------------- /cbm1_patches.s: -------------------------------------------------------------------------------- 1 | .segment "INIT" 2 | 3 | PATCH1: 4 | clc 5 | jmp CONTROL_C_TYPED 6 | PATCH2: 7 | bit FAC+4 8 | bpl LE1AA 9 | cmp #$54 10 | bne LE1AA 11 | jmp LCE3B 12 | LE1AA: 13 | rts 14 | PATCH3: 15 | bit FAC+4 16 | bmi LE1B2 17 | jmp LCE90 18 | LE1B2: 19 | cmp #$54 20 | beq LE1B9 21 | jmp LCE82 22 | LE1B9: 23 | jmp LCE69 24 | PATCH4: 25 | sta CHARAC 26 | inx 27 | jmp LE1D9 28 | PATCH5: 29 | bpl LE1C9 30 | lda Z8C 31 | ldy Z8C+1 32 | rts 33 | LE1C9: 34 | ldy #$FF 35 | rts 36 | PATCH6: 37 | bne LE1D8 38 | LE1CE: 39 | inc POSX 40 | bne LE1D8 41 | lda $E2 42 | sta POSX 43 | bne LE1CE 44 | LE1D8: 45 | rts 46 | LE1D9: 47 | stx TXTPTR 48 | pla 49 | pla 50 | tya 51 | jmp L2B1C 52 | -------------------------------------------------------------------------------- /cbm_iscntc.s: -------------------------------------------------------------------------------- 1 | ; nothing - ISCNTC is a KERNAL function -------------------------------------------------------------------------------- /cbmbasic1.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $C000, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /cbmbasic2.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $C000, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /chrget.s: -------------------------------------------------------------------------------- 1 | .segment "CHRGET" 2 | RAMSTART1: 3 | GENERIC_CHRGET: 4 | inc TXTPTR 5 | bne GENERIC_CHRGOT 6 | inc TXTPTR+1 7 | GENERIC_CHRGOT: 8 | GENERIC_TXTPTR = GENERIC_CHRGOT + 1 9 | lda $EA60 10 | .ifdef KBD 11 | jsr LF430 12 | .endif 13 | cmp #$3A 14 | bcs L4058 15 | GENERIC_CHRGOT2: 16 | cmp #$20 17 | beq GENERIC_CHRGET 18 | sec 19 | sbc #$30 20 | sec 21 | sbc #$D0 22 | L4058: 23 | rts 24 | -------------------------------------------------------------------------------- /defines.s: -------------------------------------------------------------------------------- 1 | .if .def(cbmbasic1) 2 | CBM1 := 1 3 | .include "defines_cbm1.s" 4 | .elseif .def(osi) 5 | OSI := 1 6 | .include "defines_osi.s" 7 | .elseif .def(applesoft) 8 | APPLE := 1 9 | .include "defines_apple.s" 10 | .elseif .def(kb9) 11 | KIM := 1 12 | .include "defines_kim.s" 13 | .elseif .def(cbmbasic2) 14 | CBM2 := 1 15 | .include "defines_cbm2.s" 16 | .elseif .def(kbdbasic) 17 | KBD := 1 18 | .include "defines_kbd.s" 19 | .elseif .def(microtan) 20 | MICROTAN := 1 21 | .include "defines_microtan.s" 22 | .elseif .def(aim65) 23 | AIM65 := 1 24 | .include "defines_aim65.s" 25 | .elseif .def(sym1) 26 | SYM1 := 1 27 | .include "defines_sym1.s" 28 | .elseif .def(eater) 29 | EATER := 1 30 | .include "defines_eater.s" 31 | .endif 32 | 33 | .ifdef CONFIG_2C 34 | CONFIG_2B := 1 35 | .endif 36 | .ifdef CONFIG_2B 37 | CONFIG_2A := 1 38 | .endif 39 | .ifdef CONFIG_2A 40 | CONFIG_2 := 1 41 | .endif 42 | .ifdef CONFIG_2 43 | CONFIG_11A := 1 44 | .endif 45 | .ifdef CONFIG_11A 46 | CONFIG_11 := 1 47 | .endif 48 | .ifdef CONFIG_11 49 | CONFIG_10A := 1 50 | .endif 51 | 52 | .ifdef CONFIG_SMALL 53 | BYTES_FP := 4 54 | CONFIG_SMALL_ERROR := 1 55 | .else 56 | BYTES_FP := 5 57 | .endif 58 | 59 | .ifndef BYTES_PER_ELEMENT 60 | BYTES_PER_ELEMENT := BYTES_FP 61 | .endif 62 | BYTES_PER_VARIABLE := BYTES_FP+2 63 | MANTISSA_BYTES := BYTES_FP-1 64 | BYTES_PER_FRAME := 2*BYTES_FP+8 65 | FOR_STACK1 := 2*BYTES_FP+5 66 | FOR_STACK2 := BYTES_FP+4 67 | 68 | .ifndef MAX_EXPON 69 | MAX_EXPON = 10 70 | .endif 71 | 72 | STACK := $0100 73 | .ifndef STACK2 74 | STACK2 := STACK 75 | .endif 76 | 77 | .ifdef INPUTBUFFER 78 | .if INPUTBUFFER >= $0100 79 | CONFIG_NO_INPUTBUFFER_ZP := 1 80 | .endif 81 | .if INPUTBUFFER = $0200 82 | CONFIG_INPUTBUFFER_0200 := 1 83 | .endif 84 | .endif 85 | INPUTBUFFERX = INPUTBUFFER & $FF00 86 | 87 | CR=13 88 | LF=10 89 | 90 | .ifndef CRLF_1 91 | CRLF_1 := CR 92 | CRLF_2 := LF 93 | .endif 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /defines_aim65.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_2A := 1 3 | 4 | CONFIG_NULL := 1 5 | CONFIG_PRINT_CR := 1 ; print CR when line end reached 6 | CONFIG_SAFE_NAMENOTFOUND := 1 7 | CONFIG_SCRTCH_ORDER := 1 8 | CONFIG_PEEK_SAVE_LINNUM := 1 9 | CONFIG_SMALL_ERROR := 1 10 | 11 | ; zero page 12 | ZP_START1 = $00 13 | ZP_START2 = $10 14 | ZP_START3 = $06 15 | ZP_START4 = $5E 16 | 17 | ;extra ZP variables 18 | USR := $03 19 | TXPSV := LASTOP 20 | 21 | NULL := IQERR 22 | 23 | ; inputbuffer 24 | INPUTBUFFER := $0016 25 | 26 | ;extra stack 27 | STACK2 := $0200 28 | 29 | ; constants 30 | STACK_TOP := $FD 31 | SPACE_FOR_GOSUB := $44 32 | NULL_MAX := $F2 33 | CRLF_1 := CR 34 | CRLF_2 := LF 35 | WIDTH := 20 36 | WIDTH2 := 10 37 | 38 | ; memory layout 39 | RAMSTART2 := $0211 40 | 41 | ; monitor functions 42 | PRIFLG := $A411 43 | INFLG := $A412 44 | OUTFLG := $A413 45 | DRA2 := $A480 46 | DRB2 := $A482 47 | 48 | DU13 := $E520 49 | PSLS := $E7DC 50 | LOAD := $E848 51 | WHEREO := $E871 52 | OUTPUT := $E97A 53 | INALL := $E993 54 | OUTALL := $E9BC 55 | CRCK := $EA24 56 | GETKEY := $EC40 57 | GETKY := $EC43 58 | ROONEK := $ECEF 59 | CUREAD := $FE83 -------------------------------------------------------------------------------- /defines_apple.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_11 := 1 3 | 4 | APPLE_BAD_BYTE := 1 5 | CONFIG_IO_MSB := 1 ; all I/O has bit #7 set 6 | CONFIG_PRINT_CR := 1 ; print CR when line end reached 7 | CONFIG_SAFE_NAMENOTFOUND := 1 8 | CONFIG_SCRTCH_ORDER := 3 9 | 10 | BYTES_PER_ELEMENT := 6 ; XXX override 11 | 12 | ; zero page 13 | ZP_START1 = $00 14 | ZP_START2 = $4F 15 | ZP_START3 = $0D 16 | ZP_START4 = $55 17 | 18 | ;extra ZP variables 19 | USR := $000A 20 | 21 | ; inputbuffer 22 | INPUTBUFFER := $0200 23 | 24 | ; constants 25 | STACK_TOP := $F8 26 | SPACE_FOR_GOSUB := $36 27 | CRLF_1 := CR 28 | CRLF_2 := $80 29 | WIDTH := 40 30 | WIDTH2 := 14 31 | 32 | ; memory layout 33 | RAMSTART2 := $2A00 34 | 35 | ; monitor functions 36 | MONRDKEY := $FD0C 37 | MONCOUT := $FDED 38 | LF689 := $F689 39 | LF800 := $F800 40 | LF819 := $F819 41 | LF828 := $F828 42 | LF864 := $F864 43 | TEX := $FB2F 44 | LFB40 := $FB40 45 | LFD0C := $FD0C 46 | LFD6A := $FD6A 47 | LFECD := $FECD 48 | LFEFD := $FEFD 49 | 50 | -------------------------------------------------------------------------------- /defines_cbm1.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | ; oldest known version, no CONFIG_n 3 | 4 | CONFIG_CBM_ALL := 1 5 | CONFIG_CBM1_PATCHES := 1 ; ** don't turn off! ** 6 | 7 | CONFIG_DATAFLG := 1 8 | CONFIG_FILE := 1; support PRINT#, INPUT#, GET#, CMD 9 | CONFIG_NO_CR := 1; terminal doesn't need explicit CRs on line ends 10 | CONFIG_NO_LINE_EDITING := 1; support for "@", "_", BEL etc. 11 | CONFIG_PRINTNULLS := 1; whether PRINTNULLS does anything 12 | CONFIG_SCRTCH_ORDER := 2 13 | 14 | ; zero page 15 | ZP_START1 = $00 16 | ZP_START2 = $04 17 | ZP_START3 = $5A 18 | ZP_START4 = $65 19 | 20 | ; extra ZP variables 21 | CURDVC := $0003 22 | TISTR := $0200 23 | Z96 := $020C 24 | USR := GORESTART 25 | 26 | ; constants 27 | SPACE_FOR_GOSUB := $36 28 | STACK_TOP := $FC 29 | NULL_MAX := $0A 30 | MAX_EXPON := 12 ; XXX override 31 | 32 | RAMSTART2 := $0400 33 | 34 | ; magic memory locations 35 | ENTROPY = $9044 36 | 37 | ; monitor functions 38 | OPEN := $FFC0 39 | CLOSE := $FFC3 40 | CHKIN := $FFC6 41 | CHKOUT := $FFC9 42 | CLRCH := $FFCC 43 | CHRIN := $FFCF 44 | CHROUT := $FFD2 45 | LOAD := $FFD5 46 | SAVE := $FFD8 47 | VERIFY := $FFDB 48 | SYS := $FFDE 49 | ISCNTC := $FFE1 50 | GETIN := $FFE4 51 | CLALL := $FFE7 52 | LE7F3 := $E7F3; for CBM1 53 | MONCOUT := CHROUT 54 | MONRDKEY := GETIN 55 | -------------------------------------------------------------------------------- /defines_cbm2.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_2A := 1 3 | 4 | CONFIG_CBM_ALL := 1 5 | 6 | CONFIG_DATAFLG := 1 7 | CONFIG_EASTER_EGG := 1 8 | CONFIG_FILE := 1; support PRINT#, INPUT#, GET#, CMD 9 | CONFIG_NO_CR := 1; terminal doesn't need explicit CRs on line ends 10 | CONFIG_NO_LINE_EDITING := 1; support for "@", "_", BEL etc. 11 | CONFIG_NO_READ_Y_IS_ZERO_HACK := 1 12 | CONFIG_PEEK_SAVE_LINNUM := 1 13 | CONFIG_SCRTCH_ORDER := 2 14 | 15 | ; zero page 16 | ZP_START1 = $00 17 | ZP_START2 = $0D 18 | ZP_START3 = $03 19 | ZP_START4 = $13 20 | 21 | ; extra/override ZP variables 22 | CURDVC := $000E 23 | TISTR := $008D 24 | Z96 := $0096 25 | POSX := $00C6 26 | TXPSV := LASTOP 27 | USR := GORESTART ; XXX 28 | 29 | ; inputbuffer 30 | INPUTBUFFER := $0200 31 | 32 | ; constants 33 | SPACE_FOR_GOSUB := $3E 34 | STACK_TOP := $FA 35 | WIDTH := 40 36 | WIDTH2 := 30 37 | 38 | RAMSTART2 := $0400 39 | 40 | ; magic memory locations 41 | ENTROPY = $E844 42 | 43 | ; monitor functions 44 | OPEN := $FFC0 45 | CLOSE := $FFC3 46 | CHKIN := $FFC6 47 | CHKOUT := $FFC9 48 | CLRCH := $FFCC 49 | CHRIN := $FFCF 50 | CHROUT := $FFD2 51 | LOAD := $FFD5 52 | SAVE := $FFD8 53 | VERIFY := $FFDB 54 | SYS := $FFDE 55 | ISCNTC := $FFE1 56 | GETIN := $FFE4 57 | CLALL := $FFE7 58 | LE7F3 := $E7F3; for CBM1 59 | MONCOUT := CHROUT 60 | MONRDKEY := GETIN 61 | -------------------------------------------------------------------------------- /defines_eater.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_2A := 1 3 | 4 | CONFIG_SCRTCH_ORDER := 2 5 | 6 | ; zero page 7 | ZP_START0 = $00 8 | ZP_START1 = $02 9 | ZP_START2 = $0C 10 | ZP_START3 = $62 11 | ZP_START4 = $6D 12 | 13 | ; extra/override ZP variables 14 | USR := GORESTART 15 | 16 | ; constants 17 | SPACE_FOR_GOSUB := $3E 18 | STACK_TOP := $FA 19 | WIDTH := 40 20 | WIDTH2 := 30 21 | RAMSTART2 := $0400 22 | -------------------------------------------------------------------------------- /defines_kbd.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_2B := 1 3 | 4 | CONFIG_NO_POKE := 1 5 | CONFIG_NO_READ_Y_IS_ZERO_HACK := 1 6 | CONFIG_SAFE_NAMENOTFOUND := 1 7 | CONFIG_SCRTCH_ORDER := 3 8 | CONFIG_SMALL := 1 9 | 10 | ; zero page 11 | ZP_START1 = $00 12 | ZP_START2 = $0F 13 | ZP_START3 = $06 14 | ZP_START4 = $15 15 | 16 | ; extra/override ZP variables 17 | TXPSV := $0049 18 | JMPADRS := $0093 19 | LOWTRX := $0094 ; $AB also EXPSGN? 20 | Z96 := $0096 21 | Z17 := $06FC 22 | Z18 := $06FD 23 | 24 | ; inputbuffer 25 | INPUTBUFFER := $0700 26 | 27 | ; constants 28 | STACK_TOP := $FE 29 | SPACE_FOR_GOSUB := $49 30 | CRLF_1 := LF 31 | CRLF_2 := CR 32 | 33 | ; magic memory locations 34 | L06FE := $06FE 35 | L6874 := $6874 36 | 37 | ; memory layout 38 | RAMSTART2 := $0300 39 | CONST_MEMSIZ := $3FFF 40 | 41 | ; monitor functions 42 | MONCOUT := $FDFA 43 | LC000 := $C000 44 | LC009 := $C009 45 | LDE24 := $DE24 46 | PRIMM := $DE42 47 | LDE48 := $DE48 48 | LDE53 := $DE53 49 | LDE7F := $DE7F 50 | LDE8C := $DE8C 51 | 52 | 53 | -------------------------------------------------------------------------------- /defines_kim.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_11A := 1 3 | 4 | CONFIG_MONCOUT_DESTROYS_Y := 1 5 | CONFIG_NULL := 1 6 | CONFIG_PRINT_CR := 1 ; print CR when line end reached 7 | CONFIG_RAM := 1 8 | CONFIG_ROR_WORKAROUND := 1 9 | CONFIG_SAFE_NAMENOTFOUND := 1 10 | CONFIG_SCRTCH_ORDER := 2 11 | 12 | ; zero page 13 | ZP_START1 = $00 14 | ZP_START2 = $15 15 | ZP_START3 = $0A 16 | ZP_START4 = $63 17 | 18 | ; constants 19 | STACK_TOP := $FC 20 | SPACE_FOR_GOSUB := $36 21 | NULL_MAX := $F2 ; probably different in original version; the image I have seems to be modified; see PDF 22 | WIDTH := 72 23 | WIDTH2 := 56 24 | 25 | ; magic memory locations 26 | L1800 := $1800 27 | L1873 := $1873 28 | 29 | ; monitor functions 30 | MONRDKEY := $1E5A 31 | MONCOUT := $1EA0 32 | 33 | -------------------------------------------------------------------------------- /defines_microtan.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_2C := 1 3 | 4 | CONFIG_NULL := 1 5 | CONFIG_MONCOUT_DESTROYS_Y := 1 6 | CONFIG_PEEK_SAVE_LINNUM := 1 7 | CONFIG_PRINT_CR := 1 ; print CR when line end reached 8 | CONFIG_ROR_WORKAROUND := 1 9 | CONFIG_SAFE_NAMENOTFOUND := 1 10 | CONFIG_SCRTCH_ORDER := 1 11 | 12 | ; zero page 13 | ZP_START1 = $17 14 | ZP_START2 = $2F 15 | ZP_START3 = $24 16 | ZP_START4 = $85 17 | 18 | ;extra ZP variables 19 | USR := $0021 20 | TXPSV := $00BA 21 | 22 | ; constants 23 | STACK_TOP := $FE 24 | SPACE_FOR_GOSUB := $3E 25 | NULL_MAX := $F0 26 | WIDTH := 80 27 | WIDTH2 := 56 28 | ; memory layout 29 | RAMSTART2 := $0400 30 | 31 | ; monitor functions 32 | MONRDKEY := $E210 33 | MONRDKEY2 := $E213 34 | MONCOUT := $E216 35 | LF000 := $F000 36 | LF003 := $F003 37 | LF006 := $F006 38 | LF009 := $F009 39 | LF00C := $F00C 40 | LF00F := $F00F 41 | LF018 := $F018 42 | LF01B := $F01B 43 | LF01E := $F01E 44 | LF021 := $F021 45 | LFDFA := $FDFA 46 | LFE73 := $FE73 47 | LFE75 := $FE75 48 | -------------------------------------------------------------------------------- /defines_osi.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_10A := 1 3 | 4 | CONFIG_DATAFLG := 1 5 | CONFIG_NULL := 1 6 | CONFIG_PRINT_CR := 1 ; print CR when line end reached 7 | CONFIG_SCRTCH_ORDER := 3 8 | CONFIG_SMALL := 1 9 | 10 | ; zero page 11 | ZP_START1 = $00 12 | ZP_START2 = $0D 13 | ZP_START3 = $5B 14 | ZP_START4 = $65 15 | 16 | ;extra ZP variables 17 | USR := $000A 18 | 19 | ; constants 20 | STACK_TOP := $FC 21 | SPACE_FOR_GOSUB := $33 22 | NULL_MAX := $0A 23 | WIDTH := 72 24 | WIDTH2 := 56 25 | 26 | ; memory layout 27 | RAMSTART2 := $0300 28 | 29 | ; magic memory locations 30 | L0200 := $0200 31 | 32 | ; monitor functions 33 | MONRDKEY := $FFEB 34 | MONCOUT := $FFEE 35 | MONISCNTC := $FFF1 36 | LOAD := $FFF4 37 | SAVE := $FFF7 38 | -------------------------------------------------------------------------------- /defines_sym1.s: -------------------------------------------------------------------------------- 1 | ; configuration 2 | CONFIG_2A := 1 3 | 4 | CONFIG_NULL := 1 5 | CONFIG_PRINT_CR := 1 ; print CR when line end reached 6 | CONFIG_SAFE_NAMENOTFOUND := 1 7 | CONFIG_SCRTCH_ORDER := 1 8 | CONFIG_PEEK_SAVE_LINNUM := 1 9 | CONFIG_SMALL_ERROR := 1 10 | 11 | ; zero page 12 | ZP_START1 = $00 13 | ZP_START2 = $18 14 | ZP_START3 = $0d 15 | ZP_START4 = $66 16 | 17 | ;extra ZP variables 18 | USR := $0A 19 | TXPSV := LASTOP 20 | ZD3 := $D3 21 | ZD4 := $D4 22 | 23 | GET := IQERR 24 | COS := USR1 25 | SIN := USR1 26 | TAN := USR1 27 | ATN := USR1 28 | 29 | ; inputbuffer 30 | INPUTBUFFER := $001E 31 | 32 | ; constants 33 | STACK_TOP := $FE 34 | SPACE_FOR_GOSUB := $3E 35 | NULL_MAX := $F0 36 | CRLF_1 := CR 37 | CRLF_2 := LF 38 | WIDTH := 72 39 | WIDTH2 := 56 40 | 41 | ; memory layout 42 | RAMSTART2 := $0200 43 | 44 | ; monitor functions 45 | ASCNIB := $8275 46 | INSTAT := $8386 47 | MONRDKEY := $8A1B 48 | MONCOUT := $8A47 49 | ACCESS := $8B86 50 | L8C78 := $8C78 51 | DUMPT := $8E87 52 | 53 | P3L := $A64A 54 | P3H := P3L+1 55 | P2L := $A64C 56 | P2H := P2L+1 57 | P1L := $A64E -------------------------------------------------------------------------------- /eater.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | INPUT_BUFFER: start = $0300, size = $0100, type = rw, file = ""; 4 | BASROM: start = $8000, size = $7E00, fill = yes, file = %O; 5 | WOZMON: start = $FE00, size = $1FA, fill = yes, file = %O; 6 | RESETVEC: start = $FFFA, size = 6, fill = yes, file = %O; 7 | DUMMY: start = $0000, size = $00FF, file = ""; 8 | } 9 | 10 | SEGMENTS { 11 | ZEROPAGE: load = ZP, type = zp; 12 | INPUT_BUFFER: load = INPUT_BUFFER, type = rw; 13 | HEADER: load = BASROM, type = ro; 14 | VECTORS: load = BASROM, type = ro; 15 | KEYWORDS: load = BASROM, type = ro; 16 | ERROR: load = BASROM, type = ro; 17 | CODE: load = BASROM, type = ro; 18 | CHRGET: load = BASROM, type = ro; 19 | INIT: load = BASROM, type = ro; 20 | EXTRA: load = BASROM, type = ro; 21 | DUMMY: load = DUMMY; # don't include 22 | 23 | BIOS: load = BASROM, type = ro; 24 | WOZMON: load = WOZMON, type = ro; 25 | RESETVEC: load = RESETVEC, type = ro; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /eater_iscntc.s: -------------------------------------------------------------------------------- 1 | ISCNTC: 2 | jsr MONRDKEY 3 | bcc not_cntc 4 | cmp #3 5 | bne not_cntc 6 | jmp is_cntc 7 | 8 | not_cntc: 9 | rts 10 | 11 | is_cntc: 12 | ; Fall through 13 | -------------------------------------------------------------------------------- /error.s: -------------------------------------------------------------------------------- 1 | init_error_table 2 | 3 | .ifdef CONFIG_SMALL_ERROR 4 | define_error ERR_NOFOR, "NF" 5 | define_error ERR_SYNTAX, "SN" 6 | define_error ERR_NOGOSUB, "RG" 7 | define_error ERR_NODATA, "OD" 8 | define_error ERR_ILLQTY, "FC" 9 | define_error ERR_OVERFLOW, "OV" 10 | define_error ERR_MEMFULL, "OM" 11 | define_error ERR_UNDEFSTAT, "US" 12 | define_error ERR_BADSUBS, "BS" 13 | define_error ERR_REDIMD, "DD" 14 | define_error ERR_ZERODIV, "/0" 15 | define_error ERR_ILLDIR, "ID" 16 | define_error ERR_BADTYPE, "TM" 17 | define_error ERR_STRLONG, "LS" 18 | define_error ERR_FRMCPX, "ST" 19 | define_error ERR_CANTCONT, "CN" 20 | define_error ERR_UNDEFFN, "UF" 21 | .else 22 | define_error ERR_NOFOR, "NEXT WITHOUT FOR" 23 | define_error ERR_SYNTAX, "SYNTAX" 24 | define_error ERR_NOGOSUB, "RETURN WITHOUT GOSUB" 25 | define_error ERR_NODATA, "OUT OF DATA" 26 | define_error ERR_ILLQTY, "ILLEGAL QUANTITY" 27 | .ifdef CBM1 28 | .byte 0,0,0,0,0 29 | .endif 30 | define_error ERR_OVERFLOW, "OVERFLOW" 31 | define_error ERR_MEMFULL, "OUT OF MEMORY" 32 | define_error ERR_UNDEFSTAT, "UNDEF'D STATEMENT" 33 | define_error ERR_BADSUBS, "BAD SUBSCRIPT" 34 | define_error ERR_REDIMD, "REDIM'D ARRAY" 35 | define_error ERR_ZERODIV, "DIVISION BY ZERO" 36 | define_error ERR_ILLDIR, "ILLEGAL DIRECT" 37 | define_error ERR_BADTYPE, "TYPE MISMATCH" 38 | define_error ERR_STRLONG, "STRING TOO LONG" 39 | .ifdef CONFIG_FILE 40 | .ifdef CBM1 41 | define_error ERR_BADDATA, "BAD DATA" 42 | .else 43 | define_error ERR_BADDATA, "FILE DATA" 44 | .endif 45 | .endif 46 | define_error ERR_FRMCPX, "FORMULA TOO COMPLEX" 47 | define_error ERR_CANTCONT, "CAN'T CONTINUE" 48 | define_error ERR_UNDEFFN, "UNDEF'D FUNCTION" 49 | .endif -------------------------------------------------------------------------------- /extra.s: -------------------------------------------------------------------------------- 1 | .segment "EXTRA" 2 | 3 | .ifdef KIM 4 | .include "kim_extra.s" 5 | .endif 6 | 7 | .ifdef CONFIG_CBM1_PATCHES 8 | .include "cbm1_patches.s" 9 | .endif 10 | 11 | .ifdef KBD 12 | .include "kbd_extra.s" 13 | .endif 14 | 15 | .ifdef APPLE 16 | .include "apple_extra.s" 17 | .endif 18 | 19 | .ifdef MICROTAN 20 | .include "microtan_extra.s" 21 | .endif 22 | 23 | .ifdef AIM65 24 | .include "aim65_extra.s" 25 | .endif 26 | 27 | .ifdef SYM1 28 | .byte 0,0,0 29 | .endif 30 | 31 | .ifdef EATER 32 | .include "bios.s" 33 | .endif 34 | -------------------------------------------------------------------------------- /flow1.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; "FOR" STATEMENT 5 | ; 6 | ; FOR PUSHES 18 BYTES ON THE STACK: 7 | ; 2 -- TXTPTR 8 | ; 2 -- LINE NUMBER 9 | ; 5 -- INITIAL (CURRENT) FOR VARIABLE VALUE 10 | ; 1 -- STEP SIGN 11 | ; 5 -- STEP VALUE 12 | ; 2 -- ADDRESS OF FOR VARIABLE IN VARTAB 13 | ; 1 -- FOR TOKEN ($81) 14 | ; ---------------------------------------------------------------------------- 15 | FOR: 16 | lda #$80 17 | sta SUBFLG 18 | jsr LET 19 | jsr GTFORPNT 20 | bne L2619 21 | txa 22 | adc #FOR_STACK1 23 | tax 24 | txs 25 | L2619: 26 | pla 27 | pla 28 | lda #FOR_STACK2 29 | jsr CHKMEM 30 | jsr DATAN 31 | clc 32 | tya 33 | adc TXTPTR 34 | pha 35 | lda TXTPTR+1 36 | adc #$00 37 | pha 38 | lda CURLIN+1 39 | pha 40 | lda CURLIN 41 | pha 42 | lda #TOKEN_TO 43 | jsr SYNCHR 44 | jsr CHKNUM 45 | jsr FRMNUM 46 | lda FACSIGN 47 | ora #$7F 48 | and FAC+1 49 | sta FAC+1 50 | lda #STEP 52 | sta INDEX 53 | sty INDEX+1 54 | jmp FRM_STACK3 55 | 56 | ; ---------------------------------------------------------------------------- 57 | ; "STEP" PHRASE OF "FOR" STATEMENT 58 | ; ---------------------------------------------------------------------------- 59 | STEP: 60 | lda #CON_ONE 62 | jsr LOAD_FAC_FROM_YA 63 | jsr CHRGOT 64 | cmp #TOKEN_STEP 65 | bne L2665 66 | jsr CHRGET 67 | jsr FRMNUM 68 | L2665: 69 | jsr SIGN 70 | jsr FRM_STACK2 71 | lda FORPNT+1 72 | pha 73 | lda FORPNT 74 | pha 75 | lda #$81 76 | pha 77 | 78 | ; ---------------------------------------------------------------------------- 79 | ; PERFORM NEXT STATEMENT 80 | ; ---------------------------------------------------------------------------- 81 | NEWSTT: 82 | jsr ISCNTC 83 | lda TXTPTR 84 | ldy TXTPTR+1 85 | .if .def(CONFIG_NO_INPUTBUFFER_ZP) && .def(CONFIG_2) 86 | cpy #>INPUTBUFFER 87 | .ifdef CBM2 88 | nop 89 | .endif 90 | beq LC6D4 91 | .else 92 | ; BUG on AppleSoft I, 93 | ; fixed differently on AppleSoft II (ldx/inx) 94 | beq L2683 95 | .endif 96 | sta OLDTEXT 97 | sty OLDTEXT+1 98 | LC6D4: 99 | ldy #$00 100 | L2683: 101 | lda (TXTPTR),y 102 | .ifndef CONFIG_11 103 | beq LA5DC ; old: 1 cycle more on generic case 104 | cmp #$3A 105 | beq NEWSTT2 106 | SYNERR1: 107 | jmp SYNERR 108 | LA5DC: 109 | .else 110 | bne COLON; new: 1 cycle more on ":" case 111 | .endif 112 | ldy #$02 113 | lda (TXTPTR),y 114 | clc 115 | .ifdef CONFIG_2 116 | jeq L2701 117 | .else 118 | beq L2701 119 | .endif 120 | iny 121 | lda (TXTPTR),y 122 | sta CURLIN 123 | iny 124 | lda (TXTPTR),y 125 | sta CURLIN+1 126 | tya 127 | adc TXTPTR 128 | sta TXTPTR 129 | bcc NEWSTT2 130 | inc TXTPTR+1 131 | NEWSTT2: 132 | jsr CHRGET 133 | jsr EXECUTE_STATEMENT 134 | jmp NEWSTT 135 | 136 | ; ---------------------------------------------------------------------------- 137 | ; EXECUTE A STATEMENT 138 | ; 139 | ; (A) IS FIRST CHAR OF STATEMENT 140 | ; CARRY IS SET 141 | ; ---------------------------------------------------------------------------- 142 | EXECUTE_STATEMENT: 143 | .ifndef CONFIG_11A 144 | beq RET1 145 | .else 146 | beq RET2 147 | .endif 148 | .ifndef CONFIG_11 149 | sec 150 | .endif 151 | EXECUTE_STATEMENT1: 152 | sbc #$80 153 | .ifndef CONFIG_11 154 | jcc LET ; old: 1 cycle more on instr. 155 | .else 156 | bcc LET1; new: 1 cycle more on assignment 157 | .endif 158 | cmp #NUM_TOKENS 159 | .ifdef CONFIG_2 160 | bcs LC721 161 | .else 162 | bcs SYNERR1 163 | .endif 164 | asl a 165 | tay 166 | lda TOKEN_ADDRESS_TABLE+1,y 167 | pha 168 | lda TOKEN_ADDRESS_TABLE,y 169 | pha 170 | jmp CHRGET 171 | 172 | .ifdef CONFIG_11 173 | LET1: 174 | jmp LET 175 | 176 | COLON: 177 | cmp #$3A 178 | beq NEWSTT2 179 | SYNERR1: 180 | jmp SYNERR 181 | .endif 182 | 183 | .ifdef CONFIG_2; GO TO 184 | LC721: 185 | cmp #TOKEN_GO-$80 186 | bne SYNERR1 187 | jsr CHRGET 188 | lda #TOKEN_TO 189 | jsr SYNCHR 190 | jmp GOTO 191 | .endif 192 | 193 | ; ---------------------------------------------------------------------------- 194 | ; "RESTORE" STATEMENT 195 | ; ---------------------------------------------------------------------------- 196 | RESTORE: 197 | sec 198 | lda TXTTAB 199 | sbc #$01 200 | ldy TXTTAB+1 201 | bcs SETDA 202 | dey 203 | SETDA: 204 | sta DATPTR 205 | sty DATPTR+1 206 | RET2: 207 | rts 208 | 209 | .include "iscntc.s" 210 | ;!!! runs into "STOP" 211 | ; ---------------------------------------------------------------------------- 212 | ; "STOP" STATEMENT 213 | ; ---------------------------------------------------------------------------- 214 | STOP: 215 | bcs END2 216 | 217 | ; ---------------------------------------------------------------------------- 218 | ; "END" STATEMENT 219 | ; ---------------------------------------------------------------------------- 220 | END: 221 | clc 222 | END2: 223 | bne RET1 224 | lda TXTPTR 225 | ldy TXTPTR+1 226 | .if .def(CONFIG_NO_INPUTBUFFER_ZP) && .def(CONFIG_2) 227 | ; BUG on AppleSoft I 228 | ; fix exists on AppleSoft II 229 | ; TXTPTR+1 will always be > 0 230 | ldx CURLIN+1 231 | inx 232 | .endif 233 | beq END4 234 | sta OLDTEXT 235 | sty OLDTEXT+1 236 | CONTROL_C_TYPED: 237 | lda CURLIN 238 | ldy CURLIN+1 239 | sta OLDLIN 240 | sty OLDLIN+1 241 | END4: 242 | pla 243 | pla 244 | L2701: 245 | lda #QT_BREAK 247 | .ifndef KBD 248 | ldx #$00 249 | stx Z14 250 | .endif 251 | bcc L270E 252 | jmp PRINT_ERROR_LINNUM 253 | L270E: 254 | jmp RESTART 255 | .ifdef KBD 256 | LE664: 257 | tay 258 | jmp SNGFLT 259 | .endif 260 | 261 | ; ---------------------------------------------------------------------------- 262 | ; "CONT" COMMAND 263 | ; ---------------------------------------------------------------------------- 264 | CONT: 265 | bne RET1 266 | ldx #ERR_CANTCONT 267 | ldy OLDTEXT+1 268 | bne L271C 269 | jmp ERROR 270 | L271C: 271 | lda OLDTEXT 272 | sta TXTPTR 273 | sty TXTPTR+1 274 | lda OLDLIN 275 | ldy OLDLIN+1 276 | sta CURLIN 277 | sty CURLIN+1 278 | RET1: 279 | rts 280 | 281 | .ifdef KBD 282 | PRT: 283 | jsr GETBYT 284 | txa 285 | ; not ROR bug safe 286 | ror a 287 | ror a 288 | ror a 289 | sta $8F 290 | rts 291 | 292 | LE68C: 293 | ldy #$12 294 | LE68E: 295 | lda LEA30,y 296 | sta $03A2,y 297 | dey 298 | bpl LE68E 299 | rts 300 | .endif 301 | 302 | .ifndef AIM65 303 | .if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS) 304 | ; CBM1 has the keyword removed, 305 | ; but the code is still here 306 | NULL: 307 | jsr GETBYT 308 | bne RET1 309 | inx 310 | cpx #NULL_MAX 311 | bcs L2739 312 | dex 313 | stx Z15 314 | L2738: 315 | rts 316 | L2739: 317 | jmp IQERR 318 | .endif 319 | .ifndef CONFIG_11A 320 | CLEAR: 321 | bne RET1 322 | jmp CLEARC 323 | .endif 324 | .endif 325 | -------------------------------------------------------------------------------- /flow2.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ; ---------------------------------------------------------------------------- 3 | ; "RUN" COMMAND 4 | ; ---------------------------------------------------------------------------- 5 | RUN: 6 | bne L27CF 7 | jmp SETPTRS 8 | L27CF: 9 | jsr CLEARC 10 | jmp L27E9 11 | 12 | ; ---------------------------------------------------------------------------- 13 | ; "GOSUB" STATEMENT 14 | ; 15 | ; LEAVES 7 BYTES ON STACK: 16 | ; 2 -- RETURN ADDRESS (NEWSTT) 17 | ; 2 -- TXTPTR 18 | ; 2 -- LINE # 19 | ; 1 -- GOSUB TOKEN 20 | ; ---------------------------------------------------------------------------- 21 | GOSUB: 22 | lda #$03 23 | jsr CHKMEM 24 | lda TXTPTR+1 25 | pha 26 | lda TXTPTR 27 | pha 28 | lda CURLIN+1 29 | pha 30 | lda CURLIN 31 | pha 32 | lda #TOKEN_GOSUB 33 | pha 34 | L27E9: 35 | jsr CHRGOT 36 | jsr GOTO 37 | jmp NEWSTT 38 | 39 | ; ---------------------------------------------------------------------------- 40 | ; "GOTO" STATEMENT 41 | ; ALSO USED BY "RUN" AND "GOSUB" 42 | ; ---------------------------------------------------------------------------- 43 | GOTO: 44 | jsr LINGET 45 | jsr REMN 46 | lda CURLIN+1 47 | cmp LINNUM+1 48 | bcs L2809 49 | tya 50 | sec 51 | adc TXTPTR 52 | ldx TXTPTR+1 53 | bcc L280D 54 | inx 55 | bcs L280D 56 | L2809: 57 | lda TXTTAB 58 | ldx TXTTAB+1 59 | L280D: 60 | .ifdef KBD 61 | jsr LF457 62 | bne UNDERR 63 | .else 64 | jsr FL1 65 | bcc UNDERR 66 | .endif 67 | lda LOWTRX 68 | sbc #$01 69 | sta TXTPTR 70 | lda LOWTRX+1 71 | sbc #$00 72 | sta TXTPTR+1 73 | L281E: 74 | rts 75 | 76 | ; ---------------------------------------------------------------------------- 77 | ; "POP" AND "RETURN" STATEMENTS 78 | ; ---------------------------------------------------------------------------- 79 | POP: 80 | bne L281E 81 | lda #$FF 82 | .ifdef CONFIG_2A 83 | sta FORPNT+1 ; bugfix, wrong in AppleSoft II 84 | .else 85 | sta FORPNT 86 | .endif 87 | jsr GTFORPNT 88 | txs 89 | cmp #TOKEN_GOSUB 90 | beq RETURN 91 | ldx #ERR_NOGOSUB 92 | .byte $2C 93 | UNDERR: 94 | ldx #ERR_UNDEFSTAT 95 | jmp ERROR 96 | ; ---------------------------------------------------------------------------- 97 | SYNERR2: 98 | jmp SYNERR 99 | ; ---------------------------------------------------------------------------- 100 | RETURN: 101 | pla 102 | pla 103 | sta CURLIN 104 | pla 105 | sta CURLIN+1 106 | pla 107 | sta TXTPTR 108 | pla 109 | sta TXTPTR+1 110 | 111 | ; ---------------------------------------------------------------------------- 112 | ; "DATA" STATEMENT 113 | ; EXECUTED BY SKIPPING TO NEXT COLON OR EOL 114 | ; ---------------------------------------------------------------------------- 115 | DATA: 116 | jsr DATAN 117 | 118 | ; ---------------------------------------------------------------------------- 119 | ; ADD (Y) TO TXTPTR 120 | ; ---------------------------------------------------------------------------- 121 | ADDON: 122 | tya 123 | clc 124 | adc TXTPTR 125 | sta TXTPTR 126 | bcc L2852 127 | inc TXTPTR+1 128 | L2852: 129 | rts 130 | 131 | ; ---------------------------------------------------------------------------- 132 | ; SCAN AHEAD TO NEXT ":" OR EOL 133 | ; ---------------------------------------------------------------------------- 134 | DATAN: 135 | ldx #$3A 136 | .byte $2C 137 | REMN: 138 | ldx #$00 139 | stx CHARAC 140 | ldy #$00 141 | sty ENDCHR 142 | L285E: 143 | lda ENDCHR 144 | ldx CHARAC 145 | sta CHARAC 146 | stx ENDCHR 147 | L2866: 148 | lda (TXTPTR),y 149 | beq L2852 150 | cmp ENDCHR 151 | beq L2852 152 | iny 153 | cmp #$22 154 | .ifndef CONFIG_11 155 | beq L285E; old: swap & cont is faster 156 | bne L2866 157 | .else 158 | bne L2866; new: cont is faster 159 | beq L285E 160 | .endif 161 | 162 | ; ---------------------------------------------------------------------------- 163 | ; "IF" STATEMENT 164 | ; ---------------------------------------------------------------------------- 165 | IF: 166 | jsr FRMEVL 167 | jsr CHRGOT 168 | cmp #TOKEN_GOTO 169 | beq L2884 170 | lda #TOKEN_THEN 171 | jsr SYNCHR 172 | L2884: 173 | lda FAC 174 | bne L288D 175 | 176 | ; ---------------------------------------------------------------------------- 177 | ; "REM" STATEMENT, OR FALSE "IF" STATEMENT 178 | ; ---------------------------------------------------------------------------- 179 | REM: 180 | jsr REMN 181 | beq ADDON 182 | L288D: 183 | jsr CHRGOT 184 | bcs L2895 185 | jmp GOTO 186 | L2895: 187 | jmp EXECUTE_STATEMENT 188 | 189 | ; ---------------------------------------------------------------------------- 190 | ; "ON" STATEMENT 191 | ; 192 | ; ON GOTO 193 | ; ON GOSUB 194 | ; ---------------------------------------------------------------------------- 195 | ON: 196 | jsr GETBYT 197 | pha 198 | cmp #TOKEN_GOSUB 199 | beq L28A4 200 | L28A0: 201 | cmp #TOKEN_GOTO 202 | bne SYNERR2 203 | L28A4: 204 | dec FAC_LAST 205 | bne L28AC 206 | pla 207 | jmp EXECUTE_STATEMENT1 208 | L28AC: 209 | jsr CHRGET 210 | jsr LINGET 211 | cmp #$2C 212 | beq L28A4 213 | pla 214 | L28B7: 215 | rts 216 | -------------------------------------------------------------------------------- /header.s: -------------------------------------------------------------------------------- 1 | .segment "HEADER" 2 | .ifdef KBD 3 | jmp LE68C 4 | .byte $00,$13,$56 5 | .endif 6 | .ifdef AIM65 7 | jmp COLD_START 8 | jmp RESTART 9 | .word AYINT,GIVAYF 10 | .endif 11 | .ifdef SYM1 12 | jmp PR_WRITTEN_BY 13 | .endif 14 | .ifdef EATER 15 | jmp COLD_START 16 | .endif 17 | -------------------------------------------------------------------------------- /init.s: -------------------------------------------------------------------------------- 1 | .segment "INIT" 2 | 3 | .ifdef KBD 4 | FNDLIN2: 5 | php 6 | jmp FNDLIN 7 | .endif 8 | 9 | ; ---------------------------------------------------------------------------- 10 | PR_WRITTEN_BY: 11 | .ifndef KBD 12 | .ifndef CONFIG_CBM_ALL 13 | .ifndef AIM65 14 | .ifndef SYM1 15 | lda #QT_WRITTEN_BY 17 | jsr STROUT 18 | .endif 19 | .endif 20 | .endif 21 | .endif 22 | COLD_START: 23 | .ifdef SYM1 24 | jsr ACCESS 25 | .endif 26 | .ifdef KBD 27 | lda #LFD81 30 | sta $03A1 31 | lda #$20 32 | sta $0480 33 | lda $0352 34 | sta $04 35 | lda $0353 36 | sta $05 37 | .else 38 | .ifndef CBM2 39 | ldx #$FF 40 | stx CURLIN+1 41 | .endif 42 | .ifdef CONFIG_NO_INPUTBUFFER_ZP 43 | ldx #$FB 44 | .elseif .def(AIM65) 45 | ldx #$FE 46 | .endif 47 | txs 48 | .ifndef CONFIG_CBM_ALL 49 | lda #COLD_START 51 | sta GORESTART+1 52 | sty GORESTART+2 53 | .ifndef AIM65 54 | sta GOSTROUT+1 55 | sty GOSTROUT+2 56 | lda #AYINT 58 | sta GOAYINT 59 | sty GOAYINT+1 60 | lda #GIVAYF 62 | sta GOGIVEAYF 63 | sty GOGIVEAYF+1 64 | .endif 65 | .endif 66 | lda #$4C 67 | .ifdef CONFIG_CBM_ALL 68 | sta JMPADRS 69 | .endif 70 | sta GORESTART 71 | .ifdef AIM65 72 | sta JMPADRS 73 | sta ATN 74 | sta GOSTROUT 75 | .else 76 | .ifndef CONFIG_CBM_ALL 77 | sta GOSTROUT 78 | sta JMPADRS 79 | .endif 80 | .ifdef SYM1 81 | sta USR1 82 | sta USR3 83 | sta USR2 84 | .endif 85 | .if (!.def(CONFIG_RAM)) && (!.def(CONFIG_CBM_ALL)) 86 | sta USR 87 | .endif 88 | .endif 89 | 90 | .ifndef CONFIG_RAM 91 | .ifdef APPLE 92 | lda #USR_FUNC 94 | .else 95 | lda #IQERR 97 | .endif 98 | .ifdef AIM65 99 | sta ATN+1 100 | sty ATN+2 101 | sta GOSTROUT+1 102 | sty GOSTROUT+2 103 | .else 104 | sta USR+1 105 | sty USR+2 106 | .ifdef SYM1 107 | sta USR1+1 108 | sty USR1+2 109 | lda #DUMPT 111 | sta USR2+1 112 | sty USR2+2 113 | lda #L8C78 115 | sta USR3+1 116 | sty USR3+2 117 | .endif 118 | .endif 119 | .endif 120 | .ifndef CBM1 121 | lda #WIDTH 122 | sta Z17 123 | lda #WIDTH2 124 | sta Z18 125 | .endif 126 | .ifdef EATER 127 | jsr LCDINIT 128 | .endif 129 | .endif 130 | 131 | ; All non-CONFIG_SMALL versions of BASIC have 132 | ; the same bug here: While the number of bytes 133 | ; to be copied is correct for CONFIG_SMALL, 134 | ; it is one byte short on non-CONFIG_SMALL: 135 | ; It seems the "ldx" value below has been 136 | ; hardcoded. So on these configurations, 137 | ; the last byte of GENERIC_RNDSEED, which 138 | ; is 5 bytes instead of 4, does not get copied - 139 | ; which is nothing major, because it is just 140 | ; the least significant 8 bits of the mantissa 141 | ; of the random number seed. 142 | ; KBD added three bytes to CHRGET and removed 143 | ; the random number seed, but only adjusted 144 | ; the number of bytes by adding 3 - this 145 | ; copies four bytes too many, which is no 146 | ; problem. 147 | .ifdef CONFIG_SMALL 148 | .ifdef KBD 149 | ldx #GENERIC_CHRGET_END-GENERIC_CHRGET+4 150 | .else 151 | ldx #GENERIC_CHRGET_END-GENERIC_CHRGET 152 | .endif 153 | .else 154 | ldx #GENERIC_CHRGET_END-GENERIC_CHRGET-1 ; XXX 155 | .endif 156 | L4098: 157 | lda GENERIC_CHRGET-1,x 158 | sta CHRGET-1,x 159 | dex 160 | bne L4098 161 | .ifdef CONFIG_2 162 | lda #$03 163 | sta DSCLEN 164 | .endif 165 | .ifndef KBD 166 | txa 167 | sta SHIFTSIGNEXT 168 | .ifdef CONFIG_CBM_ALL 169 | sta CURDVC 170 | .endif 171 | sta LASTPT+1 172 | .ifndef AIM65 173 | .if .defined(CONFIG_NULL) || .defined(CONFIG_PRINTNULLS) 174 | sta Z15 175 | .endif 176 | .endif 177 | .ifndef CONFIG_11 178 | sta POSX 179 | .endif 180 | pha 181 | sta Z14 182 | .ifndef CBM2 183 | .ifndef AIM65 184 | .ifndef SYM1 185 | .ifndef MICROTAN 186 | lda #$03 187 | sta DSCLEN 188 | .endif 189 | .endif 190 | .endif 191 | .ifndef CONFIG_11 192 | lda #$2C 193 | sta LINNUM+1 194 | .endif 195 | jsr CRDO 196 | .endif 197 | .ifdef CBM2 198 | inx 199 | stx INPUTBUFFER-3 200 | stx INPUTBUFFER-4 201 | .endif 202 | .ifdef APPLE 203 | lda #$01 204 | sta INPUTBUFFER-3 205 | sta INPUTBUFFER-4 206 | .endif 207 | ldx #TEMPST 208 | stx TEMPPT 209 | .ifndef CONFIG_CBM_ALL 210 | lda #QT_MEMORY_SIZE 212 | jsr STROUT 213 | .ifdef APPLE 214 | jsr INLINX 215 | .else 216 | jsr NXIN 217 | .endif 218 | stx TXTPTR 219 | sty TXTPTR+1 220 | jsr CHRGET 221 | .ifndef AIM65 222 | .ifndef SYM1 223 | cmp #$41 224 | beq PR_WRITTEN_BY 225 | .endif 226 | .endif 227 | tay 228 | bne L40EE 229 | .endif 230 | .ifndef CBM2 231 | lda #RAMSTART2 234 | .ifdef CONFIG_2 235 | sta TXTTAB 236 | sty TXTTAB+1 237 | .endif 238 | sta LINNUM 239 | sty LINNUM+1 240 | .ifdef CBM2 241 | tay 242 | .else 243 | ldy #$00 244 | .endif 245 | L40D7: 246 | inc LINNUM 247 | bne L40DD 248 | inc LINNUM+1 249 | .ifdef CBM1 250 | ; CBM: hard RAM top limit is $8000 251 | lda LINNUM+1 252 | cmp #$80 253 | beq L40FA 254 | .endif 255 | .ifdef CBM2 256 | ; optimized version of the CBM1 code 257 | bmi L40FA 258 | .endif 259 | .if .def(AIM65) 260 | ; AIM65: hard RAM top limit is $A000 261 | lda LINNUM+1 262 | cmp #$A0 263 | beq L40FA 264 | .endif 265 | L40DD: 266 | .ifdef CONFIG_2 267 | lda #$55 ; 01010101 / 10101010 268 | .else 269 | lda #$92 ; 10010010 / 00100100 270 | .endif 271 | sta (LINNUM),y 272 | cmp (LINNUM),y 273 | bne L40FA 274 | asl a 275 | sta (LINNUM),y 276 | cmp (LINNUM),y 277 | .ifdef CONFIG_CBM_ALL 278 | beq L40D7 279 | .else 280 | .ifndef CONFIG_11 281 | beq L40D7; old: faster 282 | bne L40FA 283 | .else 284 | bne L40FA; new: slower 285 | beq L40D7 286 | .endif 287 | L40EE: 288 | jsr CHRGOT 289 | jsr LINGET 290 | tay 291 | beq L40FA 292 | jmp SYNERR 293 | .endif 294 | L40FA: 295 | lda LINNUM 296 | ldy LINNUM+1 297 | sta MEMSIZ 298 | sty MEMSIZ+1 299 | .if !(.def(MICROTAN) || .def(AIM65) || .def(SYM1)) 300 | sta FRETOP 301 | sty FRETOP+1 302 | .endif 303 | L4106: 304 | .ifndef CONFIG_CBM_ALL 305 | .ifdef APPLE 306 | lda #$FF 307 | jmp L2829 308 | .word STROUT ; PATCH! 309 | jsr NXIN 310 | .else 311 | lda #QT_TERMINAL_WIDTH 313 | jsr STROUT 314 | jsr NXIN 315 | .endif 316 | stx TXTPTR 317 | sty TXTPTR+1 318 | jsr CHRGET 319 | tay 320 | beq L4136 321 | jsr LINGET 322 | lda LINNUM+1 323 | bne L4106 324 | lda LINNUM 325 | cmp #$10 326 | bcc L4106 327 | L2829: 328 | sta Z17 329 | L4129: 330 | .ifdef AIM65 331 | sbc #$0A 332 | .else 333 | sbc #$0E 334 | .endif 335 | bcs L4129 336 | eor #$FF 337 | .ifdef AIM65 338 | sbc #$08 339 | .else 340 | sbc #$0C 341 | .endif 342 | clc 343 | adc Z17 344 | sta Z18 345 | .endif 346 | L4136: 347 | .ifdef CONFIG_RAM 348 | lda #QT_WANT 350 | jsr STROUT 351 | jsr NXIN 352 | stx TXTPTR 353 | sty TXTPTR+1 354 | jsr CHRGET 355 | ldx #RAMSTART1 357 | cmp #'Y' 358 | beq L4183 359 | cmp #'A' 360 | beq L4157 361 | cmp #'N' 362 | bne L4136 363 | L4157: 364 | ldx #IQERR 366 | stx UNFNC_ATN 367 | sty UNFNC_ATN+1 368 | ldx #ATN ; with ATN 370 | cmp #'A' 371 | beq L4183 372 | ldx #IQERR 374 | stx UNFNC_COS 375 | sty UNFNC_COS+1 376 | stx UNFNC_TAN 377 | sty UNFNC_TAN+1 378 | stx UNFNC_SIN 379 | sty UNFNC_SIN+1 380 | ldx #SIN_COS_TAN_ATN ; all of trig.s 382 | L4183: 383 | .else 384 | ldx #RAMSTART2 386 | .endif 387 | stx TXTTAB 388 | sty TXTTAB+1 389 | ldy #$00 390 | tya 391 | sta (TXTTAB),y 392 | inc TXTTAB 393 | .ifndef CBM2 394 | bne L4192 395 | inc TXTTAB+1 396 | L4192: 397 | .endif 398 | .if CONFIG_SCRTCH_ORDER = 1 399 | jsr SCRTCH 400 | .endif 401 | lda TXTTAB 402 | ldy TXTTAB+1 403 | jsr REASON 404 | .ifdef CBM2 405 | lda #QT_BASIC 407 | jsr STROUT 408 | .else 409 | jsr CRDO 410 | .endif 411 | lda MEMSIZ 412 | sec 413 | sbc TXTTAB 414 | tax 415 | lda MEMSIZ+1 416 | sbc TXTTAB+1 417 | jsr LINPRT 418 | lda #QT_BYTES_FREE 420 | jsr STROUT 421 | .if CONFIG_SCRTCH_ORDER = 2 422 | jsr SCRTCH 423 | .endif 424 | .ifdef CONFIG_CBM_ALL 425 | jmp RESTART 426 | .elseif .def(AIM65) 427 | lda #CRDO 429 | sta GORESTART+1 430 | sty GORESTART+2 431 | jmp RESTART 432 | .else 433 | lda #STROUT 435 | sta GOSTROUT+1 436 | sty GOSTROUT+2 437 | .if CONFIG_SCRTCH_ORDER = 3 438 | jsr SCRTCH 439 | .endif 440 | lda #RESTART 442 | sta GORESTART+1 443 | sty GORESTART+2 444 | jmp (GORESTART+1) 445 | .endif 446 | 447 | .if .def(CONFIG_RAM) || .def(OSI) 448 | ; OSI is compiled for ROM, but includes 449 | ; this unused string 450 | QT_WANT: 451 | .byte "WANT SIN-COS-TAN-ATN" 452 | .byte 0 453 | .endif 454 | QT_WRITTEN_BY: 455 | .ifndef CONFIG_CBM_ALL 456 | .if !(.def(AIM65) || .def(SYM1)) 457 | .ifdef APPLE 458 | asc80 "COPYRIGHT 1977 BY MICROSOFT CO" 459 | .byte CR,0 460 | .else 461 | .byte CR,LF,$0C ; FORM FEED 462 | .ifndef CONFIG_11 463 | .byte "WRITTEN BY RICHARD W. WEILAND." 464 | .else 465 | .byte "WRITTEN BY WEILAND & GATES" 466 | .endif 467 | .byte CR,LF,0 468 | .endif 469 | .endif 470 | QT_MEMORY_SIZE: 471 | .byte "MEMORY SIZE" 472 | .byte 0 473 | QT_TERMINAL_WIDTH: 474 | .if !(.def(AIM65) || .def(SYM1)) 475 | .byte "TERMINAL " 476 | .endif 477 | .byte "WIDTH" 478 | .byte 0 479 | .endif 480 | QT_BYTES_FREE: 481 | .byte " BYTES FREE" 482 | .ifdef CBM1 483 | .elseif .def(CBM2) 484 | .byte CR,0 485 | .elseif .def(APPLE) 486 | .byte 0 487 | .else 488 | .byte CR,LF,CR,LF 489 | .endif 490 | QT_BASIC: 491 | .ifdef OSI 492 | .byte "OSI 6502 BASIC VERSION 1.0 REV 3.2" 493 | .endif 494 | .ifdef KIM 495 | .byte "MOS TECH 6502 BASIC V1.1" 496 | .endif 497 | .ifdef MICROTAN 498 | .byte "MICROTAN BASIC" 499 | .endif 500 | .ifdef AIM65 501 | .byte " AIM 65 BASIC V1.1" 502 | .endif 503 | .ifdef SYM1 504 | .byte "BASIC V1.1" 505 | .endif 506 | .ifdef CBM1 507 | .byte $13 ; HOME 508 | .byte "*** COMMODORE BASIC ***" 509 | .byte $11,$11,$11,0 ; DOWN/DOWN/DOWN 510 | .endif 511 | .ifdef CBM2 512 | .byte "### COMMODORE BASIC ###" 513 | .byte CR,CR,0 514 | .endif 515 | .ifdef APPLE 516 | .byte LF,CR,LF 517 | .byte "APPLE BASIC V1.1" 518 | .endif 519 | .ifndef CONFIG_CBM_ALL 520 | .byte CR,LF 521 | .ifdef MICROTAN 522 | .byte "(C) 1980 MICROSOFT" 523 | .elseif .def(AIM65) 524 | .byte 0 525 | .byte "(C) 1978 MICROSOFT" 526 | .elseif .def(SYM1) 527 | .byte "COPYRIGHT 1978 SYNERTEK SYSTEMS CORP." 528 | .else 529 | .byte "COPYRIGHT 1977 BY MICROSOFT CO." 530 | .endif 531 | .byte CR,LF 532 | .ifndef AIM65 533 | .byte 0 534 | .endif 535 | .endif 536 | .endif 537 | -------------------------------------------------------------------------------- /inline.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | .ifndef CONFIG_NO_INPUTBUFFER_ZP 4 | L2420: 5 | .ifdef OSI 6 | jsr OUTDO 7 | .endif 8 | dex 9 | .ifdef AIM65 10 | bmi L2423 11 | jsr PSLS 12 | jmp INLIN2 13 | LB35F: 14 | jsr OUTDO 15 | .else 16 | bpl INLIN2 17 | .endif 18 | L2423: 19 | .ifdef OSI 20 | jsr OUTDO 21 | .endif 22 | jsr CRDO 23 | .endif 24 | 25 | ; ---------------------------------------------------------------------------- 26 | ; READ A LINE, AND STRIP OFF SIGN BITS 27 | ; ---------------------------------------------------------------------------- 28 | .ifndef KBD 29 | INLIN: 30 | .ifdef APPLE 31 | ldx #$DD 32 | INLIN1: 33 | stx $33 34 | jsr L2900 35 | cpx #$EF 36 | bcs L0C32 37 | ldx #$EF 38 | L0C32: 39 | lda #$00 40 | sta INPUTBUFFER,x 41 | ldx #INPUTBUFFER-1 43 | rts 44 | .endif 45 | 46 | .ifndef APPLE 47 | ldx #$00 48 | INLIN2: 49 | jsr GETLN 50 | .ifdef AIM65 51 | cmp #$1A 52 | bne INLINAIM 53 | jsr DU13 54 | jmp INLIN 55 | INLINAIM: 56 | .endif 57 | .ifndef CONFIG_NO_LINE_EDITING 58 | cmp #$07 59 | beq L2443 60 | .endif 61 | cmp #$0D 62 | beq L2453 63 | .ifndef CONFIG_NO_LINE_EDITING 64 | cmp #$20 65 | .ifdef AIM65 66 | bcc L244E 67 | .else 68 | bcc INLIN2 69 | .endif 70 | .ifdef MICROTAN 71 | cmp #$80 72 | .else 73 | .ifdef AIM65 74 | cmp #$7F 75 | beq L2420 76 | .endif 77 | cmp #$7D 78 | .endif 79 | bcs INLIN2 80 | cmp #$40 ; @ 81 | .ifdef AIM65 82 | beq LB35F 83 | .else 84 | beq L2423 85 | .ifdef MICROTAN 86 | cmp #$7F ; DEL 87 | .else 88 | cmp #$5F ; _ 89 | .endif 90 | beq L2420 91 | .endif 92 | L2443: 93 | .ifdef MICROTAN 94 | cpx #$4F 95 | .else 96 | cpx #$47 97 | .endif 98 | bcs L244C 99 | .endif 100 | sta INPUTBUFFER,x 101 | inx 102 | .if .def(OSI) || .def(AIM65) 103 | .byte $2C 104 | .else 105 | bne INLIN2 106 | .endif 107 | L244C: 108 | .ifndef CONFIG_NO_LINE_EDITING 109 | lda #$07 ; BEL 110 | L244E: 111 | jsr OUTDO 112 | bne INLIN2 113 | .endif 114 | L2453: 115 | jmp L29B9 116 | .endif 117 | .endif 118 | 119 | .ifndef KBD 120 | .ifndef APPLE 121 | GETLN: 122 | .ifdef CONFIG_FILE 123 | jsr CHRIN 124 | ldy CURDVC 125 | bne L2465 126 | .else 127 | jsr MONRDKEY 128 | .endif 129 | .ifdef OSI 130 | nop 131 | nop 132 | nop 133 | nop 134 | nop 135 | nop 136 | nop 137 | nop 138 | nop 139 | nop 140 | nop 141 | nop 142 | nop 143 | nop 144 | and #$7F 145 | .endif 146 | .endif 147 | .ifdef APPLE 148 | RDKEY: 149 | jsr LFD0C 150 | and #$7F 151 | .endif 152 | .ifdef SYM1 153 | cmp #$14 154 | .else 155 | cmp #$0F 156 | .endif 157 | bne L2465 158 | pha 159 | lda Z14 160 | eor #$FF 161 | sta Z14 162 | pla 163 | L2465: 164 | rts 165 | .endif 166 | -------------------------------------------------------------------------------- /input.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; INPUT CONVERSION ERROR: ILLEGAL CHARACTER 5 | ; IN NUMERIC FIELD. MUST DISTINGUISH 6 | ; BETWEEN INPUT, READ, AND GET 7 | ; ---------------------------------------------------------------------------- 8 | INPUTERR: 9 | lda INPUTFLG 10 | beq RESPERR ; INPUT 11 | .ifndef SYM1 12 | .ifndef CONFIG_SMALL 13 | .ifdef CONFIG_10A 14 | ; without this, it treats GET errors 15 | ; like READ errors 16 | bmi L2A63 ; READ 17 | ldy #$FF ; GET 18 | bne L2A67 19 | L2A63: 20 | .endif 21 | .endif 22 | .endif 23 | .ifdef CONFIG_CBM1_PATCHES 24 | jsr PATCH5 25 | nop 26 | .else 27 | lda Z8C 28 | ldy Z8C+1 29 | .endif 30 | L2A67: 31 | sta CURLIN 32 | sty CURLIN+1 33 | SYNERR4: 34 | jmp SYNERR 35 | RESPERR: 36 | .ifdef CONFIG_FILE 37 | lda CURDVC 38 | beq LCA8F 39 | ldx #ERR_BADDATA 40 | jmp ERROR 41 | LCA8F: 42 | .endif 43 | lda #ERRREENTRY 45 | jsr STROUT 46 | lda OLDTEXT 47 | ldy OLDTEXT+1 48 | sta TXTPTR 49 | sty TXTPTR+1 50 | RTS20: 51 | rts 52 | 53 | ; ---------------------------------------------------------------------------- 54 | ; "GET" STATEMENT 55 | ; ---------------------------------------------------------------------------- 56 | .ifndef CONFIG_SMALL 57 | .ifndef SYM1 58 | GET: 59 | jsr ERRDIR 60 | ; CBM: if GET#, then switch input 61 | .ifdef CONFIG_FILE 62 | cmp #'#' 63 | bne LCAB6 64 | jsr CHRGET 65 | jsr GETBYT 66 | lda #',' 67 | jsr SYNCHR 68 | jsr CHKIN 69 | stx CURDVC 70 | LCAB6: 71 | .endif 72 | ldx #<(INPUTBUFFER+1) 73 | ldy #>(INPUTBUFFER+1) 74 | .ifdef CONFIG_NO_INPUTBUFFER_ZP 75 | lda #$00 76 | sta INPUTBUFFER+1 77 | .else 78 | sty INPUTBUFFER+1 79 | .endif 80 | lda #$40 81 | jsr PROCESS_INPUT_LIST 82 | ; CBM: if GET#, then switch input back 83 | .ifdef CONFIG_FILE 84 | ldx CURDVC 85 | bne LCAD8 86 | .endif 87 | rts 88 | .endif 89 | .endif 90 | 91 | ; ---------------------------------------------------------------------------- 92 | ; "INPUT#" STATEMENT 93 | ; ---------------------------------------------------------------------------- 94 | .ifdef CONFIG_FILE 95 | INPUTH: 96 | jsr GETBYT 97 | lda #$2C 98 | jsr SYNCHR 99 | jsr CHKIN 100 | stx CURDVC 101 | jsr L2A9E 102 | LCAD6: 103 | lda CURDVC 104 | LCAD8: 105 | jsr CLRCH 106 | ldx #$00 107 | stx CURDVC 108 | rts 109 | LCAE0: 110 | .endif 111 | 112 | .ifdef SYM1 113 | LC9B0: 114 | jsr OUTQUES ; '?' 115 | jsr OUTSP 116 | jmp L2A9E 117 | .endif 118 | ; ---------------------------------------------------------------------------- 119 | ; "INPUT" STATEMENT 120 | ; ---------------------------------------------------------------------------- 121 | INPUT: 122 | .ifndef KBD 123 | lsr Z14 124 | .endif 125 | .ifdef AIM65 126 | lda PRIFLG 127 | sta ZBE 128 | jsr LCFFA 129 | .endif 130 | cmp #$22 131 | .ifdef SYM1 132 | bne LC9B0 133 | .else 134 | bne L2A9E 135 | .endif 136 | jsr STRTXT 137 | lda #$3B 138 | jsr SYNCHR 139 | jsr STRPRT 140 | L2A9E: 141 | jsr ERRDIR 142 | lda #$2C 143 | sta INPUTBUFFER-1 144 | LCAF8: 145 | .ifdef APPLE 146 | jsr INLINX 147 | .elseif .def(SYM1) 148 | jsr INLIN 149 | .else 150 | jsr NXIN 151 | .endif 152 | .ifdef KBD 153 | bmi L2ABE 154 | .else 155 | .ifdef CONFIG_FILE 156 | lda CURDVC 157 | beq LCB0C 158 | lda Z96 159 | and #$02 160 | beq LCB0C 161 | jsr LCAD6 162 | jmp DATA 163 | LCB0C: 164 | .endif 165 | lda INPUTBUFFER 166 | bne L2ABE 167 | .ifdef CONFIG_FILE 168 | lda CURDVC 169 | bne LCAF8 170 | .endif 171 | .ifdef CONFIG_CBM1_PATCHES 172 | jmp PATCH1 173 | .else 174 | clc 175 | jmp CONTROL_C_TYPED 176 | .endif 177 | .endif 178 | 179 | NXIN: 180 | .ifdef KBD 181 | jsr INLIN 182 | bmi RTS20 183 | pla 184 | jmp LE86C 185 | .else 186 | .ifdef CONFIG_FILE 187 | lda CURDVC 188 | bne LCB21 189 | .endif 190 | jsr OUTQUES ; '?' 191 | jsr OUTSP 192 | LCB21: 193 | jmp INLIN 194 | .endif 195 | 196 | ; ---------------------------------------------------------------------------- 197 | ; "GETC" STATEMENT 198 | ; ---------------------------------------------------------------------------- 199 | .ifdef KBD 200 | GETC: 201 | jsr CONINT 202 | jsr LF43D 203 | jmp LE664 204 | .endif 205 | 206 | ; ---------------------------------------------------------------------------- 207 | ; "READ" STATEMENT 208 | ; ---------------------------------------------------------------------------- 209 | READ: 210 | ldx DATPTR 211 | ldy DATPTR+1 212 | .ifdef CONFIG_NO_READ_Y_IS_ZERO_HACK 213 | ; AppleSoft II, too 214 | lda #$98 ; READ 215 | .byte $2C 216 | L2ABE: 217 | lda #$00 ; INPUT 218 | .else 219 | .byte $A9 ; LDA #$98 220 | L2ABE: 221 | tya 222 | .endif 223 | 224 | ; ---------------------------------------------------------------------------- 225 | ; PROCESS INPUT LIST 226 | ; 227 | ; (Y,X) IS ADDRESS OF INPUT DATA STRING 228 | ; (A) = VALUE FOR INPUTFLG: $00 FOR INPUT 229 | ; $40 FOR GET 230 | ; $98 FOR READ 231 | ; ---------------------------------------------------------------------------- 232 | PROCESS_INPUT_LIST: 233 | sta INPUTFLG 234 | stx INPTR 235 | sty INPTR+1 236 | PROCESS_INPUT_ITEM: 237 | jsr PTRGET 238 | sta FORPNT 239 | sty FORPNT+1 240 | lda TXTPTR 241 | ldy TXTPTR+1 242 | sta TXPSV 243 | sty TXPSV+1 244 | ldx INPTR 245 | ldy INPTR+1 246 | stx TXTPTR 247 | sty TXTPTR+1 248 | jsr CHRGOT 249 | bne INSTART 250 | bit INPUTFLG 251 | .ifndef CONFIG_SMALL ; GET 252 | .ifndef SYM1 253 | bvc L2AF0 254 | .ifdef MICROTAN 255 | jsr MONRDKEY2 256 | .elseif .def(AIM65) 257 | jsr MONRDKEY2 258 | .else 259 | jsr MONRDKEY 260 | .endif 261 | .ifdef CONFIG_IO_MSB 262 | and #$7F 263 | .endif 264 | sta INPUTBUFFER 265 | ; BUG: The beq/bne L2AF8 below is supposed 266 | ; to be always taken. For this to happen, 267 | ; the last load must be a 0 for beq 268 | ; and != 0 for bne. The original Microsoft 269 | ; code had ldx/ldy/bne here, which was only 270 | ; correct for a non-ZP INPUTBUFFER. Commodore 271 | ; fixed it in CBMBASIC V1 by swapping the 272 | ; ldx and the ldy. It was broken on KIM, 273 | ; but okay on APPLE and CBM2, because 274 | ; these used a non-ZP INPUTBUFFER. 275 | ; Microsoft fixed this somewhere after KIM 276 | ; and before MICROTAN, by using beq instead 277 | ; of bne in the ZP case. 278 | .ifdef CBM1 279 | ldy #>(INPUTBUFFER-1) 280 | ldx #<(INPUTBUFFER-1) 281 | .else 282 | ldx #<(INPUTBUFFER-1) 283 | ldy #>(INPUTBUFFER-1) 284 | .endif 285 | .if .def(CONFIG_2) && (!.def(CONFIG_NO_INPUTBUFFER_ZP)) 286 | beq L2AF8 ; always 287 | .else 288 | bne L2AF8 ; always 289 | .endif 290 | L2AF0: 291 | .endif 292 | .endif 293 | bmi FINDATA 294 | .ifdef CONFIG_FILE 295 | lda CURDVC 296 | bne LCB64 297 | .endif 298 | .ifdef KBD 299 | jsr OUTQUESSP 300 | .else 301 | jsr OUTQUES 302 | .endif 303 | LCB64: 304 | jsr NXIN 305 | L2AF8: 306 | stx TXTPTR 307 | sty TXTPTR+1 308 | 309 | ; ---------------------------------------------------------------------------- 310 | INSTART: 311 | jsr CHRGET 312 | bit VALTYP 313 | bpl L2B34 314 | .ifndef CONFIG_SMALL ; GET 315 | .ifndef SYM1 316 | bit INPUTFLG 317 | bvc L2B10 318 | .ifdef CONFIG_CBM1_PATCHES 319 | lda #$00 320 | jsr PATCH4 321 | nop 322 | .else 323 | inx 324 | stx TXTPTR 325 | lda #$00 326 | sta CHARAC 327 | beq L2B1C 328 | .endif 329 | L2B10: 330 | .endif 331 | .endif 332 | sta CHARAC 333 | cmp #$22 334 | beq L2B1D 335 | lda #$3A 336 | sta CHARAC 337 | lda #$2C 338 | L2B1C: 339 | clc 340 | L2B1D: 341 | sta ENDCHR 342 | lda TXTPTR 343 | ldy TXTPTR+1 344 | adc #$00 345 | bcc L2B28 346 | iny 347 | L2B28: 348 | jsr STRLT2 349 | jsr POINT 350 | .ifdef CONFIG_SMALL 351 | jsr LETSTRING 352 | .else 353 | jsr PUTSTR 354 | .endif 355 | jmp INPUT_MORE 356 | ; ---------------------------------------------------------------------------- 357 | L2B34: 358 | jsr FIN 359 | .ifdef CONFIG_SMALL 360 | jsr SETFOR 361 | .else 362 | lda VALTYP+1 363 | jsr LET2 364 | .endif 365 | ; ---------------------------------------------------------------------------- 366 | INPUT_MORE: 367 | jsr CHRGOT 368 | beq L2B48 369 | cmp #$2C 370 | beq L2B48 371 | jmp INPUTERR 372 | L2B48: 373 | lda TXTPTR 374 | ldy TXTPTR+1 375 | sta INPTR 376 | sty INPTR+1 377 | lda TXPSV 378 | ldy TXPSV+1 379 | sta TXTPTR 380 | sty TXTPTR+1 381 | jsr CHRGOT 382 | beq INPDONE 383 | jsr CHKCOM 384 | jmp PROCESS_INPUT_ITEM 385 | ; ---------------------------------------------------------------------------- 386 | FINDATA: 387 | jsr DATAN 388 | iny 389 | tax 390 | bne L2B7C 391 | ldx #ERR_NODATA 392 | iny 393 | lda (TXTPTR),y 394 | beq GERR 395 | iny 396 | lda (TXTPTR),y 397 | sta Z8C 398 | iny 399 | lda (TXTPTR),y 400 | iny 401 | sta Z8C+1 402 | L2B7C: 403 | lda (TXTPTR),y 404 | tax 405 | jsr ADDON 406 | cpx #$83 407 | bne FINDATA 408 | jmp INSTART 409 | ; ---NO MORE INPUT REQUESTED------ 410 | INPDONE: 411 | lda INPTR 412 | ldy INPTR+1 413 | ldx INPUTFLG 414 | .if .def(CONFIG_SMALL) && (!.def(CONFIG_11)) 415 | beq L2B94 ; INPUT 416 | .else 417 | bpl L2B94; INPUT or GET 418 | .endif 419 | jmp SETDA 420 | L2B94: 421 | ldy #$00 422 | .ifdef AIM65 423 | jsr LB8B1 424 | .endif 425 | lda (INPTR),y 426 | beq L2BA1 427 | .ifdef CONFIG_FILE 428 | lda CURDVC 429 | bne L2BA1 430 | .endif 431 | lda #ERREXTRA 433 | jmp STROUT 434 | L2BA1: 435 | rts 436 | 437 | ; ---------------------------------------------------------------------------- 438 | ERREXTRA: 439 | .ifdef KBD 440 | .byte "?Extra" 441 | .else 442 | .byte "?EXTRA IGNORED" 443 | .endif 444 | .byte $0D,$0A,$00 445 | ERRREENTRY: 446 | .ifdef KBD 447 | .byte "What?" 448 | .else 449 | .byte "?REDO FROM START" 450 | .endif 451 | .byte $0D,$0A,$00 452 | .ifdef KBD 453 | LEA30: 454 | .byte "B" 455 | .byte $FD 456 | .byte "GsBASIC" 457 | .byte $00,$1B,$0D,$13 458 | .byte " BASIC" 459 | .endif 460 | -------------------------------------------------------------------------------- /iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ; ---------------------------------------------------------------------------- 3 | ; SEE IF CONTROL-C TYPED 4 | ; ---------------------------------------------------------------------------- 5 | .ifndef CONFIG_CBM_ALL 6 | .include "cbm_iscntc.s" 7 | .endif 8 | .ifdef KBD 9 | .include "kbd_iscntc.s" 10 | .endif 11 | .ifdef OSI 12 | .include "osi_iscntc.s" 13 | .endif 14 | .ifdef APPLE 15 | .include "apple_iscntc.s" 16 | .endif 17 | .ifdef KIM 18 | .include "kim_iscntc.s" 19 | .endif 20 | .ifdef MICROTAN 21 | .include "microtan_iscntc.s" 22 | .endif 23 | .ifdef AIM65 24 | .include "aim65_iscntc.s" 25 | .endif 26 | .ifdef SYM1 27 | .include "sym1_iscntc.s" 28 | .endif 29 | .ifdef EATER 30 | .include "eater_iscntc.s" 31 | .endif 32 | ;!!! runs into "STOP" 33 | -------------------------------------------------------------------------------- /kb9.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $2000, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /kbd_extra.s: -------------------------------------------------------------------------------- 1 | .segment "EXTRA" 2 | stx SHIFTSIGNEXT 3 | stx $0800 4 | inx 5 | stx Z17 6 | stx Z18 7 | stx TXTTAB 8 | lda #$08 9 | sta TXTTAB+1 10 | jsr SCRTCH 11 | sta STACK+255 12 | LFD81: 13 | jsr PRIMM 14 | .byte $1B,$06,$01,$0C 15 | .byte "INTELLIVISION BASIC" 16 | .byte $0D,$0A,$0A 17 | .byte "Copyright Microsoft, Mattel 1980" 18 | .byte $0D,$0A,$00 19 | sta $0435 20 | sta $8F 21 | ldy #$0F 22 | lda #$FF 23 | sta ($04),y 24 | jsr LDE8C 25 | .byte $0C ; NOP $xxxx 26 | jmp RESTART 27 | OUTQUESSP: 28 | jsr OUTQUES 29 | jmp OUTSP 30 | INLIN: 31 | ldy #$FF 32 | LFDDC: 33 | iny 34 | LFDDD: 35 | jsr GETLN 36 | cmp #$03 ; CTRL+C 37 | beq LFDF7 38 | cmp #$20 39 | bcs LFDEC ; no control char 40 | sbc #$09 41 | bne LFDDD 42 | LFDEC: 43 | sta INPUTBUFFER,y 44 | tax 45 | bne LFDDC 46 | jsr CRDO2 47 | ldy #$06 48 | LFDF7: 49 | tax 50 | clc 51 | rts 52 | LFDFA: 53 | bit $8F 54 | bmi LFE01 55 | jsr LDE48 56 | LFE01: 57 | bit $8F 58 | bvc LFE10 59 | jmp LDE53 60 | LFE08: 61 | jsr LFDFA 62 | LFE0B: 63 | jsr LDE24 64 | bne LFE08 65 | LFE10: 66 | rts 67 | VSAV: 68 | jsr GARBAG 69 | lda FRETOP 70 | sta $00 71 | lda FRETOP+1 72 | .byte $85 73 | LFE1B: 74 | ora ($A5,x) 75 | .byte $2F 76 | sta $02 77 | lda STREND+1 78 | sta $03 79 | ldy #$00 80 | LFE26: 81 | lda ($00),y 82 | sta ($02),y 83 | inc $02 84 | bne LFE30 85 | inc $03 86 | LFE30: 87 | inc $00 88 | bne LFE26 89 | inc $01 90 | bit $01 91 | bvc LFE26 92 | ldx VARTAB 93 | ldy VARTAB+1 94 | lda #$01 95 | bne LFE50 96 | PSAV: 97 | lda VARTAB 98 | sta $02 99 | lda VARTAB+1 100 | sta $03 101 | ldx #$01 102 | ldy #$08 103 | lda #$02 104 | LFE50: 105 | sta $0513 106 | stx $0503 107 | stx $00 108 | sty $0504 109 | sty $01 110 | ldy #$0D 111 | lda #$00 112 | LFE61: 113 | sta $0504,y 114 | dey 115 | bne LFE61 116 | sty $0500 117 | lda #$40 118 | sta $0505 119 | lda $02 120 | sec 121 | sbc $00 122 | sta $00 123 | lda $03 124 | sbc $01 125 | sta $01 126 | lsr a 127 | lsr a 128 | lsr a 129 | sta $03 130 | jsr LE870 131 | sta $02 132 | jsr CHRGOT 133 | beq LFEA6 134 | cmp #$2C 135 | beq L40FA 136 | jmp SYNERR 137 | L40FA: 138 | jsr CHRGET 139 | jsr LE870 140 | sec 141 | sbc $02 142 | cmp $03 143 | bpl LFEBF 144 | lda #$27 145 | sta JMPADRS 146 | jmp LFFBD 147 | LFEA6: 148 | lda $02 149 | clc 150 | adc $03 151 | jsr LE874 152 | pha 153 | jsr LFE0B 154 | jsr L6874 155 | .byte $72 156 | adc $00,x 157 | pla 158 | tax 159 | lda #$00 160 | jsr LINPRT 161 | LFEBF: 162 | ldx #$07 163 | LBF83: 164 | dex 165 | lda VARTAB,x 166 | sec 167 | sbc TXTTAB,x 168 | sta $051B,x 169 | lda VARTAB+1,x 170 | sbc TXTTAB+1,x 171 | sta $051C,x 172 | dex 173 | bpl LBF83 174 | txa 175 | sbc FRETOP 176 | sta $0521 177 | lda #>CONST_MEMSIZ 178 | sbc FRETOP+1 179 | sta $0522 180 | lda FRETOP 181 | sta $0523 182 | lda FRETOP+1 183 | sta $0524 184 | ldx $02 185 | jsr LFFDD 186 | jsr LFFD1 187 | lda $01 188 | ldx #$05 189 | LFEF7: 190 | stx $0511 191 | ldy #$E4 192 | sec 193 | sbc #$08 194 | sta $01 195 | bpl LFF15 196 | adc #$08 197 | asl $00 198 | rol a 199 | asl $00 200 | rol a 201 | asl $00 202 | rol a 203 | adc #$01 204 | sta $0505 205 | ldy #$00 206 | LFF15: 207 | sty $0512 208 | jsr LE4C0 209 | ldx #$00 210 | lda $01 211 | bpl LFEF7 212 | LFF21: 213 | rts 214 | VLOD: 215 | jsr LFFD1 216 | stx JMPADRS 217 | lda VARTAB 218 | ldy VARTAB+1 219 | ldx #$01 220 | jsr LFF64 221 | ldx #$00 222 | ldy #$02 223 | LFF34: 224 | jsr LE39A 225 | iny 226 | iny 227 | inx 228 | inx 229 | cpx #$05 230 | bmi LFF34 231 | lda STREND 232 | sta LOWTR 233 | lda STREND+1 234 | sta LOWTR+1 235 | lda FRETOP 236 | sta HIGHTR 237 | lda FRETOP+1 238 | sta HIGHTR+1 239 | lda #CONST_MEMSIZ 242 | sta HIGHDS+1 243 | lda $0523 244 | sta FRETOP 245 | lda $0524 246 | sta FRETOP+1 247 | jmp BLTU2 248 | LFF64: 249 | sta $9A 250 | sty $9B 251 | stx $00 252 | jsr LE870 253 | jsr LFFDD 254 | lda JMPADRS 255 | beq LFF7F 256 | lda #$01 257 | sta $9A 258 | lda #$08 259 | sta $9B 260 | jsr STXTPT 261 | LFF7F: 262 | lda $9A 263 | sta $0503 264 | lda $9B 265 | sta $0504 266 | lda #$ED 267 | sta $0512 268 | lda #$05 269 | sta $01 270 | LFF92: 271 | ldx $0512 272 | beq LFF21 273 | ldy #$04 274 | jsr LE4C4 275 | lda $01 276 | cmp $0511 277 | bne LFFB2 278 | lda #$00 279 | sta $01 280 | lda $00 281 | cmp $0513 282 | beq LFF92 283 | lda #$18 284 | bne LFFB8 285 | LFFB2: 286 | lda #$27 287 | bne LFFB8 288 | LFFB6: 289 | lda #$3C 290 | LFFB8: 291 | sta JMPADRS 292 | jsr CLEARC 293 | LFFBD: 294 | jsr VARTAB_MINUS_2_TO_AY 295 | sta $9A 296 | sty $9B 297 | lda #$00 298 | tay 299 | sta ($9A),y 300 | iny 301 | sta ($9A),y 302 | ldx JMPADRS 303 | jmp ERROR 304 | LFFD1: 305 | ldx #$00 306 | LFFD3: 307 | lda #$02 308 | .byte $2C 309 | LFFD6: 310 | lda #$03 311 | jsr LDE8C 312 | asl FACSIGN 313 | LFFDD: 314 | jsr CHRGOT 315 | beq LFFE5 316 | jmp SYNERR 317 | LFFE5: 318 | lda #$0D 319 | ldy #$00 320 | jsr LDE8C 321 | .byte $06 322 | LFFED: 323 | lda $034C 324 | bmi LFFED 325 | ldy #$01 326 | lda ($04),y 327 | bne LFFB6 328 | rts 329 | .byte $FF 330 | ; NMI 331 | .addr LC000 332 | ; RESET 333 | .addr LC000 334 | ; IRQ 335 | .addr LC009 336 | -------------------------------------------------------------------------------- /kbd_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | jsr LE8F3 4 | bcc RET1 5 | LE633: 6 | jsr LDE7F 7 | beq STOP 8 | cmp #$03 9 | bne LE633 10 | ;!!! runs into "STOP" -------------------------------------------------------------------------------- /kbd_loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | SLOD: 3 | ldx #$01 4 | .byte $2C 5 | PLOD: 6 | ldx #$00 7 | ldy CURLIN+1 8 | iny 9 | sty JMPADRS 10 | jsr LFFD3 11 | jsr VARTAB_MINUS_2_TO_AY 12 | ldx #$02 13 | jsr LFF64 14 | ldx #$6F 15 | ldy #$00 16 | jsr LE39A 17 | jsr LE33D 18 | jmp CLEARC 19 | .byte $FF,$FF,$FF 20 | 21 | ; ---------------------------------------------------------------------------- 22 | VER: 23 | lda #$13 24 | ldx FAC 25 | beq LE397 26 | lda $DFF9 27 | LE397: 28 | jmp FLOAT 29 | LE39A: 30 | lda VARTAB,x 31 | clc 32 | adc $051B,y 33 | sta VARTAB,y 34 | lda VARTAB+1,x 35 | adc $051C,y 36 | sta VARTAB+1,y 37 | ; !!! next instruction is an RTS! -------------------------------------------------------------------------------- /kbdbasic.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $E000, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /kim_extra.s: -------------------------------------------------------------------------------- 1 | .segment "EXTRA" 2 | 3 | RAMSTART2: 4 | .byte $08,$29,$25,$20,$60,$2A,$E5,$E4 5 | .byte $20,$66,$24,$65,$AC,$04,$A4 6 | -------------------------------------------------------------------------------- /kim_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | lda #$01 4 | bit $1740 5 | bmi RET2 6 | ldx #$08 7 | lda #$03 8 | clc 9 | cmp #$03 10 | ;!!! runs into "STOP" -------------------------------------------------------------------------------- /kim_loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | SAVE: 3 | tsx 4 | stx INPUTFLG 5 | lda #$37 6 | sta $F2 7 | lda #$FE 8 | sta $17F9 9 | lda TXTTAB 10 | ldy TXTTAB+1 11 | sta $17F5 12 | sty $17F6 13 | lda VARTAB 14 | ldy VARTAB+1 15 | sta $17F7 16 | sty $17F8 17 | jmp L1800 18 | ldx INPUTFLG 19 | txs 20 | lda #QT_SAVED 22 | jmp STROUT 23 | QT_LOADED: 24 | .byte "LOADED" 25 | .byte $00 26 | QT_SAVED: 27 | .byte "SAVED" 28 | .byte $0D,$0A,$00,$00,$00,$00,$00,$00 29 | .byte $00,$00,$00,$00,$00,$00,$00,$00 30 | .byte $00,$00,$00,$00,$00,$00,$00 31 | LOAD: 32 | lda TXTTAB 33 | ldy TXTTAB+1 34 | sta $17F5 35 | sty $17F6 36 | lda #$FF 37 | sta $17F9 38 | lda #L27A6 40 | sta GORESTART+1 41 | sty GORESTART+2 42 | jmp L1873 43 | L27A6: 44 | ldx #$FF 45 | txs 46 | lda #RESTART 48 | sta GORESTART+1 49 | sty GORESTART+2 50 | lda #QT_LOADED 52 | jsr STROUT 53 | ldx $17ED 54 | ldy $17EE 55 | txa 56 | bne L27C2 57 | nop 58 | L27C2: 59 | nop 60 | stx VARTAB 61 | sty VARTAB+1 62 | jmp FIX_LINKS 63 | -------------------------------------------------------------------------------- /lcd.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | .ifdef EATER 3 | PORTB = $6000 4 | DDRB = $6002 5 | E = %01000000 6 | RW = %00100000 7 | RS = %00010000 8 | 9 | lcd_wait: 10 | pha 11 | lda #%11110000 ; LCD data is input 12 | sta DDRB 13 | lcdbusy: 14 | lda #RW 15 | sta PORTB 16 | lda #(RW | E) 17 | sta PORTB 18 | lda PORTB ; Read high nibble 19 | pha ; and put on stack since it has the busy flag 20 | lda #RW 21 | sta PORTB 22 | lda #(RW | E) 23 | sta PORTB 24 | lda PORTB ; Read low nibble 25 | pla ; Get high nibble off stack 26 | and #%00001000 27 | bne lcdbusy 28 | 29 | lda #RW 30 | sta PORTB 31 | lda #%11111111 ; LCD data is output 32 | sta DDRB 33 | pla 34 | rts 35 | 36 | LCDINIT: 37 | lda #$ff ; Set all pins on port B to output 38 | sta DDRB 39 | 40 | lda #%00000011 ; Set 8-bit mode 41 | sta PORTB 42 | ora #E 43 | sta PORTB 44 | and #%00001111 45 | sta PORTB 46 | 47 | lda #%00000011 ; Set 8-bit mode 48 | sta PORTB 49 | ora #E 50 | sta PORTB 51 | and #%00001111 52 | sta PORTB 53 | 54 | lda #%00000011 ; Set 8-bit mode 55 | sta PORTB 56 | ora #E 57 | sta PORTB 58 | and #%00001111 59 | sta PORTB 60 | 61 | ; Okay, now we're really in 8-bit mode. 62 | ; Command to get to 4-bit mode ought to work now 63 | lda #%00000010 ; Set 4-bit mode 64 | sta PORTB 65 | ora #E 66 | sta PORTB 67 | and #%00001111 68 | sta PORTB 69 | 70 | lda #%00101000 ; Set 4-bit mode; 2-line display; 5x8 font 71 | jsr lcd_instruction 72 | lda #%00001110 ; Display on; cursor on; blink off 73 | jsr lcd_instruction 74 | lda #%00000110 ; Increment and shift cursor; don't shift display 75 | jsr lcd_instruction 76 | lda #%00000001 ; Clear display 77 | jsr lcd_instruction 78 | rts 79 | 80 | 81 | LCDCMD: 82 | jsr GETBYT 83 | txa 84 | lcd_instruction: 85 | jsr lcd_wait 86 | pha 87 | lsr 88 | lsr 89 | lsr 90 | lsr ; Send high 4 bits 91 | sta PORTB 92 | ora #E ; Set E bit to send instruction 93 | sta PORTB 94 | eor #E ; Clear E bit 95 | sta PORTB 96 | pla 97 | and #%00001111 ; Send low 4 bits 98 | sta PORTB 99 | ora #E ; Set E bit to send instruction 100 | sta PORTB 101 | eor #E ; Clear E bit 102 | sta PORTB 103 | rts 104 | 105 | LCDPRINT: 106 | jsr FRMEVL 107 | bit VALTYP 108 | bmi lcd_print 109 | jsr FOUT 110 | jsr STRLIT 111 | lcd_print: 112 | jsr FREFAC 113 | tax 114 | ldy #0 115 | lcd_print_loop: 116 | lda (INDEX),y 117 | jsr lcd_print_char 118 | iny 119 | dex 120 | bne lcd_print_loop 121 | rts 122 | 123 | lcd_print_char: 124 | jsr lcd_wait 125 | pha 126 | lsr 127 | lsr 128 | lsr 129 | lsr ; Send high 4 bits 130 | ora #RS ; Set RS 131 | sta PORTB 132 | ora #E ; Set E bit to send instruction 133 | sta PORTB 134 | eor #E ; Clear E bit 135 | sta PORTB 136 | pla 137 | and #%00001111 ; Send low 4 bits 138 | ora #RS ; Set RS 139 | sta PORTB 140 | ora #E ; Set E bit to send instruction 141 | sta PORTB 142 | eor #E ; Clear E bit 143 | sta PORTB 144 | rts 145 | 146 | .endif 147 | -------------------------------------------------------------------------------- /loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | .ifdef APPLE 4 | .include "apple_loadsave.s" 5 | .endif 6 | .ifdef KIM 7 | .include "kim_loadsave.s" 8 | .endif 9 | .ifdef MICROTAN 10 | .include "microtan_loadsave.s" 11 | .endif 12 | .ifdef AIM65 13 | .include "aim65_loadsave.s" 14 | .endif 15 | .ifdef SYM1 16 | .include "sym1_loadsave.s" 17 | .endif -------------------------------------------------------------------------------- /macros.s: -------------------------------------------------------------------------------- 1 | ; htasc - set the hi bit on the last byte of a string for termination 2 | ; (by Tom Greene) 3 | .macro htasc str 4 | .repeat .strlen(str)-1,I 5 | .byte .strat(str,I) 6 | .endrep 7 | .byte .strat(str,.strlen(str)-1) | $80 8 | .endmacro 9 | 10 | ; For every token, a byte gets put into segment "DUMMY". 11 | ; This way, we count up with every token. The DUMMY segment 12 | ; doesn't get linked into the binary. 13 | .macro init_token_tables 14 | .segment "VECTORS" 15 | TOKEN_ADDRESS_TABLE: 16 | .segment "KEYWORDS" 17 | TOKEN_NAME_TABLE: 18 | .segment "DUMMY" 19 | DUMMY_START: 20 | .endmacro 21 | 22 | ; optionally define token symbol 23 | ; count up token number 24 | .macro define_token token 25 | .segment "DUMMY" 26 | .ifnblank token 27 | token := <(*-DUMMY_START)+$80 28 | .endif 29 | .res 1; count up in any case 30 | .endmacro 31 | 32 | ; lay down a keyword, optionally define a token symbol 33 | .macro keyword key, token 34 | .segment "KEYWORDS" 35 | htasc key 36 | define_token token 37 | .endmacro 38 | 39 | ; lay down a keyword and an address (RTS style), 40 | ; optionally define a token symbol 41 | .macro keyword_rts key, vec, token 42 | .segment "VECTORS" 43 | .word vec-1 44 | keyword key, token 45 | .endmacro 46 | 47 | ; lay down a keyword and an address, 48 | ; optionally define a token symbol 49 | .macro keyword_addr key, vec, token 50 | .segment "VECTORS" 51 | .addr vec 52 | keyword key, token 53 | .endmacro 54 | 55 | .macro count_tokens 56 | .segment "DUMMY" 57 | NUM_TOKENS := <(*-DUMMY_START) 58 | .endmacro 59 | 60 | .macro init_error_table 61 | .segment "ERROR" 62 | ERROR_MESSAGES: 63 | .endmacro 64 | 65 | .macro define_error error, msg 66 | .segment "ERROR" 67 | error := <(*-ERROR_MESSAGES) 68 | htasc msg 69 | .endmacro 70 | 71 | ;--------------------------------------------- 72 | ; set the MSB of every byte of a string 73 | .macro asc80 str 74 | .repeat .strlen(str),I 75 | .byte .strat(str,I)+$80 76 | .endrep 77 | .endmacro 78 | 79 | -------------------------------------------------------------------------------- /make.sh: -------------------------------------------------------------------------------- 1 | if [ ! -d tmp ]; then 2 | mkdir tmp 3 | fi 4 | 5 | for i in cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan aim65 sym1 eater; do 6 | 7 | echo $i 8 | ca65 -D $i msbasic.s -o tmp/$i.o && 9 | ld65 -C $i.cfg tmp/$i.o -o tmp/$i.bin -Ln tmp/$i.lbl 10 | 11 | done 12 | 13 | -------------------------------------------------------------------------------- /memory.s: -------------------------------------------------------------------------------- 1 | ; generic stack and memory management code 2 | ; this code is identical across all versions of 3 | ; BASIC 4 | 5 | .segment "CODE" 6 | 7 | ; ---------------------------------------------------------------------------- 8 | ; CALLED BY "NEXT" AND "FOR" TO SCAN THROUGH 9 | ; THE STACK FOR A FRAME WITH THE SAME VARIABLE. 10 | ; 11 | ; (FORPNT) = ADDRESS OF VARIABLE IF "FOR" OR "NEXT" 12 | ; = $XXFF IF CALLED FROM "RETURN" 13 | ; <<< BUG: SHOULD BE $FFXX >>> 14 | ; 15 | ; RETURNS .NE. IF VARIABLE NOT FOUND, 16 | ; (X) = STACK PNTR AFTER SKIPPING ALL FRAMES 17 | ; 18 | ; .EQ. IF FOUND 19 | ; (X) = STACK PNTR OF FRAME FOUND 20 | ; ---------------------------------------------------------------------------- 21 | GTFORPNT: 22 | tsx 23 | inx 24 | inx 25 | inx 26 | inx 27 | L2279: 28 | lda STACK+1,x 29 | cmp #$81 30 | bne L22A1 31 | lda FORPNT+1 32 | bne L228E 33 | lda STACK+2,x 34 | sta FORPNT 35 | lda STACK+3,x 36 | sta FORPNT+1 37 | L228E: 38 | cmp STACK+3,x 39 | bne L229A 40 | lda FORPNT 41 | cmp STACK+2,x 42 | beq L22A1 43 | L229A: 44 | txa 45 | clc 46 | adc #BYTES_PER_FRAME 47 | tax 48 | bne L2279 49 | L22A1: 50 | rts 51 | 52 | ; ---------------------------------------------------------------------------- 53 | ; MOVE BLOCK OF MEMORY UP 54 | ; 55 | ; ON ENTRY: 56 | ; (Y,A) = (HIGHDS) = DESTINATION END+1 57 | ; (LOWTR) = LOWEST ADDRESS OF SOURCE 58 | ; (HIGHTR) = HIGHEST SOURCE ADDRESS+1 59 | ; ---------------------------------------------------------------------------- 60 | BLTU: 61 | jsr REASON 62 | sta STREND 63 | sty STREND+1 64 | BLTU2: 65 | sec 66 | lda HIGHTR 67 | sbc LOWTR 68 | sta INDEX 69 | tay 70 | lda HIGHTR+1 71 | sbc LOWTR+1 72 | tax 73 | inx 74 | tya 75 | beq L22DD 76 | lda HIGHTR 77 | sec 78 | sbc INDEX 79 | sta HIGHTR 80 | bcs L22C6 81 | dec HIGHTR+1 82 | sec 83 | L22C6: 84 | lda HIGHDS 85 | sbc INDEX 86 | sta HIGHDS 87 | bcs L22D6 88 | dec HIGHDS+1 89 | bcc L22D6 90 | L22D2: 91 | lda (HIGHTR),y 92 | sta (HIGHDS),y 93 | L22D6: 94 | dey 95 | bne L22D2 96 | lda (HIGHTR),y 97 | sta (HIGHDS),y 98 | L22DD: 99 | dec HIGHTR+1 100 | dec HIGHDS+1 101 | dex 102 | bne L22D6 103 | rts 104 | 105 | ; ---------------------------------------------------------------------------- 106 | ; CHECK IF ENOUGH ROOM LEFT ON STACK 107 | ; FOR "FOR", "GOSUB", OR EXPRESSION EVALUATION 108 | ; ---------------------------------------------------------------------------- 109 | CHKMEM: 110 | asl a 111 | adc #SPACE_FOR_GOSUB 112 | bcs MEMERR 113 | sta INDEX 114 | tsx 115 | cpx INDEX 116 | bcc MEMERR 117 | rts 118 | 119 | ; ---------------------------------------------------------------------------- 120 | ; CHECK IF ENOUGH ROOM BETWEEN ARRAYS AND STRINGS 121 | ; (Y,A) = ADDR ARRAYS NEED TO GROW TO 122 | ; ---------------------------------------------------------------------------- 123 | REASON: 124 | cpy FRETOP+1 125 | bcc L231E 126 | bne L22FC 127 | cmp FRETOP 128 | bcc L231E 129 | L22FC: 130 | pha 131 | ldx #FAC-TEMP1-1 132 | tya 133 | L2300: 134 | pha 135 | lda TEMP1,x 136 | dex 137 | bpl L2300 138 | jsr GARBAG 139 | ldx #TEMP1-FAC+1 140 | L230B: 141 | pla 142 | sta FAC,x 143 | inx 144 | bmi L230B 145 | pla 146 | tay 147 | pla 148 | cpy FRETOP+1 149 | bcc L231E 150 | bne MEMERR 151 | cmp FRETOP 152 | bcs MEMERR 153 | L231E: 154 | rts 155 | -------------------------------------------------------------------------------- /message.s: -------------------------------------------------------------------------------- 1 | ; global messages: "error", "in", "ready", "break" 2 | 3 | .segment "CODE" 4 | 5 | QT_ERROR: 6 | .ifdef KBD 7 | .byte " err" 8 | .else 9 | .ifdef APPLE 10 | .byte " ERR" 11 | .byte $07,$07 12 | .else 13 | .byte " ERROR" 14 | .endif 15 | .endif 16 | .byte 0 17 | 18 | .ifndef KBD 19 | QT_IN: 20 | .byte " IN " 21 | .byte $00 22 | .endif 23 | 24 | .ifdef KBD 25 | .byte $54,$D2 ; ??? 26 | OKPRT: 27 | jsr PRIMM 28 | .byte CR,CR,">>",CR,LF 29 | .byte 0 30 | rts 31 | nop 32 | .else 33 | .ifndef AIM65 34 | QT_OK: 35 | .ifdef CONFIG_CBM_ALL 36 | .byte CR,LF,"READY.",CR,LF 37 | .else 38 | .ifdef APPLE 39 | ; binary patch! 40 | .byte CR,0,0,"K",CR,LF 41 | .else 42 | .byte CR,LF,"OK",CR,LF 43 | .endif 44 | .endif 45 | .byte 0 46 | .endif 47 | .endif 48 | QT_BREAK: 49 | 50 | .ifdef KBD 51 | .byte CR,LF," Brk" 52 | .byte 0 53 | .byte $54,$D0 ; ??? 54 | .elseif .def(MICROTAN) || .def(AIM65) 55 | .byte CR,LF," BREAK" 56 | .byte 0 57 | .else 58 | .byte CR,LF,"BREAK" 59 | .byte 0 60 | .endif 61 | -------------------------------------------------------------------------------- /microtan.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $C000, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /microtan_extra.s: -------------------------------------------------------------------------------- 1 | .byte 0,0,0,0,0,0,0,0,0 2 | LE210: 3 | jmp LE34A 4 | LE213: 5 | jmp LE34A 6 | LE216: 7 | jmp LE33C 8 | LE219: 9 | jmp LE252 10 | LE21C: 11 | jmp LE6AD 12 | LE21F: 13 | jmp LE6B9 14 | LE222: 15 | pla 16 | tay 17 | sta $5E 18 | pla 19 | sta $5F 20 | pha 21 | tya 22 | pha 23 | ldy #$03 24 | LE22E: 25 | lda ($5E),y 26 | beq LE238 27 | jsr LFE75 28 | iny 29 | bne LE22E 30 | LE238: 31 | jsr LFDFA 32 | lda $01 33 | cmp #$03 34 | beq LE24C 35 | cmp #$0D 36 | beq LE24B 37 | jsr LFE75 38 | jmp LE238 39 | LE24B: 40 | rts 41 | LE24C: 42 | pla 43 | pla 44 | pla 45 | jmp LE2D6 46 | LE252: 47 | tya 48 | pha 49 | jsr LE222 50 | bcs LE260 51 | .byte "FAST?" 52 | .byte $0D,$00 53 | LE260: 54 | ldy #$00 55 | sty $50 56 | sty $31 57 | lda $03E0 58 | cmp #$59 59 | beq LE26F 60 | inc $50 61 | LE26F: 62 | pla 63 | pha 64 | beq LE28C 65 | jsr LE222 66 | bcs LE280 67 | ora $5845 68 | .byte "AM?" 69 | .byte $0D,$00 70 | LE280: 71 | lda $03E0 72 | cmp #$59 73 | beq LE28C 74 | pla 75 | clc 76 | adc #$01 77 | pha 78 | LE28C: 79 | jsr LE222 80 | bcs LE29D 81 | ora $4946 82 | .byte "LENAME?" 83 | .byte $0D,$00 84 | LE29D: 85 | ldy #$FF 86 | jsr LF006 87 | bcs LE28C 88 | cmp #$FF 89 | bne LE28C 90 | lda #$00 91 | lda #$42 92 | jsr LF003 93 | jsr LF000 94 | pla 95 | bne LE2C3 96 | ldy #$20 97 | jsr LF009 98 | jsr LF00C 99 | jsr LF01E 100 | jmp LE2D6 101 | LE2C3: 102 | pha 103 | jsr LF01B 104 | pla 105 | clc 106 | sbc #$00 107 | jsr LF021 108 | lda $1E 109 | sta $9C 110 | lda $1F 111 | sta $9D 112 | LE2D6: 113 | jsr LFE73 114 | cli 115 | lda #$00 116 | sta $BFCB 117 | sta $BFC2 118 | ldx #$00 119 | LE2E4: 120 | pla 121 | sta $13,x 122 | inx 123 | cpx #$4D 124 | bne LE2E4 125 | rts 126 | lda #$0F 127 | sta $0C 128 | lda #$00 129 | sta $BFC2 130 | sta $15 131 | sta $16 132 | jmp COLD_START 133 | LE2FD: 134 | pha 135 | txa 136 | pha 137 | lda #$02 138 | sta $14 139 | lda #$00 140 | LE306: 141 | dex 142 | bmi LE312 143 | clc 144 | adc #$20 145 | bcc LE306 146 | inc $14 147 | bne LE306 148 | LE312: 149 | sta $13 150 | pla 151 | tax 152 | pla 153 | rts 154 | LE318: 155 | jsr LE2FD 156 | sta ($13),y 157 | rts 158 | LE31E: 159 | pha 160 | txa 161 | pha 162 | ldx #$00 163 | LE323: 164 | lda $0220,x 165 | sta $0200,x 166 | inx 167 | cpx #$A0 168 | bne LE323 169 | lda #$20 170 | ldx #$1F 171 | LE332: 172 | sta $0280,x 173 | dex 174 | bpl LE332 175 | pla 176 | tax 177 | LE33A: 178 | pla 179 | rts 180 | LE33C: 181 | pha 182 | lda $16 183 | beq LE346 184 | bpl LE33A 185 | jmp LE714 186 | LE346: 187 | pla 188 | jmp LC7A5 189 | LE34A: 190 | lda $16 191 | beq LE357 192 | bmi LE353 193 | jmp LE778 194 | LE353: 195 | lda #$00 196 | sta $16 197 | LE357: 198 | lda $15 199 | beq LE35E 200 | jmp LE660 201 | LE35E: 202 | jsr LC764 203 | cmp #$05 204 | beq LE366 205 | rts 206 | LE366: 207 | stx $0E 208 | lda #$00 209 | sta $33 210 | sta $34 211 | ldx #$FF 212 | LE370: 213 | inx 214 | cpx $0E 215 | beq LE3C8 216 | lda $34 217 | cmp #$19 218 | bcs LE3A7 219 | pha 220 | lda $33 221 | asl a 222 | rol $34 223 | asl a 224 | rol $34 225 | adc $33 226 | sta $33 227 | pla 228 | adc $34 229 | sta $34 230 | asl $33 231 | rol $34 232 | lda $35,x 233 | sec 234 | sbc #$30 235 | bmi LE3A7 236 | cmp #$3A 237 | bcs LE3A7 238 | clc 239 | adc $33 240 | sta $33 241 | bcc LE370 242 | inc $34 243 | bne LE370 244 | LE3A7: 245 | ldx #$00 246 | LE3A9: 247 | lda LE3B4,x 248 | beq LE3C3 249 | jsr LFE75 250 | inx 251 | bne LE3A9 252 | LE3B4: 253 | ora $4F4E 254 | .byte " SUCH LINE" 255 | 256 | .byte $0D,$00 257 | LE3C3: 258 | ldx #$00 259 | lda #$0D 260 | rts 261 | LE3C8: 262 | ldx #$09 263 | LE3CA: 264 | lda #$04 265 | sta $45,x 266 | dex 267 | lda #$01 268 | sta $45,x 269 | dex 270 | bpl LE3CA 271 | sta $CE 272 | lda #$04 273 | sta $CF 274 | stx $7D 275 | stx $7B 276 | LE3E0: 277 | ldy #$03 278 | lda ($CE),y 279 | pha 280 | dey 281 | lda ($CE),y 282 | pha 283 | dey 284 | lda ($CE),y 285 | tax 286 | dey 287 | lda ($CE),y 288 | sta $CE 289 | stx $CF 290 | sta $4F 291 | stx $50 292 | pla 293 | tax 294 | pla 295 | cmp $34 296 | bne LE403 297 | cpx $33 298 | beq LE419 299 | LE403: 300 | stx $7A 301 | sta $7B 302 | ldx #$00 303 | LE409: 304 | lda $47,x 305 | sta $45,x 306 | inx 307 | cpx #$0A 308 | bne LE409 309 | iny 310 | lda ($CE),y 311 | beq LE3A7 312 | bne LE3E0 313 | LE419: 314 | iny 315 | lda ($CE),y 316 | beq LE428 317 | iny 318 | lda ($CE),y 319 | sta $7C 320 | iny 321 | lda ($CE),y 322 | sta $7D 323 | LE428: 324 | ldx #$03 325 | LE42A: 326 | lda $7A,x 327 | pha 328 | dex 329 | bpl LE42A 330 | lda #$20 331 | ldx #$0F 332 | LE434: 333 | ldy #$1F 334 | LE436: 335 | jsr LE318 336 | dey 337 | bpl LE436 338 | dex 339 | bpl LE434 340 | ldx #$05 341 | LE441: 342 | ldy #$1F 343 | lda #$2D 344 | LE445: 345 | jsr LE318 346 | dey 347 | bpl LE445 348 | cpx #$09 349 | beq LE453 350 | ldx #$09 351 | bne LE441 352 | LE453: 353 | lda $45 354 | sta $CE 355 | lda $46 356 | sta $CF 357 | LE45B: 358 | txa 359 | pha 360 | lda #$00 361 | sta $07 362 | ldy #$02 363 | lda ($CE),y 364 | tax 365 | iny 366 | lda ($CE),y 367 | cmp $34 368 | beq LE473 369 | bcc LE479 370 | LE46F: 371 | dec $07 372 | bmi LE47B 373 | LE473: 374 | cpx $33 375 | beq LE47B 376 | bcs LE46F 377 | LE479: 378 | inc $07 379 | LE47B: 380 | sty $08 381 | stx $D2 382 | sta $D1 383 | ldx #$90 384 | sec 385 | jsr FLOAT2 386 | jsr FOUT 387 | ldx #$00 388 | LE48C: 389 | lda $0100,x 390 | beq LE496 391 | sta $35,x 392 | inx 393 | bne LE48C 394 | LE496: 395 | lda #$20 396 | LE498: 397 | ldy $08 398 | and #$7F 399 | LE49C: 400 | sta $35,x 401 | beq LE4D0 402 | inx 403 | cpx #$4F 404 | bcc LE4A9 405 | lda #$00 406 | beq LE49C 407 | LE4A9: 408 | iny 409 | lda ($CE),y 410 | bpl LE49C 411 | sec 412 | sbc #$7F 413 | stx $09 414 | tax 415 | sty $08 416 | ldy #$FF 417 | LE4B8: 418 | dex 419 | beq LE4C3 420 | LE4BB: 421 | iny 422 | lda TOKEN_NAME_TABLE,y 423 | bpl LE4BB 424 | bmi LE4B8 425 | LE4C3: 426 | ldx $09 427 | LE4C5: 428 | iny 429 | lda TOKEN_NAME_TABLE,y 430 | bmi LE498 431 | sta $35,x 432 | inx 433 | bne LE4C5 434 | LE4D0: 435 | ldx #$00 436 | stx $08 437 | pla 438 | tax 439 | ldy #$00 440 | lda $07 441 | bne LE4E0 442 | ldx #$06 443 | bne LE4EE 444 | LE4E0: 445 | bpl LE4E9 446 | LE4E2: 447 | inx 448 | cpx #$0E 449 | beq LE529 450 | bne LE4EE 451 | LE4E9: 452 | jsr LE31E 453 | ldx #$04 454 | LE4EE: 455 | stx $09 456 | LE4F0: 457 | ldx $08 458 | lda $35,x 459 | beq LE50D 460 | inx 461 | stx $08 462 | ldx $09 463 | jsr LE318 464 | iny 465 | cpy #$20 466 | bne LE4F0 467 | ldy #$00 468 | lda $07 469 | beq LE4E2 470 | bpl LE4E9 471 | bmi LE4E2 472 | LE50D: 473 | ldy #$00 474 | lda ($CE),y 475 | pha 476 | iny 477 | lda ($CE),y 478 | sta $CF 479 | pla 480 | sta $CE 481 | lda ($CE),y 482 | beq LE529 483 | ldx $09 484 | lda $07 485 | bne LE526 486 | ldx #$09 487 | LE526: 488 | jmp LE45B 489 | LE529: 490 | ldx #$00 491 | LE52B: 492 | lda $02C1,x 493 | cmp #$20 494 | beq LE53A 495 | sta $03E1,x 496 | inx 497 | stx $0E 498 | bne LE52B 499 | LE53A: 500 | ldx #$00 501 | LE53C: 502 | pla 503 | sta $7A,x 504 | inx 505 | cpx #$04 506 | bne LE53C 507 | ldx #$06 508 | ldy #$00 509 | sty $01 510 | LE54A: 511 | jsr LE2FD 512 | lda ($13),y 513 | sta $82 514 | lda #$FF 515 | sta ($13),y 516 | LE555: 517 | lda #$40 518 | sta $80 519 | sta $81 520 | LE55B: 521 | lda $01 522 | bne LE574 523 | dec $80 524 | bne LE55B 525 | dec $81 526 | bne LE55B 527 | lda ($13),y 528 | pha 529 | lda $82 530 | sta ($13),y 531 | pla 532 | sta $82 533 | jmp LE555 534 | LE574: 535 | lda $82 536 | bmi LE57A 537 | sta ($13),y 538 | LE57A: 539 | lda $01 540 | cmp #$18 541 | bne LE584 542 | dey 543 | bpl LE584 544 | iny 545 | LE584: 546 | cmp #$06 547 | bne LE58D 548 | cpy #$1F 549 | beq LE58D 550 | iny 551 | LE58D: 552 | cmp #$02 553 | bne LE596 554 | cpx #$06 555 | beq LE596 556 | dex 557 | LE596: 558 | cmp #$04 559 | bne LE59F 560 | cpx #$08 561 | beq LE59F 562 | inx 563 | LE59F: 564 | cmp #$7F 565 | bne LE5B6 566 | cpy #$00 567 | bne LE5AB 568 | cpx #$06 569 | beq LE5B6 570 | LE5AB: 571 | dey 572 | bpl LE5BA 573 | ldy #$1F 574 | dex 575 | jsr LE2FD 576 | bne LE5BA 577 | LE5B6: 578 | cmp #$05 579 | bne LE5D5 580 | LE5BA: 581 | pha 582 | tya 583 | pha 584 | LE5BD: 585 | tya 586 | clc 587 | adc $13 588 | cmp #$1F 589 | beq LE5CE 590 | iny 591 | lda ($13),y 592 | dey 593 | sta ($13),y 594 | iny 595 | bne LE5BD 596 | LE5CE: 597 | lda #$20 598 | sta ($13),y 599 | pla 600 | tay 601 | pla 602 | LE5D5: 603 | cmp #$1B 604 | beq LE641 605 | cmp #$0D 606 | beq LE657 607 | cmp #$0A 608 | beq LE631 609 | cmp #$03 610 | beq LE645 611 | cmp #$0B 612 | beq LE627 613 | cmp #$09 614 | beq LE63D 615 | cmp #$20 616 | bcc LE620 617 | cmp #$7E 618 | bcs LE620 619 | pha 620 | tya 621 | pha 622 | lda ($13),y 623 | LE5FA: 624 | sta $80 625 | tya 626 | clc 627 | adc $13 628 | cmp #$1F 629 | beq LE60F 630 | iny 631 | lda ($13),y 632 | pha 633 | lda $80 634 | sta ($13),y 635 | pla 636 | bne LE5FA 637 | LE60F: 638 | pla 639 | tay 640 | pla 641 | sta ($13),y 642 | cpy #$1F 643 | bne LE61F 644 | cpx #$08 645 | beq LE620 646 | inx 647 | ldy #$FF 648 | LE61F: 649 | iny 650 | LE620: 651 | lda #$00 652 | sta $01 653 | jmp LE54A 654 | LE627: 655 | ldx #$5F 656 | lda #$20 657 | LE62B: 658 | sta $02C0,x 659 | dex 660 | bpl LE62B 661 | LE631: 662 | ldx #$02 663 | LE633: 664 | lda $7A,x 665 | sta $13 666 | inx 667 | lda $7A,x 668 | jmp LE659 669 | LE63D: 670 | ldx #$00 671 | stx $0E 672 | LE641: 673 | ldx #$00 674 | beq LE633 675 | LE645: 676 | jsr LFE73 677 | ldx #$00 678 | lda #$00 679 | sta $16 680 | LE64E: 681 | sta $15 682 | ldy #$00 683 | sty $03 684 | lda #$0D 685 | rts 686 | LE657: 687 | lda #$FF 688 | LE659: 689 | sta $14 690 | lda #$01 691 | pha 692 | bne LE685 693 | LE660: 694 | cmp #$03 695 | beq LE69E 696 | cmp #$02 697 | beq LE681 698 | ldx $03C0 699 | cpx #$20 700 | bne LE645 701 | ldx #$FF 702 | LE671: 703 | inx 704 | cpx $0E 705 | bne LE67A 706 | lda #$02 707 | bne LE64E 708 | LE67A: 709 | lda $03E1,x 710 | sta $35,x 711 | bne LE671 712 | LE681: 713 | tax 714 | inx 715 | txa 716 | pha 717 | LE685: 718 | ldx #$4F 719 | LE687: 720 | lda $02C0,x 721 | sta $35,x 722 | dex 723 | bpl LE687 724 | ldx #$4F 725 | LE691: 726 | lda $02BF,x 727 | cmp #$20 728 | bne LE69B 729 | dex 730 | bne LE691 731 | LE69B: 732 | pla 733 | bne LE64E 734 | LE69E: 735 | ldx $14 736 | cpx #$FF 737 | beq LE645 738 | stx $34 739 | lda $13 740 | sta $33 741 | jmp LE3C8 742 | LE6AD: 743 | pha 744 | lda #$05 745 | sta $0E 746 | pla 747 | jsr LINGET 748 | jmp LC57E 749 | LE6B9: 750 | lda $0E 751 | bmi LE6D1 752 | dec $0E 753 | bne LE6D1 754 | jsr LFDFA 755 | lda #$82 756 | sta $0E 757 | lda $01 758 | cmp #$0A 759 | beq LE6D1 760 | sec 761 | rol $0E 762 | LE6D1: 763 | jsr ISCNTC 764 | jmp LC5A9 765 | LE6D7: 766 | ldx #$FF 767 | LE6D9: 768 | jsr LE6E2 769 | dey 770 | bne LE6D9 771 | dex 772 | bne LE6D9 773 | LE6E2: 774 | rts 775 | LE6E3: 776 | lda #$0C 777 | LE6E5: 778 | ldx #$FF 779 | tay 780 | lda $01 781 | cmp #$03 782 | beq LE6E2 783 | tya 784 | LE6EF: 785 | pha 786 | lda $BFC0 787 | LE6F3: 788 | lda $BFCD 789 | and #$08 790 | beq LE6F3 791 | lda $BFC9 792 | pha 793 | lda #$FF 794 | sta $BFC9 795 | pla 796 | cmp #$FC 797 | pla 798 | bcc LE6E5 799 | dex 800 | bne LE6EF 801 | dey 802 | bne LE6EF 803 | rts 804 | LE710: 805 | lda #$06 806 | bne LE6E5 807 | LE714: 808 | stx $13 809 | sty $14 810 | lda $16 811 | cmp #$FD 812 | beq LE749 813 | lda #$00 814 | sta $BFCB 815 | lda #$20 816 | sta $BFC0 817 | lda #$40 818 | sta $BFC2 819 | jsr LE6D7 820 | jsr LF000 821 | lda $16 822 | cmp #$FF 823 | bne LE740 824 | ldy #$20 825 | jsr LF009 826 | dec $16 827 | LE740: 828 | ldy #$10 829 | ldx #$FF 830 | jsr LF009 831 | dec $16 832 | LE749: 833 | pla 834 | sei 835 | pha 836 | cmp #$0A 837 | beq LE771 838 | ldx $0E 839 | stx $50 840 | jsr LF00F 841 | cli 842 | lda $01 843 | cmp #$03 844 | beq LE771 845 | pla 846 | pha 847 | cmp #$0D 848 | bne LE771 849 | lda #$00 850 | sta $16 851 | sta $BFCB 852 | jsr LE6D7 853 | sta $BFC2 854 | LE771: 855 | ldx $13 856 | ldy $14 857 | cli 858 | pla 859 | rts 860 | LE778: 861 | lda #$40 862 | sta $BFC0 863 | jsr LF000 864 | cli 865 | lda $16 866 | cmp #$01 867 | bne LE78A 868 | jsr LE6E3 869 | LE78A: 870 | jsr LE710 871 | lda $01 872 | cmp #$03 873 | beq LE7CE 874 | LE793: 875 | lda $50 876 | pha 877 | lda $51 878 | pha 879 | lda $0E 880 | sta $50 881 | sei 882 | jsr LF018 883 | cli 884 | tay 885 | pla 886 | sta $51 887 | pla 888 | sta $50 889 | bcs LE7BD 890 | lda #$00 891 | sta $16 892 | ldx #$06 893 | LE7B1: 894 | lda LE7DC,x ; "PARITY" 895 | jsr LFE75 896 | dex 897 | bpl LE7B1 898 | inx 899 | beq LE7CE 900 | LE7BD: 901 | lda $01 902 | cmp #$03 903 | beq LE7CE 904 | cpy #$0D 905 | beq LE7CE 906 | sty $35,x 907 | inx 908 | cpx #$4F 909 | bne LE793 910 | LE7CE: 911 | lda #$00 912 | sta $BFCB 913 | sta $BFC2 914 | sta $16 915 | cli 916 | lda #$0D 917 | rts 918 | LE7DC: 919 | .byte "YTIRAP" 920 | .byte $0D,$FF,$FF,$FF,$FF,$FF,$FF,$FF 921 | .byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF 922 | .byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF 923 | .byte $FF,$FF,$FF,$FF,$FF,$FF 924 | -------------------------------------------------------------------------------- /microtan_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | lda $01 4 | cmp #$03 5 | beq LC6EF 6 | lda #$01 7 | rts 8 | LC6EF: 9 | nop 10 | nop 11 | cmp #$03 12 | ;!!! runs into "STOP" -------------------------------------------------------------------------------- /microtan_loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | SAVE: 4 | ldy #$00 5 | beq LC74D 6 | LC74B: 7 | ldy #$01 8 | LC74D: 9 | ldx #$4C 10 | LC74F: 11 | lda $13,x 12 | pha 13 | dex 14 | bpl LC74F 15 | ldx #$03 16 | LC757: 17 | lda TXTTAB,x 18 | sta GOSTROUT+2,x 19 | dex 20 | bpl LC757 21 | jmp LE219 22 | nop 23 | nop 24 | nop 25 | LC764: 26 | tya 27 | pha 28 | ldy $03 29 | lda #$FF 30 | sta ($0A),y 31 | pla 32 | tay 33 | jsr LFDFA 34 | lda $01 35 | jsr LC7A5 36 | rts 37 | .byte "DED" 38 | .byte $0D,$0A 39 | .byte "OK" 40 | .byte $0D,$0A,$00 41 | .byte "SAVED" 42 | .byte $0D,$0A,$00 43 | LOAD: 44 | jsr LC74B 45 | ldx #$FF 46 | tsx 47 | lda #$4F 48 | jsr LFE75 49 | lda #$4B 50 | jsr LFE75 51 | jsr LFE73 52 | lda VARTAB 53 | tax 54 | ldy VARTAB+1 55 | jmp FIX_LINKS 56 | nop 57 | LC7A5: 58 | pha 59 | cmp #$0A 60 | beq LC7AD 61 | jsr LFE75 62 | LC7AD: 63 | tya 64 | pha 65 | ldy $03 66 | lda #$20 67 | sta ($0A),y 68 | pla 69 | tay 70 | pla 71 | rts 72 | inc $8A17 73 | stx VARTAB 74 | sty VARTAB+1 75 | jmp FIX_LINKS 76 | -------------------------------------------------------------------------------- /misc1.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; CONVERT LINE NUMBER 5 | ; ---------------------------------------------------------------------------- 6 | LINGET: 7 | ldx #$00 8 | stx LINNUM 9 | stx LINNUM+1 10 | L28BE: 11 | bcs L28B7 12 | sbc #$2F 13 | sta CHARAC 14 | lda LINNUM+1 15 | sta INDEX 16 | cmp #$19 17 | bcs L28A0 18 | ; <<<<>>>> 19 | ; NOTE THAT IF (A) = $AB ON THE LINE ABOVE, 20 | ; ON.1 WILL COMPARE = AND CAUSE A CATASTROPHIC 21 | ; JUMP TO $22D9 (FOR GOTO), OR OTHER LOCATIONS 22 | ; FOR OTHER CALLS TO LINGET. 23 | ; 24 | ; YOU CAN SEE THIS IS YOU FIRST PUT "BRK" IN $22D9, 25 | ; THEN TYPE "GO TO 437761". 26 | ; 27 | ; ANY VALUE FROM 437760 THROUGH 440319 WILL CAUSE 28 | ; THE PROBLEM. ($AB00 - $ABFF) 29 | ; <<<<>>>> 30 | lda LINNUM 31 | asl a 32 | rol INDEX 33 | asl a 34 | rol INDEX 35 | adc LINNUM 36 | sta LINNUM 37 | lda INDEX 38 | adc LINNUM+1 39 | sta LINNUM+1 40 | asl LINNUM 41 | rol LINNUM+1 42 | lda LINNUM 43 | adc CHARAC 44 | sta LINNUM 45 | bcc L28EC 46 | inc LINNUM+1 47 | L28EC: 48 | jsr CHRGET 49 | jmp L28BE 50 | 51 | ; ---------------------------------------------------------------------------- 52 | ; "LET" STATEMENT 53 | ; 54 | ; LET = 55 | ; = 56 | ; ---------------------------------------------------------------------------- 57 | LET: 58 | jsr PTRGET 59 | sta FORPNT 60 | sty FORPNT+1 61 | lda #TOKEN_EQUAL 62 | jsr SYNCHR 63 | .ifndef CONFIG_SMALL 64 | lda VALTYP+1 65 | pha 66 | .endif 67 | lda VALTYP 68 | pha 69 | jsr FRMEVL 70 | pla 71 | rol a 72 | jsr CHKVAL 73 | bne LETSTRING 74 | .ifndef CONFIG_SMALL 75 | pla 76 | LET2: 77 | bpl L2923 78 | jsr ROUND_FAC 79 | jsr AYINT 80 | ldy #$00 81 | lda FAC+3 82 | sta (FORPNT),y 83 | iny 84 | lda FAC+4 85 | sta (FORPNT),y 86 | rts 87 | L2923: 88 | .endif 89 | 90 | ; ---------------------------------------------------------------------------- 91 | ; REAL VARIABLE = EXPRESSION 92 | ; ---------------------------------------------------------------------------- 93 | jmp SETFOR 94 | LETSTRING: 95 | .ifndef CONFIG_SMALL 96 | pla 97 | .endif 98 | 99 | ; ---------------------------------------------------------------------------- 100 | ; INSTALL STRING, DESCRIPTOR ADDRESS IS AT FAC+3,4 101 | ; ---------------------------------------------------------------------------- 102 | PUTSTR: 103 | .ifdef CONFIG_CBM_ALL 104 | ldy FORPNT+1 105 | .ifdef CBM1 106 | cpy #$D0 ; TI$ 107 | .else 108 | cpy #$DE 109 | .endif 110 | bne LC92B 111 | jsr FREFAC 112 | cmp #$06 113 | .ifdef CBM2 114 | bne IQERR1 115 | .else 116 | jne IQERR 117 | .endif 118 | ldy #$00 119 | sty FAC 120 | sty FACSIGN 121 | LC8E8: 122 | sty STRNG2 123 | jsr LC91C 124 | jsr MUL10 125 | inc STRNG2 126 | ldy STRNG2 127 | jsr LC91C 128 | jsr COPY_FAC_TO_ARG_ROUNDED 129 | tax 130 | beq LC902 131 | inx 132 | txa 133 | jsr LD9BF 134 | LC902: 135 | ldy STRNG2 136 | iny 137 | cpy #$06 138 | bne LC8E8 139 | jsr MUL10 140 | jsr QINT 141 | ldx #$02 142 | sei 143 | LC912: 144 | lda FAC+2,x 145 | sta TISTR,x 146 | dex 147 | bpl LC912 148 | cli 149 | rts 150 | LC91C: 151 | lda (INDEX),y 152 | jsr CHRGOT2 153 | bcc LC926 154 | IQERR1: 155 | jmp IQERR 156 | LC926: 157 | sbc #$2F 158 | jmp ADDACC 159 | LC92B: 160 | .endif 161 | ldy #$02 162 | lda (FAC_LAST-1),y 163 | cmp FRETOP+1 164 | bcc L2946 165 | bne L2938 166 | dey 167 | lda (FAC_LAST-1),y 168 | cmp FRETOP 169 | bcc L2946 170 | L2938: 171 | ldy FAC_LAST 172 | cpy VARTAB+1 173 | bcc L2946 174 | bne L294D 175 | lda FAC_LAST-1 176 | cmp VARTAB 177 | bcs L294D 178 | L2946: 179 | lda FAC_LAST-1 180 | ldy FAC_LAST 181 | jmp L2963 182 | L294D: 183 | ldy #$00 184 | lda (FAC_LAST-1),y 185 | jsr STRINI 186 | lda DSCPTR 187 | ldy DSCPTR+1 188 | sta STRNG1 189 | sty STRNG1+1 190 | jsr MOVINS 191 | lda #FAC 192 | ldy #$00 193 | L2963: 194 | sta DSCPTR 195 | sty DSCPTR+1 196 | jsr FRETMS 197 | ldy #$00 198 | lda (DSCPTR),y 199 | sta (FORPNT),y 200 | iny 201 | lda (DSCPTR),y 202 | sta (FORPNT),y 203 | iny 204 | lda (DSCPTR),y 205 | sta (FORPNT),y 206 | RET5: 207 | rts 208 | .ifdef AIM65 209 | LB89D: 210 | cmp #$21 211 | bne RET5 212 | lda #$80 213 | sta PRIFLG 214 | jmp CHRGET 215 | .endif 216 | 217 | .ifdef CONFIG_FILE 218 | PRINTH: 219 | jsr CMD 220 | jmp LCAD6 221 | CMD: 222 | jsr GETBYT 223 | beq LC98F 224 | lda #$2C 225 | jsr SYNCHR 226 | LC98F: 227 | php 228 | jsr CHKOUT 229 | stx CURDVC 230 | plp 231 | jmp PRINT 232 | .endif 233 | 234 | -------------------------------------------------------------------------------- /misc2.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; "FRE" FUNCTION 5 | ; 6 | ; COLLECTS GARBAGE AND RETURNS # BYTES OF MEMORY LEFT 7 | ; ---------------------------------------------------------------------------- 8 | FRE: 9 | lda VALTYP 10 | beq L3188 11 | jsr FREFAC 12 | L3188: 13 | jsr GARBAG 14 | sec 15 | lda FRETOP 16 | sbc STREND 17 | tay 18 | lda FRETOP+1 19 | sbc STREND+1 20 | ; FALL INTO GIVAYF TO FLOAT THE VALUE 21 | ; NOTE THAT VALUES OVER 32767 WILL RETURN AS NEGATIVE 22 | 23 | ; ---------------------------------------------------------------------------- 24 | ; FLOAT THE SIGNED INTEGER IN A,Y 25 | ; ---------------------------------------------------------------------------- 26 | GIVAYF: 27 | ldx #$00 28 | stx VALTYP 29 | sta FAC+1 30 | sty FAC+2 31 | ldx #$90 32 | jmp FLOAT1 33 | POS: 34 | ldy POSX 35 | 36 | ; ---------------------------------------------------------------------------- 37 | ; FLOAT (Y) INTO FAC, GIVING VALUE 0-255 38 | ; ---------------------------------------------------------------------------- 39 | SNGFLT: 40 | lda #$00 41 | beq GIVAYF 42 | 43 | ; ---------------------------------------------------------------------------- 44 | ; CHECK FOR DIRECT OR RUNNING MODE 45 | ; GIVING ERROR IF DIRECT MODE 46 | ; ---------------------------------------------------------------------------- 47 | ERRDIR: 48 | ldx CURLIN+1 49 | inx 50 | bne RTS9 51 | ldx #ERR_ILLDIR 52 | .ifdef CONFIG_2 53 | .byte $2C 54 | LD288: 55 | ldx #ERR_UNDEFFN 56 | .endif 57 | L31AF: 58 | jmp ERROR 59 | DEF: 60 | jsr FNC 61 | jsr ERRDIR 62 | jsr CHKOPN 63 | lda #$80 64 | sta SUBFLG 65 | jsr PTRGET 66 | jsr CHKNUM 67 | jsr CHKCLS 68 | lda #TOKEN_EQUAL 69 | jsr SYNCHR 70 | .ifndef CONFIG_SMALL 71 | pha 72 | .endif 73 | lda VARPNT+1 74 | pha 75 | lda VARPNT 76 | pha 77 | lda TXTPTR+1 78 | pha 79 | lda TXTPTR 80 | pha 81 | jsr DATA 82 | jmp L3250 83 | FNC: 84 | lda #TOKEN_FN 85 | jsr SYNCHR 86 | ora #$80 87 | sta SUBFLG 88 | jsr PTRGET3 89 | sta FNCNAM 90 | sty FNCNAM+1 91 | jmp CHKNUM 92 | L31F3: 93 | jsr FNC 94 | lda FNCNAM+1 95 | pha 96 | lda FNCNAM 97 | pha 98 | jsr PARCHK 99 | jsr CHKNUM 100 | pla 101 | sta FNCNAM 102 | pla 103 | sta FNCNAM+1 104 | ldy #$02 105 | .ifndef CONFIG_2 106 | ldx #ERR_UNDEFFN 107 | .endif 108 | lda (FNCNAM),y 109 | .ifndef CONFIG_2 110 | beq L31AF 111 | .endif 112 | sta VARPNT 113 | tax 114 | iny 115 | lda (FNCNAM),y 116 | .ifdef CONFIG_2 117 | beq LD288 118 | .endif 119 | sta VARPNT+1 120 | .ifndef CONFIG_SMALL 121 | iny 122 | .endif 123 | L3219: 124 | lda (VARPNT),y 125 | pha 126 | dey 127 | bpl L3219 128 | ldy VARPNT+1 129 | jsr STORE_FAC_AT_YX_ROUNDED 130 | lda TXTPTR+1 131 | pha 132 | lda TXTPTR 133 | pha 134 | lda (FNCNAM),y 135 | sta TXTPTR 136 | iny 137 | lda (FNCNAM),y 138 | sta TXTPTR+1 139 | lda VARPNT+1 140 | pha 141 | lda VARPNT 142 | pha 143 | jsr FRMNUM 144 | pla 145 | sta FNCNAM 146 | pla 147 | sta FNCNAM+1 148 | jsr CHRGOT 149 | beq L324A 150 | jmp SYNERR 151 | L324A: 152 | pla 153 | sta TXTPTR 154 | pla 155 | sta TXTPTR+1 156 | L3250: 157 | ldy #$00 158 | pla 159 | sta (FNCNAM),y 160 | pla 161 | iny 162 | sta (FNCNAM),y 163 | pla 164 | iny 165 | sta (FNCNAM),y 166 | pla 167 | iny 168 | sta (FNCNAM),y 169 | .ifndef CONFIG_SMALL 170 | pla 171 | iny 172 | sta (FNCNAM),y 173 | .endif 174 | rts 175 | -------------------------------------------------------------------------------- /misc3.s: -------------------------------------------------------------------------------- 1 | ; KBD specific patches 2 | 3 | .segment "CODE" 4 | 5 | .ifdef KBD 6 | VARTAB_MINUS_2_TO_AY: 7 | lda VARTAB 8 | sec 9 | sbc #$02 10 | ldy VARTAB+1 11 | bcs LF42C 12 | dey 13 | LF42C: 14 | rts 15 | 16 | ; ---------------------------------------------------------------------------- 17 | GET_UPPER: 18 | lda INPUTBUFFERX,x 19 | LF430: 20 | cmp #'a' 21 | bcc LF43A 22 | cmp #'z'+1 23 | bcs LF43A 24 | LF438: 25 | sbc #$1F 26 | LF43A: 27 | rts 28 | 29 | ; ---------------------------------------------------------------------------- 30 | GETLN: 31 | ldx #$5D 32 | LF43D: 33 | txa 34 | and #$7F 35 | cmp $0340 36 | beq LF44D 37 | sta $0340 38 | lda #$03 39 | jsr LDE48 40 | LF44D: 41 | jsr LDE7F 42 | bne RTS4 43 | cpx #$80 44 | bcc LF44D 45 | RTS4: 46 | rts 47 | 48 | ; ---------------------------------------------------------------------------- 49 | LF457: 50 | lda TXTTAB 51 | ldx TXTTAB+1 52 | LF45B: 53 | sta JMPADRS+1 54 | stx JMPADRS+2 55 | ldy #$01 56 | lda (JMPADRS+1),y 57 | beq LF438 58 | iny 59 | iny 60 | lda (JMPADRS+1),y 61 | dey 62 | cmp LINNUM+1 63 | bne LF472 64 | lda (JMPADRS+1),y 65 | cmp LINNUM 66 | LF472: 67 | bcs LF43A 68 | dey 69 | lda (JMPADRS+1),y 70 | tax 71 | dey 72 | lda (JMPADRS+1),y 73 | bcc LF45B 74 | LF47D: 75 | jmp (JMPADRS+1) 76 | .endif 77 | -------------------------------------------------------------------------------- /msbasic.s: -------------------------------------------------------------------------------- 1 | .feature force_range 2 | .debuginfo + 3 | 4 | .setcpu "6502" 5 | .macpack longbranch 6 | 7 | .include "defines.s" 8 | .include "macros.s" 9 | .include "zeropage.s" 10 | 11 | .include "header.s" 12 | .include "token.s" 13 | .include "error.s" 14 | .include "message.s" 15 | .include "memory.s" 16 | .include "program.s" 17 | .include "flow1.s" 18 | .include "loadsave.s" 19 | .include "flow2.s" 20 | .include "misc1.s" 21 | .include "print.s" 22 | .include "input.s" 23 | .include "eval.s" 24 | .include "var.s" 25 | .include "array.s" 26 | .include "misc2.s" 27 | .include "string.s" 28 | .include "misc3.s" 29 | .include "poke.s" 30 | .include "float.s" 31 | .include "chrget.s" 32 | .include "rnd.s" 33 | .include "trig.s" 34 | .include "init.s" 35 | .include "extra.s" 36 | .include "lcd.s" 37 | -------------------------------------------------------------------------------- /orig/aim65.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/aim65.bin -------------------------------------------------------------------------------- /orig/applesoft.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/applesoft.bin -------------------------------------------------------------------------------- /orig/cbmbasic1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/cbmbasic1.bin -------------------------------------------------------------------------------- /orig/cbmbasic2.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/cbmbasic2.bin -------------------------------------------------------------------------------- /orig/kb9.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/kb9.bin -------------------------------------------------------------------------------- /orig/kbdbasic.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/kbdbasic.bin -------------------------------------------------------------------------------- /orig/microtan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/microtan.bin -------------------------------------------------------------------------------- /orig/osi.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/osi.bin -------------------------------------------------------------------------------- /orig/sym1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/beneater/msbasic/e00362b6eda6ec9fdaec134a30b0ab814f26fc3e/orig/sym1.bin -------------------------------------------------------------------------------- /osi.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $A000, size = $3F00, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /osi_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | jmp MONISCNTC 4 | nop 5 | nop 6 | nop 7 | nop 8 | lsr a 9 | bcc RET2 10 | jsr GETLN 11 | cmp #$03 12 | ;!!! *used*to* run into "STOP" -------------------------------------------------------------------------------- /poke.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | .ifndef CONFIG_NO_POKE 4 | ; ---------------------------------------------------------------------------- 5 | ; EVALUATE "EXP1,EXP2" 6 | ; 7 | ; CONVERT EXP1 TO 16-BIT NUMBER IN LINNUM 8 | ; CONVERT EXP2 TO 8-BIT NUMBER IN X-REG 9 | ; ---------------------------------------------------------------------------- 10 | GTNUM: 11 | jsr FRMNUM 12 | jsr GETADR 13 | 14 | ; ---------------------------------------------------------------------------- 15 | ; EVALUATE ",EXPRESSION" 16 | ; CONVERT EXPRESSION TO SINGLE BYTE IN X-REG 17 | ; ---------------------------------------------------------------------------- 18 | COMBYTE: 19 | jsr CHKCOM 20 | jmp GETBYT 21 | 22 | ; ---------------------------------------------------------------------------- 23 | ; CONVERT (FAC) TO A 16-BIT VALUE IN LINNUM 24 | ; ---------------------------------------------------------------------------- 25 | GETADR: 26 | lda FACSIGN 27 | .ifdef APPLE 28 | nop ; PATCH 29 | nop 30 | .else 31 | bmi GOIQ 32 | .endif 33 | lda FAC 34 | cmp #$91 35 | bcs GOIQ 36 | jsr QINT 37 | lda FAC_LAST-1 38 | ldy FAC_LAST 39 | sty LINNUM 40 | sta LINNUM+1 41 | rts 42 | 43 | ; ---------------------------------------------------------------------------- 44 | ; "PEEK" FUNCTION 45 | ; ---------------------------------------------------------------------------- 46 | PEEK: 47 | .ifdef CONFIG_PEEK_SAVE_LINNUM 48 | lda LINNUM+1 49 | pha 50 | lda LINNUM 51 | pha 52 | .endif 53 | jsr GETADR 54 | ldy #$00 55 | .ifdef CBM1 56 | ; disallow PEEK between $C000 and $DFFF 57 | cmp #$C0 58 | bcc LD6F3 59 | cmp #$E1 60 | bcc LD6F6 61 | LD6F3: 62 | .endif 63 | .ifdef CBM2 64 | nop ; patch that disables the compares above 65 | nop 66 | nop 67 | nop 68 | nop 69 | nop 70 | nop 71 | nop 72 | .endif 73 | lda (LINNUM),y 74 | tay 75 | .ifdef CONFIG_PEEK_SAVE_LINNUM 76 | pla 77 | sta LINNUM 78 | pla 79 | sta LINNUM+1 80 | .endif 81 | LD6F6: 82 | jmp SNGFLT 83 | 84 | ; ---------------------------------------------------------------------------- 85 | ; "POKE" STATEMENT 86 | ; ---------------------------------------------------------------------------- 87 | POKE: 88 | jsr GTNUM 89 | txa 90 | ldy #$00 91 | sta (LINNUM),y 92 | rts 93 | 94 | ; ---------------------------------------------------------------------------- 95 | ; "WAIT" STATEMENT 96 | ; ---------------------------------------------------------------------------- 97 | WAIT: 98 | jsr GTNUM 99 | stx FORPNT 100 | ldx #$00 101 | jsr CHRGOT 102 | .ifdef CONFIG_EASTER_EGG 103 | beq EASTER_EGG 104 | .else 105 | beq L3628 106 | .endif 107 | jsr COMBYTE 108 | L3628: 109 | stx FORPNT+1 110 | ldy #$00 111 | L362C: 112 | lda (LINNUM),y 113 | eor FORPNT+1 114 | and FORPNT 115 | beq L362C 116 | RTS3: 117 | rts 118 | .endif 119 | -------------------------------------------------------------------------------- /print.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | .ifdef AIM65 4 | PRINT: 5 | lda PRIFLG 6 | sta ZBE 7 | jsr L297E 8 | LB8B1: 9 | lda ZBE 10 | sta PRIFLG 11 | rts 12 | .endif 13 | 14 | PRSTRING: 15 | jsr STRPRT 16 | L297E: 17 | jsr CHRGOT 18 | 19 | ; ---------------------------------------------------------------------------- 20 | ; "PRINT" STATEMENT 21 | ; ---------------------------------------------------------------------------- 22 | .ifndef AIM65 23 | PRINT: 24 | .endif 25 | beq CRDO 26 | PRINT2: 27 | beq L29DD 28 | .ifdef AIM65 29 | jsr LB89D 30 | beq L29DD 31 | .endif 32 | cmp #TOKEN_TAB 33 | beq L29F5 34 | cmp #TOKEN_SPC 35 | .ifdef CONFIG_2 36 | clc ; also AppleSoft II 37 | .endif 38 | beq L29F5 39 | cmp #',' 40 | ; Pre-KIM had no CLC. KIM added the CLC 41 | ; here. Post-KIM moved the CLC up... 42 | ; (makes no sense on KIM, liveness = 0) 43 | .if .def(CONFIG_11A) && (!.def(CONFIG_2)) 44 | clc 45 | .endif 46 | beq L29DE 47 | cmp #$3B 48 | beq L2A0D 49 | jsr FRMEVL 50 | bit VALTYP 51 | bmi PRSTRING 52 | jsr FOUT 53 | jsr STRLIT 54 | .ifndef CONFIG_NO_CR 55 | ldy #$00 56 | lda (FAC_LAST-1),y 57 | clc 58 | adc POSX 59 | .ifdef KBD 60 | cmp #$28 61 | .else 62 | cmp Z17 63 | .endif 64 | bcc L29B1 65 | jsr CRDO 66 | L29B1: 67 | .endif 68 | jsr STRPRT 69 | .ifdef KBD 70 | jmp L297E 71 | .else 72 | jsr OUTSP 73 | bne L297E ; branch always 74 | .endif 75 | 76 | .ifdef KBD 77 | ; PATCHES 78 | LE86C: 79 | pla 80 | jmp CONTROL_C_TYPED 81 | LE870: 82 | jsr GETBYT 83 | txa 84 | LE874: 85 | beq LE878 86 | bpl LE8F2 87 | LE878: 88 | jmp IQERR 89 | ; PATCHES 90 | .endif 91 | 92 | 93 | 94 | .ifndef KBD 95 | L29B9: 96 | .ifdef CBM2 97 | lda #$00 98 | sta INPUTBUFFER,x 99 | ldx #<(INPUTBUFFER-1) 100 | ldy #>(INPUTBUFFER-1) 101 | .else 102 | .ifndef APPLE 103 | ldy #$00 104 | sty INPUTBUFFER,x 105 | ldx #LINNUM+1 106 | .endif 107 | .if .def(MICROTAN) || .def(SYM1) 108 | bne CRDO2 109 | .endif 110 | .endif 111 | .ifdef CONFIG_FILE 112 | lda CURDVC 113 | bne L29DD 114 | .endif 115 | .endif 116 | 117 | 118 | CRDO: 119 | .if .def(CONFIG_PRINTNULLS) && .def(CONFIG_FILE) 120 | lda CURDVC 121 | bne LC9D8 122 | sta POSX 123 | LC9D8: 124 | .endif 125 | lda #CRLF_1 126 | .ifndef CONFIG_CBM_ALL 127 | sta POSX 128 | .endif 129 | jsr OUTDO 130 | CRDO2: 131 | lda #CRLF_2 132 | jsr OUTDO 133 | 134 | PRINTNULLS: 135 | .if .def(KBD) || .def(AIM65) 136 | lda #$00 137 | sta POSX 138 | eor #$FF 139 | .else 140 | .if .def(CONFIG_NULL) || .def(CONFIG_PRINTNULLS) 141 | .ifdef CONFIG_FILE 142 | ; Although there is no statement for it, 143 | ; CBM1 had NULL support and ignores 144 | ; it when not targeting the screen, 145 | ; CBM2 dropped it completely. 146 | lda CURDVC 147 | bne L29DD 148 | .endif 149 | txa 150 | pha 151 | ldx Z15 152 | beq L29D9 153 | .ifdef SYM1 154 | lda #$FF 155 | .else 156 | lda #$00 157 | .endif 158 | L29D3: 159 | jsr OUTDO 160 | dex 161 | bne L29D3 162 | L29D9: 163 | stx POSX 164 | pla 165 | tax 166 | .else 167 | .ifndef CONFIG_2 168 | lda #$00 169 | sta POSX 170 | .endif 171 | eor #$FF 172 | .endif 173 | .endif 174 | L29DD: 175 | rts 176 | L29DE: 177 | lda POSX 178 | .ifndef CONFIG_NO_CR 179 | .ifdef KBD 180 | cmp #$1A 181 | .else 182 | cmp Z18 183 | .endif 184 | bcc L29EA 185 | jsr CRDO 186 | jmp L2A0D 187 | L29EA: 188 | .endif 189 | sec 190 | L29EB: 191 | .if .def(CONFIG_CBM_ALL) || .def(AIM65) 192 | sbc #$0A 193 | .else 194 | .ifdef KBD 195 | sbc #$0D 196 | .else 197 | sbc #$0E 198 | .endif 199 | .endif 200 | bcs L29EB 201 | eor #$FF 202 | adc #$01 203 | bne L2A08 204 | L29F5: 205 | .ifdef CONFIG_11A 206 | php 207 | .else 208 | pha 209 | .endif 210 | jsr GTBYTC 211 | cmp #')' 212 | .ifdef CONFIG_11A 213 | .ifdef CONFIG_2 214 | bne SYNERR4 215 | .else 216 | jne SYNERR 217 | .endif 218 | plp 219 | bcc L2A09 220 | .else 221 | .ifdef CONFIG_11 222 | jne SYNERR 223 | .else 224 | bne SYNERR4 225 | .endif 226 | pla 227 | cmp #TOKEN_TAB 228 | .ifdef CONFIG_11 229 | bne L2A09 230 | .else 231 | bne L2A0A 232 | .endif 233 | .endif 234 | txa 235 | sbc POSX 236 | bcc L2A0D 237 | .ifndef CONFIG_11 238 | beq L2A0D 239 | .endif 240 | L2A08: 241 | tax 242 | .ifdef CONFIG_11 243 | L2A09: 244 | inx 245 | .endif 246 | L2A0A: 247 | .ifndef CONFIG_11 248 | jsr OUTSP 249 | .endif 250 | dex 251 | .ifndef CONFIG_11 252 | bne L2A0A 253 | .else 254 | bne L2A13 255 | .endif 256 | L2A0D: 257 | jsr CHRGET 258 | jmp PRINT2 259 | .ifdef CONFIG_11 260 | L2A13: 261 | jsr OUTSP 262 | bne L2A0A 263 | .endif 264 | 265 | ; ---------------------------------------------------------------------------- 266 | ; PRINT STRING AT (Y,A) 267 | ; ---------------------------------------------------------------------------- 268 | STROUT: 269 | jsr STRLIT 270 | 271 | ; ---------------------------------------------------------------------------- 272 | ; PRINT STRING AT (FACMO,FACLO) 273 | ; ---------------------------------------------------------------------------- 274 | STRPRT: 275 | jsr FREFAC 276 | tax 277 | ldy #$00 278 | inx 279 | L2A22: 280 | dex 281 | beq L29DD 282 | lda (INDEX),y 283 | jsr OUTDO 284 | iny 285 | cmp #$0D 286 | bne L2A22 287 | jsr PRINTNULLS 288 | jmp L2A22 289 | ; ---------------------------------------------------------------------------- 290 | OUTSP: 291 | .ifdef CONFIG_FILE 292 | .ifndef CBM1 293 | ; on non-screen devices, print SPACE 294 | ; instead of CRSR RIGHT 295 | lda CURDVC 296 | beq LCA40 297 | lda #$20 298 | .byte $2C 299 | LCA40: 300 | .endif 301 | lda #$1D ; CRSR RIGHT 302 | .else 303 | lda #$20 304 | .endif 305 | .byte $2C 306 | OUTQUES: 307 | lda #$3F 308 | 309 | ; ---------------------------------------------------------------------------- 310 | ; PRINT CHAR FROM (A) 311 | ; ---------------------------------------------------------------------------- 312 | OUTDO: 313 | .ifndef KBD 314 | bit Z14 315 | bmi L2A56 316 | .endif 317 | .if .def(CONFIG_PRINT_CR) || .def(CBM1) 318 | ; Commodore forgot to remove this in CBM1 319 | pha 320 | .endif 321 | .ifdef CBM1 322 | cmp #$1D ; CRSR RIGHT 323 | beq LCA6A 324 | cmp #$9D ; CRSR LEFT 325 | beq LCA5A 326 | cmp #$14 ; DEL 327 | bne LCA64 328 | LCA5A: 329 | lda POSX 330 | beq L2A4E 331 | lda CURDVC 332 | bne L2A4E 333 | dec POSX 334 | LCA64: 335 | and #$7F 336 | .endif 337 | .ifndef CBM2 338 | cmp #$20 339 | bcc L2A4E 340 | .endif 341 | LCA6A: 342 | .ifdef CONFIG_CBM1_PATCHES 343 | lda CURDVC 344 | jsr PATCH6 345 | nop 346 | .endif 347 | .ifdef CONFIG_PRINT_CR 348 | lda POSX 349 | cmp Z17 350 | bne L2A4C 351 | .ifdef AIM65 352 | lda #$00 353 | sta POSX 354 | .elseif .def(APPLE) 355 | nop ; PATCH! 356 | nop ; don't print CR 357 | nop 358 | .else 359 | jsr CRDO 360 | .endif 361 | L2A4C: 362 | .endif 363 | .ifndef CONFIG_CBM_ALL 364 | inc POSX 365 | .endif 366 | L2A4E: 367 | .if .def(CONFIG_PRINT_CR) || .def(CBM1) 368 | ; Commodore forgot to remove this in CBM1 369 | pla 370 | .endif 371 | .ifdef CONFIG_MONCOUT_DESTROYS_Y 372 | sty DIMFLG 373 | .endif 374 | .ifdef CONFIG_IO_MSB 375 | ora #$80 376 | .endif 377 | jsr MONCOUT 378 | .ifdef CONFIG_IO_MSB 379 | and #$7F 380 | .endif 381 | .ifdef CONFIG_MONCOUT_DESTROYS_Y 382 | ldy DIMFLG 383 | .endif 384 | .ifdef OSI 385 | nop 386 | nop 387 | nop 388 | nop 389 | .endif 390 | L2A56: 391 | and #$FF 392 | LE8F2: 393 | rts 394 | 395 | ; ---------------------------------------------------------------------------- 396 | ; ??? 397 | ; ---------------------------------------------------------------------------- 398 | .ifdef KBD 399 | LE8F3: 400 | pha 401 | lda $047F 402 | clc 403 | beq LE900 404 | lda #$00 405 | sta $047F 406 | sec 407 | LE900: 408 | pla 409 | rts 410 | .endif 411 | -------------------------------------------------------------------------------- /regress.sh: -------------------------------------------------------------------------------- 1 | if [ ! -d orig ]; then 2 | echo Please first run make.sh on the original .s files, create 3 | echo the directory \"orig\", and copy all .bin files from \"tmp\" 4 | echo into \"orig\". 5 | exit; 6 | fi 7 | 8 | for i in cbmbasic1 cbmbasic2 kbdbasic osi kb9 applesoft microtan aim65 sym1; do 9 | 10 | echo $i 11 | ca65 -D $i msbasic.s -o tmp/$i.o && 12 | ld65 -C $i.cfg tmp/$i.o -o tmp/$i-new.bin -Ln tmp/$i.lbl && 13 | xxd -g 1 orig/$i.bin > tmp/$i.bin.txt 14 | xxd -g 1 tmp/$i-new.bin > tmp/$i-new.bin.txt 15 | diff -u tmp/$i.bin.txt tmp/$i-new.bin.txt | head 16 | 17 | done 18 | -------------------------------------------------------------------------------- /rnd.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; "RND" FUNCTION 5 | ; ---------------------------------------------------------------------------- 6 | 7 | .ifdef KBD 8 | RND: 9 | ldx #$10 10 | jsr SIGN 11 | beq LFC26 12 | bmi LFC10 13 | lda RNDSEED 14 | ldy RNDSEED+1 15 | LFBFA: 16 | sta FAC+2 17 | sty FAC+1 18 | LFBFE: 19 | asl a 20 | asl a 21 | eor FAC+2 22 | asl a 23 | eor FAC+1 24 | asl a 25 | asl a 26 | asl a 27 | asl a 28 | eor FAC+1 29 | asl a 30 | rol FAC+2 31 | rol FAC+1 32 | LFC10: 33 | lda FAC+2 34 | dex 35 | bne LFBFE 36 | sta RNDSEED 37 | sta FAC+3 38 | lda FAC+1 39 | sta RNDSEED+1 40 | lda #$80 41 | sta FAC 42 | stx FACSIGN 43 | jmp NORMALIZE_FAC2 44 | LFC26: 45 | ldy $03CA 46 | lda $03C7 47 | ora #$01 48 | GOMOVMF: 49 | bne LFBFA 50 | .byte $F0 51 | .else 52 | ; <<< THESE ARE MISSING ONE BYTE FOR FP VALUES >>> 53 | ; (non CONFIG_SMALL) 54 | CONRND1: 55 | .byte $98,$35,$44,$7A 56 | CONRND2: 57 | .byte $68,$28,$B1,$46 58 | RND: 59 | jsr SIGN 60 | .ifdef CONFIG_CBM_ALL 61 | bmi L3F01 62 | bne LDF63 63 | lda ENTROPY 64 | sta FAC+1 65 | lda ENTROPY+4 66 | sta FAC+2 67 | lda ENTROPY+1 68 | sta FAC+3 69 | lda ENTROPY+5 70 | sta FAC+4 71 | jmp LDF88 72 | LDF63: 73 | .else 74 | tax 75 | bmi L3F01 76 | .endif 77 | lda #RNDSEED 79 | jsr LOAD_FAC_FROM_YA 80 | .ifndef CONFIG_CBM_ALL 81 | txa 82 | beq RTS19 83 | .endif 84 | lda #CONRND1 86 | jsr FMULT 87 | lda #CONRND2 89 | jsr FADD 90 | L3F01: 91 | ldx FAC_LAST 92 | lda FAC+1 93 | sta FAC_LAST 94 | stx FAC+1 95 | .ifdef CONFIG_CBM_ALL 96 | ldx FAC+2 97 | lda FAC+3 98 | sta FAC+2 99 | stx FAC+3 100 | LDF88: 101 | .endif 102 | lda #$00 103 | sta FACSIGN 104 | lda FAC 105 | sta FACEXTENSION 106 | lda #$80 107 | sta FAC 108 | jsr NORMALIZE_FAC2 109 | ldx #RNDSEED 111 | GOMOVMF: 112 | jmp STORE_FAC_AT_YX_ROUNDED 113 | .endif 114 | 115 | .segment "CHRGET" 116 | ; ---------------------------------------------------------------------------- 117 | ; INITIAL VALUE FOR RANDOM NUMBER, ALSO COPIED 118 | ; IN ALONG WITH CHRGET, BUT ERRONEOUSLY: 119 | ; <<< THE LAST BYTE IS NOT COPIED >>> 120 | ; (on all non-CONFIG_SMALL) 121 | ; ---------------------------------------------------------------------------- 122 | GENERIC_RNDSEED: 123 | .ifndef KBD 124 | ; random number seed 125 | .ifdef CONFIG_SMALL 126 | .byte $80,$4F,$C7,$52 127 | .else 128 | .ifdef CONFIG_11 129 | .byte $80,$4F,$C7,$52,$58 130 | .else 131 | .byte $80,$4F,$C7,$52,$59 132 | .endif 133 | .endif 134 | .endif 135 | GENERIC_CHRGET_END: 136 | -------------------------------------------------------------------------------- /sym1.cfg: -------------------------------------------------------------------------------- 1 | MEMORY { 2 | ZP: start = $0000, size = $0100, type = rw; 3 | BASROM: start = $C000, size = $2000, fill = no, file = %O; 4 | DUMMY: start = $0000, size = $00FF, file = ""; 5 | } 6 | 7 | SEGMENTS { 8 | ZEROPAGE: load = ZP, type = zp; 9 | HEADER: load = BASROM, type = ro; 10 | VECTORS: load = BASROM, type = ro; 11 | KEYWORDS: load = BASROM, type = ro; 12 | ERROR: load = BASROM, type = ro; 13 | CODE: load = BASROM, type = ro; 14 | CHRGET: load = BASROM, type = ro; 15 | INIT: load = BASROM, type = ro; 16 | EXTRA: load = BASROM, type = ro; 17 | DUMMY: load = DUMMY; # don't include 18 | } 19 | 20 | -------------------------------------------------------------------------------- /sym1_iscntc.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | ISCNTC: 3 | jsr INSTAT 4 | bcc RET1 5 | 6 | lda #$03 7 | cmp #$03 8 | ;!!! runs into "STOP" -------------------------------------------------------------------------------- /sym1_loadsave.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | SAVE: 4 | beq L2739 5 | sta P1L 6 | jsr CHRGET 7 | bne NULL-1 8 | 9 | lda TXTTAB 10 | ldy TXTTAB+1 11 | sta P2L 12 | sty P2H 13 | 14 | lda VARTAB 15 | ldy VARTAB+1 16 | sta P3L 17 | sty P3H 18 | 19 | ldy #$80 20 | jsr USR2 21 | bcs LC6DD 22 | lda #SAVED 24 | jmp STROUT 25 | 26 | LOADED: 27 | .byte "LOADED",CR,LF 28 | .byte "OK",CR,LF,0 29 | 30 | SAVED: 31 | .byte "SAVED",CR,LF,0 32 | 33 | LOAD: 34 | beq L2739 35 | sta $A64E 36 | jsr CHRGET 37 | bne L2738 38 | ldy #$80 39 | jsr USR3 40 | bcs LC6EF 41 | 42 | lda #LOADED 44 | jsr STROUT 45 | 46 | ldx P3L 47 | ldy P3H 48 | txa 49 | stx VARTAB 50 | sty VARTAB+1 51 | jmp FIX_LINKS 52 | 53 | LC6DD: 54 | lda #BAD_SAVE 56 | jmp STROUT 57 | 58 | BAD_SAVE: 59 | htasc "BAD SAVE" 60 | .byte CR,LF,0 61 | LC6EF: 62 | lda #BAD_LOAD 64 | jsr STROUT 65 | jsr SCRTCH 66 | jmp RESTART 67 | 68 | BAD_LOAD: 69 | htasc "BAD LOAD" 70 | .byte CR,LF,0 71 | -------------------------------------------------------------------------------- /token.s: -------------------------------------------------------------------------------- 1 | init_token_tables 2 | 3 | keyword_rts "END", END 4 | keyword_rts "FOR", FOR 5 | keyword_rts "NEXT", NEXT 6 | keyword_rts "DATA", DATA 7 | .ifdef CONFIG_FILE 8 | keyword_rts "INPUT#", INPUTH 9 | .endif 10 | keyword_rts "INPUT", INPUT 11 | keyword_rts "DIM", DIM 12 | keyword_rts "READ", READ 13 | .ifdef APPLE 14 | keyword_rts "PLT", PLT 15 | .else 16 | keyword_rts "LET", LET 17 | .endif 18 | keyword_rts "GOTO", GOTO, TOKEN_GOTO 19 | keyword_rts "RUN", RUN 20 | keyword_rts "IF", IF 21 | keyword_rts "RESTORE", RESTORE 22 | keyword_rts "GOSUB", GOSUB, TOKEN_GOSUB 23 | keyword_rts "RETURN", POP 24 | .ifdef APPLE 25 | keyword_rts "TEX", TEX, TOKEN_REM 26 | .else 27 | keyword_rts "REM", REM, TOKEN_REM 28 | .endif 29 | keyword_rts "STOP", STOP 30 | keyword_rts "ON", ON 31 | .ifdef CONFIG_NULL 32 | keyword_rts "NULL", NULL 33 | .endif 34 | .ifdef KBD 35 | keyword_rts "PLOD", PLOD 36 | keyword_rts "PSAV", PSAV 37 | keyword_rts "VLOD", VLOD 38 | keyword_rts "VSAV", VSAV 39 | .endif 40 | .ifndef CONFIG_NO_POKE 41 | keyword_rts "WAIT", WAIT 42 | .endif 43 | .ifndef KBD 44 | keyword_rts "LOAD", LOAD 45 | keyword_rts "SAVE", SAVE 46 | .endif 47 | .ifdef CONFIG_CBM_ALL 48 | keyword_rts "VERIFY", VERIFY 49 | .endif 50 | keyword_rts "DEF", DEF 51 | .ifdef KBD 52 | keyword_rts "SLOD", SLOD 53 | .endif 54 | .ifndef CONFIG_NO_POKE 55 | keyword_rts "POKE", POKE 56 | .endif 57 | .ifdef CONFIG_FILE 58 | keyword_rts "PRINT#", PRINTH 59 | .endif 60 | keyword_rts "PRINT", PRINT, TOKEN_PRINT 61 | keyword_rts "CONT", CONT 62 | keyword_rts "LIST", LIST 63 | .ifdef CONFIG_CBM_ALL 64 | keyword_rts "CLR", CLEAR 65 | .else 66 | keyword_rts "CLEAR", CLEAR 67 | .endif 68 | .ifdef CONFIG_FILE 69 | keyword_rts "CMD", CMD 70 | keyword_rts "SYS", SYS 71 | keyword_rts "OPEN", OPEN 72 | keyword_rts "CLOSE", CLOSE 73 | .endif 74 | .ifndef CONFIG_SMALL 75 | keyword_rts "GET", GET 76 | .endif 77 | .ifdef KBD 78 | keyword_rts "PRT", PRT 79 | .endif 80 | keyword_rts "NEW", NEW 81 | .ifdef EATER 82 | keyword_rts "LCDCMD", LCDCMD 83 | keyword_rts "LCDPRINT", LCDPRINT 84 | .endif 85 | 86 | count_tokens 87 | 88 | keyword "TAB(", TOKEN_TAB 89 | keyword "TO", TOKEN_TO 90 | keyword "FN", TOKEN_FN 91 | keyword "SPC(", TOKEN_SPC 92 | keyword "THEN", TOKEN_THEN 93 | keyword "NOT", TOKEN_NOT 94 | keyword "STEP", TOKEN_STEP 95 | keyword "+", TOKEN_PLUS 96 | keyword "-", TOKEN_MINUS 97 | keyword "*" 98 | keyword "/" 99 | .ifdef KBD 100 | keyword "#" 101 | .else 102 | keyword "^" 103 | .endif 104 | keyword "AND" 105 | keyword "OR" 106 | keyword ">", TOKEN_GREATER 107 | keyword "=", TOKEN_EQUAL 108 | keyword "<" 109 | 110 | .segment "VECTORS" 111 | UNFNC: 112 | 113 | keyword_addr "SGN", SGN, TOKEN_SGN 114 | keyword_addr "INT", INT 115 | keyword_addr "ABS", ABS 116 | .ifdef KBD 117 | keyword_addr "VER", VER 118 | .endif 119 | .ifndef CONFIG_NO_POKE 120 | .ifdef CONFIG_RAM 121 | keyword_addr "USR", IQERR 122 | .else 123 | keyword_addr "USR", USR, TOKEN_USR 124 | .endif 125 | .endif 126 | keyword_addr "FRE", FRE 127 | keyword_addr "POS", POS 128 | keyword_addr "SQR", SQR 129 | keyword_addr "RND", RND 130 | keyword_addr "LOG", LOG 131 | keyword_addr "EXP", EXP 132 | .segment "VECTORS" 133 | UNFNC_COS: 134 | keyword_addr "COS", COS 135 | .segment "VECTORS" 136 | UNFNC_SIN: 137 | keyword_addr "SIN", SIN 138 | .segment "VECTORS" 139 | UNFNC_TAN: 140 | keyword_addr "TAN", TAN 141 | .segment "VECTORS" 142 | UNFNC_ATN: 143 | keyword_addr "ATN", ATN 144 | .ifdef KBD 145 | keyword_addr "GETC", GETC 146 | .endif 147 | .ifndef CONFIG_NO_POKE 148 | keyword_addr "PEEK", PEEK 149 | .endif 150 | keyword_addr "LEN", LEN 151 | keyword_addr "STR$", STR 152 | keyword_addr "VAL", VAL 153 | keyword_addr "ASC", ASC 154 | keyword_addr "CHR$", CHRSTR 155 | keyword_addr "LEFT$", LEFTSTR, TOKEN_LEFTSTR 156 | keyword_addr "RIGHT$", RIGHTSTR 157 | keyword_addr "MID$", MIDSTR 158 | .ifdef CONFIG_2 159 | keyword "GO", TOKEN_GO 160 | .endif 161 | .segment "KEYWORDS" 162 | .byte 0 163 | 164 | .segment "VECTORS" 165 | MATHTBL: 166 | .byte $79 167 | .word FADDT-1 168 | .byte $79 169 | .word FSUBT-1 170 | .byte $7B 171 | .word FMULTT-1 172 | .byte $7B 173 | .word FDIVT-1 174 | .byte $7F 175 | .word FPWRT-1 176 | .byte $50 177 | .word TAND-1 178 | .byte $46 179 | .word OR-1 180 | .byte $7D 181 | .word NEGOP-1 182 | .byte $5A 183 | .word EQUOP-1 184 | .byte $64 185 | .word RELOPS-1 186 | -------------------------------------------------------------------------------- /trig.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | .ifndef SYM1 4 | SIN_COS_TAN_ATN: 5 | ; ---------------------------------------------------------------------------- 6 | ; "COS" FUNCTION 7 | ; ---------------------------------------------------------------------------- 8 | COS: 9 | lda #CON_PI_HALF 11 | jsr FADD 12 | 13 | ; ---------------------------------------------------------------------------- 14 | ; "SIN" FUNCTION 15 | ; ---------------------------------------------------------------------------- 16 | SIN: 17 | jsr COPY_FAC_TO_ARG_ROUNDED 18 | lda #CON_PI_DOUB 20 | ldx ARGSIGN 21 | jsr DIV 22 | jsr COPY_FAC_TO_ARG_ROUNDED 23 | jsr INT 24 | lda #$00 25 | sta STRNG1 26 | jsr FSUBT 27 | ; ---------------------------------------------------------------------------- 28 | ; (FAC) = ANGLE AS A FRACTION OF A FULL CIRCLE 29 | ; 30 | ; NOW FOLD THE RANGE INTO A QUARTER CIRCLE 31 | ; 32 | ; <<< THERE ARE MUCH SIMPLER WAYS TO DO THIS >>> 33 | ; ---------------------------------------------------------------------------- 34 | lda #QUARTER 36 | jsr FSUB 37 | lda FACSIGN 38 | pha 39 | bpl SIN1 40 | jsr FADDH 41 | lda FACSIGN 42 | bmi L3F5B 43 | lda CPRMASK 44 | eor #$FF 45 | sta CPRMASK 46 | ; ---------------------------------------------------------------------------- 47 | ; IF FALL THRU, RANGE IS 0...1/2 48 | ; IF BRANCH HERE, RANGE IS 0...1/4 49 | ; ---------------------------------------------------------------------------- 50 | SIN1: 51 | jsr NEGOP 52 | ; ---------------------------------------------------------------------------- 53 | ; IF FALL THRU, RANGE IS -1/2...0 54 | ; IF BRANCH HERE, RANGE IS -1/4...0 55 | ; ---------------------------------------------------------------------------- 56 | L3F5B: 57 | lda #QUARTER 59 | jsr FADD 60 | pla 61 | bpl L3F68 62 | jsr NEGOP 63 | L3F68: 64 | lda #POLY_SIN 66 | jmp POLYNOMIAL_ODD 67 | 68 | ; ---------------------------------------------------------------------------- 69 | ; "TAN" FUNCTION 70 | ; 71 | ; COMPUTE TAN(X) = SIN(X) / COS(X) 72 | ; ---------------------------------------------------------------------------- 73 | TAN: 74 | jsr STORE_FAC_IN_TEMP1_ROUNDED 75 | lda #$00 76 | sta CPRMASK 77 | jsr SIN 78 | ldx #TEMP3 79 | ldy #$00 80 | jsr GOMOVMF 81 | lda #TEMP1+(5-BYTES_FP) 82 | ldy #$00 83 | jsr LOAD_FAC_FROM_YA 84 | lda #$00 85 | sta FACSIGN 86 | lda CPRMASK 87 | jsr TAN1 88 | lda #TEMP3 89 | ldy #$00 90 | jmp FDIV 91 | TAN1: 92 | pha 93 | jmp SIN1 94 | 95 | ; ---------------------------------------------------------------------------- 96 | .ifdef CONFIG_SMALL 97 | CON_PI_HALF: 98 | .byte $81,$49,$0F,$DB 99 | CON_PI_DOUB: 100 | .byte $83,$49,$0F,$DB 101 | QUARTER: 102 | .byte $7F,$00,$00,$00 103 | POLY_SIN: 104 | .byte $04,$86,$1E,$D7,$FB,$87,$99,$26 105 | .byte $65,$87,$23,$34,$58,$86,$A5,$5D 106 | .byte $E1,$83,$49,$0F,$DB 107 | .else 108 | CON_PI_HALF: 109 | .byte $81,$49,$0F,$DA,$A2 110 | CON_PI_DOUB: 111 | .byte $83,$49,$0F,$DA,$A2 112 | QUARTER: 113 | .byte $7F,$00,$00,$00,$00 114 | POLY_SIN: 115 | .byte $05,$84,$E6,$1A,$2D,$1B,$86,$28 116 | .byte $07,$FB,$F8,$87,$99,$68,$89,$01 117 | .byte $87,$23,$35,$DF,$E1,$86,$A5,$5D 118 | .byte $E7,$28,$83,$49,$0F,$DA,$A2 119 | .ifndef CONFIG_11 120 | ; no easter egg text before BASIC 1.1 121 | .elseif !.def(CONFIG_2A) 122 | ; ASCII encoded easter egg 123 | MICROSOFT: 124 | .byte $A6,$D3,$C1,$C8,$D4,$C8,$D5,$C4 125 | .byte $CE,$CA 126 | .else 127 | ; PET encoded easter egg text since CBM2 128 | MICROSOFT: 129 | .byte $A1,$54,$46,$8F,$13,$8F,$52,$43 130 | .byte $89,$CD 131 | .endif 132 | .endif 133 | 134 | .ifndef AIM65 135 | ; ---------------------------------------------------------------------------- 136 | ; "ATN" FUNCTION 137 | ; ---------------------------------------------------------------------------- 138 | ATN: 139 | lda FACSIGN 140 | pha 141 | bpl L3FDB 142 | jsr NEGOP 143 | L3FDB: 144 | lda FAC 145 | pha 146 | cmp #$81 147 | bcc L3FE9 148 | lda #CON_ONE 150 | jsr FDIV 151 | ; ---------------------------------------------------------------------------- 152 | ; 0 <= X <= 1 153 | ; 0 <= ATN(X) <= PI/8 154 | ; ---------------------------------------------------------------------------- 155 | L3FE9: 156 | lda #POLY_ATN 158 | jsr POLYNOMIAL_ODD 159 | pla 160 | cmp #$81 161 | bcc L3FFC 162 | lda #CON_PI_HALF 164 | jsr FSUB 165 | L3FFC: 166 | pla 167 | bpl L4002 168 | jmp NEGOP 169 | L4002: 170 | rts 171 | 172 | ; ---------------------------------------------------------------------------- 173 | POLY_ATN: 174 | .ifdef CONFIG_SMALL 175 | .byte $08 176 | .byte $78,$3A,$C5,$37 177 | .byte $7B,$83,$A2,$5C 178 | .byte $7C,$2E,$DD,$4D 179 | .byte $7D,$99,$B0,$1E 180 | .byte $7D,$59,$ED,$24 181 | .byte $7E,$91,$72,$00 182 | .byte $7E,$4C,$B9,$73 183 | .byte $7F,$AA,$AA,$53 184 | .byte $81,$00,$00,$00 185 | .else 186 | .byte $0B 187 | .byte $76,$B3,$83,$BD,$D3 188 | .byte $79,$1E,$F4,$A6,$F5 189 | .byte $7B,$83,$FC,$B0,$10 190 | .byte $7C,$0C,$1F,$67,$CA 191 | .byte $7C,$DE,$53,$CB,$C1 192 | .byte $7D,$14,$64,$70,$4C 193 | .byte $7D,$B7,$EA,$51,$7A 194 | .byte $7D,$63,$30,$88,$7E 195 | .byte $7E,$92,$44,$99,$3A 196 | .byte $7E,$4C,$CC,$91,$C7 197 | .byte $7F,$AA,$AA,$AA,$13 198 | .byte $81,$00,$00,$00,$00 199 | .endif 200 | 201 | .if .def(CONFIG_11A) && (!.def(CONFIG_2)) 202 | .byte $00 ; XXX 203 | .endif 204 | .endif 205 | .endif -------------------------------------------------------------------------------- /var.s: -------------------------------------------------------------------------------- 1 | .segment "CODE" 2 | 3 | ; ---------------------------------------------------------------------------- 4 | ; "DIM" STATEMENT 5 | ; ---------------------------------------------------------------------------- 6 | NXDIM: 7 | jsr CHKCOM 8 | DIM: 9 | tax 10 | jsr PTRGET2 11 | jsr CHRGOT 12 | bne NXDIM 13 | rts 14 | 15 | ; ---------------------------------------------------------------------------- 16 | ; PTRGET -- GENERAL VARIABLE SCAN 17 | ; 18 | ; SCANS VARIABLE NAME AT TXTPTR, AND SEARCHES THE 19 | ; VARTAB AND ARYTAB FOR THE NAME. 20 | ; IF NOT FOUND, CREATE VARIABLE OF APPROPRIATE TYPE. 21 | ; RETURN WITH ADDRESS IN VARPNT AND Y,A 22 | ; 23 | ; ACTUAL ACTIVITY CONTROLLED SOMEWHAT BY TWO FLAGS: 24 | ; DIMFLG -- NONZERO IF CALLED FROM "DIM" 25 | ; ELSE = 0 26 | ; 27 | ; SUBFLG -- = $00 28 | ; = $40 IF CALLED FROM "GETARYPT" 29 | ; ---------------------------------------------------------------------------- 30 | PTRGET: 31 | ldx #$00 32 | jsr CHRGOT 33 | PTRGET2: 34 | stx DIMFLG 35 | PTRGET3: 36 | sta VARNAM 37 | jsr CHRGOT 38 | jsr ISLETC 39 | bcs NAMOK 40 | SYNERR3: 41 | jmp SYNERR 42 | NAMOK: 43 | ldx #$00 44 | stx VALTYP 45 | .ifndef CONFIG_SMALL 46 | stx VALTYP+1 47 | .endif 48 | jsr CHRGET 49 | bcc L2ECD 50 | jsr ISLETC 51 | bcc L2ED8 52 | L2ECD: 53 | tax 54 | L2ECE: 55 | jsr CHRGET 56 | bcc L2ECE 57 | jsr ISLETC 58 | bcs L2ECE 59 | L2ED8: 60 | cmp #$24 61 | .ifdef CONFIG_SMALL 62 | bne L2EF9 63 | .else 64 | bne L2EE2 65 | .endif 66 | lda #$FF 67 | sta VALTYP 68 | .ifndef CONFIG_SMALL 69 | bne L2EF2 70 | L2EE2: 71 | cmp #$25 72 | bne L2EF9 73 | lda SUBFLG 74 | bne SYNERR3 75 | lda #$80 76 | sta VALTYP+1 77 | ora VARNAM 78 | sta VARNAM 79 | L2EF2: 80 | .endif 81 | txa 82 | ora #$80 83 | tax 84 | jsr CHRGET 85 | L2EF9: 86 | stx VARNAM+1 87 | sec 88 | ora SUBFLG 89 | sbc #$28 90 | bne L2F05 91 | jmp ARRAY 92 | L2F05: 93 | lda #$00 94 | sta SUBFLG 95 | lda VARTAB 96 | ldx VARTAB+1 97 | ldy #$00 98 | L2F0F: 99 | stx LOWTR+1 100 | L2F11: 101 | sta LOWTR 102 | cpx ARYTAB+1 103 | bne L2F1B 104 | cmp ARYTAB 105 | beq NAMENOTFOUND 106 | L2F1B: 107 | lda VARNAM 108 | cmp (LOWTR),y 109 | bne L2F29 110 | lda VARNAM+1 111 | iny 112 | cmp (LOWTR),y 113 | beq SET_VARPNT_AND_YA 114 | dey 115 | L2F29: 116 | clc 117 | lda LOWTR 118 | adc #BYTES_PER_VARIABLE 119 | bcc L2F11 120 | inx 121 | bne L2F0F 122 | 123 | ; ---------------------------------------------------------------------------- 124 | ; CHECK IF (A) IS ASCII LETTER A-Z 125 | ; 126 | ; RETURN CARRY = 1 IF A-Z 127 | ; = 0 IF NOT 128 | ; ---------------------------------------------------------------------------- 129 | ISLETC: 130 | cmp #$41 131 | bcc L2F3C 132 | sbc #$5B 133 | sec 134 | sbc #$A5 135 | L2F3C: 136 | rts 137 | 138 | ; ---------------------------------------------------------------------------- 139 | ; VARIABLE NOT FOUND, SO MAKE ONE 140 | ; ---------------------------------------------------------------------------- 141 | NAMENOTFOUND: 142 | pla 143 | pha 144 | cmp #FRM_VARIABLE_CALL 150 | bne MAKENEWVARIABLE 151 | .endif 152 | LD015: 153 | lda #C_ZERO 155 | rts 156 | 157 | ; ---------------------------------------------------------------------------- 158 | .ifndef CONFIG_2 159 | C_ZERO: 160 | .byte $00,$00 161 | .endif 162 | 163 | ; ---------------------------------------------------------------------------- 164 | ; MAKE A NEW SIMPLE VARIABLE 165 | ; 166 | ; MOVE ARRAYS UP 7 BYTES TO MAKE ROOM FOR NEW VARIABLE 167 | ; ENTER 7-BYTE VARIABLE DATA IN THE HOLE 168 | ; ---------------------------------------------------------------------------- 169 | MAKENEWVARIABLE: 170 | .ifdef CONFIG_CBM_ALL 171 | lda VARNAM 172 | ldy VARNAM+1 173 | cmp #$54 174 | bne LD02F 175 | cpy #$C9 176 | beq LD015 177 | cpy #$49 178 | bne LD02F 179 | LD02C: 180 | jmp SYNERR 181 | LD02F: 182 | cmp #$53 183 | bne LD037 184 | cpy #$54 185 | beq LD02C 186 | LD037: 187 | .endif 188 | lda ARYTAB 189 | ldy ARYTAB+1 190 | sta LOWTR 191 | sty LOWTR+1 192 | lda STREND 193 | ldy STREND+1 194 | sta HIGHTR 195 | sty HIGHTR+1 196 | clc 197 | adc #BYTES_PER_VARIABLE 198 | bcc L2F68 199 | iny 200 | L2F68: 201 | sta HIGHDS 202 | sty HIGHDS+1 203 | jsr BLTU 204 | lda HIGHDS 205 | ldy HIGHDS+1 206 | iny 207 | sta ARYTAB 208 | sty ARYTAB+1 209 | ldy #$00 210 | lda VARNAM 211 | sta (LOWTR),y 212 | iny 213 | lda VARNAM+1 214 | sta (LOWTR),y 215 | lda #$00 216 | iny 217 | sta (LOWTR),y 218 | iny 219 | sta (LOWTR),y 220 | iny 221 | sta (LOWTR),y 222 | iny 223 | sta (LOWTR),y 224 | .ifndef CONFIG_SMALL 225 | iny 226 | sta (LOWTR),y 227 | .endif 228 | 229 | ; ---------------------------------------------------------------------------- 230 | ; PUT ADDRESS OF VALUE OF VARIABLE IN VARPNT AND Y,A 231 | ; ---------------------------------------------------------------------------- 232 | SET_VARPNT_AND_YA: 233 | lda LOWTR 234 | clc 235 | adc #$02 236 | ldy LOWTR+1 237 | bcc L2F9E 238 | iny 239 | L2F9E: 240 | sta VARPNT 241 | sty VARPNT+1 242 | rts 243 | -------------------------------------------------------------------------------- /wozmon.s: -------------------------------------------------------------------------------- 1 | .setcpu "65C02" 2 | .segment "WOZMON" 3 | 4 | XAML = $24 ; Last "opened" location Low 5 | XAMH = $25 ; Last "opened" location High 6 | STL = $26 ; Store address Low 7 | STH = $27 ; Store address High 8 | L = $28 ; Hex value parsing Low 9 | H = $29 ; Hex value parsing High 10 | YSAV = $2A ; Used to see if hex value is given 11 | MODE = $2B ; $00=XAM, $7F=STOR, $AE=BLOCK XAM 12 | 13 | IN = $0200 ; Input buffer 14 | 15 | RESET: 16 | CLD ; Clear decimal arithmetic mode. 17 | JSR INIT_BUFFER 18 | CLI 19 | LDA #$1F ; 8-N-1, 19200 bps 20 | STA ACIA_CTRL 21 | LDY #$89 ; No parity, no echo, rx interrupts. 22 | STY ACIA_CMD 23 | 24 | NOTCR: 25 | CMP #$08 ; Backspace key? 26 | BEQ BACKSPACE ; Yes. 27 | CMP #$1B ; ESC? 28 | BEQ ESCAPE ; Yes. 29 | INY ; Advance text index. 30 | BPL NEXTCHAR ; Auto ESC if line longer than 127. 31 | 32 | ESCAPE: 33 | LDA #$5C ; "\". 34 | JSR ECHO ; Output it. 35 | 36 | GETLINE: 37 | LDA #$0D ; Send CR 38 | JSR ECHO 39 | LDA #$0A ; Send LF 40 | JSR ECHO 41 | 42 | LDY #$01 ; Initialize text index. 43 | BACKSPACE: DEY ; Back up text index. 44 | BMI GETLINE ; Beyond start of line, reinitialize. 45 | 46 | NEXTCHAR: 47 | JSR CHRIN 48 | BCC NEXTCHAR 49 | STA IN,Y ; Add to text buffer. 50 | CMP #$0D ; CR? 51 | BNE NOTCR ; No. 52 | 53 | LDY #$FF ; Reset text index. 54 | LDA #$00 ; For XAM mode. 55 | TAX ; X=0. 56 | SETBLOCK: 57 | ASL 58 | SETSTOR: 59 | ASL ; Leaves $7B if setting STOR mode. 60 | SETMODE: 61 | STA MODE ; $00 = XAM, $74 = STOR, $B8 = BLOK XAM. 62 | BLSKIP: 63 | INY ; Advance text index. 64 | NEXTITEM: 65 | LDA IN,Y ; Get character. 66 | CMP #$0D ; CR? 67 | BEQ GETLINE ; Yes, done this line. 68 | CMP #$2E ; "."? 69 | BCC BLSKIP ; Skip delimiter. 70 | BEQ SETBLOCK ; Set BLOCK XAM mode. 71 | CMP #$3A ; ":"? 72 | BEQ SETSTOR ; Yes, set STOR mode. 73 | CMP #$52 ; "R"? 74 | BEQ RUNPROG ; Yes, run user program. 75 | STX L ; $00 -> L. 76 | STX H ; and H. 77 | STY YSAV ; Save Y for comparison 78 | 79 | NEXTHEX: 80 | LDA IN,Y ; Get character for hex test. 81 | EOR #$30 ; Map digits to $0-9. 82 | CMP #$0A ; Digit? 83 | BCC DIG ; Yes. 84 | ADC #$88 ; Map letter "A"-"F" to $FA-FF. 85 | CMP #$FA ; Hex letter? 86 | BCC NOTHEX ; No, character not hex. 87 | DIG: 88 | ASL 89 | ASL ; Hex digit to MSD of A. 90 | ASL 91 | ASL 92 | 93 | LDX #$04 ; Shift count. 94 | HEXSHIFT: 95 | ASL ; Hex digit left, MSB to carry. 96 | ROL L ; Rotate into LSD. 97 | ROL H ; Rotate into MSD's. 98 | DEX ; Done 4 shifts? 99 | BNE HEXSHIFT ; No, loop. 100 | INY ; Advance text index. 101 | BNE NEXTHEX ; Always taken. Check next character for hex. 102 | 103 | NOTHEX: 104 | CPY YSAV ; Check if L, H empty (no hex digits). 105 | BEQ ESCAPE ; Yes, generate ESC sequence. 106 | 107 | BIT MODE ; Test MODE byte. 108 | BVC NOTSTOR ; B6=0 is STOR, 1 is XAM and BLOCK XAM. 109 | 110 | LDA L ; LSD's of hex data. 111 | STA (STL,X) ; Store current 'store index'. 112 | INC STL ; Increment store index. 113 | BNE NEXTITEM ; Get next item (no carry). 114 | INC STH ; Add carry to 'store index' high order. 115 | TONEXTITEM: JMP NEXTITEM ; Get next command item. 116 | 117 | RUNPROG: 118 | JMP (XAML) ; Run at current XAM index. 119 | 120 | NOTSTOR: 121 | BMI XAMNEXT ; B7 = 0 for XAM, 1 for BLOCK XAM. 122 | 123 | LDX #$02 ; Byte count. 124 | SETADR: LDA L-1,X ; Copy hex data to 125 | STA STL-1,X ; 'store index'. 126 | STA XAML-1,X ; And to 'XAM index'. 127 | DEX ; Next of 2 bytes. 128 | BNE SETADR ; Loop unless X = 0. 129 | 130 | NXTPRNT: 131 | BNE PRDATA ; NE means no address to print. 132 | LDA #$0D ; CR. 133 | JSR ECHO ; Output it. 134 | LDA #$0A ; LF. 135 | JSR ECHO ; Output it. 136 | LDA XAMH ; 'Examine index' high-order byte. 137 | JSR PRBYTE ; Output it in hex format. 138 | LDA XAML ; Low-order 'examine index' byte. 139 | JSR PRBYTE ; Output it in hex format. 140 | LDA #$3A ; ":". 141 | JSR ECHO ; Output it. 142 | 143 | PRDATA: 144 | LDA #$20 ; Blank. 145 | JSR ECHO ; Output it. 146 | LDA (XAML,X) ; Get data byte at 'examine index'. 147 | JSR PRBYTE ; Output it in hex format. 148 | XAMNEXT: STX MODE ; 0 -> MODE (XAM mode). 149 | LDA XAML 150 | CMP L ; Compare 'examine index' to hex data. 151 | LDA XAMH 152 | SBC H 153 | BCS TONEXTITEM ; Not less, so no more data to output. 154 | 155 | INC XAML 156 | BNE MOD8CHK ; Increment 'examine index'. 157 | INC XAMH 158 | 159 | MOD8CHK: 160 | LDA XAML ; Check low-order 'examine index' byte 161 | AND #$07 ; For MOD 8 = 0 162 | BPL NXTPRNT ; Always taken. 163 | 164 | PRBYTE: 165 | PHA ; Save A for LSD. 166 | LSR 167 | LSR 168 | LSR ; MSD to LSD position. 169 | LSR 170 | JSR PRHEX ; Output hex digit. 171 | PLA ; Restore A. 172 | 173 | PRHEX: 174 | AND #$0F ; Mask LSD for hex print. 175 | ORA #$30 ; Add "0". 176 | CMP #$3A ; Digit? 177 | BCC ECHO ; Yes, output it. 178 | ADC #$06 ; Add offset for letter. 179 | 180 | ECHO: 181 | STA ACIA_DATA ; Output character. 182 | PHA ; Save A. 183 | LDA #$FF ; Initialize delay loop. 184 | TXDELAY: DEC ; Decrement A. 185 | BNE TXDELAY ; Until A gets to 0. 186 | PLA ; Restore A. 187 | RTS ; Return. 188 | 189 | 190 | -------------------------------------------------------------------------------- /zeropage.s: -------------------------------------------------------------------------------- 1 | 2 | .feature org_per_seg 3 | .zeropage 4 | 5 | .org ZP_START1 6 | 7 | GORESTART: 8 | .res 3 9 | GOSTROUT: 10 | .res 3 11 | GOAYINT: 12 | .res 2 13 | GOGIVEAYF: 14 | .res 2 15 | 16 | .org ZP_START2 17 | Z15: 18 | .res 1 19 | .ifndef POSX; allow override 20 | POSX: 21 | .endif 22 | .res 1 23 | .ifndef Z17; allow override 24 | Z17: 25 | .endif 26 | .res 1 27 | .ifndef Z18; allow override 28 | Z18: 29 | .endif 30 | .res 1 31 | LINNUM: 32 | .ifndef TXPSV; allow override 33 | TXPSV: 34 | .endif 35 | .res 2 36 | .ifndef INPUTBUFFER; allow override 37 | INPUTBUFFER: 38 | .endif 39 | 40 | .org ZP_START3 41 | 42 | CHARAC: 43 | .res 1 44 | ENDCHR: 45 | .res 1 46 | EOLPNTR: 47 | .res 1 48 | DIMFLG: 49 | .res 1 50 | VALTYP: 51 | .ifdef CONFIG_SMALL 52 | .res 1 53 | .else 54 | .res 2 55 | .endif 56 | DATAFLG: 57 | .res 1 58 | SUBFLG: 59 | .res 1 60 | INPUTFLG: 61 | .res 1 62 | CPRMASK: 63 | .res 1 64 | Z14: 65 | .res 1 66 | 67 | .org ZP_START4 68 | 69 | TEMPPT: 70 | .res 1 71 | LASTPT: 72 | .res 2 73 | TEMPST: 74 | .res 9 75 | INDEX: 76 | .res 2 77 | DEST: 78 | .res 2 79 | RESULT: 80 | .res BYTES_FP 81 | RESULT_LAST = RESULT + BYTES_FP-1 82 | TXTTAB: 83 | .res 2 84 | VARTAB: 85 | .res 2 86 | ARYTAB: 87 | .res 2 88 | STREND: 89 | .res 2 90 | FRETOP: 91 | .res 2 92 | FRESPC: 93 | .res 2 94 | MEMSIZ: 95 | .res 2 96 | CURLIN: 97 | .res 2 98 | OLDLIN: 99 | .res 2 100 | OLDTEXT: 101 | .res 2 102 | Z8C: 103 | .res 2 104 | DATPTR: 105 | .res 2 106 | INPTR: 107 | .res 2 108 | VARNAM: 109 | .res 2 110 | VARPNT: 111 | .res 2 112 | FORPNT: 113 | .res 2 114 | LASTOP: 115 | .res 2 116 | CPRTYP: 117 | .res 1 118 | FNCNAM: 119 | TEMP3: 120 | .res 2 121 | DSCPTR: 122 | .ifdef CONFIG_SMALL 123 | .res 2 124 | .else 125 | .res 3 126 | .endif 127 | DSCLEN: 128 | .res 2 129 | .ifndef JMPADRS ; allow override 130 | JMPADRS := DSCLEN + 1 131 | .endif 132 | Z52: 133 | .res 1 134 | ARGEXTENSION: 135 | .ifndef CONFIG_SMALL 136 | .res 1 137 | .endif 138 | TEMP1: 139 | .res 1 140 | HIGHDS: 141 | .res 2 142 | HIGHTR: 143 | .res 2 144 | .ifndef CONFIG_SMALL 145 | TEMP2: 146 | .res 1 147 | .endif 148 | INDX: 149 | TMPEXP: 150 | .ifdef CONFIG_SMALL 151 | TEMP2: 152 | .endif 153 | .res 1 154 | EXPON: 155 | .res 1 156 | LOWTR: 157 | .ifndef LOWTRX ; allow override 158 | LOWTRX: 159 | .endif 160 | .res 1 161 | EXPSGN: 162 | .res 1 163 | FAC: 164 | .res BYTES_FP 165 | FAC_LAST = FAC + BYTES_FP-1 166 | FACSIGN: 167 | .res 1 168 | SERLEN: 169 | .res 1 170 | SHIFTSIGNEXT: 171 | .res 1 172 | ARG: 173 | .res BYTES_FP 174 | ARG_LAST = ARG + BYTES_FP-1 175 | ARGSIGN: 176 | .res 1 177 | STRNG1: 178 | .res 2 179 | SGNCPR = STRNG1 180 | FACEXTENSION = STRNG1+1 181 | STRNG2: 182 | .res 2 183 | .ifdef AIM65 184 | ATN: 185 | .res 3 186 | ZBE: 187 | .res 1 188 | .endif 189 | .ifdef SYM1 190 | USR1: 191 | .res 3 192 | USR2: 193 | .res 3 194 | USR3: 195 | .res 3 196 | .endif 197 | CHRGET: 198 | TXTPTR = <(GENERIC_TXTPTR-GENERIC_CHRGET + CHRGET) 199 | CHRGOT = <(GENERIC_CHRGOT-GENERIC_CHRGET + CHRGET) 200 | CHRGOT2 = <(GENERIC_CHRGOT2-GENERIC_CHRGET + CHRGET) 201 | RNDSEED = <(GENERIC_RNDSEED-GENERIC_CHRGET + CHRGET) 202 | 203 | 204 | --------------------------------------------------------------------------------