mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 23:10:32 +00:00
Compare commits
15 commits
73dd2acbf6
...
35c1d08879
Author | SHA1 | Date | |
---|---|---|---|
|
35c1d08879 | ||
|
8773bd95f0 | ||
|
5658469acb | ||
|
2ffd423f7b | ||
|
38c41e551a | ||
|
b08c10e343 | ||
|
f8c9845026 | ||
|
05febc9803 | ||
|
9f363f265d | ||
|
16eec2be89 | ||
|
4e77bf1c0a | ||
|
d1380b57f1 | ||
|
41e7e302d5 | ||
|
ad7489e322 | ||
|
262ab2bb5c |
14 changed files with 351 additions and 36 deletions
|
@ -74,6 +74,12 @@ else
|
||||||
sudo modprobe nbd
|
sudo modprobe nbd
|
||||||
[ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT
|
[ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT
|
||||||
case $1 in
|
case $1 in
|
||||||
|
flush)
|
||||||
|
mount_vdisk
|
||||||
|
sudo blockdev --flushbufs /dev/nbd0
|
||||||
|
sudo dosfsck -w -r -l -v -t /dev/nbd0
|
||||||
|
umount_vdisk
|
||||||
|
;;
|
||||||
diff)
|
diff)
|
||||||
mount_vdisk
|
mount_vdisk
|
||||||
diff -x *.MAP --color=always -r ../src/ $TMPMOUNT/ | less -R -p "diff -x.*|Only in.*"
|
diff -x *.MAP --color=always -r ../src/ $TMPMOUNT/ | less -R -p "diff -x.*|Only in.*"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
I0 DrawPixel(I64 x, I64 y, CBGR24 color)
|
I0 DrawPixel(I64 x, I64 y, CBGR24 color)
|
||||||
{
|
{
|
||||||
text.fb_alias[x + y * GR_WIDTH] = color;
|
text.fb_alias[x + y * sys_framebuffer_width] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
I0 Color32Demo()
|
I0 Color32Demo()
|
||||||
|
|
|
@ -32,12 +32,12 @@ U0 PaintGlobalsInit()
|
||||||
|
|
||||||
I0 DrawImagePixel(I64 x, I64 y, CBGR24 color)
|
I0 DrawImagePixel(I64 x, I64 y, CBGR24 color)
|
||||||
{
|
{
|
||||||
paint.fb[x + y * GR_WIDTH] = color;
|
paint.fb[x + y * sys_framebuffer_width] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
I0 DrawScreenPixel(I64 x, I64 y, CBGR24 color)
|
I0 DrawScreenPixel(I64 x, I64 y, CBGR24 color)
|
||||||
{
|
{
|
||||||
text.fb_alias[x + y * GR_WIDTH] = color;
|
text.fb_alias[x + y * sys_framebuffer_width] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
I0 DrawScreenChar(I64 x, I64 y, I64 char)
|
I0 DrawScreenChar(I64 x, I64 y, I64 char)
|
||||||
|
@ -136,7 +136,7 @@ U0 PaintLoadImage()
|
||||||
|
|
||||||
U32 PaintImagePeek(I64 x, I64 y)
|
U32 PaintImagePeek(I64 x, I64 y)
|
||||||
{
|
{
|
||||||
return paint.fb[x + y * GR_WIDTH];
|
return paint.fb[x + y * sys_framebuffer_width];
|
||||||
}
|
}
|
||||||
|
|
||||||
I0 Paint32()
|
I0 Paint32()
|
||||||
|
@ -176,7 +176,7 @@ I0 Paint32()
|
||||||
// draw the image where the brush was last covering it
|
// draw the image where the brush was last covering it
|
||||||
for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++)
|
for (i = paint.last_x; i < paint.last_x + paint.last_thick; i++)
|
||||||
for (j = paint.last_y; j < paint.last_y + paint.last_thick; j++)
|
for (j = paint.last_y; j < paint.last_y + paint.last_thick; j++)
|
||||||
DrawScreenPixel(i, j, paint.fb[i + j * GR_WIDTH]);
|
DrawScreenPixel(i, j, paint.fb[i + j * sys_framebuffer_width]);
|
||||||
|
|
||||||
// draw the brush on the screen
|
// draw the brush on the screen
|
||||||
DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick);
|
DrawScreenBrush(mouse.pos.x, mouse.pos.y, paint.color, paint.thick);
|
||||||
|
@ -193,7 +193,7 @@ I0 Paint32()
|
||||||
// draw the image where the color strings where covering it
|
// draw the image where the color strings where covering it
|
||||||
for (i = 0; i < 3 * FONT_HEIGHT; i++)
|
for (i = 0; i < 3 * FONT_HEIGHT; i++)
|
||||||
for (j = 0; j < 12 * FONT_WIDTH; j++)
|
for (j = 0; j < 12 * FONT_WIDTH; j++)
|
||||||
DrawScreenPixel(j, i, paint.fb[j + i * GR_WIDTH]);
|
DrawScreenPixel(j, i, paint.fb[j + i * sys_framebuffer_width]);
|
||||||
|
|
||||||
// draw the color strings on screen
|
// draw the color strings on screen
|
||||||
DrawScreenStr(0, 0 * FONT_HEIGHT, str_r);
|
DrawScreenStr(0, 0 * FONT_HEIGHT, str_r);
|
||||||
|
|
51
src/Home/Net/Programs/Skynet/HowToHost.TXT
Executable file
51
src/Home/Net/Programs/Skynet/HowToHost.TXT
Executable file
|
@ -0,0 +1,51 @@
|
||||||
|
// This is an NGINX reverse proxy configuration file for the Skynet Middleware
|
||||||
|
|
||||||
|
server {
|
||||||
|
// set whatever port you'd like
|
||||||
|
listen 9000;
|
||||||
|
// replace the server name with yours
|
||||||
|
server_name skynet.middleware.com;
|
||||||
|
|
||||||
|
# Custom log locations
|
||||||
|
access_log /var/log/nginx/skynet_access.log;
|
||||||
|
error_log /var/log/nginx/skynet_error.log;
|
||||||
|
|
||||||
|
location /gpt3 {
|
||||||
|
proxy_pass https://api.openai.com/v1/completions; # GPT-3 endpoint
|
||||||
|
|
||||||
|
# Required for SSL verification with the upstream server (OpenAI)
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
|
proxy_ssl_session_reuse off;
|
||||||
|
|
||||||
|
# Headers for OpenAI
|
||||||
|
// replace the sk-XXXX with your API key
|
||||||
|
proxy_set_header Authorization "Bearer sk-XXXX";
|
||||||
|
proxy_set_header Content-Type "application/json";
|
||||||
|
|
||||||
|
# Standard proxy headers
|
||||||
|
proxy_set_header Host api.openai.com;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /chat {
|
||||||
|
proxy_pass https://api.openai.com/v1/chat/completions; # ChatGPT endpoint
|
||||||
|
|
||||||
|
# Required for SSL verification with the upstream server (OpenAI)
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||||
|
proxy_ssl_session_reuse off;
|
||||||
|
|
||||||
|
# Headers for OpenAI
|
||||||
|
// replace the sk-XXXX with your API key
|
||||||
|
proxy_set_header Authorization "Bearer sk-XXXX";
|
||||||
|
proxy_set_header Content-Type "application/json";
|
||||||
|
|
||||||
|
# Standard proxy headers
|
||||||
|
proxy_set_header Host api.openai.com;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
170
src/Home/Net/Programs/Skynet/Skynet.ZC
Executable file
170
src/Home/Net/Programs/Skynet/Skynet.ZC
Executable file
|
@ -0,0 +1,170 @@
|
||||||
|
#define SERVER_ADDR "skynet.middleware.com"
|
||||||
|
#define SERVER_PORT 9000
|
||||||
|
#define INITIAL_BUF_SIZE 2048
|
||||||
|
#define DEFAULT_SYSTEMPROMPT "You are a helpful assistant but roleplay as skynet from Terminator."
|
||||||
|
#include "::/Home/Net/Utilities/JSON/JSON"
|
||||||
|
class Message {
|
||||||
|
U8 role[10]; // "user" or "assistant"
|
||||||
|
U8 content[1024];
|
||||||
|
} history[100];
|
||||||
|
I64 currentHistoryCount = 0;
|
||||||
|
|
||||||
|
U0 AppendToHistory(U8 *role, U8 *content) {
|
||||||
|
if (currentHistoryCount < 100) {
|
||||||
|
StrCopy(history[currentHistoryCount].role, role);
|
||||||
|
StrCopy(history[currentHistoryCount].content, content);
|
||||||
|
currentHistoryCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
U8 *StrChr(U8 *Str,U8 Pivot)
|
||||||
|
{
|
||||||
|
//U8 *Orig=Str;
|
||||||
|
while (*Str!=Pivot&&*Str!=0)Str++;
|
||||||
|
if (*Str==Pivot) return Str;
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
U8* RemoveBeforeJSON(U8 *input) {
|
||||||
|
U8 *jsonStart = StrChr(input, '{');
|
||||||
|
|
||||||
|
if (jsonStart != NULL) {
|
||||||
|
return jsonStart;
|
||||||
|
}
|
||||||
|
return NULL; // No JSON detected
|
||||||
|
}
|
||||||
|
|
||||||
|
I64 Skynet(U8 *message, U8 *system, U8 *model)
|
||||||
|
{
|
||||||
|
I64 sock, index, bufferSize = INITIAL_BUF_SIZE;
|
||||||
|
U8 *responseBuf = MAlloc(bufferSize); // Dynamic allocation of the buffer
|
||||||
|
|
||||||
|
sock = TCPConnectionCreate(SERVER_ADDR, SERVER_PORT);
|
||||||
|
if (sock <= 0)
|
||||||
|
{
|
||||||
|
PrintErr("Failed to connect to middleware server");
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
U8 *messages = StrPrint(NULL, "{\"role\": \"system\",\"content\": \"%s\"},", system);
|
||||||
|
|
||||||
|
for (index = 0; index < currentHistoryCount; index++) {
|
||||||
|
U8 *msg = StrPrint(NULL, "{\"role\": \"%s\",\"content\": \"%s\"},", history[index].role, history[index].content);
|
||||||
|
messages = CatPrint(messages, msg);
|
||||||
|
Free(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
U8 *currentUserMsg = StrPrint(NULL, "{\"role\": \"user\",\"content\": \"%s\"}", message);
|
||||||
|
messages = CatPrint(messages, currentUserMsg);
|
||||||
|
Free(currentUserMsg);
|
||||||
|
|
||||||
|
U8 *payload = StrPrint(NULL, "{\"model\": \"%s\",\"messages\": [%s]}", model, messages);
|
||||||
|
Free(messages);
|
||||||
|
|
||||||
|
//SysLog(payload);
|
||||||
|
|
||||||
|
U8 *requestHeader = StrPrint(NULL,
|
||||||
|
"POST /chat HTTP/1.1\r\n"
|
||||||
|
"Host: %s:%d\r\n"
|
||||||
|
"User-Agent: ZealOSClient/1.0\r\n"
|
||||||
|
"Accept: */*\r\n"
|
||||||
|
"Content-Type: application/json\r\n"
|
||||||
|
"Content-Length: %d\r\n"
|
||||||
|
"\r\n",
|
||||||
|
SERVER_ADDR,
|
||||||
|
SERVER_PORT,
|
||||||
|
StrLen(payload)
|
||||||
|
);
|
||||||
|
|
||||||
|
U8 *fullRequest = StrPrint(NULL, "%s%s", requestHeader, payload);
|
||||||
|
TCPSocketSendString(sock, fullRequest);
|
||||||
|
|
||||||
|
Free(requestHeader);
|
||||||
|
Free(payload);
|
||||||
|
Free(fullRequest);
|
||||||
|
|
||||||
|
I64 responseLength = TCPSocketReceive(sock, responseBuf, bufferSize - 1);
|
||||||
|
responseBuf[responseLength] = 0; // Null-terminate the buffer for safety
|
||||||
|
|
||||||
|
if (responseLength == sizeof(responseBuf) - 1) {
|
||||||
|
PrintErr("Warning: responseBuf might be full. Some data could be truncated.");
|
||||||
|
}
|
||||||
|
// Check if buffer might be full
|
||||||
|
while (responseLength == bufferSize - 1)
|
||||||
|
{
|
||||||
|
// Double the buffer size and reallocate
|
||||||
|
bufferSize *= 2;
|
||||||
|
Free(responseBuf);
|
||||||
|
responseBuf = MAlloc(bufferSize);
|
||||||
|
|
||||||
|
// Continue receiving data from where you left off
|
||||||
|
responseLength += TCPSocketReceive(sock, responseBuf + responseLength, bufferSize - responseLength - 1);
|
||||||
|
responseBuf[responseLength] = 0;
|
||||||
|
}
|
||||||
|
//SysLog(responseBuf);
|
||||||
|
|
||||||
|
CCompCtrl *cc = CompCtrlNew(MStrPrint("%s", RemoveBeforeJSON(responseBuf)));
|
||||||
|
CJSONDataEntry *jsonData = JSONParse(cc);
|
||||||
|
|
||||||
|
// Retrieve the 'choices' array
|
||||||
|
CJSONDataEntry *choicesEntry = JSONKeyValueGet(jsonData, "choices");
|
||||||
|
if (!choicesEntry || choicesEntry->type != JSONT_ARRAY) {
|
||||||
|
// Handle error: choices key not found or not an array
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the first object from the 'choices' array
|
||||||
|
CJSONDataEntry *firstChoice = JSONIndexValueGet(choicesEntry, 0);
|
||||||
|
if (!firstChoice || firstChoice->type != JSONT_OBJ) {
|
||||||
|
// Handle error: First choice not found or not an object
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the 'message' object from the first choice
|
||||||
|
CJSONDataEntry *messageEntry = JSONKeyValueGet(firstChoice, "message");
|
||||||
|
if (!messageEntry || messageEntry->type != JSONT_OBJ) {
|
||||||
|
// Handle error: message key not found or not an object
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the 'content' string from the 'message' object
|
||||||
|
CJSONDataEntry *contentEntry = JSONKeyValueGet(messageEntry, "content");
|
||||||
|
if (!contentEntry || contentEntry->type != JSONT_STRING) {
|
||||||
|
// Handle error: content key not found or not a string
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
U8 *completion = contentEntry->string_data;
|
||||||
|
//SysLog(completion);
|
||||||
|
CompCtrlDel(cc);
|
||||||
|
|
||||||
|
"\n$$RED$$ Skynet: $$YELLOW$$%s$$FG$$\n", completion;
|
||||||
|
|
||||||
|
AppendToHistory("user", message);
|
||||||
|
AppendToHistory("assistant", completion);
|
||||||
|
|
||||||
|
TCPSocketClose(sock);
|
||||||
|
Free(responseBuf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// gpt-3.5-turbo || gpt-4
|
||||||
|
public U0 ChatUI(U8 *system=DEFAULT_SYSTEMPROMPT, U8 *model="gpt-4") {
|
||||||
|
U8 *userInput;
|
||||||
|
DocClear;
|
||||||
|
|
||||||
|
try{
|
||||||
|
"\t\t\t\t\t\t\t$$LTRED$$Welcome to Skynet$$FG$$\n";
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
"\n$$LTBLUE$$ You: $$GREEN$$";
|
||||||
|
|
||||||
|
LBts(&Fs->task_flags, TASKf_CMD_LINE_PROMPT);
|
||||||
|
userInput = StrGet(,, SGF_SHIFT_ESC_EXIT);
|
||||||
|
LBtr(&Fs->task_flags, TASKf_CMD_LINE_PROMPT);
|
||||||
|
Skynet(userInput, system, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
PutExcept;
|
||||||
|
}
|
||||||
|
ChatUI;
|
73
src/Home/Net/Programs/Skynet/Skynet3.ZC
Executable file
73
src/Home/Net/Programs/Skynet/Skynet3.ZC
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
#define SERVER_ADDR "skynet.middleware.com"
|
||||||
|
#define SERVER_PORT 9000
|
||||||
|
|
||||||
|
// GPT2 - GPT3 version
|
||||||
|
U8* ExtractGPTCompletion(U8 *response) {
|
||||||
|
U8 *start = StrFind("\"text\": \"", response);
|
||||||
|
if (!start) {
|
||||||
|
return NULL; // Pattern not found
|
||||||
|
}
|
||||||
|
|
||||||
|
start += 10; // Move pointer after '"text": "'
|
||||||
|
|
||||||
|
U8 *end = StrFind("\",", start); // Find the closing double quote
|
||||||
|
if (!end) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*end = 0; // Null terminate the completion string
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public I64 Skynet3(U8 *prompt)
|
||||||
|
{
|
||||||
|
U8 responseBuf[8192];
|
||||||
|
I64 sock;
|
||||||
|
|
||||||
|
sock = TCPConnectionCreate(SERVER_ADDR, SERVER_PORT);
|
||||||
|
if (sock <= 0)
|
||||||
|
{
|
||||||
|
PrintErr("Failed to connect to middleware server");
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
U8 *payload = StrPrint(NULL, "{\"model\": \"text-davinci-003\",\"prompt\": \"%s\",\"max_tokens\": 100,\"temperature\": 1}", prompt);
|
||||||
|
U8 *requestHeader = StrPrint(NULL,
|
||||||
|
"POST /gpt3 HTTP/1.1\r\n"
|
||||||
|
"Host: %s:%d\r\n"
|
||||||
|
"User-Agent: ZealOSClient/1.0\r\n"
|
||||||
|
"Accept: */*\r\n"
|
||||||
|
"Content-Type: application/json\r\n"
|
||||||
|
"Content-Length: %d\r\n"
|
||||||
|
"\r\n",
|
||||||
|
SERVER_ADDR,
|
||||||
|
SERVER_PORT,
|
||||||
|
StrLen(payload)
|
||||||
|
);
|
||||||
|
U8 *fullRequest = StrPrint(NULL, "%s%s\n\n", requestHeader, payload);
|
||||||
|
|
||||||
|
TCPSocketSendString(sock, fullRequest);
|
||||||
|
Free(requestHeader);
|
||||||
|
Free(payload);
|
||||||
|
Free(fullRequest);
|
||||||
|
|
||||||
|
|
||||||
|
I64 responseLength = TCPSocketReceive(sock, responseBuf, sizeof(responseBuf) - 1); // -1 to ensure space for null terminator
|
||||||
|
|
||||||
|
responseBuf[responseLength] = 0; // Null-terminate the response
|
||||||
|
|
||||||
|
// Assuming the headers and payload are separated by two newline sequences (standard HTTP)
|
||||||
|
U8 *jsonPayload = StrFind("\r\n\r\n", responseBuf);
|
||||||
|
if (!jsonPayload) {
|
||||||
|
TCPSocketClose(sock);
|
||||||
|
return -1; // or some error code
|
||||||
|
}
|
||||||
|
jsonPayload += 4; // Move past the header separator
|
||||||
|
|
||||||
|
U8 *completion = ExtractGPTCompletion(jsonPayload);
|
||||||
|
Print("$$RED$$Skynet: $$YELLOW$$%s$$FG$$\n", completion);
|
||||||
|
|
||||||
|
TCPSocketClose(sock);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -60,17 +60,17 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
|
||||||
{//Scroll screen down
|
{//Scroll screen down
|
||||||
|
|
||||||
MemCopy(text.fb_alias,
|
MemCopy(text.fb_alias,
|
||||||
text.fb_alias + sys_framebuffer_width * FONT_HEIGHT,
|
text.fb_alias + sys_framebuffer_pidth * FONT_HEIGHT,
|
||||||
(text.screen_size - sys_framebuffer_width * FONT_HEIGHT) * sizeof(U32));
|
(text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT) * sizeof(U32));
|
||||||
|
|
||||||
MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_width * FONT_HEIGHT, BLACK32, sys_framebuffer_width * FONT_HEIGHT);
|
MemSetU32(text.fb_alias + text.screen_size - sys_framebuffer_pidth * FONT_HEIGHT, BLACK32, sys_framebuffer_pidth * FONT_HEIGHT);
|
||||||
text.raw_col -= text.cols ;
|
text.raw_col -= text.cols ;
|
||||||
row = text.rows - 1;
|
row = text.rows - 1;
|
||||||
}
|
}
|
||||||
x = col * FONT_WIDTH;
|
x = col * FONT_WIDTH;
|
||||||
y = row * FONT_HEIGHT;
|
y = row * FONT_HEIGHT;
|
||||||
ch_bitmap = text.font[ch & 0xFF];
|
ch_bitmap = text.font[ch & 0xFF];
|
||||||
framebuffer = text.fb_alias + sys_framebuffer_width * y + x;
|
framebuffer = text.fb_alias + sys_framebuffer_pidth * y + x;
|
||||||
|
|
||||||
PUSHFD
|
PUSHFD
|
||||||
CLI
|
CLI
|
||||||
|
@ -81,7 +81,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
|
||||||
else
|
else
|
||||||
*framebuffer++ = BLACK32;
|
*framebuffer++ = BLACK32;
|
||||||
if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1)
|
if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1)
|
||||||
framebuffer += sys_framebuffer_width - FONT_WIDTH;
|
framebuffer += sys_framebuffer_pidth - FONT_WIDTH;
|
||||||
ch_bitmap >>= 1;
|
ch_bitmap >>= 1;
|
||||||
}
|
}
|
||||||
POPFD
|
POPFD
|
||||||
|
|
|
@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed
|
||||||
CDate local_time_offset;
|
CDate local_time_offset;
|
||||||
F64 *pow10_I64,
|
F64 *pow10_I64,
|
||||||
sys_os_version = 2.03;
|
sys_os_version = 2.03;
|
||||||
U64 sys_os_version_sub = 118;
|
U64 sys_os_version_sub = 119;
|
||||||
U8 *sys_os_version_str;
|
U8 *sys_os_version_str;
|
||||||
U8 *sys_os_version_full;
|
U8 *sys_os_version_full;
|
||||||
U8 *sys_os_version_nice;
|
U8 *sys_os_version_nice;
|
||||||
|
|
|
@ -91,7 +91,8 @@ U0 SysGrInit()
|
||||||
text.cols = sys_framebuffer_width / FONT_WIDTH;
|
text.cols = sys_framebuffer_width / FONT_WIDTH;
|
||||||
text.rows = sys_framebuffer_height / FONT_HEIGHT;
|
text.rows = sys_framebuffer_height / FONT_HEIGHT;
|
||||||
|
|
||||||
text.screen_size = sys_framebuffer_width * sys_framebuffer_height;
|
sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);
|
||||||
|
text.screen_size = sys_framebuffer_pidth * sys_framebuffer_height;
|
||||||
text.buffer_size = text.screen_size * 4; //buffer for 32-bit, but only 16 colors now.
|
text.buffer_size = text.screen_size * 4; //buffer for 32-bit, but only 16 colors now.
|
||||||
text.raw_screen = CAlloc(text.buffer_size);
|
text.raw_screen = CAlloc(text.buffer_size);
|
||||||
text.fb_alias = sys_framebuffer_addr;
|
text.fb_alias = sys_framebuffer_addr;
|
||||||
|
|
|
@ -1272,7 +1272,7 @@ public class CDocBin
|
||||||
#assert !($$ & 7)
|
#assert !($$ & 7)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DOC_SCROLL_SPEED 8
|
#define DOC_SCROLL_SPEED 6
|
||||||
|
|
||||||
#define DOCSS_NORMAL 0
|
#define DOCSS_NORMAL 0
|
||||||
#define DOCSS_SINGLE_QUOTE 1
|
#define DOCSS_SINGLE_QUOTE 1
|
||||||
|
|
|
@ -249,7 +249,7 @@ public _extern SYS_FRAMEBUFFER_WIDTH U64 sys_framebuffer_width;
|
||||||
public _extern SYS_FRAMEBUFFER_HEIGHT U64 sys_framebuffer_height;
|
public _extern SYS_FRAMEBUFFER_HEIGHT U64 sys_framebuffer_height;
|
||||||
public _extern SYS_FRAMEBUFFER_PITCH U64 sys_framebuffer_pitch;
|
public _extern SYS_FRAMEBUFFER_PITCH U64 sys_framebuffer_pitch;
|
||||||
public _extern SYS_FRAMEBUFFER_BPP U8 sys_framebuffer_bpp;
|
public _extern SYS_FRAMEBUFFER_BPP U8 sys_framebuffer_bpp;
|
||||||
|
public U64 sys_framebuffer_pidth;
|
||||||
_extern SYS_FRAMEBUFFER_LIST CVideoInfo sys_framebuffer_list[VBE_MODES_NUM];
|
_extern SYS_FRAMEBUFFER_LIST CVideoInfo sys_framebuffer_list[VBE_MODES_NUM];
|
||||||
|
|
||||||
#help_index "Processor/SMBIOS"
|
#help_index "Processor/SMBIOS"
|
||||||
|
|
|
@ -214,7 +214,8 @@ public CDC *DCNew(I64 width, I64 height, CTask *task=NULL, Bool null_bitmap=FALS
|
||||||
res->win_task = task;
|
res->win_task = task;
|
||||||
res->mem_task = task;
|
res->mem_task = task;
|
||||||
res->width = width;
|
res->width = width;
|
||||||
res->width_internal = (width + 7) & ~7;
|
// res->width_internal = (width + 7) & ~7;
|
||||||
|
res->width_internal = width & ~7;
|
||||||
res->height = height;
|
res->height = height;
|
||||||
if (null_bitmap)
|
if (null_bitmap)
|
||||||
res->flags |= DCF_DONT_DRAW;
|
res->flags |= DCF_DONT_DRAW;
|
||||||
|
|
|
@ -47,7 +47,7 @@ public CBGR24 gr_palette[COLORS_NUM];
|
||||||
//See $LK,"SysGrInit",A="MN:SysGrInit"$()
|
//See $LK,"SysGrInit",A="MN:SysGrInit"$()
|
||||||
//Allows consts to be used instead of variables.
|
//Allows consts to be used instead of variables.
|
||||||
HashPublic("GR_WIDTH", HTT_DEFINE_STR);;
|
HashPublic("GR_WIDTH", HTT_DEFINE_STR);;
|
||||||
DefinePrint("GR_WIDTH", "%d", sys_framebuffer_width);
|
DefinePrint("GR_WIDTH", "%d", sys_framebuffer_width & ~7);
|
||||||
HashPublic("GR_HEIGHT", HTT_DEFINE_STR);;
|
HashPublic("GR_HEIGHT", HTT_DEFINE_STR);;
|
||||||
DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height);
|
DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height);
|
||||||
|
|
||||||
|
@ -56,3 +56,5 @@ DefinePrint("TEXT_ROWS", "%d", text.rows);;
|
||||||
HashPublic("TEXT_ROWS", HTT_DEFINE_STR);;
|
HashPublic("TEXT_ROWS", HTT_DEFINE_STR);;
|
||||||
DefinePrint("TEXT_COLS", "%d", text.cols);;
|
DefinePrint("TEXT_COLS", "%d", text.cols);;
|
||||||
HashPublic("TEXT_COLS", HTT_DEFINE_STR);;
|
HashPublic("TEXT_COLS", HTT_DEFINE_STR);;
|
||||||
|
|
||||||
|
sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);
|
|
@ -142,8 +142,8 @@ public U0 GrScaleZoom(F64 scale)
|
||||||
mouse.offset.x = mouse.pos.x - (mouse.pos.x - mouse.offset.x) * s;
|
mouse.offset.x = mouse.pos.x - (mouse.pos.x - mouse.offset.x) * s;
|
||||||
mouse.offset.y = mouse.pos.y - (mouse.pos.y - mouse.offset.y) * s;
|
mouse.offset.y = mouse.pos.y - (mouse.pos.y - mouse.offset.y) * s;
|
||||||
mouse.offset.z = mouse.pos.z - (mouse.pos.z - mouse.offset.z) * s;
|
mouse.offset.z = mouse.pos.z - (mouse.pos.z - mouse.offset.z) * s;
|
||||||
gr.sx = mouse.pos.x - gr.zoomed_dc->width >> 1 / gr.screen_zoom;
|
gr.sx = mouse.pos.x - GR_WIDTH >> 1 / gr.screen_zoom;
|
||||||
gr.sy = mouse.pos.y - gr.zoomed_dc->height >> 1 / gr.screen_zoom;
|
gr.sy = mouse.pos.y - GR_HEIGHT >> 1 / gr.screen_zoom;
|
||||||
GrFixZoomScale;
|
GrFixZoomScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ U0 GrZoomInScreen()
|
||||||
|
|
||||||
GrFixZoomScale;
|
GrFixZoomScale;
|
||||||
|
|
||||||
src = gr.dc2->body + gr.sx + gr.sy * gr.dc2->width_internal;
|
src = gr.dc2->body + gr.sx + gr.sy * GR_WIDTH;
|
||||||
dst = gr.zoomed_dc->body;
|
dst = gr.zoomed_dc->body;
|
||||||
|
|
||||||
for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++)
|
for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++)
|
||||||
|
@ -359,42 +359,53 @@ U0 DCBlotColor8(CDC *dc, CDC *img)
|
||||||
|
|
||||||
U0 GrCalcScreenUpdates()
|
U0 GrCalcScreenUpdates()
|
||||||
{
|
{
|
||||||
U16 *screen, *last_screen = gr.screen_cache;
|
U8 *screen, reg RCX *last_screen = gr.screen_cache;
|
||||||
U64 i, *src = text.raw_screen, *dst = text.fb_alias, diffs_size = GR_WIDTH * GR_HEIGHT / 2;
|
U32 *src = text.raw_screen, *dst = text.fb_alias;
|
||||||
|
U64 i, j, x, y, yi;
|
||||||
|
|
||||||
if (gr.screen_zoom == 1)
|
if (gr.screen_zoom == 1)
|
||||||
screen = gr.dc2->body;
|
screen = gr.dc2->body;
|
||||||
else
|
else
|
||||||
screen = gr.zoomed_dc->body;
|
screen = gr.zoomed_dc->body;
|
||||||
|
|
||||||
for (i = 0; i < diffs_size; i++)
|
for (y = yi = 0; y < GR_HEIGHT; yi = ++y * GR_WIDTH)
|
||||||
{
|
{
|
||||||
if (screen[i] != last_screen[i])
|
for (x = 0; x < GR_WIDTH; x++)
|
||||||
dst[i] = src[i];
|
{
|
||||||
|
i = x + yi;
|
||||||
|
j = x + y * sys_framebuffer_pidth;
|
||||||
|
if (screen[i] != last_screen[i])
|
||||||
|
{
|
||||||
|
dst = text.fb_alias + j;
|
||||||
|
src = text.raw_screen + j;
|
||||||
|
*dst = *src;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MemCopy(gr.screen_cache, screen, diffs_size * 2);
|
MemCopy(gr.screen_cache, screen, GR_WIDTH * GR_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
U0 GrUpdateScreen32()
|
U0 GrUpdateScreen32()
|
||||||
{
|
{
|
||||||
U64 size, *dst;
|
U64 x, y, j, i;
|
||||||
|
U32 *dst;
|
||||||
U8 *src;
|
U8 *src;
|
||||||
|
|
||||||
if (gr.screen_zoom == 1)
|
if (gr.screen_zoom == 1)
|
||||||
{
|
|
||||||
src = gr.dc2->body;
|
src = gr.dc2->body;
|
||||||
size = src + gr.dc2->height * gr.dc2->width_internal;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GrZoomInScreen;
|
GrZoomInScreen;
|
||||||
src = gr.zoomed_dc->body;
|
src = gr.zoomed_dc->body;
|
||||||
size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal;
|
|
||||||
}
|
}
|
||||||
dst = text.raw_screen;
|
for (y = j = i = 0; y < GR_HEIGHT; j = ++y * sys_framebuffer_pidth, i = y * GR_WIDTH)
|
||||||
while (src < size) //draw 2 pixels at a time
|
{
|
||||||
*dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32;
|
for (x = 0; x < GR_WIDTH; x++)
|
||||||
|
{
|
||||||
|
dst = text.raw_screen + x + j;
|
||||||
|
*dst = gr_palette[src[x + i] & 0xFF];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GrCalcScreenUpdates;
|
GrCalcScreenUpdates;
|
||||||
|
|
||||||
|
@ -420,6 +431,6 @@ U0 GrUpdateScreen()
|
||||||
(*gr.fp_final_screen_update)(dc);
|
(*gr.fp_final_screen_update)(dc);
|
||||||
DCDel(dc);
|
DCDel(dc);
|
||||||
|
|
||||||
DCBlotColor4(gr.dc1->body, gr.dc2->body, gr.dc_cache->body, gr.dc2->height * gr.dc2->width_internal >> 3);
|
DCBlotColor4(gr.dc1->body, gr.dc2->body, gr.dc_cache->body, GR_HEIGHT * GR_WIDTH >> 3);
|
||||||
GrUpdateScreen32;
|
GrUpdateScreen32;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue