Atlas - ExampleXYZ.java

Home / lab / nova / src / main / java / com / github / _0x4248 / nova_examples Lines: 1 | Size: 2079 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1package com.github._0x4248.nova_examples; 2 3import com.github._0x4248.nova.Machine.core.Keyboard; 4import com.github._0x4248.nova.Machine.core.Machine; 5import com.github._0x4248.nova.Machine.core.MachineProgram; 6import com.github._0x4248.nova.Machine.core.Video; 7import com.github._0x4248.nova.Machine.gpu.GPU; 8 9import java.awt.event.KeyEvent; 10 11public class ExampleXYZ implements MachineProgram { 12 13 public static void main(String[] args) { 14 new ExampleXYZ().run(Machine.basic(), args); 15 } 16 17 @Override 18 public void run(Machine machine, String[] args) { 19 GPU gpu = machine.video().gpu; 20 Keyboard keyboard = machine.keyboard(); 21 22 gpu.init(Video.Modes.CGA_TEXT_40x25); 23 gpu.clear(0); 24 gpu.drawText(8, 8, "NOVA TEXT MODE", 15, 0, false); 25 gpu.drawText(8, 20, "Press ENTER for VGA graphics", 14, 0, false); 26 gpu.drawText(8, 32, "ESC exits", 10, 0, false); 27 gpu.present(); 28 29 while (true) { 30 Integer keyCode = keyboard.pollKeyCode(); 31 if (keyCode == null) { 32 sleep(10); 33 continue; 34 } 35 if (keyCode == KeyEvent.VK_ESCAPE) { 36 break; 37 } 38 if (keyCode == KeyEvent.VK_ENTER) { 39 break; 40 } 41 } 42 43 gpu.init(Video.Modes.VGA_GRAPHICS_640x480_16); 44 gpu.clear(1); 45 gpu.drawText(8, 8, "VGA VIDEO MODE", 15, 1, false); 46 47 for (int x = 0; x < gpu.getWidth(); x++) { 48 int y = (int) (gpu.getHeight() * 0.5 + Math.sin(x / 20.0) * 50); 49 gpu.setPixel(x, y, 14); 50 } 51 gpu.present(); 52 53 while (true) { 54 Integer keyCode = keyboard.pollKeyCode(); 55 if (keyCode != null && keyCode == KeyEvent.VK_ESCAPE) { 56 break; 57 } 58 sleep(10); 59 } 60 61 gpu.shutdown(); 62 } 63 64 private void sleep(long millis) { 65 try { 66 Thread.sleep(millis); 67 } catch (InterruptedException e) { 68 Thread.currentThread().interrupt(); 69 } 70 } 71} 72
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.