mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 17:13:31 +02:00
small changes
This commit is contained in:
parent
9df8512716
commit
72abd56b4e
@ -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) {
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
double heat = nn_getTemperature(computer);
|
if(idleTime >= interval) {
|
||||||
double roomHeat = nn_getRoomTemperature(computer);
|
idleTime -= interval;
|
||||||
|
|
||||||
double tx = 0.1;
|
for (int i = 0; i < 256; i++) {
|
||||||
|
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");
|
||||||
|
|
||||||
// remove some heat per second
|
const char* error = nn_pushSignal(computer, values, 5);
|
||||||
nn_removeHeat(computer, dt * (rand() % 3) * tx * (heat - roomHeat));
|
|
||||||
if(nn_isOverheating(computer)) {
|
|
||||||
goto render;
|
|
||||||
}
|
|
||||||
|
|
||||||
int state = nn_tickComputer(computer);
|
if (error != NULL) {
|
||||||
if(state == NN_STATE_SWITCH) {
|
// well fuck
|
||||||
nn_architecture *nextArch = nn_getNextArchitecture(computer);
|
printf("error happened when eventing the keyboarding: %s\n", error);;;;;;
|
||||||
printf("Next architecture: %s\n", nextArch->archName);
|
}
|
||||||
break;
|
}
|
||||||
} else if(state == NN_STATE_CLOSING || state == NN_STATE_REPEAT) {
|
}
|
||||||
break;
|
}
|
||||||
} else if(state == NN_STATE_BLACKOUT) {
|
|
||||||
printf("blackout\n");
|
int state = nn_tickComputer(computer);
|
||||||
break;
|
if(state == NN_STATE_SWITCH) {
|
||||||
}
|
nn_architecture *nextArch = nn_getNextArchitecture(computer);
|
||||||
const char *e = nn_getError(computer);
|
printf("Next architecture: %s\n", nextArch->archName);
|
||||||
if(e != NULL) {
|
break;
|
||||||
printf("Error: %s\n", e);
|
} else if(state == NN_STATE_CLOSING || state == NN_STATE_REPEAT) {
|
||||||
break;
|
break;
|
||||||
|
} else if(state == NN_STATE_BLACKOUT) {
|
||||||
|
printf("blackout\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const char *e = nn_getError(computer);
|
||||||
|
if(e != NULL) {
|
||||||
|
printf("Error: %s\n", e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render:
|
render:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user