From d0c778f397df8fa6f813fb364525840fe21af767 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Thu, 25 Jul 2024 21:20:57 +0300 Subject: [PATCH] We uhh.... ran out of space --- boot.asm | 2 +- gfx/cvbmp.py | 6 +++--- gfx_util.asm | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.asm | 19 +++++++++---------- 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/boot.asm b/boot.asm index 126351c..0a2e867 100644 --- a/boot.asm +++ b/boot.asm @@ -7,7 +7,7 @@ OS_SEGMENT equ 0x100 boot: ; Load from disk mov ah, 0x02 ; read - mov al, 0x01 ; No of sectors (1) + mov al, 0x02 ; No of sectors (1) mov cl, 0x02 ; Sector start (1 = boot sector, 2 = OS) mov ch, 0x00 ; Cylinder 0 mov dh, 0x00 ; Head 0 diff --git a/gfx/cvbmp.py b/gfx/cvbmp.py index c0c4031..1b51acb 100644 --- a/gfx/cvbmp.py +++ b/gfx/cvbmp.py @@ -5,8 +5,8 @@ pixels = list(im.getdata()) w, h = im.size with open('gfxd_cursor.asm', 'w') as f: - f.write(f'gfxd_cursor_dim: db {w} db {h}\n') - f.write('gfxd_cursor: ') + f.write(f'gfxd_cursor_dim: db {w}, {h}\n') + f.write('gfxd_cursor: db ') for px in pixels: if px == (255, 255, 255, 255): @@ -15,4 +15,4 @@ with open('gfxd_cursor.asm', 'w') as f: c = '0x00' else: c = '0xFF' - f.write(f'db {c} ') \ No newline at end of file + f.write(f'{c}, ') \ No newline at end of file diff --git a/gfx_util.asm b/gfx_util.asm index ee57e25..87475cb 100644 --- a/gfx_util.asm +++ b/gfx_util.asm @@ -1,5 +1,14 @@ +; Constants VMEM equ 0xA000 +; Initializes 320x200 8-bit/256-color (13h) video graphics mode +gfx_init_vga13: + push ax + mov ax, 0x0013 + int 0x10 + pop ax + ret + ; di = y*32+x ; ax = width ; bl = height @@ -66,5 +75,47 @@ gfx_rect: call _gfx_rect0 + popa + ret + + +; di = y*32+x +; si = source color data +; ax = width +; bl = height + +; ax/bl = 0 is undefined behavior. Don't do it. +; (To be clear, in the current implementation it just halts) + +_gfx_blit0: + pusha + + push VMEM + pop es + + mov dl, 0 ; row counter + + .row: + add dl, 1 + + mov cx, 0 ; col counter + + .col: + add cx, 1 + + mov dh, [si] + mov [es:di], dh + add di, 1 + add si, 1 + + cmp cx, ax + jnz .col + + sub di, ax ; di - width + 320. == x=x1; y++ + add di, 320 + + cmp dl, bl + jnz .row + popa ret \ No newline at end of file diff --git a/main.asm b/main.asm index 6d7d770..46d3cb2 100644 --- a/main.asm +++ b/main.asm @@ -18,16 +18,13 @@ section KERNEL follows=BOOTSECTOR vstart=1000h %endmacro main: - mov ax, 0x0013 - int 0x10 + call gfx_init_vga13 - mov cx, 50 ; x - mov al, 50 ; y - mov dx, 100 ; w - mov bl, 100 ; h - mov bh, 0x01 ; color = Dark blue - - call gfx_rect + mov di, 0 + mov si, gfxd_cursor + mov ax, 11 + mov bl, 18 + call _gfx_blit0 jmp $ ; Halt @@ -38,4 +35,6 @@ jmp $ ; Halt ; Data HELLO_WORLD: - db 'Hello, world! :D', 0 \ No newline at end of file + db 'Hello, world! :D', 0 + +%include "gfx/gfxd_cursor.asm" \ No newline at end of file