|
| 1 | +#include "dsmoke2.h" |
| 2 | +#include "libgcl/libgcl.h" |
| 3 | + |
| 4 | +// External globals |
| 5 | +extern char s11d_dword_800D1E6C[]; // Name string "dsmoke2" |
| 6 | +extern int GV_Clock; |
| 7 | + |
| 8 | +// Forward declarations for all 12 functions |
| 9 | +int s11d_dsmoke2_800CC08C(DSmoke2Work *work, SVECTOR *arg1); |
| 10 | +void s11d_dsmoke2_800CC0E0(DSmoke2Work *work, SVECTOR *arg1); |
| 11 | +void s11d_dsmoke2_800CC1DC(DSmoke2Work *work, int arg1); |
| 12 | +void s11d_dsmoke2_800CC418(DSmoke2Work *work); |
| 13 | +void s11d_dsmoke2_800CC4B8(DSmoke2Work *work); |
| 14 | +void s11d_dsmoke2_800CC648(DSmoke2Work *work); |
| 15 | +void s11d_dsmoke2_800CC730(DSmoke2Work *work); |
| 16 | +void s11d_dsmoke2_800CC794(DSmoke2Work *work, int arg1); |
| 17 | +void s11d_dsmoke2_800CCAB4(DSmoke2Work *work); |
| 18 | +int s11d_dsmoke2_800CCC60(DSmoke2Work *work, int where, int argc); |
| 19 | +void s11d_dsmoke2_800CCCE0(DSmoke2Work *work); |
| 20 | +void *s11d_dsmoke2_800CCD54(int name, int where, int argc, char **argv); |
| 21 | + |
| 22 | +// s11d_dsmoke2_800CC08C - Check if position is in range (26 lines) |
| 23 | +int s11d_dsmoke2_800CC08C(DSmoke2Work *work, SVECTOR *arg1) |
| 24 | +{ |
| 25 | + short val1, val2; |
| 26 | + short range_min, range_max; |
| 27 | + |
| 28 | + val1 = *(short *)((char *)work + 0x6E); |
| 29 | + val2 = *(short *)((char *)work + 0x76); |
| 30 | + |
| 31 | + if (val2 < val1) |
| 32 | + { |
| 33 | + range_max = val1 + 2000; |
| 34 | + range_min = val1 - 2000; |
| 35 | + } |
| 36 | + else |
| 37 | + { |
| 38 | + range_max = val1 + 2000; |
| 39 | + range_min = val2 - 2000; |
| 40 | + } |
| 41 | + |
| 42 | + if (arg1->vy < range_min || arg1->vy > range_max) |
| 43 | + { |
| 44 | + return 1; |
| 45 | + } |
| 46 | + |
| 47 | + return 0; |
| 48 | +} |
| 49 | + |
| 50 | +// s11d_dsmoke2_800CC0E0 - Vector operations helper (68 lines) |
| 51 | +void s11d_dsmoke2_800CC0E0(DSmoke2Work *work, SVECTOR *arg1) |
| 52 | +{ |
| 53 | + // Uses GV_SubVec3 and other vector operations |
| 54 | + // TBD - needs detailed assembly analysis |
| 55 | +} |
| 56 | + |
| 57 | +// s11d_dsmoke2_800CC1DC - Major update function (148 lines) |
| 58 | +void s11d_dsmoke2_800CC1DC(DSmoke2Work *work, int arg1) |
| 59 | +{ |
| 60 | + // Large function with collision checks |
| 61 | + // TBD - needs detailed assembly analysis |
| 62 | +} |
| 63 | + |
| 64 | +// s11d_dsmoke2_800CC418 - Helper function (45 lines) |
| 65 | +void s11d_dsmoke2_800CC418(DSmoke2Work *work) |
| 66 | +{ |
| 67 | + // Medium complexity helper |
| 68 | + // TBD - needs detailed assembly analysis |
| 69 | +} |
| 70 | + |
| 71 | +// s11d_dsmoke2_800CC4B8 - Primitive rendering (105 lines) |
| 72 | +void s11d_dsmoke2_800CC4B8(DSmoke2Work *work) |
| 73 | +{ |
| 74 | + // Handles primitive rendering based on field_284-28A |
| 75 | + // TBD - needs detailed assembly analysis |
| 76 | +} |
| 77 | + |
| 78 | +// s11d_dsmoke2_800CC648 - Act function (63 lines) |
| 79 | +void s11d_dsmoke2_800CC648(DSmoke2Work *work) |
| 80 | +{ |
| 81 | + GM_CurrentMap = work->field_B0; |
| 82 | + |
| 83 | + if (work->field_BC != 0) |
| 84 | + { |
| 85 | + work->field_BC--; |
| 86 | + return; |
| 87 | + } |
| 88 | + |
| 89 | + if (work->field_B4 < 0) |
| 90 | + { |
| 91 | + return; |
| 92 | + } |
| 93 | + |
| 94 | + if (work->field_B2 == 0) |
| 95 | + { |
| 96 | + if (work->field_B8 != work->field_B6) |
| 97 | + { |
| 98 | + work->field_B2 = 1; |
| 99 | + } |
| 100 | + |
| 101 | + if (work->field_B6 - 24 >= work->field_B8 && |
| 102 | + work->field_B8 >= work->field_B6 - 18) |
| 103 | + { |
| 104 | + s11d_dsmoke2_800CC1DC(work, work->field_84 + 0x6C); |
| 105 | + } |
| 106 | + |
| 107 | + s11d_dsmoke2_800CC418(work); |
| 108 | + |
| 109 | + work->field_B8++; |
| 110 | + return; |
| 111 | + } |
| 112 | + |
| 113 | + s11d_dsmoke2_800CCCE0(work); |
| 114 | +} |
| 115 | + |
| 116 | +// s11d_dsmoke2_800CC730 - Die function (30 lines) |
| 117 | +void s11d_dsmoke2_800CC730(DSmoke2Work *work) |
| 118 | +{ |
| 119 | + void **ptr; |
| 120 | + int i; |
| 121 | + |
| 122 | + ptr = (void **)work->prims; |
| 123 | + for (i = 0; i < 16; i++) |
| 124 | + { |
| 125 | + if (*ptr != NULL) |
| 126 | + { |
| 127 | + GM_FreeObject((OBJECT *)*ptr); |
| 128 | + DG_FreePrim((DG_PRIM *)*ptr); |
| 129 | + } |
| 130 | + ptr++; |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +// s11d_dsmoke2_800CC794 - Main rendering/update (205 lines) |
| 135 | +void s11d_dsmoke2_800CC794(DSmoke2Work *work, int arg1) |
| 136 | +{ |
| 137 | + // Largest function - main rendering logic |
| 138 | + // Accesses field_280, field_284-28A |
| 139 | + // TBD - needs detailed assembly analysis |
| 140 | +} |
| 141 | + |
| 142 | +// s11d_dsmoke2_800CCAB4 - GCL operations (112 lines) |
| 143 | +void s11d_dsmoke2_800CCAB4(DSmoke2Work *work) |
| 144 | +{ |
| 145 | + // GCL-related operations using field_98 array |
| 146 | + // TBD - needs detailed assembly analysis |
| 147 | +} |
| 148 | + |
| 149 | +// s11d_dsmoke2_800CCC60 - Init function (37 lines) |
| 150 | +int s11d_dsmoke2_800CCC60(DSmoke2Work *work, int where, int argc) |
| 151 | +{ |
| 152 | + int i; |
| 153 | + int *gcl_ptr; |
| 154 | + |
| 155 | + if (GCL_GetOption('p') == 0) |
| 156 | + { |
| 157 | + return -1; |
| 158 | + } |
| 159 | + |
| 160 | + gcl_ptr = (int *)&work->field_98; |
| 161 | + i = 0; |
| 162 | + |
| 163 | + while (i < 3) |
| 164 | + { |
| 165 | + if (GCL_GetParamResult() == 0) |
| 166 | + { |
| 167 | + break; |
| 168 | + } |
| 169 | + |
| 170 | + if (i == 3) |
| 171 | + { |
| 172 | + GCL_StrToInt((unsigned char *)gcl_ptr); |
| 173 | + gcl_ptr += 2; |
| 174 | + i++; |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + work->field_94 = i; |
| 179 | + return 0; |
| 180 | +} |
| 181 | + |
| 182 | +// s11d_dsmoke2_800CCCE0 - Small helper (34 lines) |
| 183 | +void s11d_dsmoke2_800CCCE0(DSmoke2Work *work) |
| 184 | +{ |
| 185 | + s11d_dsmoke2_800CCAB4(work); |
| 186 | + s11d_dsmoke2_800CC794(work, 0); |
| 187 | + s11d_dsmoke2_800CC0E0(work, NULL); |
| 188 | +} |
| 189 | + |
| 190 | +// s11d_dsmoke2_800CCD54 - Constructor (40 lines) |
| 191 | +void *s11d_dsmoke2_800CCD54(int name, int where, int argc, char **argv) |
| 192 | +{ |
| 193 | + DSmoke2Work *work; |
| 194 | + |
| 195 | + work = (DSmoke2Work *)GV_NewActor(6, sizeof(DSmoke2Work)); |
| 196 | + if (work != NULL) |
| 197 | + { |
| 198 | + GV_SetNamedActor(&work->actor, |
| 199 | + s11d_dsmoke2_800CC648, |
| 200 | + s11d_dsmoke2_800CC730, |
| 201 | + s11d_dword_800D1E6C); |
| 202 | + |
| 203 | + if (s11d_dsmoke2_800CCC60(work, where, argc) < 0) |
| 204 | + { |
| 205 | + GV_DestroyActor(&work->actor); |
| 206 | + return NULL; |
| 207 | + } |
| 208 | + |
| 209 | + return work; |
| 210 | + } |
| 211 | + |
| 212 | + return NULL; |
| 213 | +} |
0 commit comments