diff options
| author | Akira Akashi <rubenru09@aol.com> | 2021-06-03 02:48:35 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-03 02:48:35 +0100 | 
| commit | 33a7ec1fd719b9321357aa59460cbdb9f7779053 (patch) | |
| tree | 993c0c156f6a3c310cccd2a3e0ac802b59ab149e /arm9/lib/include | |
| parent | 7e32d3758e7e36d7a67a1442cdb9386f9aa18a6e (diff) | |
| parent | 6e3af5fa580d0f6aca3bb310d979323bf2a09a84 (diff) | |
Merge pull request #400 from PikalaxALT/doc_heap_etc
SDK-informed refactoring
Diffstat (limited to 'arm9/lib/include')
| -rw-r--r-- | arm9/lib/include/NNS_FND_allocator.h | 34 | ||||
| -rw-r--r-- | arm9/lib/include/NNS_FND_expheap.h | 55 | ||||
| -rw-r--r-- | arm9/lib/include/NNS_FND_heapcommon.h | 26 | ||||
| -rw-r--r-- | arm9/lib/include/NNS_FND_list.h | 20 | ||||
| -rw-r--r-- | arm9/lib/include/OS_irqHandler.h | 2 | ||||
| -rw-r--r-- | arm9/lib/include/consts.h | 1 | ||||
| -rw-r--r-- | arm9/lib/include/gx.h | 23 | ||||
| -rw-r--r-- | arm9/lib/include/registers.h | 38 | ||||
| -rw-r--r-- | arm9/lib/include/tp.h | 8 | 
9 files changed, 197 insertions, 10 deletions
| diff --git a/arm9/lib/include/NNS_FND_allocator.h b/arm9/lib/include/NNS_FND_allocator.h new file mode 100644 index 00000000..48df282a --- /dev/null +++ b/arm9/lib/include/NNS_FND_allocator.h @@ -0,0 +1,34 @@ +#ifndef GUARD_NNS_FND_ALLOCATOR_H
 +#define GUARD_NNS_FND_ALLOCATOR_H
 +
 +#include "NNS_FND_heapcommon.h"
 +
 +typedef struct NNSFndAllocator NNSFndAllocator;
 +
 +typedef void*   (*NNSFndFuncAllocatorAlloc)(
 +    NNSFndAllocator*    pAllocator,
 +    u32                 size);
 +
 +typedef void    (*NNSFndFuncAllocatorFree)(
 +    NNSFndAllocator*    pAllocator,
 +    void*               memBlock);
 +
 +typedef struct NNSFndAllocatorFunc NNSFndAllocatorFunc;
 +
 +struct NNSFndAllocatorFunc
 +{
 +    NNSFndFuncAllocatorAlloc    pfAlloc;
 +    NNSFndFuncAllocatorFree     pfFree;
 +};
 +
 +struct NNSFndAllocator
 +{
 +    NNSFndAllocatorFunc const * pFunc;
 +    void*                       pHeap;
 +    u32                         heapParam1;
 +    u32                         heapParam2;
 +};
 +
 +void NNS_FndInitAllocatorForExpHeap(NNSFndAllocator * pAllocator, NNSFndHeapHandle heap, int alignment);
 +
 +#endif //GUARD_NNS_FND_ALLOCATOR_H
 diff --git a/arm9/lib/include/NNS_FND_expheap.h b/arm9/lib/include/NNS_FND_expheap.h new file mode 100644 index 00000000..c0008f28 --- /dev/null +++ b/arm9/lib/include/NNS_FND_expheap.h @@ -0,0 +1,55 @@ +#ifndef GUARD_NNS_FND_EXPHEAP_H
 +#define GUARD_NNS_FND_EXPHEAP_H
 +
 +#include "NNS_FND_heapcommon.h"
 +
 +typedef struct NNSiFndExpHeapMBlockHead NNSiFndExpHeapMBlockHead;
 +
 +struct NNSiFndExpHeapMBlockHead
 +{
 +    u16                         signature;      // Signature
 +    u16                         attribute;      // Attribute
 +    // [8:groupID]
 +    // [7:alignment]
 +    // [1:temporary flag]
 +
 +    u32                         blockSize;      // Block size (data area only)
 +
 +    NNSiFndExpHeapMBlockHead*   pMBHeadPrev;    // Previous block
 +    NNSiFndExpHeapMBlockHead*   pMBHeadNext;    // Next block
 +};
 +
 +typedef struct NNSiFndExpMBlockList NNSiFndExpMBlockList;
 +
 +struct NNSiFndExpMBlockList
 +{
 +    NNSiFndExpHeapMBlockHead*   head;   // Pointer for memory block linked to header
 +    NNSiFndExpHeapMBlockHead*   tail;   // Pointer to the memory block linked to the tail of the expanded heap
 +};
 +
 +typedef struct NNSiFndExpHeapHead NNSiFndExpHeapHead;
 +
 +struct NNSiFndExpHeapHead
 +{
 +    NNSiFndExpMBlockList        mbFreeList;     // Free list
 +    NNSiFndExpMBlockList        mbUsedList;     // Used list
 +
 +    u16                         groupID;        // Current group ID (lower 8 bits only)
 +    u16                         feature;        // Attribute
 +};
 +
 +NNSFndHeapHandle NNS_FndCreateExpHeapEx(void *startAddress, u32 size, u32 optFlag);
 +void *NNS_FndAllocFromExpHeapEx(NNSFndHeapHandle heap, u32 size, int alignment);
 +void NNS_FndDestroyExpHeap(NNSFndHeapHandle heap);
 +void NNS_FndFreeToExpHeap(NNSFndHeapHandle heap, void *memBlock);
 +u32 NNS_FndGetTotalFreeSizeForExpHeap(NNSFndHeapHandle heap);
 +u32 NNS_FndGetSizeForMBlockExpHeap(const void *memBlock);
 +void NNS_FndResizeForMBlockExpHeap(NNSFndHeapHandle heap, void *memBlock, u32 size);
 +
 +#define             NNS_FndCreateExpHeap(startAddress, size) \
 +                        NNS_FndCreateExpHeapEx(startAddress, size, 0)
 +#define             NNS_FndAllocFromExpHeap(heap, size) \
 +                        NNS_FndAllocFromExpHeapEx(heap, size, NNS_FND_HEAP_DEFAULT_ALIGNMENT)
 +
 +
 +#endif //GUARD_NNS_FND_EXPHEAP_H
 diff --git a/arm9/lib/include/NNS_FND_heapcommon.h b/arm9/lib/include/NNS_FND_heapcommon.h new file mode 100644 index 00000000..eb6f1bdb --- /dev/null +++ b/arm9/lib/include/NNS_FND_heapcommon.h @@ -0,0 +1,26 @@ +#ifndef GUARD_NNS_FND_HEAPCOMMON_H
 +#define GUARD_NNS_FND_HEAPCOMMON_H
 +
 +#include "NNS_FND_list.h"
 +
 +#define NNS_FND_HEAP_DEFAULT_ALIGNMENT          4
 +
 +typedef struct NNSiFndHeapHead NNSiFndHeapHead;
 +
 +struct NNSiFndHeapHead
 +{
 +    u32             signature;
 +
 +    NNSFndLink      link;
 +    NNSFndList      childList;
 +
 +    void*           heapStart;      // Heap start address
 +    void*           heapEnd;        // Heap end (+1) address
 +
 +    u32             attribute;      // Attribute
 +    // [8:Option flag]
 +};
 +
 +typedef NNSiFndHeapHead* NNSFndHeapHandle;   // Type to represent heap handle
 +
 +#endif //GUARD_NNS_FND_HEAPCOMMON_H
 diff --git a/arm9/lib/include/NNS_FND_list.h b/arm9/lib/include/NNS_FND_list.h new file mode 100644 index 00000000..5df01e5f --- /dev/null +++ b/arm9/lib/include/NNS_FND_list.h @@ -0,0 +1,20 @@ +#ifndef GUARD_NNS_FND_LIST_H
 +#define GUARD_NNS_FND_LIST_H
 +
 +typedef struct
 +{
 +    void*       prevObject;     // Pointer to the previous linked object.
 +    void*       nextObject;     // Pointer to the next linked object.
 +
 +} NNSFndLink;
 +
 +typedef struct
 +{
 +    void*       headObject;     // Pointer for the object linked to the top of the list.
 +    void*       tailObject;     // Pointer for the object linked to the end of the list.
 +    u16         numObjects;     // Number of objects linked in the list.
 +    u16         offset;         // Offset for NNSFndLink type structure member.
 +
 +} NNSFndList;
 +
 +#endif //GUARD_NNS_FND_LIST_H
 diff --git a/arm9/lib/include/OS_irqHandler.h b/arm9/lib/include/OS_irqHandler.h index f052016d..ea12a0ad 100644 --- a/arm9/lib/include/OS_irqHandler.h +++ b/arm9/lib/include/OS_irqHandler.h @@ -16,6 +16,6 @@ static inline OSIrqMask OS_GetIrqCheckFlag(void)  void OS_IrqHandler(void);  void OS_IrqHandler_ThreadSwitch(void); -void OS_WaitIrq(BOOL param1, u32 param2); +void OS_WaitIrq(BOOL clear, OSIrqMask irqFlags);  #endif //POKEDIAMOND_OS_IRQHANDLER_H diff --git a/arm9/lib/include/consts.h b/arm9/lib/include/consts.h index a41f22ae..1ad79b93 100644 --- a/arm9/lib/include/consts.h +++ b/arm9/lib/include/consts.h @@ -52,6 +52,7 @@  #define OSi_TCM_REGION_BASE_MASK   0xfffff000  #define OS_IE_V_BLANK              (1UL << 0) +#define OS_IE_H_BLANK              (1UL << 1)  #define HW_CPU_CLOCK_ARM9          67027964 diff --git a/arm9/lib/include/gx.h b/arm9/lib/include/gx.h index 11081942..acd23b39 100644 --- a/arm9/lib/include/gx.h +++ b/arm9/lib/include/gx.h @@ -27,15 +27,6 @@ void GXi_NopClearFifo128_(void *);  #include "GX_g3imm.h"  #include "GX_dma.h" -void GX_Init(); -u32 GX_HBlankIntr(u32 enable); -u32 GX_VBlankIntr(u32 enable); -void GX_DispOff(); -void GX_DispOn(); -void GX_SetGraphicsMode(u32 mode1, u32 mode2, u32 mode3); -void GXS_SetGraphicsMode(u32 mode); -void GXx_SetMasterBrightness_(vu16 *dst, s32 brightness); -  typedef union  {      u32     raw; @@ -181,4 +172,18 @@ typedef enum  }      GXOBJVRamModeChar; +void GX_Init(); +u32 GX_HBlankIntr(u32 enable); +u32 GX_VBlankIntr(u32 enable); +void GX_DispOff(); +void GX_DispOn(); +void GX_SetGraphicsMode(GXDispMode dispMode, GXBGMode bgMode, GXBG0As bg0_2d3d); +void GXS_SetGraphicsMode(GXBGMode mode); +void GXx_SetMasterBrightness_(vu16 *dst, s32 brightness); + +static inline void GX_SetMasterBrightness(int brightness) +{ +    GXx_SetMasterBrightness_(®_GX_MASTER_BRIGHT, brightness); +} +  #endif //GUARD_GX_H diff --git a/arm9/lib/include/registers.h b/arm9/lib/include/registers.h index 7a0155da..73ae7ccf 100644 --- a/arm9/lib/include/registers.h +++ b/arm9/lib/include/registers.h @@ -659,4 +659,42 @@  #define REG_GXS_DB_DISPCNT_EXOBJ_CH_SIZE                   2  #define REG_GXS_DB_DISPCNT_EXOBJ_CH_MASK                   0x00300000 +// MASTER BRIGHT +#define REG_GX_MASTER_BRIGHT_E_MOD_SHIFT                   14 +#define REG_GX_MASTER_BRIGHT_E_MOD_SIZE                    2 +#define REG_GX_MASTER_BRIGHT_E_MOD_MASK                    0xc000 + +#define REG_GX_MASTER_BRIGHT_E_VALUE_SHIFT                 0 +#define REG_GX_MASTER_BRIGHT_E_VALUE_SIZE                  5 +#define REG_GX_MASTER_BRIGHT_E_VALUE_MASK                  0x001f + +// DISPSTAT +#define REG_GX_DISPSTAT_VCOUNTER_SHIFT                     7 +#define REG_GX_DISPSTAT_VCOUNTER_SIZE                      9 +#define REG_GX_DISPSTAT_VCOUNTER_MASK                      0xff80 + +#define REG_GX_DISPSTAT_VQI_SHIFT                          5 +#define REG_GX_DISPSTAT_VQI_SIZE                           1 +#define REG_GX_DISPSTAT_VQI_MASK                           0x0020 + +#define REG_GX_DISPSTAT_HBI_SHIFT                          4 +#define REG_GX_DISPSTAT_HBI_SIZE                           1 +#define REG_GX_DISPSTAT_HBI_MASK                           0x0010 + +#define REG_GX_DISPSTAT_VBI_SHIFT                          3 +#define REG_GX_DISPSTAT_VBI_SIZE                           1 +#define REG_GX_DISPSTAT_VBI_MASK                           0x0008 + +#define REG_GX_DISPSTAT_LYC_SHIFT                          2 +#define REG_GX_DISPSTAT_LYC_SIZE                           1 +#define REG_GX_DISPSTAT_LYC_MASK                           0x0004 + +#define REG_GX_DISPSTAT_HBLK_SHIFT                         1 +#define REG_GX_DISPSTAT_HBLK_SIZE                          1 +#define REG_GX_DISPSTAT_HBLK_MASK                          0x0002 + +#define REG_GX_DISPSTAT_VBLK_SHIFT                         0 +#define REG_GX_DISPSTAT_VBLK_SIZE                          1 +#define REG_GX_DISPSTAT_VBLK_MASK                          0x0001 +  #endif //POKEDIAMOND_ARM9_REGISTERS_H diff --git a/arm9/lib/include/tp.h b/arm9/lib/include/tp.h index d2687545..dc762f10 100644 --- a/arm9/lib/include/tp.h +++ b/arm9/lib/include/tp.h @@ -1,6 +1,14 @@  #ifndef NITRO_TP_H_  #define NITRO_TP_H_ +#define     TP_TOUCH_OFF                0       // Not being touched +#define     TP_TOUCH_ON                 1       // Being touched + +#define     TP_VALIDITY_VALID           0       // Valid +#define     TP_VALIDITY_INVALID_X       1       // Data with invalid X coordinate +#define     TP_VALIDITY_INVALID_Y       2       // Data with invalid Y coordinate +#define     TP_VALIDITY_INVALID_XY      (TP_VALIDITY_INVALID_X | TP_VALIDITY_INVALID_Y) // Data with invalid X and Y coordinates +  // Touch panel input structure  typedef struct  { | 
