[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reverse engineering a "13/16 boot"



"Alien Addition" has a 13/16 boot sector. I'd like to try to replicate how it works. So far I've disassembled the sector itself, but not yet reverse engineered how DOS 3.2 is stored...

-uso.

secs13     =        $0300
entry13    =        $0301
patch13    =        $031F

monerr     =        $FF2D

          .org      $0800

secs:     .byte     $01

entry:    ldy       #<reloc   ; move rest of the sector to $0200
@1:       lda       secs, y
          sta       $0200, y
          iny
          bne       @1
          jmp       entry2    ; then jump to it

reloc:    .org      $0200+(*-$0800)

entry2:   ldx       #$20
@1:       lda       #$03
          sta       $3C
          clc
          dey
          tya
@2:       bit       $3C
          beq       @1
          rol       $3C
          bcc       @2
          cpy       #$D5
          beq       @1
          dex
          txa
          sta       secs, y
          bne       @1
          sta       $3D
          sta       $26
          lda       #$03
          sta       $27
          ldx       $2B
          jsr       L025D
          jmp       L02D1

gosec:    lda       #$A9      ; LDA #$xx
          sta       patch13
          lda       #$02
          sta       patch13+1
          jmp       entry13

          .res      $025D-*, $EA ; NOP

L025D:    clc
@1:       php
@2:       lda       $C08C, x
          bpl       @2
@3:       eor       #$D5
          bne       @2
@4:       lda       $C08C, x
          bpl       @4
          cmp       #$AA
          bne       @3
          nop
@5:       lda       $C08C, x
          bpl       @5
          cmp       #$B5
          beq       @6
          plp
          bcc       L025D
          eor       #$AD
          beq       @9
          bne       L025D     ; ALWAYS

@6:       ldy       #$03
          sty       $2A
@7:       lda       $C08C, x
          bpl       @7
          rol
          sta       $3C
@8:       lda       $C08C, x
          bpl       @8
          and       $3C
          dey
          bne       @7
          plp
          cmp       $3D
          bne       L025D
          bcs       @1
@9:       ldy       #$9A
@10:      sty       $3C
@11:      ldy       $C08C, x
          bpl       @11
          eor       secs, y
          ldy       $3C
          dey
          sta       secs, y
          bne       @10
@12:      sty       $3C
@13:      ldy       $C08C, x
          bpl       @13
          eor       secs, y
          ldy       $3C
          sta       ($26), y
          iny
          bne       @12
@14:      ldy       $C08C, x
          bpl       @14
          eor       secs, y
          bne       L025D
          rts

L02D1:    tay
@15:      ldx       #$00
@16:      lda       secs, y
          lsr
          rol       $03CC, x
          lsr
          rol       $0399, x
          sta       $3C
          lda       ($26), y
          asl
          asl
          asl
          ora       $3C
          sta       ($26), y
          iny
          inx
          cpx       #$33
          bne       @16
          dec       $2A
          bne       @15
          cpy       secs13
          bne       @17
          jmp       gosec
@17:      jmp       monerr

          .res      $0300-*, $FF