ML}  X c0C)HCCH Mhhݩh `eCDiCD`  RyHP   * 1H0芢@) Y0.Ș`i`#(PM\ \b Pgi 0  % @ / ՠ`d   0DDԝLN10 .OPT NO LIST20 .SET 2,12030 .SET 4,800100 .TITLE "ATARI 1050 DISK DRIVE O.S."0110 * ATARI 1050 D}ISK DRIVE OPERATING SYSTEM0120 *0130 * based on listings of Michael Pascher (Abbuc-Buch)0140 * and W. Derks0150 *0160 * }RAM $0000 - $00FF0170 * TIMER,IO $0280 - $029F (6532)0180 * memory used by ports:0190 * PORT A ($0280)0200 * bit 0 drive} number read0210 * 1 " read0220 * 2 write0230 * 3 }motor off write0240 * 4 > track 20 write0250 * 5 single density write0260 * } 6 IRQ floppy ? read0270 * 7 data request floppy NAK read0280 *0290 * PORT B ($0282)0300 * bit 0 dat }a out (to CPU) write0310 * 1 read0320 * 2 step motor phase 1 write0330 * 3 step motor p }hase 2 write0340 * 4 step motor phase 3 write0350 * 5 step motor phase 4 write0360 * 6 data in (from CPU) r }ead0370 * 7 command (from CPU) read0380 *0390 * memory usage0400 *0410 * sector buffer from $0000 to $007F0420 *0 }430 SEKBUF = $000440 *0450 * buffer for address info after READ ADRESS0460 * TRACK, SIDE, SEKTOR, LENGTH, CRC1, CRC20470 }*0480 ATRACK = $7A0490 ASEK = $7C0500 ALEN = $7D0510 ACRC1 = $7E0520 ACRC2 = $7F0530 *0540 * buffer for command and }sector number0550 *0560 RDRIVE = $800570 RKOMND = $810580 RSEKL = $820590 RSEKH = $830600 *0610 FDATA = $850620 FSNR }= $870630 FTNR = $890640 *0650 MOTIML = $8B timer for MOTOR ON0660 MOTIMH = $8C0670 TRACK = $8D track #0680 SE}KTOR = $8E sector #0690 CSTAT = $8F controller status shadow0700 STATUS = $90 floppy drive status0710 ERROR = $9}1 error byte0720 COUNT = $92 counter0730 DIR = $93 step direction floppy0740 FLAG = $940750 HZ95 = $95 } aux byte for track/sector calculation0760 SEEKERR = $960770 TRKERR = $970780 KOMND = $98 command 0 - 70790 JUMPL = }$99 jump vector0800 JUMPH = $9A0810 DSTAT = $9B drive status, to detect change of diskette0820 MUSTERNR = $9C0830} HZ9D = $9D0840 HZ9E = $9E0850 PHASE = $9F actual phase of step motor0860 FMERK = $A00870 ERRADR = $A3 error add}r for floppy test0880 HZA4 = $A40890 BUFFER = $A5 temp for floppy test0900 STEPCNT = $AF step count0910 STEPS = $B0} steps to do0920 SBUF = $B1 write buffer and track count for floppy test0930 DRA = $0280 data register PORT A}0940 DDRA = $0281 data direction register PORT A0950 DRB = $0282 data register PORT B0960 DDRB = $0283 data direc}tion register PORT B0970 TIM64 = $0296 timer : 640980 TIM1024 = $0297 timer : 10240990 T1024I = $029F timer : 1024 INTE}RRUPT ENABLE1000 FCNTRL = $0400 control register floppy controller1010 TRKREG = $0401 track register1020 SEKREG = $0402 } sector register1030 DATREG = $0403 data register1040 *1050 *= $F0001060 *1070 * masks for phases of step motor10}80 *1090 PHASE1 .BYTE $FB each time 1 phase on 01100 .BYTE $F71110 .BYTE $EF1120 PHASE4 .BYTE $DF1130 *1140 } .BYTE $571150 *1160 * command table1170 *1180 READSEK .BYTE $52 read sector1190 WRITSEK .BYTE $50 write sector without }verify1200 WRVESEK .BYTE $57 write sector with verify1210 .BYTE $53 status request1220 .BYTE $21 format single} density1230 .BYTE $22 format enhanced density1240 SPEZIAL .BYTE $23 special1250 * first byte in following data bloc }k1260 * 0 or 1 second byte to FLAG for command $241270 * 2 second byte contains sector number1280 * !} it will be tested if sector after sector 1 on1290 * each track is less or equal to this sector #1300 * 3 "} do 1 step, direction in second byte ($FF or 1)1310 * 4 floppy test1320 * the diskette is enhanced f#}ormatted, then1330 * several tests are done. The test returns1340 * a 'C' or 'E' (error)1350 * 5$} SEEK on track in second byte1360 .BYTE $24 send time for one rotation in1370 * first two bytes of block (if%} command $23 00 00) or send motor rpms (if command $23 00 01)1380 * The time is stored in first 2 bytes of the sector13&}90 * send after the test1400 *1410 DRVNR .BYTE $33 drive number1420 .BYTE $32,$34,$311430 .BYTE $FF end of '}table1440 .BYTE 01450 *1460 * start of program after RESET1470 *1480 * port init & hardware test1490 START CLD 150(}0 LDX #$FF reset stack1510 TXS 1520 LDA #$3C PORT A bit 2 - 5 output1530 STA DDRA1540 LDA #$38 )} set bits 3-51550 STA DRA1560 LDA DRA read register1570 AND #$3C1580 CMP #$38 check for written *}value1590 BNE FAIL no, FATAL ERROR1600 LDA #$3D PORT B bit 0, 2-5 output1610 STA DDRB1620 LDA #$3D +} set all bits1630 STA DRB1640 LDA DRB read register1650 AND #$3D1660 CMP #$3D check for written ,}value1670 BNE FAIL no, FATAL ERROR1680 LDA #$D01690 STA FCNTRL force interrupt floppy controller1700 -}LDX #$151710 DEL1 DEX wait a little while1720 BNE DEL11730 LDA FCNTRL controller ready?1740 AND #117.}50 BNE FAIL no, FATAL ERROR1760 LDA #$55 test sector & track register1770 STA TRKREG1780 STA SEKREG/}1790 LDX #$1E1800 DEL2 DEX some respite1810 BNE DEL21820 EOR TRKREG ok?1830 BNE FAIL no, FATAL0} ERROR1840 LDA #$551850 EOR SEKREG1860 BNE FAIL also for track register1870 LDA #$481880 STA FCNT1}RL HEAD LOAD & STEP IN1890 LDX #$28 delay1900 JSR DELAY1 wait X * 71 cycles (?)1910 LDA FCNTRL busy?1922}0 AND #11930 BEQ FAIL no, something is rotten1940 LDX #$281950 JSR DELAY1 wait another time1960 L3}DA FCNTRL1970 AND #1 now it must by ok1980 BNE FAIL otherwise it't wrong1990 LDA #$F0 get checksum 4}of PROM2000 STA SEKBUF+1 start address2010 LDA #02020 STA SEKBUF2030 CLC 2040 TAY 2050 PCHECK ADC (5}SEKBUF),Y add PROM bytes2060 INY 2070 BNE PCHECK2080 INC SEKBUF+1 next page2090 BNE PCHECK2100 ORA #6}0 result must be zero2110 STA SEKBUF2120 BEQ TSTOK if so, everything is fine2130 *2140 * fatal error, brea7}k2150 *2160 FAIL BRK hardware defect2170 *2180 * hardware test ok, do RAM test2190 *2200 TSTOK LDX #0 write t8}o RAM2210 RAMTST TXA 2220 STA SEKBUF,X2230 INX 2240 BNE RAMTST2250 RAMTST1 TXA read it2260 CMP SEKB9}UF,X and compare2270 BNE FAIL2280 DEX 2290 BNE RAMTST12300 TXA 2310 RAMCLR STA SEKBUF,X write another ti:}me2320 INX to zero out2330 BNE RAMCLR2340 *2350 * for now, init motor2360 *2370 LDX #3 step mo;}tor phase 32380 STX PHASE2390 LDA PHASE4 bitpattern of phase2400 AND DRB to PORT B2410 STA DRB2420 <} JSR TMOTON motor on?, otherwise start motor2430 LDA #0 track 02440 STA TRACK2450 JSR SIREST 10 step=}s in, then restore2460 LDA FCNTRL controller status2470 STA CSTAT to RAM2480 AND #$80 drive ready?2490 >} BNE DRDY yes2500 JSR IDENT otherwise, init drive, density etc2510 *2520 * here loops the program if nothing e?}lse to do2530 * wait for command or new diskette2540 *2550 DRDY JSR DSKCHG change of disk?2560 JSR TKOMND command fr@}om CPU, if so -- do it2570 LDA DRA motor on?2580 AND #82590 BNE DRDY no2600 LDX #8 yes, delayA}2610 DEL3 DEX 2620 BNE DEL32630 INC MOTIML incr MOTOR ON timer2640 BNE DRDY2650 INC MOTIMH also msb26B}60 BNE DRDY2670 JSR MOTOFF if timer expires, stop motor2680 JMP DRDY end of main loop2690 *2700 * look foC}r change of diskette2710 *2720 DSKCHG LDA #$802730 AND FCNTRL controller bit ready2740 TAX still the samD}e?2750 EOR DSTAT if not2760 BNE NEWDSK it's a change2770 RTS for motor is turned on each change278E}0 NEWDSK STX DSTAT store new status2790 TXA 2800 BPL DIDENT motor off?2810 JSR MOTOFF no, turn it off2820 F} JMP UPDATE update status2830 *2840 DIDENT JSR TMOTON identify new diskette2850 JSR IDENT2860 UPDATE LDA FCNTRL upG}date status2870 STA CSTAT2880 RTS 2890 *2900 * turn motor off2910 *2920 MOTOFF LDA DRA turn motor off2930 H} ORA #8 via bit 3 of PORT A2940 STA DRA2950 LDA #$3C2960 ORA DRB2970 STA DRB all step motor phasI}es off2980 LDA STATUS2990 AND #$EF indicate MOTOR OFF to STATUS3000 STA STATUS3010 RTS 3020 *3030 * J}turn motor on3040 *3050 MOTON LDA DRA turn motor on3060 AND #$F73070 STA DRA3080 LDX PHASE step motor inK}3090 LDA DRB right phase3100 AND PHASE1,X3110 STA DRB3120 LDA #0 reset MOTOR ON timer3130 SL}TA MOTIMH3140 STA MOTIML3150 LDA STATUS indicate MOTOR ON to STATUS3160 ORA #$103170 STA STATUS3180 M} LDX #53190 JSR DELAY2 give motor some time to speed up3200 RTS 3210 *3220 * identify inserted diskette3230 * sN}ingle or enhanced density3240 *3250 IDENT JSR RESTORE3260 LDA DRA3270 AND #$DF try enhanced3280 STA DRA3O}290 JSR RDADR READ ADRESS command3300 BEQ IDENT1 succesfull read?3310 JSR RDADR no, try again3320 BEQP} IDENT1 ok3330 LDA DRA otherwise, try single3340 EOR #$203350 STA DRA3360 LDA STATUS indicate singlQ}e3370 AND #$7F3380 STA STATUS3390 RTS 3400 IDENT1 LDA STATUS3410 ORA #$80 indicate enhanced3420 R}STA STATUS3430 RTS 3440 *3450 * turn motor on if not on3460 * & reset MOTOR ON timer3470 *3480 TMOTON LDA DRA3490 S} AND #8 already on?3500 BEQ ZF18A3510 JSR MOTON no, turn it on3520 ZF18A LDA #03530 STA MOTIML3540T} STA MOTIMH reset timer3550 RTS 3560 *3570 * delay, (X) * 100 micro seconds3580 *3590 DELAY1 LDY #$123600 D11 U}DEY 3610 BNE D113620 DEX 3630 NOP 3640 NOP 3650 BNE DELAY13660 RTS 3670 *3680 * delay, (X) * V}10 milliseconds3690 *3700 DELAY2 STX SBUF SBUF used as counter3710 D21 LDY #43720 STY SBUF+13730 D22 LDX #$FA3740 W} JSR DELAY13750 DEC SBUF+13760 BNE D223770 DEC SBUF3780 BNE D213790 RTS 3800 *3810 * delay, (X) X}* 5 + 12 micro seconds3820 *3830 DELAY3 DEY 3840 BNE DELAY33850 RTS 3860 *3870 * 10 steps to the middle, and reY}store3880 *3890 SIREST LDA #103900 JSR DOSTEPS make the steps3910 *3920 * restore on track 03930 *3940 RESTORE JSRZ} FORCE force IRQ3950 JSR FORCE interrupt floppy command3960 LDA #$FF direction: from the middle3970 STA D[}IR3980 LDA #03990 STA STEPCNT no steps4000 STA STEPS4010 RESTOR1 LDA FCNTRL on track 0?4020 AND #44030 \} BEQ RESTOR2 br if so4040 JSR HSTEP make half a step4050 JMP RESTOR1 until on track 04060 RESTOR2 LDA PHASE i]}n phase 4?4070 CMP #34080 BEQ RESTOR3 br if so4090 JSR HSTEP otherwise, go on4100 JMP RESTOR2 until on ^}track 0, phase 44110 RESTOR3 LDA #04120 STA TRKREG reset track register4130 STA STEPCNT and step counter4140 _} LDX #$C8 20 milli seconds delay4150 JSR DELAY14160 RTS 4170 *4180 * make half a step4190 * the step motor ru`}ns a cyclus of 4 phases, equal to 2 tracks4200 *4210 HSTEP JSR DOHSTEP make half a step4220 JSR FORCE interrupt flopa}py command4230 LDX #$64 10 ms delay4240 JMP DELAY14250 *4260 * do half a step4270 *4280 DOHSTEP INC STEPCNT b}incr counter4290 LDA STEPCNT4300 CMP #$78 already 120 steps?4310 BCS STEPERR if so, something wrong4320 c} LDA DRA motor on?4330 AND #84340 BEQ STEP is so, alright4350 STEPERR BRK step error: motor off or tood} many steps4360 STEP LDX PHASE4370 LDA PHASE1,X get mask for phase4380 EOR #$FF invert4390 TAY 4400 Be}IT DIR get step direction4410 BPL STEPM for following phase4420 INX step forward4430 CPX #4 f} cyclus done?4440 BNE STEP14450 LDX #0 if so, do it again4460 BEQ STEP14470 STEPM DEX step backwarg}d4480 BPL STEP1 cyclus done?4490 LDX #3 if so, do it again backward4500 STEP1 STX PHASE save new phase4510h} TYA reset old phase4520 ORA DRB4530 AND PHASE1,X set new phase4540 STA DRB4550 RTS 4560 *4i}570 * seek track number in 008D4580 *4590 SEEK JSR FORCE interrupt actual command4600 LDA TRACK get destination traj}ck4610 SEC 4620 SBC TRKREG subtract actual track4630 BNE DOSTEPS already there?4640 RTS yes, donk}e4650 *4660 * make as many steps as value in accu4670 *4680 DOSTEPS BMI DOST1 step backward?4690 LDX #1 no, forl}ward4700 BPL DOSTEP14710 DOST1 LDX #$FF backward4720 EOR #$FF get two's complement4730 CLC 4740 ADC m}#14750 DOSTEP1 ASL A two times (2 phases/step)4760 BPL DOSTEP2 br if ok4770 JSR RESTORE otherwise too many stepsn}: restore4780 LDA #$80 indicate error4790 STA STATUS4800 RTS 4810 DOSTEP2 STA STEPS number of steps4820 o} STX DIR direction4830 LDA #04840 STA STEPCNT reset count of error steps4850 DOSTEP3 JSR HSTEP make half a sp}tep4860 DEC STEPS all done?4870 BNE DOSTEP3 no, continue4880 BIT DIR backward step?4890 BMI CHKTRK q} br if so4900 LDA #$FF otherwise step backward4910 STA STEPS but first one step too much4920 LDA #0 r}forward, so track will always4930 STA STEPCNT be encountered from the4940 JSR HSTEP same direction4950 LDA #s}$FF4960 STA DIR4970 JSR HSTEP step backward4980 LDA #0 reset error count4990 STA STEPS5000 STt}A STEPCNT5010 *5020 * set bit 4 of PORT A for tracks > track 205030 *5040 CHKTRK LDA TRACK5050 STA TRKREG actual tru}ack in track register5060 CMP #20 greater then 20?5070 BCC KTR20 no5080 LDA #$10 otherwise, set bit 4v} of PORT A5090 ORA DRA5100 BNE GTR20 br always5110 KTR20 LDA #$EF reset bit 4 of PORT A5120 AND DRA fow}r track less then 205130 GTR20 STA DRA5140 LDX #$C85150 JSR DELAY1 20 ms delay after SEEK5160 *5170 * force IRQx}, interrupt floppy command5180 *5190 DFORCE JSR FORCE two times force IRQ5200 FORCE LDA #$D05210 STA FCNTRL command y}force IRQ5220 LDX #7 short delay5230 FORC1 DEX 5240 BNE FORC15250 LDA #05260 FORC2 BIT FCNTRL wait untiz}l5270 BNE FORC2 controller ready5280 RTS 5290 *5300 * command from CPU?5310 *5320 TKOMND LDA #25330 BIT {}DRB test bit 1 of PORT B ???5340 BNE NOKOM5350 BMI TKOM1 bit 7 of PORT B = 1?5360 NOKOM RTS no command|} from CPU5370 *5380 * link other parts5390 *5400 .INCLUDE #D8:FLOPOS2.M655410 .OPT LIST5420 .INCLUDE #D8:FL}}OPOS3.M655430 .INCLUDE #D8:FLOPOS4.M655440 .INCLUDE #D8:FLOPOS5.M655450 .OPT NO LIST5420 .INCLUDE #D8:FLd0100 * ATARI 1050 DISK DRIVE OPERATING SYSTEM -- part 20110 *0120 * command from CPU0130 *0140 TKOM1 JSR RDKOM read comma}nd0150 BIT ERROR command ok?0160 BVS NEXT no, checksum error0170 JSR PROCESS execute0180 BIT ERROR } everything fine?0190 BMI NEXT other drive?0200 BVC KOK ok0210 JSR SENDNAK send NAK, can't execute comm}and0220 LDA STATUS0230 ORA #1 set to o.k.0240 STA STATUS0250 BNE NEXT always0260 *0270 KOK JSR }SENDA send 'A'0280 LDA ERROR0290 AND #1 read sector?0300 BEQ DOKOM no, execute command0310 JSR S}LOAD read sector from interface0320 BIT ERROR read error?0330 BVC KOK1 br if ok0340 JSR SENDNAK yes, se}nd NAK0350 LDA STATUS and indicate error0360 ORA #20370 STA STATUS0380 BNE NEXT0390 *0400 KOK1 JSR SEN}DA send 'A'0410 DOKOM JSR EXECUTE execute command0420 LDA STATUS read sector status bits0430 AND #$FC reset i}/o error0440 STA STATUS0450 NEXT LDX #4 clear buffer for new command0460 LDA #00470 EBCL STA RDRIVE,X0480 } DEX 0490 BPL EBCL0500 RTS 0510 *0520 * look at command0530 *0540 PROCESS LDA DRA0550 AND #3 drive n}umber0560 TAX to X reg0570 LDA DRVNR,X drive number same0580 CMP RDRIVE as in command frame0590 }BNE ERR80 no, error0600 LDX #7 commands 0 - 7 are o.k.0610 LDA RKOMND seek in table0620 KOMSUCH CMP READSE}K,X0630 BEQ KOMFND br if found0640 DEX otherwise, continue0650 BPL KOMSUCH until end of table0660 } BMI ERR40 unknown command0670 KOMFND STX KOMND save command number0680 CPX #3 command with sector number?0690} BCS NOSEK no0700 LDA RSEKL otherwise, test0710 CLC sector number in buffer0720 ORA RSEKH ca}n't be 00730 BEQ ERR400740 LDA DRA in single density0750 AND #$200760 BEQ ZF33D0770 LDX #$D0 }max $2D0 sectors0780 LDY #$020790 BNE TSANZ0800 ZF33D LDX #$10 in enhanced density $410 sectors0810 LDY #$04}0820 TSANZ SEC 0830 TXA 0840 SBC RSEKL0850 TYA 0860 SBC RSEKH0870 BCC ERR40 wrong sector0880 *0}890 NOSEK LDA RKOMND get command0900 CMP WRITSEK write sector?0910 BEQ LSSET if so, set load sector flag0920 } CMP WRVESEK write with verify?0930 BEQ LSSET load sector, again0940 CMP SPEZIAL special command0950 BEQ LSS}ET load sector, again0960 LDA #0 all other commands0970 BEQ NOLS don't load sector0980 *0990 * set load} sector flag1000 *1010 LSSET LDA #11020 *1030 * reset load sector flag1040 *1050 NOLS STA ERROR1060 RTS 1070 *10}80 * indicate error1090 *1100 ERR80 LDA #$801110 STA ERROR1120 RTS 1130 ERR40 LDA #$401140 STA ERROR1150 } RTS 1160 *1170 * send 'A' to CPU1180 *1190 SENDA LDY #'A ascii code for 'A'1200 JSR SBYTE send byte1210 }RTS 1220 *1230 * send 'NAK' to CPU1240 *1250 SENDNAK LDY #'N ascii code for 'N'1260 JSR SBYTE send1270 RTS 1}280 *1290 * send 'C' to CPU1300 *1310 SCONT LDY #'C ascii code for 'C'1320 JSR SBYTE send1330 RTS 1340 *13}50 * send 'E' to CPU for error1360 *1370 SERROR LDY #'E ascii code for 'E'1380 JSR SBYTE send1390 RTS 1400 *}1410 * read a serial byte1420 *1430 RDBYTE STX SBUF+2 save X reg1440 WSB BIT DRA wait for start bit1450 BVC ERR1 } data interrupt from floppy?1460 BIT DRB or DATA IN at PORT 6 high?1470 BVC WSB no1480 SEC o}therwise1490 LDA #$80 bit 7 mark for end1500 LDX #6 wait 0.5 bit time1510 WHB DEX 1520 BNE WHB1530 W}32B LDX #6 wait 2/3 bit time1540 W32B1 DEX to get first bit in the middle1550 BNE W32B11560 NOP 1570 } NOP 1580 NOP 1590 BIT DRB bit 1 or 0?1600 BVC BIT11610 CLC got a zero1620 BCC NXTBIT1}630 BIT1 SEC got a one1640 NOP keep in same tempo as BCC1650 NXTBIT ROR A roll bit in result1660 } BCC W32B already 8 bits?1670 TAY yes, result in Y reg1680 LDX SBUF+2 restore X reg1690 RTS 1700 }ERR1 PLA balance stack1710 PLA 1720 JMP ERRSTAT indicate error1730 *1740 * read a command (4 chars) from s}erial port1750 *1760 RDKOM LDA #4 number of chars1770 STA COUNT1780 LDX #RDRIVE buffer is from addr $801790 } JSR RDTO read 4 bytes with TIME OUT1800 NOTKOM BIT DRB wait until command on zero1810 BMI NOTKOM1820 RTS } done1830 *1840 * read a sector1850 *1860 SLOAD LDA #$80 sector length1870 STA COUNT1880 LDX #SEKBUF read} to addr 01890 JSR RDTO from serial port1900 LDX #9 short delay1910 JSR DELAY11920 RTS 1930 *19}40 * read bytes from serial port1950 * number of bytes in COUNT/buffer address in X1960 *1970 RDTO LDA #$FF1980 JSR T}IMEOUT set TIMEOUT1990 LDA #0 reset checksum2000 STA SBUF2010 RNXTB JSR RDBYTE read byte2020 STY SEKBUF,}X and store it2030 CLC add to checksum2040 LDA SBUF2050 ADC SEKBUF,X2060 ADC #02070 STA SBUF}2080 INX buffer pointer + 12090 DEC COUNT job done?2100 BNE RNXTB no, continue2110 JSR RDBYTE} yes, read checksum2120 STY SEKBUF,X store2130 LDA SBUF and compare with accumulated value2140 EOR SEKBUF,}X2150 BEQ NORERR br if ok2160 *2170 * indicate error / no error2180 *2190 ERRSTAT LDA #$402200 NORERR STA ERROR22}10 LDA TIM64 reset TIMEOUT counter2220 RTS 2230 *2240 * send bytes from address X2250 * number of bytes in COUN}T2260 *2270 SEND LDA #0 checksum2280 SEND1 CLC 2290 LDY SEKBUF,X add to checksum2300 ADC SEKBUF,X2310 A}DC #02320 JSR SBYTE send byte2330 INX buffer address + 12340 DEC COUNT job done?2350 BNE SEND}1 no, continue2360 TAY send checksum2370 JSR SBYTE2380 RTS 2390 *2400 * send sector2410 *2420 SN}DSEK LDA #$80 bytes/sector2430 STA COUNT2440 LDX #SEKBUF send from sector buffer2450 JMP SEND2460 *2470 * se}nd a byte to serial port2480 *2490 SBYTE STY SBUF save char2500 STA SBUF+1 save checksum2510 STX SBUF+2 save X}2520 LDY #8 send 8 bits2530 LDA #$FE set start bit2540 AND DRB ...and send2550 STA DRB2560 } INC SBUF+2 delay2570 SBYTE1 ROR SBUF next data bit2580 BCC SBIT0 send '0' bit2590 LDA #1 send '1' bit i}f carry set2600 ORA DRB2610 BNE SBIT send bit2620 SBIT0 LDA #$FE send '0' bit2630 AND DRB2640 NOP } keep synchronous2650 SBIT LDX #5 send bit2660 SBIT2 DEX delay2670 BNE SBIT22680 STA DRB to po}rt2690 DEY done?2700 BNE SBYTE12710 LDX #6 delay for last bit2720 SBIT3 DEX 2730 BNE SBIT3}2740 NOP 2750 DEC SBUF+2 delay2760 LDA #1 send stop bit2770 ORA DRB2780 STA DRB2790 LDX #5} delay for stop bit2800 SBIT4 DEX 2810 BNE SBIT42820 LDX SBUF+2 restore X2830 LDY SBUF and Y2840 } LDA SBUF+1 and A2850 RTS done2860 *2870 * execute command 0 - 7 from KOMND2880 *2890 EXECUTE LDX KOMND ge}t command number2900 LDA JMPTBL,X get low byte2910 STA JUMPL of command routine addr2920 LDA JMPTBH,X and hi}gh byte2930 STA JUMPH2940 JMP (JUMPL) jump to routine2950 *2960 * calculate track & sector from logical sector nu}mber2970 *2980 COMTS LDY RSEKL logical sector number to SBUF2990 STY SBUF3000 LDY RSEKH3010 STY SBUF+13020 } LDY #0 reset track & sector3030 STY TRACK3040 STY SEKTOR3050 INY transfer logical sector 1 ..}. n3060 JSR SUBY to 0 ... n-13070 LDA #$20 single or enhanced?3080 AND DRA3090 BNE SINGLE3100 }LDY #$1A number of sectors/track in MD3110 BNE COMTS13120 SINGLE LDY #$12 sectors/tracks in SD3130 COMTS1 JSR SUBY }subtrackt as many times3140 BCC TOMUCH as possible3150 INC TRACK count every time3160 BCS COMTS1 continue}3170 TOMUCH INC SEKTOR first sector is #13180 RTS 3190 *3200 * B1,B2 - Y3210 *3220 SUBY STY HZ953230 SEC 3240 } LDA SBUF save remaining sector number3250 STA SEKTOR3260 SBC HZ95 subtrackt sectors/track3270 STA SB}UF and store result3280 LDA SBUF+1 hi byte also3290 SBC #03300 STA SBUF+13310 RTS 3320 *3330 * read} sector, command 'R'3340 *3350 READ JSR SREAD read one sector3360 JSR QUITT return 'C' or 'E'3370 JMP SNDSEK }send sector3380 SREAD JSR SETUP set number of retries etc.3390 BIT FCNTRL drive ready?3400 BPL READ1 br if ok3}410 RTS otherwise error3420 READ1 JSR SEEK on right track?3430 BEQ READ2 ok?3440 RTS SEEK E}RROR3450 READ2 LDA SEKTOR put sector number in register3460 STA SEKREG3470 JSR RDSEKTOR read sector3480 BNE R}EAD3 error?3490 LDA #0 no, indicate 'no error'3500 STA ERROR3510 RTS done3520 READ3 DEC COUNT }another retry?3530 BEQ READ4 br if no more3540 LDA FCNTRL record not found error?3550 AND #$103560 BEQ} READ5 if so, try again, incl SEEK3570 JSR RESTORE3580 JMP READ13590 READ5 LDA #1 last try?3600 CMP COUN}T3610 BNE READ1 no, do it again3620 LDA #0 last try3630 STA STEPCNT another half step3640 LDA #$FF} backward3650 STA STEPS3660 STA DIR3670 JSR HSTEP make half a step3680 LDA #1 and forward again}3690 STA DIR3700 JSR HSTEP make half a step3710 LDX #$C8 delay3720 JSR DELAY13730 JMP READ1 r}ead another time3740 READ4 RTS done or break3750 *3760 * set retry number, motor on etc.3770 *3780 SETUP LDA #$80 } assume error3790 STA ERROR3800 LDA #2 retries3810 STA COUNT3820 JSR COMTS calculate track & secto}r3830 BIT FCNTRL drive ready?3840 BMI SETUP1 no, exit3850 JSR TMOTON otherwise, motor on3860 SETUP1 RTS 3}870 *3880 * quit off, send 'C' or 'E'3890 *3900 QUITT LDX #2 delay3910 JSR DELAY13920 LDA FCNTRL3930 STA} CSTAT return floppy status3940 BIT ERROR error?3950 BMI QUITTE br if so3960 LDA STATUS3970 AND #$9B} reset error bit in STATUS3980 STA STATUS3990 JSR SCONT send 'C'4000 RTS 4010 QUITTE LDA STATUS set erro}r bit4020 ORA #44030 STA STATUS4040 JSR SERROR send 'E'4050 RTS 4060 *4070 * read a sector, head alrea}dy on right track4080 *4090 RDSEKTOR LDX #0 set timeout4100 LDA #$E64110 JSR TIMEOUT4120 LDA #$82 read se}ctor command for controller4130 STA FCNTRL4140 READSE1 BIT DRA IRQ controller?4150 BVC READSE24160 BPL READSE}1 DRQ controller?4170 LDA DATREG yes, read data byte4180 EOR #$FF invert4190 STA SEKBUF,X and put in secto}r buffer4200 LDA TIM64 reset timer4210 INX sector buffer pointer + 14220 BPL READSE1 continue until }128 bytes read4230 LDA #14240 READSE3 BIT FCNTRL wait until controller ready4250 BNE READSE34260 LDA FCNTRL }mask status bits for READ SECTOR4270 AND #$2C4280 RTS done4290 READSE2 LDA FCNTRL4300 AND #1 con}troller still busy?4310 BEQ READSE4 br if not4320 LDA #$E6 otherwise, set timer again4330 JSR TIMEOUT4340 } BNE READSE1 and read again4350 READSE4 LDA TIM64 reset timer4360 LDA FCNTRL lost data?4370 AND #44380 BN}E RDSEKTOR yes, read again4390 LDA #1 otherwise error4400 RTS and exit4410 *4420 * execute 'read add}ress' command4430 *4440 RDADR LDX #$7A buffer for address info4450 LDA #$80 set timeout4460 JSR TIMEOUT4470 } LDA #$C0 'read address' command to controller4480 STA FCNTRL4490 RDADR1 BIT DRA wait for IRQ4500 BVC RDADR}34510 BPL RDADR1 or DRQ from controller4520 LDA DATREG read / store data at DRQ4530 STA SEKBUF,X4540 LD}A TIM64 reset timer4550 INX 4560 BPL RDADR1 until done4570 LDA #1 and wait4580 RDADR2 BIT FCNTRL for }controller ready4590 BNE RDADR24600 LDA FCNTRL read status4610 AND #$0C mask relevant bits4620 RTS } done4630 RDADR3 JSR DFORCE force interrupt4640 LDA #1 return error4650 RTS 4660 *4670 * set timeout, }value in A4680 *4690 TIMEOUT STA TIM64 set timeout value4700 STA T1024I4710 RTS 4720 *4730 * write sector witho}ut verify -- command 'P'4740 *4750 WRITE JSR WRITE1 write sector4760 JSR QUITT return result4770 RTS 4780 *47}90 WRITE1 JSR SETUP set retries etc.4800 BIT FCNTRL drive ready?4810 BPL WRITE2 br if so4820 RTS 4830 WRITE}2 JSR SEEK goto track4840 BEQ WRITE3 ok?4850 RTS no, error4860 WRITE3 LDA SEKTOR set sector4870 STA }SEKREG4880 JSR WRSEKTOR write sector4890 BNE WRITE4 br if error4900 LDA #0 indicate no error4910 ST}A ERROR4920 RTS done4930 WRITE4 DEC COUNT another retry?4940 BEQ WRITE5 no, error4950 JSR RESTORE ot}herwise, do it all over4960 JMP WRITE24970 WRITE5 RTS done or break4980 *4990 * write sector, head already on tr}ack5000 *5010 WRSEKTOR LDX #05020 LDA #$E6 set timeout5030 JSR TIMEOUT5040 LDA #$A2 'write sector' com}mand for controller5050 STA FCNTRL5060 WRITSE1 LDA SEKBUF,X read data byte from buffer5070 EOR #$FF invert5080} WRITSE2 BIT DRA IRQ from controller?5090 BVC WRITSE3 yes, error5100 BPL WRITSE2 DRQ from controller?5110 STA }DATREG yes, put byte5120 LDA TIM64 reset timer5130 INX next byte5140 BPL WRITSE1 if any5150 LD}A #1 otherwise,5160 WRITSE4 BIT FCNTRL wait for controller ready5170 BNE WRITSE45180 LDA FCNTRL read status}5190 AND #$0C mask relevant bits5200 RTS done5210 WRITSE3 LDA FCNTRL error5220 AND #1 wait for} controller ready5230 BEQ WRITSE55240 LDA #$E6 set timeout5250 JSR TIMEOUT5260 BNE WRITSE1 continue52}70 WRITSE5 LDA TIM64 reset timer5280 LDA FCNTRL5290 AND #4 lost data?5300 BNE WRSEKTOR do it again5310 } LDA FCNTRL otherwise, return error5320 RTS 5330 *5340 * write sector with verify -- command 'W'5350 *5360 VWRITE} JSR WRITE1 write sector, same as 'P'5370 BIT ERROR test for error5380 BMI VWRITE15390 LDA #2 set retry} to 25400 STA COUNT5410 JSR VERIFY check sector5420 VWRITE1 JSR QUITT return result5430 RTS set retryn0100 * ATARI 1050 DISK DRIVE OPERATING SYSTEM -- part 30110 *0120 * verify a sector0130 *0140 VERIFY LDA #$80 assume erro}r0150 STA ERROR0160 JSR VERSEK verify sector0170 BNE VERIFY1 br on error0180 LDA #0 otherwise, indi}cate 'no error'0190 STA ERROR0200 RTS done0210 VERIFY1 DEC COUNT another retry?0220 BNE VERIFY br if} so0230 RTS otherwise error0240 *0250 * verify0260 *0270 VERSEK LDX #0 set timeout0280 LDA #$E60290 } JSR TIMEOUT0300 LDA #$82 'READ SECTOR' command for controller0310 STA FCNTRL0320 VERSE1 BIT DRA IRQ from c}ontroller?0330 BVC VERSE2 error0340 BPL VERSE1 DRQ from controller?0350 LDA DATREG yes, read byte0360 }EOR #$FF invert0370 CMP SEKBUF,X and check0380 BNE VERSE3 br on error0390 LDA TIM64 othersine, reset tim}er0400 INX next byte0410 BPL VERSE1 until end of buffer0420 LDA #10430 VERSE4 BIT FCNTRL wait for co}ntroller ready0440 BNE VERSE40450 LDA FCNTRL mask status bits0460 AND #$2C0470 RTS done0480 VER}SE2 LDA FCNTRL error0490 AND #1 controller ready?0500 BEQ VERSE5 br if so0510 LDA #$E6 otherwise, ano}ther timeout0520 JSR TIMEOUT0530 BNE VERSE1 and continue0540 VERSE3 LDA TIM64 reset timer0550 STX ERRADR ma}rk error address0560 JSR FORCE interrupt controller0570 LDA DATREG reset IRQ0580 VERSE5 LDA TIM64 reset timer0}590 LDA FCNTRL read status0600 AND #4 lost data?0610 BNE VERSEK try again, if so0620 LDA #1 ot}herwise, return error0630 RTS 0640 *0650 * read status -- command 'S'0660 *0670 RSTAT JSR FORCE stop controller0680} LDA DRA0690 AND #$20 enhanced density?0700 BEQ RSTAT1 br if so0710 LDA #$1F otherwise, reset bit 7},6,50720 AND STATUS0730 JMP RSTAT20740 RSTAT1 LDA #$80 set bit 7 for enhanced0750 ORA STATUS0760 RSTAT2 BIT }FCNTRL test for 'write protected' disk0770 BVC RSTAT30780 ORA #8 set bit 3 if so0790 BNE RSTAT4 br alway}s0800 RSTAT3 AND #$F7 otherwise, reset bit 30810 RSTAT4 LDX #0 put diskette status0820 STA BUFFER,X to send buffer0}830 INX 0840 LDA CSTAT controller status0850 EOR #$FF invert0860 STA BUFFER,X put also0870 INX }0880 LDA #$E0 3.byte E00890 STA BUFFER,X0900 INX 0910 LDA #0 4.byte 000920 STA BUFFER,X0930  } STA ERROR indicate 'no error'0940 JSR SCONT send 'C'0950 LDX #4 and also 4 status bytes0960 STX C }OUNT0970 LDX #BUFFER from address BUFFER0980 JSR SEND0990 LDA FCNTRL update status1000 STA CSTAT1010  } RTS done1020 *1030 * format single density -- command $211040 *1050 SFORM JSR SDF do formatting1060 FORMVER  }BIT ERROR error?1070 BMI SFORM1 br if so1080 JSR VERIFO verify formatting1090 SFORM1 LDA TIM64 reset timer1100  } JSR QUITT return result1110 LDA #$FF write FF to format buffer1120 LDX #01130 SFORM2 STA SEKBUF,X write F}F1140 INX 1150 BPL SFORM2 until end of buffer1160 BIT ERROR formatted without error?1170 BPL SFORM3 b}r if so1180 LDA #0 otherwise, reset1190 STA SEKBUF first 2 bytes in buffer1200 STA SEKBUF+11210 SFORM3 }JMP SNDSEK sector to CPU1220 *1230 * single density formatting1240 *1250 SDF JSR BSEKT build up a sector1260 LDA #}0 start with track 01270 STA SEKBUF+1 set address info1280 LDA DRA set for single density1290 ORA #$2}01300 STA DRA1310 SDF1 BIT FCNTRL drive ready?1320 BMI SDF2 br if not1330 BVS SDF2 br if 'write protect}'1340 BPL SDF3 br always1350 SDF2 LDA #$80 indicate error1360 STA ERROR1370 RTS done1380 SDF3 J}SR SEEK goto track to format1390 LDA #2 try always 2 times1400 STA COUNT1410 JSR F1T format one tra}ck1420 LDX #$D21430 STX T1024I set timer1440 BIT ERROR error?1450 BPL SDF4 no, next trak1460 }RTS yes, break1470 SDF4 INC TRACK incr track1480 INC FTNR1490 LDA #$28 all 40 tracks?1500 CMP TRA}CK1510 BNE SDF1 no, continue1520 RTS yes, formatting done1530 *1540 * write a track1550 *1560 F1T LD}Y #01570 LDA SKEWTB,Y mark first sector from SKEW table1580 STA FSNR1590 LDA #$F0 'write track' command to }controller1600 STA FCNTRL1610 LDA #$D2 for timeout1620 F1T1 BIT DRA write 1 byte 00 at DRQ1630 gPL F1T1}1640 STY DATREG1650 F1T2 BIT DRA another byte 001660 BPL F1T21670 STY DATREG1680 STA T1024I start ti}mer1690 LDA #0 write 001700 LDX #$AC 172 times1710 F1T3 BIT DRA wait for DRQ1720 BVC F1T4 error}, IRQ1730 BPL F1T31740 STA DATREG write data byte1750 DEX zero?1760 BNE F1T3 no, continue177}0 LDA #$FC write FC1780 F1T5 BIT DRA1790 BVC F1T41800 BPL F1T51810 STA DATREG1820 LDA #01830 } LDX #$10 16 times 001840 F1T6 BIT DRA1850 BVC F1T41860 BPL F1T6870 STA DATREG1880 DEX 1890 BNE} F1T61900 BEQ F1T7 br always1910 F1T4 JMP F1T8 error1920 F1T7 LDA #01930 LDX #6 write 6 times 001940 F }1T9 BIT DRA1950 BVC F1T41960 BPL F1T91970 STA DATREG1980 DEX 1990 BNE F1T92000 LDX #5 writ!}e 5 bytes from address $85 down2010 F1T10 LDA FDATA,X2020 F1T11 BIT DRA2030 BVC F1T42040 BPL F1T112050 STA D"}ATREG2060 DEX 2070 BPL F1T102080 LDA #02090 LDX #$11 write 17 times 002100 F1T12 BIT DRA2110 BVC#} F1T42120 BPL F1T122130 STA DATREG2140 DEX 2150 BNE F1T122160 LDX #$83 write sector, including tr$}ack & sector addr2170 F1T13 LDA SEKBUF,X2180 F1T14 BIT DRA2190 BVC F1T42200 BPL F1T142210 STA DATREG2220 %} DEX 2230 BNE F1T132240 INY SKEW table ends at 92250 CPY #9 for single density2260 BNE F1T1&}52270 LDY #$0D now the even sectors2280 F1T15 CPY #$16 ends at 162290 BEQ F1T162300 LDA SKEWTB,Y otherwis'}e, continue formatting2310 STA FSNR2320 LDA #0 write 11 times 002330 LDX #$0B2340 F1T17 BIT DRA2350 (} BVC F1T42360 BPL F1T172370 STA DATREG2380 DEX 2390 BNE F1T172400 JMP F1T72410 F1T16 LDA #1 all )}tracks formatted2420 LDX #0 wait for controller ready2430 F1T18 AND FCNTRL2440 BEQ F1T19 IRQ from controlle*}r2450 BIT DRA2460 BPL F1T182470 STX DATREG continue to write 002480 JMP F1T182490 F1T19 LDA FCNTRL cont+}roller ready2500 AND #4 lost data?2510 BNE F1T8 br if error2520 LDA #0 o.k.2530 F1T20 STA ERROR ,}set error status2540 LDA TIM64 reset timer2550 LDA FCNTRL indicate status2560 STA CSTAT2570 RTS -} done2580 F1T8 JSR FORCE interrupt command2590 DEC COUNT another try?2600 BMI F1T21 br if not2610 LDA #.}1 yes, set timer2620 STA T1024I2630 JMP F1T try again2640 F1T21 LDA #$80 indicate error2650 JMP F1T/}202660 *2670 * format enhanced density -- command $222680 *2690 DFORM JSR DDF build up a track in enhanced density27000} JMP FORMVER and format2710 *2720 * enhanced density formatting2730 *2740 DDF JSR BSEKT build up sector2750 LD1}A #02760 STA SEKBUF+12770 LDA DRA2780 AND #$DF set to enhanced density2790 STA DRA2800 DDF1 BIT FCNTR2}L2810 BMI DDF2 IRQ?2820 BVS DDF2 or DRQ?2830 BPL DDF3 no, everything fine2840 DDF2 LDA #$80 indica3}te error2850 STA ERROR2860 RTS 2870 DDF3 JSR SEEK goto track without verify2880 LDA #2 two tries2890 4} STA COUNT2900 JSR F1TD write one track2910 LDX #$D22920 STX T1024I set timeout2930 BIT ERROR er5}ror?2940 BPL DDF42950 RTS 2960 DDF4 INC TRACK next track2970 INC FTNR2980 LDA #$28 all tracks done?6}2990 CMP TRACK3000 BNE DDF1 no, continue3010 RTS 3020 *3030 * format a track in enhanced density3040 *307}50 F1TD LDY #03060 LDA SKEWTB,Y to start of SKEW table3070 STA FSNR first sector number3080 LDX #$4E wri8}te 4E3090 LDA #$F0 but first 'write track' command3100 STA FCNTRL3110 F1TD1 BIT DRA wait for controller ready9}3120 BPL F1TD13130 STX DATREG3140 TXA write another 4E3150 LDX #$D2 timeout value3160 F1TD2 B:}IT DRA3170 BPL F1TD23180 STA DATREG3190 STX T1024I start timer3200 LDX #$90 write another 144 times 4;}E3210 F1TD3 BIT DRA3220 BVC F1TD43230 BPL F1TD33240 STA DATREG3250 DEX 3260 BNE F1TD33270 F1TD5 BI<}T DRA write another 256 times 4E3280 BVC F1TD43290 BPL F1TD53300 STA DATREG3310 DEX 3320 BNE F1TD5=}3330 LDA #03340 LDX #$0C write 12 times 003350 F1TD6 BIT DRA3360 BVC F1TD43370 BPL F1TD63380 STA>} DATREG3390 DEX 3400 BNE F1TD63410 LDA #$F63420 LDX #3 write 3 times F63430 F1TD7 BIT DRA3440 ?}BVC F1TD43450 BPL F1TD73460 STA DATREG3470 DEX 3480 BNE F1TD73490 LDA #$FC write FC3500 F1TD8 BI@}T DRA3510 BVC F1TD43520 BPL F1TD83530 STA DATREG3540 LDA #$4E3550 LDX #$32 write 50 times 4E3560A} F1TD9 BIT DRA3570 BVC F1TD43580 BPL F1TD93590 STA DATREG3600 DEX 3610 BNE F1TD93620 BEQ F1TD10B}3630 F1TD4 JMP F1TD113640 F1TD10 LDA #03650 LDX #$0C write 12 times 003660 F1TD12 BIT DRA3670 BVC F1TD43680 C} BPL F1TD123690 STA DATREG3700 DEX 3710 BNE F1TD123720 LDA #$F53730 LDX #3 write 3 times F5D}3740 F1TD13 BIT DRA3750 BVC F1TD43760 BPL F1TD133770 STA DATREG3780 DEX 3790 BNE F1TD133800 LDXE} #5 write 5 bytes from address $853810 F1TD14 LDA FDATA,X3820 F1TD15 BIT DRA3830 BVC F1TD43840 BPL F1TD1538F}50 STA DATREG3860 DEX 3870 BPL F1TD143880 LDA #$4E3890 LDX #$16 write 22 times 4E3900 F1TD16 BIT G}DRA3910 BVC F1TD43920 BPL F1TD163930 STA DATREG3940 DEX 3950 BNE F1TD163960 LDA #$003970 LH}DX #$0C write 12 times 003980 F1TD17 BIT DRA3990 BVC F1TD44000 BPL F1TD174010 STA DATREG4020 DEX 403I}0 BNE F1TD174040 LDA #$F54050 LDX #3 write 3 times F54060 F1TD18 BIT DRA4070 BVC F1TD44080 BPL J}F1TD184090 STA DATREG4100 DEX 4110 BNE F1TD184120 LDX #$83 write sector + track§or number4130 F1TK}D19 LDA SEKBUF,X4140 F1TD20 BIT DRA4150 BVC F1TD44160 BPL F1TD204170 STA DATREG4180 DEX 4190 BNE F1L}TD194200 INY next sector from table4210 LDA SKEWTB,Y4220 BMI F1TD21 end of table?4230 STA FSNR M} no4240 LDA #0 continue formatting4250 LDX #$11 write 17 times 004260 F1TD22 BIT DRA4270 BVC F1TD11N}4280 BPL F1TD224290 STA DATREG4300 DEX 4310 BNE F1TD224320 LDA #$4E4330 LDX #$20 write 32 timO}es 4E4340 F1TD23 BIT DRA4350 BVC F1TD114360 BPL F1TD234370 STA DATREG4380 DEX 4390 BNE F1TD234400 P} JMP F1TD104410 *4420 F1TD21 LDX #$4E4430 LDA #14440 F1TD24 AND FCNTRL4450 BEQ F1TD254460 BIT DRA4470 Q} BPL F1TD244480 STX DATREG write 4E4490 JMP F1TD244500 F1TD25 LDA FCNTRL4510 AND #4 lost data?4520 R} BNE F1TD114530 LDA #0 no4540 F1TD26 STA ERROR no error4550 LDA TIM64 reset timer4560 LDA FCNTRL457S}0 STA CSTAT indicate controller status4580 RTS done4590 F1TD11 JSR FORCE interrupt command4600 DEC CT}OUNT another try?4610 BMI F1TD27 no, formatting error4620 LDA #1 yes, set timer4630 STA T1024I4640 U} JMP F1TD try again4650 *4660 F1TD27 LDA #$80 indicate error4670 JMP F1TD264680 *4690 * sector skew table4700 *V} this table contains the sector numbers in the order4710 * they are written to the diskette4720 *4730 SKEWTB .BYTE 1,3,5,7W},9,11,13,15,17,19,21,23,254740 .BYTE 2,4,6,8,10,12,14,16,18,20,22,24,264750 .BYTE $FF end of table4760 *4770 * X}build up a sector incl. addr info & SYNCBYTES4780 *4790 BSEKT JSR MOTON start motor4800 JSR RESTORE to track 04810 Y} LDA #04820 STA TRACK start with track 04830 LDX #0 clear sector buffer4840 LDA #$FF4850 BSEKT1 STA SZ}EKBUF+3,X4860 INX 4870 BPL BSEKT14880 LDA #$FB set SYNCBYTES, address marks etc.4890 STA RSEKH4900 [} LDA #$F74910 STA SEKBUF+24920 STA FDATA4930 LDA #04940 LDX #44950 BSEKT2 STA FDATA,X4960 DEX 497\}0 BNE BSEKT24980 LDA #$FE4990 STA FTNR+15000 LDA #25010 STA T1024I set timer5020 RTS 5030 *50]}40 * read tracks from 39 down to check formatting5050 *5060 VERIFO LDA #$27 track 39 is the last one5070 STA TRACK508^}0 LDA DRA5090 AND #$20 single density?5100 ASL A5110 STA SBUF if so, $40 to SBUF5120 VERIFO1 LDA #0_} read until track 05130 STA SBUF+15140 STA ERROR no error, up to now5150 LDA #2 two tries5160 STA`} COUNT5170 JSR SEEK goto track5180 VERIFO2 LDY SBUF+15190 BIT SBUF5200 BVC VERIFO3 single density?5210 a} CPY #9 yes, go until sector 9 in SKEW table5220 BNE VERIFO4 more to do5230 LDY #$0D otherwise, continue wb}ith number 135240 STY SBUF+1 the even sector numbers5250 VERIFO4 CPY #$16 whole table for enhanced density5260 BEc}Q VERIFO55270 VERIFO3 LDA SKEWTB,Y get sector number5280 BMI VERIFO5 end of table?5290 STA SEKTOR put sector numbd}er5300 STA SEKREG also to controller5310 JSR RDSEKTOR and read sector5320 BNE VERIFO6 read error?5330 INe}C SBUF+1 no, incr. pointer to SKEW table5340 BPL VERIFO2 br always5350 VERIFO6 DEC COUNT error, retry?5360 BEQ VEf}RIFO7 no more retries5370 JSR RDSEKTOR otherwise, read one more time5380 BNE VERIFO6 another error?5390 LDA #2q}iFzFLOPOS LSTFw~FLOPOS2 LSTFFLOPOS3 LSTFtFLOPOS4 LSTF#FLOPOS5 LSTF+ATARICOMTXTF CRCVPIA OBJF\MRCVPIA SORF RECVSIO OBJF`RECVSIO SORFSYSTEXT PIAFSYSTEXT SIOFTALK192 OBJFTALKPIA OBJF=%TALKPIA SORF8bTALKSIO SORFKXMTPIA SORFXMTSIO OBJFKXMTSIO SOR no, set 2 retries for next sector5400 STA COUNT5410 INC SBUF+1 next sector5420 BPL VERIFO2 br always54r}30 VERIFO7 LDA #$80 error5440 VERIFO8 STA ERROR indicate error status5450 LDA FCNTRL indicate controller status5460 s} STA CSTAT5470 RTS verify done5480 VERIFO5 DEC TRACK next track5490 BPL VERIFO1 until track 05500 Lt}DA #0 done, no error5510 BEQ VERIFO85520 *5530 * motor off, wait, motor on5540 *5550 MOTONOF JSR MOTOFF motor ou}ff5560 LDX #$F05570 JSR DELAY25580 LDX #$6E5590 JSR DELAY25600 JSR TMOTON5610 RTS 5620 *5630 v}* command $23, floppy test, does several tests5640 * the command byte is followed by the test number, <2,2,3,4,55650 *5660w} TEST JSR TMOTON motor on5670 LDA SEKBUF get test number5680 CMP #2 test number 2?5690 BNE TEST15700 x} JSR RESTORE yes, to track 05710 LDA #05720 STA TRACK mark track 05730 LDA SEKBUF+1 second byte after commay}nd is sector number5740 STA SEKTOR mark sector5750 JSR TSTEPR test step rate for all tracks5760 BCS TEST2 z}error?5770 BCC TESTE no, done & return 'C'5780 TEST1 BMI TEST3 test number <2?5790 CMP #35800 BNE TEST4 i{}f not5810 JSR TSTEP yes, make a step5820 JMP TESTE direction in second byte after command5830 TEST4 CMP #4 |}test number 4?5840 BNE TEST5 if not5850 JSR TESTE otherwise return 'C'5860 JMP FPTEST and do floppy test}}5870 TEST5 CMP #5 test number 5?5880 BNE TEST2 no, error5890 JSR TSEEK SEEK on track5900 BCC TESTE tr~}ack number in second byte after command5910 TEST2 LDA ERROR wrong test number5920 ORA #$80 or test error5930 BN}E TEST6 br always5940 TEST3 STA FLAG store test number <2 in FLAG5950 TESTE LDA ERROR5960 AND #$7F clear error5}970 TEST6 STA ERROR test done5980 JMP QUITT return 'C' or 'E' to CPUESTE LDA ERROR5960 AND #$7F clear error5L0100 * ATARI 1050 DISK DRIVE OPERATING SYSTEM -- part 40110 *0120 * execute floppy test0130 * fist format diskette enhance}d density0140 *0150 FPTEST LDA SEKBUF+1 mark first 12 bytes from sector0160 STA HZ9D0170 LDA SEKBUF+20180 ST}A HZ9E0190 LDX #90200 FPTST1 LDA SEKBUF+3,X0210 STA BUFFER,X0220 DEX 0230 BPL FPTST10240 JSR DDF } format now0250 BMI TFAIL error, motor on/off every 2 seconds0260 JSR VERIFO ok, verify0270 BIT ERROR0280} BMI TFAIL error?0290 JSR WS13AT write pattern to sector 1,3 of each track0300 FPTST2 JSR M6DB6 fill sector buff}er with $6DB60310 JSR TWR1 write it to other sectors0320 JSR MOTONOF short delay0330 JSR TVER1 verify tes}t 10340 JSR MOTONOF delay0350 JSR MDB66 fill sector with $DB660360 JSR TWR2 write it to other sectors037}0 JSR MOTONOF delay0380 JSR TVER2 verify0390 JSR MOTONOF delay0400 JSR M6DB6 pattern 6DB6 again0410 } JSR WALTER1 write alternately0420 JSR MOTONOF delay0430 JSR VALTER1 verify alternately0440 JSR MOTONOF dela}y0450 JSR MDB66 pattern DB660460 JSR WALTER2 write alternately0470 JSR MOTONOF delay0480 JSR VALTER2 ve}rify alternately0490 JSR MOTONOF delay0500 LDA #0 SEEK on track 00510 STA TRACK0520 JSR SEEK0530 } LDA #1 sector 10540 STA SEKTOR0550 STA SEKREG to controller0560 JSR TREAD read sector 10570 INC} SEKBUF+10 number of o.k. tests + 10580 BNE TST10590 INC SEKBUF+110600 TST1 JSR WOSV write one sector, verify06}10 DEC HZ9D number of test loops - 10620 BNE FPTST2 more to do0630 LDA HZ9E0640 BEQ TST20650 DEC }HZ9E0660 JMP FPTST20670 *0680 TST2 LDA FCNTRL test loop done0690 STA CSTAT mark status0700 LDX #$FF res}et stack0710 TXS 0720 JSR RESTORE to track 00730 JMP DRDY back to main loop0740 *0750 * fatal error durin}g test0760 * turn motor on and off every 2 seconds0770 *0780 TFAIL LDA #8 invert motor bit0790 EOR DRA0800 ST}A DRA0810 LDX #$14 2 seconds delay0820 JSR DELAY20830 JMP TFAIL loop forever0840 *0850 * read alternate}ly from track 39 down and from track 0 up0860 *0870 VALTER2 LDA #$27 track 390880 STA SBUF0890 LDA #0 and tr}ack 00900 STA SBUF+10910 LDA #$140920 STA SBUF+2 read 20 tracks0930 VALT1 JSR SR2TRK SEEK, read 2 tracks094}0 INC SBUF+1 next track from begin0950 DEC SBUF next track from end0960 DEC SBUF+2 read 20 tracks?0970 } BNE VALT1 no, continue0980 RTS 0990 *1000 * read tracks alternately, 0 - 19 and 39 - 201010 *1020 VALTER1 LDA #0} start with track 01030 STA SBUF1040 LDA #$27 and track 391050 STA SBUF+11060 LDA #$14 20 tracks e}ach1070 STA SBUF+21080 VALT2 JSR SR2TRK SEEK, read 2 tracks1090 INC SBUF+11100 DEC SBUF1110 DEC SBUF+2 }all done?1120 BNE VALT21130 RTS 1140 *1150 * write tracks alternately, 39 - 20 and 0 - 191160 *1170 WALTER1 LDA} #$27 start with track 391180 STA SBUF1190 LDA #0 and track 01200 STA SBUF+11210 LDA #$14 20 trac}ks each1220 STA SBUF+21230 WALT1 JSR SW2TRK SEEK and write 2 tracks1240 INC SBUF+11250 DEC SBUF1260 DEC }SBUF+2 all done?1270 BNE WALT11280 RTS 1290 *1300 * write tracks alternately, 0 - 19 and 39 - 201310 *1320 WAL}TER2 LDA #0 start with 01330 STA SBUF1340 LDA #$27 and 391350 STA SBUF+11360 LDA #$14 20 tracks ea}ch1370 STA SBUF+21380 WALT2 JSR SW2TRK write 2 tracks1390 INC SBUF+11400 DEC SBUF1410 DEC SBUF+2 all do}ne?1420 BNE WALT21430 RTS 1440 *1450 * test SEEK on track1460 *1470 TSEEK LDA SEKBUF+1 intended track in second} byte after command1480 CMP #$281490 BPL TSEEK1 only 39 tracks1500 STA TRACK1510 JSR SEEK execute SEE}K1520 CLC 1530 RTS 1540 TSEEK1 SEC wrong track1550 RTS 1560 *1570 * read two tracks1580 *1590 SR2TRK} LDA SBUF tracknumber 11600 STA TRACK1610 JSR TRKVER verify1620 LDA SBUF+1 tracknumber 21630 STA TRACK}1640 JSR TRKVER read also1650 RTS 1660 *1670 * write test pattern to two tracks1680 *1690 SW2TRK LDA SBUF track}number 11700 STA TRACK1710 JSR TRKWRT write to track1720 LDA SBUF+1 tracknumber 21730 STA TRACK1740 } JSR TRKWRT also1750 RTS 1760 *1770 * do step for testing1780 *1790 TSTEP LDA SEKBUF+1 do test step, direction in }$011800 STA DIR1810 JSR STEP1820 RTS 1830 *1840 * fill sector with test pattern1850 *1860 WS13AT LDA #018}70 STA TRACK1880 LDA #0 pattern byte #11890 TAY pattern byte #21900 JSR SEKPAT1910 WS13AT1 L}DA #1 fill sector 11920 STA SEKTOR1930 JSR WOSV write + verify sector1940 BMI TWERR write test error195}0 LDA #3 sector 3 also1960 STA SEKTOR1970 JSR WOSV write1980 BMI TWERR on error to TWERR1990 } INC TRACK next track2000 LDA TRACK2010 CMP #$28 until track 392020 BNE WS13AT12030 LDA #02040 } STA TRACK track 02050 LDX #92060 WS13AT2 LDA BUFFER,X move test bytes2070 STA SEKBUF,X2080 DEX 2090 B}PL WS13AT22100 LDA HZ9D move counter for test2110 STA SEKBUF+122120 LDA HZ9E2130 STA SEKBUF+132140 } LDA #12150 STA SEKTOR2160 JSR WOSV write to sector 12170 BMI TWERR2180 RTS 2190 *2200 * pattern $6}DB6 or $DB66, depending on choice ($009C)2210 *2220 MWAHL LDA MUSTERNR2230 BNE MWAHL1 pattern $DB66?2240 JMP M6D}B6 no, $6DB62250 MWAHL1 JMP MDB662260 *2270 * test read2280 * read sector 1 if sector number <16, otherwise sector 322}90 *2300 TREAD LDA SEKREG2310 CMP #$10 sector number <16?2320 BPL TREAD12330 LDY #1 yes, read sector }12340 JMP TREAD22350 TREAD1 SEC otherwise subtract 16 & read sector 32360 SBC #$102370 LDY #32380 TREAD}2 STY SEKREG2390 STY SEKTOR2400 ASL A2410 ASL A2420 ASL A calculate address of status byte2430 } ADC #0 for error (0 - $80)2440 STA KOMND move address to KOMND & JUMPL2450 LDA #02460 STA JUMPL2470 } LDA #2 number of retries2480 STA COUNT2490 TREAD3 JSR RDSEKTOR read sector2500 BEQ TREAD52510 DEC COU}NT error, retry2520 BEQ TWERR2530 LDA FCNTRL get error type2540 AND #$0C2550 BEQ TREAD4 lost data?25}60 JMP TREAD3 if so, another try2570 TWERR JMP TST2 end of test2580 TREAD4 LDA CSTAT2590 AND #$10 RECORD NOT }FOUND?2600 BEQ TREAD3 no, other error2610 JSR RESTORE otherwise to track 02620 JSR SEEK goto track, again}2630 JSR RDSEKTOR read, again2640 BNE TWERR no good to nobody2650 LDA #$40 mark SEEK ERROR2660 STA SE}EKERR2670 LDA #$FF2680 STA FMERK+1 error occured2690 TREAD5 RTS end of test2700 *2710 * fill sector with pa}ttern2720 *2730 M6DB6 LDA #02740 STA MUSTERNR indicate pattern 12750 LDA #$6D first pattern byte2760 LDY }#$B6 second pattern byte2770 JMP SEKPAT fill sector2780 *2790 MDB66 LDA #$FF2800 STA MUSTERNR indicate patter}n 22810 LDA #$DB first pattern byte2820 LDY #$66 second pattern byte2830 *2840 * fill sector with pattern2}850 *2860 SEKPAT LDX #02870 SEKPA1 STA SEKBUF,X put first byte2880 INX 2890 STY SEKBUF,X put second byte2900 } INX 2910 BPL SEKPA1 until sector filled2920 RTS 2930 *2940 * check error2950 *2960 FAUSW LDA FCNTRL move cont}roller status2970 STA CSTAT2980 STY JUMPH to aux. cell2990 LDA CSTAT3000 AND #$10 RNF error?3010 } BEQ FAUSW13020 LDA FMERK yes, indicated by now?3030 BEQ FAUSW2 no, do it3040 LDA FMERK+2 write track erro}r?3050 BEQ FAUSW3 no, only read3060 LDA #$80 indicate write error3070 BNE FAUSW43080 FAUSW3 LDA #4 indi}cate read error3090 FAUSW4 JMP FAUSW5 mark3100 FAUSW2 LDA #$FF indicate error3110 STA FMERK3120 STA FMERK+13130 } LDA FMERK+2 write error?3140 BNE FAUSW6 br if so3150 JSR WRSEKTOR otherwise, write again3160 BNE FAUSW3 }wrong, again3170 FAUSW6 JMP FAUSW73180 FAUSW1 LDA CSTAT controller status3190 AND #8 CRC error bit3200 BEQ F}AUSW8 no CRC error3210 LDA #2 yes, indicate it3220 BNE FAUSW53230 FAUSW8 LDA CSTAT3240 AND #4 lost} data?3250 BEQ FAUSW9 br if not3260 LDA #8 yes, indicate it3270 BNE FAUSW53280 FAUSW9 LDA TRKERR imposs}ible to verify track?3290 BEQ FAUSW10 yes, only errors3300 LDA #$10 error, but not fatal3310 BNE FAUSW5332}0 FAUSW10 LDA #1 track verify FATAL ERROR3330 FAUSW5 LDY #03340 STY FMERK+1 reset error mark3350 STA SEEKERR indi}cate error code3360 JSR TREAD try another read, look after address for error3370 LDA SEEKERR mark for test error}3380 LDY #03390 ORA (KOMND),Y in command byte or3400 STA (KOMND),Y3410 LDA SEEKERR3420 CMP #8 lo}st data error?3430 BEQ FAUSW11 br if so3440 LDY #7 change error code to binary3450 CMP #$10 on $10 err}or 7, non fatal read error3460 BEQ FAUSW123470 DEY 3480 CMP #$80 on $80 error 6, write error3490 BEQ F}AUSW133500 DEY 3510 CMP #$40 on $40 error 5, SEEK error3520 BEQ FAUSW133530 DEY 3540 CMP #$04 }on $04 error 4, read error3550 BEQ FAUSW133560 DEY 3570 CMP #$02 on $02 error 3, CRC error3580 BEQ FAU}SW133590 DEY 3600 FAUSW12 STY HZA4 otherwise, error 23610 LDY #13620 LDA ERRADR move error address3630 }STA (KOMND),Y to sector buffer3640 LDY HZA43650 FAUSW13 LDA (KOMND),Y get byte, error number as offset3660 CLC 36}70 ADC #13680 STA (KOMND),Y3690 BPL FAUSW113700 BRK 3710 FAUSW11 JSR WOSV write sector with verify3720 } BPL FAUSW73730 JMP TST2 error3740 FAUSW7 JSR MWAHL other pattern3750 LDY JUMPH3760 RTS 3770 *3780 * w}rite one sector with verify3790 *3800 WOSV LDA #$803810 STA ERROR assume error3820 LDA #23830 STA COUNT }try two times3840 JSR WRITE2 write3850 BIT ERROR error?3860 BMI WOSV1 br if so3870 LDA #$80 assum}e error, again3880 STA ERROR3890 LDA #2 try two times3900 STA COUNT3910 JSR VERIFY for verify3920 } BIT ERROR error?3930 WOSV1 RTS 3940 *3950 * test if step to next track is done in a certain time3960 * a step to th}e start of sector 1 is indicated3970 * at the end, the number of sectors is read3980 * and compared with a maximum in the t}est command3990 *4000 TSTPRT JSR WSONE go read sector 14010 BCS TSTPRT1 br if no sector 14020 INC TRACK step to} next track4030 JSR SEEK4040 LDA #$C0 read address4050 STA FCNTRL4060 LDA #$D2 with timeout4070 } JSR TIMEOUT4080 LDX #$7A from sector buffer address $7A4090 TSTPRT2 BIT DRA4100 BVC TSTPRT1 IRQ from controll}er?4110 BPL TSTPRT2 DRQ?4120 LDA DATREG yes, read data byte4130 STA SEKBUF,X and store it4140 INX } six bytes4150 BPL TSTPRT24160 LDA TIM64 reset timer4170 LDA #14180 TSTPRT3 BIT FCNTRL4190 BNE TSTPRT}3 wait for controller ready4200 LDA FCNTRL4210 BNE TSTPRT1 error?4220 LDA ASEK test if sector <= maximum42}30 CMP SEKTOR4240 BEQ TSTPRT4 br if so4250 BMI TSTPRT44260 TSTPRT1 SEC step takes too long4270 RTS 4}280 *4290 TSTPRT4 CLC no error4300 RTS 4310 *4320 * test step rate for all tracks4330 *4340 TSTEPR JSR TSTPRT4}350 BCS TSTEPR14360 LDA TRACK already on track 394370 CMP #$274380 BNE TSTEPR no, continue4390 CLC} yes, no error4400 TSTEPR1 RTS 4410 *4420 * verify all tracks (0 - 39)4430 *4440 TVER2 LDA #04450 STA TRACK} from track 04460 LDA #$28 to track 394470 STA SBUF+24480 TVER21 JSR TRKVER4490 INC TRACK4500 DEC S}BUF+24510 BNE TVER214520 RTS 4530 *4540 * verify all tracks (39 - 0)4550 *4560 TVER1 LDA #$27 read from 39457}0 STA TRACK down to 04580 TVER11 JSR TRKVER4590 DEC TRACK4600 BPL TVER114610 RTS 4620 *4630 * write t}o all tracks (0 - 39)4640 *4650 TWR1 LDA #0 from track 04660 STA TRACK4670 LDA #$28 to 394680 STA SBU}F+24690 TWR11 JSR TRKWRT write4700 INC TRACK4710 DEC SBUF+24720 BNE TWR114730 RTS 4740 *4750 * write t}o all tracks (39 - 0)4760 *4770 TWR2 LDA #$27 write from 394780 STA TRACK down to 04790 TWR21 JSR TRKWRT4800 } DEC TRACK4810 BPL TWR214820 RTS 4830 *4840 * verify track4850 *4860 TRKVER JSR SEEK goto track4870 LDA #0}4880 STA FMERK+2 mark verify track4890 LDY #2 read from sector 34900 TRKVER1 LDA #04910 STA FMERK no e}rror4920 TRKVER2 LDA SKEWTB,Y4930 BMI TRKVER3 end of table?4940 INY 4950 STA SEKREG read & verify sector496}0 JSR VERSEK4970 BEQ TRKVER14980 LDA FCNTRL4990 AND #$1C error?5000 BNE TRKVER4 br if so5010 }LDA #65020 STA COUNT read 6 times5030 TRKVER5 DEC COUNT5040 BEQ TRKVER65050 JSR VERSEK read another time5}060 BEQ TRKVER55070 LDA FCNTRL5080 AND #$1C mask error bits5090 BNE TRKVER55100 LDA #$FF mark e}rror, other than CRC, LOST DATA, RNF5110 STA TRKERR5120 JMP TRKVER45130 TRKVER6 LDA #0 no error, drive not ready }etc.5140 STA TRKERR5150 TRKVER4 JSR FAUSW check error5160 LDA FMERK+1 again?5170 BEQ TRKVER1 no, continue518}0 DEY same sector again5190 JMP TRKVER25200 TRKVER3 RTS 5210 *5220 * write track5230 *5240 TRKWRT JSR S}EEK move head to track5250 LDA #$FF5260 STA FMERK+2 mark write track5270 LDY #2 from sector 35280 TRKWRT}1 LDA #05290 STA FMERK no error, now5300 TRKWRT2 LDA SKEWTB,Y5310 BMI TRKVER end of table?5320 INY 5330 } STA SEKREG select sector and write5340 JSR WRSEKTOR5350 BEQ TRKWRT1 o.k.?5360 JSR FAUSW check error5370} LDA FMERK+1 again?5380 BEQ TRKWRT1 repeat5390 DEY continue5400 JMP TRKWRT2USW check error5370g0100 * ATARI 1050 DISK DRIVE OPERATING SYSTEM -- part 50110 *0120 * command $240130 * on flag = 0 check rotation time of d}iskette0140 * otherwise, check motor speed0150 *0160 TTRK201 JSR TMOTON motor on, if needed0170 LDA #00180 STA S}EKBUF0190 STA SEKBUF+10200 LDA TSTRNG move test bytes0210 STA ALEN to address length0220 LDA TSTRNG+1}0230 STA ACRC1 and CRC0240 LDA TSTRNG+20250 STA ACRC20260 LDA FLAG0270 BEQ TTRK2011 check on 0 act}ual track0280 CMP #10290 BNE TTRK20120300 JMP MOTHL on 1 motor speed0310 *0320 TTRK2012 LDA ERROR0330 } ORA #$80 indicate error0340 STA ERROR0350 BNE TTRK2013 br always0360 TTRK2014 LDA ERROR0370 AND #$7F i}ndicate no error0380 STA ERROR0390 TTRK2013 LDA #$D0 interrupt command0400 STA FCNTRL0410 JSR QUITT return }'C' or 'E'0420 JMP SNDSEK return sector with error table0430 *0440 TTRK2011 JSR WSONE read sector 10450 BCS TTRK}2012 br if not present0460 JSR SPEED check rotation time0470 BCS TTRK2012 error0480 JMP TTRK2014 no error04}90 *0500 * check motor speed0510 *0520 MOTHL LDA #$14 goto track 200530 STA TRACK0540 JSR SEEK0550 JSR MOT}OFF motor off0560 LDX #$320570 JSR DELAY2 wait until quiet0580 LDA DRA0590 AND #$7F motor on0600 } STA DRA0610 LDA #$C0 'read address' to controller0620 STA FCNTRL0630 LDX #ATRACK destination address for }data0640 MOTHL1 LDA #10650 STA TIM1024 set timer0660 MOTHL2 BIT DRA0670 BMI MOTHL3 DRQ from controller?0680 } BIT T1024I timeout?0690 BPL MOTHL20700 INC SEKBUF incr. time counter0710 BNE MOTHL10720 INC SEKBUF+10}730 BNE MOTHL10740 LDA TIM64 reset timer0750 JMP TTRK2012 overflow, takes too long0760 MOTHL4 BIT DRA DRQ?}0770 BPL MOTHL40780 MOTHL3 LDA DATREG read data byte0790 STA SEKBUF,X and store it0800 INX 0810 BPL MOTHL}40820 LDA #10830 MOTHL5 BIT FCNTRL wait for controller ready0840 BNE MOTHL50850 LDA ATRACK0860 CMP #$14 } track 20?0870 BEQ MOTHL6 br if so0880 MOTHL7 LDA #$C0 'read address' again, motor not on speed0890 STA FCNTRL}0900 LDX #ATRACK dest. addr., again0910 BNE MOTHL2 do it again0920 *0930 MOTHL6 LDA FCNTRL0940 BNE MOTHL7 e}rror, try again0950 MOTTHL8 BIT T1024I0960 BPL MOTTHL8 wait for timeout0970 LDA TIM64 reset timer0980 JMP T }TRK2014 done0990 *1000 * wait for sector 11010 *1020 WSONE LDA #1 sector 11030 STA SEKREG1040 LDA DATREG105 }0 LDA #$82 READ SECTOR1060 STA FCNTRL1070 LDA #$E6 set timeout1080 JSR TIMEOUT1090 SWONE1 BIT DRA  }wait for DRQ1100 BVC WSONE2 IRQ, error1110 BPL SWONE11120 LDA TIM64 reset timer1130 LDA DATREG get da }ta byte1140 JSR FORCE interrupt command1150 LDA DATREG1160 CLC done1170 RTS 1180 WSONE2 SEC  } error1190 RTS 1200 *1210 * check time of one rotation1220 *1230 SPEED LDA #1 sector 11240 STA SEKREG1250} LDA #$82 read1260 STA FCNTRL1270 LDY #11280 JSR DELAY3 delay1290 SPEED1 BIT DRA data?1300 BMI }SPEED21310 LDY #$0D no, delay1320 JSR DELAY31330 NOP 1340 NOP 1350 NOP 1360 NOP 1370 IN}C SEKBUF time count + 11380 BNE SPEED11390 INC SEKBUF+11400 BNE SPEED11410 SEC error, overflow, }diskette jams1420 RTS 1430 SPEED2 CLC ok1440 SPEED3 RTS 1450 *1460 * break routine1470 * fatal errors of flopp}y comes here1480 *1490 BREAK JSR FORCE interrupt command1500 LDA #$3C1510 ORA DRB reset PORT B1520 STA D}RB1530 JMP TFAIL motor on/off1540 *1550 .BYTE $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA fillers1560 *1570 * jump tab}le for commands1580 * -- R, P, W, S, $21, $22, $23, $241590 *1600 JMPTBL .BYTE READ, >WRITE, >VWRITE, >RSTAT1630 .BYTE >SFORM, >DFORM, >TEST,} >TTRK2011640 .BYTE $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA fillers1650 TSTRNG .BYTE $4B,$04,$1A test bytes1660 *1670 * v}ectors1680 *1690 .WORD START reset vector1700 .WORD BREAK1650 TSTRNG .BYTE $4B,$04,$1A test bytes1660 *1670 * vE ATARICOM.DOCby Nick KennedyNOTE TO SIO2PC USERS:What is this ATARICOM.ATR disk image and why do I need it? You don'}t.But I mentioned in my SIO2PC info that I had tied two Atari's together via SIO ports and via joystick ports, and someone }asked mehow I did it. So, for those who are interested, here are the programs,the source code, and the whole exciting story}:This DOC describes some Atari communications programs I wrote, whichwere sort of forerunners of SIO2PC, for Atari to Atar}i file transfers.The idea was, I had one Atari with a disk drive and one without. I wrote a pair of programs, the "transmit}ter" program ran on the Atariwith the disk drive and was called XMTSIO or XMTPIA. The "receive"program was designed to run }from a cassette on the Atari without thedisk drive. With the correct hook-up, the diskless Atari could requestfiles from th}e Atari with a drive, which would transmit them. The reveive programs were called RCVSIO and RCVPIA. When run, these program }sactually put the "real" receive program to a cassette boot file.There were also demonstration programs I called "intercom!}" programs,which allowed two people to talk to each other, teletype style, over their atari's. These two programs are call"}ed TALKSIO and TALKPIA.I did two versions of these programs. The first version communicated viathe serial bus (SIO). It wo#}rked pretty well, but occasionally would lockup via an unidentifiable bug. Also, it was a pain to unplug the cassettecord a$}nd plug in the communications link cable. So the next versionused the joystick ports (PIA lines) in an unclocked, fully hand%}shakingprotocall I made up myself. This version worked flawlessly.Following are some excerpts from my source code which to&}ld what theprograms did and how the computers were to be hooked up:FROM TALKSIO.SOR: TALK;; Nick Ken'}nedy;; 10-29-86;; An experiment with the serial bus; which will send characters between; two Atari 800 compute(}rs using the ; serial port, but not using SIO.;Note: when I said "not using SIO," I mean I didn't use the Atari OS'srouti)}nes to send the data, since they are device specific and send infixed length blocks. I addressed the POKEY chip directly and*} sent onebyte at a time. Also, I started out at 600 baud, but when that was ok,I changed the program to run at 19,200. I ne+}ver had trouble (or did I?)even though I had about 75-100 feet of unshielded telephone wire between my Atari's.FROM XMT,}SIO.SOR:; TRANSMIT;; A program to send DOS binary load; files from one ATARI 800 to another; using the SERIAL -}port. For ground, ; connect the pins # 6 and/or 4 ; together (via cord/connector). For; data, connect pin 3 on computer A .}; to 5 on computer B, and vice versa.; 4 conductor phone cord is ok here.;;; Nick Kennedy;; 11/21/86/}Note, here's what the SIO jack on the Atari looks like for pin-out:2 4 6 8 10 12 1 3 5 7 9 11 13FROM RCVSIO.SOR:;0} RECEIVE;; Nick Kennedy;; 11/15/86;; This program is intended to receive; and run binary fil1}es via the serial; input port.;; This part of the program creates ; the cassette boot file.FROM TALKPIA.SOR:; 2} TALKP;; Nick Kennedy;; A program to send data between two; Atari 800 computers using the PIA's; (joystick po3}rts).;;; For STICK 0, bits 0-3 equal pins; 1-4. (8 is ground);; PINS:;;; 1 2 3 4 5 ; View of jack on; 6 7 8 4}9 ; console.;; NOTES:;; Pin 1 is data.; Pin 2 is Transmitter status.; (DATA READY or DR) (0 = READY).; Pin 3 is Rec5}eiver status.; (RECEIVER READY or RR) (0 = READY).;; Initialization: Before each byte; sent/received all out lines are ;6} made high. Transmitter makes sure; RR is high, then sets DATA lo. ; Receiver watches for DR high AND; Data lo, then is fr7}eed to set RR; lo (ready). Transmitter is then; free to put data and set DR lo (rdy)FROM RCVPIA.SOR:; RECEIVE8};; Nick Kennedy;; 11/15/86;; This program is intended to receive; and run binary files via the ; joys9}tick (PIA) port.;; This part of the program creates ; the cassette boot file.FROM XMTPIA.SOR:; TRANSMIT;; A:} program to send DOS binary load; files from one ATARI 800 to another; using the JOYSTICK port.;; Nick Kennedy;;;} 12/22/86OK. I had hoped that one of those told exactly how to interconnectthe two computers via joysticks. But I<}'m pretty sure it's like this:Use stick 0 (the first joystick port)pin 1 to pin 1pin 2 to pin 2pin 3 to pin 3pin 8 to =}pin 8You can use connectors from dead joysticks for this purpose.I consider all these programs to be "public domain." You>} can use them,give them away, modify them at will. You can have the source code aswell as the executable OBJ files. The sou?}rce code was written for Atari'sAMAC assembler. It's a good assembler when used with a ramdisk, but tooslow for use with a @}real disk drive. (SIO2PC falls somewhere in between.)Oh yeah, when using the intercom (TALK) programs, the transmitting statA}ionmust press control-A to give the other station the opportunity to send. COMMENTS? The author is:Nick Kennedy300 SouB}th VancouverRussellville, AR 72801 other station the opportunity to send. COMMENTS? The author is:Nick Kennedy300 Sou$@|@C:@B@EDJK V`@ B@EYDIH V` B V` #<ө7 8 D} ``@}AK:Input Filespec. Example: D2:FILEBad status on opening file.Header error - not a load file. Y E} 7 7 E,D  7 THUHVH ~ ɛ 7 LhVhUhT 7  7 J ED ! ED  J s    ɛF}  1 ~AyBEND  L 1  1 EjD  L 1 | 1 } 1 $ 1 % 1  }% |$LG}|}Lv    1 LR L`&&&&`i &&`H}HI B V`zBNCBHI V` BIH V`HIB V`BJE)D V` B V`BI}HI V` ED  hhL E֍D  hhLWent to INIT with INIT=0; ERROR!Went to RUN but RUN = 0; ERROR!QCLDTIMED OUT DJ}URING BYTE TRANSFERө 7 8өө<`) ӭ ' ED  hhL''') )mK} ӭ')  ` )ө '''' ED  hhhL) iӭ'խMDqD)L} `ө8өө<`@)ө '''' ED  hhhL) iӭ'խMDqD)&; RECEIVE;; Nick Kennedy;; 11/15/86;; This program is intended to receive; and run binary fiN}les via the ; joystick (PIA) port.;; This part of the program creates ; the cassette boot file.;NORECS: EQU [RECORD-STAO}RT+127]/128FLEN: EQU NORECS*128; ORG $4000; PROCCASFN: DB 'C:', $9BRUNCS: LDX #$40 ; IOCB #4 P} LDA #3 ; Open STA ICCOM,X LDA #HIGH CASFN STA ICBAH,X LDA #LOW CASFN STA ICBAL,X Q} LDA #8 STA ICAX1,X LDA #%10000000; Short IR gaps STA ICAX2,X JSR CIOV BPL :OK1 R} STY $600 RTS;; Now, put the entire file:;:OK1: LDX #$40 LDA #$B STA ICCOM,X LDA S}#HIGH STRT STA ICBAH,X LDA #LOW STRT STA ICBAL,X LDA #HIGH FLEN STA ICBLH,X LT}DA #LOW FLEN STA ICBLL,X JSR CIOV BPL :OK2 STY $600 RTS;:OK2: LDA #$C ; Close IOCU}B STA ICCOM,X JSR CIOV BPL :OK3 STY $601;:OK3: RTS ; Back to DOS;EPROC;; System EquaV}tes:CH: EQU $2FC ; Keyboard code hereCIOV: EQU $E456ICCOM: EQU $342ICBAL: EQU $344ICBAH: EQU $345ICBLL: EQU $W}348ICBLH: EQU $349ICAX1: EQU $34AICAX2: EQU $34BRTCLOK: EQU $14BEEP: EQU $FDCONSOL: EQU $D01FZLOAD: EQU $CB ; Z-X}page pointer L=2;STRT: LOC $700 ; Cassette start;; Put Cassette header bytes:;LDADR: DB $FF, LOW NORECS, LOW LDADR,Y} HIGH LDADR; DB LOW INIT1, HIGH INIT1; Refer. to OS manual pg 166 and; De Re Atari pg c-7/8:;START: LDA #$3C ; Z}Off motor STA $D302 ; (PACTL) LDA #LOW [RECORD+1] STA $237 ; (MEMLO) STA $E ; (APPMHI) [} LDA #HIGH [RECORD+1] STA $238 STA $F LDA #LOW INIT STA $A ; (DOSVEC) LDA #HIGH INIT\} STA $B ; (DOSVEC) CLC ; indicate boot success RTS ; End of init.INIT1: RTS ; No boot continuation.]}ENDL: DS 1ENDH: DS 1PLACE: DS 1TIMER: DS 1 ; My timeout timerFLAG: DS 1 ;;; STRINGS:KYBD: DB 'K:^}',$9BPMPT1: DB 'Input Filespec. Example: D2:FILE',$9BBSTMSG: DB 'Bad status on opening file.', $9BNTLF: DB 'Header err_}or - not a load file.', $9B; INITIALIZE;INIT: LDA #0 ; Clear Run/Init adr. STA $2E0 STA $2E1`} STA $2E2 STA $2E3 JSR OPENK LDA #$9B JSR PUTBYT LDA #$9B JSR PUTBYT a} PRINTS PMPT1 LDA #$9B JSR PUTBYT;; Stash cursor position:; LDA $54 PHA LDA b}$55 PHA LDA $56 PHAGETRK: JSR GETK CMP #$9B BEQ GREC JSR PUTBYT JMPc} GETRKGREC: PLA STA $56 PLA STA $55 PLA STA $54 LDA #$1F ; CURSOR right d} JSR PUTBYT LDA #$1E ; left JSR PUTBYT LDA #13 STA ICAX1 ; Forced read LDA #HIGHe} RECORD STA ICBAH LDA #LOW RECORD STA ICBAL JSR GETREC ; Get filename. PRINTS RECORD f}; Echo it. LDA #12 STA ICAX1 JSR CLOSK ; Close #1.;; Send the filespec to the other 800:; g}PROC JSR TINIT LDY #0:LOOP: LDA RECORD,Y ; Get byte JSR TLOOP ; Send it LDA RECORD,Y ; agaih}n to check CMP #$9B ; For EOL BEQ :DUN INY ; Next byte BNE :LOOP ; Forced branch;; Get readi}y to receive acknowledge:;:DUN: JSR RINIT JSR RLOOP ; Get status BNE :GOOD PRINTS BSTMSG j}JMP INIT:GOOD: JSR RLOOP ; check header byts CMP #$FF BNE :BADHD JSR RLOOP CMP #$FF k} BEQ :GDHD:BADHD: PRINTS NTLF ; Not load file JMP INIT:GDHD: JSR RLOOP ; Get load address STA LOAD+1 l} STA $605 ;********** STA $607 JSR RLOOP STA LOAD+2 STA $606 ;*********** STA $608m} JSR RLOOP ; Get end address STA ENDL JSR RLOOP STA ENDH:RBYTE: LDY #0 ; Dummy index. n} JSR RLOOP ; Get file byte.LOAD: STA RECORD ; (Dummy address) LDA LOAD+2 CMP ENDH BNE :NOTEQ o} LDA LOAD+1 CMP ENDL BNE :NOTEQ JMP :SEGDUN ; Segment done:NOTEQ: INC LOAD+1 ; Increment load p} INC $607;************** BNE :RBYTE ; address. INC LOAD+2 INC $608 ;************** JMP :RBq}YTE:SEGDUN LDA $2E2 ; Check init adr. BNE :INIT ; No init if = 0. LDA $2E3 BEQ :RDY:INIT: LDA $2E2r} ; (:INIT, not INIT) STA :GO+1 ; Set up JSR adr LDA $2E3 STA :GO+2:GO: JSR HELL ; HELL is dummy As}DR.:RDY: JSR JIF2 ; Stall 2 jiffies JSR TINIT JSR TLOOP ; Send any byte. JSR RINIT JSR RLOt}OP ; EOF? BEQ :RUN ; Yes JMP :GDHD;:RUN: LDA $2E0 BNE :DORUN LDA $2E1 BNE :DORUNu}:RUNN: JSR HECK ; HECK is a dummy:DORUN: LDA $2E0 ; if there's a run STA :RUNN+1 ; address, else LDA $2E1 ;v} we restart. STA :RUNN+2 JMP :RUNN RTS ; In case it comes back EPROC;; JIF2: Stall 2 jiffw}ies waiting to; be sure the other guy gets into; receive mode.;JIF2: LDA RTCLOK STA PLACE INC PLACE x} INC PLACEJIF2A: LDA RTCLOK CMP PLACE BNE JIF2A RTS;JIF10: LDA RTCLOK ; waste 10/60 sec. y} ADC #$A STA PLACEJIF10A: LDA RTCLOK CMP PLACE BNE JIF10A RTS;; Subroutine to put recoz}rd to E:; (Have ICBAH/L loaded before entry); (Use MACRO PRINTS);PUTREC: LDA #$80 STA ICBLL LDX #0 {} STX ICBLH LDA #9 ; Put record. STA ICCOM JSR CIOV RTS;; Subroutine to get a record from #|}0; User set ICBAL/H.;GETREC: LDX #0 LDA #5 STA ICCOM LDA #$80 STA ICBLL STX ICBLH}} JSR CIOV STY $600 RTS;;; Subroutine to put byte to E:; (Have byte in accumulator on entry);PUTB~}YT: LDX #$B ; Put byte STX ICCOM LDX #0 STX ICBLH STX ICBLL JSR CIOV RTS;;}; A routine to get one byte from ; IOCB #0 (assumed to be E:):;GETBYT: LDX #0 STX ICBLL STX ICBLH }LDA #7 STA ICCOM ; Get bytes. JSR CIOV RTS;;; OPEN KEYBOARD, IOCB #1;OPENK: LDX #$10 LD}A #3 STA ICCOM,X LDA #4 ; Read STA ICAX1,X LDA #HIGH KYBD STA ICBAH,X LDA #LO}W KYBD STA ICBAL,X JSR CIOV RTSCLOSK: LDX #$10 ; Close it. LDA #$C STA ICCOM,X } JSR CIOV RTS;GETK: LDX #$10 ; Get one byte from LDA #$7 ; keyboard. STA ICCOM,X LDA} #0 STA ICBLL,X STA ICBLH,X JSR CIOV RTSHELL: PRINTS NOINI ; INIT =0 PLA ; We shou}ldn't be here. PLA JMP INITHECK: PRINTS RUNZRO ; RUN = 0 PLA ; We shouldn't be here PLA } JMP INITNOINI: DB 'Went to INIT with INIT=0; ERROR!', $9BRUNZRO DB 'Went to RUN but RUN = 0; ERROR!', $9B;;; Th}e following is the transmit/; receive portion of TALKP.;; System Equates:PACTL: EQU $D302;CTLRW: EQU %00111100 ; to R}/W portCTLDD: EQU %00111000 ; to write data; direction. (0=input; 1=output);PORTA: EQU $D300;; For STICK 0, bits 0-3 }equal pins; 1-4. (8 is ground);; PINS:;;; 1 2 3 4 5 ; View of jack on; 6 7 8 9 ; console.;; NOTES:;; Pin} 1 is data.; Pin 2 is Transmitter status.; (DATA READY or DR) (0 = READY).; Pin 3 is Receiver status.; (RECEIVER READY or} RR) (0 = READY).;; Initialization: Before each byte; sent/received all out lines are ; made high. Transmitter makes sure}; RR is high, then sets DATA lo. ; Receiver watches for DR high AND; Data lo, then is freed to set RR; lo (ready). Transm}itter is then; free to put data and set DR lo (rdy);;;DATA DS 1 ; Store/send byte hereBITCT: DS 1 ; Bit counter;;} STRINGS:TOM: DB 'TIMED OUT DURING BYTE TRANSFER', $9B;; INITIALIZE;;RINIT: LDA #$FF ; Not re}ady. STA PORTA LDA #$9B JSR PUTBYT LDA #LOW CTLDD ; Make PORTA STA PACTL ; be data di}rection LDA #%00000100 ; register. STA PORTA ; Made bit 2 input. LDA #LOW CTLRW ; Make PORTA }STA PACTL ; be I/O port again RTS;; This subroutine receives a byte:;RLOOP: LDA PORTA ; XMT initialized? } AND #3 ; Get bits 0 and 1 CMP #2 ; Data LO & DR HI? BNE RLOOP ; Keep checking LDA #7 ; Bit counter (}0-7) STA BITCTRLP3: LDA #$FF - 4 ; clear bit 2 STA PORTA ; (set RR ready)RLP1: LDA BITCT ; We don't tim}e out CMP #7 ; if waiting for the BEQ SEVEN ; first bit. LDA RTCLOK ; But check on CMP TIMER }; later bits BNE NOTO ; No timeoutGOON: PRINTS TOM ; timeout message PLA ; Clear return address PL}A ; from stack. JMP INIT ; Goto menuSEVEN: LDA RTCLOK ; Set up timer for STA TIMER ; one to two jiff's } INC TIMER INC TIMERNOTO: LDA PORTA ; check DR AND #2 ; Mask all but DR line BNE RLP1 ; DATA no}t ready ASL DATA LDA PORTA ; Read data AND #1 ; Mask non-data CLC ADC DATA ; add it t}o DATA STA DATA LDA #$0F STA PORTA ; RR not readyRLP2: LDA TIMER CMP RTCLOK BEQ GO}ON ; Go on. (exit) LDA PORTA ; Check for DR not. AND #2 BEQ RLP2 ; DR not set DEC BITCT ; Ne}xt bit BPL RLP3 ; Do 8 bits LDA DATA ; Take it home RTS;;; This subroutine sends a byte out; over} the PIA line:;TLOOP: STA DATA ; Store the byteTLP4: LDA PORTA ; Check rcvr status AND #4 BEQ TLP4 ; Lo}op if ready. LDA #2 ; Set DR=1, DATA=0 STA PORTA LDA #7 ; Bit counter STA BITCT ; initiali}ze LDA RTCLOK STA TIMER INC TIMER INC TIMERTLP1: LDA RTCLOK ; Check for time CMP T}IMER ;waiting for RR. BNE TLP5 ; No timeoutTGOON: PRINTS TOM ; timeout message PLA ; Clear return address } PLA ; from stack. PLA ; Also clear data byte. JMP INIT ; Goto menuTLP5: LDA PORTA ; Receiver ready?} AND #4 ; Bit 2 is RR line BNE TLP1 ; Not ready ASL DATA ; Knock left bit LDA #0 ; Into carry} ADC #0 ; add carry to 0 STA PORTA ; Put data/DR readyTLP2: LDA TIMER CMP RTCLOK BEQ TGOON} ; Timed out LDA PORTA ; RCVR accept data? AND #4 ; RR line set? BEQ TLP2 ; Not yet LDA #$0F }; Data not ready. STA PORTA ; Tell RCVR DEC BITCT ; Count the bit BPL TLP1 ; 8 bits sent? RTS};; TRANSMIT section follows:;TINIT: LDA #$0F ; Not ready/Not init STA PORTA LDA #LOW CTLDD STA }PACTL ; Data direction LDA #%00000011 STA PORTA LDA #LOW CTLRW STA PACTL ; Data register } RTS;; RECORD is where I input my filename; It takes no file space cause it's ; at the end;OEND: EQU *ORECORD: E}ND RUNCS; s where I input my filename; It takes no file space cause it's ; at the end;OEND: EQU *ORECORD: E@|@C:@B@EDJK V`@ B@EYDIH V` B V` #<ө7 8҅ } ``@AI VE MADE IT THIS FAR!K:Input Filespec. Example: D2:FILEBad status on opening file.Header error - not a load fi}le.Data input frame errorSerial input over-run 3 3 EGD 3 THUHVH ɛ 3 LhVhUhT} 3  3 A~BJ ED  ED J (ҩ(ҩҩҍҍҩx     ȍX-+} D e ɛ EiD L  ED L    $ %  %} $L3 BzC L J K  D e L%ҭ $ t u Ls ` -}ҩ2x )X `,0ED hhL,pED hhL,+0ͩ+ `&&&&`i &&`}HI B V`{CvDBHI V` BIH V` ҍ,#2x)߅X`H && EwD hh}hL,0h ҩ,-xX`HIB V`X,h@X+h@x-%hX@BJEED V` B V`}BHI V` E6D wDD hhL EWD hhLWent to INIT with INIT=0; ERROR!Went to RUN but RUN = 0; ERROR!TI}MED OUT IN TLOOP!@6D wDD hhL EWD hhLWent to INIT with INIT=0; ERROR!Went to RUN but RUN = 0; ERROR!TI; RECEIVE;; Nick Kennedy;; 11/15/86;; This program is intended to receive; and run binary fi}les via the serial; input port.;; This part of the program creates ; the cassette boot file.; IF [RECORD-START+1}] MOD 128NORECS: EQU [RECORD-START+1]/128 + 1 ELSENORECS: EQU [RECORD-START+1]/128 ENDIF; ORG $400}0; PROCCASFN: DB 'C:', $9BRUNCS: LDX #$40 ; IOCB #4 LDA #3 ; Open STA ICCOM,X LDA #HIGH }CASFN STA ICBAH,X LDA #LOW CASFN STA ICBAL,X LDA #8 STA ICAX1,X LDA #%1000000}0; Short IR gaps STA ICAX2,X JSR CIOV BPL :OK1 STY $600 RTS;; Now, put the entire f}ile:;:OK1: LDX #$40 LDA #$B STA ICCOM,X LDA #HIGH STRT STA ICBAH,X LDA #LOW STRT} STA ICBAL,X LDA #HIGH [RECORD-START+1] STA ICBLH,X LDA #LOW [RECORD-START+1] STA ICBL}L,X JSR CIOV BPL :OK2 STY $600 RTS;:OK2: LDA #$C ; Close IOCB STA ICCOM,X } JSR CIOV BPL :OK3 STY $601;:OK3: RTS ; Back to DOS;EPROC;; System Equates:IRQST: EQU $D20EB600LO} EQU $CC ; for 600 baudB600HI EQU $05B192LO EQU $28 ; for 19.2K baudB192HI EQU $0SERIN: EQU $D20D ; Data in register.SE}ROUT: EQU $D20D ; Outgoing data hereIRQEN EQU $D20E ; IRQ enable. 0=disable, 1=enable. Bit 5 is serial input.;POKMSK EQU }$10 ; Shadow for above.SKCTL: EQU $D20FSSKCTL: EQU $232 ; Shadow for aboveSKSTAT: EQU $D20F ; Serial port stat.SKRES: E}QU $D20A; Write resets aboveAUDCTL EQU $D208VSERIN EQU $20A; Serial input vectorVSEROR: EQU $20C ; Serial out ready.VSE}ROC: EQU $20E ; Transmission cpt.AUDF1: EQU $D200AUDF2: EQU $D202AUDF3: EQU $D204AUDF4: EQU $D206AUDC1: EQU $D201A}UDC2: EQU $D203AUDC3: EQU $D205AUDC4: EQU $D207CH: EQU $2FC ; Keyboard code hereCIOV: EQU $E456ICCOM: EQU $342}ICBAL: EQU $344ICBAH: EQU $345ICBLL: EQU $348ICBLH: EQU $349ICAX1: EQU $34AICAX2: EQU $34BRTCLOK: EQU $14BEEP: } EQU $FDCONSOL: EQU $D01FZLOAD: EQU $CB ; Z-page pointer L=2;STRT: LOC $700 ; Cassette start;; Put Cassette header} bytes:;LDADR: DB $FF, LOW NORECS, LOW LDADR, HIGH LDADR, LOW INIT1, HIGH INIT1;; Refer. to OS manual pg 166 and; De Re} Atari pg c-7/8:;START: LDA #$3C ; Off motor STA $D302 ; (PACTL) LDA #LOW [RECORD+1] STA $237 ; (M}EMLO) STA $E ; (APPMHI) LDA #HIGH [RECORD+1] STA $238 STA $F LDA #LOW INIT ST}A $A ; (DOSVEC) LDA #HIGH INIT STA $B ; (DOSVEC) CLC ; indicate boot success RTS ; End of ini}t.INIT1: RTS ; No boot continuation.ENDL: DS 1ENDH: DS 1PLACE: DS 1TIMER: DS 1 ; My timeout timerFLAG: DS 1 ;}TVECT: DS 2 ; Place for VSERORSIRF: DS 1 ; Serial input rdy flagSORF: DS 1 ; Output ready flagTCF: DS 1 ; Transmi}ssion cpt flag;; STRINGS:IMHR: DB 'I VE MADE IT THIS FAR!', $9BKYBD: DB 'K:'PMPT1: DB 'Input Filespec. }Example: D2:FILE',$9BBSTMSG: DB 'Bad status on opening file.', $9BNTLF: DB 'Header error - not a load file.', $9BMSFRE: } DB 'Data input frame error', $9BSBOR: DB 'Serial input over-run', $9B;;; INITIALIZE;INIT: LDA #0 ; Clea}r Run/Init adr. STA $2E0 STA $2E1 STA $2E2 STA $2E3 JSR OPENK LDA #$9B } JSR PUTBYT LDA #$9B JSR PUTBYT PRINTS PMPT1 LDA #$9B JSR PUTBYT;; Stash cursor po}sition:; LDA $54 PHA LDA $55 PHA LDA $56 PHAGETRK: JSR GETK CMP #$}9B BEQ GREC JSR PUTBYT JMP GETRKGREC: PLA STA $56 PLA STA $55 PLA} STA $54 LDA #$1F ; CURSOR right JSR PUTBYT LDA #$1E ; left JSR PUTBYT LDA #13} STA ICAX1 ; Forced read LDA #HIGH RECORD STA ICBAH LDA #LOW RECORD STA ICBAL } JSR GETREC ; Get filename. PRINTS RECORD ; Echo it. LDA #12 STA ICAX1 JSR CLOSK ; Close #1.};; Set AUDCTL for 1.79 Mhz. into ch 3; and ch 3 into ch 4:; LDA #%00101000 STA AUDCTL;; Set baud rate}; LDA #B192LO STA AUDF3 LDA #B192HI STA AUDF4;; LDA #$A0 ; Off Sound 1,2,3 } STA AUDC1 STA AUDC2 STA AUDC3 LDA #$A8 ; On, channel 4 STA AUDC4;; Set the interrupt vecto}rs:; SEI LDA #HIGH TINT STA VSEROR+1 LDA #LOW TINT STA VSEROR LDA #HIGH RINT} STA VSERIN+1 LDA #LOW RINT STA VSERIN LDA #HIGH TCINT STA VSEROC+1 LDA #LOW }TCINT STA VSEROC CLI;; Initialize transmission done; flag & input ready flag.; LDA #0 STA} TCF LDA #$FF STA SIRF;; Send the filespec to the other 800:; PROC JSR TINIT LDY #}0:LOOP: LDA RECORD,Y ; Get byte JSR TLOOP ; Send it LDA RECORD,Y ; again to check CMP #$9B ; For EO}L BEQ :DUN INY ; Next byte BNE :LOOP ; Forced branch;; Get ready to receive acknowledge:;:DUN: }JSR RINIT JSR RLOOP ; Get status BNE :GOOD PRINTS BSTMSG JMP INIT:GOOD: JSR RLOOP ; check h}eader byts CMP #$FF BNE :BADHD JSR RLOOP CMP #$FF BEQ :GDHD:BADHD: PRINTS NTLF ; Not} load file JMP INIT:GDHD: JSR RLOOP ; Get load address STA LOAD+1 STA $605 ;********** STA }$607 JSR RLOOP STA LOAD+2 STA $606 ;*********** STA $608 JSR RLOOP ; Get end address} STA ENDL JSR RLOOP STA ENDH:RBYTE: LDY #0 ; Dummy index. JSR RLOOP ; Get file byte.LOAD: }STA RECORD ; (Dummy address) LDA LOAD+2 CMP ENDH BNE :NOTEQ LDA LOAD+1 CMP ENDL } BNE :NOTEQ JMP :SEGDUN ; Segment done:NOTEQ: INC LOAD+1 ; Increment load INC $607;************** }BNE :RBYTE ; address. INC LOAD+2 INC $608 ;************** JMP :RBYTE:SEGDUN LDA $2E2 ; Check init ad}r. BNE :INIT ; No init if = 0. LDA $2E3 BEQ :RDY:INIT: LDA $2E2 ; (:INIT, not INIT) STA :GO}+1 ; Set up JSR adr LDA $2E3 STA :GO+2:GO: JSR HELL ; HELL is dummy ADR.:RDY: JSR JIF2 ; Stall 2 jiffi}es JSR TINIT JSR TLOOP ; Send any byte. JSR RINIT JSR RLOOP ; EOF? BEQ :RUN ; Yes } JMP :GDHD;:RUN: LDA #%11000111 AND POKMSK ; Disable serial STA POKMSK ; bus IRQ's. STA IRQEN} LDA $2E0 BNE :DORUN LDA $2E1 BNE :DORUN:RUNN: JSR HECK ; HECK is a dummy:DORUN: LDA $2E0 }; if there's a run STA :RUNN+1 ; address, else LDA $2E1 ; we restart. STA :RUNN+2 JMP :RUNN } RTS ; In case it comes back EPROC;RINIT: JSR JIF2 ; in case TCF fails. LDA TCF ; output complete?} BNE RINIT ; No, wait. LDA #0 STA SKCTL ; Init. POKEY LDA #$13 STA SSKCTL STA} SKCTL ;; Set the serial input IRQ vector to; my service routine:; SEI LDA #%00100000 ORA POKMSK }; Enable input AND #%11100111;Disable output STA POKMSK ; and trans. cpt STA IRQEN CLI } STA SKRES ; Reset status flgs RTS;; The program idles here while waiting for a SERIN interrupt:;RLOOP: BIT SKS}TAT ; Frame error? BMI GDSTM PRINTS MSFRE ; Yes PLA PLA JMP INITGDSTM: BIT SKSTAT ;} Over-run? BVS GDSTAT PRINTS SBOR ; Yes PLA PLA JMP INITGDSTAT: BIT SIRF ; Serial in} ready? BMI RLOOP ; No LDA #$FF STA SIRF LDA SERIN ; Yes, read byte. RTS;; JIF2: St}all 2 jiffies waiting to; be sure the other guy gets into; receive mode.;JIF2: LDA RTCLOK STA PLACE INC} PLACE INC PLACEJIF2A: LDA RTCLOK CMP PLACE BNE JIF2A RTS;JIF10: LDA RTCLOK ; waste 10/6}0 sec. ADC #$A STA PLACEJIF10A: LDA RTCLOK CMP PLACE BNE JIF10A RTS;; Subroutine t}o put record to E:; (Have ICBAH/L loaded before entry); (Use MACRO PRINTS);PUTREC: LDA #$80 STA ICBLL LDX} #0 STX ICBLH LDA #9 ; Put record. STA ICCOM JSR CIOV RTS;; Subroutine to get a rec}ord from #0; User set ICBAL/H.;GETREC: LDX #0 LDA #5 STA ICCOM LDA #$80 STA ICBLL }STX ICBLH JSR CIOV STY $600 RTS;;; Subroutine to put byte to E:; (Have byte in accumulator on ent}ry);PUTBYT: LDX #$B ; Put byte STX ICCOM LDX #0 STX ICBLH STX ICBLL JSR CIOV } RTS;; TRANSMIT section follows:;TINIT: JSR JIF10 LDA #0 STA SKCTL ; init POKEY STA SORF ; Out}put ready flag LDA #$23 ; KYBD scan and STA SSKCTL ; debounce on and STA SKCTL; bit 5 mode.;; } Enable interrupts:; SEI LDA #%00010000 ;Send ready on ORA POKMSK AND #%11011111 ; Receive o}ff. STA POKMSK STA IRQEN CLI RTS;; Transmit loop follows:;TLOOP: PHA ; Save data } LDA RTCLOK ; set up time out SBC #$A ; 10 jiffies limit STA PLACETLOOP1: LDA RTCLOK CMP PLACE ; Tim}ed out? BNE TLOOP2 ; No. PRINTS TLPTO ; Yes PLA ; Clean off return adr PLA PLA ; And }data JMP INIT ; Start overTLOOP2: LDA SORF ; Ser. out ready? BMI TLOOP1 ; No. PLA ; Get data back } STA SEROUT; Yes, send byte. LDA #$FF ; Not rdy flag. STA SORF STA TCF ; Trans. not cpt. } SEI LDA #%00001000; Enable IRQ ORA POKMSK ; for trans. cpt. STA POKMSK STA IRQEN CLI} RTS;; A routine to get one byte from ; IOCB #0 (assumed to be E:):;GETBYT: LDX #0 STX ICBLL STX} ICBLH LDA #7 STA ICCOM ; Get bytes. JSR CIOV RTS;; Transmit interrupt routine:;TIN}T: CLI LDA #0 STA SORF ; Output rdy flag STA CONSOL ;**************** PLA RTI;;  }Receive interrupt routine:;RINT: CLI LDA #0 STA SIRF PLA RTI;; Output transmission cpt  }routine:;TCINT: SEI ; in case not already LDA #0 ; Output is complete. STA TCF LDA #%11110111 ; Of }f with IRQ AND POKMSK ; for trans. cpt. STA POKMSK STA IRQEN PLA CLI RTI;; }; OPEN KEYBOARD, IOCB #1;OPENK: LDX #$10 LDA #3 STA ICCOM,X LDA #4 ; Read STA ICAX1,X  } LDA #HIGH KYBD STA ICBAH,X LDA #LOW KYBD STA ICBAL,X JSR CIOV RTSCLOSK: LDX #$1}0 ; Close it. LDA #$C STA ICCOM,X JSR CIOV RTS;GETK: LDX #$10 ; Get one byte from } LDA #$7 ; keyboard. STA ICCOM,X LDA #0 STA ICBLL,X STA ICBLH,X JSR CIOV RT}SHELL: PRINTS NOINI ; INIT =0 PLA ; We shouldn't be here. PLA JMP INITHECK: PRINTS RUNZRO ; RUN} = 0 PLA ; We shouldn't be here PLA JMP INITNOINI: DB 'Went to INIT with INIT=0; ERROR!', $9BRUNZR}O DB 'Went to RUN but RUN = 0; ERROR!', $9BTLPTO: DB 'TIMED OUT IN TLOOP!', $9B;; RECORD is where I input my filename; }It takes no file space cause it's ; at the end;OEND: EQU *ORECORD: END RUNCS; s where I input my filename; _; SYSTEXT;PRINTS: MACRO ADDRESS LDA #HIGH %1 STA ICBAH LDA #LOW %1 STA ICBAL} JSR PUTRECENDM;INTS: MACRO ADDRESS LDA #HIGH %1 STA ICBAH LDA #LOW %1 STA ICBAL; SYSTEXT;PRINTS: MACRO ADDRESS LDA #HIGH %1 STA ICBAH LDA #LOW %1 STA ICBAL} JSR PUTRECENDM;INTS: MACRO ADDRESS LDA #HIGH %1 STA ICBAH LDA #LOW %1 STA ICBAL@APRESS START FOR RECEIVEPRESS SELECT FOR TRANSMITNOW IN RECEIVE MODE.NOW IN TRANSMIT MODE.K:} LA LA LA@ED} 9A LA@ED 9A DB A L]A@E9D 9Aҍҩ2ҩ(ҩҍҍҩҩ@(ҩxA   }XɿAA@L@L]A)`XHH ҍ@ LA@@hhh@HI B V` BIH V`@END 9Aҍҩ#}2ҩ(ҩҍҍҩҩ@@@ @ @x҅B 2 (ҩX@Q@ iB@ LA)@@ }@@LAA{B%xҭ@ @ X ^B`L@HIB V`X@@@h@BJ@EdD V` B V`}BHI V`f@ҭ@ @ X ^B`L@HIB V`X@@@h@BJ@EdD V` B V`@APRESS START FOR RECEIVEPRESS SELECT FOR TRANSMITNOW IN RECEIVE MODE.TRANSMIT MODE; "CONTROL-A" to RECEIVEPRESS OPTI}ON TO EXITTRANSMIT CONTROL-D FOR MENUTIMED OUT DURING BYTE TRANSFERK:TRANSMITTER HAS EXITED PROGRAM} Bө B B }@EDAA B B@ED B B@ErD B B@ED B B B A*` B "CH >Bh} BL@ BL!}VA A A B@EōD BL@ BLwAө B@E7D B8өө<`)`)@ӭ@@"}@ED BhABhL@@@@)@)m@@ӭ@)@@`@)ө@@@@@@E#}D BhhhL@)@iӭ@խ)@`HI B V` BIH V`ө@ELD B8өө<$}ө`HIBB4C V`BJ@ED V` B V`BHI V`@V`ө@ELD B8өө<Z; TALKP;; Nick Kennedy;; A program to send data between two; Atari 800 computers using the PIA's; (jo&}ystick ports).;; System Equates:PACTL: EQU $D302;CTLRW: EQU %00111100 ; to R/W portCTLDD: EQU %00111000 ; to write '}data; direction. (0=input; 1=output);PORTA: EQU $D300;; For STICK 0, bits 0-3 equal pins; 1-4. (8 is ground);; PIN(}S:;;; 1 2 3 4 5 ; View of jack on; 6 7 8 9 ; console.;; NOTES:;; Pin 1 is data.; Pin 2 is Transmitter status)}.; (DATA READY or DR) (0 = READY).; Pin 3 is Receiver status.; (RECEIVER READY or RR) (0 = READY).;; Initialization: Bef*}ore each byte; sent/received all out lines are ; made high. Transmitter makes sure; RR is high, then sets DATA lo. ; Rece+}iver watches for DR high AND; Data lo, then is freed to set RR; lo (ready). Transmitter is then; free to put data and set ,}DR lo (rdy);;CH: EQU $2FC ; Keyboard code hereCIOV: EQU $E456ICCOM: EQU $342ICBAL: EQU $344ICBAH: EQU $345IC-}BLL: EQU $348ICBLH: EQU $349ICAX1: EQU $34ARTCLOK: EQU $14BEEP: EQU $FDCONSOL: EQU $D01F; ORG $4000PLACE.}: DS 1TIMER: DS 1 ; My timeout timerFLAG: DS 1 ;DATA DS 1 ; Store/send byte hereBITCT: DS 1 ; Bit counter;; /} STRINGS:MODE: DB 'PRESS START FOR RECEIVE',$9BMODE2: DB 'PRESS SELECT FOR TRANSMIT',$9BMSG1: DB 'NOW IN RECEI0}VE MODE.',$9BMSG2: DB 'TRANSMIT MODE; "CONTROL-A" to RECEIVE',$9BMSG3: DB 'PRESS OPTION TO EXIT', $9BMSG5: DB 'TRA1}NSMIT CONTROL-D FOR MENU', $9BTOM: DB 'TIMED OUT DURING BYTE TRANSFER', $9BKYBD: DB 'K:', $9BMSG4: DB 'TRANSMITTER 2}HAS EXITED PROGRAM', $9B;;; INITIALIZE;INIT: LDA #125 ; Clear screen. JSR PUTBYTINIT1: LDA #$FF ;3} Trans. and Rcvr STA PORTA; Not ready LDA #$9B JSR PUTBYT LDA #$9B JSR PUTBYT 4} PRINTS MODE LDA #$9B JSR PUTBYT PRINTS MODE2 LDA #$9B JSR PUTBYT PRINTS MS5}G3 LDA #$9B JSR PUTBYT PRINTS MSG5 LDA #$9B JSR PUTBYT JSR OPENK;TORR: JS6}R WAIT ; Get button choice CMP #6 ; START BEQ GRINIT CMP #5 ; SELECT BEQ GTINIT ; Long branc7}h CMP #3 ; OPTION BNE TORR RTS ; Choice was exit;;; Transmit loop follows:;GTINIT: JSR TINIT ; S8}et up to XMTTRANS: JSR GETK ; get a byte PHA ; stash it JSR TLOOP ; send the byte PLA ; restore it9} CMP #'A'-$40 ; CONTROL-A? BEQ GRINIT ; Yes? Switch CMP #'D'-$40 ; CONTROL-D? BNE DONTQ ; Don:}'t quit LDA #125 ; Clean screen JSR PUTBYT JMP INIT1 ; EXIT to menuDONTQ: JSR PUTBYT ; No? Print it;} and JMP TRANS ; Get another.;; Receive loop follows:;GRINIT: JSR RINIT ; Set up to RCVRCV: JSR RLOOP ; Recei<}ve a byte CMP #'A'-$40 ; CTRL-A? BEQ GTINIT ; Yes? Switch! CMP #'D'-$40 ; CTRL-D BNE NQ ; Don=}'t quit LDA #$9B JSR PUTBYT PRINTS MSG4 ; XMTR has exited JMP INIT1 ; EXIT to menuNQ: JS>}R PUTBYT ; No? Print it! JMP RCV ; and get another.;;RINIT: LDA #$FF ; Not ready. STA PORTA LDA #?}$9B JSR PUTBYT PRINTS MSG1 LDA #LOW CTLDD ; Make PORTA STA PACTL ; be data direction @}LDA #%00000100 ; register. STA PORTA ; Made bit 2 input. LDA #LOW CTLRW ; Make PORTA STA PACTL ; be IA}/O port again RTS;;; Wait for console button routine:;WAIT: LDA CONSOL AND #7 ; 3 lo bits only. B} CMP #7 BEQ WAIT RTS;; This subroutine receives a byte:;RLOOP: LDA PORTA ; XMT initialized? ANDC} #3 ; Get bits 0 and 1 CMP #2 ; Data LO & DR HI? BNE RLOOP ; Keep checking LDA #7 ; Bit counter (0-7)D} STA BITCTRLP3: LDA #$FF - 4 ; clear bit 2 STA PORTA ; (set RR ready)RLP1: LDA BITCT ; We don't time ouE}t CMP #7 ; if waiting for the BEQ SEVEN ; first bit. LDA RTCLOK ; But check on CMP TIMER ; laF}ter bits BNE NOTO ; No timeoutGOON: PRINTS TOM ; timeout message PLA ; Clear return address PLA ; G}from stack. JMP INIT1 ; Goto menuSEVEN: LDA RTCLOK ; Set up timer for STA TIMER ; one to two jiff's H} INC TIMER INC TIMERNOTO: LDA PORTA ; check DR AND #2 ; Mask all but DR line BNE RLP1 ; DATA not rI}eady ASL DATA LDA PORTA ; Read data AND #1 ; Mask non-data CLC ADC DATA ; add it to DJ}ATA STA DATA LDA #$0F STA PORTA ; RR not readyRLP2: LDA TIMER CMP RTCLOK BEQ GOON K}; Go on. (exit) LDA PORTA ; Check for DR not. AND #2 BEQ RLP2 ; DR not set DEC BITCT ; Next L}bit BPL RLP3 ; Do 8 bits LDA DATA ; Take it home RTS;;; This subroutine sends a byte out; over thM}e PIA line:;TLOOP: STA DATA ; Store the byteTLP4: LDA PORTA ; Check rcvr status AND #4 BEQ TLP4 ; Loop N}if ready. LDA #2 ; Set DR=1, DATA=0 STA PORTA LDA #7 ; Bit counter STA BITCT ; initializeO} LDA RTCLOK STA TIMER INC TIMER INC TIMERTLP1: LDA RTCLOK ; Check for time CMP TIMEP}R ;waiting for RR. BNE TLP5 ; No timeoutTGOON: PRINTS TOM ; timeout message PLA ; Clear return address Q} PLA ; from stack. PLA ; Also clear data byte. JMP INIT1 ; Goto menuTLP5: LDA PORTA ; Receiver ready? R} AND #4 ; Bit 2 is RR line BNE TLP1 ; Not ready ASL DATA ; Knock left bit LDA #0 ; Into carry S} ADC #0 ; add carry to 0 STA PORTA ; Put data/DR readyTLP2: LDA TIMER CMP RTCLOK BEQ TGOON ;T} Timed out LDA PORTA ; RCVR accept data? AND #4 ; RR line set? BEQ TLP2 ; Not yet LDA #$0F ; U}Data not ready. STA PORTA ; Tell RCVR DEC BITCT ; Count the bit BPL TLP1 ; 8 bits sent? RTS;V} Subroutine to put record to E:; (Have ICBAH/L loaded before entry);PUTREC: LDA #$80 STA ICBLL LDX #0 W} STX ICBLH LDA #9 ; Put record. STA ICCOM JSR CIOV RTS;; Subroutine to put byte to E:X}; (Have byte in accumulator on entry);PUTBYT: LDX #$B ; Put byte STX ICCOM LDX #0 STX ICBLH Y} STX ICBLL JSR CIOV RTS;; TRANSMIT section follows:;TINIT: LDA #$0F ; Not ready/Not init STA POZ}RTA PRINTS MSG2 LDA #LOW CTLDD STA PACTL ; Data direction LDA #%00000011 STA PORTA [} LDA #LOW CTLRW STA PACTL ; Data register LDA #$FF STA CH ; Clear keyboard RTS;; A ro\}utine to get one byte from ; IOCB #0 (assumed to be E:):;GETBYT: LDX #0 STX ICBLL STX ICBLH LDA #7]} STA ICCOM ; Get bytes. JSR CIOV RTS;; OPEN KEYBOARD, IOCB #1;OPENK: LDX #$10 LDA #3 ^} STA ICCOM,X LDA #4 ; Read STA ICAX1,X LDA #HIGH KYBD STA ICBAH,X LDA #LOW KYBD _} STA ICBAL,X JSR CIOV RTSCLOSK: LDX #$10 ; Close it. LDA #$C STA ICCOM,X JSR `}CIOV RTS;GETK: LDX #$10 ; Get one byte from LDA #$7 ; keyboard. STA ICCOM,X LDA #0 a} STA ICBLL,X STA ICBLH,X JSR CIOV RTS; END INIT; TA ICCOM,X LDA #0 _; TALK;; Nick Kennedy;; 10-29-86;; An experiment with the serial bus; which will send charac}cters between; two Atari 800 computers using the ; serial port, but not using SIO.;; System Equates:B600LO EQU $CC ; ford} 600 baudB600HI EQU $05SERIN: EQU $D20D ; Data in register.SEROUT: EQU $D20D ; Outgoing data hereIRQST EQU $D20E ; IRQ e}interrupt status. 1 = Interrupt, 0 = No interrupt. ; Bit 5 is input ready.;IRQEN EQU $D20E ; IRQ enable. 0=disable, 1=enaf}ble. Bit 5 is serial input.;POKMSK EQU $10 ; Shadow for above.SKCTL: EQU $D20FSSKCTL: EQU $232 ; Shadow for aboveAUDCTLg} EQU $D208VSERIN EQU $20A; Serial input vectorVSEROR: EQU $20C ; Serial out ready.AUDF1: EQU $D200AUDF2: EQU $D202AUh}DF3: EQU $D204AUDF4: EQU $D206AUDC1: EQU $D201AUDC2: EQU $D203AUDC3: EQU $D205AUDC4: EQU $D207PACTL: EQU $D302 ;i} Bit 3=0 for motor; on.CH: EQU $2FC ; Keyboard code hereCIOV: EQU $E456ICCOM: EQU $342ICBAL: Ej}QU $344ICBAH: EQU $345ICBLL: EQU $348ICBLH: EQU $349ICAX1: EQU $34ARTCLOK: EQU $14BEEP: EQU $FDCONSOL: EQU $D01Fk}; ORG $4000PLACE: DS 1TIMER: DS 1 ; My timeout timerFLAG: DS 1 ;TVECT: DS 2 ; Place for VSERORSWITCH: DS l}1 ; Exch. trans/receiveSWIT1: DS 1 ; Same.;; STRINGS:MODE: DB 'PRESS START FOR RECEIVE',$9BMODE2: DB 'PRm}ESS SELECT FOR TRANSMIT',$9BMSG1: DB 'NOW IN RECEIVE MODE.',$9BMSG2: DB 'NOW IN TRANSMIT MODE.',$9BKYBD: DB 'K:';;n}; INITIALIZE;INIT: LDA #125 JSR PUTBYT LDA #$9B JSR PUTBYT LDA #$9B Jo}SR PUTBYT PRINTS MODE LDA #$9B JSR PUTBYT PRINTS MODE2 JSR OPENK;TORR: JSR WAIT ;p} Get button choice CMP #6 ; START BEQ RINIT CMP #5 ; SELECT BEQ GTINIT ; Long branch q} BNE TORRGTINIT: JMP TINIT;; INITIALIZE POKEY; de re Atari says do this on; page 7-2:;RINIT: PRINTS MSG1 r} LDA #0 STA AUDCTL STA SKCTL ; Init. POKEY LDA #$13 STA SSKCTL STA SKCTL s} LDA #$28 ; 1.79 Mhz into 3 STA AUDCTL;and 3 into 4. LDA #$A0; Turn off sound. STA AUDC3 STt}A AUDC1 STA AUDC2 LDA #$A8 ; Let's hear it. STA AUDC4 LDA #$FF ; Don't switch flag STu}A SWITCH;; Set baud rate to 600:; LDA #B600LO STA AUDF3 LDA #B600HI STA AUDF4;; Set tv}he serial input IRQ vector to; my service routine:; SEI LDA #HIGH RECV STA VSERIN+1 LDA #LOw}W RECV STA VSERIN LDA #%00100000 ORA POKMSK STA POKMSK STA IRQEN CLI;; The x}program idles here while waiting for a SERIN interrupt:;TIME: LDA CH ; CTRL-A PRESSED? CMP #$3F + $80 ; CTRL-A y} BEQ GOT LDA SWITCH ; CTRL-A RECEIVED? BEQ GOT ; Go to transmit JMP TIME GOT: JMP TINIT ;;z} Wait for console button routine:;WAIT: LDA CONSOL AND #7 ; 3 lo bits only. CMP #7 BEQ WAIT {} RTS;; The interrupt service routine:;RECV: CLI TXA ; Preserve X during PHA ; interrupt. TYA |}; And Y too. PHA LDA SERIN; Get byte from bus. STA PLACE JSR PUTBYT ; Put to screen L}}DA PLACE CMP #1 ; CONTROL-A BNE NOFLG LDA #0 STA SWITCHNOFLG: PLA ; Restore registers: ~} TAY PLA TAX PLA RTI;; Subroutine to put record to E:; (Have ICBAH/L loaded before entr}y);PUTREC: LDA #$80 STA ICBLL LDX #0 STX ICBLH LDA #9 ; Put record. STA ICCOM } JSR CIOV RTS;; Subroutine to put byte to E:; (Have byte in accumulator on entry);PUTBYT: LDX #$B ; Put byte } STX ICCOM LDX #0 STX ICBLH STX ICBLL JSR CIOV RTS;; TRANSMIT section follow}s:;TINIT: PRINTS MSG2 LDA #0 STA AUDCTL STA SKCTL ; init POKEY LDA #$23 ; KYBD scan and } STA SSKCTL ; debounce on and STA SKCTL; bit 5 mode. LDA #$28 ; 1.79Mhz; 3 into 4 STA AUDCTL } LDA #$A0 STA AUDC1 STA AUDC2 STA AUDC3 LDA #$A8 ; Let's hear it! STA AUDC4 } LDA #$FF; Enable one byte out STA FLAG STA CH ; Clear K:;; SWITCH = 0, CTRL-A has been pressed; SWIT1 =} 0, it's sent, now switch.; STA SWITCH ; No switch STA SWIT1 LDA VSEROR ; Save vector to STA} TVECT ; be restored. LDA VSEROR+1 STA TVECT+1;; Enable interrupt:; SEI LDA #%000100}00 ORA POKMSK STA IRQEN STA POKMSK;; Point interrupt vector to my routine; LDA #HIGH TINT} STA VSEROR+1 LDA #LOW TINT STA VSEROR;; Set baud to 600:; LDA #B600LO STA AUDF3 } LDA #B600HI STA AUDF4;; Enable processor IRQ's; CLI;; Main program follows:;TLOOP: LDA SWIT1 } BEQ GOR ; Go to receive. LDA SWITCH ; Loop till sent. BEQ TLOOP JSR GETK STA PLACE } JSR PUTBYTTLOOP1: LDA CONSOL AND #%00000100 ; OPTION BEQ THOME ; Back to DOS LDA FLAG ; Has inte}rrupt BEQ TLOOP1 ; occured? LDA PLACE STA SEROUT; Yes, send byte. CMP #1 ; CTRL-A BNE} NOSW LDA #0 STA SWITCHNOSW: LDA #0 STA FLAG ; Need another one. JMP TLOOPTHOME: LDA #%1}1101111 ; Disable IRQ AND POKMSK SEI STA POKMSK STA IRQEN LDA TVECT ; Restore IRQ } STA VSEROR ; vector. LDA TVECT+1 STA VSEROR+1 CLI LDA #$A0 STA AUDC4 JSR} CLOSK RTS;GOR: JMP RINIT ; Switch to receive;;; A routine to get one byte from ; IOCB #0 (assumed to be E:)}:;GETBYT: LDX #0 STX ICBLL STX ICBLH LDA #7 STA ICCOM ; Get bytes. JSR CIOV } RTS;; Transmit interrupt routine:;TINT: CLI LDA #$FF STA FLAG LDA SWITCH BNE NO}SW1 LDA #0 ; Last byte has just STA SWIT1 ; gone - switch.NOSW1: PLA RTI;; OPEN KEYBOARD, IOCB #1};OPENK: LDX #$10 LDA #3 STA ICCOM,X LDA #4 ; Read STA ICAX1,X LDA #HIGH KYBD } STA ICBAH,X LDA #LOW KYBD STA ICBAL,X JSR CIOV RTSCLOSK: LDX #$10 ; Close it. LD}A #$C STA ICCOM,X JSR CIOV RTS;GETK: LDX #$10 ; Get one byte from LDA #$7 ; keyboard. } STA ICCOM,X LDA #0 STA ICBLL,X STA ICBLH,X JSR CIOV RTS; END INIT; } TA ICCOM,X LDA #0 STA ICBLL,X STA ICBLH,X JSR CIOV RTS; END INIT; ; TRANSMIT;; A program to send DOS binary load; files from one ATARI 800 to another; using the JOYSTICK port.;}; Nick Kennedy;; 12/22/86;; System Equates:;CH: EQU $2FC ; Keyboard code hereCIOV: EQU $E456ICC}OM: EQU $342ICSTA: EQU $343ICBAL: EQU $344ICBAH: EQU $345ICBLL: EQU $348ICBLH: EQU $349ICAX1: EQU $34ARTCLOK: E}QU $14BEEP: EQU $FDCONSOL: EQU $D01F; ORG $4000 JMP INITLOADL: DS 1LOADH: DS 1ENDL: DS 1ENDH: }DS 1PLACE: DS 1EOFF: DS 1 ; EOF FlagFLAG: DS 1 ;;; STRINGS:SEGMES: DB 'SEGMENT SENT/READY RCVD',$9BCIO}E: DB 'ERROR IN GETFB Y=$605',$9BKYBD: DB 'K:'PMPT1: DB 'Awaiting filespec from receiver:',$9BBSTMSG: DB 'Bad status }on opening file.', $9BNTLF: DB 'Header error - not a load file.', $9B;;; INITIALIZE;INIT: LDA #$9B } JSR PUTBYT LDA #$9B JSR PUTBYT PRINTS PMPT1 LDA #$9B JSR PUTBYT;; Get the files}pec from the other 800; PROC JSR RINIT LDY #0:GET1: JSR RLOOP ; Get filespec byte STA RECO}RD,Y ; store it INY CMP #$9B ; EOR? BNE :GET1 ; No.;; Put the filespec to the screen; LDA }#LOW RECORD STA ICBAL LDA #HIGH RECORD STA ICBAH JSR PUTREC JSR TINIT ; To send statu}s.;; Now, open the file for input:; Use IOCB #1; LDX #$10 LDA #$C STA ICCOM,X ; First close it } JSR CIOV LDA #3 STA ICCOM,X LDA #HIGH RECORD STA ICBAH,X LDA #LOW RECORD } STA ICBAL,X LDA #4 STA ICAX1,X JSR CIOV ; Open it. BPL :NOERR PRINTS BSTMSG ; Bad }open stat LDA #0 JSR TLOOP ; Send badstat JSR INIT ; Start over:NOERR: LDA #$FF ; Send goodstatus } JSR TLOOP; JSR GETFB ; Get file byte. PHA ; Stash byte JSR TLOOP ; Send it PLA } CMP #$FF BNE :BADHD JSR GETFB PHA JSR TLOOP PLA CMP #$FF BEQ :GOODHD}:BADHD: PRINTS NTLF ; Not load file JMP INIT;; Get/Send Load/End addresses:;:GOODHD JSR GETFB:GDHD1: STA LOADL} JSR TLOOP JSR GETFB:GDHD2: STA LOADH JSR TLOOP JSR GETFB STA ENDL JSR TLOOP} JSR GETFB STA ENDH JSR TLOOP;; Now send the file bytes:;:SLOOP: JSR GETFB STY EOFF ; EOF }Flag JSR TLOOP;; Now, is LOAD=END?; LDA LOADH CMP ENDH BNE :NTDUN LDA LOADL } CMP ENDL BNE :NTDUN JMP :SEGDUN ; Load = End.:NTDUN: INC LOADL BNE :NOMO INC LOADH:NOMO: } JMP :SLOOP ; Get/Send next.;; Receive ready code from RECEIVER:;:SEGDUN JSR RINIT JSR RLOOP ; Any byte received} PRINTS SEGMES ;************** JSR TINIT ; means ready JSR JIF2 ; Waste jiffy or 2;; Now, are we at }the EOF?; LDA EOFF ; Status byte CMP #3 ; 3 = impending EOF. BNE :NOEOF LDA #0 ; Indicates E}OF JSR TLOOP ; Tell receiver. LDA #$C ; Close file. LDX #$10 STA ICCOM,X JSR CIOV } RTS ; Back to DOS;; Now, next two bytes may or may not; be $FFFF header (optional).;:NOEOF: LDA #$FF ; =Not EOF sta}tus JSR TLOOP JSR GETFB CMP #$FF BNE :NOHDR JSR GETFB CMP #$FF BNE :O}HNO JSR GETFB ; Header was $FFFF:NOHDR: JMP :GDHD1:OHNO: PHA ; Stash 2nd byte LDA #$FF ; 1st was $FF } STA LOADL JSR TLOOP PLA JMP :GDHD2 ; Whew!;EPROC;; GET FILE BYTE:;GETFB: LDX #$10 }LDA #0 STA ICBLL,X STA ICBLH,X LDA #7 STA ICCOM,X JSR CIOV BMI ERROR;********}*********** RTSERROR: STY $605 PRINTS CIOE ;**************** PLA ;************ PLA ;*******}***** RTS; JIF2: Stall 2 jiffies waiting to; be sure the other guy gets into; receive mode.;JIF2: LDA RTCLOK } STA PLACE INC PLACE INC PLACEJIF2A: LDA RTCLOK CMP PLACE BNE JIF2A RTS;JIF}10: LDA RTCLOK ADC #$A STA PLACEJIF10A: LDA RTCLOK CMP PLACE BNE JIF10A RTS;; Sub}routine to put record to E:; (Have ICBAH/L loaded before entry); (Use MACRO PRINTS);PUTREC: LDA #$80 STA ICBLL } LDX #0 STX ICBLH LDA #9 ; Put record. STA ICCOM JSR CIOV RTS;; Subroutine to }get a record from #0; User set ICBAL/H.;GETREC: LDX #0 LDA #5 STA ICCOM LDA #$80 STA ICBLL} STX ICBLH JSR CIOV RTS;;; Subroutine to put byte to E:; (Have byte in accumulator on entry);PU}TBYT: LDX #$B ; Put byte STX ICCOM LDX #0 STX ICBLH STX ICBLL JSR CIOV RTS;};; A routine to get one byte from ; IOCB #0 (assumed to be E:):;GETBYT: LDX #0 STX ICBLL STX ICBLH } LDA #7 STA ICCOM ; Get bytes. JSR CIOV RTS;;; The following is the transmit/; receive portion o}f TALKP.;; System Equates:PACTL: EQU $D302;CTLRW: EQU %00111100 ; to R/W portCTLDD: EQU %00111000 ; to write data; }direction. (0=input; 1=output);PORTA: EQU $D300;; For STICK 0, bits 0-3 equal pins; 1-4. (8 is ground);; PINS:;;}; 1 2 3 4 5 ; View of jack on; 6 7 8 9 ; console.;; NOTES:;; Pin 1 is data.; Pin 2 is Transmitter status.; (DA}TA READY or DR) (0 = READY).; Pin 3 is Receiver status.; (RECEIVER READY or RR) (0 = READY).;; Initialization: Before eac}h byte; sent/received all out lines are ; made high. Transmitter makes sure; RR is high, then sets DATA lo. ; Receiver wa}tches for DR high AND; Data lo, then is freed to set RR; lo (ready). Transmitter is then; free to put data and set DR lo (}rdy);;;TIMER: DS 1 ; My timeout timerDATA DS 1 ; Store/send byte hereBITCT: DS 1 ; Bit counter;; STRI}NGS:TOM: DB 'TIMED OUT DURING BYTE TRANSFER', $9B;; INITIALIZE;;RINIT: LDA #$FF ; Not ready. STA} PORTA LDA #$9B JSR PUTBYT LDA #LOW CTLDD ; Make PORTA STA PACTL ; be data direction }LDA #%00000100 ; register. STA PORTA ; Made bit 2 input. LDA #LOW CTLRW ; Make PORTA STA PACTL ; be I}/O port again RTS;; This subroutine receives a byte:;RLOOP: LDA PORTA ; XMT initialized? AND #3 ; Get bi}ts 0 and 1 CMP #2 ; Data LO & DR HI? BNE RLOOP ; Keep checking LDA #7 ; Bit counter (0-7) STA} BITCTRLP3: LDA #$FF - 4 ; clear bit 2 STA PORTA ; (set RR ready)RLP1: LDA BITCT ; We don't time out CM}P #7 ; if waiting for the BEQ SEVEN ; first bit. LDA RTCLOK ; But check on CMP TIMER ; later bits } BNE NOTO ; No timeoutGOON: PRINTS TOM ; timeout message PLA ; Clear return address PLA ; from stack.} JMP INIT ; Goto menuSEVEN: LDA RTCLOK ; Set up timer for STA TIMER ; one to two jiff's INC TIMER } INC TIMERNOTO: LDA PORTA ; check DR AND #2 ; Mask all but DR line BNE RLP1 ; DATA not ready }ASL DATA LDA PORTA ; Read data AND #1 ; Mask non-data CLC ADC DATA ; add it to DATA S}TA DATA LDA #$0F STA PORTA ; RR not readyRLP2: LDA TIMER CMP RTCLOK BEQ GOON ; Go on. (ex}it) LDA PORTA ; Check for DR not. AND #2 BEQ RLP2 ; DR not set DEC BITCT ; Next bit B}PL RLP3 ; Do 8 bits LDA DATA ; Take it home RTS;;; This subroutine sends a byte out; over the PIA line:;}TLOOP: STA DATA ; Store the byteTLP4: LDA PORTA ; Check rcvr status AND #4 BEQ TLP4 ; Loop if ready. } LDA #2 ; Set DR=1, DATA=0 STA PORTA LDA #7 ; Bit counter STA BITCT ; initialize LDA R}TCLOK STA TIMER INC TIMER INC TIMERTLP1: LDA RTCLOK ; Check for time CMP TIMER ;waiting fo}r RR. BNE TLP5 ; No timeoutTGOON: PRINTS TOM ; timeout message PLA ; Clear return address PLA ; fro}m stack. PLA ; Also clear data byte. JMP INIT ; Goto menuTLP5: LDA PORTA ; Receiver ready? AND #4 }; Bit 2 is RR line BNE TLP1 ; Not ready ASL DATA ; Knock left bit LDA #0 ; Into carry ADC #0 }; add carry to 0 STA PORTA ; Put data/DR readyTLP2: LDA TIMER CMP RTCLOK BEQ TGOON ; Timed out } LDA PORTA ; RCVR accept data? AND #4 ; RR line set? BEQ TLP2 ; Not yet LDA #$0F ; Data not ready}. STA PORTA ; Tell RCVR DEC BITCT ; Count the bit BPL TLP1 ; 8 bits sent? RTS;; TRANSMIT s}ection follows:;TINIT: LDA #$0F ; Not ready/Not init STA PORTA LDA #LOW CTLDD STA PACTL ; Data dir}ection LDA #%00000011 STA PORTA LDA #LOW CTLRW STA PACTL ; Data register RTS;; REC}ORD is where I input my filename; It takes no file space cause it's ; at the end;RECORD: END INITer RTS;; RECf@@L@@ ASEGMENT SENT/READY RCVDERROR IN GETFB Y=$605K:Awaiting filespec from receiver:Bad status on opening file.Hea}der error - not a load file. B B@E?D B B(ҩ(ҩҩҍҍҩxC 7 C ? CJX@} @ OB rBg ABCɛgDCE B B B VBCEgDJ V@E`D B B @ B 'BH Bh 'BH Bh}@E|D BL@ 'B@ B 'B@ B 'B@ B 'B@ B 'B@ B@@ @@LA@@LA OB rB@ED B B B@} B B V` B BC'B 'B 'BLAH@ BhLAHIB V0`@E'D Bhh` B@ҩ2x )}X`, @0 @ `@@@@`i @@`HI B V`BHI V` BIH V` Bҍ @#2}x)߅X`Hi@CfC@, @0h ҩ @@xX`HIB V`X @h@X @h@x@%hX@ }B V`@X`Hi@CfC@, @0h ҩ @@xX`HIB V`X @h@X @h@x@%hX@ ; TRANSMIT;; A program to send DOS binary load; files from one ATARI 800 to another; using the SERIAL port. For }ground, ; connect the pins # 6 and/or 4 ; together (via cord/connector). For; data, connect pin 3 on computer A ; 5 on co}mputer B, and vice versa.; 4 conductor phone cord is ok here.;;; Nick Kennedy;; 11/21/86;; System Equ}ates:;B600LO EQU $CC ; for 600 baudB600HI EQU $05B192LO EQU $28 ; for 19.2K baudB192HI EQU $0IRQST: EQU $D20ESERIN: }EQU $D20D ; Data in register.SEROUT: EQU $D20D ; Outgoing data hereIRQEN EQU $D20E ; IRQ enable. 0=disable, 1=enable. Bit }5 is serial input.;POKMSK EQU $10 ; Shadow for above.SKCTL: EQU $D20FSSKCTL: EQU $232 ; Shadow for aboveAUDCTL EQU $D2}08VSERIN EQU $20A; Serial input vectorVSEROR: EQU $20C ; Serial out ready.VSEROC: EQU $20E ; Transmission cpt.AUDF1: EQ}U $D200AUDF2: EQU $D202AUDF3: EQU $D204AUDF4: EQU $D206AUDC1: EQU $D201AUDC2: EQU $D203AUDC3: EQU $D205AUDC4: E}QU $D207CH: EQU $2FC ; Keyboard code hereCIOV: EQU $E456ICCOM: EQU $342ICSTA: EQU $343ICBAL: EQU $344ICBAH: E}QU $345ICBLL: EQU $348ICBLH: EQU $349ICAX1: EQU $34ARTCLOK: EQU $14BEEP: EQU $FDCONSOL: EQU $D01F; ORG $4}000 JMP INITLOADL: DS 1LOADH: DS 1ENDL: DS 1ENDH: DS 1PLACE: DS 1EOFF: DS 1 ; EOF FlagFLAG: DS 1 ;}TVECT: DS 2 ; Place for VSERORSIRF: DS 1 ; Serial input rdy flagSORF: DS 1 ; Output ready flagTCF: DS 1 ; Transmi}ssion cpt flag;; STRINGS:SEGMES: DB 'SEGMENT SENT/READY RCVD',$9BCIOE: DB 'ERROR IN GETFB Y=$605',$9BKYBD: } DB 'K:'PMPT1: DB 'Awaiting filespec from receiver:',$9BBSTMSG: DB 'Bad status on opening file.', $9BNTLF: DB 'Header }error - not a load file.', $9B;;; INITIALIZE;INIT: LDA #$9B JSR PUTBYT LDA #$9B JS}R PUTBYT PRINTS PMPT1 LDA #$9B JSR PUTBYT;; Set AUDCTL for 1.79 Mhz. into ch 3; and ch 3 into ch 4}:; LDA #%00101000 STA AUDCTL;; Set baud rate to 600:; LDA #B192LO STA AUDF3 LD}A #B192HI STA AUDF4;; LDA #$A0 ; Off Sound 1,2,3 STA AUDC1 STA AUDC2 STA AUDC3 } LDA #$A8 ; On, channel 4 STA AUDC4;; Set the interrupt vectors:; SEI LDA #HIGH TINT ST}A VSEROR+1 LDA #LOW TINT STA VSEROR LDA #HIGH RINT STA VSERIN+1 LDA #LOW RINT } STA VSERIN LDA #HIGH TCINT STA VSEROC+1 LDA #LOW TCINT STA VSEROC CLI;; Initialize} transmission (not) done; flag & input ready flag.; LDA #0 ; Transmission is cpt. STA TCF LDA #$FF }; Input not ready. STA SIRF;; Get the filespec from the other 800; PROC JSR RINIT LDY #0:}GET1: JSR RLOOP ; Get filespec byte STA RECORD,Y ; store it INY CMP #$9B ; EOR? BNE :GET1 ; }No.;; Put the filespec to the screen; LDA #LOW RECORD STA ICBAL LDA #HIGH RECORD STA ICBAH} JSR PUTREC JSR TINIT ; To send status.;; Now, open the file for input:; Use IOCB #1; LDX #$10 } LDA #$C STA ICCOM,X ; First close it JSR CIOV LDA #3 STA ICCOM,X LDA #HIGH REC}ORD STA ICBAH,X LDA #LOW RECORD STA ICBAL,X LDA #4 STA ICAX1,X JSR CIOV ; Ope }n it. BPL :NOERR PRINTS BSTMSG ; Bad open stat LDA #0 JSR TLOOP ; Send badstat JSR IN }IT ; Start over:NOERR: LDA #$FF ; Send goodstatus JSR TLOOP; JSR GETFB ; Get file byte. PHA ; Stash } byte JSR TLOOP ; Send it PLA CMP #$FF BNE :BADHD JSR GETFB PHA JSR T }LOOP PLA CMP #$FF BEQ :GOODHD:BADHD: PRINTS NTLF ; Not load file JMP INIT;; Get/Send Load/ }End addresses:;:GOODHD JSR GETFB:GDHD1: STA LOADL JSR TLOOP JSR GETFB:GDHD2: STA LOADH JSR TLOOP} JSR GETFB STA ENDL JSR TLOOP JSR GETFB STA ENDH JSR TLOOP;; Now send the fi}le bytes:;:SLOOP: JSR GETFB STY EOFF ; EOF Flag JSR TLOOP;; Now, is LOAD=END?; LDA LOADH } CMP ENDH BNE :NTDUN LDA LOADL CMP ENDL BNE :NTDUN JMP :SEGDUN ; Load = End.:NTDUN: }INC LOADL BNE :NOMO INC LOADH:NOMO: JMP :SLOOP ; Get/Send next.;; Receive ready code from RECEIVER:;:SE}GDUN JSR RINIT JSR RLOOP ; Any byte received PRINTS SEGMES ;************** JSR TINIT ; means ready } JSR JIF2 ; Waste jiffy or 2;; Now, are we at the EOF?; LDA EOFF ; Status byte CMP #3 ; 3 = impending} EOF. BNE :NOEOF LDA #0 ; Indicates EOF JSR TLOOP ; Tell receiver. LDA #$C ; Close file. } LDX #$10 STA ICCOM,X JSR CIOV RTS ; Back to DOS;; Now, next two bytes may or may not; be $FFFF} header (optional).;:NOEOF: LDA #$FF ; =Not EOF status JSR TLOOP JSR GETFB CMP #$FF BNE :NO}HDR JSR GETFB CMP #$FF BNE :OHNO JSR GETFB ; Header was $FFFF:NOHDR: JMP :GDHD1:OHNO: PHA }; Stash 2nd byte LDA #$FF ; 1st was $FF STA LOADL JSR TLOOP PLA JMP :GDHD2 ; Whew!;}EPROC;; GET FILE BYTE:;GETFB: LDX #$10 LDA #0 STA ICBLL,X STA ICBLH,X LDA #7 ST}A ICCOM,X JSR CIOV BMI ERROR;******************* RTSERROR: STY $605 PRINTS CIOE ;**********}****** PLA ;************ PLA ;************ RTSRINIT: JSR JIF2 ;************** LDA TCF ; Tra}nsmission cpt? BNE RINIT LDA #0 STA SKCTL ; Init. POKEY LDA #$13 STA SSKCTL S}TA SKCTL ;; Set the serial input IRQ enable ; bits for input:; SEI LDA #%00100000 ORA POKMSK ; En}able input AND #%11100111;Disable output STA POKMSK ; and trans. cpt STA IRQEN CLI RT}S;; The program idles here while waiting for a SERIN interrupt:;RLOOP: BIT SIRF ; Serial in ready? BMI RLOOP ; N }o LDA #$FF STA SIRF LDA SERIN ; Yes, read byte. RTS;; JIF2: Stall 2 jiffies waiting to; be!} sure the other guy gets into; receive mode.;JIF2: LDA RTCLOK STA PLACE INC PLACE INC PLACEJIF2"}A: LDA RTCLOK CMP PLACE BNE JIF2A RTS;JIF10: LDA RTCLOK ADC #$A STA PLACEJIF10A:#} LDA RTCLOK CMP PLACE BNE JIF10A RTS;; Subroutine to put record to E:; (Have ICBAH/L loaded before$} entry); (Use MACRO PRINTS);PUTREC: LDA #$80 STA ICBLL LDX #0 STX ICBLH LDA #9 ; Put recor%}d. STA ICCOM JSR CIOV RTS;; Subroutine to get a record from #0; User set ICBAL/H.;GETREC: LDX #0&} LDA #5 STA ICCOM LDA #$80 STA ICBLL STX ICBLH JSR CIOV RTS;;; Sub'}routine to put byte to E:; (Have byte in accumulator on entry);PUTBYT: LDX #$B ; Put byte STX ICCOM LDX #0(} STX ICBLH STX ICBLL JSR CIOV RTS;; TRANSMIT section follows:;TINIT: JSR JIF10 )}LDA #0 STA SKCTL ; init POKEY STA SORF ; Output ready flag LDA #$23 ; KYBD scan and STA SSKCT*}L ; debounce on and STA SKCTL; bit 5 mode.;; Enable interrupts:; SEI LDA #%00010000; Set rea+}dy on ORA POKMSK AND #%11011111 ; Receive off. STA POKMSK STA IRQEN;; Enable processor IRQ',}s; CLI RTS;; Main transmit loop follows:;TLOOP: PHA LDA RTCLOK ADC #3 STA PLACE-}TLP2: LDA RTCLOK CMP PLACE BEQ SNDIT BIT SORF ; Ser. out ready? BMI TLP2 ; No.SNDIT: PLA.} STA SEROUT; Yes, send byte. LDA #$FF ; Not rdy flag. STA SORF STA TCF ; Trans. not cpt. /} SEI ; Enable trans. cpt. IRQ LDA #%00001000 ORA POKMSK STA POKMSK STA IRQEN CLI 0} RTS;; A routine to get one byte from ; IOCB #0 (assumed to be E:):;GETBYT: LDX #0 STX ICBLL STX I1}CBLH LDA #7 STA ICCOM ; Get bytes. JSR CIOV RTS;; Transmit interrupt routine:;TINT:2} CLI LDA #0 STA SORF ; Output rdy flag PLA RTI;; Receive interrupt routine:;RINT: CL3}I LDA #0 STA SIRF STA CONSOL;***************** PLA RTI;; Output transmission cpt ro4}utine:;TCINT: SEI ; in case not already LDA #0 STA TCF LDA #%11110111 AND POKMSK ; Trans c5}pt. off STA POKMSK STA IRQEN PLA CLI RTI;CLOSK: LDX #$10 ; Close it. LDA #6}$C STA ICCOM,X JSR CIOV RTS;; RECORD is where I input my filename; It takes no file space cause it7}'s ; at the end;RECORD: END INITIOV RTS;; RECORD is where I input my filename; It takes no file space cause it$