Skip to content

Commit

Permalink
Fix issue with div/modulus, fix OW shadows on small sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseurae committed Oct 6, 2024
1 parent 3ee5d39 commit ee4171e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ASM_OBJS := $(ASM_FILES:assembly/%.s=build/assembly/%.o)

OBJ_FILES ?= $(SRC_OBJS) $(ASM_OBJS)

CFLAGS = -Wall -std=c99 -O2 -Iinclude -g -mlong-calls -mthumb -mno-thumb-interwork -march=armv4t -mcpu=arm7tdmi -mtune=arm7tdmi -x c -c -Wparentheses -Wno-unused -Werror
CFLAGS = -Wall -std=c99 -O2 -Iinclude -g -mlong-calls -mthumb -mthumb-interwork -specs=gba.specs -x c -c -Wparentheses -Wno-unused -Werror

AS := $(PREFIX)as
ASFLAGS := -mthumb -I assembly -I include
Expand Down
17 changes: 15 additions & 2 deletions assembly/thumb.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
.global __aeabi_idivmod, __aeabi_uidivmod
.global __aeabi_idivmod, __aeabi_uidivmod, __aeabi_idiv, __aeabi_uidiv

.force_thumb
.thumb_func
__aeabi_idivmod:
.force_thumb
.thumb_func
__aeabi_uidivmod:
swi #6
swi #0x6
bx lr

.force_thumb
.thumb_func
__aeabi_uidiv:
.force_thumb
.thumb_func
_aeabi_idiv:
swi #0x6
bx lr
8 changes: 0 additions & 8 deletions include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
bool32 MgbaOpen(void);
void MgbaClose(void);
void MgbaPrintf(s32 level, const char *pBuf, ...);
void MgbaAssert(const char *pFile, s32 nLine, const char *pExpression, bool32 nStopProgram);

#define DebugPrintf(pBuf, ...) MgbaPrintf(MGBA_LOG_INFO, pBuf, ## __VA_ARGS__)
#define DebugAssert(pFile, nLine, pExpression, nStopProgram) MgbaAssert(pFile, nLine, pExpression, nStopProgram)
#define DebugPrintfLevel(level, pBuf, ...) MgbaPrintf(level, pBuf, ## __VA_ARGS__)

#define AGB_ASSERT(exp) (exp) ? ((void*)0) : DebugAssert(__FILE__, __LINE__, #exp, TRUE)
#define AGB_WARNING(exp) (exp) ? ((void*)0) : DebugAssert(__FILE__, __LINE__, #exp, FALSE)

#define AGB_WARNING_EX(exp, file, line) (exp) ? ((void *)0) : DebugAssert(file, line, #exp, FALSE);
#define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void *)0) : DebugAssert(file, line, #exp, TRUE);
4 changes: 2 additions & 2 deletions include/mini_printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@

#else

s32 LONG_CALL mini_vsnprintf(char* buffer, u32 buffer_len, const char *fmt, va_list va);
s32 LONG_CALL mini_vpprintf(void* buf, const char *fmt, va_list va);
s32 mini_vsnprintf(char* buffer, u32 buffer_len, const char *fmt, va_list va);
s32 mini_vpprintf(void* buf, const char *fmt, va_list va);

#endif
#endif
3 changes: 1 addition & 2 deletions linker.ld
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ SECTIONS {
.rodata :
ALIGN(4)
{
*(.rodata);
*(.rodata.str1.4);
*(.rodata*);
} > rom = 0xff

.script_data :
Expand Down
13 changes: 0 additions & 13 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,3 @@ void MgbaPrintf(s32 level, const char* ptr, ...)
va_end(args);
*REG_DEBUG_FLAGS = level | 0x100;
}

void MgbaAssert(const char *pFile, s32 nLine, const char *pExpression, bool32 nStopProgram)
{
if (nStopProgram)
{
MgbaPrintf(MGBA_LOG_ERROR, "ASSERTION FAILED FILE=[%s] LINE=[%d] EXP=[%s]", pFile, nLine, pExpression);
__asm__(".hword 0xEFFF");
}
else
{
MgbaPrintf(MGBA_LOG_WARN, "WARING FILE=[%s] LINE=[%d] EXP=[%s]", pFile, nLine, pExpression);
}
}
10 changes: 5 additions & 5 deletions src/event_object_movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ void GetGroundEffectFlags_Shadow(struct ObjectEvent *objEvent, u32 *flags)
}
}

#include "debug.h"

void GroundEffect_Shadow(struct ObjectEvent *objEvent, struct Sprite *sprite)
{
(void)sprite;
// StartFieldEffectForObjectEvent(FLDEFF_SHADOW, objEvent);
// ObjectEventGetLocalIdAndMap(
// objEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
gFieldEffectArguments[0] = objEvent->localId;
gFieldEffectArguments[1] = objEvent->mapNum;
gFieldEffectArguments[2] = objEvent->mapGroup;
ObjectEventGetLocalIdAndMap(
objEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);

gFieldEffectArguments[3] = objEvent->graphicsId;
FldEff_Shadow_();
}

Expand Down
4 changes: 1 addition & 3 deletions src/field_effect_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ u32 FldEff_Shadow_(void)
const struct ObjectEventGraphicsInfo *graphicsInfo;
u8 spriteId;

objectEventId =
GetObjectEventIdByLocalIdAndMap(gFieldEffectArguments[0], gFieldEffectArguments[1], gFieldEffectArguments[2]);
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[objectEventId].graphicsId);
graphicsInfo = GetObjectEventGraphicsInfo(gFieldEffectArguments[3]);
spriteId = CreateSpriteAtEnd(
gFieldEffectObjectTemplatePointers[gShadowEffectTemplateIds[graphicsInfo->shadowSize]], 0, 0, 0x94);

Expand Down
2 changes: 1 addition & 1 deletion src/mini_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
*/

#include "types.h"
#include "text.h"
#include "mini_printf.h"
#include "string_util.h"
#include "text.h"

#ifndef NDEBUG

Expand Down
10 changes: 10 additions & 0 deletions src/pokemon_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,14 @@ void BufferAlternateAbilityName(void)
struct Pokemon *mon = &gPlayerParty[gSpecialVar_0x8004];
StringCopy(gStringVar1,
gAbilityNames[GetAbilityBySpecies(GetMonData(mon, MON_DATA_SPECIES), !GetMonData(mon, MON_DATA_ALT_ABILITY))]);
}

void CheckDivision(void)
{
gSpecialVar_Result = gSpecialVar_0x8004 / gSpecialVar_0x8005;
}

void CheckModulus(void)
{
gSpecialVar_Result = gSpecialVar_0x8004 % gSpecialVar_0x8005;
}

0 comments on commit ee4171e

Please sign in to comment.