mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-11 03:39:59 +00:00
Force required alignment on DMA related stuff (#1135)
* Force dword alignment on OSPifRam * force_structure_alignment on each Font buffer * Add ALIGNED8 macro to gSaveContext to ensure alignment * create alignment.h header and use ALIGN8 in PLAYER_LIMB_BUF_COUNT * add comment in common_data * Roman's suggestion * player_limb_buf_count Co-authored-by: fig02 <fig02srl@gmail.com>
This commit is contained in:
parent
c8d150afe2
commit
8926b08582
6 changed files with 36 additions and 16 deletions
16
include/alignment.h
Normal file
16
include/alignment.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef ALIGNMENT_H
|
||||||
|
#define ALIGNMENT_H
|
||||||
|
|
||||||
|
#define ALIGN8(val) (((val) + 7) & ~7)
|
||||||
|
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||||
|
#define ALIGN32(val) (((val) + 0x1F) & ~0x1F)
|
||||||
|
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
|
||||||
|
#define ALIGN256(val) (((val) + 0xFF) & ~0xFF)
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define ALIGNED8 __attribute__ ((aligned (8)))
|
||||||
|
#else
|
||||||
|
#define ALIGNED8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -8,11 +8,6 @@
|
||||||
#define VIRTUAL_TO_PHYSICAL(addr) (u32)((u8*)(addr) - 0x80000000)
|
#define VIRTUAL_TO_PHYSICAL(addr) (u32)((u8*)(addr) - 0x80000000)
|
||||||
#define SEGMENTED_TO_VIRTUAL(addr) PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr))
|
#define SEGMENTED_TO_VIRTUAL(addr) PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr))
|
||||||
|
|
||||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
|
||||||
#define ALIGN32(val) (((val) + 0x1F) & ~0x1F)
|
|
||||||
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
|
|
||||||
#define ALIGN256(val) (((val) + 0xFF) & ~0xFF)
|
|
||||||
|
|
||||||
#define OFFSETOF(structure, member) ((size_t)&(((structure*)0)->member))
|
#define OFFSETOF(structure, member) ((size_t)&(((structure*)0)->member))
|
||||||
|
|
||||||
#define SQ(x) ((x)*(x))
|
#define SQ(x) ((x)*(x))
|
||||||
|
@ -168,10 +163,4 @@ extern GraphicsContext* __gfxCtx;
|
||||||
((height)-1) << G_TEXTURE_IMAGE_FRAC); \
|
((height)-1) << G_TEXTURE_IMAGE_FRAC); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define ALIGNED8 __attribute__ ((aligned (8)))
|
|
||||||
#else
|
|
||||||
#define ALIGNED8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -96,9 +96,12 @@
|
||||||
#define BTN_B 0x4000
|
#define BTN_B 0x4000
|
||||||
#define BTN_A 0x8000
|
#define BTN_A 0x8000
|
||||||
|
|
||||||
typedef struct {
|
typedef union {
|
||||||
|
struct {
|
||||||
/* 0x00 */ u32 ram[15];
|
/* 0x00 */ u32 ram[15];
|
||||||
/* 0x3C */ u32 status;
|
/* 0x3C */ u32 status;
|
||||||
|
};
|
||||||
|
u64 force_structure_alignment;
|
||||||
} OSPifRam; // size = 0x40
|
} OSPifRam; // size = 0x40
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "z64skin.h"
|
#include "z64skin.h"
|
||||||
#include "z64transition.h"
|
#include "z64transition.h"
|
||||||
#include "z64interface.h"
|
#include "z64interface.h"
|
||||||
|
#include "alignment.h"
|
||||||
#include "sequence.h"
|
#include "sequence.h"
|
||||||
#include "sfx.h"
|
#include "sfx.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
@ -49,8 +50,6 @@
|
||||||
#define Z_PRIORITY_DMAMGR 16
|
#define Z_PRIORITY_DMAMGR 16
|
||||||
#define Z_PRIORITY_IRQMGR 17
|
#define Z_PRIORITY_IRQMGR 17
|
||||||
|
|
||||||
#define ALIGN8(val) (((val) + 7) & ~7)
|
|
||||||
|
|
||||||
#define STACK(stack, size) \
|
#define STACK(stack, size) \
|
||||||
u64 stack[ALIGN8(size) / sizeof(u64)]
|
u64 stack[ALIGN8(size) / sizeof(u64)]
|
||||||
|
|
||||||
|
@ -521,12 +520,22 @@ typedef enum {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x0000 */ u32 msgOffset;
|
/* 0x0000 */ u32 msgOffset;
|
||||||
/* 0x0004 */ u32 msgLength;
|
/* 0x0004 */ u32 msgLength;
|
||||||
|
union {
|
||||||
/* 0x0008 */ u8 charTexBuf[FONT_CHAR_TEX_SIZE * 120];
|
/* 0x0008 */ u8 charTexBuf[FONT_CHAR_TEX_SIZE * 120];
|
||||||
|
/* 0x0008 */ u64 force_structure_alignment_charTex;
|
||||||
|
};
|
||||||
|
union {
|
||||||
/* 0x3C08 */ u8 iconBuf[FONT_CHAR_TEX_SIZE];
|
/* 0x3C08 */ u8 iconBuf[FONT_CHAR_TEX_SIZE];
|
||||||
|
/* 0x3C08 */ u64 force_structure_alignment_icon;
|
||||||
|
};
|
||||||
|
union {
|
||||||
/* 0x3C88 */ u8 fontBuf[FONT_CHAR_TEX_SIZE * 320];
|
/* 0x3C88 */ u8 fontBuf[FONT_CHAR_TEX_SIZE * 320];
|
||||||
|
/* 0x3C88 */ u64 force_structure_alignment_font;
|
||||||
|
};
|
||||||
union {
|
union {
|
||||||
/* 0xDC88 */ char msgBuf[1280];
|
/* 0xDC88 */ char msgBuf[1280];
|
||||||
/* 0xDC88 */ u16 msgBufWide[640];
|
/* 0xDC88 */ u16 msgBufWide[640];
|
||||||
|
/* 0xDC88 */ u64 force_structure_alignment_msg;
|
||||||
};
|
};
|
||||||
} Font; // size = 0xE188
|
} Font; // size = 0xE188
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define Z64PLAYER_H
|
#define Z64PLAYER_H
|
||||||
|
|
||||||
#include "z64actor.h"
|
#include "z64actor.h"
|
||||||
|
#include "alignment.h"
|
||||||
|
|
||||||
struct Player;
|
struct Player;
|
||||||
|
|
||||||
|
@ -158,7 +159,8 @@ typedef enum {
|
||||||
} PlayerDoorType;
|
} PlayerDoorType;
|
||||||
|
|
||||||
|
|
||||||
#define PLAYER_LIMB_BUF_COUNT PLAYER_LIMB_MAX + 2 // 2 extra entries in limb buffers?
|
#define LIMB_BUF_COUNT(limbCount) ((ALIGN16((limbCount) * sizeof(Vec3s)) + sizeof(Vec3s) - 1) / sizeof(Vec3s))
|
||||||
|
#define PLAYER_LIMB_BUF_COUNT LIMB_BUF_COUNT(PLAYER_LIMB_MAX)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 0x00 */ f32 unk_00;
|
/* 0x00 */ f32 unk_00;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
SaveContext gSaveContext;
|
// The use of ALIGNED8 here is just a temporary solution until the SaveContext is re-structured
|
||||||
|
ALIGNED8 SaveContext gSaveContext;
|
||||||
u32 D_8015FA88;
|
u32 D_8015FA88;
|
||||||
u32 D_8015FA8C;
|
u32 D_8015FA8C;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue