modern working

This commit is contained in:
DizzyEggg
2025-05-26 13:36:54 +02:00
parent 552f8629b3
commit 7bf162955f
15 changed files with 566 additions and 50 deletions

View File

@@ -400,7 +400,7 @@ extern const struct ToneData voicegroup_pokemon_cry;
extern char gNumMusicPlayers[];
extern char gMaxLines[];
#define NUM_MUSIC_PLAYERS ((u16)gNumMusicPlayers)
#define NUM_MUSIC_PLAYERS ((u16)((u32)gNumMusicPlayers))
#define MAX_LINES ((u32)gMaxLines)
u32 umul3232H32(u32 multiplier, u32 multiplicand);

View File

@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include "config.h" // We need to define config before gba headers as print stuff needs the functions nulled before defines.
#include "gba/gba.h"
@@ -54,6 +55,17 @@ static inline bool8 AreStringsDifferent(const u8 *str1, const u8 *str2)
return strcmp(str1, str2) != 0;
}
#ifdef MODERN
#define BUGFIX
#define NONMATCHING
#include "mini_printf.h"
void sprintfStatic(char *buffer, const char *text, ...);
// Use miniprintf instead of library printf functions
#define sprintf sprintfStatic
#define vsprintf mini_vsprintf
#endif // MODERN
// Sometimes incrementing and decrementing a variable changes how registers are allocated, which helps with matching functions. Functionality-wise this doesn't do anything.
#ifdef NONMATCHING
#define ASM_MATCH_TRICK(a) {;}

42
include/mini_printf.h Normal file
View File

@@ -0,0 +1,42 @@
/*
* The Minimal snprintf() implementation
*
* Copyright (c) 2013 Michal Ludvig <michal@logix.cz>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the auhor nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Courtey of https://github.com/mludvig/mini-printf
* stripped to reduce file size for agb needs
*/
#ifndef __MINI_PRINTF__
#define __MINI_PRINTF__
s32 mini_vsprintf(char *buffer, 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