Skip to content

Commit 4e99d76

Browse files
committed
Merge pull request #62 from Tororoi/fix/opening-crash
2 parents 38e57b5 + 4a5b068 commit 4e99d76

11 files changed

Lines changed: 245 additions & 97 deletions

File tree

‎docs/port/truncations.md‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ recovered, as `CCharacter::ClothStep` does with `PortImagePointer`) fixes the ro
7575

7676
| site | function | state | class | expression | origin | use |
7777
|---|---|---|---|---|---|---|
78-
| port/src/title/op_b.cpp:761 | OpB_InitProcess2 | port | resolved | `(intptr_t)& Wind` | image | store: Chara__3[8].wind (read back only in CCharacter::ClothStep) |
78+
| port/src/title/op_b.cpp:844 | OpB_InitProcess2 | port | resolved | `(intptr_t)& Wind` | image | store: Chara__3[8].wind (read back only in CCharacter::ClothStep) |
7979
| port/src/title/op_c.cpp:886 | OpC_InitProcess5 | port | resolved | `(intptr_t)& Wind` | image | store: Chara__3[11].wind (read back only in CCharacter::ClothStep) |
8080
| port/src/title/op_c.cpp:1589 | OpC_MotionProcess | port | resolved | `(intptr_t)& Wind` | image | store: Chara__3[11].wind (read back only in CCharacter::ClothStep) |
8181
| port/src/title/rushmovi.cpp:446 | MotionProcess | port | resolved | `(intptr_t)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
@@ -96,7 +96,7 @@ recovered, as `CCharacter::ClothStep` does with `PortImagePointer`) fixes the ro
9696
| ps2/src/editloop.cpp:5215 | LoadObjectParts | retail | resolved | `(int)parts->frame[2]` | field | store: parts->preview_frame (read back only in CEditGround::DrawPartsCursor) |
9797
| ps2/src/editloop.cpp:5217 | LoadObjectParts | retail | resolved | `(int)parts->frame[1]` | field | store: parts->preview_frame (read back only in CEditGround::DrawPartsCursor) |
9898
| ps2/src/editloop.cpp:5219 | LoadObjectParts | retail | resolved | `(int)parts->frame[0]` | field | store: parts->preview_frame (read back only in CEditGround::DrawPartsCursor) |
99-
| ps2/src/title/op_d.cpp:669 | OpD_MotionProcess | retail | resolved | `(int)& Wind` | image | store: Chara__3[cloth_actor].wind (read back only in CCharacter::ClothStep) |
99+
| ps2/src/title/op_d.cpp:673 | OpD_MotionProcess | retail | resolved | `(int)& Wind` | image | store: Chara__3[cloth_actor].wind (read back only in CCharacter::ClothStep) |
100100

101101
## Sites that never run (116)
102102

@@ -201,22 +201,22 @@ recovered, as `CCharacter::ClothStep` does with `PortImagePointer`) fixes the ro
201201
| ps2/src/texture.cpp:1065 | LoadImage | dead | escapes | `(u_int)source` | parameter | store to memory: packet[9] |
202202
| ps2/src/texture.cpp:1356 | CTextureManager::CleanUpBuffer | replaced | round-trip | `(int)* slot` | field | cast back: (u_int *)((int)* slot - shift) |
203203
| ps2/src/texture.cpp:1360 | CTextureManager::CleanUpBuffer | replaced | round-trip | `(int)tex->clut` | field | cast back: (u_int *)((int)tex->clut - shift) |
204-
| ps2/src/title/op_b.cpp:969 | OpB_InitProcess2 | replaced | resolved | `(int)& Wind` | image | store: Chara__3[8].wind (read back only in CCharacter::ClothStep) |
205-
| ps2/src/title/op_c.cpp:1242 | OpC_InitProcess5 | replaced | resolved | `(int)& Wind` | image | store: Chara__3[11].wind (read back only in CCharacter::ClothStep) |
206-
| ps2/src/title/op_c.cpp:1953 | OpC_MotionProcess | replaced | resolved | `(int)& Wind` | image | store: Chara__3[11].wind (read back only in CCharacter::ClothStep) |
207-
| ps2/src/title/rushmovi.cpp:601 | MotionProcess | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
208-
| ps2/src/title/rushmovi.cpp:603 | MotionProcess | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
209-
| ps2/src/title/title.cpp:424 | InitProcA | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
210-
| ps2/src/title/title.cpp:793 | InitProcB | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
211-
| ps2/src/title/title.cpp:1088 | InitProcC | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
212-
| ps2/src/title/title.cpp:1337 | InitProcD | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
213-
| ps2/src/title/title.cpp:1510 | InitProcE | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
214-
| ps2/src/title/title.cpp:1681 | InitProcF | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
215-
| ps2/src/title/title.cpp:1870 | InitProcG | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
216-
| ps2/src/title/title.cpp:1871 | InitProcG | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
217-
| ps2/src/title/title.cpp:1872 | InitProcG | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[2].wind (read back only in CCharacter::ClothStep) |
218-
| ps2/src/title/title.cpp:2061 | InitProcH | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
219-
| ps2/src/title/title.cpp:2288 | InitProcI | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
204+
| ps2/src/title/op_b.cpp:983 | OpB_InitProcess2 | replaced | resolved | `(int)& Wind` | image | store: Chara__3[8].wind (read back only in CCharacter::ClothStep) |
205+
| ps2/src/title/op_c.cpp:1271 | OpC_InitProcess5 | replaced | resolved | `(int)& Wind` | image | store: Chara__3[11].wind (read back only in CCharacter::ClothStep) |
206+
| ps2/src/title/op_c.cpp:1982 | OpC_MotionProcess | replaced | resolved | `(int)& Wind` | image | store: Chara__3[11].wind (read back only in CCharacter::ClothStep) |
207+
| ps2/src/title/rushmovi.cpp:615 | MotionProcess | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
208+
| ps2/src/title/rushmovi.cpp:617 | MotionProcess | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
209+
| ps2/src/title/title.cpp:417 | InitProcA | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
210+
| ps2/src/title/title.cpp:786 | InitProcB | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
211+
| ps2/src/title/title.cpp:1081 | InitProcC | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
212+
| ps2/src/title/title.cpp:1330 | InitProcD | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
213+
| ps2/src/title/title.cpp:1503 | InitProcE | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
214+
| ps2/src/title/title.cpp:1674 | InitProcF | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
215+
| ps2/src/title/title.cpp:1863 | InitProcG | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
216+
| ps2/src/title/title.cpp:1864 | InitProcG | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
217+
| ps2/src/title/title.cpp:1865 | InitProcG | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[2].wind (read back only in CCharacter::ClothStep) |
218+
| ps2/src/title/title.cpp:2054 | InitProcH | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[1].wind (read back only in CCharacter::ClothStep) |
219+
| ps2/src/title/title.cpp:2281 | InitProcI | dead | resolved | `(int)& Wind__4` | image | store: Chara__3[0].wind (read back only in CCharacter::ClothStep) |
220220
| ps2/src/visualvu1.cpp:614 | CVisualVu1::DrawVu1 | replaced | escapes | `(u_int)vu_data` | field | store to memory: * packet ++ |
221221

222222
## Where round-trip values become pointers again (40)

‎port/src/title/op_a.cpp‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ static void setCloudTexScroll();
110110
void FaceChange(int actor_no);
111111
void LoadCharaData(int buffer_no, int actor_no);
112112
void LoadMotionData();
113+
/* The port's buffer for each dancer's next step, which retail keeps in read_buffer (op_b.cpp). */
114+
u_int *OpeningDancePack(int dancer);
113115

114116
/* Each of the couple's motion files is one key range — the frame it starts at and the frame it ends
115117
at — written straight over the character's own first key, so that a file loaded in the background
@@ -172,8 +174,8 @@ PC_OVERRIDE void OpA_InitProcess() {
172174
CSnd.SE_Play(MIDI_PORT_SE_TITLE, 16, 20, 0, 0);
173175
wait_now_loading_vsync();
174176
SetDanceMotion();
175-
LoadFile("opdat/chara/01p19a1b.chr", (void *) ((char *) read_buffer + 0x10C900), 0);
176-
LoadFile("opdat/chara/01p17a1b.chr", (void *) read_buffer, 0);
177+
LoadFile("opdat/chara/01p19a1b.chr", (void *) OpeningDancePack(0), 0);
178+
LoadFile("opdat/chara/01p17a1b.chr", (void *) OpeningDancePack(1), 0);
177179
StartReadBG();
178180
DanceWait = 0.0f;
179181
DanceCnt = 1;
@@ -735,7 +737,7 @@ PC_OVERRIDE void OpA_DrawProcess() {
735737
case 10:
736738
case 24:
737739
case 25: {
738-
float dof[] = {50.0f};
740+
float dof[2] = {50.0f, 50.0f};
739741

740742
DepthOfField(dof, 1, 56, 0);
741743
} break;

‎port/src/title/op_b.cpp‎

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,87 @@ PC_OVERRIDE void FaceChange(int actor_no) {
277277
}
278278
}
279279

280-
/* The couple's dance, which is ten motion files played end to end. A file is swapped in when the
281-
one running reaches its last key and the next pair is started in the background straight after,
282-
so the dance runs continuously off a buffer that only ever holds two steps. */
280+
extern CDataAlloc2<1> CharaDataBuffer__2[7];
281+
extern CCharacter Chara__3[23];
282+
283+
namespace {
284+
285+
// The largest of the couple's motion files is 1,187,152 bytes.
286+
u_char g_dance_pack[2][0x130000] __attribute__((aligned(64)));
287+
288+
} // namespace
289+
290+
u_int *OpeningDancePack(int dancer) {
291+
return (u_int *) g_dance_pack[dancer];
292+
}
293+
294+
/* Plays the couple's dance from separate motion buffers so object loads cannot overwrite the next
295+
step before it starts. */
296+
PC_OVERRIDE void LoadMotionData() {
297+
char *motion_files[20][2] = {
298+
{"opdat/chara/01p19a1a.chr", "01p19a1a.cfg"},
299+
{"opdat/chara/01p19a1b.chr", "01p19a1b.cfg"},
300+
{"opdat/chara/01p19a2a.chr", "01p19a2a.cfg"},
301+
{"opdat/chara/01p19a2a.chr", "01p19a2a.cfg"},
302+
{"opdat/chara/01p19a2b.chr", "01p19a2b.cfg"},
303+
{"opdat/chara/01p19a3.chr", "01p19a3.cfg" },
304+
{"opdat/chara/01p19a3b.chr", "01p19a3b.cfg"},
305+
{"opdat/chara/01p19a4a.chr", "01p19a4a.cfg"},
306+
{"opdat/chara/01p19a4b.chr", "01p19a4b.cfg"},
307+
{"opdat/chara/01p19a5.chr", "01p19a5.cfg" },
308+
{"opdat/chara/01p17a1a.chr", "01p17a1a.cfg"},
309+
{"opdat/chara/01p17a1b.chr", "01p17a1b.cfg"},
310+
{"opdat/chara/01p17a2a.chr", "01p17a2a.cfg"},
311+
{"opdat/chara/01p17a2a.chr", "01p17a2a.cfg"},
312+
{"opdat/chara/01p17a2b.chr", "01p17a2b.cfg"},
313+
{"opdat/chara/01p17a3.chr", "01p17a3.cfg" },
314+
{"opdat/chara/01p17a3b.chr", "01p17a3b.cfg"},
315+
{"opdat/chara/01p17a4a.chr", "01p17a4a.cfg"},
316+
{"opdat/chara/01p17a4b.chr", "01p17a4b.cfg"},
317+
{"opdat/chara/01p17a5.chr", "01p17a5.cfg" }
318+
};
319+
320+
if (DanceCnt < 10) {
321+
if (Chara__3[6].motion_type.state.time > (float) (Chara__3[6].motion_type.motion_info->end - 1)) {
322+
if (DanceCnt != 2) {
323+
CharaDataBuffer__2[6].used = 0;
324+
Chara__3[6].LoadPackData(OpeningDancePack(0), motion_files[DanceCnt][1], &CharaDataBuffer__2[4], &CharaDataBuffer__2[6], 0);
325+
Chara__3[7].LoadPackData(OpeningDancePack(1), motion_files[DanceCnt + 10][1], &CharaDataBuffer__2[4], &CharaDataBuffer__2[6], 0);
326+
}
327+
328+
Chara__3[6].motion_type.motion_info->start = noroi[DanceCnt].start;
329+
Chara__3[6].motion_type.motion_info->end = noroi[DanceCnt].end;
330+
Chara__3[6].motion_type.state.time = (float) Chara__3[6].motion_type.motion_info->start;
331+
Chara__3[7].motion_type.motion_info->start = dancer[DanceCnt].start;
332+
Chara__3[7].motion_type.motion_info->end = dancer[DanceCnt].end;
333+
Chara__3[7].motion_type.state.time = (float) Chara__3[7].motion_type.motion_info->start;
334+
DanceCnt++;
335+
336+
if (DanceCnt != 3 && DanceCnt < 10) {
337+
LoadFileBG(motion_files[DanceCnt][0], (u_long128 *) OpeningDancePack(0), 0);
338+
LoadFileBG(motion_files[DanceCnt + 10][0], (u_long128 *) OpeningDancePack(1), 0);
339+
}
340+
}
341+
342+
Chara__3[6].motion_no = 0;
343+
Chara__3[6].motion_flags = 0;
344+
Chara__3[6].motion_speed = -1.0f;
345+
346+
if (Chara__3[6].motion_type.state.time > 225.0f) {
347+
DanceStart = 1;
348+
}
349+
350+
if (DanceStart == 1) {
351+
Chara__3[7].motion_no = 0;
352+
Chara__3[7].motion_flags = 0;
353+
Chara__3[7].motion_speed = -1.0f;
354+
} else {
355+
Chara__3[7].motion_no = 1;
356+
Chara__3[7].motion_flags = 0;
357+
Chara__3[7].motion_speed = -1.0f;
358+
}
359+
}
360+
}
283361

284362
/* The village scene's set-up, and the shape every scene file's is a variation of. The textures come
285363
out of the pack the background load left in memory, so the manifest is built with its five fixed

‎ps2/src/title/op_a.cpp‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "framevu1.hpp"
3434
#include "main.hpp"
3535
#include "mainselect.hpp"
36+
#include "mapobject.hpp"
3637
#include "mathutil.hpp"
3738
#include "mds.hpp"
3839
#include "mglib.hpp"
@@ -83,13 +84,6 @@ class CategoryAttr {
8384
CategoryAttr();
8485
};
8586

86-
class CMapObject {
87-
public:
88-
char unk_00[240];
89-
90-
CMapObject();
91-
} __attribute__((aligned(16)));
92-
9387
/* The scene's own map, of which this file keeps three — the ground, the buildings standing on it
9488
and a second set of buildings nothing here draws. Initialize is called from the constructor
9589
rather than by the scene, which is why the three are ready before OpA_InitProcess clears them. */
@@ -105,12 +99,17 @@ class CMap {
10599
void Draw();
106100
};
107101

102+
class CTexture;
103+
108104
/* The scene's one fire, which is a light rather than a model. */
109105
class CFireOmni {
110106
public:
111107
char unk_00[32];
112-
sceVu0FVECTOR pos; /**< World position DrawFire draws the next fire at. */
113-
char unk_30[16];
108+
sceVu0FVECTOR pos; /**< World position DrawFire draws the next fire at. */
109+
s32 texture_set; /**< Indicates that the textures were supplied rather than looked up. */
110+
CTexture *core; /**< Bright inner texture of the flame. */
111+
CTexture *glow; /**< Soft outer texture of the flame. */
112+
s32 unk_3C;
114113

115114
CFireOmni();
116115

@@ -126,7 +125,8 @@ class CEffectParam;
126125

127126
class CEffectGroup {
128127
public:
129-
char unk_00[8];
128+
CEffect *effect_table; /**< First effect in the caller-supplied pool. */
129+
int capacity; /**< Number of effects in the pool. */
130130

131131
CEffectGroup() { Initialize(0, 0); }
132132

@@ -204,7 +204,11 @@ class OBJ_ANIME_SEQ {
204204
float step_x; /**< Amount added to the first component each tick. */
205205
float step_y; /**< Amount added to the second component each tick. */
206206
float step_z; /**< Amount added to the third component each tick. */
207-
char unk_4C[60];
207+
float step_w;
208+
sceVu0FVECTOR current; /**< Current animated value applied to the attached frames. */
209+
CFrame *frames[10]; /**< Frames driven by this animation. */
210+
int completion_flag;
211+
int unk_8C;
208212

209213
OBJ_ANIME_SEQ();
210214

‎ps2/src/title/op_b.cpp‎

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class CRect {
7373
/* A frame parented to an object, which is what lets the world transform drive a model. */
7474
class CObjectFrame : public CObject {
7575
public:
76+
CFrameVu1 *frame[4]; /**< Frame of each level of detail; zero where the object has none. */
77+
s32 rotation_changed; /**< Set whenever the angle, its motion or the moment changes. */
78+
s32 draw_on; /**< 1 while the object draws; 0 leaves it out of the scene. */
79+
7680
virtual void FrameObjectOnOff(char *name, int on);
7781
virtual void Draw();
7882

@@ -83,12 +87,13 @@ class CObjectFrame : public CObject {
8387
through the object dispatch like anything else in the world. */
8488
class CMapObject : public CObjectFrame {
8589
public:
86-
char unk_00[36];
87-
CFrameVu1 *shadow_frame; /**< Model the object's shadow is drawn from. */
88-
char unk_28[8];
89-
float shadow_offset; /**< Height the shadow drops below the object. */
90-
int unk_34; /**< Map category the object is sorted under. */
91-
int handle; /**< Map handle; below zero leaves the object undrawn. */
90+
CFrameVu1 *collision_frame; /**< Frame that collision reads; zero where the object has none. */
91+
CFrameVu1 *shadow_frame; /**< Model the object's shadow is drawn from. */
92+
CFrameVu1 *shade_frame; /**< Frame that the shade draws from; zero where the object takes none. */
93+
CFrameVu1 *camera_frame; /**< Collision frame the camera reads; zero where the object has none. */
94+
float shadow_offset; /**< Height the shadow drops below the object. */
95+
int unk_34; /**< Map category the object is sorted under. */
96+
int handle; /**< Map handle; below zero leaves the object undrawn. */
9297
char unk_EC[4];
9398

9499
CMapObject();
@@ -99,12 +104,17 @@ class CMapObject : public CObjectFrame {
99104
void DrawShadow(int unknown0);
100105
};
101106

107+
class CTexture;
108+
102109
/* The scene's one fire, which is a light rather than a model. */
103110
class CFireOmni {
104111
public:
105112
char unk_00[32];
106-
sceVu0FVECTOR pos; /**< World position DrawFire draws the next fire at. */
107-
char unk_30[16];
113+
sceVu0FVECTOR pos; /**< World position DrawFire draws the next fire at. */
114+
s32 texture_set; /**< Indicates that the textures were supplied rather than looked up. */
115+
CTexture *core; /**< Bright inner texture of the flame. */
116+
CTexture *glow; /**< Soft outer texture of the flame. */
117+
s32 unk_3C;
108118

109119
CFireOmni();
110120

@@ -126,7 +136,11 @@ class OBJ_ANIME_SEQ {
126136
float step_x; /**< Amount added to the first component each tick. */
127137
float step_y; /**< Amount added to the second component each tick. */
128138
float step_z; /**< Amount added to the third component each tick. */
129-
char unk_4C[60];
139+
float step_w;
140+
sceVu0FVECTOR current; /**< Current animated value applied to the attached frames. */
141+
CFrame *frames[10]; /**< Frames driven by this animation. */
142+
int completion_flag;
143+
int unk_8C;
130144

131145
OBJ_ANIME_SEQ();
132146

0 commit comments

Comments
 (0)