1
0
forked from Rust/Core

feat: display_message_str

This commit is contained in:
Gleb Zaharov 2024-02-01 17:44:21 +03:00
parent 264618fe3b
commit ab3db879d2
3 changed files with 20 additions and 2 deletions

View File

@ -47,6 +47,23 @@ pub fn display_message<'a>(start: Dot, color: Color, text: &'a CStr, bg_color: O
start.x << 16 | start.y, start.x << 16 | start.y,
color.as_rgb_val() | BG_FLAG * bg_color.is_some() as u32 | UTF8_FLAG | ASCIIZ_FLAG, color.as_rgb_val() | BG_FLAG * bg_color.is_some() as u32 | UTF8_FLAG | ASCIIZ_FLAG,
text.as_ptr() as u32, text.as_ptr() as u32,
0,
bg_color.unwrap_or(Color(0, 0, 0)).as_rgb_val(),
);
}
}
pub fn display_message_str<'a>(start: Dot, color: Color, text: &'a str, bg_color: Option<Color>) {
// XX=ABFFCSSS
const UTF8_FLAG: u32 = (3 << 4) << 24; // FF
const BG_FLAG: u32 = (1 << 6) << 24; // B
unsafe {
sys::display_message(
start.x << 16 | start.y,
color.as_rgb_val() | BG_FLAG * bg_color.is_some() as u32 | UTF8_FLAG,
text.as_ptr() as u32,
text.len() as u32,
bg_color.unwrap_or(Color(0, 0, 0)).as_rgb_val(), bg_color.unwrap_or(Color(0, 0, 0)).as_rgb_val(),
); );
} }

View File

@ -14,7 +14,7 @@ extern "C" {
// 4 // 4
#[link_name = "_display_message"] #[link_name = "_display_message"]
pub fn display_message(ebx: u32, ecx: u32, edx: u32, edi: u32); pub fn display_message(ebx: u32, ecx: u32, edx: u32, esi: u32, edi: u32);
// 8 // 8
#[link_name = "_define_button"] #[link_name = "_define_button"]

View File

@ -55,7 +55,8 @@ _display_message:
mov ebx, dword [esp + 4 * 3] mov ebx, dword [esp + 4 * 3]
mov ecx, dword [esp + 4 * 4] mov ecx, dword [esp + 4 * 4]
mov edx, dword [esp + 4 * 5] mov edx, dword [esp + 4 * 5]
mov edi, dword [esp + 4 * 6] mov esi, dword [esp + 4 * 6]
mov edi, dword [esp + 4 * 7]
int 0x40 int 0x40
pop edi esi pop edi esi
ret ret