🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #89

Re: code for loading dire

#89
From: Cyberman
Date: Wed, 04 Nov 1992 23:28
100 lines
3280 bytes
   Corey D. Stinson was espousing about 'Code for loading directly',
   on [11-01-92  19:13] to All!
 CDS> unsigned char (far *VideoMemory)[200][320];
 CDS> VideoMemory=(unsigned char (far *)[200][320])0xA0000000L;
 CDS> for (x=0;x<=15;x++ )
 CDS> for (y=0;y<=15;y++)
 CDS> VideoMemory[y][x]=pic[x][y];
 CDS> **** LValue required error on above line ****

    This is a VideoMemory is a pointer to an array you need to to
    dereferenced.

 CDS> unsigned char (far *VideoMemory)[200][320];
 CDS> VideoMemory=(unsigned char (far *)[200][320])0xA0000000L;
 CDS> for (x=0;x<=15;x++ )
 CDS> for (y=0;y<=15;y++)
 CDS> VideoMemory[y][x]=pic[x][y];

 CDS> -A good compiler should be able to optimize this pretty good.

 CDS> OR, using Microsoft C inline assembler, a very fast version:


 CDS> Why this doesn't work:

 CDS> void PUTBLT( int x, int y, int width, int height, char far * buffer
 CDS> ) {
 CDS> _asm   {
    try just asm not _asm
 CDS> push   es
 CDS> push   ds 
 CDS> mov    ax, A000h   ; The segment of VGA memory

    NO comments! TC++ 1.0 doesn't allow them I don't know about
    later versions.

 CDS> mov    es, ax
 CDS> mov    ax, 320
 CDS> mul    y
 CDS> add    ax, height  ; AX = y*320+x
 CDS> mov    di, ax      ; The offset into VGA memory
 CDS> mov    dx, width   ; USe DX for width
 CDS> mov    bx, height  ; Use BX for height 
 CDS> lds    si, buffer  ; Point DS:SI to the memory
 CDS> rowloop:
        NO imbeded lables the compilor won't recognize them
 CDS> mov    cx, dx      ; Number of pixels to fill per row
 CDS> rep    movsb       ; blast 'em out there
 CDS> dec    bx
 CDS> jnz    rowloop 

 CDS> *** it's not recognizing the label I designated previously.  A friend
 CDS> tells me it is illegal to create labels in inline assembler but
 CDS> I would think there would be a way to do it.
 CDS> **
 CDS> pop    ds
 CDS> pop    es
 CDS> 
 CDS> -This is assuming you're using mode 13h.
 CDS> -This just writes directly to video memory.

 CDS> Any help or advice would be GREATLY appreciated! :)

 Modified to work with TC++ 1.0

void PUTBLT( int x, int y, int width, int height, char far * buffer) {
    asm   {
        push   es
        push   ds
        mov    ax, A000h
        mov    es, ax
        mov    ax, 320
        mul    y
        add    ax, height
        mov    di, ax
        mov    dx, width
        mov    bx, height
        lds    si, buffer
        }

    rowloop:
    asm {
        mov    cx, dx
        rep    movsb
        dec    bx
        jnz    rowloop
        pop    ds
        pop    es
        }
    }

    This should work.

                Stephen Cyberman@Toz.Buffalo.NY.US
             Mangled on Tue  11-03-1992  at 19:52:52

... This tagline stolen by Silly Little Mail Reader!
--- Blue Wave/QWK v2.10
                                                   
Technical Details
Message-ID: <gate.o2mqTB1w165w@toz.buffalo.ny.us>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!ub!toz!cyberman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!ub!toz!cyberman
From: cyberman@toz.buffalo.ny.us (Cyberman)
Newsgroups: rec.games.programmer
Subject: Re: code for loading dire
Message-ID: <gate.o2mqTB1w165w@toz.buffalo.ny.us>
Date: 4 Nov 92 23:28:10 GMT
Lines: 100
X-Maildoor: WaflineMail 1.00r