|
@@ -3,75 +3,11 @@ import Foundation
|
|
|
import Glibc
|
|
import Glibc
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
-// ── Framebuffer structs ──
|
|
|
|
|
|
|
|
|
|
-struct fb_bitfield {
|
|
|
|
|
- var offset: UInt32 = 0
|
|
|
|
|
- var length: UInt32 = 0
|
|
|
|
|
- var msb_right: UInt32 = 0
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-struct fb_var_screeninfo {
|
|
|
|
|
- var xres: UInt32 = 0
|
|
|
|
|
- var yres: UInt32 = 0
|
|
|
|
|
- var xres_virtual: UInt32 = 0
|
|
|
|
|
- var yres_virtual: UInt32 = 0
|
|
|
|
|
- var xoffset: UInt32 = 0
|
|
|
|
|
- var yoffset: UInt32 = 0
|
|
|
|
|
- var bits_per_pixel: UInt32 = 0
|
|
|
|
|
- var grayscale: UInt32 = 0
|
|
|
|
|
- var red: fb_bitfield = fb_bitfield()
|
|
|
|
|
- var green: fb_bitfield = fb_bitfield()
|
|
|
|
|
- var blue: fb_bitfield = fb_bitfield()
|
|
|
|
|
- var transp: fb_bitfield = fb_bitfield()
|
|
|
|
|
- var nonstd: UInt32 = 0
|
|
|
|
|
- var activate: UInt32 = 0
|
|
|
|
|
- var height: UInt32 = 0
|
|
|
|
|
- var width: UInt32 = 0
|
|
|
|
|
- var accel_flags: UInt32 = 0
|
|
|
|
|
- var pixclock: UInt32 = 0
|
|
|
|
|
- var left_margin: UInt32 = 0
|
|
|
|
|
- var right_margin: UInt32 = 0
|
|
|
|
|
- var upper_margin: UInt32 = 0
|
|
|
|
|
- var lower_margin: UInt32 = 0
|
|
|
|
|
- var hsync_len: UInt32 = 0
|
|
|
|
|
- var vsync_len: UInt32 = 0
|
|
|
|
|
- var sync: UInt32 = 0
|
|
|
|
|
- var vmode: UInt32 = 0
|
|
|
|
|
- var reserved: (UInt32, UInt32, UInt32, UInt32, UInt32, UInt32) = (0, 0, 0, 0, 0, 0)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-struct fb_fix_screeninfo {
|
|
|
|
|
- var id: (Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8,
|
|
|
|
|
- Int8, Int8, Int8, Int8, Int8, Int8, Int8, Int8) =
|
|
|
|
|
- (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
|
|
|
|
|
- var smem_start: UInt = 0
|
|
|
|
|
- var smem_len: UInt32 = 0
|
|
|
|
|
- var type: UInt32 = 0
|
|
|
|
|
- var type_aux: UInt32 = 0
|
|
|
|
|
- var visual: UInt32 = 0
|
|
|
|
|
- var xpanstep: UInt16 = 0
|
|
|
|
|
- var ypanstep: UInt16 = 0
|
|
|
|
|
- var ywrapstep: UInt16 = 0
|
|
|
|
|
- var line_length: UInt32 = 0
|
|
|
|
|
- var mmio_start: UInt = 0
|
|
|
|
|
- var mmio_len: UInt32 = 0
|
|
|
|
|
- var accel: UInt32 = 0
|
|
|
|
|
- var reserved: (UInt16, UInt16, UInt16) = (0, 0, 0)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-@_silgen_name("get_vinfo")
|
|
|
|
|
-func get_vinfo(_ fd: Int32, _ vinfo: UnsafeMutableRawPointer) -> Int32
|
|
|
|
|
-
|
|
|
|
|
-@_silgen_name("get_finfo")
|
|
|
|
|
-func get_finfo(_ fd: Int32, _ finfo: UnsafeMutableRawPointer) -> Int32
|
|
|
|
|
-
|
|
|
|
|
-@_silgen_name("pan_display")
|
|
|
|
|
-func pan_display(_ fd: Int32, _ vinfo: UnsafeMutableRawPointer) -> Int32
|
|
|
|
|
|
|
|
|
|
-// ══════════════════════════════════════════════════════════════════
|
|
|
|
|
|
|
+// -
|
|
|
// Anti-Aliased High-Resolution Back-Buffered Renderer
|
|
// Anti-Aliased High-Resolution Back-Buffered Renderer
|
|
|
-// ══════════════════════════════════════════════════════════════════
|
|
|
|
|
|
|
+// -
|
|
|
|
|
|
|
|
let AW = 600
|
|
let AW = 600
|
|
|
let AH = 600
|
|
let AH = 600
|
|
@@ -177,7 +113,7 @@ func blit(_ src: UnsafeMutablePointer<UInt8>,
|
|
|
_ fbp: UnsafeMutablePointer<UInt8>,
|
|
_ fbp: UnsafeMutablePointer<UInt8>,
|
|
|
_ sx: Int, _ sy: Int,
|
|
_ sx: Int, _ sy: Int,
|
|
|
_ lineLen: Int, _ scrH: Int,
|
|
_ lineLen: Int, _ scrH: Int,
|
|
|
- _ fd: Int32, _ vinfo: UnsafeMutableRawPointer) {
|
|
|
|
|
|
|
+ _ fd: Int32, _ scrSz: Int) {
|
|
|
for y in 0..<AH {
|
|
for y in 0..<AH {
|
|
|
let fy = sy + y
|
|
let fy = sy + y
|
|
|
if fy < 0 || fy >= scrH { continue }
|
|
if fy < 0 || fy >= scrH { continue }
|
|
@@ -185,10 +121,11 @@ func blit(_ src: UnsafeMutablePointer<UInt8>,
|
|
|
src + y * AW * 4,
|
|
src + y * AW * 4,
|
|
|
AW * 4)
|
|
AW * 4)
|
|
|
}
|
|
}
|
|
|
- _ = pan_display(fd, vinfo)
|
|
|
|
|
|
|
+ lseek(fd, 0, SEEK_SET)
|
|
|
|
|
+ write(fd, fbp, scrSz)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// ── Isolated IPC Client (talks to arkrt daemon) ──
|
|
|
|
|
|
|
+// - Isolated IPC Client (talks to arkrt daemon) -
|
|
|
|
|
|
|
|
func queryIPC(cmdId: UInt16, payload: String = "") -> String {
|
|
func queryIPC(cmdId: UInt16, payload: String = "") -> String {
|
|
|
let fd = socket(AF_UNIX, 1, 0)
|
|
let fd = socket(AF_UNIX, 1, 0)
|
|
@@ -253,30 +190,11 @@ func queryIPC(cmdId: UInt16, payload: String = "") -> String {
|
|
|
return "INVALID_DATA"
|
|
return "INVALID_DATA"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// ══════════════════════════════════════════════════════════════════
|
|
|
|
|
|
|
+// -
|
|
|
|
|
|
|
|
-func drawSwiftSplash() {
|
|
|
|
|
- let fd = open("/dev/fb0", O_RDWR)
|
|
|
|
|
- if fd < 0 { print("Error: Cannot open /dev/fb0"); return }
|
|
|
|
|
-
|
|
|
|
|
- var vinfo = fb_var_screeninfo()
|
|
|
|
|
- if get_vinfo(fd, &vinfo) < 0 { close(fd); return }
|
|
|
|
|
-
|
|
|
|
|
- var finfo = fb_fix_screeninfo()
|
|
|
|
|
- if get_finfo(fd, &finfo) < 0 { close(fd); return }
|
|
|
|
|
-
|
|
|
|
|
- let scrW = Int(vinfo.xres)
|
|
|
|
|
- let scrH = Int(vinfo.yres)
|
|
|
|
|
- let bpp = Int(vinfo.bits_per_pixel) / 8
|
|
|
|
|
- let lineLen = Int(finfo.line_length)
|
|
|
|
|
- let scrSz = Int(finfo.smem_len)
|
|
|
|
|
-
|
|
|
|
|
- let fb_ptr = mmap(nil, scrSz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)
|
|
|
|
|
- if fb_ptr == MAP_FAILED { close(fd); return }
|
|
|
|
|
- let fbp = fb_ptr!.bindMemory(to: UInt8.self, capacity: scrSz)
|
|
|
|
|
-
|
|
|
|
|
- // ── Clear entire screen to BLACK immediately ──
|
|
|
|
|
- memset(fbp, 0, scrSz)
|
|
|
|
|
|
|
+func drawSwiftSplash(fbp: UnsafeMutablePointer<UInt8>, scrW: Int, scrH: Int, lineLen: Int, bpp: Int) {
|
|
|
|
|
+ // - Clear entire screen to BLACK immediately -
|
|
|
|
|
+ memset(fbp, 0, scrH * lineLen)
|
|
|
|
|
|
|
|
// Allocate raw pointer buffers
|
|
// Allocate raw pointer buffers
|
|
|
let tpl = UnsafeMutablePointer<UInt8>.allocate(capacity: ABUFSZ) // template
|
|
let tpl = UnsafeMutablePointer<UInt8>.allocate(capacity: ABUFSZ) // template
|
|
@@ -286,11 +204,11 @@ func drawSwiftSplash() {
|
|
|
let sx = (scrW - AW) / 2
|
|
let sx = (scrW - AW) / 2
|
|
|
let sy = (scrH - AH) / 2
|
|
let sy = (scrH - AH) / 2
|
|
|
|
|
|
|
|
- // ── Pre-render static nucleus template ──
|
|
|
|
|
|
|
+ // - Pre-render static nucleus template -
|
|
|
memset(tpl, 0, ABUFSZ)
|
|
memset(tpl, 0, ABUFSZ)
|
|
|
diskAA(tpl, Double(AC), Double(AC), Double(NUC_R), 255)
|
|
diskAA(tpl, Double(AC), Double(AC), Double(NUC_R), 255)
|
|
|
|
|
|
|
|
- // ── Phase 1: Spawn & Orbit Expansion (35 frames) ──
|
|
|
|
|
|
|
+ // - Phase 1: Spawn & Orbit Expansion (35 frames) -
|
|
|
for frame in 0..<35 {
|
|
for frame in 0..<35 {
|
|
|
memset(work, 0, ABUFSZ)
|
|
memset(work, 0, ABUFSZ)
|
|
|
|
|
|
|
@@ -327,17 +245,17 @@ func drawSwiftSplash() {
|
|
|
diskAA(work, ex, ey, curElR, 255)
|
|
diskAA(work, ex, ey, curElR, 255)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- blit(work, fbp, sx, sy, lineLen, scrH, fd, &vinfo)
|
|
|
|
|
|
|
+ blit(work, fbp, sx, sy, lineLen, scrH, fbFd, screenSize)
|
|
|
usleep(16666)
|
|
usleep(16666)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ── Pre-render static stable orbit template for Phase 2 ──
|
|
|
|
|
|
|
+ // - Pre-render static stable orbit template for Phase 2 -
|
|
|
memset(tpl, 0, ABUFSZ)
|
|
memset(tpl, 0, ABUFSZ)
|
|
|
diskAA(tpl, Double(AC), Double(AC), Double(NUC_R), 255)
|
|
diskAA(tpl, Double(AC), Double(AC), Double(NUC_R), 255)
|
|
|
ringAA(tpl, Double(AC), Double(AC), Double(INNER_R), RING_T, 60)
|
|
ringAA(tpl, Double(AC), Double(AC), Double(INNER_R), RING_T, 60)
|
|
|
ringAA(tpl, Double(AC), Double(AC), Double(OUTER_R), RING_T, 60)
|
|
ringAA(tpl, Double(AC), Double(AC), Double(OUTER_R), RING_T, 60)
|
|
|
|
|
|
|
|
- // ── Phase 2: Stable Orbiting (150 frames ≈ 2.5 seconds at 60fps) ──
|
|
|
|
|
|
|
+ // - Phase 2: Stable Orbiting (150 frames ≈ 2.5 seconds at 60fps) -
|
|
|
for frame in 0..<150 {
|
|
for frame in 0..<150 {
|
|
|
memcpy(work, tpl, ABUFSZ)
|
|
memcpy(work, tpl, ABUFSZ)
|
|
|
|
|
|
|
@@ -357,11 +275,11 @@ func drawSwiftSplash() {
|
|
|
diskAA(work, ex, ey, Double(ELEC_R), 255)
|
|
diskAA(work, ex, ey, Double(ELEC_R), 255)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- blit(work, fbp, sx, sy, lineLen, scrH, fd, &vinfo)
|
|
|
|
|
|
|
+ blit(work, fbp, sx, sy, lineLen, scrH, fbFd, screenSize)
|
|
|
usleep(16666)
|
|
usleep(16666)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ── Phase 3: Spiral Inward & Crash (30 frames) ──
|
|
|
|
|
|
|
+ // - Phase 3: Spiral Inward & Crash (30 frames) -
|
|
|
let baseAngle = (35.0 * 0.10) + (150.0 * 0.05)
|
|
let baseAngle = (35.0 * 0.10) + (150.0 * 0.05)
|
|
|
for frame in 0..<30 {
|
|
for frame in 0..<30 {
|
|
|
memset(work, 0, ABUFSZ)
|
|
memset(work, 0, ABUFSZ)
|
|
@@ -398,11 +316,11 @@ func drawSwiftSplash() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- blit(work, fbp, sx, sy, lineLen, scrH, fd, &vinfo)
|
|
|
|
|
|
|
+ blit(work, fbp, sx, sy, lineLen, scrH, fbFd, screenSize)
|
|
|
usleep(16666)
|
|
usleep(16666)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ── Phase 4: Flash & Fade to Black (20 frames) ──
|
|
|
|
|
|
|
+ // - Phase 4: Flash & Fade to Black (20 frames) -
|
|
|
let finalNucG = Double(NUC_R) + 20.0
|
|
let finalNucG = Double(NUC_R) + 20.0
|
|
|
for frame in 0..<20 {
|
|
for frame in 0..<20 {
|
|
|
memset(work, 0, ABUFSZ)
|
|
memset(work, 0, ABUFSZ)
|
|
@@ -412,23 +330,16 @@ func drawSwiftSplash() {
|
|
|
if bright > 0 {
|
|
if bright > 0 {
|
|
|
diskAA(work, Double(AC), Double(AC), flashR, bright)
|
|
diskAA(work, Double(AC), Double(AC), flashR, bright)
|
|
|
}
|
|
}
|
|
|
- blit(work, fbp, sx, sy, lineLen, scrH, fd, &vinfo)
|
|
|
|
|
|
|
+ blit(work, fbp, sx, sy, lineLen, scrH, fbFd, screenSize)
|
|
|
usleep(16666)
|
|
usleep(16666)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ── Clear to BLACK ──
|
|
|
|
|
- memset(fbp, 0, scrSz)
|
|
|
|
|
- _ = pan_display(fd, &vinfo)
|
|
|
|
|
|
|
+ // - Clear to BLACK -
|
|
|
|
|
+ memset(fbp, 0, screenSize)
|
|
|
|
|
+ lseek(fbFd, 0, SEEK_SET)
|
|
|
|
|
+ write(fbFd, fbp, screenSize)
|
|
|
|
|
|
|
|
tpl.deallocate()
|
|
tpl.deallocate()
|
|
|
work.deallocate()
|
|
work.deallocate()
|
|
|
- munmap(fb_ptr, scrSz)
|
|
|
|
|
- close(fd)
|
|
|
|
|
-
|
|
|
|
|
- // Hand over control to ui_test (via ui_daemon) by just hanging here silently
|
|
|
|
|
- while true {
|
|
|
|
|
- usleep(500_000)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Done with splash
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-drawSwiftSplash()
|
|
|