Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start writing C headers, add kernel-headers target
- Loading branch information
Showing
7 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bin/ | ||
*.swp | ||
*.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This directory contains headers for userspace programs written in C. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef __DISPLAY_H | ||
#define __DISPLAY_H | ||
|
||
#include <kernel.h> | ||
|
||
typedef unsigned char SCREEN; | ||
|
||
unsigned char left_margin = 0; | ||
|
||
inline void get_lcd_lock() __naked { | ||
__asm | ||
PCALL(GETLCDLOCK) | ||
__endasm; | ||
} | ||
|
||
SCREEN *create_screen() __naked { | ||
__asm | ||
PCALL(ALLOCSCREENBUFFER) | ||
PUSH IY | ||
POP HL | ||
RET | ||
__endasm; | ||
} | ||
|
||
void clear_buffer(SCREEN *screen) { | ||
__asm | ||
POP IX | ||
POP IY | ||
PCALL(CLEARBUFFER) | ||
PUSH IY | ||
PUSH IX | ||
__endasm; | ||
screen; | ||
} | ||
|
||
void fast_copy(SCREEN *screen) { | ||
__asm | ||
POP IX | ||
POP IY | ||
PCALL(FASTCOPY) | ||
PUSH IY | ||
PUSH IX | ||
__endasm; | ||
screen; | ||
} | ||
|
||
inline void set_left_margin(unsigned char margin) { | ||
left_margin = margin; | ||
} | ||
|
||
void draw_str(SCREEN *screen, unsigned char x, unsigned char y, const char *string) { | ||
__asm | ||
POP IX | ||
POP IY | ||
POP DE | ||
ld hl, _left_margin | ||
ld b, (hl) | ||
POP HL | ||
ld a, d | ||
ld d, e | ||
ld e, a | ||
PCALL(DRAWSTR) | ||
PUSH HL | ||
PUSH DE | ||
PUSH IY | ||
PUSH IX | ||
__endasm; | ||
screen; x; y; string; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef __JUMPTABLE_H | ||
#define __JUMPTABLE_H | ||
|
||
#define PCALL(ADDRESS) \ | ||
.if ADDRESS & 0xFF \ \ | ||
rst 0x20 \ \ | ||
.dw ADDRESS \ \ | ||
.else \ \ | ||
call 0x4000 - (((ADDRESS >> 8) + 1) * 3) \ \ | ||
.endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name=kernel-headers | ||
repo=core | ||
description=Development headers for the KnightOS kernel | ||
# The headers are in the public domain, because they describe an API | ||
# The implementation (i.e. the kernel itself) is still MIT/X11 | ||
copyright=Public Domain | ||
infourl=http://www.knightos.org/documentation/reference/ |