14#include "dataalloc.hpp"
17#include "framevu1.hpp"
23#include "renderinfo.hpp"
27#include "title/op_a.hpp"
28#include "title/op_b.hpp"
29#include "title/op_d.hpp"
30#include "title/opening.hpp"
31#include "title/script.hpp"
32#include "title/seireiking.hpp"
42 OPD_SPRITE_HALL_LIGHT = 1,
43 OPD_SPRITE_RUIN_STILL_1 = 2,
44 OPD_SPRITE_RUIN_STILL_2 = 3,
45 OPD_SPRITE_RUIN_STILL_3 = 4,
46 OPD_SPRITE_CAPTION_1 = 5,
47 OPD_SPRITE_CAPTION_2 = 6,
70 CRect(T left, T top, T width, T height) {
76} __attribute__((aligned(16)));
89 virtual void FrameObjectOnOff(
char *name,
int on);
114 void DrawShadow(
int fast);
144void MoveImageTest(
sceVif1Packet *packet,
int sbp,
int sbw,
int spsm,
const CRect<int> &rect,
int dbp,
int dbw,
int dpsm,
int dsax,
int dsay,
int dir);
146void DepthOfField(
float *dist,
int level,
int alpha,
int blur);
149static void EffectAtraPrizum();
150static void RollLight(
float *target);
151static void EffectSeireiKing(
float size);
152static void LensFreaProcess();
153static void Setsumei();
154static void HamonProcess();
155void FaceChangeMovie(
int actor);
159static float HScale[5];
171void FaceChange(
int actor_no) {
173 {0, 0, 42, 40, 87, 35, 0, 0, 256, 2, 0},
174 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
175 {0, 0, 32, 40, 84, 35, 0, 0, 448, 3, 0},
176 {
"c09a01",
"c09a01an", 10, 40, 73, 35, 0, 0, 448, 2, 0},
177 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
178 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
179 {0, 0, 8, 40, 76, 35, 0, 0, 256, 2, 0},
180 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
181 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
182 {
"p09a01",
"p09a01an_3", 44, 40, 92, 32, 0, 0, 192, 2, 0},
183 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
184 {
"c01d01",
"c01d01an_3", 27, 48, 78, 44, 0, 0, 512, 3, 0},
185 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
186 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
187 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
188 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
189 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
190 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
191 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
192 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0},
193 {0, 0, 42, 40, 87, 35, 0, 0, 320, 2, 0}
202 sceVif1PkCnt(Vif1Packet, 0);
203 sceVif1PkOpenDirectCode(Vif1Packet, 0);
204 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
205 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
206 sceVif1PkCloseGifTag(Vif1Packet);
207 sceVif1PkCloseDirectCode(Vif1Packet);
209 if (face[actor_no].plate == 0) {
213 plate = TexManager.GetTexture(face[actor_no].plate, -1);
214 strip = TexManager.GetTexture(face[actor_no].strip, -1);
216 if (plate == 0 || strip == 0) {
220 sbp = strip->
tex0 & 0x3fff;
221 dbp = plate->tex0 & 0x3fff;
222 sbw = (strip->tex0 >> 14) & 0x3f;
223 dbw = (plate->tex0 >> 14) & 0x3f;
225 face[actor_no].
eye = CScript__2.
obj[actor_no].
eye;
227 CRect<int> eye(0, face[actor_no].strip_bottom - face[actor_no].eye_height * (face[actor_no].eye + 1), 128, face[actor_no].eye_height);
229 MoveImageTest(Vif1Packet, sbp, sbw, SCE_GS_PSMT8, eye, dbp, dbw, SCE_GS_PSMT8, 0, 128 - face[actor_no].eye_height - face[actor_no].eye_bottom, 0);
235 if (CScript__2.
obj[actor_no].
talk) {
236 if ((
int) (100.0f * CScript__2.
obj[actor_no].
mouth_time) % 6 == 0) {
237 CScript__2.
obj[actor_no].
mouth = rand() % 4;
242 CScript__2.
obj[actor_no].
talk =
false;
248 CRect<int> mouth(128, face[actor_no].strip_bottom - face[actor_no].mouth_height * (face[actor_no].mouth + 1), 128, face[actor_no].mouth_height);
250 MoveImageTest(Vif1Packet, sbp, sbw, SCE_GS_PSMT8, mouth, dbp, dbw, SCE_GS_PSMT8, 0, 128 - face[actor_no].mouth_height - face[actor_no].mouth_bottom, 0);
252 sceVif1PkCnt(Vif1Packet, 0);
253 sceVif1PkOpenDirectCode(Vif1Packet, 0);
254 sceVif1PkOpenGifTag(Vif1Packet, *(u_long128 *) &GiftagAD);
255 sceVif1PkAddGsAD(Vif1Packet, SCE_GS_TEXFLUSH, 0);
256 sceVif1PkCloseGifTag(Vif1Packet);
257 sceVif1PkCloseDirectCode(Vif1Packet);
264void OpD_LoadDataBG() {
268 LoadFileBG(
"opdat/norn4/seirei.pak", (u_long128 *) read_buffer, 0);
269 CScript__2.
load_no = OP_SCENE_NONE;
272void OpD_LoadDataBG2() {
278 LoadFileBG(
"opdat/norn4/seirei2.pak", (u_long128 *) read_buffer, &size);
279 SndBgmLoadBG(0, (u_int *) ((u_long128 *) read_buffer + (size >> 4) + 1), 0);
280 CScript__2.
load_no = OP_SCENE_NONE;
288void OpD_InitProcess() {
292 for (
int i = 0; i < 17; i++) {
293 TexManager.DeleteTextureBlock(i);
296 TexManager.CleanUpBuffer();
299 {
"#blender#640#" HALF_BUFFER_HEIGHT_STR
"#4", 0, 0},
310 tex[1].
name = (
char *) GetPackFile(read_buffer,
"b0401.img", 0);
311 tex[2].
name = (
char *) GetPackFile(read_buffer,
"b0402.img", 0);
312 tex[3].
name = (
char *) GetPackFile(read_buffer,
"eef01.img", 0);
313 tex[4].
name = (
char *) GetPackFile(read_buffer,
"eef02.img", 0);
314 tex[5].
name = (
char *) GetPackFile(read_buffer,
"eef03.img", 0);
315 tex[6].
name = (
char *) GetPackFile(read_buffer,
"eef04.img", 0);
316 tex[7].
name = (
char *) GetPackFile(read_buffer,
"eef05.img", 0);
318 TexManager.LoadTextureBlock(-1, tex);
320 tex[0].
name = (
char *) GetPackFile(read_buffer,
"c01d01.img", 0);
322 tex[0].mipmap =
false;
323 tex[1].
name = (
char *) GetPackFile(read_buffer,
"c01d01an.img", 0);
325 tex[1].mipmap =
false;
328 TexManager.LoadTextureBlock(1, tex);
330 tex[0].
name = (
char *) GetPackFile(read_buffer,
"c03c01.img", 0);
332 tex[0].mipmap =
false;
335 TexManager.LoadTextureBlock(2, tex);
336 MapDataBuffer.
used = 0;
338 CFrameVu1 *frame = LoadMDSFile((u_int *) GetPackFile(read_buffer,
"b0401.mds", 0), &MapDataBuffer, 2, 0, 0);
342 hall.SetFrame(frame, 0);
343 OP_NornMapObj[0].
handle = 0;
344 OP_NornMapObj[0].
unk_34 = 0;
347 Hamon[0] = LoadMDSFile((u_int *) GetPackFile(read_buffer,
"b0402.mds", 0), &CharaDataBuffer__2[6], 2, 0, 0);
348 Hamon[1] = Hamon[2] = Hamon[3] = Hamon[0];
355 OPAnalyz(
"opdat/seirei.cfg");
357 CharaDataBuffer__2[6].
used = 0;
358 Chara__3[8].
LoadPackData(read_buffer,
"05c01d.cfg", &CharaDataBuffer__2[6], 0);
363 Chara__3[8].
frame->SetAttr(attr8, 1, 4);
369 Chara__3[11].
LoadPackData(read_buffer,
"05c01e.cfg", &CharaDataBuffer__2[6], 0);
371 Chara__3[11].
frame->SetAttr(attr8, 1, 4);
377 Chara__3[21].
LoadPackData(read_buffer,
"05c03c.cfg", &CharaDataBuffer__2[6], 0);
382 Chara__3[21].
frame->SetAttr(attr21, 1, 4);
388 Effect.
LoadPackData(read_buffer,
"atrpeff1.cfg", &CharaDataBuffer__2[6], 0);
393 Effect.
frame->SetAttr(effect_attr, 1, 4);
401 CSnd.
SetVol(MIDI_PORT_SE_TITLE, 256);
402 CSnd.
SetVol(MIDI_PORT_SE_DEFAULT, 256);
403 CSnd.
SetVol(MIDI_PORT_UNK_D, 256);
404 CSnd.
SetVol(MIDI_PORT_SE_SPECIAL, 256);
407 {
"opdat/norn4/i00002.img", 5, 0},
408 {
"opdat/norn4/i00006.img", 5, 0},
409 {
"opdat/norn4/i00022.img", 6, 0},
410 {
"opdat/norn4/0519.img", 7, 0},
411 {
"opdat/norn4/0519p.img", 7, 0},
424 TexManager.LoadTextureBlock(-1, img, read_buffer);
435void OpD_InitProcess2() {
451 tex[0].
name = (
char *) GetPackFile(read_buffer,
"b0403.img", 0);
452 tex[1].
name = (
char *) GetPackFile(read_buffer,
"e01b01.img", 0);
453 tex[2].
name = (
char *) GetPackFile(read_buffer,
"t0401.img", 0);
454 tex[3].
name = (
char *) GetPackFile(read_buffer,
"e01s01.img", 0);
455 tex[4].
name = (
char *) GetPackFile(read_buffer,
"e01s06.img", 0);
456 tex[5].
name = (
char *) GetPackFile(read_buffer,
"t0402.img", 0);
457 tex[6].
name = (
char *) GetPackFile(read_buffer,
"buterfly.img", 0);
458 tex[7].
name = (
char *) GetPackFile(read_buffer,
"lensfler.img", 0);
460 TexManager.LoadTextureBlock(-1, tex);
463 {
"b0403.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
464 {
"e01g02_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
465 {
"e01g03_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
466 {
"e01g04_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
467 {
"e01h06_2.mds", 0, {0.0f, 4.7424f, 79.274f}, {0.0f, 0.0f, 0.0f}},
468 {
"e01a02_2.mds", 0, {0.0f, 0.0f, 59.965f}, {0.0f, 0.0f, 0.0f}},
469 {
"flower.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
470 {
"e01s05_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
471 {
"e01s01_0.mds", 0, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f}},
472 {
"e01s01_1.mds", 0, {104.195f, 3.399f, -150.395f}, {0.0f, 0.0f, 0.0f}}
480 for (i = 1; i < 11; i++) {
481 frame = LoadMDSFile((u_int *) GetPackFile(read_buffer, map[i - 1].name, 0), &MapDataBuffer, 2, 0, 0);
485 frame->SetAttr(attr, 512, 0);
489 frame->SetAttr(attr, 1, 64);
490 SetFrameAttr(frame, 1);
504 object.SetFrame(frame, 0);
505 OP_NornMapObj[i].
handle = 0;
506 OP_NornMapObj[i].
unk_34 = 0;
509 object.FrameObjectOnOff(
"flo_S", 0);
512 object.SetPosition(
CVector3_f_(10.0f * map[i - 1].position[0], 10.0f * map[i - 1].position[1], 10.0f * map[i - 1].position[2]));
513 object.SetRotation(
CVector3_f_((
float) (PI_D * map[i - 1].rotation[0] / 180), (
float) (PI_D * map[i - 1].rotation[1] / 180), (
float) (PI_D * map[i - 1].rotation[2] / 180)));
516 Chara__3[22].
LoadPackData(read_buffer,
"buterfly.cfg", &CharaDataBuffer__2[6], 0);
521 Chara__3[22].
frame->SetAttr(attr22, 1, 4);
527 Chara__3[5].
LoadPackData(read_buffer,
"buterfly.cfg", &CharaDataBuffer__2[6], 0);
529 Chara__3[5].
frame->SetAttr(attr22, 1, 4);
538 CSnd.
SetVol(MIDI_PORT_SE_TITLE, 256);
539 CSnd.
SetVol(MIDI_PORT_SE_DEFAULT, 256);
540 CSnd.
SetVol(MIDI_PORT_UNK_D, 256);
541 CSnd.
SetVol(MIDI_PORT_SE_SPECIAL, 256);
564 sceVu0FVECTOR *color = (sceVu0FVECTOR *) ((
char *) model + model->
colour_ofs);
565 sceVu0FVECTOR color0 = {50.0f, 100.0f, 255.0f, 0.0f};
566 sceVu0FVECTOR color1 = {255.0f, 255.0f, 255.0f, 0.0f};
568 color0[0] = color0[0] / 128.0f;
569 color0[1] = color0[1] / 128.0f;
570 color0[2] = color0[2] / 128.0f;
571 color1[0] = color1[0] / 128.0f;
572 color1[1] = color1[1] / 128.0f;
573 color1[2] = color1[2] / 128.0f;
575 for (
int i = 0; i < 32; i++) {
577 color[i][0] = color0[0];
578 color[i][1] = color0[1];
579 color[i][2] = color0[2];
582 color[i][0] = color1[0];
583 color[i][1] = color1[1];
584 color[i][2] = color1[2];
600void OpD_MotionProcess() {
602 register float zero = 0.0f;
604 for (
int i = 0; i < 23; i++) {
607 if (Chara__3[i].motion_type.state.time > (
float) (Chara__3[i].motion_type.motion_info[CScript__2.
obj[i].
motion].end - 1)) {
615 if (CScript__2.
obj[i].
step == 1.0f) {
616 if (CScript__2.
obj[i].
motion != Chara__3[i].motion_no) {
627 char *frame_names[23] = {
"",
"",
"",
"",
"",
"tyou2",
"",
"",
"c01d",
"",
"",
"c01d",
"",
"",
"",
"",
628 "",
"",
"",
"",
"",
"c03c",
"tyou"};
629 sceVu0FMATRIX matrix;
631 for (
int i = 0; i < 23; i++) {
633 CFrame *frame = Cam__2[SceneNp__2].
frame->SearchFrame(frame_names[i]);
636 frame->GetLWMatrix(matrix);
637 Chara__3[i].
SetRotation(zero, atan2f(matrix[2][0], matrix[2][2]), zero);
638 float x = matrix[3][0];
639 float y = matrix[3][1];
640 float z = matrix[3][2];
673 Chara__3[cloth_actor].
wind = (int) &Wind;
676 static int camera = 0;
687 for (
int i = 0; i < 20; i++) {
700 for (
int i = 0; i < 10; i++) {
714void OpD_SoundProcess() {
720 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 42, 1.0f);
721 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 44, 1.0f);
722 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 49, 1.0f);
723 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 51, 1.0f);
724 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 45, 1.0f);
725 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 47, 1.0f);
726 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 48, 1.0f);
738 if (CScript__2.
mes_no == 101) {
741 CSnd.
SQ_Play(MIDI_PORT_AMBIENT, 0);
755 CSnd.
Fade(MIDI_PORT_BGM, -1.0f, 0);
769 CSnd.
SQ_Play(MIDI_PORT_AMBIENT, 0);
782 CSnd.
Fade(MIDI_PORT_BGM, -1.0f, 0);
796 CSnd.
Stop(MIDI_PORT_BGM);
801 CSnd.
SetVol(MIDI_PORT_SE_TITLE, 256);
802 CSnd.
SetVol(MIDI_PORT_SE_DEFAULT, 256);
803 CSnd.
SetVol(MIDI_PORT_UNK_D, 256);
804 CSnd.
SetVol(MIDI_PORT_SE_SPECIAL, 256);
810 CSnd.
SQ_Play(MIDI_PORT_AMBIENT, 0);
820 sceVu0FVECTOR position;
823 sceVu0CopyVector(position, Chara__3[21].pos);
824 motion_frame = (int) Chara__3[21].motion_type.state.time;
827 if (motion_frame > 43.0f && motion_frame < 45.0f) {
828 OpPlayVolPanSE(position, 50.0f, 300.0f, MIDI_PORT_SE_DEFAULT, 21, 20);
830 }
else if (motion_frame > 53.0f && motion_frame < 55.0f) {
831 OpPlayVolPanSE(position, 50.0f, 300.0f, MIDI_PORT_SE_DEFAULT, 21, 21);
844void OpD_DrawProcess() {
845 OP_CharaFrame__2 = Cam__2[SceneNp__2].
frame;
856 MGSetRenderInfo(mgRenderInfo.
scale[0], 1.0f, 0xffff);
862 MGSetRenderInfo(mgRenderInfo.
scale[0], 20.0f, 0xffff);
866 MGSetRenderInfo(mgRenderInfo.
scale[0], 8.0f, 0xffff);
871 TexManager.ReloadTexture(Vif1Packet, 11);
873 if (CScript__2.
sprite == OPD_SPRITE_HALL_LIGHT && amb3 < 127) {
877 sceVu0FVECTOR ambient;
879 sceVu0CopyVector(ambient, ambientlight);
880 ambient[3] = (float) amb3;
881 MGSetAmbient(ambient);
886 MGSetAmbient(ambientlight);
888 float green = 100.0f;
890 MGSetBGColor(50.0f, green, blue, 128.0f);
891 TexManager.ReloadTexture(Vif1Packet, 10);
893 for (
int i = 1; i < 11; i++) {
895 mgRenderInfo.
unlit = 1;
897 mgRenderInfo.
unlit = 0;
914 CFrame *frame = flower.
frame[0]->SearchFrame(
"flo_S");
915 sceVu0FVECTOR ambient;
917 sceVu0CopyVector(ambient, ambientlight);
919 MGSetAmbient(ambient);
921 MGSetAmbient(ambientlight);
933 TexManager.ReloadTexture(Vif1Packet, 22);
935 float dof[2] = {400.0f, 1000.0f};
937 DepthOfField(dof, 2, 64, 0);
939 for (
int i = 0; i < 23; i++) {
940 if (i != 22 && i != 5 && CScript__2.
obj[i].
disp) {
941 TexManager.ReloadTexture(Vif1Packet, 23);
942 MGBeginDrawShadow(*(
sceGsTex0 *) &TexManager.GetTexture(
"shadow_buff", -1)->
tex0);
953 for (
int i = 0; i < 23; i++) {
955 TexManager.ReloadTexture(Vif1Packet, CharaTex__2[i]);
962 if (i == 8 || i == 11) {
967 sceVu0FVECTOR position;
969 sceVu0CopyVector(position, Chara__3[i].frame->
position);
974 MGSetPLight(light, lightcolor);
980 EffectSeireiKing(2.0f);
986 EffectSeireiKing(4.0f);
997 static int fade1 = 0;
998 static int fade2 = 0;
999 static int fade3 = 0;
1001 if (CScript__2.
sprite == OPD_SPRITE_RUIN_STILL_1) {
1003 }
else if (fade1 > 0) {
1007 if (CScript__2.
sprite == OPD_SPRITE_RUIN_STILL_2) {
1011 }
else if (fade2 > 0) {
1015 if (CScript__2.
sprite == OPD_SPRITE_RUIN_STILL_3) {
1019 }
else if (fade3 > 0) {
1024 TexManager.ReloadTexture(Vif1Packet, 5);
1025 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"i00002", -1),
CRect<int>(0, 0, 640, SCREEN_HEIGHT),
CRect<int>(0, 0, 640, 448), (u_char) fade1);
1029 TexManager.ReloadTexture(Vif1Packet, 5);
1030 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"i00006", -1),
CRect<int>(0, 0, 640, SCREEN_HEIGHT),
CRect<int>(0, 0, 640, 448), (u_char) fade2);
1034 TexManager.ReloadTexture(Vif1Packet, 6);
1035 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"i00022", -1),
CRect<int>(0, 0, 640, SCREEN_HEIGHT),
CRect<int>(0, 0, 640, 448), (u_char) fade3);
1038 switch (CScript__2.
sprite) {
1039 case OPD_SPRITE_CAPTION_1:
1040 case OPD_SPRITE_CAPTION_2:
1041 TexManager.ReloadTexture(Vif1Packet, 7);
1056static void EffectAtraPrizum() {
1057 if (CScript__2.
obj[11].
disp) {
1058 static float rot1 = 0.0f;
1059 static float rot2 = 0.0f;
1065 rot1 = rot1 - 6.28f;
1068 rot2 = rot2 - 0.01f;
1070 if (rot2 < -3.14f) {
1075 sceVu0FMATRIX matrix;
1076 sceVu0FVECTOR ambient;
1078 sceVu0CopyVector(ambient, ambientlight);
1080 MGSetAmbient(ambient);
1088 setAlphaFlag(Vif1Packet, &alpha);
1089 TexManager.ReloadTexture(Vif1Packet, 4);
1091 CFrame *frame = Chara__3[11].
frame->SearchFrame(
"atrp");
1094 frame->GetLWMatrix(matrix);
1097 sceVu0FVECTOR position;
1100 sceVu0CopyVector(position, matrix[3]);
1101 sceVu0UnitMatrix(spin);
1102 sceVu0RotMatrixY(spin, spin, rot1);
1103 sceVu0MulMatrix(matrix, matrix, spin);
1104 sceVu0CopyVector(matrix[3], position);
1105 Effect.
frame->SetTransMatrix(matrix);
1115 frame->GetLWMatrix(matrix);
1116 sceVu0CopyVector(position, matrix[3]);
1117 sceVu0UnitMatrix(spin);
1118 sceVu0RotMatrixY(spin, spin, rot2);
1119 sceVu0MulMatrix(matrix, matrix, spin);
1120 sceVu0CopyVector(matrix[3], position);
1121 Effect.
frame->SetTransMatrix(matrix);
1122 MGDraw(Effect.
frame);
1130 SeireiKing.
Draw(matrix[3], 0.2f, 1);
1134 sceVu0CopyVector(eye, OP_CharaFrame__2->
position);
1135 SeireiKing.
Draw2(&OP_MainCamera, matrix[3], eye);
1136 setAlphaFlag(Vif1Packet, &mgAlpha);
1137 MGSetAmbient(ambientlight);
1152static void RollLight(
float *target) {
1157 frame = Cam__2[SceneNp__2].
frame->SearchFrame(
"hikari");
1159 frame = Chara__3[11].
frame->SearchFrame(
"atrp");
1162 sceVu0FMATRIX matrix;
1164 sceVu0FMATRIX colors;
1167 frame->GetLWMatrix(matrix);
1172 dir[0] = matrix[3][0] - target[0];
1173 dir[1] = matrix[3][1];
1174 dir[2] = matrix[3][2] - target[2];
1175 sceVu0Normalize(dir, dir);
1176 sceVu0CopyMatrix(dirs, light);
1177 sceVu0CopyMatrix(colors, lightcolor);
1178 dirs[0][1] = dir[0];
1179 dirs[1][1] = dir[1];
1180 dirs[2][1] = dir[2];
1181 colors[1][0] = 255.0f;
1182 colors[1][1] = 255.0f;
1183 colors[1][2] = 255.0f;
1187 static float angle = 0.0f;
1191 if (angle > 3.14f) {
1192 angle = angle - 6.28f;
1195 dir[0] = (float) (matrix[3][0] + sin(angle) * 25.0 - target[0]);
1196 dir[1] = (float) (matrix[3][1] + 5.0);
1197 dir[2] = (float) (matrix[3][2] + cos(angle) * 25.0 - target[2]);
1198 sceVu0Normalize(dir, dir);
1199 sceVu0CopyMatrix(dirs, light);
1200 sceVu0CopyMatrix(colors, lightcolor);
1201 dirs[0][1] = dir[0];
1202 dirs[1][1] = dir[1];
1203 dirs[2][1] = dir[2];
1204 colors[1][0] = 128.0f;
1205 colors[1][1] = 128.0f;
1206 colors[1][2] = 128.0f;
1210 MGSetPLight(dirs, colors);
1224static void EffectSeireiKing(
float size) {
1225 CFrame *frame = Cam__2[SceneNp__2].
frame->SearchFrame(
"hikari");
1228 sceVu0FMATRIX matrix;
1230 frame->GetLWMatrix(matrix);
1231 TexManager.ReloadTexture(Vif1Packet, 4);
1235 head[0] = matrix[3][0];
1236 head[1] = matrix[3][1];
1237 head[2] = matrix[3][2];
1253 SeireiKing.
Draw(head, size, 2);
1266static void LensFreaProcess() {
1267 sceVu0FVECTOR world;
1269 sceVu0FVECTOR local = {0.0f, 0.0f, 0.0f, 1.0f};
1270 CFrame *frame = SkyFrame->SearchFrame(
"sun1");
1273 frame->GetWorldPosition(world, local);
1275 if (MGRotTransPers2D(screen, world, 0)) {
1276 if (TexManager.GetTexture(
"lensfler", -1)) {
1277 LensFlare(TexManager.GetTexture(
"lensfler", -1), world, 255, 255, 255);
1296static void Setsumei() {
1297 static int cnt1 = 0;
1298 static int cntA = 0;
1311 static int cnt2 = 0;
1312 static int cntB = 0;
1325 static int fadeA1 = 128;
1326 static int fadeA2 = 0;
1332 fadeA2 = fadeA2 - 8;
1338 fadeA1 = fadeA1 - 8;
1342 static int fadeB1 = 128;
1343 static int fadeB2 = 0;
1344 static int fadeB3 = 0;
1351 fadeB2 = fadeB2 - 8;
1355 fadeB3 = fadeB3 - 8;
1364 fadeB1 = fadeB1 - 8;
1368 fadeB3 = fadeB3 - 8;
1377 fadeB1 = fadeB1 - 8;
1381 fadeB2 = fadeB2 - 8;
1387 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519", -1),
CRect<int>(0, 0, 640, SCREEN_HEIGHT),
CRect<int>(0, 0, 640, 448), 128);
1388 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(540, 254, 88, 128),
CRect<int>(89, 206, 88, 119), (u_char) fadeA1);
1389 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(540, 254, 88, 128),
CRect<int>(0, 206, 88, 119), (u_char) fadeA2);
1390 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(450, 27, 105, 113),
CRect<int>(117, 448, 105, 105), (u_char) fadeB1);
1391 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(450, 27, 105, 113),
CRect<int>(222, 448, 105, 105), (u_char) fadeB2);
1392 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(450, 27, 105, 113),
CRect<int>(327, 448, 105, 105), (u_char) fadeB3);
1393 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(350, 139, 208, 62),
CRect<int>(432, 448, 208, 58), (u_char) fadeB1);
1394 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(350, 139, 208, 62),
CRect<int>(432, 506, 208, 58), (u_char) fadeB2);
1395 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(350, 139, 208, 62),
CRect<int>(432, 564, 208, 58), (u_char) fadeB3);
1396 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(100, 188, 117, 60),
CRect<int>(0, 325, 117, 56), (u_char) fadeA1);
1397 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(100, 188, 117, 60),
CRect<int>(0, 381, 117, 56), (u_char) fadeA2);
1399 if (CScript__2.
sprite == OPD_SPRITE_CAPTION_1) {
1400 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(6, 245, 178, 191),
CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1401 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(184, 245, 178, 191),
CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1402 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(362, 245, 178, 191),
CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1403 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(6, 245, 178, 191),
CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1404 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(184, 245, 178, 191),
CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1405 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(362, 245, 178, 191),
CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1407 static float x = 6.0f;
1408 static float y = 245.0f;
1409 static float rot = -1.57f;
1410 static float x2 = 184.0f;
1411 static float y2 = 245.0f;
1412 static float rot2 = 1.57f;
1413 static float x3 = 362.0f;
1414 static float y3 = 245.0f;
1415 static float rot3 = 1.57f;
1417 float heading = atan2f((
float) (-100.0f - x), -107.0f - y);
1419 if (heading < rot) {
1423 if (heading > rot) {
1428 x = x + (float) (sin(rot) * 4.8f);
1429 y = y + (float) (cos(rot) * 4.8f);
1431 x = x + (float) (sin(rot) * 4.0);
1432 y = y + (float) (cos(rot) * 4.0);
1438 alpha = (int) (128.0f - 4.0f * (32.0f - y));
1452 int cut = (int) ((245.0f - y) / 2.0f);
1454 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x, (
int) y, 178 - cut, 191 - cut),
CRect<int>(210, 0, 178, 178), (u_char) alpha);
1456 float heading2 = atan2f(500.0f - x2, -107.0f - y2);
1458 if (heading2 < rot2) {
1459 rot2 = rot2 - 0.05f;
1462 if (heading2 > rot2) {
1467 x2 = x2 + (float) (sin(rot2) * 4.8f);
1468 y2 = y2 + (float) (cos(rot2) * 4.8f);
1470 x2 = x2 + (float) (sin(rot2) * 4.0);
1471 y2 = y2 + (float) (cos(rot2) * 4.0);
1477 alpha2 = (int) (128.0f - 4.0f * (32.0f - y2));
1491 int cut2 = (int) ((245.0f - y2) / 2.0f);
1493 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x2, (
int) y2, 178 - cut2, 191 - cut2),
CRect<int>(210, 0, 178, 178), (u_char) alpha2);
1495 float heading3 = atan2f(900.0f - x3, -107.0f - y3);
1497 if (heading3 < rot3) {
1498 rot3 = rot3 - 0.05f;
1501 if (heading3 > rot3) {
1506 x3 = x3 + (float) (sin(rot3) * 4.8f);
1507 y3 = y3 + (float) (cos(rot3) * 4.8f);
1509 x3 = x3 + (float) (sin(rot3) * 4.0);
1510 y3 = y3 + (float) (cos(rot3) * 4.0);
1516 alpha3 = (int) (128.0f - 4.0f * (32.0f - y3));
1530 int cut3 = (int) ((245.0f - y3) / 2.0f);
1532 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x3, (
int) y3, 178 - cut3, 191 - cut3),
CRect<int>(210, 0, 178, 178), (u_char) alpha3);
1535 static float x = 426.0f;
1536 static float y = -221.0f;
1537 static float x2 = 726;
1538 static float y2 = -328.0f;
1544 float heading = atan2f(dx, dy);
1547 x = x + (float) (sin(heading) * 3.6f);
1548 y = y + (float) (cos(heading) * 3.6f);
1550 x = x + (float) (sin(heading) * 3.0);
1551 y = y + (float) (cos(heading) * 3.0);
1557 alpha = (int) (128.0f - 4.0f * (y - 159.0f));
1571 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x, (
int) y, 210, 221),
CRect<int>(0, 0, 210, 206), (u_char) alpha);
1573 float heading2 = atan2f(240.0f - x2, 193.0f - y2);
1576 x2 = x2 + (float) (sin(heading2) * 3.6f);
1577 y2 = y2 + (float) (cos(heading2) * 3.6f);
1579 x2 = x2 + (float) (sin(heading2) * 3.0);
1580 y2 = y2 + (float) (cos(heading2) * 3.0);
1586 alpha2 = (int) (128.0f - 4.0f * (y2 - 159.0f));
1600 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x2, (
int) y2, 210, 221),
CRect<int>(0, 0, 210, 206), (u_char) alpha2);
1602 if (CScript__2.
sprite == OPD_SPRITE_CAPTION_2) {
1603 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(40, 193, 463, 221),
CRect<int>(177, 206, 463, 242), (u_char) fadeA1);
1607static void Setsumei() {
1608 static int cnt1 = 0;
1609 static int cntA = 0;
1622 static int cnt2 = 0;
1623 static int cntB = 0;
1636 static int fadeA1 = 128;
1637 static int fadeA2 = 0;
1643 fadeA2 = fadeA2 - 8;
1649 fadeA1 = fadeA1 - 8;
1653 static int fadeB1 = 128;
1654 static int fadeB2 = 0;
1655 static int fadeB3 = 0;
1662 fadeB2 = fadeB2 - 8;
1666 fadeB3 = fadeB3 - 8;
1675 fadeB1 = fadeB1 - 8;
1679 fadeB3 = fadeB3 - 8;
1688 fadeB1 = fadeB1 - 8;
1692 fadeB2 = fadeB2 - 8;
1698 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519", -1),
CRect<int>(0, 0, 640, 448),
CRect<int>(0, 0, 640, 448), 128);
1699 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(540, 237, 88, 119),
CRect<int>(89, 206, 88, 119), (u_char) fadeA1);
1700 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(540, 237, 88, 119),
CRect<int>(0, 206, 88, 119), (u_char) fadeA2);
1701 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(450, 25, 105, 105),
CRect<int>(117, 448, 105, 105), (u_char) fadeB1);
1702 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(450, 25, 105, 105),
CRect<int>(222, 448, 105, 105), (u_char) fadeB2);
1703 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(450, 25, 105, 105),
CRect<int>(327, 448, 105, 105), (u_char) fadeB3);
1704 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(350, 130, 208, 58),
CRect<int>(432, 448, 208, 58), (u_char) fadeB1);
1705 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(350, 130, 208, 58),
CRect<int>(432, 506, 208, 58), (u_char) fadeB2);
1706 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(350, 130, 208, 58),
CRect<int>(432, 564, 208, 58), (u_char) fadeB3);
1707 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(100, 175, 117, 56),
CRect<int>(0, 325, 117, 56), (u_char) fadeA1);
1708 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(100, 175, 117, 56),
CRect<int>(0, 381, 117, 56), (u_char) fadeA2);
1710 if (CScript__2.
sprite == OPD_SPRITE_CAPTION_1) {
1711 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(6, 229, 178, 178),
CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1712 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(184, 229, 178, 178),
CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1713 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(362, 229, 178, 178),
CRect<int>(388, 0, 178, 178), (u_char) fadeA1);
1714 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(6, 229, 178, 178),
CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1715 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(184, 229, 178, 178),
CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1716 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(362, 229, 178, 178),
CRect<int>(210, 0, 178, 178), (u_char) fadeA2);
1718 static float x = 6.0f;
1719 static float y = 229.0f;
1720 static float rot = -1.57f;
1721 static float x2 = 184.0f;
1722 static float y2 = 229.0f;
1723 static float rot2 = 1.57f;
1724 static float x3 = 362.0f;
1725 static float y3 = 229.0f;
1726 static float rot3 = 1.57f;
1728 float heading = atan2f((
float) (-100.0f - x), -100.0f - y);
1730 if (heading < rot) {
1734 if (heading > rot) {
1738 x = x + (float) (sin(rot) * 4.0);
1739 y = y + (float) (cos(rot) * 4.0);
1744 alpha = (int) (128.0f - 4.0f * (32.0f - y));
1758 int cut = (int) ((229.0f - y) / 2.0f);
1760 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x, (
int) y, 178 - cut, 178 - cut),
CRect<int>(210, 0, 178, 178), (u_char) alpha);
1762 float heading2 = atan2f(500.0f - x2, -100.0f - y2);
1764 if (heading2 < rot2) {
1765 rot2 = rot2 - 0.05f;
1768 if (heading2 > rot2) {
1772 x2 = x2 + (float) (sin(rot2) * 4.0);
1773 y2 = y2 + (float) (cos(rot2) * 4.0);
1778 alpha2 = (int) (128.0f - 4.0f * (32.0f - y2));
1792 int cut2 = (int) ((229.0f - y2) / 2.0f);
1794 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x2, (
int) y2, 178 - cut2, 178 - cut2),
CRect<int>(210, 0, 178, 178), (u_char) alpha2);
1796 float heading3 = atan2f(900.0f - x3, -100.0f - y3);
1798 if (heading3 < rot3) {
1799 rot3 = rot3 - 0.05f;
1802 if (heading3 > rot3) {
1806 x3 = x3 + (float) (sin(rot3) * 4.0);
1807 y3 = y3 + (float) (cos(rot3) * 4.0);
1812 alpha3 = (int) (128.0f - 4.0f * (32.0f - y3));
1826 int cut3 = (int) ((229.0f - y3) / 2.0f);
1828 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x3, (
int) y3, 178 - cut3, 178 - cut3),
CRect<int>(210, 0, 178, 178), (u_char) alpha3);
1831 static float x = 426.0f;
1832 static float y = -206.0f;
1833 static float x2 = 726;
1834 static float y2 = -306.0f;
1840 float heading = atan2f(dx, dy);
1842 x = x + (float) (sin(heading) * 3.0);
1843 y = y + (float) (cos(heading) * 3.0);
1848 alpha = (int) (128.0f - 4.0f * (y - 148.0f));
1862 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x, (
int) y, 210, 206),
CRect<int>(0, 0, 210, 206), (u_char) alpha);
1864 float heading2 = atan2f(240.0f - x2, 180.0f - y2);
1866 x2 = x2 + (float) (sin(heading2) * 3.0);
1867 y2 = y2 + (float) (cos(heading2) * 3.0);
1872 alpha2 = (int) (128.0f - 4.0f * (y2 - 148.0f));
1886 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>((
int) x2, (
int) y2, 210, 206),
CRect<int>(0, 0, 210, 206), (u_char) alpha2);
1888 if (CScript__2.
sprite == OPD_SPRITE_CAPTION_2) {
1889 set2DSprite(GetVif1Packet(), TexManager.GetTexture(
"0519p", -1),
CRect<int>(40, 180, 463, 206),
CRect<int>(177, 206, 463, 242), (u_char) fadeA1);
1905static void HamonProcess() {
1906 sceVu0FVECTOR ambient;
1908 sceVu0CopyVector(ambient, ambientlight);
1910 for (
int i = 0; i < 5; i++) {
1911 static int se[5] = {0, 0, 0, 0, 0};
1913 if (!Pause && HScale[i] < 3.2f) {
1914 HScale[i] += 0.005f;
1917 if (HScale[i] > 0.0f) {
1921 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 1.0f);
1925 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.85f);
1929 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.6f);
1933 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.45f);
1937 OpPlayVolSE(MIDI_PORT_SE_DEFAULT, 40, 46, 0.3f);
1945 Hamon[i]->SetScale(HScale[i], HScale[i], HScale[i]);
1946 Hamon[i]->SetPosition((
float) (i - i), 0.01f + (
float) i / 100.0f, 0.0f);
1947 ambient[3] = 128.0f - 40.0f * HScale[i];
1949 if (ambient[3] < 0.0f) {
1953 MGSetAmbient(ambient);
1961 setAlphaFlag(Vif1Packet, &alpha);
1963 setAlphaFlag(Vif1Packet, &mgAlpha);
1968 MGSetAmbient(ambientlight);
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
virtual void ShadowStep()
tagMOTION_TYPE motion_type
virtual void SetRotation(float x, float y, float z)
virtual void DrawShadow()
virtual void SetPosition(float x, float y, float z)
virtual void ClothStep(int step)
CFrameVu1 * collision_frame
virtual void FrameObjectOnOff(char *name, int on)
virtual void SetRotation(CVector3_f_ rotation)
virtual void SetPosition(CVector3_f_ position)
void Draw(float *origin, float size, int spread)
void Draw2(CCamera *camera, float *head, float *source)
int LoadSoundFileFromPack(char *name, unsigned int *pack)
void SetVol(int port, int volume)
void Fade(int port, float step, int volume)
void SQ_Play(int port, int seq_no)
void SetReverb(int core, int mode, int depth)
void SetVelocity(float speed)
void SetDir(float *direction)