mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-08 18:30:35 +00:00
Now fully supports multi-disk mode.
This commit is contained in:
parent
437471451b
commit
dab8bd2908
Binary file not shown.
@ -66,6 +66,14 @@ gcHash_dstHi = $5500
|
|||||||
; Other equates
|
; Other equates
|
||||||
prodosMemMap = $BF58
|
prodosMemMap = $BF58
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
!macro callMLI cmd, parms {
|
||||||
|
lda #cmd
|
||||||
|
ldx #<parms
|
||||||
|
ldy #>parms
|
||||||
|
jsr _callMLI
|
||||||
|
}
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Relocate all the pieces to their correct locations and perform patching.
|
; Relocate all the pieces to their correct locations and perform patching.
|
||||||
relocate:
|
relocate:
|
||||||
@ -216,7 +224,19 @@ relocate:
|
|||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
init: !zone
|
init: !zone
|
||||||
bit setLcRW+lcBank1 ; switch in mem mgr
|
; grab the prefix of the current drive
|
||||||
|
lda #<prodosPrefix
|
||||||
|
sta getPfxAddr
|
||||||
|
lda #>prodosPrefix
|
||||||
|
sta getPfxAddr+1
|
||||||
|
+callMLI MLI_GET_PREFIX, getPfxParams
|
||||||
|
bcc +
|
||||||
|
jmp prodosError
|
||||||
|
+ lda prodosPrefix
|
||||||
|
and #$F ; strip off drive/slot, keep string len
|
||||||
|
sta prodosPrefix
|
||||||
|
; switch in mem mgr
|
||||||
|
bit setLcRW+lcBank1
|
||||||
bit setLcRW+lcBank1
|
bit setLcRW+lcBank1
|
||||||
; put something interesting on the screen :)
|
; put something interesting on the screen :)
|
||||||
jsr home
|
jsr home
|
||||||
@ -230,7 +250,6 @@ init: !zone
|
|||||||
.clr: sta prodosMemMap-1,x
|
.clr: sta prodosMemMap-1,x
|
||||||
dex
|
dex
|
||||||
bne .clr
|
bne .clr
|
||||||
|
|
||||||
; clear the segment tables
|
; clear the segment tables
|
||||||
- sta tSegLink,x
|
- sta tSegLink,x
|
||||||
sta tSegAdrLo,x
|
sta tSegAdrLo,x
|
||||||
@ -792,13 +811,6 @@ __internalErr: !zone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
!macro callMLI cmd, parms {
|
|
||||||
lda #cmd
|
|
||||||
ldx #<parms
|
|
||||||
ldy #>parms
|
|
||||||
jsr _callMLI
|
|
||||||
}
|
|
||||||
|
|
||||||
; Call MLI from main memory rather than LC, since it lives in aux LC.
|
; Call MLI from main memory rather than LC, since it lives in aux LC.
|
||||||
_callMLI: sta .cmd
|
_callMLI: sta .cmd
|
||||||
stx .params
|
stx .params
|
||||||
@ -808,15 +820,17 @@ _callMLI: sta .cmd
|
|||||||
.params !word 0
|
.params !word 0
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; Out ProDOS param blocks can't be in LC ram
|
; Our ProDOS param blocks can't be in LC ram
|
||||||
openParams: !byte 3 ; param count
|
openParams: !byte 3 ; param count
|
||||||
!word filename ; pointer to file name
|
!word filename ; pointer to file name
|
||||||
!word fileBuf ; pointer to buffer
|
!word fileBuf ; pointer to buffer
|
||||||
openFileRef: !byte 0 ; returned file number
|
openFileRef: !byte 0 ; returned file number
|
||||||
filename: !byte 15 ; length
|
|
||||||
!raw "/LL/GAME.PART." ; TODO: Figure out how to avoid specifying full path. "raw" for ProDOS
|
; ProDOS prefix of the boot disk
|
||||||
; If I leave it out, ProDOS complains with error $40.
|
prodosPrefix: !fill 16
|
||||||
partNumChar: !raw "x" ; "x" replaced by partition number
|
|
||||||
|
; Buffer for forming the full filename
|
||||||
|
filename: !fill 28 ; 16 for prefix plus 11 for "/GAME.PART.1"
|
||||||
|
|
||||||
readParams: !byte 4 ; param count
|
readParams: !byte 4 ; param count
|
||||||
readFileRef: !byte 0 ; file ref to read
|
readFileRef: !byte 0 ; file ref to read
|
||||||
@ -833,6 +847,11 @@ setMarkPos: !byte 0 ; mark position (3 byte integer)
|
|||||||
closeParams: !byte 1 ; param count
|
closeParams: !byte 1 ; param count
|
||||||
closeFileRef: !byte 0 ; file ref to close
|
closeFileRef: !byte 0 ; file ref to close
|
||||||
|
|
||||||
|
getPfxParams: !byte 1 ; param count
|
||||||
|
getPfxAddr: !word 0 ; pointer to buffer
|
||||||
|
|
||||||
|
multiDiskMode: !byte 0 ; hardcoded to YES for now
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Heap management variables
|
; Heap management variables
|
||||||
MAX_TYPES = 16
|
MAX_TYPES = 16
|
||||||
@ -2028,17 +2047,55 @@ diskLoader: !zone
|
|||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
openPartition: !zone
|
openPartition: !zone
|
||||||
!if DEBUG { +prStr : !text "Opening part file ",0 : +prByte curPartition : +crout }
|
!if DEBUG { +prStr : !text "Opening part file ",0 : +prByte curPartition : +crout }
|
||||||
; complete the partition file name
|
; complete the partition file name, changing "1" to "2" if we're in multi-disk mode
|
||||||
|
; and opening partition 2.
|
||||||
|
.mkname ldx #1
|
||||||
|
ldy #1
|
||||||
|
- lda prodosPrefix,x
|
||||||
|
sta filename,y
|
||||||
|
cmp #$31 ; "1"
|
||||||
|
bne +
|
||||||
|
lda multiDiskMode
|
||||||
|
beq + ; don't change if single-disk mode
|
||||||
lda curPartition
|
lda curPartition
|
||||||
beq sequenceError ; partition number must be >= 1
|
cmp #2
|
||||||
clc
|
bcc +
|
||||||
adc #'0' ; assume partition numbers range from 0..9 for now
|
lda #$32 ; "2"
|
||||||
sta partNumChar
|
sta filename,y
|
||||||
|
+ cpx prodosPrefix ; done with full length of prefix?
|
||||||
|
beq +
|
||||||
|
inx
|
||||||
|
iny
|
||||||
|
bne - ; always taken
|
||||||
|
+ ldx #0
|
||||||
|
- lda .fileStr,x
|
||||||
|
beq +++
|
||||||
|
cmp #$31 ; "1"
|
||||||
|
bne ++
|
||||||
|
lda curPartition
|
||||||
|
bne +
|
||||||
|
jmp sequenceError ; partition number must be >= 1
|
||||||
|
+ clc
|
||||||
|
adc #$30
|
||||||
|
++ sta filename,y
|
||||||
|
inx
|
||||||
|
iny
|
||||||
|
bne - ; always taken
|
||||||
|
+++ dey
|
||||||
|
sty filename ; total length
|
||||||
; open the file
|
; open the file
|
||||||
+callMLI MLI_OPEN, openParams
|
.open +callMLI MLI_OPEN, openParams
|
||||||
bcs prodosError
|
bcc .opened
|
||||||
|
cmp #$46 ; file not found?
|
||||||
|
bne +
|
||||||
|
lda #1 ; enter into
|
||||||
|
sta multiDiskMode ; multi-disk mode
|
||||||
|
bne .mkname ; and retry
|
||||||
|
+ cmp #$45 ; volume not found?
|
||||||
|
beq .insert ; ask user to insert the disk
|
||||||
|
jmp prodosError ; no, misc error - print it and die
|
||||||
; grab the file number, since we're going to keep it open
|
; grab the file number, since we're going to keep it open
|
||||||
lda openFileRef
|
.opened lda openFileRef
|
||||||
sta partFileRef
|
sta partFileRef
|
||||||
sta readFileRef
|
sta readFileRef
|
||||||
; Read the first two bytes, which tells us how long the header is.
|
; Read the first two bytes, which tells us how long the header is.
|
||||||
@ -2059,6 +2116,19 @@ openPartition: !zone
|
|||||||
lda #2 ; read just after the 2-byte length
|
lda #2 ; read just after the 2-byte length
|
||||||
sta readAddr
|
sta readAddr
|
||||||
jmp readToMain ; finish by reading the rest of the header
|
jmp readToMain ; finish by reading the rest of the header
|
||||||
|
; ask user to insert the disk
|
||||||
|
.insert jsr home
|
||||||
|
+prStr : !text "Insert disk ",0
|
||||||
|
bit $c051
|
||||||
|
lda curPartition
|
||||||
|
clc
|
||||||
|
adc #"0"
|
||||||
|
jsr cout
|
||||||
|
jsr rdkey
|
||||||
|
jsr home
|
||||||
|
bit $c050
|
||||||
|
jmp .open ; try again
|
||||||
|
.fileStr !raw "/GAME.PART.1",0 ; 'raw' chars to get lo-bit ascii that ProDOS likes.
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
sequenceError: !zone
|
sequenceError: !zone
|
||||||
|
Loading…
x
Reference in New Issue
Block a user