Figured out first display list thingy!

Added `ASSERT_SIZE` macro to make sure sizes match
Added compile_flags for mips
This commit is contained in:
Ogre 2023-09-15 15:43:35 +02:00
parent d3dd7a908e
commit a10f6e5db2
14 changed files with 87 additions and 24 deletions

View File

@ -2,4 +2,5 @@
-Ilib/libreultra/include/2.0I
-D_LANGUAGE_C
-D_FINALROM
-DF3DEX_GBI_2
-DF3DEX_GBI_2
--target=mips-linux-gnu

View File

@ -3,6 +3,7 @@
#include <ultra64.h>
#include "assert.h"
#include "element.h"
typedef struct {
@ -21,6 +22,8 @@ typedef struct {
/* 0x0f */ u8 field_0xf;
} AbilityData; // size:0x10
ASSERT_SIZE(AbilityData, 0x10);
extern AbilityData ABILITY_DATA[];
extern char *ability_get_name(u8 index);

7
include/assert.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __ASSERT_H__
#define __ASSERT_H__
#define STATIC_ASSERT(COND,MSG) typedef char MSG[(COND) ? 1 : -1]
#define ASSERT_SIZE(_struct, _size) STATIC_ASSERT(sizeof(_struct) == _size, _struct ## _is_not_size_ ## _size)
#endif // __ASSERT_H__

View File

@ -3,6 +3,7 @@
#include <ultra64.h>
#include "assert.h"
#include "element.h"
typedef struct {
@ -44,4 +45,6 @@ typedef struct {
/* 0x37 */ u8 field_0x37;
} CharacterSlot; // size:0x38
ASSERT_SIZE(CharacterSlot, 0x38);
#endif // __CHARACTER_H__

View File

@ -3,6 +3,7 @@
#include <ultra64.h>
#include "assert.h"
#include "equipment.h"
typedef struct {
@ -79,6 +80,8 @@ typedef struct {
/* 0x47 */ u8 max_items;
} ClassData; // size:0x48
ASSERT_SIZE(ClassData, 0x48);
extern ClassData CLASS_DATA[];
extern EquipmentId (*FP_CLASS_GET_ITEM[4])(u8, u8);

View File

@ -84,7 +84,7 @@ extern s32 D_800E8B14;
extern Unk0 MQ_800E8B4C;
extern s32 __SCREEN_IS_NOT_BLACK;
extern s32 D_800A9EB0;
extern s32 D_800A9EE0;
extern s32 __SOMETHING_FRAMEBUFFERS;
extern s32 D_800C4B20;
extern void* D_800C4CE0;
extern s32 D_A9EF0;
@ -151,7 +151,7 @@ extern void __calls_osViBlack(bool black);
extern void __start_thread_800B9C88();
extern void __start_thread_800BE1C0();
extern void func_80089804(s32*, s32, s32, s32);
extern void __something_display_list(Gfx*, s32, s32, s32);
extern void func_80089A10();
extern void func_80089AB0(s32*, s32);

View File

@ -3,6 +3,8 @@
#include <ultra64.h>
#include "assert.h"
typedef u8 Element;
#define ELEMENT_PHYSICAL 0
@ -25,4 +27,6 @@ typedef u8 Element;
#define ELEMENT_INVALID 0xFF
ASSERT_SIZE(Element, 1);
#endif // __ELEMENT_H__

View File

@ -3,6 +3,7 @@
#include <ultra64.h>
#include "assert.h"
#include "element.h"
typedef u8 EquipmentType;
@ -36,6 +37,8 @@ typedef u8 EquipmentType;
typedef u16 EquipmentId;
ASSERT_SIZE(EquipmentId, 2);
#define EQUIPMENT_ID_GALLANT_DOLL 132
typedef struct {
@ -69,6 +72,8 @@ typedef struct {
/* 0x1f */ u8 field_0x1f;
} EquipmentData; // size:0x20
ASSERT_SIZE(EquipmentData, 0x20);
extern char *EQUIPMENT_TYPE_NAMES[];
extern EquipmentData EQUIPMENT_DATA[];
extern s8 (*FP_EQUIPMENT_GET_RESISTANCE[])(EquipmentId index);

View File

@ -438,7 +438,7 @@ segments:
- [0x40E80, asm]
- [0x420D0, asm]
- [0x42C30, c]
- [0x42C90, asm]
- [0x42C90, c]
- [0x43100, c, "class"]
- [0x44340, c, "ability"]
- [0x45480, c, "equipment"]

View File

@ -111,7 +111,7 @@ INCLUDE_ASM(const s32, "19050", __thread_80089540);
INCLUDE_ASM(const s32, "19050", __start_thread_800B9C88);
INCLUDE_ASM(const s32, "19050", func_80089804);
INCLUDE_ASM(const s32, "19050", __something_display_list);
/* 19D90 80089990 */
void func_80089990(void (*arg0)(s32)) {

View File

@ -1,30 +1,23 @@
#include "PR/gbi.h"
#include "common.h"
/* 1A5B0 8008A1B0 */
void func_8008A1B0(void) {
struct {
/* 0x00 */ s32 field_0x0;
/* 0x04 */ void* field_0x4;
/* 0x08 */ s32 field_0x8;
/* 0x0c */ s32 field_0xc;
/* 0x10 */ s32 field_0x10;
/* 0x14 */ s32 field_0x14;
} sp10;
u8 pad[0x7F0];
Gfx list[257];
Gfx* ptr = list;
__start_thread_800BE1C0();
func_80089AB0(&D_800A9EE0, 3);
D_800C4B20 = 0x80000400;
func_80089AB0(&__SOMETHING_FRAMEBUFFERS, 3);
D_800C4B20 = BOOT_ADDRESS_ULTRA;
set_swap_buffer_func(&__osViSwapBuffer_3);
D_800C4CE0 = &D_800A9EB0;
__start_thread_800B9C88();
sp10.field_0x0 = 0xDE000000;
sp10.field_0x4 = &D_A9EF0;
sp10.field_0x8 = 0xE9000000;
sp10.field_0xc = 0;
sp10.field_0x10 = 0xDF000000;
sp10.field_0x14 = 0;
func_80089804(&sp10, 0x18, 0, 0);
gSPDisplayList(ptr++, &D_A9EF0);
gDPFullSync(ptr++);
gSPEndDisplayList(ptr++);
__something_display_list(list, sizeof(Gfx) * 3, 0, 0);
func_80089A10();
}

18
src/42C90.c Normal file
View File

@ -0,0 +1,18 @@
#include "PR/gbi.h"
#include "common.h"
INCLUDE_ASM(const s32, "42C90", func_8016CD90);
INCLUDE_ASM(const s32, "42C90", func_8016CDCC);
INCLUDE_ASM(const s32, "42C90", func_8016CDF4);
INCLUDE_ASM(const s32, "42C90", func_8016CE40);
INCLUDE_ASM(const s32, "42C90", func_8016CEC4);
INCLUDE_ASM(const s32, "42C90", func_8016CF64);
INCLUDE_ASM(const s32, "42C90", func_8016D068);
INCLUDE_ASM(const s32, "42C90", func_8016D100);

View File

@ -36,7 +36,22 @@ Element ability_get_element(u8 index, u16 arg1, u16 arg2, s32 arg3, u16 arg4) {
INCLUDE_ASM(const s32, "ability", func_8016E50C);
INCLUDE_ASM(const s32, "ability", func_8016EA34);
// INCLUDE_ASM(const s32, "ability", func_8016EA34);
/* 44934 8016EA34 */
u8 func_8016EA34(u8 portrait, u8 class, u8 arg2)
{
if (CLASS_DATA[portrait].field_0x45 != class)
portrait = class;
portrait = (CLASS_DATA[portrait].field_0x42 != 0xFF && arg2 < CLASS_DATA[portrait].field_0x42) ?
CLASS_DATA[portrait].field_0x41 :
(CLASS_DATA[portrait].field_0x44 != 0xFF && arg2 < CLASS_DATA[portrait].field_0x44) ?
CLASS_DATA[portrait].field_0x43 : portrait;
return portrait;
}
/* 449EC 8016EAEC */
u16 character_get_item(CharacterSlot* character, u8 slot) {

View File

@ -1,3 +1,10 @@
__SOMETHING_FRAMEBUFFERS = 0x800A9EE0; // rom:0x3A2E0 size:0xC
__something_display_list = 0x80089804; // rom:0x19C04
__SOMETHING_WITH_GFX = 0x800E9BE0; // size:0x18
__MAYBE_DISPLAY_LIST = 0x801B8430; // rom:0x1EE930
FP_CLASS_GET_ITEM = 0x8018B494; // rom:0x61394 size:0x10
__restore_zombie_hp_to_max = 0x80219EEC; // rom:0x1B75DC
@ -27,6 +34,10 @@ __CONTAINS_BATTALION_NAME = 0x80196A58; // size:0x94
DEFAULT_BATTALION_NAME = 0x80190EFC; // rom:0x66DFC type:asciz
STR_COMMAND_MOBILE_WALL = 0x80212FF0; // rom:0x164160 type:asciz
STR_LEGION_LED_BY_COMMANDER_OF_BATTALION_MAY = 0x801EEBA4; // rom:0x1432E4 type:asciz
STR_UNPACK_ERROR_UNSUPPORTED_FORMAT = 0x800AE038; // rom:0x3E438
STR_SERIFU_POSITION_X_ERROR = 0x8019E20C; // rom:0xEAF8C type:asciz