From 4f4cc47d0e4d7fba8dffe0e8b8851bf4d79bb440 Mon Sep 17 00:00:00 2001 From: gamemasterplc Date: Mon, 4 Dec 2023 17:51:34 -0600 Subject: [PATCH] Match all but MotionLoad --- include/ctype.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++ src/game/hsfload.c | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 include/ctype.h diff --git a/include/ctype.h b/include/ctype.h new file mode 100644 index 00000000..559e7278 --- /dev/null +++ b/include/ctype.h @@ -0,0 +1,51 @@ +#ifndef _CTYPE_H +#define _CTYPE_H + + +extern unsigned char __ctype_map[256]; +extern unsigned char __lower_map[256]; +extern unsigned char __upper_map[256]; + +#define __control_char 0x01 +#define __motion_char 0x02 +#define __space_char 0x04 +#define __punctuation 0x08 +#define __digit 0x10 +#define __hex_digit 0x20 +#define __lower_case 0x40 +#define __upper_case 0x80 + +#define __letter (__lower_case | __upper_case) +#define __alphanumeric (__letter | __digit) +#define __graphic (__alphanumeric | __punctuation) +#define __printable (__graphic | __space_char) +#define __whitespace (__motion_char | __space_char) +#define __control (__motion_char | __control_char) + +#ifdef __cplusplus +extern "C" +{ +#endif + + __declspec(weak) int isalpha(int __c); + __declspec(weak) int isdigit(int __c); + __declspec(weak) int isspace(int __c); + __declspec(weak) int isupper(int __c); + __declspec(weak) int isxdigit(int __c); + + __declspec(weak) int tolower(int __c); + __declspec(weak) int toupper(int __c); + + // added underscore to avoid naming conflicts + inline int _isalpha(int c) { return (int)(__ctype_map[(u8)c] & __letter); } + inline int _isdigit(int c) { return (int)(__ctype_map[(u8)c] & __digit); } + inline int _isspace(int c) { return (int)(__ctype_map[(u8)c] & __whitespace); } + inline int _isupper(int c) { return (int)(__ctype_map[(u8)c] & __upper_case); } + inline int _isxdigit(int c) { return (int)(__ctype_map[(u8)c] & __hex_digit); } + inline int _tolower(int c) { return (c == -1 ? -1 : (int)__lower_map[(u8)c]); } + inline int _toupper(int c) { return (c == -1 ? -1 : (int)__upper_map[(u8)c]); } + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/src/game/hsfload.c b/src/game/hsfload.c index 976bc113..7c48e550 100644 --- a/src/game/hsfload.c +++ b/src/game/hsfload.c @@ -1,5 +1,6 @@ #include "game/hsfformat.h" #include "string.h" +#include "ctype.h" GXColor rgba[100]; HsfHeader head; @@ -947,6 +948,43 @@ static void PaletteLoad(void) } } +char *MakeObjectName(char *name) +{ + static char buf[768]; + int index, num_minus; + char *temp_name; + num_minus = 0; + index = 0; + temp_name = name; + while(*temp_name) { + if(*temp_name == '-') { + name = temp_name+1; + break; + } + temp_name++; + } + while(*name) { + if(num_minus != 0) { + break; + } + if(*name == '_' && !isalpha(name[1])) { + num_minus++; + break; + } + buf[index] = *name; + name++; + index++; + } + buf[index] = '\0'; + return buf; +} + +int CmpObjectName(char *name1, char *name2) +{ + int temp = 0; + return strcmp(name1, name2); +} + static void MotionLoad(void) {