diff --git a/src/framebuffer.asm b/src/framebuffer.asm index 377ba9a..e7168b0 100644 --- a/src/framebuffer.asm +++ b/src/framebuffer.asm @@ -1,11 +1,19 @@ +macro kputpixel x, y, r, g, b { + push b ;b + push g ;g + push r ;r + push y ;y + push x ;x + call putpixel + add esp, 4*5 +} + ;; x, y, r, g, b putpixel: push ebp mov ebp, esp - push eax push ebx - push ecx push edi ; check pixel is in screen @@ -58,9 +66,7 @@ putpixel: stosb .done: pop edi - pop ecx pop ebx - pop eax pop ebp ret diff --git a/src/mbootinfo.asm b/src/mbootinfo.asm index d7425f0..3c3db73 100644 --- a/src/mbootinfo.asm +++ b/src/mbootinfo.asm @@ -1,7 +1,6 @@ mbootgetinfo: push ebp mov ebp, esp - push ebx push esi push edi cld @@ -10,23 +9,23 @@ mbootgetinfo: cmp eax, 0x2badb002 jne mbootnomagic - mov ebx, [ebp+12] - mov eax, [ebx] + mov edx, [ebp+12] + mov eax, [edx] mov [mbootinfo.flags], eax ;; Get memoryinformation test eax, 1b jz mbootnomeminfo - mov eax, [ebx+4] + mov eax, [edx+4] mov [mbootinfo.mem_lower], eax - mov eax, [ebx+8] + mov eax, [edx+8] mov [mbootinfo.mem_upper], eax ;; Get videoinformation test [mbootinfo.flags], (1 shl 02) jz mbootnovideoinfo - mov esi, ebx + mov esi, edx add esi, 88 mov eax, [esi] mov [mbootinfo.fb_addr], eax @@ -64,13 +63,12 @@ mbootgetinfo: .bytesppcalc: xor eax, eax mov al, [mbootinfo.fb_bpp] - mov ebx, 8 - div bl + mov edx, 8 + div dl mov [mbootinfo.fb_bytespp], al .done: pop edi pop esi - pop ebx pop ebp ret diff --git a/src/serial.asm b/src/serial.asm index b4e3353..c46b511 100644 --- a/src/serial.asm +++ b/src/serial.asm @@ -1,9 +1,14 @@ SERIAL_PORT equ 0x3f8 serialinitialized db 0 -serialinit: - push ax +; Write null terminated string in address str_pointer to serial +macro serw str_pointer { + push str_pointer + call serialwrite + add esp, 4 +} +serialinit: ;Disable ints mov dx, SERIAL_PORT+1 mov al, 0x00 @@ -54,7 +59,6 @@ serialinit: out dx, al mov [serialinitialized], 1 .end: - pop ax ret .errormsg db "Serial init failed", 0 @@ -64,7 +68,6 @@ serialwrite: push ebp mov ebp, esp push esi - push ax cld mov esi, [ebp+8] .loop: @@ -80,7 +83,6 @@ serialwrite: out dx, al jmp .loop .done: - pop ax pop esi pop ebp ret diff --git a/src/start32.asm b/src/start32.asm index 1e3121f..b6cb689 100644 --- a/src/start32.asm +++ b/src/start32.asm @@ -29,6 +29,13 @@ multiboot: dd VHEIGHT ; video height dd VDEPTH ; video depth +; Includes yayyy +include "src/serial.asm" +include "src/mbootinfo.asm" +include "src/itoa.asm" +include "src/framebuffer.asm" +include "src/roskalogoraw.asm" + start: ; Setup stack mov ebp, stack_top @@ -38,16 +45,13 @@ start: push eax call serialinit - push stuff.bootmsg - call serialwrite - add esp, 4 + + serw stuff.bootmsg call mbootgetinfo add esp, 2*4 - push stuff.fbaddrmsgpfx - call serialwrite - add esp, 4 + serw stuff.fbaddrmsgpfx sub esp, 36 ;Reserve stack for return push dword esp ;Destination address @@ -55,36 +59,24 @@ start: push dword [mbootinfo.fb_addr] ;source call __uitoa add esp, 3*4 - push esp - call serialwrite - add esp, 4 + serw esp - push stuff.fbdimensionsmsgpfx - call serialwrite - add esp, 4 + serw stuff.fbdimensionsmsgpfx push dword esp ;destination address push dword 10 ;base push dword [mbootinfo.fb_width] call __uitoa add esp, 3*4 - push esp - call serialwrite - add esp, 4 - push stuff.x - call serialwrite - add esp, 4 + serw esp + serw stuff.x push dword esp ;destination address push dword 10 ;base push dword [mbootinfo.fb_height] call __uitoa add esp, 3*4 - push esp - call serialwrite - add esp, 4 - push stuff.x - call serialwrite - add esp, 4 + serw esp + serw stuff.x push dword esp ;destination address push dword 10 ;base @@ -93,115 +85,87 @@ start: push dword eax call __uitoa add esp, 3*4 - push esp + serw esp + + + serw stuff.rpostxt + + push dword esp + push dword 10 + xor eax, eax + mov al, [mbootinfo.fb_rpos] + push dword eax + call __uitoa + add esp, 3*4 + serw esp + + serw stuff.gpostxt + + push dword esp + push dword 10 + xor eax, eax + mov al, [mbootinfo.fb_gpos] + push dword eax + call __uitoa + add esp, 3*4 + serw esp + + serw stuff.bpostxt + + push dword esp + push dword 10 + xor eax, eax + mov al, [mbootinfo.fb_bpos] + push dword eax + call __uitoa + add esp, 3*4 + serw esp + + + + push stuff.rmasksizetxt call serialwrite add esp, 4 + push dword esp + push dword 10 + xor eax, eax + mov al, [mbootinfo.fb_rmasksize] + push dword eax + call __uitoa + add esp, 3*4 + serw esp -push stuff.rpostxt -call serialwrite -add esp, 4 + push stuff.gmasksizetxt + call serialwrite + add esp, 4 -push dword esp -push dword 10 -xor eax, eax -mov al, [mbootinfo.fb_rpos] -push dword eax -call __uitoa -add esp, 3*4 -push esp -call serialwrite -add esp, 4 + push dword esp + push dword 10 + xor eax, eax + mov al, [mbootinfo.fb_gmasksize] + push dword eax + call __uitoa + add esp, 3*4 + serw esp -push stuff.gpostxt -call serialwrite -add esp, 4 - -push dword esp -push dword 10 -xor eax, eax -mov al, [mbootinfo.fb_gpos] -push dword eax -call __uitoa -add esp, 3*4 -push esp -call serialwrite -add esp, 4 - -push stuff.bpostxt -call serialwrite -add esp, 4 - -push dword esp -push dword 10 -xor eax, eax -mov al, [mbootinfo.fb_bpos] -push dword eax -call __uitoa -add esp, 3*4 -push esp -call serialwrite -add esp, 4 - - - -push stuff.rmasksizetxt -call serialwrite -add esp, 4 - -push dword esp -push dword 10 -xor eax, eax -mov al, [mbootinfo.fb_rmasksize] -push dword eax -call __uitoa -add esp, 3*4 -push esp -call serialwrite -add esp, 4 - -push stuff.gmasksizetxt -call serialwrite -add esp, 4 - -push dword esp -push dword 10 -xor eax, eax -mov al, [mbootinfo.fb_gmasksize] -push dword eax -call __uitoa -add esp, 3*4 -push esp -call serialwrite -add esp, 4 - -push stuff.bmasksizetxt -call serialwrite -add esp, 4 - -push dword esp -push dword 10 -xor eax, eax -mov al, [mbootinfo.fb_bmasksize] -push dword eax -call __uitoa -add esp, 3*4 -push esp -call serialwrite -add esp, 4 + serw stuff.bmasksizetxt + push dword esp + push dword 10 + xor eax, eax + mov al, [mbootinfo.fb_bmasksize] + push dword eax + call __uitoa + add esp, 3*4 + serw esp add esp, 36 ;Clean reserved uitoa return string from stack - ; Draw a test pixel to bottom right corner - push 0xff - push 0xff - push 0xff - push VHEIGHT-1 - push VWIDTH-1 - call putpixel - add esp, 3*4 + ; Draw a green test pixel to bottom-right + kputpixel VWIDTH-1, VHEIGHT-1, 0x00, 0xff, 0x00 +; Draw a predefined logo in magenta to top-left rOSkalogodraw: mov esi, roskalogo mov eax, 0 ;Brightness @@ -209,17 +173,12 @@ rOSkalogodraw: mov ecx, 0 ;x .loop: lodsb - push eax ;b - push eax ;g - push eax ;r - push ebx ;y - push ecx ;x - call putpixel + + push ecx + push eax + kputpixel ecx, ebx, eax, 0x00, eax + pop eax pop ecx - pop ebx - pop eax - pop eax - pop eax inc ecx cmp byte cl, [roskalogo.w] @@ -242,12 +201,6 @@ hang: jmp .loop .msg db 10, "Halting...", 10, 0 -include "src/serial.asm" -include "src/mbootinfo.asm" -include "src/itoa.asm" -include "src/framebuffer.asm" -include "src/roskalogoraw.asm" - stuff: .bootmsg db 10, "=== rOSka ===", 10, 0 .fbaddrmsgpfx db 10, "Framebuffer address: 0x", 0