flat assembler
Message board for the users of flat assembler.

Index > Main > VBE study

Goto page Previous  1, 2, 3, 4
Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Mar 2011, 00:59
i thought that was just the buffer that had trash, but i did
Code:
 clear:

        mov edi,videobuff32bpp
        mov eax,0xFFFFFFFF
        mov ecx,1280*1024*4
        rep stosd

        mov edi,[video_ptr]
        mov esi,videobuff32bpp
        mov ecx,1280*1024*4 /4
        rep movsd

        ret     

and i got:


Description:
Filesize: 16.98 KB
Viewed: 10569 Time(s)

imagem2.PNG



_________________
Sorry if bad english.
Post 01 Mar 2011, 00:59
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 01 Mar 2011, 02:31
Teehee wrote:
i thought that was just the buffer that had trash, but i did
Code:
 clear:

        mov edi,videobuff32bpp
        mov eax,0xFFFFFFFF
        mov ecx,1280*1024*4
        rep stosd

        mov edi,[video_ptr]
        mov esi,videobuff32bpp
        mov ecx,1280*1024*4 /4
        rep movsd

        ret     

and i got:


First are you sure bochs uses 32bit ?
But if it does it should be more like this
Code:
 clear:

        mov edi,videobuff32bpp
        mov eax,0x00FFFFFF
        mov ecx,1280*1024
        rep stosd

        mov edi,[video_ptr]
        mov esi,videobuff32bpp
        mov ecx,1280*1024
        rep movsd

      ret 

videobuff32bpp rd 1280*1024

    


That is, if you have set 1280x1024 32bpp mode
Also that you are using a zero base descriptor
Post 01 Mar 2011, 02:31
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Mar 2011, 11:41
how to ensure bochs use 32bit? i didnt find any option to change that.
and how to set a 32bpp mode? i just set video mode to 0x411B (1280x1024x16M (8:8:8 ) + LFB).

I'v made 3 descriptors: null, CS and DS, both zero base and limit 0xFFFFFFFF.
Post 01 Mar 2011, 11:41
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 01 Mar 2011, 11:48
read the bpp field in vesainfo block.
Post 01 Mar 2011, 11:48
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Mar 2011, 11:56
ModeInfoBlock do you mean?
Code:
cmp byte[ModeInfoBlock.BitsPerPixel],32 
je $ ; never equal Sad its 24.    
Post 01 Mar 2011, 11:56
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 01 Mar 2011, 17:12
Try this demo
Code:
;************************************

; By Dex

; Assemble with fasm 

; c:\fasm Vesa.asm Vesa.bin

;

;************************************

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. Wink

;*****************************



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   Letsloop 



;*****************************

; 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
Letsloop:
        hlt
        jmp   Letsloop



;*************************************

; 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.

;*************************************



;=========================================================;

; Vesa Information Block                         11/12/03 ;

;---------------------------------------------------------;

; DOS EXTREME OS V0.01                                    ;

; by Craig Bamford(Dex).                                  ;

;                                                         ;

;=========================================================;



;============================== VESA MODE INFORMATION ===========================================

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



;======================================= START OF PROGRAM  ======================================



    


Do not change the mode just test, just assemble as a bin file.
I think bochs let you boot bin files, if not you will need to add it to a floppy image.

Your res is too high, start at the basic then when it works move to a higher res.
Post 01 Mar 2011, 17:12
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 01 Mar 2011, 18:18
When I started with VBE, I found myself writing different code for all the virtual machines and PC. I learned that I needed to have detection code. Now I can tell you that Bochs 800x600x32 is 0x143; 1280x1024x32 is 0x145. You can never be sure what modes to expect because VESA allows vendors to make up their own.

I just updated my VESA example (64-bit mode) and here's the link:
http://board.flatassembler.net/topic.php?p=118339#118339
Post 01 Mar 2011, 18:18
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Mar 2011, 20:43
Madis731 wrote:
1280x1024x32 is 0x145.

Indeed. Now i have 32 bit in cmp, however im still having this problem:

Image

_________________
Sorry if bad english.
Post 01 Mar 2011, 20:43
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 01 Mar 2011, 21:11
You need to clear the buffer, at start it usually does include some garbage.

EDIT: Sorry, I was tired, I didn't understand the source Embarassed


Last edited by Madis731 on 02 Mar 2011, 07:55; edited 1 time in total
Post 01 Mar 2011, 21:11
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Mar 2011, 22:40
i did Madis.. but i still have that problem, see:

Code:
  clear:
       ; Clear
        mov edi,video_buff
        mov eax,0xFFFFFFFF
        mov ecx,1280*1024
        rep stosd 
   ; Copy
        mov edi,[video_ptr] 
        mov esi,video_buff
        mov ecx,1280*1024
        rep movsd

        ret       
Post 01 Mar 2011, 22:40
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 01 Mar 2011, 23:44
where is video_buff... it is maybe not in the right place...
remember, the video_ptr is memory mapped for the screen, but there are many other memories mapped for other peripherals, and video_buff maybe points to one of them, as shows the trash on your screenshot.

try another adress for your buffer then...
Post 01 Mar 2011, 23:44
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 01 Mar 2011, 23:53
i just made this:
Code:
format binary as 'img'

    org SECTOR_BOOT

        include 'boot.asm' 

        ; Fill this sector up  
        rb 512-($-$$)-2
        dw BIOS_SIGNATURE

    org SECTOR_KERNEL ; = 0x8000

    kernel: 

        include 'kernel.asm'

        ; Fill the disk image up (1.4Mb) 
        ;times (0x0167E00-($-kernel)) db 0

        video_buff rd 1280*1024           

how do i change the buffer address?
Post 01 Mar 2011, 23:53
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 02 Mar 2011, 01:25
OK, then, it is a certitude, all your video buffer is trashed by the BIOS, because parasites you see, it is the BIOS.

to change this adress, just declare the position you want it to be in the label instead of reserve datas.
Code:
video_buff=10'0000h ;it starts now at 16MB, under 16MB, it may be used by DMA...
    



there are many other ways to do, more or less complex.
if you want to continue to use the RB 1280*1024 statement, and then have the data size defined, use virtual
Code:
virtual at 10'0000h
video_buff rd 1280*1024
end virtual
    

something like that.

don't know if it works, i never use virtual...

but first try the = statement, it will save you a lot of time.
Post 02 Mar 2011, 01:25
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 02 Mar 2011, 10:58
thank you ed, i just forgot that i do not need to reserve bytes, i just can use a free memory location. Now it works.

But how do i know which memory region is being used by the hardware or whatever?

i would never know that bios was inside that address bc i did org 0x8000 while bios was on org 0x7C00.
Post 02 Mar 2011, 10:58
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 02 Mar 2011, 11:09
Madis731 wrote:
I just updated my VESA example (64-bit mode) and here's the link:
http://board.flatassembler.net/topic.php?p=118339#118339

WOW Madis! Nice example! its a window system working! Very Happy Im going to study the code and make some questions later. Thanks.

_________________
Sorry if bad english.
Post 02 Mar 2011, 11:09
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 02 Mar 2011, 11:45
bios is not at org 7C00h, it is somewhere over linear [0C'0000h]

the ROM BIOS is in the upper real mode memory.
and to know that HW use some memory, first read a memory map and some hw spec.

DMA can use any adress between 0 and 16M, but only in 4 chunks of 64k (4 channels).
VESA uses memory you found in vesainfoblock
USB uses another memory that you don't have to care about if you don't use it. NIC too use some memory adresses...

ones you will se advanced hw, you will be able to generate a memory map from the HW prior to any kernel loading.

step by step, continue as you make, by experimentations, and step by step you will understand more and more things.

you can try to read the memory mapp from HW properties in windows.
for exemple, my video card uses 4800'0000h to 5000'FFFFh, and 0A0000h to 0CBFFFh. with IOPORTS 03B0-03BB, and 03C0-03DF

my NIC uses E800'0000h to E800'03FFh, and IO ports 1C00 to 1CFFh
my usb controler just uses IOPORTS

windows doesn't map the DMA memory, but you can assume, when yuo write your own os, to be the only one to be able to determine it.
and maybe, only use the lower 1MB memory for DMA.

if you look closer to the memory map i gave you for my HW, you can notice that video and NIC are mapped outside the RAM.
my ram is 256 MB. then, from 0 to 1000'0000h.
if you have 1GB ram, limit adress is 4000'0000h and is still well under HW memory zones.
Post 02 Mar 2011, 11:45
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 570
Location: Brazil
Teehee 02 Mar 2011, 15:57
edfed wrote:
the ROM BIOS is in the upper real mode memory.

you mean 1Mb - ROM_BIOS_SIZE or 1Mb + ROM_BIOS_SIZE ? This place can't be writen, right?

Quote:
step by step, continue as you make, by experimentations, and step by step you will understand more and more things.
nice. Very Happy

Quote:
you can try to read the memory mapp from HW properties in windows.
how/where?

Quote:
if you have 1GB ram, limit adress is 4000'0000h and is still well under HW memory zones.
Where is that memory? is it possible to access that or read/write there?

_________________
Sorry if bad english.
Post 02 Mar 2011, 15:57
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.