We put R, G and B pixel on top left to see if framebuffer works. Why wouldn't it!
This commit is contained in:
		
							parent
							
								
									791c1f6c31
								
							
						
					
					
						commit
						6139ea7875
					
				
					 3 changed files with 224 additions and 0 deletions
				
			
		
							
								
								
									
										188
									
								
								roska.fasm
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								roska.fasm
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,188 @@
 | 
			
		|||
format binary
 | 
			
		||||
use32
 | 
			
		||||
org 0x100000
 | 
			
		||||
 | 
			
		||||
MB_HEADER_MAGIC      equ 0x1BADB002
 | 
			
		||||
MB_PAGE_ALIGN        equ (1 shl 0)
 | 
			
		||||
MB_MEMORY_INFO       equ (1 shl 1)
 | 
			
		||||
MB_VIDEO_REQUEST     equ (1 shl 2)
 | 
			
		||||
MB_AOUT_KLUDGE       equ (1 shl 16)
 | 
			
		||||
MB_HEADER_FLAGS      equ MB_PAGE_ALIGN or MB_MEMORY_INFO or MB_VIDEO_REQUEST
 | 
			
		||||
MB_HEADER_FLAGS      equ MB_PAGE_ALIGN or MB_MEMORY_INFO or MB_VIDEO_REQUEST or MB_AOUT_KLUDGE
 | 
			
		||||
MB_CHECKSUM          equ -(MB_HEADER_MAGIC + MB_HEADER_FLAGS)
 | 
			
		||||
 | 
			
		||||
;; safe modes according to https://wiki.osdev.org/VESA_Video_Modes
 | 
			
		||||
VWIDTH  equ 640 ; 640/720
 | 
			
		||||
VHEIGHT equ 480 ; 480
 | 
			
		||||
VDEPTH  equ 32  ; 24/32
 | 
			
		||||
 | 
			
		||||
multiboot:
 | 
			
		||||
	dd MB_HEADER_MAGIC
 | 
			
		||||
	dd MB_HEADER_FLAGS
 | 
			
		||||
	dd MB_CHECKSUM
 | 
			
		||||
	dd multiboot	; header address
 | 
			
		||||
	dd 0x100000	; load address
 | 
			
		||||
	dd bss_start	; load end address
 | 
			
		||||
	dd bss_end	; bss end address
 | 
			
		||||
	dd start	; entry address
 | 
			
		||||
 | 
			
		||||
	dd 0	; video mode_type (0:fb, 1:txt) (set flags[2]!)
 | 
			
		||||
	dd VWIDTH	; video width
 | 
			
		||||
	dd VHEIGHT	; video height
 | 
			
		||||
	dd VDEPTH	; video depth
 | 
			
		||||
 | 
			
		||||
start:
 | 
			
		||||
	; Setup stack
 | 
			
		||||
	mov ebp, stack_top
 | 
			
		||||
	mov esp, stack_top
 | 
			
		||||
 | 
			
		||||
	;push ebx ; mboot info struct addr
 | 
			
		||||
	;push eax ; 0x2BADB002
 | 
			
		||||
 | 
			
		||||
	;mov [mbootmagic], eax
 | 
			
		||||
	;mov [mbootaddr], ebx
 | 
			
		||||
 | 
			
		||||
	; store video info
 | 
			
		||||
	mov ecx, [ebx+88]
 | 
			
		||||
	mov [fb.addr], ecx
 | 
			
		||||
	mov ecx, [ebx+98]
 | 
			
		||||
	mov [fb.pitch], ecx
 | 
			
		||||
	mov ecx, [ebx+100]
 | 
			
		||||
	mov [fb.width], ecx
 | 
			
		||||
	mov ecx, [ebx+104]
 | 
			
		||||
	mov [fb.height], ecx
 | 
			
		||||
	mov cl, [ebx+108]
 | 
			
		||||
	mov [fb.depth], cl
 | 
			
		||||
 | 
			
		||||
	; calculate bytespp
 | 
			
		||||
	movzx eax, cl
 | 
			
		||||
	mov cl, 8
 | 
			
		||||
	div byte cl
 | 
			
		||||
	mov [fb.bytespp], al
 | 
			
		||||
 | 
			
		||||
	; color component positions
 | 
			
		||||
	mov cl, [ebx+110+2]
 | 
			
		||||
	mov [fb.rpos], cl
 | 
			
		||||
	;mov cl, [ebx+111]
 | 
			
		||||
	;mov [fb.rmasksize], cl
 | 
			
		||||
	mov cl, [ebx+112+2]
 | 
			
		||||
	mov [fb.gpos], cl
 | 
			
		||||
	;mov cl, [ebx+113]
 | 
			
		||||
	;mov [fb.gmasksize], cl
 | 
			
		||||
	mov cl, [ebx+114+2]
 | 
			
		||||
	mov [fb.bpos], cl
 | 
			
		||||
	;mov cl, [ebx+115]
 | 
			
		||||
	;mov [fb.bmasksize], cl
 | 
			
		||||
testpixels:
 | 
			
		||||
	; construct pixel R
 | 
			
		||||
	mov al, 0xff ;r
 | 
			
		||||
	mov ah, 0x00 ;g
 | 
			
		||||
	mov ch, 0x00 ;b
 | 
			
		||||
	xor edx, edx ;final pixel
 | 
			
		||||
	;ebx is temp pixel
 | 
			
		||||
	movzx ebx, al
 | 
			
		||||
	mov cl, [fb.rpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.rmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	movzx ebx, ah
 | 
			
		||||
	mov cl, [fb.gpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.gmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	movzx ebx, ch
 | 
			
		||||
	mov cl, [fb.bpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.bmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	mov ecx, [fb.addr]
 | 
			
		||||
	mov [ecx], edx
 | 
			
		||||
 | 
			
		||||
	; construct pixel G
 | 
			
		||||
	mov al, 0x00 ;r
 | 
			
		||||
	mov ah, 0xff ;g
 | 
			
		||||
	mov ch, 0x00 ;b
 | 
			
		||||
	xor edx, edx ;final pixel
 | 
			
		||||
	;ebx is temp pixel
 | 
			
		||||
	movzx ebx, al
 | 
			
		||||
	mov cl, [fb.rpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.rmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	movzx ebx, ah
 | 
			
		||||
	mov cl, [fb.gpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.gmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	movzx ebx, ch
 | 
			
		||||
	mov cl, [fb.bpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.bmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	mov ecx, [fb.addr]
 | 
			
		||||
	movzx ebx, [fb.bytespp]
 | 
			
		||||
	add ecx, ebx
 | 
			
		||||
	mov [ecx], edx
 | 
			
		||||
 | 
			
		||||
	; construct pixel B
 | 
			
		||||
	mov al, 0x00 ;r
 | 
			
		||||
	mov ah, 0x00 ;g
 | 
			
		||||
	mov ch, 0xff ;b
 | 
			
		||||
	xor edx, edx ;final pixel
 | 
			
		||||
	;ebx is temp pixel
 | 
			
		||||
	movzx ebx, al
 | 
			
		||||
	mov cl, [fb.rpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.rmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	movzx ebx, ah
 | 
			
		||||
	mov cl, [fb.gpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.gmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	movzx ebx, ch
 | 
			
		||||
	mov cl, [fb.bpos]
 | 
			
		||||
	shl ebx, cl
 | 
			
		||||
	;and ebx, [fb.bmasksize]
 | 
			
		||||
	or edx, ebx
 | 
			
		||||
	mov ecx, [fb.addr]
 | 
			
		||||
	movzx ebx, [fb.bytespp]
 | 
			
		||||
	add ecx, ebx
 | 
			
		||||
	add ecx, ebx
 | 
			
		||||
	mov [ecx], edx
 | 
			
		||||
 | 
			
		||||
	;mov dword [edx], 0xff00ff00
 | 
			
		||||
testpixels_end:
 | 
			
		||||
 | 
			
		||||
hang:
 | 
			
		||||
	;cli
 | 
			
		||||
	.loop:
 | 
			
		||||
		;hlt
 | 
			
		||||
		jmp .loop
 | 
			
		||||
error:
 | 
			
		||||
	mov dword [0xFD000000], 0x00FF0000
 | 
			
		||||
	jmp hang
 | 
			
		||||
 | 
			
		||||
mbootaddr: dd 0
 | 
			
		||||
mbootmagic: dd 0
 | 
			
		||||
fb:
 | 
			
		||||
	.addr dd 0
 | 
			
		||||
	.pitch dd 0
 | 
			
		||||
	.width dd 0
 | 
			
		||||
	.height dd 0
 | 
			
		||||
	.depth db 0
 | 
			
		||||
	.bytespp db 0
 | 
			
		||||
	.rpos db 0
 | 
			
		||||
	;.rmasksize db 0
 | 
			
		||||
	.gpos db 0
 | 
			
		||||
	;.gmasksize db 0
 | 
			
		||||
	.bpos db 0
 | 
			
		||||
	;.bmasksize db 0
 | 
			
		||||
 | 
			
		||||
align 4096
 | 
			
		||||
bss_start:
 | 
			
		||||
align 4096
 | 
			
		||||
stack_bottom:
 | 
			
		||||
rb 16384
 | 
			
		||||
stack_top:
 | 
			
		||||
bss_end:
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue