ZealOS/src/System/Gr/GrGlobals.ZC
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

60 lines
2.0 KiB
HolyC
Executable File

#help_index "Graphics"
public class CGrGlobals
{
I64 *to_8_bits, *to_8_colors;
CDC *screen_image, //Read only.
*dc, //Persistent
*dc1,
*dc2, //Updated every refresh
*dc_cache,
*zoomed_dc;
U32 *text_base; //See $LK,"TextBase Layer",A="HI:TextBase Layer"$. (Similar to 0xB8000 but 32 bits)
U16 *win_z_buf;
#define SPHT_ELEM_CODE 1
CHashTable *sprite_hash;
U16 *win_uncovered_bitmap;
I64 highest_uncovered;
I64 pan_text_x, pan_text_y; //[-7,7]
U0 (*fp_final_screen_update)(CDC *dc);//Mouse cursor is handled here.
U0 (*fp_wall_paper)(CTask *task);
U0 (*fp_draw_mouse)(CDC *dc, I64 x, I64 y);
U0 (*fp_draw_grab_mouse)(CDC *dc, I64 x, I64 y, Bool closed);
U8 *empty_sprite; //Gets assigned $LK,"gr.empty_sprite",A="FF:::/System/Mouse.ZC,empty_sprite"$
#define GR_PEN_BRUSHES_NUM 64
CDC *pen_brushes [GR_PEN_BRUSHES_NUM],
*collision_pen_brushes [GR_PEN_BRUSHES_NUM],
*even_pen_brushes [GR_PEN_BRUSHES_NUM],
*odd_pen_brushes [GR_PEN_BRUSHES_NUM];
I8 circle_lo[GR_PEN_BRUSHES_NUM][GR_PEN_BRUSHES_NUM],
circle_hi[GR_PEN_BRUSHES_NUM][GR_PEN_BRUSHES_NUM];
#define GR_SCREEN_ZOOM_MAX 8
U8 *screen_zoom_tables[GR_SCREEN_ZOOM_MAX + 1], *screen_cache;
I64 screen_zoom, sx, sy;
//When zoomed, this keeps the mouse centered.
Bool continuous_scroll,
hide_row, hide_col;
} gr;
public CBGR24 gr_palette[COLORS_NUM];
//See $LK,"RLf_VESA",A="FF:::/Kernel/KStart16.ZC,RLf_VESA"$
//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 & ~7);
HashPublic("GR_HEIGHT", HTT_DEFINE_STR);;
DefinePrint("GR_HEIGHT", "%d", sys_framebuffer_height);
#help_index "Char;TextBase Layer/Char"
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);