[refactor] Organize INT

This commit is contained in:
2026-06-05 18:29:11 +08:00
Unverified
parent 7c66610c13
commit da03b301fb
17 changed files with 79 additions and 59 deletions
+3 -2
View File
@@ -1,9 +1,10 @@
#pragma once
#include <types.h>
#define ASM asm volatile
static unsigned int strlen(const char* arr) { // 获取string长度
int i = 0;
static SUINT32 strlen(const char* arr) { // 获取string长度
SSINT32 i = 0;
while (arr[i++] != '\0');
return i - 1;
}
+2 -1
View File
@@ -1,7 +1,8 @@
#pragma once
#include <common.h>
// Hankaku 字体,不动
static unsigned char hankaku_pixels[256][16] = {
static SUINT8 hankaku_pixels[256][16] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x10, 0x10, 0x38, 0x38, 0x7c, 0x7c, 0xfe, 0xfe, 0x7c, 0x7c, 0x38, 0x38, 0x10, 0x10, 0x00, 0x00},
{0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x00, 0x00},
+2 -2
View File
@@ -2,6 +2,6 @@
#include <graphics/context.h>
void pf_print_char(char c, unsigned int basex, unsigned int basey,
void pf_print_char(char c, SUINT32 basex, SUINT32 basey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印字符
void pf_print(const char* text, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印string
void pf_print(const char* text, SUINT32 basex, SUINT32 basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印string
+6 -5
View File
@@ -3,11 +3,12 @@
// 这个文件存在的目的是让graphics的draw功能不用每次传 GOP hr vr base
#include <efi.h>
#include <common.h>
struct gfx_context {
EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP;
unsigned int hr;
unsigned int vr;
SUINT32 hr;
SUINT32 vr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base;
};
@@ -15,13 +16,13 @@ extern gfx_context g_gfx;
struct draw_target {
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf;
unsigned int w;
unsigned int h;
SUINT32 w;
SUINT32 h;
};
extern draw_target g_draw_target;
void gfx_init(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP);
void gfx_clear(void);
void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, unsigned int w, unsigned int h);
void draw_set_target(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *buf, SUINT32 w, SUINT32 h);
void draw_set_default_target(void);
+4 -4
View File
@@ -3,10 +3,10 @@
#include <efi.h>
#include <graphics/context.h>
void global_draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void global_draw_rect(unsigned int bx, unsigned int by, unsigned int ex, unsigned int ey,
void global_draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void global_draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void draw_pixel(unsigned int x, unsigned int y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void draw_rect(unsigned int bx, unsigned int by, unsigned int ex, unsigned int ey,
void draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
void draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
+5 -4
View File
@@ -1,6 +1,7 @@
#pragma once
#include <efi.h>
#include <common.h>
#define LAYER_MAX 32
#define LAYER_NAME_LEN 32
@@ -16,9 +17,9 @@ typedef struct layer {
UINT32 id;
char name[LAYER_NAME_LEN];
layer_type_t type;
int x, y;
SSINT32 x, y;
UINT32 w, h;
int z;
SSINT32 z;
bool visible;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* buffer;
struct layer* next;
@@ -30,8 +31,8 @@ void layer_init(void);
// Layer management
layer_t* layer_create(const char* name, layer_type_t type, UINT32 w, UINT32 h);
void layer_destroy(layer_t* layer);
void layer_set_z(layer_t* layer, int z);
void layer_set_pos(layer_t* layer, int x, int y);
void layer_set_z(layer_t* layer, SSINT32 z);
void layer_set_pos(layer_t* layer, SSINT32 x, SSINT32 y);
void layer_set_visible(layer_t* layer, bool visible);
layer_t* layer_get_by_id(UINT32 id);
layer_t* layer_get_focused(void);
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include <stdint.h>
// Signed integers
#define SSINT8 int8_t
#define SSINT16 int16_t
#define SSINT32 int32_t
#define SSINT64 int64_t
// Unsigned integers
#define SUINT8 uint8_t
#define SUINT16 uint16_t
#define SUINT32 uint32_t
#define SUINT64 uint64_t