Get the game to compile for SPARC cpu architecture

This commit is contained in:
UnknownShadow200 2019-05-25 20:06:35 +10:00
parent c06da53ae7
commit 2ee398b0a3
2 changed files with 19 additions and 4 deletions

View File

@ -184,7 +184,8 @@ void Json_Parse(struct JsonContext* ctx) {
static void Json_Handle(uint8_t* data, uint32_t len,
JsonOnValue onVal, JsonOnNew newArr, JsonOnNew newObj) {
struct JsonContext ctx;
String str = String_Init(data, len, len);
/* NOTE: classicube.net uses \u JSON for non ASCII, no need to UTF8 convert characters */
String str = String_Init((char*)data, len, len);
Json_Init(&ctx, &str);
if (onVal) ctx.OnValue = onVal;
@ -398,6 +399,7 @@ static void FetchServersTask_Next(struct JsonContext* ctx) {
}
static void FetchServersTask_Handle(uint8_t* data, uint32_t len) {
int count;
Mem_Free(FetchServersTask.Servers);
Mem_Free(FetchServersTask.Orders);
@ -408,10 +410,11 @@ static void FetchServersTask_Handle(uint8_t* data, uint32_t len) {
/* -1 because servers is surrounded by a { */
FetchServersTask.NumServers = -1;
Json_Handle(data, len, NULL, NULL, FetchServersTask_Count);
count = FetchServersTask.NumServers;
if (FetchServersTask.NumServers <= 0) return;
FetchServersTask.Servers = Mem_Alloc(FetchServersTask.NumServers, sizeof(struct ServerInfo), "servers list");
FetchServersTask.Orders = Mem_Alloc(FetchServersTask.NumServers, 2, "servers order");
if (count <= 0) return;
FetchServersTask.Servers = (struct ServerInfo*)Mem_Alloc(count, sizeof(struct ServerInfo), "servers list");
FetchServersTask.Orders = (uint16_t*)Mem_Alloc(count, 2, "servers order");
/* -2 because servers is surrounded by a { */
curServer = FetchServersTask.Servers - 2;

View File

@ -255,6 +255,13 @@ String_Format4(&str, "r24=%x r25=%x r26=%x r27=%x" _NL, REG_GNUM(24), REG_GNUM(2
String_Format3(&str, "r28=%x r29=%x r30=%x" _NL, REG_GNUM(28), REG_GNUM(29), REG_GNUM(30)); \
String_Format2(&str, "sp =%x pc =%x" _NL, REG_GET(sp,SP), REG_GET(pc,PC));
#define Logger_Dump_SPARC() \
String_Format4(&str, "o0=%x o1=%x o2=%x o3=%x" _NL, REG_GET(o0,O0), REG_GET(o1,O1), REG_GET(o2,O2), REG_GET(o3,O3)); \
String_Format4(&str, "o4=%x o5=%x o6=%x o7=%x" _NL, REG_GET(o4,O4), REG_GET(o5,O5), REG_GET(o6,O6), REG_GET(o7,O7)); \
String_Format4(&str, "g1=%x g2=%x g3=%x g4=%x" _NL, REG_GET(g1,G1), REG_GET(g2,G2), REG_GET(g3,G3), REG_GET(g4,G4)); \
String_Format4(&str, "g5=%x g6=%x g7=%x y =%x" _NL, REG_GET(g5,G5), REG_GET(g6,G6), REG_GET(g7,G7), REG_GET( y, Y)); \
String_Format2(&str, "pc=%x nc=%x" _NL, REG_GET(pc,PC), REG_GET(npc,nPC));
#if defined CC_BUILD_WEB
static void Logger_DumpBacktrace(String* str, void* ctx) { }
static void Logger_DumpRegisters(void* ctx) { }
@ -497,6 +504,11 @@ static void Logger_DumpRegisters(void* ctx) {
#define REG_GET(reg, ign) &r.arm_##reg
#endif
Logger_Dump_ARM32()
#elif defined __sparc__
#if defined CC_BUILD_LINUX
#define REG_GET(ign, reg) &r.gregs[REG_##reg]
#endif
Logger_Dump_SPARC()
#else
#error "Unknown ISA/architecture"
#endif