Working on C export for cutscene types

This commit is contained in:
Sauraen
2021-05-01 23:02:50 -07:00
parent 392cb2501b
commit 35cddbbdde
4 changed files with 203 additions and 0 deletions
@@ -549,6 +549,45 @@ def ootCutsceneToC(scene, headerIndex):
data.source += "\tCS_BEGIN_CUTSCENE(" + str(1 if scene.csWriteTerminator else 0) + ", " + str(scene.csEndFrame) + "),\n"
if scene.csWriteTerminator:
data.source += "\tCS_TERMINATOR(" + str(scene.csTermIdx) + ", " + str(scene.csTermStart) + ", " + str(scene.csTermEnd) + "),\n"
for list in scene.csLists:
data.source += "\t" + ootEnumCSListTypeListC[list.listType] + "("
if list.listType == "Unk":
data.source += list.unkType + ", "
if list.listType == "FX":
data.source += str(list.fxType) + ", " + str(list.fxStartFrame) + ", " + str(list.fxEndFrame)
else:
data.source += str(len(list.entries))
data.source += "),\n"
for e in list.entries:
data.source += "\t\t"
if list.listType == "Textbox":
data.source += ootEnumCSTextboxTypeEntryC[e.textboxType]
else:
data.source += ootEnumCSListTypeEntryC[list.listType]
data.source += "("
if list.listType == "Textbox":
TODO()
elif list.listType == "Lighting":
TODO()
elif list.listType == "Time":
TODO()
elif list.listType in ["PlayBGM", "StopBGM", "FadeBGM"]:
data.source += e.value + ", " + str(e.startFrame) + ", " + str(e.endFrame) \
+ ", 0, 0, 0, 0, 0, 0, 0, 0"
elif list.listType == "Misc":
data.source += str(e.operation) + ", " + str(e.startFrame) + ", " \
+ str(e.endFrame) + ", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0"
elif list.listType == "0x09":
data.source += "0, " + str(e.startFrame) + ", " + str(e.startFrame + 1) + ", " \
+ e.unk2 + ", " + e.unk3 + ", " + e.unk4 + ", 0, 0"
elif list.listType == "Unk":
data.source += e.unk1 + ", " + e.unk2 + ", " + e.unk3 + ", " \
+ e.unk4 + ", " + e.unk5 + ", " + e.unk6 + ", " \
+ e.unk7 + ", " + e.unk8 + ", " + e.unk9 + ", " \
+ e.unk10 + ", " + e.unk11 + ", " + e.unk12
else:
raise PluginError("Invalid cutscene list type")
data.source += "),\n"
data.source += "\tCS_END(),\n"
data.source += "};\n"
return data
+32
View File
@@ -1430,6 +1430,32 @@ ootEnumCSListTypeIcons = [
'OPTIONS', 'EVENT_F9', 'QUESTION'
]
ootEnumCSListTypeListC = {
"Textbox": 'CS_TEXT_LIST',
"FX": 'CS_SCENE_TRANS_FX',
"Lighting": 'CS_LIGHTING_LIST',
"Time": 'CS_TIME_LIST',
"PlayBGM": 'CS_PLAY_BGM_LIST',
"StopBGM": 'CS_STOP_BGM_LIST',
"FadeBGM": 'CS_FADE_BGM_LIST',
"Misc": 'CS_MISC_LIST',
"0x09": 'CS_CMD_09_LIST',
"Unk": 'CS_UNK_DATA_LIST'
}
ootEnumCSListTypeEntryC = {
"Textbox": None, # special case
"FX": None, # no list entries
"Lighting": 'CS_LIGHTING',
"Time": 'CS_TIME',
"PlayBGM": 'CS_PLAY_BGM',
"StopBGM": 'CS_STOP_BGM',
"FadeBGM": 'CS_FADE_BGM',
"Misc": 'CS_MISC',
"0x09": 'CS_CMD_09',
"Unk": 'CS_UNK_DATA'
}
ootEnumCSTextboxType = [
("Text", "Text", "Text"),
("None", "None", "None"),
@@ -1439,3 +1465,9 @@ ootEnumCSTextboxType = [
ootEnumCSTextboxTypeIcons = [
'FILE_TEXT', 'HIDE_ON', 'FILE_SOUND'
]
ootEnumCSTextboxTypeEntryC = {
"Text": 'CS_TEXT_DISPLAY_TEXTBOX',
"None": 'CS_TEXT_NONE',
"LearnSong": 'CS_TEXT_LEARN_SONG',
}
+58
View File
@@ -55,6 +55,63 @@ class OOTLight:
def getBlendFogShort(self):
return format((self.transitionSpeed << 10) | self.fogNear, "#06x")
class OOTCSTextbox:
def __init__(self):
self.textboxType = None
self.messageId = '0x0000'
self.ocarinaSongAction = '0x0000'
self.startFrame = 0
self.endFrame = 1
self.type = '0x0000'
self.topOptionBranch = '0x0000'
self.bottomOptionBranch = '0x0000'
self.ocarinaMessageId = '0x0000'
class OOTCSLighting:
def __init__(self):
self.index = 1
self.startFrame = 0
class OOTCSTime:
def __init__(self):
self.startFrame = 0
self.hour = 23
self.minute = 59
class OOTCSBGM:
def __init__(self):
self.value = '0x0000'
self.startFrame = 0
self.endFrame = 1
class OOTCSMisc:
def __init__(self):
self.operation = 1
self.startFrame = 0
self.endFrame = 1
class OOTCS0x09:
def __init__(self):
self.startFrame = 0
self.unk2 = '0x00'
self.unk3 = '0x00'
self.unk4 = '0x00'
class OOTCSUnk:
def __unk__(self):
self.unk1 = self.unk2 = self.unk3 = self.unk4 = self.unk5 = self.unk6 = \
self.unk7 = self.unk8 = self.unk9 = self.unk10 = self.unk11 = \
self.unk12 = '0x00000000'
class OOTCSList:
def __init__(self):
self.listType = None
self.entries = []
self.unkType = '0x0001'
self.fxType = 2
self.fxStartFrame = 0
self.fxEndFrame = 0
class OOTSceneTableEntry:
def __init__(self):
self.drawConfig = 0
@@ -100,6 +157,7 @@ class OOTScene:
self.csTermIdx = 0
self.csTermStart = 99
self.csTermEnd = 100
self.csLists = []
self.sceneTableEntry = OOTSceneTableEntry()
+74
View File
@@ -66,6 +66,79 @@ def writeOtherSceneProperties(scene, exportInfo):
modifyDmaTableEntries(scene, exportInfo)
modifySegmentDefinition(scene, exportInfo)
modifySceneFiles(scene, exportInfo)
def readCutsceneData(scene, sceneHeader):
for listIn in sceneHeader.csLists:
listOut = OOTCSList()
listOut.listType = listIn.listType
listOut.unkType, listOut.fxType, listOut.fxStartFrame, listOut.fxEndFrame \
= listIn.unkType, listIn.fxType, listIn.fxStartFrame, listIn.fxEndFrame
listData = []
if listOut.listType == 'Textbox':
for entryIn in listIn.textbox:
entryOut = OOTCSTextbox()
entryOut.textboxType = entryIn.textboxType
entryOut.messageId = entryIn.messageId
entryOut.ocarinaSongAction = entryIn.ocarinaSongAction
entryOut.startFrame = entryIn.startFrame
entryOut.endFrame = entryIn.endFrame
entryOut.type = entryIn.type
entryOut.topOptionBranch = entryIn.topOptionBranch
entryOut.bottomOptionBranch = entryIn.bottomOptionBranch
entryOut.ocarinaMessageId = entryIn.ocarinaMessageId
listOut.entries.append(entryOut)
elif listOut.listType == 'Lighting':
for entryIn in listIn.lighting:
entryOut = OOTCSLighting()
entryOut.index = entryIn.index
entryOut.startFrame = entryIn.startFrame
listOut.entries.append(entryOut)
elif listOut.listType == 'Time':
for entryIn in listIn.time:
entryOut = OOTCSTime()
entryOut.startFrame = entryIn.startFrame
entryOut.hour = entryIn.hour
entryOut.minute = entryIn.minute
listOut.entries.append(entryOut)
elif listOut.listType in ['PlayBGM', 'StopBGM', 'FadeBGM']:
for entryIn in listIn.bgm:
entryOut = OOTCSBGM()
entryOut.value = entryIn.value
entryOut.startFrame = entryIn.startFrame
entryOut.endFrame = entryIn.endFrame
listOut.entries.append(entryOut)
elif listOut.listType == 'Misc':
for entryIn in listIn.misc:
entryOut = OOTCSMisc()
entryOut.operation = entryIn.operation
entryOut.startFrame = entryIn.startFrame
entryOut.endFrame = entryIn.endFrame
listOut.entries.append(entryOut)
elif listOut.listType == '0x09':
for entryIn in listIn.nine:
entryOut = OOTCS0x09()
entryOut.startFrame = entryIn.startFrame
entryOut.unk2 = entryIn.unk2
entryOut.unk3 = entryIn.unk3
entryOut.unk4 = entryIn.unk4
listOut.entries.append(entryOut)
elif listOut.listType == 'Unk':
for entryIn in listIn.unk:
entryOut = OOTCSUnk()
entryOut.unk1 = entryIn.unk1
entryOut.unk2 = entryIn.unk2
entryOut.unk3 = entryIn.unk3
entryOut.unk4 = entryIn.unk4
entryOut.unk5 = entryIn.unk5
entryOut.unk6 = entryIn.unk6
entryOut.unk7 = entryIn.unk7
entryOut.unk8 = entryIn.unk8
entryOut.unk9 = entryIn.unk9
entryOut.unk10 = entryIn.unk10
entryOut.unk11 = entryIn.unk11
entryOut.unk12 = entryIn.unk12
listOut.entries.append(entryOut)
scene.csLists.append(listOut)
def readSceneData(scene, sceneHeader, alternateSceneHeaders):
scene.sceneTableEntry.drawConfig = sceneHeader.sceneTableEntry.drawConfig
@@ -98,6 +171,7 @@ def readSceneData(scene, sceneHeader, alternateSceneHeaders):
scene.csTermIdx = getCustomProperty(sceneHeader, "csTermIdx")
scene.csTermStart = getCustomProperty(sceneHeader, "csTermStart")
scene.csTermEnd = getCustomProperty(sceneHeader, "csTermEnd")
readCutsceneData(scene, sceneHeader)
if alternateSceneHeaders is not None:
scene.collision.cameraData = OOTCameraData(scene.name)