Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
libseven 0.17.0: make type aliases optional
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarLambda committed Feb 5, 2023
1 parent ca326ca commit 2f23369
Show file tree
Hide file tree
Showing 43 changed files with 262 additions and 259 deletions.
2 changes: 1 addition & 1 deletion dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ make_dist() {

[ ! -d "$DIST" ] && mkdir "$DIST" || rm "$DIST"/*

(PROJECT=libseven VERSION=0.16.1 make_dist)
(PROJECT=libseven VERSION=0.17.0 make_dist)
(PROJECT=minrt VERSION=0.5.1 make_dist)
10 changes: 6 additions & 4 deletions libseven/include/seven/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#ifndef _LIBSEVEN_BASE_H
#define _LIBSEVEN_BASE_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
#define _LIBSEVEN_EXTERN_C extern "C" {
#define _LIBSEVEN_EXTERN_C_END }
Expand All @@ -22,8 +26,8 @@
#define _LIBSEVEN_ALIGN4 __attribute__((__aligned__(4)))

#define LIBSEVEN_VERSION_MAJOR 0
#define LIBSEVEN_VERSION_MINOR 16
#define LIBSEVEN_VERSION_PATCH 1
#define LIBSEVEN_VERSION_MINOR 17
#define LIBSEVEN_VERSION_PATCH 0

#define LIBSEVEN_VERSION \
_LIBSEVEN_STR2(LIBSEVEN_VERSION_MAJOR) "." \
Expand All @@ -41,6 +45,4 @@
#define BITFIELD(name, value) \
(((value) & BITS(BF_##name##_LENGTH)) << (BF_##name##_OFFSET))

#include <seven/types.h>

#endif /* !_LIBSEVEN_BASE_H */
48 changes: 24 additions & 24 deletions libseven/include/seven/hw/bios/affine.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,45 @@ _LIBSEVEN_EXTERN_C

struct BgAffineSrcData
{
i32 src_center_x;
i32 src_center_y;
i16 disp_center_x;
i16 disp_center_y;
i16 ratio_x;
i16 ratio_y;
u16 theta;
int32_t src_center_x;
int32_t src_center_y;
int16_t disp_center_x;
int16_t disp_center_y;
int16_t ratio_x;
int16_t ratio_y;
uint16_t theta;
};

struct BgAffineDstData
{
i16 h_diff_x;
i16 v_diff_x;
i16 h_diff_y;
i16 v_diff_y;
i32 start_x;
i32 start_y;
int16_t h_diff_x;
int16_t v_diff_x;
int16_t h_diff_y;
int16_t v_diff_y;
int32_t start_x;
int32_t start_y;
};

extern void biosBgAffineSet(
const struct BgAffineSrcData *src,
struct BgAffineDstData *dst,
u32 num);
uint32_t num);

struct ObjAffineSrcData
{
i16 ratio_x;
i16 ratio_y;
u16 theta;
int16_t ratio_x;
int16_t ratio_y;
uint16_t theta;
// BIOS wants this type to be 8 bytes but doesn't need alignment > 2
u8 pad[2];
uint8_t pad[2];
};

struct ObjAffineDstData
{
i16 h_diff_x;
i16 v_diff_x;
i16 h_diff_y;
i16 v_diff_y;
int16_t h_diff_x;
int16_t v_diff_x;
int16_t h_diff_y;
int16_t v_diff_y;
};

enum ObjAffineSetOffset
Expand All @@ -63,8 +63,8 @@ enum ObjAffineSetOffset
extern void biosObjAffineSet(
const struct ObjAffineSrcData *src,
void *dst,
u32 num,
u32 offset);
uint32_t num,
uint32_t offset);

_LIBSEVEN_EXTERN_C_END

Expand Down
10 changes: 5 additions & 5 deletions libseven/include/seven/hw/bios/decompression.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ _LIBSEVEN_EXTERN_C

struct BitUnPackParam
{
u16 src_length; // in bytes
u8 src_width; // width of each src element (1, 2, 4, 8)
u8 dst_width; // width of each dst element (1, 2, 4, 8, 16, 32)
u32 offset:31; // value to add to each dst element
u32 keep_zeroes:1; // whether to add offset to zero elements too
uint16_t src_length; // in bytes
uint8_t src_width; // width of each src element (1, 2, 4, 8)
uint8_t dst_width; // width of each dst element (1, 2, 4, 8, 16, 32)
uint32_t offset:31; // value to add to each dst element
uint32_t keep_zeroes:1; // whether to add offset to zero elements too
};

extern void biosBitUnPack(
Expand Down
14 changes: 7 additions & 7 deletions libseven/include/seven/hw/bios/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ _LIBSEVEN_EXTERN_C

struct Div
{
i32 quot;
i32 rem;
int32_t quot;
int32_t rem;
};

extern i32 biosDiv(i32 numerator, i32 denominator);
extern struct Div biosDivMod(i32 numerator, i32 denominator);
extern u16 biosSqrt(u32 x);
extern i16 biosArcTan(i16 tan);
extern u16 biosArcTan2(i16 x, i16 y);
extern int32_t biosDiv(int32_t numerator, int32_t denominator);
extern struct Div biosDivMod(int32_t numerator, int32_t denominator);
extern uint16_t biosSqrt(uint32_t x);
extern int16_t biosArcTan(int16_t tan);
extern uint16_t biosArcTan2(int16_t x, int16_t y);

_LIBSEVEN_EXTERN_C_END

Expand Down
4 changes: 2 additions & 2 deletions libseven/include/seven/hw/bios/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ enum CpuFastSetFlags
CFS_SRC_FIXED = BIT(24),
};

extern void biosCpuSet(const void *src, void *dst, u32 ctrl);
extern void biosCpuFastSet(const void *src, void *dst, u32 ctrl);
extern void biosCpuSet(const void *src, void *dst, uint32_t ctrl);
extern void biosCpuFastSet(const void *src, void *dst, uint32_t ctrl);

_LIBSEVEN_EXTERN_C_END

Expand Down
4 changes: 2 additions & 2 deletions libseven/include/seven/hw/bios/reset.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum SoftResetExFlags
// Combines biosRegisterRamReset and svcSoftReset
// Allows reset from EWRAM, automatically unsets RRR_EWRAM
// Disables IME to prevent IRQs crashing from a dangling handler
extern void _LIBSEVEN_NORETURN biosSoftResetEx(u8 reset_flags, bool from_ewram);
extern void _LIBSEVEN_NORETURN biosSoftResetEx(uint8_t reset_flags, bool from_ewram);

enum RegisterRamResetFlags
{
Expand All @@ -38,7 +38,7 @@ enum RegisterRamResetFlags
RRR_EVERYTHING = BITS(8),
};

extern void biosRegisterRamReset(u8 reset_flags);
extern void biosRegisterRamReset(uint8_t reset_flags);

_LIBSEVEN_EXTERN_C_END

Expand Down
2 changes: 1 addition & 1 deletion libseven/include/seven/hw/bios/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum BiosChecksum
BIOS_CHECKSUM_NDS = 0xBAAE1880,
};

extern u32 biosBiosChecksum(void);
extern uint32_t biosBiosChecksum(void);

_LIBSEVEN_EXTERN_C_END

Expand Down
2 changes: 1 addition & 1 deletion libseven/include/seven/hw/bios/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _LIBSEVEN_EXTERN_C
extern void biosHalt(void);
extern void biosStop(void);

extern void biosIntrWait(bool wait_next, u16 intr_flags);
extern void biosIntrWait(bool wait_next, uint16_t intr_flags);
extern void biosVBlankIntrWait(void);

_LIBSEVEN_EXTERN_C_END
Expand Down
6 changes: 3 additions & 3 deletions libseven/include/seven/hw/cartridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
_LIBSEVEN_EXTERN_C

// GPIO Data
#define REG_GPIODAT VOLADDR(0x080000C4, u16)
#define REG_GPIODAT VOLADDR(0x080000C4, uint16_t)
// GPIO Direction
#define REG_GPIODIR VOLADDR(0x080000C6, u16)
#define REG_GPIODIR VOLADDR(0x080000C6, uint16_t)
// GPIO Control
#define REG_GPIOCNT VOLADDR(0x080000C8, u16)
#define REG_GPIOCNT VOLADDR(0x080000C8, uint16_t)

enum GpioDirection
{
Expand Down
22 changes: 11 additions & 11 deletions libseven/include/seven/hw/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ _LIBSEVEN_EXTERN_C

#define REG_DMA0SRC VOLADDR(0x040000B0, const void *)
#define REG_DMA0DST VOLADDR(0x040000B4, void *)
#define REG_DMA0LEN VOLADDR(0x040000B8, u16)
#define REG_DMA0CNT VOLADDR(0x040000BA, u16)
#define REG_DMA0LEN VOLADDR(0x040000B8, uint16_t)
#define REG_DMA0CNT VOLADDR(0x040000BA, uint16_t)

#define REG_DMA1SRC VOLADDR(0x040000BC, const void *)
#define REG_DMA1DST VOLADDR(0x040000C0, void *)
#define REG_DMA1LEN VOLADDR(0x040000C4, u16)
#define REG_DMA1CNT VOLADDR(0x040000C6, u16)
#define REG_DMA1LEN VOLADDR(0x040000C4, uint16_t)
#define REG_DMA1CNT VOLADDR(0x040000C6, uint16_t)

#define REG_DMA2SRC VOLADDR(0x040000C8, const void *)
#define REG_DMA2DST VOLADDR(0x040000CC, void *)
#define REG_DMA2LEN VOLADDR(0x040000D0, u16)
#define REG_DMA2CNT VOLADDR(0x040000D2, u16)
#define REG_DMA2LEN VOLADDR(0x040000D0, uint16_t)
#define REG_DMA2CNT VOLADDR(0x040000D2, uint16_t)

#define REG_DMA3SRC VOLADDR(0x040000D4, const void *)
#define REG_DMA3DST VOLADDR(0x040000D8, void *)
#define REG_DMA3LEN VOLADDR(0x040000DC, u16)
#define REG_DMA3CNT VOLADDR(0x040000DE, u16)
#define REG_DMA3LEN VOLADDR(0x040000DC, uint16_t)
#define REG_DMA3CNT VOLADDR(0x040000DE, uint16_t)

struct DMA
{
const void *src;
void *dst;
u16 len;
u16 cnt;
uint16_t len;
uint16_t cnt;
};

enum DMAControl
Expand Down Expand Up @@ -108,7 +108,7 @@ enum DMAControlPreset
#define DMA_BUILD(src, dst, len, flags) \
((struct DMA){ src, dst, DMA_LEN(len, flags), flags })

extern void dmaSet(u32 channel, struct DMA dma);
extern void dmaSet(uint32_t channel, struct DMA dma);

_LIBSEVEN_EXTERN_C_END

Expand Down
24 changes: 12 additions & 12 deletions libseven/include/seven/hw/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ _LIBSEVEN_EXTERN_C

// Keypad input register. Reports held keys as active-low bits.
//
#define REG_KEYINPUT VOLADDR(0x04000130, const u16)
#define REG_KEYINPUT VOLADDR(0x04000130, const uint16_t)

// Keypad control register. Allows configuring the keypad IRQ.
//
#define REG_KEYCNT VOLADDR(0x04000132, u16)
#define REG_KEYCNT VOLADDR(0x04000132, uint16_t)

// Key bits as used by KEYINPUT and KEYCNT.
enum Key
Expand Down Expand Up @@ -72,8 +72,8 @@ enum KeyIRQ

struct InputState
{
u16 now;
u16 last;
uint16_t now;
uint16_t last;
} __attribute__((aligned(4)));

// Returns a fresh InputState.
Expand All @@ -83,40 +83,40 @@ extern struct InputState inputNew(void);
extern struct InputState inputPoll(struct InputState i);

// Returns the keys that were pressed this frame. ("Rising egde")
extern u16 inputKeysPressed(u16 keys, struct InputState i);
extern uint16_t inputKeysPressed(uint16_t keys, struct InputState i);

// Returns the keys that were released this frame. ("Falling edge")
extern u16 inputKeysReleased(u16 keys, struct InputState i);
extern uint16_t inputKeysReleased(uint16_t keys, struct InputState i);

// Returns the keys that are being held this frame.
extern u16 inputKeysDown(u16 keys, struct InputState i);
extern uint16_t inputKeysDown(uint16_t keys, struct InputState i);

// Returns the keys that are not being held this frame.
extern u16 inputKeysUp(u16 keys, struct InputState i);
extern uint16_t inputKeysUp(uint16_t keys, struct InputState i);

// Gets the state of the Dpad X-axis.
// -1: Left
// 0: None
// 1: Right
extern i32 inputAxisX(struct InputState i);
extern int32_t inputAxisX(struct InputState i);

// Gets the state of the Dpad Y-axis.
// -1: Up
// 0: None
// 1: Down
extern i32 inputAxisY(struct InputState i);
extern int32_t inputAxisY(struct InputState i);

// Gets the state of the shoulder button axis.
// -1: L
// 0: None/Both
// 1: R
extern i32 inputAxisLR(struct InputState i);
extern int32_t inputAxisLR(struct InputState i);

// Gets the state of the face button axis.
// -1: B
// 0: None/Both
// 1: A
extern i32 inputAxisAB(struct InputState i);
extern int32_t inputAxisAB(struct InputState i);

_LIBSEVEN_EXTERN_C_END

Expand Down
Loading

0 comments on commit 2f23369

Please sign in to comment.