10
20 MODE7:?&FE62=15:?&FE60=15
30 title$="UVIPROM 1.0"
40 author$="(C) 1984 Solidisk, written by T Lee"
50
60 pam=&80:s_n=&B0:s_h=&BA:ex_vec=&0D9F
70 break_vec=&0202:basicont=&B1F4
80 tmp=&0C00:holdit=tmp+16:byte_count=tmp+18
90 f_name=tmp+32
100 opb=&FE60:drb=&FE62:pcr=&FE6C:acr=&FE6B:ifr=&FE6D:ier=&FE6E
110 wr=&FFE3:vdu=&FFEE:red=129:green=130:yellow=131:blue=132:magenta=133
120 A$="":P%=&C000:I%=0:N%=FNBYT(0):N%=FNWORD(0):N%=FNSTRING("AA")
130 PROCassemble
140 CALL !-4
150 END
160 DEFFNBYT(A%)
170 ?P%=A%
180 P%=P%+1
190 =I%
200 DEFFNWORD(A%)
210 ?P%=A% MOD 256:P%?1=A% DIV 256
220 P%=P%+2
230 =I%
240 DEFFNSTRING(A$)
250 $P%=A$:P%=P%+LENA$+1
260 =I%
270
280 :LDA#&40:JSR&FFCE:BNEbcont
290 DEFPROCassemble
300 V%=2:
310 FORI%=0TOV%STEPV%:P%=&8000:[OPTI%
320 BRK:BRK:BRK
330 JMPservice
340 OPT FNBYT(&82):OPT FNBYT(copy -&8001):OPT FNBYT(1)
350 .rom_title OPT FNSTRING(title$)
360 OPT FNWORD(13)
370 .copy OPT FNSTRING(author$)
380 OPT FNBYT(0)
390 .msg5 OPT FNSTRING("Press <BREAK> if Vcc switch is off."):OPT FNBYT(0)
400 .savemsg OPT FNSTRING("SA. 2000 +4000 D9CD 8000")
410 .save8k OPT FNSTRING("SA. 2000 +2000 D9CD 8000")
420 .loadmsg OPT FNSTRING("LO. 2000"):OPT FNBYT(13)
430 .header OPT FNBYT(yellow)
440 OPT FNSTRING("ADDRESS BLOWN AS SHOULD BE ")
450 .wrenable
460 RTS
470 .service
480 PHP:PHA:TYA:PHA:TXA:PHA:TSX:LDA&103,X:CMP#9:BEQhelp
490 CMP#3:BEQautoboot:JMPcommand
500 .autoboot
510 JSRboot
520 .help
530 JSRhelp_instr
540 LDY#9:LDX#&80:JSRprint_it
550 .end
560 PLA:TAX:PLA:TAY:PLA:PLP:RTS
570 .line_print
580 PLA:STAs_n:PLA:STAs_n+1
590 .lp1 LDY#1
600 LDA(s_n),Y:CMP#&EA:BEQlp3:JSRwr:INCs_n:BNElp1:INCs_n+1:BNElp1
610 .lp3
620 LDAs_n+1:PHA:LDAs_n:PHA:RTS
630 .print_it
640 STYs_n:STXs_n+1:LDY#0
650 LDA(s_n),Y:BEQprint_done:JSR&FFE3
660 INY:BNEprint_it+6:INCs_n+1:BNEprint_it+6
670 .print_done RTS
680 .command
690 CMP#4:BNEend
700 CLC:JSR&FFC2:LDA#0
710 .first PHA:TAX:LDAlist,X:CMP#&2E:BEQnolist:LDA(&F2),Y:CMPlist,X:BEQnextone
720 PLA:CLC:ADC#08:BNEfirst:BEQnolist+1
730 .nolist PLA:JMPend
740 .nextone INY:INX:LDA(&F2),Y:AND#&5F:BEQendword:CMPlist,X:BEQnextone
750 CMP#&0E:BEQgoodword:CMP#&0D:BNEnolist
760 .endword LDAlist,X:CMP#&2E:BEQgoodword:CMP#&0D:BNEnolist
770 .goodword STYholdit:LDX#0:PLA:LSR A:LSR A:LSR A:TAY
780 .getadd BEQ nowjump:INX:INX:INX:DEY:BNEgetadd
790 .nowjump JSRwrenable
800 LDAjmptable+1,X:STAbyte_count:LDAjmptable+2,X:STAbyte_count+1:JMP(byte_count)
810 \******** SERVICE PROGRAM *********
820 .jmptable
830 JMPview
840 JMPtest
850 JMPblow
860 JMPcompare
870 JMPread_to_disk
880 .list
890 OPT FNSTRING("VIEW...")
900 OPT FNSTRING("TEST...")
910 OPT FNSTRING("BLOW...")
920 OPT FNSTRING("COMP...")
930 OPT FNSTRING("READ...")
940 OPT FNBYT(0)
950 OPT FNBYT(13)
960 \ **** End of data area *****
970 .help_instr
980 LDA(&F2),Y:CMP#13:BEQhelp_msg
990 .h_space LDA(&F2),Y:INY:CMP#&20:BEQh_space
1000 CMP#13:BEQhelp_msg:DEY:LDX#0
1010 .h_title LDA(&F2),Y:CMP#&0D:BEQinstruction
1020 CMP#&2E:BEQinstruction
1030 EORrom_title,X:AND#&5F:BNEhelp_msg
1040 INY:INX:BNEh_title
1050 .help_msg
1060 RTS
1070 .instruction
1080 LDY#help_text MOD 256:LDX#help_text DIV 256:JSRprint_it
1090 LDY#list MOD 256:LDX#list DIV 256:JSRprint_it
1100 JSR&FFE7
1110 JSRline_print:OPT FNSTRING("Refer to user manual for operating instructions."):NOP
1120 JSR&FFE7
1130 LDY#copy MOD 256:LDX#copy DIV 256:JSRprint_it
1140 PLA:PLA:JMPexit
1150 .name
1160 LDX#0:LDYholdit
1170 LDA(&F2),Y:CMP#&2E:BNEnspace:INY
1180 .nspace LDA(&F2),Y:INY:CMP#&20:BEQnspace
1190 .neachlet CMP#&0D:BEQendname:CMP#&20:BEQendname:STAf_name,X:LDA(&F2),Y:INY:INX:BNEneachlet
1200 .endname LDA#&0D:STAf_name,X:STAf_name+12
1210 RTS
1220 .exit
1225 JSR&FFE7
1230 PLA:TAX:PLA:TAY:PLA:PLP:LDA#0:RTS
1240 BRK
1250 .boot
1260 LDAtmp:CMP#&52:BEQ P%+5:JMP cb2low:JMPcb2high
1280 .reset
1290 LDY#0:STYdrb
1300 JSRmsg5v
1310 LDA#&10:STAier
1320 LDApcr:ORA#&F0:STApcr:LDAdrb:LDAopb:LDAier:LDAifr
1330 .res1
1340 JSRpulse
1350 LDAifr:AND#&10:BEQres1:RTS
1360 .cb2low
1370 LDApcr:AND#&DF:STApcr:RTS
1380 .pulse
1390 JSRcb2low
1400 .cb2high
1410 LDApcr:ORA#&E0:STApcr:RTS
1420 \****** Main routine *********
1430 \
1440 .screen
1450 LDA#22:JSRvdu:LDA#7:JSRvdu
1460 LDA#yellow:JSRvdu:JSRline_print:OPT FNSTRING("<CTL><SHIFT> to slow, <ESC> to stop"):NOP
1470 .scr2
1480 LDA#28:JSRvdu:LDA#0:JSRvdu:LDA#&14:JSRvdu:LDA#&25:JSRvdu:LDA#4:JMPvdu
1490 .scr1
1500 LDA#22:JSRvdu:LDA#7:JSRvdu
1510 LDA#yellow:JSRvdu:JSRline_print:OPT FNSTRING("<SHIFT> key to continue. <ESC> to stop."):NOP
1520 JSRscr2:LDA#14:JSRvdu
1530 LDA#&20:STAs_h+1:LDY#0:STYs_h
1540 RTS
1550 .msg5v
1560 LDY#msg5 MOD 256:LDX#msg5 DIV 256:JMPprint_it
1570 .view
1580 JSRscr1
1590 .v1 LDA#15:LDX#1:JSR&FFF4:LDA#&7A:JSR&FFF4:CPX#112:BEQv2
1600 JSRmemory:LDA#8:CLC:ADCs_h:STAs_h:BCCv1:INCs_h+1:BNEv1
1610 .v2 JMPexit
1620 .test
1630 JSRreset
1640 LDA#0:STAs_h+1:STAs_h:STAdrb
1650 .l_vfy
1660 JSRcb2low
1670 LDAopb:PHA:JSRcb2high:PLA:CMP#&FF:BNEfault:INCs_h:BNE P%+4:INCs_h+1:LDAs_h+1:CMP#&40:BNEl_vfy
1675 JSRline_print:OPT FNSTRING("OK"):NOP:JMP exit
1680 .fault
1690 JSRline_print:OPT FNBYT(7):OPT FNSTRING("Eprom fails blank test at"):NOP:JSRprintsh
1710 JMPexit
1720 .compare
1730 JSRbfile:JSR reset
1735 DECpam:BNE P%+4:DECpam+1
1740 LDA#&60:STApam+3:LDA#&20:STAs_h+1:LDA#0:STApam+2:STAs_h
1750 JSRscreen
1760 .c1
1770 LDAs_h:AND#7:STAtmp+27:BNEc_byte:LDA#yellow:JSRvdu:LDY#0:JSRprintsh1
1780 .c_byte
1790 JSRcb2low:LDAopb:PHA:JSRcb2high:PLA:PHA:LDY#0:CMP(s_h),Y:BEQpr_green
1800 LDY#2:PLA:PHA:STA(pam+2),Y:DEY:LDAs_h+1:STA(pam+2),Y:DEY:LDAs_h:STA(pam+2),Y
1810 LDA#3:CLC:ADCpam+2:STApam+2:BCC P%+4:INCpam+3:LDApam+3:CMP#&7C:BCC P%+5:PLA:BCSc4
1820 LDA#red:BNEpr_cont:.pr_green LDA#green:.pr_cont JSRvdu:PLA:JSRprint2hex
1830 LDAtmp+27:CMP#7:BNEc3
1840 .c2
1850 LDAs_h:AND#&F8:STAs_h:JSRm1g:LDAs_h:ORA#7:STAs_h:LDA&FF:BPLc3:AND#&7F:STA&FF:JMPc4
1860 .c3
1870 INCs_h:BNE P%+4:INCs_h+1:LDApam:BNE P%+4:DECpam+1:DECpam:LDApam+1:BNEc_return:LDApam:BNEc4:.c_return JMPc1
1880 .c4
1890 LDApam+2:BNEc5:LDApam+3:CMP#&60:BNEc5
1900 JSRline_print:OPT FNBYT(7):OPT FNSTRING(" Verification completed. No error"):NOP:JSR&FFE7:JMPexit
1910 .c5
1920 JSRscr1
1930 LDY#31:.c5b LDAheader,Y:STA&7FC1,Y:DEY:BPLc5b
1940 LDA#&60:STApam+1:LDY#0:STYpam
1950 .c6
1960 LDA&FF:BMI c7
1970 JSR&FFE7:LDA#magenta:LDX#2:JSRspce:LDY#0:LDA(pam),Y:STAs_h:INY:LDA(pam),Y:STAs_h+1:JSRprintsh1
1980 LDX#6:LDA#red:JSRspce:INY:LDA(pam),Y:JSRprint2hex:LDX#6:LDA#green:JSRspce:LDY#0:LDA(s_h),Y:JSRprint2hex
1990 LDA#3:CLC:ADCpam:STApam:LDA#0:ADCpam+1:STApam+1:LDApam+1:CMPpam+3:BCCc6:LDApam:CMPpam+2:BCCc6
2000 .c7
2010 LDA#&0D:JSRwr:LDA#&0A:JSRwr
2020 JMPexit
2030 .spce
2040 JSRvdu:LDA#&20:JSRwr:DEX:BPLspce+3:RTS
2050 .memory
2060 LDA#magenta:JSRvdu
2070 LDAs_h+1:JSRprint2hex:LDAs_h:JSRprint2hex
2080 .m1
2090 LDY#0:LDA(s_h),Y:JSRprintsp2:INY:CPY#8:BNEm1+2
2100 .m1g
2110 LDA#green:JSRvdu:LDY#0
2120 .m2
2130 LDA(s_h),Y:CMP#126:BCC P%+4:LDA#&2E:CMP#&20:BCS P%+4:LDA#&2E:JSRvdu:INY:CPY#8:BNEm2
2140 RTS
2150 .printsh1
2160 LDAs_h+1:SEC:SBC#&20:JMP P%+5
2170 .printsh
2180 LDAs_h+1:JSRprint2hex:LDAs_h:JMPprint2hex
2190 .printsp2
2200 PHA:LDA#green:JSRvdu:PLA
2210 .print2hex
2220 PHA:LSR A:LSR A:LSR A:LSR A
2230 JSRprint1hex
2240 PLA:AND#&0F
2250 .print1hex
2260 CMP#10:BCC P%+4:ADC#6:ADC#&30:JMPvdu
2270 .bfile
2280 JSRname:DEX:CPX#11:BCC P%+4:LDX#10:STXtmp:LDX#f_name MOD 256:LDY#f_name DIV 256:LDA#&40:JSR&FFCE:BNEbcont
2290 JSRline_print:OPT FNSTRING("File not found"):NOP:LDA#7:JSRvdu:JSR&FFE7:PLA:PLA:JMPexit
2300 .bcont
2310 LDX#pam:TAY:LDA#2:JSR&FFDA:LDA#0:TAY:JSR&FFCE
2320 LDY#0:.bl0 LDAloadmsg,Y:STAf_name+12,Y:CMP#&0D:BEQbl1:INY:BNEbl0
2330 .bl1 LDXtmp:LDAf_name,X:STAf_name+16,X:DEX:BPLbl1+3:LDX#(f_name+12) MOD 256:LDY#(f_name+12) DIV 256:JSR&FFF7
2340 RTS
2350 .blow
2360 JSRbfile
2362 JSRline_print:OPT FNSTRING("File length= &"):]:P%=P%-1:[OPT I%:NOP
2363 LDA pam+1:JSR print2hex:LDA pam:JSR print2hex
2364 JSRline_print:OPT FNSTRING(", Do you wish to program this Eprom (Y/N)?_"):]:P%=P%-1:[OPT I%:NOP
2365 JSR get1key:AND#&5F:CMP#ASC"Y":BEQ P%+10:LDA#ASC"N":JSR wr:JMP exit
2370 JSRreset:LDA#&52:STAtmp
2380 JSRline_print:OPT FNBYT(12):OPT FNSTRING("Switch on VPP then press <RET>"):NOP:NOP
2390 .blstart JSR get1key:CMP#&0D:BNEblstart:LDA#7:JSRvdu
2400 LDAacr:AND#&DF:STAacr:LDA#&20:STAier
2410 LDA#&FF:STAdrb
2420 LDA#&20:STAs_h+1:LDY#0:STYs_h
2430 JSRscreen
2440 .bl2
2450 LDY#0
2460 LDA(s_h),Y:STAopb:CMP#&FF:BNEblowit:JSRpulse:JMPbl2a
2470 .blowit
2480 JSRcb2low:LDA#&50:STA&FE68:LDA#&C0:STA&FE69:.wait2 LDAifr:AND#&20:BEQwait2:JSRcb2high
2490 .bl2a
2500 LDAs_h:AND#7:BNEbl2b:JSRmemory
2510 LDA&FF:BPLbl2b:AND#&7F:STA&FF:JMPbl3
2520 .bl2b
2530 INCs_h:BNE P%+4:INCs_h+1:LDApam:BNE P%+4:DECpam+1:DECpam:BNEbl2:LDApam+1:BNEbl2
2540 .bl3
2550 LDA#&7C:STAtmp:JSR&FFF4
2560 JSRline_print:OPT FNBYT(red):OPT FNSTRING("Programming terminated.")
2570 NOP:JSR&FFE7:JSRline_print
2580 OPT FNBYT(yellow):OPT FNSTRING("Switch off Vpp then press <RETURN>."):OPT FNWORD(&0A0D)
2590 NOP
2600 LDA#7:JSRvdu
2610 JSR get1key:CMP#&0D:BNE P%-5:STA tmp
2620 JMPexit
2630 .read_to_disk
2640 LDA#&20:STAs_h+1:LDY#0:STYs_h:STYdrb
2650 JSRreset
2660 .ld1
2670 JSRcb2low:LDY#0
2680 LDAopb:STA(s_h),Y:JSRcb2high:INCs_h:BNE P%+4:INCs_h+1:LDAs_h+1:CMP#&60:BNEld1
2690 JSRname:DEX:CPX#11:BCC P%+4:LDX#10
2700 LDA&2009:CMP&4009:BNEld2
2710 .ld8k
2720 LDY#0:LDAsave8k,Y:STAf_name+12,Y:CMP#&0D:BEQld3:INY:BNEld8k+2
2730 .ld2 LDY#0:LDAsavemsg,Y:STAf_name+12,Y:CMP#&0D:BEQld3:INY:BNEld2+2
2740 .ld3 LDAf_name,X:STAf_name+16,X:DEX:BPLld3:.ld4 LDX#(f_name+12) MOD 256:LDY#(f_name+12) DIV 256:JSR&FFF7
2750 JMPexit
2755 .get1key LDA#&15:LDX#0:JSR &FFF4:JMP &FFE0
2760 .help_text:OPT FNSTRING("Switch off Vcc (5V) before inserting or removing EPROMs (no LED is brightly lit).")
2770 OPT FNSTRING("Always press the <BREAK> key after power on the UVIPROM.")
2780 OPT FNSTRING("The following commands are available"):OPT FNBYT(&2E)
2790 OPT FNWORD(13):]NEXT:ENDPROC