devkitPro / libgba

C Library for Nintendo GBA
http://devkitpro.org/viewforum.php?f=5
Other
192 stars 26 forks source link

Registers not marked as volatile #5

Closed tromero closed 2 years ago

tromero commented 3 years ago

gba_video.h

#define REG_BG0HOFS     *((u16 *)(REG_BASE + 0x10)) // BG 0 H Offset
#define REG_BG0VOFS     *((u16 *)(REG_BASE + 0x12)) // BG 0 V Offset
#define REG_BG1HOFS     *((u16 *)(REG_BASE + 0x14)) // BG 1 H Offset
#define REG_BG1VOFS     *((u16 *)(REG_BASE + 0x16)) // BG 1 V Offset
#define REG_BG2HOFS     *((u16 *)(REG_BASE + 0x18)) // BG 2 H Offset
#define REG_BG2VOFS     *((u16 *)(REG_BASE + 0x1a)) // BG 2 V Offset
#define REG_BG3HOFS     *((u16 *)(REG_BASE + 0x1c)) // BG 3 H Offset
#define REG_BG3VOFS     *((u16 *)(REG_BASE + 0x1e)) // BG 3 V Offset

#define REG_BG2PA   *((s16 *)(REG_BASE + 0x20))
#define REG_BG2PB   *((s16 *)(REG_BASE + 0x22))
#define REG_BG2PC   *((s16 *)(REG_BASE + 0x24))
#define REG_BG2PD   *((s16 *)(REG_BASE + 0x26))
#define REG_BG2X    *((s32 *)(REG_BASE + 0x28))
#define REG_BG2Y    *((s32 *)(REG_BASE + 0x2c))
#define REG_BG3PA   *((s16 *)(REG_BASE + 0x30))
#define REG_BG3PB   *((s16 *)(REG_BASE + 0x32))
#define REG_BG3PC   *((s16 *)(REG_BASE + 0x34))
#define REG_BG3PD   *((s16 *)(REG_BASE + 0x36))
#define REG_BG3X    *((s32 *)(REG_BASE + 0x38))
#define REG_BG3Y    *((s32 *)(REG_BASE + 0x3c))

These registers should be volatile.

kusma commented 2 years ago

I'm seeing issues because BG_COLORS isn't maked as volatile either. This fixes it for me:

#undef BG_COLORS
#define BG_COLORS       ((volatile uint16_t *)0x05000000)
rawr51919 commented 2 years ago

All of these issues have been fixed by #14 in commit fc95d49d97fc7cec31a023e20c13a7446db3a059