summaryrefslogtreecommitdiff
path: root/include/utils.h
blob: 0634700e1648afc3075dc3e58bfa0533c24affb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef UTILS_H
#define UTILS_H

#include "global.h"

typedef struct {
    u16 heldKeys;
    u16 newKeys;
    u16 unk4;
    u8 unk6;
    u8 unk7;
} Input;

extern Input gInput;

/**
 * Fill memory with 16 bit value.
 */
void MemFill16(u32 value, void* dest, u32 size);

/**
 * Fill memory with 32 bit value.
 */
void MemFill32(u32 value, void* dest, u32 size);

/**
 * Clear memory.
 */
void MemClear(void* dest, u32 size);

/**
 * Copy memory.
 */
void MemCopy(const void* src, void* dest, u32 size);

/**
 * Refresh gInput from hardware registers.
 */
void ReadKeyInput(void);

void LoadPalettes(const u8*, int, int);
void LoadPaletteGroup(u32 group);

/**
 * Allocate memory on heap.
 *
 * The heap size is 0x1000 bytes and should be used sparingly.
 * It is customary for entities store the returned handle in their 'myHeap' field.
 *
 * @param size u32 Size to be allocated
 * @return void* Pointer to allocated memory
 */
void* zMalloc(u32 size);

/**
 * Free memory from heap.
 *
 * The entity system will automatically free the address stored in the 'myHeap' field.
 *
 * @param ptr void* Handle to be freed
 */
void zFree(void* ptr);

/**
 * Reset All display hardware registers.
 *
 * @param updateHUD bool32 Request refresh of HUD layer (bg 0)
 */
void DispReset(bool32 updateHUD);

#endif