From 610f7dd83f5c58cc523d6182b353d4a62fe1856c Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 3 Sep 2020 14:24:39 -0400 Subject: [PATCH] disk_test: debugging a possible but in AppleWin --- disk_bug/Makefile | 41 +++++ disk_bug/disk_test1.dsk | Bin 0 -> 143360 bytes disk_bug/disk_test2.dsk | Bin 0 -> 143360 bytes disk_bug/extra_empty.dsk | Bin 0 -> 143360 bytes disk_bug/qboot_sector.s | 235 +++++++++++++++++++++++++ disk_bug/qboot_stage2.s | 365 +++++++++++++++++++++++++++++++++++++++ disk_bug/test.s | 276 +++++++++++++++++++++++++++++ 7 files changed, 917 insertions(+) create mode 100644 disk_bug/Makefile create mode 100644 disk_bug/disk_test1.dsk create mode 100644 disk_bug/disk_test2.dsk create mode 100644 disk_bug/extra_empty.dsk create mode 100644 disk_bug/qboot_sector.s create mode 100644 disk_bug/qboot_stage2.s create mode 100644 disk_bug/test.s diff --git a/disk_bug/Makefile b/disk_bug/Makefile new file mode 100644 index 00000000..c6d187f7 --- /dev/null +++ b/disk_bug/Makefile @@ -0,0 +1,41 @@ +include ../Makefile.inc + +DOS33 = ../dos33fs-utils/dos33 +DOS33_RAW = ../dos33fs-utils/dos33_raw +PNG_TO_40x96 = ../gr-utils/png_to_40x96 +PNG_TO_40x48D = ../gr-utils/png_to_40x48d +PNG2RLE = ../gr-utils/png2rle +B2D = ../bmp2dhr/b2d + +all: disk_test1.dsk + +disk_test1.dsk: QBOOT TEST + cp extra_empty.dsk disk_test1.dsk + $(DOS33_RAW) disk_test1.dsk 0 0 QBOOT 0 1 + $(DOS33_RAW) disk_test1.dsk 0 2 QBOOT 1 1 + $(DOS33_RAW) disk_test1.dsk 0 4 QBOOT 2 1 + $(DOS33_RAW) disk_test1.dsk 1 0 TEST 0 13 + + +### + +TEST: test.o + ld65 -o TEST test.o -C ../linker_scripts/apple2_1200.inc + +test.o: test.s + ca65 -o test.o test.s -l test.lst + +### + +QBOOT: qboot_sector.o + ld65 -o QBOOT qboot_sector.o -C ../linker_scripts/apple2_800.inc + +qboot_sector.o: qboot_sector.s qboot_stage2.s + ca65 -o qboot_sector.o qboot_sector.s -l qboot_sector.lst + +#### + +clean: + rm -f *~ *.o *.lst QBOOT TEST + + diff --git a/disk_bug/disk_test1.dsk b/disk_bug/disk_test1.dsk new file mode 100644 index 0000000000000000000000000000000000000000..88b18f1e3d4ec75fee091d9b50beb663a54af5e9 GIT binary patch literal 143360 zcmeI$Z)n_i9S88=UD`E?&HDTHO6ddt{MfqMgcj5Iz@ik%nzXsDbj76GiVX5dZJ+2f zK|uwp#B6sId@w^>2?t6pG#Y%QXhXUow84eDfe!>9$c7^m+np12rA^M?brjQX(3N=) zuJ`(q{C@ZS-tYIm&*$~y_>yFf%$(ZtgHK=GT6^@(1CvM6(X}{I{_@E9WY>#V7QWDV zA&M*i>3z5Gc-V0&Q}}7fcNM-GN?-h8eP#N)mG10I<;#D1JIZD{&aC~Ud*@nh>&CTw zz4trw-A5`nmnOTrr~a0msJwAz^-%p#{nAk9RFr*l^=GS3)GHfTCVM+(ucTwKWB#w{ z;q0HwVWeCiNnYwax+yMa3j?9lQ{FlqjYrKJaTJ;t-V(`=wM3Q8EAq3=i*AYJp_Zt! zc}1RRUUW+&f2Ad=Y+jMyY+iIrBu}(NmCY-1s(H~Zkv!WHRW`54-!?D0C6fQp5>+;@ z$Q$#M)78nT7sB%PuzWu3ue@E@6_={DuImFK{W%)PbJfN1a#YBN^iYcTzg4Z(<~QZ* z*Y||88&9n*?+LHw!`W=PdbM*tJF|aoPgwYNsBGFXSBe+DABr17Z%5zkh3aA{w^UhO z-ViGPJ~IFM^?azzXZm;VOg{OEkAGv&uE#!=p5Nc(+*^yKN6PhN=GIc>-MP!5JN=_* z?&UBu_ez+ZTMWsjc>Mi0J=jVnZ7;q#{^G8xO^FRMfR4b**zi1S7 z>2!7~Tg_LmRIW|W-d=hBbao+IeLkC=dL~`{d+)8g*E89vi|?(ME?#UToIIWVT~s|8 zWiLe4mB#gVRizw~$RPX9-){KmSw(@(yd)OyNKHP*KMul|ke<{$J458VUR5CH-N2z)4k z_50WUZFlWopW9aMUAKE2?aP&-O9yhb&aUqz*H%|5{~RA19v#acJDd#VN1xg|`fPse z;7Ic1iNieyK6v!>L|+;n9J+JIzGSTb^P~OA*we|*gZ=&KyGioo$+6+2KY4a=G}(Fh zaI$;&x#PnJ$A*WJo&EcI(<_c29UdGVPL7`#OY+BVf9}9NsRIv`I`E;8Ttt8X0Rj)5 zK!0ObS-&gYvwtLmhX?b=?z1-y+)nB1>ucwf3)BKM@FLt<0A+(9%ws{kZtGgqbQ_b|8^c>Lpyh$ zKL3qv-v1+Q-v6dH@4vIn`|oP={=3_}|BtnK|C`&q|DHDQ|IzmDU-twE5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk n1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNC976ShTbcqJN literal 0 HcmV?d00001 diff --git a/disk_bug/disk_test2.dsk b/disk_bug/disk_test2.dsk new file mode 100644 index 0000000000000000000000000000000000000000..2eab2f39840674c32a1d2bdd296fd02c11c37d4b GIT binary patch literal 143360 zcmeIxJ8lzE7zN%V(-=C{?_((s`p`MP`_N%Zx;3T*ZTRQ ze)8>Y*nPBmv{D})e?It9uOB}hgxAZ9%j+i7Hjbw4ew+;3IBVjlX=B&Kk4@8k`14f% z;B?lG=Up7mnrFMR)%!uMY-d%yJr2oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF b5FkK+009C72oNAZfB*pk1PBlyP=vsDA}_2* literal 0 HcmV?d00001 diff --git a/disk_bug/extra_empty.dsk b/disk_bug/extra_empty.dsk new file mode 100644 index 0000000000000000000000000000000000000000..f6298fb98367ed8a185c172c7404233a140e04ac GIT binary patch literal 143360 zcmeIxy=oLu7zW@Ie`2ChckW=&(!xT#11o#ME3mQ`tPMoL%F6CwA!y+ZNFXb_uuEho z>}+FUZ)zl5T5oI`&&$=Z5&P8{Wux6an{69)5b*;-!;wR z&7Y^b2dA@kJYU4&tXWLP^PfK%&PKmtx(5#CTIIBW-;4>9?|Pn6}`ZwDH-e-^;#X+JX<##%G_tlYPUq1)ryl&p!Qi_6^e(e492t z`}FtOH%wdbW7_!a(~q)mn6}_5ZM<{>1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNCfe+X2U zPlvGlTi1ubAE?$sxH<^kcL=N1$v*!gqwnBOAke?ilCL^d^7;^}?(bjnRcA_G-@X5{ zh3{W4eE+$^_iq%wf3xuY=L_F|q451%h3~&u`2I^}@3)=+0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly fK!5-N0t5&UAV7cs0RjXF5FkK+009C7iV*k?gCnuX literal 0 HcmV?d00001 diff --git a/disk_bug/qboot_sector.s b/disk_bug/qboot_sector.s new file mode 100644 index 00000000..384848af --- /dev/null +++ b/disk_bug/qboot_sector.s @@ -0,0 +1,235 @@ +; fast seek/multi-read +; copyright (c) Peter Ferrie 2015-16 + + sectors = 13 ; user-defined + firsttrk = 1 ; user-defined, first track to read + firstsec = 0 ; user-defined, first sector to read + address = $12 ; user-defined + entry = $1200 ; user-defined + version = 1 + + ;memory usage: + ;256 bytes ($200-2ff) static table + grouped = $200 + + ; stay aware from interrupt vectors at $3fe !!! + + ;106 bytes ($300-369) static table + preshift = $300 + zvalue = $fd ; only during init + znibble = $fe ; only during init + zmask = $ff ; only during init + + +; $26/$27 sector read location (ROM) +; $3D sector number (ROM) + + +; at entry (at least on AppleWin) A=1, X=60 (slot<<4), Y=0 +; qkumba says cffa cards leave Y at $10 +; 26/27 = 00/09 +; 3D = 1 + + ; For Disk II booting, the firmware loads track0/sector0 + ; to $800 and then jumps to $801 + +.org $800 + .byte 1 ; number of sectors for ROM to load + +boot_entry: + ; this code loads two sectors up to $10/$11 + + lsr ; check sector number + tay + adc #$0f + sta $27 ; set or update address as needed + cmp #$12 + ; 10 11 12 (1 1 1) + ; be, bf, c0 (1011 1011 1100) + ; so if hit $c000 we are done + + beq done_load_2 ; branch if loaded 2 + + inc $3d ; increment sector (faster to find) + + ; call to the read routine in proper slot + ; using rts to jump indirect to + ; $CX5C + + ; this routine reads sector in $3D on track in $41 + ; to address in $26/$27 + ; when it's done it jumps back to $801 + + txa ; x is slot# << 4 + lsr + lsr + lsr + lsr + ora #$c0 ; slot to PROM base + pha + lda #$5b ;read-1 + pha + rts + +done_load_2: + + ; patch self modifying code for Q6L read + + txa + ora #$8c ; slot to Q6L + ; Q6L? + ; if slot 6, after this A is $EC +patch_loop: + iny + ldx patchtbl-3, Y + sta code_begin, X ; replace placeholders with Q6L + ; BE02 = EC? lda c0ec + ; so sets to c08c (Q6L) + + bne patch_loop + + ; patch self-modifying code for turning motor off + + and #$f8 ; MOTOROFF (c088) -> c0e8 + sta slotpatch7+1 + + ; patch self-modifying code for turning motor on + clc + adc #1 ; MOTOROFF (c088) -> c0e9 + sta slotpatch9+1 + + ; patch self-modifying code for phase off + + eor #9 ; PHASEOFF (c080) + sta slotpatch8+1 + + ldx #$3f + stx zmask + inx + ldy #$7f + + bne skip_ahead ; branch always + + ; pad with zeros until $839 + ; $839 is the entry point + ; adjusts address at $8FE to be entry point + ; jumps to boot 2 +;.res $839-* + +; lda #>(entry-1) +; pha +; lda #<(entry-1) +; pha +; jsr preread +; jmp $1000 ; stage2 entry point + +patchtbl: + .byte <(slotpatch1+1), <(slotpatch2+1), <(slotpatch3+1) + .byte <(slotpatch4+1), <(slotpatch5+1), <(slotpatch6+1) +indextbl: ;the 0 also terminates the patchtbl list! + .byte 0, 2, 1, 3 + + + ;construct denibbilisation table + ;pre-shifted for interleave read + +skip_ahead: +loopaa: + sty znibble + tya + asl + bit znibble + beq loopz + ora znibble + eor #$ff + and #$7e +loopa: + bcs loopz + lsr + bne loopa + dex + txa + asl + asl + sta preshift-$16, Y +loopz: + dey + bne loopaa + + ;construct 2-bit group table + + sty zvalue +loopbb: + lsr zmask + lsr zmask +loopb: + lda indextbl, X + sta grouped, Y + inc zvalue + lda zvalue + and zmask + bne loopy + inx + txa + and #3 + tax +loopy: + iny + iny + iny + iny + cpy #3 + bcs loopb + iny + cpy #3 + bcc loopbb + lda #>(entry-1) + pha + lda #<(entry-1) + pha + jsr preread + + ; seek backward support +; sty startsec+1 +; sta tmpadr+1 +; stx total+1 + + jmp seekread + +preread: + +;copy post-read if necessary +;push post-read address here +; pla +; tax +; pla +; tay +; lda #>(postread-1) +; pha +; lda #<(postread-1) +; pha +; tya +; pha +; txa +; pha + + lda #<(firsttrk*2) + sta phase+1 + ldx #sectors + lda #address + ldy #firstsec + rts + + + +end_code: + +.res $8fe-* + +; traditionally, entry point to jump to at end of loading +; $1000 in this case +;*=$8fe + .byte $10, $00 + + +.include "qboot_stage2.s" diff --git a/disk_bug/qboot_stage2.s b/disk_bug/qboot_stage2.s new file mode 100644 index 00000000..70b316a3 --- /dev/null +++ b/disk_bug/qboot_stage2.s @@ -0,0 +1,365 @@ +; the following lives on sectors $0E and $0D +; why? +; request sector 2 and 4, and the interleave is + +; beneath apple dos (3-23) +; Physical (firmware) : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +; DOS33 mapping : 0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15 + + +; Beneath Apple DOS +; p86 (dos reference) +; + +WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us + +.org $1000 + +code_begin: + + .byte version + +readnib: +slotpatch1: ; smc + lda $c0d1 ; gets set to C08C (Q6L) read + bpl readnib + rts + + ;fill address array for one track +seekread: + sty startsec+1 + sta tmpadr+1 + stx total+1 + +inittrk: + sec + lda #$10 + sbc startsec+1 + cmp total+1 + bcs it_skip + + tax + +it_skip: + stx partial1 + stx partial2 + jsr seek + +startsec: + ldy #$d1 + +tmpadr: +tmpadr_loop: + lda #$d1 + sta addrtbl, y + inc tmpadr+1 + iny + dec partial1 + bne tmpadr_loop + + ;==================================== + ; read a sector + ;==================================== + ; first address field + ;==================================== + ; starts with $D5 $AA $96 + ; then XX YY volume + ; then XX YY track + ; then XX YY sector + ; then XX YY checksum + ; then ends with $DE $AA $EB + ;==================================== + ; data field + ;==================================== + ; starts with $D5 $AA $AD + ; 342 bytes of data + ; XX checksum + ; ends with $DE $AA $EB +read: + +outer_read: + jsr readnib +inner_read: + cmp #$d5 ; look for $D5 part of addr field + bne outer_read + + jsr readnib ; look for $D5 $AA + cmp #$aa + bne inner_read + + ; look for $D5 $AA $AD + + tay ; we need Y=#$AA later + jsr readnib + eor #$ad ; zero A if match + beq check_mode + + ; if not #$AD, then #$96 is assumed + ; so in address field + + ldy #2 ; volume, track, sector +another: + jsr readnib + rol ; set carry + sta sector+1 + jsr readnib + and sector+1 + dey + bpl another + + tay + ldx addrtbl, Y ; fetch corresponding address + beq read ; done? + + sta sector+1 ; store index for later + + stx adrpatch1+2 + stx adrpatch8+2 + stx adrpatch2+2 + stx adrpatch3+2 + stx adrpatch5+2 + stx adrpatch7+2 + + inx + stx adrpatch9+2 + dex + + dex + stx adrpatch4+2 + stx adrpatch6+2 + + ldy #$fe + +loop2: +adrpatch1: + lda $d102, Y + pha + iny + bne loop2 + +branch_read: + bcs read ; branch always + +check_mode: + cpx #0 + beq read ; loop if not expecting #$AD + +loop33: + sta tmpval+1 ; zero rolling checksum +slotpatch2: +loop4: + ldx $c0d1 + bpl loop4 + lda preshift-$96, X +adrpatch2: + sta $d102, Y ; store 2-bit array + +tmpval: + eor #$d1 + iny + bne loop33 + ldy #$aa +slotpatch3: +loop5: + ldx $c0d1 + bpl loop5 + eor preshift-$96, X +adrpatch3: + ldx $d102, Y ; bit2tbl + eor grouped+2, X ; first 86 nibbles use group bits 0-1 +adrpatch4: + sta $d156, y + iny + bne loop5 + and #$fc + ldy #$aa +slotpatch4: +loop6: + ldx $c0d1 + bpl loop6 + eor preshift-$96, X +adrpatch5: + ldx $d102, Y ; bit2tbl + eor grouped+1, X ; second 86 nibbles use group bits 2-3 +adrpatch6: + sta $d1ac, Y + iny + bne loop6 + and #$fc + ldx #$ac +slotpatch5: +loop7: + ldy $c0d1 + bpl loop7 + eor preshift-$96, Y +adrpatch7: + ldy $d100, X ; bit2tbl + eor grouped, Y ; last 84 nibbles use group bits 4-5 +adrpatch8: + sta $d100, x + inx + bne loop7 + and #$fc +slotpatch6: +loop8: + ldy $c0d1 + bpl loop8 + eor preshift-$96, Y + cmp #1 ; carry = !zero + ldy #1 +loop9: + pla +adrpatch9: + sta $d100, Y + dey + bpl loop9 +branch_read2: + bcs branch_read ; branch if checksum failure + +sector: + ldy #$d1 + txa + sta addrtbl, Y ; zero corresponding address + dec total+1 + dec partial2 ; adjust remaining count + ; (faster than looping over array) + sec + bne branch_read2 ; read all requested sectors in one track + + sta startsec+1 ; this was missing from original code + ; leading to trouble on wrap around + ; it not starting at sector0 +total: + ldx #$d1 + beq driveoff + inc phase+1 + inc phase+1 ; update current track + jmp inittrk + +driveoff: +slotpatch7: + lda $c0d1 + +seekret: + rts + +seek: + lda #0 + sta step+1 +copy_cur: +curtrk: + lda #0 + sta tmpval+1 + sec +phase: + sbc #$d1 + beq seekret + + ; if seek backwards + bcs sback + + eor #$ff + inc curtrk+1 + + bcc ssback +sback: + adc #$fe + dec curtrk+1 +ssback: + cmp step+1 + bcc loop10 +step: + lda #$d1 +loop10: + cmp #8 + bcs loop11 + tay + sec +loop11: + lda curtrk+1 + ldx step1, Y + bne loop12 +loopmmm: + clc + lda tmpval+1 + ldx step2, Y +loop12: + stx sector+1 + and #3 + rol + tax +slotpatch8: + sta $c0d1, X +loopmm: + ldx #$13 +loopm: + dex + bne loopm + dec sector+1 + bne loopmm + lsr + bcs loopmmm + inc step+1 + bne copy_cur + +step1: .byte 1, $30, $28, $24, $20, $1e, $1d, $1c +step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c +addrtbl: .res 16 + +partial1: .byte $00 +partial2: .byte $00 +code_end: + + +load_new: + +; enable drive motor + +slotpatch9: + lda $c0e9 ; fixme, patch + + ; wait 1s + + ldx #6 +wait_1s: + lda #255 + jsr WAIT + dex + bne wait_1s + + ; setup return on stack + ; is value - 1 + +; lda load_address +; sec +; sbc #1 +; pha +; lda #$ff +; pha + + lda load_track + asl ; track to start*2 + sta phase+1 + + lda load_sector + tay ; sector to start + + lda load_length ; length + tax + + lda load_address ; address to load + + jsr seekread + + rts + +load_address: + .byte $00 +load_track: + .byte $00 +load_sector: + .byte $00 +load_length: + .byte $00 + + diff --git a/disk_bug/test.s b/disk_bug/test.s new file mode 100644 index 00000000..e0dc0190 --- /dev/null +++ b/disk_bug/test.s @@ -0,0 +1,276 @@ +test_entry: + + +load_new = $119D +load_address=$11C0 +load_track=load_address+1 +load_sector=load_address+2 +load_length=load_address+3 + + ; make sure we are in 40col mode + ; with monitor I/O working + + jsr $FE89 ; SETKBD (simulate keypress?) + jsr $FE93 ; SETVID (simulate video output?) + jsr $FB2F ; INIT (clear screen/etc) + jsr $FE84 ; SETNORM (set normal video) + jsr $FC58 ; HOME (clear screen) + + + ;============================= + ; print title + ;============================= + lda #message1 + sta print_smc+2 + jsr print_message + + ; wait for keypress + + jsr $fd0c ; RDKEY + + + ;============================= + ; print reading disk1 message + ;============================= + lda #message2 + sta print_smc+2 + jsr print_message + + ; wait for keypress + +; jsr $fd0c ; RDKEY + + ;================================ + ; read t0/s0 into c0 + ;================================ + + lda #$c + sta load_address + lda #$00 + sta load_track + lda #$00 + sta load_sector + lda #$1 + sta load_length + + jsr load_new + + + lda $c00 + and #$f + clc + adc #'0' + sta message3+15 + + lda $c00 + lsr + lsr + lsr + lsr + and #$f + clc + adc #'0' + sta message3+14 + + + + ;============================= + ; print read1 result message + ;============================= + lda #message3 + sta print_smc+2 + jsr print_message + + ; wait for keypress + + jsr $fd0c ; RDKEY + + ;============================= + ; print insert disk2 message + ;============================= + lda #message4 + sta print_smc+2 + jsr print_message + + ; wait for keypress + + jsr $fd0c ; RDKEY + + ;=============================== + ; print read disk2 try1 message + ;=============================== + lda #message5 + sta print_smc+2 + jsr print_message + + + lda #$c + sta load_address + lda #$00 + sta load_track + lda #$00 + sta load_sector + lda #$1 + sta load_length + + jsr load_new + + + lda $c00 + and #$f + clc + adc #'0' + sta message6+15 + + lda $c00 + lsr + lsr + lsr + lsr + and #$f + clc + adc #'0' + sta message6+14 + + + ;============================= + ; print result2 message + ;============================= + lda #message6 + sta print_smc+2 + jsr print_message + + lda $c00 + cmp #$20 + beq no_bug_found + + ;============================= + ; print bug found + ;============================= + lda #message9 + sta print_smc+2 + jsr print_message + +no_bug_found: + + + ; wait for keypress + + jsr $fd0c ; RDKEY + + ;=============================== + ; print read disk2 try2 message + ;=============================== + lda #message7 + sta print_smc+2 + jsr print_message + + + lda #$c + sta load_address + lda #$00 + sta load_track + lda #$00 + sta load_sector + lda #$1 + sta load_length + + jsr load_new + + + lda $c00 + and #$f + clc + adc #'0' + sta message8+15 + + lda $c00 + lsr + lsr + lsr + lsr + and #$f + clc + adc #'0' + sta message8+14 + + + ;============================= + ; print result3 message + ;============================= + lda #message8 + sta print_smc+2 + jsr print_message + + + + ;============================ + ; forever + ;============================ +forever: + jmp forever + + ;============================ + ; print message + ;============================ + +print_message: + + ldx #$00 ; loop either 256 chars or until hit zero +loop1: +print_smc: + lda message1,X + beq done1 + ora #$80 + jsr $FDED ; COUT + inx + bne loop1 +done1: + rts + + +message1: + .byte "TESTING DISK-SWITCH BUG",$0d + .byte "=======================",$0d,$0d,0 + +message2: + .byte "READING DISK1 T0:S0 TO $C00",$0d,$0d,0 + +message3: + .byte " BYTE 0 WAS $GG (EXPECTED $01)",$0d,$0d,0 + +message4: + .byte "PLEASE PUT IN DISK2",$0d,$0d,0 + +message5: + .byte "READING DISK2 T0:S0 TO $C00",$0d,$0d,0 + +message6: + .byte " BYTE 0 WAS $GG (EXPECTED $20)",$0d,$0d,0 + +message7: + .byte "READING DISK2 T0:S0 TO $C00 AGAIN",$0d,$0d,0 + +message8: + .byte " BYTE 0 WAS $GG (EXPECTED $20)",$0d,$0d,0 + +message9: + .byte "*** BUG FOUND ***",$0d,$0d,0