nn_ComputerState real

This commit is contained in:
2026-05-28 20:45:52 -03:00
parent 560cce77e8
commit 287e773aa5
5 changed files with 65 additions and 18 deletions

View File

@@ -19,11 +19,14 @@ public class NativeBindings {
nn_Universe universe = nn_createUniverse(ctx);
nn_Architecture arch = getLuaArch();
nn_EEPROM eeprom = new nn_EEPROM(2048, 2048, 1, 1, 1, 1, 1, 1);
eeprom.allocate();
nn_Component eepromCard = ncl_createEEPROM(universe, UUID.randomUUID().toString(), eeprom, "error('amog us')", false);
eeprom.free();
nn_Computer computer = nn_createComputer(universe, UUID.randomUUID().toString(), 4096, 100, 100);
nn_setCallBudget(computer, 0);
nn_setArchitecture(computer, arch);
nn_addSupportedArchitecture(computer, arch);
nn_mountComponent(computer, eepromCard, 0, false);
nn_Exit e = nn_tick(computer);
if (e != nn_Exit.NN_OK) {
System.out.println("NN tick error: " + nn_getError(computer));
@@ -35,26 +38,26 @@ public class NativeBindings {
return;
}
nn_ComputerState state = nn_getComputerState(computer);
/*if(state == nn_Exit.NN_POWEROFF) break;
if(state == nn_Exit.NN_CRASHED) {
System.out.println("error: %s\n", nn_getError(c));
if(state == nn_ComputerState.NN_POWEROFF) return;
if(state == nn_ComputerState.NN_CRASHED) {
System.out.println("error: " + nn_getError(computer));
return;
}
if(state == nn_Exit.NN_CHARCH) {
System.out.println("new arch: %s\n", nn_getDesiredArchitecture(c).name);
if(state == nn_ComputerState.NN_CHARCH) {
System.out.println("new arch: " + nn_getDesiredArchitecture(computer).name);
return;
}
if(state == nn_Exit.NN_BLACKOUT) {
System.out.println("out of energy\n");
goto cleanup;
if(state == nn_ComputerState.NN_BLACKOUT) {
System.out.println("out of energy");
//goto cleanup;
}
if(state == nn_Exit.NN_RESTART) {
System.out.println("restart requested\n");
if(state == nn_ComputerState.NN_RESTART) {
System.out.println("restart requested");
nn_stopComputer(computer);
//ncl_resetScreen(nn_getComponentState(screen));
nn_addIdleTime(computer, 1);
continue;
}*/
}
//System.out.println(ctx.ptr);
}
public static native nn_Architecture getLuaArch();

View File

@@ -1,5 +1,19 @@
package org.neoflock.NeoNucleus;
public class nn_ComputerState {
// TODO
}
public enum nn_ComputerState {
// the machine is running just fine
NN_RUNNING,
// machine is initializing. This is the state after createComputer but before the first nn_tick.
// It is a required state of various initialization functions.
NN_BOOTUP,
// the machine has powered off.
NN_POWEROFF,
// the machine demands being restarted.
NN_RESTART,
// the machine has crashed. RIP
NN_CRASHED,
// the machine ran out of energy.
NN_BLACKOUT,
// change architecture.
NN_CHARCH,
}