From 3ce301ad0d7e7565192eebf9ff254f490a890f39 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Fri, 10 Jun 2022 18:20:00 +0100 Subject: [PATCH] some `static-screen` decomp fixes (#1435) * some decomp fixes * memcard robustness * fix wrong bank in savefile being picked * wtf??? * remove deleted memcard code --- decompiler/config/all-types.gc | 7 +- game/kernel/kmemcard.cpp | 995 +----------------- goal_src/engine/collide/collide-shape.gc | 279 ++--- goal_src/engine/gfx/texture.gc | 265 ++--- goal_src/engine/gfx/vis/bsp-h.gc | 16 +- goal_src/engine/gfx/vis/bsp.gc | 12 +- .../engine/sparticle/sparticle-launcher-h.gc | 2 +- goal_src/levels/demo/demo-obs.gc | 223 +++- goal_src/levels/demo/static-screen.gc | 21 +- goal_src/levels/title/title-obs.gc | 12 +- .../reference/levels/demo/demo-obs_REF.gc | 221 +++- .../levels/demo/static-screen_REF.gc | 25 +- .../reference/levels/title/title-obs_REF.gc | 12 +- 13 files changed, 710 insertions(+), 1380 deletions(-) diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index dc17fed786..bbbb33e915 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -14637,7 +14637,7 @@ (random-mult int32 :offset 12) (sym symbol :offset 4) ;; moved (func symbol :offset 4) - (tex uint32 :offset 4) + (tex texture-id :offset 4) (pntr pointer :offset 4) ;; sym used to be here (sound sound-spec :offset 4) @@ -25978,7 +25978,8 @@ ;; - Functions -(define-extern static-screen-spawn (function int int int int int symbol target (pointer process))) ;; target may differ +(declare-type static-screen process) +(define-extern static-screen-spawn (function int texture-id texture-id texture-id time-frame symbol process-tree (pointer static-screen))) ;; ---------------------- @@ -26004,7 +26005,7 @@ ;; - Functions -(define-extern static-screen-init-by-other (function int int int int time-frame symbol none :behavior static-screen)) +(define-extern static-screen-init-by-other (function int texture-id texture-id texture-id time-frame symbol none :behavior static-screen)) ;; ---------------------- diff --git a/game/kernel/kmemcard.cpp b/game/kernel/kmemcard.cpp index 6cc253f98f..4885b16e3d 100644 --- a/game/kernel/kmemcard.cpp +++ b/game/kernel/kmemcard.cpp @@ -26,16 +26,12 @@ using McCallbackFunc = void (*)(s32); McCallbackFunc callback; -// static s32 next; static s32 language; static MemoryCardOperation op; -// static MemoryCard mc[2]; // instead of two memory cards we just simulate the 4 save files (8 banks). static MemoryCardFile mc_files[4]; // keep track of latest file selected. this is only used in an auto-save mode thats not used static int mc_last_file = -1; -// static RPC_Ramdisk_LoadCmd ramdisk_cmd; -// static ee::sceMcTblGetDir dirent; // a random value we will use as the memory card "handle" for the pc port, which has no memcards. constexpr u32 PC_MEM_CARD_HANDLE = 0x6C616F67; @@ -59,34 +55,6 @@ static McHeader header; static s32 p1, p2, p3, p4; using namespace ee; -// void cb_reprobe_format(s32); -// void cb_format_complete(s32); -// void cb_unformat(s32); -// void cb_reprobe_createfile(s32); -// void cb_wait_for_ramdisk(s32); -// void cb_wait_for_ramdisk_load(s32); -// void cb_createfile_erasing(s32); -// void cb_createdir(s32); -// void cb_createdfile(s32); -// void cb_writtenfile(s32); -// void cb_closedfile(s32); -// void cb_reprobe_save(s32); -// void cb_reprobe_load(s32); -// void cb_probe(s32); -// void cb_reprobe(s32); -// void cb_getdir(s32); -// void cb_check_open(s32); -// void cb_check_read(s32); -// void cb_check_close(s32); -// void cb_openedsave(s32); -// void cb_savedheader(s32); -// void cb_saveddata(s32); -// void cb_savedfooter(s32); -// void cb_closedsave(s32); -// void cb_openedload(s32); -// void cb_readload(s32); -// void cb_closedload(s32); - template void mc_print(const std::string& str, Args&&... args) { if (memcard_debug) { @@ -126,23 +94,6 @@ void kmemcard_init_globals() { memset(&header, 0, sizeof(McHeader)); } -/*! - * Get a new memory card handle. - * Will never return 0. - * A handle is a unique integer that can be passed up to the GOAL game code and represents a - * specific memory card. If the card is removed, the handle will become invalid. - */ -// s32 new_mc_handle() { -// s32 handle = next++; -// -// // if you wrap around, it avoids the zero handle. -// // it doesn't seem like you will need billions of memory card handles -// if (handle == 0) { -// handle = next++; -// } -// return handle; -//} - /*! * A questionable checksum used on memory card data. */ @@ -160,32 +111,17 @@ u32 mc_checksum(Ptr data, s32 size) { return result ^ 0xedd1e666; } -/*! - * Get the slot for a handle. The card must be in the given state. - * Return -1 if it fails. - * There are no slots in the port. This function should not be used. - */ -// s32 handle_to_slot(u32 handle, MemoryCardState state) { -// if (mc[0].state == state && mc[0].handle == handle) { -// return 0; -// } -// if (mc[1].state == state && mc[0].handle == handle) { -// return 1; -// } else { -// return -1; -// } -//} - /*! * PC port function that returns whether a given bank ID's file exists or not. */ bool file_is_present(int id, int bank = 0) { auto bankname = file_util::get_user_memcard_dir() / filename[4 + id * 2 + bank]; - if (!std::filesystem::exists(bankname)) { - // file doesn't exist... + if (!std::filesystem::exists(bankname) || + std::filesystem::file_size(bankname) < BANK_TOTAL_SIZE) { + // file doesn't exist, or size is bad. we do not want to open files that will crash on read! return false; } - // avoid file check tbh. there shouldn't be any saves with a save count of zero anyway. + // avoid file check here tbh. there shouldn't be any saves with a save count of zero anyway. // the file check is quite slow and ultimately not very useful. return true; @@ -218,7 +154,7 @@ void pc_update_card() { if (file_is_present(file, 1)) { auto bankname2 = file_util::get_user_memcard_dir() / filename[1 + 4 + file * 2]; auto bankdata2 = file_util::read_binary_file(bankname2.string()); - auto header2 = reinterpret_cast(bankdata.data()); + auto header2 = reinterpret_cast(bankdata2.data()); if (header2->save_count > header1->save_count) { // use most recent bank here. @@ -278,7 +214,7 @@ void pc_game_save_synch() { auto save_path = file_util::get_user_memcard_dir() / filename[op.param2 * 2 + 4 + p4]; file_util::create_dir_if_needed_for_file(save_path.string()); auto fd = fopen(save_path.string().c_str(), "wb"); - fmt::print("[MC] synchronous save file open took {:.2f}ms\n", mc_timer.getMs()); + mc_print("synchronous save file open took {:.2f}ms\n", mc_timer.getMs()); if (fd) { // cb_openedsave // mc_print("save file opened, writing header..."); @@ -331,7 +267,7 @@ void pc_game_save_synch() { op.result = McStatusCode::INTERNAL_ERROR; } - fmt::print("[MC] synchronous save took {:.2f}ms\n", mc_timer.getMs()); + mc_print("[MC] synchronous save took {:.2f}ms\n", mc_timer.getMs()); } void pc_game_load_open_file(FILE* fd) { @@ -470,7 +406,7 @@ void pc_game_load_synch() { auto fd = fopen(path.string().c_str(), "rb"); pc_game_load_open_file(fd); - fmt::print("[MC] synchronous load took {:.2f}ms\n", mc_timer.getMs()); + mc_print("synchronous load took {:.2f}ms\n", mc_timer.getMs()); } /*! @@ -515,70 +451,13 @@ void MC_run() { if (op.operation == MemoryCardOperationKind::FORMAT) { // format memory card. Not used in PC port, so lets move on. return; - /* - mc_print("begin format operation"); - // grab the slot. should be open, but not formatted - p1 = handle_to_slot(op.param, MemoryCardState::OPEN_BUT_UNFORMATTED); - if (p1 == -1) { - // no slot in the right state. - op.operation = MemoryCardOperationKind::NO_OP; - op.result = McStatusCode::BAD_HANDLE; - } else { - // do a getInfo - s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); - if (info_result == sceMcResSucceed) { - callback = cb_reprobe_format; - } - // allow some number of errors. - op.retry_count--; - if (op.retry_count == 0) { - op.operation = MemoryCardOperationKind::NO_OP; - op.result = McStatusCode::INTERNAL_ERROR; - } - } */ } else if (op.operation == MemoryCardOperationKind::UNFORMAT) { // unformat memory card. return; - /* - mc_print("begin unformat operation"); - p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); - if (p1 == -1) { - op.operation = MemoryCardOperationKind::NO_OP; - op.result = McStatusCode::BAD_HANDLE; - } else { - s32 rv = sceMcUnformat(p1, 0); - if (rv == sceMcResSucceed) { - callback = cb_unformat; - } - op.retry_count--; - if (op.retry_count == 0) { - op.operation = MemoryCardOperationKind::NO_OP; - op.result = McStatusCode::INTERNAL_ERROR; - } - } - */ } else if (op.operation == MemoryCardOperationKind::CREATE_FILE) { // create the game file. // there's no cards, keep in mind. return; - /* - mc_print("begin create file operation"); - p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); - if (p1 == -1) { - op.operation = MemoryCardOperationKind::NO_OP; - op.result = McStatusCode::BAD_HANDLE; - } else { - s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); - if (info_result == sceMcResSucceed) { - callback = cb_reprobe_createfile; - } - // allow some number of errors. - op.retry_count--; - if (op.retry_count == 0) { - op.operation = MemoryCardOperationKind::NO_OP; - op.result = McStatusCode::INTERNAL_ERROR; - } - } */ } else if (op.operation == MemoryCardOperationKind::SAVE) { // write game save. // there's no cards, keep in mind. @@ -589,22 +468,6 @@ void MC_run() { op.operation = MemoryCardOperationKind::NO_OP; op.result = McStatusCode::INTERNAL_ERROR; } - // p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); - // if (p1 == -1) { - // op.operation = MemoryCardOperationKind::NO_OP; - // op.result = McStatusCode::BAD_HANDLE; - //} else { - // s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); - // if (info_result == sceMcResSucceed) { - // callback = cb_reprobe_save; - // } - // // allow some number of errors. - // op.retry_count--; - // if (op.retry_count == 0) { - // op.operation = MemoryCardOperationKind::NO_OP; - // op.result = McStatusCode::INTERNAL_ERROR; - // } - //} } else if (op.operation == MemoryCardOperationKind::LOAD) { // load game save. // potato. @@ -620,81 +483,7 @@ void MC_run() { op.result = McStatusCode::INTERNAL_ERROR; } } - // mc_print("begin load operation"); - // p1 = handle_to_slot(op.param, MemoryCardState::FORMATTED); - // if (p1 == -1) { - // op.operation = MemoryCardOperationKind::NO_OP; - // op.result = McStatusCode::BAD_HANDLE; - //} else { - // if (!mc[p1].files[op.param2].present) { - // // tried to load, but there's no save data in the file. - // op.operation = MemoryCardOperationKind::NO_OP; - // op.result = McStatusCode::NO_MEMORY; - // } else { - // s32 info_result = sceMcGetInfo(p1, 0, &p2, &p3, &p4); - // if (info_result == sceMcResSucceed) { - // callback = cb_reprobe_load; - // } - // op.retry_count--; - // if (op.retry_count == 0) { - // op.operation = MemoryCardOperationKind::NO_OP; - // op.result = McStatusCode::INTERNAL_ERROR; - // } - // } - //} - // below here is just doing maintenance to look for new/removed memory cards. - // it's cut from the port. we do not use memory cards. just raw saves. - } /* else if (mc[0].state == MemoryCardState::UNKNOWN) { - mc_print("begin probe operation for slot 0"); - // don't know anything about port 0, try and see - p1 = 0; - if (sceMcGetInfo(0, 0, &p2, &p3, &p4) == sceMcResSucceed) { - callback = cb_probe; - } - } else if (mc[1].state == MemoryCardState::UNKNOWN) { - mc_print("begin probe operation for slot 1"); - // don't know anything about port 1, try and see - p1 = 1; - if (sceMcGetInfo(1, 0, &p2, &p3, &p4) == sceMcResSucceed) { - callback = cb_probe; - } - } else if (mc[0].state == MemoryCardState::KNOWN) { - if (mc[0].countdown_to_check == 1) { - // we're about to recheck the memory card. If we're only inknown, reset to unknown so we do a - // completely fresh probe instead of a reprobe. - mc[0].state = MemoryCardState::UNKNOWN; - } - } else if (mc[0].countdown_to_check == 1) { - // it's been a while, do a check and see if the memory card is still there. - p1 = 0; - mc[0].countdown_to_check--; - mc_print("begin reprobe operation for slot 0"); - if (sceMcGetInfo(0, 0, &p2, &p3, &p4) == sceMcResSucceed) { - callback = cb_reprobe; - } - return; - } else { - // decrement port 0's countdown - mc[0].countdown_to_check--; - - // do the same thing for port 1 - if (mc[1].state == MemoryCardState::KNOWN) { - mc[1].countdown_to_check--; - if (mc[1].countdown_to_check == 0) { - // hack - will make us do a probe next time we get here. - mc[1].state = MemoryCardState::UNKNOWN; - } - } else { - mc[1].countdown_to_check--; - if (mc[1].countdown_to_check == 0) { - p1 = 1; - mc_print("begin probe operation for slot 0"); - if (sceMcGetInfo(1, 0, &p2, &p3, &p4) == sceMcResSucceed) { - callback = cb_reprobe; - } - } - } - }*/ + } } ///////////////////////// @@ -881,770 +670,4 @@ void MC_get_status(s32 /*slot*/, Ptr info) { } } info->last_file = mc_last_file; - - /* - switch (mc[slot].state) { - case MemoryCardState::KNOWN: - info->known = 1; - break; - case MemoryCardState::OPEN_BUT_UNFORMATTED: - info->known = 1; - info->handle = mc[slot].handle; - break; - case MemoryCardState::FORMATTED: - info->known = 1; - info->handle = mc[slot].handle; - info->formatted = 1; - if (mc[slot].inited == 0) { - info->mem_actual = mc[slot].mem_size; - } else { - info->initted = 1; - // copy over the preview data. - for (s32 file = 0; file < 4; file++) { - info->files[file].present = mc[slot].files[file].present; - for (s32 i = 0; i < 64; i++) { // actually a loop over u32's - info->files[file].data[i] = mc[slot].files[file].data[i]; - } - } - info->last_file = mc[slot].last_file; - } - break; - case MemoryCardState::UNKNOWN: - break; - }*/ } - -/*! - * Check for an error. Returns true if there is an error and sets op.result as needed - */ -// u64 cb_check(s32 sony_error, McStatusCode goal_error) { -// if (sony_error < 0) { -// // sony thing failed. -// if (sony_error < -9) { -// // memory card gone. reset state -// mc[p1].state = MemoryCardState::UNKNOWN; -// // kill in progress op -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::BAD_HANDLE; -// return 1; -// } else { -// // return the given GOAL error. -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = goal_error; -// return 1; -// } -// } -// return 0; -//} - -/*! - * Is this sync-result an error? If so, set status to unknown. - */ -// bool cb_pcheck(s32 sync_result) { -// if (sync_result < 0) { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// return sync_result < 0; -//} - -/*! - * Callback for sceMcGetInfo for the first time (assumes nothing about the card) - * Cut. We don't use memory cards. - */ -// void cb_probe(s32 sync_result) { -// if (sync_result < -9) { -// // changed card. We have the card, but we don't know anything about it. -// mc[p1].state = MemoryCardState::KNOWN; -// mc[p1].countdown_to_check = 100; -// mc_print("probe: bad sync, trying again in a bit"); -// } else { -// // there is a memory card. -// if (p2 == sceMcTypePS2) { -// // it is the right type. -// // create a new handle -// mc[p1].handle = new_mc_handle(); -// if (p4 == 0) { -// mc_print("probe: got a card, but it's not formatted"); -// // it's not formatted. But open (we have a handle) -// mc[p1].state = MemoryCardState::OPEN_BUT_UNFORMATTED; -// mc[p1].countdown_to_check = 100; -// } else { -// mc_print("probe: got a formatted card, trying getdir"); -// // it's formatted. Get the size -// mc[p1].mem_size = p3; -// p2 = 0; -// -// // and get our jak and daxter directory -// if (sceMcGetDir(p1, 0, filename[0], 0, 1, &dirent) == sceMcResSucceed) { -// callback = cb_getdir; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// } -// -// } else { -// mc_print("probe: bad card type, trying again in a bit"); -// mc[p1].state = MemoryCardState::KNOWN; -// mc[p1].countdown_to_check = 100; -// } -// } -//} - -/*! - * Callback for sceMcGetDir. This runs again and again to check all files - */ -// void cb_getdir(s32 sync_result) { -// // called after sceMcGetDir -// if (sync_result == 0) { -// // didn't find the jak and daxter dir, or some stuff is missing. -// // call this uninitialized. -// mc[p1].inited = false; -// mc[p1].state = MemoryCardState::FORMATTED; -// mc[p1].countdown_to_check = 100; -// mc[p1].last_file = -1; -// } else if (sync_result == 1) { -// // found whatever we were looking for -// p2++; -// if (p2 == 12) { -// // all done checking for files. -// mc[p1].inited = true; -// mc[p1].countdown_to_check = 100; -// mc[p1].last_file = -1; -// for (int i = 0; i < 4; i++) { -// mc[p1].files[i].present = 0; -// } -// -// // now open file 4, which is the first bank. -// p2 = 4; -// mc_print("opening first bank..."); -// if (sceMcOpen(p1, 0, filename[4], 1) == sceMcResSucceed) { -// callback = cb_check_open; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// } else { -// // still checking files, check the next one. -// mc_print("checking {}", filename[p2]); -// if (sceMcGetDir(p1, 0, filename[p2], 0, 1, &dirent) == sceMcResSucceed) { -// callback = cb_getdir; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// } -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -//} - -/*! - * Callback for sceMcOpen for opening bank files. - */ -// void cb_check_open(s32 sync_result) { -// if (!cb_pcheck(sync_result)) { -// p3 = sync_result; -// // read the header. -// mc_print("read header"); -// if (sceMcRead(sync_result, &header, sizeof(McHeader)) == sceMcResSucceed) { -// callback = cb_check_read; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// } -//} - -/*! - * Callback for sceMcRead for reading the header of a bank file. - */ -// void cb_check_read(s32 sync_result) { -// if (!cb_pcheck(sync_result)) { -// if (header.save_count != 0 && // we've saved into this bank -// header.magic == MEM_CARD_MAGIC // looks valid -// ) { -// // each file has two banks. so if you corrupt a save, you hopefully have the other bank. -// // get the file that goes with this bank -// s32 file_idx = (p2 - 4) / 2; -// if (mc_files[file_idx].present == 0 || // haven't found any banks for this file -// header.save_count > mc_files[file_idx].most_recent_save_count // newer than prev. -// ) { -// // this is so far our best guess at the right bank to use. -// mc_files[file_idx].present = 1; -// mc_files[file_idx].most_recent_save_count = header.save_count; -// mc_files[file_idx].last_saved_bank = p2 & 1; -// // copy header data (for GOAL to read) -// for (int i = 0; i < 64; i++) { -// mc_files[file_idx].data[i] = header.preview_data[i]; -// } -// } -// } -// -// if (sceMcClose(p3) == sceMcResSucceed) { -// // close the file -// callback = cb_check_close; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// } -//} - -/*! - * Callback for closing a file after reading the header - */ -// void cb_check_close(s32 sync_result) { -// if (!cb_pcheck(sync_result)) { -// // next bank. -// p2++; -// if (p2 == 12) { -// // done with banks -// mc[p1].state = MemoryCardState::FORMATTED; -// // and we're done! -// } else { -// // on to the next bank... -// if (sceMcOpen(p1, 0, filename[p2], 1) == sceMcResSucceed) { -// callback = cb_check_open; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -// } -// } -//} - -/*! - * Callback for checking on a known memory card. If it is swapped, will reset. - */ -// void cb_reprobe(s32 sync_result) { -// if (sync_result == sceMcResSucceed) { -// // nobody took out the memory card. try again in 100 frames -// mc[p1].countdown_to_check = 100; -// } else { -// // somebody took it out. reset everything! -// mc[p1].state = MemoryCardState::UNKNOWN; -// } -//} - -/*! - * Callback for probe before formatting. - */ -// void cb_reprobe_format(s32 sync_result) { -// if (sync_result == sceMcResSucceed) { -// // get info succeeded. we can format. -// s32 format_result = sceMcFormat(p1, 0); -// if (format_result == sceMcResSucceed) { -// callback = cb_format_complete; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // get info failed. Revert the state to unknown, this will restart everything. -// mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::BAD_HANDLE; -// } -//} - -/*! - * Callback for actual formatting operation - */ -// void cb_format_complete(s32 sync_result) { -// if (sync_result == sceMcResSucceed) { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::OK; -// mc[p1].state = MemoryCardState::FORMATTED; -// mc[p1].countdown_to_check = 100; -// mc[p1].inited = 0; -// for (int i = 0; i < 4; i++) { -// mc[p1].files[i].present = 0; -// } -// mc[p1].last_file = -1; -// mc[p1].mem_size = 8000; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::FORMAT_FAILED; -// } -//} - -/*! - * Callback for actual unformatting operation - */ -// void cb_unformat(s32 sync_result) { -// if (sync_result == sceMcResSucceed) { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::OK; -// mc[p1].state = MemoryCardState::UNKNOWN; -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::FORMAT_FAILED; -// } -//} - -/*! - * Callback for probe before creating save files. - */ -// void cb_reprobe_createfile(s32 sync_result) { -// if (sync_result == sceMcResSucceed) { -// // if the ramdisk is ready, just jump directly to its callback -// if (!RpcBusy(RAMDISK_RPC_CHANNEL)) { -// cb_wait_for_ramdisk(0); -// } else { -// // I think this is a typo and should be cb_reprobe_createfile again. -// callback = cb_wait_for_ramdisk; -// } -// } else { -// mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::BAD_HANDLE; -// } -//} - -/*! - * Actually start the ramdisk load of the icon file to temp buffer - */ -// void cb_wait_for_ramdisk(s32) { -// ramdisk_cmd.pad = 0; -// // caller should have given us a temporary buffer. -// ramdisk_cmd.file_id_or_ee_addr = op.data_ptr.offset; -// ramdisk_cmd.offset_into_file = 0; -// ramdisk_cmd.size = 0x1e800; -// memcpy(ramdisk_cmd.name, "SAVEGAME.ICO", 13); // was 16. -// RpcCall(RAMDISK_RPC_CHANNEL, RAMDISK_BYPASS_LOAD_FILE, 1, &ramdisk_cmd, 0x20, nullptr, 0); -// callback = cb_wait_for_ramdisk_load; -//} - -/*! - * Callback for checking if the ramdisk load is done - */ -// void cb_wait_for_ramdisk_load(s32) { -// if (RpcBusy(RAMDISK_RPC_CHANNEL) == 0) { -// // ramdisk is done. start deleting 12 files -// p2 = 11; // filenames left to delete -// mc_print("start delete {}", filename[11]); -// if (sceMcDelete(p1, 0, filename[11]) == sceMcResSucceed) { -// callback = cb_createfile_erasing; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // still waiting... -// callback = cb_wait_for_ramdisk_load; -// } -//} - -/*! - * Callback to start erasing previous save files. - */ -// void cb_createfile_erasing(s32 sync_result) { -// if (sync_result == sceMcResSucceed || sync_result == sceMcResNoEntry || -// sync_result == sceMcResNotEmpty) { -// mc[p1].inited = 0; -// // delete didn't fail. -// if (p2 < 1) { -// // on the last one. move on on to creating the directory again. -// mc_print("create dir {}", filename[0]); -// if (sceMcMkdir(p1, 0, filename[0]) == sceMcResSucceed) { -// callback = cb_createdir; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// p2--; -// mc_print("delete next {}", filename[p2]); -// if (sceMcDelete(p1, 0, filename[p2]) == sceMcResSucceed) { -// callback = cb_createfile_erasing; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -// } else { -// if (sync_result == sceMcResDeniedPermit) { -// mc_print("erasing: denied"); -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } else { -// mc_print("erasing: other bad"); -// mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::BAD_HANDLE; -// } -// } -//} - -/*! - * Callback after creating directory for jak save data - */ -// void cb_createdir(s32 sync_result) { -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// // this sets up some stuff for the icon file that we will ignore. -// // memset(&iconsys,0,0x3c4); -// // kstrcpy(&iconsys,&DAT_00137000); -// // if (language == Language::Japanese) { -// // kstrcpy(&DAT_00137560,titles[5]); -// // } else { -// // // non japanese need to convert to shift-JIS format. -// // ASCII2SJIS(&DAT_00137560,titles[language]); -// // } -// // DAT_001374a6 = 0x20; -// // DAT_001374ac = 0; -// // memcpy(&DAT_001374b0,bgcolor.610,0x40); -// // memcpy(&DAT_001374f0,lightdir.611,0x30); -// // memcpy(&DAT_00137520,lightcol.612,0x30); -// // memcpy(&DAT_00137550,ambient.613,0x10); -// // kstrcpy(&DAT_001375a4,"icon.ico"); -// // kstrcpy(&DAT_001375e4,"icon.ico"); -// // kstrcpy(&DAT_00137624,"icon.ico"); -// -// p2 = 1; -// // move on to creating files -// mc_print("starting create file at {}", filename[p2]); -// if (sceMcOpen(p1, 0, filename[1], 0x203) == 0) { -// callback = cb_createdfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} - -/*! - * Callback after creating the file. - */ -// void cb_createdfile(s32 sync_result) { -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// mc_print("create file cb {}", filename[p2]); -// if (p2 == 1) { -// p3 = sync_result; // the fd of the icon file. -// // actually would write the icon sys file. -// if (sceMcWrite(sync_result, nullptr, 0) == sceMcResSucceed) { -// callback = cb_writtenfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else if (p2 == 2) { -// p3 = sync_result; -// // would write the icon data (ramdisk loaded into the temp buffer) -// if (sceMcWrite(sync_result, nullptr, 0) == sceMcResSucceed) { -// callback = cb_writtenfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else if (p2 == 3) { -// // writes the aybabtu meme file -// p3 = sync_result; -// kstrcpy(op.data_ptr.cast().c(), "Nope, the save game data isn\'t in this file!\n"); -// if (sceMcWrite(p3, op.data_ptr.c(), strlen((const char*)op.data_ptr.c())) == -// sceMcResSucceed) { -// callback = cb_writtenfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // writes the actual bank files. -// p3 = sync_result; -// memset(op.data_ptr.c(), 0, 0x11800); -// if (sceMcWrite(p3, op.data_ptr.c(), 0x11800) == sceMcResSucceed) { -// callback = cb_writtenfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -// } -//} - -/*! - * Callback after writing data to files. - */ -// void cb_writtenfile(s32 sync_result) { -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// if (sceMcClose(p3) == sceMcResSucceed) { -// callback = cb_closedfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} - -/*! - * Callback after closing the file. - */ -// void cb_closedfile(s32 sync_result) { -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// p2++; -// if (p2 < 12) { -// // open the next one -// if (sceMcOpen(p1, 0, filename[p2], 0x203) == sceMcResSucceed) { -// callback = cb_createdfile; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // done! -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::OK; -// -// // save data is inited -// mc[p1].inited = 1; -// // but no files have anything in it. -// for (int i = 0; i < 4; i++) { -// mc[p1].files[i].present = 0; -// } -// mc[p1].last_file = -1; -// } -// } -//} - -/*! - * Callback after check before saving. - */ -// void cb_reprobe_save(s32 sync_result) { -// if (sync_result == sceMcResSucceed) { -// if (!mc[p1].files[op.param2].present) { -// mc_print("reprobe save: first time!"); -// // first time saving! -// p2 = 0; // save count 0 -// p4 = 0; // first bank for file -// } else { -// p2 = mc_files[op.param2].most_recent_save_count + 1; // increment save count -// p4 = mc_files[op.param2].last_saved_bank ^ 1; // use the other bank -// } -// -// // reserve 0 as "I never saved" and use 1 instead. -// if (p2 == 0) { -// p2 = 1; -// } -// -// // file*2 + p4 is the bank (2 banks per file, p4 is 0 or 1 to select the bank) -// // 4 is the first bank file -// mc_print("open {} for saving", filename[op.param2 * 2 + 4 + p4]); -// if (sceMcOpen(p1, 0, filename[op.param2 * 2 + 4 + p4], 2) == sceMcResSucceed) { -// callback = cb_openedsave; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::BAD_HANDLE; -// } -//} -// -// void cb_openedsave(s32 sync_result) { -// mc_print("save file opened, writing header..."); -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// p3 = sync_result; -// memset(&header, 0, sizeof(McHeader)); -// header.save_count = p2; -// header.checksum = mc_checksum(op.data_ptr, BANK_SIZE); -// header.magic = MEM_CARD_MAGIC; -// header.unk1_repeated = p2; -// for (int i = 0; i < 64; i++) { -// header.preview_data[i] = op.data_ptr2.c()[i]; -// } -// if (sceMcWrite(p3, &header, sizeof(McHeader)) == sceMcResSucceed) { -// callback = cb_savedheader; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} -// -// void cb_savedheader(s32 sync_result) { -// mc_print("save file writing main data"); -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// if (sceMcWrite(p3, op.data_ptr.c(), BANK_SIZE) == sceMcResSucceed) { -// callback = cb_saveddata; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} -// -// void cb_saveddata(s32 sync_result) { -// mc_print("save file writing footer"); -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// if (sceMcWrite(p3, &header, sizeof(McHeader)) == sceMcResSucceed) { -// callback = cb_savedfooter; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} -// -// void cb_savedfooter(s32 sync_result) { -// mc_print("closing after save"); -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// if (sceMcClose(p3) == sceMcResSucceed) { -// callback = cb_closedsave; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} -// -// void cb_closedsave(s32 sync_result) { -// if (!cb_check(sync_result, McStatusCode::WRITE_ERROR)) { -// mc_print("All done with saving!!"); -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::OK; -// // mc_files[op.param2].present = 1; -// mc_files[op.param2].most_recent_save_count = p2; -// mc_files[op.param2].last_saved_bank = p4; -// for (int i = 0; i < 64; i++) { -// mc_files[op.param2].data[i] = op.data_ptr2.c()[i]; -// } -// mc_last_file = op.param2; -// flush_memory_card_to_file(); -// } -//} -// -// void cb_reprobe_load(s32 sync_result) { -// if (sync_result == 0) { -// p2 = 0; -// mc_print("opening save file {}", filename[op.param2 * 2 + 4]); -// if (sceMcOpen(p1, 0, filename[op.param2 * 2 + 4], 1) == sceMcResSucceed) { -// callback = cb_openedload; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // mc[p1].state = MemoryCardState::UNKNOWN; -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::BAD_HANDLE; -// } -//} -// -// void cb_openedload(s32 sync_result) { -// if (cb_check(sync_result, McStatusCode::READ_ERROR) == 0) { -// p3 = sync_result; -// size_t read_size = BANK_TOTAL_SIZE; -// mc_print("reading save file..."); -// if (sceMcRead(sync_result, op.data_ptr.c() + p2 * read_size, read_size) == sceMcResSucceed) { -// callback = cb_readload; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} -// -// void cb_readload(s32 sync_result) { -// if (cb_check(sync_result, McStatusCode::READ_ERROR) == 0) { -// mc_print("closing save file.."); -// if (sceMcClose(p3) == sceMcResSucceed) { -// callback = cb_closedload; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } -//} -// -// void cb_closedload(s32 sync_result) { -// if (cb_check(sync_result, McStatusCode::READ_ERROR) == 0) { -// p2++; -// if (p2 < 2) { -// mc_print("reading next save bank {}", filename[op.param2 * 2 + 4 + p2]); -// if (sceMcOpen(p1, 0, filename[op.param2 * 2 + 4 + p2], 1) == sceMcResSucceed) { -// callback = cb_openedload; -// } else { -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::INTERNAL_ERROR; -// } -// } else { -// // let's verify the data. -// McHeader* headers[2]; -// McHeader* footers[2]; -// bool ok[2]; -// -// headers[0] = (McHeader*)(op.data_ptr.c()); -// footers[0] = (McHeader*)(op.data_ptr.c() + sizeof(McHeader) + BANK_SIZE); -// headers[1] = (McHeader*)(op.data_ptr.c() + BANK_TOTAL_SIZE); -// footers[1] = (McHeader*)(op.data_ptr.c() + BANK_TOTAL_SIZE + sizeof(McHeader) + BANK_SIZE); -// static_assert(BANK_TOTAL_SIZE * 2 == 0x21000, "save layout"); -// ok[0] = true; -// ok[1] = true; -// -// for (int idx = 0; idx < 2; idx++) { -// u32 expected_save_count = headers[idx]->save_count; -// if (headers[idx]->unk1_repeated == expected_save_count && -// footers[idx]->save_count == expected_save_count && -// footers[idx]->unk1_repeated == expected_save_count) { -// // save count is okay! -// if (headers[idx]->magic == MEM_CARD_MAGIC && footers[idx]->magic == MEM_CARD_MAGIC) { -// // magic numbers okay! -// if (headers[idx]->checksum == footers[idx]->checksum) { -// // checksum -// auto expected_checksum = headers[idx]->checksum; -// if (mc_checksum(make_u8_ptr(headers[idx] + 1), BANK_SIZE) != expected_checksum) { -// mc_print("failed checksum"); -// ok[idx] = false; -// } -// } else { -// mc_print("corrupted checksum"); -// ok[idx] = false; -// } -// } else { -// mc_print("bad magic"); -// ok[idx] = false; -// } -// } else { -// mc_print("bad save count"); -// ok[idx] = false; -// } -// } -// -// mc_print("checking loaded banks"); -// -// // -// if (!ok[0] && !ok[1]) { -// // no good data. -// if (headers[0]->save_count == 0 && headers[0]->checksum == 0 && headers[0]->magic == 0 && -// headers[0]->unk1_repeated == 0 && headers[1]->save_count == 0 && -// headers[1]->checksum == 0 && headers[1]->magic == 0 && headers[1]->unk1_repeated == 0) -// { -// // this is a fresh file that you tried to load from... -// mc_print("new game result"); -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::NEW_GAME; -// mc_last_file = op.param2; -// } else { -// mc_print("corrupted data"); -// op.operation = MemoryCardOperationKind::NO_OP; -// op.result = McStatusCode::READ_ERROR; -// } -// } else { -// // pick the bank -// int bank = 0; -// -// if (!ok[0] || !ok[1]) { -// if (ok[1]) { -// bank = 1; -// } -// } else { -// bank = headers[0]->save_count <= headers[1]->save_count; -// } -// -// u32 current_save_count = headers[bank]->save_count; -// memcpy(op.data_ptr.c(), op.data_ptr.c() + bank * BANK_TOTAL_SIZE + sizeof(McHeader), -// BANK_SIZE); mc_last_file = op.param2; mc_files[op.param2].most_recent_save_count = -// current_save_count; mc_files[op.param2].last_saved_bank = bank; op.operation = -// MemoryCardOperationKind::NO_OP; op.result = McStatusCode::OK; mc_print("load succeeded"); -// } -// } -// } -//} diff --git a/goal_src/engine/collide/collide-shape.gc b/goal_src/engine/collide/collide-shape.gc index eeb800b194..78a90a8c1d 100644 --- a/goal_src/engine/collide/collide-shape.gc +++ b/goal_src/engine/collide/collide-shape.gc @@ -722,7 +722,7 @@ bbox (-> target-ctrl root-prim collide-with) (-> target-ctrl process) - (new 'static 'pat-surface :skip #x1 :noentity #x1) + (new 'static 'pat-surface :noentity #x1) ) ) @@ -824,188 +824,131 @@ (defun target-attack-up ((arg0 target) (arg1 symbol) (arg2 symbol)) "Handle an attack up. This launches the player in the air, forcing them back to a safe location." - (with-pp - ;; attempt to find a safe ground. - (let ((s4-0 (find-ground-point (-> arg0 control) (new 'stack-no-clear 'vector) 8192.0 40960.0))) - (set! s4-0 (cond - (s4-0 ;; if we found it, use that - s4-0 - ) - (else - ;; failed to find it. Use the last known safe ground point instaed. - (-> arg0 control last-known-safe-ground) - ) + ;; attempt to find a safe ground. + (let ((s4-0 (find-ground-point (-> arg0 control) (new 'stack-no-clear 'vector) (meters 2) (meters 10)))) + (set! s4-0 (cond + (s4-0 ;; if we found it, use that + s4-0 ) - ) - (let* ((s2-1 (vector-! (new 'stack-no-clear 'vector) s4-0 (-> arg0 control trans))) ;; jump direction - (f30-1 (fmax 8192.0 (fmin 40960.0 (vector-xz-length s2-1)))) ;; distance we should jump (limited) - ) - ;; note: the above limit is the same as the limit passed into find-ground-point. So the limiting should only kick in - ;; if we use last safe ground. - (cond - ((< (fabs (vector-dot - (-> arg0 control dynam gravity-normal) - (vector-! (new 'stack-no-clear 'vector) s4-0 (-> arg0 control trans)) - ) + (else + ;; failed to find it. Use the last known safe ground point instaed. + (-> arg0 control last-known-safe-ground) + ) + ) + ) + (let* ((s2-1 (vector-! (new 'stack-no-clear 'vector) s4-0 (-> arg0 control trans))) ;; jump direction + (f30-1 (fmax (meters 2) (fmin (meters 10) (vector-xz-length s2-1)))) ;; distance we should jump (limited) + ) + ;; note: the above limit is the same as the limit passed into find-ground-point. So the limiting should only kick in + ;; if we use last safe ground. + (cond + ((< (fabs (vector-dot + (-> arg0 control dynam gravity-normal) + (vector-! (new 'stack-no-clear 'vector) s4-0 (-> arg0 control trans)) ) - 40960.0 + ) + (meters 10) + ) + ;; if we reach here, we have to jump up or down less than 10m. + ;; reduce our jump direction to within reasonable distance + (vector-xz-normalize! s2-1 f30-1) + ;; send an attack + ;; the shove is proportional to how high we jump (and has a min, so we at least get off the ground) + (send-event + arg0 + arg1 + #f + (static-attack-info + ((mode arg2) + (vector s2-1) + (shove-up + (+ (lerp-scale (meters 1) (meters 4) f30-1 (meters 1) (meters 10)) (fmax 0.0 (- (-> s4-0 y) (-> arg0 control trans y)))) + ) + (angle 'up) ) - ;; if we reach here, we have to jump up or down less than 10m. - ;; reduce our jump direction to within reasonable distance - (vector-xz-normalize! s2-1 f30-1) - ;; send an attack - (let ((s1-0 (new 'stack-no-clear 'event-message-block))) - (set! (-> s1-0 from) pp) - (set! (-> s1-0 num-params) 2) - (set! (-> s1-0 message) arg1) - (set! (-> s1-0 param 0) (the-as uint #f)) - (let ((s3-1 (new 'static 'attack-info :mask #x8a2))) - (set! (-> s3-1 mode) arg2) - ;; go in the direction we determined. - (set! (-> s3-1 vector quad) (-> s2-1 quad)) - ;; the shove is proportional to how high we jump (and has a min, so we at least get off the ground) - (set! (-> s3-1 shove-up) - (+ (lerp-scale 4096.0 16384.0 f30-1 4096.0 40960.0) (fmax 0.0 (- (-> s4-0 y) (-> arg0 control trans y)))) - ) - (set! (-> s3-1 angle) 'up) - (set! (-> s1-0 param 1) (the-as uint s3-1)) - ) - ;; shove! - (send-event-function arg0 s1-0) ) ) - (else - ;; the last safest place we jumped is too high. just launch jak in the air and hope for the best. - ;; fire canyon skip jumps - (let ((a1-6 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-6 from) pp) - (set! (-> a1-6 num-params) 2) - (set! (-> a1-6 message) arg1) - (set! (-> a1-6 param 0) (the-as uint #f)) - (let ((v1-12 (new 'static 'attack-info :mask #xca2))) - (set! (-> v1-12 mode) arg2) - (set! (-> v1-12 vector quad) (-> (new 'static 'vector :y 40960.0 :w 1.0) quad)) - (set! (-> v1-12 shove-up) 40960.0) - (set! (-> v1-12 angle) 'up) - (set! (-> v1-12 control) 1.0) - (set! (-> a1-6 param 1) (the-as uint v1-12)) - ) - (send-event-function arg0 a1-6) - ) - ) + ) + (else + ;; the last safest place we jumped is too high. just launch jak in the air and hope for the best. + ;; fire canyon skip jumps + (send-event arg0 arg1 #f (static-attack-info ((mode arg2) + (vector (new 'static 'vector :y (meters 10) :w 1.0)) + (shove-up (meters 10)) + (angle 'up) + (control 1.0) + ) + ) + ) ) ) ) - (none) ) + (none) ) (defmethod set-and-handle-pat! collide-shape-moving ((obj collide-shape-moving) (arg0 pat-surface)) "Handle landing on the given pat-surface. This is likely target-specific." - (with-pp - ;; set our pat - (set! (-> obj cur-pat) arg0) - (set! (-> obj poly-pat) arg0) - ;; set our surface - (case (-> arg0 material) - (((pat-material ice)) - (set! (-> obj surf) *ice-surface*) - ) - (((pat-material quicksand)) - (set! (-> obj surf) *quicksand-surface*) - ) - (((pat-material tube)) - (set! (-> obj surf) *no-walk-surface*) - ) - (((pat-material rotate)) - (set! (-> obj surf) *rotate-surface*) - ) - (else - (set! (-> obj surf) *standard-ground-surface*) - ) + ;; set our pat + (set! (-> obj cur-pat) arg0) + (set! (-> obj poly-pat) arg0) + ;; set our surface + (case (-> arg0 material) + (((pat-material ice)) + (set! (-> obj surf) *ice-surface*) + ) + (((pat-material quicksand)) + (set! (-> obj surf) *quicksand-surface*) + ) + (((pat-material tube)) + (set! (-> obj surf) *no-walk-surface*) + ) + (((pat-material rotate)) + (set! (-> obj surf) *rotate-surface*) + ) + (else + (set! (-> obj surf) *standard-ground-surface*) ) - - ;; ca-9 gets set whenever you get on the zoomer. If we are on the zoomer, just go to "race-track" - (if (logtest? (-> obj root-prim prim-core action) (collide-action ca-9)) - (set! (-> obj surf) *race-track-surface*) - ) - - (when (nonzero? (-> arg0 event)) - (case (-> arg0 event) - (((pat-event deadly)) - ;; deadly. Send a deadly event - (let ((a1-3 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-3 from) pp) - (set! (-> a1-3 num-params) 2) - (set! (-> a1-3 message) 'attack) - (set! (-> a1-3 param 0) (the-as uint #f)) - (let ((v1-19 (new 'static 'attack-info :mask #xa0))) - (set! (-> v1-19 mode) 'deadly) - (set! (-> v1-19 shove-up) 12288.0) - (set! (-> a1-3 param 1) (the-as uint v1-19)) - ) - (send-event-function (-> obj process) a1-3) - ) - ) - (((pat-event burn)) - ;; burn. Send a burn event - (let ((a1-6 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-6 from) pp) - (set! (-> a1-6 num-params) 2) - (set! (-> a1-6 message) 'attack) - (set! (-> a1-6 param 0) (the-as uint #f)) - (let ((v1-23 (new 'static 'attack-info :mask #xa0))) - (set! (-> v1-23 mode) 'burn) - (set! (-> v1-23 shove-up) 12288.0) - (set! (-> a1-6 param 1) (the-as uint v1-23)) - ) - (send-event-function (-> obj process) a1-6) - ) - ) - (((pat-event deadlyup)) - ;; deadlyup. Launch! - (target-attack-up (the-as target (-> obj process)) 'attack-or-shove 'deadlyup) - ) - (((pat-event burnup)) - ;; burnup (like fire canyon lava). - ;; only send if we don't have ca-9 (on zoomer) - (if (zero? (logand (-> (the-as target (-> obj process)) control root-prim prim-core action) (collide-action ca-9))) - (target-attack-up (the-as target (-> obj process)) 'attack-or-shove 'burnup) - ) - ) - (((pat-event melt)) - ;; just send melt - (let ((a1-15 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-15 from) pp) - (set! (-> a1-15 num-params) 2) - (set! (-> a1-15 message) 'attack-invinc) - (set! (-> a1-15 param 0) (the-as uint #f)) - (let ((a2-8 (new 'static 'attack-info :mask #x20))) - (set! (-> a2-8 mode) 'melt) - (set! (-> a1-15 param 1) (the-as uint a2-8)) - ) - (send-event-function (-> obj process) a1-15) - ) - ) - (((pat-event endlessfall)) - ;; endless pit death plane. - (let ((a1-17 (new 'stack-no-clear 'event-message-block))) - (set! (-> a1-17 from) pp) - (set! (-> a1-17 num-params) 2) - (set! (-> a1-17 message) 'attack-invinc) - (set! (-> a1-17 param 0) (the-as uint #f)) - (let ((a2-9 (new 'static 'attack-info :mask #x20))) - (set! (-> a2-9 mode) 'endlessfall) - (set! (-> a1-17 param 1) (the-as uint a2-9)) - ) - (send-event-function (-> obj process) a1-17) - ) - ) - ) - ) - 0 - (none) ) + + ;; ca-9 gets set whenever you get on the zoomer. If we are on the zoomer, just go to "race-track" + (if (logtest? (-> obj root-prim prim-core action) (collide-action ca-9)) + (set! (-> obj surf) *race-track-surface*) + ) + + (when (nonzero? (-> arg0 event)) + (case (-> arg0 event) + (((pat-event deadly)) + ;; deadly. Send a deadly event + (send-event (-> obj process) 'attack #f (static-attack-info ((mode 'deadly) (shove-up (meters 3))))) + ) + (((pat-event burn)) + ;; burn. Send a burn event + (send-event (-> obj process) 'attack #f (static-attack-info ((mode 'burn) (shove-up (meters 3))))) + ) + (((pat-event deadlyup)) + ;; deadlyup. Launch! + (target-attack-up (the-as target (-> obj process)) 'attack-or-shove 'deadlyup) + ) + (((pat-event burnup)) + ;; burnup (like fire canyon lava). + ;; only send if we don't have ca-9 (on zoomer) + (if (zero? (logand (-> (the-as target (-> obj process)) control root-prim prim-core action) (collide-action ca-9))) + (target-attack-up (the-as target (-> obj process)) 'attack-or-shove 'burnup) + ) + ) + (((pat-event melt)) + ;; just send melt + (send-event (-> obj process) 'attack-invinc #f (static-attack-info ((mode 'melt)))) + ) + (((pat-event endlessfall)) + ;; endless pit death plane. + (send-event (-> obj process) 'attack-invinc #f (static-attack-info ((mode 'endlessfall)))) + ) + ) + ) + 0 + (none) ) (defun default-collision-reaction ((arg0 collide-shape-moving) (arg1 collide-shape-intersect) (arg2 vector) (arg3 vector)) diff --git a/goal_src/engine/gfx/texture.gc b/goal_src/engine/gfx/texture.gc index 0914bf6347..21b2213826 100644 --- a/goal_src/engine/gfx/texture.gc +++ b/goal_src/engine/gfx/texture.gc @@ -410,12 +410,8 @@ (let* ((block-width (gs-block-width tex-format)) (block-height (gs-block-height tex-format)) ;; round up to neaest block. - (real-width - (* (/ (+ (+ block-width -1) tex-width) block-width) block-width) - ) - (real-height - (* (/ (+ (+ block-height -1) tex-height) block-height) block-height) - ) + (real-width (* (/ (+ (+ block-width -1) tex-width) block-width) block-width)) + (real-height (* (/ (+ (+ block-height -1) tex-height) block-height) block-height)) ;; and now convert to actual blocks (width-blocks (/ real-width block-width)) (height-blocks (/ real-height block-height)) @@ -436,12 +432,8 @@ "This function doesn't make much sense... It's unused so maybe it's just wrong?" (let* ((page-width (gs-page-width tex-format)) (page-height (gs-page-height tex-format)) - (real-width - (* (/ (+ (+ page-width -1) tex-width) page-width) page-width) - ) - (real-height - (* (/ (+ (+ page-height -1) tex-height) page-height) page-height) - ) + (real-width (* (/ (+ (+ page-width -1) tex-width) page-width) page-width)) + (real-height (* (/ (+ (+ page-height -1) tex-height) page-height) page-height)) (width-blocks (/ real-width page-width)) (height-blocks (/ real-height page-height)) ;; past here, it doesn't make much sense to me. @@ -1929,13 +1921,7 @@ (font-tx-1-fmt (gs-psm mt4hl)) ;; 4-bit, using 4 of the 8 free bits of z24 ) ;; do the relocation! - (texture-relocate - dma-buff - font-tx-1 - font-tx-1-dest - font-tx-1-fmt - font-clut - ) + (texture-relocate dma-buff font-tx-1 font-tx-1-dest font-tx-1-fmt font-clut) ;; tell the font system that we put the texture here. (font-set-tex0 (the-as (pointer gs-tex0) (-> *font-work* small-font-lo-tmpl)) @@ -1949,13 +1935,7 @@ (font-tx-0-dest #xe0000) (font-tx-0-fmt (gs-psm mt4hh)) ) - (texture-relocate - dma-buff - font-tx-0 - font-tx-0-dest - font-tx-0-fmt - font-clut - ) + (texture-relocate dma-buff font-tx-0 font-tx-0-dest font-tx-0-fmt font-clut) (font-set-tex0 (the-as (pointer gs-tex0) (-> *font-work* small-font-hi-tmpl)) font-tx-0 @@ -1968,13 +1948,7 @@ (font-tx-3-dest #xe6000) (font-tx-3-fmt (gs-psm mt4hl)) ) - (texture-relocate - dma-buff - font-tx-3 - font-tx-3-dest - font-tx-3-fmt - font-clut - ) + (texture-relocate dma-buff font-tx-3 font-tx-3-dest font-tx-3-fmt font-clut) (font-set-tex0 (the-as (pointer gs-tex0) (-> *font-work* large-font-lo-tmpl)) font-tx-3 @@ -1982,23 +1956,19 @@ (the-as uint font-tx-3-fmt) (the-as uint clut-dest-addr) ) - (set! font-tx-3 (lookup-texture-by-id (new 'static 'texture-id :index #x2 :page #x4fe))) - (set! font-tx-3-dest #xe6000) - (set! font-tx-3-fmt (gs-psm mt4hh)) - (texture-relocate - dma-buff - font-tx-3 - font-tx-3-dest - font-tx-3-fmt - font-clut - ) + ) + (let ((font-tx-2 (lookup-texture-by-id (new 'static 'texture-id :index #x2 :page #x4fe))) + (font-tx-2-dest #xe0000) + (font-tx-2-fmt (gs-psm mt4hh)) + ) + (texture-relocate dma-buff font-tx-2 font-tx-2-dest (the-as gs-psm font-tx-2-fmt) font-clut) (font-set-tex0 - (the-as (pointer gs-tex0) (-> *font-work* large-font-hi-tmpl)) - font-tx-3 - (the-as uint font-tx-3-dest) - (the-as uint font-tx-3-fmt) - (the-as uint clut-dest-addr) - ) + (the-as (pointer gs-tex0) (-> *font-work* large-font-hi-tmpl)) + font-tx-2 + (the-as uint font-tx-2-dest) + (the-as uint font-tx-2-fmt) + (the-as uint clut-dest-addr) + ) ) ;; texflush @@ -2118,9 +2088,7 @@ (tex-dbg " tpage is with level ~A~%" v1-2) (when v1-2 ;; add us to the loading level's tpages - (set! (-> v1-2 loaded-texture-page (-> v1-2 loaded-texture-page-count)) - obj - ) + (set! (-> v1-2 loaded-texture-page (-> v1-2 loaded-texture-page-count)) obj) (+! (-> v1-2 loaded-texture-page-count) 1) ) ) @@ -2134,12 +2102,7 @@ (set! (-> *texture-relocate-later* memcpy) #f) ;; allocate! - ((-> *texture-pool* allocate-func) - *texture-pool* - obj - arg0 - (the-as int a3-0) - ) + ((-> *texture-pool* allocate-func) *texture-pool* obj arg0 (the-as int a3-0)) ) ;; the actual condition (not (-> *texture-relocate-later* memcpy)) @@ -2148,11 +2111,8 @@ (set! (-> s4-0 page) obj) (if (not (-> s4-0 link)) (set! (-> s4-0 link) - (the-as - texture-link - (malloc 'loading-level (* (max (-> s4-0 length) (-> obj length)) 4)) - ) - ) + (the-as texture-link (malloc 'loading-level (* (max (-> s4-0 length) (-> obj length)) 4))) + ) ) ) (else @@ -2174,19 +2134,12 @@ (s4-0 (-> gp-0 page)) ) ;; do this first, before allocating - (ultimate-memcpy - (the-as pointer (-> gp-0 dest)) - (the-as pointer (-> gp-0 source)) - (-> gp-0 move) - ) + (ultimate-memcpy (the-as pointer (-> gp-0 dest)) (the-as pointer (-> gp-0 source)) (-> gp-0 move)) (set! (-> s5-0 page) s4-0) ;; now safe to allocate links! (if (not (-> s5-0 link)) (set! (-> s5-0 link) - (the-as - texture-link - (malloc 'loading-level (* (max (-> s5-0 length) (-> s4-0 length)) 4)) - ) + (the-as texture-link (malloc 'loading-level (* (max (-> s5-0 length) (-> s4-0 length)) 4))) ) ) ) @@ -2271,7 +2224,7 @@ ;; debug menu shader stuff (define *shader-list* '()) -(define *edit-shader* (the-as texture-id 0)) +(define *edit-shader* (new 'static 'texture-id)) (defun link-texture-by-id ((arg0 texture-id) (arg1 adgif-shader)) "Link the given adgif shader to the texture with the given ID" @@ -2485,12 +2438,8 @@ (-> dir-entry link) ) ;; push - (set! (-> shader next shader) - (-> dir-entry link next (-> tex-id index) shader) - ) - (set! (-> dir-entry link next (-> tex-id index) shader) - (shr (the-as uint shader) 4) - ) + (set! (-> shader next shader) (-> dir-entry link next (-> tex-id index) shader)) + (set! (-> dir-entry link next (-> tex-id index) shader) (shr (the-as uint shader) 4)) ) (when (and (-> dir-entry page) (< (-> tex-id index) (the-as uint (-> dir-entry page length))) @@ -2522,9 +2471,7 @@ (let ((a1-7 (-> *texture-page-dir* entries (the-as uint (-> v1-4 page))))) (when (and (< (-> v1-4 index) (the-as uint (-> a1-7 length))) (-> a1-7 link)) (set! (-> arg0 next shader) (-> a1-7 link next (-> v1-4 index) shader)) - (set! (-> a1-7 link next (-> v1-4 index) shader) - (shr (the-as uint arg0) 4) - ) + (set! (-> a1-7 link next (-> v1-4 index) shader) (shr (the-as uint arg0) 4)) ) (when (and (-> a1-7 page) (< (-> v1-4 index) (the-as uint (-> a1-7 page length))) @@ -2580,96 +2527,94 @@ (defun-debug texture-page-dir-inspect ((dir texture-page-dir) (mode symbol)) (format #t "[~8x] ~A~%" dir (-> dir type)) (let ((pool *texture-pool*)) - (format - #t - "~Ttexture pool (~DK used, ~DK free)~%" - (/ (- (-> pool cur) (-> pool top)) 256) - (/ (- #xa0000 (-> pool cur)) 256) + (format #t "~Ttexture pool (~DK used, ~DK free)~%" + (/ (- (-> pool cur) (-> pool top)) 256) + (/ (- #xa0000 (-> pool cur)) 256) + ) ) - ) (dotimes (level-idx (-> *level* length)) - (let ((lev (-> *level* level level-idx))) - (if (= (-> lev status) 'active) - (texture-page-size-check *texture-pool* lev #f) - ) + (let ((lev (-> *level* level level-idx))) + (if (= (-> lev status) 'active) + (texture-page-size-check *texture-pool* lev #f) + ) + ) ) - ) (format #t "~Tlength: ~D~%" (-> dir length)) (format #t "~Tdata[~D]: @ #x~X~%" (-> dir length) (-> dir entries)) (dotimes (entry-idx (-> dir length)) - (let ((entry-page (-> dir entries entry-idx page)) - (entry-link (-> dir entries entry-idx link)) - ) - (cond - (entry-page - (format #t "~T [~3D] loaded ~S ~A~%" entry-idx (if entry-link - " linked" - "unlinked" - ) - entry-page - ) - ) - (else - (if (= mode 'full) - (format - #t - "~T [~3D] unloaded ~S #~%" - entry-idx - (if entry-link - " linked" - "unlinked" - ) - (-> dir entries entry-idx length) - ) - ) - ) - ) - (when (and (or entry-page entry-link) mode) - (dotimes (entry-list-length (-> dir entries entry-idx length)) - (cond - ((not entry-link) - (format #t "~T [~3D] unlinked" entry-list-length) - ) - ((zero? (-> entry-link next entry-list-length shader)) - (format #t "~T [~3D] UNUSED " entry-list-length) - ) - (else - (let ((t9-9 format) - (a0-12 #t) - (a1-10 "~T [~3D] ~3D links ") - (a2-11 entry-list-length) - (a3-7 0) - ) - (let - ((v1-40 - (the-as object (* (-> entry-link next entry-list-length shader) 16)) - ) - ) - (while (nonzero? (the-as int v1-40)) - (nop!) - (+! a3-7 1) - (set! v1-40 (* (-> (the-as adgif-shader v1-40) next shader) 16)) - ) + (let ((entry-page (-> dir entries entry-idx page)) + (entry-link (-> dir entries entry-idx link)) ) - (t9-9 a0-12 a1-10 a2-11 a3-7) - ) - ) - ) (cond - ((not entry-page) - (format #t " unloaded~%") + (entry-page + (format + #t + "~T [~3D] loaded ~S ~A~%" + entry-idx + (if entry-link + " linked" + "unlinked" + ) + entry-page + ) + ) + (else + (if (= mode 'full) + (format + #t + "~T [~3D] unloaded ~S #~%" + entry-idx + (if entry-link + " linked" + "unlinked" + ) + (-> dir entries entry-idx length) + ) + ) + ) ) - ((not (-> entry-page data entry-list-length)) - (format #t " empty~%") + (when (and (or entry-page entry-link) mode) + (dotimes (entry-list-length (-> dir entries entry-idx length)) + (cond + ((not entry-link) + (format #t "~T [~3D] unlinked" entry-list-length) + ) + ((zero? (-> entry-link next entry-list-length shader)) + (format #t "~T [~3D] UNUSED " entry-list-length) + ) + (else + (let ((t9-9 format) + (a0-12 #t) + (a1-10 "~T [~3D] ~3D links ") + (a2-11 entry-list-length) + (a3-7 0) + ) + (let ((v1-40 (the-as object (* (-> entry-link next entry-list-length shader) 16)))) + (while (nonzero? (the-as uint v1-40)) + (nop!) + (+! a3-7 1) + (set! v1-40 (* (-> (the-as adgif-shader v1-40) next shader) 16)) + ) + ) + (t9-9 a0-12 a1-10 a2-11 a3-7) + ) + ) + ) + (cond + ((not entry-page) + (format #t " unloaded~%") + ) + ((not (-> entry-page data entry-list-length)) + (format #t " empty~%") + ) + (else + (format #t " ~A~%" (-> entry-page data entry-list-length)) + ) + ) + ) ) - (else - (format #t " ~A~%" (-> entry-page data entry-list-length)) - ) - ) ) - ) ) - ) (none) ) diff --git a/goal_src/engine/gfx/vis/bsp-h.gc b/goal_src/engine/gfx/vis/bsp-h.gc index 6455c77871..d01e411815 100644 --- a/goal_src/engine/gfx/vis/bsp-h.gc +++ b/goal_src/engine/gfx/vis/bsp-h.gc @@ -115,7 +115,21 @@ (format #t "~Tdrawable-trees: ~A~%" (-> obj drawable-trees)) (format #t "~Tpat: #x~X~%" (-> obj pat)) (format #t "~Tpat-length: ~D~%" (-> obj pat-length)) - (inspect-bsp-tree obj (the-as bsp-node (-> obj nodes))) + ;; putting this stuff here for debugging! + (format #t "~Ttexture-remap-table-len: ~D~%" (-> obj texture-remap-table-len)) + (dotimes (i (-> obj texture-remap-table-len)) + (let* ((tex-id-array (the (pointer texture-id) (&-> obj texture-remap-table i))) + (tex-id-from (-> tex-id-array 0)) + (tex-id-to (-> tex-id-array 1)) + ) + (format #t "~T~Ttex-remap[~D]: # --> #~%" + i + (-> tex-id-from page) (-> tex-id-from index) + (-> tex-id-to page) (-> tex-id-to index) + ) + ) + ) + ;;(inspect-bsp-tree obj (the-as bsp-node (-> obj nodes))) obj ) diff --git a/goal_src/engine/gfx/vis/bsp.gc b/goal_src/engine/gfx/vis/bsp.gc index 3568cee6f2..bb7fc7038f 100644 --- a/goal_src/engine/gfx/vis/bsp.gc +++ b/goal_src/engine/gfx/vis/bsp.gc @@ -609,19 +609,19 @@ (let ((bsp-hdr (-> *level* log-in-level-bsp))) (when bsp-hdr (let* ((table-size (-> bsp-hdr texture-remap-table-len)) ;; in 64-bit entries - (table-data-start (-> bsp-hdr texture-remap-table)) - (table-data-ptr table-data-start) + (table-data-ptr (-> bsp-hdr texture-remap-table)) + (table-data-start table-data-ptr) (mask1 (the-as uint #xfffffff8)) ;; mask for table entry addresses (masked-tex-id (logand (the-as uint #xffffff00) tex-id)) ;; bits of tex-id we care about - (table-data-end (&+ table-data-ptr (* table-size 8))) + (table-data-end (&+ table-data-start (* table-size 8))) ) ;; top of binary search (label cfg-2) ;; if we didn't find anything, quit - (b! (= table-data-start table-data-end) cfg-8) + (b! (= table-data-ptr table-data-end) cfg-8) ;; find the middle entry. - (let ((midpoint (logand (/ (+ (the-as int table-data-start) (the-as int table-data-end)) 2) + (let ((midpoint (logand (/ (+ (the-as int table-data-ptr) (the-as int table-data-end)) 2) mask1 ) ) @@ -641,7 +641,7 @@ (label cfg-6) (b! #t cfg-2 :delay - (set! table-data-start (the-as (pointer uint64) (+ (the-as int midpoint) 8))) + (set! table-data-ptr (the-as (pointer uint64) (+ (the-as int midpoint) 8))) ) ;; exact match diff --git a/goal_src/engine/sparticle/sparticle-launcher-h.gc b/goal_src/engine/sparticle/sparticle-launcher-h.gc index 7c702a773b..6003b00c7a 100644 --- a/goal_src/engine/sparticle/sparticle-launcher-h.gc +++ b/goal_src/engine/sparticle/sparticle-launcher-h.gc @@ -146,7 +146,7 @@ (random-mult int32 :offset 12) (sym symbol :offset 4) ;; moved (func symbol :offset 4) - (tex uint32 :offset 4) + (tex texture-id :offset 4) (pntr pointer :offset 4) ;; sym used to be here (sound sound-spec :offset 4) diff --git a/goal_src/levels/demo/demo-obs.gc b/goal_src/levels/demo/demo-obs.gc index 29490bc9df..befb57aae8 100644 --- a/goal_src/levels/demo/demo-obs.gc +++ b/goal_src/levels/demo/demo-obs.gc @@ -5,7 +5,7 @@ ;; name in dgo: demo-obs ;; dgos: DEM, L1 -(define-extern static-screen-spawn (function int int int int int symbol target (pointer process))) ;; target may differ +(define-extern static-screen-spawn (function int texture-id texture-id texture-id time-frame symbol process-tree (pointer static-screen))) ;; DECOMP BEGINS @@ -24,17 +24,50 @@ (load-state-want-vis 'vi1) (case (scf-get-territory) ((2) - (let ((gp-0 (ppointer->handle (static-screen-spawn 6 #x27c00000 #x27c00100 #x27c00200 1500 #f self)))) + (let ((gp-0 (ppointer->handle (static-screen-spawn + 6 + (new 'static 'texture-id :page #x27c) + (new 'static 'texture-id :index #x1 :page #x27c) + (new 'static 'texture-id :index #x2 :page #x27c) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-0) (suspend) ) ) - (let ((gp-1 (ppointer->handle (static-screen-spawn 7 #x27d00000 #x27d00100 #x27d00200 1500 #f self)))) + (let ((gp-1 (ppointer->handle (static-screen-spawn + 7 + (new 'static 'texture-id :page #x27d) + (new 'static 'texture-id :index #x1 :page #x27d) + (new 'static 'texture-id :index #x2 :page #x27d) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-1) (suspend) ) ) - (let ((gp-2 (ppointer->handle (static-screen-spawn 8 #x2f000000 #x2f000100 #x2f000200 #x4650 #t self)))) + (let ((gp-2 (ppointer->handle (static-screen-spawn + 8 + (new 'static 'texture-id :page #x2f0) + (new 'static 'texture-id :index #x1 :page #x2f0) + (new 'static 'texture-id :index #x2 :page #x2f0) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-2) (suspend) ) @@ -43,77 +76,198 @@ ((1) (case (-> *setting-control* current language) (((language-enum french)) - (let ((gp-3 (ppointer->handle (static-screen-spawn 10 #x63f00000 #x63f00100 #x63f00200 1500 #f self)))) + (let ((gp-3 (ppointer->handle (static-screen-spawn + 10 + (new 'static 'texture-id :page #x63f) + (new 'static 'texture-id :index #x1 :page #x63f) + (new 'static 'texture-id :index #x2 :page #x63f) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-3) (suspend) ) ) ) (((language-enum german)) - (let ((gp-4 (ppointer->handle (static-screen-spawn 11 #x64000000 #x64000100 #x64000200 1500 #f self)))) + (let ((gp-4 (ppointer->handle (static-screen-spawn + 11 + (new 'static 'texture-id :page #x640) + (new 'static 'texture-id :index #x1 :page #x640) + (new 'static 'texture-id :index #x2 :page #x640) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-4) (suspend) ) ) ) (((language-enum italian)) - (let ((gp-5 (ppointer->handle (static-screen-spawn 12 #x64100000 #x64100100 #x64100200 1500 #f self)))) + (let ((gp-5 (ppointer->handle (static-screen-spawn + 12 + (new 'static 'texture-id :page #x641) + (new 'static 'texture-id :index #x1 :page #x641) + (new 'static 'texture-id :index #x2 :page #x641) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-5) (suspend) ) ) ) (((language-enum spanish)) - (let ((gp-6 (ppointer->handle (static-screen-spawn 13 #x64200000 #x64200100 #x64200200 1500 #f self)))) + (let ((gp-6 (ppointer->handle (static-screen-spawn + 13 + (new 'static 'texture-id :page #x642) + (new 'static 'texture-id :index #x1 :page #x642) + (new 'static 'texture-id :index #x2 :page #x642) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-6) (suspend) ) ) ) (else - (let ((gp-7 (ppointer->handle (static-screen-spawn 2 #x5cd00000 #x5cd00100 #x5cd00200 1500 #f self)))) + (let ((gp-7 (ppointer->handle (static-screen-spawn + 2 + (new 'static 'texture-id :page #x5cd) + (new 'static 'texture-id :index #x1 :page #x5cd) + (new 'static 'texture-id :index #x2 :page #x5cd) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-7) (suspend) ) ) ) ) - (let ((gp-8 (ppointer->handle (static-screen-spawn 3 #x5ce00000 #x5ce00100 #x5ce00200 1500 #f self)))) + (let ((gp-8 (ppointer->handle (static-screen-spawn + 3 + (new 'static 'texture-id :page #x5ce) + (new 'static 'texture-id :index #x1 :page #x5ce) + (new 'static 'texture-id :index #x2 :page #x5ce) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-8) (suspend) ) ) (case (-> *setting-control* current language) (((language-enum french)) - (let ((gp-9 (ppointer->handle (static-screen-spawn 15 #x64400000 #x64400100 #x64400200 #x4650 #t self)))) + (let ((gp-9 (ppointer->handle (static-screen-spawn + 15 + (new 'static 'texture-id :page #x644) + (new 'static 'texture-id :index #x1 :page #x644) + (new 'static 'texture-id :index #x2 :page #x644) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-9) (suspend) ) ) ) (((language-enum german)) - (let ((gp-10 (ppointer->handle (static-screen-spawn 16 #x64500000 #x64500100 #x64500200 #x4650 #t self)))) + (let ((gp-10 (ppointer->handle (static-screen-spawn + 16 + (new 'static 'texture-id :page #x645) + (new 'static 'texture-id :index #x1 :page #x645) + (new 'static 'texture-id :index #x2 :page #x645) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-10) (suspend) ) ) ) (((language-enum italian)) - (let ((gp-11 (ppointer->handle (static-screen-spawn 17 #x64600000 #x64600100 #x64600200 #x4650 #t self)))) + (let ((gp-11 (ppointer->handle (static-screen-spawn + 17 + (new 'static 'texture-id :page #x646) + (new 'static 'texture-id :index #x1 :page #x646) + (new 'static 'texture-id :index #x2 :page #x646) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-11) (suspend) ) ) ) (((language-enum spanish)) - (let ((gp-12 (ppointer->handle (static-screen-spawn 18 #x64700000 #x64700100 #x64700200 #x4650 #t self)))) + (let ((gp-12 (ppointer->handle (static-screen-spawn + 18 + (new 'static 'texture-id :page #x647) + (new 'static 'texture-id :index #x1 :page #x647) + (new 'static 'texture-id :index #x2 :page #x647) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-12) (suspend) ) ) ) (else - (let ((gp-13 (ppointer->handle (static-screen-spawn 14 #x64300000 #x64300100 #x64300200 #x4650 #t self)))) + (let ((gp-13 (ppointer->handle (static-screen-spawn + 14 + (new 'static 'texture-id :page #x643) + (new 'static 'texture-id :index #x1 :page #x643) + (new 'static 'texture-id :index #x2 :page #x643) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-13) (suspend) ) @@ -122,17 +276,50 @@ ) ) (else - (let ((gp-14 (ppointer->handle (static-screen-spawn 2 #x5cd00000 #x5cd00100 #x5cd00200 1500 #f self)))) + (let ((gp-14 (ppointer->handle (static-screen-spawn + 2 + (new 'static 'texture-id :page #x5cd) + (new 'static 'texture-id :index #x1 :page #x5cd) + (new 'static 'texture-id :index #x2 :page #x5cd) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-14) (suspend) ) ) - (let ((gp-15 (ppointer->handle (static-screen-spawn 3 #x5ce00000 #x5ce00100 #x5ce00200 1500 #f self)))) + (let ((gp-15 (ppointer->handle (static-screen-spawn + 3 + (new 'static 'texture-id :page #x5ce) + (new 'static 'texture-id :index #x1 :page #x5ce) + (new 'static 'texture-id :index #x2 :page #x5ce) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-15) (suspend) ) ) - (let ((gp-16 (ppointer->handle (static-screen-spawn 4 #x5cf00000 #x5cf00100 #x5cf00200 #x4650 #t self)))) + (let ((gp-16 (ppointer->handle (static-screen-spawn + 4 + (new 'static 'texture-id :page #x5cf) + (new 'static 'texture-id :index #x1 :page #x5cf) + (new 'static 'texture-id :index #x2 :page #x5cf) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-16) (suspend) ) diff --git a/goal_src/levels/demo/static-screen.gc b/goal_src/levels/demo/static-screen.gc index b77d6a9cc9..fff3df3428 100644 --- a/goal_src/levels/demo/static-screen.gc +++ b/goal_src/levels/demo/static-screen.gc @@ -138,7 +138,7 @@ ) ) -(defbehavior static-screen-init-by-other static-screen ((arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 time-frame) (arg5 symbol)) +(defbehavior static-screen-init-by-other static-screen ((arg0 int) (arg1 texture-id) (arg2 texture-id) (arg3 texture-id) (arg4 time-frame) (arg5 symbol)) (let ((s3-0 (lookup-part-group-by-name "group-part-screen1"))) (when (and s3-0 (nonzero? s3-0) (type-type? (-> s3-0 type) sparticle-launch-group)) (set! (-> *part-id-table* 2966 init-specs 0 initial-valuef) (the-as float arg1)) @@ -152,16 +152,15 @@ (none) ) -(defun static-screen-spawn ((arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 symbol) (arg6 target)) - (local-vars (sv-16 process)) - (set! sv-16 (get-process *default-dead-pool* static-screen #x4000)) - (when sv-16 - (let ((t9-1 (method-of-type static-screen activate))) - (t9-1 (the-as static-screen sv-16) arg6 'static-screen (the-as pointer #x70004000)) - ) - (run-now-in-process sv-16 static-screen-init-by-other arg0 arg1 arg2 arg3 arg4 arg5) - (-> sv-16 ppointer) - ) +(defun static-screen-spawn ((arg0 int) + (arg1 texture-id) + (arg2 texture-id) + (arg3 texture-id) + (arg4 time-frame) + (arg5 symbol) + (arg6 process-tree) + ) + (process-spawn static-screen arg0 arg1 arg2 arg3 arg4 arg5 :to arg6) ) diff --git a/goal_src/levels/title/title-obs.gc b/goal_src/levels/title/title-obs.gc index 9a97d0eaf7..2ad977293b 100644 --- a/goal_src/levels/title/title-obs.gc +++ b/goal_src/levels/title/title-obs.gc @@ -678,7 +678,17 @@ (let ((gp-0 (the-as handle #f))) (case (scf-get-territory) ((2) - (set! gp-0 (ppointer->handle (static-screen-spawn 5 #x64900000 #x64900100 #x64900200 900 #f self))) + (set! gp-0 (ppointer->handle (static-screen-spawn + 5 + (new 'static 'texture-id :page #x649) + (new 'static 'texture-id :index #x1 :page #x649) + (new 'static 'texture-id :index #x2 :page #x649) + (seconds 3) + #f + self + ) + ) + ) ) (else (while (!= (file-status *art-control* "ndi-intro" 0) 'active) diff --git a/test/decompiler/reference/levels/demo/demo-obs_REF.gc b/test/decompiler/reference/levels/demo/demo-obs_REF.gc index 08886be20a..2c58e03adb 100644 --- a/test/decompiler/reference/levels/demo/demo-obs_REF.gc +++ b/test/decompiler/reference/levels/demo/demo-obs_REF.gc @@ -17,17 +17,50 @@ (load-state-want-vis 'vi1) (case (scf-get-territory) ((2) - (let ((gp-0 (ppointer->handle (static-screen-spawn 6 #x27c00000 #x27c00100 #x27c00200 1500 #f self)))) + (let ((gp-0 (ppointer->handle (static-screen-spawn + 6 + (new 'static 'texture-id :page #x27c) + (new 'static 'texture-id :index #x1 :page #x27c) + (new 'static 'texture-id :index #x2 :page #x27c) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-0) (suspend) ) ) - (let ((gp-1 (ppointer->handle (static-screen-spawn 7 #x27d00000 #x27d00100 #x27d00200 1500 #f self)))) + (let ((gp-1 (ppointer->handle (static-screen-spawn + 7 + (new 'static 'texture-id :page #x27d) + (new 'static 'texture-id :index #x1 :page #x27d) + (new 'static 'texture-id :index #x2 :page #x27d) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-1) (suspend) ) ) - (let ((gp-2 (ppointer->handle (static-screen-spawn 8 #x2f000000 #x2f000100 #x2f000200 #x4650 #t self)))) + (let ((gp-2 (ppointer->handle (static-screen-spawn + 8 + (new 'static 'texture-id :page #x2f0) + (new 'static 'texture-id :index #x1 :page #x2f0) + (new 'static 'texture-id :index #x2 :page #x2f0) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-2) (suspend) ) @@ -36,77 +69,198 @@ ((1) (case (-> *setting-control* current language) (((language-enum french)) - (let ((gp-3 (ppointer->handle (static-screen-spawn 10 #x63f00000 #x63f00100 #x63f00200 1500 #f self)))) + (let ((gp-3 (ppointer->handle (static-screen-spawn + 10 + (new 'static 'texture-id :page #x63f) + (new 'static 'texture-id :index #x1 :page #x63f) + (new 'static 'texture-id :index #x2 :page #x63f) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-3) (suspend) ) ) ) (((language-enum german)) - (let ((gp-4 (ppointer->handle (static-screen-spawn 11 #x64000000 #x64000100 #x64000200 1500 #f self)))) + (let ((gp-4 (ppointer->handle (static-screen-spawn + 11 + (new 'static 'texture-id :page #x640) + (new 'static 'texture-id :index #x1 :page #x640) + (new 'static 'texture-id :index #x2 :page #x640) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-4) (suspend) ) ) ) (((language-enum italian)) - (let ((gp-5 (ppointer->handle (static-screen-spawn 12 #x64100000 #x64100100 #x64100200 1500 #f self)))) + (let ((gp-5 (ppointer->handle (static-screen-spawn + 12 + (new 'static 'texture-id :page #x641) + (new 'static 'texture-id :index #x1 :page #x641) + (new 'static 'texture-id :index #x2 :page #x641) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-5) (suspend) ) ) ) (((language-enum spanish)) - (let ((gp-6 (ppointer->handle (static-screen-spawn 13 #x64200000 #x64200100 #x64200200 1500 #f self)))) + (let ((gp-6 (ppointer->handle (static-screen-spawn + 13 + (new 'static 'texture-id :page #x642) + (new 'static 'texture-id :index #x1 :page #x642) + (new 'static 'texture-id :index #x2 :page #x642) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-6) (suspend) ) ) ) (else - (let ((gp-7 (ppointer->handle (static-screen-spawn 2 #x5cd00000 #x5cd00100 #x5cd00200 1500 #f self)))) + (let ((gp-7 (ppointer->handle (static-screen-spawn + 2 + (new 'static 'texture-id :page #x5cd) + (new 'static 'texture-id :index #x1 :page #x5cd) + (new 'static 'texture-id :index #x2 :page #x5cd) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-7) (suspend) ) ) ) ) - (let ((gp-8 (ppointer->handle (static-screen-spawn 3 #x5ce00000 #x5ce00100 #x5ce00200 1500 #f self)))) + (let ((gp-8 (ppointer->handle (static-screen-spawn + 3 + (new 'static 'texture-id :page #x5ce) + (new 'static 'texture-id :index #x1 :page #x5ce) + (new 'static 'texture-id :index #x2 :page #x5ce) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-8) (suspend) ) ) (case (-> *setting-control* current language) (((language-enum french)) - (let ((gp-9 (ppointer->handle (static-screen-spawn 15 #x64400000 #x64400100 #x64400200 #x4650 #t self)))) + (let ((gp-9 (ppointer->handle (static-screen-spawn + 15 + (new 'static 'texture-id :page #x644) + (new 'static 'texture-id :index #x1 :page #x644) + (new 'static 'texture-id :index #x2 :page #x644) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-9) (suspend) ) ) ) (((language-enum german)) - (let ((gp-10 (ppointer->handle (static-screen-spawn 16 #x64500000 #x64500100 #x64500200 #x4650 #t self)))) + (let ((gp-10 (ppointer->handle (static-screen-spawn + 16 + (new 'static 'texture-id :page #x645) + (new 'static 'texture-id :index #x1 :page #x645) + (new 'static 'texture-id :index #x2 :page #x645) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-10) (suspend) ) ) ) (((language-enum italian)) - (let ((gp-11 (ppointer->handle (static-screen-spawn 17 #x64600000 #x64600100 #x64600200 #x4650 #t self)))) + (let ((gp-11 (ppointer->handle (static-screen-spawn + 17 + (new 'static 'texture-id :page #x646) + (new 'static 'texture-id :index #x1 :page #x646) + (new 'static 'texture-id :index #x2 :page #x646) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-11) (suspend) ) ) ) (((language-enum spanish)) - (let ((gp-12 (ppointer->handle (static-screen-spawn 18 #x64700000 #x64700100 #x64700200 #x4650 #t self)))) + (let ((gp-12 (ppointer->handle (static-screen-spawn + 18 + (new 'static 'texture-id :page #x647) + (new 'static 'texture-id :index #x1 :page #x647) + (new 'static 'texture-id :index #x2 :page #x647) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-12) (suspend) ) ) ) (else - (let ((gp-13 (ppointer->handle (static-screen-spawn 14 #x64300000 #x64300100 #x64300200 #x4650 #t self)))) + (let ((gp-13 (ppointer->handle (static-screen-spawn + 14 + (new 'static 'texture-id :page #x643) + (new 'static 'texture-id :index #x1 :page #x643) + (new 'static 'texture-id :index #x2 :page #x643) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-13) (suspend) ) @@ -115,17 +269,50 @@ ) ) (else - (let ((gp-14 (ppointer->handle (static-screen-spawn 2 #x5cd00000 #x5cd00100 #x5cd00200 1500 #f self)))) + (let ((gp-14 (ppointer->handle (static-screen-spawn + 2 + (new 'static 'texture-id :page #x5cd) + (new 'static 'texture-id :index #x1 :page #x5cd) + (new 'static 'texture-id :index #x2 :page #x5cd) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-14) (suspend) ) ) - (let ((gp-15 (ppointer->handle (static-screen-spawn 3 #x5ce00000 #x5ce00100 #x5ce00200 1500 #f self)))) + (let ((gp-15 (ppointer->handle (static-screen-spawn + 3 + (new 'static 'texture-id :page #x5ce) + (new 'static 'texture-id :index #x1 :page #x5ce) + (new 'static 'texture-id :index #x2 :page #x5ce) + (seconds 5) + #f + self + ) + ) + ) + ) (while (handle->process gp-15) (suspend) ) ) - (let ((gp-16 (ppointer->handle (static-screen-spawn 4 #x5cf00000 #x5cf00100 #x5cf00200 #x4650 #t self)))) + (let ((gp-16 (ppointer->handle (static-screen-spawn + 4 + (new 'static 'texture-id :page #x5cf) + (new 'static 'texture-id :index #x1 :page #x5cf) + (new 'static 'texture-id :index #x2 :page #x5cf) + (seconds 60) + #t + self + ) + ) + ) + ) (while (handle->process gp-16) (suspend) ) diff --git a/test/decompiler/reference/levels/demo/static-screen_REF.gc b/test/decompiler/reference/levels/demo/static-screen_REF.gc index 6e4ba150d5..e672208814 100644 --- a/test/decompiler/reference/levels/demo/static-screen_REF.gc +++ b/test/decompiler/reference/levels/demo/static-screen_REF.gc @@ -152,7 +152,7 @@ ;; definition for function static-screen-init-by-other ;; INFO: Return type mismatch int vs none. -(defbehavior static-screen-init-by-other static-screen ((arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 time-frame) (arg5 symbol)) +(defbehavior static-screen-init-by-other static-screen ((arg0 int) (arg1 texture-id) (arg2 texture-id) (arg3 texture-id) (arg4 time-frame) (arg5 symbol)) (let ((s3-0 (lookup-part-group-by-name "group-part-screen1"))) (when (and s3-0 (nonzero? s3-0) (type-type? (-> s3-0 type) sparticle-launch-group)) (set! (-> *part-id-table* 2966 init-specs 0 initial-valuef) (the-as float arg1)) @@ -167,15 +167,26 @@ ) ;; definition for function static-screen-spawn +;; INFO: Return type mismatch (pointer process) vs (pointer static-screen). ;; Used lq/sq -(defun static-screen-spawn ((arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 symbol) (arg6 target)) +(defun static-screen-spawn ((arg0 int) + (arg1 texture-id) + (arg2 texture-id) + (arg3 texture-id) + (arg4 time-frame) + (arg5 symbol) + (arg6 process-tree) + ) (local-vars (sv-16 process)) (set! sv-16 (get-process *default-dead-pool* static-screen #x4000)) - (when sv-16 - (let ((t9-1 (method-of-type static-screen activate))) - (t9-1 (the-as static-screen sv-16) arg6 'static-screen (the-as pointer #x70004000)) + (the-as + (pointer static-screen) + (when sv-16 + (let ((t9-1 (method-of-type static-screen activate))) + (t9-1 (the-as static-screen sv-16) arg6 'static-screen (the-as pointer #x70004000)) + ) + (run-now-in-process sv-16 static-screen-init-by-other arg0 arg1 arg2 arg3 arg4 arg5) + (-> sv-16 ppointer) ) - (run-now-in-process sv-16 static-screen-init-by-other arg0 arg1 arg2 arg3 arg4 arg5) - (-> sv-16 ppointer) ) ) diff --git a/test/decompiler/reference/levels/title/title-obs_REF.gc b/test/decompiler/reference/levels/title/title-obs_REF.gc index 4ef475407d..e46e45e002 100644 --- a/test/decompiler/reference/levels/title/title-obs_REF.gc +++ b/test/decompiler/reference/levels/title/title-obs_REF.gc @@ -723,7 +723,17 @@ (let ((gp-0 (the-as handle #f))) (case (scf-get-territory) ((2) - (set! gp-0 (ppointer->handle (static-screen-spawn 5 #x64900000 #x64900100 #x64900200 900 #f self))) + (set! gp-0 (ppointer->handle (static-screen-spawn + 5 + (new 'static 'texture-id :page #x649) + (new 'static 'texture-id :index #x1 :page #x649) + (new 'static 'texture-id :index #x2 :page #x649) + (seconds 3) + #f + self + ) + ) + ) ) (else (while (!= (file-status *art-control* "ndi-intro" 0) 'active)