Drawing graphics, using JamesM Genesis kernel as a basis

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Drawing graphics, using JamesM Genesis kernel as a basis

Post by Troy Martin »

Combuster wrote:braindamaging
Exactly.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Drawing graphics, using JamesM Genesis kernel as a basis

Post by Dex »

This is not using JamesM Genesis kernel as a basis, but it's a simple bootable vesa putpixal demo, that fit on the boot sector of a floppy.

Code: Select all

 ;************************************
; By Dex
;
; Assemble with fasm 
; c:\fasm Vesa.asm Vesa.bin
;
; Use rawrite to put on floppy
;
;************************************
org 0x7C00 

use16
;****************************
; Realmode startup code.
;****************************

start:
        xor   ax,ax
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   sp,0x7C00 

;****************************
; Vesa start code.
;****************************

        mov  bx,4112h
        mov  ax,4f01h
        mov  di,Mode_Info	
        mov  cx,bx
        int  10h 
        
        mov  ax,4f02h
        int  10h

;*****************************
; Setting up, to enter pmode.
;*****************************

        cli 
        lgdt  [gdtr]
        
        mov   eax, cr0
        or    al,0x1 
        mov   cr0,eax
 
        jmp   0x10: protected

;*****************************
; Pmode. ;-)
;*****************************

use32
protected:
        mov   ax,0x8 
        mov   ds,ax
        mov   es,ax
        mov   ss,ax
        mov   esp,0x7C00
;*****************************
; Turn floppy off 
;*****************************

        mov   dx,3F2h
        mov   al,0
        out   dx,al

;*****************************
; Do we have 32 BitsPerPixel.
;*****************************

        cmp   byte[ModeInfo_BitsPerPixel],32
        jne   JustLoop

;*****************************
; fade background screen.
;*****************************

fade_screen:
        mov   edx,[ModeInfo_PhysBasePtr]
        mov   edi,edx
        xor   eax,eax
        mov   al,0xc5          
        xor   ebx,ebx
        mov   bl,195 
DoLoop:    
        mov   cx,640*2 
        dec   eax    

        rep   stosd
       
        dec   ebx
        jnz   DoLoop

;***********************************
; Draws the iPOD.
;***********************************

        mov   edi,236*4+640*4*125 
        add   edi,edx
Pod:
        xor   ecx,ecx
        mov   ebx,245
button2:
        mov   cl,14
        mov   al,0x2d
letsloop1:
        stosd
        add   eax,15
        loop  letsloop1
        mov   cl,130
        rep   stosd
        mov   cl,14
letsloop2:
        stosd
        sub   eax,15
        loop  letsloop2
        add   edi,640*4-158*4
        dec   ebx
        jnz   button2
       
;***********************************
; Draws the Pod window.  :-(
;***********************************

        mov   edi,263*4+640*4*143
        add   edi,edx 
PodWindow:
        mov   eax,0xffa6ffff
        xor   edx,edx
        mov   dl,65
DrawSomePixals:
        mov   cl,104
        rep   stosd
        add   edi,640*4-104*4 
        dec   edx
        jnz   DrawSomePixals

        xor   eax,eax
        mov   dl,65
DrawaLine:
        sub   edi,641*4
        stosd
        dec   edx
        jnz   DrawaLine

        mov   cl,104
        rep   stosd
JustLoop:
        jmp   $


;*************************************
; GDT. 
;*************************************

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:	    dw gdt_end - gdt - 1	                                  
	    dd gdt 


;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
            
times 510- ($-start)  db 0  
dw 0xaa55

;*************************************
; Put uninitialized data here. eg: vesa info
;*************************************

Mode_Info:		
ModeInfo_ModeAttributes		rw	1
ModeInfo_WinAAttributes		rb	1
ModeInfo_WinBAttributes		rb	1
ModeInfo_WinGranularity		rw	1
ModeInfo_WinSize		rw	1
ModeInfo_WinASegment		rw	1
ModeInfo_WinBSegment		rw	1
ModeInfo_WinFuncPtr		rd	1
ModeInfo_BytesPerScanLine	rw	1
ModeInfo_XResolution		rw	1
ModeInfo_YResolution		rw	1
ModeInfo_XCharSize		rb	1
ModeInfo_YCharSize		rb	1
ModeInfo_NumberOfPlanes		rb	1
ModeInfo_BitsPerPixel		rb	1
ModeInfo_NumberOfBanks		rb	1
ModeInfo_MemoryModel		rb	1
ModeInfo_BankSize		rb	1
ModeInfo_NumberOfImagePages	rb	1
ModeInfo_Reserved_page		rb	1
ModeInfo_RedMaskSize		rb	1
ModeInfo_RedMaskPos		rb	1
ModeInfo_GreenMaskSize		rb	1
ModeInfo_GreenMaskPos		rb	1
ModeInfo_BlueMaskSize		rb	1
ModeInfo_BlueMaskPos		rb	1
ModeInfo_ReservedMaskSize	rb	1
ModeInfo_ReservedMaskPos	rb	1
ModeInfo_DirectColorModeInfo	rb	1
; VBE 2.0 extensions
ModeInfo_PhysBasePtr		rd	1
ModeInfo_OffScreenMemOffset	rd	1
ModeInfo_OffScreenMemSize	rw	1
It boots, set up vesa mode 640x480 32bpp, goes to pmode, fades the screen, than draws a window and halts.
It should give you the basic's.
Post Reply