Brain-Board-II/Source and Serial Driver/a2a1emulv5_1/a2a1emulv5_1.lst
2023-02-08 17:47:18 -05:00

4243 lines
207 KiB
Plaintext

------- FILE a2a1emulv5_1.asm LEVEL 1 PASS 2
1 10000 PROCESSOR 6502
2 10000 ???? LIST ON
3 10000 ???? ;
4 10000 ???? ;-----------------------------------------------------------------------;
5 10000 ???? ; The Wozanium Pack ;
6 10000 ???? ; This file is part one of the Wozanium Pack. ;
7 10000 ???? ; Apple 1 basic is the other part ;
8 10000 ???? ;-----------------------------------------------------------------------;
9 10000 ???? ; Copyright 2010,2011 Mike Willegal
10 10000 ???? ; A1 monitor and A1 apple cassette interface derived from
11 10000 ???? ; original Apple 1 implemenations by Steve Wozniak
12 10000 ???? ;
13 10000 ???? ; The Wozanium Pack is free software:
14 10000 ???? ; you can redistribute it and/or modify
15 10000 ???? ; it under the terms of the GNU General Public License as published by
16 10000 ???? ; the Free Software Foundation, either version 3 of the License, or
17 10000 ???? ; (at your option) any later version.
18 10000 ???? ;
19 10000 ???? ; The Wozanium Pack is distributed in the hope that it will be useful,
20 10000 ???? ; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 10000 ???? ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 10000 ???? ; GNU General Public License for more details.
23 10000 ???? ;
24 10000 ???? ; You should have received a copy of the GNU General Public License
25 10000 ???? ; along with the Wozanium Pack. If not, see <http://www.gnu.org/licenses/>.
26 10000 ???? ;
27 10000 ???? ;-----------------------------------------------------------------------;
28 10000 ???? ;-------------------------------------------------------------------------
29 10000 ???? ; Defines - this code can be built one of four ways
30 10000 ???? ; 1. clone/real Apple 1 HW
31 10000 ???? ; 2. runs in ram of real or virtual Apple 2
32 10000 ???? ; 3. runs in virtual apple 2 as ROM
33 10000 ???? ; 4. runs in plug in board of real Apple 2
34 10000 ???? ;
35 10000 ???? ; select one of these three options
36 10000 ???? ;-------------------------------------------------------------------------
37 10000 ???? ; Build with dasm 6502 assembler and the following command line
38 10000 ???? ;dasm a2a1emulv5_1.asm -DBLD4ROMBD=0 -DHUSTNBASIC=0 -oa2a1rbh.o -la2a1rbh.lst
39 10000 ???? ;
40 10000 ????
41 10000 ???? ;BLD4APPLE1 EQU 0 ;ACTUAL APPLE 1 or CLONE
42 10000 ???? ;BLD4RAM EQU 0 ;RAM of virtual or real A2
43 10000 ???? ;BLD4EMULROM EQU 0 ;ROM of virtual A2
44 10000 ???? ;BLD4ROMBD EQU 0 ;ROM board in Real A2
45 10000 ????
46 10000 ???? ;-------------------------------------------------------------------------
47 10000 ???? ; Constants
48 10000 ???? ;-------------------------------------------------------------------------
49 10000 ????
50 10000 ???? 00 df BS EQU $DF ;Backspace key, arrow left key
51 10000 ???? 00 8d CR EQU $8D ;Carriage Return
52 10000 ???? 00 9b ESC EQU $9B ;ESC key
53 10000 ???? 00 5c PROMPT EQU "\" ;Prompt character
54 10000 ????
55 10000 ???? ;-------------------------------------------------------------------------
56 10000 ???? ; scratchpad memory - uses last 1k of apple ii 48k
57 10000 ???? ;-------------------------------------------------------------------------
58 10000 ???? MAC storage
59 10000 ???? TURBO DS.b 1 ; any bit non-zero is turbo mode
60 10000 ???? TURBOUSR EQU $01 ; USER TURBO MODE
61 10000 ???? TURBOCMP EQU $02 ; COMPUTER DRIVEN TURBO MODE
62 10000 ????
63 10000 ???? RDCONVERT DS.b 1
64 10000 ???? READVECTOR DS.w 1 ;allows user override of default keyboard read function
65 10000 ???? WRITVECTOR DS.w 1 ;allows user override of default video out function
66 10000 ????
67 10000 ???? savey DS.b 1
68 10000 ???? savex DS.b 1
69 10000 ???? POWERUPINIT DS.b 1
70 10000 ???? SCRNCLRD DS.b 1
71 10000 ???? CHAR DS.b 1
72 10000 ???? TMP1 DS.b 1
73 10000 ???? CURROW DS.b 1
74 10000 ???? CURCOL DS.b 1
75 10000 ???? COUNTER0 DS.b 1
76 10000 ???? COUNTER1 DS.b 1
77 10000 ???? CURSOR DS.b 1
78 10000 ???? RDSTRTL DS.b 1
79 10000 ???? RDSTRTH DS.b 1
80 10000 ???? HEX2LB DS.b 1 ;Begin address of dump block
81 10000 ???? HEX2HB DS.b 1
82 10000 ????
83 10000 ???? ;;; zero page back up so graphics routines can use them
84 10000 ???? TMPG0 DS.b 16
85 10000 ???? PG0SAVD DS.b 1
86 10000 ???? ENDM
87 10000 ???? IFNCONST BLD4APPLE1
88 10000 ???? IFNCONST BLD4RAM
89 bc00 ORG $bc00
0 bc00 STORAGE
1 bc00 00 TURBO DS.b 1
2 bc00 00 01 TURBOUSR EQU $01
3 bc00 00 02 TURBOCMP EQU $02
4 bc01
5 bc01 00 RDCONVERT DS.b 1
6 bc02 00 00 READVECTOR DS.w 1
7 bc04 00 00 WRITVECTOR DS.w 1
8 bc06
9 bc06 00 savey DS.b 1
10 bc07 00 savex DS.b 1
11 bc08 00 POWERUPINIT DS.b 1
12 bc09 00 SCRNCLRD DS.b 1
13 bc0a 00 CHAR DS.b 1
14 bc0b 00 TMP1 DS.b 1
15 bc0c 00 CURROW DS.b 1
16 bc0d 00 CURCOL DS.b 1
17 bc0e 00 COUNTER0 DS.b 1
18 bc0f 00 COUNTER1 DS.b 1
19 bc10 00 CURSOR DS.b 1
20 bc11 00 RDSTRTL DS.b 1
21 bc12 00 RDSTRTH DS.b 1
22 bc13 00 HEX2LB DS.b 1
23 bc14 00 HEX2HB DS.b 1
24 bc15
25 bc15
26 bc15 00 00 00 00*TMPG0 DS.b 16
27 bc25 00 PG0SAVD DS.b 1
91 bc26 ENDIF
92 bc26 ENDIF
93 bc26
94 bc26
95 bc26
96 bc26
97 bc26
98 bc26
99 bc26 ;-------------------------------------------------------------------------
100 bc26 ; Memory declaration
101 bc26 ;-------------------------------------------------------------------------
102 bc26
103 bc26
104 bc26 00 24 HEX1L EQU $24 ;End address of dump block
105 bc26 00 25 HEX1H EQU $25
106 bc26 00 26 HEX2L EQU $26 ;Begin address of dump block
107 bc26 00 27 HEX2H EQU $27
108 bc26
109 bc26 00 28 SAVEINDEX EQU $28 ;Save index in input buffer
110 bc26 00 29 LASTSTATE EQU $29 ;Last input state
111 bc26
112 bc26 02 00 IN EQU $0200 ;Input buffer
113 bc26 - IFCONST BLD4APPLE1
114 bc26 -FLIP EQU $C000 ;Output flip-flop
115 bc26 -TAPEIN EQU $C081 ;Tape input
116 bc26 -KBD EQU $D010 ;PIA.A keyboard input
117 bc26 -KBDCR EQU $D011 ;PIA.A keyboard control register
118 bc26 ELSE
119 bc26 c0 20 FLIP EQU $C020 ;Output flip-flop
120 bc26 c0 60 TAPEIN EQU $C060 ;Tape input
121 bc26 c0 00 KBD EQU $C000 ;keyboard input
122 bc26 c0 10 KBDCR EQU $C010 ;keybaord strobe clear
123 bc26 ENDIF
124 bc26
125 bc26 ;-------------------------------------------------------------------------
126 bc26 ; Constants
127 bc26 ;-------------------------------------------------------------------------
128 bc26
129 bc26 00 8d CR EQU $8D ;Carriage Return
130 bc26 00 9b ESC EQU $9B ;ASCII ESC
131 bc26 00 e0 CNTSTRT EQU $E0
132 bc26
133 bc26 ;---------------------------------------------------------------------------
134 bc26 ; build in ACI Driver
135 bc26 ;---------------------------------------------------------------------------
136 bc26 - IFCONST BLD4EMULROM
137 bc26 - ORG $D000 ; EMULATOR ROM image
138 bc26 ELSE
139 bc26 - IFCONST BLD4RAM
140 bc26 - ORG $6000 ; build for memory
141 bc26 ELSE
142 c100 ORG $C100 ; real apple 1 or plug in ROM board for A2
143 c100 ENDIF
144 c100 ENDIF
145 c100
146 c100 ;-------------------------------------------------------------------------
147 c100 ;
148 c100 ; The WOZ Apple Cassette Interface for the Apple 1
149 c100 ; Written by Steve Wozniak somewhere around 1976
150 c100 ;
151 c100 ;-------------------------------------------------------------------------
152 c100 WOZACI
153 c100
154 c100 a9 aa LDA #$aa ;Print the Tape prompt
155 c102 IFNCONST BLD4APPLE1
156 c102 4c 00 d0 JMP A2ACIDRIVER ;If not actual Apple 1, use A2 driver
157 c105 - ELSE
158 c105 - JSR ECHO
159 c105 ENDIF
160 c105 a9 8d LDA #CR ;And drop the cursor one line
161 c107 20 ef ff JSR ECHO
162 c10a
163 c10a a0 ff LDY #-1 ;Reset the input buffer index
164 c10c c8 ACINEXTCHAR INY
165 c10d
166 c10d
167 c10d ad 10 c0 ACIWAITCHAR LDA KBDCR ;Wait for key press
168 c110 10 fb BPL ACIWAITCHAR ;No key yet!
169 c112 ad 00 c0 LDA KBD ;Clear strobe
170 c115 99 00 02 STA IN,Y ;Save it into buffer
171 c118 20 ef ff JSR ECHO ;And type it on the screen
172 c11b c9 9b CMP #ESC
173 c11d f0 e1 BEQ WOZACI ;Start from scratch if ESC!
174 c11f c9 8d CMP #CR
175 c121 d0 e9 BNE ACINEXTCHAR ;Read keys until CR
176 c123
177 c123 a2 ff LDX #-1 ;Initialize parse buffer pointer
178 c125
179 c125 ;-------------------------------------------------------------------------
180 c125 ; Start parsing first or a new tape command
181 c125 ;-------------------------------------------------------------------------
182 c125
183 c125 a9 00 NEXTCMD LDA #0 ;Clear begin and end values
184 c127 85 24 STA HEX1L
185 c129 85 25 STA HEX1H
186 c12b 85 26 STA HEX2L
187 c12d 85 27 STA HEX2H
188 c12f
189 c12f e8 NEXTCHR INX ;Increment input pointer
190 c130 bd 00 02 LDA IN,X ;Get next char from input line
191 c133 c9 d2 CMP #$d2 ;Read command?
192 c135 f0 56 BEQ READ ;Yes!
193 c137 c9 d7 CMP #$d7 ;Write command?
194 c139 f0 35 BEQ WRITE ;Yes! (note: CY=1)
195 c13b c9 ae CMP #$ae ;Separator?
196 c13d f0 27 BEQ SEP ;Yes!
197 c13f c9 8d CMP #CR ;End of line?
198 c141 f0 20 BEQ GOESC ;Escape to monitor! We're done
199 c143 c9 a0 CMP #$a0 ;Ignore spaces
200 c145 f0 e8 BEQ NEXTCHR
201 c147 49 b0 EOR #$b0 ;Map digits to 0-9
202 c149 c9 0a CMP #9+1 ;Is it a decimal digit?
203 c14b 90 06 BCC ACIDIG ;Yes!
204 c14d 69 88 ADC #$88 ;Map letter "A"-"F" to $FA-$FF
205 c14f c9 fa CMP #$FA ;Hex letter?
206 c151 90 ad BCC WOZACI ;No! Character not hex!
207 c153
208 c153 0a ACIDIG ASL ;Hex digit to MSD of A
209 c154 0a ASL
210 c155 0a ASL
211 c156 0a ASL
212 c157
213 c157 a0 04 LDY #4 ;Shift count
214 c159 0a ACIHEXSHIFT ASL ;Hex digit left, MSB to carry
215 c15a 26 24 ROL HEX1L ;Rotate into LSD
216 c15c 26 25 ROL HEX1H ;Rotate into MSD
217 c15e 88 DEY ;Done 4 shifts?
218 c15f d0 f8 BNE ACIHEXSHIFT ;No! Loop
219 c161 f0 cc BEQ NEXTCHR ;Handle next character
220 c163
221 c163 ;-------------------------------------------------------------------------
222 c163 ; Return to monitor, prints \ first
223 c163 ;-------------------------------------------------------------------------
224 c163
225 c163 4c 1a ff GOESC JMP ESCAPE ;Escape back to monitor
226 c166
227 c166 ;-------------------------------------------------------------------------
228 c166 ; Separating . found. Copy HEX1 to Hex2. Doesn't clear HEX1!!!
229 c166 ;-------------------------------------------------------------------------
230 c166
231 c166 a5 24 SEP LDA HEX1L ;Copy hex value 1 to hex value 2
232 c168 85 26 STA HEX2L
233 c16a a5 25 LDA HEX1H
234 c16c 85 27 STA HEX2H
235 c16e b0 bf BCS NEXTCHR ;Always taken!
236 c170
237 c170 ;-------------------------------------------------------------------------
238 c170 ; Write a block of memory to tape
239 c170 ;-------------------------------------------------------------------------
240 c170
241 c170 WRITE
242 c170 a9 40 LDA #64 ;Write 10 second header
243 c172 20 cc c1 JSR WHEADER
244 c175 88 WRNEXT DEY ;Compensate timing for extra work
245 c176 a2 00 LDX #0 ;Get next byte to write
246 c178 a1 26 LDA (HEX2L,X)
247 c17a
248 c17a a2 10 LDX #8*2 ;Shift 8 bits (decremented twice)
249 c17c 0a WBITLOOP ASL ;Shift MSB to carry
250 c17d 20 db c1 JSR WRITEBIT ;Write this bit
251 c180 d0 fa BNE WBITLOOP ;Do all 8 bits!
252 c182
253 c182 20 f1 c1 JSR INCADDR ;Increment address
254 c185 a0 1e LDY #30 ;Compensate timer for extra work
255 c187 90 ec BCC WRNEXT ;Not done yet! Write next byte
256 c189
257 c189 RESTIDX
258 c189 a6 28 LDX SAVEINDEX ;Restore index in input line
259 c18b b0 98 BCS NEXTCMD ;Always taken!
260 c18d
261 c18d ;-------------------------------------------------------------------------
262 c18d ; For case when ACI must fit in c100-c1ff - the read function must be moved
263 c18d ; because the standard read doesn't fit with the extra mask instruction
264 c18d ; required for the Apple II hardware
265 c18d ;-------------------------------------------------------------------------
266 c18d
267 c18d READ
268 c18d 20 bc c1 JSR FULLCYCLE ;Wait until full cycle is detected
269 c190 a9 16 LDA #22 ;Introduce some delay to allow
270 c192 20 cc c1 JSR WHEADER ; the tape speed to stabilize
271 c195 20 bc c1 JSR FULLCYCLE ;Synchronize with full cycle
272 c198 NOTSTART
273 c198 a0 1f LDY #31 ;Try to detect the much shorter
274 c19a 20 bf c1 JSR CMPLEVEL ; start bit
275 c19d b0 f9 BCS NOTSTART ;Start bit not detected yet!
276 c19f 20 bf c1 JSR CMPLEVEL ;Wait for 2nd phase of start bit
277 c1a2
278 c1a2 a0 3a LDY #58 ;Set threshold value in middle
279 c1a4 a2 08 RDBYTE LDX #8 ;Receiver 8 bits
280 c1a6 48 RDBIT PHA
281 c1a7 20 bc c1 JSR FULLCYCLE ;Detect a full cycle
282 c1aa 68 PLA
283 c1ab 2a ROL ;Roll new bit into result
284 c1ac a0 39 LDY #57 ;Set threshold value in middle
285 c1ae ca DEX ;Decrement bit counter
286 c1af d0 f5 BNE RDBIT ;Read next bit!
287 c1b1 81 26 STA (HEX2L,X) ;Save new byte
288 c1b3
289 c1b3 20 f1 c1 JSR INCADDR ;Increment address
290 c1b6 a0 35 LDY #53 ;Compensate threshold with workload
291 c1b8 90 ea BCC RDBYTE ;Do next byte if not done yet!
292 c1ba b0 cd BCS RESTIDX ;Always taken! Restore parse index
293 c1bc
294 c1bc 20 bf c1 FULLCYCLE JSR CMPLEVEL ;Wait for two level changes
295 c1bf 88 CMPLEVEL DEY ;Decrement time counter
296 c1c0 ad 60 c0 LDA TAPEIN ;Get Tape In data
297 c1c3
298 c1c3 ;-------------------------------------------------------------------------
299 c1c3 ; the next instruction must be added for apple II
300 c1c3 ; since it doesn't fit in the 256 bytes allowed in the
301 c1c3 ; original PROM, a substitute A2 read function is called instead
302 c1c3 ; (READ_APPLE2_VERSION)which is located in a different bank
303 c1c3 ;
304 c1c3 ; AND #$80 ;CLEAR floating bits
305 c1c3 ;-------------------------------------------------------------------------
306 c1c3 c5 29 CMP LASTSTATE ;Same as before?
307 c1c5 f0 f8 BEQ CMPLEVEL ;Yes!
308 c1c7 85 29 STA LASTSTATE ;Save new data
309 c1c9
310 c1c9 c0 80 CPY #128 ;Compare threshold
311 c1cb 60 RTS
312 c1cc ;-------------------------------------------------------------------------
313 c1cc ; Write header to tape
314 c1cc ;
315 c1cc ; The header consists of an asymmetric cycle, starting with one phase of
316 c1cc ; approximately (66+47)x5=565us, followed by a second phase of
317 c1cc ; approximately (44+47)x5=455us.
318 c1cc ; Total cycle duration is approximately 1020us ~ 1kHz. The actual
319 c1cc ; frequencywill be a bit lower because of the additional workload between
320 c1cc ; the twoloops.
321 c1cc ; The header ends with a short phase of (30+47)x5=385us and a normal
322 c1cc ; phase of (44+47)x5=455us. This start bit must be detected by the read
323 c1cc ; routine to trigger the reading of the actual data.
324 c1cc ;-------------------------------------------------------------------------
325 c1cc
326 c1cc 86 28 WHEADER STX SAVEINDEX ;Save index in input line
327 c1ce a0 42 HCOUNT LDY #66 ;Extra long delay
328 c1d0 20 e0 c1 JSR WDELAY ;CY is constantly 1, writing a 1
329 c1d3 d0 f9 BNE HCOUNT ;Do this 64 * 256 time!
330 c1d5 69 fe ADC #-2 ;Decrement A (CY=1 all the time)
331 c1d7 b0 f5 BCS HCOUNT ;Not all done!
332 c1d9 a0 1e LDY #30 ;Write a final short bit (start)
333 c1db
334 c1db ;-------------------------------------------------------------------------
335 c1db ; Write a full bit cycle
336 c1db ;
337 c1db ; Upon entry Y contains a compensated value for the first phase of 0
338 c1db ; bit length. All subsequent loops don't have to be time compensated.
339 c1db ;-------------------------------------------------------------------------
340 c1db
341 c1db 20 e0 c1 WRITEBIT JSR WDELAY ;Do two equal phases
342 c1de a0 2c LDY #44 ;Load 250us counter - compensation
343 c1e0
344 c1e0 88 WDELAY DEY ;Delay 250us (one phase of 2kHz)
345 c1e1 d0 fd BNE WDELAY
346 c1e3 90 05 BCC WRITE1 ;Write a '1' (2kHz)
347 c1e5
348 c1e5 a0 2f LDY #47 ;Additional delay for '0' (1kHz)
349 c1e7 88 WDELAY0 DEY ; (delay 250us)
350 c1e8 d0 fd BNE WDELAY0
351 c1ea
352 c1ea WRITE1
353 c1ea bc 20 c0 LDY FLIP,X ;Flip the output bit
354 c1ed a0 29 LDY #41 ;Reload 250us cntr (compensation)
355 c1ef ca DEX ;Decrement bit counter
356 c1f0 60 RTS
357 c1f1
358 c1f1 ;-------------------------------------------------------------------------
359 c1f1 ; Increment current address and compare with last address
360 c1f1 ;-------------------------------------------------------------------------
361 c1f1 a5 26 INCADDR LDA HEX2L ;Compare current address with
362 c1f3 c5 24 CMP HEX1L ; end address
363 c1f5 a5 27 LDA HEX2H
364 c1f7 e5 25 SBC HEX1H
365 c1f9 e6 26 INC HEX2L ;And increment current address
366 c1fb d0 02 BNE NOCARRY ;No carry to MSB!
367 c1fd e6 27 INC HEX2H
368 c1ff 60 NOCARRY RTS
369 c200
370 c200
371 c200 ;---------------------------------------------------------------------------
372 c200 ; all the following code is needed for the A2 version
373 c200 ; skip to Basic for the real thing
374 c200 ;---------------------------------------------------------------------------
375 c200 IFNCONST BLD4APPLE1
376 c200 ;---------------------------------------------------------------------------
377 c200 ; build in an A2 ACI driver for ROM version
378 c200 ; if using an A2, the version at C100 jumps to this version
379 c200 ; and this version is at D000 (so slots 0 & 2-7 can be used)
380 c200 ;---------------------------------------------------------------------------
381 c200 IFNCONST BLD4EMULROM
382 c200 IFNCONST BLD4RAM
383 d000 ORG $D000 ; A2 ROM or image
384 d000 ENDIF
385 d000 ENDIF
386 d000
387 d000 ;-------------------------------------------------------------------------
388 d000 ; ACI DRIVER
389 d000 ;-------------------------------------------------------------------------
390 d000 A2ACIDRIVER
391 d000 a9 aa LDA #$aa ;Print the Tape prompt
392 d002 20 ef ff JSR ECHO
393 d005 a9 8d LDA #CR ;And drop the cursor one line
394 d007 20 ef ff JSR ECHO
395 d00a
396 d00a a0 ff LDY #-1 ;Reset the input buffer index
397 d00c RB_ACINEXTCHAR
398 d00c c8 INY
399 d00d
400 d00d 20 4d d2 JSR A2GETCHAR
401 d010
402 d010 99 00 02 STA IN,Y ;Save it into buffer
403 d013 20 ef ff JSR ECHO ;And type it on the screen
404 d016 c9 9b CMP #ESC
405 d018 f0 e6 BEQ A2ACIDRIVER ;Start from scratch if ESC!
406 d01a c9 8d CMP #CR
407 d01c d0 ee BNE RB_ACINEXTCHAR ;Read keys until CR
408 d01e
409 d01e a2 ff LDX #-1 ;Initialize parse buffer pointer
410 d020
411 d020 ;-------------------------------------------------------------------------
412 d020 ; Start parsing first or a new tape command
413 d020 ;-------------------------------------------------------------------------
414 d020
415 d020 RB_NEXTCMD
416 d020 a9 00 LDA #0 ;Clear begin and end values
417 d022 85 24 STA HEX1L
418 d024 85 25 STA HEX1H
419 d026 85 26 STA HEX2L
420 d028 85 27 STA HEX2H
421 d02a
422 d02a RB_NEXTCHR
423 d02a e8 INX ;Increment input pointer
424 d02b bd 00 02 LDA IN,X ;Get next char from input line
425 d02e c9 d2 CMP #$d2 ;Read command?
426 d030 f0 69 BEQ RB_READ ;Yes!
427 d032 c9 d7 CMP #$d7 ;Write command?
428 d034 f0 35 BEQ RB_WRITE ;Yes! (note: CY=1)
429 d036 c9 ae CMP #$ae ;Separator?
430 d038 f0 27 BEQ RB_SEP ;Yes!
431 d03a c9 8d CMP #CR ;End of line?
432 d03c f0 20 BEQ RB_GOESC ;Escape to monitor! We're done
433 d03e c9 a0 CMP #$a0 ;Ignore spaces
434 d040 f0 e8 BEQ RB_NEXTCHR
435 d042 49 b0 EOR #$b0 ;Map digits to 0-9
436 d044 c9 0a CMP #9+1 ;Is it a decimal digit?
437 d046 90 06 BCC RB_ACIDIG ;Yes!
438 d048 69 88 ADC #$88 ;Map letter "A"-"F" to $FA-$FF
439 d04a c9 fa CMP #$FA ;Hex letter?
440 d04c 90 b2 BCC A2ACIDRIVER ;No! Character not hex!
441 d04e
442 d04e RB_ACIDIG
443 d04e 0a ASL ;Hex digit to MSD of A
444 d04f 0a ASL
445 d050 0a ASL
446 d051 0a ASL
447 d052
448 d052 a0 04 LDY #4 ;Shift count
449 d054 RB_ACIHEXSHIFT
450 d054 0a ASL ;Hex digit left, MSB to carry
451 d055 26 24 ROL HEX1L ;Rotate into LSD
452 d057 26 25 ROL HEX1H ;Rotate into MSD
453 d059 88 DEY ;Done 4 shifts?
454 d05a d0 f8 BNE RB_ACIHEXSHIFT ;No! Loop
455 d05c f0 cc BEQ RB_NEXTCHR ;Handle next character
456 d05e
457 d05e ;-------------------------------------------------------------------------
458 d05e ; Return to monitor, prints \ first
459 d05e ;-------------------------------------------------------------------------
460 d05e
461 d05e 4c 1a ff RB_GOESC JMP ESCAPE ;Escape back to monitor
462 d061
463 d061 ;-------------------------------------------------------------------------
464 d061 ; Separating . found. Copy HEX1 to Hex2. Doesn't clear HEX1!!!
465 d061 ;-------------------------------------------------------------------------
466 d061
467 d061 a5 24 RB_SEP LDA HEX1L ;Copy hex value 1 to hex value 2
468 d063 85 26 STA HEX2L
469 d065 a5 25 LDA HEX1H
470 d067 85 27 STA HEX2H
471 d069 b0 bf BCS RB_NEXTCHR ;Always taken!
472 d06b
473 d06b ;-------------------------------------------------------------------------
474 d06b ; Write a block of memory to tape
475 d06b ;-------------------------------------------------------------------------
476 d06b
477 d06b RB_WRITE
478 d06b ;-------------------------------------------------------------------------
479 d06b ; save write start addresses
480 d06b ; so we can check for keyboard
481 d06b ; or console write sequences
482 d06b ; and dynamicly modify code to
483 d06b ; use original A1 driver
484 d06b ; and then revert later on
485 d06b ;-------------------------------------------------------------------------
486 d06b a5 26 LDA HEX2L
487 d06d 8d 11 bc STA RDSTRTL
488 d070 a5 27 LDA HEX2H
489 d072 8d 12 bc STA RDSTRTH
490 d075 86 28 STX SAVEINDEX ;Save index in input line
491 d077 20 ce d1 JSR A2_WRITECONVERT ; convert I/O to A1 compatible format
492 d07a ;-------------------------------------------------------------------------
493 d07a ; now start write of this block
494 d07a ;-------------------------------------------------------------------------
495 d07a
496 d07a a9 40 LDA #64 ;Write 10 second header
497 d07c 20 d7 d0 JSR RB_WHEADER
498 d07f
499 d07f 88 RB_WRNEXT DEY ;Compensate timing for extra work
500 d080 a2 00 LDX #0 ;Get next byte to write
501 d082 a1 26 LDA (HEX2L,X)
502 d084
503 d084 a2 10 LDX #8*2 ;Shift 8 bits (decremented twice)
504 d086 0a RB_WBITLOOP ASL ;Shift MSB to carry
505 d087 20 e4 d0 JSR RB_WRITEBIT ;Write this bit
506 d08a d0 fa BNE RB_WBITLOOP ;Do all 8 bits!
507 d08c
508 d08c 20 0c d1 JSR A2_INCADDR ;Increment address
509 d08f a0 1e LDY #30 ;Compensate timer for extra work
510 d091 90 ec BCC RB_WRNEXT ;Not done yet! Write next byte
511 d093
512 d093 RB_RESTIDX
513 d093 20 1b d1 JSR A2_READCONVERT ; convert buffer to A2 I/O
514 d096 a6 28 LDX SAVEINDEX ;Restore index in input line
515 d098 4c 20 d0 JMP RB_NEXTCMD ;Always taken!
516 d09b
517 d09b ;-------------------------------------------------------------------------
518 d09b ; For case when ACI must fit in c100-c1ff - the read function must be moved
519 d09b ; because the standard read doesn't fit with the extra mask instruction
520 d09b ; required for the Apple II hardware
521 d09b ;-------------------------------------------------------------------------
522 d09b
523 d09b RB_READ
524 d09b ;-------------------------------------------------------------------------
525 d09b ; save read start addresses
526 d09b ; so we can check for keyboard
527 d09b ; or console write sequences
528 d09b ; and dynamicly modify code to
529 d09b ; use A2 driver
530 d09b ;-------------------------------------------------------------------------
531 d09b a5 26 LDA HEX2L
532 d09d 8d 11 bc STA RDSTRTL
533 d0a0 a5 27 LDA HEX2H
534 d0a2 8d 12 bc STA RDSTRTH
535 d0a5
536 d0a5 20 fa d0 JSR A2_FULLCYCLE ;Wait until full cycle is detected
537 d0a8 86 28 STX SAVEINDEX ;Save index in input line
538 d0aa a9 16 LDA #22 ;Introduce some delay to allow
539 d0ac 20 d7 d0 JSR RB_WHEADER ; the tape speed to stabilize
540 d0af
541 d0af ;-------------------------------------------------------------------------
542 d0af ;
543 d0af ; This read function will optionally convert and A1 keyboard reads
544 d0af ; to calls to use our driver to read from A2 hardware by scanning
545 d0af ; read data looking for one of three code sequences
546 d0af ;-------------------------------------------------------------------------
547 d0af ;
548 d0af ; Normal start
549 d0af ;
550 d0af 20 fa d0 JSR A2_FULLCYCLE ;Synchronize with full cycle
551 d0b2 a0 1c A2_NOTSTART LDY #28 ;Try to detect the much shorter
552 d0b4 20 fd d0 JSR A2_CMPLEVEL ; start bit
553 d0b7 b0 f9 BCS A2_NOTSTART ;Start bit not detected yet!
554 d0b9 20 fd d0 JSR A2_CMPLEVEL ;Wait for 2nd phase of start bit
555 d0bc
556 d0bc a0 35 LDY #53 ;Set threshold value in middle
557 d0be a2 08 A2_RDBYTE LDX #8 ;Receiver 8 bits
558 d0c0 48 A2_RDBIT PHA
559 d0c1 20 fa d0 JSR A2_FULLCYCLE ;Detect a full cycle
560 d0c4 68 PLA
561 d0c5 2a ROL ;Roll new bit into result
562 d0c6 a0 34 LDY #52 ;Set threshold value in middle
563 d0c8 ca DEX ;Decrement bit counter
564 d0c9 d0 f5 BNE A2_RDBIT ;Read next bit!
565 d0cb 81 26 STA (HEX2L,X) ;Save new byte
566 d0cd
567 d0cd 20 0c d1 JSR A2_INCADDR ;Increment address
568 d0d0 a0 2e LDY #46 ;Compensate threshold with workload
569 d0d2 90 ea BCC A2_RDBYTE ;Do next byte if not done yet!
570 d0d4
571 d0d4 4c 93 d0 JMP RB_RESTIDX
572 d0d7
573 d0d7
574 d0d7
575 d0d7 ;-------------------------------------------------------------------------
576 d0d7 ; Write header to tape
577 d0d7 ;
578 d0d7 ; The header consists of an asymmetric cycle, starting with one phase of
579 d0d7 ; approximately (66+47)x5=565us, followed by a second phase of
580 d0d7 ; approximately (44+47)x5=455us.
581 d0d7 ; Total cycle duration is approximately 1020us ~ 1kHz. The actual
582 d0d7 ; frequencywill be a bit lower because of the additional workload between
583 d0d7 ; the twoloops.
584 d0d7 ; The header ends with a short phase of (30+47)x5=385us and a normal
585 d0d7 ; phase of (44+47)x5=455us. This start bit must be detected by the read
586 d0d7 ; routine to trigger the reading of the actual data.
587 d0d7 ;-------------------------------------------------------------------------
588 d0d7
589 d0d7 RB_WHEADER
590 d0d7 a0 48 RB_HCOUNT LDY #72 ;Extra long delay
591 d0d9 20 e9 d0 JSR RB_WDELAY ;CY is constantly 1, writing a 1
592 d0dc d0 f9 BNE RB_HCOUNT ;Do this 64 * 256 time!
593 d0de 69 fe ADC #-2 ;Decrement A (CY=1 all the time)
594 d0e0 b0 f5 BCS RB_HCOUNT ;Not all done!
595 d0e2 a0 20 LDY #32 ;Write a final short bit (start)
596 d0e4
597 d0e4 ;-------------------------------------------------------------------------
598 d0e4 ; Write a full bit cycle
599 d0e4 ;
600 d0e4 ; Upon entry Y contains a compensated value for the first phase of 0
601 d0e4 ; bit length. All subsequent loops don't have to be time compensated.
602 d0e4 ;-------------------------------------------------------------------------
603 d0e4
604 d0e4 RB_WRITEBIT
605 d0e4
606 d0e4 20 e9 d0 JSR RB_WDELAY ;Do two equal phases
607 d0e7 a0 2f LDY #47 ;Load 250us counter - compensation
608 d0e9
609 d0e9 88 RB_WDELAY DEY ;Delay 250us (one phase of 2kHz)
610 d0ea d0 fd BNE RB_WDELAY
611 d0ec 90 05 BCC RB_WRITE1 ;Write a '1' (2kHz)
612 d0ee
613 d0ee a0 32 LDY #50 ;Additional delay for '0' (1kHz)
614 d0f0 88 RB_WDELAY0 DEY ; (delay 250us)
615 d0f1 d0 fd BNE RB_WDELAY0
616 d0f3
617 d0f3 RB_WRITE1
618 d0f3
619 d0f3 ac 20 c0 LDY FLIP ;Flip the output bit
620 d0f6
621 d0f6 a0 2e LDY #46 ;Reload 250us cntr (compensation)
622 d0f8 ca DEX ;Decrement bit counter
623 d0f9 60 RTS
624 d0fa
625 d0fa ;-------------------------------------------------------------------------
626 d0fa ; Wait for FULL cycle (cmplevel- waits till level transisiton)
627 d0fa ;-------------------------------------------------------------------------
628 d0fa 20 fd d0 A2_FULLCYCLE JSR A2_CMPLEVEL ;Wait for two level changes
629 d0fd 88 A2_CMPLEVEL DEY ;Decrement time counter
630 d0fe ad 60 c0 LDA TAPEIN ;Get Tape In data
631 d101
632 d101 ; the next instruction must be added for apple II
633 d101 29 80 AND #$80 ;CLEAR floating bits
634 d103 c5 29 CMP LASTSTATE ;Same as before?
635 d105 f0 f6 BEQ A2_CMPLEVEL ;Yes!
636 d107 85 29 STA LASTSTATE ;Save new data
637 d109
638 d109 c0 80 CPY #128 ;Compare threshold
639 d10b 60 RTS
640 d10c ;-------------------------------------------------------------------------
641 d10c ; Increment current address and compare with last address
642 d10c ;-------------------------------------------------------------------------
643 d10c a5 26 A2_INCADDR LDA HEX2L ;Compare current address with
644 d10e c5 24 CMP HEX1L ; end address
645 d110 a5 27 LDA HEX2H
646 d112 e5 25 SBC HEX1H
647 d114 e6 26 INC HEX2L ;And increment current address
648 d116 d0 02 BNE A2_NOCARRY ;No carry to MSB!
649 d118 e6 27 INC HEX2H
650 d11a 60 A2_NOCARRY RTS
651 d11b
652 d11b ;-------------------------------------------------------------------------
653 d11b ; one block read
654 d11b ; modify A1 code that touches PIA to A2 version as it is loaded
655 d11b ; these are keyboard and display functions
656 d11b ;
657 d11b ; APPLE 1 version
658 d11b ;ACIWAITCHAR
659 d11b ; ad 11 d0 LDA KBDCR ;Wait for key press
660 d11b ; 30 FB BPL ACIWAITCHAR ;No key yet!
661 d11b ; ad 10 d0 LDA KBD ;Clear strobe
662 d11b ; converted to our version
663 d11b ; 20 3a d1 JSR A2GETCHAR
664 d11b ; ea NOP
665 d11b ; ea NOP
666 d11b ; ea NOP
667 d11b ; ea NOP
668 d11b ; ea NOP
669 d11b ;
670 d11b ; instead if BPL is not present or has mismatching branch offset
671 d11b ; ad 11 d0 LDA KBDCR
672 d11b ; is converted to
673 d11b ; ad 00 c0 LDA KBD
674 d11b ;
675 d11b ;
676 d11b ;
677 d11b ; ad 10 d0 LDA KBD
678 d11b ; is converted to
679 d11b ; 8d 10 c0 STA KBDCR ;Clear strobe
680 d11b ;
681 d11b ; finally there are some cases where presence of character is
682 d11b ; determined with the bit command
683 d11b ; 2c 11 d0 BIT KBDCR
684 d11b ; is converted to
685 d11b ; 2c 00 c00 BIT KBD
686 d11b ;
687 d11b ;
688 d11b ;
689 d11b ;-------------------------------------------------------------------------
690 d11b
691 d11b 00 77 CNVRTTERM EQU $77 ; UNIQUE CHAR NEEDED TO TERMINATE CONVERSION STRINGS
692 d11b
693 d11b A2_READCONVERT
694 d11b a9 00 LDA #0 ; RDCONVERT can be turned off
695 d11d cd 01 bc CMP RDCONVERT
696 d120 d0 4d BNE A2_READCONVERTDONE ; not zero, then skip conversion
697 d122 a2 00 LDX #0
698 d124 a0 00 LDY #0
699 d126 ;
700 d126 ; check next string through all of memory
701 d126 ;
702 d126
703 d126 A2_READCONVERT_1 ; for this string, scan all of read memory
704 d126 8c 06 bc STY savey ;save compare string starting point
705 d129
706 d129 b9 90 d1 LDA CNVRT_IN,Y
707 d12c c9 77 CMP #CNVRTTERM ; Termination character?
708 d12e f0 3f BEQ A2_READCONVERTDONE ;all done checking, exit
709 d130
710 d130 ad 11 bc LDA RDSTRTL ; start of memory load
711 d133 85 26 STA HEX2L
712 d135 ad 12 bc LDA RDSTRTH
713 d138 85 27 STA HEX2H
714 d13a
715 d13a ;
716 d13a ; restart currnet string
717 d13a ;
718 d13a A2_READCONVERT_8
719 d13a a5 26 LDA HEX2L ;save memory starting point
720 d13c 8d 13 bc STA HEX2LB
721 d13f a5 27 LDA HEX2H
722 d141 8d 14 bc STA HEX2HB
723 d144 ac 06 bc LDY savey
724 d147
725 d147 A2_READCONVERT1
726 d147 a1 26 LDA (HEX2L),X ; fetch byte from memory
727 d149 d9 90 d1 CMP CNVRT_IN,Y ; compare
728 d14c f0 11 BEQ A2_READCONVERT1_2 ; this byte does match, process
729 d14e ;
730 d14e ; mo match, restart match string
731 d14e ;
732 d14e 20 0c d1 JSR A2_INCADDR
733 d151 90 e7 BCC A2_READCONVERT_8 ; not end of memory - restart scan for current string
734 d153
735 d153 ;
736 d153 ; end of memory block - go to next string
737 d153 ;
738 d153 A2_READCONVERT1_3
739 d153 c8 INY
740 d154 b9 90 d1 LDA CNVRT_IN,Y
741 d157 c9 77 CMP #CNVRTTERM ; Termination character?
742 d159 d0 f8 BNE A2_READCONVERT1_3 ; not end of block, keep looking
743 d15b c8 INY ; found end, move to start of next block
744 d15c 4c 26 d1 JMP A2_READCONVERT_1 ; rescan memory with next string
745 d15f ;
746 d15f ; match - keep going until mismatch or end of string
747 d15f ;
748 d15f A2_READCONVERT1_2
749 d15f c8 INY
750 d160 b9 90 d1 LDA CNVRT_IN,Y
751 d163 c9 77 CMP #CNVRTTERM ; Termination character?
752 d165 f0 09 BEQ A2_READCONVERT3 ; end of string - this is match do substitute
753 d167 20 0c d1 JSR A2_INCADDR ; next memory address
754 d16a 90 db BCC A2_READCONVERT1 ; not done - keep scanning
755 d16c
756 d16c 4c 53 d1 JMP A2_READCONVERT1_3 ; not a complete match - try next string
757 d16f
758 d16f ;-------------------------------------------------------------------------
759 d16f ; Finished with READ
760 d16f ;-------------------------------------------------------------------------
761 d16f A2_READCONVERTDONE
762 d16f 60 RTS
763 d170
764 d170 ;-------------------------------------------------------------------------
765 d170 ; Substitute string here
766 d170 ;-------------------------------------------------------------------------
767 d170
768 d170 A2_READCONVERT3 ; match - substitute here
769 d170 ac 06 bc LDY savey
770 d173
771 d173 ad 13 bc LDA HEX2LB ;restore memory starting point
772 d176 85 26 STA HEX2L
773 d178 ad 14 bc LDA HEX2HB
774 d17b 85 27 STA HEX2H
775 d17d A2_READCONVERT4
776 d17d b9 90 d1 LDA CNVRT_IN,Y
777 d180 c9 77 CMP #CNVRTTERM ; Termination character?
778 d182 f0 b6 BEQ A2_READCONVERT_8 ; done with sustibute, continue checking
779 d184 b9 af d1 LDA CNVRT_OUT,Y
780 d187 c8 INY
781 d188 81 26 STA (HEX2L),X
782 d18a 20 0c d1 JSR A2_INCADDR
783 d18d 4c 7d d1 JMP A2_READCONVERT4
784 d190
785 d190 ;-------------------------------------------------------------------------
786 d190 ; conversion strings
787 d190 ; IN(what we are looking for
788 d190 ; OUT (what we change it to)
789 d190 ;-------------------------------------------------------------------------
790 d190
791 d190 CNVRT_IN
792 d190 ad 11 d0 CI1 LDA $d011
793 d193 10 fb BPL CI1
794 d195 ad 10 d0 LDA $d010
795 d198 77 DC.b CNVRTTERM
796 d199 ad 11 d0 LDA $d011
797 d19c 77 DC.b CNVRTTERM
798 d19d ad 10 d0 LDA $d010
799 d1a0 77 DC.b CNVRTTERM
800 d1a1 2c 11 d0 BIT $d011
801 d1a4 77 DC.b CNVRTTERM
802 d1a5 CI2
803 d1a5 2c 12 d0 BIT $D012
804 d1a8 30 fb BMI CI2
805 d1aa 8d 12 d0 STA $D012
806 d1ad 77 DC.b CNVRTTERM
807 d1ae - IFCONST BLD4RAM
808 d1ae - JSR $FFEF
809 d1ae - DC.b CNVRTTERM
810 d1ae ENDIF
811 d1ae 77 DC.b CNVRTTERM
812 d1af
813 d1af CNVRT_OUT
814 d1af 20 4d d2 JSR A2GETCHAR
815 d1b2 ea NOP
816 d1b3 ea NOP
817 d1b4 ea NOP
818 d1b5 ea NOP
819 d1b6 ea NOP
820 d1b7 77 DC.b CNVRTTERM
821 d1b8 ad 00 c0 LDA KBD
822 d1bb 77 DC.b CNVRTTERM
823 d1bc 8d 10 c0 STA KBDCR
824 d1bf 77 DC.b CNVRTTERM
825 d1c0 2c 00 c0 BIT KBD
826 d1c3 77 DC.b CNVRTTERM
827 d1c4 20 ef ff JSR ECHO
828 d1c7 ea NOP
829 d1c8 ea NOP
830 d1c9 ea NOP
831 d1ca ea NOP
832 d1cb ea NOP
833 d1cc 77 DC.b CNVRTTERM
834 d1cd - IFCONST BLD4RAM
835 d1cd - JSR ECHO
836 d1cd - DC.b CNVRTTERM
837 d1cd ENDIF
838 d1cd 77 DC.b CNVRTTERM
839 d1ce
840 d1ce
841 d1ce ;-------------------------------------------------------------------------
842 d1ce ; one block write
843 d1ce ; undo read convert when writing to tape so tape
844 d1ce ; can be loaded and run on a real actual A1
845 d1ce ;-------------------------------------------------------------------------
846 d1ce A2_WRITECONVERT
847 d1ce a9 00 LDA #0 ; RDCONVERT can be turned off
848 d1d0 cd 01 bc CMP RDCONVERT
849 d1d3 d0 4d BNE A2_WRITECONVERTDONE ; not zero, then skip conversion
850 d1d5 a2 00 LDX #0
851 d1d7 a0 00 LDY #0
852 d1d9 ;
853 d1d9 ; check next string through all of memory
854 d1d9 ;
855 d1d9
856 d1d9 A2_WRITECONVERT_1 ; for this string, scan all of read memory
857 d1d9 8c 06 bc STY savey ;save compare string starting point
858 d1dc
859 d1dc b9 af d1 LDA CNVRT_OUT,Y
860 d1df c9 77 CMP #CNVRTTERM ; Termination character?
861 d1e1 f0 3f BEQ A2_WRITECONVERTDONE ;all done checking, exit
862 d1e3
863 d1e3 ad 11 bc LDA RDSTRTL ; reset block address
864 d1e6 85 26 STA HEX2L
865 d1e8 ad 12 bc LDA RDSTRTH
866 d1eb 85 27 STA HEX2H
867 d1ed
868 d1ed ;
869 d1ed ; restart currnet string
870 d1ed ;
871 d1ed A2_WRITECONVERT_8
872 d1ed a5 26 LDA HEX2L ;save memory starting point
873 d1ef 8d 13 bc STA HEX2LB
874 d1f2 a5 27 LDA HEX2H
875 d1f4 8d 14 bc STA HEX2HB
876 d1f7 ac 06 bc LDY savey
877 d1fa
878 d1fa A2_WRITECONVERT1
879 d1fa a1 26 LDA (HEX2L),X ; fetch byte from memory
880 d1fc d9 af d1 CMP CNVRT_OUT,Y ; compare
881 d1ff f0 11 BEQ A2_WRITECONVERT1_2 ; this byte does match, process
882 d201 ;
883 d201 ; mo match, restart match string
884 d201 ;
885 d201 20 0c d1 JSR A2_INCADDR
886 d204 90 e7 BCC A2_WRITECONVERT_8 ; not end of memory - restart scan for current string
887 d206
888 d206 ;
889 d206 ; end of memory block - go to next string
890 d206 ;
891 d206 A2_WRITECONVERT1_3
892 d206 c8 INY
893 d207 b9 af d1 LDA CNVRT_OUT,Y
894 d20a c9 77 CMP #CNVRTTERM ; Termination character?
895 d20c d0 f8 BNE A2_WRITECONVERT1_3 ; not end of block, keep looking
896 d20e c8 INY ; found end, move to start of next block
897 d20f 4c d9 d1 JMP A2_WRITECONVERT_1 ; rescan memory with next string
898 d212 ;
899 d212 ; match - keep going until mismatch or end of string
900 d212 ;
901 d212 A2_WRITECONVERT1_2
902 d212 c8 INY
903 d213 b9 af d1 LDA CNVRT_OUT,Y
904 d216 c9 77 CMP #CNVRTTERM ; Termination character?
905 d218 f0 13 BEQ A2_WRITECONVERT3 ; end of string - this is match do substitute
906 d21a 20 0c d1 JSR A2_INCADDR ; next memory address
907 d21d 90 db BCC A2_WRITECONVERT1 ; not done - keep scanning
908 d21f
909 d21f 4c 06 d2 JMP A2_WRITECONVERT1_3 ; not a complete match - try next string
910 d222
911 d222 ;-------------------------------------------------------------------------
912 d222 ; Finished with WRITE CONVERSION
913 d222 ;-------------------------------------------------------------------------
914 d222 A2_WRITECONVERTDONE
915 d222 ad 11 bc LDA RDSTRTL ; reset block address
916 d225 85 26 STA HEX2L
917 d227 ad 12 bc LDA RDSTRTH
918 d22a 85 27 STA HEX2H
919 d22c
920 d22c 60 RTS
921 d22d ;-------------------------------------------------------------------------
922 d22d ; Substitute string here
923 d22d ;-------------------------------------------------------------------------
924 d22d
925 d22d A2_WRITECONVERT3 ; match - substitute here
926 d22d ac 06 bc LDY savey
927 d230
928 d230 ad 13 bc LDA HEX2LB ;restore memory starting point
929 d233 85 26 STA HEX2L
930 d235 ad 14 bc LDA HEX2HB
931 d238 85 27 STA HEX2H
932 d23a A2_WRITECONVERT4
933 d23a b9 af d1 LDA CNVRT_OUT,Y
934 d23d c9 77 CMP #CNVRTTERM ; Termination character?
935 d23f f0 ac BEQ A2_WRITECONVERT_8 ; done with sustibute, continue checking
936 d241 b9 90 d1 LDA CNVRT_IN,Y
937 d244 c8 INY
938 d245 81 26 STA (HEX2L),X
939 d247 20 0c d1 JSR A2_INCADDR
940 d24a 4c 3a d2 JMP A2_WRITECONVERT4
941 d24d
942 d24d ;-------------------------------------------------------------------------
943 d24d ; output driver - uses hires memory
944 d24d ;-------------------------------------------------------------------------
945 d24d
946 d24d A2GETCHAR
947 d24d 6c 02 bc JMP (READVECTOR) ;Allow user override of default get char function
948 d250 A2GETCHAR2
949 d250 20 af d2 JSR TOGGLE
950 d253 ad 00 c0 LDA KBD ;Wait for key press
951 d256 10 f5 BPL A2GETCHAR ;No key yet!
952 d258 8d 10 c0 STA KBDCR ;Clear strobe
953 d25b c9 88 CMP #$88 ; left arrow
954 d25d d0 02 BNE A2_GC_NOT_BS ; brnch no
955 d25f a9 df LDA #BS ; convert to _
956 d261 A2_GC_NOT_BS
957 d261 c9 95 CMP #$95 ; right arrow
958 d263 d0 06 BNE A2_GC_RET ; no, exit
959 d265 20 11 d4 JSR CLEAR ; yes, clear screen and
960 d268
961 d268 4c 4d d2 JMP A2GETCHAR ; get next char (this is a special HW emulation
962 d26b ; function so skip call to READVECTOR)
963 d26b A2_GC_RET
964 d26b 60 RTS
965 d26c
966 d26c
967 d26c ;-------------------------------------------------------------------------
968 d26c ; output driver - uses hires memory
969 d26c ;-------------------------------------------------------------------------
970 d26c ;;; Magic Numbers
971 d26c 00 f0 SCRINIT EQU $f0
972 d26c 00 f0 PG0SAVEFLG EQU $f0
973 d26c ;;; Definitions
974 d26c c0 54 HRPG1 EQU $C054
975 d26c c0 55 HRPG2 EQU $C055
976 d26c c0 56 LORES EQU $C056
977 d26c c0 57 HIRES EQU $C057
978 d26c c0 50 TXTCLR EQU $C050
979 d26c c0 51 TXTMOD EQU $C051
980 d26c c0 52 MIXCLR EQU $C052
981 d26c fd 0c GETCHAR EQU $FD0C
982 d26c
983 d26c ;;; Page Zero Temps (8 locations reserved)
984 d26c 00 00 TRGLOW EQU $00
985 d26c 00 01 TRGHIGH EQU $01
986 d26c 00 02 SRCLOW EQU $02
987 d26c 00 03 SRCHIGH EQU $03
988 d26c 00 05 CNT2 EQU $05
989 d26c 00 06 CNT3 EQU $06
990 d26c
991 d26c ; Last location of low res
992 d26c 07 f8 LASTLOCATION EQU $7F8
993 d26c
994 d26c ;;; Entry point for testing
995 d26c 20 83 d3 START JSR INIT
996 d26f 20 0c fd L0 JSR GETCHAR
997 d272 20 47 d4 JSR PUTCH
998 d275 4c 6f d2 JMP L0
999 d278 00 BRK
1000 d279
1001 d279 ;;; Move the cursor
1002 d279 ee 0d bc MVCSR INC CURCOL
1003 d27c ad 0d bc LDA CURCOL
1004 d27f c9 28 CMP #40
1005 d281 10 14 BPL NXTROW
1006 d283 MD
1007 d283 a9 00 LDA #0
1008 d285 cd 00 bc CMP TURBO
1009 d288 d0 0c BNE MR
1010 d28a
1011 d28a a0 00 LDY #0
1012 d28c a2 0c ML0 LDX #12 ; speed fine tuning
1013 d28e e8 ML1 INX
1014 d28f d0 fd BNE ML1
1015 d291 c8 INY
1016 d292 c0 09 CPY #$9
1017 d294 d0 f6 BNE ML0
1018 d296 60 MR RTS
1019 d297 NXTROW
1020 d297 a9 00 LDA #0
1021 d299 8d 0d bc STA CURCOL
1022 d29c
1023 d29c ad 0c bc LDA CURROW ; don't increment current row until in case
1024 d29f ; we are already at bottom of screen
1025 d29f c9 17 CMP #23 ; if a reset comes in, it could leave us on an illegal row
1026 d2a1 30 06 BMI NXTROW2
1027 d2a3
1028 d2a3 20 14 d3 JSR SCROLL ; scrolling bottom line, do not advance CURROW
1029 d2a6 4c 83 d2 JMP MD
1030 d2a9
1031 d2a9 NXTROW2
1032 d2a9 ee 0c bc INC CURROW ; not at bottom of screen advance to next row (CURROW)
1033 d2ac 4c 83 d2 JMP MD
1034 d2af
1035 d2af ;;; Toggle the cursor
1036 d2af TOGGLE
1037 d2af
1038 d2af ee 0e bc INC COUNTER0
1039 d2b2 d0 5f BNE DT
1040 d2b4 ee 0f bc INC COUNTER1
1041 d2b7 d0 5a BNE DT
1042 d2b9 48 PHA
1043 d2ba a9 e0 LDA #CNTSTRT
1044 d2bc 8d 0f bc STA COUNTER1
1045 d2bf ;
1046 d2bf ; if screen has not been cleared- toggle betweeen hi res pages
1047 d2bf ;
1048 d2bf ad 09 bc LDA SCRNCLRD
1049 d2c2 30 1b BMI TOGGLE2
1050 d2c4 ;
1051 d2c4 ; toggle from hi-res to low-res
1052 d2c4 ;
1053 d2c4 ad 10 bc LDA CURSOR
1054 d2c7 d0 0b BNE TOGGLE1
1055 d2c9 a9 20 LDA #32
1056 d2cb 8d 10 bc STA CURSOR
1057 d2ce ad 54 c0 LDA HRPG1
1058 d2d1 4c 12 d3 JMP TOGGLE4
1059 d2d4
1060 d2d4 TOGGLE1
1061 d2d4 a9 00 LDA #0
1062 d2d6 8d 10 bc STA CURSOR
1063 d2d9 ad 55 c0 LDA HRPG2
1064 d2dc 4c 12 d3 JMP TOGGLE4
1065 d2df ;
1066 d2df ; else toggle cursor
1067 d2df ;
1068 d2df TOGGLE2
1069 d2df 8e 07 bc STX savex
1070 d2e2 8c 06 bc STY savey
1071 d2e5 20 1a d5 JSR SAVPG0
1072 d2e8
1073 d2e8 ad 10 bc LDA CURSOR
1074 d2eb d0 05 BNE SETSPC
1075 d2ed a9 20 LDA #32
1076 d2ef 4c f4 d2 JMP DRWCUR
1077 d2f2 a9 00 SETSPC LDA #0
1078 d2f4 8d 10 bc DRWCUR STA CURSOR
1079 d2f7 ae 0d bc LDX CURCOL
1080 d2fa ac 0c bc LDY CURROW
1081 d2fd 20 ed d4 JSR GETBLOK
1082 d300 ae 10 bc LDX CURSOR
1083 d303 20 ca d4 JSR GETCHB
1084 d306 20 b3 d4 JSR DRAWCH
1085 d309 20 3b d5 JSR LODPG0
1086 d30c ae 07 bc LDX savex
1087 d30f ac 06 bc LDY savey
1088 d312 TOGGLE4
1089 d312 68 PLA
1090 d313 60 DT RTS
1091 d314
1092 d314 ;;; Scrolls the screen at the end
1093 d314 SCROLL
1094 d314 ;------------------------------------------------------------------------------------------------------------
1095 d314 ;
1096 d314 ; HIRES is organized
1097 d314 ; into three blocks, offset by 0x28 bytes each, starting at 2000
1098 d314 ; each block holds 8 lines of text, offset by 0x80 bytes
1099 d314 ; each line of text is split into 8 rows of pixels offset by 0x400 bytes
1100 d314 ;
1101 d314 ; this function starts at second from top row copy all pixels to row above it and continues down the screen
1102 d314 ;
1103 d314 ;------------------------------------------------------------------------------------------------------------
1104 d314 ; first block -set up starting addresses
1105 d314 ;
1106 d314 a2 00 ldx #0 ;index into graphics table - starts at zero
1107 d316 ; top loop - 24 lines of characters per page - copy bottom 23 lines (first line scrolls off top)
1108 d316 a9 17 LDA #23
1109 d318 85 05 STA CNT2
1110 d31a
1111 d31a ;
1112 d31a ; next line of text
1113 d31a ;
1114 d31a scr1
1115 d31a bd 5c d5 LDA PG1ROWS,x ; target
1116 d31d 85 01 STA TRGHIGH
1117 d31f e8 inx
1118 d320 bd 5c d5 LDA PG1ROWS,x ; target
1119 d323 85 00 STA TRGLOW
1120 d325 e8 inx
1121 d326 bd 5c d5 LDA PG1ROWS,x ; src
1122 d329 85 03 STA SRCHIGH
1123 d32b e8 inx
1124 d32c bd 5c d5 LDA PG1ROWS,x ; scr
1125 d32f 85 02 STA SRCLOW
1126 d331 ca DEX ;next pass target is current source
1127 d332 a9 08 LDA #8
1128 d334 85 06 STA CNT3
1129 d336 4c 47 d3 JMP scr2.1
1130 d339 ;
1131 d339 ; adjust address to next line of pixels
1132 d339 ;
1133 d339 scr2
1134 d339
1135 d339 a9 04 LDA #$4
1136 d33b 18 CLC
1137 d33c 65 03 ADC SRCHIGH
1138 d33e 85 03 STA SRCHIGH
1139 d340 a9 04 LDA #$4
1140 d342 18 CLC
1141 d343 65 01 ADC TRGHIGH
1142 d345 85 01 STA TRGHIGH
1143 d347 scr2.1
1144 d347 a0 27 LDY #39
1145 d349 ;copy 40 characters that make up a line of pixels
1146 d349 scr3
1147 d349 b1 02 LDA (SRCLOW),y
1148 d34b 91 00 STA (TRGLOW),y
1149 d34d 88 DEY
1150 d34e 10 f9 BPL scr3 ; repeat for 40 characters that make line of pixels
1151 d350 c6 06 DEC CNT3
1152 d352 d0 e5 BNE scr2 ; done with this line of pixels =- goto to next liine of pixels
1153 d354 c6 05 DEC CNT2
1154 d356 d0 c2 BNE scr1 ; done with this line of characters - goto next line of chars
1155 d358
1156 d358 20 5c d3 JSR CLEAR_LINE
1157 d35b 60 RTS
1158 d35c
1159 d35c ;
1160 d35c ; clear line - X contains line #
1161 d35c ;
1162 d35c CLEAR_LINE
1163 d35c bd 5c d5 LDA PG1ROWS,x ; target (was last source)
1164 d35f 85 01 STA TRGHIGH
1165 d361 e8 inx
1166 d362 bd 5c d5 LDA PG1ROWS,x ; target
1167 d365 85 00 STA TRGLOW
1168 d367
1169 d367 a9 08 LDA #8
1170 d369 85 06 STA CNT3
1171 d36b 4c 75 d3 JMP CL4.1
1172 d36e ;
1173 d36e ; adjust address to next line of pixels
1174 d36e ;
1175 d36e CL4
1176 d36e a9 04 LDA #$4
1177 d370 18 CLC
1178 d371 65 01 ADC TRGHIGH
1179 d373 85 01 STA TRGHIGH
1180 d375 CL4.1
1181 d375 a0 27 LDY #39
1182 d377 a9 00 lda #$0
1183 d379 ;copy 40 characters that make up a line of pixels
1184 d379 CL5
1185 d379 91 00 STA (TRGLOW),y
1186 d37b 88 DEY
1187 d37c 10 fb BPL CL5 ; repeat for 40 characters that make line of pixels
1188 d37e c6 06 DEC CNT3
1189 d380 d0 ec BNE CL4 ; done with this line of pixels =- goto to next liine of pixels
1190 d382 60 RTS
1191 d383
1192 d383
1193 d383 ;;; Initialize the graphics system, set cursor and clear the screen
1194 d383 INIT
1195 d383 ;
1196 d383 ; Initialize default keyboard in and video out routines
1197 d383 a9 4a LDA #<PUTCH2 ;first video out
1198 d385 8d 04 bc STA WRITVECTOR
1199 d388 a9 d4 LDA #>PUTCH2
1200 d38a 8d 05 bc STA WRITVECTOR+1
1201 d38d
1202 d38d a9 50 LDA #<A2GETCHAR2 ;now keyboard in
1203 d38f 8d 02 bc STA READVECTOR
1204 d392 a9 d2 LDA #>A2GETCHAR2
1205 d394 8d 03 bc STA READVECTOR+1
1206 d397
1207 d397 ad 00 bc LDA TURBO ;clear computer driven turbo mode
1208 d39a 29 01 AND #TURBOUSR ;but save user turbo mode
1209 d39c 8d 00 bc STA TURBO
1210 d39f ;
1211 d39f ; reset could have occurred during video driver operations
1212 d39f ; attempt to restore page 0 if possible
1213 d39f ; there is a case where we were in the process of saving
1214 d39f ; or restoring page zero variables when reset occurred
1215 d39f ; we cannot recover from that case
1216 d39f ;
1217 d39f 20 3b d5 JSR LODPG0 ;restore page zero variables
1218 d3a2 ;
1219 d3a2 ; determine whether we should emulate power up screen
1220 d3a2 ;
1221 d3a2 a9 f0 LDA #SCRINIT
1222 d3a4 cd 08 bc CMP POWERUPINIT ;have we initialized power up screen
1223 d3a7 d0 12 BNE INITSCREEN ;no, let's do it
1224 d3a9 cd 09 bc CMP SCRNCLRD ;has user cleared the screen?
1225 d3ac d0 0c BNE INITEXIT ;no, leave graphics mode alone
1226 d3ae
1227 d3ae ;
1228 d3ae ; clear screen already done - set HGR PG 2 mode
1229 d3ae ;
1230 d3ae 8d 57 c0 STA HIRES ; set high res pg 2 graphics mode
1231 d3b1 8d 55 c0 STA HRPG2 ; if this is power up, this will be changed below
1232 d3b4 8d 50 c0 STA TXTCLR
1233 d3b7 8d 52 c0 STA MIXCLR
1234 d3ba INITEXIT
1235 d3ba 60 RTS
1236 d3bb ;
1237 d3bb ; initialize lowres page 1 as startup screen
1238 d3bb ;
1239 d3bb
1240 d3bb INITSCREEN
1241 d3bb a9 04 LDA #$04 ;START ADDRESS
1242 d3bd 85 27 STA HEX2H
1243 d3bf a9 00 LDA #$0
1244 d3c1 85 26 STA HEX2L
1245 d3c3
1246 d3c3 a9 0b LDA #$0B ;END ADDRESS
1247 d3c5 85 25 STA HEX1H
1248 d3c7 a9 f8 LDA #$F8
1249 d3c9 85 24 STA HEX1L
1250 d3cb
1251 d3cb a0 00 LDY #0
1252 d3cd
1253 d3cd INIT1
1254 d3cd a9 df LDA #$DF ; underbar
1255 d3cf 91 26 STA (HEX2L),y
1256 d3d1 20 0c d1 JSR A2_INCADDR
1257 d3d4 b0 13 BCS INIT2
1258 d3d6 a9 08 LDA #$08 ; check address range <800 use at sign
1259 d3d8 24 27 BIT HEX2H ; >800 use space
1260 d3da d0 04 BNE INIT1_1
1261 d3dc a9 c0 LDA #$C0 ; at sign
1262 d3de 30 02 BMI INIT1_2
1263 d3e0 INIT1_1
1264 d3e0 a9 a0 LDA #$A0 ; space
1265 d3e2 INIT1_2
1266 d3e2 91 26 STA (HEX2L),y ; save it
1267 d3e4 20 0c d1 JSR A2_INCADDR
1268 d3e7 90 e4 BCC INIT1
1269 d3e9
1270 d3e9 INIT2
1271 d3e9
1272 d3e9 a9 00 LDA #0
1273 d3eb 8d 09 bc STA SCRNCLRD ; now indicate that screen has been not cleared
1274 d3ee 8d 0c bc STA CURROW
1275 d3f1 8d 0d bc STA CURCOL
1276 d3f4 8d 00 bc STA TURBO ; default not turbo mode
1277 d3f7 8d 01 bc STA RDCONVERT ; default convert cassette reads
1278 d3fa a9 e0 LDA #CNTSTRT
1279 d3fc 8d 0f bc STA COUNTER1
1280 d3ff
1281 d3ff 8d 56 c0 STA LORES ; set lowres pg 1 graphics mode for start up screen
1282 d402 8d 54 c0 STA HRPG1 ; use page 1
1283 d405 8d 51 c0 STA TXTMOD
1284 d408 8d 52 c0 STA MIXCLR
1285 d40b
1286 d40b a9 f0 LDA #SCRINIT
1287 d40d 8d 08 bc STA POWERUPINIT ; indicate power on init done
1288 d410
1289 d410 60 RTS
1290 d411
1291 d411 ;;; Clears hires page 1
1292 d411 CLEAR
1293 d411 8c 06 bc STY savey
1294 d414 8e 07 bc STX savex
1295 d417 20 1a d5 JSR SAVPG0
1296 d41a
1297 d41a a2 00 LDX #0
1298 d41c
1299 d41c CLEAR2
1300 d41c 20 5c d3 JSR CLEAR_LINE
1301 d41f e8 INX
1302 d420 e0 30 CPX #48
1303 d422 d0 f8 BNE CLEAR2
1304 d424 ;; page cleared
1305 d424
1306 d424 a9 f0 LDA #SCRINIT
1307 d426 8d 09 bc STA SCRNCLRD ;indicate screen cleared
1308 d429
1309 d429 8d 57 c0 STA HIRES ; set high res pg 2 graphics mode
1310 d42c 8d 55 c0 STA HRPG2
1311 d42f 8d 50 c0 STA TXTCLR
1312 d432 8d 52 c0 STA MIXCLR
1313 d435
1314 d435 a9 00 LDA #$00
1315 d437 ;
1316 d437 ; cursor to top left
1317 d437 ;
1318 d437 8d 0c bc STA CURROW
1319 d43a 8d 0d bc STA CURCOL
1320 d43d
1321 d43d 20 3b d5 JSR LODPG0
1322 d440 ac 06 bc LDY savey
1323 d443 ae 07 bc LDX savex
1324 d446 60 RTS
1325 d447
1326 d447 ;;; Prints character from A to the screen
1327 d447 PUTCH
1328 d447 6c 04 bc JMP (WRITVECTOR) ;allow user override of default video out routine
1329 d44a PUTCH2
1330 d44a 48 PHA
1331 d44b 8c 06 bc STY savey
1332 d44e 8e 07 bc STX savex
1333 d451
1334 d451 ac 09 bc LDY SCRNCLRD
1335 d454 10 27 BPL PUTCH_DROP ;if plus, screen has not been cleared, so drop
1336 d456
1337 d456 20 1a d5 JSR SAVPG0
1338 d459 ;; drop the high bit
1339 d459 29 7f AND #$7F
1340 d45b ;; check for return
1341 d45b c9 0d CMP #$0D
1342 d45d f0 26 BEQ ENTERKY
1343 d45f ;; it's a regular key
1344 d45f 20 0d d5 JSR GETCODE
1345 d462 8d 0a bc STA CHAR
1346 d465 ;; get the block address
1347 d465 ae 0d bc LDX CURCOL
1348 d468 ac 0c bc LDY CURROW
1349 d46b 20 ed d4 JSR GETBLOK
1350 d46e ;; get block bytes
1351 d46e ae 0a bc LDX CHAR
1352 d471 20 ca d4 JSR GETCHB
1353 d474 ;; render the char to the block
1354 d474 20 b3 d4 JSR DRAWCH
1355 d477 ;; restore state and exit
1356 d477 20 79 d2 PD JSR MVCSR
1357 d47a 20 3b d5 JSR LODPG0
1358 d47d
1359 d47d PUTCH_DROP
1360 d47d ac 06 bc LDY savey
1361 d480 ae 07 bc LDX savex
1362 d483 68 PLA
1363 d484 60 RTS
1364 d485
1365 d485 ENTERKY ; print spaces until end of line (use turbo mode)
1366 d485 ad 00 bc LDA TURBO
1367 d488 09 02 ORA #TURBOCMP ; set computer turbo mode
1368 d48a 8d 00 bc STA TURBO ; turbo mode to clear end of line
1369 d48d ENTERKY1
1370 d48d ac 0c bc LDY CURROW
1371 d490 ae 0d bc LDX CURCOL
1372 d493 e0 28 CPX #40
1373 d495 f0 11 BEQ ENTERKY_EXIT
1374 d497 20 ed d4 JSR GETBLOK
1375 d49a a2 00 LDX #0 ; space key
1376 d49c 20 ca d4 JSR GETCHB
1377 d49f 20 b3 d4 JSR DRAWCH
1378 d4a2 ee 0d bc INC CURCOL
1379 d4a5 4c 8d d4 JMP ENTERKY1
1380 d4a8
1381 d4a8 ENTERKY_EXIT
1382 d4a8 ad 00 bc LDA TURBO
1383 d4ab 29 01 AND #TURBOUSR ; reset computer turbo mode, saving user mode
1384 d4ad 8d 00 bc STA TURBO ;
1385 d4b0 4c 77 d4 JMP PD
1386 d4b3
1387 d4b3 ;;; Draws character to block
1388 d4b3 a2 00 DRAWCH LDX #0
1389 d4b5 8a L6 TXA
1390 d4b6 a8 TAY
1391 d4b7 b1 02 LDA (SRCLOW),Y
1392 d4b9 a0 00 LDY #0
1393 d4bb 91 00 STA (TRGLOW),Y
1394 d4bd e8 INX
1395 d4be a5 01 LDA TRGHIGH
1396 d4c0 18 CLC
1397 d4c1 69 04 ADC #$4
1398 d4c3 85 01 STA TRGHIGH
1399 d4c5 e0 08 CPX #8
1400 d4c7 30 ec BMI L6
1401 d4c9 60 RTS
1402 d4ca
1403 d4ca ;;; Get byte for char in X
1404 d4ca a0 8c GETCHB LDY #<SPCODE
1405 d4cc 84 02 STY SRCLOW
1406 d4ce a0 d5 LDY #>SPCODE
1407 d4d0 84 03 STY SRCHIGH
1408 d4d2 e0 00 L5 CPX #0
1409 d4d4 f0 16 BEQ D
1410 d4d6 ca DEX
1411 d4d7 a9 08 LDA #8
1412 d4d9 18 CLC
1413 d4da 65 02 ADC SRCLOW
1414 d4dc 85 02 STA SRCLOW
1415 d4de b0 03 BCS AC
1416 d4e0 4c d2 d4 JMP L5
1417 d4e3 a9 00 AC LDA #0
1418 d4e5 65 03 ADC SRCHIGH
1419 d4e7 85 03 STA SRCHIGH
1420 d4e9 4c d2 d4 JMP L5
1421 d4ec 60 D RTS
1422 d4ed
1423 d4ed ;;; Gets the block address at X,Y
1424 d4ed 98 GETBLOK TYA
1425 d4ee 20 ff d4 JSR GETROW
1426 d4f1 ;; add the column
1427 d4f1 8a TXA
1428 d4f2 18 CLC
1429 d4f3 65 00 ADC TRGLOW
1430 d4f5 85 00 STA TRGLOW
1431 d4f7 b0 01 BCS A1
1432 d4f9 60 RTS
1433 d4fa a9 00 A1 LDA #0
1434 d4fc 65 01 ADC TRGHIGH
1435 d4fe 60 RTS
1436 d4ff
1437 d4ff ;;; Gets the row (A) address
1438 d4ff 0a GETROW ASL ; multiply row by two, there are two bytes per address
1439 d500 a8 TAY
1440 d501 b9 5c d5 LDA PG1ROWS,Y
1441 d504 85 01 STA TRGHIGH
1442 d506 c8 INY
1443 d507 b9 5c d5 LDA PG1ROWS,Y
1444 d50a 85 00 STA TRGLOW
1445 d50c 60 RTS
1446 d50d
1447 d50d ;;; Converts ASCII code to table index
1448 d50d 38 GETCODE SEC
1449 d50e e9 20 SBC #$20
1450 d510 30 05 BMI NC
1451 d512 c9 40 CMP #$40
1452 d514 10 01 BPL NC
1453 d516 60 RTS
1454 d517 a9 00 NC LDA #0
1455 d519 60 RTS
1456 d51a
1457 d51a ;;; Store page zero data
1458 d51a 48 SAVPG0 PHA
1459 d51b 8e 0b bc STX TMP1
1460 d51e
1461 d51e a9 f0 LDA #PG0SAVEFLG ;check saved flag
1462 d520 cd 25 bc CMP PG0SAVD
1463 d523 f0 11 BEQ SD ;already saved, just exit
1464 d525
1465 d525 a2 00 LDX #0
1466 d527 b5 00 L1 LDA $00,X
1467 d529 9d 15 bc STA TMPG0,X
1468 d52c e8 INX
1469 d52d e0 08 CPX #$8
1470 d52f d0 f6 BNE L1
1471 d531
1472 d531 a9 f0 LDA #PG0SAVEFLG ;set save flag to saved after completely saved
1473 d533 8d 25 bc STA PG0SAVD ;this way, if a reset comes in before we are done
1474 d536 ;we will not corrupt zero page
1475 d536 ;as the reset code restores zero page if flag set
1476 d536
1477 d536 ae 0b bc SD LDX TMP1
1478 d539 68 PLA
1479 d53a 60 RTS
1480 d53b
1481 d53b ;;; Restore page zero data
1482 d53b LODPG0
1483 d53b 48 PHA
1484 d53c 8e 0b bc STX TMP1
1485 d53f
1486 d53f a9 f0 LDA #PG0SAVEFLG ;checked saved flag
1487 d541 cd 25 bc CMP PG0SAVD
1488 d544 d0 11 BNE LD ;not saved, exit
1489 d546
1490 d546 a2 00 LDX #0
1491 d548 bd 15 bc L2 LDA TMPG0,X
1492 d54b 95 00 STA $00,X
1493 d54d e8 INX
1494 d54e e0 08 CPX #$8
1495 d550 d0 f6 BNE L2
1496 d552
1497 d552 a9 0f LDA #<(~PG0SAVEFLG) ;clear saved flag to not saved after completely restored
1498 d554 ;this way, if a reset comes in before we are done
1499 d554 8d 25 bc STA PG0SAVD ;as the reset code restores zero page if flag set
1500 d557
1501 d557 ae 0b bc LD LDX TMP1
1502 d55a 68 PLA
1503 d55b 60 RTS
1504 d55c
1505 d55c
1506 d55c ;;; tables
1507 d55c 40 00 40 80*PG1ROWS HEX 4000 4080 4100 4180 4200 4280 4300 4380 4028 40A8 4128 41A8 4228 42A8 4328 43A8 4050 40D0 4150 41D0 4250 42D0 4350 43D0
1508 d58c 00 00 00 00*SPCODE HEX 00 00 00 00 00 00 00 00
1509 d594 00 08 08 08*EXPCODE HEX 00 08 08 08 08 08 00 08
1510 d59c 00 14 14 14*QUOCODE HEX 00 14 14 14 00 00 00 00
1511 d5a4 00 14 14 3e*NUMCODE HEX 00 14 14 3e 14 3e 14 14
1512 d5ac 00 08 3c 0a*STRCODE HEX 00 08 3c 0a 1c 28 1e 08
1513 d5b4 00 06 26 10*PERCODE HEX 00 06 26 10 08 04 32 30
1514 d5bc 00 04 0a 0a*AMPCODE HEX 00 04 0a 0a 04 2a 12 2c
1515 d5c4 00 08 08 08*SQCODE HEX 00 08 08 08 00 00 00 00
1516 d5cc 00 08 04 02*RPCODE HEX 00 08 04 02 02 02 04 08
1517 d5d4 00 08 10 20*LPCODE HEX 00 08 10 20 20 20 10 08
1518 d5dc 00 08 2a 1c*STACODE HEX 00 08 2a 1c 08 1c 2a 08
1519 d5e4 00 00 08 08*PLSCODE HEX 00 00 08 08 3e 08 08 00
1520 d5ec 00 00 00 00*CMACODE HEX 00 00 00 00 00 08 08 04
1521 d5f4 00 00 00 00*MINCODE HEX 00 00 00 00 3e 00 00 00
1522 d5fc 00 00 00 00*DOTCODE HEX 00 00 00 00 00 00 00 08
1523 d604 00 00 20 10*FSCODE HEX 00 00 20 10 08 04 02 00
1524 d60c 00 1c 22 32*0CODE HEX 00 1c 22 32 2a 26 22 1c
1525 d614 00 08 0c 08*1CODE HEX 00 08 0c 08 08 08 08 1c
1526 d61c 00 1c 22 20*2CODE HEX 00 1c 22 20 18 04 02 3e
1527 d624 00 3e 20 10*3CODE HEX 00 3e 20 10 18 20 22 1c
1528 d62c 00 10 18 14*4CODE HEX 00 10 18 14 12 3e 10 10
1529 d634 00 3e 02 1e*5CODE HEX 00 3e 02 1e 20 20 22 1c
1530 d63c 00 38 04 02*6CODE HEX 00 38 04 02 1e 22 22 1c
1531 d644 00 3e 20 10*7CODE HEX 00 3e 20 10 08 04 04 04
1532 d64c 00 1c 22 22*8CODE HEX 00 1c 22 22 1c 22 22 1c
1533 d654 00 1c 22 22*9CODE HEX 00 1c 22 22 3c 20 10 0e
1534 d65c 00 00 00 08*COLCODE HEX 00 00 00 08 00 08 00 00
1535 d664 00 00 00 08*SEMCODE HEX 00 00 00 08 00 08 08 04
1536 d66c 00 10 08 04*LTCODE HEX 00 10 08 04 02 04 08 10
1537 d674 00 00 00 3e*EQCODE HEX 00 00 00 3e 00 3e 00 00
1538 d67c 00 04 08 10*GTCODE HEX 00 04 08 10 20 10 08 04
1539 d684 00 1c 22 10*QESCODE HEX 00 1c 22 10 08 08 00 08
1540 d68c 00 1c 22 2a*ATCODE HEX 00 1C 22 2A 3A 1A 02 3C
1541 d694 00 08 14 22*ACODE HEX 00 08 14 22 22 3e 22 22
1542 d69c 00 1e 22 22*BCODE HEX 00 1e 22 22 1e 22 22 1e
1543 d6a4 00 1c 22 02*CCODE HEX 00 1c 22 02 02 02 22 1c
1544 d6ac 00 1e 22 22*DCODE HEX 00 1e 22 22 22 22 22 1e
1545 d6b4 00 3e 02 02*ECODE HEX 00 3e 02 02 1e 02 02 3e
1546 d6bc 00 3e 02 02*FCODE HEX 00 3e 02 02 1e 02 02 02
1547 d6c4 00 3c 02 02*GCODE HEX 00 3c 02 02 02 32 22 3c
1548 d6cc 00 22 22 22*HCODE HEX 00 22 22 22 3e 22 22 22
1549 d6d4 00 1c 08 08*ICODE HEX 00 1c 08 08 08 08 08 1c
1550 d6dc 00 20 20 20*JCODE HEX 00 20 20 20 20 20 22 1c
1551 d6e4 00 22 12 0a*KCODE HEX 00 22 12 0a 06 0a 12 22
1552 d6ec 00 02 02 02*LCODE HEX 00 02 02 02 02 02 02 3e
1553 d6f4 00 22 36 2a*MCODE HEX 00 22 36 2a 2a 22 22 22
1554 d6fc 00 22 22 26*NCODE HEX 00 22 22 26 2a 32 22 22
1555 d704 00 1c 22 22*OCODE HEX 00 1c 22 22 22 22 22 1c
1556 d70c 00 1e 22 22*PCODE HEX 00 1e 22 22 1e 02 02 02
1557 d714 00 1c 22 22*QCODE HEX 00 1c 22 22 22 2a 12 2c
1558 d71c 00 1e 22 22*RCODE HEX 00 1e 22 22 1e 0a 12 22
1559 d724 00 1c 22 02*SCODE HEX 00 1c 22 02 1c 20 22 1c
1560 d72c 00 3e 08 08*TCODE HEX 00 3e 08 08 08 08 08 08
1561 d734 00 22 22 22*UCODE HEX 00 22 22 22 22 22 22 1c
1562 d73c 00 22 22 22*VCODE HEX 00 22 22 22 22 22 14 08
1563 d744 00 22 22 22*WCODE HEX 00 22 22 22 2a 2a 36 22
1564 d74c 00 22 22 14*XCODE HEX 00 22 22 14 08 14 22 22
1565 d754 00 22 22 14*YCODE HEX 00 22 22 14 08 08 08 08
1566 d75c 00 3e 20 10*ZCODE HEX 00 3e 20 10 08 04 02 3e
1567 d764 00 3e 06 06*LBCODE HEX 00 3e 06 06 06 06 06 3e
1568 d76c 00 00 02 04*BSCODE HEX 00 00 02 04 08 10 20 00
1569 d774 00 3e 30 30*RBCODE HEX 00 3e 30 30 30 30 30 3e
1570 d77c 00 00 00 08*CRTCODE HEX 00 00 00 08 14 22 00 00
1571 d784 00 00 00 00*UNDCODE HEX 00 00 00 00 00 00 00 3e
1572 d78c
1573 d78c
1574 d78c
1575 d78c ;------------------------------------------------------------------------
1576 d78c ; BASIC SUPPORT FUNCTIONs
1577 d78c ; peek and poke of the PIA is emulated
1578 d78c ; using A2 hardware drivers
1579 d78c ;------------------------------------------------------------------------
1580 d78c ;------------------------------------------------------------------------
1581 d78c ; POKE of D012 is emulated by calling
1582 d78c ; A2 putchar routine
1583 d78c ;------------------------------------------------------------------------
1584 d78c 00 ce ACC EQU $ce ; must be same as basic "acc"
1585 d78c A2POKE
1586 d78c 20 34 ee JSR getbyte
1587 d78f a5 ce LDA ACC
1588 d791 48 PHA
1589 d792 20 15 e7 JSR get16bit
1590 d795 a9 d0 LDA #$D0
1591 d797 c5 cf CMP ACC+1
1592 d799 f0 04 BEQ A2POKE2
1593 d79b A2POKE1
1594 d79b 68 PLA
1595 d79c 91 ce STA (ACC),Y
1596 d79e 60 RTS
1597 d79f A2POKE2
1598 d79f a9 12 LDA #$12
1599 d7a1 c5 ce CMP ACC
1600 d7a3 d0 f6 BNE A2POKE1
1601 d7a5 ;------------------------------------------------------------------------
1602 d7a5 ; Poke D012 == A2 ECHO CALL
1603 d7a5 ;------------------------------------------------------------------------
1604 d7a5 68 PLA
1605 d7a6 4c ef ff JMP ECHO
1606 d7a9
1607 d7a9 ;------------------------------------------------------------------------
1608 d7a9 ; PEEK of D012, D011 and D010 is emulated by using
1609 d7a9 ; equivalent A2 functionality
1610 d7a9 ;------------------------------------------------------------------------
1611 d7a9
1612 d7a9 A2PEEK
1613 d7a9 20 15 e7 JSR get16bit
1614 d7ac a9 d0 LDA #$D0
1615 d7ae c5 cf CMP ACC+1
1616 d7b0 f0 07 BEQ A2PEEK3
1617 d7b2 A2PEEK1
1618 d7b2 b1 ce LDA (ACC),Y
1619 d7b4 A2PEEK2
1620 d7b4 94 9f STY syn_stk_l+31,X
1621 d7b6 4c 08 e7 JMP push_ya_noun_stk
1622 d7b9
1623 d7b9 ;------------------------------------------------------------------------
1624 d7b9 ; Peek D012 == determine if terminal is ready for output
1625 d7b9 ; in the A2 memory mapped video driver case - the answer
1626 d7b9 ; is always yes -so return positive number(or zero in this case)
1627 d7b9 ;------------------------------------------------------------------------
1628 d7b9 A2PEEK3
1629 d7b9 a9 12 LDA #$12
1630 d7bb c5 ce CMP ACC
1631 d7bd d0 05 BNE A2PEEK4
1632 d7bf a9 00 LDA #$00
1633 d7c1 4c b4 d7 JMP A2PEEK2
1634 d7c4 ;------------------------------------------------------------------------
1635 d7c4 ; Peek D011 == A2 read c000 (does keyboard have char, yes if MSB set)
1636 d7c4 ;------------------------------------------------------------------------
1637 d7c4 A2PEEK4
1638 d7c4 a9 11 LDA #$11
1639 d7c6 c5 ce CMP ACC
1640 d7c8 d0 06 BNE A2PEEK5
1641 d7ca ad 00 c0 LDA KBD
1642 d7cd 4c b4 d7 JMP A2PEEK2
1643 d7d0 ;------------------------------------------------------------------------
1644 d7d0 ; Peek D010 == A2 getchar (also clears strobe)
1645 d7d0 ;------------------------------------------------------------------------
1646 d7d0 A2PEEK5
1647 d7d0 a9 10 LDA #$10
1648 d7d2 c5 ce CMP ACC
1649 d7d4 d0 dc BNE A2PEEK1
1650 d7d6 ad 00 c0 LDA KBD
1651 d7d9 8d 10 c0 STA KBDCR
1652 d7dc 4c b4 d7 JMP A2PEEK2
1653 d7df
1654 d7df - IFCONST BLD4RAM
1655 d7df - STORAGE
1656 d7df ENDIF
1657 d7df ENDIF ; end of A2 driver code
1658 d7df ;------------------------------------------------------------------------
1659 d7df ; VERSION
1660 d7df ;------------------------------------------------------------------------
1661 d7df - IFCONST BLD4RAM
1662 d7df - ORG $6FFE
1663 d7df ELSE
1664 dffe ORG $DFFE
1665 dffe ENDIF
1666 dffe 05 01 DC.w $0105
1667 e000
1668 e000 ;------------------------------------------------------------------------
1669 e000 ; BASIC
1670 e000 ;------------------------------------------------------------------------
------- FILE a1basic-universal.asm LEVEL 2 PASS 2
0 e000 INCLUDE a1basic-universal.asm
1 e000 PROCESSOR 6502
2 e000 LIST ON
3 e000 ;
4 e000 ;------------------------------------------------------------------------
5 e000 ; Apple 1 Basic by Steve Wozniak
6 e000 ;
7 e000 ; This source was derived from BASIC disassembly done by Eric Smith.
8 e000 ; This derivation is reproduced and distributed with permission of
9 e000 ; Eric Smith
10 e000 ;
11 e000 ; Eric Smith's disassembly can be found at
12 e000 ; http://www.brouhaha.com/~eric/retrocomputing/apple/apple1/basic/
13 e000 ;
14 e000 ; Do not reproduce or distribute without permission
15 e000 ;
16 e000 ; copyright 2010, Mike Willegal
17 e000 ; copyright 2003, Eric Smith
18 e000 ;
19 e000 ;------------------------------------------------------------------------
20 e000 ; Disassembly of Apple 1 BASIC
21 e000 ; 17-Sep-2003
22 e000 ; Apple 1 BASIC was written by Steve Wozniak
23 e000 ; This disassembly is copyright 2003 Eric Smith <eric@brouhaha.com>
24 e000 ; http://www.brouhaha.com/~eric/retrocomputing/apple/apple1/basic/
25 e000 ;------------------------------------------------------------------------
26 e000
27 e000 ;------------------------------------------------------------------------
28 e000 ; build with 6502 assembler called DASM using the following command line
29 e000 ;
30 e000 ; Huston's version of Basic (may be latest version available)
31 e000 ; http://www.apple1notes.com/Home/Programs.html
32 e000 ;./dasm a1basic.asm -DHUSTNBASIC=0 -oa1hbas.o -la1hbas.lst
33 e000 ;
34 e000 ; Sander's version of Basic (same as Eric Smith's original disassembly)
35 e000 ; http://www.apple1notes.com/Home/Programs.html
36 e000 ;./dasm a1basic.asm -DSNDERBASIC=0 -oa1sbas.o -la1sbas.lst
37 e000 ;
38 e000 ; Vince Briel's version of Basic
39 e000 ; (can't find the link right now)
40 e000 ;./dasm a1basic.asm -DBRIELBASIC=0 -oa1bbas.o -la1bbas.lst
41 e000 ;
42 e000 ; Pagetable version of Basic (only PIA address different from Briel's version)
43 e000 ; http://www.pagetable.com/?p=32
44 e000 ;./dasm a1basic.asm -DPAGETBASIC=0 -oa1pbas.o -la1pbas.lst
45 e000 ;
46 e000 ;------------------------------------------------------------------------
47 e000 ;-------------------------------------------------------------------------
48 e000 ; Defines - this code can be built one of four ways
49 e000 ; 1. clone/real Apple 1 HW
50 e000 ; 2. runs in ram of real or virtual Apple 2
51 e000 ; 3. runs in virtual apple 2 as ROM
52 e000 ; 4. runs in plug in board of real Apple 2
53 e000 ;
54 e000 ; select one of these three options
55 e000 ;-------------------------------------------------------------------------
56 e000
57 e000 ;BLD4APPLE1 EQU 0 ;ACTUAL APPLE 1 or CLONE
58 e000 ;BLD4RAM EQU 0 ;RAM of virtual or real A2
59 e000 ;BLD4EMULROM EQU 0 ;ROM of virtual A2
60 e000 ;BLD4ROMBD EQU 0 ;ROM board in Real A2
61 e000
62 e000
63 e000 ;------------------------------------------------------------------------
64 e000 ; BASIC source taken from http://www.brouhaha.com
65 e000 ; IFCONST added to allow building Apple 1 basic version found
66 e000 ; on Vince Briels site
67 e000 ;------------------------------------------------------------------------
68 e000 ; up to four versions of Apple 1 Basic Known
69 e000 ; use defines to control which one we build
70 e000 ;SNDERBASIC EQU 0 ;from Wendell Sander's site (DEFAULT)
71 e000 ;SMITHBASIC EQU 0 ;original source from brouhaha.com
72 e000 ;BRIELBASIC EQU 0 ;version used in Replica 1
73 e000 ;HUSTNBASIC EQU 0 ;huston version from Wendell's site
74 e000
75 e000
76 e000 ;------------------------------------------------------------------------
77 e000 ; Disassembly of Apple 1 BASIC
78 e000 ; 17-Sep-2003
79 e000 ; Apple 1 BASIC was written by Steve Wozniak
80 e000 ; This disassembly is copyright 2003 Eric Smith <eric@brouhaha.com>
81 e000 ; http://www.brouhaha.com/~eric/retrocomputing/apple/apple1/basic/
82 e000 ;------------------------------------------------------------------------
83 e000
84 e000 00 00 LOCZERO EQU $00
85 e000 00 1d Z1d EQU $1d
86 e000 00 24 ch EQU $24
87 e000 00 25 cv EQU $25
88 e000 00 48 zp48 EQU $48
89 e000 00 49 zp49 EQU $49
90 e000 00 4a lomem EQU $4a
91 e000 00 4b zp4b EQU $4b
92 e000 00 4c himem EQU $4c
93 e000 00 4d zp4d EQU $4d
94 e000 00 4e rnd EQU $4e
95 e000 00 50 noun_stk_l EQU $50
96 e000 00 58 syn_stk_h EQU $58
97 e000 00 60 zp60 EQU $60
98 e000 00 78 noun_stk_h_str EQU $78
99 e000 00 80 syn_stk_l EQU $80
100 e000 00 85 zp85 EQU $85
101 e000 00 a0 noun_stk_h_int EQU $a0
102 e000 00 a8 txtndxstk EQU $a8
103 e000 00 c8 text_index EQU $c8
104 e000 00 c9 leadbl EQU $c9
105 e000 00 ca pp EQU $ca
106 e000 00 cb zpcb EQU $cb
107 e000 00 cc pv EQU $cc
108 e000 00 ce acc EQU $ce
109 e000 00 cf zpcf EQU $cf
110 e000 00 d0 srch EQU $d0
111 e000 00 d1 tokndxstk EQU $d1
112 e000 00 d2 srch2 EQU $d2
113 e000 00 d4 if_flag EQU $d4
114 e000 00 d5 cr_flag EQU $d5
115 e000 00 d6 current_verb EQU $d6
116 e000 00 d7 precedence EQU $d7
117 e000 00 d8 x_save EQU $d8
118 e000 00 d9 run_flag EQU $d9
119 e000 00 da aux EQU $da
120 e000 00 dc pline EQU $dc
121 e000 00 e0 pverb EQU $e0
122 e000 00 e2 p1 EQU $e2
123 e000 00 e4 p2 EQU $e4
124 e000 00 e6 p3 EQU $e6
125 e000 00 f1 token_index EQU $f1
126 e000 00 f2 pcon EQU $f2
127 e000 00 f4 auto_inc EQU $f4
128 e000 00 f6 auto_ln EQU $f6
129 e000 00 f8 auto_flag EQU $f8
130 e000 00 f9 char EQU $f9
131 e000 00 fa leadzr EQU $fa
132 e000 00 fb for_nest_count EQU $fb
133 e000 00 fc gosub_nest_count EQU $fc
134 e000 00 fd synstkdx EQU $fd
135 e000 00 fe synpag EQU $fe
136 e000 01 00 gstk_pverbl EQU $0100
137 e000 01 08 gstk_pverbh EQU $0108
138 e000 01 10 gstk_plinel EQU $0110
139 e000 01 18 gstk_plineh EQU $0118
140 e000 01 20 fstk_varl EQU $0120
141 e000 01 28 fstk_varh EQU $0128
142 e000 01 30 fstk_stepl EQU $0130
143 e000 01 38 fstk_steph EQU $0138
144 e000 01 40 fstk_plinel EQU $0140
145 e000 01 48 fstk_plineh EQU $0148
146 e000 01 50 fstk_pverbl EQU $0150
147 e000 01 58 fstk_pverbh EQU $0158
148 e000 01 60 fstk_tol EQU $0160
149 e000 01 68 fstk_toh EQU $0168
150 e000 02 00 buffer EQU $0200
151 e000
152 e000 - IFCONST BLD4APPLE1
153 e000 - IFCONST SMITHBASIC
154 e000 -DSP EQU $D0F2 ;DISPLAY port in PIA
155 e000 -KBDCR EQU $D0F1 ;Keyboard control port
156 e000 -KBD EQU $D0F0 ;KEYBOARD data port
157 e000 - ENDIF
158 e000 - IFCONST BRIELBASIC
159 e000 -DSP EQU $D012 ;DISPLAY port in PIA
160 e000 -KBDCR EQU $D011 ;Keyboard control port (WS BASIC)
161 e000 -KBD EQU $D010 ;KEYBOARD data port
162 e000 - ENDIF
163 e000 - IFCONST SNDERBASIC
164 e000 -DSP EQU $D0F2 ;DISPLAY port in PIA
165 e000 -KBDCR EQU $D011 ;Keyboard control port (WS BASIC)
166 e000 -KBD EQU $D010 ;KEYBOARD data port
167 e000 - ENDIF
168 e000 - IFCONST HUSTNBASIC
169 e000 -DSP EQU $D0F2 ;DISPLAY port in PIA
170 e000 -KBDCR EQU $D011 ;Keyboard control port (WS BASIC)
171 e000 -KBD EQU $D010 ;KEYBOARD data port
172 e000 - ENDIF
173 e000 -
174 e000 ENDIF
175 e000 - IFCONST BLD4RAM
176 e000 - ORG $7000
177 e000 ELSE
178 e000 ORG $E000
179 e000 ENDIF
180 e000
181 e000 4c b0 e2 Pe000 JMP cold
182 e003
183 e003 rdkey
184 e003 - IFCONST BLD4APPLE1
185 e003 - LDA KBDCR ;Wait for key press
186 e003 - BPL rdkey ;No key yet!
187 e003 - LDA KBD ;Clear strobe
188 e003 ELSE
189 e003 20 4d d2 JSR A2GETCHAR
190 e006 ea NOP
191 e007 ea NOP
192 e008 ea NOP
193 e009 ea NOP
194 e00a ea NOP
195 e00b ENDIF
196 e00b 60 RTS
197 e00c
198 e00c 8a Se00c TXA
199 e00d 29 20 AND #$20 ; 32
200 e00f f0 23 BEQ Le034
201 e011
202 e011 a9 a0 Se011 LDA #$a0 ; 160
203 e013 85 e4 STA p2
204 e015 4c c9 e3 JMP cout
205 e018
206 e018 a9 20 Se018 LDA #$20 ; 32
207 e01a
208 e01a c5 24 Se01a CMP ch
209 e01c b0 0c BCS nextbyte
210 e01e a9 8d LDA #$8d ; 141 .
211 e020 a0 07 LDY #$07 ; 7 .
212 e022 20 c9 e3 Le022 JSR cout
213 e025 a9 a0 LDA #$a0 ; 160
214 e027 88 DEY
215 e028 d0 f8 BNE Le022
216 e02a
217 e02a a0 00 nextbyte LDY #$00 ; 0 .
218 e02c b1 e2 LDA (p1),Y
219 e02e e6 e2 INC p1
220 e030 d0 02 BNE Le034
221 e032 e6 e3 INC p1+1
222 e034 60 Le034 RTS
223 e035
224 e035 20 15 e7 list_comman JSR get16bit
225 e038 20 76 e5 JSR find_line2
226 e03b a5 e2 Le03b LDA p1
227 e03d c5 e6 CMP p3
228 e03f a5 e3 LDA p1+1
229 e041 e5 e7 SBC p3+1
230 e043 b0 ef BCS Le034
231 e045 20 6d e0 JSR list_line
232 e048 4c 3b e0 JMP Le03b
233 e04b
234 e04b a5 ca list_all LDA pp
235 e04d 85 e2 STA p1
236 e04f a5 cb LDA pp+1
237 e051 85 e3 STA p1+1
238 e053 a5 4c LDA himem
239 e055 85 e6 STA p3
240 e057 a5 4d LDA himem+1
241 e059 85 e7 STA p3+1
242 e05b d0 de BNE Le03b
243 e05d
244 e05d 20 15 e7 list_cmd JSR get16bit
245 e060 20 6d e5 JSR find_line
246 e063 a5 e4 LDA p2
247 e065 85 e2 STA p1
248 e067 a5 e5 LDA p2+1
249 e069 85 e3 STA p1+1
250 e06b b0 c7 BCS Le034
251 e06d
252 e06d 86 d8 list_line STX x_save
253 e06f a9 a0 LDA #$a0 ; 160
254 e071 85 fa STA leadzr
255 e073 20 2a e0 JSR nextbyte
256 e076 98 TYA
257 e077 85 e4 list_int STA p2
258 e079 20 2a e0 JSR nextbyte
259 e07c aa TAX
260 e07d 20 2a e0 JSR nextbyte
261 e080 20 1b e5 JSR prdec
262 e083 20 18 e0 Le083 JSR Se018
263 e086 84 fa STY leadzr
264 e088 aa TAX
265 e089 10 18 BPL list_token
266 e08b 0a ASL
267 e08c 10 e9 BPL list_int
268 e08e a5 e4 LDA p2
269 e090 d0 03 BNE Le095
270 e092 20 11 e0 JSR Se011
271 e095 8a Le095 TXA
272 e096 20 c9 e3 Le096 JSR cout
273 e099 a9 25 Le099 LDA #$25 ; 37 %
274 e09b 20 1a e0 JSR Se01a
275 e09e aa TAX
276 e09f 30 f5 BMI Le096
277 e0a1 85 e4 STA p2
278 e0a3 c9 01 list_token CMP #$01 ; 1 .
279 e0a5 d0 05 BNE Le0ac
280 e0a7 a6 d8 LDX x_save
281 e0a9 4c cd e3 JMP crout
282 e0ac 48 Le0ac PHA
283 e0ad 84 ce STY acc
284 e0af a2 ed LDX #[syntabl2>>8] ; $ED, when from ROM, $AD from RAM
285 e0b1 86 cf STX acc+1
286 e0b3 c9 51 CMP #$51 ; 81 Q
287 e0b5 90 04 BCC Le0bb
288 e0b7 c6 cf DEC acc+1
289 e0b9 e9 50 SBC #$50 ; 80 P
290 e0bb 48 Le0bb PHA
291 e0bc b1 ce LDA (acc),Y
292 e0be aa Le0be TAX
293 e0bf 88 DEY
294 e0c0 b1 ce LDA (acc),Y
295 e0c2 10 fa BPL Le0be
296 e0c4 e0 c0 CPX #$c0 ; 192 @
297 e0c6 b0 04 BCS Le0cc
298 e0c8 e0 00 CPX #$00 ; 0 .
299 e0ca 30 f2 BMI Le0be
300 e0cc aa Le0cc TAX
301 e0cd 68 PLA
302 e0ce e9 01 SBC #$01 ; 1 .
303 e0d0 d0 e9 BNE Le0bb
304 e0d2 24 e4 BIT p2
305 e0d4 30 03 BMI Le0d9
306 e0d6 20 f8 ef JSR Seff8
307 e0d9 b1 ce Le0d9 LDA (acc),Y
308 e0db 10 10 BPL Le0ed
309 e0dd aa TAX
310 e0de 29 3f AND #$3f ; 63 ?
311 e0e0 85 e4 STA p2
312 e0e2 18 CLC
313 e0e3 69 a0 ADC #$a0 ; 160
314 e0e5 20 c9 e3 JSR cout
315 e0e8 88 DEY
316 e0e9 e0 c0 CPX #$c0 ; 192 @
317 e0eb 90 ec BCC Le0d9
318 e0ed 20 0c e0 Le0ed JSR Se00c
319 e0f0 68 PLA
320 e0f1 c9 5d CMP #$5d ; 93 ]
321 e0f3 f0 a4 BEQ Le099
322 e0f5 c9 28 CMP #$28 ; 40 (
323 e0f7 d0 8a BNE Le083
324 e0f9 f0 9e BEQ Le099
325 e0fb
326 e0fb 20 18 e1 paren_substr JSR Se118
327 e0fe 95 50 STA noun_stk_l,X
328 e100 d5 78 CMP noun_stk_h_str,X
329 e102 90 11 Le102 BCC Le115
330 e104 a0 2b string_err LDY #$2b ; 43 +
331 e106 4c e0 e3 go_errmess_1 JMP print_err_msg
332 e109
333 e109 20 34 ee comma_substr JSR getbyte
334 e10c d5 50 CMP noun_stk_l,X
335 e10e 90 f4 BCC string_err
336 e110 20 e4 ef JSR Sefe4
337 e113 95 78 STA noun_stk_h_str,X
338 e115 4c 23 e8 Le115 JMP left_paren
339 e118
340 e118 20 34 ee Se118 JSR getbyte
341 e11b f0 e7 BEQ string_err
342 e11d 38 SEC
343 e11e e9 01 SBC #$01 ; 1 .
344 e120 60 RTS
345 e121
346 e121 20 18 e1 str_arr_dest JSR Se118
347 e124 95 50 STA noun_stk_l,X
348 e126 18 CLC
349 e127 f5 78 SBC noun_stk_h_str,X
350 e129 4c 02 e1 JMP Le102
351 e12c a0 14 Le12c LDY #$14 ; 20 .
352 e12e d0 d6 BNE go_errmess_1
353 e130
354 e130 20 18 e1 dim_str JSR Se118
355 e133 e8 INX
356 e134 b5 50 Le134 LDA noun_stk_l,X
357 e136 85 da STA aux
358 e138 65 ce ADC acc
359 e13a 48 PHA
360 e13b a8 TAY
361 e13c b5 78 LDA noun_stk_h_str,X
362 e13e 85 db STA aux+1
363 e140 65 cf ADC acc+1
364 e142 48 PHA
365 e143 c4 ca CPY pp
366 e145 e5 cb SBC pp+1
367 e147 b0 e3 BCS Le12c
368 e149 a5 da LDA aux
369 e14b 69 fe ADC #$fe ; 254 ~
370 e14d 85 da STA aux
371 e14f a9 ff LDA #$ff ; 255 .
372 e151 a8 TAY
373 e152 65 db ADC aux+1
374 e154 85 db STA aux+1
375 e156 c8 Le156 INY
376 e157 b1 da LDA (aux),Y
377 e159 d9 cc 00 CMP pv,Y
378 e15c d0 0f BNE Le16d
379 e15e 98 TYA
380 e15f f0 f5 BEQ Le156
381 e161 68 Le161 PLA
382 e162 91 da STA (aux),Y
383 e164 99 cc 00 STA pv,Y
384 e167 88 DEY
385 e168 10 f7 BPL Le161
386 e16a e8 INX
387 e16b 60 RTS
388 e16c ea NOP ; "j"
389 e16d a0 80 Le16d LDY #$80 ; 128 .
390 e16f d0 95 Le16f BNE go_errmess_1
391 e171
392 e171 a9 00 input_str LDA #$00 ; 0 .
393 e173 20 0a e7 JSR push_a_noun_stk
394 e176 a0 02 LDY #$02 ; 2 .
395 e178 94 78 STY noun_stk_h_str,X
396 e17a 20 0a e7 JSR push_a_noun_stk
397 e17d a9 bf LDA #$bf ; 191 ?
398 e17f 20 c9 e3 JSR cout
399 e182 a0 00 LDY #$00 ; 0 .
400 e184 20 9e e2 JSR read_line
401 e187 94 78 STY noun_stk_h_str,X
402 e189 ea NOP
403 e18a ea NOP
404 e18b ea NOP
405 e18c
406 e18c b5 51 string_lit LDA noun_stk_l+1,X
407 e18e 85 ce STA acc
408 e190 b5 79 LDA noun_stk_h_str+1,X
409 e192 85 cf STA acc+1
410 e194 e8 INX
411 e195 e8 INX
412 e196 20 bc e1 JSR Se1bc
413 e199 b5 4e Le199 LDA rnd,X
414 e19b d5 76 CMP syn_stk_h+30,X
415 e19d b0 15 BCS Le1b4
416 e19f f6 4e INC rnd,X
417 e1a1 a8 TAY
418 e1a2 b1 ce LDA (acc),Y
419 e1a4 b4 50 LDY noun_stk_l,X
420 e1a6 c4 e4 CPY p2
421 e1a8 90 04 BCC Le1ae
422 e1aa a0 83 LDY #$83 ; 131 .
423 e1ac d0 c1 BNE Le16f
424 e1ae 91 da Le1ae STA (aux),Y
425 e1b0 f6 50 INC noun_stk_l,X
426 e1b2 90 e5 BCC Le199
427 e1b4 b4 50 Le1b4 LDY noun_stk_l,X
428 e1b6 8a TXA
429 e1b7 91 da STA (aux),Y
430 e1b9 e8 INX
431 e1ba e8 INX
432 e1bb 60 RTS
433 e1bc
434 e1bc b5 51 Se1bc LDA noun_stk_l+1,X
435 e1be 85 da STA aux
436 e1c0 38 SEC
437 e1c1 e9 02 SBC #$02 ; 2 .
438 e1c3 85 e4 STA p2
439 e1c5 b5 79 LDA noun_stk_h_str+1,X
440 e1c7 85 db STA aux+1
441 e1c9 e9 00 SBC #$00 ; 0 .
442 e1cb 85 e5 STA p2+1
443 e1cd a0 00 LDY #$00 ; 0 .
444 e1cf b1 e4 LDA (p2),Y
445 e1d1 18 CLC
446 e1d2 e5 da SBC aux
447 e1d4 85 e4 STA p2
448 e1d6 60 RTS
449 e1d7
450 e1d7 b5 53 string_eq LDA noun_stk_l+3,X
451 e1d9 85 ce STA acc
452 e1db b5 7b LDA noun_stk_h_str+3,X
453 e1dd 85 cf STA acc+1
454 e1df b5 51 LDA noun_stk_l+1,X
455 e1e1 85 da STA aux
456 e1e3 b5 79 LDA noun_stk_h_str+1,X
457 e1e5 85 db STA aux+1
458 e1e7 e8 INX
459 e1e8 e8 INX
460 e1e9 e8 INX
461 e1ea a0 00 LDY #$00 ; 0 .
462 e1ec 94 78 STY noun_stk_h_str,X
463 e1ee 94 a0 STY noun_stk_h_int,X
464 e1f0 c8 INY
465 e1f1 94 50 STY noun_stk_l,X
466 e1f3 b5 4d Le1f3 LDA himem+1,X
467 e1f5 d5 75 CMP syn_stk_h+29,X
468 e1f7 08 PHP
469 e1f8 48 PHA
470 e1f9 b5 4f LDA rnd+1,X
471 e1fb d5 77 CMP syn_stk_h+31,X
472 e1fd 90 07 BCC Le206
473 e1ff 68 PLA
474 e200 28 PLP
475 e201 b0 02 BCS Le205
476 e203 56 50 Le203 LSR noun_stk_l,X
477 e205 60 Le205 RTS
478 e206 a8 Le206 TAY
479 e207 b1 ce LDA (acc),Y
480 e209 85 e4 STA p2
481 e20b 68 PLA
482 e20c a8 TAY
483 e20d 28 PLP
484 e20e b0 f3 BCS Le203
485 e210 b1 da LDA (aux),Y
486 e212 c5 e4 CMP p2
487 e214 d0 ed BNE Le203
488 e216 f6 4f INC rnd+1,X
489 e218 f6 4d INC himem+1,X
490 e21a b0 d7 BCS Le1f3
491 e21c
492 e21c 20 d7 e1 string_neq JSR string_eq
493 e21f 4c 36 e7 JMP not_op
494 e222
495 e222 20 54 e2 mult_op JSR Se254
496 e225 06 ce Le225 ASL acc
497 e227 26 cf ROL acc+1
498 e229 90 0d BCC Le238
499 e22b 18 CLC
500 e22c a5 e6 LDA p3
501 e22e 65 da ADC aux
502 e230 85 e6 STA p3
503 e232 a5 e7 LDA p3+1
504 e234 65 db ADC aux+1
505 e236 85 e7 STA p3+1
506 e238 88 Le238 DEY
507 e239 f0 09 BEQ Le244
508 e23b 06 e6 ASL p3
509 e23d 26 e7 ROL p3+1
510 e23f 10 e4 BPL Le225
511 e241 4c 7e e7 JMP Le77e
512 e244 a5 e6 Le244 LDA p3
513 e246 20 08 e7 JSR push_ya_noun_stk
514 e249 a5 e7 LDA p3+1
515 e24b 95 a0 STA noun_stk_h_int,X
516 e24d 06 e5 ASL p2+1
517 e24f 90 28 BCC Le279
518 e251 4c 6f e7 JMP negate
519 e254
520 e254 a9 55 Se254 LDA #$55 ; 85 U
521 e256 85 e5 STA p2+1
522 e258 20 5b e2 JSR Se25b
523 e25b
524 e25b a5 ce Se25b LDA acc
525 e25d 85 da STA aux
526 e25f a5 cf LDA acc+1
527 e261 85 db STA aux+1
528 e263 20 15 e7 JSR get16bit
529 e266 84 e6 STY p3
530 e268 84 e7 STY p3+1
531 e26a a5 cf LDA acc+1
532 e26c 10 09 BPL Le277
533 e26e ca DEX
534 e26f 06 e5 ASL p2+1
535 e271 20 6f e7 JSR negate
536 e274 20 15 e7 JSR get16bit
537 e277 a0 10 Le277 LDY #$10 ; 16 .
538 e279 60 Le279 RTS
539 e27a
540 e27a 20 6c ee mod_op JSR See6c
541 e27d f0 c5 BEQ Le244
542 e27f ff DC.B $ff ; "."
543 e280 c9 84 Le280 CMP #$84 ; 132 .
544 e282 d0 02 BNE Le286
545 e284 46 f8 LSR auto_flag
546 e286 c9 df Le286 CMP #$df ; 223 _
547 e288 f0 11 BEQ Le29b
548 e28a c9 9b CMP #$9b ; 155 .
549 e28c f0 06 BEQ Le294
550 e28e 99 00 02 STA buffer,Y
551 e291 c8 INY
552 e292 10 0a BPL read_line
553 e294 a0 8b Le294 LDY #$8b ; 139 .
554 e296 20 c4 e3 JSR Se3c4
555 e299
556 e299 a0 01 Se299 LDY #$01 ; 1 .
557 e29b 88 Le29b DEY
558 e29c 30 f6 BMI Le294
559 e29e
560 e29e 20 03 e0 read_line JSR rdkey
561 e2a1 ea NOP
562 e2a2 ea NOP
563 e2a3 20 c9 e3 JSR cout
564 e2a6 c9 8d CMP #$8d ; 141 .
565 e2a8 d0 d6 BNE Le280
566 e2aa a9 df LDA #$df ; 223 _
567 e2ac 99 00 02 STA buffer,Y
568 e2af 60 RTS
569 e2b0 20 d3 ef cold JSR mem_init_4k
570 e2b3 20 cd e3 warm JSR crout
571 e2b6 46 d9 Le2b6 LSR run_flag
572 e2b8 a9 be LDA #$be ; 190 >
573 e2ba 20 c9 e3 JSR cout
574 e2bd a0 00 LDY #$00 ; 0 .
575 e2bf 84 fa STY leadzr
576 e2c1 24 f8 BIT auto_flag
577 e2c3 10 0c BPL Le2d1
578 e2c5 a6 f6 LDX auto_ln
579 e2c7 a5 f7 LDA auto_ln+1
580 e2c9 20 1b e5 JSR prdec
581 e2cc a9 a0 LDA #$a0 ; 160
582 e2ce 20 c9 e3 JSR cout
583 e2d1 a2 ff Le2d1 LDX #$ff ; 255 .
584 e2d3 9a TXS
585 e2d4 20 9e e2 JSR read_line
586 e2d7 84 f1 STY token_index
587 e2d9 8a TXA
588 e2da 85 c8 STA text_index
589 e2dc a2 20 LDX #$20 ; 32
590 e2de 20 91 e4 JSR Se491
591 e2e1 a5 c8 LDA text_index
592 e2e3 69 00 ADC #$00 ; 0 .
593 e2e5 85 e0 STA pverb
594 e2e7 a9 00 LDA #$00 ; 0 .
595 e2e9 aa TAX
596 e2ea 69 02 ADC #$02 ; 2 .
597 e2ec 85 e1 STA pverb+1
598 e2ee a1 e0 LDA (pverb,X)
599 e2f0 29 f0 AND #$f0 ; 240 p
600 e2f2 c9 b0 CMP #$b0 ; 176 0
601 e2f4 f0 03 BEQ Le2f9
602 e2f6 4c 83 e8 JMP Le883
603 e2f9 a0 02 Le2f9 LDY #$02 ; 2 .
604 e2fb b1 e0 Le2fb LDA (pverb),Y
605 e2fd 99 cd 00 STA pv+1,Y
606 e300 88 DEY
607 e301 d0 f8 BNE Le2fb
608 e303 20 8a e3 JSR Se38a
609 e306 a5 f1 LDA token_index
610 e308 e5 c8 SBC text_index
611 e30a c9 04 CMP #$04 ; 4 .
612 e30c f0 a8 BEQ Le2b6
613 e30e 91 e0 STA (pverb),Y
614 e310 a5 ca LDA pp
615 e312 f1 e0 SBC (pverb),Y
616 e314 85 e4 STA p2
617 e316 a5 cb LDA pp+1
618 e318 e9 00 SBC #$00 ; 0 .
619 e31a 85 e5 STA p2+1
620 e31c a5 e4 LDA p2
621 e31e c5 cc CMP pv
622 e320 a5 e5 LDA p2+1
623 e322 e5 cd SBC pv+1
624 e324 90 45 BCC Le36b
625 e326 a5 ca Le326 LDA pp
626 e328 f1 e0 SBC (pverb),Y
627 e32a 85 e6 STA p3
628 e32c a5 cb LDA pp+1
629 e32e e9 00 SBC #$00 ; 0 .
630 e330 85 e7 STA p3+1
631 e332 b1 ca LDA (pp),Y
632 e334 91 e6 STA (p3),Y
633 e336 e6 ca INC pp
634 e338 d0 02 BNE Le33c
635 e33a e6 cb INC pp+1
636 e33c a5 e2 Le33c LDA p1
637 e33e c5 ca CMP pp
638 e340 a5 e3 LDA p1+1
639 e342 e5 cb SBC pp+1
640 e344 b0 e0 BCS Le326
641 e346 b5 e4 Le346 LDA p2,X
642 e348 95 ca STA pp,X
643 e34a ca DEX
644 e34b 10 f9 BPL Le346
645 e34d b1 e0 LDA (pverb),Y
646 e34f a8 TAY
647 e350 88 Le350 DEY
648 e351 b1 e0 LDA (pverb),Y
649 e353 91 e6 STA (p3),Y
650 e355 98 TYA
651 e356 d0 f8 BNE Le350
652 e358 24 f8 BIT auto_flag
653 e35a 10 09 BPL Le365
654 e35c b5 f7 Le35c LDA auto_ln+1,X
655 e35e 75 f5 ADC auto_inc+1,X
656 e360 95 f7 STA auto_ln+1,X
657 e362 e8 INX
658 e363 f0 f7 BEQ Le35c
659 e365 10 7e Le365 BPL Le3e5
660 e367 00 BRK
661 e368 00 BRK
662 e369 00 BRK
663 e36a 00 BRK ; "..."
664 e36b a0 14 Le36b LDY #$14 ; 20 .
665 e36d d0 71 BNE print_err_msg
666 e36f
667 e36f 20 15 e7 del_comma JSR get16bit
668 e372 a5 e2 LDA p1
669 e374 85 e6 STA p3
670 e376 a5 e3 LDA p1+1
671 e378 85 e7 STA p3+1
672 e37a 20 75 e5 JSR find_line1
673 e37d a5 e2 LDA p1
674 e37f 85 e4 STA p2
675 e381 a5 e3 LDA p1+1
676 e383 85 e5 STA p2+1
677 e385 d0 0e BNE Le395
678 e387
679 e387 20 15 e7 del_cmd JSR get16bit
680 e38a
681 e38a 20 6d e5 Se38a JSR find_line
682 e38d a5 e6 LDA p3
683 e38f 85 e2 STA p1
684 e391 a5 e7 LDA p3+1
685 e393 85 e3 STA p1+1
686 e395 a0 00 Le395 LDY #$00 ; 0 .
687 e397 a5 ca Le397 LDA pp
688 e399 c5 e4 CMP p2
689 e39b a5 cb LDA pp+1
690 e39d e5 e5 SBC p2+1
691 e39f b0 16 BCS Le3b7
692 e3a1 a5 e4 LDA p2
693 e3a3 d0 02 BNE Le3a7
694 e3a5 c6 e5 DEC p2+1
695 e3a7 c6 e4 Le3a7 DEC p2
696 e3a9 a5 e6 LDA p3
697 e3ab d0 02 BNE Le3af
698 e3ad c6 e7 DEC p3+1
699 e3af c6 e6 Le3af DEC p3
700 e3b1 b1 e4 LDA (p2),Y
701 e3b3 91 e6 STA (p3),Y
702 e3b5 90 e0 BCC Le397
703 e3b7 a5 e6 Le3b7 LDA p3
704 e3b9 85 ca STA pp
705 e3bb a5 e7 LDA p3+1
706 e3bd 85 cb STA pp+1
707 e3bf 60 RTS
708 e3c0 20 c9 e3 Le3c0 JSR cout
709 e3c3 c8 INY
710 e3c4
711 e3c4 b9 00 eb Se3c4 LDA error_msg_tbl,Y
712 e3c7 30 f7 BMI Le3c0
713 e3c9
714 e3c9 c9 8d cout CMP #$8d ; 141 .
715 e3cb d0 06 BNE Le3d3
716 e3cd
717 e3cd a9 00 crout LDA #$00 ; 0 .
718 e3cf 85 24 STA ch
719 e3d1 a9 8d LDA #$8d ; 141 .
720 e3d3 e6 24 Le3d3 INC ch
721 e3d5 Le3d5
722 e3d5 - IFCONST BLD4APPLE1
723 e3d5 - BIT DSP
724 e3d5 - BMI Le3d5
725 e3d5 - STA DSP
726 e3d5 ELSE
727 e3d5 20 ef ff JSR ECHO ; use monitor function to output
728 e3d8 ea nop
729 e3d9 ea nop
730 e3da ea nop
731 e3db ea nop
732 e3dc ea nop
733 e3dd ENDIF
734 e3dd
735 e3dd 60 RTS
736 e3de a0 06 too_long_err LDY #$06 ; 6
737 e3e0 20 d3 ee print_err_msg JSR print_err_msg2
738 e3e3 24 d9 BIT run_flag
739 e3e5 30 03 Le3e5 BMI Le3ea
740 e3e7 4c b6 e2 JMP Le2b6
741 e3ea 4c 9a eb Le3ea JMP Leb9a
742 e3ed 2a Le3ed ROL
743 e3ee 69 a0 ADC #$a0 ; 160
744 e3f0 dd 00 02 CMP buffer,X
745 e3f3 d0 53 BNE Le448
746 e3f5 b1 fe LDA (synpag),Y
747 e3f7 0a ASL
748 e3f8 30 06 BMI Le400
749 e3fa 88 DEY
750 e3fb b1 fe LDA (synpag),Y
751 e3fd 30 29 BMI Le428
752 e3ff c8 INY
753 e400 86 c8 Le400 STX text_index
754 e402 98 TYA
755 e403 48 PHA
756 e404 a2 00 LDX #$00 ; 0 .
757 e406 a1 fe LDA (synpag,X)
758 e408 aa TAX
759 e409 4a Le409 LSR
760 e40a 49 48 EOR #$48 ; 72 H
761 e40c 11 fe ORA (synpag),Y
762 e40e c9 c0 CMP #$c0 ; 192 @
763 e410 90 01 BCC Le413
764 e412 e8 INX
765 e413 c8 Le413 INY
766 e414 d0 f3 BNE Le409
767 e416 68 PLA
768 e417 a8 TAY
769 e418 8a TXA
770 e419 4c c0 e4 JMP Le4c0
771 e41c
772 e41c e6 f1 put_token INC token_index
773 e41e a6 f1 LDX token_index
774 e420 f0 bc BEQ too_long_err
775 e422 9d 00 02 STA buffer,X
776 e425 60 Le425 RTS
777 e426 a6 c8 Le426 LDX text_index
778 e428 a9 a0 Le428 LDA #$a0 ; 160
779 e42a e8 Le42a INX
780 e42b dd 00 02 CMP buffer,X
781 e42e b0 fa BCS Le42a
782 e430 b1 fe LDA (synpag),Y
783 e432 29 3f AND #$3f ; 63 ?
784 e434 4a LSR
785 e435 d0 b6 BNE Le3ed
786 e437 bd 00 02 LDA buffer,X
787 e43a b0 06 BCS Le442
788 e43c 69 3f ADC #$3f ; 63 ?
789 e43e c9 1a CMP #$1a ; 26 .
790 e440 90 6f BCC Le4b1
791 e442 69 4f Le442 ADC #$4f ; 79 O
792 e444 c9 0a CMP #$0a ; 10 .
793 e446 90 69 BCC Le4b1
794 e448 a6 fd Le448 LDX synstkdx
795 e44a c8 Le44a INY
796 e44b b1 fe LDA (synpag),Y
797 e44d 29 e0 AND #$e0 ; 224 `
798 e44f c9 20 CMP #$20 ; 32
799 e451 f0 7a BEQ Le4cd
800 e453 b5 a8 LDA txtndxstk,X
801 e455 85 c8 STA text_index
802 e457 b5 d1 LDA tokndxstk,X
803 e459 85 f1 STA token_index
804 e45b 88 Le45b DEY
805 e45c b1 fe LDA (synpag),Y
806 e45e 0a ASL
807 e45f 10 fa BPL Le45b
808 e461 88 DEY
809 e462 b0 38 BCS Le49c
810 e464 0a ASL
811 e465 30 35 BMI Le49c
812 e467 b4 58 LDY syn_stk_h,X
813 e469 84 ff STY synpag+1
814 e46b b4 80 LDY syn_stk_l,X
815 e46d e8 INX
816 e46e 10 da BPL Le44a
817 e470 f0 b3 Le470 BEQ Le425
818 e472 c9 7e CMP #$7e ; 126 ~
819 e474 b0 22 BCS Le498
820 e476 ca DEX
821 e477 10 04 BPL Le47d
822 e479 a0 06 LDY #$06 ; 6 .
823 e47b 10 29 BPL go_errmess_2
824 e47d 94 80 Le47d STY syn_stk_l,X
825 e47f a4 ff LDY synpag+1
826 e481 94 58 STY syn_stk_h,X
827 e483 a4 c8 LDY text_index
828 e485 94 a8 STY txtndxstk,X
829 e487 a4 f1 LDY token_index
830 e489 94 d1 STY tokndxstk,X
831 e48b 29 1f AND #$1f ; 31 .
832 e48d a8 TAY
833 e48e b9 20 ec LDA syntabl_index,Y
834 e491
835 e491 0a Se491 ASL
836 e492 a8 TAY
837 e493 ; when running from a000, shifts to AC or AD
838 e493 ; when running from e000 shifts to EC or ED
839 e493 a9 76 LDA #[syntabl_index>>9]
840 e495 2a ROL
841 e496 85 ff STA synpag+1
842 e498 d0 01 Le498 BNE Le49b
843 e49a c8 INY
844 e49b c8 Le49b INY
845 e49c 86 fd Le49c STX synstkdx
846 e49e b1 fe LDA (synpag),Y
847 e4a0 30 84 BMI Le426
848 e4a2 d0 05 BNE Le4a9
849 e4a4 a0 0e LDY #$0e ; 14 .
850 e4a6 4c e0 e3 go_errmess_2 JMP print_err_msg
851 e4a9 c9 03 Le4a9 CMP #$03 ; 3 .
852 e4ab b0 c3 BCS Le470
853 e4ad 4a LSR
854 e4ae a6 c8 LDX text_index
855 e4b0 e8 INX
856 e4b1 bd 00 02 Le4b1 LDA buffer,X
857 e4b4 90 04 BCC Le4ba
858 e4b6 c9 a2 CMP #$a2 ; 162 "
859 e4b8 f0 0a BEQ Le4c4
860 e4ba c9 df Le4ba CMP #$df ; 223 _
861 e4bc f0 06 BEQ Le4c4
862 e4be 86 c8 STX text_index
863 e4c0 20 1c e4 Le4c0 JSR put_token
864 e4c3 c8 INY
865 e4c4 88 Le4c4 DEY
866 e4c5 a6 fd LDX synstkdx
867 e4c7 b1 fe Le4c7 LDA (synpag),Y
868 e4c9 88 DEY
869 e4ca 0a ASL
870 e4cb 10 cf BPL Le49c
871 e4cd b4 58 Le4cd LDY syn_stk_h,X
872 e4cf 84 ff STY synpag+1
873 e4d1 b4 80 LDY syn_stk_l,X
874 e4d3 e8 INX
875 e4d4 b1 fe LDA (synpag),Y
876 e4d6 29 9f AND #$9f ; 159 .
877 e4d8 d0 ed BNE Le4c7
878 e4da 85 f2 STA pcon
879 e4dc 85 f3 STA pcon+1
880 e4de 98 TYA
881 e4df 48 PHA
882 e4e0 86 fd STX synstkdx
883 e4e2 b4 d0 LDY srch,X
884 e4e4 84 c9 STY leadbl
885 e4e6 18 CLC
886 e4e7 a9 0a Le4e7 LDA #$0a ; 10 .
887 e4e9 85 f9 STA char
888 e4eb a2 00 LDX #$00 ; 0 .
889 e4ed c8 INY
890 e4ee b9 00 02 LDA buffer,Y
891 e4f1 29 0f AND #$0f ; 15 .
892 e4f3 65 f2 Le4f3 ADC pcon
893 e4f5 48 PHA
894 e4f6 8a TXA
895 e4f7 65 f3 ADC pcon+1
896 e4f9 30 1c BMI Le517
897 e4fb aa TAX
898 e4fc 68 PLA
899 e4fd c6 f9 DEC char
900 e4ff d0 f2 BNE Le4f3
901 e501 85 f2 STA pcon
902 e503 86 f3 STX pcon+1
903 e505 c4 f1 CPY token_index
904 e507 d0 de BNE Le4e7
905 e509 a4 c9 LDY leadbl
906 e50b c8 INY
907 e50c 84 f1 STY token_index
908 e50e 20 1c e4 JSR put_token
909 e511 68 PLA
910 e512 a8 TAY
911 e513 a5 f3 LDA pcon+1
912 e515 b0 a9 BCS Le4c0
913 e517 a0 00 Le517 LDY #$00 ; 0 .
914 e519 10 8b BPL go_errmess_2
915 e51b
916 e51b 85 f3 prdec STA pcon+1
917 e51d 86 f2 STX pcon
918 e51f a2 04 LDX #$04 ; 4 .
919 e521 86 c9 STX leadbl
920 e523 a9 b0 Le523 LDA #$b0 ; 176 0
921 e525 85 f9 STA char
922 e527 a5 f2 Le527 LDA pcon
923 e529 dd 63 e5 CMP dectabl,X
924 e52c a5 f3 LDA pcon+1
925 e52e fd 68 e5 SBC dectabh,X
926 e531 90 0d BCC Le540
927 e533 85 f3 STA pcon+1
928 e535 a5 f2 LDA pcon
929 e537 fd 63 e5 SBC dectabl,X
930 e53a 85 f2 STA pcon
931 e53c e6 f9 INC char
932 e53e d0 e7 BNE Le527
933 e540 a5 f9 Le540 LDA char
934 e542 e8 INX
935 e543 ca DEX
936 e544 f0 0e BEQ Le554
937 e546 c9 b0 CMP #$b0 ; 176 0
938 e548 f0 02 BEQ Le54c
939 e54a 85 c9 STA leadbl
940 e54c 24 c9 Le54c BIT leadbl
941 e54e 30 04 BMI Le554
942 e550 a5 fa LDA leadzr
943 e552 f0 0b BEQ Le55f
944 e554 20 c9 e3 Le554 JSR cout
945 e557 24 f8 BIT auto_flag
946 e559 10 04 BPL Le55f
947 e55b 99 00 02 STA buffer,Y
948 e55e c8 INY
949 e55f ca Le55f DEX
950 e560 10 c1 BPL Le523
951 e562 60 RTS
952 e563 01 0a 64 e8*dectabl DC.B $01,$0a,$64,$e8,$10 ; "..dh."
953 e568 00 00 00 03*dectabh DC.B $00,$00,$00,$03,$27 ; "....'"
954 e56d
955 e56d a5 ca find_line LDA pp
956 e56f 85 e6 STA p3
957 e571 a5 cb LDA pp+1
958 e573 85 e7 STA p3+1
959 e575
960 e575 e8 find_line1 INX
961 e576
962 e576 a5 e7 find_line2 LDA p3+1
963 e578 85 e5 STA p2+1
964 e57a a5 e6 LDA p3
965 e57c 85 e4 STA p2
966 e57e c5 4c CMP himem
967 e580 a5 e5 LDA p2+1
968 e582 e5 4d SBC himem+1
969 e584 b0 26 BCS Le5ac
970 e586 a0 01 LDY #$01 ; 1 .
971 e588 b1 e4 LDA (p2),Y
972 e58a e5 ce SBC acc
973 e58c c8 INY
974 e58d b1 e4 LDA (p2),Y
975 e58f e5 cf SBC acc+1
976 e591 b0 19 BCS Le5ac
977 e593 a0 00 LDY #$00 ; 0 .
978 e595 a5 e6 LDA p3
979 e597 71 e4 ADC (p2),Y
980 e599 85 e6 STA p3
981 e59b 90 03 BCC Le5a0
982 e59d e6 e7 INC p3+1
983 e59f 18 CLC
984 e5a0 c8 Le5a0 INY
985 e5a1 a5 ce LDA acc
986 e5a3 f1 e4 SBC (p2),Y
987 e5a5 c8 INY
988 e5a6 a5 cf LDA acc+1
989 e5a8 f1 e4 SBC (p2),Y
990 e5aa b0 ca BCS find_line2
991 e5ac 60 Le5ac RTS
992 e5ad
993 e5ad 46 f8 new_cmd LSR auto_flag
994 e5af a5 4c LDA himem
995 e5b1 85 ca STA pp
996 e5b3 a5 4d LDA himem+1
997 e5b5 85 cb STA pp+1
998 e5b7
999 e5b7 a5 4a clr LDA lomem
1000 e5b9 85 cc STA pv
1001 e5bb a5 4b LDA lomem+1
1002 e5bd 85 cd STA pv+1
1003 e5bf a9 00 LDA #$00 ; 0 .
1004 e5c1 85 fb STA for_nest_count
1005 e5c3 85 fc STA gosub_nest_count
1006 e5c5 85 fe STA synpag
1007 e5c7 a9 00 LDA #$00 ; 0 .
1008 e5c9 85 1d STA Z1d
1009 e5cb 60 RTS
1010 e5cc a5 d0 Le5cc LDA srch
1011 e5ce 69 05 ADC #$05 ; 5 .
1012 e5d0 85 d2 STA srch2
1013 e5d2 a5 d1 LDA tokndxstk
1014 e5d4 69 00 ADC #$00 ; 0 .
1015 e5d6 85 d3 STA srch2+1
1016 e5d8 a5 d2 LDA srch2
1017 e5da c5 ca CMP pp
1018 e5dc a5 d3 LDA srch2+1
1019 e5de e5 cb SBC pp+1
1020 e5e0 90 03 BCC Le5e5
1021 e5e2 4c 6b e3 JMP Le36b
1022 e5e5 a5 ce Le5e5 LDA acc
1023 e5e7 91 d0 STA (srch),Y
1024 e5e9 a5 cf LDA acc+1
1025 e5eb c8 INY
1026 e5ec 91 d0 STA (srch),Y
1027 e5ee a5 d2 LDA srch2
1028 e5f0 c8 INY
1029 e5f1 91 d0 STA (srch),Y
1030 e5f3 a5 d3 LDA srch2+1
1031 e5f5 c8 INY
1032 e5f6 91 d0 STA (srch),Y
1033 e5f8 a9 00 LDA #$00 ; 0 .
1034 e5fa c8 INY
1035 e5fb 91 d0 STA (srch),Y
1036 e5fd c8 INY
1037 e5fe 91 d0 STA (srch),Y
1038 e600 a5 d2 LDA srch2
1039 e602 85 cc STA pv
1040 e604 a5 d3 LDA srch2+1
1041 e606 85 cd STA pv+1
1042 e608 a5 d0 LDA srch
1043 e60a 90 43 BCC Le64f
1044 e60c 85 ce execute_var STA acc
1045 e60e 84 cf STY acc+1
1046 e610 20 ff e6 JSR get_next_prog_byte
1047 e613 30 0e BMI Le623
1048 e615 c9 40 CMP #$40 ; 64 @
1049 e617 f0 0a BEQ Le623
1050 e619 4c 28 e6 JMP Le628
1051 e61c 06 c9 49 d0* DC.B $06,$c9,$49,$d0,$07,$a9,$49 ; ".IIP.)I"
1052 e623 85 cf Le623 STA acc+1
1053 e625 20 ff e6 JSR get_next_prog_byte
1054 e628 a5 4b Le628 LDA lomem+1
1055 e62a 85 d1 STA tokndxstk
1056 e62c a5 4a LDA lomem
1057 e62e 85 d0 Le62e STA srch
1058 e630 c5 cc CMP pv
1059 e632 a5 d1 LDA tokndxstk
1060 e634 e5 cd SBC pv+1
1061 e636 b0 94 BCS Le5cc
1062 e638 b1 d0 LDA (srch),Y
1063 e63a c8 INY
1064 e63b c5 ce CMP acc
1065 e63d d0 06 BNE Le645
1066 e63f b1 d0 LDA (srch),Y
1067 e641 c5 cf CMP acc+1
1068 e643 f0 0e BEQ Le653
1069 e645 c8 Le645 INY
1070 e646 b1 d0 LDA (srch),Y
1071 e648 48 PHA
1072 e649 c8 INY
1073 e64a b1 d0 LDA (srch),Y
1074 e64c 85 d1 STA tokndxstk
1075 e64e 68 PLA
1076 e64f a0 00 Le64f LDY #$00 ; 0 .
1077 e651 f0 db BEQ Le62e
1078 e653 a5 d0 Le653 LDA srch
1079 e655 69 03 ADC #$03 ; 3 .
1080 e657 20 0a e7 JSR push_a_noun_stk
1081 e65a a5 d1 LDA tokndxstk
1082 e65c 69 00 ADC #$00 ; 0 .
1083 e65e 95 78 STA noun_stk_h_str,X
1084 e660 a5 cf LDA acc+1
1085 e662 c9 40 CMP #$40 ; 64 @
1086 e664 d0 1c BNE fetch_prog_byte
1087 e666 88 DEY
1088 e667 98 TYA
1089 e668 20 0a e7 JSR push_a_noun_stk
1090 e66b 88 DEY
1091 e66c 94 78 STY noun_stk_h_str,X
1092 e66e a0 03 LDY #$03 ; 3 .
1093 e670 f6 78 Le670 INC noun_stk_h_str,X
1094 e672 c8 INY
1095 e673 b1 d0 LDA (srch),Y
1096 e675 30 f9 BMI Le670
1097 e677 10 09 BPL fetch_prog_byte
1098 e679
1099 e679 a9 00 execute_stmt LDA #$00 ; 0 .
1100 e67b 85 d4 STA if_flag
1101 e67d 85 d5 STA cr_flag
1102 e67f a2 20 LDX #$20 ; 32
1103 e681 48 push_old_verb PHA
1104 e682 a0 00 fetch_prog_byte LDY #$00 ; 0 .
1105 e684 b1 e0 LDA (pverb),Y
1106 e686 10 18 Le686 BPL execute_token
1107 e688 0a ASL
1108 e689 30 81 BMI execute_var
1109 e68b 20 ff e6 JSR get_next_prog_byte
1110 e68e 20 08 e7 JSR push_ya_noun_stk
1111 e691 20 ff e6 JSR get_next_prog_byte
1112 e694 95 a0 STA noun_stk_h_int,X
1113 e696 24 d4 Le696 BIT if_flag
1114 e698 10 01 BPL Le69b
1115 e69a ca DEX
1116 e69b 20 ff e6 Le69b JSR get_next_prog_byte
1117 e69e b0 e6 BCS Le686
1118 e6a0 c9 28 execute_token CMP #$28 ; 40 (
1119 e6a2 d0 1f BNE execute_verb
1120 e6a4 a5 e0 LDA pverb
1121 e6a6 20 0a e7 JSR push_a_noun_stk
1122 e6a9 a5 e1 LDA pverb+1
1123 e6ab 95 78 STA noun_stk_h_str,X
1124 e6ad 24 d4 BIT if_flag
1125 e6af 30 0b BMI Le6bc
1126 e6b1 a9 01 LDA #$01 ; 1 .
1127 e6b3 20 0a e7 JSR push_a_noun_stk
1128 e6b6 a9 00 LDA #$00 ; 0 .
1129 e6b8 95 78 STA noun_stk_h_str,X
1130 e6ba f6 78 Le6ba INC noun_stk_h_str,X
1131 e6bc 20 ff e6 Le6bc JSR get_next_prog_byte
1132 e6bf 30 f9 BMI Le6ba
1133 e6c1 b0 d3 BCS Le696
1134 e6c3 24 d4 execute_verb BIT if_flag
1135 e6c5 10 06 BPL Le6cd
1136 e6c7 c9 04 CMP #$04 ; 4 .
1137 e6c9 b0 d0 BCS Le69b
1138 e6cb 46 d4 LSR if_flag
1139 e6cd a8 Le6cd TAY
1140 e6ce 85 d6 STA current_verb
1141 e6d0 b9 98 e9 LDA verb_prec_tbl,Y
1142 e6d3 29 55 AND #$55 ; 85 U
1143 e6d5 0a ASL
1144 e6d6 85 d7 STA precedence
1145 e6d8 68 Le6d8 PLA
1146 e6d9 a8 TAY
1147 e6da b9 98 e9 LDA verb_prec_tbl,Y
1148 e6dd 29 aa AND #$aa ; 170 *
1149 e6df c5 d7 CMP precedence
1150 e6e1 b0 09 BCS do_verb
1151 e6e3 98 TYA
1152 e6e4 48 PHA
1153 e6e5 20 ff e6 JSR get_next_prog_byte
1154 e6e8 a5 d6 LDA current_verb
1155 e6ea 90 95 BCC push_old_verb
1156 e6ec b9 10 ea do_verb LDA verb_adr_l,Y
1157 e6ef 85 ce STA acc
1158 e6f1 b9 88 ea LDA verb_adr_h,Y
1159 e6f4 85 cf STA acc+1
1160 e6f6 20 fc e6 JSR Se6fc
1161 e6f9 4c d8 e6 JMP Le6d8
1162 e6fc
1163 e6fc 6c ce 00 Se6fc JMP (acc)
1164 e6ff
1165 e6ff e6 e0 get_next_prog_byte INC pverb
1166 e701 d0 02 BNE Le705
1167 e703 e6 e1 INC pverb+1
1168 e705 b1 e0 Le705 LDA (pverb),Y
1169 e707 60 RTS
1170 e708
1171 e708 94 77 push_ya_noun_stk STY syn_stk_h+31,X
1172 e70a
1173 e70a ca push_a_noun_stk DEX
1174 e70b 30 03 BMI Le710
1175 e70d 95 50 STA noun_stk_l,X
1176 e70f 60 RTS
1177 e710 a0 66 Le710 LDY #$66 ; 102 f
1178 e712 4c e0 e3 go_errmess_3 JMP print_err_msg
1179 e715
1180 e715 a0 00 get16bit LDY #$00 ; 0 .
1181 e717 b5 50 LDA noun_stk_l,X
1182 e719 85 ce STA acc
1183 e71b b5 a0 LDA noun_stk_h_int,X
1184 e71d 85 cf STA acc+1
1185 e71f b5 78 LDA noun_stk_h_str,X
1186 e721 f0 0e BEQ Le731
1187 e723 85 cf STA acc+1
1188 e725 b1 ce LDA (acc),Y
1189 e727 48 PHA
1190 e728 c8 INY
1191 e729 b1 ce LDA (acc),Y
1192 e72b 85 cf STA acc+1
1193 e72d 68 PLA
1194 e72e 85 ce STA acc
1195 e730 88 DEY
1196 e731 e8 Le731 INX
1197 e732 60 RTS
1198 e733
1199 e733 20 4a e7 eq_op JSR neq_op
1200 e736
1201 e736 20 15 e7 not_op JSR get16bit
1202 e739 98 TYA
1203 e73a 20 08 e7 JSR push_ya_noun_stk
1204 e73d 95 a0 STA noun_stk_h_int,X
1205 e73f c5 ce CMP acc
1206 e741 d0 06 BNE Le749
1207 e743 c5 cf CMP acc+1
1208 e745 d0 02 BNE Le749
1209 e747 f6 50 INC noun_stk_l,X
1210 e749 60 Le749 RTS
1211 e74a
1212 e74a 20 82 e7 neq_op JSR subtract
1213 e74d 20 59 e7 JSR sgn_fn
1214 e750
1215 e750 20 15 e7 abs_fn JSR get16bit
1216 e753 24 cf BIT acc+1
1217 e755 30 1b BMI Se772
1218 e757 ca Le757 DEX
1219 e758 60 Le758 RTS
1220 e759
1221 e759 20 15 e7 sgn_fn JSR get16bit
1222 e75c a5 cf LDA acc+1
1223 e75e d0 04 BNE Le764
1224 e760 a5 ce LDA acc
1225 e762 f0 f3 BEQ Le757
1226 e764 a9 ff Le764 LDA #$ff ; 255 .
1227 e766 20 08 e7 JSR push_ya_noun_stk
1228 e769 95 a0 STA noun_stk_h_int,X
1229 e76b 24 cf BIT acc+1
1230 e76d 30 e9 BMI Le758
1231 e76f
1232 e76f 20 15 e7 negate JSR get16bit
1233 e772
1234 e772 98 Se772 TYA
1235 e773 38 SEC
1236 e774 e5 ce SBC acc
1237 e776 20 08 e7 JSR push_ya_noun_stk
1238 e779 98 TYA
1239 e77a e5 cf SBC acc+1
1240 e77c 50 23 BVC Le7a1
1241 e77e a0 00 Le77e LDY #$00 ; 0 .
1242 e780 10 90 BPL go_errmess_3
1243 e782
1244 e782 20 6f e7 subtract JSR negate
1245 e785
1246 e785 20 15 e7 add JSR get16bit
1247 e788 a5 ce LDA acc
1248 e78a 85 da STA aux
1249 e78c a5 cf LDA acc+1
1250 e78e 85 db STA aux+1
1251 e790 20 15 e7 JSR get16bit
1252 e793
1253 e793 18 Se793 CLC
1254 e794 a5 ce LDA acc
1255 e796 65 da ADC aux
1256 e798 20 08 e7 JSR push_ya_noun_stk
1257 e79b a5 cf LDA acc+1
1258 e79d 65 db ADC aux+1
1259 e79f 70 dd BVS Le77e
1260 e7a1 95 a0 Le7a1 STA noun_stk_h_int,X
1261 e7a3
1262 e7a3 60 unary_pos RTS
1263 e7a4
1264 e7a4 20 15 e7 tab_fn JSR get16bit
1265 e7a7 a4 ce LDY acc
1266 e7a9 f0 05 BEQ Le7b0
1267 e7ab 88 DEY
1268 e7ac a5 cf LDA acc+1
1269 e7ae f0 0c BEQ Le7bc
1270 e7b0 60 Le7b0 RTS
1271 e7b1
1272 e7b1 a5 24 tabout LDA ch
1273 e7b3 09 07 ORA #$07 ; 7 .
1274 e7b5 a8 TAY
1275 e7b6 c8 INY
1276 e7b7 a9 a0 Le7b7 LDA #$a0 ; 160
1277 e7b9 20 c9 e3 JSR cout
1278 e7bc c4 24 Le7bc CPY ch
1279 e7be b0 f7 BCS Le7b7
1280 e7c0 60 RTS
1281 e7c1
1282 e7c1 20 b1 e7 print_com_num JSR tabout
1283 e7c4
1284 e7c4 20 15 e7 print_num JSR get16bit
1285 e7c7 a5 cf LDA acc+1
1286 e7c9 10 0a BPL Le7d5
1287 e7cb a9 ad LDA #$ad ; 173 -
1288 e7cd 20 c9 e3 JSR cout
1289 e7d0 20 72 e7 JSR Se772
1290 e7d3 50 ef BVC print_num
1291 e7d5 88 Le7d5 DEY
1292 e7d6 84 d5 STY cr_flag
1293 e7d8 86 cf STX acc+1
1294 e7da a6 ce LDX acc
1295 e7dc 20 1b e5 JSR prdec
1296 e7df a6 cf LDX acc+1
1297 e7e1 60 RTS
1298 e7e2
1299 e7e2 20 15 e7 auto_cmd JSR get16bit
1300 e7e5 a5 ce LDA acc
1301 e7e7 85 f6 STA auto_ln
1302 e7e9 a5 cf LDA acc+1
1303 e7eb 85 f7 STA auto_ln+1
1304 e7ed 88 DEY
1305 e7ee 84 f8 STY auto_flag
1306 e7f0 c8 INY
1307 e7f1 a9 0a LDA #$0a ; 10 .
1308 e7f3 85 f4 Le7f3 STA auto_inc
1309 e7f5 84 f5 STY auto_inc+1
1310 e7f7 60 RTS
1311 e7f8
1312 e7f8 20 15 e7 auto_com JSR get16bit
1313 e7fb a5 ce LDA acc
1314 e7fd a4 cf LDY acc+1
1315 e7ff 10 f2 BPL Le7f3
1316 e801
1317 e801 20 15 e7 var_assign JSR get16bit
1318 e804 b5 50 LDA noun_stk_l,X
1319 e806 85 da STA aux
1320 e808 b5 78 LDA noun_stk_h_str,X
1321 e80a 85 db STA aux+1
1322 e80c a5 ce LDA acc
1323 e80e 91 da STA (aux),Y
1324 e810 c8 INY
1325 e811 a5 cf LDA acc+1
1326 e813 91 da STA (aux),Y
1327 e815 e8 INX
1328 e816
1329 e816 60 Te816 RTS
1330 e817
1331 e817 68 begin_line PLA
1332 e818 68 PLA
1333 e819
1334 e819 24 d5 colon BIT cr_flag
1335 e81b 10 05 BPL Le822
1336 e81d
1337 e81d 20 cd e3 print_cr JSR crout
1338 e820
1339 e820 46 d5 print_semi LSR cr_flag
1340 e822 60 Le822 RTS
1341 e823
1342 e823 a0 ff left_paren LDY #$ff ; 255 .
1343 e825 84 d7 STY precedence
1344 e827
1345 e827 60 right_paren RTS
1346 e828
1347 e828 20 cd ef if_stmt JSR Sefcd
1348 e82b f0 07 BEQ Le834
1349 e82d a9 25 LDA #$25 ; 37 %
1350 e82f 85 d6 STA current_verb
1351 e831 88 DEY
1352 e832 84 d4 STY if_flag
1353 e834 e8 Le834 INX
1354 e835 60 RTS
1355 e836 a5 ca run_warm LDA pp
1356 e838 a4 cb LDY pp+1
1357 e83a d0 5a BNE Le896
1358 e83c
1359 e83c a0 41 gosub_stmt LDY #$41 ; 65 A
1360 e83e a5 fc LDA gosub_nest_count
1361 e840 c9 08 CMP #$08 ; 8 .
1362 e842 b0 5e BCS go_errmess_4
1363 e844 a8 TAY
1364 e845 e6 fc INC gosub_nest_count
1365 e847 a5 e0 LDA pverb
1366 e849 99 00 01 STA gstk_pverbl,Y
1367 e84c a5 e1 LDA pverb+1
1368 e84e 99 08 01 STA gstk_pverbh,Y
1369 e851 a5 dc LDA pline
1370 e853 99 10 01 STA gstk_plinel,Y
1371 e856 a5 dd LDA pline+1
1372 e858 99 18 01 STA gstk_plineh,Y
1373 e85b
1374 e85b 20 15 e7 goto_stmt JSR get16bit
1375 e85e 20 6d e5 JSR find_line
1376 e861 90 04 BCC Le867
1377 e863 a0 37 LDY #$37 ; 55 7
1378 e865 d0 3b BNE go_errmess_4
1379 e867 a5 e4 Le867 LDA p2
1380 e869 a4 e5 LDY p2+1
1381 e86b 85 dc run_loop STA pline
1382 e86d 84 dd STY pline+1
1383 e86f - IFCONST BLD4APPLE1
1384 e86f - BIT KBDCR
1385 e86f ELSE
1386 e86f 2c 00 c0 BIT KBD
1387 e872 ENDIF
1388 e872 30 4f BMI Le8c3
1389 e874 18 CLC
1390 e875 69 03 ADC #$03 ; 3 .
1391 e877 90 01 BCC Le87a
1392 e879 c8 INY
1393 e87a a2 ff Le87a LDX #$ff ; 255 .
1394 e87c 86 d9 STX run_flag
1395 e87e 9a TXS
1396 e87f 85 e0 STA pverb
1397 e881 84 e1 STY pverb+1
1398 e883 20 79 e6 Le883 JSR execute_stmt
1399 e886 24 d9 BIT run_flag
1400 e888 10 49 BPL end_stmt
1401 e88a 18 CLC
1402 e88b a0 00 LDY #$00 ; 0 .
1403 e88d a5 dc LDA pline
1404 e88f 71 dc ADC (pline),Y
1405 e891 a4 dd LDY pline+1
1406 e893 90 01 BCC Le896
1407 e895 c8 INY
1408 e896 c5 4c Le896 CMP himem
1409 e898 d0 d1 BNE run_loop
1410 e89a c4 4d CPY himem+1
1411 e89c d0 cd BNE run_loop
1412 e89e a0 34 LDY #$34 ; 52 4
1413 e8a0 46 d9 LSR run_flag
1414 e8a2 4c e0 e3 go_errmess_4 JMP print_err_msg
1415 e8a5
1416 e8a5 a0 4a return_stmt LDY #$4a ; 74 J
1417 e8a7 a5 fc LDA gosub_nest_count
1418 e8a9 f0 f7 BEQ go_errmess_4
1419 e8ab c6 fc DEC gosub_nest_count
1420 e8ad a8 TAY
1421 e8ae b9 0f 01 LDA gstk_plinel-1,Y
1422 e8b1 85 dc STA pline
1423 e8b3 b9 17 01 LDA gstk_plineh-1,Y
1424 e8b6 85 dd STA pline+1
1425 e8b8
1426 e8b8 be ff 00 DC.B $be,$ff,$00
1427 e8bb ; LDX synpag+1,Y
1428 e8bb
1429 e8bb b9 07 01 LDA gstk_pverbh-1,Y
1430 e8be a8 Le8be TAY
1431 e8bf 8a TXA
1432 e8c0 4c 7a e8 JMP Le87a
1433 e8c3 a0 63 Le8c3 LDY #$63 ; 99 c
1434 e8c5 20 c4 e3 JSR Se3c4
1435 e8c8 a0 01 LDY #$01 ; 1 .
1436 e8ca b1 dc LDA (pline),Y
1437 e8cc aa TAX
1438 e8cd c8 INY
1439 e8ce b1 dc LDA (pline),Y
1440 e8d0 20 1b e5 JSR prdec
1441 e8d3
1442 e8d3 4c b3 e2 end_stmt JMP warm
1443 e8d6 c6 fb Le8d6 DEC for_nest_count
1444 e8d8
1445 e8d8 a0 5b next_stmt LDY #$5b ; 91 [
1446 e8da a5 fb LDA for_nest_count
1447 e8dc f0 c4 Le8dc BEQ go_errmess_4
1448 e8de a8 TAY
1449 e8df b5 50 LDA noun_stk_l,X
1450 e8e1 d9 1f 01 CMP fstk_varl-1,Y
1451 e8e4 d0 f0 BNE Le8d6
1452 e8e6 b5 78 LDA noun_stk_h_str,X
1453 e8e8 d9 27 01 CMP fstk_varh-1,Y
1454 e8eb d0 e9 BNE Le8d6
1455 e8ed b9 2f 01 LDA fstk_stepl-1,Y
1456 e8f0 85 da STA aux
1457 e8f2 b9 37 01 LDA fstk_steph-1,Y
1458 e8f5 85 db STA aux+1
1459 e8f7 20 15 e7 JSR get16bit
1460 e8fa ca DEX
1461 e8fb 20 93 e7 JSR Se793
1462 e8fe 20 01 e8 JSR var_assign
1463 e901 ca DEX
1464 e902 a4 fb LDY for_nest_count
1465 e904 b9 67 01 LDA fstk_toh-1,Y
1466 e907 95 9f STA syn_stk_l+31,X
1467 e909 b9 5f 01 LDA fstk_tol-1,Y
1468 e90c a0 00 LDY #$00 ; 0 .
1469 e90e 20 08 e7 JSR push_ya_noun_stk
1470 e911 20 82 e7 JSR subtract
1471 e914 20 59 e7 JSR sgn_fn
1472 e917 20 15 e7 JSR get16bit
1473 e91a a4 fb LDY for_nest_count
1474 e91c a5 ce LDA acc
1475 e91e f0 05 BEQ Le925
1476 e920 59 37 01 EOR fstk_steph-1,Y
1477 e923 10 12 BPL Le937
1478 e925 b9 3f 01 Le925 LDA fstk_plinel-1,Y
1479 e928 85 dc STA pline
1480 e92a b9 47 01 LDA fstk_plineh-1,Y
1481 e92d 85 dd STA pline+1
1482 e92f be 4f 01 LDX fstk_pverbl-1,Y
1483 e932 b9 57 01 LDA fstk_pverbh-1,Y
1484 e935 d0 87 BNE Le8be
1485 e937 c6 fb Le937 DEC for_nest_count
1486 e939 60 RTS
1487 e93a
1488 e93a a0 54 for_stmt LDY #$54 ; 84 T
1489 e93c a5 fb LDA for_nest_count
1490 e93e c9 08 CMP #$08 ; 8 .
1491 e940 f0 9a BEQ Le8dc
1492 e942 e6 fb INC for_nest_count
1493 e944 a8 TAY
1494 e945 b5 50 LDA noun_stk_l,X
1495 e947 99 20 01 STA fstk_varl,Y
1496 e94a b5 78 LDA noun_stk_h_str,X
1497 e94c 99 28 01 STA fstk_varh,Y
1498 e94f 60 RTS
1499 e950
1500 e950 20 15 e7 to_clause JSR get16bit
1501 e953 a4 fb LDY for_nest_count
1502 e955 a5 ce LDA acc
1503 e957 99 5f 01 STA fstk_tol-1,Y
1504 e95a a5 cf LDA acc+1
1505 e95c 99 67 01 STA fstk_toh-1,Y
1506 e95f a9 01 LDA #$01 ; 1 .
1507 e961 99 2f 01 STA fstk_stepl-1,Y
1508 e964 a9 00 LDA #$00 ; 0 .
1509 e966 99 37 01 Le966 STA fstk_steph-1,Y
1510 e969 a5 dc LDA pline
1511 e96b 99 3f 01 STA fstk_plinel-1,Y
1512 e96e a5 dd LDA pline+1
1513 e970 99 47 01 STA fstk_plineh-1,Y
1514 e973 a5 e0 LDA pverb
1515 e975 99 4f 01 STA fstk_pverbl-1,Y
1516 e978 a5 e1 LDA pverb+1
1517 e97a 99 57 01 STA fstk_pverbh-1,Y
1518 e97d 60 RTS
1519 e97e
1520 e97e 20 15 e7 Te97e JSR get16bit
1521 e981 a4 fb LDY for_nest_count
1522 e983 a5 ce LDA acc
1523 e985 99 2f 01 STA fstk_stepl-1,Y
1524 e988 a5 cf LDA acc+1
1525 e98a 4c 66 e9 JMP Le966
1526 e98d 00 00 00 00* DC.B $00,$00,$00,$00,$00,$00,$00,$00 ; "........"
1527 e995 00 00 00 DC.B $00,$00,$00 ; "..."
1528 e998 00 00 00 ab*verb_prec_tbl DC.B $00,$00,$00,$ab,$03,$03,$03,$03 ; "...+...."
1529 e9a0 03 03 03 03* DC.B $03,$03,$03,$03,$03,$03,$03,$03 ; "........"
1530 e9a8 03 03 3f 3f* DC.B $03,$03,$3f,$3f,$c0,$c0,$3c,$3c ; "..??@@<<"
1531 e9b0 3c 3c 3c 3c* DC.B $3c,$3c,$3c,$3c,$3c,$30,$0f,$c0 ; "<<<<<0.@"
1532 e9b8 IFCONST HUSTNBASIC
1533 e9b8 c3 ff 55 00* DC.B $c3,$ff,$55,$00,$ab,$ab,$03,$03 ; "L.U.++.."
1534 e9c0 - ELSE
1535 e9c0 - DC.B $cc,$ff,$55,$00,$ab,$ab,$03,$03 ; "L.U.++.."
1536 e9c0 ENDIF
1537 e9c0 ff ff 55 ff* DC.B $ff,$ff,$55,$ff,$ff,$55,$cf,$cf ; "..U..UOO"
1538 e9c8 cf cf cf ff* DC.B $cf,$cf,$cf,$ff,$55,$c3,$c3,$c3 ; "OOO.UCCC"
1539 e9d0 55 f0 f0 cf* DC.B $55,$f0,$f0,$cf,$56,$56,$56,$55 ; "UppOVVVU"
1540 e9d8 ff ff 55 03* DC.B $ff,$ff,$55,$03,$03,$03,$03,$03 ; "..U....."
1541 e9e0 03 03 ff ff* DC.B $03,$03,$ff,$ff,$ff,$03,$03,$03 ; "........"
1542 e9e8 03 03 03 03* DC.B $03,$03,$03,$03,$03,$03,$03,$03 ; "........"
1543 e9f0 03 03 03 03* DC.B $03,$03,$03,$03,$03,$00,$ab,$03 ; "......+."
1544 e9f8 57 03 03 03* DC.B $57,$03,$03,$03,$03,$07,$03,$03 ; "W......."
1545 ea00 03 03 03 03* DC.B $03,$03,$03,$03,$03,$03,$03,$03 ; "........"
1546 ea08 03 03 aa ff* DC.B $03,$03,$aa,$ff,$ff,$ff,$ff,$ff ; "..*....."
1547 ea10
1548 ea10
1549 ea10 verb_adr_l
1550 ea10 17 ff ff 19* DC.B <begin_line,$ff,$ff,<colon,<list_cmd,<list_comman,<list_all,<Teff2
1551 ea18 ec 87 6f ad* DC.B <Tefec,<del_cmd,<del_comma,<new_cmd,<clr,<auto_cmd,<auto_com,<man_cmd
1552 ea20 80 96 85 82* DC.B <Tef80,<Tef96,<add,< subtract,<mult_op,<divide,<eq_op,<neq_op
1553 ea28 13 06 0b 4a* DC.B <Tec13,< Tec06,< Tec0b,<neq_op,<Tec01,< Tec40,< Tec47,<mod_op
1554 ea30 IFCONST HUSTNBASIC
1555 ea30 a6 ff 23 09* DC.B <bogus_eea6,$ff,<left_paren,<comma_substr,<goto_stmt,<Te816,<string_input,<input_num_comma
1556 ea38 - ELSE
1557 ea38 - DC.B $00,$ff,<left_paren,<comma_substr,<goto_stmt,<Te816,<string_input,<input_num_comma
1558 ea38 ENDIF
1559 ea38 ff ff fb ff* DC.B $ff,$ff,<paren_substr,$ff,$ff,<num_array_subs,<peek_fn,<rnd_fn
1560 ea40 59 50 00 ff* DC.B <sgn_fn,<abs_fn,$00,$ff,<left_paren,<unary_pos,<negate,<not_op
1561 ea48 23 d7 1c 22* DC.B <left_paren,<string_eq,<string_neq,<len_fn,<bogus_eec2,<Teeae,<Teeba,<left_paren
1562 ea50 ff ff 21 30* DC.B $ff,$ff,<str_arr_dest,<dim_str,<dim_num,<print_str,<print_num,<print_semi
1563 ea58 00 c1 ff ff* DC.B <print_str_comma,<print_com_num,$ff,$ff,$ff,<call_stmt,<dim_str,<dim_num
1564 ea60 a4 d3 b6 bc* DC.B <tab_fn,<end_stmt,<string_input,<input_prompt,<input_num_stmt,<for_stmt,<var_assign,<to_clause
1565 ea68 7e d8 d8 a5* DC.B <Te97e,<next_stmt,<next_stmt,<return_stmt,<gosub_stmt,$ff,<Te816,<goto_stmt
1566 ea70 28 03 c4 1d* DC.B <if_stmt,<print_str,<print_num,<print_cr,<poke_stmt,<Tef0c,<Tee4e,<poke_stmt
1567 ea78 3e 00 a6 b0* DC.B <plot_comma,<poke_stmt,<bogus_eea6,<Teeb0,<poke_stmt,<Teebc,<Teec6,<vtab_stmt
1568 ea80 8c 01 27 ff* DC.B <string_lit,<var_assign,<right_paren,$ff,$ff,$ff,$ff,$ff
1569 ea88 verb_adr_h
1570 ea88 e8 ff ff e8* DC.B >begin_line,$ff,$ff,>colon,>list_cmd,>list_comman,>list_all,>Teff2
1571 ea90 ef e3 e3 e5* DC.B >Tefec,>del_cmd,>del_comma,>new_cmd,>clr,>auto_cmd,>auto_com,>man_cmd
1572 ea98 ef ef e7 e7* DC.B >Tef80,>Tef96,>add,> subtract,>mult_op,>divide,>eq_op,>neq_op
1573 eaa0 ec ec ec e7* DC.B >Tec13,> Tec06,> Tec0b,>neq_op,>Tec01,> Tec40,> Tec47,>mod_op
1574 eaa8 IFCONST HUSTNBASIC
1575 eaa8 ee ff e8 e1* DC.B >bogus_eea6,$ff,>left_paren,>comma_substr,>goto_stmt,>Te816,>string_input,>input_num_comma
1576 eab0 - ELSE
1577 eab0 - DC.B $0,$ff,>left_paren,>comma_substr,>goto_stmt,>Te816,>string_input,>input_num_comma
1578 eab0 ENDIF
1579 eab0 ff ff e0 ff* DC.B $ff,$ff,>paren_substr,$ff,$ff,>num_array_subs,>peek_fn,>rnd_fn
1580 eab8 e7 e7 00 ff* DC.B >sgn_fn,>abs_fn,$00,$ff,>left_paren,>unary_pos,>negate,>not_op
1581 eac0 e8 e1 e2 ee* DC.B >left_paren,>string_eq,>string_neq,>len_fn,>bogus_eec2,>Teeae,>Teeba,>left_paren
1582 eac8 ff ff e1 e1* DC.B $ff,$ff,>str_arr_dest,>dim_str,>dim_num,>print_str,>print_num,>print_semi
1583 ead0 ee e7 ff ff* DC.B >print_str_comma,>print_com_num,$ff,$ff,$ff,>call_stmt,>dim_str,>dim_num
1584 ead8 e7 e8 ef ef* DC.B >tab_fn,>end_stmt,>string_input,>input_prompt,>input_num_stmt,>for_stmt,>var_assign,>to_clause
1585 eae0 e9 e8 e8 e8* DC.B >Te97e,>next_stmt,>next_stmt,>return_stmt,>gosub_stmt,$ff,>Te816,>goto_stmt
1586 eae8 e8 ee e7 e8* DC.B >if_stmt,>print_str,>print_num,>print_cr,>poke_stmt,>Tef0c,>Tee4e,>poke_stmt
1587 eaf0 ee ef ee ee* DC.B >plot_comma,>poke_stmt,>bogus_eea6,>Teeb0,>poke_stmt,>Teebc,>Teec6,>vtab_stmt
1588 eaf8 e1 e8 e8 ff* DC.B >string_lit,>var_assign,>right_paren,$ff,$ff,$ff,$ff,$ff
1589 eb00 be b3 b2 b7*error_msg_tbl DC.B $be,$b3,$b2,$b7,$b6,$37,$d4,$cf ; ">32767TO"
1590 eb08 cf a0 cc cf* DC.B $cf,$a0,$cc,$cf,$ce,$47,$d3,$d9 ; "O LONGSY"
1591 eb10 ce d4 c1 58* DC.B $ce,$d4,$c1,$58,$cd,$c5,$cd,$a0 ; "NTAXMEM "
1592 eb18 c6 d5 cc 4c* DC.B $c6,$d5,$cc,$4c,$d4,$cf,$cf,$a0 ; "FULLTOO "
1593 eb20 cd c1 ce d9* DC.B $cd,$c1,$ce,$d9,$a0,$d0,$c1,$d2 ; "MANY PAR"
1594 eb28 c5 ce 53 d3* DC.B $c5,$ce,$53,$d3,$d4,$d2,$c9,$ce ; "ENSSTRIN"
1595 eb30 47 ce cf a0* DC.B $47,$ce,$cf,$a0,$c5,$ce,$44,$c2 ; "GNO ENDB"
1596 eb38 c1 c4 a0 c2* DC.B $c1,$c4,$a0,$c2,$d2,$c1,$ce,$c3 ; "AD BRANC"
1597 eb40 48 be b8 a0* DC.B $48,$be,$b8,$a0,$c7,$cf,$d3,$d5 ; "H>8 GOSU"
1598 eb48 c2 53 c2 c1* DC.B $c2,$53,$c2,$c1,$c4,$a0,$d2,$c5 ; "BSBAD RE"
1599 eb50 d4 d5 d2 4e* DC.B $d4,$d5,$d2,$4e,$be,$b8,$a0,$c6 ; "TURN>8 F"
1600 eb58 cf d2 53 c2* DC.B $cf,$d2,$53,$c2,$c1,$c4,$a0,$ce ; "ORSBAD N"
1601 eb60 c5 d8 54 d3* DC.B $c5,$d8,$54,$d3,$d4,$cf,$d0,$d0 ; "EXTSTOPP"
1602 eb68 c5 c4 a0 c1* DC.B $c5,$c4,$a0,$c1,$d4,$20,$aa,$aa ; "ED AT **"
1603 eb70 aa 20 a0 c5* DC.B $aa,$20,$a0,$c5,$d2,$d2,$0d,$be ; "* ERR.>"
1604 eb78 b2 b5 35 d2* DC.B $b2,$b5,$35,$d2,$c1,$ce,$c7,$45 ; "255RANGE"
1605 eb80 c4 c9 4d d3* DC.B $c4,$c9,$4d,$d3,$d4,$d2,$a0,$cf ; "DIMSTR O"
1606 eb88 d6 c6 4c dc* DC.B $d6,$c6,$4c,$dc,$0d,$d2,$c5,$d4 ; "VFL\.RET"
1607 eb90 d9 d0 c5 a0* DC.B $d9,$d0,$c5,$a0,$cc,$c9,$ce,$c5 ; "YPE LINE"
1608 eb98 8d 3f DC.B $8d,$3f ; ".?"
1609 eb9a 46 d9 Leb9a LSR run_flag
1610 eb9c 90 03 BCC Leba1
1611 eb9e 4c c3 e8 JMP Le8c3
1612 eba1 a6 cf Leba1 LDX acc+1
1613 eba3 9a TXS
1614 eba4 a6 ce LDX acc
1615 eba6 a0 8d LDY #$8d ; 141 .
1616 eba8 d0 02 BNE Lebac
1617 ebaa
1618 ebaa a0 99 input_num_stmt LDY #$99 ; 153 .
1619 ebac 20 c4 e3 Lebac JSR Se3c4
1620 ebaf 86 ce STX acc
1621 ebb1 ba TSX
1622 ebb2 86 cf STX acc+1
1623 ebb4 a0 fe LDY #$fe ; 254 ~
1624 ebb6 84 d9 STY run_flag
1625 ebb8 c8 INY
1626 ebb9 84 c8 STY text_index
1627 ebbb 20 99 e2 JSR Se299
1628 ebbe 84 f1 STY token_index
1629 ebc0 a2 20 LDX #$20 ; 32
1630 ebc2 a9 30 LDA #$30 ; 48 0
1631 ebc4 20 91 e4 JSR Se491
1632 ebc7 e6 d9 INC run_flag
1633 ebc9 a6 ce LDX acc
1634 ebcb
1635 ebcb a4 c8 input_num_comma LDY text_index
1636 ebcd 0a ASL
1637 ebce 85 ce Lebce STA acc
1638 ebd0 c8 INY
1639 ebd1 b9 00 02 LDA buffer,Y
1640 ebd4 c9 74 CMP #$74 ; 116 t
1641 ebd6 f0 d2 BEQ input_num_stmt
1642 ebd8 49 b0 EOR #$b0 ; 176 0
1643 ebda c9 0a CMP #$0a ; 10 .
1644 ebdc b0 f0 BCS Lebce
1645 ebde c8 INY
1646 ebdf c8 INY
1647 ebe0 84 c8 STY text_index
1648 ebe2 b9 00 02 LDA buffer,Y
1649 ebe5 48 PHA
1650 ebe6 b9 ff 01 LDA buffer-1,Y
1651 ebe9 a0 00 LDY #$00 ; 0 .
1652 ebeb 20 08 e7 JSR push_ya_noun_stk
1653 ebee 68 PLA
1654 ebef 95 a0 STA noun_stk_h_int,X
1655 ebf1 a5 ce LDA acc
1656 ebf3 c9 c7 CMP #$c7 ; 199 G
1657 ebf5 d0 03 BNE Lebfa
1658 ebf7 20 6f e7 JSR negate
1659 ebfa 4c 01 e8 Lebfa JMP var_assign
1660 ebfd ff ff ff 50 DC.B $ff,$ff,$ff,$50 ; "...P"
1661 ec01
1662 ec01 20 13 ec Tec01 JSR Tec13
1663 ec04 d0 15 BNE Lec1b
1664 ec06
1665 ec06 20 0b ec Tec06 JSR Tec0b
1666 ec09 d0 10 BNE Lec1b
1667 ec0b
1668 ec0b 20 82 e7 Tec0b JSR subtract
1669 ec0e 20 6f e7 JSR negate
1670 ec11 50 03 BVC Lec16
1671 ec13
1672 ec13 20 82 e7 Tec13 JSR subtract
1673 ec16 20 59 e7 Lec16 JSR sgn_fn
1674 ec19 56 50 LSR noun_stk_l,X
1675 ec1b 4c 36 e7 Lec1b JMP not_op
1676 ec1e ff ff DC.B $ff,$ff ; ".."
1677 ec20 c1 ff 7f d1*syntabl_index DC.B $c1,$ff,$7f,$d1,$cc,$c7,$cf,$ce ; "A..QLGON"
1678 ec28 c5 9a 98 8b* DC.B $c5,$9a,$98,$8b,$96,$95,$93,$bf ; "E......?"
1679 ec30 b2 32 2d 2b* DC.B $b2,$32,$2d,$2b,$bc,$b0,$ac,$be ; "22-+<0,>"
1680 ec38 35 8e 61 ff* DC.B $35,$8e,$61,$ff,$ff,$ff,$dd,$fb ; "5.a...]{"
1681 ec40
1682 ec40 20 c9 ef Tec40 JSR Sefc9
1683 ec43 15 4f ORA rnd+1,X
1684 ec45 10 05 BPL Lec4c
1685 ec47
1686 ec47 20 c9 ef Tec47 JSR Sefc9
1687 ec4a 35 4f AND rnd+1,X
1688 ec4c 95 50 Lec4c STA noun_stk_l,X
1689 ec4e 10 cb BPL Lec1b
1690 ec50 4c c9 ef JMP Sefc9
1691 ec53 40 60 8d 60* DC.B $40,$60,$8d,$60,$8b,$00,$7e,$8c ; "@`.`..~."
1692 ec5b 33 00 00 60* DC.B $33,$00,$00,$60,$03,$bf,$12,$00 ; "3..`.?.."
1693 ec63 40 89 c9 47* DC.B $40,$89,$c9,$47,$9d,$17,$68,$9d ; "@.IG..h."
1694 ec6b 0a 00 40 60* DC.B $0a,$00,$40,$60,$8d,$60,$8b,$00 ; "..@`.`.."
1695 ec73 7e 8c 3c 00* DC.B $7e,$8c,$3c,$00,$00,$60,$03,$bf ; "~.<..`.?"
1696 ec7b 1b 4b 67 b4* DC.B $1b,$4b,$67,$b4,$a1,$07,$8c,$07 ; ".Kg4!..."
1697 ec83 ae a9 ac a8* DC.B $ae,$a9,$ac,$a8,$67,$8c,$07,$b4 ; ".),(g..4"
1698 ec8b af ac b0 67* DC.B $af,$ac,$b0,$67,$9d,$b2,$af,$ac ; "/,0g.2/,"
1699 ec93 af a3 67 8c* DC.B $af,$a3,$67,$8c,$07,$a5,$ab,$af ; "/#g..%+/"
1700 ec9b b0 f4 ae a9* DC.B $b0,$f4,$ae,$a9,$b2,$b0,$7f,$0e ; "0t.)20.."
1701 eca3 27 b4 ae a9* DC.B $27,$b4,$ae,$a9,$b2,$b0,$7f,$0e ; "'4.)20.."
1702 ecab 28 b4 ae a9* DC.B $28,$b4,$ae,$a9,$b2,$b0,$64,$07 ; "(4.)20d."
1703 ecb3 a6 a9 67 af* DC.B $a6,$a9,$67,$af,$b4,$af,$a7,$78 ; "&)g/4/'x"
1704 ecbb b4 a5 ac 78* DC.B $b4,$a5,$ac,$78,$7f,$02,$ad,$a5 ; "4%,x..-%"
1705 ecc3 b2 67 a2 b5* DC.B $b2,$67,$a2,$b5,$b3,$af,$a7,$ee ; "2g"53/'n"
1706 eccb b2 b5 b4 a5* DC.B $b2,$b5,$b4,$a5,$b2,$7e,$8c,$39 ; "254%2~.9"
1707 ecd3 b4 b8 a5 ae* DC.B $b4,$b8,$a5,$ae,$67,$b0,$a5,$b4 ; "48%.g0%4"
1708 ecdb b3 27 af b4* DC.B $b3,$27,$af,$b4,$07,$9d,$19,$b2 ; "3'/4...2"
1709 ece3 af a6 7f 05* DC.B $af,$a6,$7f,$05,$37,$b4,$b5,$b0 ; "/&..7450"
1710 eceb ae a9 7f 05* DC.B $ae,$a9,$7f,$05,$28,$b4,$b5,$b0 ; ".)..(450"
1711 ecf3 ae a9 7f 05* DC.B $ae,$a9,$7f,$05,$2a,$b4,$b5,$b0 ; ".)..*450"
1712 ecfb ae a9 e4 ae* DC.B $ae,$a9,$e4,$ae,$a5,$00,$ff,$ff ; ".)d.%..."
1713 ed03 47 a2 a1 b4*syntabl2 DC.B $47,$a2,$a1,$b4,$7f,$0d,$30,$ad ; "G"!4..0-"
1714 ed0b a9 a4 7f 0d* DC.B $a9,$a4,$7f,$0d,$23,$ad,$a9,$a4 ; ")$..#-)$"
1715 ed13 67 ac ac a1* DC.B $67,$ac,$ac,$a1,$a3,$00,$40,$80 ; "g,,!#.@."
1716 ed1b c0 c1 80 00* DC.B $c0,$c1,$80,$00,$47,$8c,$68,$8c ; "@A..G.h."
1717 ed23 db 67 9b 68* DC.B $db,$67,$9b,$68,$9b,$50,$8c,$63 ; "[g.h.P.c"
1718 ed2b 8c 7f 01 51* DC.B $8c,$7f,$01,$51,$07,$88,$29,$84 ; "...Q..)."
1719 ed33 80 c4 80 57* DC.B $80,$c4,$80,$57,$71,$07,$88,$14 ; ".D.Wq..."
1720 ed3b ed a5 ad af* DC.B $ed,$a5,$ad,$af,$ac,$ed,$a5,$ad ; "m%-/,m%-"
1721 ed43 a9 a8 f2 af* DC.B $a9,$a8,$f2,$af,$ac,$af,$a3,$71 ; ")(r/,/#q"
1722 ed4b 08 88 ae a5* DC.B $08,$88,$ae,$a5,$ac,$68,$83,$08 ; "...%,h.."
1723 ed53 68 9d 08 71* DC.B $68,$9d,$08,$71,$07,$88,$60,$76 ; "h..q..`v"
1724 ed5b b4 af ae 76* DC.B $b4,$af,$ae,$76,$8d,$76,$8b,$51 ; "4/.v.v.Q"
1725 ed63 07 88 19 b8* DC.B $07,$88,$19,$b8,$a4,$ae,$b2,$f2 ; "...8$.2r"
1726 ed6b b3 b5 f3 a2* DC.B $b3,$b5,$f3,$a2,$a1,$ee,$a7,$b3 ; "35s"!n'3"
1727 ed73 e4 ae b2 eb* DC.B $e4,$ae,$b2,$eb,$a5,$a5,$b0,$51 ; "d.2k%%0Q"
1728 ed7b 07 88 39 81* DC.B $07,$88,$39,$81,$c1,$4f,$7f,$0f ; "..9.AO.."
1729 ed83 2f 00 51 06* DC.B $2f,$00,$51,$06,$88,$29,$c2,$0c ; "/.Q..)B."
1730 ed8b 82 57 8c 6a* DC.B $82,$57,$8c,$6a,$8c,$42,$ae,$a5 ; ".W.j.B.%"
1731 ed93 a8 b4 60 ae* DC.B $a8,$b4,$60,$ae,$a5,$a8,$b4,$4f ; "(4`.%(4O"
1732 ed9b 7e 1e 35 8c* DC.B $7e,$1e,$35,$8c,$27,$51,$07,$88 ; "~.5.'Q.."
1733 eda3 09 8b fe e4* DC.B $09,$8b,$fe,$e4,$af,$ad,$f2,$af ; "..~d/-r/"
1734 edab e4 ae a1 dc* DC.B $e4,$ae,$a1,$dc,$de,$9c,$dd,$9c ; "d.!\^.]."
1735 edb3 de dd 9e c3* DC.B $de,$dd,$9e,$c3,$dd,$cf,$ca,$cd ; "^].C]OJM"
1736 edbb cb 00 47 9d* DC.B $cb,$00,$47,$9d,$ad,$a5,$ad,$af ; "K.G.-%-/"
1737 edc3 ac 76 9d ad* DC.B $ac,$76,$9d,$ad,$a5,$ad,$a9,$a8 ; ",v.-%-)("
1738 edcb e6 a6 af 60* DC.B $e6,$a6,$af,$60,$8c,$20,$af,$b4 ; "f&/`. /4"
1739 edd3 b5 a1 f2 ac* DC.B $b5,$a1,$f2,$ac,$a3,$f2,$a3,$b3 ; "5!r,#r#3"
1740 eddb 60 8c 20 ac* DC.B $60,$8c,$20,$ac,$a5,$a4,$ee,$b5 ; "`. ,%$n5"
1741 ede3 b2 60 ae b5* DC.B $b2,$60,$ae,$b5,$b2,$f4,$b3,$a9 ; "2`.52t3)"
1742 edeb ac 60 8c 20* DC.B $ac,$60,$8c,$20,$b4,$b3,$a9,$ac ; ",`. 43),"
1743 edf3 7a 7e 9a 22* DC.B $7a,$7e,$9a,$22,$20,$00,$60,$03 ; "z~." .`."
1744 edfb bf 60 03 bf* DC.B $bf,$60,$03,$bf,$1f ; "?`.?."
1745 ee00
1746 ee00 20 b1 e7 print_str_comma JSR tabout
1747 ee03
1748 ee03 e8 print_str INX
1749 ee04 e8 INX
1750 ee05 b5 4f LDA rnd+1,X
1751 ee07 85 da STA aux
1752 ee09 b5 77 LDA syn_stk_h+31,X
1753 ee0b 85 db STA aux+1
1754 ee0d b4 4e LDY rnd,X
1755 ee0f 98 Lee0f TYA
1756 ee10 d5 76 CMP syn_stk_h+30,X
1757 ee12 b0 09 BCS Lee1d
1758 ee14 b1 da LDA (aux),Y
1759 ee16 20 c9 e3 JSR cout
1760 ee19 c8 INY
1761 ee1a 4c 0f ee JMP Lee0f
1762 ee1d a9 ff Lee1d LDA #$ff ; 255 .
1763 ee1f 85 d5 STA cr_flag
1764 ee21 60 RTS
1765 ee22
1766 ee22 e8 len_fn INX
1767 ee23 a9 00 LDA #$00 ; 0 .
1768 ee25 95 78 STA noun_stk_h_str,X
1769 ee27 95 a0 STA noun_stk_h_int,X
1770 ee29 b5 77 LDA syn_stk_h+31,X
1771 ee2b 38 SEC
1772 ee2c f5 4f SBC rnd+1,X
1773 ee2e 95 50 STA noun_stk_l,X
1774 ee30 4c 23 e8 JMP left_paren
1775 ee33 ff DC.B $ff ; "."
1776 ee34
1777 ee34 20 15 e7 getbyte JSR get16bit
1778 ee37 a5 cf LDA acc+1
1779 ee39 d0 28 BNE gr_255_err
1780 ee3b a5 ce LDA acc
1781 ee3d Tee3d
1782 ee3d 60 RTS
1783 ee3e plot_comma
1784 ee3e IFCONST HUSTNBASIC
1785 ee3e 20 08 e7 JSR push_ya_noun_stk
1786 ee41 94 a0 STY $a0,X
1787 ee43 Tee43
1788 ee43 a5 d0 LDA $D0
1789 ee45 d0 04 BNE Tee4b
1790 ee47 c6 d1 DEC $D1
1791 ee49 30 f2 BMI Tee3d
1792 ee4b Tee4b
1793 ee4b c6 d0 DEC $D0
1794 ee4d ; LDA $D2
1795 ee4d a5 DC.b $a5
1796 ee4e Tee4e ;MJW wrong address, so we have to break this instruction
1797 ee4e d2 DC.b $d2
1798 ee4f
1799 ee4f a0 00 LDY #$00
1800 ee51 20 08 e7 JSR push_ya_noun_stk
1801 ee54 man_cmd
1802 ee54 a5 d3 LDA $D3
1803 ee56 ; STA $A0,X
1804 ee56 95 DC.b $95
1805 ee57 vtab_stmt
1806 ee57 a0 DC.b $a0
1807 ee58 20 22 e2 JSR mult_op
1808 ee5b 4c 43 ee JMP Tee43
1809 ee5e - ELSE
1810 ee5e -
1811 ee5e - JSR getbyte
1812 ee5e - LDY text_index
1813 ee5e - CMP #$30 ; 48 0
1814 ee5e - BCS range_err
1815 ee5e - CPY #$28 ; 40 (
1816 ee5e - BCS range_err
1817 ee5e - RTS
1818 ee5e - NOP
1819 ee5e - NOP
1820 ee5e -
1821 ee5e -
1822 ee5e -Tee4e JSR getbyte
1823 ee5e - RTS
1824 ee5e ENDIF
1825 ee5e ;
1826 ee5e - IFCONST SNDERBASIC ;WSANDER BASIC HERE
1827 ee5e - NOP
1828 ee5e - NOP
1829 ee5e -
1830 ee5e -man_cmd LSR auto_flag
1831 ee5e - RTS
1832 ee5e -
1833 ee5e -vtab_stmt JSR getbyte
1834 ee5e - CMP #$18 ; 24 .
1835 ee5e - BCS range_err
1836 ee5e - STA cv
1837 ee5e - RTS
1838 ee5e - NOP
1839 ee5e - NOP
1840 ee5e ELSE ;OTHER BASIC
1841 ee5e - IFNCONST HUSTNBASIC ; omit next 12 bytes if Hustn basic
1842 ee5e - nop
1843 ee5e -Lee53
1844 ee5e - txa
1845 ee5e -man_cmd
1846 ee5e - ldx #$1
1847 ee5e -Lee56
1848 ee5e - ; ldy acc,x
1849 ee5e - DC.b $B4
1850 ee5e -vtab_stmt ;wrong address MJW
1851 ee5e - DC.b acc
1852 ee5e -
1853 ee5e - sty himem,x
1854 ee5e - ldy zp48,x
1855 ee5e - sty pp,x
1856 ee5e -
1857 ee5e - dex
1858 ee5e - IFCONST BRIELBASIC ;BRIEL BASIC HERE
1859 ee5e - beq Lee56
1860 ee5e - ELSE
1861 ee5e - beq man_cmd
1862 ee5e - ENDIF
1863 ee5e - tax
1864 ee5e - rts
1865 ee5e ELSE ;HUSTNBASIC
1866 ee5e 85 25 STA cv
1867 ee60 60 RTS
1868 ee61 ea NOP
1869 ee62 ea NOP
1870 ee63 ENDIF
1871 ee63 ENDIF
1872 ee63 a0 77 gr_255_err LDY #$77 ; 119 w
1873 ee65 4c e0 e3 go_errmess_5 JMP print_err_msg
1874 ee68 a0 7b range_err LDY #$7b ; 123 {
1875 ee6a d0 f9 BNE go_errmess_5
1876 ee6c
1877 ee6c 20 54 e2 See6c JSR Se254
1878 ee6f a5 da LDA aux
1879 ee71 d0 07 BNE Lee7a
1880 ee73 a5 db LDA aux+1
1881 ee75 d0 03 BNE Lee7a
1882 ee77 4c 7e e7 JMP Le77e
1883 ee7a 06 ce Lee7a ASL acc
1884 ee7c 26 cf ROL acc+1
1885 ee7e 26 e6 ROL p3
1886 ee80 26 e7 ROL p3+1
1887 ee82 a5 e6 LDA p3
1888 ee84 c5 da CMP aux
1889 ee86 a5 e7 LDA p3+1
1890 ee88 e5 db SBC aux+1
1891 ee8a 90 0a BCC Lee96
1892 ee8c 85 e7 STA p3+1
1893 ee8e a5 e6 LDA p3
1894 ee90 e5 da SBC aux
1895 ee92 85 e6 STA p3
1896 ee94 e6 ce INC acc
1897 ee96 88 Lee96 DEY
1898 ee97 d0 e1 BNE Lee7a
1899 ee99 60 RTS
1900 ee9a ff ff ff ff* DC.B $ff,$ff,$ff,$ff,$ff,$ff ; "......"
1901 eea0
1902 eea0 20 15 e7 call_stmt JSR get16bit
1903 eea3 6c ce 00 JMP (acc)
1904 eea6 - IFCONST BRIELBASIC ;BRIEL BASIC
1905 eea6 -bogus_eea6
1906 eea6 - LDA himem
1907 eea6 - BNE Leeac
1908 eea6 - dec zp4d
1909 eea6 -Leeac
1910 eea6 - dec himem
1911 eea6 -Teeae
1912 eea6 - lda zp48
1913 eea6 -Teeb0
1914 eea6 - bne Leeb4
1915 eea6 - dec zp49
1916 eea6 -Leeb4
1917 eea6 - dec zp48
1918 eea6 -Leeb6
1919 eea6 - ldy #$00
1920 eea6 - lda (himem),y
1921 eea6 -Teeba
1922 eea6 - sta (zp48),y
1923 eea6 -Teebc
1924 eea6 - lda pp
1925 eea6 - cmp himem
1926 eea6 - lda zpcb
1927 eea6 -bogus_eec2
1928 eea6 - sbc zp4d
1929 eea6 - bcc bogus_eea6
1930 eea6 -Teec6 jmp Lee53
1931 eea6 -
1932 eea6 -
1933 eea6 -
1934 eea6 ELSE ;SANDER/HUSTON (NOT BREIL) BASIC HERE
1935 eea6
1936 eea6
1937 eea6 bogus_eea6 ;DC.B $20,$34,$ee,$c5,$c8,$90,$bb,$85 ; " 4nEH.;."
1938 eea6 - IFCONST SNDERBASIC ;WSANDER BASIC HERE
1939 eea6 - JSR getbyte
1940 eea6 - CMP text_index
1941 eea6 - BCC range_err
1942 eea6 - ; sta LOCZERO
1943 eea6 - DC.b $85
1944 eea6 -
1945 eea6 -Teeae LDA himem+1
1946 eea6 -
1947 eea6 -Teeb0 PHA
1948 eea6 - LDA himem
1949 eea6 - JSR push_ya_noun_stk
1950 eea6 -Leeb6
1951 eea6 - PLA
1952 eea6 - STA noun_stk_h_int,X
1953 eea6 - RTS
1954 eea6 -
1955 eea6 -Teeba LDA lomem+1
1956 eea6 -
1957 eea6 -Teebc PHA
1958 eea6 - LDA lomem
1959 eea6 - JMP Lefb3
1960 eea6 -bogus_eec2
1961 eea6 - LDA zp85
1962 eea6 - DC.b $2D,$60
1963 eea6 -Teec6 JSR getbyte
1964 eea6 ELSE ;HUSTON BASIC HERE
1965 eea6 20 15 e7 JSR get16bit
1966 eea9 a5 cf LDA zpcf
1967 eeab 10 08 BPL Leeb5
1968 eead 98 TYA
1969 eeae Teeae
1970 eeae ca DEX
1971 eeaf ; JSR push_ya_noun_stk
1972 eeaf 20 DC.b $20
1973 eeb0 Teeb0
1974 eeb0 08 e7 DC.b $08,$e7
1975 eeb2
1976 eeb2 94 a0 STY noun_stk_h_int,x
1977 eeb4 60 rts
1978 eeb5 Leeb5
1979 eeb5 ; STA tokndxstk
1980 eeb5 85 DC.b $85
1981 eeb6 Leeb6
1982 eeb6 d1 DC.b $d1
1983 eeb7
1984 eeb7 a5 ce LDA acc
1985 eeb9 ; STA srch
1986 eeb9 85 DC.b $85
1987 eeba Teeba
1988 eeba d0 DC.b $d0
1989 eebb
1990 eebb ; JSR get16bit
1991 eebb 20 DC.b $20
1992 eebc Teebc
1993 eebc 15 e7 DC.b $15, $e7
1994 eebe
1995 eebe a5 ce LDA acc
1996 eec0 85 d2 STA srch2
1997 eec2 bogus_eec2
1998 eec2 a5 cf LDA zpcf
1999 eec4 85 d3 STA $d3
2000 eec6 Teec6
2001 eec6 a9 01 LDA #$01
2002 eec8 4c 3e ee JMP plot_comma
2003 eecb ENDIF
2004 eecb ENDIF
2005 eecb - IFNCONST HUSTNBASIC ; omit next 2 bytes if Hustn basic
2006 eecb - CMP #$28 ; 40 (
2007 eecb ENDIF
2008 eecb b0 9b Leecb BCS range_err
2009 eecd a8 TAY
2010 eece a5 c8 LDA text_index
2011 eed0 60 RTS
2012 eed1 ea NOP
2013 eed2 ea NOP
2014 eed3
2015 eed3 98 print_err_msg2 TYA
2016 eed4 aa TAX
2017 eed5 a0 6e LDY #$6e ; 110 n
2018 eed7 20 c4 e3 JSR Se3c4
2019 eeda 8a TXA
2020 eedb a8 TAY
2021 eedc 20 c4 e3 JSR Se3c4
2022 eedf a0 72 LDY #$72 ; 114 r
2023 eee1 4c c4 e3 JMP Se3c4
2024 eee4
2025 eee4 20 15 e7 Seee4 JSR get16bit
2026 eee7 06 ce Leee7 ASL acc
2027 eee9 26 cf ROL acc+1
2028 eeeb 30 fa BMI Leee7
2029 eeed b0 dc BCS Leecb
2030 eeef d0 04 BNE Leef5
2031 eef1 c5 ce CMP acc
2032 eef3 b0 d6 BCS Leecb
2033 eef5 60 Leef5 RTS
2034 eef6
2035 eef6 peek_fn
2036 eef6 - IFCONST BLD4APPLE1
2037 eef6 - JSR get16bit
2038 eef6 ELSE
2039 eef6 4c a9 d7 JMP A2PEEK
2040 eef9 ENDIF
2041 eef9 b1 ce LDA (acc),Y
2042 eefb 94 9f STY syn_stk_l+31,X
2043 eefd 4c 08 e7 JMP push_ya_noun_stk
2044 ef00
2045 ef00 poke_stmt
2046 ef00 - IFCONST BLD4APPLE1
2047 ef00 - JSR getbyte
2048 ef00 ELSE
2049 ef00 4c 8c d7 JMP A2POKE
2050 ef03 ENDIF
2051 ef03 a5 ce LDA acc
2052 ef05 48 PHA
2053 ef06 20 15 e7 JSR get16bit
2054 ef09 68 PLA
2055 ef0a 91 ce STA (acc),Y
2056 ef0c
2057 ef0c 60 Tef0c RTS
2058 ef0d ff ff ff DC.B $ff,$ff,$ff ; "..."
2059 ef10
2060 ef10 20 6c ee divide JSR See6c
2061 ef13 a5 ce LDA acc
2062 ef15 85 e6 STA p3
2063 ef17 a5 cf LDA acc+1
2064 ef19 85 e7 STA p3+1
2065 ef1b 4c 44 e2 JMP Le244
2066 ef1e
2067 ef1e 20 e4 ee dim_num JSR Seee4
2068 ef21 4c 34 e1 JMP Le134
2069 ef24
2070 ef24 20 e4 ee num_array_subs JSR Seee4
2071 ef27 b4 78 LDY noun_stk_h_str,X
2072 ef29 b5 50 LDA noun_stk_l,X
2073 ef2b 69 fe ADC #$fe ; 254 ~
2074 ef2d b0 01 BCS Lef30
2075 ef2f 88 DEY
2076 ef30 85 da Lef30 STA aux
2077 ef32 84 db STY aux+1
2078 ef34 18 CLC
2079 ef35 65 ce ADC acc
2080 ef37 95 50 STA noun_stk_l,X
2081 ef39 98 TYA
2082 ef3a 65 cf ADC acc+1
2083 ef3c 95 78 STA noun_stk_h_str,X
2084 ef3e a0 00 LDY #$00 ; 0 .
2085 ef40 b5 50 LDA noun_stk_l,X
2086 ef42 d1 da CMP (aux),Y
2087 ef44 c8 INY
2088 ef45 b5 78 LDA noun_stk_h_str,X
2089 ef47 f1 da SBC (aux),Y
2090 ef49 b0 80 BCS Leecb
2091 ef4b 4c 23 e8 JMP left_paren
2092 ef4e
2093 ef4e 20 15 e7 rnd_fn JSR get16bit
2094 ef51 a5 4e LDA rnd
2095 ef53 20 08 e7 JSR push_ya_noun_stk
2096 ef56 a5 4f LDA rnd+1
2097 ef58 d0 04 BNE Lef5e
2098 ef5a c5 4e CMP rnd
2099 ef5c 69 00 ADC #$00 ; 0 .
2100 ef5e 29 7f Lef5e AND #$7f ; 127 .
2101 ef60 85 4f STA rnd+1
2102 ef62 95 a0 STA noun_stk_h_int,X
2103 ef64 a0 11 LDY #$11 ; 17 .
2104 ef66 a5 4f Lef66 LDA rnd+1
2105 ef68 0a ASL
2106 ef69 18 CLC
2107 ef6a 69 40 ADC #$40 ; 64 @
2108 ef6c 0a ASL
2109 ef6d 26 4e ROL rnd
2110 ef6f 26 4f ROL rnd+1
2111 ef71 88 DEY
2112 ef72 d0 f2 BNE Lef66
2113 ef74 a5 ce LDA acc
2114 ef76 20 08 e7 JSR push_ya_noun_stk
2115 ef79 a5 cf LDA acc+1
2116 ef7b 95 a0 STA noun_stk_h_int,X
2117 ef7d 4c 7a e2 JMP mod_op
2118 ef80
2119 ef80 20 15 e7 Tef80 JSR get16bit
2120 ef83 a4 ce LDY acc
2121 ef85 - IFCONST SNDERBASIC ;SANDER BASIC HERE
2122 ef85 - CPY lomem
2123 ef85 - LDA acc+1
2124 ef85 - SBC lomem+1
2125 ef85 - BCC Lefab_efad
2126 ef85 - STY himem
2127 ef85 - LDA acc+1
2128 ef85 - STA himem+1
2129 ef85 -Lef93 JMP new_cmd
2130 ef85 -
2131 ef85 -Tef96 JSR get16bit
2132 ef85 - LDY acc
2133 ef85 - CPY himem
2134 ef85 - LDA acc+1
2135 ef85 - SBC himem+1
2136 ef85 - BCS Lefab_efad
2137 ef85 - STY lomem
2138 ef85 - LDA acc+1
2139 ef85 - STA lomem+1
2140 ef85 - BCC Lef93
2141 ef85 -Lefab_efad JMP Leecb
2142 ef85 - ;DC.B ;$a5,$4d,$48,$a5,$4c ; "%MH%L"
2143 ef85 - lda zp4d
2144 ef85 - pha
2145 ef85 - lda himem
2146 ef85 ELSE
2147 ef85 IFCONST HUSTNBASIC
2148 ef85 c4 4a CPY lomem
2149 ef87 a5 cf LDA zpcf
2150 ef89 e5 4b SBC zp4b
2151 ef8b 90 1e BCC Lefab
2152 ef8d 84 4c STY himem
2153 ef8f a5 cf LDA zpcf
2154 ef91 85 4d STA zp4d
2155 ef93 Lef93
2156 ef93 4c ad e5 JMP new_cmd
2157 ef96 Tef96
2158 ef96 20 15 e7 JSR get16bit
2159 ef99 a4 ce LDY acc
2160 ef9b c4 4c CPY himem
2161 ef9d a5 cf LDA zpcf
2162 ef9f e5 4d SBC zp4d
2163 efa1 b0 08 BCS Lefab
2164 efa3 84 4a STY lomem
2165 efa5 a5 cf LDA zpcf
2166 efa7 85 4b sta zp4b
2167 efa9 90 e8 bcc Lef93
2168 efab Lefab
2169 efab 4c cb ee JMP Leecb
2170 efae a5 4d LDA zp4d
2171 efb0 48 PHA
2172 efb1 a5 4c LDA himem
2173 efb3 - ELSE
2174 efb3 - cpy himem
2175 efb3 - lda zpcf
2176 efb3 - sbc zp4d
2177 efb3 - bcc Lefac
2178 efb3 - sty zp48
2179 efb3 - lda zpcf
2180 efb3 - sta zp49
2181 efb3 - jmp Leeb6
2182 efb3 -Tef96
2183 efb3 - jsr get16bit
2184 efb3 - ldy acc
2185 efb3 - cpy pp
2186 efb3 - lda zpcf
2187 efb3 - sbc zpcb
2188 efb3 - bcs Lefac
2189 efb3 - sty lomem
2190 efb3 - lda zpcf
2191 efb3 - sta zp4b
2192 efb3 - jmp clr
2193 efb3 -Lefac
2194 efb3 - jmp Leecb
2195 efb3 -
2196 efb3 -Lefab_efad
2197 efb3 - nop
2198 efb3 - nop
2199 efb3 - nop
2200 efb3 - nop
2201 efb3 ENDIF
2202 efb3 ENDIF
2203 efb3 20 c9 ef Lefb3 JSR Sefc9
2204 efb6
2205 efb6 20 71 e1 string_input JSR input_str
2206 efb9 4c bf ef JMP Lefbf
2207 efbc
2208 efbc 20 03 ee input_prompt JSR print_str
2209 efbf a9 ff Lefbf LDA #$ff ; 255 .
2210 efc1 85 c8 STA text_index
2211 efc3 a9 74 LDA #$74 ; 116 t
2212 efc5 8d 00 02 STA buffer
2213 efc8 60 RTS
2214 efc9
2215 efc9 20 36 e7 Sefc9 JSR not_op
2216 efcc e8 INX
2217 efcd
2218 efcd 20 36 e7 Sefcd JSR not_op
2219 efd0 b5 50 LDA noun_stk_l,X
2220 efd2 60 RTS
2221 efd3
2222 efd3 a9 00 mem_init_4k LDA #$00 ; 0 .
2223 efd5 85 4a STA lomem
2224 efd7 85 4c STA himem
2225 efd9 a9 08 LDA #$08 ; 8 .
2226 efdb 85 4b STA lomem+1
2227 efdd a9 10 LDA #$10 ; 16 .
2228 efdf 85 4d STA himem+1
2229 efe1 4c ad e5 JMP new_cmd
2230 efe4
2231 efe4 d5 78 Sefe4 CMP noun_stk_h_str,X
2232 efe6 d0 01 BNE Lefe9
2233 efe8 18 CLC
2234 efe9 4c 02 e1 Lefe9 JMP Le102
2235 efec
2236 efec 20 b7 e5 Tefec JSR clr
2237 efef 4c 36 e8 JMP run_warm
2238 eff2
2239 eff2 20 b7 e5 Teff2 JSR clr
2240 eff5 4c 5b e8 JMP goto_stmt
2241 eff8
2242 eff8 e0 80 Seff8 CPX #$80 ; 128 .
2243 effa d0 01 BNE Leffd
2244 effc 88 DEY
2245 effd 4c 0c e0 Leffd JMP Se00c
2246 f000
2247 f000
2248 f000
2249 f000
------- FILE a2a1emulv5_1.asm
1672 f000
1673 f000 ;-------------------------------------------------------------------------
1674 f000 ;
1675 f000 ; The WOZ Monitor for the Apple 1
1676 f000 ; Written by Steve Wozniak 1976
1677 f000 ;
1678 f000 ;-------------------------------------------------------------------------
1679 f000
1680 f000
1681 f000 IFNCONST BLD4RAM
1682 ff00 ORG $FF00
1683 ff00 ENDIF
1684 ff00
1685 ff00 ;-------------------------------------------------------------------------
1686 ff00 ; Memory declaration
1687 ff00 ;-------------------------------------------------------------------------
1688 ff00
1689 ff00
1690 ff00
1691 ff00
1692 ff00
1693 ff00 00 24 XAML EQU $24 ;Last "opened" location Low
1694 ff00 00 25 XAMH EQU $25 ;Last "opened" location High
1695 ff00 00 26 STL EQU $26 ;Store address Low
1696 ff00 00 27 STH EQU $27 ;Store address High
1697 ff00 00 28 L EQU $28 ;Hex value parsing Low
1698 ff00 00 29 H EQU $29 ;Hex value parsing High
1699 ff00 00 2a YSAV EQU $2A ;Used to see if hex value is given
1700 ff00 00 2b MODE EQU $2B ;$00=XAM, $7F=STOR, $AE=BLOCK XAM
1701 ff00
1702 ff00 02 00 IN EQU $0200 ;Input buffer
1703 ff00
1704 ff00 - IFCONST BLD4APPLE1
1705 ff00 -MONDSP EQU $D012 ;PIA.B display output register
1706 ff00 -MONDSPCR EQU $D013 ;PIA.B display control register
1707 ff00 ENDIF
1708 ff00
1709 ff00 ; KBD b7..b0 are inputs, b6..b0 is ASCII input, b7 is constant high
1710 ff00 ; Programmed to respond to low to high KBD strobe
1711 ff00 ; DSP b6..b0 are outputs, b7 is input
1712 ff00 ; CB2 goes low when data is written, returns high when CB1 goes high
1713 ff00 ; Interrupts are enabled, though not used. KBD can be jumpered to IRQ,
1714 ff00 ; whereas DSP can be jumpered to NMI.
1715 ff00
1716 ff00
1717 ff00
1718 ff00 ;-------------------------------------------------------------------------
1719 ff00 ; Let's get started
1720 ff00 ;
1721 ff00 ; Remark the RESET routine is only to be entered by asserting the RESET
1722 ff00 ; line of the system. This ensures that the data direction registers
1723 ff00 ; are selected.
1724 ff00 ;-------------------------------------------------------------------------
1725 ff00
1726 ff00 d8 RESET CLD ;Clear decimal arithmetic mode
1727 ff01 58 CLI
1728 ff02 IFNCONST BLD4APPLE1
1729 ff02 20 83 d3 JSR INIT ;init display driver
1730 ff05 ENDIF
1731 ff05 a0 7f LDY #$7f ;Mask for DSP data direction reg
1732 ff07 - IFCONST BLD4APPLE1
1733 ff07 - STY MONDSP ; (DDR mode is assumed after reset)
1734 ff07 ENDIF
1735 ff07 a9 a7 LDA #$a7 ;KBD and DSP control register mask
1736 ff09 - IFCONST BLD4APPLE1
1737 ff09 - STA KBDCR ;Enable interrupts, set CA1, CB1 for
1738 ff09 - STA MONDSPCR ; positive edge sense/output mode.
1739 ff09 ELSE
1740 ff09 ea NOP
1741 ff0a ea NOP
1742 ff0b ea NOP
1743 ff0c ea NOP
1744 ff0d ea NOP
1745 ff0e ea NOP
1746 ff0f ENDIF
1747 ff0f
1748 ff0f ; Program falls through to the GETLINE routine to save some program bytes
1749 ff0f ; Please note that Y still holds $7F, which will cause an automatic Escape
1750 ff0f
1751 ff0f ;-------------------------------------------------------------------------
1752 ff0f ; The GETLINE process
1753 ff0f ;-------------------------------------------------------------------------
1754 ff0f
1755 ff0f c9 df NOTCR CMP #BS ;Backspace key?
1756 ff11 f0 13 BEQ BACKSPACE ;Yes
1757 ff13 c9 9b CMP #ESC ;ESC?
1758 ff15 f0 03 BEQ ESCAPE ;Yes
1759 ff17 c8 INY ;Advance text index
1760 ff18 10 0f BPL NEXTCHAR ;Auto ESC if line longer than 127
1761 ff1a
1762 ff1a a9 5c ESCAPE LDA #PROMPT ;Print prompt character
1763 ff1c 20 ef ff JSR ECHO ;Output it.
1764 ff1f
1765 ff1f a9 8d GETLINE LDA #CR ;Send CR
1766 ff21 20 ef ff JSR ECHO
1767 ff24
1768 ff24 a0 01 LDY #0+1 ;Start a new input line
1769 ff26 88 BACKSPACE DEY ;Backup text index
1770 ff27 30 f6 BMI GETLINE ;Oops, line's empty, reinitialize
1771 ff29
1772 ff29 NEXTCHAR
1773 ff29 - IFCONST BLD4APPLE1
1774 ff29 - LDA KBDCR ;Wait for key press
1775 ff29 - BPL NEXTCHAR ;No key yet!
1776 ff29 - LDA KBD ;Clear strobe
1777 ff29 ELSE
1778 ff29 20 4d d2 JSR A2GETCHAR
1779 ff2c ea NOP
1780 ff2d ea NOP
1781 ff2e ea NOP
1782 ff2f ea NOP
1783 ff30 ea NOP
1784 ff31 ENDIF
1785 ff31 99 00 02 STA IN,Y ;Add to text buffer
1786 ff34 20 ef ff JSR ECHO ;Display character
1787 ff37 c9 8d CMP #CR
1788 ff39 d0 d4 BNE NOTCR ;It's not CR!
1789 ff3b
1790 ff3b ; Line received, now let's parse it
1791 ff3b
1792 ff3b a0 ff LDY #-1 ;Reset text index
1793 ff3d a9 00 LDA #0 ;Default mode is XAM
1794 ff3f aa TAX ;X=0
1795 ff40
1796 ff40 0a SETSTOR ASL ;Leaves $7B if setting STOR mode
1797 ff41
1798 ff41 85 2b SETMODE STA MODE ;Set mode flags
1799 ff43
1800 ff43 c8 BLSKIP INY ;Advance text index
1801 ff44
1802 ff44 b9 00 02 NEXTITEM LDA IN,Y ;Get character
1803 ff47 c9 8d CMP #CR
1804 ff49 f0 d4 BEQ GETLINE ;We're done if it's CR!
1805 ff4b c9 ae CMP #$AE ;"."
1806 ff4d 90 f4 BCC BLSKIP ;Ignore everything below "."!
1807 ff4f f0 f0 BEQ SETMODE ;Set BLOCK XAM mode ("." = $AE)
1808 ff51 c9 ba CMP #$BA ;":"
1809 ff53 f0 eb BEQ SETSTOR ;Set STOR mode! $BA will become $7B
1810 ff55 c9 d2 CMP #$d2 ;"R"
1811 ff57 f0 3b BEQ RUN ;Run the program! Forget the rest
1812 ff59 86 28 STX L ;Clear input value (X=0)
1813 ff5b 86 29 STX H
1814 ff5d 84 2a STY YSAV ;Save Y for comparison
1815 ff5f
1816 ff5f ; Here we're trying to parse a new hex value
1817 ff5f
1818 ff5f b9 00 02 NEXTHEX LDA IN,Y ;Get character for hex test
1819 ff62 49 b0 EOR #$B0 ;Map digits to 0-9
1820 ff64 c9 0a CMP #9+1 ;Is it a decimal digit?
1821 ff66 90 06 BCC DIG ;Yes!
1822 ff68 69 88 ADC #$88 ;Map letter "A"-"F" to $FA-FF
1823 ff6a c9 fa CMP #$FA ;Hex letter?
1824 ff6c 90 11 BCC NOTHEX ;No! Character not hex
1825 ff6e
1826 ff6e 0a DIG ASL
1827 ff6f 0a ASL ;Hex digit to MSD of A
1828 ff70 0a ASL
1829 ff71 0a ASL
1830 ff72
1831 ff72 a2 04 LDX #4 ;Shift count
1832 ff74 0a HEXSHIFT ASL ;Hex digit left, MSB to carry
1833 ff75 26 28 ROL L ;Rotate into LSD
1834 ff77 26 29 ROL H ;Rotate into MSD's
1835 ff79 ca DEX ;Done 4 shifts?
1836 ff7a d0 f8 BNE HEXSHIFT ;No, loop
1837 ff7c c8 INY ;Advance text index
1838 ff7d d0 e0 BNE NEXTHEX ;Always taken
1839 ff7f
1840 ff7f c4 2a NOTHEX CPY YSAV ;Was at least 1 hex digit given?
1841 ff81 f0 97 BEQ ESCAPE ;No! Ignore all, start from scratch
1842 ff83
1843 ff83 24 2b BIT MODE ;Test MODE byte
1844 ff85 50 10 BVC NOTSTOR ;B6=0 is STOR, 1 is XAM or BLOCK XAM
1845 ff87
1846 ff87 ; STOR mode, save LSD of new hex byte
1847 ff87
1848 ff87 a5 28 LDA L ;LSD's of hex data
1849 ff89 81 26 STA (STL,X) ;Store current 'store index'(X=0)
1850 ff8b e6 26 INC STL ;Increment store index.
1851 ff8d d0 b5 BNE NEXTITEM ;No carry!
1852 ff8f e6 27 INC STH ;Add carry to 'store index' high
1853 ff91 4c 44 ff TONEXTITEM JMP NEXTITEM ;Get next command item.
1854 ff94
1855 ff94 ;-------------------------------------------------------------------------
1856 ff94 ; RUN user's program from last opened location
1857 ff94 ;-------------------------------------------------------------------------
1858 ff94
1859 ff94 6c 24 00 RUN JMP (XAML) ;Run user's program
1860 ff97
1861 ff97 ;-------------------------------------------------------------------------
1862 ff97 ; We're not in Store mode
1863 ff97 ;-------------------------------------------------------------------------
1864 ff97
1865 ff97 30 2b NOTSTOR BMI XAMNEXT ;B7 = 0 for XAM, 1 for BLOCK XAM
1866 ff99
1867 ff99 ; We're in XAM mode now
1868 ff99
1869 ff99 a2 02 LDX #2 ;Copy 2 bytes
1870 ff9b b5 27 SETADR LDA L-1,X ;Copy hex data to
1871 ff9d 95 25 STA STL-1,X ; 'store index'
1872 ff9f 95 23 STA XAML-1,X ; and to 'XAM index'
1873 ffa1 ca DEX ;Next of 2 bytes
1874 ffa2 d0 f7 BNE SETADR ;Loop unless X = 0
1875 ffa4
1876 ffa4 ; Print address and data from this address, fall through next BNE.
1877 ffa4
1878 ffa4 d0 14 NXTPRNT BNE PRDATA ;NE means no address to print
1879 ffa6 a9 8d LDA #CR ;Print CR first
1880 ffa8 20 ef ff JSR ECHO
1881 ffab a5 25 LDA XAMH ;Output high-order byte of address
1882 ffad 20 dc ff JSR PRBYTE
1883 ffb0 a5 24 LDA XAML ;Output low-order byte of address
1884 ffb2 20 dc ff JSR PRBYTE
1885 ffb5 a9 3a LDA #":" ;Print colon
1886 ffb7 20 ef ff JSR ECHO
1887 ffba
1888 ffba a9 20 PRDATA LDA #" " ;Print space
1889 ffbc 20 ef ff JSR ECHO
1890 ffbf a1 24 LDA (XAML,X) ;Get data from address (X=0)
1891 ffc1 20 dc ff JSR PRBYTE ;Output it in hex format
1892 ffc4 86 2b XAMNEXT STX MODE ;0 -> MODE (XAM mode).
1893 ffc6 a5 24 LDA XAML ;See if there's more to print
1894 ffc8 c5 28 CMP L
1895 ffca a5 25 LDA XAMH
1896 ffcc e5 29 SBC H
1897 ffce b0 c1 BCS TONEXTITEM ;Not less! No more data to output
1898 ffd0
1899 ffd0 e6 24 INC XAML ;Increment 'examine index'
1900 ffd2 d0 02 BNE MOD8CHK ;No carry!
1901 ffd4 e6 25 INC XAMH
1902 ffd6
1903 ffd6 a5 24 MOD8CHK LDA XAML ;If address MOD 8 = 0 start new line
1904 ffd8 29 07 AND #$07
1905 ffda 10 c8 BPL NXTPRNT ;Always taken.
1906 ffdc
1907 ffdc ;-------------------------------------------------------------------------
1908 ffdc ; Subroutine to print a byte in A in hex form (destructive)
1909 ffdc ;-------------------------------------------------------------------------
1910 ffdc
1911 ffdc 48 PRBYTE PHA ;Save A for LSD
1912 ffdd 4a LSR
1913 ffde 4a LSR
1914 ffdf 4a LSR ;MSD to LSD position
1915 ffe0 4a LSR
1916 ffe1 20 e5 ff JSR PRHEX ;Output hex digit
1917 ffe4 68 PLA ;Restore A
1918 ffe5
1919 ffe5 ; Fall through to print hex routine
1920 ffe5
1921 ffe5 ;-------------------------------------------------------------------------
1922 ffe5 ; Subroutine to print a hexadecimal digit
1923 ffe5 ;-------------------------------------------------------------------------
1924 ffe5
1925 ffe5 29 0f PRHEX AND #$0F ;Mask LSD for hex print
1926 ffe7 09 30 ORA #"0" ;Add "0"
1927 ffe9 c9 3a CMP #"9"+1 ;Is it a decimal digit?
1928 ffeb 90 02 BCC ECHO ;Yes! output it
1929 ffed 69 06 ADC #6 ;Add offset for letter A-F
1930 ffef
1931 ffef ; Fall through to print routine
1932 ffef
1933 ffef ;-------------------------------------------------------------------------
1934 ffef ; Subroutine to print a character to the terminal
1935 ffef ;-------------------------------------------------------------------------
1936 ffef ECHO
1937 ffef - IFCONST BLD4APPLE1
1938 ffef - BIT MONDSP ;DA bit (B7) cleared yet?
1939 ffef - BMI ECHO ;No! Wait for display ready
1940 ffef - STA MONDSP ;Output character. Sets DA
1941 ffef - RTS
1942 ffef ELSE
1943 ffef c9 20 CMP #$20
1944 fff1 30 02 BMI ECHO1
1945 fff3 09 80 ORA #$80
1946 fff5 ECHO1
1947 fff5 4c 47 d4 JMP PUTCH ; use hi-res screen
1948 fff8 ENDIF
1949 fff8
1950 fff8 ;-------------------------------------------------------------------------
1951 fff8 ; Vector area
1952 fff8 ;-------------------------------------------------------------------------
1953 fff8 IFNCONST BLD4RAM
1954 fff8 ORG $fff8
1955 fff8 00 00 DC.W $0000 ;Unused, what a pity
1956 fffa 00 0f NMI_VEC DC.W $0F00 ;NMI vector
1957 fffc 00 ff RESET_VEC DC.W RESET ;RESET vector
1958 fffe 00 00 IRQ_VEC DC.W $0000 ;IRQ vector
1959 10000 ENDIF
1960 10000
1961 10000 ;-------------------------------------------------------------------------
1962 10000
1963 10000