mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-11-17 14:12:58 +00:00
peasant: use qboot so we don't have DOS in the way
This commit is contained in:
parent
5fa1473172
commit
9bc4d738b5
@ -8,11 +8,14 @@ EMPTY_DISK = ../../empty_disk
|
||||
|
||||
all: peasant.dsk
|
||||
|
||||
peasant.dsk: HELLO PEASANT FONT_TEST
|
||||
peasant.dsk: QBOOT QLOAD PEASANT
|
||||
cp $(EMPTY_DISK)/empty.dsk peasant.dsk
|
||||
$(DOS33) -y peasant.dsk SAVE A HELLO
|
||||
$(DOS33) -y peasant.dsk BSAVE -a 0x6000 PEASANT
|
||||
$(DOS33) -y peasant.dsk BSAVE -a 0x6000 FONT_TEST
|
||||
# $(DOS33) -y peasant.dsk BSAVE -a 0x6000 PEASANT
|
||||
$(DOS33_RAW) peasant.dsk 0 0 QBOOT 0 1
|
||||
$(DOS33_RAW) peasant.dsk 0 2 QBOOT 1 1
|
||||
$(DOS33_RAW) peasant.dsk 0 4 QBOOT 2 1
|
||||
$(DOS33_RAW) peasant.dsk 1 0 QLOAD 0 0
|
||||
$(DOS33_RAW) peasant.dsk 3 0 PEASANT 0 0
|
||||
|
||||
###
|
||||
|
||||
@ -21,11 +24,29 @@ HELLO: hello.bas
|
||||
|
||||
###
|
||||
|
||||
QBOOT: qboot_sector.o
|
||||
ld65 -o QBOOT qboot_sector.o -C $(LINKER_SCRIPTS)/apple2_800.inc
|
||||
|
||||
qboot_sector.o: qboot_sector.s qboot_stage2.s
|
||||
ca65 -o qboot_sector.o qboot_sector.s -l qboot_sector.lst
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
|
||||
QLOAD: qload.o
|
||||
ld65 -o QLOAD qload.o -C $(LINKER_SCRIPTS)/apple2_e00.inc
|
||||
|
||||
qload.o: qload.s qboot.inc
|
||||
ca65 -o qload.o qload.s -l qload.lst
|
||||
|
||||
###
|
||||
|
||||
PEASANT: peasant.o
|
||||
ld65 -o PEASANT peasant.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
|
||||
|
||||
peasant.o: peasant.s graphics/graphics.inc \
|
||||
directions.s cottage.s lake_w.s lake_e.s river.s
|
||||
directions.s cottage.s lake_w.s lake_e.s river.s knight.s
|
||||
ca65 -o peasant.o peasant.s -l peasant.lst
|
||||
|
||||
###
|
||||
|
@ -24,7 +24,7 @@ graphics.inc: \
|
||||
echo "lake_w_lzsa: .incbin \"lake_w.lzsa\"" >> graphics.inc
|
||||
echo "lake_e_lzsa: .incbin \"lake_e.lzsa\"" >> graphics.inc
|
||||
echo "river_lzsa: .incbin \"river.lzsa\"" >> graphics.inc
|
||||
# echo "knight_lzsa: .incbin \"knight.lzsa\"" >> graphics.inc
|
||||
echo "knight_lzsa: .incbin \"knight.lzsa\"" >> graphics.inc
|
||||
|
||||
|
||||
###
|
||||
|
26
games/peasant/knight.s
Normal file
26
games/peasant/knight.s
Normal file
@ -0,0 +1,26 @@
|
||||
; o/~ One knight in Bangkok makes a hard man humble o/~
|
||||
|
||||
;************************
|
||||
; Knight
|
||||
;************************
|
||||
knight:
|
||||
lda #<(knight_lzsa)
|
||||
sta getsrc_smc+1
|
||||
lda #>(knight_lzsa)
|
||||
sta getsrc_smc+2
|
||||
|
||||
lda #$40
|
||||
|
||||
jsr decompress_lzsa2_fast
|
||||
|
||||
lda #<peasant_text
|
||||
sta OUTL
|
||||
lda #>peasant_text
|
||||
sta OUTH
|
||||
|
||||
jsr hgr_put_string
|
||||
|
||||
|
||||
jsr wait_until_keypress
|
||||
|
||||
rts
|
9
games/peasant/qboot.inc
Normal file
9
games/peasant/qboot.inc
Normal file
@ -0,0 +1,9 @@
|
||||
; made by hand?
|
||||
seek = $d26
|
||||
driveon = $d9D
|
||||
driveoff = $d22
|
||||
load_new = $dAB
|
||||
load_address=$dC4
|
||||
load_track=load_address+1
|
||||
load_sector=load_address+2
|
||||
load_length=load_address+3
|
244
games/peasant/qboot_sector.s
Normal file
244
games/peasant/qboot_sector.s
Normal file
@ -0,0 +1,244 @@
|
||||
; fast seek/multi-read
|
||||
; copyright (c) Peter Ferrie 2015-16
|
||||
|
||||
; Paramaters for loading QLOAD
|
||||
|
||||
sectors = 18 ; user-defined
|
||||
firsttrk = 1 ; user-defined, first track to read
|
||||
firstsec = 0 ; user-defined, first sector to read
|
||||
address = $0E ; user-defined
|
||||
entry = $E00 ; user-defined
|
||||
version = 1
|
||||
|
||||
;memory usage:
|
||||
;256 bytes ($200-2ff) static table
|
||||
grouped = $200
|
||||
|
||||
; stay away from interrupt vectors at $3fe !!!
|
||||
|
||||
;106 bytes ($300-369) static table
|
||||
preshift = $300
|
||||
zvalue = $fd ; only during init
|
||||
znibble = $fe ; only during init
|
||||
zmask = $ff ; only during init
|
||||
|
||||
WHICH_SLOT = $DA
|
||||
|
||||
; $26/$27 sector read location (ROM)
|
||||
; $3D sector number (ROM)
|
||||
|
||||
|
||||
; at entry (at least on AppleWin) A=1, X=60 (slot<<4), Y=0
|
||||
; qkumba says cffa cards leave Y at $10
|
||||
; 26/27 = 00/09
|
||||
; 3D = 1
|
||||
|
||||
; For Disk II booting, the firmware loads track0/sector0
|
||||
; to $800 and then jumps to $801
|
||||
|
||||
.org $800
|
||||
.byte 1 ; number of sectors for ROM to load
|
||||
|
||||
boot_entry:
|
||||
; this code loads two sectors up to $C0/$D0
|
||||
|
||||
; assume A=1 coming in here
|
||||
|
||||
lsr ; check sector number
|
||||
; A=0, carry=1
|
||||
tay ; Y=0
|
||||
adc #$0B ; A=$C (destintation)
|
||||
|
||||
sta $27 ; set or update address as needed
|
||||
cmp #$0E
|
||||
; so if hit $0e00 we are done
|
||||
|
||||
beq done_load_2 ; branch if loaded 2
|
||||
|
||||
inc $3d ; increment sector (faster to find)
|
||||
|
||||
; call to the read routine in proper slot
|
||||
; using rts to jump indirect to
|
||||
; $CX5C
|
||||
|
||||
; this routine reads sector in $3D on track in $41
|
||||
; to address in $26/$27
|
||||
; when it's done it jumps back to $801
|
||||
stx WHICH_SLOT ; save for later
|
||||
|
||||
txa ; x is slot# << 4
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$c0 ; slot to PROM base
|
||||
pha
|
||||
lda #$5b ;read-1
|
||||
pha
|
||||
rts ; return used to call $CX5C in DISK II ROM
|
||||
|
||||
done_load_2:
|
||||
|
||||
; patch self modifying code for Q6L read
|
||||
|
||||
txa
|
||||
ora #$8c ; slot to Q6L
|
||||
; Q6L?
|
||||
; if slot 6, after this A is $EC
|
||||
; Y should be 2 here
|
||||
patch_loop:
|
||||
iny
|
||||
ldx patchtbl-3, Y
|
||||
sta code_begin, X ; replace placeholders with Q6L
|
||||
; BE02 = EC? lda c0ec
|
||||
; so sets to c08c (Q6L)
|
||||
|
||||
bne patch_loop
|
||||
|
||||
; patch self-modifying code for turning motor off
|
||||
|
||||
and #$f8 ; MOTOROFF (c088) -> c0e8
|
||||
sta slotpatch7+1
|
||||
|
||||
; patch self-modifying code for turning motor on
|
||||
clc
|
||||
adc #1 ; MOTORON (c089) -> c0e9
|
||||
sta slotpatch9+1
|
||||
|
||||
; patch self-modifying code for phase off
|
||||
|
||||
eor #9 ; PHASEOFF (c080)
|
||||
sta slotpatch8+1
|
||||
|
||||
ldx #$3f
|
||||
stx zmask
|
||||
inx
|
||||
ldy #$7f
|
||||
|
||||
bne skip_ahead ; branch always
|
||||
|
||||
; pad with zeros until $839
|
||||
; $839 is the entry point
|
||||
; adjusts address at $8FE to be entry point
|
||||
; jumps to boot 2
|
||||
;.res $839-*
|
||||
|
||||
; lda #>(entry-1)
|
||||
; pha
|
||||
; lda #<(entry-1)
|
||||
; pha
|
||||
; jsr preread
|
||||
; jmp $1000 ; stage2 entry point
|
||||
|
||||
patchtbl:
|
||||
.byte <(slotpatch1+1), <(slotpatch2+1), <(slotpatch3+1)
|
||||
.byte <(slotpatch4+1), <(slotpatch5+1), <(slotpatch6+1)
|
||||
indextbl: ;the 0 also terminates the patchtbl list!
|
||||
.byte 0, 2, 1, 3
|
||||
|
||||
|
||||
;construct denibbilisation table
|
||||
;pre-shifted for interleave read
|
||||
|
||||
skip_ahead:
|
||||
loopaa:
|
||||
sty znibble
|
||||
tya
|
||||
asl
|
||||
bit znibble
|
||||
beq loopz
|
||||
ora znibble
|
||||
eor #$ff
|
||||
and #$7e
|
||||
loopa:
|
||||
bcs loopz
|
||||
lsr
|
||||
bne loopa
|
||||
dex
|
||||
txa
|
||||
asl
|
||||
asl
|
||||
sta preshift-$16, Y
|
||||
loopz:
|
||||
dey
|
||||
bne loopaa
|
||||
|
||||
;construct 2-bit group table
|
||||
|
||||
sty zvalue
|
||||
loopbb:
|
||||
lsr zmask
|
||||
lsr zmask
|
||||
loopb:
|
||||
lda indextbl, X
|
||||
sta grouped, Y
|
||||
inc zvalue
|
||||
lda zvalue
|
||||
and zmask
|
||||
bne loopy
|
||||
inx
|
||||
txa
|
||||
and #3
|
||||
tax
|
||||
loopy:
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
cpy #3
|
||||
bcs loopb
|
||||
iny
|
||||
cpy #3
|
||||
bcc loopbb
|
||||
lda #>(entry-1)
|
||||
pha
|
||||
lda #<(entry-1)
|
||||
pha
|
||||
jsr preread
|
||||
|
||||
; seek backward support
|
||||
; sty startsec+1
|
||||
; sta tmpadr+1
|
||||
; stx total+1
|
||||
|
||||
jmp seekread
|
||||
|
||||
preread:
|
||||
|
||||
;copy post-read if necessary
|
||||
;push post-read address here
|
||||
; pla
|
||||
; tax
|
||||
; pla
|
||||
; tay
|
||||
; lda #>(postread-1)
|
||||
; pha
|
||||
; lda #<(postread-1)
|
||||
; pha
|
||||
; tya
|
||||
; pha
|
||||
; txa
|
||||
; pha
|
||||
|
||||
lda #<(firsttrk*2)
|
||||
sta phase+1
|
||||
ldx #sectors
|
||||
lda #address
|
||||
ldy #firstsec
|
||||
rts
|
||||
|
||||
|
||||
|
||||
end_code:
|
||||
|
||||
.res $8fe-*
|
||||
|
||||
; traditionally, entry point to jump to at end of loading
|
||||
; $c00 in this case
|
||||
;*=$8fe
|
||||
.byte $C, $00
|
||||
|
||||
|
||||
.include "qboot_stage2.s"
|
||||
|
||||
|
363
games/peasant/qboot_stage2.s
Normal file
363
games/peasant/qboot_stage2.s
Normal file
@ -0,0 +1,363 @@
|
||||
; the following lives on sectors $0E and $0D
|
||||
; why?
|
||||
; request sector 2 and 4, and the interleave is
|
||||
|
||||
; beneath apple dos (3-23)
|
||||
; Physical (firmware) : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
; DOS33 mapping : 0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15
|
||||
|
||||
|
||||
; Beneath Apple DOS
|
||||
; p86 (dos reference)
|
||||
;
|
||||
|
||||
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
||||
|
||||
.org $c00
|
||||
|
||||
code_begin:
|
||||
|
||||
.byte version
|
||||
|
||||
readnib:
|
||||
slotpatch1: ; smc
|
||||
lda $c0d1 ; gets set to C08C (Q6L) read
|
||||
bpl readnib
|
||||
rts
|
||||
|
||||
;fill address array for one track
|
||||
seekread:
|
||||
sty startsec+1
|
||||
sta tmpadr+1
|
||||
stx total+1
|
||||
|
||||
inittrk:
|
||||
sec
|
||||
lda #$10
|
||||
sbc startsec+1
|
||||
cmp total+1
|
||||
bcs it_skip
|
||||
|
||||
tax
|
||||
|
||||
it_skip:
|
||||
stx partial1
|
||||
stx partial2
|
||||
jsr seek
|
||||
|
||||
startsec:
|
||||
ldy #$d1
|
||||
|
||||
tmpadr:
|
||||
tmpadr_loop:
|
||||
lda #$d1
|
||||
sta addrtbl, y
|
||||
inc tmpadr+1
|
||||
iny
|
||||
dec partial1
|
||||
bne tmpadr_loop
|
||||
|
||||
;====================================
|
||||
; read a sector
|
||||
;====================================
|
||||
; first address field
|
||||
;====================================
|
||||
; starts with $D5 $AA $96
|
||||
; then XX YY volume
|
||||
; then XX YY track
|
||||
; then XX YY sector
|
||||
; then XX YY checksum
|
||||
; then ends with $DE $AA $EB
|
||||
;====================================
|
||||
; data field
|
||||
;====================================
|
||||
; starts with $D5 $AA $AD
|
||||
; 342 bytes of data
|
||||
; XX checksum
|
||||
; ends with $DE $AA $EB
|
||||
read:
|
||||
|
||||
outer_read:
|
||||
jsr readnib
|
||||
inner_read:
|
||||
cmp #$d5 ; look for $D5 part of addr field
|
||||
bne outer_read
|
||||
|
||||
jsr readnib ; look for $D5 $AA
|
||||
cmp #$aa
|
||||
bne inner_read
|
||||
|
||||
; look for $D5 $AA $AD
|
||||
|
||||
tay ; we need Y=#$AA later
|
||||
jsr readnib
|
||||
eor #$ad ; zero A if match
|
||||
beq check_mode
|
||||
|
||||
; if not #$AD, then #$96 is assumed
|
||||
; so in address field
|
||||
|
||||
ldy #2 ; volume, track, sector
|
||||
another:
|
||||
jsr readnib
|
||||
rol ; set carry
|
||||
sta sector+1
|
||||
jsr readnib
|
||||
and sector+1
|
||||
dey
|
||||
bpl another
|
||||
|
||||
tay
|
||||
ldx addrtbl, Y ; fetch corresponding address
|
||||
beq read ; done?
|
||||
|
||||
sta sector+1 ; store index for later
|
||||
|
||||
stx adrpatch1+2
|
||||
stx adrpatch8+2
|
||||
stx adrpatch2+2
|
||||
stx adrpatch3+2
|
||||
stx adrpatch5+2
|
||||
stx adrpatch7+2
|
||||
|
||||
inx
|
||||
stx adrpatch9+2
|
||||
dex
|
||||
|
||||
dex
|
||||
stx adrpatch4+2
|
||||
stx adrpatch6+2
|
||||
|
||||
ldy #$fe
|
||||
|
||||
loop2:
|
||||
adrpatch1:
|
||||
lda $d102, Y
|
||||
pha
|
||||
iny
|
||||
bne loop2
|
||||
|
||||
branch_read:
|
||||
bcs read ; branch always
|
||||
|
||||
check_mode:
|
||||
cpx #0
|
||||
beq read ; loop if not expecting #$AD
|
||||
|
||||
loop33:
|
||||
sta tmpval+1 ; zero rolling checksum
|
||||
slotpatch2:
|
||||
loop4:
|
||||
ldx $c0d1
|
||||
bpl loop4
|
||||
lda preshift-$96, X
|
||||
adrpatch2:
|
||||
sta $d102, Y ; store 2-bit array
|
||||
|
||||
tmpval:
|
||||
eor #$d1
|
||||
iny
|
||||
bne loop33
|
||||
ldy #$aa
|
||||
slotpatch3:
|
||||
loop5:
|
||||
ldx $c0d1
|
||||
bpl loop5
|
||||
eor preshift-$96, X
|
||||
adrpatch3:
|
||||
ldx $d102, Y ; bit2tbl
|
||||
eor grouped+2, X ; first 86 nibbles use group bits 0-1
|
||||
adrpatch4:
|
||||
sta $d156, y
|
||||
iny
|
||||
bne loop5
|
||||
and #$fc
|
||||
ldy #$aa
|
||||
slotpatch4:
|
||||
loop6:
|
||||
ldx $c0d1
|
||||
bpl loop6
|
||||
eor preshift-$96, X
|
||||
adrpatch5:
|
||||
ldx $d102, Y ; bit2tbl
|
||||
eor grouped+1, X ; second 86 nibbles use group bits 2-3
|
||||
adrpatch6:
|
||||
sta $d1ac, Y
|
||||
iny
|
||||
bne loop6
|
||||
and #$fc
|
||||
ldx #$ac
|
||||
slotpatch5:
|
||||
loop7:
|
||||
ldy $c0d1
|
||||
bpl loop7
|
||||
eor preshift-$96, Y
|
||||
adrpatch7:
|
||||
ldy $d100, X ; bit2tbl
|
||||
eor grouped, Y ; last 84 nibbles use group bits 4-5
|
||||
adrpatch8:
|
||||
sta $d100, x
|
||||
inx
|
||||
bne loop7
|
||||
and #$fc
|
||||
slotpatch6:
|
||||
loop8:
|
||||
ldy $c0d1
|
||||
bpl loop8
|
||||
eor preshift-$96, Y
|
||||
cmp #1 ; carry = !zero
|
||||
ldy #1
|
||||
loop9:
|
||||
pla
|
||||
adrpatch9:
|
||||
sta $d100, Y
|
||||
dey
|
||||
bpl loop9
|
||||
branch_read2:
|
||||
bcs branch_read ; branch if checksum failure
|
||||
|
||||
sector:
|
||||
ldy #$d1
|
||||
txa
|
||||
sta addrtbl, Y ; zero corresponding address
|
||||
dec total+1
|
||||
dec partial2 ; adjust remaining count
|
||||
; (faster than looping over array)
|
||||
sec
|
||||
bne branch_read2 ; read all requested sectors in one track
|
||||
|
||||
sta startsec+1 ; this was missing from original code
|
||||
; leading to trouble on wrap around
|
||||
; it not starting at sector0
|
||||
total:
|
||||
ldx #$d1
|
||||
beq driveoff
|
||||
inc phase+1
|
||||
inc phase+1 ; update current track
|
||||
jmp inittrk
|
||||
|
||||
driveoff:
|
||||
slotpatch7:
|
||||
lda $c0d1
|
||||
|
||||
seekret:
|
||||
rts
|
||||
|
||||
seek:
|
||||
ldx #0
|
||||
stx step+1
|
||||
copy_cur:
|
||||
curtrk:
|
||||
lda #0
|
||||
sta tmpval+1
|
||||
sec
|
||||
phase:
|
||||
sbc #$d1
|
||||
beq seekret
|
||||
|
||||
; if seek backwards
|
||||
bcs sback
|
||||
|
||||
eor #$ff
|
||||
inc curtrk+1
|
||||
|
||||
bcc ssback
|
||||
sback:
|
||||
adc #$fe
|
||||
dec curtrk+1
|
||||
ssback:
|
||||
cmp step+1
|
||||
bcc loop10
|
||||
step:
|
||||
lda #$d1
|
||||
loop10:
|
||||
cmp #8
|
||||
bcs loop11
|
||||
tay
|
||||
sec
|
||||
loop11:
|
||||
lda curtrk+1
|
||||
ldx step1, Y
|
||||
bne loop12
|
||||
loopmmm:
|
||||
clc
|
||||
lda tmpval+1
|
||||
ldx step2, Y
|
||||
loop12:
|
||||
stx sector+1
|
||||
and #3
|
||||
rol
|
||||
tax
|
||||
slotpatch8:
|
||||
sta $c0d1, X
|
||||
loopmm:
|
||||
ldx #$13
|
||||
loopm:
|
||||
dex
|
||||
bne loopm
|
||||
dec sector+1
|
||||
bne loopmm
|
||||
lsr
|
||||
bcs loopmmm
|
||||
inc step+1
|
||||
bne copy_cur
|
||||
|
||||
step1: .byte 1, $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:
|
||||
|
||||
|
||||
|
||||
;==========================
|
||||
; enable drive motor
|
||||
;==========================
|
||||
|
||||
driveon:
|
||||
|
||||
slotpatch9:
|
||||
lda $c0d1
|
||||
|
||||
; wait 1s
|
||||
|
||||
ldx #6
|
||||
wait_1s:
|
||||
lda #255
|
||||
jsr WAIT
|
||||
dex
|
||||
bne wait_1s
|
||||
|
||||
rts
|
||||
|
||||
load_new:
|
||||
|
||||
jsr driveon
|
||||
|
||||
lda load_track
|
||||
asl ; track to start*2
|
||||
sta phase+1
|
||||
|
||||
lda load_sector
|
||||
tay ; sector to start
|
||||
|
||||
lda load_length ; length
|
||||
tax
|
||||
|
||||
lda load_address ; address to load
|
||||
|
||||
jsr seekread
|
||||
|
||||
rts
|
||||
|
||||
load_address:
|
||||
.byte $00
|
||||
load_track:
|
||||
.byte $00
|
||||
load_sector:
|
||||
.byte $00
|
||||
load_length:
|
||||
.byte $00
|
||||
|
247
games/peasant/qkumba_popwr.s
Normal file
247
games/peasant/qkumba_popwr.s
Normal file
@ -0,0 +1,247 @@
|
||||
; popwr -- code provided by qkumba
|
||||
|
||||
|
||||
frombuff=$d00 ; sector data to write
|
||||
|
||||
; note these must be contiguous
|
||||
encbuf=$e00 ; nibble buffer must be page alined
|
||||
bit2tbl=$f00
|
||||
|
||||
readnib = $1001
|
||||
|
||||
|
||||
readd5aa:
|
||||
|
||||
try_again:
|
||||
jsr readnib
|
||||
try_for_d5:
|
||||
cmp #$d5
|
||||
bne try_again
|
||||
jsr readnib
|
||||
cmp #$aa
|
||||
bne try_for_d5
|
||||
|
||||
jsr readnib
|
||||
rts
|
||||
|
||||
;================================
|
||||
; set up the self-modifying code
|
||||
; to point to the proper slot
|
||||
;================================
|
||||
; slot number is in high nibble of A
|
||||
popwr_init:
|
||||
and #$70 ; the slot number is in the top here
|
||||
sta slotpatchw1+1 ; self modify the code
|
||||
sta slotpatchw2+1
|
||||
sta slotpatchw3+1
|
||||
sta slotpatchw4+1
|
||||
|
||||
rts
|
||||
|
||||
;================================
|
||||
; write a sector
|
||||
;================================
|
||||
|
||||
sector_write:
|
||||
|
||||
; convert the input to nibbles
|
||||
|
||||
ldy #2 ; why start at 2?
|
||||
aa:
|
||||
ldx #$aa
|
||||
b1:
|
||||
dey
|
||||
frombuff_smc:
|
||||
lda frombuff, y
|
||||
lsr
|
||||
rol bit2tbl-$aa, x
|
||||
lsr
|
||||
rol bit2tbl-$aa, x
|
||||
sta encbuf, y
|
||||
lda bit2tbl-$aa, x
|
||||
and #$3f
|
||||
sta bit2tbl-$aa, x
|
||||
inx
|
||||
bne b1
|
||||
tya
|
||||
bne aa
|
||||
|
||||
jmp cmpsecwr
|
||||
|
||||
.align $100
|
||||
|
||||
; look for the proper sector to write
|
||||
|
||||
cmpsecwr:
|
||||
b2:
|
||||
jsr readd5aa ; look for dd55aa marker
|
||||
cmp #$96
|
||||
bne b2
|
||||
|
||||
ldy #3 ; try getting the sector number
|
||||
b3:
|
||||
jsr readnib
|
||||
rol
|
||||
sta tmpsec
|
||||
jsr readnib
|
||||
and tmpsec ; and with prev nibble?
|
||||
dey
|
||||
bne b3
|
||||
|
||||
|
||||
requested_sector:
|
||||
cmp #$d1
|
||||
|
||||
bne cmpsecwr ; retry if not what we want?
|
||||
|
||||
;skip tail #$DE #$AA #$EB some #$FFs ...
|
||||
|
||||
ldy #$24
|
||||
b4:
|
||||
dey
|
||||
bpl b4
|
||||
|
||||
|
||||
; c0e0 slot 6 ph0 off
|
||||
; c0e1 slot 6 ph0 on
|
||||
; c0e2 slot 6 ph1 off
|
||||
; c0e3 slot 6 ph1 on
|
||||
; c0e4 slot 6 ph2 off
|
||||
; c0e5 slot 6 ph2 on
|
||||
; c0e6 slot 6 ph3 off
|
||||
; c0e7 slot 6 ph3 on
|
||||
; c0e8 slot 6 motor off
|
||||
; c0e9 slot 6 motor on
|
||||
; c0ea slot 6 drive 1
|
||||
; c0eb slot 6 drive 2
|
||||
; c0ec slot 6 q6 off \ Q6 Q7
|
||||
; c0ed slot 6 q6 on |-- state machine 0 0 READ
|
||||
; c0ee slot 6 q7 off | 0 1 WRITE
|
||||
; c0ef slot 6 q7 on / 1 0 SENSE WRITE PROTECT
|
||||
; 1 1 WRITE LOAD
|
||||
|
||||
; write sector data
|
||||
|
||||
slotpatchw1:
|
||||
ldx #$d1 ; cycle num smc Q6 Q7
|
||||
lda $c08d, x ; prime drive 1 X
|
||||
lda $c08e, x ; required by Unidisk 1 0 ; senese wp?
|
||||
tya
|
||||
sta $c08f, x ; 1 1 ; write load
|
||||
ora $c08c, x ; 0 1 ; write
|
||||
|
||||
; 40 cycles
|
||||
|
||||
ldy #4 ; 2 cycles
|
||||
cmp $ea ; nop ; 3 cycles
|
||||
cmp ($ea,x) ; nop ; 6 cycles
|
||||
b5:
|
||||
jsr writenib1 ; (29 cycles)
|
||||
|
||||
; +6 cycles
|
||||
dey ; 2 cycles
|
||||
bne b5 ; 3/2nt
|
||||
|
||||
; 36 cycles
|
||||
; +10 cycles
|
||||
ldy #(prolog_e-prolog)
|
||||
; 2 cycles
|
||||
cmp $ea ; nop ; 3 cycles
|
||||
b6:
|
||||
lda prolog-1, y ; 4 cycles
|
||||
jsr writenib3 ; (17 cycles)
|
||||
|
||||
; 32 cycles if branch taken
|
||||
; +6 cycles
|
||||
dey ; 2 cycles
|
||||
bne b6 ; 3/2nt
|
||||
|
||||
; 36 cycles on first pass
|
||||
; +10 cycles
|
||||
tya ; 2 cycles
|
||||
ldy #$56 ; 2 cycles
|
||||
b7:
|
||||
eor bit2tbl-1, y ; 5 cycles
|
||||
tax ; 2 cycles
|
||||
lda xlattbl, x ; 4 cycles
|
||||
slotpatchw2:
|
||||
ldx #$d1 ; slot number smc ; 2 cycles
|
||||
sta $c08d, x ; wp sense ; 5 cycles
|
||||
lda $c08c, x ; read ; 4 cycles
|
||||
|
||||
; 32 cycles if branch taken
|
||||
|
||||
lda bit2tbl-1, y ; 5 cycles
|
||||
dey ; 2 cycles
|
||||
bne b7 ; 3/2nt
|
||||
|
||||
; 32 cycles
|
||||
; +9 cycles
|
||||
clc ; 2 cycles
|
||||
b88:
|
||||
eor encbuf, y ; 4 cycles
|
||||
b8:
|
||||
tax ; 2 cycles
|
||||
lda xlattbl, x ; 4 cycles
|
||||
slotpatchw3:
|
||||
ldx #$d1 ; slot number smc ; 2 cycles
|
||||
sta $c08d, x ; wp sense ; 5 cycles
|
||||
lda $c08c, x ; read ; 4 cycles
|
||||
bcs f1 ; 3/2nt
|
||||
|
||||
; 32 cycles if branch taken
|
||||
|
||||
lda encbuf, y ; 4 cycles
|
||||
iny ; 2 cycles
|
||||
bne b88 ; 3/2nt
|
||||
|
||||
; 32 cycles
|
||||
; +10 cycles
|
||||
sec ; 2 cycles
|
||||
bcs b8 ; 3 cycles
|
||||
|
||||
; 32 cycles
|
||||
; +3 cycles
|
||||
f1:
|
||||
ldy #(epilog_e-epilog)
|
||||
; 2 cycles
|
||||
cmp ($ea,x) ; nop ; 6 cycles
|
||||
b9:
|
||||
lda epilog-1, y ; 4 cycles
|
||||
jsr writenib3 ; (17 cycles)
|
||||
|
||||
; 32 cycles if branch taken
|
||||
; +6 cycles
|
||||
dey ; 2 cycles
|
||||
bne b9 ;3/2nt
|
||||
|
||||
lda $c08e, x ; read/wp
|
||||
lda $c08c, x ; read
|
||||
lda $c088, x ; motor off
|
||||
rts ; 6 cycles
|
||||
|
||||
writenib1:
|
||||
cmp ($ea,x) ; nop ; 6 cycles
|
||||
cmp ($ea,x) ; nop ; 6 cycles
|
||||
writenib3:
|
||||
slotpatchw4:
|
||||
ldx #$d1 ; slot number ; 2 cycles
|
||||
writenib4:
|
||||
sta $c08d, x ; wp sense? ; 5 cycles
|
||||
ora $c08c, x ; read ; 4 cycles
|
||||
rts ; 6 cycles
|
||||
|
||||
prolog: .byte $ad, $aa, $d5
|
||||
prolog_e:
|
||||
epilog: .byte $ff, $eb, $aa, $de
|
||||
epilog_e:
|
||||
|
||||
xlattbl:
|
||||
.byte $96,$97,$9A,$9B,$9D,$9E,$9F,$A6
|
||||
.byte $A7,$AB,$AC,$AD,$AE,$AF,$B2,$B3
|
||||
.byte $B4,$B5,$B6,$B7,$B9,$BA,$BB,$BC
|
||||
.byte $BD,$BE,$BF,$CB,$CD,$CE,$CF,$D3
|
||||
.byte $D6,$D7,$D9,$DA,$DB,$DC,$DD,$DE
|
||||
.byte $DF,$E5,$E6,$E7,$E9,$EA,$EB,$EC
|
||||
.byte $ED,$EE,$EF,$F2,$F3,$F4,$F5,$F6
|
||||
.byte $F7,$F9,$FA,$FB,$FC,$FD,$FE,$FF
|
244
games/peasant/qload.s
Normal file
244
games/peasant/qload.s
Normal file
@ -0,0 +1,244 @@
|
||||
; Loader for MIST
|
||||
|
||||
;.include "zp.inc"
|
||||
|
||||
LOAD_TEXT_TITLE = 16 ; ???
|
||||
LOAD_FIRST_SECTOR = 22 ; ???
|
||||
|
||||
tmpsec = $3C
|
||||
WHICH_LOAD=$80
|
||||
WHICH_SLOT=$DA
|
||||
CURRENT_DISK=$DC
|
||||
OUTL = $FE
|
||||
OUTH = $FF
|
||||
|
||||
|
||||
LOAD_TITLE = 0
|
||||
|
||||
.include "hardware.inc"
|
||||
|
||||
;.include "common_defines.inc"
|
||||
.include "qboot.inc"
|
||||
|
||||
qload_start:
|
||||
|
||||
; init the write code
|
||||
lda WHICH_SLOT
|
||||
jsr popwr_init
|
||||
|
||||
; first time entry
|
||||
; start by loading text title
|
||||
|
||||
lda #LOAD_TEXT_TITLE ; load title
|
||||
sta WHICH_LOAD
|
||||
|
||||
lda #1
|
||||
sta CURRENT_DISK ; current disk number
|
||||
|
||||
jsr load_file
|
||||
|
||||
jsr $800
|
||||
|
||||
lda #LOAD_TITLE ; load title
|
||||
sta WHICH_LOAD
|
||||
|
||||
main_game_loop:
|
||||
jsr load_file
|
||||
|
||||
; lda WHICH_LOAD
|
||||
; bne not_title
|
||||
|
||||
|
||||
start_title:
|
||||
jsr $6000
|
||||
jmp main_game_loop
|
||||
|
||||
;not_title:
|
||||
; jsr $2000
|
||||
; jmp main_game_loop
|
||||
|
||||
;====================================
|
||||
; loads file specified by WHICH_LOAD
|
||||
;====================================
|
||||
load_file:
|
||||
ldx WHICH_LOAD
|
||||
|
||||
lda which_disk_array,X
|
||||
cmp CURRENT_DISK
|
||||
bne change_disk
|
||||
|
||||
load_file_no_diskcheck:
|
||||
lda load_address_array,X
|
||||
sta load_address
|
||||
|
||||
lda track_array,X
|
||||
sta load_track
|
||||
|
||||
lda sector_array,X
|
||||
sta load_sector
|
||||
|
||||
lda length_array,X
|
||||
sta load_length
|
||||
|
||||
jsr load_new
|
||||
|
||||
rts
|
||||
|
||||
;===================================================
|
||||
;===================================================
|
||||
; change disk
|
||||
;===================================================
|
||||
;===================================================
|
||||
|
||||
change_disk:
|
||||
|
||||
; turn off disk drive light
|
||||
|
||||
jsr driveoff
|
||||
|
||||
jsr TEXT
|
||||
jsr HOME
|
||||
|
||||
lda #<error_string
|
||||
sta OUTL
|
||||
lda #>error_string
|
||||
sta OUTH
|
||||
|
||||
ldx WHICH_LOAD
|
||||
lda which_disk_array,X
|
||||
clc
|
||||
adc #48
|
||||
|
||||
ldy #19
|
||||
sta (OUTL),Y
|
||||
|
||||
ldy #0
|
||||
|
||||
quick_print:
|
||||
lda (OUTL),Y
|
||||
beq quick_print_done
|
||||
jsr COUT1
|
||||
iny
|
||||
jmp quick_print
|
||||
|
||||
quick_print_done:
|
||||
|
||||
fnf_keypress:
|
||||
lda KEYPRESS
|
||||
bpl fnf_keypress
|
||||
bit KEYRESET
|
||||
|
||||
;==============================================
|
||||
; actually verify proper disk is there
|
||||
; read T0:S0 and verify proper disk
|
||||
|
||||
lda WHICH_LOAD
|
||||
pha
|
||||
|
||||
ldx #LOAD_FIRST_SECTOR ; load track 0 sector 0
|
||||
stx WHICH_LOAD
|
||||
|
||||
jsr load_file_no_diskcheck
|
||||
|
||||
pla
|
||||
sta WHICH_LOAD
|
||||
tax
|
||||
|
||||
; first sector now in $800
|
||||
; offset 59
|
||||
; disk1 = $0a
|
||||
; disk2 = $32 ('2')
|
||||
; disk3 = $33 ('3')
|
||||
|
||||
lda $859
|
||||
cmp #$0a
|
||||
beq is_disk1
|
||||
cmp #$32
|
||||
beq is_disk2
|
||||
cmp #$33
|
||||
beq is_disk3
|
||||
bne change_disk ; unknown disk
|
||||
|
||||
is_disk1:
|
||||
lda #1
|
||||
bne disk_compare
|
||||
|
||||
is_disk2:
|
||||
lda #2
|
||||
bne disk_compare
|
||||
|
||||
is_disk3:
|
||||
lda #3
|
||||
|
||||
disk_compare:
|
||||
cmp which_disk_array,X
|
||||
bne change_disk ; disk mismatch
|
||||
|
||||
;==============================================
|
||||
; all good, retry original load
|
||||
|
||||
jsr HOME
|
||||
|
||||
ldx WHICH_LOAD
|
||||
lda which_disk_array,X
|
||||
sta CURRENT_DISK
|
||||
|
||||
jmp load_file
|
||||
|
||||
; offset for disk number is 19
|
||||
error_string:
|
||||
.byte "PLEASE INSERT DISK 1, PRESS RETURN",0
|
||||
|
||||
|
||||
which_disk_array:
|
||||
.byte 1,1,3,3 ; MIST_TITLE,MIST,MECHE,SELENA
|
||||
.byte 1,1,3,2 ; OCTAGON,VIEWER,STONEY,CHANNEL
|
||||
.byte 2,1,2,2 ; CABIN,DENTIST,ARBOR,NIBEL
|
||||
.byte 1,1,1,3 ; SHIP,GENERATOR,D'NI,SUB
|
||||
.byte 1 ; TEXT_TITLE
|
||||
.byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
|
||||
.byte $f ; FIRST_SECTOR
|
||||
|
||||
load_address_array:
|
||||
.byte $60,$40,$40,$40 ; MIST_TITLE,MIST,MECHE,SELENA
|
||||
.byte $40,$40,$40,$40 ; OCTAGON,VIEWER,STONEY,CHANNEL
|
||||
.byte $40,$40,$40,$40 ; CABIN,DENTIST,ARBOR,NIBEL
|
||||
.byte $40,$40,$40,$40 ; SHIP,GENERATOR,D'NI,SUB
|
||||
.byte $08 ; TEXT_TITLE
|
||||
.byte $0A,$0A,$0A,$0A
|
||||
.byte $0A ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
|
||||
.byte $08 ; FIRST_SECTOR
|
||||
|
||||
track_array:
|
||||
.byte 3, 9, 1,21 ; MIST_TITLE,MIST,MECHE,SELENA
|
||||
.byte 18,31,11, 1 ; OCTAGON,VIEWER,STONEY,CHANNEL
|
||||
.byte 27,26,10,20 ; CABIN,DENTIST,ARBOR,NIBEL
|
||||
.byte 30,32,28,30 ; SHIP,GENERATOR,D'NI,SUB
|
||||
.byte 0 ; TEXT_TITLE
|
||||
.byte 0, 0, 0, 0, 0 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
|
||||
.byte 0 ; FIRST_SECTOR
|
||||
|
||||
sector_array:
|
||||
.byte 0, 0, 0, 0 ; MIST_TITLE,MIST,MECHE,SELENA
|
||||
.byte 0, 8, 0, 0 ; OCTAGON,VIEWER,STONEY,CHANNEL
|
||||
.byte 0, 0, 0, 0 ; CABIN,DENTIST,ARBOR,NIBEL
|
||||
.byte 0,13, 0, 1 ; SHIP,GENERATOR,D'NI,SUB
|
||||
.byte 6 ; TEXT_TITLE
|
||||
.byte 11,12,13,14,15 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
|
||||
.byte 0 ; FIRST_SECTOR
|
||||
|
||||
length_array:
|
||||
.byte 88, 99,157,145 ; MIST_TITLE,MIST,MECHE,SELENA
|
||||
.byte 128, 20,158,135 ; OCTAGON,VIEWER,STONEY,CHANNEL
|
||||
.byte 61, 31,159,109 ; CABIN,DENTIST,ARBOR,NIBEL
|
||||
.byte 20, 33, 27, 78 ; SHIP,GENERATOR,D'NI,SUB
|
||||
.byte 3 ; TEXT_TITLE
|
||||
.byte 1,1,1,1,1 ; SAVE1,SAVE2,SAVE3,SAVE4,SAVE5
|
||||
.byte 1 ; FIRST_SECTOR
|
||||
|
||||
.include "qkumba_popwr.s"
|
||||
|
||||
qload_end:
|
||||
|
||||
;.assert (>qload_end - >qload_start) < $e , error, "loader too big"
|
||||
.assert (>qload_end - >qload_start) < $12 , error, "loader too big"
|
Loading…
Reference in New Issue
Block a user