| 194 | } |
| 195 | |
| 196 | extern "C" void recomp_get_object_data(uint8_t* rdram, recomp_context* ctx) { |
| 197 | u32 type_index = _arg<0, u32>(rdram, ctx); |
| 198 | u32 subtype_index = _arg<1, u32>(rdram, ctx); |
| 199 | u32 object_handle = _arg<2, u32>(rdram, ctx); |
| 200 | u32 extension_handle = _arg<3, u32>(rdram, ctx); |
| 201 | |
| 202 | ExtensionContext& context = type_contexts[type_index]; |
| 203 | std::lock_guard lock{ extension_mutex }; |
| 204 | |
| 205 | // Check if the extension handle is valid. |
| 206 | if (extension_handle == 0 || extension_handle >= context.extensions.size()) { |
| 207 | _return<PTR(void)>(ctx, NULLPTR); |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | ExtensionInfo& extension = context.extensions[extension_handle]; |
| 212 | bool generic_extension = extension.subtype_index == 0xFFFFFFFFU; |
| 213 | |
| 214 | // Check if the extension is generic or for the provided subtype. |
| 215 | if (!generic_extension && extension.subtype_index != subtype_index) { |
| 216 | _return<PTR(void)>(ctx, NULLPTR); |
| 217 | return; |
| 218 | } |
| 219 | |
| 220 | extension_data_map_t::key object_key{object_handle}; |
| 221 | ExtensionData* data = context.extension_data.get(object_key); |
| 222 | |
| 223 | // Check if object handle is valid. |
| 224 | if (data == nullptr) { |
| 225 | _return<PTR(void)>(ctx, NULLPTR); |
| 226 | return; |
| 227 | } |
| 228 | |
| 229 | // Calculate the address for this specific extension's data. |
| 230 | PTR(void) base_address = data->data_addr; |
| 231 | u32 offset = extension.data_offset; |
| 232 | // Specific object data is after generic object data, so increase the offset by the total generic object data if this isn't generic data. |
| 233 | if (!generic_extension) { |
| 234 | offset += context.generic_data_size; |
| 235 | } |
| 236 | |
| 237 | PTR(void) ret = base_address + offset; |
| 238 | _return<PTR(void)>(ctx, ret); |
| 239 | } |
| 240 | |
| 241 | extern "C" void recomp_get_object_spawn_index(uint8_t* rdram, recomp_context* ctx) { |
| 242 | u32 type_index = _arg<0, u32>(rdram, ctx); |
no test coverage detected