mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
lots of random little fixes
This commit is contained in:
parent
0c2727c9a7
commit
8f5cfb6be1
@ -140,9 +140,12 @@ void nni_gpu_set(nni_gpu *gpu, void *_, nn_component *component, nn_computer *co
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("It is to print: %s\n", s);
|
||||||
|
|
||||||
int current = 0;
|
int current = 0;
|
||||||
while(s[current] != 0) {
|
while(s[current] != 0) {
|
||||||
int codepoint = nn_unicode_codepointAt(s, current);
|
int codepoint = nn_unicode_codepointAt(s, current);
|
||||||
|
printf("char rendered: %i\n", codepoint);
|
||||||
nn_setPixel(gpu->currentScreen, x, y, nni_gpu_makePixel(gpu, s + current));
|
nn_setPixel(gpu->currentScreen, x, y, nni_gpu_makePixel(gpu, s + current));
|
||||||
if(isVertical) {
|
if(isVertical) {
|
||||||
y++;
|
y++;
|
||||||
|
@ -536,7 +536,7 @@ nn_component *nn_addDrive(nn_computer *computer, nn_address address, int slot, n
|
|||||||
typedef struct nn_screen nn_screen;
|
typedef struct nn_screen nn_screen;
|
||||||
|
|
||||||
typedef struct nn_scrchr_t {
|
typedef struct nn_scrchr_t {
|
||||||
int codepoint;
|
unsigned int codepoint;
|
||||||
int fg;
|
int fg;
|
||||||
int bg;
|
int bg;
|
||||||
bool isFgPalette;
|
bool isFgPalette;
|
||||||
|
@ -42,23 +42,25 @@ nn_computer *testLuaArch_getComputer(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static nn_value testLuaArch_getValue(lua_State *L, int index) {
|
static nn_value testLuaArch_getValue(lua_State *L, int index) {
|
||||||
if(lua_isinteger(L, index)) {
|
int type = lua_type(L, index);
|
||||||
return nn_values_integer(lua_tointeger(L, index));
|
|
||||||
}
|
if(type == LUA_TBOOLEAN) {
|
||||||
if(lua_isnumber(L, index)) {
|
|
||||||
return nn_values_number(lua_tonumber(L, index));
|
|
||||||
}
|
|
||||||
if(lua_isboolean(L, index)) {
|
|
||||||
return nn_values_boolean(lua_toboolean(L, index));
|
return nn_values_boolean(lua_toboolean(L, index));
|
||||||
}
|
}
|
||||||
if(lua_isnoneornil(L, index)) {
|
if(lua_isnoneornil(L, index)) {
|
||||||
return nn_values_nil();
|
return nn_values_nil();
|
||||||
}
|
}
|
||||||
if(lua_isstring(L, index)) {
|
if(type == LUA_TSTRING) {
|
||||||
size_t l = 0;
|
size_t l = 0;
|
||||||
const char *s = lua_tolstring(L, index, &l);
|
const char *s = lua_tolstring(L, index, &l);
|
||||||
return nn_values_string(s, l);
|
return nn_values_string(s, l);
|
||||||
}
|
}
|
||||||
|
if(type == LUA_TNUMBER && lua_isnumber(L, index)) {
|
||||||
|
return nn_values_number(lua_tonumber(L, index));
|
||||||
|
}
|
||||||
|
if(type == LUA_TNUMBER && lua_isinteger(L, index)) {
|
||||||
|
return nn_values_integer(lua_tointeger(L, index));
|
||||||
|
}
|
||||||
//TODO: bring it back once I make everything else not leak memory
|
//TODO: bring it back once I make everything else not leak memory
|
||||||
//luaL_argcheck(L, false, index, luaL_typename(L, index));
|
//luaL_argcheck(L, false, index, luaL_typename(L, index));
|
||||||
return nn_values_nil();
|
return nn_values_nil();
|
||||||
|
@ -103,22 +103,22 @@ size_t nn_unicode_len(const char *b) {
|
|||||||
unsigned int nn_unicode_codepointAt(const char *s, size_t byteOffset) {
|
unsigned int nn_unicode_codepointAt(const char *s, size_t byteOffset) {
|
||||||
unsigned int point = 0;
|
unsigned int point = 0;
|
||||||
const unsigned char *b = (const unsigned char *)s + byteOffset;
|
const unsigned char *b = (const unsigned char *)s + byteOffset;
|
||||||
const unsigned int subpartMask = 0b111111;
|
const unsigned char subpartMask = 0b111111;
|
||||||
// look into nn_unicode_codepointToChar as well.
|
// look into nn_unicode_codepointToChar as well.
|
||||||
if(b[0] <= 0x7F) {
|
if(b[0] <= 0x7F) {
|
||||||
return b[0];
|
return b[0];
|
||||||
} else if((b[0] >> 5) == 0b110) {
|
} else if((b[0] >> 5) == 0b110) {
|
||||||
point += b[0] & 0b11111;
|
point += ((unsigned int)(b[0] & 0b11111)) << 6;
|
||||||
point += (b[1] & subpartMask) << 5;
|
point += ((unsigned int)(b[1] & subpartMask));
|
||||||
} else if((b[0] >> 4) == 0b1110) {
|
} else if((b[0] >> 4) == 0b1110) {
|
||||||
point += b[0] & 0b1111;
|
point += ((unsigned int)(b[0] & 0b1111)) << 12;
|
||||||
point += (b[1] & subpartMask) << 4;
|
point += ((unsigned int)(b[1] & subpartMask)) << 6;
|
||||||
point += (b[2] & subpartMask) << 10;
|
point += ((unsigned int)(b[2] & subpartMask));
|
||||||
} else if((b[0] >> 3) == 0b11110) {
|
} else if((b[0] >> 3) == 0b11110) {
|
||||||
point += b[0] & 0b111;
|
point += ((unsigned int)(b[0] & 0b111)) << 18;
|
||||||
point += (b[1] & subpartMask) << 3;
|
point += ((unsigned int)(b[1] & subpartMask)) << 12;
|
||||||
point += (b[2] & subpartMask) << 9;
|
point += ((unsigned int)(b[2] & subpartMask)) << 6;
|
||||||
point += (b[3] & subpartMask) << 15;
|
point += ((unsigned int)(b[3] & subpartMask));
|
||||||
}
|
}
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
@ -146,17 +146,17 @@ const char *nn_unicode_codepointToChar(unsigned int codepoint, size_t *len) {
|
|||||||
if (codepointSize == 1) {
|
if (codepointSize == 1) {
|
||||||
buffer[0] = (char)codepoint;
|
buffer[0] = (char)codepoint;
|
||||||
} else if (codepointSize == 2) {
|
} else if (codepointSize == 2) {
|
||||||
buffer[0] = 0b11000000 + (codepoint & 0b11111);
|
buffer[0] = 0b11000000 + ((codepoint >> 6) & 0b11111);
|
||||||
buffer[1] = 0b10000000 + (codepoint >> 5);
|
buffer[1] = 0b10000000 + (codepoint & 0b111111);
|
||||||
} else if (codepointSize == 3) {
|
} else if (codepointSize == 3) {
|
||||||
buffer[0] = 0b11100000 + (codepoint & 0b1111);
|
buffer[0] = 0b11100000 + ((codepoint >> 12) & 0b1111);
|
||||||
buffer[1] = 0b10000000 + ((codepoint >> 4) & 0b111111);
|
buffer[1] = 0b10000000 + ((codepoint >> 6) & 0b111111);
|
||||||
buffer[2] = 0b10000000 + (codepoint >> 10);
|
buffer[2] = 0b10000000 + (codepoint & 0b111111);
|
||||||
} else if (codepointSize == 4) {
|
} else if (codepointSize == 4) {
|
||||||
buffer[0] = 0b11110000 + (codepoint & 0b111);
|
buffer[0] = 0b11110000 + ((codepoint >> 18) & 0b111);
|
||||||
buffer[1] = 0b10000000 + ((codepoint >> 3) & 0b111111);
|
buffer[1] = 0b10000000 + ((codepoint >> 12) & 0b111111);
|
||||||
buffer[2] = 0b10000000 + ((codepoint >> 9) & 0b111111);
|
buffer[2] = 0b10000000 + ((codepoint >> 6) & 0b111111);
|
||||||
buffer[3] = 0b10000000 + (codepoint >> 15);
|
buffer[3] = 0b10000000 + (codepoint & 0b111111);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user