mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-08-15 08:27:41 +00:00
megaload: more messing with trying to get loader going
This commit is contained in:
@@ -10,7 +10,7 @@ all: megademo.dsk
|
|||||||
megademo.dsk: MEGADEMO MEGALOAD
|
megademo.dsk: MEGADEMO MEGALOAD
|
||||||
$(DOS33) -y megademo.dsk BSAVE -a 0x4000 MEGADEMO
|
$(DOS33) -y megademo.dsk BSAVE -a 0x4000 MEGADEMO
|
||||||
$(DOS33) -y megademo.dsk BSAVE -a 0x800 MEGALOAD
|
$(DOS33) -y megademo.dsk BSAVE -a 0x800 MEGALOAD
|
||||||
$(DOS33) -y megademo.dsk RAWWRITE -t 27 -s 0 MEGADEMO MEGA2
|
# $(DOS33) -y megademo.dsk RAWWRITE -t 27 -s 0 MEGADEMO MEGA2
|
||||||
# $(DOS33) -y megademo.dsk BSAVE -a 0x4000 D_HGRC.BIN
|
# $(DOS33) -y megademo.dsk BSAVE -a 0x4000 D_HGRC.BIN
|
||||||
# $(DOS33) -y megademo.dsk BSAVE -a 0x4000 FS_HGRC.BIN
|
# $(DOS33) -y megademo.dsk BSAVE -a 0x4000 FS_HGRC.BIN
|
||||||
# $(DOS33) -y megademo.dsk BSAVE -a 0x2000 C64C.BIN
|
# $(DOS33) -y megademo.dsk BSAVE -a 0x2000 C64C.BIN
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
MOVE = $fe2c
|
MOVE = $fe2c
|
||||||
|
|
||||||
start:
|
start:
|
||||||
|
; jmp start
|
||||||
jsr init ;one-time call to unhook DOS
|
jsr init ;one-time call to unhook DOS
|
||||||
;open and read a file
|
;open and read a file
|
||||||
lda #<file_to_read
|
lda #<file_to_read
|
||||||
@@ -64,50 +65,57 @@ init:
|
|||||||
; sta A2L
|
; sta A2L
|
||||||
; lda #>(unreloc+(codeend-opendir)-1)
|
; lda #>(unreloc+(codeend-opendir)-1)
|
||||||
; sta A2H
|
; sta A2H
|
||||||
; ldy #0
|
ldy #0
|
||||||
; sty A4L
|
; sty A4L
|
||||||
; lda #>reloc
|
; lda #>reloc
|
||||||
; sta A4H
|
; sta A4H
|
||||||
; jsr MOVE ; move mem from A1-A2 to location A4
|
; jsr MOVE ; move mem from A1-A2 to location A4
|
||||||
|
|
||||||
|
; Create nibble table?
|
||||||
ldx #3
|
ldx #3
|
||||||
L1: stx $3c
|
L1: stx $3c ; store tempx (3?)
|
||||||
txa
|
txa ; a=x (a=3)
|
||||||
asl
|
asl ; a*=2 (a=6)
|
||||||
bit $3c
|
bit $3c ; a&tempx, set N/V (a=6)
|
||||||
beq L3
|
beq L3 ; if 0, skip to L3
|
||||||
ora $3c
|
ora $3c ; a|=tempx (a=7)
|
||||||
eor #$ff
|
eor #$ff ; a=~a (a=f8)
|
||||||
and #$7e
|
and #$7e ; a&=0x7e 0111 1110 (a=78)
|
||||||
L2: bcs L3
|
L2: bcs L3 ; this set way back at asl??
|
||||||
lsr
|
lsr ; a>>1 a=3c c=0
|
||||||
bne L2
|
; a=1e c=0
|
||||||
tya
|
; a=0f c=0
|
||||||
sta nibtbl, x
|
; a=07 c=1
|
||||||
iny
|
bne L2 ; if a!=0 goto l2
|
||||||
L3: inx
|
tya ; if a==0, a=y
|
||||||
bpl L1
|
sta nibtbl, x ; write out to table
|
||||||
|
iny ; increment y
|
||||||
|
L3: inx ; increment x x=4, a=0f
|
||||||
|
bpl L1 ; loop while high bit not set
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.align $100
|
||||||
unreloc:
|
unreloc:
|
||||||
;!pseudopc reloc {
|
;!pseudopc reloc {
|
||||||
|
|
||||||
;turn on drive and read volume table of contents
|
;turn on drive and read volume table of contents
|
||||||
|
|
||||||
opendir:
|
opendir:
|
||||||
lda $c0e9
|
lda $c0e9 ; turn slot#6 drive on
|
||||||
ldx #0
|
ldx #0
|
||||||
stx adrlo
|
stx adrlo ; zero out adrlo
|
||||||
stx secsize
|
stx secsize ; zero out secsize
|
||||||
lda #$11
|
lda #$11 ; a=$11 (VTOC?)
|
||||||
jsr readdirsec
|
jsr readdirsec
|
||||||
firstent:
|
firstent:
|
||||||
|
jmp firstent
|
||||||
|
|
||||||
lda dirbuf+1
|
lda dirbuf+1
|
||||||
|
|
||||||
;lock if entry not found
|
;lock if entry not found
|
||||||
|
entry_not_found:
|
||||||
beq *
|
beq entry_not_found
|
||||||
|
|
||||||
;read directory sector
|
;read directory sector
|
||||||
|
|
||||||
@@ -275,6 +283,12 @@ L7:
|
|||||||
bpl L7
|
bpl L7
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;======================
|
||||||
|
; readdirsec
|
||||||
|
;======================
|
||||||
|
; a = track?
|
||||||
|
; x = sector?
|
||||||
readdirsec:
|
readdirsec:
|
||||||
ldy #>dirbuf
|
ldy #>dirbuf
|
||||||
seekread:
|
seekread:
|
||||||
@@ -289,47 +303,55 @@ seekread1:
|
|||||||
|
|
||||||
lda curtrk
|
lda curtrk
|
||||||
cmp phase
|
cmp phase
|
||||||
beq checksec
|
beq repeat_until_right_sector
|
||||||
jsr seek
|
jsr seek
|
||||||
|
|
||||||
; [re-]read sector
|
; [re-]read sector
|
||||||
|
|
||||||
L8:
|
re_read_addr:
|
||||||
jsr readadr
|
jsr readadr
|
||||||
checksec:
|
|
||||||
cmp reqsec
|
|
||||||
bne L8
|
|
||||||
|
|
||||||
|
repeat_until_right_sector:
|
||||||
|
cmp reqsec
|
||||||
|
bne re_read_addr
|
||||||
|
|
||||||
|
blah2: jmp blah2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;==========================
|
||||||
; read sector data
|
; read sector data
|
||||||
|
;==========================
|
||||||
|
;
|
||||||
|
|
||||||
readdata:
|
readdata:
|
||||||
ldy $c0ec
|
ldy $c0ec ; read data until valid
|
||||||
bpl readdata
|
bpl readdata
|
||||||
L9:
|
find_D5:
|
||||||
cpy #$d5
|
cpy #$d5 ; if not D5, repeat
|
||||||
bne readdata
|
bne readdata
|
||||||
L10:
|
find_AA:
|
||||||
ldy $c0ec
|
ldy $c0ec ; read data until valid, should be AA
|
||||||
bpl L10
|
bpl find_AA
|
||||||
cpy #$aa ;we need Y=#$AA later
|
cpy #$aa ; we need Y=#$AA later
|
||||||
bne L9
|
bne find_D5
|
||||||
L11:
|
find_AD:
|
||||||
lda $c0ec
|
lda $c0ec ; read data until high bit set (valid)
|
||||||
bpl L11
|
bpl find_AD
|
||||||
eor #$ad ;zero A if match
|
eor #$ad ; should match $ad
|
||||||
bne * ;lock if read failure
|
bne * ; lock if didn't find $ad (failure)
|
||||||
L12:
|
L12:
|
||||||
ldx $c0ec
|
ldx $c0ec ; read data until high bit set (valid)
|
||||||
bpl L12
|
bpl L12
|
||||||
eor nibtbl-$80, x
|
eor nibtbl-$80, x
|
||||||
sta bit2tbl-$aa, y
|
sta bit2tbl-$aa, y
|
||||||
iny
|
iny
|
||||||
bne L12
|
bne L12
|
||||||
L13:
|
L13:
|
||||||
ldx $c0ec
|
ldx $c0ec ; read data until high bit set (valid)
|
||||||
bpl L13
|
bpl L13
|
||||||
eor nibtbl-$80, x
|
eor nibtbl-$80, x
|
||||||
sta (adrlo), y ;the real address
|
sta (adrlo), y ; the real address
|
||||||
iny
|
iny
|
||||||
cpy secsize
|
cpy secsize
|
||||||
bne L13
|
bne L13
|
||||||
@@ -350,39 +372,50 @@ L15:
|
|||||||
bne L15
|
bne L15
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;no tricks here, just the regular stuff
|
; no tricks here, just the regular stuff
|
||||||
|
|
||||||
|
;=================
|
||||||
|
; readadr -- read address field
|
||||||
|
;=================
|
||||||
|
; Find address field, put track in cutrk, sector in tmpsec
|
||||||
readadr:
|
readadr:
|
||||||
lda $c0ec
|
lda $c0ec ; read data until we find a $D5
|
||||||
bpl readadr
|
bpl readadr
|
||||||
L16:
|
adr_d5:
|
||||||
cmp #$d5
|
cmp #$d5
|
||||||
bne readadr
|
bne readadr
|
||||||
L17:
|
|
||||||
lda $c0ec
|
adr_aa:
|
||||||
bpl L17
|
lda $c0ec ; read data until we find a $AA
|
||||||
|
bpl adr_aa
|
||||||
cmp #$aa
|
cmp #$aa
|
||||||
bne L16
|
bne adr_d5
|
||||||
L18:
|
|
||||||
lda $c0ec
|
adr_96:
|
||||||
bpl L18
|
lda $c0ec ; read data until we find a $96
|
||||||
|
bpl adr_96
|
||||||
cmp #$96
|
cmp #$96
|
||||||
bne L16
|
bne adr_d5
|
||||||
ldy #3
|
|
||||||
L19:
|
ldy #3 ; three?
|
||||||
sta curtrk
|
; first read volume/volume
|
||||||
|
; then track/track
|
||||||
|
; then sector/sector?
|
||||||
|
adr_read_two_bytes:
|
||||||
|
sta curtrk ; store out current track
|
||||||
L20:
|
L20:
|
||||||
lda $c0ec
|
lda $c0ec ; read until full value
|
||||||
bpl L20
|
bpl L20
|
||||||
rol
|
rol
|
||||||
sta tmpsec
|
sta tmpsec
|
||||||
L21:
|
L21:
|
||||||
lda $c0ec
|
lda $c0ec ; read until full value
|
||||||
bpl L21
|
bpl L21 ; sector value is (v1<<1)&v2????
|
||||||
and tmpsec
|
and tmpsec
|
||||||
dey
|
dey ; loop 3 times
|
||||||
bne L19
|
bne adr_read_two_bytes
|
||||||
rts
|
|
||||||
|
rts ; return
|
||||||
|
|
||||||
;=====================
|
;=====================
|
||||||
; Stepper motor delay
|
; Stepper motor delay
|
||||||
@@ -408,24 +441,27 @@ seekret:
|
|||||||
;================
|
;================
|
||||||
; SEEK
|
; SEEK
|
||||||
;================
|
;================
|
||||||
|
; current track in curtrk
|
||||||
|
; desired track in phase
|
||||||
seek:
|
seek:
|
||||||
asl curtrk
|
asl curtrk
|
||||||
lda #0
|
lda #0
|
||||||
sta step ; *** WAS *** stz step
|
sta step ; *** WAS *** stz step
|
||||||
asl phase
|
asl phase
|
||||||
copy_cur:
|
copy_cur:
|
||||||
lda curtrk
|
lda curtrk ; load current track
|
||||||
sta tmptrk
|
sta tmptrk ; store as temtrk
|
||||||
|
sec ; calc current-desired
|
||||||
|
sbc phase ;
|
||||||
|
beq seekret ; if they match, we are done!
|
||||||
|
|
||||||
|
bcs seek_neg ; if negative, skip ahead
|
||||||
|
eor #$ff ; ones-complement the distance
|
||||||
|
inc curtrk ; increment current?
|
||||||
|
bcc L25 ; skip ahead
|
||||||
|
seek_neg:
|
||||||
sec
|
sec
|
||||||
sbc phase
|
sbc #1 ; *** WAS *** dec
|
||||||
beq seekret
|
|
||||||
bcs L24
|
|
||||||
eor #$ff
|
|
||||||
inc curtrk
|
|
||||||
bcc L25
|
|
||||||
L24:
|
|
||||||
sec
|
|
||||||
sbc #1 ; *** WAS *** dec
|
|
||||||
dec curtrk
|
dec curtrk
|
||||||
L25:
|
L25:
|
||||||
cmp step
|
cmp step
|
||||||
@@ -449,11 +485,32 @@ L27:
|
|||||||
step1: .byte $01, $30, $28, $24, $20, $1e, $1d, $1c
|
step1: .byte $01, $30, $28, $24, $20, $1e, $1d, $1c
|
||||||
step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
step2: .byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c
|
||||||
|
|
||||||
sectbl: .byte 0, $0d, $0b, 9, 7, 5, 3, 1, $0e, $0c, $0a, 8, 6, 4, 2, $0f
|
sectbl: .byte $00,$0d,$0b,$09,$07,$05,$03,$01,$0e,$0c,$0a,$08,$06,$04,$02,$0f
|
||||||
|
|
||||||
|
.align $100
|
||||||
|
|
||||||
codeend = *
|
codeend = *
|
||||||
|
|
||||||
nibtbl = *
|
; From $BA96 of DOS33
|
||||||
|
nibtbl = *
|
||||||
|
; .byte $00,$01,$98,$99,$02,$03,$9C,$04 ; $BA96 ; 00
|
||||||
|
; .byte $05,$06,$A0,$A1,$A2,$A4,$A4,$A5 ; $BA9E ; 08
|
||||||
|
; .byte $07,$08,$A8,$A9,$AA,$09,$0A,$0B ; $BAA6 ; 10
|
||||||
|
; .byte $0C,$0D,$B0,$B1,$0E,$0F,$10,$11 ; $BAAE ; 18
|
||||||
|
; .byte $12,$13,$B8,$14,$15,$16,$17,$18 ; $BAB6 ; 20
|
||||||
|
; .byte $19,$1A,$C0,$C1,$C2,$C3,$C4,$C5 ; $BABE ; 28
|
||||||
|
; .byte $C6,$C7,$C8,$C9,$CA,$1B,$CC,$1C ; $BAC6 ; 30
|
||||||
|
; .byte $1D,$1E,$D0,$D1,$D2,$1E,$D4,$D5 ; $BACE ; 38
|
||||||
|
; .byte $20,$21,$D8,$22,$23,$24,$25,$26 ; $BAD6 ; 40
|
||||||
|
; .byte $27,$28,$E0,$E1,$E2,$E3,$E4,$29 ; $BADE ; 48
|
||||||
|
; .byte $2A,$2B,$E8,$2C,$2D,$2E,$2F,$30 ; $BAE6 ; 50
|
||||||
|
; .byte $31,$32,$F0,$F1,$33,$34,$35,$36 ; $BAEE ; 58
|
||||||
|
; .byte $37,$38,$F8,$39,$3A,$3B,$3C,$3D ; $BAF6 ; 60
|
||||||
|
; .byte $3E,$3F,$13,$00,$01,$02,$01,$00 ; $BAFE ; 68
|
||||||
|
; .byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
; .byte $00,$00,$00,$00,$00,$00,$00,$00
|
||||||
|
|
||||||
|
|
||||||
bit2tbl = nibtbl+128
|
bit2tbl = nibtbl+128
|
||||||
filbuf = bit2tbl+86
|
filbuf = bit2tbl+86
|
||||||
dataend = filbuf+4
|
dataend = filbuf+4
|
||||||
|
Reference in New Issue
Block a user