mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
formatting
This commit is contained in:
parent
a793e62d83
commit
4db33778ad
@ -716,21 +716,19 @@ gUnknown_08DC3A0C:: @ 8DC3A0C
|
|||||||
gUnknown_08DC3CD4:: @ 8DC3CD4
|
gUnknown_08DC3CD4:: @ 8DC3CD4
|
||||||
.incbin "baserom.gba", 0xdc3cd4, 0x80
|
.incbin "baserom.gba", 0xdc3cd4, 0x80
|
||||||
|
|
||||||
|
.align 2
|
||||||
gIntroCopyright_Pal:: @ 8DC3D54
|
gIntroCopyright_Pal:: @ 8DC3D54
|
||||||
.incbin "graphics/intro/copyright.gbapal"
|
.incbin "graphics/intro/copyright.gbapal"
|
||||||
|
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
gIntroCopyright_Gfx:: @ 8DC3D74
|
gIntroCopyright_Gfx:: @ 8DC3D74
|
||||||
.incbin "graphics/intro/copyright.4bpp.lz"
|
.incbin "graphics/intro/copyright.4bpp.lz"
|
||||||
|
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
gIntroCopyright_Tilemap:: @ 8DC3FD4
|
gIntroCopyright_Tilemap:: @ 8DC3FD4
|
||||||
.incbin "graphics/intro/copyright.bin.lz"
|
.incbin "graphics/intro/copyright.bin.lz"
|
||||||
|
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
gUnknown_08DC4120:: @ 8DC4120
|
gUnknown_08DC4120:: @ 8DC4120
|
||||||
.incbin "baserom.gba", 0xdc4120, 0x20
|
.incbin "baserom.gba", 0xdc4120, 0x20
|
||||||
|
|
||||||
|
250
src/libc.c
250
src/libc.c
@ -11,163 +11,163 @@
|
|||||||
|
|
||||||
void *memcpy(void *dst0, const void *src0, size_t len0)
|
void *memcpy(void *dst0, const void *src0, size_t len0)
|
||||||
{
|
{
|
||||||
char *dst = dst0;
|
char *dst = dst0;
|
||||||
const char *src = src0;
|
const char *src = src0;
|
||||||
long *aligned_dst;
|
long *aligned_dst;
|
||||||
const long *aligned_src;
|
const long *aligned_src;
|
||||||
unsigned int len = len0;
|
unsigned int len = len0;
|
||||||
|
|
||||||
// If the size is small, or either src or dst is unaligned,
|
// If the size is small, or either src or dst is unaligned,
|
||||||
// then go to the byte copy loop. This should be rare.
|
// then go to the byte copy loop. This should be rare.
|
||||||
if(len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst)))
|
if(len >= 16 && !(UNALIGNED(src) | UNALIGNED(dst)))
|
||||||
{
|
{
|
||||||
aligned_dst = (long *)dst;
|
aligned_dst = (long *)dst;
|
||||||
aligned_src = (long *)src;
|
aligned_src = (long *)src;
|
||||||
|
|
||||||
// Copy 4X long words at a time if possible.
|
// Copy 4X long words at a time if possible.
|
||||||
while(len >= 16)
|
while(len >= 16)
|
||||||
{
|
{
|
||||||
*aligned_dst++ = *aligned_src++;
|
*aligned_dst++ = *aligned_src++;
|
||||||
*aligned_dst++ = *aligned_src++;
|
*aligned_dst++ = *aligned_src++;
|
||||||
*aligned_dst++ = *aligned_src++;
|
*aligned_dst++ = *aligned_src++;
|
||||||
*aligned_dst++ = *aligned_src++;
|
*aligned_dst++ = *aligned_src++;
|
||||||
len -= 16;
|
len -= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy one long word at a time if possible
|
// Copy one long word at a time if possible
|
||||||
while(len >= 4)
|
while(len >= 4)
|
||||||
{
|
{
|
||||||
*aligned_dst++ = *aligned_src++;
|
*aligned_dst++ = *aligned_src++;
|
||||||
len -= 4;
|
len -= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = (char *)aligned_dst;
|
dst = (char *)aligned_dst;
|
||||||
src = (char *)aligned_src;
|
src = (char *)aligned_src;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick up any remaining bytes with a byte copier.
|
// Pick up any remaining bytes with a byte copier.
|
||||||
while(len--)
|
while(len--)
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
|
|
||||||
return dst0;
|
return dst0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memset(void *m, int c, size_t n)
|
void *memset(void *m, int c, size_t n)
|
||||||
{
|
{
|
||||||
char *s = (char *)m;
|
char *s = (char *)m;
|
||||||
int count, i;
|
int count, i;
|
||||||
unsigned long buffer;
|
unsigned long buffer;
|
||||||
unsigned long *aligned_addr;
|
unsigned long *aligned_addr;
|
||||||
unsigned char *unaligned_addr;
|
unsigned char *unaligned_addr;
|
||||||
|
|
||||||
// If the size is small or m is unaligned,
|
// If the size is small or m is unaligned,
|
||||||
// then go to the byte copy loop. This should be rare.
|
// then go to the byte copy loop. This should be rare.
|
||||||
if(n >= LBLOCKSIZE && !UNALIGNED(m))
|
if(n >= LBLOCKSIZE && !UNALIGNED(m))
|
||||||
{
|
{
|
||||||
// We know that n is large and m is word-aligned.
|
// We know that n is large and m is word-aligned.
|
||||||
aligned_addr = (unsigned long *)m;
|
aligned_addr = (unsigned long *)m;
|
||||||
|
|
||||||
// Store C into each char sized location in buffer so that
|
// Store C into each char sized location in buffer so that
|
||||||
// we can set large blocks quickly.
|
// we can set large blocks quickly.
|
||||||
c &= 0xFF;
|
c &= 0xFF;
|
||||||
if(LBLOCKSIZE == 4)
|
if(LBLOCKSIZE == 4)
|
||||||
{
|
{
|
||||||
buffer = (c << 8) | c;
|
buffer = (c << 8) | c;
|
||||||
buffer |= (buffer << 16);
|
buffer |= (buffer << 16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
for(i = 0; i < LBLOCKSIZE; i++)
|
for(i = 0; i < LBLOCKSIZE; i++)
|
||||||
buffer = (buffer << 8) | c;
|
buffer = (buffer << 8) | c;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(n >= LBLOCKSIZE * 4)
|
while(n >= LBLOCKSIZE * 4)
|
||||||
{
|
{
|
||||||
*aligned_addr++ = buffer;
|
*aligned_addr++ = buffer;
|
||||||
*aligned_addr++ = buffer;
|
*aligned_addr++ = buffer;
|
||||||
*aligned_addr++ = buffer;
|
*aligned_addr++ = buffer;
|
||||||
*aligned_addr++ = buffer;
|
*aligned_addr++ = buffer;
|
||||||
n -= LBLOCKSIZE * 4;
|
n -= LBLOCKSIZE * 4;
|
||||||
}
|
}
|
||||||
while(n >= LBLOCKSIZE)
|
while(n >= LBLOCKSIZE)
|
||||||
{
|
{
|
||||||
*aligned_addr++ = buffer;
|
*aligned_addr++ = buffer;
|
||||||
n -= LBLOCKSIZE;
|
n -= LBLOCKSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = (char *)aligned_addr;
|
s = (char *)aligned_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick up the remainder with a bytewise loop.
|
// Pick up the remainder with a bytewise loop.
|
||||||
while(n--)
|
while(n--)
|
||||||
*s++ = (char)c;
|
*s++ = (char)c;
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
int strcmp(const char *s1, const char *s2)
|
int strcmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
unsigned long *a1;
|
unsigned long *a1;
|
||||||
unsigned long *a2;
|
unsigned long *a2;
|
||||||
|
|
||||||
// If s1 or s2 are unaligned, then skip this and compare bytes.
|
// If s1 or s2 are unaligned, then skip this and compare bytes.
|
||||||
if(!(UNALIGNED(s1) | UNALIGNED(s2)))
|
if(!(UNALIGNED(s1) | UNALIGNED(s2)))
|
||||||
{
|
{
|
||||||
// Compare them a word at a time.
|
// Compare them a word at a time.
|
||||||
a1 = (unsigned long *)s1;
|
a1 = (unsigned long *)s1;
|
||||||
a2 = (unsigned long *)s2;
|
a2 = (unsigned long *)s2;
|
||||||
while(*a1 == *a2)
|
while(*a1 == *a2)
|
||||||
{
|
{
|
||||||
// If *a1 == *a2, and we find a null in *a1,
|
// If *a1 == *a2, and we find a null in *a1,
|
||||||
// then the strings must be equal, so return zero.
|
// then the strings must be equal, so return zero.
|
||||||
if(CONTAINSNULL(*a1))
|
if(CONTAINSNULL(*a1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
a1++;
|
a1++;
|
||||||
a2++;
|
a2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
s1 = (char *)a1;
|
s1 = (char *)a1;
|
||||||
s2 = (char *)a2;
|
s2 = (char *)a2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the remaining few bytes.
|
// Check the remaining few bytes.
|
||||||
while(*s1 != '\0' && *s1 == *s2)
|
while(*s1 != '\0' && *s1 == *s2)
|
||||||
{
|
{
|
||||||
s1++;
|
s1++;
|
||||||
s2++;
|
s2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*(unsigned char *) s1) - (*(unsigned char *) s2);
|
return (*(unsigned char *) s1) - (*(unsigned char *) s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* strcpy(char *dst0, const char *src0)
|
char* strcpy(char *dst0, const char *src0)
|
||||||
{
|
{
|
||||||
char *dst = dst0;
|
char *dst = dst0;
|
||||||
const char *src = src0;
|
const char *src = src0;
|
||||||
unsigned long *a1;
|
unsigned long *a1;
|
||||||
const unsigned long *a2;
|
const unsigned long *a2;
|
||||||
|
|
||||||
/* If SRC or DEST is unaligned, then copy bytes. */
|
// If SRC or DEST is unaligned, then copy bytes.
|
||||||
if(!(UNALIGNED(src) | UNALIGNED(dst)))
|
if(!(UNALIGNED(src) | UNALIGNED(dst)))
|
||||||
{
|
{
|
||||||
/* SRC and DEST are both "long int" aligned, try to do "long int"
|
// SRC and DEST are both "long int" aligned, try to do "long int"
|
||||||
sized copies. */
|
// sized copies.
|
||||||
a1 = (unsigned long *)dst;
|
a1 = (unsigned long *)dst;
|
||||||
a2 = (unsigned long *)src;
|
a2 = (unsigned long *)src;
|
||||||
while(!CONTAINSNULL(*a2))
|
while(!CONTAINSNULL(*a2))
|
||||||
{
|
{
|
||||||
*a1++ = *a2++;
|
*a1++ = *a2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = (char *)a1;
|
dst = (char *)a1;
|
||||||
src = (char *)a2;
|
src = (char *)a2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the remaining few bytes.
|
// Copy the remaining few bytes.
|
||||||
while(*dst++ = *src++);
|
while(*dst++ = *src++);
|
||||||
|
|
||||||
return dst0;
|
return dst0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user