|
| 1 | +#include <PR/ultratypes.h> |
| 2 | +#include "variables.h" |
| 3 | +#include "functions.h" |
| 4 | +#include "prevent_bss_reordering.h" |
| 5 | + |
| 6 | +static u8 bss_0x0[5]; |
| 7 | +static u8 bss_0x5; |
| 8 | +static s8 bss_0x6; |
| 9 | + |
| 10 | +void dll_30_ctor(void *self) { |
| 11 | + |
| 12 | +} |
| 13 | + |
| 14 | +void dll_30_dtor(void *self) { |
| 15 | + |
| 16 | +} |
| 17 | + |
| 18 | +void dll_30_func_18() { |
| 19 | + s32 i; |
| 20 | + u8 val; |
| 21 | + |
| 22 | + for (i = 0; i != 5; i++) { |
| 23 | + val = get_gplay_bitstring(311 + i); |
| 24 | + bss_0x0[i] = val; |
| 25 | + |
| 26 | + if (val != 0) { |
| 27 | + bss_0x6 = i; |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + val = get_gplay_bitstring(316); |
| 32 | + bss_0x5 = val; |
| 33 | + if (val == 0) { |
| 34 | + bss_0x5 = 1; |
| 35 | + bss_0x6 = -1; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +// tricky int casting |
| 40 | +#if 1 |
| 41 | +void dll_30_func_DC(u8 param1); |
| 42 | +#pragma GLOBAL_ASM("asm/nonmatchings/dlls/engine/30_tasktext/dll_30_func_DC.s") |
| 43 | +#else |
| 44 | +void dll_30_func_DC(u8 param1) { |
| 45 | + s16 i; |
| 46 | + s16 bs_entry; |
| 47 | + s32 curr_bs_value; |
| 48 | + s32 bit_to_set; |
| 49 | + s32 bit_idx; |
| 50 | + u32 new_bs_value; |
| 51 | + s16 bs_entry2; |
| 52 | + s32 tmp; |
| 53 | + |
| 54 | + // bail if already in array |
| 55 | + for (i = 0; i < 5; i++) { |
| 56 | + if (param1 == bss_0x0[i]) { |
| 57 | + return; |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + if (bss_0x6 != 4) { |
| 62 | + // append if there's room |
| 63 | + bss_0x6 = bss_0x6 + 1; |
| 64 | + bss_0x0[bss_0x6] = param1; |
| 65 | + |
| 66 | + set_gplay_bitstring(311 + bss_0x6, param1); |
| 67 | + } else { |
| 68 | + // otherwise, shift everything down and add to the end |
| 69 | + for (i = 0; i < 4; i++) { |
| 70 | + bss_0x0[i] = bss_0x0[i + 1]; |
| 71 | + } |
| 72 | + |
| 73 | + bss_0x0[4] = param1; |
| 74 | + |
| 75 | + for (i = 0; i < 5; i++) { |
| 76 | + set_gplay_bitstring(311 + i, bss_0x0[i]); |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + tmp = param1; |
| 81 | + if (tmp < 0) { |
| 82 | + tmp = tmp + 31; |
| 83 | + } |
| 84 | + |
| 85 | + bs_entry = 303 + (tmp >> 5); |
| 86 | + |
| 87 | + curr_bs_value = get_gplay_bitstring((s16)bs_entry); |
| 88 | + |
| 89 | + bit_to_set = param1 & 0x1f; |
| 90 | + if (param1 < 0 && (param1 & 0x1f) != 0) { |
| 91 | + bit_to_set = bit_to_set - 32; |
| 92 | + } |
| 93 | + |
| 94 | + new_bs_value = (1 << (s16)bit_to_set) | curr_bs_value; |
| 95 | + |
| 96 | + set_gplay_bitstring((s16)bs_entry, new_bs_value); |
| 97 | + |
| 98 | + |
| 99 | + if (param1 == bss_0x5) { |
| 100 | + do { |
| 101 | + tmp = bss_0x5 + 1; |
| 102 | + bss_0x5 = tmp; |
| 103 | + |
| 104 | + if (bss_0x5 < 0) { |
| 105 | + tmp = tmp + 31; |
| 106 | + } |
| 107 | + |
| 108 | + bs_entry2 = ((tmp >> 5) + 303) >> 16; |
| 109 | + |
| 110 | + if (bs_entry2 != bs_entry) { |
| 111 | + bs_entry = bs_entry2; |
| 112 | + |
| 113 | + new_bs_value = get_gplay_bitstring(bs_entry2); |
| 114 | + } |
| 115 | + |
| 116 | + bit_idx = bss_0x5 & 0x1f; |
| 117 | + if (bss_0x5 < 0 && bit_idx != 0) { |
| 118 | + bit_idx = bit_idx - 32; |
| 119 | + } |
| 120 | + |
| 121 | + } while ((new_bs_value >> (s16)bit_idx) & 1); |
| 122 | + |
| 123 | + set_gplay_bitstring(316, bss_0x5); |
| 124 | + } |
| 125 | + |
| 126 | + if (!param1) { |
| 127 | + gDLL_29_gplay->exports->func_958(NULL, 0, 1, func_80048498()); |
| 128 | + } |
| 129 | +} |
| 130 | +#endif |
| 131 | + |
| 132 | +u8 dll_30_func_368() { |
| 133 | + return bss_0x6 + 1; |
| 134 | +} |
| 135 | + |
| 136 | +void dll_30_func_390(u8 param1) { |
| 137 | + gDLL_text->exports->func[5].withTwoArgs((u16)(bss_0x0[param1] + 244), 0); |
| 138 | +} |
| 139 | + |
| 140 | +void dll_30_func_3F8() { |
| 141 | + gDLL_text->exports->func[5].withTwoArgs((u16)(bss_0x5 + 244), 1); |
| 142 | +} |
| 143 | + |
| 144 | +s16 dll_30_func_454() { |
| 145 | + f32 tmp = bss_0x5 / 206.0f; |
| 146 | + return tmp * 100.0f; |
| 147 | +} |
0 commit comments