standard-delivery/fstbt.s

107 lines
3.1 KiB
ArmAsm
Raw Permalink Normal View History

2018-03-01 05:44:26 +00:00
;license:BSD-3-Clause
2016-11-27 18:19:15 +00:00
;fast boot-loader in one sector
;copyright (c) Peter Ferrie 2016
;thanks to 4am for inspiration and testing
;assemble using ACME
!cpu 6502
!to "fstbt",plain
*=$800
2016-11-29 00:35:24 +00:00
enable_banked = 0 ;set to bank number (1 or 2) to enable reading into banked RAM
2016-11-27 18:19:15 +00:00
!byte 1
tay ;A is last read sector+1 on entry
2017-01-03 04:35:56 +00:00
!if enable_banked > 0 {
lda $C081 ;bank in ROM
2016-11-30 00:53:44 +00:00
}
;check array before checking sector number
;allows us to avoid a redundant seek if all slots are full in a track,
;and then the list ends
incindex
inc adrindex + 1 ;select next address
adrindex
lda adrtable - 1 ;15 entries in first row, 16 entries thereafter
cmp #$C0
beq jmpoep ;#$C0 means end of data
sta $27 ;set high part of address
2018-03-01 05:42:47 +00:00
lda #1 ;preload in case we are finished with the first round
2016-11-27 18:19:15 +00:00
;2, 4, 6, 8, $0A, $0C, $0E
;because PROM increments by one itself
;and is too slow to read sectors in purely incremental order
;so we offer every other sector for read candidates
iny
2016-11-30 00:53:44 +00:00
cpy #$10
bcc setsector ;cases 1-$0F
2016-11-27 18:19:15 +00:00
beq sector1 ;finished with $0E
;next should be 1 for 1, 3, 5, 7... sequence
;finished with $0F, now we are $11, so 16 sectors done
jsr seek ;returns A=0
;back to 0
sector1
2018-03-01 05:42:47 +00:00
tay
2016-11-27 18:19:15 +00:00
2016-11-30 00:53:44 +00:00
setsector
sty $3D ;set sector
2016-11-27 18:19:15 +00:00
iny ;prepare to be next sector in case of unallocated sector
2016-11-30 00:53:44 +00:00
lda $27
beq incindex ;empty slot, back to the top
2016-11-27 18:19:15 +00:00
;convert slot to PROM address
txa
2017-01-03 04:35:56 +00:00
jsr $F87B ;4xlsr
2016-11-29 00:35:24 +00:00
ora #$C0
2016-11-27 18:19:15 +00:00
pha
lda #$5B ;read-1
pha
2017-01-03 04:35:56 +00:00
!if enable_banked > 0 {
writeenable
lda $C093-(enable_banked*8)
lda $C093-(enable_banked*8)
;write-enable RAM and bank it in so read can decode
2016-11-30 00:53:44 +00:00
}
2016-11-27 18:19:15 +00:00
rts ;return to PROM
seek
inc $41 ;next track
2016-11-29 00:35:24 +00:00
asl $40 ;carry clear, phase off
2016-11-30 00:53:44 +00:00
jsr seek1 ;returns carry set, not useful
2016-11-29 00:35:24 +00:00
clc ;carry clear, phase off
2016-11-27 18:19:15 +00:00
2016-11-29 00:35:24 +00:00
seek1
jsr delay ;returns with carry set, phase on
2016-11-30 00:53:44 +00:00
inc $40 ;next phase
2016-11-27 18:19:15 +00:00
delay
2016-11-29 00:35:24 +00:00
lda $40
2016-11-27 18:19:15 +00:00
and #3
rol
ora $2B ;merge in slot
tay
lda $C080, y
2016-11-30 00:53:44 +00:00
lda #$30
jmp $FCA8 ;common delay for all phases
jmpoep
2017-01-03 04:35:56 +00:00
!if enable_banked > 0 {
jsr writeenable ;bank in our RAM, write-enabled
2016-11-29 00:35:24 +00:00
}
2016-11-27 19:06:44 +00:00
jmp $1234 ;arbitrary entry-point to use after read completes
;set to the value that you need
2016-11-27 18:19:15 +00:00
adrtable
2016-11-27 19:06:44 +00:00
;15 slots for track 0 (track 0 sector 0 is not addressable)
2016-11-29 00:35:24 +00:00
;16 slots for all other tracks, fill with addresses, 0 to skip any sector
2016-11-30 00:53:44 +00:00
!byte $C0 ;end of list