mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
progress
This commit is contained in:
parent
0d9a59bfc7
commit
5f5c474fa7
1
TODO.md
1
TODO.md
@ -8,7 +8,6 @@
|
||||
|
||||
# Parity with Vanilla OC (only the stuff that makes sense for an emulator)
|
||||
|
||||
- complete the GPU implementation (screen buffers and missing methods)
|
||||
- complete the screen implementation (bunch of missing methods)
|
||||
- `hologram` component
|
||||
- `computer` component
|
||||
|
@ -956,7 +956,7 @@ void nn_loadGraphicsCardTable(nn_universe *universe) {
|
||||
nn_defineMethod(gpuTable, "freeBuffer", (nn_componentMethod *)nni_gpu_freeBuffer, "freeBuffer([buffer: integer]): boolean - Frees a buffer. By default, the current buffer. If the current buffer is freed, it will switch back to the screen.");
|
||||
nn_defineMethod(gpuTable, "freeAllBuffers", (nn_componentMethod *)nni_gpu_freeAllBuffers, "freeAllBuffers() - Frees every VRAM buffer (if any). Also switches back to the screen.");
|
||||
nn_defineMethod(gpuTable, "getBufferSize", (nn_componentMethod *)nni_gpu_getBufferSize, "getBufferSize(buffer: integer): integer, integer - Returns the size of the specified buffer.");
|
||||
nn_defineMethod(gpuTable, "bitblt", (nn_componentMethod *)nni_gpu_bitblt, "dummy func");
|
||||
nn_defineMethod(gpuTable, "bitblt", (nn_componentMethod *)nni_gpu_bitblt, "bitblt([dst: integer, x: integer, y: integer, w: integer, h: integer, src: integer, fromCol: integer, fromRow: integer]) - Copy regions between buffers");
|
||||
}
|
||||
|
||||
nn_component *nn_addGPU(nn_computer *computer, nn_address address, int slot, nn_gpuControl *control) {
|
||||
|
@ -236,12 +236,97 @@ void nn_screenComp_getAspectRatio(nn_screen *screen, void *_, nn_component *comp
|
||||
nn_return_integer(computer, h);
|
||||
}
|
||||
|
||||
void nn_screenComp_isOn(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_bool_t isOn = nn_isOn(screen);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isOn);
|
||||
}
|
||||
|
||||
void nn_screenComp_turnOn(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_bool_t isOff = !nn_isOn(screen);
|
||||
nn_setOn(screen, true);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isOff);
|
||||
nn_return_boolean(computer, true);
|
||||
}
|
||||
|
||||
void nn_screenComp_turnOff(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_bool_t isOn = nn_isOn(screen);
|
||||
nn_setOn(screen, false);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isOn);
|
||||
nn_return_boolean(computer, false);
|
||||
}
|
||||
|
||||
void nn_screenComp_setPrecise(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_bool_t isPrecise = nn_toBooleanOr(nn_getArgument(computer, 0), true);
|
||||
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_setPrecise(screen, isPrecise);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isPrecise);
|
||||
}
|
||||
|
||||
void nn_screenComp_isPrecise(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_bool_t isPrecise = nn_isPrecise(screen);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isPrecise);
|
||||
}
|
||||
|
||||
void nn_screenComp_setTouchModeInverted(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_bool_t isTouchModeInverted = nn_toBooleanOr(nn_getArgument(computer, 0), true);
|
||||
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_setTouchModeInverted(screen, isTouchModeInverted);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isTouchModeInverted);
|
||||
}
|
||||
|
||||
void nn_screenComp_isTouchModeInverted(nn_screen *screen, void *_, nn_component *component, nn_computer *computer) {
|
||||
nn_lockScreen(screen);
|
||||
|
||||
nn_bool_t isTouchModeInverted = nn_isTouchModeInverted(screen);
|
||||
|
||||
nn_unlockScreen(screen);
|
||||
|
||||
nn_return_boolean(computer, isTouchModeInverted);
|
||||
}
|
||||
|
||||
void nn_loadScreenTable(nn_universe *universe) {
|
||||
nn_componentTable *screenTable = nn_newComponentTable(nn_getAllocator(universe), "screen", NULL, NULL, (nn_componentDestructor *)nn_screenComp_destroy);
|
||||
nn_storeUserdata(universe, "NN:SCREEN", screenTable);
|
||||
|
||||
nn_defineMethod(screenTable, "getKeyboards", (nn_componentMethod *)nn_screenComp_getKeyboards, "getKeyboards(): string[] - Returns the keyboards registered to this screen.");
|
||||
nn_defineMethod(screenTable, "getAspectRatio", (nn_componentMethod *)nn_screenComp_getAspectRatio, "");
|
||||
nn_defineMethod(screenTable, "getAspectRatio", (nn_componentMethod *)nn_screenComp_getAspectRatio, "getAspectRatio(): integer, integer - Returns the dimensions, in blocks, of the screen.");
|
||||
nn_defineMethod(screenTable, "isOn", (nn_componentMethod *)nn_screenComp_isOn, "isOn(): boolean - Returns whether the screen is on.");
|
||||
nn_defineMethod(screenTable, "turnOn", (nn_componentMethod *)nn_screenComp_turnOn, "turnOn(): boolean, boolean - Turns the screen on. Returns whether the screen was off and the new power state.");
|
||||
nn_defineMethod(screenTable, "turnOff", (nn_componentMethod *)nn_screenComp_turnOff, "turnOff(): boolean, boolean - Turns the screen off. Returns whether the screen was on and the new power state.");
|
||||
nn_defineMethod(screenTable, "setPrecise", (nn_componentMethod *)nn_screenComp_setPrecise, "setPrecise(precise: boolean) - Sets whether precise (sub-pixel) mouse events are enabled");
|
||||
nn_defineMethod(screenTable, "isPrecise", (nn_componentMethod *)nn_screenComp_isPrecise, "isPrecise(): boolean - Checks whether precise mouse events are enabled");
|
||||
nn_defineMethod(screenTable, "setTouchModeInverted", (nn_componentMethod *)nn_screenComp_setTouchModeInverted, "setTouchModeInverted(mode: boolean) - Sets whether inverted touch mode is enabled");
|
||||
nn_defineMethod(screenTable, "isTouchModeInverted", (nn_componentMethod *)nn_screenComp_isTouchModeInverted, "isTouchModeInverted(): boolean - Checks whether inverted touch mode is enabled");
|
||||
}
|
||||
|
||||
nn_componentTable *nn_getScreenTable(nn_universe *universe) {
|
||||
|
@ -644,7 +644,7 @@ int main() {
|
||||
|
||||
nn_addEEPROM(computer, NULL, 0, genericEEPROM);
|
||||
|
||||
nn_address fsFolder = "Halyde";
|
||||
nn_address fsFolder = "OpenOS";
|
||||
nn_filesystemTable genericFSTable = {
|
||||
.userdata = fsFolder,
|
||||
.deinit = NULL,
|
||||
@ -909,28 +909,30 @@ render:
|
||||
|
||||
ClearBackground(BLACK);
|
||||
|
||||
int scrW = 1, scrH = 1;
|
||||
nn_getResolution(s, &scrW, &scrH);
|
||||
int pixelHeight = GetScreenHeight() / scrH;
|
||||
float spacing = (float)pixelHeight/10;
|
||||
int pixelWidth = MeasureTextEx(unscii, "A", pixelHeight, spacing).x;
|
||||
if(nn_isOn(s)) {
|
||||
int scrW = 1, scrH = 1;
|
||||
nn_getResolution(s, &scrW, &scrH);
|
||||
int pixelHeight = GetScreenHeight() / scrH;
|
||||
float spacing = (float)pixelHeight/10;
|
||||
int pixelWidth = MeasureTextEx(unscii, "A", pixelHeight, spacing).x;
|
||||
|
||||
int depth = nn_getDepth(s);
|
||||
int depth = nn_getDepth(s);
|
||||
|
||||
int offX = (GetScreenWidth() - scrW * pixelWidth) / 2;
|
||||
int offY = (GetScreenHeight() - scrH * pixelHeight) / 2;
|
||||
int offX = (GetScreenWidth() - scrW * pixelWidth) / 2;
|
||||
int offY = (GetScreenHeight() - scrH * pixelHeight) / 2;
|
||||
|
||||
for(size_t x = 0; x < scrW; x++) {
|
||||
for(size_t y = 0; y < scrH; y++) {
|
||||
ne_premappedPixel p = ne_getPremap(premap, s, x, y);
|
||||
for(size_t x = 0; x < scrW; x++) {
|
||||
for(size_t y = 0; y < scrH; y++) {
|
||||
ne_premappedPixel p = ne_getPremap(premap, s, x, y);
|
||||
|
||||
// fuck palettes
|
||||
Color fgColor = ne_processColor(p.mappedFgRes);
|
||||
Color bgColor = ne_processColor(p.mappedBgRes);
|
||||
DrawRectangle(x * pixelWidth + offX, y * pixelHeight + offY, pixelWidth, pixelHeight, bgColor);
|
||||
DrawTextCodepoint(unscii, p.codepoint, (Vector2) {x * pixelWidth + offX, y * pixelHeight + offY}, pixelHeight - 5, fgColor);
|
||||
}
|
||||
}
|
||||
// fuck palettes
|
||||
Color fgColor = ne_processColor(p.mappedFgRes);
|
||||
Color bgColor = ne_processColor(p.mappedBgRes);
|
||||
DrawRectangle(x * pixelWidth + offX, y * pixelHeight + offY, pixelWidth, pixelHeight, bgColor);
|
||||
DrawTextCodepoint(unscii, p.codepoint, (Vector2) {x * pixelWidth + offX, y * pixelHeight + offY}, pixelHeight - 5, fgColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user