From 6d7f9870f3e99b184f6df529d86443ae9b2c8968 Mon Sep 17 00:00:00 2001 From: boreddevnl Date: Mon, 9 Mar 2026 10:33:10 +0100 Subject: [PATCH] doom render fix --- boredos.iso | Bin 20641792 -> 20641792 bytes src/kernel/userland/browser.c | 39 ++++++++---------- .../userland/doom/doomgeneric_boredos.c | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/boredos.iso b/boredos.iso index 6d256c68c4738acb8787d6af5e68fb63978b7733..c4b3383d2f473e5b1d89594ddd22320aa0565778 100644 GIT binary patch delta 5793 zcmcK82~@v(dhVr{UinS@HntQW{$I`Ld+jZ0GkR6o`UNvx z<;-UqR_!9qFjy^YL0!XIh^rCi%Xz-HM%1EyaV^`zEw#ceI$g`Q=v?gvQGYH* zev6F4{BfRt+bHaB+Q|C%trO-C*RlL7b;AC~>sbG8^}_Wt>REq<^}_kD*0cGo&kFN< z&$4`uIDdiXC&l?_6RXcO3FmJ!?O{(ygD{`b!0L;{`C*<{HVW$>YGn1fjl%u8(8%^@ zLY&{+#PaD)!snx_8M*8JTITQw|u)v?QyfeIa`~+J)VxwX>^xu3gyu)ppjsvO`$Ew}aJZcL=*5 z=wNsEmN>t&ljXBJg}d`!C)=HgPGNu1U97*XF5&t;U2OibE@A!VZdQMwTeyBpH(UQ& zx3E5}ht((a2=hjszaq>V*PQ#9-0KUzm%re9BbErC30tDr6dSwSRIVlOTbK0nC!$*T zc`^Mio9<4ZC;fc6e&LP>46q%K9}w+`@vVUj>wCT8LEge(gvXt(cuQ>Tc15P1jIfW# zt(PK1A3w#HJf&{xE{VQD7|CVlyR}Qtg=ovGrhp*rB5+i(x5%EnKg1`TRLqz(;n zM0`fMd`2%Jq6fj`Zb811Rxzkl#AD{38Y1P9PDOmAV^6EdDrr=wA{uElB4?dkNvL!z z#+8IP%>I1xF$}npMTQDjvQ#>w*Ojc7MoKrbNgC~NBOx;*(@{54C~ccTrCL&+)N;m zQV-#Y{NYGXB>vK|(nMa{Cy%~PB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U*USVV6=S7+L%y}k0 zbG3!&6&*rl{o6Xm4&*r^M@@#Q%4gnjO z1GZoX_TT_&a0Dlq3(nvIuHXjlFc0Q~2Y7-P+ye_h1K!{R3t4YPv9UF!?SP*ehP=-Id~pQ-~}j!GAIYS$4B5ORDcD32FKt<_&K};zkuWL zGE_npR6`A%fLeG3UWH%6Yw$X}0l$J@!<+CH)ImKofCP=u1Si1?&Cmj^&<5?$0iDnV z-OvNQ&g>$iH5l}IMd)lgDVYgG`Q0+kB0d)c+lWU zgBK0=(6E384GrEj_|UMBhD9_ireO&UzBKsJ;7`L+8kW%zK*Mqx0%=%5Ll6yG8iHxK zmxh%zgwPO5!zvndG_0l}jD~O;B4~)DA&Q1*8e(XOC0*JCJ-M{X-KL|k`;p?V_#=sq jy(O1I_P*@*q@Lv6JiL`1uKdr#TjaxCeoyJiNdCV8Mzebj diff --git a/src/kernel/userland/browser.c b/src/kernel/userland/browser.c index d7bbda2..3f4629c 100644 --- a/src/kernel/userland/browser.c +++ b/src/kernel/userland/browser.c @@ -92,7 +92,7 @@ static long strtol(const char* nptr, char** endptr, int base) { typedef struct { char content[1024]; int x, y, w, h; - int tag; // Changed from HTMLTag enum to int + int tag; char link_url[256]; char attr_value[256]; uint32_t color; @@ -109,7 +109,7 @@ typedef struct { int input_scroll; float scale; int list_depth; - int blockquote_depth; // Added blockquote support + int blockquote_depth; bool img_loading; bool img_failed; uint32_t **img_frames; @@ -276,7 +276,7 @@ static int fetch_content(const char *url, char *dest_buf, int max_len, bool prog int total = 0; int last_render = 0; - if (progressive) inc_parse_offset = 0; // Reset incremental state for new page + if (progressive) inc_parse_offset = 0; while (1) { int len = sys_tcp_recv(dest_buf + total, max_len - 1 - total); if (len <= 0) break; @@ -289,16 +289,14 @@ static int fetch_content(const char *url, char *dest_buf, int max_len, bool prog if (body) { body += 4; if (!strstr(dest_buf, "Transfer-Encoding: chunked")) { - // Find last '>' to avoid splitting a tag int body_len = total - (body - dest_buf); int safe_len = body_len; while (safe_len > 0 && body[safe_len - 1] != '>') safe_len--; - // Avoid splitting an HTML entity (&...;) int check_amp = total - (body - dest_buf) - 1; if (check_amp >= safe_len) check_amp = safe_len - 1; int amp_pos = -1; for (int k = 0; k < 15 && check_amp - k >= 0; k++) { - if (body[check_amp - k] == ';') break; // Complete entity + if (body[check_amp - k] == ';') break; if (body[check_amp - k] == '&') { amp_pos = check_amp - k; break; } } if (amp_pos != -1) safe_len = amp_pos; @@ -453,14 +451,13 @@ static int cur_line_y = 10; static int cur_line_x = 10; static int list_depth = 0; -// Incremental parser state for progressive rendering static int inc_list_type[16]; static int inc_list_index[16]; static int inc_center_depth = 0; static int inc_table_depth = 0; -static int inc_blockquote_depth = 0; // New field for blockquote +static int inc_blockquote_depth = 0; static bool inc_is_bold = false; static bool inc_is_italic = false; static bool inc_is_underline = false; @@ -487,11 +484,11 @@ static void flush_line(void) { RenderElement *first_el = &elements[line_elements[0]]; bool centered = first_el->centered; int ldepth = first_el->list_depth; - int bdepth = first_el->blockquote_depth; // Get blockquote depth + int bdepth = first_el->blockquote_depth; int line_w = 0; for (int i = 0; i < line_element_count; i++) line_w += elements[line_elements[i]].w; - int offset_x = centered ? (win_w - SCROLL_BAR_W - line_w) / 2 : 10 + (ldepth * 20) + (bdepth * 20); // Adjust for blockquote + int offset_x = centered ? (win_w - SCROLL_BAR_W - line_w) / 2 : 10 + (ldepth * 20) + (bdepth * 20); if (offset_x < 10) offset_x = 10; int max_h = 16; @@ -536,16 +533,16 @@ static void browser_reflow(void) { if (el->tag == TAG_BR) { flush_line(); - cur_line_x = 10 + (el->list_depth * 20) + (el->blockquote_depth * 20); // Adjust for blockquote + cur_line_x = 10 + (el->list_depth * 20) + (el->blockquote_depth * 20); continue; } if (el->tag == TAG_HR) { flush_line(); - el->w = win_w - SCROLL_BAR_W - 40 - (el->blockquote_depth * 40); // Adjust for blockquote + el->w = win_w - SCROLL_BAR_W - 40 - (el->blockquote_depth * 40); line_elements[line_element_count++] = i; flush_line(); - cur_line_x = 10 + (el->list_depth * 20) + (el->blockquote_depth * 20); // Adjust for blockquote + cur_line_x = 10 + (el->list_depth * 20) + (el->blockquote_depth * 20); continue; } @@ -554,9 +551,9 @@ static void browser_reflow(void) { if (cur_line_x + el->w > win_w - SCROLL_BAR_W - 20 - (el->blockquote_depth * 40)) continue; } - if (cur_line_x + el->w > win_w - SCROLL_BAR_W - 20 - (el->blockquote_depth * 40)) { // Adjust for blockquote - flush_line(); - cur_line_x = 10 + (el->list_depth * 20) + (el->blockquote_depth * 20); // Adjust for blockquote + if (cur_line_x + el->w > win_w - SCROLL_BAR_W - 20 - (el->blockquote_depth * 40)) { + flush_line(); + cur_line_x = 10 + (el->list_depth * 20) + (el->blockquote_depth * 20); } line_elements[line_element_count++] = i; @@ -572,7 +569,7 @@ static uint32_t parse_html_color(const char *str) { if (*str == '#') { char *end; uint32_t val = (uint32_t)strtol(str + 1, &end, 16); - return 0xFF000000 | val; // Assumes RRGGBB + return 0xFF000000 | val; } if (str_istarts_with(str, "red")) return 0xFFFF0000; if (str_istarts_with(str, "green")) return 0xFF008000; @@ -598,7 +595,7 @@ static void decode_html_entities(char *str) { if (str_istarts_with(src, "'")) { *dst++ = '\''; src += 6; continue; } if (str_istarts_with(src, " ")) { *dst++ = ' '; src += 6; continue; } if (str_istarts_with(src, "—")) { *dst++ = (char)128; src += 7; continue; } - if (str_istarts_with(src, "&mdash")) { *dst++ = (char)128; src += 6; continue; } // Fallback + if (str_istarts_with(src, "&mdash")) { *dst++ = (char)128; src += 6; continue; } if (str_istarts_with(src, "–")) { *dst++ = (char)129; src += 7; continue; } if (str_istarts_with(src, "&ndash")) { *dst++ = (char)129; src += 6; continue; } if (str_istarts_with(src, "•")) { *dst++ = (char)130; src += 6; continue; } @@ -611,9 +608,7 @@ static void decode_html_entities(char *str) { if (str_istarts_with(src, "‘")) { *dst++ = '\''; src += 7; continue; } if (str_istarts_with(src, "’")) { *dst++ = '\''; src += 7; continue; } if (str_istarts_with(src, "“")) { *dst++ = '\"'; src += 7; continue; } - if (str_istarts_with(src, "”")) { *dst++ = '\"'; src += 7; continue; } - - // ISO Latin-1 (RFC 1866 Section 9.7) + if (str_istarts_with(src, "”")) { *dst++ = '\"'; src += 7; continue; } if (str_istarts_with(src, "¡")) { *dst++ = (char)161; src += 7; continue; } if (str_istarts_with(src, "¢")) { *dst++ = (char)162; src += 6; continue; } if (str_istarts_with(src, "£")) { *dst++ = (char)163; src += 7; continue; } @@ -714,7 +709,7 @@ static void parse_html(const char *html) { if (tag_name[0] == '/') { if (str_iequals(tag_name+1, "center")) { emit_br(); if (center_depth > 0) center_depth--; } else if (str_iequals(tag_name+1, "table")) { emit_br(); if (table_depth > 0) table_depth--; } - else if (str_iequals(tag_name+1, "blockquote")) { emit_br(); if (blockquote_depth > 0) blockquote_depth--; } // Handle blockquote end + else if (str_iequals(tag_name+1, "blockquote")) { emit_br(); if (blockquote_depth > 0) blockquote_depth--; } else if (str_iequals(tag_name+1, "ul") || str_iequals(tag_name+1, "ol") || str_iequals(tag_name+1, "dl") || str_iequals(tag_name+1, "dir") || str_iequals(tag_name+1, "menu")) { emit_br(); if (list_depth > 0) list_depth--; } diff --git a/src/kernel/userland/doom/doomgeneric_boredos.c b/src/kernel/userland/doom/doomgeneric_boredos.c index 1894fae..e8db615 100644 --- a/src/kernel/userland/doom/doomgeneric_boredos.c +++ b/src/kernel/userland/doom/doomgeneric_boredos.c @@ -35,7 +35,7 @@ void DG_DrawFrame(void) { int sy = y * src_h / dst_h; for (int x = 0; x < dst_w; x++) { int sx = x * src_w / dst_w; - scaled_buffer[y * dst_w + x] = ((uint32_t*)DG_ScreenBuffer)[sy * src_w + sx]; + scaled_buffer[y * dst_w + x] = 0xFF000000 | ((uint32_t*)DG_ScreenBuffer)[sy * src_w + sx]; } }