The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nrdev on May 24, 2009, 02:25:46 PM

Title: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 02:25:46 PM
How can I use SVGA or VGA graphics in the msam, I don't see that he have any dos graphic libraries?
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 03:09:39 PM
i think what you want to research is "direct-x"
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 03:18:04 PM
that's not it, I want to use one of SVGA, or VGA graphics in my console app, but I don't know how to do that.
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 03:25:31 PM
well - you communicate with the video system by way of the operating system
newer operating systems do not allow direct manipulation of hardware (they may emulate it for you)
i do have one program i wrote several years ago, however, that uses 320x200 256 color mode (mode 8 i think)
that program seems to run under windows XP, but it goes full-screen (emulated)
as i am new to writing for 32-bit code myself, i haven't played with graphics much yet
but, console mode is really intended for text apps
if you are talking about ways to move the cursor and that sort of thing, windows API gives you some functions

btw - welcome to masm32 forum
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 03:31:56 PM
So how can I make my program ot use 320x200x16 screen resoultion in fullscreen mode? That is the thing that I currently want ot do in my program.
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 03:37:03 PM
i am not sure about 16 color mode - 256 colors works better, though - and it's easier to program
because each pixel takes a single byte
i looked it up...
320 x 200 16-color is mode 0Dh
320 x 256 256-color is mode 13h
this page has a nice tutorial....
http://www.brackeen.com/vga/basics.html

EDIT:
to set the video mode to 13h.....


        mov     ax,13h
        int       10h
Title: Re: SVGA or VGA initialization
Post by: UtillMasm on May 24, 2009, 03:40:05 PM
Windows 32-bit Console Application?
FullScreen?

what you mean?

###

Title: Command Prompt
Body: This system does not support fullscreen mode.
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 03:45:00 PM
I tried to use this code

mov     ax,13h
int       10h

but hte program crashes.

I want ot make  fullscreen 16-bit application
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 03:45:23 PM
lol
well - console mode as in - i wrote this program for DOS years ago
it works in that one mode (13h) - i doubt windows will support too many other modes
mode 13h was one that was supported by all vga's - the same way - for years
but - it runs from a console window
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 03:47:40 PM
Quote
but hte program crashes.

I want ot make  fullscreen 16-bit application

crashes ? - does it go blank ?
does it assemble ok ?
let me put my old program up.......
(see attached zip)

EDIT
use Exc to exit
cursor keys to move around on the map


[attachment deleted by admin]
Title: Re: SVGA or VGA initialization
Post by: UtillMasm on May 24, 2009, 03:49:36 PM
sorry, i misread the 'DOS'.
:wink
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 04:00:34 PM
what code will do this correctly? I think on the fullscreen and part that interests me.
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 04:08:20 PM
well, for starters, it was written as a 16-bit app
if you want to write a 16-bit program, it is a little different than a 32-bit program
you have to use a 16-bit linker, too - not the 32-bit one that comes with the masm32 package
but - for video mode 13h, you set the mode - fill the palette registers and start placing bytes in the video buffer
i used that mode because it is so easy to program for and because it will run on any VGA
the link i gave you should tell you about the video mode

Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 04:20:19 PM
ok, I think we can't totally understand each other so, here is my code:

include \masm32\include\masm32rt.inc                    ;   main masm32 INC file

.586
.code

ConsoleName equ "Console"                               ;   declaration of the console title

start:                                                  ;   start of the main loop of the program
cls

mov ax,13h
int 10h

invoke SetConsoleTitle,chr$(ConsoleName)                ;   implementation of console title

inkey                                                   ;   wait for the key to be pressed
ret

end start                                               ;   end of the main program loop


So, what I need to do to make this program run in the fullscreen in resolution 320x200x16
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 04:24:46 PM
ok - that is set up as a 32-bit program
you want to write a 16-bit program
they are written differently and link differently
in many respects, 16-bit code is much simpler to write, but does not allow all the neat windows abilities
if you want to learn to write 16-bit code, i suggest the art of assembly site i sent you in your PM box
although, Kip Irvine gives some 16-bit stuff, as well

EDIT
here is where to download the 16-bit LINK.EXE
ftp://ftp.microsoft.com/softlib/mslfiles/lnk563.exe

we should move this topic to the 16-bit forum
also, you will find many tips in there - better than i can give you (i am set up for 32-bit code)

Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 04:48:17 PM
how can I make my masm32 to compile a 16-bit app?
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 04:54:03 PM
let me see
i did it once to see if i could....
first - get the 16-bit linker (LINK563.EXE) - place it in the masm32\bin folder
then make a little batch file to assemble 16-bit code - i named it a16.bat and placed it in the same folder

@echo off
if "x%1"=="x" goto ascusage
if exist %1.asm goto ascasm
:ascusage
echo Usage: a16 asmfile
echo "asmfile" = asmfile.asm
goto batchexit
:ascasm
if exist %1.obj del %1.obj
c:\masm32\bin\ml /c %1.asm >c:\masm32\bin\asmbl.txt
if errorlevel 1 goto showtxt
if exist %1.exe del %1.exe
c:\masm32\bin\Link563 %1.obj >>c:\masm32\bin\asmbl.txt
:showtxt
if exist %1.obj del %1.obj
type c:\masm32\bin\asmbl.txt
:batchexit
dir %1.*


then - to assemble a 16-bit program type (at the prompt)
a16 MyAsmFile   (the batch file is written to assume .asm extension)

now - let me see if i can dig up an example 16-bit program for you
then - you should post in the 16-bit forum rather than here

Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 05:02:03 PM
ok
i had to modify one line in the batch file.... (added the semicolon)


c:\masm32\bin\ml /c %1.asm; >c:\masm32\bin\asmbl.txt


then - here is a program.....


        .model small

        .dosseg

        .stack 512

        .data

messag  db      'Hello World',0Dh,0Ah,24h

        .code

_main   proc

        mov     ax,_data          ;data segment
        mov     ds,ax

        mov     dx,offset messag
        mov     ah,9              ;function
        int     21h               ;DOS call

        mov     ax,4C00h          ;terminate - exit code = 0
        int     21h               ;DOS call

_main   endp

        end     _main
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 05:11:24 PM
nope - that semicolon isn't working either
the assembler is looking for more filenames
give me a few minutes...
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 05:24:05 PM
c:\masm32\bin\Link563 %1.obj >>c:\masm32\bin\asmbl.txt
in this line should be writen lnk563 instead of Link563. But in both ways it doesn't give any errors, and also don't give an exe file
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 05:27:36 PM
i named the linker link563.exe - so it works - lol
also - it helps if c:\masm32\bin is in the PATH environment variable (mine is already set up like that)

try this batch file.....

@echo off
if "x%1"=="x" goto ascusage
if exist %1.asm goto ascasm
:ascusage
echo Usage: asc asmfile
echo "asmfile" = asmfile.asm
goto batchexit
:ascasm
if exist %1.obj del %1.obj
c:\masm32\bin\ml /c %1.asm >c:\masm32\bin\asmbl.txt
if errorlevel 1 goto showtxt
if exist %1.exe del %1.exe
c:\masm32\bin\Link563 %1.obj; >>c:\masm32\bin\asmbl.txt
:showtxt
if exist %1.obj del %1.obj
type c:\masm32\bin\asmbl.txt
:batchexit
dir %1.*


EDIT the semicolon was needed on the linker line - not the assembler line
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 05:30:32 PM
if c:\masm32\bin is not in the PATH variable, type this at the command prompt...

\masm32\bin\a16 MyAsmFile
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 05:42:19 PM
it still have the same effect, dosn't report any error, and doesn't make the exe file.

my paths are

D:\masm32\bin\
D:\projects\16bit\16bit.asm
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 05:46:15 PM
ohhhhhhhhh - lol
then you will want d:\masm32\bin to be in the path (or use d:\masm32\bin\a16 MyAsmFile at the prompt)
and modify the batch file as follows....


@echo off
if "x%1"=="x" goto ascusage
if exist %1.asm goto ascasm
:ascusage
echo Usage: a16 asmfile
echo "asmfile" = asmfile.asm
goto batchexit
:ascasm
if exist %1.obj del %1.obj
d:\masm32\bin\ml /c %1.asm >d:\masm32\bin\asmbl.txt
if errorlevel 1 goto showtxt
if exist %1.exe del %1.exe
d:\masm32\bin\Link563 %1.obj; >>d:\masm32\bin\asmbl.txt
:showtxt
if exist %1.obj del %1.obj
type d:\masm32\bin\asmbl.txt
:batchexit
dir %1.*
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 05:49:23 PM
the basic commands are....

ml /c MyAsmFile.asm

link563 MyAsmFile.obj;

you can do it without a batch file
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 06:06:38 PM
still doesn't work. This time I have moved my *.asm file to my bin folder and, run command ml /c 16bit.asm, and get lots of errors, that I couldnt get when runing the batch file.
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 06:09:27 PM
ouch
it runs on mine
can you copy/paste the errors in here ?

it may not be great form for 16-bit - lol
i am used to a much older assembler for 16-bit code
this was my first attempt at a 16-bit program for this assembler

it may be best if you refer to the 16-bit forum or one of the
sites for a better example of how to write a 16-bit program

but - like i say - it assembled on mine
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 06:25:53 PM
here is the process and the errors

(http://img29.imageshack.us/img29/5605/console.th.jpg) (http://img29.imageshack.us/my.php?image=console.jpg)
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 06:32:43 PM
let me find my glasses

here - let me send you the file.....
(see attached zip)

i got the full-size pic
it looks like you are missing a period before the word model

   .model small

you also need it before

   .dosseg

   .data

   .code


[attachment deleted by admin]
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 06:45:19 PM
ok it compiled, but how can I make this program run in fullscreen?

turns out I didn't need lin563.exe becouse i had link16.exe to make it done.
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 06:49:48 PM
this page does a good job of explaining video mode 13h
read the text - the code is in C - ignore that - let me look for an ASM example

http://www.brackeen.com/vga/basics.html

Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 07:03:23 PM

ok - this program fills the screen with red
press any key to exit
when it's done, the text mode is full-screen - type EXIT to close the console window


[attachment deleted by admin]
Title: Re: SVGA or VGA initialization
Post by: nrdev on May 24, 2009, 07:11:04 PM
thats it, thanks, it was a lot of help.
Title: Re: SVGA or VGA initialization
Post by: dedndave on May 24, 2009, 07:14:24 PM
i found a few more links for you to look at

http://www.codebreakers-journal.com/content/view/140/93/
http://digiassn.blogspot.com/2006/03/asm-working-with-video-palette.html
http://webpages.charter.net/danrollins/techhelp/0113.HTM

that last one tells about other int 10h functions
one of them you will be interested in is int 10h function 1002h
Title: Re: SVGA or VGA initialization
Post by: Ossa on May 24, 2009, 09:53:57 PM
A few things:

1) look at this (http://www.masm32.com/board/index.php?topic=5001.msg37427#msg37427), it is a post of a tutorial that I translated about writing VGA graphics things using DOS under ASM nearly 3 years ago (actually how I learned ASM). Note that full screen is not usable under Vista, but you're OK so long as you're using XP or older.

2) take a peek at this (http://www.gamedev.net/reference/articles/article789.asp) - this is a fully working game using DirectX 6 and is still the best ASM game tutorial out there (IMHO).

3) have a good look at Scronty's site (http://scrontsoft.com/Scrontsoft.asp?pageID=2) for more up-to-date DirectX usage in ASM.

4) DOS is outdated and really much too hard to use... 32-bit Windows code is the way to go. Go for the Direct X versions.

All the best,
Ossa

[edit] Oh, if you want to know about interrupt codes, you need to look at Ralf Brown's Interrupt Listing (http://www.ctyme.com/rbrown.htm) i.e. for 10h, ax=1002h (http://www.ctyme.com/intr/rb-0116.htm) [/edit]
Title: Re: SVGA or VGA initialization
Post by: Farabi on May 25, 2009, 01:29:20 PM
If you want somethings cool, search about VESA and protected mode since DOS will only give you 1 MB of total memory.