gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit ca326fbe45e0b00107c6f2960bee994743afba63 parent 87d09cf365fb7f0f2b692cd7c807de6f676b9d1e Author: Toxa <untoxa@mail.ru> Date: Mon, 6 Sep 2021 15:37:20 +0300 SMS/GG: itoa()/uitoa() returns valid pointer Diffstat:
| M | gbdk-lib/include/sms/sms.h | 14 | +++++++------- |
| M | gbdk-lib/libc/asm/z80/__strreverse.s | 50 | ++++++++++++++++++++++++++------------------------ |
2 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -418,9 +418,9 @@ void joypad_ex(joypads_t * joypads) __z88dk_fastcall __preserves_regs(iyh, iyl); #if defined(__TARGET_sms) -#define RGB(r,g,b) ((r)|((g)<<2)|((b)<<4)) -#define RGB8(r,g,b) (((r)>>6)|(((g)>>6)<<2)|(((b)>>6)<<4)) -#define RGBHTML(RGB24bit) (((RGB24bit)>>22)|((((RGB24bit)&0xFFFF)>>14)<<2)|((((RGB24bit)&0xFF)>>6)<<4)) +#define RGB(r,g,b) ((r) | ((g) << 2) | ((b) << 4)) +#define RGB8(r,g,b) (((r) >> 6) | (((g) >> 6) << 2) | (((b) >> 6) << 4)) +#define RGBHTML(RGB24bit) (((RGB24bit) >> 22) | ((((RGB24bit) & 0xFFFF) >> 14) << 2) | ((((RGB24bit) & 0xFF) >> 6) << 4)) /** Common colors based on the EGA default palette. */ @@ -445,9 +445,9 @@ typedef uint8_t palette_entry_t; #elif defined(__TARGET_gg) -#define RGB(r,g,b) ((r)|((g)<<4)|((b)<<8)) -#define RGB8(r,g,b) (((r)>>4)|(((g)>>4)<<4)|(((b)>>4)<<8)) -#define RGBHTML(RGB24bit) (((RGB24bit)>>20)|((((RGB24bit)&0xFFFF)>>12)<<4)|((((RGB24bit)&0xFF)>>4)<<8)) +#define RGB(r,g,b) ((uint16_t)(r) | (uint16_t)((g) << 4) | (uint16_t)((b) << 8)) +#define RGB8(r,g,b) ((uint16_t)((r) >> 4) | ((uint16_t)((g) >> 4) << 4) | ((uint16_t)((b) >> 4) << 8)) +#define RGBHTML(RGB24bit) (((RGB24bit) >> 20) | ((((RGB24bit) & 0xFFFF) >> 12) << 4)|((((RGB24bit) & 0xFF) >> 4) << 8)) /** Common colors based on the EGA default palette. */ @@ -497,7 +497,7 @@ inline void set_sprite_4bpp_data(uint16_t start, uint16_t ntiles, const void *sr set_tile_data((uint8_t)(start) + 0x100u, ntiles, src); } -#define COMPAT_PALETTE(C0,C1,C2,C3) (((C3) << 12) | ((C2) << 8) | ((C1) << 4) | (C0)) +#define COMPAT_PALETTE(C0,C1,C2,C3) (((uint16_t)(C3) << 12) | ((uint16_t)(C2) << 8) | ((uint16_t)(C1) << 4) | (uint16_t)(C0)) extern uint16_t _current_2bpp_palette; inline void set_2bpp_palette(uint16_t palette) { _current_2bpp_palette = palette; diff --git a/gbdk-lib/libc/asm/z80/__strreverse.s b/gbdk-lib/libc/asm/z80/__strreverse.s @@ -26,36 +26,38 @@ ; might be covered by the GNU General Public License. ;-------------------------------------------------------------------------- - .area _CODE + .area _CODE - .globl ___strreverse - .globl ___strreverse_reg + .globl ___strreverse + .globl ___strreverse_reg ; -;void __reverse(char *beg, char *end); +;char * __reverse(char *beg, char *end); ; ___strreverse:: - pop bc - pop de - pop hl - push hl - push de - push bc -; + pop bc + pop de + pop hl + push hl + push de + push bc + ;in: HL - pointer to end of string (null symbol), DE - pointer to start of string ; ___strreverse_reg:: - jr 110$ + jr 110$ 100$: - add hl, de - ld a, (de) - ld c, (hl) - ld (hl), a - ld a, c - ld (de), a - inc de + add hl, de + ld a, (de) + ld c, (hl) + ld (hl), a + ld a, c + ld (de), a + inc de 110$: - dec hl - or a, a - sbc hl, de - jr NC, 100$ - ret + dec hl + or a, a + sbc hl, de + jr NC, 100$ + add hl, de + inc hl + ret
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.