Compare commits

...

19 commits

Author SHA1 Message Date
Z8Griz
729a866121
Merge dbe88c18c9 into 8773bd95f0 2024-12-03 00:37:59 +01:00
Gunch
8773bd95f0
Merge pull request #161 from Zeal-Operating-System/pitch-fix
Some checks failed
Build ZealOS ISOs / Build (push) Has been cancelled
Use framebuffer pitch instead of width where necessary
2024-12-02 01:12:24 -05:00
Gunch
5658469acb
Merge branch 'master' into pitch-fix 2024-12-02 01:08:33 -05:00
GutPuncher
2ffd423f7b
Refactor framebuffer handling and remove redundant variables. (not tested on baremetal)
- Removed the 'fb_width_from_pitch' variable and replaced its usage with 'sys_framebuffer_pidth' to standardize the handling of framebuffer width-from-pitch across the codebase.
- Updated references to 'fb_width_from_pitch' in display and screen update functions to use 'sys_framebuffer_pidth', ensuring consistent calculations.
- Replaced 'sys_framebuffer_pitch / (sys_framebuffer_bpp / 8)' with 'sys_framebuffer_pidth' to avoid redundant calculations and improve code readability.
- Fixed framebuffer calculations in 'GrCalcScreenUpdates', 'GrUpdateScreen32', and related functions to use the correct framebuffer width-from-pitch value.
- Corrected and simplified screen update logic in 'GrZoomInScreen' and 'GrUpdateScreen'.
2024-12-02 01:02:34 -05:00
GutPuncher
38c41e551a
Fix zoom handling and update screen calculations
- Corrected loop bounds in 'GrZoomInScreen' to use 'GR_HEIGHT' and 'GR_WIDTH' constants instead of dynamic values from 'gr.dc2'.
- Updated 'src' offset calculations to use 'GR_WIDTH' instead of 'gr.dc2->width_internal'.
- Simplified 'GrUpdateScreen32' to use fixed 'GR_HEIGHT' and 'GR_WIDTH' values for screen updates, removing unnecessary calculations and size adjustments based on 'gr.dc2' and 'gr.zoomed_dc'.
2024-08-29 01:48:17 -04:00
GutPuncher
b08c10e343
Fixing GrCalcScreenUpdates incorrect size passed to MemCopy 2024-08-29 01:00:35 -04:00
GutPuncher
f8c9845026
Cleaning up leftover scraps from graphics code hacking, reimplementing GrCalcScreenUpdates 2024-08-29 00:49:38 -04:00
Z8Griz
dbe88c18c9 did not mean to include that specific code and file. 2024-08-27 20:21:38 -06:00
Z8Griz
295a97bf4c changed hardcoded to systemside clock or ticks. JIFFY_FREQ.
Noticed slightly better responsive times while reducing timeouts.
2024-08-27 19:04:03 -06:00
Z8Griz
e363a0b0b6 Unsure if this is correct but as far as connections and speeds goes, it remained unchanged. 2024-08-27 13:50:40 -06:00
Z8Griz
ff978b1ce3 RECEIVE WINDOW is different than RECEIVE BUFFER
The receive buffer is allocated per socket.
TCP receive buffer holds TCP data that has not yet been processed
(consumed via read/recv system calls) by the application.
2024-08-26 18:34:11 -06:00
Z8Griz
1a5368962b There is no receive window size.
Client(send) overrides host(receive) window size.
It's one of the reasons why telnet chars and gopher files/links tend to drop. Packetloss/timeout.
2024-08-26 07:16:48 -06:00
Z8Griz
1f750d9237 Most modern network cards and routers uses standard frame.
Lowered the frame size because if network card / router can't handle high frame,
it will causes fragmentation, leading to packetloss or lost connection.
It depends on the network card and router.
A standard frame is 1518 bytes on the wire (as far as any capturing device is concerned).
A tagged frame (single tag) is 1522 bytes on the wire.
These take up 1538 bytes or 1542 bytes of transmission space on the wire.
On most OS, it is usually set at 1542. As a safe measure.
If one wants run on 90s network card, it should be set at 1518.
I think this should be automated, not hardcoded.
2024-08-26 07:05:39 -06:00
GutPuncher
05febc9803
Hacking graphics code in pursuit of fixing #28 2024-08-26 02:14:30 -04:00
GutPuncher
9f363f265d
Lower DOC_SCROLL_SPEED from 8 to 6 2024-08-26 02:07:47 -04:00
GutPuncher
16eec2be89
Increment sys_os_version_sub 2024-08-26 02:04:18 -04:00
GutPuncher
4e77bf1c0a
Add flush command option to sync.sh , to attempt to flush qemu-nbd state and attempt basic repair of filesystem 2024-08-26 02:01:43 -04:00
Gunch
d1380b57f1
Merge branch 'master' into pitch-fix 2024-08-25 06:20:52 -04:00
mintsuki
41e7e302d5 Use framebuffer pitch instead of width where necessary 2024-08-14 22:16:39 +02:00
15 changed files with 88 additions and 50 deletions

View file

@ -74,6 +74,12 @@ else
sudo modprobe nbd
[ ! -d $TMPMOUNT ] && mkdir $TMPMOUNT
case $1 in
flush)
mount_vdisk
sudo blockdev --flushbufs /dev/nbd0
sudo dosfsck -w -r -l -v -t /dev/nbd0
umount_vdisk
;;
diff)
mount_vdisk
diff -x *.MAP --color=always -r ../src/ $TMPMOUNT/ | less -R -p "diff -x.*|Only in.*"

View file

@ -4,7 +4,7 @@
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()

View file

@ -32,12 +32,12 @@ U0 PaintGlobalsInit()
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)
{
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)
@ -136,7 +136,7 @@ U0 PaintLoadImage()
U32 PaintImagePeek(I64 x, I64 y)
{
return paint.fb[x + y * GR_WIDTH];
return paint.fb[x + y * sys_framebuffer_width];
}
I0 Paint32()
@ -176,7 +176,7 @@ I0 Paint32()
// draw the image where the brush was last covering it
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++)
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
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
for (i = 0; i < 3 * FONT_HEIGHT; i++)
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
DrawScreenStr(0, 0 * FONT_HEIGHT, str_r);

View file

@ -2,15 +2,28 @@
#define TCP_SRTT_ALPHA 0.9
// Transmission Time Out to prevent network slugglish performance
#define TCP_RTO_BETA 2
#define TCP_RTO_MIN 0.2
#define TCP_RTO_MAX 10
#define TCP_RTO_MIN JIFFY_FREQ/5 // (linux TCP.H) should be using system timer/clock instead hardcoded
#define TCP_RTO_MAX 120*JIFFY_FREQ // JIFFY_FREZ = Hz. Hz is software clock ticks
#define TCP_WINDOW_SIZE 8192
#define TCP_MAX_WINDOW 32676 // Beyond this number, use window_scale(not implemented). 8192 is recommended/default.
U16 WINDOW_SIZE; // Initiate window size in CTPCPacketAllocate{} ?? Need more study
U16 RECEIVE_WINDOW; // gets host window size. It is not static.
U16 SEND_WINDOW; // gets receive window size from host, then adjust accordingly.
U32 RECEIVE_BUFFER; // is 32 too much? receive_buffer holds TCP data that has not yet been processed
#define TCP_MSS 536 // Max Segment Size default
#define TCP_MIN_MSS 88 // Min Segment Size
#define TCP_TIMEOUT 5000
#define TCP_INIT_TIMEOUT 1*JIFFY_FREQ // TODO... Init RTO Value. Not sure if this is needed.
#define TCP_TIMEOUT 20*JIFFY_FREQ // Roughly a minute based on software clock
#define TCP_KEEPALIVE 120*JIFFY_FREQ // TODO... 1 hour
#define TCP_MAX_INCREASEACK 16 //TODO... At Initial start up, it's generally slow. This accelerates the process.
#define TCP_MAX_DELAYACK JIFFY_FREQ/5 //TODO... Delay max time ack
#define TCP_MIN_DELAYACK JIFFY_FREQ/25 //TODO... Delay min time ack
#define TCP_STATE_CLOSED 0
#define TCP_STATE_LISTEN 1
@ -24,7 +37,7 @@
#define TCP_STATE_LAST_ACK 9
#define TCP_STATE_TIME_WAIT 10
// TCP header flags. Test with Bt(), e.g. Bt(&flags, TCPf_RST)
// TCP header flags. Order of Operation matters. Test with Bt(), e.g. Bt(&flags, TCPf_RST)
#define TCPf_FIN 0
#define TCPf_SYN 1
#define TCPf_RST 2
@ -39,6 +52,8 @@
#define TCPF_ACK (1 << TCPf_ACK)
//#define TCPF_URG (1 << TCPf_URG) // most stacks don't implement URGENT.
// U32 TCP_MAX_DELAYACK(CSocket *Socket); // TODO
class CTCPAckQueue:CQueue
{

View file

@ -101,7 +101,7 @@ I64 TCPPacketAllocate(U8 **frame_out,
header->ack_num = EndianU32(ack_num);
header->data_offset = (sizeof(CTCPHeader) / 4) << 4; // ???
header->flags = flags;
header->window_size = EndianU16(TCP_WINDOW_SIZE / 2);// TODO: What is window size supposed to be ?
header->window_size = EndianU16(WINDOW_SIZE);// Window Size allocation data. Adjusted based on receive window.
header->checksum = 0;
header->urgent_pointer = 0;
@ -647,8 +647,8 @@ CTCPSocket TCPSocket(U16 domain=AF_UNSPEC)
QueueInit(accept_queue); // init pending connection queue
tcp_socket->accept_queue = accept_queue;
tcp_socket->receive_buffer_size = TCP_WINDOW_SIZE;
tcp_socket->receive_buffer = CAlloc(TCP_WINDOW_SIZE);
tcp_socket->receive_buffer_size = RECEIVE_BUFFER;
tcp_socket->receive_buffer = CAlloc(RECEIVE_BUFFER);
tcp_socket->max_segment_size = TCP_MSS;
@ -1057,7 +1057,7 @@ I64 TCPSocketConnect(CTCPSocket *tcp_socket, CSocketAddressStorage *address)
}
tcp_socket->connection_time = tS;
tcp_socket->receive_window = TCP_WINDOW_SIZE;
tcp_socket->receive_window = RECEIVE_WINDOW;
tcp_socket->state = TCP_STATE_SYN_SENT;
TCPSendFlags(tcp_socket, TCPF_SYN);
@ -1165,7 +1165,7 @@ CTCPSocket *TCPSocketAccept(CTCPSocket *tcp_socket)
new_socket->next_recv_seq_num = ++pending->segment_seq_num;
new_socket->connection_time = tS;
new_socket->receive_window = TCP_WINDOW_SIZE;
new_socket->receive_window = RECEIVE_WINDOW;
new_socket->timeout = tcp_socket->timeout;
temp_addr = &tcp_socket->source_address;

View file

@ -8,9 +8,11 @@
#define FCS_LENGTH 4
/* Ethernet Frame Size.
Linux uses 1544, OSDev and Shrine use 1548. Based on IEEE 802.3as, max frame size was agreed upon as 2000 bytes. */
#define ETHERNET_FRAME_SIZE 2000
Based on IEEE 802.3 layer 1 Ethernet Max Frame is 1542 according to wiki. 72-1530 frame octet + 12 IPG octet
Default: 1538 | Vlan: 1542 | Jumbo: 9038 | JumboVlan: 9042 */
#define ETHERNET_FRAME_SIZE 1542
// Max PayLoad standard: 1500 | Jumbo: 9000 for Gignet (fiber)
#define ETHERNET_v2_MTU 1500
#define HTYPE_ETHERNET 1

View file

@ -60,17 +60,17 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
{//Scroll screen down
MemCopy(text.fb_alias,
text.fb_alias + sys_framebuffer_width * FONT_HEIGHT,
(text.screen_size - sys_framebuffer_width * FONT_HEIGHT) * sizeof(U32));
text.fb_alias + sys_framebuffer_pidth * FONT_HEIGHT,
(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 ;
row = text.rows - 1;
}
x = col * FONT_WIDTH;
y = row * FONT_HEIGHT;
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
CLI
@ -81,7 +81,7 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
else
*framebuffer++ = BLACK32;
if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1)
framebuffer += sys_framebuffer_width - FONT_WIDTH;
framebuffer += sys_framebuffer_pidth - FONT_WIDTH;
ch_bitmap >>= 1;
}
POPFD

View file

@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed
CDate local_time_offset;
F64 *pow10_I64,
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_full;
U8 *sys_os_version_nice;

View file

@ -91,7 +91,8 @@ U0 SysGrInit()
text.cols = sys_framebuffer_width / FONT_WIDTH;
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.raw_screen = CAlloc(text.buffer_size);
text.fb_alias = sys_framebuffer_addr;

View file

@ -1272,7 +1272,7 @@ public class CDocBin
#assert !($$ & 7)
};
#define DOC_SCROLL_SPEED 8
#define DOC_SCROLL_SPEED 6
#define DOCSS_NORMAL 0
#define DOCSS_SINGLE_QUOTE 1

View file

@ -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_PITCH U64 sys_framebuffer_pitch;
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];
#help_index "Processor/SMBIOS"

View file

@ -214,7 +214,8 @@ public CDC *DCNew(I64 width, I64 height, CTask *task=NULL, Bool null_bitmap=FALS
res->win_task = task;
res->mem_task = task;
res->width = width;
res->width_internal = (width + 7) & ~7;
// res->width_internal = (width + 7) & ~7;
res->width_internal = width & ~7;
res->height = height;
if (null_bitmap)
res->flags |= DCF_DONT_DRAW;

View file

@ -47,7 +47,7 @@ public CBGR24 gr_palette[COLORS_NUM];
//See $LK,"SysGrInit",A="MN:SysGrInit"$()
//Allows consts to be used instead of variables.
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);;
DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height);
@ -56,3 +56,5 @@ DefinePrint("TEXT_ROWS", "%d", text.rows);;
HashPublic("TEXT_ROWS", HTT_DEFINE_STR);;
DefinePrint("TEXT_COLS", "%d", text.cols);;
HashPublic("TEXT_COLS", HTT_DEFINE_STR);;
sys_framebuffer_pidth = sys_framebuffer_pitch / (sys_framebuffer_bpp / 8);

View file

@ -142,8 +142,8 @@ public U0 GrScaleZoom(F64 scale)
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.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.sy = mouse.pos.y - gr.zoomed_dc->height >> 1 / gr.screen_zoom;
gr.sx = mouse.pos.x - GR_WIDTH >> 1 / gr.screen_zoom;
gr.sy = mouse.pos.y - GR_HEIGHT >> 1 / gr.screen_zoom;
GrFixZoomScale;
}
@ -154,7 +154,7 @@ U0 GrZoomInScreen()
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;
for (i = 0; i < GR_HEIGHT / gr.screen_zoom; i++)
@ -359,42 +359,53 @@ U0 DCBlotColor8(CDC *dc, CDC *img)
U0 GrCalcScreenUpdates()
{
U16 *screen, *last_screen = gr.screen_cache;
U64 i, *src = text.raw_screen, *dst = text.fb_alias, diffs_size = GR_WIDTH * GR_HEIGHT / 2;
U8 *screen, reg RCX *last_screen = gr.screen_cache;
U32 *src = text.raw_screen, *dst = text.fb_alias;
U64 i, j, x, y, yi;
if (gr.screen_zoom == 1)
screen = gr.dc2->body;
else
screen = gr.zoomed_dc->body;
for (i = 0; i < diffs_size; i++)
for (y = yi = 0; y < GR_HEIGHT; yi = ++y * GR_WIDTH)
{
for (x = 0; x < GR_WIDTH; x++)
{
i = x + yi;
j = x + y * sys_framebuffer_pidth;
if (screen[i] != last_screen[i])
dst[i] = src[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()
{
U64 size, *dst;
U64 x, y, j, i;
U32 *dst;
U8 *src;
if (gr.screen_zoom == 1)
{
src = gr.dc2->body;
size = src + gr.dc2->height * gr.dc2->width_internal;
}
else
{
GrZoomInScreen;
src = gr.zoomed_dc->body;
size = src + gr.zoomed_dc->height * gr.zoomed_dc->width_internal;
}
dst = text.raw_screen;
while (src < size) //draw 2 pixels at a time
*dst++ = gr_palette[*src++ & 0xFF] | gr_palette[*src++ & 0xFF] << 32;
for (y = j = i = 0; y < GR_HEIGHT; j = ++y * sys_framebuffer_pidth, i = y * GR_WIDTH)
{
for (x = 0; x < GR_WIDTH; x++)
{
dst = text.raw_screen + x + j;
*dst = gr_palette[src[x + i] & 0xFF];
}
}
GrCalcScreenUpdates;
@ -420,6 +431,6 @@ U0 GrUpdateScreen()
(*gr.fp_final_screen_update)(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;
}