10 ;BASIC TO BINARY -10/16 ; 20 ;BY: MATTHEW ARRINGTON ; 30 ; ; 40 ; OSS. MAC-65 SOURCE ; 50 ; 60 .OPT NO LIST 70 ; 80 ; 90 ; MACROS 0100 ; 0110 .MACRO @PT 0120 ; 0130 ; PUT TO DEVICE 0140 ; " PUT IOCB#,BYTE " 0150 ; 0160 STY 0 0170 TAY 0180 .IF %0=1 0190 LDX #%1*16 0200 .ENDIF 0210 LDA #11 0220 STA 834,X ; COMMAND PUT=11 0230 LDA #0 0240 STA 840,X 0250 STA 841,X 0260 TYA 0270 JSR 58454 0280 LDY 0 0290 .ENDM 0300 ; 0310 ; 0320 ; 0330 .MACRO @GT 0340 ; 0350 ; GET FROM DEVICE (INTERNAL) 0360 ; " GET IOCB# " 0370 ; 0380 .IF %0=1 0390 LDX #%1*16 0400 .ENDIF 0410 LDA #7 0420 STA 834,X ; COMMAND GET=7 0430 LDA #0 0440 STA 840,X 0450 STA 841,X 0460 JSR 58454 0470 .ENDM 0480 ; 0490 ; PUT BYTE 0500 ; 0510 ; 0520 .MACRO PUT 0530 .IF %0=0 0540 @PT 0550 .ELSE 0560 @PT %1 0570 .ENDIF 0580 .ENDM 0590 ; 0600 ; GET EX. "GET 0" 0610 ; 0620 .MACRO GET 0630 .IF %0=0 0640 @GT 0650 .ELSE 0660 @GT %1 0670 .ENDIF 0680 .ENDM 0690 ; 0700 ; PRINT 0710 ; 0720 .MACRO PRINT 0730 ; 0740 JMP @OVER 0750 @TEXT .BYTE %$2,0 0760 @OVER LDY #0 0770 @LOOP STY 0 0780 LDA @TEXT,Y 0790 CMP #'. 0800 BNE @CIO 0810 LDA #155 0820 @CIO @PT %1 0830 LDY 0 0840 INY 0850 LDA @TEXT,Y 0860 BNE @LOOP 0870 .ENDM 0880 ; 0890 ; PRINT BUFFER 0900 .MACRO PRINTB 0910 LDY #0 0920 @LO STY 0 0930 ; 0940 .IF %2<256 0950 LDA (%2),Y 0960 .ELSE 0970 ; 0980 LDA %2,Y 0990 .ENDIF 1000 ; 1010 CMP #'. 1020 BNE @CO 1030 LDA #155 1040 @CO @PT %1 1050 LDY 0 1060 INY 1070 .IF %2<256 1080 LDA (%2),Y 1090 .ELSE 1100 LDA %2,Y 1110 .ENDIF 1120 BNE @LO 1130 .ENDM 1140 ; 1150 ; INPUT RECORD/ SAVE EOL 1160 ; EX. "INPUT IOCB#" 1170 ; 1180 .MACRO INPUT 1190 ; 1200 LDX #%1*16 1210 LDA #%2&255 ; INBUF LO 1220 STA 836,X 1230 LDA #%2/256 ; INBUF LO 1240 STA 837,X 1250 LDA #5 ; GET RECORD 1260 STA 834,X 1270 LDA #40 ; BUF LEN 1280 STA 840,X 1290 LDA #0 1300 STA 841,X 1310 JSR 58454 1320 LDY 840,X 1330 LDA #0 1340 STA %2,Y 1350 .ENDM 1360 ; 1370 .MACRO OPEN 1380 ; 1390 LDX #%1*16 ; IOCB # 1400 .IF %4<256 1410 JMP @EXC 1420 @OPEN .BYTE %$4 1430 @EXC LDA #@OPEN&255 ;(S:,D:) 1440 STA 836,X 1450 LDA #@OPEN/256 1460 STA 837,X 1470 .ELSE 1480 LDA #%4&255 1490 STA 836,X 1500 LDA #%4/256 1510 STA 837,X 1520 .ENDIF 1530 LDA #%2 1540 STA 842,X ; OPEN (8,12,4) 1550 LDA #%3 1560 STA 843,X ; AUX1 1570 LDA #3 ; COMMAND OPEN 1580 STA 834,X 1590 JSR 58454 1600 .ENDM 1610 ; 1620 .MACRO RWSECT 1630 ; 1640 ; DUNIT,DCOM,DBUFF,SIZE,SECT 1650 ; 1660 LDA #49 1670 STA 768 ; DDEVIC 1680 .IF %1>4 1690 LDA %1 1700 .ELSE 1710 LDA #%1 1720 .ENDIF 1730 STA 769 ; DUNIT 1740 LDA #%2 1750 STA 770 1760 LDA #%6 1770 STA 771 1780 LDA #%3&255 1790 STA 772 1800 LDA #%3/256 1810 STA 773 1820 LDA #31 1830 STA 774 1840 LDA #%4&255 1850 STA 776 1860 LDA #%4/256 1870 STA 777 1880 LDA #%5&255 1890 STA 778 1900 LDA #%5/256 1910 STA 779 1920 JSR 58457 1930 .ENDM 1940 ; 1950 ; MACRO CLOSE IOCB 1960 ; 1970 .MACRO CLOSE 1980 ; 1990 LDX #%1*16 2000 LDA #12 ; COMMAND CLOSE 2010 STA 834,X 2020 JSR 58454 ; CIO 2030 .ENDM 2040 ; 2050 .MACRO XIO 2060 ; 2070 LDX #%2*16 ; IOCB 2080 LDA #%1 ; COMMAND 2090 STA 834,X 2100 LDA #%3 2110 STA 842,X ; AUX1 2120 LDA #%4 2130 STA 843,X ; AUX2 2140 LDA #%5&255 2150 STA 836,X 2160 LDA #%5/256 2170 STA 837,X 2180 JSR 58454 ; CIOV 2190 ; 2200 .ENDM 2210 ; 2220 .MACRO POS 2230 ;.EX POS COL,ROW 2240 ; 2250 LDA #%1 2260 STA 84 2270 LDA #%2 2280 STA 85 2290 ; 2300 .ENDM 2310 ; 2320 .MACRO BGET 2330 ; 2340 ; EX. BGET 1,BUFFER,10000,LEN 2350 ; 2360 LDX #%1*16 2370 LDA #7 2380 STA 834,X ; COMMAND 2390 LDA #%2&255 2400 STA 836,X 2410 LDA #%2/256 2420 STA 837,X 2430 LDA #%3&255 2440 STA 840,X 2450 LDA #%3/256 2460 STA 841,X 2470 JSR $E456 ;CIO 2480 ; 2490 LDA 840,X 2500 STA %4 2510 LDA 841,X 2520 STA %4+1 2530 .ENDM 2540 ; 2550 ; EX. BPUT 1,BUFFER,LEN 2560 ; 2570 .MACRO BPUT 2580 LDX #%1*16 2590 LDA #11 2600 STA 834,X ; COMMAND 2610 LDA #%2&255 2620 STA 836,X 2630 LDA #%2/256 2640 STA 837,X 2650 LDA %3 2660 STA 840,X 2670 LDA %3+1 2680 STA 841,X 2690 JSR $E456 ;CIO 2700 ; 2710 .ENDM 2720 ; 2730 ; 2740 ; WORK BYTES 2750 ; 2760 *= $0600 2770 ; 2780 MAXLINE .BYTE 0 2790 INLINE .BYTE 0 2800 FLASH .BYTE 0 2810 TEMP1 .BYTE 0 2820 CHR1 .BYTE 0 2830 CHR2 .BYTE 0 2840 OPTION .BYTE 0 2850 SCRN .BYTE 0 2860 LEN .BYTE 0,0 2870 TEMY .BYTE 0 2880 ; 2890 LBUFF = $057E 2900 HATABS = $031A 2910 ; 2920 ; ZERO PAGE 2930 ; 2940 TEMP2 = 203 2950 TEMP3 = 204 2960 PSTART = 224 2970 PEND = 226 2980 MEMBOT = 228 2990 AMOUNT = 230 3000 ; 3010 *= $2700 3020 ; 3030 ; LOAD SCREEN 3040 ; 3050 INIT LDA #0 ; BLACK 3060 STA 710 ; SCREEN 3070 STA 82 3080 LDA #97 ; RED 3090 STA 712 ; BORDER 3100 LDA #1 ; NO CURSOR 3110 STA 752 3120 PRINT 0,"$).......... Basic to Binary by: Matthew Arrington" 3130 RTS ; CONTINUE LOAD 3140 ; 3150 *= 738 3160 .WORD INIT ; FOR BIN LOAD 3170 ; 3180 *= $2700 3190 ; 3200 ; 3210 ; EXECUTE & RUN BASIC PROGRAM 3220 ; 3230 ; THIS ROUTINE GETS SAVED ALONG 3240 ; WITH BASIC PROGRAM. 3250 ; 3260 ; 3270 BASRUN .BYTE " " ; BIN LOAD HEADER 3280 .WORD FILELEN ; LOAD START 3290 .WORD RN3 ; LOAD END 3300 ; 3310 ; 3320 FILELEN *= *+2 ; BASIC FILE LEN 3330 ; 3340 TLINE .BYTE " ." ; TITLE STORED HERE 3350 ; 3360 RESET .BYTE 0 ; OPTION FLAGS 3370 BREAK .BYTE 0 3380 TITLE2 .BYTE 0,0 3390 MEMLO .WORD LA12+3 3400 ; 3410 GO LDA 6 ; CART PRESENT? 3420 BNE RN2 ; YES CONTINUE 3430 ; 3440 LDA #1 ; CURSOR OFF 3450 STA 752 3460 LDA #0 ; ZERO MARGIN 3470 STA 82 3480 PRINT 0,"$) PROGRAM REQUIRES BASIC. REBOOT " 3490 X2 JMP X2 ; LOOP FOREVER 3500 ; 3510 RN2 LDA TITLE2 ; DISPLAY TITLE? 3520 BEQ RN3 ; NO 3530 ; 3540 OPEN 6,12,1,"S" ; GR. 1 3550 POS 10,0 3560 PRINTB 6,TLINE 3570 RN3 RTS ; COUNTINE LOAD 3580 ; 3590 ; MORE BIN POINTERS 3600 ; 3610 .WORD 738,739 ; INIT ADD. 3620 .WORD GO 3630 ; 3640 .WORD X1,LA12+2 3650 ; 3660 ; 3670 ; INIT MEMLO 3680 ; 3690 X1 LDY #0 3700 LDA MEMLO ; SET REAL MEMLO 3710 STA 743 3720 ; 3730 CLC 3740 ADC #242 3750 STA TEMP2 3760 ; 3770 LDA MEMLO+1 3780 STA 744 3790 ; 3800 ADC #0 3810 STA TEMP3 3820 ; 3830 ; INIT RESET VECTORS 3840 ; 3850 LDA RESET ; TRAP RESET? 3860 BEQ TRAP ; BR. IF YES 3870 ; 3880 CMP #2 ; COLD START? 3890 BNE MOVEPOINT ;NO, RESET NORMAL 3900 LDA #1 ; DIE ON RESET 3910 STA 580 ; COLST 3920 JMP MOVEPOINT 3930 ; 3940 TRAP LDA 13 ; TRAP RESET 3950 CMP #8 ; DOS PRESENT? 3960 BCS DODOS ;BR. IF SO 3970 LDA #INITAL&255 ; SET RESET VECTOR 3980 STA 12 3990 LDA #INITAL/256 4000 STA 13 4010 JMP MOVEPOINT 4020 ; 4030 DODOS LDA 12 ; SAVE DOS INIT VEC 4040 STA RESET1+1 4050 LDA 13 4060 STA RESET1+2 4070 ; 4080 LDA #RESET1&255 ; SET NEW RESET VEC 4090 STA 12 4100 LDA #RESET1/256 4110 STA 13 4120 ; 4130 ; ADD VALUE OF MEMLO TO BASIC'S 4140 ; PROGRAM POINTERS. 4150 ; 4160 MOVEPOINT LDA 743 4170 CLC 4180 ADC (TEMP2),Y 4190 STA 128,Y 4200 INY 4210 ; 4220 LDA 744 4230 ADC (TEMP2),Y 4240 STA 128,Y 4250 INY 4260 CPY #14 4270 BNE MOVEPOINT 4280 ; 4290 LDA 140 ; COPY STARP TO: 4300 STA 142 ; RUNSTAK 4310 STA 144 ; MEMTOP (LOW) 4320 ; 4330 LDA 141 ; (HIGH) 4340 STA 143 4350 STA 145 4360 ; 4370 ; 4380 ; SET UP TO RUN 4390 ; 4400 LDA #0 4410 STA $92 ; BASIC DOES THIS 4420 STA $CA ; ON COLD START 4430 LDX #$FF 4440 TXS 4450 CLD 4460 ; 4470 LDA $0222 ; SAVE VBI VEC 4480 STA VBIX+1 4490 LDA $0223 4500 STA VBIX+2 4510 JMP INITAL 4520 ; 4530 ; IMMEDIATE VBI TO DISSABLE 4540 ; BREAK. 4550 ; 4560 BRK LDA #64 4570 STA 16 4580 STA 53774 4590 VBIX .BYTE $4C,0,0 4600 ; 4610 ; 4620 RESET1 .BYTE $20,0,0 ; JSR INIT DOS 4630 INITAL LDX #0 4640 LDA BREAK ; DISSABLE BREAK? 4650 BNE LA2 ; BR. IF NOT 4660 ; 4670 LDA #BRK&255 ; SET IMM. VBI 4680 STA $0222 ; VECTOR 4690 LDA #BRK/256 4700 STA $0223 4710 ; 4720 ; PATCH THE "E:" INPUT COMMAND 4730 ; WILL FORCE A "RUN" WHEN BASIC 4740 ; GOES TO THE "READY" PROMPT. 4750 ; 4760 LA2 LDA HATABS,X ; GET A BYTE 4770 CMP #'E ; LOOK FOR E 4780 BEQ LA1 ; FOUND YA 4790 ; 4800 INX ; NEXT HANDLER 4810 INX ; ADDRESS 4820 INX 4830 BNE LA2 ; KNOW ITS THERE 4840 ; 4850 LA1 INX 4860 STX LA3 ; SAVE OFFSET 4870 ; 4880 LDA HATABS,X ; SAVE OLD 4890 STA TEMP2 4900 LDA #VTBLE&255 ; REPLACE WITH NEW 4910 STA HATABS,X ;$031A 4920 ; 4930 INX ; NOW HI BYTES 4940 ; 4950 LDA HATABS,X ; SAVE OLD 4960 STA TEMP2+1 4970 LDA #VTBLE/256 ; REPLACE WITH NEW 4980 STA HATABS,X 4990 ; 5000 LDY #0 ; COPY VTABLE 5010 LDX #4 5020 LA7 LDA (TEMP2),Y 5030 STA VTBLE,Y 5040 INY 5050 DEX 5060 BNE LA7 5070 LDY #8 5080 LDX #7 5090 LA8 LDA (TEMP2),Y 5100 STA VTBLE,Y 5110 INY 5120 DEX 5130 BNE LA8 5140 ; 5150 LDA #2 ; COUNTER 5160 STA LA10 5170 ; 5180 LDA #1 ; BOOT SUCCESSFUL 5190 STA 9 ; BOOT 5200 STA 8 ; WARMST 5210 ; 5220 LDA 49146 ; CART RUN ADD. 5230 STA CART+1 5240 LDA 49147 5250 STA CART+2 5260 CART .BYTE $4C,0,0 ; JMP TO BASIC 5270 ; 5280 EINPUT LDY LA10 ; GET OFFSET 5290 CPY #255 ; END? 5300 BEQ LA11 ; YES 5310 ; 5320 LDA LA12,Y 5330 DEC LA10 5340 LDY #1 5350 RTS 5360 ; 5370 LA11 TXA 5380 PHA 5390 LDX LA3 5400 LDA TEMP2 5410 STA HATABS,X ;$031A 5420 INX 5430 LDA TEMP2+1 5440 STA HATABS,X ;$031A 5450 PLA 5460 TAX 5470 LDA #155 ; C/R 5480 LDY #1 ; SUCCESS 5490 RTS ; DONE 5500 LA3 .BYTE 0 5510 LA10 .BYTE 0 5520 ; 5530 VTBLE .BYTE 0,0 ; CLOSE 5540 .BYTE 0,0 ; OPEN 5550 .WORD EINPUT-1 ; GET 5560 .BYTE 0,0 ; PUT 5570 .BYTE 0,0 ; STATUS 5580 .BYTE 0,0 ; SPECIAL 5590 .BYTE 0,0,0 ; JMP INIT 5600 ; 5610 LA12 .BYTE "NUR" 5620 ; 5630 .BYTE "..a." ;RUN POINTERS 5640 .WORD X1 ;FOR BAS RUN 5650 ; 5660 BASICSTART .BYTE 0,0 5670 .BYTE 0 5680 ENDRUN .BYTE 0 5690 ; 5700 ; DISPLAY LIST 5710 ; 5720 DLIST .BYTE 112,112,112,66,64,156 5730 .BYTE 66,104,156,66,144,156,66,184,156 5740 .BYTE 66,224,156,66,8,157,66,48,157 5750 .BYTE 66,88,157,66,128,157,66,168,157 5760 .BYTE 66,208,157,66,248,157,66,32,158 5770 .BYTE 66,72,158,66,112,158,66,152,158 5780 .BYTE 66,192,158,66,232,158,66,16,159 5790 .BYTE 66,56,159,66,96,159,66,136,159 5800 .BYTE 66,176,159,66,216,159,65 5810 .WORD DLIST 5820 MENU .BYTE "$)....." 5830 .BYTE " ......... ." 5840 .BYTE " | ." 5850 .BYTE " .................." 5860 .BYTE " |Basic to Binary|." 5870 .BYTE "............................" 5880 .BYTE "| |." 5890 .BYTE "| 1: Display/Set Options |." 5900 .BYTE "| |." 5910 .BYTE "| 2: Convert Basic file |.." 5920 MENU2 .BYTE "| |." 5930 .BYTE "| 3: File Directory |." 5940 .BYTE "| |." 5950 .BYTE "| 4: Exit to DOS |." 5960 .BYTE "| |." 5970 .BYTE "............................." 5980 ; 5990 ; 6000 ; 6010 ; EVERYDAY TYPE SUBROUTINES 6020 ; 6030 ; 6040 ; INPUT A LINE 6050 ; 6060 GETLINE LDA #0 ; LINE INDEX & 6070 STA INLINE ; LINE LEN=0 6080 ; 6090 GLOOP LDA #10 ; 1/6 SEC 6100 STA 536 ; SYS TIMER 6110 TIMLOOP LDA 764 ; STAT KEYBOARD 6120 CMP #255 ; KEY IN? 6130 BEQ CHECKTIME ; BR. IF NO 6140 PRINT 0,"_." ; PRINT CURSOR 6150 JMP GCHR ; GET KEY 6160 ; 6170 CHECKTIME LDA 536 ; SYS TIMER=0? 6180 BNE TIMLOOP ; NO, LOOP 6190 LDA FLASH ; FLASH ON OR OFF? 6200 BEQ OFF ; TURN IT OFF 6210 PRINT 0,"_." ; CURSOR ON 6220 LDA #0 ; FLASH OFF=0 6230 STA FLASH ; FOR NEXT TIME 6240 JMP GLOOP ; LOOP 6250 ; 6260 OFF PRINT 0," ." ; CUROSRO OFF 6270 LDA #1 ; FLASH ON=1 6280 STA FLASH ; FOR NEXT TIME 6290 JMP GLOOP ; LOOP 6300 ; 6310 GCHR GET 3 ; GET A CHAR 6320 ; 6330 CMP #'$- ; BACKSPACE? 6340 BNE DL ; BR. IF NOT 6350 ; 6360 LDX INLINE ; SOMTHING TO BS? 6370 BNE OK1 ; BR. IF YES 6380 JMP GLOOP ; NOTHING THERE 6390 OK1 JMP BACKSPACE ; DO BACKSPACE 6400 ; 6410 DL CMP #'. ; DELETE LINE? 6420 BNE ENDL ; BR. IF NOT 6430 LDX INLINE ; SOMTHING TO DEL? 6440 BNE OK2 ; BR. IF YES 6450 JMP GLOOP ; ELSE IGNORE & LOOP 6460 OK2 JMP DLINE ; DO DELETE LINE 6470 ; 6480 ENDL CMP #155 ; END OF LINE? 6490 BNE NOCTRL ; NO 6500 JMP EOL ; DO ENDLINE 6510 NOCTRL LDX STRIP ; FILTER CHARS? 6520 BNE OK3 ; BR. IF NO 6530 ; 6540 ; 6550 AND #127 ; STRIP INVERSE 6560 CMP #97 ; LOWWER CASE?? 6570 BCC OK3 ; BRANCH IF NOT 6580 SEC 6590 SBC #32 ; MAKE IT UPPER 6600 OK3 LDX INLINE ; RESTORE X 6610 CPX MAXLINE ; LINE TOO LONG? 6620 BNE OK5 ; BR. AND SAVE 6630 JMP GLOOP ; IGNORE KEY & LOOP 6640 ; 6650 OK5 STA 1406,X ; SAVE BYTE 6660 INX ; FOR NEXT SAVE 6670 STX INLINE ; SAVE X 6680 PUT 0 ; PRINT CHAR 6690 JMP GLOOP ; GET NEXT BYTE 6700 ; 6710 ; 6720 BACKSPACE JSR ST 6730 ; 6740 DOBS LDA #'$- ; BS CHAR 6750 PUT 0 ; PRINT IT 6760 DEC INLINE ; DEC LINE LEN 6770 JMP GLOOP ; NEXT KEY 6780 ; 6790 ; 6800 DLINE JSR ST 6810 ; 6820 DODL LDA #'$- ; BS CHAR 6830 PUT 0 ; PRINT IT 6840 DEC INLINE ; DEC LINE LEN 6850 BNE DODL ; LOOP TILL GONE 6860 JMP GLOOP ; START AGAIN 6870 ; 6880 ; 6890 EOL LDA #'. ; DELETE PROMPT 6900 PUT 0 6910 LDX INLINE ; GET LINE LEN 6920 LDA #0 6930 STA 1406,X ; MARK EOL 6940 RTS ; RETURN 6950 ; 6960 ; 6970 ST PRINT 0,".$-" ; ERASE CURSOR 6980 RTS 6990 ; 7000 ; 7010 PUTBYTE LDX #0 ; IOCB #0 7020 PUTD PUT ; PUT A 7030 RTS ; RETURN 7040 ; 7050 ; ; 7060 ; VALIDATE A FILENAME ; 7070 ; ; 7080 SETNAME LDY #0 ; SET DEFUALT 7090 L8 LDA DEF,Y ; TO DRIVE ONE 7100 STA FNAME,Y 7110 INY 7120 CPY #3 7130 BNE L8 7140 ; 7150 LDA LBUFF+1 ; "D:FNAME"? 7160 CMP #': 7170 BNE L5 ; BR. IF NOT 7180 LDY #2 ; SET OFFSET 7190 JMP MOVENAME ; COPY NAME OVER 7200 ; 7210 L5 LDY #0 ; "DX:FNAME"?? 7220 LDA LBUFF+2 7230 CMP #': 7240 BNE MOVENAME ;NO, ASSUME "D1:" 7250 LDA LBUFF+1 ; GET D# BYTE 7260 STA FNAME+1 ; SAVE IT 7270 LDY #3 ; OFFSET 7280 ; 7290 MOVENAME LDX #3 ; COPY FILE NAME 7300 L6 LDA LBUFF,Y ; FROM LBUFF. 7310 STA FNAME,X 7320 BEQ L7 7330 INY 7340 INX 7350 BNE L6 7360 ; 7370 L7 RTS 7380 ; 7390 ; CALCULATE THE DISTANCE BETWEEN 7400 ; TO ADRESS'S... 7410 ; 7420 SUBTRACT LDA PEND 7430 SEC 7440 SBC PSTART 7450 STA LEN 7460 ; 7470 LDA PEND+1 7480 SBC PSTART+1 7490 STA LEN+1 7500 ; 7510 INC LEN 7520 BNE L15 7530 INC LEN+1 7540 L15 RTS 7550 ; 7560 BUF *= *+5125 ; 5K BUFFER 7570 ; 7580 FNAME *= *+16 7590 STRIP .BYTE 0 7600 DEF .BYTE "D1:" ; DEFUALT DRIVE 7610 DIR .BYTE "D0:*.*" ; DIRECTORY 7620 ; 7630 RUN OPEN 3,4,0,"K:" 7640 LDA #DLIST&255 ; POINT TO 7650 STA 560 ; MY DIS. LIST 7660 LDA #DLIST/256 7670 STA 561 7680 ; 7690 LDA #64 ; LET THE "E:" 7700 STA 88 ; IN ON THE CHANGE. 7710 LDA #156 7720 STA 89 7730 LDA #1 ; CURSOR OFF 7740 STA 752 7750 LDA #31 ; RIGHT MARGIN 7760 STA 83 7770 ; 7780 ; 7790 MAINMENU LDA #0 ; SCREEN OFF 7800 STA 559 7810 STA 710 ; CHANGE COLOR 7820 LDA #97 7830 STA 712 7840 LDA #2 ; LEFT MARGIN 7850 STA 82 7860 PRINTB 0,MENU ; PRINT MENU 7870 PRINTB 0,MENU2 7880 LDA #33 ; SCREEN ON 7890 STA 559 7900 ; 7910 ; TWIRLING THING 7920 ; 7930 LDA #69 7940 STA CHR1 7950 LDA #90 7960 STA CHR2 7970 TITLE LDY #11 7980 LDA #0 7990 LDX #3 8000 STA 40208,X 8010 STA 40208,Y 8020 LDY CHR1 8030 LDA CHR2 8040 STY CHR2 8050 STA CHR1 8060 LDX #4 8070 LDY #10 8080 TLOOP LDA 40208,X 8090 STA TEMP1 8100 LDA CHR1 8110 STA 40208,X 8120 LDA 40208,Y 8130 STA TEMP2 8140 LDA CHR2 8150 STA 40208,Y 8160 LDA #0 8170 STA 20 8180 TTIME LDA 20 8190 CMP #3 8200 BNE TTIME 8210 LDA #0 8220 JSR TWIST 8230 STA 40208,X 8240 LDA #1 8250 JSR TWIST 8260 STA 40208,Y 8270 ; 8280 LDA 764 8290 CMP #255 8300 BNE GOPT 8310 ; 8320 INX 8330 DEY 8340 CPY #2 8350 BNE TLOOP 8360 JMP TITLE 8370 TWIST CMP #1 8380 BEQ OVER 8390 LDA TEMP1 8400 JMP SWAP 8410 OVER LDA TEMP2 8420 ; 8430 SWAP CMP #90 8440 BNE F1 8450 JMP SWITCH 8460 F1 CMP #69 8470 BNE F2 8480 JMP SWITCH 8490 F2 CMP #67 8500 BNE F3 8510 JMP SWITCH 8520 F3 CMP #81 8530 BNE F4 8540 JMP SWITCH 8550 F4 CMP #82 8560 BEQ ZERO 8570 LDA #82 8580 RTS 8590 ZERO LDA #0 8600 RTS 8610 SWITCH LDA CHR1 8620 CMP #90 8630 BNE OTHER 8640 LDA #67 8650 STA CHR1 8660 LDA #81 8670 STA CHR2 8680 JMP EXIT 8690 ; 8700 OTHER LDA #69 8710 STA CHR1 8720 LDA #90 8730 STA CHR2 8740 EXIT LDA #87 8750 RTS 8760 ; 8770 ; GET OPTION FROM KEYBOARD 8780 ; 8790 GOPT LDA #0 ; ZERO MARGIN 8800 STA 82 8810 GET 3 ; GET KEY 8820 AND #127 ; STRIP INVERSE 8830 CMP #97 ; LOWWER CASE? 8840 BCC A6 ; BR. IF NOT 8850 SEC ; ELSE.... 8860 SBC #32 ; MAKE IT UPPER 8870 ; 8880 A6 CMP #'2 ; OPTION 2? 8890 BNE A1 ; NO 8900 JSR CONVERT ; GO CONVERT 8910 JMP MAINMENU ; 8920 ; 8930 A1 CMP #'1 ; OPTION 1? 8940 BNE A2 ; NO 8950 JSR PAD ; CONTROL PAD 8960 JMP MAINMENU 8970 ; 8980 A2 CMP #'3 ; HOW ABOUT 3? 8990 BNE A4 ; NO 9000 JSR FILES ; DIRECTORY 9010 JMP RUN ; REINIT SCREEN 9020 ; 9030 A4 CMP #'4 ; OPTION 4? 9040 BEQ A5 ; YES... 9050 JMP MAINMENU ; BAD INPUT 9060 ; 9070 A5 LDA #39 ; RESET RIGHT 9080 STA 83 ; MARGIN 9090 JMP (10) ; GO TO DOS 9100 ; 9110 ; CONVERT A FILE TO BINARY 9120 ; 9130 CONVERT LDA #125 9140 JSR PUTBYTE ; CLEAR SCREEN 9150 LDA #16 9160 STA MAXLINE ; INPUT LINE LEN. 9170 ; 9180 POS 10,0 9190 L11 PRINT 0,"INPUT FILE - " 9200 JSR GETLINE ; GET INPUT NAME 9210 LDA INLINE ; NAME ENTERED? 9220 BNE L10 ; BR. IF YES 9230 RTS ; NO, RETURN 9240 ; 9250 L10 JSR SETNAME ; VALIDATE NAME 9260 CLOSE 1 9270 OPEN 1,4,0,FNAME 9280 BMI L11 ; ERROR TRY AGAIN 9290 ; 9300 ; PASS 1, COUNT BYTES 9310 ; 9320 ; MUST KNOW EXACT LEN OF BASIC 9330 ; FILE. 9340 ; 9350 LDA #0 ; ZERO BASIC 9360 STA FILELEN ; FILE LENGTH 9370 STA FILELEN+1 9380 ; 9390 L13 GET 1 ; GET A BYTE 9400 CPY #136 ; CHECK FOR EOF 9410 BEQ PASS2 ; BR. EOF REACHED 9420 ; 9430 INC FILELEN ; COUNT BYTES. 9440 BNE L13 9450 INC FILELEN+1 9460 BNE L13 9470 ; 9480 ; PASS2 SAVE ROUTINE THAT RUNS 9490 ; THE BASIC. THEN COPY BASIC 9500 ; PROGRAM OVER TO THE NEW FILE. 9510 ; 9520 PASS2 CLOSE 1 ; REOPEN INPUT FILE 9530 OPEN 1,4,0,FNAME 9540 ; 9550 L3 PRINT 0,"OUTPUT FILE - " 9560 JSR GETLINE ; GET FILENAME 9570 LDA INLINE ; NAME ENTERED? 9580 BNE L12 ; BR. IF SO 9590 RTS ; RETURN - ABORT 9600 ; 9610 L12 JSR SETNAME ; VALIDATE NAME 9620 CLOSE 2 9630 OPEN 2,8,0,FNAME 9640 BMI L3 9650 ; 9660 ; CALCULATE LENGTH OF THE ROUTINE 9670 ; THAT'LL EXECUTE THE BASIC 9680 ; PROGRAM. SAVE RESULT IN "LEN" 9690 ; 9700 LDA #BASRUN&255 9710 STA PSTART 9720 LDA #BASRUN/256 9730 STA PSTART+1 9740 ; 9750 LDA #ENDRUN&255 9760 STA PEND 9770 LDA #ENDRUN/256 9780 STA PEND+1 9790 JSR SUBTRACT ; GET LENGTH 9800 ; 9810 ; MAKE BIN LOAD POINTERS 9820 ; 9830 ; ADD THE LEN. OF THE BAS PROGRAM 9840 ; TO THE ADDRESS WHERE IT FIRST 9850 ; LOADS IN MEMORY. 9860 ; 9870 LDA MEMLO ; START ADDRESS 9880 CLC 9890 ADC #242 ; BAS. BUFFER OFFSET 9900 STA TEMP2 9910 LDA MEMLO+1 9920 ADC #0 9930 STA TEMP3 9940 ; 9950 ; LOW BYTES 9960 ; 9970 LDA TEMP2 ; SAVE START POINT 9980 STA BASICSTART 9990 CLC ; ADD IN FILE LENGTH 010000 ADC FILELEN 010010 STA ENDRUN-1 ;SAVE END POINT 010020 ; 010030 ; HIGH BYTES 010040 ; 010050 LDA TEMP3 ; SAVE START 010060 STA BASICSTART+1 010070 ADC FILELEN+1 ; ADD IN LEN 010080 STA ENDRUN ; SAVE END 010090 ; 010100 LDA ENDRUN-1 ; SUBTRACT 1 010110 SEC ; FROM END POINT 010120 SBC #1 ; (FUDGE) 010130 STA ENDRUN-1 010140 LDA ENDRUN 010150 SBC #0 010160 STA ENDRUN 010170 ; 010180 ; SAVE THE EXECUTE ROUTINE 010190 ; ALONG WITH ALL BIN POINTERS 010200 ; 010210 BPUT 2,BASRUN,LEN 010220 ; 010230 ; COPY BASIC FILE OVER 010240 ; 010250 L4 BGET 1,BUF,5125,LEN 010260 STY TEMY ; SAVE ERROR FLAG 010270 BPUT 2,BUF,LEN 010280 ; 010290 LDY TEMY ; GET ERROR FLAG 010300 CPY #136 ; EOF REACHED? 010310 BNE L4 ; BR. IF NOT 010320 ; 010330 CLOSE 1 ; CLEAN UP 010340 CLOSE 2 010350 RTS ; ALL DONE 010360 ; 010370 ; CONTROL PAD?! 010380 ; 010390 PAD LDA #125 ; CLEAR SCREEN 010400 JSR PUTBYTE 010410 LDA #0 ; ZERO MARGIN 010420 STA 82 010430 ; 010440 PRINT 0," Basic to Binary Control Pad." 010450 PRINT 0," ............................" 010460 PRINT 0," SELECT : Item to change." 010470 PRINT 0," OPTION : Changes Item." 010480 PRINT 0," START : Exits...." 010490 PRINT 0,"RESET -..BREAK -..TITLE -..MEMLO -" 010500 ; 010510 ; 010520 LDA #0 ; ZERO VARIABLES 010530 STA TEMP1 010540 STA OPTION 010550 TAX 010560 ; 010570 LDA #8 010580 STA SCRN 010590 PRINTITEM JSR PITEM ; PRINT OPTION 010600 LDX TEMP1 ; GET X 010610 INX ; ADD 1 010620 STX TEMP1 ; SAVE IT 010630 CPX #4 ; ALL DONE? 010640 BNE PRINTITEM ; NO. 010650 ; 010660 STATCON LDA #8 ; CLEAR CONSOL 010670 STA 53279 010680 LDA 53279 ; STATUS CONSOL 010690 CMP #7 ; PRESSED? 010700 BCS STATCON ; BR. IF NOT 010710 TAY ; SAVE A 010720 LDA #0 ; 010730 STA 53279 ; CLICK 010740 STA 54282 ; WAIT 010750 ; 010760 CN1 LDA #8 ; CLEAR CON 010770 STA 53279 010780 LDA 53279 ; STATUS CON 010790 CMP #7 ; HANDS OFF? 010800 BNE CN1 ; NO, PEOPLE ARE SLOW 010810 ; 010820 LDA #10 ; 1/6 SEC DELAY 010830 STA 542 010840 CN2 LDA 542 010850 BNE CN2 ; LOOP TIL ZERO 010860 ; 010870 TYA ; RESTORE A 010880 ; 010890 CMP #5 ; SELECT PRESSED? 010900 BEQ CON1 ; YES 010910 ; 010920 CMP #3 ; OPTION PRESSED? 010930 BNE EXITPAD ; NO, EXIT 010940 ; 010950 JMP OPT 010960 EXITPAD RTS 010970 ; 010980 CON1 LDA 88 ; GET SCREEN ADDR 010990 STA TEMP2 011000 LDA 89 011010 STA TEMP3 011020 ; 011030 LDA SCRN ; CALC. SCREEN 011040 TAX ; POSITON 011050 Z1 LDA TEMP2 011060 CLC 011070 ADC #40 011080 STA TEMP2 011090 LDA TEMP3 011100 ADC #0 011110 STA TEMP3 011120 DEX 011130 BNE Z1 011140 ; 011150 LDY #0 011160 Z2 LDA (TEMP2),Y ; GET BYTE 011170 BEQ Z7 ; END OF BLOCK 011180 AND #127 ; INVERSE OFF 011190 STA (TEMP2),Y ; PUT IT BACK 011200 INY ; NEXT BYTE 011210 BNE Z2 ; NO 011220 ; 011230 Z7 LDA OPTION ; LAST OPTION? 011240 CMP #3 011250 BNE Z3 ; NO 011260 ; 011270 LDA #0 ; YES LOOP TO FIRST 011280 STA OPTION 011290 LDA #8 ; RESET POSITION 011300 STA SCRN 011310 LDA TEMP2 011320 SEC 011330 SBC #240 011340 STA TEMP2 011350 LDA TEMP3 011360 SBC #0 011370 STA TEMP3 011380 LDY #0 011390 JMP Z4 011400 ; 011410 Z3 INC OPTION ; NEXT OPTION 011420 INC SCRN 011430 INC SCRN 011440 LDY #80 011450 ; 011460 Z4 LDA (TEMP2),Y ; GET BYTE 011470 BEQ Z6 ; END OF BLOCK 011480 CLC 011490 ADC #128 ; INVERSE ON 011500 STA (TEMP2),Y ; PUT IT BACK 011510 INY ; NEXT BYTE 011520 BNE Z4 ; LOOP 011530 Z6 JMP STATCON ; DONE 011540 ; 011550 ; PRINT SELECTED ITEM. 011560 ; 011570 PITEM LDA #0 ; ZERO VARIABLES 011580 STA TEMP2 011590 STA TEMP3 011600 ; 011610 LDA RESET,X ; GET Y VALUE 011620 TAY 011630 ; 011640 ; (X*6)+(Y*2)=JMP ADDR 011650 ; X=OPTION Y=ITEM 011660 ; 011670 ; MULTIPLY X*6 011680 ; 011690 DOX DEX 011700 CPX #255 011710 BEQ DOY 011720 LDA TEMP2 011730 CLC 011740 ADC #6 011750 STA TEMP2 011760 JMP DOX 011770 ; 011780 ; MULTIPLY Y*2 011790 ; 011800 DOY DEY 011810 CPY #255 011820 BEQ ADDEM 011830 LDA TEMP3 011840 CLC 011850 ADC #2 011860 STA TEMP3 011870 JMP DOY 011880 ; 011890 ADDEM LDA TEMP3 011900 CLC 011910 ADC TEMP2 011920 TAX 011930 ; 011940 LDA TABLE1,X 011950 STA GOPRNT+1 011960 LDA TABLE1+1,X 011970 STA GOPRNT+2 011980 ; 011990 GOPRNT .BYTE $4C,0,0 ; JMP XX 012000 ; 012010 ; PRINT'S TO MAKE TABLE1 012020 ; 012030 O0I0 POS 8,8 012040 PRINT 0,"Trap & Re-Run Program" 012050 RTS 012060 O0I1 POS 8,8 012070 PRINT 0,"Reset Normally " 012080 RTS 012090 O0I2 POS 8,8 012100 PRINT 0,"Cold Start " 012110 RTS 012120 ; 012130 ; 012140 O1I0 POS 10,8 012150 PRINT 0,"Disabled" 012160 RTS 012170 O1I1 POS 10,8 012180 PRINT 0,"Enabled " 012190 RTS 012200 ; 012210 O2I0 POS 12,8 012220 PRINT 0,"Off" 012230 RTS 012240 O2I1 POS 12,8 012250 PRINT 0,"On " 012260 INC STRIP ; STRIP CHR OFF 012270 POS 16,0 012280 PRINT 0,"ENTER TITLE:.." 012290 PRINT 0,"[ ]....................." 012300 LDA #19 012310 STA MAXLINE ; 19 CHR LIMIT 012320 JSR GETLINE ; GET TITLE 012330 POS 16,0 012340 PRINT 0,"." ; ERASE PROMPT 012350 LDA INLINE ; TITLE ENTERED? 012360 BNE TI5 ; BR IF SO 012370 DEC STRIP ; NO TITLE 012380 JMP NULL 012390 ; 012400 TI5 LDY #19 ; TITLE LEN-1 012410 LDA #32 ; SPACE CHR 012420 ; 012430 TI4 STA TLINE,Y ; ERASE OLD TITLE 012440 DEY 012450 CPY #255 012460 BNE TI4 012470 ; 012480 ; CENTER TITLE 012490 ; 012500 LDX #10 ; MAX TITLE LEN/2 012510 LDA INLINE ; TITLE LEN 012520 ; 012530 TI1 DEX ; DIVIDE TITLE 012540 SEC ; LEN BY 2 012550 SBC #2 012560 BCS TI1 012570 ; 012580 CPX #11 ; X>10 ? 012590 BCC TI9 ; NO 012600 ; 012610 LDX #0 ; YES 012620 ; 012630 TI9 LDY #0 ; MOVE TITLE 012640 TI3 LDA LBUFF,Y ; GET BYTE 012650 BEQ TI2 ; BR IF END 012660 STA TLINE,X ; SAVE BYTE 012670 INY ; NEXT BYTE 012680 INX 012690 JMP TI3 ; LOOP 012700 TI2 DEC STRIP ; STRIP CHR ON 012710 RTS ; DONE 012720 ; 012730 O3I0 POS 14,8 012740 PRINT 0," " 012750 POS 14,8 012760 PNUM 0,MEMLO 012770 RTS 012780 ; 012790 O3I1 POS 16,0 012800 PRINT 0,"NEW MEMLO VALUE IS:" 012810 LDA #5 ; 5 CHRS MAX 012820 STA MAXLINE 012830 ; 012840 JSR GETLINE ; GET NUMBER 012850 LDA INLINE ; CHECK LEN 012860 BEQ NULL ; NOTHING THERE 012870 ASCIINUM LBUFF,MEMLO ; ASCII->FP 012880 ; 012890 NULL LDX OPTION ; NULL ITEM 012900 LDA #0 ; LOOP TO VALID 012910 STA RESET,X ; ITEM 012920 JMP PITEM 012930 ; 012940 TABLE1 .WORD O0I0,O0I1,O0I2 012950 .WORD O1I0,O1I1,NULL 012960 .WORD O2I0,O2I1,NULL 012970 .WORD O3I0,O3I1,NULL 012980 ; 012990 ; 013000 ; 013010 OPT LDX OPTION ; GET OFFSET 013020 INC RESET,X ; NEXT ITEM 013030 LDA RESET,X 013040 CMP #3 ; INC TO FAR? 013050 BNE Z5 ; BR. IF NOT 013060 LDA #0 ; LOOP TO FIRST 013070 STA RESET,X ; ITEM. 013080 Z5 JSR PITEM ; PRINT NEW ITEM 013090 JMP STATCON ; CHECK CONSOL 013100 ; 013110 ; FILES 013120 ; 013130 FILES LDA #125 013140 JSR PUTBYTE 013150 ; 013160 LDA #0 ; ZERO DRIVE BYTE 013170 STA DIR+1 013180 ; 013190 PRINT 0,"...Which drive? 1-8" 013200 GET 3 ; GET A KEY 013210 STA DIR+1 ; STORE AT D# 013220 CLOSE 1 013230 OPEN 1,6,0,DIR 013240 BPL DD1 ; BR. IF SUCCESSFUL 013250 RTS ; ERROR, RETURN 013260 ; 013270 DD1 CLOSE 0 ; CLOSE EDITOR 013280 OPEN 0,12,0,"E" ; GR. 0 013290 LDA #0 ; CHANGE COLOR 013300 STA 710 013310 DD3 GET 1 ; GET A BYTE 013320 BMI DD2 ; BR. ON ERROR 013330 PUT 0 ; PRINT BYTE 013340 BPL DD3 ; LOOP 013350 ; 013360 DD2 CLOSE 1 013370 PRINT 0,"..Type any key.." 013380 GET 3 ; GET KEY 013390 RTS 013400 ; 013410 *= 736 ; BIN LOAD RUN 013420 .WORD RUN