passport/src/id/protecteddos.a

58 lines
1.5 KiB
Plaintext
Executable File

;-------------------------------
; ProtectedDOS
; in: $0800..$08FF contains boot0
; $B600..$BFFF contains boot1
; out: C clear if "Protected DOS" was found
; C set if "Protected DOS" was not found
; gIsProtDOS is set to TRUE or FALSE
;-------------------------------
!zone {
ProtectedDOS
lda #$B7
ldx #$00
ldy #$1A
jsr CompareMemory
!byte $A0,$1A,$B9,$00,$B7,$49,$97,$99
!byte $00,$B7,$C8,$D0,$F5,$EE,$04,$B7
!byte $EE,$09,$B7,$AD,$09,$B7,$C9,$C0
!byte $D0,$E8
bcs .exit ; passport-test-suite/Ultima IV.woz [C=0] matches
stx gDisplayBytes
lda $B706 ; decryption key
sta .key+1
sta gDisplayBytes+1
jsr PrintByID
!byte s_protdos
;
; decrypt RWTS in memory
;
lda #$B7
sta .decrypt+2
sta .store+2
ldy #$1A
.decrypt lda $B700,y
.key eor #$FF ; set at runtime
.store sta $B700,y
iny
bne .decrypt
inc .decrypt+2
inc .store+2
lda .store+2
cmp #$C0
bne .decrypt
;
; this RWTS swaps the A/Y hi/lo parameter table address
; when calling the RWTS entry point, so we need to
; set a flag so we can call it properly later
; (in ReadSector)
;
lda #TRUE
sta gIsProtDOS
clc
.exit
rts
}