mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-03-01 03:30:04 +00:00
Refined the resource index so that wilderness map really does fully function from any of the data disks.
This commit is contained in:
parent
681faa7187
commit
54735f5317
@ -59,7 +59,7 @@ class A2PackPartitions
|
||||
static final int AC_KLUDGE = 2 // minus 1 to work around last-block bug in AppleCommander
|
||||
static final int DOS_OVERHEAD = 3 // only 3 blks overhead! ProRWTS is so freaking amazing.
|
||||
static final int SAVE_GAME_BYTES = 0x1200
|
||||
static final int MAX_DISKS = 20 // for now this should be way more than enough
|
||||
static final int MAX_DISKS = 8 // if more are needed, we'd have to expand the resource index format
|
||||
|
||||
def typeNumToDisplayName = [1: "Code",
|
||||
2: "2D map",
|
||||
@ -1700,6 +1700,9 @@ class A2PackPartitions
|
||||
mapChunks[key] = chunk
|
||||
chunk.buf.partNum = 1
|
||||
portraitSpace += len
|
||||
if (!chunkDisks.containsKey(key.toString()))
|
||||
chunkDisks[key.toString()] = [] as Set
|
||||
chunkDisks[key.toString()].add(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1765,9 +1768,9 @@ class A2PackPartitions
|
||||
mapChunks.each { k,v ->
|
||||
v.buf.partNum = partNum
|
||||
outChunks[k] = v
|
||||
if (!chunkDisks.containsKey(k))
|
||||
chunkDisks[k] = [] as Set
|
||||
chunkDisks[k].add(partNum)
|
||||
if (!chunkDisks.containsKey(k.toString()))
|
||||
chunkDisks[k.toString()] = [] as Set
|
||||
chunkDisks[k.toString()].add(partNum)
|
||||
}
|
||||
// Handle maps that get dupe'd on each data disk
|
||||
if (toDupe.contains(mapName))
|
||||
@ -1844,6 +1847,13 @@ class A2PackPartitions
|
||||
return String.format("%s%s%d", engineCode, offset < 0 ? "-" : ".", Math.abs(offset))
|
||||
}
|
||||
|
||||
def calcDiskBits(disks)
|
||||
{
|
||||
int out = 0
|
||||
disks.each { out |= (1<<(it-1)) }
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an index listing the partition number wherein each map and portrait can be found.
|
||||
*/
|
||||
@ -1859,16 +1869,18 @@ class A2PackPartitions
|
||||
// Then output 2D maps, 3d maps, and portraits
|
||||
tmp.put((byte) maps2D.size())
|
||||
maps2D.each { k, v ->
|
||||
tmp.put((byte) ((parseOrder(v.order) < 0) ? 255 : v.buf.partNum))
|
||||
tmp.put((byte) calcDiskBits(chunkDisks[["map2D", k].toString()]))
|
||||
}
|
||||
|
||||
tmp.put((byte) maps3D.size())
|
||||
maps3D.each { k, v ->
|
||||
tmp.put((byte) ((parseOrder(v.order) < 0) ? 255 : v.buf.partNum))
|
||||
tmp.put((byte) calcDiskBits(chunkDisks[["map3D", k].toString()]))
|
||||
}
|
||||
|
||||
tmp.put((byte) portraits.size())
|
||||
portraits.each { k, v -> tmp.put((byte) (v.buf.partNum ? v.buf.partNum : 0)) }
|
||||
portraits.each { k, v ->
|
||||
tmp.put((byte) calcDiskBits(chunkDisks[["portrait", k].toString()]))
|
||||
}
|
||||
|
||||
code["resourceIndex"].buf = compress(unwrapByteBuffer(tmp))
|
||||
def chunk = [type:TYPE_CODE, num:code["resourceIndex"].num,
|
||||
@ -2409,7 +2421,7 @@ class A2PackPartitions
|
||||
def dataKey = [type:type, name:name]
|
||||
if (!data.containsKey(dataKey)) {
|
||||
data[dataKey] = [clen: v.clen, uclen: v.uclen,
|
||||
disks: chunkDisks[[typeNumToName[k.type], k.name]],
|
||||
disks: chunkDisks[[typeNumToName[k.type], k.name].toString()],
|
||||
ids: [k.num] as Set]
|
||||
}
|
||||
else {
|
||||
|
@ -28,7 +28,6 @@
|
||||
MAX_SEGS = 96
|
||||
|
||||
DEBUG = 0
|
||||
SANITY_CHECK = 0 ; also prints out request data
|
||||
|
||||
; Zero page temporary variables.
|
||||
; Don't move these - they overlap in clever ways with ProRWTS shadows (see below)
|
||||
@ -269,7 +268,7 @@ init: !zone
|
||||
cpx #MAX_SEGS-1 ; did all segments yet?
|
||||
bne .loop ; no, loop again
|
||||
; Allocate space for the PLASMA frame stack
|
||||
!if SANITY_CHECK {
|
||||
!if DEBUG {
|
||||
lda #$20
|
||||
sta framePtr+1 ; because sanity check verifies it's not $BE or $BF
|
||||
}
|
||||
@ -812,7 +811,7 @@ heapCheck: !zone
|
||||
; fall through to heapCorrupt...
|
||||
|
||||
heapCorrupt:
|
||||
+prWord pTmp
|
||||
+prWord pSrc
|
||||
jsr inlineFatal : !text "HeapCorrupt",0
|
||||
|
||||
; Begin a heap scan by setting pTmp to start-of-heap, then returns
|
||||
@ -1282,7 +1281,7 @@ dispatch:
|
||||
rol ; transfer carry bit
|
||||
sta isAuxCmd ; to isAuxCmd
|
||||
pla
|
||||
!if SANITY_CHECK { jsr saneStart : jsr + : jmp saneEnd }
|
||||
!if DEBUG { jsr saneStart : jsr + : jmp saneEnd }
|
||||
+ cmp #REQUEST_MEMORY
|
||||
bne +
|
||||
jmp mem_request
|
||||
@ -1342,8 +1341,8 @@ dispatch:
|
||||
+ jmp nextLdVec ; Pass command to next chained loader
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Sanity check mode
|
||||
!if SANITY_CHECK {
|
||||
; Debug-mode sanity checking
|
||||
!if DEBUG {
|
||||
saneStart: !zone {
|
||||
sta saneEnd+2 ; save cmd num for end-checking
|
||||
cmp #ADVANCE_ANIMS
|
||||
@ -2031,7 +2030,7 @@ openPartition: !zone
|
||||
bne .open
|
||||
; ask user to insert the disk
|
||||
; TODO: handle dual drive configuration
|
||||
.insert +safeHome
|
||||
.insert !if DEBUG = 0 { +safeHome }
|
||||
+prStr : !text "Insert disk ",0
|
||||
bit $c051
|
||||
lda curPartition
|
||||
@ -2039,7 +2038,7 @@ openPartition: !zone
|
||||
adc #"0"
|
||||
+safeCout
|
||||
+waitKey
|
||||
+safeHome
|
||||
!if DEBUG = 0 { +safeHome }
|
||||
bit $c050
|
||||
jmp .retry ; try again
|
||||
.origFloppy: !byte 0
|
||||
|
@ -1682,7 +1682,7 @@ end
|
||||
// sectioNum: 1=map2d, 2=map3d, 3=portrait
|
||||
export def lookupResourcePart(sectionNum, resourceNum)#1
|
||||
word ptr
|
||||
byte n
|
||||
byte n, i
|
||||
|
||||
// Skip to the requested section (starting just after version num)
|
||||
ptr = pResourceIndex
|
||||
@ -1695,13 +1695,18 @@ export def lookupResourcePart(sectionNum, resourceNum)#1
|
||||
n = readAuxByte(ptr)
|
||||
if resourceNum > n; fatal("lkupFail1"); fin
|
||||
n = readAuxByte(ptr + resourceNum)
|
||||
// 255 is special code for map that is replicated on every data disk
|
||||
if n == 255
|
||||
if curMapPartition > 0; return curMapPartition; fin
|
||||
return 2
|
||||
|
||||
// If resource is on the current map's disk, prefer that
|
||||
if n & (1<<(curMapPartition-1))
|
||||
return curMapPartition
|
||||
fin
|
||||
if n < 0 or n > 20; fatal("lkupFail2"); fin // allow zero (e.g. portrait not used so not packed)
|
||||
return n
|
||||
|
||||
// Otherwise return the first disk it's on
|
||||
for i = 0 to 8
|
||||
if n & (1<<i); return i+1; fin
|
||||
next
|
||||
fatal("lkupFail2")
|
||||
return 0
|
||||
end
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user