; Bootsector tracer ; written by qkumba ; IDBoot ; try to determine sector type based on found boot sector lda #$60 sta $867B @patch jsr $8600 ;SMC ldy #$5C sty @patch+1 bcc + ; we found D5 AA 96 T00S00 D5 AA .. ; check for weird Sensible Software 13-sector disk with D5 AA 96 sectors cmp #$B5 beq ++ lda #$90 sta $867B ; found D5 AA 96 T00S00 D5 AA AD, proceed as 16-sector bne @patch ;always @retries !byte 14 ;sectors per track+1 to cover the corner-case ; found D5 AA not-96 ; check for out-of-order D5 AA AD, and retry in that case + cmp #$AD beq @patch ; otherwise, loop in case we will see D5 AA B5 cmp #$B5 bne @patch ; and loop anyway in case it's a hybrid disk and we missed the D5 AA 96 ++ dec @retries bne @patch ; found nothing but D5 AA B5, proceed as 13-sector lda #$90 sta $867B ; build 5-and-3 decoder table ldx #$20 ;now you know why the boot PROM ldy #$00 ;starts with these magic values -- lda #$03 sta $3C clc dey tya - bit $3C beq -- rol $3C bcc - cpy #$D5 beq -- dex txa sta $800,y bne -- ; patch boot PROM to recognise 13-sector instead ldy #$B5 sty $8677 dec $86A1 ldy #$9A sty $86A7 sta $86B0 ldy #$08 sty $86B1 sty $86B7 sta $86C2 sty $86C3 sta $86D1 sty $86D2 - lda @decode53,x sta $86D5,x lda @decode53 + $100,x sta $86D5 + $100,x inx bne - lda #$03 sta $27 sta $2A ldx #$60 jsr $865D jmp $86D6 @decode53 !pseudopc $86D5 { @decode53x rts tay -- ldx #$00 - lda $800,y lsr rol $3CC,x lsr rol $399,x sta $3C lda ($26),y asl asl asl ora $3C sta ($26),y iny inx cpx #$33 bne - dec $2A bne -- cpy $300 - bne - jmp Tracer13 IDBoot13 lda $33C cmp #$AD sec bne + lda #$4C sta $33C lda $33D sta @dispatch+1 lda #<@callback53 sta $33D lda $33E sta @dispatch+2 lda #>@callback53 sta $33E clc + rts @CompareMemoryRel sta cmp1+1 stx cmp1 pla sta cmp2 pla sta cmp2+1 tax tya clc adc cmp2 bcc + inx + sta tmp txa pha lda tmp pha .cmp lda (cmp2),y dey bmi .success cmp (cmp1),y beq .cmp cmp #WILDCARD beq .cmp sec !byte $24 ; hide CLC .success clc lda cmp1+1 ldx cmp1 rts @callback53 lda $85FF beq @jmp_dispatch lda #$29 ldx #$6E ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notinfocom inc $296F @jmp_dispatch jmp @dispatch @notinfocom lda #$3D ldx #$5F ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32a inc $3D60 jmp @dispatch @notdos32a lda #$BD ldx #$6E ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32b inc $BD6F jmp @dispatch @notdos32b lda #$3D ldx #$6E ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32c inc $3D6F jmp @dispatch @notdos32c lda #$BD ldx #$5F ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32d inc $BD60 jmp @dispatch @notdos32d lda #$24 ldx #$6E ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32e inc $246F jmp @dispatch @notdos32e lda #$7D ldx #$5F ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32f inc $7D60 jmp @dispatch @notdos32f lda #$7D ldx #$6E ldy #8 jsr @CompareMemoryRel !byte $BD,$8A,$C0 ;LDA $C08A,X !byte $B0,$03 ;BCS *+5 !byte $BD,$8B,$C0 ;LDA $C08B,X bcs @notdos32g inc $7D6F jmp @dispatch @notdos32g @dispatch lda $d1d1 ;SMC pha lda #$ff pha ldx #$60 rts } PatchBoot13 lda #3 ldx #$1B ldy #8 jsr CompareMemory !byte $4A ;LSR !byte $4A ;LSR !byte $4A ;LSR !byte $4A ;LSR !byte $09,$C0 ;ORA #$C0 !byte $85,$3F ;STA $3F bcs @retry lda #$80 sta $320 bcc @exit @retry lda #3 ldx #$25 ldy #8 jsr CompareMemory !byte $4A ;LSR !byte $4A ;LSR !byte $4A ;LSR !byte $4A ;LSR !byte $09,$C0 ;ORA #$C0 !byte $85,$3F ;STA $3F bcs @exit lda #$80 sta $32A @exit rts