ChibraxOS 2

Changes:
- kernel 6.0.2
- Broken init scripts
- Switch to bun for better peroformance an easier ffi
- Removed grup
- Efi support without graphics (at least graphics werent tested)
- Suppression de toutes les dépendance non libc
- new splash
- broken audio
- typescript support
- ls rewritten to be more reliable
This commit is contained in:
Marc
2022-10-22 13:47:33 +02:00
parent db49f8d205
commit 721c919c7b
76 changed files with 2485 additions and 2665 deletions
+10 -12
View File
@@ -1,6 +1,6 @@
//@ts-check
const fs = require('fs')
const jimp = require('jimp')
import * as fs from 'fs'
import * as jimp from 'jimp'
const screen = getScreenDimensions()
const buffer = Buffer.alloc(screen.width * screen.height * screen.byteDepth)
@@ -24,7 +24,7 @@ function getScreenDimensions() {
/**
* @param { Buffer } data
*/
function flip(data = buffer) {
export function flip(data = buffer) {
try {
fs.writeFileSync('/dev/fb0', data, { encoding: 'binary' })
} catch(e) {
@@ -33,14 +33,14 @@ function flip(data = buffer) {
}
}
function clear() {
export function clear() {
buffer.fill(0)
}
/**
* @param {string} filepath
*/
function removeFromCache(filepath) {
export function removeFromCache(filepath) {
delete imageCache[filepath]
}
@@ -48,7 +48,7 @@ function removeFromCache(filepath) {
* @param {string} filepath
* @returns { Promise<import('@jimp/core').Bitmap> } BGRA buffer
*/
async function readImgFile(filepath) {
export async function readImgFile(filepath) {
const img = await jimp.read(filepath)
const bitmap = img.bitmap
bitmap.data = rgbaTObgra(bitmap.data)
@@ -60,7 +60,7 @@ async function readImgFile(filepath) {
* @param { number } y
* @param { import('@jimp/core').Bitmap | Pencil } bitmap
*/
function drawBitmap(x, y, bitmap, handleTransparency = true) {
export function drawBitmap(x, y, bitmap, handleTransparency = true) {
for(let dy = 0; dy < bitmap.height; dy++) {
let bitmapLineEnd = bitmap.width * screen.byteDepth * (dy + 1)
let bitmapLineStart = bitmap.width * screen.byteDepth * dy
@@ -123,7 +123,7 @@ function drawBitmap(x, y, bitmap, handleTransparency = true) {
* @description this function work fine but will use caching. to clear the cache you can use removeFromCache(filepath) or you can keep the cache on the
* client side and use readImgFile and drawBitmap methods instead
*/
async function drawImgFile(x, y, filepath) {
export async function drawImgFile(x, y, filepath) {
//not caching would imply reading the image each time we want to write it to the screen even for small movement
let bitmap;
if(!imageCache[filepath]) {
@@ -153,7 +153,7 @@ function rgbaTObgra(buff) {
* @param { string } color
* @returns { number[] }
*/
function parseHexColor(color) {
export function parseHexColor(color) {
if(!color.startsWith('#') || color.length !== 7) {
throw new Error('invalid hex color code')
}
@@ -169,7 +169,7 @@ function parseHexColor(color) {
* @param { number } y
* @param { string | number[] } colorCode
*/
function setPixel(x, y, colorCode) {
export function setPixel(x, y, colorCode) {
if (screen.byteDepth !== 4) {
throw new Error('Depth not supported yet')
}
@@ -179,5 +179,3 @@ function setPixel(x, y, colorCode) {
}
buffer.set(colorCode, (x + y * screen.width) * screen.byteDepth)
}
module.exports = { flip, clear, getScreenDimensions, drawImgFile, readImgFile, drawBitmap, parseHexColor, setPixel, removeFromCache }