🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #63

Code for loading

#63
From: colin buckley
Date: Mon, 02 Nov 1992 00:23
73 lines
2744 bytes
Date Entered: 11-01-92 19:20
JA>>   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

You should be adding x, not height so

       ADD    AX, X

  >>   mov    di, ax      ; The offset into VGA memory
  >>   mov    dx, width   ; USe DX for width

       MOV    AX, 320
       SUB    AX, DX

  >>   mov    bx, height  ; Use BX for height
  >>   lds    si, buffer  ; Point DS:SI to the memory

JA>rowloop: push   di         ; << CHANGE THIS LINE!!

This is pointless when you have a free register.  Don't use the above line
but include the label.  See end of message regarding labels.

JA>>   mov    cx, dx      ; Number of pixels to fill per row
  >>   rep    movsb       ; blast 'em out there

JA>    pop    di          ; << ADD THIS LINE!!!
  >    add    di, 320     ; Move to next scan line

Kill the above 2 lines and use the one below instead.

       ADD    DI, AX

JA>>   dec    bx
  >>   jnz    rowloop

JA>>*** 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 do not code in C, however I have seen other posts that disable the inline
assembler when defineing labels.  So try.

}
Rowloop:
_ASM {

I've also seen ASM declared before each line, except labels.  Press ALT-F1
with the cursor on ASM and see what the Help system tells you about it.


John, this isn't directed at you, but the original poster, even though it's
your message.

Maybe I should have quoted his message directly, the above might seem
confusing...
.----------------------------------------------------.
| Colin Buckley -- 486 Powered (Packing Extra Socks) |
| Toronto, Ontario, Canada                           |
| InterNet: colin.buckley@rose.com                   |
|                                                    |
| So Eager to Play, So Relunctant to Admit it...     |
`----------------------------------------------------'
---
   RM 2.00 : RoseNet<=>Usenet Gateway : Rose Media 416-733-2285
Technical Details
Message-ID: <1992Nov02.002322.11241@rose.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uunet.ca!rose!usenet

Show Full Headers
Complete Article Headers
Newsgroups: rec.games.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uunet.ca!rose!usenet
From: colin.buckley@rose.com (colin buckley)
Subject: Code for loading
Organization: Rose Media Inc, Toronto, Ontario.
Date: Mon, 2 Nov 1992 00:23:20 GMT
Message-ID: <1992Nov02.002322.11241@rose.com>
Sender: usenet@rose.com (Usenet Gateway)
X-Gated-By: Usenet <==> RoseMail Gateway (v1.70)
Lines: 73