2017-04-12 23:31:25 +00:00
|
|
|
;loader.s
|
|
|
|
;
|
2017-04-16 04:03:18 +00:00
|
|
|
; moves itself to another page memory,
|
2017-04-12 23:31:25 +00:00
|
|
|
; then reads binary from disk using params at end,
|
|
|
|
; then jumps to binary
|
|
|
|
;
|
2017-04-09 00:41:29 +00:00
|
|
|
|
2017-04-12 23:31:25 +00:00
|
|
|
; apple params/vectors
|
2017-04-09 00:41:29 +00:00
|
|
|
|
|
|
|
warm = $FF69 ; back to monitor
|
|
|
|
bell = $FBDD ; ding
|
2017-04-12 23:31:25 +00:00
|
|
|
preg = $48 ; mon p reg
|
2017-04-09 00:41:29 +00:00
|
|
|
|
2017-04-12 23:31:25 +00:00
|
|
|
; dos params/vectors
|
2017-04-09 00:41:29 +00:00
|
|
|
|
|
|
|
rwtsprm = $B7E8 ; looked at dos 3.3 disk, not using $3E3 to find
|
2017-04-12 23:31:25 +00:00
|
|
|
rwts = $B7B5 ; rwts jsr
|
|
|
|
|
|
|
|
; vars
|
|
|
|
|
2017-04-16 01:41:29 +00:00
|
|
|
stage1 = $800
|
|
|
|
;stage2 = $B600 ; overwrite track 0/sector 0, not needed any more?
|
|
|
|
stage2 = $300 ; $300 looks open
|
2017-04-09 15:17:09 +00:00
|
|
|
;;;run time
|
|
|
|
trkcnt = $00 ; track counter
|
|
|
|
segcnt = $01 ; loop var
|
|
|
|
buffer = $02 ; MSB of RWTS buffer
|
|
|
|
secnum = $03 ; loop var
|
|
|
|
trknum = $04 ; loop var
|
2017-04-09 00:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
start:
|
2017-04-16 01:41:29 +00:00
|
|
|
.org stage1
|
2017-04-09 00:41:29 +00:00
|
|
|
|
2017-04-16 04:03:18 +00:00
|
|
|
ldx #0 ; move code to stage2
|
2017-04-09 00:41:29 +00:00
|
|
|
move:
|
|
|
|
lda moved,x
|
|
|
|
sta loader,x
|
|
|
|
inx
|
2017-04-16 01:41:29 +00:00
|
|
|
;bne move ; move 256 bytes
|
|
|
|
bpl move ; move 128 bytes
|
2017-04-09 00:41:29 +00:00
|
|
|
jmp loader
|
|
|
|
|
|
|
|
moved:
|
2017-04-16 01:41:29 +00:00
|
|
|
.org stage2
|
2017-04-09 00:41:29 +00:00
|
|
|
|
|
|
|
loader:
|
|
|
|
lda #1 ; read(1)/write(2) command
|
|
|
|
ldy #$0C ; offset in RWTS
|
|
|
|
sta rwtsprm,y ; write it to RWTS
|
|
|
|
|
|
|
|
lda #0 ; buffer LSB
|
|
|
|
ldy #8 ; offset in RWTS
|
|
|
|
sta rwtsprm,y ; write it to RWTS
|
|
|
|
|
|
|
|
lda #2
|
|
|
|
sta trknum ; start with track 2
|
|
|
|
|
|
|
|
lda loadpage ; where to dump the tracks
|
|
|
|
sta buffer
|
|
|
|
|
|
|
|
ldx lasttrack
|
|
|
|
dex ; because data starts at track 2
|
|
|
|
dex
|
|
|
|
stx trkcnt ; number of complete and partial tracks
|
|
|
|
|
|
|
|
;;;begin track loop
|
|
|
|
trkloop:
|
|
|
|
lda trknum ; track number
|
|
|
|
ldy #4 ; offset in RWTS
|
|
|
|
sta rwtsprm,y ; write it to RWTS
|
|
|
|
|
|
|
|
;;;begin sector loop (16), backwards is faster, much faster
|
2017-04-12 23:31:25 +00:00
|
|
|
lda trkcnt ; check if last track
|
|
|
|
bne fulltrack ; if not then full track
|
|
|
|
lda lastsector ; if so, get last sector number
|
2017-04-09 15:17:09 +00:00
|
|
|
bpl subtrack
|
2017-04-09 00:41:29 +00:00
|
|
|
fulltrack:
|
|
|
|
lda #$F
|
|
|
|
subtrack:
|
|
|
|
sta secnum
|
|
|
|
secloop:
|
|
|
|
lda secnum ; sector number
|
|
|
|
ldy #5 ; offset in RWTS
|
|
|
|
sta rwtsprm,y ; write it to RWTS
|
|
|
|
|
|
|
|
lda buffer ; buffer MSB
|
|
|
|
clc
|
2017-04-12 23:31:25 +00:00
|
|
|
adc secnum ; compute page load address
|
2017-04-09 00:41:29 +00:00
|
|
|
ldy #9 ; offset in RWTS
|
|
|
|
sta rwtsprm,y ; write it to RWTS
|
|
|
|
|
|
|
|
ldy #<rwtsprm ; load rwts paramlist B7E8
|
|
|
|
lda #>rwtsprm
|
|
|
|
jsr rwts ; do it!
|
|
|
|
bcs diskerror
|
|
|
|
lda #0
|
|
|
|
sta preg ; fix p reg so mon is happy
|
|
|
|
|
|
|
|
dec secnum
|
|
|
|
bpl secloop
|
|
|
|
;;;end sector loop
|
|
|
|
|
|
|
|
lda buffer ; buffer += $10
|
|
|
|
clc
|
|
|
|
adc #$10
|
|
|
|
sta buffer
|
|
|
|
|
|
|
|
inc trknum ; next track
|
|
|
|
dec trkcnt ;
|
|
|
|
bpl trkloop ; 0, all done with tracks
|
|
|
|
;;;end track loop
|
|
|
|
|
|
|
|
done:
|
2017-04-12 23:31:25 +00:00
|
|
|
jmp (nextjump) ; down with load, run it
|
2017-04-09 00:41:29 +00:00
|
|
|
|
|
|
|
diskerror:
|
|
|
|
jmp warm
|
|
|
|
|
|
|
|
lasttrack:
|
|
|
|
.org *+1
|
|
|
|
lastsector:
|
|
|
|
.org *+1
|
|
|
|
loadpage:
|
|
|
|
.org *+1
|
|
|
|
nextjump:
|
|
|
|
.org *+2
|
2017-04-09 15:17:09 +00:00
|
|
|
;;; used for debug
|
|
|
|
;trkcnt:
|
|
|
|
; .org *+1
|
|
|
|
;segcnt:
|
|
|
|
; .org *+1
|
|
|
|
;buffer:
|
|
|
|
; .org *+1
|
|
|
|
;secnum:
|
|
|
|
; .org *+1
|
|
|
|
;trknum:
|
|
|
|
; .org *+1
|