mirror of
https://github.com/jmechner/Prince-of-Persia-Apple-II.git
synced 2025-01-29 15:35:57 +00:00
1 line
11 KiB
ArmAsm
1 line
11 KiB
ArmAsm
|
* boot
org = $800
lst off
xc off
REDFLAG79 = $23B ; in aux mem!
*-------------------------------
* $800 TS (0,0) boot sector
SLOT = $2b
sector = $50
text = $fb2f
home = $fc58
vtab = $FB5B
cout = $FDF0
normal = $fe84
pr0 = $fe93
in0 = $fe89
*-------------------------------
smclo = $4E
smchi = $4F
rw18 = $d000
slot = $fd
track = $fe
lastrack = $ff
dum $00
dest ds 2
source ds 2
endsourc ds 2
dend
*-------------------------------------------------
org org
hex 01
entry lda #$60
sta entry
lda #MAKEBIT
sta smclo
ldx #$ff
stx $4fb
stx $3f3
stx $3f4
stx $7831
stx $c000 ;80store off
stx $c002 ;RAMRD main
stx $9fd8
stx $c004 ;RAMWRT main
stx $c00c ;80col off
stx $c00e ;Altcharset off
stx $c081 ;write RAM, read ROM (2nd 4k bank)
txs
jsr text
jsr home
jsr normal
jsr pr0
sta $DF35
jsr in0
stx $8492
ldx SLOT
txa
lsr
lsr
lsr
lsr
ora #$c0
sta :rdsect+2
lda #$0f
sta sector
:0 ldy sector
lda skewtbl,y
sta $3d
lda sectaddr,y
beq :1
sta $27
inc $9fd8
:rdsect jsr $005c
:1 dec sector
bne :0
beq decode
skewtbl hex 00,0d,0b,09,07,05,03,01
hex 0e,0c,0a,08,06,04,02,0f
sectaddr hex 00,09,0a,0b,00,0c,0d,0e
hex 30,31,32,33,34,10,11,2f
decode ldx #14
:loop lda sectaddr,x
beq :nope
sta :smc0+2
sta :smc1+2
ldy #0
:loop1
:smc0 lda $FF00,y
eor $2F00,y
:smc1 sta $FF00,y
eor $7831 ;bogus garbage
sta $7831 ; " " " "
sta $3C
iny
bne :loop1
:nope dex
bpl :loop
ldx SLOT
stage2 stx slot
jsr check128k ;check for 128K memory
jsr moverw18 ;& move RW18 to D000
lda #0
sta lastrack
jsr rw18
hex 07,a9 ;Bbund ID byte
jsr rw18
hex 00,01,00 ;drive 1 on
jsr rw18 ;seek track 1
hex 02,00,01
* load & run stage 3 boot
* from drive 1
jsr rw18
hex c3,ee
jmp $ee00
*-------------------------------------------------
* Check for AUX memory routine
CHECKER lda #$EE
sta $C005
lda #>MAKEBIT
sta smchi
sta $C003
sta $0800
lda $0C00
cmp #$EE
bne :0
asl $0C00
lda $0800
cmp $0C00
beq :1
:0 clc
:1 sta $C004
sta $C002
rts
CHECKEND = *-CHECKER
*-------------------------------------------------
*
* Check to make sure //c or //e
* with 128k
*
*-------------------------------
hex 34
hex 55
hex 99
check128k
sta $c081
lda $FBB3 ;Apple // family ID byte
cmp #6
bne NOT128K ;Must be e/c/GS
bit $C017
bmi NOT128K
ldx #CHECKEND
:0 lda CHECKER,X
sta $180,X
dex
bpl :0
jsr $180
bcs NOT128K
rts
*-------------------------------
* Turn off drive and display message
NOT128K ldx SLOT
lda $C088,X
jsr text
jsr home
lda #8
jsr vtab
ldy #0
:0 lda MEMTEXT,Y
beq *
jsr cout
cmp #$8D
bne :1
lda #4
sta $24
:1 iny
bne :0
MEMTEXT hex 8D
asc "REQUIRES A //C OR //E WITH 128K"
hex 00
*-------------------------------
* Move RW18
* d0 < 30.40
*-------------------------------
moverw18
bit $c08b
bit $c08b ;rd/wrt RAM, 1st 4k bank
lda #$d0
ldx #$30
ldy #$40
* a < x.y
* 20 < 40.60 means 2000 < 4000.5fffm
* WARNING: If x >= y, routine will wipe out 64k
movemem sta dest+1
stx source+1
sty endsourc+1
ldy #0
lda #$24
sta (smclo),y
sty dest
sty source
sty endsourc
:loop lda (source),y
sta (dest),y
iny
bne :loop
inc source+1
inc dest+1
lda source+1
cmp endsourc+1
bne :loop
MAKEBIT rts
hex FF
*-------------------------------------------------
*
* HLS APPLE COPY PROTECTION
* COPYRIGHT (C) 1987 HLS DUPLICATION
*
* CONTACT ROBERT FREEDMAN 408-773-1300
* IF THERE ARE QUESTIONS ABOUT USE OF
* THIS CODE
*
* EXIT clc IF A O K
* sec IF PIRATE
*
*-------------------------------------------------
OBJSCT = $07 ;PHYSICAL SECTOR #
* ZERO PAGE
* IF THIS CONFLICTS WITH YOUR CODE
* CHANGE THE FOLLOWING ZERO PAGE
* LOCATIONS, OR USE THE SAVE ZERO
* PAGE ROUTINE
HDRC = $F0
HDRS = HDRC+1
HDRT = HDRC+2
HDRV = HDRC+3 HEADER SECTOR
LSRETRY = HDRC+4 ;NIB READ RETRIES
PRETRY = HDRC+5 ;OBJSCT RETRIES
NPTR = HDRC+6
NPTRH = HDRC+7
MEM1 = HDRC+8
MEM2 = HDRC+9
*-------------------------------------------------
CheckCP
lda #10
sta LSRETRY
lda #>REDFLAG79
sta smchi
ldx SLOT
lda $C089,X
lda $C08E,X
lda #:NIBS ; !!!!! LOW BYTE
sta NPTR
lda #>:N
|