1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3#pragma name_counter 338
17#include "actionseq.hpp"
18#include "battlemenu.hpp"
26#include "dataalloc.hpp"
28#include "debugfont.hpp"
29#include "dngstatusdata.hpp"
31#include "editground.hpp"
32#include "editloop.hpp"
33#include "editloop3.hpp"
38#include "framevu1.hpp"
39#include "gamemode.hpp"
42#include "mainselect.hpp"
46#include "menu_draw.hpp"
47#include "menu_misc.hpp"
48#include "menu_save.hpp"
51#include "npcharacter.hpp"
52#include "objanime.hpp"
54#include "runscript.hpp"
57#include "spritetable.hpp"
59#include "textureanime.hpp"
60#include "visualvu1.hpp"
68enum VillagerAppearAction {
69 VILLAGER_APPEAR_DEFAULT = 0,
70 VILLAGER_APPEAR_IN = 1,
71 VILLAGER_APPEAR_OUT = 2,
72 VILLAGER_APPEAR_OFF = 3,
73 VILLAGER_APPEAR_ON = 4,
84 TALK_MODE_MESSAGE = 1,
93 printf(
"event over!!\n");
97 point->enabled =
true;
100 point->map_object = NULL;
103 point->map_object = parts;
104 point->parts_no = -1;
107 sceVu0CopyVector(point->position, function->
position);
108 sceVu0CopyVector(point->rotation, function->
rotation);
109 point->start_time = ConvertTime(function->
start_time);
110 point->end_time = ConvertTime(function->
end_time);
116 point->frame = frame->SearchFrame(function->
frame_name);
127 for (
int i = 0; i < 8 && indices != NULL; i++) {
128 int point_index = indices[i];
130 if (point_index <= 0) {
136 if (point->event_type != ED_EVENT_POINT_DOOR) {
140 point->enabled =
true;
143 point->map_object = NULL;
146 point->map_object = parts;
147 point->parts_no = -1;
153 for (
int j = 0; j < function_count; j++, function++) {
154 int kind = function->
kind;
156 if (kind != EPARTS_FUNC_DOOR_EXTENT && kind != EPARTS_FUNC_DOOR_SIDE_B && kind != EPARTS_FUNC_DOOR_SIDE_A && kind != EPARTS_FUNC_DOOR) {
157 kind = function->
kind;
158 }
else if (function->
link_id == points[point_index].
map_no) {
159 if (kind == EPARTS_FUNC_DOOR) {
160 sceVu0CopyVector(point->position, function->
position);
161 sceVu0CopyVector(point->rotation, function->
rotation);
162 point->trigger_range[2] = 10.0f;
163 point->trigger_range[1] = 10.0f;
164 point->trigger_range[0] = 10.0f;
165 point->minimum_progress = (int) function->
values[0];
166 point->start_time = ConvertTime(function->
start_time);
167 point->end_time = ConvertTime(function->
end_time);
170 if (has_extent == 0) {
171 sceVu0FVECTOR offset = {40.0f, 50.0f, -80.0f, 1.0f};
172 sceVu0FMATRIX matrix;
173 sceVu0UnitMatrix(matrix);
174 sceVu0RotMatrixY(matrix, matrix, point->rotation[1]);
175 sceVu0ApplyMatrix(offset, matrix, offset);
176 sceVu0AddVector(point->extent, offset, point->position);
180 if (function->
kind == EPARTS_FUNC_DOOR_EXTENT) {
181 sceVu0CopyVector(point->extent, function->
position);
185 if (function->
kind == EPARTS_FUNC_DOOR_SIDE_A) {
189 if (function->
kind == EPARTS_FUNC_DOOR_SIDE_B) {
193 if (function->
kind == EPARTS_FUNC_DOOR_SIDE_A || function->
kind == EPARTS_FUNC_DOOR_SIDE_B) {
194 point->linked_value = (int) function->
values[0];
203 for (
int i = 0; i < function_count; i++, function++) {
206 switch (function->
kind) {
207 case EPARTS_FUNC_ITEM_BOX:
208 point = GetNewEventPoint(parts, function, points, point_count);
211 point->event_type = ED_EVENT_POINT_ITEM_BOX;
212 point->trigger_range[2] = 15.0f;
213 point->trigger_range[1] = 15.0f;
214 point->trigger_range[0] = 15.0f;
215 point->side = (int) function->
values[0];
216 point->linked_value = (int) function->
values[1];
217 point->minimum_progress = (int) function->
values[2];
218 point->secondary_progress = (int) function->
values[3];
222 case EPARTS_FUNC_EVENT:
223 if ((
int) function->
values[0] > 0) {
224 point = GetNewEventPoint(parts, function, points, point_count);
227 point->event_type = ED_EVENT_POINT_EVENT;
228 sceVu0CopyVector(point->trigger_range, function->
parameters);
229 point->side = (int) function->
values[0];
230 point->linked_value = (int) function->
values[1];
235 case EPARTS_FUNC_LADDER_BOTTOM:
236 point = GetNewEventPoint(parts, function, points, point_count);
239 point->event_type = ED_EVENT_POINT_LADDER_BOTTOM;
240 point->trigger_range[2] = 6.0f;
241 point->trigger_range[1] = 6.0f;
242 point->trigger_range[0] = 6.0f;
243 point->trigger_range[3] = function->
values[0];
244 point->side = (int) function->
values[1];
246 for (j = 0; j < function_count; j++) {
250 sceVu0CopyVector(point->extent, other->
position);
251 point->linked_value = (int) other->
values[1];
258 case EPARTS_FUNC_LADDER_TOP:
259 point = GetNewEventPoint(parts, function, points, point_count);
262 point->event_type = ED_EVENT_POINT_LADDER_TOP;
263 point->trigger_range[2] = 6.0f;
264 point->trigger_range[1] = 6.0f;
265 point->trigger_range[0] = 6.0f;
266 point->trigger_range[3] = function->
values[0];
267 point->linked_value = (int) function->
values[1];
269 for (j = 0; j < function_count; j++) {
272 if (other->
kind == EPARTS_FUNC_LADDER_BOTTOM && other->
link_id == function->
link_id) {
273 sceVu0CopyVector(point->extent, other->
position);
274 point->side = (int) other->
values[1];
295 float nearest = -1.0f;
297 for (i = 0; i < count; i++, point++) {
298 if (!CheckEventPoint(point, time)) {
302 sceVu0FVECTOR event_position;
303 sceVu0FVECTOR event_rotation;
304 sceVu0FVECTOR camera_position;
305 sceVu0FVECTOR camera_rotation;
306 sceVu0CopyVector(event_position, point->position);
307 sceVu0CopyVector(camera_position, point->extent);
308 sceVu0CopyVector(event_rotation, point->rotation);
309 sceVu0CopyVector(camera_rotation, point->rotation);
313 if (point->parts_no >= 0) {
316 if (
object == NULL) {
320 GetPosRot(
object, event_position, event_rotation);
321 GetPosRot(
object, camera_position, camera_rotation);
323 if (
object != NULL) {
324 GetPosRot(
object, event_position, event_rotation);
327 if (
object != NULL) {
328 GetPosRot(
object, camera_position, camera_rotation);
334 if (point->event_type == ED_EVENT_POINT_ITEM_BOX) {
336 sceVu0SubVector(delta, event_position, position);
338 distance = DistVector(delta);
340 if (event_position[1] < position[1] - 1.0f || !(event_position[1] <= position[1] + 20.0f)) {
341 distance = 1000000.0f;
344 distance = DistVector(event_position, position);
349 if (distance < point->trigger_range[0]) {
352 switch (point->event_type) {
353 case ED_EVENT_POINT_LADDER_BOTTOM:
354 case ED_EVENT_POINT_DOOR:
355 if (AngleCmp(rotation[1], event_rotation[1], 0.8f)) {
360 case ED_EVENT_POINT_LADDER_TOP:
361 if (AngleCmp(AngleLimit(rotation[1] - 3.14f), event_rotation[1], 0.8f)) {
369 if (selected && (nearest < 0.0f || !(nearest <= point->trigger_range[0]))) {
370 nearest = point->trigger_range[0];
371 param->
kind = point->event_type;
373 sceVu0CopyVector(param->
position, event_position);
374 sceVu0CopyVector(param->
camera_pos, camera_position);
375 sceVu0CopyVector(param->
rotation, event_rotation);
376 sceVu0FVECTOR offset = {40.0f, 50.0f, -80.0f, 1.0f};
377 sceVu0FMATRIX matrix;
378 sceVu0UnitMatrix(matrix);
379 sceVu0RotMatrixY(matrix, matrix, event_rotation[1]);
380 sceVu0ApplyMatrix(offset, matrix, offset);
381 sceVu0AddVector(offset, offset, event_position);
382 sceVu0CopyVector((
float *) param->unk_40, offset);
383 param->
point = point;
387 if (nearest > 0.0f) {
395 if (EdDrawOffMap != 0) {
403 static float roty = 0.0f;
406 if (roty > PI_SHORT) {
410 static float sys_eff_sc = 0.0f;
411 static int sys_eff_cnt = 0;
413 if (sys_eff_sc > 1.0f) {
415 sys_eff_cnt = rand() % 20 + 10;
418 if (sys_eff_cnt < 0) {
425 for (
int i = 0; i < count; i++, point++) {
426 if (CheckEventPoint(point, time) == 0) {
430 switch (point->event_type) {
431 case ED_EVENT_POINT_ITEM_BOX:
433 case ED_EVENT_POINT_EVENT:
434 if (point->linked_value <= 0) {
443 sceVu0FVECTOR position;
444 sceVu0FVECTOR rotation;
445 sceVu0CopyVector(position, point->position);
446 sceVu0CopyVector(rotation, point->rotation);
449 if (point->parts_no >= 0) {
452 if (
object == NULL) {
456 GetPosRot(
object, position, rotation);
457 }
else if (
object != NULL) {
458 GetPosRot(
object, position, rotation);
461 if (point->event_type == ED_EVENT_POINT_ITEM_BOX && marker != NULL) {
462 marker->SetPosition(position);
463 marker->SetRotation(0.0f, rotation[1], 0.0f);
467 if (point->event_type == ED_EVENT_POINT_EVENT) {
468 sceVu0CopyVector(effect->
position, position);
477int EdEventPointCpPoly(
float *position,
ED_EVENT_POINT *points,
int count,
CCPoly *polygons,
float time) {
484 for (i = 0; i < count; i++, points++) {
485 if (points->
event_type == ED_EVENT_POINT_ITEM_BOX && CheckEventPoint(points, time)) {
486 sceVu0FVECTOR event_position;
487 sceVu0FVECTOR event_rotation;
488 sceVu0CopyVector(event_position, points->
position);
489 sceVu0CopyVector(event_rotation, points->
rotation);
495 if (
object == NULL) {
499 GetPosRot(
object, event_position, event_rotation);
500 }
else if (
object != NULL) {
501 GetPosRot(
object, event_position, event_rotation);
505 found += chara.
PickUpPoly(position, polygons);
517 for (i = 0; i < 256; i++, point++) {
518 if (CheckEventPoint(point, time) && strcmp(point->destination, name) == 0 && point->map_no == map_no) {
519 sceVu0FVECTOR event_position;
520 sceVu0FVECTOR event_rotation;
521 sceVu0FVECTOR camera_position;
522 sceVu0FVECTOR camera_rotation;
523 sceVu0CopyVector(event_position, point->position);
524 sceVu0CopyVector(camera_position, point->extent);
525 sceVu0CopyVector(event_rotation, point->rotation);
526 sceVu0CopyVector(camera_rotation, point->rotation);
529 if (point->parts_no >= 0) {
532 if (
object != NULL) {
533 GetPosRot(
object, event_position, event_rotation);
536 if (
object != NULL) {
537 GetPosRot(
object, camera_position, camera_rotation);
540 if (
object != NULL) {
541 GetPosRot(
object, event_position, event_rotation);
544 if (
object != NULL) {
545 GetPosRot(
object, camera_position, camera_rotation);
549 param->
kind = point->event_type;
551 sceVu0CopyVector(param->
position, event_position);
552 sceVu0CopyVector(param->
camera_pos, camera_position);
553 sceVu0CopyVector(param->
rotation, event_rotation);
554 param->
point = point;
562void EdMapJump(
int kind,
char *name) {
563 if (name == NULL || *name ==
'\0') {
573 char *extensions[5] = {
"m",
"e",
"n",
"",
""};
575 u_long128 *buffer = (u_long128 *) read_buffer;
578 sprintf(filename,
"%s.scn", name);
580 if (LoadFileBG(filename, buffer, &size) == 0) {
581 name[strlen(name) - 1] =
'\0';
582 sprintf(filename,
"%s.scn", name);
584 if (LoadFileBG(filename, buffer, &size) == 0) {
589 buffer += (((size >> 6) + 1) << 6) >> 4;
590 sprintf(filename,
"%s.cfg", name);
591 LoadFileBG(filename, buffer, &size);
592 buffer = (u_long128 *) (EdNPCBuffer.
base + EdNPCBuffer.
used * 16);
593 sprintf(filename,
"%s.pak", name);
595 if (LoadFileBG(filename, buffer, &size) == 0) {
596 sprintf(filename,
"%s.img", name);
598 if (LoadFileBG(filename, buffer, &size) == 0) {
603 if (size > 0x200000) {
604 printf(
"img size over!!!\n");
612 char storage[32][32];
614 int draw_flag[2] = {2, 1};
615 int hide_flag[2] = {4, 1};
617 for (
int element = 0; element < 6; element++) {
624 for (
int i = 0; i < 32; i++) {
625 names[i] = storage[i];
629 GetElementObjName(info, names, element, mode);
633 for (
int i = 0; (prefix = names[i][0]) !=
'\0'; i++) {
642 if (names[i][0] ==
'-') {
658static int appear_table[10];
660static int select_table[10];
665void EdInitVillagerControl() {
666 for (
int i = 0; i < 16; i++) {
667 appear[i].
action = VILLAGER_APPEAR_DEFAULT;
677 int candidate_count = 0;
679 for (i = 0; i < 16; i++) {
683 for (i = 0; i < 15; i++) {
687 candidates[candidate_count++] = villager;
691 if (candidate_count > 0) {
692 for (period = 0; period < 4; period++) {
693 for (i = 0; i < 100; i++) {
694 int first = rand() % candidate_count;
695 int second = rand() % candidate_count;
696 int value = candidates[first];
697 candidates[first] = candidates[second];
698 candidates[second] = value;
701 for (i = 0; i < 10; i++) {
709 for (
int i = 0; i < 10; i++) {
710 appear_table[i] = info->
time_tables[0][EdGetTime(clock)][i];
717void EdVillagerAppearOut(
int index,
int priority) {
718 if (index < 0 || index >= 16) {
722 if (appear[index].priority > priority) {
726 appear[index].
action = VILLAGER_APPEAR_OUT;
730void EdVillagerAppearIn(
int index,
int priority) {
731 if (index < 0 || index >= 16) {
735 if (appear[index].priority > priority) {
739 appear[index].
action = VILLAGER_APPEAR_IN;
743void EdVillagerAppearOff(
int index,
int priority) {
744 if (index < 0 || index >= 16) {
748 if (appear[index].priority > priority) {
752 appear[index].
action = VILLAGER_APPEAR_OFF;
756void EdVillagerAppearOn(
int index,
int priority) {
757 if (index < 0 || index >= 16) {
761 if (appear[index].priority > priority) {
765 appear[index].
action = VILLAGER_APPEAR_ON;
769void EdVillagerAppearMove(
int index,
int destination,
int priority) {
770 if (index < 0 || index >= 16) {
774 if (appear[index].priority > priority) {
782 for (
int i = 0; i < 10; i++) {
783 villagers[i] = restore_info[i];
796 EdInitVillagerTable(clock, map_info);
801 for (i = 0; i < 10; i++) {
802 select_table[i] = -1;
805 int selected_count = 0;
807 for (i = 0; i < 16 && selected_count < 6; i++) {
808 int action = appear[i].
action;
810 if (action == VILLAGER_APPEAR_ON || action == VILLAGER_APPEAR_OUT) {
811 select_table[selected_count++] = i;
815 for (i = 0; i < 10 && selected_count < 6; i++) {
818 int index = appear_table[i];
824 int action = appear[index].
action;
826 if (action == VILLAGER_APPEAR_OFF || action == VILLAGER_APPEAR_IN) {
832 for (j = 0; j < selected_count; j++) {
833 int selected = select_table[j];
835 if (selected == index) {
841 if (duplicate == 0) {
842 select_table[selected_count++] = index;
846 for (i = 0; i < 10; i++) {
847 int index = select_table[i];
850 villagers[i].
name[0] =
'\0';
852 villagers[i] = map_info->
villagers[index];
859 restore_info[i] = villagers[i];
864 villagers[i].
name[0] =
'\0';
871 if (index < 0 || index >= 16) {
875 switch (appear[index].action) {
876 case VILLAGER_APPEAR_OFF:
877 case VILLAGER_APPEAR_OUT:
879 case VILLAGER_APPEAR_DEFAULT:
880 for (
int i = 0; i < 10; i++) {
881 if (index == select_table[i]) {
885 case VILLAGER_APPEAR_IN: {
912 if (index < 0 || index >= 16) {
916 if (ground == NULL) {
946 int candidates[10] = {-1};
950 for (i = 0; i < 10; i++) {
951 if (villagers[i].placed == 0 && villagers[i].name[0] !=
'\0') {
952 candidates[count++] = i;
960 return candidates[rand() % count];
964 int candidates[10] = {-1};
968 for (i = 0; i < 10; i++) {
969 if (villagers[i].placed == 0 && villagers[i].name[0] !=
'\0' && villagers[i].initial_motion != 0) {
970 candidates[count++] = i;
978 return candidates[rand() % count];
987 u_long128 *load_buffer = (u_long128 *) read_buffer;
989 if (buffer != NULL) {
990 load_buffer = buffer;
993 for (i = 0; i < 10; i++) {
994 info[i] = &villagers[i];
995 villagers[i].
placed =
false;
998 strcpy(EdVillager[i].resource_name, info[i]->name);
999 GetEditDataDir(directory);
1000 sprintf(path,
"%schara/%s.chr", directory, info[i]->name);
1002 if (buffer != NULL) {
1003 LoadFileBG(path, load_buffer, &size);
1004 load_buffer += (((size >> 6) + 1) << 6) >> 4;
1006 EdLoadVillager(info[i]->name, &EdVillager[i], &EdVillagerBuffer);
1012 char copied_name[32];
1013 char config_name[32];
1015 strcpy(copied_name, name);
1019 if (GetPackFile(pack,
"info.cfg", NULL) != NULL) {
1020 sprintf(config_name,
"info.cfg");
1022 sprintf(config_name,
"%s.cfg", name);
1025 villager->
LoadPackData2(pack, config_name, arena, texture_set, arena, 0);
1027 if (villager->
frame != NULL) {
1031 villager->
frame->SetAttr(attr, 1, 4);
1042 sceVu0FVECTOR origin = {0.0f, 0.0f, 0.0f, 0.0f};
1043 sceVu0FVECTOR no_rotation = {0.0f, 0.0f, 0.0f, 0.0f};
1059 if (name == NULL || *name ==
'\0') {
1063 GetEditDataDir(directory);
1064 sprintf(path,
"%schara/%s.chr", directory, name);
1066 if (LoadFile2(path, (
void *) read_buffer, NULL, 0) != 0) {
1067 return EdLoadVillager(read_buffer, name, villager, arena);
1074 for (
int i = 0; i < 10; i++) {
1077 if (villager->
placed != 0) {
1081 if (parts_no >= 0 && characters[i].villager_id >= 0) {
1109 RestoreVillagerInfo(info);
1111 for (i = 0; i < 10; i++) {
1114 if (info[i].index >= 0) {
1116 sceVu0FVECTOR position;
1117 sceVu0FVECTOR rotation;
1118 sceVu0FVECTOR people_position;
1123 rotation[1] = people_position[3];
1124 people_position[3] = 1.0f;
1126 sceVu0CopyVector(position, people_position);
1127 sceVu0CopyVector(entry->
position, position);
1128 sceVu0CopyVector(entry->
rotation, rotation);
1137 villagers[i].
SetRotation(rotation[0], rotation[1], rotation[2]);
1145 int villager_count = 0;
1147 while (info[villager_count].name[0] !=
'\0') {
1151 RestoreVillagerInfo(info);
1152 int stationary_target = villager_count >> 1;
1153 int moving_target = villager_count - stationary_target;
1154 int random_state = rand();
1156 for (i = 0; i < 10; i++) {
1160 while (info[villager_count].name[0] !=
'\0') {
1164 int stationary_count = 0;
1166 for (i = 0; i < 10; i++) {
1167 if (info[i].placed == 0 && info[i].initial_motion == 0) {
1171 if (stationary_count >= stationary_target) {
1177 while (stationary_count < stationary_target) {
1178 int index = GetRandomVillager(info);
1179 info[index].
placed =
true;
1184 int moving_count = 0;
1186 while (moving_count < moving_target) {
1187 int selected = GetRandomMoveVillager(info);
1193 info[selected].
placed =
true;
1196 int avoid_count = 0;
1197 sceVu0FVECTOR avoid_positions[11];
1199 if (transform != NULL) {
1200 sceVu0CopyVector(avoid_positions[avoid_count++], *transform);
1203 for (i = 0; i < 10; i++) {
1204 if (info[selected].initial_motion != 0) {
1205 sceVu0CopyVector(avoid_positions[avoid_count++], info[i].position);
1209 for (i = 0; i < avoid_count; i++) {
1210 avoid_positions[i][3] = 200.0f;
1213 sceVu0FVECTOR random_position;
1214 sceVu0FVECTOR reference;
1215 reference[3] = -1.0f;
1218 if (
object != NULL) {
1219 sceVu0CopyVector(reference, object->
pos);
1220 reference[3] = 200.0f;
1224 if (ground->
GetRandomPlanePos(random_position, avoid_positions, avoid_count, reference) != 0) {
1225 sceVu0CopyVector(info[selected].position, random_position);
1229 if (reference[3] > 500.0f) {
1230 reference[3] = -1.0f;
1232 if (ground->
GetRandomPlanePos(random_position, avoid_positions, avoid_count, reference) != 0) {
1233 sceVu0CopyVector(info[selected].position, random_position);
1241 reference[3] += 100.0f;
1245 info[selected].
placed =
false;
1251 int selected = GetRandomVillager(info);
1253 while (selected >= 0) {
1254 info[selected].
placed =
true;
1256 selected = GetRandomVillager(info);
1259 for (i = 0; i < 10; i++) {
1262 if (entry->
placed != 0) {
1263 sceVu0FVECTOR position;
1264 sceVu0FVECTOR rotation;
1265 sceVu0CopyVector(position, entry->
position);
1266 sceVu0CopyVector(rotation, entry->
rotation);
1270 if (parts_no >= 0) {
1290 sceVu0FVECTOR people_position;
1295 rotation[1] = people_position[3];
1296 people_position[3] = 1.0f;
1297 sceVu0CopyVector(position, people_position);
1298 sceVu0CopyVector(entry->
position, position);
1299 sceVu0CopyVector(entry->
rotation, rotation);
1310 character->
SetRotation(rotation[0], rotation[1], rotation[2]);
1316 srand(random_state);
1320 sceVu0FVECTOR player_position;
1321 sceVu0FVECTOR camera_direction;
1322 sceVu0FVECTOR camera_offset;
1323 sceVu0FVECTOR camera_position;
1324 sceVu0FVECTOR villager_position;
1327 camera->
GetDir(camera_direction);
1328 camera->
GetPos(camera_position);
1331 for (i = 0; i < 10; i++) {
1333 distances[i] = -1.0f;
1335 if (villagers[i].near_camera != 0) {
1338 sceVu0SubVector(camera_offset, villager_position, camera_position);
1340 if (sceVu0InnerProduct(camera_offset, camera_direction) > 0.0f) {
1341 distances[i] = DistVector(player_position, villager_position);
1349 int compare_index = i + 1;
1351 while (compare_index < 10) {
1352 if (distances[compare_index] >= 0.0f) {
1353 if (distances[i] > distances[compare_index] || distances[i] < 0.0f) {
1354 int index = indices[i];
1355 indices[i] = indices[compare_index];
1356 indices[compare_index] = index;
1357 float distance = distances[i];
1358 distances[i] = distances[compare_index];
1359 distances[compare_index] = distance;
1385 for (i = 0; i < 10; i++) {
1388 sceVu0FVECTOR position;
1389 sceVu0FVECTOR rotation;
1391 near_camera = (s32 *) ((
char *) &EdVillager->
near_camera + offset);
1392 *near_camera =
false;
1399 sceVu0CopyVector(position, info->
position);
1400 sceVu0CopyVector(rotation, info->
rotation);
1413 *near_camera =
true;
1414 sceVu0CopyVector(position, info->
position);
1415 sceVu0CopyVector(rotation, info->
rotation);
1417 *near_camera =
true;
1418 sceVu0CopyVector(position, info->
position);
1419 sceVu0CopyVector(rotation, info->
rotation);
1423 ((
CCharacter *) ((
char *) EdVillager + offset))->CCharacter::SetPosition(position);
1424 ((
CCharacter *) ((
char *) EdVillager + offset))->CCharacter::SetRotation(rotation[0], rotation[1], rotation[2]);
1426 sceVu0FVECTOR player_position;
1427 sceVu0FVECTOR villager_position;
1430 sceVu0CopyVector(villager_position, npc->
pos);
1431 float distance = DistVector(player_position, villager_position);
1434 if (distance < 20.0f) {
1436 *(s32 *) ((
char *) &EdVillager->
motion_no + offset) = 0;
1437 *(s32 *) ((
char *) &EdVillager->
motion_flags + offset) = 0;
1438 *(
float *) ((
char *) &EdVillager->
motion_speed + offset) = -1.0f;
1441 EdSetVillagerNextPos(npc, info, ground);
1446 float distances[10];
1447 GetNearVill(camera, player, EdVillager, indices, distances);
1449 for (
int j = 0; j < 2; j++) {
1450 if (distances[j] < 0.0f) {
1454 if (distances[j] < 150.0f) {
1459 for (i = 0; i < 10; i++) {
1460 EdVillager[i].
Step();
1464 if (EdVillager[i].event_status != 0) {
1465 sceVu0FVECTOR position;
1467 sceVu0CopyVector(position, EdVillager[i].pos);
1468 float altitude = ground->
GetAlt(position[0], position[1], position[2]);
1469 EdVillager[i].
SetPosition(position[0], altitude, position[2]);
1472 if (EdVillager[i].CheckDraw()) {
1476 int count = ground->
PickUpEditAreaPoly(polys, position[0], position[1], position[2]);
1479 if (parts != NULL) {
1481 box.
max[0] = position[0] + 20.0f;
1482 box.
min[0] = position[0] - 20.0f;
1483 box.
max[2] = position[2] + 20.0f;
1484 box.
min[2] = position[2] - 20.0f;
1485 box.
max[1] = 1000.0f;
1486 box.
min[1] = -1000.0f;
1489 if (frame != NULL) {
1490 count += frame->PickUpNearPoly(polys + count, box);
1496 position[1] += 30.0f;
1498 if (GetFootPoly(position, 1000.0f, &poly, hit, polys, count, 0)) {
1504 position[1] = altitude;
1516 for (i = 0; i < 10; i++) {
1517 if (EdVillager[i].villager_id >= 0) {
1522 if (EdVillager[i].frame != NULL) {
1529 float distances[10];
1530 GetNearVill(camera, player, EdVillager, indices, distances);
1532 for (
int i = 0; i < 2; i++) {
1533 if (distances[i] < 0.0f) {
1537 if (distances[i] < 150.0f) {
1542 for (i = 0; i < 10; i++) {
1543 if (EdVillager[i].villager_id < 0) {
1547 EdVillager[i].
Step();
1558 sceVu0FVECTOR rotation;
1559 sceVu0FVECTOR position;
1560 sceVu0FVECTOR nearby_positions[10];
1561 sceVu0FVECTOR nearby_offsets[10];
1562 float nearby_distances[10];
1563 sceVu0FVECTOR directions[4] = {
1564 {0.0f, 0.0f, 100.0f, 0.0f},
1565 {100.0f, 0.0f, 0.0f, 0.0f},
1566 {0.0f, 0.0f, -100.0f, 0.0f},
1567 {-100.0f, 0.0f, 0.0f, 0.0f},
1574 int nearby_count = 0;
1576 for (i = 0; i < 10; i++) {
1579 if (villager != other) {
1583 other->
GetPosition(nearby_positions[nearby_count]);
1584 sceVu0SubVector(nearby_offsets[nearby_count], nearby_positions[nearby_count], position);
1585 float distance = DistVector(nearby_offsets[nearby_count]);
1586 float *slot = &nearby_distances[nearby_count];
1589 if (distance <= 210.0f) {
1598 if (rotation[1] >= -QUARTER_PI_SHORT && rotation[1] < QUARTER_PI_SHORT) {
1602 if (rotation[1] >= QUARTER_PI_SHORT && rotation[1] < 2.356194f) {
1606 if (rotation[1] >= 2.356194f || rotation[1] < -2.356194f) {
1610 if (rotation[1] >= -2.356194f && rotation[1] < -QUARTER_PI_SHORT) {
1619 int total = weights[4];
1620 CMapParts *current_parts = ground->
GetParts(position[0], position[1], position[2]);
1622 for (i = 0; i < 4; i++) {
1624 int direction = i + facing;
1626 if (direction > 3) {
1630 float *offset = directions[direction];
1631 sceVu0FVECTOR destination;
1632 sceVu0AddVector(destination, position, offset);
1633 int weight = weights[i];
1637 for (
int j = 0; j < nearby_count; j++) {
1638 if ((
float) (
int) sceVu0InnerProduct(nearby_offsets[j], offset) > 0.0f) {
1646 ground->
GetPartsBox(&box, destination[0], destination[1], destination[2]);
1647 box.
max[0] += 200.0f;
1648 box.
max[2] += 200.0f;
1649 box.
min[0] -= 200.0f;
1650 box.
min[2] -= 200.0f;
1652 if (destination[0] <= box.
max[0] && destination[0] >= box.
min[0] && destination[2] <= box.
max[2] && destination[2] >= box.
min[2]) {
1653 CMapParts *next_parts = ground->
GetParts(destination[0], destination[1], destination[2]);
1655 if (next_parts == NULL && ground->
GetAreaCode(destination[0], destination[1], destination[2]) >= 0) {
1663 weights[i] = weight;
1668 weights[i] = weight;
1674 for (i = 0; i < 5; i++) {
1675 weights[i] = weights[i] * 100 / total;
1678 for (i = 1; i < 5; i++) {
1679 weights[i] = weights[i] + weights[i - 1];
1682 for (i = 0; i < 5; i++) {
1683 if (weights[i] == 0) {
1688 int random = rand() % 100;
1690 for (i = 0; i < 4; i++) {
1691 if (random < weights[i]) {
1697 int direction = i + facing;
1699 if (direction > 3) {
1703 sceVu0FVECTOR destination;
1704 sceVu0AddVector(destination, position, directions[direction]);
1712int EdCheckTime(
float time,
float start,
float end) {
1713 if (!(start <= end) && !(start <= time) && end <= time) {
1717 if (start < end && (!(start <= time) || end <= time)) {
1724int EdGetTime(
float time) {
1728 period = (int) (time / 3.0f);
1730 if (EdCheckTime(time, 11.5f, 2.5f) != 0) {
1731 period = ED_TIME_DAY;
1734 if (EdCheckTime(time, 2.5f, 5.5f) != 0) {
1735 period = ED_TIME_EVENING;
1738 if (EdCheckTime(time, 5.5f, 8.5f) != 0) {
1739 period = ED_TIME_NIGHT;
1742 if (EdCheckTime(time, 8.5f, 11.5f) != 0) {
1743 period = ED_TIME_MORNING;
1749void EdLimitShadowLight(
float light[][4],
float scale) {
1750 light[1][0] = light[1][0] * scale;
1752 if (light[1][0] < 1.0f) {
1758 sceVu0FVECTOR ambient;
1759 sceVu0FVECTOR old_ambient;
1760 sceVu0FMATRIX identity;
1761 sceVu0FVECTOR position;
1762 sceVu0FVECTOR cloud_position;
1764 sceVu0UnitMatrix(identity);
1765 identity[3][1] = 2100.0f;
1779 sky_index = (int) (clock / 3.0f);
1780 next_sky = sky_index + 1;
1781 previous_sky = sky_index - 1;
1794 if (previous_sky < 0) {
1795 previous_sky = (int) previous_sky;
1798 current_sky = sky[sky_index];
1799 following_sky = sky[next_sky];
1801 if (current_sky != NULL && following_sky == NULL) {
1802 following_sky = (
CFrameVu1 *) following_sky;
1805 camera->
GetPos(position);
1807 if (follow_axes[0] == 0) {
1811 if (follow_axes[1] == 0) {
1815 if (follow_axes[2] == 0) {
1819 sceVu0CopyVector(cloud_position, position);
1820 cloud_position[1] -= 50.0f;
1822 mgRenderInfo.
unlit = 1;
1824 if (clouds != NULL) {
1825 clouds->SetPosition(cloud_position);
1828 if (clouds != NULL) {
1829 clouds->SetScale(1.0f, 1.0f, 1.0f);
1834 if (clouds != NULL) {
1835 clouds->SetPosition(cloud_position);
1838 if (clouds != NULL) {
1839 clouds->SetScale(1.0f, -1.0f, 1.0f);
1843 mgRenderInfo.
unlit = 0;
1845 MGGetAmbient(old_ambient);
1846 sceVu0CopyVector(ambient, old_ambient);
1850 if (clock >= 9.0f && clock < 12.0f) {
1854 if (clock >= 0.0f && clock < 3.5f) {
1858 if (clock >= 3.5f && clock < 5.5f) {
1862 next_sun = sun_index + 1;
1868 current_sun = sun[sun_index];
1869 following_sun = sun[next_sun];
1875 following_sun = sun[0];
1876 current_sun = following_sun;
1877 moon = following_sun;
1880 if (current_sun != NULL && following_sun != NULL && moon == NULL) {
1884 if (clock > 11.5f && clock < 12.0f) {
1885 ambient[3] = 2.0f * (128.0f * (12.0f - clock));
1889 if (clock > 3.0f && clock < 3.5f) {
1890 ambient[3] = 2.0f * (128.0f * (3.5f - clock));
1894 float *ambient_alpha = &ambient[3];
1895 float alpha = *ambient_alpha;
1896 float adjusted_clock = clock;
1898 if (clock > 10.0f) {
1899 adjusted_clock = clock - 12.0f;
1902 float sun_rotation = PI_SHORT * ((2.0f + adjusted_clock) / 6.0f) - HALF_PI;
1904 if (sun_rotation > PI_SHORT) {
1905 sun_rotation -= TWO_PI_SHORT;
1908 float moon_rotation = 1.2f * (PI_SHORT * ((clock - 4.0f) / 6.0f) - HALF_PI);
1910 if (sun_index != 2) {
1911 float absolute_rotation = sun_rotation < 0.0f ? -sun_rotation : sun_rotation;
1913 if (absolute_rotation < 1.57f) {
1914 TexManager.ReloadTexture(Vif1Packet, 7);
1916 if (transition != 0) {
1917 *ambient_alpha = 128.0f - alpha;
1918 MGSetAmbient(ambient);
1920 if (next_sun != 2 && following_sun != NULL) {
1921 following_sun->SetTransMatrix(identity);
1922 following_sun->SetRotation(0.0f, 0.0f, sun_rotation);
1923 following_sun->SetPosition(position);
1924 MGDraw(following_sun);
1928 *ambient_alpha = alpha;
1930 if (sun_index != 2 && current_sun != NULL) {
1931 current_sun->SetTransMatrix(identity);
1932 MGSetAmbient(ambient);
1933 current_sun->SetRotation(0.0f, 0.0f, sun_rotation);
1934 current_sun->SetPosition(position);
1935 MGDraw(current_sun);
1940 mgRenderInfo.
unlit = 1;
1942 if (clouds != NULL) {
1943 clouds->SetPosition(cloud_position);
1946 if (clouds != NULL) {
1947 clouds->SetScale(1.0f, -1.0f, 1.0f);
1951 mgRenderInfo.
unlit = 0;
1953 *ambient_alpha = 128.0f;
1956 if (clock > 2.0f && clock < 3.0f) {
1957 *ambient_alpha = 128.0f * (3.0f - clock);
1961 if (clock > 5.0f && clock < 6.0f) {
1962 *ambient_alpha = 128.0f * (6.0f - clock);
1966 if (clock > 8.0f && clock < 9.0f) {
1967 *ambient_alpha = 128.0f * (9.0f - clock);
1971 if (clock > 11.0f) {
1972 *ambient_alpha = 128.0f * (12.0f - clock);
1976 float sky_alpha = ambient[3];
1978 if (transition != 0) {
1979 *ambient_alpha = 128.0f - sky_alpha;
1980 MGSetAmbient(ambient);
1981 TexManager.ReloadTexture(Vif1Packet, next_sky + 3);
1983 if (following_sky != NULL) {
1984 following_sky->SetPosition(position);
1987 MGDraw(following_sky);
1990 *ambient_alpha = sky_alpha;
1991 MGSetAmbient(ambient);
1992 TexManager.ReloadTexture(Vif1Packet, sky_index + 3);
1994 if (current_sky != NULL) {
1995 current_sky->SetPosition(position);
1998 MGDraw(current_sky);
1999 MGSetAmbient(old_ambient);
2001 if (sun_index == 2 && moon != NULL) {
2002 *ambient_alpha = 0.0f;
2004 if (clock > 5.5f && clock < 9.0) {
2005 TexManager.ReloadTexture(Vif1Packet, 7);
2006 *ambient_alpha = 128.0f;
2008 if (clock > 5.5f && clock < 6.0f) {
2009 *ambient_alpha = 128.0f - 2.0f * (128.0f * (6.0f - clock));
2012 if (clock > 8.5f && clock < 9.0f) {
2013 *ambient_alpha = 2.0f * (128.0f * (9.0f - clock));
2016 MGSetAmbient(ambient);
2017 moon->SetTransMatrix(identity);
2018 moon->SetRotation(0.0f, 0.0f, moon_rotation);
2019 moon->SetPosition(position);
2024 MGSetAmbient(old_ambient);
2027void EdDrawLensFlare(
float time,
CFrame **sky) {
2028 int sky_index = (int) (time / 3.0f);
2030 if (!EdCheckTime(time, (0, 10.0f), 4.0f)) {
2034 CFrame **sky_slot = &sky[sky_index];
2036 if (*sky_slot == NULL) {
2040 sceVu0FVECTOR position;
2042 sceVu0FVECTOR origin = {0.0f, 0.0f, 0.0f, 1.0f};
2045 if (sky_index == 0) {
2046 light = (*sky_slot)->SearchFrame(
"sun1");
2049 if (sky_index == 1) {
2050 light = (*sky_slot)->SearchFrame(
"sun2");
2053 if (sky_index == 3) {
2054 light = (*sky_slot)->SearchFrame(
"moon");
2057 if (light != NULL) {
2058 light->GetWorldPosition(position, origin);
2061 if (position[1] < -100.0f) {
2065 float fraction = time - (int) time;
2066 float inverse = 1.0f - fraction;
2067 int current = (int) time;
2068 int next = current + 1;
2074 static float color[12][3] = {
2075 {255.0f, 255.0f, 255.0f},
2076 {255.0f, 255.0f, 255.0f},
2077 {255.0f, 255.0f, 255.0f},
2078 {255.0f, 128.0f, 0.0f },
2079 {255.0f, 128.0f, 0.0f },
2080 {255.0f, 128.0f, 0.0f },
2081 {255.0f, 255.0f, 255.0f},
2082 {255.0f, 255.0f, 255.0f},
2083 {255.0f, 255.0f, 255.0f},
2084 {255.0f, 255.0f, 255.0f},
2085 {255.0f, 255.0f, 255.0f},
2086 {255.0f, 255.0f, 255.0f}
2088 unsigned char red = (
unsigned char) (color[current][0] * inverse + color[next][0] * fraction);
2089 unsigned char green = (
unsigned char) (color[current][1] * inverse + color[next][1] * fraction);
2090 unsigned char blue = (
unsigned char) (color[current][2] * inverse + color[next][2] * fraction);
2092 if (!MGRotTransPers2D(screen, position, 0)) {
2096 mgPickZBuff->
enable =
true;
2097 mgPickZBuff->
x = screen[0];
2098 mgPickZBuff->
y = screen[1];
2100 if (mgPickZBuff->
z >= 0) {
2101 if (mgPickZBuff->
z > screen[2] + 100) {
2105 TexManager.ReloadTexture(GetVif1Packet(), 23);
2106 CTexture *texture = TexManager.GetTexture(
"lensfler", 23);
2108 if (texture != NULL) {
2109 LensFlare(texture, position, red, green, blue);
2115 int current = (int) clock;
2116 int next = (int) clock + 1;
2122 float current_weight = (float) next - clock;
2123 float next_weight = 1.0f - current_weight;
2132 sceVu0FVECTOR background;
2133 sceVu0FVECTOR current_background;
2134 sceVu0FVECTOR next_background;
2138 MGSetBGColor(zero, zero, zero, zero = 0.0f);
2139 fixed_fog = info->
fog[current];
2142 current_fog = &fixed_fog;
2143 next_fog = current_fog;
2145 current_fog = &info->
fog[current];
2146 next_fog = &info->
fog[next];
2149 sceVu0ScaleVector(current_background, current_background, current_weight);
2150 sceVu0ScaleVector(next_background, next_background, next_weight);
2151 sceVu0AddVector(background, current_background, next_background);
2152 MGSetBGColor(background[0], background[1], background[2], background[3]);
2157 float fog_red = current_fog->
red * current_weight + next_fog->
red * next_weight;
2158 float fog_green = current_fog->
green * current_weight + next_fog->
green * next_weight;
2159 float fog_blue = current_fog->
blue * current_weight + next_fog->
blue * next_weight;
2160 (
unsigned char) fog_red;
2161 (
unsigned char) fog_green;
2162 (
unsigned char) fog_blue;
2163 float fog_intensity = current_fog->
intensity * current_weight + next_fog->
intensity * next_weight;
2164 float fog_exponent = current_fog->
exponent * current_weight + next_fog->
exponent * next_weight;
2165 MGSetFogParm(fog_near, fog_far, (
unsigned char) fog_red, (
unsigned char) fog_green, (
unsigned char) fog_blue, fog_intensity, fog_exponent);
2167 sceVu0FVECTOR ambient;
2168 sceVu0FVECTOR current_ambient;
2169 sceVu0FVECTOR next_ambient;
2170 sceVu0CopyVector(current_ambient, info->
ambient[current]);
2171 sceVu0CopyVector(next_ambient, info->
ambient[next]);
2172 sceVu0ScaleVector(current_ambient, current_ambient, current_weight);
2173 sceVu0ScaleVector(next_ambient, next_ambient, next_weight);
2174 sceVu0AddVector(ambient, current_ambient, next_ambient);
2175 MGSetAmbient(ambient);
2177 sceVu0FMATRIX direction;
2178 sceVu0FMATRIX current_direction;
2179 sceVu0FMATRIX next_direction;
2180 sceVu0FMATRIX colour;
2181 sceVu0FMATRIX current_colour;
2182 sceVu0FMATRIX next_colour;
2183 sceVu0CopyMatrix(current_colour, info->
light_colour[current]);
2184 sceVu0CopyMatrix(next_colour, info->
light_colour[next]);
2185 sceVu0TransposeMatrix(current_direction, info->
light_direction[current]);
2188 for (
int i = 0; i < 4; i++) {
2189 sceVu0ScaleVector(current_colour[i], current_colour[i], current_weight);
2190 sceVu0ScaleVector(next_colour[i], next_colour[i], next_weight);
2191 sceVu0AddVector(colour[i], current_colour[i], next_colour[i]);
2192 sceVu0ScaleVector(current_direction[i], current_direction[i], current_weight);
2193 sceVu0ScaleVector(next_direction[i], next_direction[i], next_weight);
2194 sceVu0AddVector(direction[i], current_direction[i], next_direction[i]);
2197 sceVu0Normalize(direction[0], direction[0]);
2198 sceVu0Normalize(direction[1], direction[1]);
2199 sceVu0Normalize(direction[2], direction[2]);
2200 sceVu0Normalize(direction[3], direction[3]);
2201 sceVu0TransposeMatrix(direction, direction);
2202 MGSetPLight(direction, colour);
2207 if (visual != NULL) {
2211 sceVu0FVECTOR *vertices = (sceVu0FVECTOR *) ((
char *) model + model->
colour_ofs);
2212 sceVu0FVECTOR primary;
2213 sceVu0FVECTOR secondary;
2214 sceVu0FVECTOR second_current;
2215 sceVu0FVECTOR second_next;
2216 MGGetBGColor(primary);
2219 sceVu0ScaleVector(second_current, second_current, current_weight);
2220 sceVu0ScaleVector(second_next, second_next, next_weight);
2221 sceVu0AddVector(secondary, second_current, second_next);
2222 primary[0] /= 128.0f;
2223 primary[1] /= 128.0f;
2224 primary[2] /= 128.0f;
2225 secondary[0] /= 128.0f;
2226 secondary[1] /= 128.0f;
2227 secondary[2] /= 128.0f;
2229 for (
int i = 0; i < 32; i++) {
2231 vertices[i][0] = primary[0];
2232 vertices[i][1] = primary[1];
2233 vertices[i][2] = primary[2];
2234 vertices[i][3] = 1.0f;
2236 vertices[i][0] = secondary[0];
2237 vertices[i][1] = secondary[1];
2238 vertices[i][2] = secondary[2];
2239 vertices[i][3] = 1.0f;
2254 header->
cell = NULL;
2256 for (
int i = 0; i < 6; i++) {
2262 header->
cell = write;
2264 for (
int i = 0; i < header->
width * header->
height; i++) {
2265 *write++ = init->
cell[i][0];
2268 for (
int i = 0; i < 6; i++) {
2276 header->
data_size = write - (u8 *) header;
2281static float fade_col[4];
2284static int fade_in_out;
2290static float fade_step;
2308void EdFadeIn(
int frames,
float red,
float green,
float blue) {
2309 if (fade_in_out == 0 || frames < 0) {
2310 fade_col[3] = 128.0f;
2319 fade_step = 128.0f / (float) frames;
2323 fade_col[1] = green;
2327void EdFadeOut(
int frames,
float red,
float green,
float blue) {
2328 if (fade_in_out == 0 || frames < 0) {
2338 fade_step = 128.0f / (float) frames;
2342 fade_col[1] = green;
2346int EdFadeOutCheck() {
2350void EdGetFadeColor(
float *colour) {
2351 colour[0] = fade_col[0];
2352 colour[1] = fade_col[1];
2353 colour[2] = fade_col[2];
2354 colour[3] = fade_col[3];
2368 if (fade_in_out == 0) {
2372 red = (int) fade_col[0];
2373 green = (int) fade_col[1];
2374 blue = (int) fade_col[2];
2375 alpha = (int) fade_col[3];
2377 if (fade_in_out > 0) {
2378 fade_col[3] -= fade_step;
2380 if (fade_col[3] <= 0.0f) {
2386 fade_col[3] += fade_step;
2388 if (fade_col[3] >= 128.0f) {
2389 fade_col[3] = 128.0f;
2394 for (x = 0; x < 640; x += 64) {
2395 for (y = 0; y < SCREEN_HALF_HEIGHT; y += 32) {
2400 MGFillBox(rect, red, green, blue, alpha);
2405static float GetMaxHeightCursor(
float *position) {
2409 for (count = 0; count < 8; count++) {
2421 for (
int i = 0; i < count; i++) {
2424 if (position[0] <= area->
maximum[0] && position[2] <= area->
maximum[2] && position[0] >= area->
minimum[0] && position[2] >= area->
minimum[2] && height < area->minimum[1]) {
2432void LimitEditCursorPos(
float *position,
float *movement) {
2433 sceVu0FVECTOR previous;
2434 sceVu0FVECTOR clamped;
2435 sceVu0FVECTOR displacement;
2437 sceVu0CopyVector(previous, position);
2438 sceVu0AddVector(position, position, movement);
2442 for (count = 0; count < 8; count++) {
2455 for (
int i = 0; i < count; i++) {
2458 if (position[0] <= area->
maximum[0] && position[2] <= area->
maximum[2] && position[0] >= area->
minimum[0] && position[2] >= area->
minimum[2]) {
2459 position[1] = GetMaxHeightCursor(position);
2464 float nearest_distance = -1.0f;
2467 for (
int i = 0; i < count; i++) {
2470 if (previous[0] <= area->
maximum[0] && previous[2] <= area->
maximum[2] && previous[0] >= area->
minimum[0] && previous[2] >= area->
minimum[2]) {
2471 VectorMin(clamped, position, area->
maximum);
2472 VectorMax(clamped, clamped, area->
minimum);
2473 sceVu0SubVector(displacement, clamped, position);
2474 displacement[1] = 0.0f;
2475 float distance = DistVector(displacement);
2479 nearest_distance = distance;
2480 }
else if (distance < nearest_distance) {
2482 nearest_distance = distance;
2489 VectorMin(position, position, area->
maximum);
2490 VectorMax(position, position, area->
minimum);
2491 position[1] = GetMaxHeightCursor(position);
2497 float max_x_distance;
2498 float min_x_distance;
2499 float min_z_distance;
2500 float max_z_distance;
2501 float x = position[0];
2502 max_x_distance = x - area->
maximum[0];
2504 if (max_x_distance < 0.0f) {
2505 max_x_distance = -max_x_distance;
2507 max_x_distance = max_x_distance;
2510 min_x_distance = x - area->
minimum[0];
2512 if (min_x_distance < 0.0f) {
2513 min_x_distance = -min_x_distance;
2515 min_x_distance = min_x_distance;
2518 float z = position[2];
2519 max_z_distance = z - area->
maximum[2];
2521 if (max_z_distance < 0.0f) {
2522 max_z_distance = -max_z_distance;
2524 max_z_distance = max_z_distance;
2527 min_z_distance = z - area->
minimum[2];
2529 if (min_z_distance < 0.0f) {
2530 min_z_distance = -min_z_distance;
2532 min_z_distance = min_z_distance;
2535 if (max_z_distance < min_z_distance) {
2536 max_z_distance = max_z_distance;
2538 max_z_distance = min_z_distance;
2541 if (max_x_distance < min_x_distance) {
2542 max_x_distance = max_x_distance;
2544 max_x_distance = min_x_distance;
2547 nearest_distance = max_x_distance + max_z_distance;
2549 for (
int i = 1; i < count; i++) {
2551 max_x_distance = x - area->
maximum[0];
2553 if (max_x_distance < 0.0f) {
2554 max_x_distance = -max_x_distance;
2556 max_x_distance = max_x_distance;
2559 min_x_distance = x - area->
minimum[0];
2561 if (min_x_distance < 0.0f) {
2562 min_x_distance = -min_x_distance;
2564 min_x_distance = min_x_distance;
2567 max_z_distance = z - area->
maximum[2];
2569 if (max_z_distance < 0.0f) {
2570 max_z_distance = -max_z_distance;
2572 max_z_distance = max_z_distance;
2575 min_z_distance = z - area->
minimum[2];
2577 if (min_z_distance < 0.0f) {
2578 min_z_distance = -min_z_distance;
2580 min_z_distance = min_z_distance;
2583 if (max_z_distance < min_z_distance) {
2584 max_z_distance = max_z_distance;
2586 max_z_distance = min_z_distance;
2589 if (max_x_distance < min_x_distance) {
2590 max_x_distance = max_x_distance;
2592 max_x_distance = min_x_distance;
2595 float distance = max_x_distance + max_z_distance;
2597 if (distance < nearest_distance) {
2598 nearest_distance = distance;
2604 VectorMin(position, position, area->
maximum);
2605 VectorMax(position, position, area->
minimum);
2606 position[1] = GetMaxHeightCursor(position);
2610 if (sound < 0 || sound >= ED_SOUND_COUNT) {
2614 SndSePlay(sound, pan, 0);
2621 if (index < 0 || index >= 16) {
2625 return &Sprite[index];
2628static void InitSprite(
ED_SPRITE *sprite) {
2629 if (sprite == NULL) {
2634 sprite->
alpha = 128;
2636 sprite->
green = 128;
2646 if (index < 0 || index >= 16) {
2650 return &obj_anime[index];
2653static void ClearObjAnime(
int index) {
2655 for (
int i = 0; i < 16; i++) {
2656 obj_anime[i].
property = OBJ_ANIME_PROPERTY_NONE;
2664 if (anime != NULL) {
2665 anime->
property = OBJ_ANIME_PROPERTY_NONE;
2673static int event_enable;
2676static int run_system_event;
2679static int not_wait_load;
2682static int motion_stop_flag;
2685static int menu_mode;
2688static int menu_mode_status;
2691static char *p_use_item;
2694static int p_jump_map_no;
2697static int event_stop;
2700static int event_pause;
2703static int skip_enable;
2706static int set_wl_matrix;
2721static u_int *BaseBuffer;
2724static int actv_file;
2727static int actv_buffer;
2730void EdEventStopPlay() {
2731 event_stop = !event_stop;
2735void EdEventPause() {
2736 event_pause = !event_pause;
2740int EdCheckEventPause() {
2746static char CurrentDir[0x40];
2749static sceVu0FVECTOR world_pos;
2752static sceVu0FVECTOR world_rot;
2755static sceVu0FMATRIX world_local;
2758static sceVu0FMATRIX local_world;
2761static sceVu0FVECTOR sync_camera_ref_offset;
2764static int work_flag[32];
2796static u_int *chr_file[16];
2799static sceVu0FMATRIX save_l[2];
2802static sceVu0FMATRIX save_c[2];
2805static sceVu0FVECTOR save_a[2];
2818static int SetWorkFlag(
int index,
int value) {
2819 if (index < 0 || index >= 32) {
2823 work_flag[index] = value;
2827static int GetWorkFlag(
int index) {
2828 if (index < 0 || index >= 32) {
2832 return work_flag[index];
2839 if (stack->
type == RS_FLOAT) {
2840 return (
int) stack->
f;
2850 if (stack->
type == RS_INT) {
2851 return (
float) stack->
i;
2868 if (stack->
type == RS_PTR) {
2869 stack->
p->
i = value;
2876static void SetStack(
RS_STACKDATA *stack,
float value) {
2877 if (stack->
type == RS_PTR) {
2878 stack->
p->
f = value;
2882static void PrintMemory() {
2886 if (index < 0 || index >= 32) {
2890 return &ObjHandle[index];
2893static int SetObjHandle(
int index,
CMapParts *map_parts,
char *frame_name) {
2896 if (handle == NULL) {
2900 if (map_parts == NULL) {
2904 if (frame_name == NULL) {
2927 handle->
frames[7] = extra_frame;
2931 for (; i < 12; i++) {
2932 handle->
frames[i] = NULL;
2935 if (frame_name[0] !=
'\0') {
2936 for (i = 0; i < 12; i++) {
2937 if (handle->
frames[i] != NULL) {
2938 handle->
frames[i] = handle->
frames[i]->SearchFrame(frame_name);
2950static int SetObjHandle(
int index,
CCharacter *character,
char *frame_name) {
2953 if (handle == NULL) {
2957 if (character == NULL) {
2961 if (frame_name == NULL) {
2971 for (; i < 12; i++) {
2972 handle->
frames[i] = NULL;
2975 if (frame_name[0] !=
'\0') {
2976 for (i = 0; i < 12; i++) {
2977 if (handle->
frames[i] != NULL) {
2978 handle->
frames[i] = handle->
frames[i]->SearchFrame(frame_name);
2990static int SetObjHandle(
int index,
CFrame *frame) {
2993 if (frame == NULL) {
2998 handle->
frames[0] = frame;
3002static void obj_draw(
OBJ_HANDLE *handle,
int draw) {
3003 if (handle == NULL) {
3008 int frame_flags = 4;
3020 for (
int i = 0; i < 12; i++) {
3021 if (handle->
frames[i] != NULL) {
3028static void set_obj_pos(
OBJ_HANDLE *handle,
float *position) {
3039 for (
int i = 0; i < 12; i++) {
3040 if (handle->
frames[i] != NULL) {
3041 handle->
frames[i]->SetPosition(position);
3046static void get_obj_pos(
OBJ_HANDLE *handle,
float *out_position) {
3057 for (
int i = 0; i < 12; i++) {
3058 if (handle->
frames[i] != NULL) {
3065static void get_obj_world_pos(
OBJ_HANDLE *handle,
float *out_position) {
3076 sceVu0FVECTOR origin = {0.0f, 0.0f, 0.0f, 1.0f};
3078 for (
int i = 0; i < 12; i++) {
3079 if (handle->
frames[i] != NULL) {
3080 handle->
frames[i]->GetWorldPosition(out_position, origin);
3086static void set_obj_rot(
OBJ_HANDLE *handle,
float *rotation) {
3097 for (
int i = 0; i < 12; i++) {
3098 if (handle->
frames[i] != NULL) {
3099 handle->
frames[i]->SetRotType(2);
3100 handle->
frames[i]->SetRotation(rotation[0], rotation[1], rotation[2]);
3105static void get_obj_rot(
OBJ_HANDLE *handle,
float *out_rotation) {
3116 for (
int i = 0; i < 12; i++) {
3117 if (handle->
frames[i] != NULL) {
3118 handle->
frames[i]->GetRotation(out_rotation);
3124static void set_obj_scale(
OBJ_HANDLE *handle,
float *scale) {
3135 for (
int i = 0; i < 12; i++) {
3136 if (handle->
frames[i] != NULL) {
3137 handle->
frames[i]->SetScale(scale);
3142static void get_obj_scale(
OBJ_HANDLE *handle,
float *out_scale) {
3153 for (
int i = 0; i < 12; i++) {
3156 if (frame != NULL) {
3157 out_scale[0] = frame->
scale[0];
3158 out_scale[1] = frame->
scale[1];
3159 out_scale[2] = frame->
scale[2];
3165static int init_obj_anime(
int anime_index,
int handle_index,
int type,
int number,
float *offset,
float *range,
float *speed) {
3167 OBJ_HANDLE *handle = GetObjHandle(handle_index);
3169 if (anime == NULL || handle == NULL) {
3174 anime->
mode = number;
3176 sceVu0CopyVector(anime->
step, offset);
3177 sceVu0CopyVector(anime->
from, range);
3178 sceVu0CopyVector(anime->
to, speed);
3179 InitObjAnime(handle->
frames, 12, anime);
3184 CFrame *reference = NULL;
3187 for (i = 0; i < 12; i++) {
3188 if (source->
frames[i] != NULL) {
3189 reference = source->
frames[i];
3194 if (reference != NULL) {
3195 for (i = 0; i < 12; i++) {
3196 if (targets->
frames[i] != NULL) {
3197 targets->
frames[i]->SetReference(reference);
3203static void release_obj_obj(
OBJ_HANDLE *handle) {
3204 for (
int i = 0; i < 12; i++) {
3205 if (handle->
frames[i] != NULL) {
3206 handle->
frames[i]->DeleteReference();
3217 for (
int i = 0; i < 12; i++) {
3218 if (handle->
frames[i] != NULL) {
3219 handle->
frames[i]->SetAttr(attr, children, mask);
3226 if (index < 0 || index >= 10) {
3230 return &ActSeq[index];
3233void turn_chara(
CCharacter *character,
float *position,
float speed) {
3234 sceVu0FVECTOR current_position;
3235 sceVu0FVECTOR rotation;
3236 sceVu0FVECTOR direction;
3239 sceVu0SubVector(direction, position, current_position);
3240 float angle = atan2f(direction[0], direction[2]);
3241 float *yaw = &rotation[1];
3251 if (index < 0 || index >= EdEventInfo.
npc_count) {
3255 return &EdEventInfo.
npcs[index];
3263 if (index < 0 || index >= EdEventInfo.
npc_count) {
3267 return &EdEventInfo.
npcs[index];
3270static CFrame *GetItemFrame(
int index) {
3271 if (index < 0 || index > 0) {
3278static void DeleteItemFrame(
int index) {
3279 if (index < 0 || index > 0) {
3286 if (*frame != NULL) {
3287 (*frame)->DeleteReference();
3293 if (index < 0 || index >= 16) {
3300static void SetWorldCoord(
float *position,
float *rotation) {
3301 sceVu0CopyVector(world_pos, position);
3302 world_pos[3] = 1.0f;
3303 sceVu0CopyVector(world_rot, rotation);
3304 world_rot[3] = 0.0f;
3305 sceVu0UnitMatrix(world_local);
3306 sceVu0RotMatrixY(world_local, world_local, world_rot[1]);
3307 sceVu0CopyVector(world_local[3], world_pos);
3308 sceVu0InversMatrix(local_world, world_local);
3312static void GetWorldPos(
float *out,
float *position) {
3313 if (set_wl_matrix == 0) {
3314 sceVu0CopyVector(out, position);
3319 sceVu0ApplyMatrix(out, world_local, position);
3322static float GetWorldRotY(
float rotation) {
3323 rotation += world_rot[1];
3325 if (rotation > PI_SHORT) {
3326 rotation -= TWO_PI_SHORT;
3329 if (rotation < -PI_SHORT) {
3330 rotation += TWO_PI_SHORT;
3336static void GetWorldRot(
float *out,
float *rotation) {
3337 sceVu0CopyVector(out, rotation);
3338 out[1] = GetWorldRotY(out[1]);
3341static void GetLocalPos(
float *out,
float *position) {
3342 if (set_wl_matrix == 0) {
3343 sceVu0CopyVector(out, position);
3348 sceVu0ApplyMatrix(out, local_world, position);
3351static float GetLocalRotY(
float rotation) {
3352 rotation -= world_rot[1];
3354 if (rotation > PI_SHORT) {
3355 rotation -= TWO_PI_SHORT;
3358 if (rotation < -PI_SHORT) {
3359 rotation += TWO_PI_SHORT;
3365static void GetLocalRot(
float *out,
float *rotation) {
3366 sceVu0CopyVector(out, rotation);
3367 out[1] = GetLocalRotY(out[1]);
3370static void GetPosition(
RS_STACKDATA *stack,
float *position) {
3371 position[0] = GetStackFloat(stack++);
3372 position[1] = GetStackFloat(stack++);
3373 position[2] = GetStackFloat(stack);
3375 GetWorldPos(position, position);
3378static void SetPosition(
RS_STACKDATA *stack,
float *position) {
3380 GetLocalPos(position, position);
3381 SetStack(stack++, position[0]);
3382 SetStack(stack++, position[1]);
3383 SetStack(stack, position[2]);
3386static void GetRotation(
RS_STACKDATA *stack,
float *rotation) {
3387 rotation[0] = GetStackFloat(stack++);
3388 rotation[1] = GetStackFloat(stack++);
3389 rotation[2] = GetStackFloat(stack);
3391 GetWorldRot(rotation, rotation);
3394static void SetRotation(
RS_STACKDATA *stack,
float *rotation) {
3396 GetLocalRot(rotation, rotation);
3397 SetStack(stack++, rotation[0]);
3398 SetStack(stack++, rotation[1]);
3399 SetStack(stack, rotation[2]);
3402static void GetFileName(
char *destination,
char *name) {
3403 if (name[0] ==
'/') {
3404 strcpy(destination, name + 1);
3408 strcpy(destination, CurrentDir);
3409 strcat(destination, name);
3412static int _TEST(
RS_STACKDATA *stack,
int argument_count) {
3416static int exch_ok_cancel(
int buttons) {
3417 int confirm = buttons & ED_PAD_CONFIRM;
3418 int cancel = buttons & ED_PAD_CANCEL;
3419 buttons &= ~(ED_PAD_CONFIRM | ED_PAD_CANCEL);
3422 buttons |= ED_PAD_CANCEL;
3426 buttons |= ED_PAD_CONFIRM;
3432static int _GET_PADON(
RS_STACKDATA *stack,
int argument_count) {
3433 if (argument_count <= 0) {
3437 SetStack(stack, exch_ok_cancel(GamePad.
GetPadOn()));
3441static int _GET_PADDOWN(
RS_STACKDATA *stack,
int argument_count) {
3442 if (argument_count <= 0) {
3446 SetStack(stack, exch_ok_cancel(GamePad.
GetPadDown()));
3450static int _GET_PADUP(
RS_STACKDATA *stack,
int argument_count) {
3451 if (argument_count <= 0) {
3455 SetStack(stack, exch_ok_cancel(GamePad.
GetPadUp()));
3459static int _GET_APAD(
RS_STACKDATA *stack,
int argument_count) {
3460 if (argument_count > 0) {
3461 SetStack(stack++, GamePad.
GetLXf());
3464 if (argument_count > 1) {
3465 SetStack(stack++, GamePad.
GetLYf());
3468 if (argument_count > 2) {
3469 SetStack(stack++, GamePad.
GetRXf());
3472 if (argument_count > 3) {
3473 SetStack(stack, GamePad.
GetRYf());
3479static int _GET_RANDOM(
RS_STACKDATA *stack,
int argument_count) {
3480 if (argument_count <= 0) {
3484 SetStack(stack, rand());
3488static int _SET_RETURN_CODE(
RS_STACKDATA *stack,
int argument_count) {
3493static int _NEXT_EVENT(
RS_STACKDATA *stack,
int argument_count) {
3498static int _GOTO_INTERIOR(
RS_STACKDATA *stack,
int argument_count) {
3500 char *destination = GetStackString(stack++);
3503 if (argument_count > 2) {
3512static int _SET_WORLD_COORD(
RS_STACKDATA *stack,
int argument_count) {
3513 if (argument_count == 6) {
3514 world_pos[0] = GetStackFloat(stack++);
3515 world_pos[1] = GetStackFloat(stack++);
3516 world_pos[2] = GetStackFloat(stack++);
3517 world_pos[3] = 1.0f;
3518 world_rot[0] = GetStackFloat(stack++);
3519 world_rot[1] = GetStackFloat(stack++);
3520 world_rot[2] = GetStackFloat(stack);
3521 world_rot[3] = 0.0f;
3522 SetWorldCoord(world_pos, world_rot);
3524 world_pos[0] = world_pos[1] = world_pos[2] = 0.0f;
3525 world_rot[0] = world_rot[1] = world_rot[2] = 0.0f;
3526 sceVu0UnitMatrix(world_local);
3527 sceVu0UnitMatrix(local_world);
3534static int _INITIALIZE(
RS_STACKDATA *stack,
int argument_count) {
3539static int _EXIT_CODE(
RS_STACKDATA *stack,
int argument_count) {
3540 EdEventInfo.
exit_code = GetStackInt(stack);
3544static int _DRAW_EXCLAMATION_MARK(
RS_STACKDATA *stack,
int argument_count) {
3549static int _GOTO_USE_ITEM(
RS_STACKDATA *stack,
int argument_count) {
3552 if (stack->
type != RS_PTR) {
3556 p_use_item = stack->
s;
3560 for (i = 0; i < argument_count - 1; i++) {
3561 items[i] = GetStackInt(stack++);
3566 EdSetUseItem(items);
3571static int _NAME_REGISTRY(
RS_STACKDATA *stack,
int argument_count) {
3572 EdSetNameRegChara(GetStackInt(stack));
3577static int _WORLD_MAP(
RS_STACKDATA *stack,
int argument_count) {
3578 if (stack->
type != RS_PTR) {
3582 p_jump_map_no = stack->
i;
3587static int _SKIP(
RS_STACKDATA *stack,
int argument_count) {
3588 skip_enable = GetStackInt(stack);
3592static int _GOTO_OUTSIDE(
RS_STACKDATA *stack,
int argument_count) {
3598static int _FINISH(
RS_STACKDATA *stack,
int argument_count) {
3603static int _MAP_JUMP(
RS_STACKDATA *stack,
int argument_count) {
3604 int map = GetStackInt(stack++) - 1;
3607 if (argument_count >= 2) {
3608 event = GetStackInt(stack);
3611 MapJump(map, event);
3616static int _GET_OLD_MAPNO(
RS_STACKDATA *stack,
int argument_count) {
3617 SetStack(stack, OldMapNo + 1);
3621static int _SET_DUNGEON_FLOOR(
RS_STACKDATA *stack,
int argument_count) {
3622 BtSetMapJumpFloor(GetStackInt(stack));
3626static int _GET_DUNGEON_FLOOR(
RS_STACKDATA *stack,
int argument_count) {
3627 SetStack(stack, BtMapJumpFloor);
3631static int _FADEOUT_TO_EVENT(
RS_STACKDATA *stack,
int argument_count) {
3636static int _MAP_JUMP_BGM_STOP(
RS_STACKDATA *stack,
int argument_count) {
3641static int _MAP_JUMP_BGM_PLAY(
RS_STACKDATA *stack,
int argument_count) {
3646static int _GOTO_FP_CHANGE(
RS_STACKDATA *stack,
int argument_count) {
3651static int _GOTO_FISH_RANKING(
RS_STACKDATA *stack,
int argument_count) {
3656static int _GOTO_CHANGE_ESA(
RS_STACKDATA *stack,
int argument_count) {
3657 if (stack->
type != RS_PTR) {
3661 p_use_item = stack->
s;
3662 int items[32] = {ITEM_EVY, ITEM_MIMI, ITEM_PRICKLY, ITEM_THROBBING_CHERRY, ITEM_GOOEY_PEACH, ITEM_BOMB_NUTS, ITEM_POISONOUS_APPLE, ITEM_MELLOW_BANANA, ITEM_CARROT, ITEM_POTATO_CAKE, ITEM_MINON, ITEM_BATTAN, ITEM_PETITE_FISH, -1};
3664 EdSetUseItem(items);
3669static int _SET_CURRENT_DIR(
RS_STACKDATA *stack,
int argument_count) {
3670 char *directory = GetStackString(stack);
3672 if (directory == NULL) {
3676 strcpy(CurrentDir, directory);
3680static u_int *get_pack_file() {
3681 return chr_file[actv_file];
3685 if (actv_buffer == 1) {
3686 return &EdEventExBuffer;
3689 return &EdEventBuffer;
3692static int _ACTIVE_FILE_BUFFER(
RS_STACKDATA *stack,
int argument_count) {
3693 actv_file = GetStackInt(stack++);
3694 actv_buffer = GetStackInt(stack);
3696 if (actv_file < 0 || actv_file >= 16) {
3703static int _LOAD_CHR_FILE(
RS_STACKDATA *stack,
int argument_count) {
3707 u_long128 *buffer = (u_long128 *) read_buffer;
3710 for (i = 0; i < 16; i++) {
3714 for (i = 0; i < argument_count; i++) {
3715 char *name = GetStackString(stack++);
3718 GetFileName(path, name);
3719 printf(
"%s\n", path);
3720 chr_file[i] = (u_int *) buffer;
3721 LoadFileBG(path, (u_long128 *) chr_file[i], &size);
3722 buffer += (((size >> 6) + 1) << 6) >> 4;
3726 return not_wait_load = 1;
3729static int _LOAD_SYNC(
RS_STACKDATA *stack,
int argument_count) {
3730 if (argument_count <= 0) {
3734 SetStack(stack, ReadBGSync());
3739static int _LOAD_CHARA(
RS_STACKDATA *stack,
int argument_count) {
3741 int index = GetStackInt(stack);
3745 char *name = GetStackString(name_stack);
3751 u_int *pack = get_pack_file();
3771 char *name = GetStackString(name_stack);
3777 u_int *pack = get_pack_file();
3798 if (npc->
frame != NULL) {
3799 npc->
frame->SetAttr(attr, 1, 4);
3806static int _LOAD_CHARA_TEXTURE(
RS_STACKDATA *stack,
int argument_count) {
3809 int index = GetStackInt(stack++);
3816 if (npc->
images[0] != NULL) {
3822 u_int *pack = get_pack_file();
3828 for (i = 0; i < argument_count - 1; i++) {
3829 u_int *file = GetPackFile(pack, GetStackString(stack++), &size);
3832 void *copy = get_buffer()->Alloc((size >> 4) + 1);
3833 memcpy(copy, file, size);
3835 textures[i].
mipmap =
false;
3836 textures[i].
name = (
char *) copy;
3840 textures[i].
name = NULL;
3841 TexManager.DeleteTextureBlock(block);
3842 TexManager.CleanUpBuffer();
3843 TexManager.LoadTextureBlockEX(block, textures);
3848static int _LOAD_SPRITE_TEXTURE(
RS_STACKDATA *stack,
int argument_count) {
3852 u_int *pack = get_pack_file();
3858 for (i = 0; i < argument_count; i++) {
3859 u_int *file = GetPackFile(pack, GetStackString(stack++), &size);
3862 void *copy = get_buffer()->Alloc((size >> 4) + 1);
3863 memcpy(copy, file, size);
3865 textures[i].
mipmap =
false;
3866 textures[i].
name = (
char *) copy;
3870 textures[i].
name = NULL;
3871 TexManager.DeleteTextureBlock(45);
3872 TexManager.CleanUpBuffer();
3873 TexManager.LoadTextureBlockEX(45, textures);
3877static int _LOAD_BG_SPRITE_TEXTURE(
RS_STACKDATA *stack,
int argument_count) {
3881 u_int *pack = get_pack_file();
3887 for (i = 0; i < argument_count; i++) {
3888 u_int *file = GetPackFile(pack, GetStackString(stack++), &size);
3891 void *copy = get_buffer()->Alloc((size >> 4) + 1);
3892 memcpy(copy, file, size);
3894 textures[i].
mipmap =
false;
3895 textures[i].
name = (
char *) copy;
3899 textures[i].
name = NULL;
3900 TexManager.DeleteTextureBlock(46);
3901 TexManager.CleanUpBuffer();
3902 TexManager.LoadTextureBlockEX(46, textures);
3906static int _LOAD_TEXTURE(
RS_STACKDATA *stack,
int argument_count) {
3909 int block = GetStackInt(stack++) + 45;
3911 if (block > 49 || block < 45) {
3916 u_int *pack = get_pack_file();
3922 for (i = 0; i < argument_count - 1; i++) {
3923 u_int *file = GetPackFile(pack, GetStackString(stack++), &size);
3926 void *copy = get_buffer()->Alloc((size >> 4) + 1);
3927 memcpy(copy, file, size);
3929 textures[i].
mipmap =
false;
3930 textures[i].
name = (
char *) copy;
3934 textures[i].
name = NULL;
3935 TexManager.DeleteTextureBlock(block);
3936 TexManager.CleanUpBuffer();
3937 TexManager.LoadTextureBlockEX(block, textures);
3948static int _LOAD_IN_VILLAGER(
RS_STACKDATA *stack,
int argument_count) {
3949 int index = GetStackInt(stack++);
3956 VILLAGER_INFO *villager = GetVillagerInfo(GetStackInt(stack++));
3957 char *name = GetStackString(stack++);
3964 EdLoadVillager(name, npc, &EdVillagerBuffer);
3966 if (villager == NULL) {
3970 memcpy(&EdVillagerInfo[index], villager,
sizeof(
VILLAGER_INFO));
3980 sceVu0FVECTOR position = {0.0f, 0.0f, 0.0f, 0.0f};
3981 sceVu0FVECTOR rotation = {0.0f, 0.0f, 0.0f, 0.0f};
3983 if (argument_count > 3) {
3984 GetPosition(stack, position);
3986 rotation[1] = GetStackFloat(stack++);
3989 GetWorldRot(rotation, rotation);
4005static int _LOAD_OUT_VILLAGER(
RS_STACKDATA *stack,
int argument_count) {
4006 int index = GetStackInt(stack++);
4013 VILLAGER_INFO *villager = GetVillagerInfo(GetStackInt(stack++));
4014 char *name = GetStackString(stack++);
4021 EdLoadVillager(name, npc, &EdVillagerBuffer);
4025 if (villager != NULL) {
4026 villager->
index = -1;
4034 sceVu0FVECTOR position = {0.0f, 0.0f, 0.0f, 0.0f};
4035 sceVu0FVECTOR rotation = {0.0f, 0.0f, 0.0f, 0.0f};
4037 if (argument_count > 3) {
4038 GetPosition(stack, position);
4040 rotation[1] = GetStackFloat(stack++);
4043 GetWorldRot(rotation, rotation);
4052static int _LOAD_VILLAGER(
RS_STACKDATA *stack,
int argument_count) {
4053 EdVillagerBuffer.
used = 0;
4054 EdSelectVillager(EdVillagerInfo, EdEventInfo.
current_time, EditMapInfo);
4055 EdInitVilager(EdVillagerInfo, EdEventInfo.
edit_ground, NULL);
4056 EdInitVilagerPosition(EdVillager, EdVillagerInfo, EdEventInfo.
edit_ground, NULL);
4060static int _CHECK_IN_VILLAGER(
RS_STACKDATA *stack,
int argument_count) {
4061 int index = GetStackInt(stack++);
4062 int in = EdCheckVillagerIn(index, &EdEventInfo.
villagers[index]);
4063 SetStack(stack, in);
4067static int _APPEAR_VILLAGER_ON(
RS_STACKDATA *stack,
int argument_count) {
4068 EdVillagerAppearOn(GetStackInt(stack), 1);
4072static int _APPEAR_VILLAGER_OFF(
RS_STACKDATA *stack,
int argument_count) {
4073 EdVillagerAppearOff(GetStackInt(stack), 1);
4077static int _APPEAR_VILLAGER_OUT(
RS_STACKDATA *stack,
int argument_count) {
4078 EdVillagerAppearOut(GetStackInt(stack), 1);
4082static int _APPEAR_VILLAGER_IN(
RS_STACKDATA *stack,
int argument_count) {
4083 EdVillagerAppearIn(GetStackInt(stack), 1);
4087static int _APPEAR_VILLAGER_MOVE(
RS_STACKDATA *stack,
int argument_count) {
4089 int index = GetStackInt(stack);
4090 EdVillagerAppearMove(index, GetStackInt(next), 1);
4094static int _DELETE_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4095 int index = GetStackInt(stack);
4109static int _INIT_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4110 for (
int i = 0; i < argument_count; i++) {
4121static int _CLEAR_VILLAGER_BUFF(
RS_STACKDATA *stack,
int argument_count) {
4123 int used = arena->
used;
4124 u_char *base = arena->
base + used * 16;
4125 int limit = arena->
limit - used;
4126 EdVillagerBuffer.
base = base;
4127 EdVillagerBuffer.
limit = limit;
4128 EdVillagerBuffer.
used = 0;
4132static int _CLEAR_EVENT_BUFF(
RS_STACKDATA *stack,
int argument_count) {
4133 int used = EdVillagerBuffer.
used;
4134 u_char *base = EdVillagerBuffer.
base + used * 16;
4135 int limit = EdVillagerBuffer.
limit - used;
4136 EdEventBuffer.
base = base;
4137 EdEventBuffer.
limit = limit;
4138 EdEventBuffer.
used = 0;
4142static int _CLEAR_EVENT_EXBUFF(
RS_STACKDATA *stack,
int argument_count) {
4143 int used = EdEventBuffer.
used;
4144 u_char *base = EdEventBuffer.
base + used * 16;
4145 int limit = EdEventBuffer.
limit - used;
4146 EdEventExBuffer.
base = base;
4147 EdEventExBuffer.
limit = limit;
4148 EdEventExBuffer.
used = 0;
4152static int _LOAD_SCENE(
RS_STACKDATA *stack,
int argument_count) {
4153 CCharacter *scene = GetScene(GetStackInt(stack++));
4155 if (scene == NULL) {
4159 char *name = GetStackString(stack++);
4165 u_int *pack = get_pack_file();
4176 if (argument_count >= 3) {
4183static int _SYNC_SCENE_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4184 CCharacter *scene = GetScene(GetStackInt(stack++));
4186 if (scene == NULL) {
4190 char *name = GetStackString(stack++);
4191 int index = GetStackInt(stack);
4195 character = GetNPC(index);
4198 if (character == NULL) {
4202 if (scene->
frame == NULL) {
4206 CFrame *reference = scene->
frame->SearchFrame(name);
4208 if (reference == NULL) {
4212 if (character->
frame == NULL) {
4216 character->
frame->SetReference(reference);
4225static int _SYNC_SCENE_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
4226 CCharacter *scene = GetScene(GetStackInt(stack));
4228 if (scene == NULL) {
4232 if (EdEventInfo.
camera != NULL) {
4240static int _RELEASE_SCENE_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4241 int index = GetStackInt(stack);
4245 character = GetNPC(index);
4248 if (character == NULL) {
4252 if (character->
frame != NULL) {
4253 character->
frame->DeleteReference();
4263static int _RELEASE_SCENE_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
4264 CCharacter *scene = GetScene(GetStackInt(stack));
4266 if (scene == NULL) {
4274static int _SET_SCENE_POS(
RS_STACKDATA *stack,
int argument_count) {
4275 CCharacter *scene = GetScene(GetStackInt(stack++));
4277 if (scene == NULL) {
4281 sceVu0FVECTOR position;
4282 GetPosition(stack, position);
4287static int _SET_SCENE_ROT(
RS_STACKDATA *stack,
int argument_count) {
4288 CCharacter *scene = GetScene(GetStackInt(stack++));
4290 if (scene == NULL) {
4294 sceVu0FVECTOR rotation;
4295 GetRotation(stack, rotation);
4300static int _LOAD_ITEM_FILE(
RS_STACKDATA *stack,
int argument_count) {
4301 char model_path[128];
4302 char texture_path[128];
4304 EdGetItemFile(GetStackInt(stack), model_path, texture_path);
4306 if (model_path[0] ==
'\0' || texture_path[0] ==
'\0') {
4311 u_long128 *buffer = (u_long128 *) read_buffer;
4312 LoadFileBG(texture_path, buffer, &size);
4313 buffer += (((size >> 6) + 1) << 6) >> 4;
4314 LoadFileBG(model_path, buffer, &size);
4318static int _LOAD_ITEM(
RS_STACKDATA *stack,
int argument_count) {
4319 int index = GetStackInt(stack);
4321 if (index < 0 || index > 0) {
4331 int size = read->
size;
4332 u_long128 *source = read->
buffer;
4333 void *copy = get_buffer()->Alloc((size >> 4) + 1);
4334 memcpy(copy, source, size);
4337 textures[0].
mipmap =
false;
4338 textures[0].
name = (
char *) copy;
4339 textures[1].
name = NULL;
4340 TexManager.DeleteTextureBlock(40);
4341 TexManager.LoadTextureBlockEX(40, textures);
4342 read = GetReadBGFile(1);
4348 EdEventInfo.
item_frame[index] = LoadMDSFile((u_int *) read->
buffer, get_buffer(), 0, NULL, NULL);
4349 return EdEventInfo.
item_frame[index] != NULL ? 1 : 0;
4352static int _SYNC_CHARA_ITEM(
RS_STACKDATA *stack,
int argument_count) {
4353 CCharacter *character = GetChara(GetStackInt(stack++));
4354 char *name = GetStackString(stack++);
4355 CFrame *reference = NULL;
4357 if (name != NULL && name[0] !=
'\0') {
4358 reference = character->
frame->SearchFrame(name);
4361 if (reference == NULL) {
4362 reference = character->
frame;
4365 CFrame *item = GetItemFrame(GetStackInt(stack));
4371 item->SetReference(reference);
4375static int _RELEASE_CHARA_ITEM(
RS_STACKDATA *stack,
int argument_count) {
4376 CFrame *frame = GetItemFrame(GetStackInt(stack));
4378 if (frame != NULL) {
4379 frame->DeleteReference();
4385static int _DELETE_ITEM(
RS_STACKDATA *stack,
int argument_count) {
4386 DeleteItemFrame(GetStackInt(stack));
4387 TexManager.DeleteTextureBlock(40);
4391static int _SYNC_CHARA_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4392 CCharacter *source = GetChara(GetStackInt(stack++));
4394 if (source == NULL) {
4398 char *name = GetStackString(stack++);
4406 if (name[0] !=
'\0') {
4407 reference = source->
frame->SearchFrame(name);
4409 reference = source->
frame;
4412 if (reference == NULL) {
4416 CCharacter *target = GetChara(GetStackInt(stack));
4418 if (target == NULL) {
4422 if (target->
frame == NULL) {
4426 target->
frame->SetReference(reference);
4435static int _RELEASE_CHARA_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4436 CCharacter *character = GetChara(GetStackInt(stack));
4438 if (character == NULL) {
4442 if (character->
frame != NULL) {
4443 character->
frame->DeleteReference();
4453static int _GET_CHARA_POS(
RS_STACKDATA *stack,
int argument_count) {
4454 sceVu0FVECTOR position;
4456 if (argument_count < 3) {
4461 SetPosition(stack, position);
4465static int _GET_CHARA_TALK_POS(
RS_STACKDATA *stack,
int argument_count) {
4468 if (argument_count < 2) {
4473 SetStack(stack++, position[0]);
4474 SetStack(stack, position[1]);
4478static int _SET_CHARA_POS(
RS_STACKDATA *stack,
int argument_count) {
4479 sceVu0FVECTOR position;
4480 GetPosition(stack, position);
4485static int _SET_CHARA_ROT(
RS_STACKDATA *stack,
int argument_count) {
4486 sceVu0FVECTOR rotation;
4488 if (argument_count == 3) {
4489 GetRotation(stack, rotation);
4493 if (argument_count == 1) {
4496 rotation[1] = GetStackFloat(stack);
4497 GetWorldRot(rotation, rotation);
4504static int _GET_CHARA_ROT(
RS_STACKDATA *stack,
int argument_count) {
4505 sceVu0FVECTOR rotation;
4507 if (argument_count < 3) {
4512 SetRotation(stack, rotation);
4516int _TURN_CHARA(
RS_STACKDATA *stack,
int argument_count) {
4517 sceVu0FVECTOR position;
4518 GetPosition(stack, position);
4519 turn_chara(EdEventInfo.
main_character, position, GetStackFloat(stack += 3));
4523static int _GET_NPC_TALK_POS(
RS_STACKDATA *stack,
int argument_count) {
4526 if (argument_count < 2) {
4531 int index = GetStackInt(stack);
4534 return _GET_CHARA_TALK_POS(result, argument_count - 1);
4537 if (index < 0 || index >= EdEventInfo.
npc_count) {
4541 GetScrPosFromChar(&EdEventInfo.
npcs[index], position);
4542 SetStack(result++, position[0]);
4543 SetStack(result, position[1]);
4547static int _GET_NPC_POS(
RS_STACKDATA *stack,
int argument_count) {
4548 sceVu0FVECTOR position;
4550 if (argument_count < 4) {
4555 CCharacter *character = GetChara(GetStackInt(stack));
4557 if (character == NULL) {
4564 SetStack(result++, position[0]);
4565 SetStack(result++, position[1]);
4566 SetStack(result, position[2]);
4570 SetPosition(result, position);
4574static int _SET_NPC_POS(
RS_STACKDATA *stack,
int argument_count) {
4575 sceVu0FVECTOR position;
4577 CCharacter *character = GetChara(GetStackInt(stack));
4579 if (character == NULL) {
4584 position[0] = GetStackFloat(argument++);
4585 position[1] = GetStackFloat(argument++);
4586 position[2] = GetStackFloat(argument);
4592 GetPosition(argument, position);
4597static int _SET_NPC_ROT(
RS_STACKDATA *stack,
int argument_count) {
4598 sceVu0FVECTOR rotation;
4599 CCharacter *character = GetChara(GetStackInt(stack++));
4601 if (character == NULL) {
4607 if (character->
frame != NULL) {
4611 if (argument_count == 4) {
4612 if (parent != NULL) {
4613 rotation[0] = GetStackFloat(stack++);
4614 rotation[1] = GetStackFloat(stack++);
4615 rotation[2] = GetStackFloat(stack++);
4617 GetRotation(stack, rotation);
4622 if (argument_count == 2) {
4625 rotation[1] = GetStackFloat(stack);
4627 if (parent == NULL) {
4628 GetWorldRot(rotation, rotation);
4636static int _GET_NPC_ROT(
RS_STACKDATA *stack,
int argument_count) {
4637 sceVu0FVECTOR rotation;
4639 if (argument_count < 4) {
4644 CCharacter *character = GetChara(GetStackInt(stack));
4646 if (character == NULL) {
4653 SetStack(result++, rotation[0]);
4654 SetStack(result++, rotation[1]);
4655 SetStack(result, rotation[2]);
4659 SetRotation(result, rotation);
4663static int _SET_NPC_SCALE(
RS_STACKDATA *stack,
int argument_count) {
4664 CCharacter *character = GetChara(GetStackInt(stack++));
4666 if (character == NULL) {
4670 float x = GetStackFloat(stack++);
4672 if (argument_count == 2) {
4675 float y = GetStackFloat(stack++);
4676 float z = GetStackFloat(stack);
4683static int _GET_NPC_SCALE(
RS_STACKDATA *stack,
int argument_count) {
4684 sceVu0FVECTOR scale;
4686 CCharacter *character = GetChara(GetStackInt(stack));
4688 if (character == NULL) {
4693 SetStack(result++, scale[0]);
4694 SetStack(result++, scale[1]);
4695 SetStack(result, scale[2]);
4699static int _NPC_POS_INIT(
RS_STACKDATA *stack,
int argument_count) {
4700 sceVu0FVECTOR transform = {0.0f, 0.0f, 0.0f, 0.0f};
4702 for (
int i = 0; i < argument_count; i++) {
4703 CCharacter *character = GetChara(GetStackInt(stack++));
4705 if (character != NULL) {
4714static int _GET_NPC_PARTS_NO(
RS_STACKDATA *stack,
int argument_count) {
4715 if (argument_count < 2) {
4719 int index = GetStackInt(stack++);
4721 if (index < 0 || index >= 16) {
4729static int _SET_NPC_MOTION(
RS_STACKDATA *stack,
int argument_count) {
4730 int index = GetStackInt(stack++);
4736 character = GetNPC(index);
4739 if (character == NULL) {
4743 int motion = GetStackInt(stack++);
4744 float speed = -1.0f;
4746 if (argument_count >= 3) {
4747 speed = GetStackFloat(stack++);
4750 if (argument_count == 4) {
4751 character->
SetMotion(motion, GetStackInt(stack));
4763static int _SET_NPC_ANIME(
RS_STACKDATA *stack,
int argument_count) {
4764 int index = GetStackInt(stack++);
4770 character = GetNPC(index);
4773 if (character == NULL) {
4777 int animation = GetStackInt(stack++);
4780 if (argument_count == 3) {
4781 enable = GetStackInt(stack);
4784 if (animation == -1 && enable == 0) {
4797static int _TURN_NPC(
RS_STACKDATA *stack,
int argument_count) {
4798 sceVu0FVECTOR position;
4799 int index = GetStackInt(stack++);
4802 return _TURN_CHARA(stack, argument_count - 1);
4807 if (character == NULL) {
4811 GetPosition(stack, position);
4812 turn_chara(character, position, GetStackFloat(stack += 3));
4816int _NPC_DRAW(
RS_STACKDATA *stack,
int argument_count) {
4817 int draw = GetStackInt(stack++);
4819 for (
int i = 0; i < argument_count - 1; i++) {
4820 int index = GetStackInt(stack++);
4822 if (GetChara(index) != NULL) {
4827 if (index >= 0 && index < 16) {
4828 EdEventInfo.
npc_draw[index] = draw;
4836int _NPC_DRAW_SHADOW(
RS_STACKDATA *stack,
int argument_count) {
4837 int draw = GetStackInt(stack++);
4839 for (
int i = 0; i < argument_count - 1; i++) {
4840 int index = GetStackInt(stack++);
4842 if (GetChara(index) != NULL) {
4847 if (index >= 0 && index < 16) {
4856int _SET_NPC_FOOT_SOUND(
RS_STACKDATA *stack,
int argument_count) {
4857 int mode = GetStackInt(stack++);
4859 for (
int i = 0; i < argument_count - 1; i++) {
4860 int index = GetStackInt(stack++);
4863 if (character != NULL) {
4868 if (index >= 0 && index < 16) {
4881static int _SET_NPC_FLOOR_ID(
RS_STACKDATA *stack,
int argument_count) {
4883 CCharacter *character = GetChara(GetStackInt(stack));
4885 if (character == NULL) {
4900static s32 _NPC_STEP(
RS_STACKDATA *stack, s32 argument_count) {
4904static int _NPC_COL(
RS_STACKDATA *stack,
int argument_count) {
4905 int collision = GetStackInt(stack++);
4907 for (
int i = 0; i < argument_count - 1; i++) {
4908 int index = GetStackInt(stack++);
4922static int _NPC_STOP(
RS_STACKDATA *stack,
int argument_count) {
4923 int stopped = GetStackInt(stack++);
4925 for (
int i = 0; i < argument_count - 1; i++) {
4926 int index = GetStackInt(stack++);
4929 EdEventInfo.
npc_stop[index] = stopped;
4940static int _NPC_DRAW_BEFORE(
RS_STACKDATA *stack,
int argument_count) {
4941 int order = GetStackInt(stack++);
4944 while (i < argument_count - 1) {
4945 int index = GetStackInt(stack++);
4957static int _INIT_NPC_CLOTH(
RS_STACKDATA *stack,
int argument_count) {
4958 int index = GetStackInt(stack);
4964 character = GetNPC(index);
4967 if (character == NULL) {
4975static int _NPC_CLOTH_FLOOR(
RS_STACKDATA *stack,
int argument_count) {
4977 CCharacter *character = GetChara(GetStackInt(stack));
4979 if (character == NULL) {
4983 character->
ClothFloor(GetStackInt(argument));
4987static int _NPC_CLOTH_STEP(
RS_STACKDATA *stack,
int argument_count) {
4988 CCharacter *character = GetChara(GetStackInt(stack++));
4990 if (character == NULL) {
4996 if (argument_count > 1) {
4997 steps = GetStackInt(stack);
5000 for (
int i = 0; i < steps; i++) {
5007static int _SET_NPC_AMBIENT(
RS_STACKDATA *stack,
int argument_count) {
5008 CCharacter *character = GetChara(GetStackInt(stack++));
5010 if (character == NULL) {
5014 sceVu0FVECTOR ambient = {0.0f, 0.0f, 0.0f, 128.0f};
5016 if (argument_count == 1) {
5021 if ((
unsigned int) (argument_count - 2) < 2) {
5022 float value = GetStackInt(stack++);
5028 if (argument_count >= 4) {
5034 if (argument_count >= 5) {
5041static int _SET_NPC_BODY_SIZE(
RS_STACKDATA *stack,
int argument_count) {
5042 CCharacter *character = GetChara(GetStackInt(stack++));
5044 if (character == NULL) {
5048 if (argument_count > 1) {
5049 character->
body_width = GetStackFloat(stack++);
5052 if (argument_count > 2) {
5056 if (argument_count > 3) {
5057 character->
body_depth = GetStackFloat(stack);
5063static int _GET_NPC_BODY_SIZE(
RS_STACKDATA *stack,
int argument_count) {
5064 CCharacter *character = GetChara(GetStackInt(stack++));
5066 if (character == NULL) {
5070 if (argument_count > 1) {
5074 if (argument_count > 2) {
5078 if (argument_count > 3) {
5085static int _NPC_PLIGHT_INIT(
RS_STACKDATA *stack,
int argument_count) {
5086 CCharacter *character = GetChara(GetStackInt(stack));
5088 if (character == NULL) {
5096static int _SET_NPC_PLIGHT(
RS_STACKDATA *stack,
int argument_count) {
5097 sceVu0FVECTOR position;
5099 CCharacter *character = GetChara(GetStackInt(stack++));
5101 if (character == NULL) {
5105 GetPosition(stack, position);
5108 for (
int i = 0; i < 5; i++) {
5109 light[i] = GetStackFloat(stack++);
5112 return character->
SetPointLight(position, light[0], light[1], light[2], light[3], light[4], 128.0f);
5115static int _SGET_NPC_TALK_MES(
RS_STACKDATA *stack,
int argument_count) {
5116 if (argument_count < 2) {
5131static int _SSET_NPC_TALK_MES(
RS_STACKDATA *stack,
int argument_count) {
5143static ClsMes *GetMes(
int index) {
5144 if (index < 0 || index >= 8) {
5148 return EdEventInfo.
messages[index];
5151static int _MES_MAKE(
RS_STACKDATA *stack,
int argument_count) {
5152 ClsMes *message = GetMes(GetStackInt(stack++));
5154 if (message == NULL) {
5158 if (EdEventInfo.
camera != NULL) {
5163 MGSetViewMatrix(view, eye);
5166 int message_no = GetStackInt(stack++);
5168 if (argument_count >= 3) {
5169 message->
value = GetStackInt(stack++);
5172 if (argument_count >= 4) {
5173 for (
int i = 0; i < 4; i++) {
5177 for (
int i = 4; argument_count >= i; i++) {
5178 int slot_message = GetStackInt(stack++);
5179 message->
mes_no[i - 4] = slot_message;
5180 printf(
"%d %d\n", i - 4, slot_message);
5188static int _MES_CLOSE(
RS_STACKDATA *stack,
int argument_count) {
5189 ClsMes *message = GetMes(GetStackInt(stack));
5191 if (message == NULL) {
5201static int _MES_NEXTPAGE(
RS_STACKDATA *stack,
int argument_count) {
5202 ClsMes *message = GetMes(GetStackInt(stack));
5204 if (message == NULL) {
5212int _SET_MES_AUTOSET(
RS_STACKDATA *stack,
int argument_count) {
5213 ClsMes *message = GetMes(GetStackInt(stack++));
5215 if (message == NULL) {
5219 if (EdEventInfo.
camera != NULL) {
5224 MGSetViewMatrix(view, eye);
5228 int talk_position[4];
5230 if (argument_count == 5) {
5231 for (
int i = 0; i < 4; i++) {
5232 position[i] = GetStackInt(stack++);
5239 if (argument_count == 3) {
5240 int first_index = GetStackInt(stack++);
5241 int second_index = GetStackInt(stack);
5244 message->
AutoSetSub(speaker, listener, talk_position);
5245 message->
AutoSet(talk_position);
5252static int _SET_MES_SHIPPO(
RS_STACKDATA *stack,
int argument_count) {
5253 ClsMes *message = GetMes(GetStackInt(stack++));
5255 if (message == NULL) {
5259 message->
tail_on = GetStackInt(stack++);
5261 if (argument_count > 2) {
5265 if (argument_count > 3) {
5272static int _SET_MES_POS(
RS_STACKDATA *stack,
int argument_count) {
5274 ClsMes *message = GetMes(GetStackInt(stack));
5276 if (message == NULL) {
5280 message->
auto_pos = GetStackInt(next);
5284static int _SET_MES_DRAWSPEED(
RS_STACKDATA *stack,
int argument_count) {
5286 ClsMes *message = GetMes(GetStackInt(stack));
5288 if (message == NULL) {
5292 message->
text_rate = GetStackFloat(next);
5296static int _SET_MES_CURSOR(
RS_STACKDATA *stack,
int argument_count) {
5298 ClsMes *message = GetMes(GetStackInt(stack));
5300 if (message == NULL) {
5308static int _SET_MES_OKURI(
RS_STACKDATA *stack,
int argument_count) {
5310 ClsMes *message = GetMes(GetStackInt(stack));
5312 if (message == NULL) {
5320static int _SET_MES_WIN_FLAG(
RS_STACKDATA *stack,
int argument_count) {
5322 ClsMes *message = GetMes(GetStackInt(stack));
5324 if (message == NULL) {
5332static int _CHECK_MES_COMPLETE(
RS_STACKDATA *stack,
int argument_count) {
5333 if (argument_count < 2) {
5338 ClsMes *message = GetMes(GetStackInt(stack));
5340 if (message == NULL) {
5344 SetStack(result, message->
State() == CLSMES_SHOWN);
5348static int _CHECK_MES_WAIT(
RS_STACKDATA *stack,
int argument_count) {
5349 if (argument_count < 2) {
5354 ClsMes *message = GetMes(GetStackInt(stack));
5356 if (message == NULL) {
5360 SetStack(result, message->
State() == CLSMES_PAGE_WAIT);
5364static int _CHECK_MES(
RS_STACKDATA *stack,
int argument_count) {
5365 if (argument_count < 2) {
5370 ClsMes *message = GetMes(GetStackInt(stack));
5372 if (message == NULL) {
5376 SetStack(result, message->
State() == CLSMES_CLOSED);
5380static int _SET_MES_FUKIDASHI(
RS_STACKDATA *stack,
int argument_count) {
5382 ClsMes *message = GetMes(GetStackInt(stack));
5384 if (message == NULL) {
5392static int _ITEM_GET_MES(
RS_STACKDATA *stack,
int argument_count) {
5393 int item = GetStackInt(stack++);
5394 int attachment = -1;
5396 if (GetAddAttachItem(item) != 0) {
5400 if (argument_count == 2) {
5401 attachment = GetStackInt(stack);
5404 ItemGetMes(item, attachment, 40, 1);
5408static int _INIT_SYS_MES(
RS_STACKDATA *stack,
int argument_count) {
5413static int _SKILL_GET_MES(
RS_STACKDATA *stack,
int argument_count) {
5414 TecGetMes(GetStackInt(stack), 40);
5418static int _ADD_MAXITEM_MES(
RS_STACKDATA *stack,
int argument_count) {
5419 int amount = GetStackInt(stack);
5422 amount = EdAddMaxItem(0);
5425 MaxUpMes(amount, 40);
5429static int _CHECK_COMPLETE_PARTS(
RS_STACKDATA *stack,
int argument_count) {
5430 if (argument_count < 2) {
5435 SetStack(result, (0, EditPartsInfo.
CheckComplete(GetStackInt(stack))));
5439static int _GET_EDIT_PARTS_POS(
RS_STACKDATA *stack,
int argument_count) {
5440 sceVu0FVECTOR position;
5441 sceVu0FVECTOR rotation;
5444 if (parts == NULL) {
5448 if (argument_count < 4) {
5454 SetStack(stack++, position[0]);
5455 SetStack(stack++, position[1]);
5456 SetStack(stack++, position[2]);
5458 if (argument_count == 7) {
5459 SetStack(stack++, rotation[0]);
5460 SetStack(stack++, rotation[1]);
5461 SetStack(stack, rotation[2]);
5467static int _GET_NOW_TIME(
RS_STACKDATA *stack,
int argument_count) {
5468 SetStack(stack, (0, EdGetTime(EdEventInfo.
current_time)));
5472static int _SET_CLOCK(
RS_STACKDATA *stack,
int argument_count) {
5473 EdSetClock(GetStackFloat(stack));
5477static int _GET_CLOCK(
RS_STACKDATA *stack,
int argument_count) {
5478 SetStack(stack, EdGetClock());
5482static int _SGET_CMP_EVENT(
RS_STACKDATA *stack,
int argument_count) {
5484 int event = GetStackInt(stack);
5485 SetStack(result, (0, EditPartsInfo.
GetCompEvent(event)));
5489static int _SSET_CMP_EVENT(
RS_STACKDATA *stack,
int argument_count) {
5491 int event = GetStackInt(stack);
5496static int _SCHECK_REQUEST(
RS_STACKDATA *stack,
int argument_count) {
5498 int request = GetStackInt(stack);
5499 SetStack(result, (0, EditPartsInfo.
GetRequest(request)));
5503static int _CHECK_PLACE(
RS_STACKDATA *stack,
int argument_count) {
5504 SetStack(stack, EdInteriorFlag);
5508static int _CHECK_VILLAGER(
RS_STACKDATA *stack,
int argument_count) {
5510 int index = GetStackInt(stack);
5511 SetStack(result, EdCheckVillager(index, &EdEventInfo.
villagers[index], EdEventInfo.
edit_ground));
5515static int _DELETE_ROBO_PARTS(
RS_STACKDATA *stack,
int argument_count) {
5516 EdDeleteE05RoboParts();
5520static int _HOBJ_FIXPARTS(
RS_STACKDATA *stack,
int argument_count) {
5529 int handle = GetStackInt(stack++);
5530 int index = GetStackInt(stack++);
5537 return SetObjHandle(handle, &EdEventInfo.
fixed_parts[index], GetStackString(stack)) ? result : 0;
5540static int _HOBJ_EDITPARTS(
RS_STACKDATA *stack,
int argument_count) {
5549 int handle = GetStackInt(stack++);
5550 int index = GetStackInt(stack++);
5557 return SetObjHandle(handle, &EdEventInfo.
edit_parts[index], GetStackString(stack)) ? result : 0;
5560static int _HOBJ_INTERIORPARTS(
RS_STACKDATA *stack,
int argument_count) {
5569 int handle = GetStackInt(stack++);
5570 int index = GetStackInt(stack++);
5577 return SetObjHandle(handle, &EdEventInfo.
interior_parts[index], GetStackString(stack)) ? result : 0;
5580static int _HOBJ_CHARA(
RS_STACKDATA *stack,
int argument_count) {
5581 int handle_index = GetStackInt(stack++);
5582 CCharacter *character = GetChara(GetStackInt(stack++));
5584 if (character == NULL) {
5588 return SetObjHandle(handle_index, character, GetStackString(stack)) != 0 ? 1 : 0;
5591static int _HOBJ_BT_HOBJ(
RS_STACKDATA *stack,
int argument_count) {
5595 count = argument_count;
5596 handle = GetObjHandle(GetStackInt(stack++));
5598 if (handle == NULL) {
5608 for (i = 0; i < count - 1; i++) {
5611 if (
object == NULL) {
5615 if (object->
type == 1) {
5623 if (object->
type == 0) {
5624 handle->
frames[i] =
object->frame;
5631static int _HOBJ_ITEM(
RS_STACKDATA *stack,
int argument_count) {
5633 int handle_index = GetStackInt(stack);
5634 CFrame *frame = GetItemFrame(GetStackInt(next));
5636 if (frame == NULL) {
5640 return SetObjHandle(handle_index, frame) != 0 ? 1 : 0;
5643static int _OBJ_DRAW(
RS_STACKDATA *stack,
int argument_count) {
5644 int draw = GetStackInt(stack++);
5646 for (
int i = 0; i < argument_count - 1; i++) {
5647 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5649 if (handle != NULL) {
5650 obj_draw(handle, draw);
5657static int _SET_OBJ_POS(
RS_STACKDATA *stack,
int argument_count) {
5658 sceVu0FVECTOR position;
5659 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5661 if (handle == NULL) {
5665 position[0] = GetStackFloat(stack++);
5666 position[1] = GetStackFloat(stack++);
5667 position[2] = GetStackFloat(stack);
5669 set_obj_pos(handle, position);
5673static int _GET_OBJ_POS(
RS_STACKDATA *stack,
int argument_count) {
5674 sceVu0FVECTOR position;
5675 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5677 if (handle == NULL) {
5681 if (argument_count < 4) {
5685 get_obj_pos(handle, position);
5686 SetStack(stack++, position[0]);
5687 SetStack(stack++, position[1]);
5688 SetStack(stack, position[2]);
5692static int _SET_OBJ_ROT(
RS_STACKDATA *stack,
int argument_count) {
5693 sceVu0FVECTOR rotation;
5694 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5696 if (handle == NULL) {
5700 rotation[0] = AngleLimit(GetStackFloat(stack++));
5701 rotation[1] = AngleLimit(GetStackFloat(stack++));
5702 rotation[2] = AngleLimit(GetStackFloat(stack));
5704 set_obj_rot(handle, rotation);
5708static int _GET_OBJ_ROT(
RS_STACKDATA *stack,
int argument_count) {
5709 sceVu0FVECTOR rotation;
5710 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5712 if (handle == NULL) {
5716 if (argument_count < 4) {
5720 get_obj_rot(handle, rotation);
5721 SetStack(stack++, rotation[0]);
5722 SetStack(stack++, rotation[1]);
5723 SetStack(stack, rotation[2]);
5727static int _SET_OBJ_SCALE(
RS_STACKDATA *stack,
int argument_count) {
5729 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack));
5731 if (handle == NULL) {
5735 sceVu0FVECTOR scale;
5736 scale[0] = GetStackFloat(arguments++);
5737 scale[1] = GetStackFloat(arguments++);
5738 scale[2] = GetStackFloat(arguments);
5740 set_obj_scale(handle, scale);
5744static int _GET_OBJ_SCALE(
RS_STACKDATA *stack,
int argument_count) {
5745 sceVu0FVECTOR scale;
5746 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5748 if (handle == NULL) {
5752 if (argument_count < 4) {
5756 get_obj_scale(handle, scale);
5757 SetStack(stack++, scale[0]);
5758 SetStack(stack++, scale[1]);
5759 SetStack(stack, scale[2]);
5763static int _SYNC_OBJ_OBJ(
RS_STACKDATA *stack,
int argument_count) {
5765 OBJ_HANDLE *source = GetObjHandle(GetStackInt(stack));
5767 if (source == NULL) {
5771 OBJ_HANDLE *target = GetObjHandle(GetStackInt(next));
5773 if (target == NULL) {
5777 sync_obj_obj(source, target);
5781static int _RELEASE_OBJ_OBJ(
RS_STACKDATA *stack,
int argument_count) {
5782 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack));
5784 if (handle == NULL) {
5788 release_obj_obj(handle);
5792static int _SET_OBJ_FOG(
RS_STACKDATA *stack,
int argument_count) {
5793 OBJ_HANDLE *handle = GetObjHandle(GetStackInt(stack++));
5795 if (handle == NULL) {
5801 set_attr_obj(handle, attr, GetStackInt(stack), 0x40);
5805static int _GET_TALKNPC_INFO_ID(
RS_STACKDATA *stack,
int argument_count) {
5806 if (argument_count <= 0) {
5810 SetStack(stack, EdNowTalkCharaInfoID());
5814static int _GET_TALKNPC_ID(
RS_STACKDATA *stack,
int argument_count) {
5815 if (argument_count <= 0) {
5830static int _GET_TALKNPC_STATUS(
RS_STACKDATA *stack,
int argument_count) {
5834 if (index >= 0 && index < EdEventInfo.
npc_count) {
5839 SetStack(stack, status);
5843static int _SET_TALK_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
5847 static sceVu0FVECTOR vv[3] = {
5848 {-18.8f, 7.1f, -21.3f, 1.0f},
5849 {21.0f, 6.5f, -5.7f, 1.0f},
5850 {22.6f, 6.9f, 16.5f, 1.0f},
5853 int view = GetStackInt(stack);
5854 sceVu0FVECTOR player_position;
5855 sceVu0FVECTOR npc_position;
5856 sceVu0FVECTOR direction;
5864 sceVu0SubVector(direction, npc_position, player_position);
5865 float angle = atan2f(direction[0], direction[2]);
5866 sceVu0FVECTOR midpoint;
5867 sceVu0AddVector(midpoint, player_position, npc_position);
5868 sceVu0ScaleVector(midpoint, midpoint, 0.5f);
5869 midpoint[1] += 15.0f;
5872 if (camera != NULL) {
5874 camera->
SetNextRef(NULL, midpoint[0], midpoint[1], midpoint[2]);
5875 camera->
SetRef(midpoint);
5878 sceVu0FVECTOR camera_position;
5879 sceVu0FMATRIX rotation;
5880 sceVu0UnitMatrix(rotation);
5881 sceVu0RotMatrixY(rotation, rotation, angle);
5882 sceVu0ApplyMatrix(camera_position, rotation, vv[view]);
5883 sceVu0AddVector(camera_position, midpoint, camera_position);
5885 if (camera != NULL) {
5886 camera->
SetPos(camera_position);
5889 if (camera != NULL) {
5890 camera->
SetNextPos(NULL, camera_position[0], camera_position[1], camera_position[2]);
5893 if (camera != NULL) {
5894 sceVu0FMATRIX view_matrix;
5898 MGSetViewMatrix(view_matrix, eye);
5904static int _SET_TALK_MES(
RS_STACKDATA *stack,
int argument_count) {
5905 for (
int i = 0; i < 16; i++) {
5909 for (
int i = 0; i < argument_count; i++) {
5920static int _SET_TALK_SELECT_MES(
RS_STACKDATA *stack,
int argument_count) {
5927static int _EVERY_TALK_EVENT(
RS_STACKDATA *stack,
int argument_count) {
5928 int villager_id = GetStackInt(stack++);
5930 if (villager_id < 0 || villager_id >= 16) {
5934 int event_no = villager_id + 0x104;
5936 if (argument_count > 1) {
5937 event_no = GetStackInt(stack);
5940 for (
int i = 0; i < EdEventInfo.
npc_count; i++) {
5954 if (camera == NULL) {
5962static int _SET_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
5963 sceVu0FVECTOR position;
5964 sceVu0FVECTOR reference;
5967 if (camera == NULL) {
5971 GetPosition(stack, position);
5972 GetPosition(stack + 3, reference);
5973 float speed = GetStackFloat(stack += 6);
5974 follow_chara = NULL;
5976 camera->
SetNextPos(NULL, position[0], position[1], position[2]);
5977 camera->
SetNextRef(NULL, reference[0], reference[1], reference[2]);
5980 if (speed <= 1.0f) {
5981 camera->
SetPos(position);
5982 camera->
SetRef(reference);
5989static int _SET_CAMERA_POS(
RS_STACKDATA *stack,
int argument_count) {
5992 if (camera == NULL) {
5996 follow_chara = NULL;
5998 sceVu0FVECTOR position;
5999 GetPosition(stack, position);
6000 camera->
SetNextPos(NULL, position[0], position[1], position[2]);
6004static int _GET_CAMERA_POS(
RS_STACKDATA *stack,
int argument_count) {
6005 if (argument_count < 3) {
6009 if (EdEventInfo.
camera == NULL) {
6013 sceVu0FVECTOR position;
6015 SetPosition(stack, position);
6019static int _SET_CAMERA_REF(
RS_STACKDATA *stack,
int argument_count) {
6022 if (camera == NULL) {
6026 follow_chara = NULL;
6028 sceVu0FVECTOR position;
6029 GetPosition(stack, position);
6030 camera->
SetNextRef(NULL, position[0], position[1], position[2]);
6034static int _GET_CAMERA_REF(
RS_STACKDATA *stack,
int argument_count) {
6035 if (argument_count < 3) {
6039 if (EdEventInfo.
camera == NULL) {
6043 sceVu0FVECTOR position;
6045 SetPosition(stack, position);
6049static int _SET_CAMERA_SPEED(
RS_STACKDATA *stack,
int argument_count) {
6052 if (camera == NULL) {
6056 camera->
SetSpeed((
float) GetStackInt(stack));
6060static int _SET_FOLLOW_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
6063 if (camera == NULL) {
6068 sceVu0FVECTOR position[2];
6070 if (stack->
type == RS_INT) {
6071 int index = GetStackInt(stack++);
6076 follow_chara = GetNPC(index);
6079 if (follow_chara != NULL) {
6083 GetPosition(stack, position[1]);
6085 follow_chara = NULL;
6088 for (
int i = 0; i < 4; i++) {
6089 values[i] = GetStackFloat(stack++);
6092 sceVu0FVECTOR rotation;
6093 rotation[1] = values[2];
6094 GetWorldRot(rotation, rotation);
6096 camera->
SetFollow(position[1][0], position[1][1], position[1][2]);
6103 if (values[3] <= 1.0f) {
6111static int _ADD_CAMERA_ANGLE(
RS_STACKDATA *stack,
int argument_count) {
6114 if (camera == NULL) {
6118 camera->
AddAngle(GetStackFloat(stack));
6123static int _ADD_CAMERA_HEIGHT(
RS_STACKDATA *stack,
int argument_count) {
6126 if (camera == NULL) {
6130 camera->
AddHeight(GetStackFloat(stack));
6135static int _ADD_CAMERA_DIST(
RS_STACKDATA *stack,
int argument_count) {
6138 if (camera == NULL) {
6147static int _CAMERA_STEP(
RS_STACKDATA *stack,
int argument_count) {
6150 if (camera == NULL) {
6154 if (follow_chara != NULL) {
6155 sceVu0FVECTOR position;
6163static int _SET_PROJECTION(
RS_STACKDATA *stack,
int argument_count) {
6164 EdEventInfo.
projection = GetStackFloat(stack);
6168static int _ITEM_GET_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
6171 if (camera == NULL) {
6175 float distance = GetStackFloat(stack);
6177 if (distance < 0.0f) {
6181 if (distance < 10.0f) {
6187 sceVu0FVECTOR character_position;
6188 sceVu0FVECTOR character_rotation;
6190 character_position[3] = 1.0f;
6192 sceVu0FMATRIX rotation;
6193 sceVu0UnitMatrix(rotation);
6194 sceVu0RotMatrixY(rotation, rotation, character_rotation[1]);
6195 sceVu0CopyVector(rotation[3], character_position);
6196 sceVu0FVECTOR camera_position = {0.0f, 16.0f, distance, 1.0f};
6197 sceVu0FVECTOR camera_reference = {0.0f, 15.0f, 0.0f, 1.0f};
6198 sceVu0ApplyMatrix(camera_position, rotation, camera_position);
6199 sceVu0ApplyMatrix(camera_reference, rotation, camera_reference);
6200 camera->
SetPos(camera_position);
6201 camera->
SetNextPos(NULL, camera_position[0], camera_position[1], camera_position[2]);
6202 camera->
SetRef(camera_reference);
6203 camera->
SetNextRef(NULL, camera_reference[0], camera_reference[1], camera_reference[2]);
6207static int _SET_CAMERA_ANGLE(
RS_STACKDATA *stack,
int argument_count) {
6208 CCamera *camera = GetCamera();
6210 if (camera == NULL) {
6214 float yaw = AngleLimit(GetStackFloat(stack++));
6215 yaw = GetLocalRotY(yaw);
6216 sceVu0FVECTOR position;
6217 sceVu0FVECTOR reference;
6218 sceVu0FVECTOR direction;
6219 camera->
GetPos(position);
6220 camera->
GetRef(reference);
6221 sceVu0SubVector(direction, reference, position);
6223 if (argument_count == 1) {
6224 direction[1] = 0.0f;
6227 float distance = DistVector(direction);
6230 if (argument_count == 2) {
6231 pitch = AngleLimit(GetStackFloat(stack));
6234 sceVu0FVECTOR offset = {0.0f, 0.0f, distance, 0.0f};
6235 sceVu0FMATRIX matrix;
6236 sceVu0FMATRIX rotation;
6237 sceVu0UnitMatrix(matrix);
6238 sceVu0RotMatrixX(rotation, matrix, pitch);
6239 sceVu0RotMatrixY(rotation, rotation, yaw);
6240 sceVu0ApplyMatrix(offset, rotation, offset);
6241 sceVu0AddVector(offset, offset, position);
6242 reference[0] = offset[0];
6243 reference[2] = offset[2];
6245 if (argument_count == 2) {
6246 reference[1] = offset[1];
6249 camera->
SetRef(reference);
6253static int _GET_CAMERA_ANGLE(
RS_STACKDATA *stack,
int argument_count) {
6254 CCamera *camera = GetCamera();
6256 if (camera == NULL) {
6260 sceVu0FVECTOR position;
6261 sceVu0FVECTOR reference;
6262 sceVu0FVECTOR direction;
6263 sceVu0FVECTOR horizontal;
6264 camera->
GetPos(position);
6265 camera->
GetRef(reference);
6266 sceVu0SubVector(direction, reference, position);
6267 horizontal[0] = direction[0];
6268 horizontal[1] = 0.0f;
6269 horizontal[2] = direction[2];
6270 horizontal[3] = 0.0f;
6271 float distance = DistVector(horizontal);
6272 sceVu0Normalize(horizontal, horizontal);
6273 float yaw = atan2f(horizontal[0], horizontal[2]);
6274 float pitch = -atan2f(direction[1], distance);
6276 if (argument_count > 0) {
6277 SetStack(stack++, GetLocalRotY(yaw));
6280 if (argument_count >= 2) {
6281 SetStack(stack, pitch);
6287static int _SET_CAMERA_ROTATE(
RS_STACKDATA *stack,
int argument_count) {
6288 CCamera *camera = GetCamera();
6290 if (camera == NULL) {
6294 float yaw = AngleLimit(GetStackFloat(stack));
6295 yaw = GetWorldRotY(yaw);
6296 sceVu0FVECTOR position;
6297 sceVu0FVECTOR reference;
6298 sceVu0FVECTOR direction;
6299 camera->
GetPos(position);
6300 camera->
GetRef(reference);
6301 sceVu0SubVector(direction, reference, position);
6302 direction[1] = 0.0f;
6303 float distance = DistVector(direction);
6304 sceVu0FVECTOR offset = {0.0f, 0.0f, distance, 0.0f};
6305 sceVu0FMATRIX matrix;
6306 sceVu0FMATRIX rotation;
6307 sceVu0UnitMatrix(matrix);
6308 sceVu0RotMatrixY(rotation, matrix, yaw);
6309 sceVu0ApplyMatrix(offset, rotation, offset);
6310 sceVu0AddVector(offset, offset, reference);
6311 position[0] = offset[0];
6312 position[2] = offset[2];
6313 camera->
SetPos(position);
6317static int _GET_CAMERA_ROTATE(
RS_STACKDATA *stack,
int argument_count) {
6318 sceVu0FVECTOR position;
6319 sceVu0FVECTOR reference;
6320 sceVu0FVECTOR direction;
6323 if (camera == NULL) {
6327 camera->
GetPos(position);
6328 camera->
GetRef(reference);
6329 sceVu0SubVector(direction, position, reference);
6330 SetStack(stack, GetLocalRotY(atan2f(direction[0], direction[2])));
6341static int _RESET_CAMERA(
RS_STACKDATA *stack,
int argument_count) {
6347static int _RESET_CAMERA_ANGLE(
RS_STACKDATA *stack,
int argument_count) {
6353static int _SYNC_CAMERA_REF_CHARA(
RS_STACKDATA *stack,
int argument_count) {
6354 sync_camera_ref_chara = GetChara(GetStackInt(stack++));
6356 if (argument_count == 4) {
6357 sync_camera_ref_offset[0] = GetStackFloat(stack++);
6358 sync_camera_ref_offset[1] = GetStackFloat(stack++);
6359 sync_camera_ref_offset[2] = GetStackFloat(stack);
6361 sync_camera_ref_offset[0] = 0.0f;
6362 sync_camera_ref_offset[1] = 0.0f;
6363 sync_camera_ref_offset[2] = 0.0f;
6369static int _RELEASE_CAMERA_REF_CHARA(
RS_STACKDATA *stack,
int argument_count) {
6370 sync_camera_ref_chara = NULL;
6374static int _SYNC_CAMERA_REF_OBJ(
RS_STACKDATA *stack,
int argument_count) {
6375 sync_camera_ref_obj = GetObjHandle(GetStackInt(stack++));
6377 if (argument_count == 4) {
6378 sync_camera_ref_offset[0] = GetStackFloat(stack++);
6379 sync_camera_ref_offset[1] = GetStackFloat(stack++);
6380 sync_camera_ref_offset[2] = GetStackFloat(stack);
6382 sync_camera_ref_offset[0] = 0.0f;
6383 sync_camera_ref_offset[1] = 0.0f;
6384 sync_camera_ref_offset[2] = 0.0f;
6390static int _RELEASE_CAMERA_REF_OBJ(
RS_STACKDATA *stack,
int argument_count) {
6391 sync_camera_ref_obj = NULL;
6395static int _SYNC_CAMERA_POS_OBJ(
RS_STACKDATA *stack,
int argument_count) {
6396 sync_camera_pos_obj = GetObjHandle(GetStackInt(stack));
6400static int _RELEASE_CAMERA_POS_OBJ(
RS_STACKDATA *stack,
int argument_count) {
6401 sync_camera_pos_obj = NULL;
6405static int _SET_CAMERA_ROLL(
RS_STACKDATA *stack,
int argument_count) {
6408 if (camera == NULL) {
6412 camera->
SetRoll(GetStackFloat(stack));
6416static int _GET_CAMERA_ROLL(
RS_STACKDATA *stack,
int argument_count) {
6419 if (camera == NULL) {
6423 SetStack(stack, camera->
GetRoll());
6427static int _FADE_IN(
RS_STACKDATA *stack,
int argument_count) {
6429 int frames = (0, GetStackInt(stack++));
6434 if (argument_count == 4) {
6435 red = GetStackInt(stack++);
6436 green = GetStackInt(stack++);
6437 blue = GetStackInt(stack);
6440 EdFadeIn(frames, (
float) red, (
float) green, (
float) blue);
6444static int _FADE_OUT(
RS_STACKDATA *stack,
int argument_count) {
6446 int frames = (0, GetStackInt(stack++));
6451 if (argument_count == 4) {
6452 red = GetStackInt(stack++);
6453 green = GetStackInt(stack++);
6454 blue = GetStackInt(stack);
6457 EdFadeOut(frames, (
float) red, (
float) green, (
float) blue);
6461static int _CHECK_FADE(
RS_STACKDATA *stack,
int argument_count) {
6462 if (argument_count <= 0) {
6466 SetStack(stack, EdFadeOutCheck());
6470static int _INIT_SPRITE(
RS_STACKDATA *stack,
int argument_count) {
6476static int _DRAW_SPRITE(
RS_STACKDATA *stack,
int argument_count) {
6478 int x = GetStackInt(stack++);
6479 int y = GetStackInt(stack++);
6480 char *name = GetStackString(stack++);
6481 source.
x = GetStackInt(stack++);
6482 source.
y = GetStackInt(stack++);
6483 source.
width = GetStackInt(stack++);
6484 source.
height = GetStackInt(stack);
6485 CTexture *texture = TexManager.GetTexture(name, -1);
6487 if (texture == NULL) {
6495static int _DRAW_BG_SPRITE(
RS_STACKDATA *stack,
int argument_count) {
6497 int x = GetStackInt(stack++);
6498 int y = GetStackInt(stack++);
6499 char *name = GetStackString(stack++);
6500 source.
x = GetStackInt(stack++);
6501 source.
y = GetStackInt(stack++);
6502 source.
width = GetStackInt(stack++);
6503 source.
height = GetStackInt(stack);
6504 CTexture *texture = TexManager.GetTexture(name, -1);
6506 if (texture == NULL) {
6514static int _DRAW_BACK(
RS_STACKDATA *stack,
int argument_count) {
6518 if (argument_count > 1) {
6519 red = GetStackFloat(stack++);
6525 if (argument_count == 4) {
6526 green = GetStackFloat(stack++);
6527 blue = GetStackFloat(stack);
6536static int _DRAW_SHADOW(
RS_STACKDATA *stack,
int argument_count) {
6548static int _SET_CLIP_POINT(
RS_STACKDATA *stack,
int argument_count) {
6549 sceVu0FVECTOR plane;
6550 GetPosition(stack, plane);
6554 float distance = GetStackFloat(stack++);
6563static int _DRAW_EDIT_WATER(
RS_STACKDATA *stack,
int argument_count) {
6571static int _DRAW_WATER_SURFACE(
RS_STACKDATA *stack,
int argument_count) {
6572 int draw = GetStackInt(stack++);
6574 for (
int i = 0; i < argument_count - 1; i++) {
6576 int index = GetStackInt(stack++);
6578 if (index >= 0 && index < 4) {
6587static int _SCREEN_FILTER(
RS_STACKDATA *stack,
int argument_count) {
6588 int red = GetStackInt(stack++);
6595 int green = GetStackInt(stack++);
6596 int blue = GetStackInt(stack++);
6597 int alpha = GetStackInt(stack);
6612static int _DRAW_THUNDER(
RS_STACKDATA *stack,
int argument_count) {
6613 EdThunderEffectFlag = GetStackInt(stack);
6617static int _SET_LIGHT(
RS_STACKDATA *stack,
int argument_count) {
6619 int index = GetStackInt(stack++);
6621 if (index < 0 || index > 3) {
6625 sceVu0FVECTOR direction;
6626 direction[0] = GetStackFloat(stack++);
6627 direction[1] = GetStackFloat(stack++);
6628 direction[2] = GetStackFloat(stack++);
6629 direction[3] = 0.0f;
6630 sceVu0Normalize(direction, direction);
6635 if (argument_count > 4) {
6636 EdEventInfo.
light_color[index][0] = GetStackFloat(stack++);
6637 EdEventInfo.
light_color[index][1] = GetStackFloat(stack++);
6638 EdEventInfo.
light_color[index][2] = GetStackFloat(stack);
6644static int _SET_LIGHT_COLOR(
RS_STACKDATA *stack,
int argument_count) {
6646 int index = GetStackInt(stack++);
6648 if (index < 0 || index > 3) {
6652 EdEventInfo.
light_color[index][0] = GetStackFloat(stack++);
6653 EdEventInfo.
light_color[index][1] = GetStackFloat(stack++);
6654 EdEventInfo.
light_color[index][2] = GetStackFloat(stack);
6658static int _SET_AMBIENT(
RS_STACKDATA *stack,
int argument_count) {
6665 if (argument_count > 3) {
6672static int _SAVE_LIGHT(
RS_STACKDATA *stack,
int argument_count) {
6673 int slot = GetStackInt(stack);
6675 if (slot < 0 || slot > 1) {
6680 sceVu0CopyMatrix(save_c[slot], EdEventInfo.
light_color);
6685static int _LOAD_LIGHT(
RS_STACKDATA *stack,
int argument_count) {
6686 int slot = GetStackInt(stack);
6699 sceVu0CopyMatrix(EdEventInfo.
light_color, save_c[slot]);
6704static int _SET_DOF_LEVEL(
RS_STACKDATA *stack,
int argument_count) {
6705 EdSetDOFLevel(GetStackInt(stack));
6709static int _SP_INIT(
RS_STACKDATA *stack,
int argument_count) {
6710 int index = GetStackInt(stack);
6713 for (
int i = 0;; i++) {
6716 if (sprite == NULL) {
6728 if (sprite == NULL) {
6736static int _SP_SET_TEX(
RS_STACKDATA *stack,
int argument_count) {
6737 ED_SPRITE *sprite = GetSprite(GetStackInt(stack++));
6739 if (sprite == NULL) {
6744 char *name = GetStackString(stack++);
6745 sprite->
source_x = GetStackInt(stack++);
6746 sprite->
source_y = GetStackInt(stack++);
6750 if (argument_count > 6) {
6751 sprite->
bilinear = GetStackInt(stack);
6754 CTexture *texture = TexManager.GetTexture(name, -1);
6756 if (texture == NULL) {
6764static int _SP_SET_POS(
RS_STACKDATA *stack,
int argument_count) {
6765 ED_SPRITE *sprite = GetSprite(GetStackInt(stack++));
6767 if (sprite == NULL) {
6771 sprite->
x = (float) GetStackInt(stack++);
6772 sprite->
y = (float) GetStackInt(stack++);
6776 if (argument_count > 3) {
6777 sprite->
width = GetStackInt(stack++);
6780 if (argument_count > 4) {
6781 sprite->
height = GetStackInt(stack);
6787static int _SP_SET_RGBA(
RS_STACKDATA *stack,
int argument_count) {
6788 ED_SPRITE *sprite = GetSprite(GetStackInt(stack++));
6790 if (sprite == NULL) {
6794 sprite->
red = GetStackInt(stack++);
6795 sprite->
green = GetStackInt(stack++);
6796 sprite->
blue = GetStackInt(stack++);
6797 sprite->
alpha = 128;
6799 if (argument_count > 4) {
6800 sprite->
alpha = GetStackInt(stack);
6806static int _SP_SET_ROT(
RS_STACKDATA *stack,
int argument_count) {
6809 sprite = GetSprite(GetStackInt(stack));
6811 if (sprite == NULL) {
6816 sprite->
rotation_x = GetStackInt(arguments++);
6817 sprite->
rotation_y = GetStackInt(arguments++);
6818 sprite->
rotation = GetStackFloat(arguments);
6822static int _SP_SET_MOVE(
RS_STACKDATA *stack,
int argument_count) {
6824 ED_SPRITE *sprite = GetSprite(GetStackInt(stack));
6826 if (sprite == NULL) {
6830 sprite->
move_x = GetStackFloat(arguments++);
6831 sprite->
move_y = GetStackFloat(arguments);
6835static int _SP_DRAW(
RS_STACKDATA *stack,
int argument_count) {
6836 int layer = GetStackInt(stack++);
6838 for (
int i = 0; i < argument_count - 1; i++) {
6839 ED_SPRITE *sprite = GetSprite(GetStackInt(stack++));
6841 if (sprite != NULL) {
6842 sprite->
layer = layer;
6849static int _INIT_DRAW_DAY(
RS_STACKDATA *stack,
int argument_count) {
6854static int _DRAW_DAY(
RS_STACKDATA *stack,
int argument_count) {
6859static int _MAP_TITLE_OFF(
RS_STACKDATA *stack,
int argument_count) {
6864static int _SET_WIND(
RS_STACKDATA *stack,
int argument_count) {
6865 EdEventInfo.
wind[0] = GetStackFloat(stack++);
6866 EdEventInfo.
wind[1] = GetStackFloat(stack++);
6867 EdEventInfo.
wind[2] = GetStackFloat(stack++);
6868 EdEventInfo.
wind[3] = GetStackFloat(stack);
6872static int _ASQ_INIT(
RS_STACKDATA *stack,
int argument_count) {
6873 int index = GetStackInt(stack);
6876 for (
int i = 0; i < 10; i++) {
6879 if (sequence != NULL) {
6889 if (sequence == NULL) {
6897int _ASQ_SYNC_CHARA(
RS_STACKDATA *stack,
int argument_count) {
6898 int sequence_index = GetStackInt(stack++);
6899 int character_index = GetStackInt(stack);
6900 CActionSeq *sequence = GetActSeq(sequence_index);
6902 if (sequence == NULL) {
6906 CCharacter *character = GetNPC(character_index);
6908 if (character_index == -1) {
6912 if (character == NULL) {
6920static int _ASQ_SET_POS(
RS_STACKDATA *stack,
int argument_count) {
6922 CActionSeq *sequence = GetActSeq(GetStackInt(stack));
6924 if (sequence == NULL) {
6928 sceVu0FVECTOR position;
6929 GetPosition(arguments, position);
6930 sequence->
SetPos(position);
6934static int _ASQ_MOVE(
RS_STACKDATA *stack,
int argument_count) {
6935 sceVu0FVECTOR position;
6936 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
6938 if (sequence == NULL) {
6942 if (argument_count == 5) {
6943 GetPosition(stack, position);
6945 sequence->
MoveSeq(position, GetStackInt(stack++));
6948 if (argument_count == 2) {
6949 sequence->
MoveSeq(GetStackInt(stack));
6955int _ASQ_MOVE_STEP(
RS_STACKDATA *stack,
int argument_count) {
6956 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
6958 if (sequence == NULL) {
6962 sceVu0FVECTOR position;
6963 GetPosition(stack, position);
6964 sequence->
MoveSeq(position, GetStackFloat(stack += 3));
6968int _ASQ_ROT_REF(
RS_STACKDATA *stack,
int argument_count) {
6969 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
6971 if (sequence == NULL) {
6975 sceVu0FVECTOR position;
6976 GetPosition(stack, position);
6977 sequence->
RotRefSeq(position, GetStackFloat(stack += 3));
6981static int _ASQ_ROT_ANGLE(
RS_STACKDATA *stack,
int argument_count) {
6982 sceVu0FVECTOR rotation;
6983 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
6985 if (sequence == NULL) {
6992 rotation[1] = GetStackFloat(stack++);
6993 GetWorldRot(rotation, rotation);
6994 sequence->
RotAngleSeq(rotation[1], GetStackFloat(stack));
6998static int _ASQ_CLEAR_ROT(
RS_STACKDATA *stack,
int argument_count) {
6999 CActionSeq *sequence = GetActSeq(GetStackInt(stack));
7001 if (sequence == NULL) {
7009static int _ASQ_WAIT_ROT(
RS_STACKDATA *stack,
int argument_count) {
7010 CActionSeq *sequence = GetActSeq(GetStackInt(stack));
7012 if (sequence == NULL) {
7020static int _ASQ_ROT_MOVE(
RS_STACKDATA *stack,
int argument_count) {
7022 CActionSeq *sequence = GetActSeq(GetStackInt(stack));
7024 if (sequence == NULL) {
7032static int _ASQ_SET_ROT(
RS_STACKDATA *stack,
int argument_count) {
7033 sceVu0FVECTOR rotation;
7034 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
7036 if (sequence == NULL) {
7040 if (argument_count == 4) {
7041 GetRotation(stack, rotation);
7045 if (argument_count == 2) {
7048 rotation[1] = GetStackFloat(stack);
7049 GetWorldRot(rotation, rotation);
7052 sequence->
SetRot(rotation);
7056static int _ASQ_DELAY_ROT(
RS_STACKDATA *stack,
int argument_count) {
7058 CActionSeq *sequence = GetActSeq(GetStackInt(stack));
7060 if (sequence == NULL) {
7068static int _ASQ_MOTION_TRG(
RS_STACKDATA *stack,
int argument_count) {
7069 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
7071 if (sequence == NULL) {
7077 if (argument_count == 2) {
7078 trigger = GetStackInt(stack);
7085static int asq_motion_play(
int mode,
RS_STACKDATA *stack,
int argument_count) {
7086 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
7088 if (sequence == NULL) {
7092 int motion = GetStackInt(stack++);
7093 float speed = -1.0f;
7095 if (argument_count >= 3) {
7096 speed = GetStackFloat(stack++);
7101 if (argument_count >= 4) {
7102 flags = (int) GetStackFloat(stack);
7106 sequence->
MotionSeq(motion, mode, speed, flags);
7110static int _ASQ_MOTION_PLAY(
RS_STACKDATA *stack,
int argument_count) {
7111 asq_motion_play(5, stack, argument_count);
7115static int _ASQ_MOTION_STOP(
RS_STACKDATA *stack,
int argument_count) {
7116 asq_motion_play(6, stack, argument_count);
7120static int _ASQ_MOTION_NEXT(
RS_STACKDATA *stack,
int argument_count) {
7121 asq_motion_play(7, stack, argument_count);
7125static int _ASQ_ANIME_TRG(
RS_STACKDATA *stack,
int argument_count) {
7126 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
7128 if (sequence == NULL) {
7134 if (argument_count == 2) {
7135 trigger = GetStackInt(stack);
7142static int _ASQ_ANIME(
RS_STACKDATA *stack,
int argument_count) {
7143 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
7145 if (sequence == NULL) {
7152 int animation = GetStackInt(stack++);
7154 if (argument_count >= 3) {
7155 enable = GetStackInt(stack++);
7158 if (argument_count >= 4) {
7159 start = GetStackInt(stack++);
7162 if (argument_count >= 5) {
7163 end = GetStackInt(stack);
7166 sequence->
AnimeSeq(animation, enable, start, end);
7177static int _ASQ_CHECK(
RS_STACKDATA *stack,
int argument_count) {
7178 CActionSeq *sequence = GetActSeq(GetStackInt(stack++));
7180 if (sequence == NULL) {
7185 SetStack(stack++, ((end != 0) ^ 1) & 0xFF);
7189static int _OBJ_ANIME_INIT(
RS_STACKDATA *stack,
int argument_count) {
7190 for (
int i = 0; i < argument_count; i++) {
7191 ClearObjAnime(GetStackInt(stack++));
7204static int _OBJ_ANIME(
RS_STACKDATA *stack,
int argument_count) {
7205 int anime_index = GetStackInt(stack++);
7206 int handle_index = GetStackInt(stack++);
7207 int angle_mode = GetStackInt(stack++);
7208 int playback_mode = GetStackInt(stack++);
7209 sceVu0FVECTOR offset = {0.0f, 0.0f, 0.0f, 0.0f};
7210 sceVu0FVECTOR range;
7211 sceVu0FVECTOR speed;
7212 sceVu0CopyVector(range, offset);
7213 sceVu0CopyVector(speed, offset);
7215 offset[0] = GetStackFloat(stack++);
7216 offset[1] = GetStackFloat(stack++);
7217 offset[2] = GetStackFloat(stack++);
7219 if (angle_mode == 0) {
7220 offset[0] = 180.0f * offset[0] / PI_SHORT;
7221 offset[1] = 180.0f * offset[1] / PI_SHORT;
7222 offset[2] = 180.0f * offset[2] / PI_SHORT;
7225 if (argument_count >= 10) {
7226 range[0] = GetStackFloat(stack++);
7227 range[1] = GetStackFloat(stack++);
7228 range[2] = GetStackFloat(stack++);
7230 if (angle_mode == 0) {
7231 range[0] = 180.0f * range[0] / PI_SHORT;
7232 range[1] = 180.0f * range[1] / PI_SHORT;
7233 range[2] = 180.0f * range[2] / PI_SHORT;
7237 if (argument_count >= 13) {
7238 speed[0] = GetStackFloat(stack++);
7239 speed[1] = GetStackFloat(stack++);
7240 speed[2] = GetStackFloat(stack);
7242 if (angle_mode == 0) {
7243 speed[0] = 180.0f * speed[0] / PI_SHORT;
7244 speed[1] = 180.0f * speed[1] / PI_SHORT;
7245 speed[2] = 180.0f * speed[2] / PI_SHORT;
7249 init_obj_anime(anime_index, handle_index, angle_mode, playback_mode, offset, range, speed);
7253static int _SSET_GAME_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7254 if (argument_count != 2) {
7259 int flag = GetStackInt(stack);
7264static int _SGET_GAME_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7265 if (argument_count != 2) {
7270 int flag = GetStackInt(stack);
7275static int _SSET_GAME_INT_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7276 if (argument_count != 2) {
7281 int flag = GetStackInt(stack);
7286static int _SGET_GAME_INT_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7287 if (argument_count != 2) {
7292 int flag = GetStackInt(stack);
7297static int _SITEM_GET(
RS_STACKDATA *stack,
int argument_count) {
7298 int attachment = -1;
7299 int item = GetStackInt(stack);
7301 if (GetAddAttachItem(item) != 0) {
7305 EdGetItem(item, 1, attachment);
7309static int _SSET_MAP_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7311 int flag = GetStackInt(stack);
7312 EdSetMapFlag(flag, ((GetStackInt(next) != 0) ^ 1) & 0xFF);
7316static int _SGET_MAP_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7318 int flag = GetStackInt(stack);
7319 SetStack(result, ((EdGetMapFlag(flag) != 0) ^ 1) & 0xFF);
7323static int _SET_WORK_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7325 int flag = GetStackInt(stack);
7326 SetWorkFlag(flag, GetStackInt(next));
7330static int _GET_WORK_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7332 int flag = GetStackInt(stack);
7333 SetStack(result, (0, GetWorkFlag(flag)));
7337static int _SITEM_CHECK(
RS_STACKDATA *stack,
int argument_count) {
7339 int item = GetStackInt(stack);
7340 SetStack(result, EdCheckItem(item));
7344static int _SITEM_CHECK_ALL(
RS_STACKDATA *stack,
int argument_count) {
7346 int item = GetStackInt(stack);
7347 SetStack(result, PlayerAllItemCheck(item));
7351static int _SGET_DUNGEON_STATUS(
RS_STACKDATA *stack,
int argument_count) {
7353 int dungeon = GetStackInt(stack++);
7355 if (dungeon < 0 || dungeon >= 6) {
7367static int _SGET_PARTY_NUM(
RS_STACKDATA *stack,
int argument_count) {
7373static int _SSET_PARTY_NUM(
RS_STACKDATA *stack,
int argument_count) {
7375 int party_size = GetStackInt(stack);
7380static int _SSET_REQUEST_EVENT_FLAG(
RS_STACKDATA *stack,
int argument_count) {
7384 if (georama == NULL) {
7399static int _SADD_VISIT_MAP(
RS_STACKDATA *stack,
int argument_count) {
7400 int map = GetStackInt(stack++) - 1;
7403 if (argument_count > 1) {
7404 add = GetStackInt(stack++);
7409 if (argument_count > 2) {
7410 SetStack(stack, visits);
7416static int _SSKILL_GET(
RS_STACKDATA *stack,
int argument_count) {
7418 int character = GetStackInt(stack);
7420 if (character < 0 || character >= 6) {
7428static int _SGET_EQUIP_WEAPON(
RS_STACKDATA *stack,
int argument_count) {
7430 int character = GetStackInt(stack++);
7432 if (character < 0 || character >= 6) {
7440static int _SADD_MAXITEM(
RS_STACKDATA *stack,
int argument_count) {
7441 EdAddMaxItem(GetStackInt(stack));
7445static int _SITEM_LOST(
RS_STACKDATA *stack,
int argument_count) {
7447 status->
LostItem(GetStackInt(stack));
7451static int _SATRA_PARTS_GET(
RS_STACKDATA *stack,
int argument_count) {
7453 int georama = GetStackInt(stack) - 1;
7458static int _SATRA_CHIP_GET(
RS_STACKDATA *stack,
int argument_count) {
7460 int georama = GetStackInt(stack) - 1;
7461 SaveData->
AtraChipGet(georama, GetStackInt(next));
7465int _SGET_REQUEST(
RS_STACKDATA *stack,
int argument_count) {
7469 if (georama == NULL) {
7470 SetStack(result, 0);
7488 if (completed == total) {
7489 SetStack(result, 100);
7491 SetStack(result++, completed * 100 / total);
7497static int _SGET_ATRA_PARTS_NUM(
RS_STACKDATA *stack,
int argument_count) {
7500 int georama = GetStackInt(stack) - 1;
7502 for (
int i = 0; i < 24; i++) {
7505 if (part != NULL && part->
obtained != 0) {
7510 SetStack(result, count);
7514static int _SGET_DAY(
RS_STACKDATA *stack,
int argument_count) {
7515 SetStack(stack, SaveData->
GetDay());
7519static int _SSET_TIME(
RS_STACKDATA *stack,
int argument_count) {
7524static int _SGET_TIME(
RS_STACKDATA *stack,
int argument_count) {
7529static int _SADD_TIME(
RS_STACKDATA *stack,
int argument_count) {
7534static int _SEQUIP_DEFAULT_WEAPON(
RS_STACKDATA *stack,
int argument_count) {
7535 EquipDefaultWeapon(GetStackInt(stack));
7539static int _LOAD_SND_SYNC(
RS_STACKDATA *stack,
int argument_count) {
7540 SetStack(stack, SndSyncBG());
7544static int _LOAD_SOUND_SET(
RS_STACKDATA *stack,
int argument_count) {
7546 SndSoundLoadBG(GetStackInt(stack), read_buffer, NULL);
7550static int _LOAD_VOICE_SET(
RS_STACKDATA *stack,
int argument_count) {
7552 SndVoiceLoadBG(GetStackInt(stack), read_buffer, NULL);
7556static int _LOAD_BGM(
RS_STACKDATA *stack,
int argument_count) {
7558 SndBgmLoadBG(GetStackInt(stack), read_buffer, NULL);
7562static int _DELETE_BGM(
RS_STACKDATA *stack,
int argument_count) {
7568static int _PLAY_BGM(
RS_STACKDATA *stack,
int argument_count) {
7569 SndBgmPlay(GetStackInt(stack));
7573static int _STOP_BGM(
RS_STACKDATA *stack,
int argument_count) {
7578static int _SET_BGM_VOL(
RS_STACKDATA *stack,
int argument_count) {
7579 SndSetBgmVol(GetStackInt(stack));
7583static int _SET_BGM_VOLF(
RS_STACKDATA *stack,
int argument_count) {
7584 SndSetBgmVolf(GetStackFloat(stack));
7588static int _GET_BGM_VOL(
RS_STACKDATA *stack,
int argument_count) {
7589 SetStack(stack, SndGetBgmVol());
7593static int _GET_BGM_NO(
RS_STACKDATA *stack,
int argument_count) {
7594 SetStack(stack, SndGetBgmNo());
7598static int _SET_OUT_BGM_NO(
RS_STACKDATA *stack,
int argument_count) {
7599 EdBeforeInBgmNo = GetStackInt(stack);
7603static int _GET_OUT_BGM_NO(
RS_STACKDATA *stack,
int argument_count) {
7604 SetStack(stack, EdBeforeInBgmNo);
7608static int _BGM_FADE_IN(
RS_STACKDATA *stack,
int argument_count) {
7609 int bgm = GetStackInt(stack++);
7613 if (argument_count > 1) {
7614 frames = GetStackInt(stack++);
7617 if (argument_count > 2) {
7618 mode = GetStackInt(stack);
7621 SndBgmFadeIn(bgm, frames, mode);
7625static int _BGM_FADE_OUT(
RS_STACKDATA *stack,
int argument_count) {
7626 int bgm = GetStackInt(stack++);
7629 if (argument_count > 1) {
7630 frames = GetStackInt(stack);
7633 SndBgmFadeOut(bgm, frames);
7637static int _CHECK_BGM_FADE(
RS_STACKDATA *stack,
int argument_count) {
7638 SetStack(stack, SndCheckFade());
7642static int _PLAY_AMB_BGM(
RS_STACKDATA *stack,
int argument_count) {
7643 SndAmbientPlay(GetStackInt(stack));
7647static int _STOP_AMB_BGM(
RS_STACKDATA *stack,
int argument_count) {
7652static int _SET_AMB_VOLF(
RS_STACKDATA *stack,
int argument_count) {
7653 SndAmbientSetVolf(GetStackFloat(stack));
7657static int _PLAY_SE(
RS_STACKDATA *stack,
int argument_count) {
7658 int sound = GetStackInt(stack++);
7660 if (argument_count >= 4) {
7662 GetPosition(stack, position);
7667 if (argument_count >= 5) {
7668 near = GetStackFloat(stack++);
7671 if (argument_count >= 6) {
7672 far = GetStackFloat(stack);
7675 SndSePlay(sound, position, near, far);
7679 if (argument_count == 2) {
7680 voice = GetStackInt(stack);
7683 SndSePlay(sound, voice, 0);
7689static int _STOP_SE(
RS_STACKDATA *stack,
int argument_count) {
7690 SndSeStop(GetStackInt(stack), 0);
7694static int _SET_SE_VOL(
RS_STACKDATA *stack,
int argument_count) {
7696 int sound = GetStackInt(stack);
7697 SndSetSeVol(sound, GetStackInt(next), 0);
7701static int _LOAD_SPECIAL_SE(
RS_STACKDATA *stack,
int argument_count) {
7703 SndSPSeLoadBG(GetStackInt(stack), read_buffer, NULL);
7707static int _PLAY_SPECIAL_SE(
RS_STACKDATA *stack,
int argument_count) {
7708 int sound = GetStackInt(stack++);
7711 if (argument_count >= 2) {
7712 voice = GetStackInt(stack);
7715 SndSPSePlay(sound, voice);
7719static int _STOP_SPECIAL_SE(
RS_STACKDATA *stack,
int argument_count) {
7720 SndSPSeStop(GetStackInt(stack));
7724static int _SET_SPECIAL_SE_VOL(
RS_STACKDATA *stack,
int argument_count) {
7725 int sound = GetStackInt(stack++);
7727 GetPosition(stack, position);
7732 if (argument_count >= 5) {
7733 near = GetStackFloat(stack++);
7736 if (argument_count >= 6) {
7737 far = GetStackFloat(stack);
7742 SndGetVolPan(&volume, &pan, position, near, far);
7743 SndSetSPSeVolf(sound, volume);
7744 SndSetSPSePanf(sound, pan);
7748static int _SOUND_OFF_COUNT(
RS_STACKDATA *stack,
int argument_count) {
7759static int _GET_V_ARG(
RS_STACKDATA *stack,
int argument_count) {
7760 int index = GetStackInt(stack++);
7762 if (index < 0 || index >= 4) {
7766 for (
int i = 0; i < argument_count - 1; i++) {
7773static int _GET_I_ARG(
RS_STACKDATA *stack,
int argument_count) {
7774 int index = GetStackInt(stack++);
7776 if (index < 0 || index >= 8) {
7784static int _GET_F_ARG(
RS_STACKDATA *stack,
int argument_count) {
7785 int index = GetStackInt(stack++);
7787 if (index < 0 || index >= 8) {
7795static int _EB_INIT(
RS_STACKDATA *stack,
int argument_count) {
7796 EBInit(GetStackFloat(stack));
7800static int _EB_SET_MOTION(
RS_STACKDATA *stack,
int argument_count) {
7803 if (argument_count < 2) {
7807 CCharacter *character = GetChara(GetStackInt(stack++));
7810 while (i < argument_count - 1) {
7811 motions[i++] = GetStackInt(stack++);
7815 EBSetMotion(character, motions);
7819static int _EB_SET_KEY(
RS_STACKDATA *stack,
int argument_count) {
7820 float time = GetStackFloat(stack++);
7821 int key = GetStackInt(stack++);
7824 if (argument_count >= 3) {
7825 mode = GetStackInt(stack);
7828 EBSetKey(time, key, mode);
7832static int _EB_LOOP(
RS_STACKDATA *stack,
int argument_count) {
7833 SetStack(stack, EBLoop());
7837static int _EB_INTRO_START(
RS_STACKDATA *stack,
int argument_count) {
7845static int _EB_INTRO_LOOP(
RS_STACKDATA *stack,
int argument_count) {
7846 SetStack(stack, EBIntroLoop());
7850static int _EB_INTRO_END(
RS_STACKDATA *stack,
int argument_count) {
7855static int _EB_DEBUG(
RS_STACKDATA *stack,
int argument_count) {
7856 EBDebug(GetStackInt(stack));
7860static int _EB_FINISH_SOUND(
RS_STACKDATA *stack,
int argument_count) {
7862 int fade_bgm = GetStackInt(stack);
7863 EBFinishSound(fade_bgm, GetStackInt(next));
7867static int _LOAD_MAIN_CHARA(
RS_STACKDATA *stack,
int argument_count) {
7868 char *model = GetStackString(stack++);
7869 char *motion = GetStackString(stack++);
7870 int use_villager_arena = GetStackInt(stack);
7873 if (use_villager_arena == 1) {
7874 arena = &EdVillagerBuffer;
7877 EdLoadMainChara(model, motion, arena);
7881static int _LOAD_FISHING_DATA(
RS_STACKDATA *stack,
int argument_count) {
7882 int fish_set = GetStackInt(stack++);
7884 FishingLoad(&EdVillagerBuffer, 8);
7885 FishingLoadFish(fish_set, &EdVillagerBuffer, 54);
7888 bounds.
min[0] = GetStackFloat(stack++);
7889 bounds.
min[1] = -1000.0f;
7890 bounds.
min[2] = GetStackFloat(stack++);
7891 bounds.
max[0] = GetStackFloat(stack++);
7892 bounds.
max[1] = 1000.0f;
7893 bounds.
max[2] = GetStackFloat(stack++);
7894 FishingSetRect(bounds);
7895 float water_near = GetStackFloat(stack++);
7896 FishingSetWaterLevel(water_near, GetStackFloat(stack));
7899 int polygon_count = 0;
7903 printf(
"poly_num = %d\n", polygon_count);
7905 if (polygon_count > 1024) {
7906 printf(
"CPOLY OVER *****************\n");
7913 FishingSetCPoly(polygons, polygon_count);
7921static sceVu0FVECTOR fishing_line_origin = {0.0f, 0.0f, 0.0f, 1.0f};
7923static int _GOTO_FISHING(
RS_STACKDATA *stack,
int argument_count) {
7926 if (character == NULL) {
7930 sceVu0FVECTOR position;
7933 if (character->
frame != NULL) {
7935 struct FishingOrigin {
7936 sceVu0FVECTOR value;
7939 FishingOrigin origin = *(FishingOrigin *) fishing_line_origin;
7940 CFrame *rod = character->
frame->SearchFrame(
"sao");
7943 rod->GetWorldPosition(position, origin.value);
7946 FishLineInit(position);
7953static int _INIT_FISH(
RS_STACKDATA *stack,
int argument_count) {
7955 bounds.
min[0] = GetStackFloat(stack++);
7956 bounds.
min[1] = 0.0f;
7957 bounds.
min[2] = GetStackFloat(stack++);
7958 bounds.
max[0] = GetStackFloat(stack++);
7960 bounds.
min[1] = 0.0f;
7961 bounds.
max[2] = GetStackFloat(stack);
7962 FishingInitFish(bounds);
7966static int _EXIT_FISHING(
RS_STACKDATA *stack,
int argument_count) {
7971static int _SET_FISHING_ESA(
RS_STACKDATA *stack,
int argument_count) {
7972 int item = GetStackInt(stack);
7973 FishingLoadEsa(item, EdEventInfo.
item_frame[0], 40);
7978static int _GET_TV_MODE(
RS_STACKDATA *stack,
int argument_count) {
7988static int _GET_LANG_CODE(
RS_STACKDATA *stack,
int argument_count) {
7989 SetStack(stack, LanguageCode);
8000 {_SET_RETURN_CODE, 3 },
8003 {_GOTO_INTERIOR, 6 },
8004 {_SET_WORLD_COORD, 7 },
8007 {_DRAW_EXCLAMATION_MARK, 10 },
8008 {_GOTO_USE_ITEM, 11 },
8010 {_GOTO_OUTSIDE, 13 },
8012 {_GET_OLD_MAPNO, 16 },
8014 {_SET_DUNGEON_FLOOR, 21 },
8015 {_GET_DUNGEON_FLOOR, 22 },
8016 {_FADEOUT_TO_EVENT, 17 },
8017 {_NAME_REGISTRY, 18 },
8019 {_MAP_JUMP_BGM_STOP, 23 },
8020 {_MAP_JUMP_BGM_PLAY, 27 },
8021 {_GOTO_FP_CHANGE, 24 },
8022 {_GOTO_CHANGE_ESA, 25 },
8023 {_GOTO_FISH_RANKING, 26 },
8024 {_SET_CURRENT_DIR, 32 },
8025 {_ACTIVE_FILE_BUFFER, 44 },
8026 {_LOAD_CHR_FILE, 33 },
8029 {_DELETE_CHARA, 47 },
8031 {_LOAD_SPRITE_TEXTURE, 56 },
8032 {_LOAD_BG_SPRITE_TEXTURE, 72 },
8033 {_LOAD_TEXTURE, 74 },
8034 {_LOAD_CHARA_TEXTURE, 36 },
8035 {_LOAD_IN_VILLAGER, 37 },
8036 {_LOAD_OUT_VILLAGER, 71 },
8037 {_LOAD_VILLAGER, 57 },
8038 {_CHECK_IN_VILLAGER, 58 },
8039 {_APPEAR_VILLAGER_ON, 59 },
8040 {_APPEAR_VILLAGER_OFF, 60 },
8041 {_APPEAR_VILLAGER_OUT, 61 },
8042 {_APPEAR_VILLAGER_IN, 62 },
8043 {_APPEAR_VILLAGER_MOVE, 70 },
8044 {_CLEAR_VILLAGER_BUFF, 38 },
8045 {_CLEAR_EVENT_BUFF, 39 },
8046 {_CLEAR_EVENT_EXBUFF, 40 },
8047 {_SYNC_SCENE_CHARA, 42 },
8049 {_SYNC_SCENE_CAMERA, 43 },
8050 {_RELEASE_SCENE_CHARA, 45 },
8051 {_RELEASE_SCENE_CAMERA, 46 },
8052 {_SET_SCENE_POS, 73 },
8053 {_SET_SCENE_ROT, 75 },
8054 {_LOAD_ITEM_FILE, 49 },
8056 {_SYNC_CHARA_ITEM, 51 },
8057 {_RELEASE_CHARA_ITEM, 52 },
8058 {_DELETE_ITEM, 53 },
8059 {_SYNC_CHARA_CHARA, 54 },
8060 {_RELEASE_CHARA_CHARA, 55 },
8061 {_GET_CHARA_POS, 64 },
8062 {_GET_CHARA_TALK_POS, 65 },
8064 {_SET_CHARA_POS, 67 },
8065 {_SET_CHARA_ROT, 68 },
8066 {_GET_CHARA_ROT, 69 },
8067 {_GET_NPC_TALK_POS, 130 },
8068 {_GET_NPC_POS, 131 },
8069 {_GET_NPC_PARTS_NO, 132 },
8070 {_SET_NPC_MOTION, 133 },
8071 {_SGET_NPC_TALK_MES, 134 },
8072 {_SSET_NPC_TALK_MES, 135 },
8074 {_SET_NPC_POS, 137 },
8075 {_SET_NPC_ROT, 138 },
8076 {_GET_NPC_ROT, 139 },
8077 {_SET_NPC_SCALE, 147 },
8078 {_GET_NPC_SCALE, 148 },
8079 {_NPC_POS_INIT, 153 },
8083 {_INIT_NPC_CLOTH, 143 },
8084 {_NPC_CLOTH_STEP, 160 },
8085 {_NPC_DRAW_SHADOW, 144 },
8086 {_SET_NPC_ANIME, 145 },
8087 {_SET_NPC_AMBIENT, 146 },
8088 {_SET_NPC_FOOT_SOUND, 149 },
8089 {_SET_NPC_FLOOR_ID, 152 },
8091 {_NPC_DRAW_BEFORE, 151 },
8092 {_SET_NPC_BODY_SIZE, 154 },
8093 {_GET_NPC_BODY_SIZE, 155 },
8094 {_NPC_CLOTH_FLOOR, 156 },
8095 {_NPC_PLIGHT_INIT, 158 },
8096 {_SET_NPC_PLIGHT, 159 },
8099 {_MES_NEXTPAGE, 194 },
8100 {_SET_MES_AUTOSET, 195 },
8101 {_SET_MES_SHIPPO, 196 },
8102 {_SET_MES_POS, 197 },
8103 {_SET_MES_DRAWSPEED, 198 },
8104 {_SET_MES_CURSOR, 199 },
8105 {_SET_MES_OKURI, 203 },
8106 {_SET_MES_FUKIDASHI, 204 },
8107 {_CHECK_MES_COMPLETE, 200 },
8108 {_CHECK_MES_WAIT, 201 },
8110 {_ITEM_GET_MES, 206 },
8111 {_INIT_SYS_MES, 207 },
8112 {_SKILL_GET_MES, 208 },
8113 {_SET_MES_WIN_FLAG, 205 },
8114 {_ADD_MAXITEM_MES, 209 },
8115 {_CHECK_COMPLETE_PARTS, 256 },
8116 {_GET_EDIT_PARTS_POS, 257 },
8117 {_GET_NOW_TIME, 258 },
8120 {_SGET_CMP_EVENT, 259 },
8121 {_SSET_CMP_EVENT, 260 },
8122 {_CHECK_PLACE, 263 },
8123 {_CHECK_VILLAGER, 267 },
8124 {_SCHECK_REQUEST, 268 },
8125 {_DELETE_ROBO_PARTS, 269 },
8126 {_HOBJ_FIXPARTS, 320 },
8127 {_HOBJ_EDITPARTS, 321 },
8128 {_HOBJ_INTERIORPARTS, 322 },
8129 {_HOBJ_CHARA, 330 },
8130 {_HOBJ_BT_HOBJ, 332 },
8133 {_SET_OBJ_POS, 324 },
8134 {_GET_OBJ_POS, 325 },
8135 {_SET_OBJ_ROT, 326 },
8136 {_GET_OBJ_ROT, 327 },
8137 {_SET_OBJ_SCALE, 328 },
8138 {_GET_OBJ_SCALE, 329 },
8139 {_SYNC_OBJ_OBJ, 333 },
8140 {_RELEASE_OBJ_OBJ, 334 },
8141 {_SET_OBJ_FOG, 335 },
8142 {_GET_TALKNPC_INFO_ID, 384 },
8143 {_GET_TALKNPC_ID, 385 },
8144 {_GET_TALKNPC_STATUS, 389 },
8145 {_SET_TALK_CAMERA, 386 },
8146 {_SET_TALK_MES, 387 },
8147 {_SET_TALK_SELECT_MES, 388 },
8148 {_EVERY_TALK_EVENT, 390 },
8149 {_SET_CAMERA, 416 },
8150 {_SET_FOLLOW_CAMERA, 417 },
8151 {_ADD_CAMERA_ANGLE, 418 },
8152 {_ADD_CAMERA_HEIGHT, 419 },
8153 {_ADD_CAMERA_DIST, 420 },
8154 {_CAMERA_STEP, 421 },
8155 {_SET_CAMERA_POS, 422 },
8156 {_GET_CAMERA_POS, 423 },
8157 {_SET_CAMERA_REF, 424 },
8158 {_GET_CAMERA_REF, 425 },
8159 {_SET_CAMERA_SPEED, 426 },
8160 {_SET_PROJECTION, 427 },
8161 {_ITEM_GET_CAMERA, 428 },
8162 {_SET_CAMERA_ANGLE, 429 },
8163 {_GET_CAMERA_ANGLE, 430 },
8164 {_SET_CAMERA_ROTATE, 431 },
8165 {_GET_CAMERA_ROTATE, 432 },
8166 {_RESET_CAMERA, 433 },
8167 {_RESET_CAMERA_ANGLE, 436 },
8168 {_SYNC_CAMERA_REF_CHARA, 434 },
8169 {_RELEASE_CAMERA_REF_CHARA, 435 },
8170 {_SYNC_CAMERA_REF_OBJ, 437 },
8171 {_RELEASE_CAMERA_REF_OBJ, 438 },
8172 {_SYNC_CAMERA_POS_OBJ, 439 },
8173 {_RELEASE_CAMERA_POS_OBJ, 440 },
8174 {_SET_CAMERA_ROLL, 441 },
8175 {_GET_CAMERA_ROLL, 442 },
8178 {_CHECK_FADE, 502 },
8179 {_INIT_SPRITE, 503 },
8180 {_DRAW_SPRITE, 504 },
8181 {_DRAW_BG_SPRITE, 516 },
8183 {_DRAW_SHADOW, 506 },
8184 {_SET_CLIP_POINT, 507 },
8185 {_DRAW_EDIT_WATER, 508 },
8186 {_DRAW_WATER_SURFACE, 509 },
8187 {_SCREEN_FILTER, 510 },
8188 {_DRAW_THUNDER, 528 },
8190 {_SET_LIGHT_COLOR, 512 },
8191 {_SET_AMBIENT, 513 },
8192 {_SAVE_LIGHT, 514 },
8193 {_LOAD_LIGHT, 515 },
8194 {_SET_DOF_LEVEL, 517 },
8196 {_SP_SET_TEX, 519 },
8197 {_SP_SET_POS, 520 },
8198 {_SP_SET_RGBA, 521 },
8199 {_SP_SET_ROT, 522 },
8200 {_SP_SET_MOVE, 526 },
8202 {_INIT_DRAW_DAY, 524 },
8204 {_MAP_TITLE_OFF, 527 },
8207 {_ASQ_SYNC_CHARA, 601 },
8208 {_ASQ_SET_POS, 602 },
8210 {_ASQ_MOVE_STEP, 604 },
8211 {_ASQ_ROT_REF, 605 },
8212 {_ASQ_CLEAR_ROT, 606 },
8213 {_ASQ_WAIT_ROT, 607 },
8214 {_ASQ_ROT_MOVE, 608 },
8215 {_ASQ_ROT_ANGLE, 618 },
8216 {_ASQ_SET_ROT, 609 },
8217 {_ASQ_DELAY_ROT, 610 },
8219 {_ASQ_MOTION_TRG, 612 },
8220 {_ASQ_MOTION_PLAY, 613 },
8221 {_ASQ_MOTION_STOP, 614 },
8222 {_ASQ_MOTION_NEXT, 615 },
8223 {_ASQ_ANIME_TRG, 616 },
8225 {_OBJ_ANIME_INIT, 650 },
8227 {_SSET_GAME_FLAG, 700 },
8228 {_SGET_GAME_FLAG, 701 },
8229 {_SSET_GAME_INT_FLAG, 711 },
8230 {_SGET_GAME_INT_FLAG, 712 },
8232 {_SSET_MAP_FLAG, 703 },
8233 {_SGET_MAP_FLAG, 704 },
8234 {_SET_WORK_FLAG, 705 },
8235 {_GET_WORK_FLAG, 706 },
8236 {_SITEM_CHECK, 707 },
8237 {_SITEM_CHECK_ALL, 724 },
8238 {_SGET_DUNGEON_STATUS, 708 },
8239 {_SGET_PARTY_NUM, 709 },
8240 {_SSET_PARTY_NUM, 710 },
8241 {_SSET_REQUEST_EVENT_FLAG, 713 },
8242 {_SADD_VISIT_MAP, 714 },
8243 {_SSKILL_GET, 715 },
8244 {_SGET_EQUIP_WEAPON, 716 },
8245 {_SADD_MAXITEM, 717 },
8246 {_SITEM_LOST, 718 },
8247 {_SATRA_PARTS_GET, 719 },
8248 {_SATRA_CHIP_GET, 720 },
8249 {_SGET_REQUEST, 264 },
8250 {_SGET_ATRA_PARTS_NUM, 265 },
8255 {_SEQUIP_DEFAULT_WEAPON, 725 },
8256 {_LOAD_SND_SYNC, 800 },
8257 {_LOAD_SOUND_SET, 816 },
8258 {_LOAD_VOICE_SET, 822 },
8260 {_DELETE_BGM, 815 },
8263 {_SET_BGM_VOL, 804 },
8264 {_SET_BGM_VOLF, 825 },
8265 {_GET_BGM_VOL, 805 },
8266 {_GET_BGM_NO, 806 },
8267 {_SET_OUT_BGM_NO, 813 },
8268 {_GET_OUT_BGM_NO, 814 },
8269 {_BGM_FADE_IN, 817 },
8270 {_BGM_FADE_OUT, 818 },
8271 {_CHECK_BGM_FADE, 819 },
8272 {_PLAY_AMB_BGM, 820 },
8273 {_STOP_AMB_BGM, 821 },
8274 {_SET_AMB_VOLF, 824 },
8277 {_SET_SE_VOL, 809 },
8278 {_LOAD_SPECIAL_SE, 810 },
8279 {_PLAY_SPECIAL_SE, 811 },
8280 {_STOP_SPECIAL_SE, 812 },
8281 {_SET_SPECIAL_SE_VOL, 823 },
8282 {_SOUND_OFF_COUNT, 826 },
8288 {_EB_SET_KEY, 951 },
8290 {_EB_SET_MOTION, 953 },
8292 {_EB_INTRO_START, 955 },
8293 {_EB_INTRO_LOOP, 956 },
8294 {_EB_INTRO_END, 957 },
8295 {_EB_FINISH_SOUND, 958 },
8296 {_LOAD_MAIN_CHARA, 999 },
8297 {_LOAD_FISHING_DATA, 998 },
8298 {_GOTO_FISHING, 997 },
8300 {_EXIT_FISHING, 995 },
8301 {_SET_FISHING_ESA, 994 },
8303 {_GET_TV_MODE, 1001},
8304 {_GET_LANG_CODE, 1002},
8309int EdSetEventScript(
char *common_script,
char *map_script,
CDataAlloc2<1> *allocator) {
8310 if (common_script == NULL) {
8320 if (map_script == NULL) {
8321 map_script = common_script + ((
int *) common_script)[5];
8324 if (EdEventInfo.
messages[1] != NULL) {
8330 for (i = 0; i < 1500; i++) {
8331 ext_func__2[i] = NULL;
8335 if (ext_func_info[i].function == NULL) {
8341 for (j = 0; j < i; j++) {
8342 if (ext_func_info[i].operation == ext_func_info[j].operation) {
8343 printf(
"same ext_func_no!!!\n");
8350 int operation = ext_func_info[i].
operation;
8352 if (operation < 0 || operation >= 1500) {
8353 printf(
"ext func over!!");
8355 ext_func__2[operation] = ext_func_info[i].
function;
8359 EdEventScript.
ext_func(ext_func__2, 1500);
8364int EdInitEventParamSimple() {
8371 motion_stop_flag = 0;
8373 CurrentDir[0] =
'\0';
8376 follow_chara = NULL;
8377 sync_camera_ref_chara = NULL;
8378 sync_camera_ref_obj = NULL;
8379 sync_camera_pos_obj = NULL;
8380 sync_camera_ref_offset[0] = 0.0f;
8381 sync_camera_ref_offset[1] = 0.0f;
8382 sync_camera_ref_offset[2] = 0.0f;
8389 for (i = 0; i < 16; i++) {
8398 for (i = 0; i < 266; i++) {
8399 asq_table[i].
operation = ACT_SEQ_UNUSED;
8400 asq_table[i].
next = NULL;
8403 for (i = 0; i < 10; i++) {
8409 SpriteTableBack.
Initialize(sprite_table, 32, 4);
8412 for (i = 45; i <= 49; i++) {
8413 TexManager.DeleteTextureBlock(i);
8416 memset(ObjHandle, 0,
sizeof(ObjHandle));
8420 for (i = 0; i <= 0; i++) {
8426 for (i = 0; i < 16; i++) {
8429 if (sprite != NULL) {
8437 EdEventInfo.
wind[3] = -1.0f;
8442int EdInitEventParam() {
8443 EdInitEventParamSimple();
8446 if (allocator != NULL) {
8447 int used = allocator->
used;
8448 u_char *base = allocator->
base + used * 16;
8449 int limit = allocator->
limit - used;
8450 EdVillagerBuffer.
base = base;
8451 EdVillagerBuffer.
limit = limit;
8452 EdVillagerBuffer.
used = 0;
8455 for (
int i = 0; i < 320; i++) {
8463 for (
int i = 0; i < EdEventInfo.
npc_count; i++) {
8485int EdEventInit(
int event_number,
CDataAlloc2<1> *arena,
char *program) {
8486 if (program == NULL) {
8490 run_system_event = 0;
8492 for (
int i = 0; i < 8; i++) {
8495 if (message == NULL) {
8504 message->
fade = 0.0f;
8520 for (
int j = 0; j < 10; j++) {
8524 for (
int j = 0; j < 8; j++) {
8538 for (
int j = 0; j < 10; j++) {
8546 EdEventInfo.
event_no = event_number;
8561 if (event_enable == 0) {
8565 EdInitEventParamSimple();
8566 BaseBuffer = (u_int *) arena;
8568 if (EdRunEvent(event_number, arena) <= 0) {
8584 int used = arena->
used;
8585 u_char *base = arena->
base + used * 16;
8586 int limit = arena->
limit - used;
8587 EdEventBuffer.
base = base;
8588 EdEventBuffer.
limit = limit;
8589 EdEventBuffer.
used = 0;
8590 world_rot[3] = 0.0f;
8591 world_rot[2] = 0.0f;
8592 world_rot[1] = 0.0f;
8593 world_rot[0] = 0.0f;
8594 sceVu0CopyVector(world_pos, world_rot);
8595 sceVu0UnitMatrix(world_local);
8596 sceVu0UnitMatrix(local_world);
8598 script->
run(program);
8605 RunEvent(&EdEventScript, program, arena);
8608int EdResumeEvent() {
8614 EdEventScript.
skip();
8618int EdEventAllClear() {
8633 for (
int i = 0; i < EdEventInfo.
npc_count; i++) {
8648 for (
int i = 0; i <= 0; i++) {
8654 for (
int i = 45; i <= 49; i++) {
8655 TexManager.DeleteTextureBlock(i);
8658 for (
int i = 0; i < 10; i++) {
8665int EdEventFinish() {
8670 EdEventInfo.
wind[3] = -1.0f;
8674 if (shadow != NULL) {
8675 shadow->DeleteReference();
8693 if (DebugMode != 0 && GamePad.
Down(PAD_R3) != 0) {
8697 if (DebugMode != 0 && menu_mode ==
ED_MENU_NONE && GamePad.
Down(PAD_START) != 0) {
8698 if (EdCheckEventPause() == 0) {
8708 if (event_stop != 0) {
8709 static int mode = 0;
8710 static char *mode_name[] = {
"! CAMERA POS\n",
"# CAMERA REF\n",
"$ CHARACTER\n"};
8711 static int select_chara = -1;
8712 sceVu0FVECTOR position;
8713 sceVu0FVECTOR reference;
8715 sceVu0FVECTOR chara_position;
8716 sceVu0FVECTOR chara_rotation;
8723 if (select_chara >= 0) {
8727 camera->
GetPos(position);
8728 camera->
GetRef(reference);
8733 EdDMoveCamera(position, reference);
8734 camera->
SetPos(position);
8735 camera->
SetRef(reference);
8739 EdDMoveCameraRef(position, reference);
8740 camera->
SetPos(position);
8741 camera->
SetRef(reference);
8744 if (GamePad.
Down(PAD_RIGHT) != 0) {
8747 if (select_chara >= EdEventInfo.
npc_count) {
8752 if (GamePad.
Down(PAD_LEFT) != 0) {
8755 if (select_chara < -1) {
8756 select_chara = EdEventInfo.
npc_count - 1;
8760 if (select_chara == -1) {
8763 EdDMoveChara(&EdEventInfo.
npcs[select_chara], camera);
8766 if (GamePad.
Down(PAD_CROSS) != 0) {
8767 *collision = !*collision;
8773 EdDPrint(mode_name[mode]);
8776 if (select_chara >= 0) {
8777 chara = &EdEventInfo.
npcs[select_chara];
8782 GetLocalPos(chara_position, chara_position);
8783 GetLocalRot(chara_rotation, chara_rotation);
8784 sprintf(text,
"select chara %d\ncollision %d\n", select_chara, *collision);
8786 EdDPrintVector(
" pos = ", chara_position);
8787 EdDPrintVector(
" rot = ", chara_rotation);
8790 EdDPrint(
"camera\n");
8791 GetLocalPos(position, position);
8792 GetLocalPos(reference, reference);
8793 EdDPrintVector(
" pos = ", position);
8794 EdDPrintVector(
" ref = ", reference);
8796 chara_rotation[2] = 0.0f;
8797 chara_rotation[0] = 0.0f;
8798 chara_rotation[1] = angle;
8799 GetLocalRot(chara_rotation, chara_rotation);
8800 sprintf(text,
" angle = %4.3f\n", chara_rotation[1]);
8802 sprintf(text,
" height = %6.2f\n", position[1] - reference[1]);
8805 reference[1] = 0.0f;
8806 sprintf(text,
" distance = %6.2f\n", DistVector(position, reference));
8808 sprintf(text,
" projection = %7.1f\n", MGGetProjection());
8812 if (GamePad.
Down(PAD_SELECT) != 0) {
8816 if (GamePad.
Down(PAD_UP) != 0) {
8820 if (GamePad.
Down(PAD_DOWN) != 0) {
8843 if (event_pause != 0) {
8865 if (GamePad.
Down(PAD_CIRCLE) != 0) {
8875 if (motion_stop_flag != 0) {
8888 EdEventInfo.
camera = camera;
8894 for (
int i = 0; i < 8; i++) {
8895 if (EdEventInfo.
messages[i] != NULL) {
8900 if (SceneData.
frame != NULL) {
8911 menu_mode_status = -1;
8915 menu_mode_status = 0;
8917 if (EdInitMenu(menu_mode) == 0) {
8921 motion_stop_flag = 1;
8924 switch (menu_mode_status) {
8926 motion_stop_flag = 1;
8928 if (EdInitModeFinish(EdEventInfo.
camera, TexManager.GetTexture(
"frame_image", -1)) != 0) {
8929 menu_mode_status = 1;
8930 motion_stop_flag = 0;
8931 MenuMapJumpMode = -1;
8939 if (EdMenuMode() != 0) {
8940 switch (menu_mode) {
8943 int item = EdGetUseItem();
8945 if (p_use_item != NULL) {
8955 if (p_jump_map_no != 0) {
8956 ((
RS_STACKDATA *) p_jump_map_no)->i = MenuMapJumpMode + 1;
8972 for (
int i = 0; i < 10; i++) {
8976 for (
int i = 0; i < 16; i++) {
8977 ObjAnimePlay(&obj_anime[i]);
8996 if (camera != NULL) {
8997 if (follow_chara != NULL) {
8998 sceVu0FVECTOR position;
9003 if (sync_camera_ref_chara != NULL) {
9004 sceVu0FVECTOR reference = {0.0f, 0.0f, 0.0f, 1.0f};
9006 sceVu0AddVector(reference, reference, sync_camera_ref_offset);
9007 camera->
SetRef(reference[0], reference[1] + 0.8f * sync_camera_ref_chara->
body_height, reference[2]);
9010 if (sync_camera_ref_obj != NULL) {
9011 sceVu0FVECTOR reference;
9012 get_obj_world_pos(sync_camera_ref_obj, reference);
9013 sceVu0AddVector(reference, reference, sync_camera_ref_offset);
9014 camera->
SetRef(reference[0], reference[1], reference[2]);
9017 if (sync_camera_pos_obj != NULL) {
9018 sceVu0FVECTOR position;
9019 get_obj_world_pos(sync_camera_pos_obj, position);
9020 camera->
SetPos(position);
9024 if (result == 0 && EdEventScript.
IsEnd() != 0) {
9034int EdEventNPCStep() {
9047 for (
int i = 0; i < EdEventInfo.
npc_count; i++) {
9050 if (EdEventInfo.
npc_stop[i] == 0) {
9061 for (
int i = 0; i < EdEventInfo.
npc_count; i++) {
9064 if (EdEventInfo.
npc_stop[i] == 0) {
9072int EdEventSpriteDraw() {
9073 for (
int block = 45; block <= 49; block++) {
9074 int texture_loaded = 0;
9076 for (
int i = 0; i < 16; i++) {
9079 if (sprite == NULL) {
9091 screen.
x = (int) sprite->
x;
9092 screen.y = (int) sprite->
y;
9093 screen.width = sprite->
width;
9094 screen.height = sprite->
height;
9100 if (screen.width < 0) {
9101 screen.width = texel.width;
9104 if (screen.height < 0) {
9105 screen.height = texel.height;
9112 if (texture_loaded == 0) {
9113 TexManager.ReloadTexture(GetVif1Packet(), block);
9122 set2DSprite(GetVif1Packet(), &sprite->
texture, screen, texel, (u_char) sprite->
red, (u_char) sprite->
green, (u_char) sprite->
blue, (u_char) sprite->
alpha);
9124 set2DSpriteRot(GetVif1Packet(), &sprite->
texture, screen, texel, sprite->
rotation_x, sprite->
rotation_y, sprite->
rotation, (u_char) sprite->
red, (u_char) sprite->
green, (u_char) sprite->
blue, (u_char) sprite->
alpha);
9129 TexManager.ReloadTexture(GetVif1Packet(), 45);
9134int EdEventBackSpriteDraw() {
9135 TexManager.ReloadTexture(GetVif1Packet(), 46);
9141 sceVu0FVECTOR direction;
9142 sceVu0FVECTOR character_rotation;
9143 sceVu0FVECTOR npc_rotation;
9144 sceVu0FVECTOR character_position;
9145 sceVu0FVECTOR npc_position;
9148 float nearest_distance = 0.0f;
9151 for (i = 0; i < count; i++) {
9152 if (npcs[i].villager_id < 0) {
9165 float height = character_position[1] - npc_position[1];
9167 if (height < 0.0f) {
9177 npc_position[1] = 0.0f;
9178 character_position[1] = 0.0f;
9179 float distance = DistVector(character_position, npc_position);
9181 if (distance > 5.0f + 1.2f * npcs[i].body_width) {
9185 character->
GetDir(npcs[i], direction);
9186 float character_angle = atan2f(direction[0], direction[2]);
9187 npcs[i].
GetDir(*character, direction);
9188 float npc_angle = atan2f(direction[0], direction[2]);
9192 if (AngleCmp(npc_angle, npc_rotation[1], HALF_PI_SHORT) != 0 && talk_direction == 0 && npcs[i].event_status == 0) {
9197 nearest_distance = distance;
9199 }
else if (distance < nearest_distance) {
9200 nearest_distance = distance;
9212static int talk_chara_info_id;
9215static int talk_camera;
9218static int talk_mode;
9221static int talk_select;
9224static int TalkMesMake;
9227static int TalkMesNo;
9229int EdTalkModeInit(
CNPCharacter *villager,
int character_info_id) {
9234 talk_villager__2 = villager;
9236 if (character_info_id < 0) {
9239 talk_chara_info_id = character_info_id;
9242 talk_mode = TALK_MODE_SELECT;
9248 talk_camera = rand() % 3;
9252 EdEventInfo.
talk_npc_id = (villager - EdVillager);
9258 return talk_villager__2;
9261int EdNowTalkCharaInfoID() {
9262 return talk_chara_info_id;
9268static inline void EdCloseTalkMes() {
9277 EditMes1.
fade = 0.0f;
9293 for (
int i = 0; i < 10; i++) {
9297 for (
int i = 0; i < 8; i++) {
9311 for (
int i = 0; i < 10; i++) {
9328 static sceVu0FVECTOR vv[3] = {
9329 {-18.8f, 7.1f, -21.3f, 1.0f},
9330 {21.0f, 6.5f, -5.7f, 1.0f},
9331 {22.6f, 6.9f, 16.5f, 1.0f},
9337 if (camera != NULL) {
9345 sceVu0FVECTOR player_position;
9346 sceVu0FVECTOR villager_position;
9347 sceVu0FVECTOR player_rotation;
9348 sceVu0FVECTOR villager_rotation;
9349 sceVu0FVECTOR direction;
9354 sceVu0SubVector(direction, villager_position, player_position);
9355 float player_yaw = atan2f(direction[0], direction[2]);
9356 float villager_yaw = atan2f(-direction[0], -direction[2]);
9357 player_rotation[1] = AngleInterpolate(player_rotation[1], player_yaw, 0.1f,
INTERPOLATE_STEP);
9359 villager_rotation[1] = AngleInterpolate(villager_rotation[1], villager_yaw, 0.1f,
INTERPOLATE_STEP);
9365 sceVu0FVECTOR reference;
9366 sceVu0AddVector(reference, player_position, villager_position);
9367 sceVu0ScaleVector(reference, reference, 0.5f);
9368 reference[1] += 15.0f;
9370 if (camera != NULL) {
9372 camera->
SetRef(reference);
9375 sceVu0FVECTOR camera_position;
9376 sceVu0FMATRIX rotation;
9377 sceVu0UnitMatrix(rotation);
9378 sceVu0RotMatrixY(rotation, rotation, player_yaw);
9379 sceVu0ApplyMatrix(camera_position, rotation, vv[talk_camera]);
9380 sceVu0AddVector(camera_position, reference, camera_position);
9382 if (camera != NULL) {
9383 camera->
SetPos(camera_position);
9386 if (camera != NULL) {
9391 MGSetViewMatrix(view, eye);
9395 talk_mode = TALK_MODE_MESSAGE;
9401 int choice_count = 0;
9413 switch (talk_mode) {
9414 case TALK_MODE_MESSAGE:
9415 if (GamePad.
Down(PAD_CIRCLE | PAD_CROSS) != 0) {
9416 if (EditMes1.
State() == CLSMES_SHOWN) {
9419 if (camera != NULL) {
9429 if (EditMes1.
State() == CLSMES_PAGE_WAIT) {
9439 case TALK_MODE_SELECT:
9440 if (GamePad.
Down(PAD_UP) != 0) {
9443 if (talk_select < 0) {
9444 talk_select = choice_count - 1;
9448 if (GamePad.
Down(PAD_DOWN) != 0) {
9451 if (talk_select > choice_count - 1) {
9456 if (GamePad.
Down(PAD_CROSS) != 0) {
9457 if (EditMes1.
State() == CLSMES_SHOWN) {
9458 talk_mode = TALK_MODE_MESSAGE;
9473 if (camera != NULL) {
9484 if (talk_select == 1) {
9488 if (talk_select == 2) {
9492 if (talk_select == 3) {
9496 if (talk_select == 4) {
9512 if (selection != NULL) {
9526 if (GamePad.
Down(PAD_CIRCLE) != 0) {
9531 if (camera != NULL) {
9544 int talk_position[4];
9546 if (talk_mode == TALK_MODE_SELECT) {
9549 EditMes1.
auto_pos = MES_POS_BOTTOM;
9552 EditMes1.
AutoSetSub(player, villager, talk_position);
9553 EditMes1.
AutoSet(talk_position);
9557 EditMes1.
AutoSetSub(villager, player, talk_position);
9558 EditMes1.
AutoSet(talk_position);
9561 switch (talk_mode) {
9562 case TALK_MODE_SELECT:
9563 if (TalkMesMake != 0) {
9565 TalkMesMake = EditMes1.
MakeMesWin(TalkMesNo);
9569 case TALK_MODE_MESSAGE:
9570 if (TalkMesMake != 0) {
9571 TalkMesMake = EditMes1.
MakeMesWin(TalkMesNo);
9588 if (info->
stock <= 0) {
void SetDelayRot(int delay)
void MotionSeq(int motion, int mode, float speed, int flags)
void Initialize(ACT_SEQ *records, int count)
void SyncChara(CCharacter *target)
void RotAngleSeq(float angle, float speed)
void SetPos(float *destination)
void SetRot(float *angles)
void AnimeSeq(int animation, int enabled, int frames, int disable_after)
void MoveSeq(float *destination, int frames)
void RotMoveSeq(float speed)
void MotionTrg(int delay)
void RotRefSeq(float *reference, float speed)
void SetHeight(float height)
void AddDistance(float delta)
void SetFollow(float x, float y, float z)
void SetAngleSoon(float angle)
void AddAngle(float delta)
void SetDistance(float distance)
virtual void Step(int steps)
void SetAngle(float angle)
void AddHeight(float delta)
void SetNextRef(CFrame *parent, float x, float y, float z)
void GetCameraMatrix(float(*matrix)[4])
void SetRef(CFrame *parent, float x, float y, float z)
void SetPos(CFrame *parent, float x, float y, float z)
void SetSpeed(float speed)
void SetNextPos(CFrame *parent, float x, float y, float z)
void SetMotion(int no, int mode, float speed=-1.0f)
virtual void GetPosition(float *out_position)
virtual void LoadPackData2(unsigned int *pack, char *name, CDataAlloc2< 1 > *alloc, int texture_block_no, CDataAlloc2< 1 > *image_alloc, int visual_type)
void DeleteExtendMotion()
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
virtual void SetScale(float x, float y, float z)
void InitializeTexAnime(CTexAnimeData *data, int count)
void SetFootSoundID(int id)
void SetMotionCamera(CCamera *camera)
sceVu0FVECTOR ambient_offset
void SetMotionSpeed(float speed)
virtual void ShadowStep()
tagMOTION_TYPE motion_type
static s32 MotionStopFlag
virtual void SetRotation(float x, float y, float z)
void FootSoundEnable(int on)
virtual void ClothFloor(int floor)
void DeleteExtendTexture(int block_no)
virtual void Initialize()
virtual void SetPosition(float x, float y, float z)
virtual int PickUpPoly(float *position, CCPoly *polygons)
int SetPointLight(float *pos, float inner_range, float outer_range, float red, float green, float blue, float alpha)
virtual void ClothStep(int step)
int LostItem(int item_id)
void SetPartySize(s8 size)
float GetAlt(float x, float y, float z)
int GetAreaCode(float x, float y, float z)
CMapParts * GetParts(float x, float y, float z)
void GetPartsBox(CBoxVu0 *out_box, float x, float y, float z)
int PickUpPoly(CCPoly *polygons, float x, float y, float z)
CMapParts * GetPartsObject(int parts_no)
int GetRandomPlanePos(sceVu0FVECTOR out_position, sceVu0FVECTOR avoid[], int avoid_count, sceVu0FVECTOR bounds)
CGroundWater water_surfaces[4]
EPARTS_FUNC_DATA * GetPeoplePos(int villager, float *out_position)
int PickUpEditAreaPoly(CCPoly *polygons, float x, float y, float z)
int GetCompEvent(int index)
int GetRequest(int index)
int CheckComplete(int index)
void SetCompEvent(int index, int completed)
EDITPARTS_INFO * GetPartsInfo(int index)
void MenuModeOn(int threshold)
CFrame * GetCollisionFrame()
virtual void SetPosition(float *position)
virtual void SetRotation(float x, float y, float z)
virtual void FrameObjectOnOff(char *name, int on)
void GetPosition(float *out_position)
int SetSeq(float *destination, float speed)
virtual void Initialize()
virtual void ShadowStep()
virtual void GetRotation(float *out_rotation)
virtual void GetScale(float *out_scale)
virtual void SetScale(float x, float y, float z)
void GetDir(CObject &other, float *out_direction)
virtual void SetVelocity(CVector3_f_ velocity)
void reload(RS_PROG_HEADER *prog)
void ext_func(int(**table)(RS_STACKDATA *, int), int count)
void load(RS_PROG_HEADER *prog, RS_STACKDATA *stack, int stack_num, RS_CALLDATA *call, int call_num)
SV_GRD_NPC * GetGrdNPCData(int map_no, int npc_no)
CDngStatusData * GetDngStatus()
void SetNowTime(float time)
int QuestDungeon(int dungeon_no, int add)
int GetGameFlag(int flag_no)
int SetGameFlag(int flag_no, int value)
int GetGameIntFlag(int flag_no)
int VisitMap(int map_no, int add)
void AddNowTime(float add)
SV_GEORAMA_DATA * GetGrdData(int georama_no)
SV_EDIT_PARTS_INFO * GetEditPartsInfo(int georama_no, int plot_no)
int AtraPartsGet(int georama_no, int plot_no)
int SetGameIntFlag(int flag_no, int value)
int AtraChipGet(int georama_no, int chip_id)
void AddTable(int x, int y, MG_SPRITE *sprite, int layer, int align_flags)
void Initialize(SPRITE_TABLE *new_pool, int entry_count, int layer_count)
WEAPON_HAVE chara_weapons[6][11]
s8 equipped_weapon_slot[6]
void AutoSetSub(CCharacter *first, CCharacter *second, int *out_pos)
void SetBuff(short *buff)
void SetMesFukidashi(int style)
MES_LINE_POS line_pos[10]
int MakeMesWin(int mes_no)
CDataAlloc2< 1 > * WorkBuffer__2
@ ED_EVENT_RETURN_FISHING
@ ED_EVENT_RETURN_MAP_JUMP
@ ED_EVENT_RETURN_INTERIOR
@ ED_EVENT_RETURN_OUTSIDE
@ ED_MENU_FISHING_EXCHANGE
@ MAP_PARTS_SUBTYPE_BRIDGE
ACT_SEQ_OPERATION operation
EDITPARTS_ELEMENT elements[6]
EDIT_AREA_RECT_INFO edit_area_rects[8]
float background_colour[12][4]
int time_tables[7][12][16]
float background_colour_2[12][4]
float light_colour[12][4][4]
float light_direction[12][4][4]
VILLAGER_INFO villagers[16]
int(* function)(RS_STACKDATA *, int)
sceVu0FMATRIX light_color
CMapParts * interior_parts
s32 main_texture_animation_count
sceVu0FVECTOR screen_filter_color
float background_color[3]
CTexAnimeData * main_texture_animation
s32 draw_exclamation_mark
CCharacter * main_character
CFrameVu1 * item_frame[1]
VILLAGER_INFO * villagers
sceVu0FVECTOR vector_arguments[4]
sceVu0FMATRIX light_direction
CEditGround * edit_ground
sceVu0FVECTOR ambient_color
C3DSprite * system_effect
char element_name[6][0x20]
ED_EVENT_POINT points[256]