Skip to content

Commit 6d36b91

Browse files
committed
Work on load/save menu
1 parent a90e8cf commit 6d36b91

27 files changed

+1125
-211
lines changed

AzelLib/3dEngine.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ struct sFieldCameraStatus
5959
extern sMatrix4x3* pCurrentMatrix;
6060

6161
void addObjectToDrawList(struct sProcessed3dModel* pObjectData);
62-
void addBillBoardToDrawList(u8* pObjectData, u32 offset);
63-
void addBillBoardToDrawList(sProcessed3dModel* pObjectData);
62+
void addBillBoardToDrawList(struct sProcessed3dModel* pObjectData);
6463

6564
void updateEngineCamera(s_cameraProperties2* r4, const sVec3_FP& r5_position, const sVec3_S16& r6_rotation);
6665

AzelLib/3dEngine_flush.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,27 +141,6 @@ void addBillBoardToDrawList(sProcessed3dModel* pObjectData)
141141
objectRenderList.push_back(newObject);
142142
}
143143

144-
void addBillBoardToDrawList(u8* pObjectData, u32 offset)
145-
{
146-
sKey thisKey;
147-
thisKey.pObjectData = pObjectData;
148-
thisKey.offset = offset;
149-
150-
sProcessed3dModel* pModel = NULL;
151-
auto search = modelMap.find(thisKey);
152-
if (search != modelMap.end())
153-
{
154-
pModel = search->second;
155-
}
156-
else
157-
{
158-
pModel = new sProcessed3dModel(pObjectData, offset);
159-
modelMap[thisKey] = pModel;
160-
}
161-
162-
addBillBoardToDrawList(pModel);
163-
}
164-
165144
void checkGLImpl(const char* file, unsigned int line)
166145
{
167146
GLenum error = glGetError();

AzelLib/PDS.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,11 @@ void patchFilePointers(s_fileBundle* destination, u32 characterArea)
559559
destination->setPatchFilePointers(characterArea);
560560
}
561561

562+
int loadFile2(const char* fileName, u8* destination, u16 vdp1Pointer)
563+
{
564+
return loadFile(fileName, destination, vdp1Pointer);
565+
}
566+
562567
// version used for raw data (non-bundle)
563568
int loadFile(const char* fileName, u8* destination, u16 vdp1Pointer)
564569
{
@@ -1104,3 +1109,4 @@ void adjustMatrixTranslation(fixedPoint r4)
11041109
pCurrentMatrix->matrix[7] += (((s64)pCurrentMatrix->matrix[5] * (s64)r4) >> 16);
11051110
pCurrentMatrix->matrix[11] += (((s64)pCurrentMatrix->matrix[9] * (s64)r4) >> 16);
11061111
}
1112+

AzelLib/PDS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ struct sSaturnPtr
192192
temp.m_file = pFile;
193193
return temp;
194194
}
195+
196+
u8* getRawPointer();
195197
};
196198

197199
struct sSaturnMemoryFile

AzelLib/VDP2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ sLayerConfig textLayerVdp2Setup[] = {
452452
m0_END
453453
};
454454

455-
void setupNBG0(sLayerConfig* setup)
455+
void setupNBG0(const sLayerConfig* setup)
456456
{
457457
while (eVdp2LayerConfig command = setup->m_configType)
458458
{
@@ -495,7 +495,7 @@ void setupNBG0(sLayerConfig* setup)
495495
vdp2Controls.m_isDirty = true;
496496
}
497497

498-
void setupNBG1(sLayerConfig* setup)
498+
void setupNBG1(const sLayerConfig* setup)
499499
{
500500
while (eVdp2LayerConfig command = setup->m_configType)
501501
{
@@ -556,7 +556,7 @@ void setupNBG1(sLayerConfig* setup)
556556
vdp2Controls.m_isDirty = true;
557557
}
558558

559-
void setupNBG2(sLayerConfig* setup)
559+
void setupNBG2(const sLayerConfig* setup)
560560
{
561561
while (eVdp2LayerConfig command = setup->m_configType)
562562
{
@@ -608,7 +608,7 @@ void setupNBG2(sLayerConfig* setup)
608608
vdp2Controls.m_isDirty = true;
609609
}
610610

611-
void setupNBG3(sLayerConfig* setup)
611+
void setupNBG3(const sLayerConfig* setup)
612612
{
613613
while (eVdp2LayerConfig command = setup->m_configType)
614614
{

AzelLib/VDP2.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ struct s_VDP2Regs
107107
u16 mF6_PRISD;
108108
u16 mF8_PRINA;
109109
u16 mFA_PRINB;
110-
u16 mFC_PRIR;
110+
u16 mFC_PRIR;
111+
u16 m100_CCRSA;
112+
u16 m102_CCRSB;
113+
u16 m104_CCRSC;
114+
u16 m106_CCRSD;
111115
u16 m10A_CCRNB;
112116
u16 m110_CLOFEN;
113117
u16 m112_CLOFSL;
@@ -170,10 +174,10 @@ void setupVDP2CoordinatesIncrement2(u32, u32);
170174
void initVDP2();
171175
void reinitVdp2();
172176

173-
void setupNBG0(sLayerConfig* setup);
174-
void setupNBG1(sLayerConfig* setup);
175-
void setupNBG2(sLayerConfig* setup);
176-
void setupNBG3(sLayerConfig* setup);
177+
void setupNBG0(const sLayerConfig* setup);
178+
void setupNBG1(const sLayerConfig* setup);
179+
void setupNBG2(const sLayerConfig* setup);
180+
void setupNBG3(const sLayerConfig* setup);
177181

178182
void setupVDP2StringRendering(s32 x, s32 y, s32 width, s32 height);
179183
void vdp2DebugPrintSetPosition(s32 x, s32 y);
@@ -249,6 +253,7 @@ void setVdp2VramU32(u32 offset, u32 value);
249253
u8* getVdp2Cram(u32 offset);
250254

251255
int loadFile(const char* fileName, u8* destination, u16 vdp1Pointer);
256+
int loadFile2(const char* fileName, u8* destination, u16 vdp1Pointer);
252257
int loadFile(const char* fileName, s_fileBundle** destination, u16 vdp1Pointer);
253258
void addToMemoryLayout(u8* pointer, u32 unk0);
254259
void asyncDmaCopy(void* source, void* target, u32 size, u32 unk);

AzelLib/common.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,3 +807,12 @@ sVec3_FP readSaturnVec3(sSaturnPtr ptr)
807807

808808
return newVec;
809809
}
810+
811+
u8* sSaturnPtr::getRawPointer()
812+
{
813+
sSaturnMemoryFile* pFile = m_file;
814+
u32 offsetInFile = m_offset - m_file->m_base;
815+
assert(offsetInFile <= pFile->m_dataSize);
816+
817+
return pFile->m_data + offsetInFile;
818+
}

AzelLib/field.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ void setupFileList(const s_MCB_CGB* fileList)
7777
fieldTaskPtr->m8_pSubFieldData->m30_fileList = fileList;
7878

7979
checkFilesExists(fileList);
80-
81-
fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[0] = fieldTaskPtr->m8_pSubFieldData->m20_memoryArea_bottom;
82-
fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[1] = fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[0] + fieldTaskPtr->m8_pSubFieldData->m34_MCBFilesSizes[0]; // TODO: should be aligned
83-
fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[2] = fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[1] + fieldTaskPtr->m8_pSubFieldData->m34_MCBFilesSizes[1]; // TODO: should be aligned
8480

85-
fieldTaskPtr->m8_pSubFieldData->m0_bundles[0] = new s_fileBundle(fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[0]);
86-
fieldTaskPtr->m8_pSubFieldData->m0_bundles[1] = new s_fileBundle(fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[1]);
87-
fieldTaskPtr->m8_pSubFieldData->m0_bundles[2] = new s_fileBundle(fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[2]);
81+
u8* buffers[3];
82+
buffers[0] = fieldTaskPtr->m8_pSubFieldData->m20_memoryArea_bottom;
83+
buffers[1] = buffers[0] + fieldTaskPtr->m8_pSubFieldData->m34_MCBFilesSizes[0]; // TODO: should be aligned
84+
buffers[2] = buffers[1] + fieldTaskPtr->m8_pSubFieldData->m34_MCBFilesSizes[1]; // TODO: should be aligned
85+
86+
fieldTaskPtr->m8_pSubFieldData->m0_bundles[0] = new s_fileBundle(buffers[0]);
87+
fieldTaskPtr->m8_pSubFieldData->m0_bundles[1] = new s_fileBundle(buffers[1]);
88+
fieldTaskPtr->m8_pSubFieldData->m0_bundles[2] = new s_fileBundle(buffers[2]);
8889

8990
fieldTaskPtr->m8_pSubFieldData->mC_characterArea[0] = fieldTaskPtr->m8_pSubFieldData->m28_characterArea_bottom;
9091
fieldTaskPtr->m8_pSubFieldData->mC_characterArea[1] = fieldTaskPtr->m8_pSubFieldData->mC_characterArea[0] + fieldTaskPtr->m8_pSubFieldData->m1B4_CGBFilesSizes[0]; // TODO: should be aligned
@@ -105,7 +106,7 @@ void setupFileList(const s_MCB_CGB* fileList)
105106
currentFileIndex++;
106107
}
107108

108-
fieldTaskPtr->m8_pSubFieldData->m18_memoryArea_edge = fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[2] + largestMCB; // TODO: should be aligned
109+
fieldTaskPtr->m8_pSubFieldData->m18_memoryArea_edge = buffers[2] + largestMCB; // TODO: should be aligned
109110
fieldTaskPtr->m8_pSubFieldData->m1C_characterArea_edge = fieldTaskPtr->m8_pSubFieldData->mC_characterArea[2] + largestCGB; // TODO: should be aligned
110111
}
111112

@@ -128,7 +129,6 @@ void loadFileFromFileList(u32 index)
128129
if (pFileData->MCB)
129130
{
130131
loadFile(pFileData->MCB, &fieldTaskPtr->m8_pSubFieldData->m0_bundles[slot], fieldTaskPtr->m8_pSubFieldData->mC_characterArea[slot] >> 3);
131-
fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[slot] = fieldTaskPtr->m8_pSubFieldData->m0_bundles[slot]->getRawBuffer();
132132
}
133133

134134
if (pFileData->CGB)
@@ -144,7 +144,6 @@ void getMemoryArea(s_memoryAreaOutput* pOutput, u32 areaIndex)
144144
areaIndex = 2;
145145
}
146146

147-
pOutput->m0_mainMemory = fieldTaskPtr->m8_pSubFieldData->m0_memoryArea[areaIndex];
148147
pOutput->m0_mainMemoryBundle = fieldTaskPtr->m8_pSubFieldData->m0_bundles[areaIndex];
149148
pOutput->m4_characterArea = fieldTaskPtr->m8_pSubFieldData->mC_characterArea[areaIndex];
150149
}

AzelLib/field.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ struct s_fieldScriptWorkArea : public s_workAreaTemplate<s_fieldScriptWorkArea>
298298

299299
struct s_memoryAreaOutput
300300
{
301-
u8* m0_mainMemory;
302301
struct s_fileBundle* m0_mainMemoryBundle;
303302
u32 m4_characterArea;
304303
};
@@ -737,7 +736,6 @@ struct s_FieldSubTaskWorkArea : public s_workAreaTemplate<s_FieldSubTaskWorkArea
737736
static void Draw(s_FieldSubTaskWorkArea*);
738737
static void Delete(s_FieldSubTaskWorkArea*);
739738

740-
std::array<u8*, 3> m0_memoryArea; // 0
741739
std::array<struct s_fileBundle*, 3> m0_bundles;
742740
std::array<u32, 3> mC_characterArea; // C
743741
u8* m18_memoryArea_edge; // 18

AzelLib/field/field_a3/o_fld_a3.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@ void s_visdibilityCellTask::gridCellDraw_normal(s_visdibilityCellTask* pTypedWor
206206
while (r14->m0_offsetTable.m_offset)
207207
{
208208
r13->m12E0++;
209-
210-
s16 r2 = readSaturnS16(r14->m0_offsetTable);
211-
u32 r1 = READ_BE_U32(pTypedWorkAread->m0_memoryLayout.m0_mainMemory + r2);
212-
r13->m12F0 += READ_BE_U32(pTypedWorkAread->m0_memoryLayout.m0_mainMemory + r1 + 4);
209+
r13->m12F0 += pTypedWorkAread->m0_memoryLayout.m0_mainMemoryBundle->get3DModel(readSaturnS16(r14->m0_offsetTable))->m4_numVertices;
213210

214211
if (!r13->m12FC_isObjectClipped(&r14->m4, r15))
215212
{
@@ -264,10 +261,7 @@ void s_visdibilityCellTask::gridCellDraw_normal(s_visdibilityCellTask* pTypedWor
264261
while (r14 != pTypedWorkAread->mC_pCell2_billboards->end())
265262
{
266263
r13->m12E0++;
267-
268-
s16 r2 = readSaturnS16(r14->m0);
269-
u32 r1 = READ_BE_U32(pTypedWorkAread->m0_memoryLayout.m0_mainMemory + r2);
270-
r13->m12F0 += READ_BE_U32(pTypedWorkAread->m0_memoryLayout.m0_mainMemory + r1 + 4);
264+
r13->m12F0 += pTypedWorkAread->m0_memoryLayout.m0_mainMemoryBundle->get3DModel(readSaturnS16(r14->m0))->m4_numVertices;
271265

272266
if (!r13->m12FC_isObjectClipped(&r14->m4, r15))
273267
{

0 commit comments

Comments
 (0)