flat assembler
Message board for the users of flat assembler.

Index > OS Construction > whats wrong with this drawing code?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 12 Sep 2005, 16:05
Code:
drawing:
     mov   eax,00ffffffh
     mov   cl,50 ; the length
     mov   edi,[modeinfo_phys]
     add   edi,2*4+800*4*2 ; the location on the screen
     rep    stosd    


everything works great, but as far as drawing as far as y, ive tried everything and nothing works, i even tried ecx,50*10 but still nothin

thanks!
Post 12 Sep 2005, 16:05
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 12 Sep 2005, 16:38
did you try ecx instead of cl?
Post 12 Sep 2005, 16:38
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009 12 Sep 2005, 20:42
Quote:
i even tried ecx,50*10


Very Happy
Post 12 Sep 2005, 20:42
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 12 Sep 2005, 22:12
what is modeinfo_phys?
Post 12 Sep 2005, 22:12
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 12 Sep 2005, 22:13
it has to do with vesa
Post 12 Sep 2005, 22:13
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009 12 Sep 2005, 23:29
I'm assuming that it's a value in this code: (taken from redragon's vesa.inc file)
Code:
space           rb 20
count           rb 1
counta          rb 1
xy              rd 1
count4          rb 1
count7          rb 1
keybuffer       rb 1
color           rb 1
command         rb 1
port            rw 1
drive           rb 1
AtapiError      rb 1

packet:
                rb 1 ;0x0                     
                rb 1 ;0x0                    
                rb 1 ;0x0                     
                rb 1 ;0x0                     
                rb 1 ;0x0                    
                rb 1 ;0x0                     
                rb 1 ;0x0
                rb 1 ;0x0                     
                rb 1 ;0x0                    
                rb 1 ;0x0
                rb 1 ;0x0
                rb 1 ;0x0


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    

Redragon: Sorry about answering questions for you. Razz I just thought the guy should have a bit more info.
Post 12 Sep 2005, 23:29
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 13 Sep 2005, 13:33
1. should it not be :
Code:
mov  edi,[ModeInfo_PhysBasePtr]    

2. you could try puting:
Code:
cldrep   stosd    

3. make shore your background color, is not the same as foreground Wink.
4. es is set to a linear based descriptor
Post 13 Sep 2005, 13:33
View user's profile Send private message Reply with quote
Redragon



Joined: 27 Nov 2004
Posts: 101
Location: U.S.
Redragon 13 Sep 2005, 21:30
i figured out what was wrong with it.. yeah, in my personal code i call it ModeInfo_PhysBasePtr, but i was in a hurry when i was typing it, so i shortned it, i figured everyone would know what i was talkin about.. and im sure that my background code isnt the same as my foreground.
Post 13 Sep 2005, 21:30
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009 13 Sep 2005, 22:07
What was the problem? Give us some info dude! Razz

But seriously... how did you fix it? I bet there are some FASM newbies out there (like me) who would like to know how to make this code work. Very Happy
Post 13 Sep 2005, 22:07
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 14 Sep 2005, 08:59
@DataHunter2009, it is very simple here is a demo i made, some time ago that may help you:
Code:
;************************************; \\|//; (@ @); Dex4u.; vesa2 640*480*256; Put vesatest.bin on boot sector; with rawrite.; Assemble with fasm; c:\fasm vesatest.asm vesatest.bin;;************************************org 0x7C00use16;****************************; Realmode startup code.;****************************start:        xor   ax,ax        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   sp,0x7C00;****************************; Vesa start code.;****************************        mov   dword [VESAInfo_Signature],'VBE2'        mov   ax,4f00h        mov   di,VESA_Info        int   10h        cmp   ax,004Fh        jne   novesa        mov   ax,4f01h                                       ; set vesa screen mode information        mov   di,Mode_Info        mov   cx,0x4101                          ; Change this number for differant screen sizes        and   cx,0xfff ;and        int   10h         cmp   dword [VESAInfo_Signature], 'VESA'        jne   novesa                mov   ax,4f02h                           ; set vesa screen mode        mov   bx,0x4101                         ; Change this number for differant screen sizes        int   10h        cmp   ax,004Fh        jne   novesa                jmp   @fnovesa:        mov   ax,0xB800        mov   es,ax        lea   si,[msg0]                           mov   di,(80 * 1 + 2) * 2        mov   cx,52        cld        rep   movsb        jmp   $  ;*****************************; Setting up, to enter pmode.;*****************************@@:        cli         lgdt  [gdtr]                mov   eax, cr0        or    al,0x1         mov   cr0,eax         jmp   0x10: protected;*****************************; Pmode. Wink;*****************************use32protected:        mov   ax,0x8        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   esp,0x7C00;*****************************; Turn floppy off (if space).;*****************************        mov   dx,3F2h        mov   al,0        out   dx,al;*****************************; render's graphic screen.;*****************************        mov   [color],0xccccccccrender_screen:        mov   edi,[ModeInfo_PhysBasePtr]             mov   ecx,640*480/4        mov   eax,[color]        cld        rep   stosd               jmp   $;*************************************; GDT. ;*************************************gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CFsys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CFgdt_end:gdtr:       dw gdt_end - gdt - 1                                                      dd gdt;*************************************; Data. ;*************************************color       dd 0msg0        db "  V E S A   M O D E   N O T   S U P P O R T E D !   " ,0x0d,0;*************************************; Make program 510 byte's + 0xaa55;*************************************            times 510- ($-start)  db 0dw 0xaa55;*************************************; Put uninitialized data here.;*************************************include 'vesa2_info.inc';*************************************; $$$$££££( vote for me Wink)££££$$$$.;*************************************    

And here is the inc file:
Code:
;=========================================================;; Vesa Information Block                         11/12/03 ;;---------------------------------------------------------;; DOS EXTREME OS V0.01                                    ;; by Craig Bamford.(Dex4u).                               ;;                                                         ;;=========================================================;;-------- FASM VESA INFORMATION BLOCK ------------VESA_Info:VESAInfo_Signature              rb      4VESAInfo_Version                rw      1VESAInfo_OEMStringPtr           rd      1VESAInfo_Capabilities           rb      4VESAInfo_VideoModePtr           rd      1VESAInfo_TotalMemory            rw      1VESAInfo_OEMSoftwareRev         rw      1VESAInfo_OEMVendorNamePtr       rd      1VESAInfo_OEMProductNamePtr      rd      1VESAInfo_OEMProductRevPtr       rd      1VESAInfo_Reserved               rb      222VESAInfo_OEMData                rb      256;========== VESA MODE INFORMATION ==============Mode_Info:ModeInfo_ModeAttributes         rw      1ModeInfo_WinAAttributes         rb      1ModeInfo_WinBAttributes         rb      1ModeInfo_WinGranularity         rw      1ModeInfo_WinSize                rw      1ModeInfo_WinASegment            rw      1ModeInfo_WinBSegment            rw      1ModeInfo_WinFuncPtr             rd      1ModeInfo_BytesPerScanLine       rw      1ModeInfo_XResolution            rw      1ModeInfo_YResolution            rw      1ModeInfo_XCharSize              rb      1ModeInfo_YCharSize              rb      1ModeInfo_NumberOfPlanes         rb      1ModeInfo_BitsPerPixel           rb      1ModeInfo_NumberOfBanks          rb      1ModeInfo_MemoryModel            rb      1ModeInfo_BankSize               rb      1ModeInfo_NumberOfImagePages     rb      1ModeInfo_Reserved_page          rb      1ModeInfo_RedMaskSize            rb      1ModeInfo_RedMaskPos             rb      1ModeInfo_GreenMaskSize          rb      1ModeInfo_GreenMaskPos           rb      1ModeInfo_BlueMaskSize           rb      1ModeInfo_BlueMaskPos            rb      1ModeInfo_ReservedMaskSize       rb      1ModeInfo_ReservedMaskPos        rb      1ModeInfo_DirectColorModeInfo    rb      1; VBE 2.0 extensionsModeInfo_PhysBasePtr            rd      1ModeInfo_OffScreenMemOffset     rd      1ModeInfo_OffScreenMemSize       rw      1; VBE 3.0 extensionsModeInfo_LinBytesPerScanLine    rw      1ModeInfo_BnkNumberOfPages       rb      1ModeInfo_LinNumberOfPages       rb      1ModeInfo_LinRedMaskSize         rb      1ModeInfo_LinRedFieldPos         rb      1ModeInfo_LinGreenMaskSize       rb      1ModeInfo_LinGreenFieldPos       rb      1ModeInfo_LinBlueMaskSize        rb      1ModeInfo_LinBlueFieldPos        rb      1ModeInfo_LinRsvdMaskSize        rb      1ModeInfo_LinRsvdFieldPos        rb      1ModeInfo_MaxPixelClock          rd      1; ReservedModeInfo_Reserved               rb      190;============= VESA MODE INFORMATION END ==============    

If you need more info just ask Wink .
Post 14 Sep 2005, 08:59
View user's profile Send private message Reply with quote
DataHunter2009



Joined: 10 Jun 2005
Posts: 144
DataHunter2009 14 Sep 2005, 21:21
Cool! Very Happy

The only problem is, I didn't quite understand the type of color value here:
Code:
        mov   [color],0xcccccccc    

So, I replaced it with 00cccccch and now it is pruple with black lines through it (vertically). Any ideas why?
Post 14 Sep 2005, 21:21
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 15 Sep 2005, 13:13
Yes this code is for "640*480*256", each pixel is a byte in size, so instead moving a byte at a time, we moved a dword (4 bytes) and div the screen size by 4.
By puting a 00 you put the color black, you can do the code like this, as it will be easier to understand:
Code:
;*****************************; render's graphic screen.;*****************************        mov   edi,[ModeInfo_PhysBasePtr]             mov   ecx,640*480        mov   al,0xcc        cld        rep   stosb           


If you want to change the mode to a higher number of colors, then each pixel maybe a word, or 3 or 4 bytes in size, depending on the mode.

Let me know if you need more help.
Post 15 Sep 2005, 13:13
View user's profile Send private message Reply with quote
cmello



Joined: 07 Dec 2005
Posts: 2
Location: Brazil
cmello 07 Dec 2005, 03:38
thanks for the great demo Dex4u!

I have an old notebook without floppy disk. Can you please tell me what changes I must do to run this demo on DOS? I have changed the 0x7C00 offsets to 0x100 so a COM was generated, but what else must I do? Is it possible to switch to pmode with the same code running from DOS?

Thanks a lot!

Best regards,
Cesar

Dex4u wrote:
@DataHunter2009, it is very simple here is a demo i made, some time ago that may help you:
Code:
;************************************
; \\|//
; (@ @)
; Dex4u.
; vesa2 640*480*256
; Put vesatest.bin on boot sector
; with rawrite.
; Assemble with fasm
; c:\fasm vesatest.asm vesatest.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   dword [VESAInfo_Signature],'VBE2'
        mov   ax,4f00h
        mov   di,VESA_Info
        int   10h

        cmp   ax,004Fh
        jne   novesa

        mov   ax,4f01h                                       ; set vesa screen mode information
        mov   di,Mode_Info
        mov   cx,0x4101                          ; Change this number for differant screen sizes
        and   cx,0xfff ;and
        int   10h 

        cmp   dword [VESAInfo_Signature], 'VESA'
        jne   novesa
        

        mov   ax,4f02h                           ; set vesa screen mode
        mov   bx,0x4101                         ; Change this number for differant screen sizes
        int   10h

        cmp   ax,004Fh
        jne   novesa
        
        jmp   @f

novesa:
        mov   ax,0xB800
        mov   es,ax
        lea   si,[msg0]                   
        mov   di,(80 * 1 + 2) * 2
        mov   cx,52
        cld
        rep   movsb

        jmp   $ 

 
;*****************************
; 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 (if space).
;*****************************

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

;*****************************
; render's graphic screen.
;*****************************

        mov   [color],0xcccccccc
render_screen:
        mov   edi,[ModeInfo_PhysBasePtr]     
        mov   ecx,640*480/4
        mov   eax,[color]
        cld
        rep   stosd       

        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

;*************************************
; Data. 
;*************************************

color       dd 0

msg0        db "  V E S A   M O D E   N O T   S U P P O R T E D !   " ,0x0d,0

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

;*************************************
; Put uninitialized data here.
;*************************************

include 'vesa2_info.inc'

;*************************************
; $$$$££££( vote for me Wink)££££$$$$.
;*************************************    

And here is the inc file:
Code:
;=========================================================;
; Vesa Information Block                         11/12/03 ;
;---------------------------------------------------------;
; DOS EXTREME OS V0.01                                    ;
; by Craig Bamford.(Dex4u).                               ;
;                                                         ;
;=========================================================;

;-------- FASM VESA INFORMATION BLOCK ------------

VESA_Info:
VESAInfo_Signature              rb      4
VESAInfo_Version                rw      1
VESAInfo_OEMStringPtr           rd      1
VESAInfo_Capabilities           rb      4
VESAInfo_VideoModePtr           rd      1
VESAInfo_TotalMemory            rw      1
VESAInfo_OEMSoftwareRev         rw      1
VESAInfo_OEMVendorNamePtr       rd      1
VESAInfo_OEMProductNamePtr      rd      1
VESAInfo_OEMProductRevPtr       rd      1
VESAInfo_Reserved               rb      222
VESAInfo_OEMData                rb      256

;========== 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
; VBE 3.0 extensions
ModeInfo_LinBytesPerScanLine    rw      1
ModeInfo_BnkNumberOfPages       rb      1
ModeInfo_LinNumberOfPages       rb      1
ModeInfo_LinRedMaskSize         rb      1
ModeInfo_LinRedFieldPos         rb      1
ModeInfo_LinGreenMaskSize       rb      1
ModeInfo_LinGreenFieldPos       rb      1
ModeInfo_LinBlueMaskSize        rb      1
ModeInfo_LinBlueFieldPos        rb      1
ModeInfo_LinRsvdMaskSize        rb      1
ModeInfo_LinRsvdFieldPos        rb      1
ModeInfo_MaxPixelClock          rd      1
; Reserved
ModeInfo_Reserved               rb      190
;============= VESA MODE INFORMATION END ==============    

If you need more info just ask Wink .
Post 07 Dec 2005, 03:38
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 07 Dec 2005, 14:52
Thanks, here is a demo i made : http://www.dex4u.com/DemoVesa.zip
that assembles as a mz exe file that can be run from dos, the zip includes a selfextrating exe to put the bootloader + demo on floppy, if you have a floppy from another pc , you can put it on a floppy and get the "vesatest.exe" from the floppy and run it from dos, this demo shows how to go back from pmode to realmode (dos)
do a realmode int ( changing to vesa mode, from textmode in this case) and back again.
So you can modify the code as you like, also in the zip is
the source code, so if you do not have a floppy at all you can assemble the code as a exe theat can be run from dos, need fasm.

If you need smaller code as a com file let me know and i will mod it for you, but you will need to code it differant, if you want to go back to dos.
NOTE: The demo as it is will not return to dos so you will need to reboot.

PS: My OS call "Dex4u" (Made by me and a team of asm coders. ) can be run from dos or boot from a floppy/CD/usbfob etc, has lots of function to help with vesa programming, that may help ?
http://www.dex4u.com

<EDIT> NOTE: If your laptop is very old, it may not have vesa2 which is needed for using vesa in pmode, as useally only vesa2 has LFB <EDIT>
Post 07 Dec 2005, 14:52
View user's profile Send private message Reply with quote
cmello



Joined: 07 Dec 2005
Posts: 2
Location: Brazil
cmello 08 Dec 2005, 04:26
Hey thanks a lot it worked perfectly. My notebook has a Chips card and it supports flat vesa modes.

Right now I tried Minix 3 (http://www.minix3.org) on this machine and it worked nice, the C compiler is very fast. I'll try to play a bit with vesa on it, now that I could fill some rectangles with a boot sector. Smile

Thanks a lot!

Best regards,
Cesar
Post 08 Dec 2005, 04:26
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 08 Dec 2005, 14:59
Thanks for the link, looks interesting Cool .
You can take alook at the code for "CdPod" which has some simple drawing example as well as simple vesa fonts + a Cdplayer. http://board.flatassembler.net/topic.php?t=2164&start=50

PS: I was called "ASHLEY4" when i made that.
Post 08 Dec 2005, 14:59
View user's profile Send private message Reply with quote
Iaro



Joined: 05 Jan 2006
Posts: 3
Iaro 05 Jan 2006, 15:26
Hello,
Sorry to bump this topic, but the link to demovesa.zip is dead. So could someone please post the code or direct me to another download link.
I searched the web for vesa and protected mode and this demo seems really nice. Unfortunately I don't know exacly how to change the program to exe or com ( until now I mainly used tasm to program in real mode, but bank switching seems kind of hard Smile ).

thanks in advance,
Robert
Post 05 Jan 2006, 15:26
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 05 Jan 2006, 23:04
Sorry, i have just updated my site and have taken some old zip file off.
I have put it back again here:
http://www.dex4u.com/images/DemoVesa.zip
I would only use bank swiching, if that all the card supported,

PS: Me and a number of asm coders are working on a online Mag, so we should have more Demo like that to come.
Post 05 Jan 2006, 23:04
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 05 Jan 2006, 23:25
Dex4u wrote:
Thanks, here is a demo i made : http://www.dex4u.com/images/DemoVesa.zip
that assembles as a mz exe file that can be run from dos, the zip includes a selfextrating exe to put the bootloader + demo on floppy, if you have a floppy from another pc , you can put it on a floppy and get the "vesatest.exe" from the floppy and run it from dos, this demo shows how to go back from pmode to realmode (dos)
do a realmode int ( changing to vesa mode, from textmode in this case) and back again.
So you can modify the code as you like, also in the zip is
the source code, so if you do not have a floppy at all you can assemble the code as a exe theat can be run from dos, need fasm.

If you need smaller code as a com file let me know and i will mod it for you, but you will need to code it differant, if you want to go back to dos.
NOTE: The demo as it is will not return to dos so you will need to reboot.

PS: My OS call "Dex4u" (Made by me and a team of asm coders. ) can be run from dos or boot from a floppy/CD/usbfob etc, has lots of function to help with vesa programming, that may help ?
http://www.dex4u.com

<EDIT> NOTE: If your laptop is very old, it may not have vesa2 which is needed for using vesa in pmode, as useally only vesa2 has LFB <EDIT>
Post 05 Jan 2006, 23:25
View user's profile Send private message Reply with quote
Iaro



Joined: 05 Jan 2006
Posts: 3
Iaro 06 Jan 2006, 09:25
Many thanks for the file Dex4u but unfortunately I couldn't make it work. I put vesatest.exe on a floppy, and after restart and boot from floppy all I got was a message to remove all media and restart.
What I would like to do is build an .exe file that can be run from Windows. So I tried combining the program that generated a bin file with the new one so that it would enter pmode, draw some graphics , enter real mode and exit with the dos call 4c00h. Unfortunately that didn't work.
the code :
Code:
   ;************************************
; \\|// 
; (@ @) 
; Dex4u. 
; vesa2 640*480*256 
; Put vesatest.bin on boot sector 
; with rawrite. 
; Assemble with fasm 
; c:\fasm vesatest.asm vesatest.bin 
; 
;************************************ 
format MZ
      use16
 jmp start
      linear_sel equ  linear_sel_1-gdt
        sys_code   equ  sys_code_1-gdt
        sys_data   equ  sys_data_1-gdt    
        Real_code  equ  Real_code_1-gdt
        Real_data  equ  Real_data_1-gdt


include 'vesa.inc'
;**************************** 
; Realmode startup code. 
;**************************** 

start: 
        push  cs
        pop   ds
        mov   ax,ds
        mov   es,ax

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

        mov   dword [VESAInfo_Signature],'VBE2' 
        mov   ax,4f00h 
        mov   di,VESA_Info 
        int   10h 

        cmp   ax,004Fh 
        jne   novesa 

        mov   ax,4f01h                                       ; set vesa screen mode information 
        mov   di,Mode_Info 
        mov   cx,0x4101                          ; Change this number for differant screen sizes 
        and   cx,0xfff ;and 
        int   10h  

        cmp   dword [VESAInfo_Signature], 'VESA' 
        jne   novesa 
         

        mov   ax,4f02h                           ; set vesa screen mode 
        mov   bx,0x4101                         ; Change this number for differant screen sizes 
        int   10h 

        cmp   ax,004Fh 
        jne   novesa 
         
        jmp   p_mode

novesa: 
        mov   ax,0xB800 
        mov   es,ax 
        lea   si,[msg0]                    
        mov   di,(80 * 1 + 2) * 2 
        mov   cx,52 
        cld 
        rep   movsb 

p_mode:
;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
;                               This sets up going into pmode                                  ;
;..............................................................................................;

;...................................... A20 ................................
        pusha
        cli                                    ; Disable all irqs
        cld
        mov   al,255                           ; Mask all irqs
        out   0xa1,al
        out   0x21,al
l.5:    in    al,0x64                          ; Enable A20
        test  al,2                             ; Test the buffer full flag
        jnz   l.5                              ; Loop until buffer is empty
        mov   al,0xD1                          ; Keyboard: write to output port
        out   0x64,al                          ; Output command to keyboard
l.6:    in    al,0x64                          
        test  al,2
        jnz   l.6                              ; Wait 'till buffer is empty again
        mov   al,0xDF                          ; keyboard: set A20
        out   0x60,al                          ; Send it to the keyboard controller
        mov   cx,14h
l.7:                                           ; this is approx. a 25uS delay to wait
        out   0edh,ax                          ; for the kb controler to execute our
        loop  l.7                              ; command.
        sti
        popa
        ret
;.................................... A20 ....................................

        xor   ebx,ebx
        mov   bx,ds                            ; BX=segment
        shl   ebx,4                            ; BX="linear" address of segment base
        mov   eax,ebx
        mov   [sys_code_1 + 2],ax              ; set base address of 32-bit segments
        mov   [sys_data_1 + 2],ax
        mov   [Real_code_1 + 2],ax             ; set base address of 16-bit segments
        mov   [Real_data_1 + 2],ax
        shr   eax,16
        mov   [sys_code_1 + 4],al
        mov   [sys_data_1 + 4],al
        mov   [Real_code_1 + 4],al
        mov   [Real_data_1 + 4],al

        mov   [sys_code_1 + 7],ah
        mov   [sys_data_1 + 7],ah
        mov   [Real_code_1 + 7],ah
        mov   [Real_data_1 + 7],ah

        add   ebx,gdt                          ; EBX=linear address of gdt
        mov   [gdtr + 2],ebx
        
        cli                                    ; Disable interrupts, 
        mov   ax,cs
        mov   [RealModeCS],ax
        lgdt  [gdtr]                           ; Load the GDT descriptor

        mov   eax, cr0                         ; Copy the contents of CR0 into EAX
        or    eax, 1                           ; Set bit 0
        mov   cr0, eax                         ; Copy the contents of EAX into CR0

        jmp   10h:clear_pipe                   ; Jump to code segment, offset clear_pipe


USE32                                          ; We now need 32-bit instructions
clear_pipe:

;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
;                                    We are in pmode                                           ;
;..............................................................................................;

       xor   edi,edi
       xor   esi,esi
       mov   ax, 18h                           ; Save data segment identifyer
       mov   ds, ax                            ; Move a valid data segment into the data segment register
       mov   ss, ax                            ; Move a valid data segment into the stack segment register
       nop
       mov   es,ax
       mov   fs,ax
       mov   gs,ax
        
       mov   ax,linear_sel
       mov   es,ax

;***************************** 
; render's graphic screen. 
;***************************** 

        mov   [color],0xcccccccc 
render_screen: 
        mov   edi,[ModeInfo_PhysBasePtr]      
        mov   ecx,640*480/4 
        mov   eax,[color] 
        cld 
        rep   stosd





;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
;                         Back to realmode for vesa int's.                                     ;
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;

Real_Mode_vesa_int:
        pushad
        
        jmp   20h:do_16v
use16

do_16v: 
      
        mov   ax,28H
        mov   ds,ax
        mov   ss,ax
        nop
  
                                            
        mov   bx,[RealModeCS]                   ; push real-mode CS:IP
        push  bx
        lea   bx,[do_rm]
        push  bx
                                                ; clear PE [protected mode enable] bit and return to real mode

        mov   eax,cr0
        and   al,0xFE
        mov   cr0,eax

MOV AH,00H
INT 16H
MOV AH,4CH
INT 21H

        retf                                    ; jumps to do_rm

;''''''''''''''''''''''''';
; 16-bit real mode again  ;
;.........................;
                                            
do_rm:  
        mov   ax,cs                             ; restore real-mode segment register values
        mov   ds,ax
        mov   ss,ax
        nop
        mov   es,ax
        mov   fs,ax
        mov   gs,ax

        lidt  [ridtr]                          ; point to real-mode IDTR

        push  cs
        pop   ds
        push  ds
        pop   es
        mov   ax,0xB800
        mov   es,ax





;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
;                                          GDT                                                 ;
;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;  
gdtr:   dw gdt_end - gdt - 1               ; GDT limit
        dd gdt                             ; (GDT base gets set above)

gdt:                                       ; Address for the gdt 
        dw 0                               ; limit 15:0    (0h) Null Segment
        dw 0                               ; base 15:0
        db 0                               ; base 23:16
        db 0                               ; type
        db 0                               ; limit 19:16, flags
        db 0                               ; base 31:24

linear_sel_1:   
       dw 0xFFFF                           ; (8h) linear Data segment, read/write, expand down
       dw 0                                        
       db 0
       db 10010010b                                
       db 11001111b                               
       db 0

sys_code_1:                                ; (10h) Code segment, read/execute, nonconforming
       dw 0FFFFh
       dw 0
       db 0
       db 10011010b
       db 11001111b
       db 0

sys_data_1:                                ; (18h) Data segment, read/write, expand down
       dw 0FFFFh
       dw 0
       db 0
       db 10010010b
       db 11001111b
       db 0

Real_code_1:                               ; (20h) Real mode code segment
       dw 0xFFFF
       dw 0                                              
       db 0
       db 10011010b                                               
       db 0                                               
       db 0

Real_data_1:                               ; (28h) Real mode data segment
       dw 0xFFFF
       dw 0                                               
       db 0
       db 10010010b                                               
       db 0                                               
       db 0

gdt_end:                                   ; Used to calculate the size of the GDT
 


;************************************* 
; Data.  
;************************************* 

color       dd 0 

msg0        db "  V E S A   M O D E   N O T   S U P P O R T E D !   " ,0x0d,0 

JustInCase:
         dd 0
RealModeCS:
         dw 0

ridtr:   dw 0xFFFF                          ; limit=0xFFFF
         dd 0                               ; base=0

count1:  dw 0

count:   db 0

;*************************************
; $$$$££££( vote for me )££££$$$$. 
;*************************************

    



When making real mode programs in tasm I think windows just emulated real mode. So could pmode - vesa - dos programs be run Windows ?

Robert
Post 06 Jan 2006, 09:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

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