peasant: more work on disk code
This commit is contained in:
parent
597570daf1
commit
a730979e71
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
check_floppy_in_drive2:
|
check_floppy_in_drive2:
|
||||||
|
|
||||||
|
|
||||||
; anti-m does E9,EB, spinup (motor on, then select d2?)
|
; anti-m does E9,EB, spinup (motor on, then select d2?)
|
||||||
; then delays, then seeks
|
; then delays, then seeks
|
||||||
; at end, driveoff E8
|
; at end, driveoff E8
|
||||||
|
@ -41,23 +42,25 @@ check_floppy_in_drive2:
|
||||||
jsr switch_drive2
|
jsr switch_drive2
|
||||||
|
|
||||||
jsr driveon ; turn drive on
|
jsr driveon ; turn drive on
|
||||||
|
|
||||||
; seems counter-intuitive but you're
|
; seems counter-intuitive but you're
|
||||||
; supposed to do this before
|
; supposed to do this before
|
||||||
; switching to drive2?
|
; switching to drive2?
|
||||||
|
; the driveon code does this internally
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; seek to track 0
|
; seek to track 0
|
||||||
|
|
||||||
lda #(40*2) ; worst case scenario(?)
|
lda #$44 ; 68 = 34 tracks; worst case scenario(?)
|
||||||
sta curtrk_smc+1
|
sta curtrk_smc+1
|
||||||
lda #0 ; seek to track0
|
lda #0 ; seek to track0
|
||||||
sta phase_smc+1
|
sta phase_smc+1
|
||||||
|
;.if 0
|
||||||
jsr seek
|
jsr seek
|
||||||
|
;.endif
|
||||||
|
|
||||||
|
;; brk
|
||||||
|
|
||||||
;=====================================
|
;=====================================
|
||||||
; try 768 times to find valid sector
|
; try 768 times to find valid sector
|
||||||
|
@ -104,6 +107,8 @@ check_if_96:
|
||||||
; because result was greater or equal to #$96
|
; because result was greater or equal to #$96
|
||||||
|
|
||||||
done_check:
|
done_check:
|
||||||
|
brk
|
||||||
|
|
||||||
jsr driveoff
|
jsr driveoff
|
||||||
|
|
||||||
jsr wait_1s
|
jsr wait_1s
|
||||||
|
@ -114,6 +119,7 @@ done_check:
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
done_check_failed:
|
done_check_failed:
|
||||||
jsr driveoff
|
jsr driveoff
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,10 @@ preread:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
switch_drive1:
|
switch_drive1:
|
||||||
|
; lda CURRENT_DRIVE
|
||||||
|
; cmp #1
|
||||||
|
; beq switch_drive1
|
||||||
|
|
||||||
lda curtrk_smc+1
|
lda curtrk_smc+1
|
||||||
sta DRIVE2_TRACK ; save track location
|
sta DRIVE2_TRACK ; save track location
|
||||||
;slotpatch10:
|
;slotpatch10:
|
||||||
|
@ -252,6 +256,10 @@ switch_drive1:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
switch_drive2:
|
switch_drive2:
|
||||||
|
; lda CURRENT_DRIVE
|
||||||
|
; cmp #2
|
||||||
|
; beq switch_drive2
|
||||||
|
|
||||||
lda curtrk_smc+1
|
lda curtrk_smc+1
|
||||||
sta DRIVE1_TRACK ; save track location
|
sta DRIVE1_TRACK ; save track location
|
||||||
;slotpatch11:
|
;slotpatch11:
|
||||||
|
|
|
@ -101,9 +101,9 @@ inner_read:
|
||||||
another:
|
another:
|
||||||
jsr readnib
|
jsr readnib
|
||||||
rol ; set carry
|
rol ; set carry
|
||||||
sta sector+1
|
sta sector_smc+1
|
||||||
jsr readnib
|
jsr readnib
|
||||||
and sector+1
|
and sector_smc+1
|
||||||
dey
|
dey
|
||||||
bpl another
|
bpl another
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ another:
|
||||||
ldx addrtbl, Y ; fetch corresponding address
|
ldx addrtbl, Y ; fetch corresponding address
|
||||||
beq read ; done?
|
beq read ; done?
|
||||||
|
|
||||||
sta sector+1 ; store index for later
|
sta sector_smc+1 ; store index for later
|
||||||
|
|
||||||
stx adrpatch1+2
|
stx adrpatch1+2
|
||||||
stx adrpatch8+2
|
stx adrpatch8+2
|
||||||
|
@ -145,7 +145,7 @@ check_mode:
|
||||||
beq read ; loop if not expecting #$AD
|
beq read ; loop if not expecting #$AD
|
||||||
|
|
||||||
loop33:
|
loop33:
|
||||||
sta tmpval+1 ; zero rolling checksum
|
sta tmpval_smc+1 ; zero rolling checksum
|
||||||
slotpatch2:
|
slotpatch2:
|
||||||
loop4:
|
loop4:
|
||||||
ldx $c0d1
|
ldx $c0d1
|
||||||
|
@ -154,7 +154,7 @@ loop4:
|
||||||
adrpatch2:
|
adrpatch2:
|
||||||
sta $d102, Y ; store 2-bit array
|
sta $d102, Y ; store 2-bit array
|
||||||
|
|
||||||
tmpval:
|
tmpval_smc:
|
||||||
eor #$d1
|
eor #$d1
|
||||||
iny
|
iny
|
||||||
bne loop33
|
bne loop33
|
||||||
|
@ -216,7 +216,7 @@ adrpatch9:
|
||||||
branch_read2:
|
branch_read2:
|
||||||
bcs branch_read ; branch if checksum failure
|
bcs branch_read ; branch if checksum failure
|
||||||
|
|
||||||
sector:
|
sector_smc:
|
||||||
ldy #$d1
|
ldy #$d1
|
||||||
txa
|
txa
|
||||||
sta addrtbl, Y ; zero corresponding address
|
sta addrtbl, Y ; zero corresponding address
|
||||||
|
@ -243,33 +243,45 @@ slotpatch7:
|
||||||
seekret:
|
seekret:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;=================================
|
||||||
|
;=================================
|
||||||
|
; seek, SEEK!
|
||||||
|
;=================================
|
||||||
|
;=================================
|
||||||
|
; phase_smc+1 = track*2 to seek to
|
||||||
|
; curtrk+1 = current track
|
||||||
|
|
||||||
seek:
|
seek:
|
||||||
ldx #0
|
ldx #0
|
||||||
stx step+1
|
stx step_smc+1
|
||||||
|
|
||||||
copy_cur:
|
copy_cur:
|
||||||
|
|
||||||
curtrk_smc:
|
curtrk_smc:
|
||||||
lda #0
|
lda #0 ; current track
|
||||||
sta tmpval+1
|
sta tmpval_smc+1
|
||||||
sec
|
sec
|
||||||
phase_smc: ; track*2 to seek to
|
phase_smc:
|
||||||
sbc #$d1
|
sbc #$d1 ; track*2 to seek to
|
||||||
beq seekret
|
beq seekret ; if equal, we are already there
|
||||||
|
|
||||||
; if seek backwards
|
; A is distance
|
||||||
bcs sback
|
bcs sback ; if positive, skip ahead
|
||||||
|
|
||||||
eor #$ff
|
eor #$ff ; negate the distance
|
||||||
inc curtrk_smc+1
|
inc curtrk_smc+1 ; move track counter up
|
||||||
|
|
||||||
|
bcc ssback ; bra
|
||||||
|
|
||||||
bcc ssback
|
|
||||||
sback:
|
sback:
|
||||||
adc #$fe
|
adc #$fe ; distance -=2
|
||||||
dec curtrk_smc+1
|
dec curtrk_smc+1 ; move track counter down
|
||||||
ssback:
|
ssback:
|
||||||
cmp step+1
|
cmp step_smc+1 ; compare to step
|
||||||
bcc loop10
|
bcc loop10 ; if less than, skip
|
||||||
step:
|
|
||||||
lda #$d1
|
step_smc:
|
||||||
|
lda #$d1 ; load step value
|
||||||
loop10:
|
loop10:
|
||||||
cmp #8
|
cmp #8
|
||||||
bcs loop11
|
bcs loop11
|
||||||
|
@ -279,30 +291,38 @@ loop11:
|
||||||
lda curtrk_smc+1
|
lda curtrk_smc+1
|
||||||
ldx step1, Y
|
ldx step1, Y
|
||||||
bne loop12
|
bne loop12
|
||||||
|
|
||||||
|
|
||||||
loopmmm:
|
loopmmm:
|
||||||
clc
|
clc
|
||||||
lda tmpval+1
|
lda tmpval_smc+1
|
||||||
ldx step2, Y
|
ldx step2, Y
|
||||||
loop12:
|
loop12:
|
||||||
stx sector+1
|
stx sector_smc+1
|
||||||
and #3
|
and #3
|
||||||
rol
|
rol
|
||||||
tax
|
tax
|
||||||
slotpatch8:
|
slotpatch8:
|
||||||
sta $c0d1, X
|
sta $c0d1, X ; PHASEOFF $c080 / $c0e0
|
||||||
loopmm:
|
loopmm:
|
||||||
ldx #$13
|
|
||||||
|
; delay 2+(19*5)+1 = 98 cycles = ~100us
|
||||||
|
|
||||||
|
ldx #$13 ; 2
|
||||||
loopm:
|
loopm:
|
||||||
dex
|
dex ; 2
|
||||||
bne loopm
|
bne loopm ; 2/3
|
||||||
dec sector+1
|
|
||||||
|
dec sector_smc+1
|
||||||
bne loopmm
|
bne loopmm
|
||||||
|
|
||||||
lsr
|
lsr
|
||||||
bcs loopmmm
|
bcs loopmmm
|
||||||
inc step+1
|
|
||||||
bne copy_cur
|
|
||||||
|
|
||||||
step1: .byte 1, $30, $28, $24, $20, $1e, $1d, $1c
|
inc step_smc+1
|
||||||
|
bne copy_cur ; bra?
|
||||||
|
|
||||||
|
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
|
||||||
addrtbl: .res 16
|
addrtbl: .res 16
|
||||||
|
|
||||||
|
@ -344,12 +364,17 @@ done_drive_select:
|
||||||
|
|
||||||
|
|
||||||
; wait 1s
|
; wait 1s
|
||||||
|
|
||||||
|
; WAIT takes 1/2(26+27A+5A^2) us
|
||||||
|
; so for A=255 = (26+6885 +325125)*1/2 = 166018s *6 = ~1s
|
||||||
|
|
||||||
|
; 6, 5, 4, 3, 2, 1
|
||||||
wait_1s:
|
wait_1s:
|
||||||
ldx #6
|
ldx #6 ; 2
|
||||||
wait_1s_loop:
|
wait_1s_loop:
|
||||||
lda #255
|
lda #255 ; 2
|
||||||
jsr wait
|
jsr wait ; 6
|
||||||
dex
|
dex ; 2
|
||||||
bne wait_1s_loop
|
bne wait_1s_loop
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
|
@ -2,38 +2,38 @@ load_file =$0b2a
|
||||||
sector_write =$0c85
|
sector_write =$0c85
|
||||||
check_floppy_in_drive2 =$0de6
|
check_floppy_in_drive2 =$0de6
|
||||||
requested_sector =$0d17
|
requested_sector =$0d17
|
||||||
decompress_lzsa2_fast =$0e35
|
decompress_lzsa2_fast =$0e36
|
||||||
getsrc_smc =$0f2b
|
getsrc_smc =$0f2c
|
||||||
hgr2 =$1831
|
hgr2 =$1832
|
||||||
hgr_make_tables =$15a5
|
hgr_make_tables =$15a6
|
||||||
hgr_put_string =$0f38
|
hgr_put_string =$0f39
|
||||||
restore_bg_1x28 =$1470
|
restore_bg_1x28 =$1471
|
||||||
hgr_draw_sprite_1x28 =$1409
|
hgr_draw_sprite_1x28 =$140a
|
||||||
input_buffer =$157d
|
input_buffer =$157e
|
||||||
hgr_text_box =$161b
|
hgr_text_box =$161c
|
||||||
hgr_text_box_nosave =$16b2
|
hgr_text_box_nosave =$16b3
|
||||||
hgr_partial_restore =$14f3
|
hgr_partial_restore =$14f4
|
||||||
clear_bottom =$1806
|
clear_bottom =$1807
|
||||||
hgr_input =$1523
|
hgr_input =$1524
|
||||||
draw_box =$12ba
|
draw_box =$12bb
|
||||||
disp_put_string =$1656
|
disp_put_string =$1657
|
||||||
disp_one_line =$166a
|
disp_one_line =$166b
|
||||||
invert_smc1 =$0fb0
|
invert_smc1 =$0fb1
|
||||||
disp_put_string_cursor =$1666
|
disp_put_string_cursor =$1667
|
||||||
hgr_put_char_cursor =$0f64
|
hgr_put_char_cursor =$0f65
|
||||||
vgi_simple_rectangle =$133b
|
vgi_simple_rectangle =$133c
|
||||||
peasant_text =$1f65
|
peasant_text =$1f66
|
||||||
save_menu =$18e4
|
save_menu =$18e5
|
||||||
load_menu =$18d9
|
load_menu =$18da
|
||||||
location_names_l =$1c11
|
location_names_l =$1c12
|
||||||
location_names_h =$1c30
|
location_names_h =$1c31
|
||||||
wait_until_keypress =$1e50
|
wait_until_keypress =$1e51
|
||||||
random16 =$1e59
|
random16 =$1e5a
|
||||||
score_points =$1ede
|
score_points =$1edf
|
||||||
print_score =$1e8e
|
print_score =$1e8f
|
||||||
update_score =$1e99
|
update_score =$1e9a
|
||||||
speaker_beep =$1f4c
|
speaker_beep =$1f4d
|
||||||
speaker_duration =$1f63
|
speaker_duration =$1f64
|
||||||
speaker_frequency =$1f64
|
speaker_frequency =$1f65
|
||||||
hposn_high = $BA00
|
hposn_high = $BA00
|
||||||
hposn_low = $BB00
|
hposn_low = $BB00
|
||||||
|
|
Loading…
Reference in New Issue