Story loading now works.

This commit is contained in:
Martin Haye 2019-02-21 09:23:34 -08:00
parent 023c33218f
commit 027d988171
6 changed files with 41 additions and 5 deletions

View File

@ -1954,7 +1954,7 @@ class A2PackPartitions
// Stick on the partition number of the stories (used by non-floppy builds)
tmp.put((byte) 1)
tmp.put((byte) storyPartition)
tmp.put((byte) (1<<(storyPartition-1)))
// Pack it all up into a chunk and add it to the partition.
code["resourceIndex"].buf = compress(unwrapByteBuffer(tmp))
@ -2024,7 +2024,10 @@ class A2PackPartitions
def chunks = [:] as LinkedHashMap
def spaceUsed = CHUNK_HEADER_SIZE
stories.each { k, v ->
stories[k].buf = compress(stories[k].text.getBytes())
// Prepend the length of the story text
def text = stories[k].text.getBytes().toList()
def textWithLen = [text.size() & 0xFF, (text.size()>>8) & 0xFF] + text
stories[k].buf = compress(textWithLen as byte[])
spaceUsed += traceResources(["story", k], chunks)
}
partChunks << [partNum:storyPartition, chunks:chunks, spaceUsed:spaceUsed]

View File

@ -23,6 +23,7 @@ RES_TYPE_BYTECODE = $9
RES_TYPE_FIXUP = $A
RES_TYPE_PORTRAIT = $B
RES_TYPE_SONG = $C
RES_TYPE_STORY = $D
;------------------------------------------------------------------------------
; Command codes

View File

@ -24,6 +24,7 @@ import gamelib
predef auxMmgr(cmd, wordParam)#1
predef beep()#0
predef benchPlayer()#0
predef blit(isAux, srcData, dstScreenPtr, nLines, lineSize)#0
predef brk()#0
predef buildString(pFunc)#0
predef buySell(storeCode, profitRatio)#0

View File

@ -633,7 +633,7 @@ export asm finishString(isPlural)#1
end
///////////////////////////////////////////////////////////////////////////////////////////////////
asm blit(isAux, srcData, dstScreenPtr, nLines, lineSize)#0
export asm blit(isAux, srcData, dstScreenPtr, nLines, lineSize)#0
+asmPlasmNoRet 5
; Save line size
@ -1686,7 +1686,7 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Look up the partition for a resource.
// sectioNum: 0=version num (do not use here), 1=map2d, 2=map3d, 3=portrait
// sectioNum: 0=version num (do not use here), 1=map2d, 2=map3d, 3=portrait, 4=story
export def lookupResourcePart(sectionNum, resourceNum)#1
word ptr
byte n, i

View File

@ -46,6 +46,7 @@ const RES_TYPE_BYTECODE = 9
const RES_TYPE_FIXUP = 10
const RES_TYPE_PORTRAIT = 11
const RES_TYPE_SONG = 12
const RES_TYPE_STORY = 13
// Command codes
const RESET_MEMORY = $10

View File

@ -17,6 +17,8 @@ include "playtype.plh"
predef _story_mode(enable, portraitNum)#1, _story_display(storyNum)#1
word[] funcTbl = @_story_mode, @_story_display
word pStoryCur, pStoryEnd
///////////////////////////////////////////////////////////////////////////////////////////////////
// Definitions used by assembly code
asm __defs
@ -78,9 +80,37 @@ def _story_mode(enable, portraitNum)#1
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display string on a blank screen, with blanking follow-up
def loadStory(storyNum)#0
byte storyPart
word pAuxText, pEnd, pSrc, pDst, len
storyPart = lookupResourcePart(4, 1) // special section just to record the partition
auxMmgr(START_LOAD, storyPart)
pAuxText = auxMmgr(QUEUE_LOAD, storyNum<<8 | RES_TYPE_STORY)
auxMmgr(FINISH_LOAD, 0)
// We can slightly abuse the blit() routine to copy the story text from aux mem temporarily
// to hgr page 2 so it'll be easier to use.
pEnd = pAuxText + 2 + (readAuxByte(pAuxText) | (readAuxByte(pAuxText+1) << 8))
pSrc = pAuxText + 2
pDst = $4000
pStoryCur = pDst
while pSrc < pEnd
len = min(127, pEnd - pSrc)
blit(1, pSrc, pDst, 1, len)
pSrc = pSrc + len
pDst = pDst + len
loop
pStoryEnd = pDst
auxMmgr(FREE_MEMORY, pAuxText)
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Display story and picture on a blank screen, with blanking follow-up
def _story_display(storyNum)#1
word p
loadStory(storyNum)
printf2("pStoryCur=$%x pStoryEnd=$%x\n", pStoryCur, pStoryEnd)
p = displayStrNoScroll("\n\nHe heh hee lorem ipsum Blah blah blah. Also blah blah blah blah and blah.")
printf1("p=$%x\n", p)
p = displayStrNoScroll(" Blah blah blah. Blah blah blah blah and blah. Blah blah.")