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