summaryrefslogtreecommitdiff
path: root/src/Runtime/Gecko_ExceptionPPC.cpp
blob: 693aa2502eed184f4f6c0f3483df06a079a7690c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// This file was taken from the Metroid Prime decompilation project.
// https://github.com/PrimeDecomp/prime/blob/main/src/Runtime/Gecko_ExceptionPPC.cpp
#include "__ppc_eabi_linker.h"
#include "NMWException.h"

#if __MWERKS__
#pragma exceptions on
#endif

typedef struct ProcessInfo {
  __eti_init_info* exception_info;
  char* TOC;
  int active;
} ProcessInfo;

static ProcessInfo fragmentinfo[1];

int __register_fragment(struct __eti_init_info* info, char* TOC) {
  ProcessInfo* f;
  int i;

  for (i = 0, f = fragmentinfo; i < 1; ++i, ++f) {
    if (f->active == 0) {
      f->exception_info = info;
      f->TOC = TOC;
      f->active = 1;
      return (i);
    }
  }

  return (-1);
}

void __unregister_fragment(int fragmentId) {
  ProcessInfo* f;
  if (fragmentId >= 0 && fragmentId < 1) {
    f = &fragmentinfo[fragmentId];
    f->exception_info = 0;
    f->TOC = 0;
    f->active = 0;
  }
}