diff --git a/games/peasant/drive2.s b/games/peasant/drive2.s index 84f4fe82..3650537e 100644 --- a/games/peasant/drive2.s +++ b/games/peasant/drive2.s @@ -57,10 +57,11 @@ check_floppy_in_drive2: lda #0 ; seek to track0 sta phase_smc+1 ;.if 0 +; jsr antim_seek_track0 jsr seek ;.endif -;; brk +; brk ;===================================== ; try 768 times to find valid sector @@ -107,7 +108,7 @@ check_if_96: ; because result was greater or equal to #$96 done_check: - brk +; brk jsr driveoff @@ -131,4 +132,88 @@ done_check_failed: rts +.if 0 +step=$fd +phase=$fe +tmptrk=$ff +tmpsec2=$3c +; $3d also modified? + +antim_seek_track0: + ldy #0 + sty step + sty phase + lda #$44 + sta tmptrk + +copy_cur: + lda tmptrk + sta tmpsec2 + sec + sbc phase + beq lPPP1 + bcs lP1 + eor #$ff + inc tmptrk + bcc lPP1 +lP1: + sbc #1 + dec tmptrk +lPP1: + cmp step + bcc lP2 + lda step +lP2: + cmp #8 + bcs lP3 + tay + sec +lP3: + jsr lPPPP1 + lda step1, y + jsr adelay + lda tmpsec2 + clc + jsr lPPPPP1 + lda step2, y + jsr adelay + inc step + bne copy_cur +lPPP1: + jsr adelay + clc +lPPPP1: + lda tmptrk + +lPPPPP1: + and #3 + rol + tax + lda $C0E0, x + rts + + +step1: +.byte $01, $30, $28, $24, $20, $1e, $1d, $1c +step2: +.byte $70, $2c, $26, $22, $1f, $1e, $1d, $1c + +adelay: + +adelay_loop: + ldx #$11 +adelay_inner: + dex + bne adelay_inner + inc tmpsec2 + bne adelay_skip + inc tmpsec2+1 +adelay_skip: + sec + sbc #1 + bne adelay_loop +knownret: + rts + +.endif diff --git a/games/peasant/qboot_stage2.s b/games/peasant/qboot_stage2.s index 614986f7..1e3ad624 100644 --- a/games/peasant/qboot_stage2.s +++ b/games/peasant/qboot_stage2.s @@ -252,84 +252,120 @@ seekret: ; curtrk+1 = current track seek: - ldx #0 + ldx #0 ; reset acceleration count? stx step_smc+1 copy_cur: curtrk_smc: lda #0 ; current track - sta tmpval_smc+1 + sta tmpval_smc+1 ; save current track for later + + ; calculate how far we need to seek + sec phase_smc: sbc #$d1 ; track*2 to seek to beq seekret ; if equal, we are already there - ; A is distance - bcs sback ; if positive, skip ahead + ; A is distance, update direction + bcs seeking_out ; if positive, skip ahead + +seeking_in: eor #$ff ; negate the distance - inc curtrk_smc+1 ; move track counter up + inc curtrk_smc+1 ; move track counter inward bcc ssback ; bra -sback: - adc #$fe ; distance -=2 - dec curtrk_smc+1 ; move track counter down +seeking_out: + adc #$fe ; distance -=1 (carry always 1) + dec curtrk_smc+1 ; move track counter outward + ssback: cmp step_smc+1 ; compare to step - bcc loop10 ; if less than, skip + bcc skip_set_step ; if below minimum, don't change? + + ;================== + ; step the proper number of times step_smc: lda #$d1 ; load step value -loop10: - cmp #8 - bcs loop11 - tay - sec -loop11: - lda curtrk_smc+1 - ldx step1, Y - bne loop12 +skip_set_step: -loopmmm: - clc - lda tmpval_smc+1 - ldx step2, Y -loop12: + ; set acceleration (???) + + cmp #8 ; see if >8 + ; our on/off + ; tables only 8 bytes long + ; (dos33 they are 12?) + + ; what is Y in that case? + ; apparently in maxes out + + bcs skip11 + + tay ; acceleration value in Y + +do_phase_on: + sec ; carry set is phase on + +skip11: + lda curtrk_smc+1 ; current track in A + ldx phase_on_time, Y ; get phase on time in X + bne do_phase_common ; (bra?) + +do_phase_off: + clc ; carry set, phase off + lda tmpval_smc+1 ; restore original track + ldx phase_off_time, Y ; get phase off time in X + +do_phase_common: stx sector_smc+1 - and #3 - rol + ; A is the track? + and #3 ; mask to 1 of 4 phases + rol ; double for index (put C in bit 1) tax slotpatch8: - sta $c0d1, X ; PHASEOFF $c080 / $c0e0 -loopmm: + sta $c0d1, X ; flip the phase (PHASEOFF $c080 / $c0e0) +seek_delay: + +seek_delay_outer: + + ; inner delay ; delay 2+(19*5)+1 = 98 cycles = ~100us ldx #$13 ; 2 -loopm: +seek_delay_inner: dex ; 2 - bne loopm ; 2/3 + bne seek_delay_inner ; 2/3 - dec sector_smc+1 - bne loopmm - lsr - bcs loopmmm + dec sector_smc+1 ; why? + bne seek_delay_outer + + lsr ; what is A here? + ; looks like it's the carry bit + ; from phase on/off + + bcs do_phase_off ; repeat, this time off + + inc step_smc+1 ; increment step count + bne copy_cur ; bra(?) back to beginning + + +; phase on/off tables, in 100us multiples + +phase_on_time: .byte $01, $30, $28, $24, $20, $1e, $1d, $1c +phase_off_time: .byte $70, $2c, $26, $22, $1f, $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 partial1: .byte $00 partial2: .byte $00 -code_end: - ;========================== @@ -409,3 +445,6 @@ load_length: .byte $00 .include "wait.s" + + +code_end: diff --git a/games/peasant/qload.inc b/games/peasant/qload.inc index daa631c1..d43c793a 100644 --- a/games/peasant/qload.inc +++ b/games/peasant/qload.inc @@ -2,38 +2,38 @@ load_file =$0b2a sector_write =$0c85 check_floppy_in_drive2 =$0de6 requested_sector =$0d17 -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 +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 hposn_high = $BA00 hposn_low = $BB00