small changes

This commit is contained in:
IonutParau 2025-07-05 13:17:12 +02:00
parent 9df8512716
commit 72abd56b4e
3 changed files with 57 additions and 42 deletions

View File

@ -156,6 +156,7 @@ void nn_setPixel(nn_screen *screen, int x, int y, nn_scrchr_t pixel) {
if(x >= screen->width) return; if(x >= screen->width) return;
if(y >= screen->height) return; if(y >= screen->height) return;
screen->buffer[x + y * screen->maxWidth] = pixel; screen->buffer[x + y * screen->maxWidth] = pixel;
screen->isDirty = true; // stuff changed
} }
nn_scrchr_t nn_getPixel(nn_screen *screen, int x, int y) { nn_scrchr_t nn_getPixel(nn_screen *screen, int x, int y) {

View File

@ -24,7 +24,7 @@ typedef struct nn_screen {
bool isOn; bool isOn;
bool isTouchModeInverted; bool isTouchModeInverted;
bool isPrecise; bool isPrecise;
bool isDirty; // ooh la laa bool isDirty;
nn_address keyboards[NN_MAX_SCREEN_KEYBOARDS]; nn_address keyboards[NN_MAX_SCREEN_KEYBOARDS];
size_t keyboardCount; size_t keyboardCount;
} nn_screen; } nn_screen;

View File

@ -691,12 +691,27 @@ int main() {
SetExitKey(KEY_NULL); SetExitKey(KEY_NULL);
SetTargetFPS(20); // match MC TPS double idleTime = 0;
int tps = 20; // mc TPS
double interval = 1.0/tps;
while(true) { while(true) {
if(WindowShouldClose()) break; if(WindowShouldClose()) break;
nn_setEnergyInfo(computer, 5000, 5000); nn_setEnergyInfo(computer, 5000, 5000);
double dt = GetFrameTime();
double heat = nn_getTemperature(computer);
double roomHeat = nn_getRoomTemperature(computer);
double tx = 0.1;
// remove some heat per second
nn_removeHeat(computer, dt * (rand() % 3) * tx * (heat - roomHeat));
if(nn_isOverheating(computer)) {
goto render;
}
while (true) { // TODO: find out if we can check if the keycode and unicode are for the same key event or not while (true) { // TODO: find out if we can check if the keycode and unicode are for the same key event or not
int keycode = GetKeyPressed(); int keycode = GetKeyPressed();
int unicode = GetCharPressed(); int unicode = GetCharPressed();
@ -730,22 +745,6 @@ int main() {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
ne_pressedKey *key = release_check_list + i; ne_pressedKey *key = release_check_list + i;
if (key->keycode != 0) { if (key->keycode != 0) {
if (IsKeyPressedRepeat(key->keycode)) {
// omg
nn_value values[5];
values[0] = nn_values_cstring("key_down");
values[1] = nn_values_cstring("shitty keyboard");
values[2] = nn_values_integer(key->charcode);
values[3] = nn_values_integer(keycode_to_oc(key->keycode));
values[4] = nn_values_cstring("USER");
const char* error = nn_pushSignal(computer, values, 5);
if (error != NULL) {
// well fuck
printf("error happened when eventing the keyboarding: %s\n", error);;;;;;
}
}
if (IsKeyReleased(key->keycode)) { if (IsKeyReleased(key->keycode)) {
// omg // omg
nn_value values[5]; nn_value values[5];
@ -766,34 +765,49 @@ int main() {
} }
} }
double dt = GetFrameTime(); idleTime += dt;
if(idleTime >= interval) {
idleTime -= interval;
double heat = nn_getTemperature(computer); for (int i = 0; i < 256; i++) {
double roomHeat = nn_getRoomTemperature(computer); ne_pressedKey *key = release_check_list + i;
if (key->keycode != 0) {
if (IsKeyPressedRepeat(key->keycode)) {
// omg
nn_value values[5];
values[0] = nn_values_cstring("key_down");
values[1] = nn_values_cstring("shitty keyboard");
values[2] = nn_values_integer(key->charcode);
values[3] = nn_values_integer(keycode_to_oc(key->keycode));
values[4] = nn_values_cstring("USER");
double tx = 0.1; const char* error = nn_pushSignal(computer, values, 5);
// remove some heat per second if (error != NULL) {
nn_removeHeat(computer, dt * (rand() % 3) * tx * (heat - roomHeat)); // well fuck
if(nn_isOverheating(computer)) { printf("error happened when eventing the keyboarding: %s\n", error);;;;;;
goto render; }
} }
}
}
int state = nn_tickComputer(computer); int state = nn_tickComputer(computer);
if(state == NN_STATE_SWITCH) { if(state == NN_STATE_SWITCH) {
nn_architecture *nextArch = nn_getNextArchitecture(computer); nn_architecture *nextArch = nn_getNextArchitecture(computer);
printf("Next architecture: %s\n", nextArch->archName); printf("Next architecture: %s\n", nextArch->archName);
break; break;
} else if(state == NN_STATE_CLOSING || state == NN_STATE_REPEAT) { } else if(state == NN_STATE_CLOSING || state == NN_STATE_REPEAT) {
break; break;
} else if(state == NN_STATE_BLACKOUT) { } else if(state == NN_STATE_BLACKOUT) {
printf("blackout\n"); printf("blackout\n");
break; break;
} }
const char *e = nn_getError(computer); const char *e = nn_getError(computer);
if(e != NULL) { if(e != NULL) {
printf("Error: %s\n", e); printf("Error: %s\n", e);
break; break;
}
} }
render: render: