peasant: properly patch the drive1/drive2 code for slot

This commit is contained in:
Vince Weaver 2022-01-08 01:10:09 -05:00
parent 2ad94749c6
commit 69f5e0a3b3
5 changed files with 89 additions and 54 deletions

View File

@ -80,7 +80,8 @@ qload.o: qload.s qboot.inc \
hgr_copy.s \ hgr_copy.s \
gr_offsets.s \ gr_offsets.s \
qkumba_popwr.s \ qkumba_popwr.s \
random16.s random16.s \
drive2.s
ca65 -o qload.o qload.s -l qload.lst ca65 -o qload.o qload.s -l qload.lst
### ###
@ -116,6 +117,8 @@ qboot.inc: generate_common QBOOT
./generate_common -a 0x000 -s phase_smc qboot_sector.lst >> qboot.inc ./generate_common -a 0x000 -s phase_smc qboot_sector.lst >> qboot.inc
./generate_common -a 0x000 -s driveon qboot_sector.lst >> qboot.inc ./generate_common -a 0x000 -s driveon qboot_sector.lst >> qboot.inc
./generate_common -a 0x000 -s driveoff qboot_sector.lst >> qboot.inc ./generate_common -a 0x000 -s driveoff qboot_sector.lst >> qboot.inc
./generate_common -a 0x000 -s switch_drive1 qboot_sector.lst >> qboot.inc
./generate_common -a 0x000 -s switch_drive2 qboot_sector.lst >> qboot.inc
./generate_common -a 0x000 -s load_new qboot_sector.lst >> qboot.inc ./generate_common -a 0x000 -s load_new qboot_sector.lst >> qboot.inc
./generate_common -a 0x000 -s load_address qboot_sector.lst >> qboot.inc ./generate_common -a 0x000 -s load_address qboot_sector.lst >> qboot.inc
echo "load_track=load_address+1" >> qboot.inc echo "load_track=load_address+1" >> qboot.inc

View File

@ -1,6 +1,5 @@
; roughly based on anti-m/anti-m.a ; roughly based on anti-m/anti-m.a
; Notes from qkumba/4am ; Notes from qkumba/4am
; Drive with no disk and no motor, will return same value in range $00..$7f ; Drive with no disk and no motor, will return same value in range $00..$7f
@ -9,13 +8,12 @@
; so the best way to detect if disk is there is to try seeking/reading ; so the best way to detect if disk is there is to try seeking/reading
; and seeing if you get valid data ; and seeing if you get valid data
.if 0
; FIXME: patch these
switch_drive1: switch_drive1:
lda curtrk_smc+1 lda curtrk_smc+1
sta DRIVE2_TRACK ; save track location sta DRIVE2_TRACK ; save track location
lda $C0EA ; drive 1 select slotpatch10:
lda $C0d1 ; drive 1 select
lda #1 lda #1
sta CURRENT_DRIVE sta CURRENT_DRIVE
lda DRIVE1_TRACK ; restore saved track location lda DRIVE1_TRACK ; restore saved track location
@ -25,12 +23,14 @@ switch_drive1:
switch_drive2: switch_drive2:
lda curtrk_smc+1 lda curtrk_smc+1
sta DRIVE1_TRACK ; save track location sta DRIVE1_TRACK ; save track location
lda $C0EB ; drive 2 select slotpatch11:
lda $C0d1 ; drive 2 select
lda #2 lda #2
sta CURRENT_DRIVE sta CURRENT_DRIVE
lda DRIVE2_TRACK ; restore saved track location lda DRIVE2_TRACK ; restore saved track location
sta curtrk_smc+1 sta curtrk_smc+1
rts rts
.endif
;================================= ;=================================
; check floppy in drive2 ; check floppy in drive2
@ -48,13 +48,7 @@ check_floppy_in_drive2:
jsr switch_drive2 jsr switch_drive2
jsr driveon jsr driveon ; turn drive on
; lda $C0E9 ; motor on 1110 1001
; jsr spinup ; spin up drive
; jsr seek_track0 ; seek to track0
; seek to track 0 ; seek to track 0
@ -88,7 +82,8 @@ check_drive2_loop:
keep_trying: keep_trying:
get_valid_byte: get_valid_byte:
lda $C0EC ; read byte ; lda $C0EC ; read byte
jsr readnib
bpl get_valid_byte ; keep trying if high bit not set bpl get_valid_byte ; keep trying if high bit not set
check_if_d5: check_if_d5:
@ -96,13 +91,15 @@ check_if_d5:
bne check_drive2_loop ; if not, try again bne check_drive2_loop ; if not, try again
check_if_aa: check_if_aa:
lda $C0EC ; read byte ; lda $C0EC ; read byte
jsr readnib
bpl check_if_aa ; keep trying until valid bpl check_if_aa ; keep trying until valid
cmp #$AA ; see if aa cmp #$AA ; see if aa
bne get_valid_byte ; if not try again bne get_valid_byte ; if not try again
check_if_96: check_if_96:
lda $C0EC ; read byte ; lda $C0EC ; read byte
jsr readnib
bpl check_if_96 ; keep trying until valid bpl check_if_96 ; keep trying until valid
cmp #$96 ; see if 96 cmp #$96 ; see if 96
bne check_if_d5 ; if not try again bne check_if_d5 ; if not try again
@ -115,5 +112,3 @@ done_check:
jmp switch_drive1 ; tail call jmp switch_drive1 ; tail call

View File

@ -3,6 +3,8 @@ curtrk_smc =$0a2b
phase_smc =$0a31 phase_smc =$0a31
driveon =$0a9d driveon =$0a9d
driveoff =$0a22 driveoff =$0a22
switch_drive1 =$08af
switch_drive2 =$08c1
load_new =$0aab load_new =$0aab
load_address =$0ac4 load_address =$0ac4
load_track=load_address+1 load_track=load_address+1

View File

@ -1,6 +1,8 @@
; fast seek/multi-read ; fast seek/multi-read
; copyright (c) Peter Ferrie 2015-16 ; copyright (c) Peter Ferrie 2015-16
.include "zp.inc"
; Paramaters for loading QLOAD ; Paramaters for loading QLOAD
sectors = 21 ; user-defined sectors = 21 ; user-defined
@ -22,7 +24,7 @@
znibble = $fe ; only during init znibble = $fe ; only during init
zmask = $ff ; only during init zmask = $ff ; only during init
WHICH_SLOT = $DA ; WHICH_SLOT = $DA
; $26/$27 sector read location (ROM) ; $26/$27 sector read location (ROM)
; $3D sector number (ROM) ; $3D sector number (ROM)
@ -110,6 +112,17 @@ patch_loop:
eor #9 ; PHASEOFF (c080) eor #9 ; PHASEOFF (c080)
sta slotpatch8+1 sta slotpatch8+1
; patch self-modifying code for disk1
ora #$A ; (C08A)
sta slotpatch10+1
; patch self-modifying code for disk2
ora #$1 ; (C08B)
sta slotpatch11+1
;========================
; ???
ldx #$3f ldx #$3f
stx zmask stx zmask
inx inx
@ -227,6 +240,28 @@ preread:
ldy #firstsec ldy #firstsec
rts rts
switch_drive1:
lda curtrk_smc+1
sta DRIVE2_TRACK ; save track location
slotpatch10:
lda $C0d1 ; drive 1 select
lda #1
sta CURRENT_DRIVE
lda DRIVE1_TRACK ; restore saved track location
sta curtrk_smc+1
rts
switch_drive2:
lda curtrk_smc+1
sta DRIVE1_TRACK ; save track location
slotpatch11:
lda $C0d1 ; drive 2 select
lda #2
sta CURRENT_DRIVE
lda DRIVE2_TRACK ; restore saved track location
sta curtrk_smc+1
rts
end_code: end_code:

View File

@ -1,40 +1,40 @@
load_file =$0b24 load_file =$0b24
sector_write =$0c7f sector_write =$0c7f
check_floppy_in_drive2 =$0e0a check_floppy_in_drive2 =$0de6
requested_sector =$0d17 requested_sector =$0d17
decompress_lzsa2_fast =$0e49 decompress_lzsa2_fast =$0e25
getsrc_smc =$0f3f getsrc_smc =$0f1b
hgr2 =$1845 hgr2 =$1821
hgr_make_tables =$15b9 hgr_make_tables =$1595
hgr_put_string =$0f4c hgr_put_string =$0f28
restore_bg_1x28 =$1484 restore_bg_1x28 =$1460
hgr_draw_sprite_1x28 =$141d hgr_draw_sprite_1x28 =$13f9
input_buffer =$1591 input_buffer =$156d
hgr_text_box =$162f hgr_text_box =$160b
hgr_text_box_nosave =$16c6 hgr_text_box_nosave =$16a2
hgr_partial_restore =$1507 hgr_partial_restore =$14e3
clear_bottom =$181a clear_bottom =$17f6
hgr_input =$1537 hgr_input =$1513
draw_box =$12ce draw_box =$12aa
disp_put_string =$166a disp_put_string =$1646
disp_one_line =$167e disp_one_line =$165a
invert_smc1 =$0fc4 invert_smc1 =$0fa0
disp_put_string_cursor =$167a disp_put_string_cursor =$1656
hgr_put_char_cursor =$0f78 hgr_put_char_cursor =$0f54
vgi_simple_rectangle =$134f vgi_simple_rectangle =$132b
peasant_text =$1f79 peasant_text =$1f55
save_menu =$18f8 save_menu =$18d4
load_menu =$18ed load_menu =$18c9
location_names_l =$1c25 location_names_l =$1c01
location_names_h =$1c44 location_names_h =$1c20
wait_until_keypress =$1e64 wait_until_keypress =$1e40
random16 =$1e6d random16 =$1e49
score_points =$1ef2 score_points =$1ece
print_score =$1ea2 print_score =$1e7e
update_score =$1ead update_score =$1e89
speaker_beep =$1f60 speaker_beep =$1f3c
speaker_duration =$1f77 speaker_duration =$1f53
speaker_frequency =$1f78 speaker_frequency =$1f54
hposn_high = $BA00 hposn_high = $BA00
hposn_low = $BB00 hposn_low = $BB00
driveoff = $A22 driveoff = $A22