peasant: finally get qboot working across 2 disks

using PRORWTS seek now
also fixed subtle bug in qboot when loading partial tracks

also a bunch of movement in the demo stuff by accident, oops but it's
2am and I'm too lazy to back that out
This commit is contained in:
Vince Weaver 2022-01-16 02:05:43 -05:00
parent d2f2d97ff1
commit e7f1907f38
27 changed files with 243 additions and 83 deletions

View File

@ -19,7 +19,7 @@
; 247 bytes -- combine note loop. makes song a bit faster ; 247 bytes -- combine note loop. makes song a bit faster
; 245 bytes -- try to optimize writing out volume ; 245 bytes -- try to optimize writing out volume
; 255 bytes -- add in some visualization ; 255 bytes -- add in some visualization
; 252 bytes -- re-arrange decode code
d2: d2:
;=================== ;===================
@ -35,17 +35,12 @@ tracker_song = peasant_song
.include "tracker_init.s" .include "tracker_init.s"
jsr SETGR jsr SETGR ; enable lo-res graphics
game_loop: game_loop:
; typically A=0, X=FF, Y=0 ; typically A=0, X=FF, Y=0 here
; lda $70 ; play a frame of music
;blah_smc:
; sta $400
; inc blah_smc+1
; start the music playing
.include "play_frame.s" .include "play_frame.s"
.include "ay3_write_regs.s" .include "ay3_write_regs.s"
@ -57,7 +52,6 @@ game_loop:
beq game_loop beq game_loop
; music ; music
.include "mA2E_2.s" .include "mA2E_2.s"

View File

@ -55,12 +55,13 @@ check_floppy_in_drive2:
; seek to track 0 ; seek to track 0
lda #$44 ; 68 = 34 tracks; worst case scenario(?) lda #$46 ; 70 = 35 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
; jsr antim_seek_track0 ; jsr antim_seek_track0
jsr seek jsr seek
;===================================== ;=====================================

View File

@ -1,13 +1,13 @@
seek =$0a26 seek =$0a28
curtrk_smc =$0a2b curtrk_smc =$0a28
phase_smc =$0a31 phase_smc =$0a33
driveon =$0a9d driveon =$0aa4
wait_1s =$0aac wait_1s =$0ab3
driveoff =$0a22 driveoff =$0a24
switch_drive1 =$08af switch_drive1 =$08af
switch_drive2 =$08be switch_drive2 =$08be
load_new =$0ab7 load_new =$0abe
load_address =$0ad0 load_address =$0ad7
load_track=load_address+1 load_track=load_address+1
load_sector=load_address+2 load_sector=load_address+2
load_length=load_address+3 load_length=load_address+3

View File

@ -25,10 +25,21 @@ slotpatch1: ; smc
bpl readnib bpl readnib
rts rts
;===============================
;===============================
;===============================
; seek then read
;===============================
;===============================
;===============================
; Y = starting sector
; A = page to read into
; X = number of sectors to read
;fill address array for one track ;fill address array for one track
seekread: seekread:
sty startsec+1 sty startsec+1
sta tmpadr+1 sta tmpadr_smc+1
stx total+1 stx total+1
inittrk: inittrk:
@ -48,11 +59,17 @@ it_skip:
startsec: startsec:
ldy #$d1 ldy #$d1
tmpadr: ;===========================================
; fill in table of addresses we want to read
; corresponding to sectors on the track
; if they are 0, it means we don't need it
tmpadr_loop: tmpadr_loop:
tmpadr_smc:
lda #$d1 lda #$d1
sta addrtbl, y sta addrtbl, y
inc tmpadr+1 inc tmpadr_smc+1
iny iny
dec partial1 dec partial1
bne tmpadr_loop bne tmpadr_loop
@ -77,6 +94,9 @@ tmpadr_loop:
; ends with $DE $AA $EB ; ends with $DE $AA $EB
read: read:
ldx #0 ; if we don't set this, bad things can happen
; if we start on a data field w/o setting
; the sector first
outer_read: outer_read:
jsr readnib jsr readnib
inner_read: inner_read:
@ -89,31 +109,41 @@ inner_read:
; look for $D5 $AA $AD ; look for $D5 $AA $AD
tay ; we need Y=#$AA later tay ; we need Y=#$AA later
jsr readnib jsr readnib
eor #$ad ; zero A if match eor #$ad ; zero A if match
beq check_mode beq check_mode ; WHY?
; if not #$AD, then #$96 is assumed ; if not #$AD, then #$96 is assumed
; so in address field ; so in address field
ldy #2 ; volume, track, sector ; following are volume, track, sector
ldy #2 ; volume, track, sector
another: another:
; these are stored in a weird 4+4 format and this is how
; you decode them
jsr readnib jsr readnib
rol ; set carry rol
sta sector_smc+1 sta sector_smc+1
jsr readnib jsr readnib
and sector_smc+1 and sector_smc+1 ; now A has the value
dey
dey ; work through the values
bpl another bpl another
tay tay ; A should be sector#?
ldx addrtbl, Y ; fetch corresponding address ; Y is now sector # VMW
beq read ; done? ldx addrtbl, Y ; fetch corresponding address
; in table.
sta sector_smc+1 ; store index for later beq outer_read ; if address 0, not valid, try again
stx adrpatch1+2 sta sector_smc+1 ; store sector for later
stx adrpatch1+2 ; store address to all of these
stx adrpatch8+2 stx adrpatch8+2
stx adrpatch2+2 stx adrpatch2+2
stx adrpatch3+2 stx adrpatch3+2
@ -121,14 +151,14 @@ another:
stx adrpatch7+2 stx adrpatch7+2
inx inx
stx adrpatch9+2 stx adrpatch9+2 ; store address+1 here
dex dex
dex dex
stx adrpatch4+2 stx adrpatch4+2 ; store address-1 here?
stx adrpatch6+2 stx adrpatch6+2
ldy #$fe ldy #$fe ; Y=-2
loop2: loop2:
adrpatch1: adrpatch1:
@ -138,11 +168,11 @@ adrpatch1:
bne loop2 bne loop2
branch_read: branch_read:
bcs read ; branch always bcs outer_read ; branch always
check_mode: check_mode:
cpx #0 cpx #0
beq read ; loop if not expecting #$AD beq outer_read ; loop if not expecting #$AD
loop33: loop33:
sta tmpval_smc+1 ; zero rolling checksum sta tmpval_smc+1 ; zero rolling checksum
@ -240,12 +270,9 @@ driveoff:
slotpatch7: slotpatch7:
lda $c0d1 lda $c0d1
seekret:
; the RWTS waits 25ms after seeking for things to settle
rts rts
;================================= ;=================================
;================================= ;=================================
; seek, SEEK! ; seek, SEEK!
@ -254,6 +281,146 @@ seekret:
; phase_smc+1 = track*2 to seek to ; phase_smc+1 = track*2 to seek to
; curtrk+1 = current track ; curtrk+1 = current track
; due to problems when switching drive1/drive
; we include here instead the larger but less fancy
; seek from PRORWTS
; "no tricks here, just the regular stuff" -- qkumba
step = $CC ;(internal) state for stepper motor
;tmptrk = $CD ;(internal) temporary copy of current track
;phase = $CE ;(internal) current phase for seek
;tmpsec = $3c
; X = destination track
; Y = 0
;cu;rtrk_smc:
; lda #0
seek:
;p;hase_smc:
; lda #0
; sta phase
curtrk_smc:
lda #0
ldy #0 ; added
sty step
; asl phase
; txa ; get destination in A
; asl ; multiply to get half track
copy_cur:
tax ; current track
sta tmpval_smc+1 ;tmptrk ; save current track for later
; calculate direction to seek
sec
phase_smc:
sbc #$d1 ; track *2 to seek to?
beq done_seek ; if match, we're there
; update direction
bcs seeking_out ; if positive, seeking out toward T34
seeking_in:
eor #$ff ; negate the result?
inx ; move current track inward
bcc seek_dir_done
seeking_out:
sbc #1 ; difference -1 (carry is set here)
dex ; move current track outward
seek_dir_done:
cmp step ; compare to step
bcc skip_set_step ; if below minimum, don't change?
lda step ; load step value
skip_set_step:
; set acceleration/momentum
cmp #8 ; see if > 8
; our momentum table is 8
; (DOS3.3 it's 12)
; Y maxes out if over 8
bcs skip_update_momentum
tay ; acceleration offset in Y
sec ; carry set is phase on
skip_update_momentum:
txa ; current track in A
pha ; save for later
ldx phase_on_time, Y ; load on time from table
done_seek: ; +++
php ; save flags(?)
bne skip_p ; bra?
loop_mmm:
clc ; set phase off
lda tmpval_smc+1 ;tmptrk ; restore saved track
ldx phase_off_time, Y ; get off time from table
skip_p:
stx sector_smc+1 ;tmpsec ; why
and #3 ; mask to 1 of 3 phases
rol ; multiply by 2, set low bit to carry
; carry holds on/off
tax
lsr ; get low bit in carry for later
; but must do before A destroyed
;unrseek=unrelocdsk+(*-reloc)
slotpatch8:
lda $C0D1, X
seek_delay:
; delay 2+(19*5)-1 = 97 cycles, + 6+2 = 105 cycles = ~100us
seek_delay_outer:
ldx #$13 ; 2
seek_delay_inner:
dex ; 2
bne seek_delay_inner ; 2/3
dec sector_smc+1 ;tmpsec ; 6 holds on/off delay time
bne seek_delay_outer ; 2/3
seek_delay_end:
; C is from the LSR previously? so phase bit
bcs loop_mmm ; if carry set, try again phase off
plp ; restore?
beq seekret ; if zero we were done
pla ; restore current track
inc step ; increment step count
bne copy_cur ; (bra) try again
seekret:
; update current track
ldx phase_smc+1
stx curtrk_smc+1
; the DOS3.3 RWTS waits 25ms after seeking for things to settle
rts
;curtrk_smc: ; FIXME
; lda #0
.if 0
seek: seek:
ldx #0 ; reset acceleration count? ldx #0 ; reset acceleration count?
stx step_smc+1 stx step_smc+1
@ -365,6 +532,7 @@ seek_delay_end:
inc step_smc+1 ; increment step count inc step_smc+1 ; increment step count
bne copy_cur ; bra(?) back to beginning bne copy_cur ; bra(?) back to beginning
.endif
; phase on/off tables, in 100us multiples ; phase on/off tables, in 100us multiples

View File

@ -1,5 +1,5 @@
load_file =$0b30 load_file =$0b2a
sector_write =$0c8b 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 =$0e35

View File

@ -65,7 +65,7 @@ zp_clear_loop:
sta DRIVE1_DISK ; it's in drive1 sta DRIVE1_DISK ; it's in drive1
sta CURRENT_DRIVE ; and currently using drive 1 sta CURRENT_DRIVE ; and currently using drive 1
lda #$ff lda #$FF
sta DRIVE1_TRACK sta DRIVE1_TRACK
sta DRIVE2_TRACK sta DRIVE2_TRACK
@ -76,9 +76,6 @@ zp_clear_loop:
lda #LOAD_TITLE ; next load title lda #LOAD_TITLE ; next load title
sta WHICH_LOAD sta WHICH_LOAD
bit $C054
bit $C051
main_game_loop: main_game_loop:
jsr load_file jsr load_file

View File

@ -9,16 +9,13 @@
.include "music.inc" .include "music.inc"
title: title:
jsr hgr2 jsr hgr2 ; clear screen, HGR page 2
;========================= ;=========================
; set up hgr lookup tables ; set up hgr lookup tables
;========================= ;=========================
jsr hgr_make_tables jsr hgr_make_tables ; necessary?
;========================= ;=========================
@ -32,8 +29,8 @@ do_title:
lda #0 lda #0
sta FRAME sta FRAME
;====================== ;================================
; load regular to $40 ; load regular title image to $40
lda #<(title_trogfree_lzsa) lda #<(title_trogfree_lzsa)
sta getsrc_smc+1 sta getsrc_smc+1
@ -45,8 +42,8 @@ do_title:
jsr decompress_lzsa2_fast jsr decompress_lzsa2_fast
;====================== ;=================================
; load trogdor to $20 ; load trogdor title image to $20
lda #<(title_lzsa) lda #<(title_lzsa)
sta getsrc_smc+1 sta getsrc_smc+1
@ -65,7 +62,6 @@ do_title:
and #SOUND_MOCKINGBOARD and #SOUND_MOCKINGBOARD
beq mockingboard_notfound beq mockingboard_notfound
jsr mockingboard_loop jsr mockingboard_loop
jmp title_loop_done jmp title_loop_done
@ -172,10 +168,10 @@ zurg:
reset_altfire: reset_altfire:
lda #50 lda #50
sta ALTFIRE sta ALTFIRE ; start on yy=50 on screen
lda #<altfire_sprite lda #<altfire_sprite ; point to alternate fire
sta alt_smc1+1 sta alt_smc1+1 ; sprite in memory
sta alt_smc2+1 sta alt_smc2+1
lda #>altfire_sprite lda #>altfire_sprite
@ -187,55 +183,57 @@ title_loop:
lda C_VOLUME ; see if volume on trogdor channel lda C_VOLUME ; see if volume on trogdor channel
beq no_trog beq no_trog
bit PAGE1 bit PAGE1 ; if it did, flip page to trogdor
jmp done_trog jmp done_trog
no_trog: no_trog:
bit PAGE2 bit PAGE2 ; otherwise stay at regular
done_trog: done_trog:
; work on flame
lda FRAME ; skip most of time lda FRAME ; skip most of time
and #$3f and #$3f
bne altfire_good bne altfire_good
; do altfire loop ; do altfire loop
ldx ALTFIRE ldx ALTFIRE ; point (GBASL) to current line to copy
lda hposn_high,X lda hposn_high,X
sta GBASH sta GBASH
lda hposn_low,X lda hposn_low,X
sta GBASL sta GBASL
ldy #34 ldy #34 ; xx=34*7
inner_altfire: inner_altfire:
lda (GBASL),Y ; swap sprite data with screen data
pha
alt_smc1:
lda $d000
sta (GBASL),Y
pla
alt_smc2:
sta $d000
inc alt_smc1+1 lda (GBASL),Y ; get pixels from screen
pha ; save for later
alt_smc1:
lda $d000 ; get pixels from sprite
sta (GBASL),Y ; store to screen
pla ; restore saved pixels
alt_smc2:
sta $d000 ; store to pixel area
inc alt_smc1+1 ; increment the sprite pointers
inc alt_smc2+1 inc alt_smc2+1
bne alt_noflo bne alt_noflo
inc alt_smc1+2 inc alt_smc1+2 ; handle 16-bit if overflowed
inc alt_smc2+2 inc alt_smc2+2
alt_noflo: alt_noflo:
iny iny
cpy #40 cpy #40 ; continue to xx=(40*7)
bne inner_altfire bne inner_altfire
inc ALTFIRE inc ALTFIRE
lda ALTFIRE lda ALTFIRE
cmp #135 cmp #135 ; continue until yy=135
beq reset_altfire beq reset_altfire
altfire_good: altfire_good:
@ -244,8 +242,11 @@ altfire_good:
lda KEYPRESS ; 4 lda KEYPRESS ; 4
bpl title_loop ; 3 bpl title_loop ; 3
bit KEYRESET ; clear the keyboard buffer
;==========================
; key was pressed, exit
bit KEYRESET ; clear the keyboard buffer
bit PAGE2 ; return to viewing PAGE2 bit PAGE2 ; return to viewing PAGE2

View File

@ -45,7 +45,6 @@ text_loop:
dex dex
bne text_loop bne text_loop
;=================== ;===================
; detect model ; detect model
;=================== ;===================