delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2010/06/19/21:31:21

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Yahoo-Newman-Property: ymail-3
X-Yahoo-Newman-Id: 749859 DOT 32702 DOT bm AT omp602 DOT mail DOT sp1 DOT yahoo DOT com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.ar; s=s1024; t=1276997460; bh=Ero5MRDxrKAEEhIqoYbjvkLi8T8psyFNGasQh30VplA=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=PZTWiTeP/i5sb1XhuWf49zHSTiA009klsMLociVtstmtGjvrZ/yhYjUxBclyugYIpN+5823ByeuUu/UdHATo70YkVk3FnXBJJhrIeifLCce/ppVqxCPXoLIluR585S48OEpkdHwc3yXgkBtPNU7wziyFA+iIOQFhnYGJ3PiMw4w=
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;
s=s1024; d=yahoo.com.ar;
h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding;
b=Ej5u6GoGs3RGPcheoPsaIrkQ59pySLJdepqa0fswAOthnvKYTa+m9v0LYgZ8aEZ3srlMh9xCJ67KYvIIBpyGeo7i39YitbYe7uyQCICNMdBnUYuaulAgl+cSPJjbb4sE9OU6BjtHwcftC6H21NFijJpTEBFW5ZIJx+BWbraEShs=;
Message-ID: <541720.49903.qm@web45105.mail.sp1.yahoo.com>
X-YMail-OSG: RLYYZPoVM1n.ojUP4Z7O7mMTD8yR6vNxTQiD7yVUf.McpAA
KWvSq1bF_6JwW4w4M49XLeaLGYkaYokevsSj7QUerLrwKcWQNhjRrXayMxXJ
4hyqZ9JkpHZm6_4HN.5wRRJRgK8gHfQHccN_g09QTKak33eXkDuRzLcDrxEB
FODyRZJ5TMa6Y0B0Xv9iMH4WrBscQO.Z8tpgaH.6ijJjkAeT7ARZNjsN4C5v
l.RHUIFRgoXh7fix6Ufw.Nzb3gDEK9YPTzJ0EPn2yauyKbw9M7e093C1Xfg-
-
X-Mailer: YahooMailClassic/11.1.4 YahooMailWebService/0.8.104.274457
Date: Sat, 19 Jun 2010 18:31:00 -0700 (PDT)
From: Pablo Marty <tigrepotrazosalvaje AT yahoo DOT com DOT ar>
Subject: Please help me to fix this: almost have the piece of code for mi game faster ... just a bit more
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

hello Girls and Guys of DJGPP

I didnt give up from searching the code for getting the linear framebuffer =
VESA VBE for my game to run normally fast under DOSBox, with music included=
. (my version of Super Mario Bros)
But the one who hasn=B4t the link broken to the page with the code, does ha=
ve it but destroyed, the fourth fragment preceding the second, etc:-
I supose I could reintegrate and debug this one from 2 web pages, and final=
ly the DOSBox didnt throw any exception or page fault but i could not see a=
 pixel on the screen. Either the VBE_linear_mapping() succeeded with return=
 0, that is no error message; I dont know weather the mismatch is on the vi=
deo mode setting or in the arg 0x112 passed to VBE_getModeInfo()
I'll thank all my life that/those ones who clear this heavy situation to me=
, retouching or fixing this, then i'll be able to run normally and with bet=
ter colors my Mario Bros (i love him and Sonic and Tails and Knuckles) ... =
and with music that under W doesnt work .... I tried Allegro, but didn t ge=
t a word, plus the direct way (VGA Access, logical and math reasoning, etc)=
 is very easier for me ... I just use the play_midi() function and related =
ones
Nevertheless I got my program much better since when I sent it to Rugxulo, =
i optimized the speed a little by reducind CPU procesor time, and improve t=
he graphics ... i supose it could be quit good with this following code wor=
king fine ; Thank you very much---
Rugxulo, may I send the game to you again? it s a bit faster and better now

/*************************************************
#include <dpmi.h>
#include <go32.h>
#include <assert.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define ushort unsigned short
#define PACKED __attribute__ ((packed))=A0=20
#pragma pack(1)
typedef struct{
=A0=A0=A0 char=A0=A0=A0 VESASignature[4] PACKED;=A0=A0
=A0=A0=A0 short=A0=A0 VESAVersion PACKED;=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 *OEMStringPtr PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 long=A0=A0=A0 Capabilities PACKED;=A0=A0=A0=A0=A0=A0
=A0=A0=A0 unsigned *VideoModePtr PACKED;=A0=A0=A0
=A0=A0=A0 short=A0=A0 TotalMemory PACKED;=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 reserved[236] PACKED;=A0=A0=A0=A0
} Vbe_Info;
typedef struct{
=A0=A0=A0 short=A0=A0 ModeAttributes PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 WinAAttributes PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 WinBAttributes PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 short=A0=A0 WinGranularity PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 short=A0=A0 WinSize PACKED;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 short=A0=A0 WinASegment PACKED;=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 short=A0=A0 WinBSegment PACKED;=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 void=A0=A0=A0 *WinFuncPtr PACKED;=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 short=A0=A0 BytesPerScanLine PACKED;=A0=A0=A0
=A0=A0=A0 short=A0=A0 XResolution PACKED;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=20
    short=A0=A0 YResolution PACKED;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char    XCharSize PACKED;
    char=A0=A0=A0 YCharSize PACKED;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 NumberOfPlanes PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 BitsPerPixel PACKED;=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 NumberOfBanks PACKED;=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 MemoryModel PACKED;=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 BankSize PACKED;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 NumberOfImagePages PACKED;=A0
=A0=A0=A0 char=A0=A0=A0 res1 PACKED;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0
=A0=A0=A0 char=A0=A0=A0 RedMaskSize PACKED;=A0=A0
=A0=A0=A0 char=A0=A0=A0 RedFieldPosition PACKED;=A0=A0
=A0=A0=A0 char=A0=A0=A0 GreenMaskSize PACKED;=A0=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 GreenFieldPosition PACKED;
=A0=A0=A0 char=A0=A0=A0 BlueMaskSize PACKED;=A0=A0=A0=A0=A0=A0=A0=20
=A0=A0=A0 char=A0=A0=A0 BlueFieldPosition PACKED;=A0=A0=20
=A0=A0=A0 char=A0=A0=A0 RsvdMaskSize PACKED;=A0=A0=A0=A0=A0=A0=A0=20
=A0=A0=A0 char=A0=A0=A0 RsvdFieldPosition PACKED;=A0=A0=20
=A0=A0=A0 char=A0=A0=A0 DirectColorModeInfo PACKED;=20
=A0=A0=A0 long=A0=A0=A0 PhysBasePtr;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=20
=A0=A0=A0 long=A0=A0=A0 OffScreenMemOffset;=A0=A0=A0=20
=A0=A0=A0 short=A0=A0 OffScreenMemSize;=A0=A0=A0=A0
=A0=A0=A0 char=A0=A0=A0 res2[206] PACKED;=A0=A0=A0=A0
} VBE_ModeInfo;

short int=A0=A0=A0=A0=A0=A0 xres =3D 640, yres =3D 480;=A0=A0=A0=A0 /* x & =
y resolutions for the requested mode */
int=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 bpp =3D 4;=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* bytes per pixel */
VBE_ModeInfo=A0=A0=A0 modeinfo;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0 /* VESA modeinfo struct */
__dpmi_meminfo=A0 meminfo;
unsigned int=A0=A0=A0 VBE_linaddr;
int=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 VBE_selector;

void VBE_getModeInfo(unsigned short mode, VBE_ModeInfo *modeinfo)
{
=A0=A0=A0=A0 __dpmi_regs r;
=A0=A0=A0=A0 assert(sizeof(VBE_ModeInfo) < _go32_info_block.size_of_transfe=
r_buffer);
=A0=A0=A0=A0 r.x.ax =3D 0x4F01;
=A0=A0=A0=A0 r.x.cx =3D mode;
=A0=A0=A0=A0 r.x.di =3D __tb & 0x0F;
=A0=A0=A0=A0 r.x.es =3D (__tb >> 4) & 0xFFFF;
=A0=A0=A0=A0 __dpmi_int(0x10, &r);
=A0=A0=A0=A0 dosmemget(__tb, sizeof(VBE_ModeInfo), modeinfo);
=A0=A0=A0=A0 return;
}

int VBE_linear_mapping(void)
{
=A0=A0 if(!&modeinfo)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 /* check if the requested VESA mode is avalaible */
=A0=A0 {
=A0=A0=A0=A0=A0=A0 printf("Get VESA mode info failed. \n");
=A0=A0=A0=A0=A0=A0 exit(1);=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* exit or a clever error handling proced=
ure */
=A0=A0 }
=A0=A0 meminfo.handle =3D 0;
=A0=A0 meminfo.size =3D xres * yres * bpp + 256; /* extra 256 for safe */
=A0=A0 meminfo.address =3D modeinfo.PhysBasePtr;
=A0=A0 if(__dpmi_physical_address_mapping(&meminfo) =3D=3D -1)
=A0=A0 {
=A0=A0=A0=A0=A0 printf("Physical mapping of address 0x%lx failed!\n",
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 modeinfo.PhysBasePtr);
=A0=A0=A0=A0=A0 exit(2);=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* exit or a clever error handling proced=
ure */
=A0=A0 }
=A0=A0 __dpmi_lock_linear_region(&meminfo);
=A0=A0 VBE_linaddr =3D meminfo.address;
=A0=A0 if((VBE_selector =3D __dpmi_allocate_ldt_descriptors(1)) =3D=3D -1)
=A0=A0 {
=A0=A0=A0=A0=A0 printf("LDT allocation failed!\n");
=A0=A0=A0=A0=A0 exit(4);=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 /* exit or a clever error handling proced=
ure */
=A0=A0 }
=A0=A0 __dpmi_set_segment_base_address(VBE_selector, VBE_linaddr);
=A0=A0 __dpmi_set_segment_limit(VBE_selector, xres*yres*bpp);
=A0=A0 return 0;
}
void VBE_free_linear_mapping(void)
{
=A0=A0 __dpmi_unlock_linear_region(&meminfo);
=A0=A0 __dpmi_free_physical_address_mapping(&meminfo);
=A0=A0 __dpmi_free_ldt_descriptor(VBE_selector);
}

void put_pixel(uint x, uint y,=20
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 uchar r, uchar g, uchar b, uchar=
 alfa)
{
=A0=A0 ulong offset;
=A0=A0 if ((x >=3D xres) || (x < 0) || (y >=3D yres) || (y < 0))
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return;
=A0=A0 offset =3D ((long int)y*xres + (long int)x)*(long int)(bpp);
=A0=A0 _farpokel(VBE_selector, offset,(ulong)(65536*r + 256*g + b));
}
int=A0 main (void) {
=A0=A0=A0=A0 __dpmi_regs r;
=A0=A0=A0=A0 int a;
=A0=A0=A0=A0 VBE_getModeInfo(0x112, &modeinfo);
=A0=A0=A0=A0 if (VBE_linear_mapping() !=3D 0) exit(2);
=A0=A0=A0=A0 r.x.ax =3D 0x4F02;
=A0=A0=A0=A0 r.x.bx =3D 0x4101;
=A0=A0=A0=A0 __dpmi_int (0x10, &r);

=A0=A0=A0=A0 for (a=3D0; a<40; a++)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 put_pixel(300+a, 240, 128, 128, 128, 127);
=A0=A0=A0=A0 getch();
=A0=A0=A0=A0 printf ("%d", _farpeekl(VBE_selector, 240*640+320)); //drawn
=A0=A0=A0=A0 printf ("%d", _farpeekl(VBE_selector, 200000));     //empty

=A0=A0=A0=A0 VBE_free_linear_mapping();
}
=0A=0A=0A      

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019