Article View: rec.games.programmer
Article #61Re: Code for loading directly into VGA mem
From: John A. Slagel
Date: Sun, 01 Nov 1992 20:00
Date: Sun, 01 Nov 1992 20:00
83 lines
3155 bytes
3155 bytes
mucds@uxa.ecn.bgu.edu (Corey D. Stinson) writes:
>Recently someone posted the code below in answer to someone's questoin
>concerning loading directly into the VGA memory buffer. The coder
>mentioned that he/she was using Microsoft C. Neither of the examples
>below will work for me (I'm using Turbo/Borland C++) and I wonder if
>someone might have some suggestions which would allow this to work
>correctly under my compiler:
>Why this doesn't work:
> unsigned char (far *VideoMemory)[200][320];
> VideoMemory=(unsigned char (far *)[200][320])0xA0000000L;
> for (x=0;x<=15;x++ )
> for (y=0;y<=15;y++)
> VideoMemory[y][x]=pic[x][y];
CHANGE TO: (*VideoMemory)[y][x]=pic[x][y];
> **** LValue required error on above line ****
> unsigned char (far *VideoMemory)[200][320];
> VideoMemory=(unsigned char (far *)[200][320])0xA0000000L;
> for (x=0;x<=15;x++ )
> for (y=0;y<=15;y++)
> VideoMemory[y][x]=pic[x][y];
> -A good compiler should be able to optimize this pretty good.
> OR, using Microsoft C inline assembler, a very fast version:
>Why this doesn't work:
> void PUTBLT( int x, int y, int width, int height, char far * buffer )
> {
> _asm {
> push es
> push ds
> mov ax, A000h ; The segment of VGA memory
> mov es, ax
> mov ax, 320
> mul y
> add ax, height ; AX = y*320+x
> mov di, ax ; The offset into VGA memory
> mov dx, width ; USe DX for width
> mov bx, height ; Use BX for height
> lds si, buffer ; Point DS:SI to the memory
rowloop: push di ; << CHANGE THIS LINE!!
> mov cx, dx ; Number of pixels to fill per row
> rep movsb ; blast 'em out there
pop di ; << ADD THIS LINE!!!
add di, 320 ; Move to next scan line
> dec bx
> jnz rowloop
>*** it's not recognizing the label I designated previously. A friend
> tells me it is illegal to create labels in inline assembler but
> I would think there would be a way to do it.
***** I'm not sure.... inline assembly does allow labels... maybe
check your manual for the compiler.
> **
> pop ds
> pop es
>
> -This is assuming you're using mode 13h.
> -This just writes directly to video memory.
>Any help or advice would be GREATLY appreciated! :)
Mail me if you can't get these to work.
--
------------------------------------------------------------------------
John A. Slagel, email: jas37876@uxa.cso.uiuc.edu
Technical Details
Message-ID:
<Bx1zLG.AMB@news.cso.uiuc.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!paladin.american.edu!news.univie.ac.at!chx400!ira.uka.de!yale.edu!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jas37876References:
<Bx1xF3.31B@uxa.ecn.bgu.edu>Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!europa.asd.contel.com!paladin.american.edu!news.univie.ac.at!chx400!ira.uka.de!yale.edu!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jas37876 From: jas37876@uxa.cso.uiuc.edu (John A. Slagel) Subject: Re: Code for loading directly into VGA mem References: <Bx1xF3.31B@uxa.ecn.bgu.edu> Message-ID: <Bx1zLG.AMB@news.cso.uiuc.edu> Sender: usenet@news.cso.uiuc.edu (Net Noise owner) Organization: University of Illinois at Urbana Date: Sun, 1 Nov 1992 20:00:51 GMT Lines: 83