Meta: Add files to repository

This commit is contained in:
Alec Murphy 2025-03-25 07:32:23 -04:00
parent 80a0428b66
commit 39198164cd
1029 changed files with 78311 additions and 0 deletions

288
System/Jakt/DC.HC Normal file
View file

@ -0,0 +1,288 @@
U0 _Z8dc_aliasm()
{
// dc_alias(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
DCAlias(p0);
POP_SYSV_REGS
}
U0 _Z7dc_blotmmmm()
{
// dc_blot(unsigned long, unsigned long, unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GrBlot(p0, p1, p2, p3);
POP_SYSV_REGS
}
U8* @dc_buffer(CDC* dc) { return dc->body; }
U0 _Z9dc_bufferm()
{
// dc_buffer(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_buffer(p0);
POP_SYSV_REGS
}
I64 @dc_color(CDC* dc) { return dc->color; }
U0 _Z8dc_colorm()
{
// dc_color(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_color(p0);
POP_SYSV_REGS
}
U0 @dc_copy(CDC* dest, I64 x, I64 y, CDC* src)
{
// If position is off-screen, return
if (x > dest->width - 1 || y > dest->height - 1)
return;
// If device context dimensions match, MemCpy and return
if (dest->width_internal == src->width_internal && dest->height == src->height) {
MemCpy(dest->body, src->body, dest->width_internal * dest->height);
return;
}
CDC* dc1 = DCAlias(dest);
CDC* dc2 = DCAlias(src);
I64 src_line = 0;
I64 src_row = 0;
I64 clip_y = 0;
// Handle horizontal clipping left
while (x < 0) {
dc2->x0++;
x++;
}
// Handle vertical clipping top
while (y < 0) {
dc2->body += src->width_internal;
dc2->y0++;
y++;
}
// default, clip line to copy as width-left off screen
src_line = src->width - dc2->x0;
if (-dc2->x0 + x + src->width >= dest->width) {
src_line -= ((-dc2->x0 + x + src->width) - dest->width);
}
dc2->body += dc2->x0;
clip_y = y;
while (src_row < (src->height - dc2->y0) && clip_y < dest->height) {
MemCpy(dc1->body + (y * dest->width) + x, dc2->body, src_line);
dc2->body += src->width_internal;
dc1->body += dest->width_internal;
clip_y++;
src_row++;
}
Free(dc2);
Free(dc1);
}
U0 _Z7dc_copymmmm()
{
// dc_copy(unsigned long, unsigned long, unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_copy(p0, p1, p2, p3);
POP_SYSV_REGS
}
U0 _Z10dc_destroym()
{
// dc_destroy(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
DCDel(p0);
POP_SYSV_REGS
}
U0 _Z14dc_draw_circlemlll()
{
// dc_draw_circle(unsigned long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GrCircle3(p0, p1, p2, 0, p3);
POP_SYSV_REGS
}
U0 _Z19dc_draw_filled_rectmllll()
{
// dc_draw_filled_rect(unsigned long, long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GrRect(p0, p1, p2, p3, p4);
POP_SYSV_REGS
}
U0 _Z12dc_draw_linemllll()
{
// dc_draw_line(unsigned long, long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GrLine3(p0, p1, p2, 0, p3, p4, 0);
POP_SYSV_REGS
}
U0 _Z13dc_draw_pixelmll()
{
// dc_draw_pixel(unsigned long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GrPlot(p0, p1, p2);
POP_SYSV_REGS
}
U0 _Z7dc_fillmm()
{
// dc_fill(unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
DCFill(p0, p1);
POP_SYSV_REGS
}
CDC* @dc_gr_dc() { return gr.dc; }
U0 _Z8dc_gr_dcv()
{
// dc_gr_dc()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_gr_dc();
POP_SYSV_REGS
}
I64 @dc_height(CDC* dc) { return dc->height; }
U0 _Z9dc_heightm()
{
// dc_height(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_height(p0);
POP_SYSV_REGS
}
U0 _Z17dc_load_from_filePKc()
{
// dc_load_from_file(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GRRead(p0);
POP_SYSV_REGS
}
U0 _Z6dc_newmm()
{
// dc_new(unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
DCNew(p0, p1);
POP_SYSV_REGS
}
U0 _Z11dc_pixel_atmll()
{
// dc_pixel_at(unsigned long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GrPeek(p0, p1, p2);
POP_SYSV_REGS
}
U0 _Z16dc_replace_colormmm()
{
// dc_replace_color(unsigned long, unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
DCColorChg(p0, p1, p2);
POP_SYSV_REGS
}
U0 _Z13dc_screenshotv()
{
// dc_screenshot()
PUSH_SYSV_REGS
GET_SYSV_ARGS
DCScrnCapture(1);
POP_SYSV_REGS
}
U0 _Z15dc_save_to_filePKcm()
{
// dc_save_to_file(char const*, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GRWrite(p0, p1);
POP_SYSV_REGS
}
U0 @dc_set_color(CDC* dc, I64 color) { dc->color = color; }
U0 _Z12dc_set_colorml()
{
// dc_set_color(unsigned long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_set_color(p0, p1);
POP_SYSV_REGS
}
U0 @dc_set_thickness(CDC* dc, I64 thickness) { dc->thick = thickness; }
U0 _Z16dc_set_thicknessml()
{
// dc_set_thickness(unsigned long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_set_thickness(p0, p1);
POP_SYSV_REGS
}
I64 @dc_thickness(CDC* dc) { return dc->thick; }
U0 _Z12dc_thicknessm()
{
// dc_thickness(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_thickness(p0);
POP_SYSV_REGS
}
I64 @dc_width(CDC* dc) { return dc->width; }
U0 _Z8dc_widthm()
{
// dc_width(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_width(p0);
POP_SYSV_REGS
}
I64 @dc_width_internal(CDC* dc) { return dc->width_internal; }
U0 _Z17dc_width_internalm()
{
// dc_width_internal(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@dc_width_internal(p0);
POP_SYSV_REGS
}

53
System/Jakt/IOPort.HC Normal file
View file

@ -0,0 +1,53 @@
U0 _Z14ioport_read_u8t()
{
// ioport_read_u8(unsigned short)
PUSH_SYSV_REGS
GET_SYSV_ARGS
InU8(p0);
POP_SYSV_REGS
}
U0 _Z15ioport_read_u16t()
{
// ioport_read_u16(unsigned short)
PUSH_SYSV_REGS
GET_SYSV_ARGS
InU16(p0);
POP_SYSV_REGS
}
U0 _Z15ioport_read_u32t()
{
// ioport_read_u32(unsigned short)
PUSH_SYSV_REGS
GET_SYSV_ARGS
InU32(p0);
POP_SYSV_REGS
}
U0 _Z15ioport_write_u8th()
{
// ioport_write_u8(unsigned short, unsigned char)
PUSH_SYSV_REGS
GET_SYSV_ARGS
OutU8(p0, p1);
POP_SYSV_REGS
}
U0 _Z16ioport_write_u16tt()
{
// ioport_write_u16(unsigned short, unsigned short)
PUSH_SYSV_REGS
GET_SYSV_ARGS
OutU16(p0, p1);
POP_SYSV_REGS
}
U0 _Z16ioport_write_u32tj()
{
// ioport_write_u32(unsigned short, unsigned int)
PUSH_SYSV_REGS
GET_SYSV_ARGS
OutU32(p0, p1);
POP_SYSV_REGS
}

72
System/Jakt/Input.HC Normal file
View file

@ -0,0 +1,72 @@
U0 _Z16input_get_stringPKc()
{
// input_get_string(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
GetStr(p0);
POP_SYSV_REGS
}
Bool @input_key_down(U8 scancode) { return Bt(kbd.down_bitmap, scancode); }
U0 _Z14input_key_downh()
{
// input_key_down(unsigned char)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@input_key_down(p0);
POP_SYSV_REGS
}
Bool @input_mouse_left() { return ms.lb; }
U0 _Z16input_mouse_leftv()
{
// input_mouse_left()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@input_mouse_left();
POP_SYSV_REGS
}
Bool @input_mouse_right() { return ms.rb; }
U0 _Z17input_mouse_rightv()
{
// input_mouse_right()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@input_mouse_right();
POP_SYSV_REGS
}
I64 @input_mouse_x() { return ms.pos.x; }
U0 _Z13input_mouse_xv()
{
// input_mouse_x()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@input_mouse_x();
POP_SYSV_REGS
}
I64 @input_mouse_y() { return ms.pos.y; }
U0 _Z13input_mouse_yv()
{
// input_mouse_y()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@input_mouse_y();
POP_SYSV_REGS
}
U0 _Z17input_press_a_keyv()
{
// input_press_a_key()
PUSH_SYSV_REGS
GET_SYSV_ARGS
PressAKey;
POP_SYSV_REGS
}

289
System/Jakt/OS.HC Normal file
View file

@ -0,0 +1,289 @@
U0 _Z8os_blinkPKc()
{
// os_blink(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
F64 frequency = Str2F64(p0);
Print("called os_blink(%.1f)\n", frequency);
Blink(frequency);
POP_SYSV_REGS
}
U64 @os_call(U8* function_name, U64 arg)
{
if (!function_name)
return NULL;
if (!StrLen(function_name))
return NULL;
CHash* h = HashFind(function_name, Fs->hash_table, Fs->hash_table->mask);
if (!h)
return NULL;
if (h->type & HTT_FUN == HTT_FUN) {
CallInd(h(CHashFun*)->exe_addr, arg);
} else {
return NULL;
}
}
U0 _Z7os_callmm()
{
// os_call(unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@os_call(p0, p1);
POP_SYSV_REGS
}
U0 _Z16os_device_callocj()
{
// os_device_calloc(unsigned int)
PUSH_SYSV_REGS
GET_SYSV_ARGS
CAllocAligned(p0, 4096, erythros_mem_task->code_heap);
POP_SYSV_REGS
}
U0 _Z7os_exitv()
{
// os_exit()
PUSH_SYSV_REGS
GET_SYSV_ARGS
UserTaskCont;
POP_SYSV_REGS
}
U8* @os_file_picker(U8* path, U8* glob)
{
U8* full_path = CAlloc(StrLen(path) + StrLen(glob) + 4, erythros_mem_task);
CatPrint(full_path, "%s/%s", path, glob);
CDirEntry* de = FilesFind(full_path);
Free(full_path);
CDirEntry* tmpde;
U8* file_list = NULL;
U8* selected_file = NULL;
I64 list_pos = 0;
I64 list_size = 0;
tmpde = de;
while (tmpde) {
list_size += StrLen(tmpde->name) + 2;
tmpde = tmpde->next;
}
file_list = CAlloc(list_size, erythros_mem_task);
tmpde = de;
while (tmpde) {
StrCpy(file_list + list_pos, tmpde->name);
list_pos += StrLen(tmpde->name) + 1;
tmpde = tmpde->next;
}
I64 list_index = Adam("PopUpPickLst(0x%08x);\n", file_list);
Free(file_list);
list_pos = 0;
if (list_index < 0) {
DirTreeDel(de);
return StrNew("", erythros_mem_task);
}
tmpde = de;
while (tmpde) {
if (list_index == list_pos) {
selected_file = CAlloc(StrLen(path) + StrLen(tmpde->name) + 4, erythros_mem_task);
CatPrint(selected_file, "%s/%s", path, tmpde->name);
break;
}
StrCpy(file_list + list_pos, tmpde->name);
list_pos++;
tmpde = tmpde->next;
}
DirTreeDel(de);
return selected_file;
}
U0 _Z14os_file_pickerPKcS0_()
{
// os_file_picker(char const*, char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@os_file_picker(p0, p1);
POP_SYSV_REGS
}
U8* @os_files_list(U8* path)
{
U8* full_path = CAlloc(StrLen(path) + 4, erythros_mem_task);
CatPrint(full_path, "%s", path);
CDirEntry* de = FilesFind(full_path);
Free(full_path);
CDateStruct ds;
CDirEntry* tmpde;
U8* file_list = NULL;
I64 list_size = 0;
tmpde = de;
while (tmpde) {
list_size += StrLen(tmpde->name) + 48; // Should be enough for filename, date,
// filesize + semicolon separators
tmpde = tmpde->next;
}
if (!list_size)
return NULL;
file_list = CAlloc(list_size, erythros_mem_task);
tmpde = de;
I64 counter = 0;
while (tmpde) {
if (counter > 0) {
StrCpy(file_list + StrLen(file_list), "|");
}
StrCpy(file_list + StrLen(file_list), tmpde->name);
if (tmpde->attr & RS_ATTR_DIR)
StrCpy(file_list + StrLen(file_list), "/");
StrCpy(file_list + StrLen(file_list), ";");
Date2Struct(&ds, tmpde->datetime);
StrPrint(file_list + StrLen(file_list), "%04d-%02d-%02d %02d:%02d", ds.year,
ds.mon, ds.day_of_mon, ds.hour, ds.min);
StrCpy(file_list + StrLen(file_list), ";");
StrPrint(file_list + StrLen(file_list), "%d", tmpde->size);
tmpde = tmpde->next;
counter++;
}
DirTreeDel(de);
return file_list;
}
U0 _Z14os_path_existsPKc()
{
// os_path_exists(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
FileFind(p0);
POP_SYSV_REGS
}
U0 _Z13os_files_listPKc()
{
// os_files_list(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@os_files_list(p0);
POP_SYSV_REGS
}
Bool @os_is_vm()
{
CRAXRBCRCXRDX res;
CPUId(0x40000000, &res);
if (res.rbx == 0x4B4D564B)
return TRUE;
return FALSE;
}
U0 _Z8os_is_vmv()
{
PUSH_SYSV_REGS
GET_SYSV_ARGS
@os_is_vm;
POP_SYSV_REGS
}
U0 @os_pc_speaker(F64 frequency)
{
I64 period;
if (!frequency)
OutU8(0x61, InU8(0x61) & ~3);
else {
period = ClampI64(SYS_TIMER_FREQ / frequency, 1, U16_MAX);
OutU8(0x43, 0xB6);
OutU8(0x42, period);
OutU8(0x42, period.u8[1]);
OutU8(0x61, 3 | InU8(0x61));
}
}
U0 _Z13os_pc_speakerPKc()
{
// os_pc_speaker(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
F64 frequency = Str2F64(p0);
@os_pc_speaker(frequency);
POP_SYSV_REGS
}
U0 _Z9os_randomv()
{
// os_random()
PUSH_SYSV_REGS
GET_SYSV_ARGS
RandU64;
POP_SYSV_REGS
}
U0 _Z19os_read_entire_filePKcPl()
{
// os_read_entire_file(char const*, long*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
FileRead(p0, p1);
POP_SYSV_REGS
}
U0 @os_screenshot()
{
CDC* dc = DCScrnCapture(, erythros_mem_task);
// Image.Write("B:/screenshot.png", dc);
DCDel(dc);
}
U0 _Z13os_screenshotv()
{
// os_screenshot()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@os_screenshot;
POP_SYSV_REGS
}
U8* @os_to_uppercase(U8* instr)
{
if (!instr)
return NULL;
if (!StrLen(instr))
return NULL;
U8* outstr = CAlloc(StrLen(instr) + 1, erythros_mem_task);
I64 i;
for (i = 0; i < StrLen(instr); i++)
outstr[i] = ToUpper(instr[i]);
return outstr;
}
U0 _Z15os_to_uppercasePKc()
{
// os_to_uppercase(char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@os_to_uppercase(p0);
POP_SYSV_REGS
}
U0 _Z20os_write_entire_filePKcPhl()
{
// os_write_entire_file(char const*, unsigned char*, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
FileWrite(p0, p1, p2);
POP_SYSV_REGS
}

62
System/Jakt/PCI.HC Normal file
View file

@ -0,0 +1,62 @@
U0 _Z8pci_findl()
{
// pci_find(long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIClassFind(p0, 0);
POP_SYSV_REGS
}
U0 _Z11pci_read_u8llll()
{
// pci_read_u8(long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIReadU8(p0, p1, p2, p3);
POP_SYSV_REGS
}
U0 _Z12pci_read_u16llll()
{
// pci_read_u16(long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIReadU16(p0, p1, p2, p3);
POP_SYSV_REGS
}
U0 _Z12pci_read_u32llll()
{
// pci_read_u32(long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIReadU32(p0, p1, p2, p3);
POP_SYSV_REGS
}
U0 _Z12pci_write_u8llllh()
{
// pci_write_u8(long, long, long, long, unsigned char)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIWriteU8(p0, p1, p2, p3, p4);
POP_SYSV_REGS
}
U0 _Z13pci_write_u16llllt()
{
// pci_write_u16(long, long, long, long, unsigned short)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIWriteU16(p0, p1, p2, p3, p4);
POP_SYSV_REGS
}
U0 _Z13pci_write_u32llllj()
{
// pci_write_u32(long, long, long, long, unsigned int)
PUSH_SYSV_REGS
GET_SYSV_ARGS
PCIWriteU32(p0, p1, p2, p3, p4);
POP_SYSV_REGS
}

37
System/Jakt/Time.HC Normal file
View file

@ -0,0 +1,37 @@
U0 _Z9time_busyl()
{
// time_busy(long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
Busy(p0);
POP_SYSV_REGS
}
I64 @time_jiffies() { return cnts.jiffies; }
U0 _Z12time_jiffiesv()
{
// time_jiffies()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@time_jiffies;
POP_SYSV_REGS
}
U0 _Z8time_nowv()
{
// time_now()
PUSH_SYSV_REGS
GET_SYSV_ARGS
Now;
POP_SYSV_REGS
}
U0 _Z10time_sleepl()
{
// time_sleep(long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
Sleep(p0);
POP_SYSV_REGS
}

94
System/Jakt/Window.HC Normal file
View file

@ -0,0 +1,94 @@
U0 @window_draw_it(CTask* task, CDC* dc)
{
if (task->user_data)
@dc_copy(dc, task->pix_left, task->pix_top, task->user_data);
}
CTask* @window_user()
{
CTask* task = Spawn(&UserCmdLine, , , 0);
TaskWait(task);
XTalk(task,
"while (1) { StrCpy(Fs->task_title, Fs->task_name); Sleep(1); };\n");
return task;
}
CTask* @window_create()
{
CTask* task = @window_user;
task->draw_it = &@window_draw_it;
return task;
}
U0 _Z13window_createv()
{
// window_create()
PUSH_SYSV_REGS
GET_SYSV_ARGS
@window_create();
POP_SYSV_REGS
}
U0 _Z14window_destroym()
{
// window_destroy(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
Kill(p0);
POP_SYSV_REGS
}
Bool @window_is_focused(CTask* task) { return task == sys_focus_task; }
U0 _Z17window_is_focusedm()
{
// window_is_focused(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@window_is_focused(p0);
POP_SYSV_REGS
}
U0 @window_set_coordinates(CTask* task, I64 top, I64 left, I64 bottom,
I64 right)
{
task->win_top = top;
task->win_left = left;
task->win_bottom = bottom;
task->win_right = right;
}
U0 _Z22window_set_coordinatesmllll()
{
// window_set_coordinates(unsigned long, long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@window_set_coordinates(p0, p1, p2, p3, p4);
POP_SYSV_REGS
}
U0 @window_set_context(CTask* task, CDC* dc) { task->user_data = dc; }
U0 _Z18window_set_contextmm()
{
// window_set_context(unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@window_set_context(p0, p1);
POP_SYSV_REGS
}
U0 @window_set_title(CTask* task, U8* title)
{
StrCpy(task->task_name, title);
StrCpy(task->task_title, title);
}
U0 _Z16window_set_titlemPKc()
{
// window_set_title(unsigned long, char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
@window_set_title(p0, p1);
POP_SYSV_REGS
}