Skip to content

Commit a2f201d

Browse files
authored
Add on init callback to GameEntry, fix thread_queue_remove not actually removing the thread (#87)
1 parent 0afeb08 commit a2f201d

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

librecomp/include/librecomp/game.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ namespace recomp {
3030
bool has_compressed_code = false;
3131

3232
gpr entrypoint_address;
33-
void (*entrypoint)(uint8_t* rdram, recomp_context* context);
33+
void (*entrypoint)(uint8_t* rdram, recomp_context* context) = nullptr;
3434

35-
void (*thread_create_callback)(uint8_t* rdram, recomp_context* context);
35+
void (*thread_create_callback)(uint8_t* rdram, recomp_context* context) = nullptr;
36+
37+
void (*on_init_callback)(uint8_t* rdram, recomp_context* context) = nullptr;
3638

3739
std::u8string stored_filename() const;
3840
};

librecomp/src/recomp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,9 @@ bool wait_for_game_started(uint8_t* rdram, recomp_context* context) {
530530
const recomp::GameEntry& game_entry = find_it->second;
531531

532532
init(rdram, context, game_entry.entrypoint_address);
533+
if (game_entry.on_init_callback) {
534+
game_entry.on_init_callback(rdram, context);
535+
}
533536

534537
uint32_t mod_ram_used = 0;
535538
if (!game_entry.mod_game_id.empty()) {

ultramodern/src/threadqueue.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ bool ultramodern::thread_queue_remove(RDRAM_ARG PTR(PTR(OSThread)) queue_, PTR(O
4747
while (cur != NULLPTR) {
4848
PTR(OSThread)* cur_ptr = queue_to_ptr(PASS_RDRAM queue_);
4949
if (*cur_ptr == t_) {
50+
*cur_ptr = TO_PTR(OSThread, *cur_ptr)->next;
5051
return true;
5152
}
5253
cur = TO_PTR(OSThread, *cur_ptr)->next;

0 commit comments

Comments
 (0)