delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/09/01/08:10:56

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Originating-IP: [193.248.160.185]
X-Originating-Email: [roomsmush AT hotmail DOT com]
X-Sender: roomsmush AT hotmail DOT com
From: "MUSH ROOMS" <roomsmush AT hotmail DOT com>
To: djgpp AT delorie DOT com
Subject: Re: Linear Frame Buffer don't work at all !
Date: Wed, 01 Sep 2004 12:09:52 +0000
Mime-Version: 1.0
Message-ID: <BAY16-F22idcDjoYAPN000b0f66@hotmail.com>
X-OriginalArrivalTime: 01 Sep 2004 12:09:53.0129 (UTC) FILETIME=[967A2D90:01C4901C]
Reply-To: djgpp AT delorie DOT com



>From: Listmaster <listmaster AT delorie DOT com>
>To: roomsmush AT hotmail DOT com
>Subject: Re: Linear Frame Buffer don't work at all ! Date: Wed, 1 Sep 2004 
>08:02:27 -0400
>
>The djgpp list is set up to allow posts only from current
>subscribers, and I cannot find you (roomsmush AT hotmail DOT com) on any
>of the mailing lists here.  Please subscribe to the
>djgpp mailing list and re-send your message (included below).
>Note that you may subscribe to the "members" mailing list
>with your real email address if you wish to use a fake (spam-proof)
>address for the mail you send.  See http://www.delorie.com/listserv/
>for details.
>
>Note that you can also post to the comp.os.msdos.djgpp newsgroup
>instead of sending email to djgpp AT delorie DOT com
>
>From lnobody AT delorie DOT com Wed Sep  1 08:02:26 2004
>Received: from hotmail.com (root AT localhost)
>	by delorie.com (8.12.8/8.12.8) with SMTP id i81C2Il5006066
>	for <djgpp AT delorie DOT com>; Wed, 1 Sep 2004 08:02:24 -0400
>Received: from hotmail.com (bay16-f1.bay16.hotmail.com [65.54.186.51])
>	by delorie.com (antispam)
>Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC;
>	 Wed, 1 Sep 2004 04:45:05 -0700
>Received: from 193.248.160.185 by by16fd.bay16.hotmail.msn.com with HTTP;
>	Wed, 01 Sep 2004 11:45:05 GMT
>X-Originating-IP: [193.248.160.185]
>X-Originating-Email: [roomsmush AT hotmail DOT com]
>X-Sender: roomsmush AT hotmail DOT com
>From: "MUSH ROOMS" <roomsmush AT hotmail DOT com>
>To: djgpp AT delorie DOT com
>Subject: Linear Frame Buffer don't work at all !
>Date: Wed, 01 Sep 2004 11:45:05 +0000
>Mime-Version: 1.0
>Content-Type: text/plain; charset=iso-8859-1; format=flowed
>Message-ID: <BAY16-F1adTMVwVn20l0001c9ba AT hotmail DOT com>
>X-OriginalArrivalTime: 01 Sep 2004 11:45:05.0460 (UTC) 
>FILETIME=[1FC1E740:01C49019]
>
>so i try all the possibilities but it doesn't want to work !!
>i have XP pro, it is maybe his faults...
>
>here is my code, i post it every where i can, and nobody know why it 
>doesn't
>work ...
>just test it with djgpp && gpp
>
>[pre]#include <dpmi.h>
>#include <sys/nearptr.h>
>#include <stdlib.h>
>#include <string.h>
>#include <go32.h>
>#include <stdio.h>
>#include <conio.h>
>#define PACKED __attribute__ ((packed))
>#pragma pack(1)
>typedef struct {
>   short   ModeAttributes PACKED;         /* Mode attributes       */
>   char    WinAAttributes PACKED;         /* Window A attributes     */
>   char    WinBAttributes PACKED;         /* Window B attributes     */
>   short   WinGranularity PACKED;         /* Window granularity in k */
>   short   WinSize PACKED;                /* Window size in k         */
>   short   WinASegment PACKED;            /* Window A segment         */
>   short   WinBSegment PACKED;            /* Window B segment         */
>   void    *WinFuncPtr PACKED;     // Pointer to window function
>   short   BytesPerScanLine PACKED;       /* Bytes per scanline      */
>   short   XResolution PACKED;            /* Horizontal resolution   */
>   short   YResolution PACKED;            /* Vertical resolution     */
>   char    XCharSize PACKED;              /* Character cell width     */
>   char    YCharSize PACKED;              /* Character cell height   */
>   char    NumberOfPlanes PACKED;         /* Number of memory planes  */
>   char    BitsPerPixel PACKED;           /* Bits per pixel           */
>   char    NumberOfBanks PACKED;          /* Number of CGA style banks*/
>   char    MemoryModel PACKED;            /* Memory model type      */
>   char    BankSize PACKED;               /* Size of CGA style banks  */
>   char    NumberOfImagePages PACKED;     /* Number of images pages   */
>   char    res1 PACKED;                   /* Reserved                 */
>   char    RedMaskSize PACKED;       /* Size of direct colorredmask  */
>   char    RedFieldPosition PACKED;     /* Bit posn of lsb of red mask*/
>   char    GreenMaskSize PACKED;   /* Size of direct color green mask*/
>   char    GreenFieldPosition PACKED; /* Bit posn of lsb of green mask */
>   char    BlueMaskSize PACKED;      /* Size of direct color blue mask*/
>   char    BlueFieldPosition PACKED;  /* Bit posn of lsb of blue mask */
>   char    RsvdMaskSize PACKED;   /* Size of direct color res mask    */
>   char    RsvdFieldPosition PACKED;/* Bit posn of lsb of res mask  */
>   char    DirectColorModeInfo PACKED;//Direct color mode attributes
>
>   /* VESA 2.0 variables */
>   long    PhysBasePtr;   /* physical address for flat frame buffer */
>   long    OffScreenMemOffset;	//pointer to start of off screen memory
>short   OffScreenMemSize; /* amount of off screen memory in 1k units */
>   char    res2[206] PACKED;      /* Pad to 256 byte block size       */
>} modeinfo;
>#pragma pack()
>struct {
>   __dpmi_meminfo mem;
>   unsigned short selector;
>} __mapping;
>unsigned char* screenptr = 0;
>
>int setmode(unsigned int mode) {
>
>     __dpmi_regs r;
>     r.x.ax = 0x4F02;
>     r.x.bx = mode | 0x4000; // Set bit 14 to enable the LFB
>     __dpmi_int(0x10, &r);
>
>     // Mode change failed.  Linear framebuffer is unavailable.
>     if (r.x.ax != 0x4F) {
>
>       // Try to set the mode normally.
>       r.x.ax = 0x4F02;
>       r.x.bx = mode;
>       __dpmi_int(0x10, &r);
>
>       // Mode change failed.  SVGA is not available.
>       if (r.x.ax != 0x4F)
>         return 0;
>
>       return -1; // SVGA mode set, but you'll have to switch banks.
>     }
>
>     return 1; // LFB enabled.
>   }
>void setmodetext()
>{
>__dpmi_regs registres;
>	registres.x.ax=0x4F02;                    //
>   registres.x.bx=3;              //
>   __dpmi_int(0x10,&registres);
>
>}
>void getmodeinfo(unsigned short mode,modeinfo * modeinfo)
>{
>__dpmi_regs regs;
>regs.x.ax = 0x4F01;
>regs.x.cx = mode;
>regs.x.di = __tb & 0x0F;
>regs.x.es = (__tb >> 4) & 0xFFFF;
>__dpmi_int(0x10, &regs);
>dosmemget(__tb,sizeof(*modeinfo),modeinfo);
>}
>
>unsigned short map_linear_framebuffer(unsigned short mode)
>{
>   // The first step is to get mode information (including the
>   // PhysBasePtr):
>
>   modeinfo info;
>   getmodeinfo(mode,&info);
>
>   // Set up a block of physical memory the same size as
>   // the current screenmode at the PhysBasePtr.
>
>   __mapping.mem.size = 800*600;
>   __mapping.mem.address = info.PhysBasePtr;
>   __mapping.selector = 0;
>
>   // Attempt to map the physical address to linear memory.
>   if (__dpmi_physical_address_mapping(&__mapping.mem) != -1) {
>
>     // Allocate one Local Description Table segment descriptor.
>     // Using this, we will attempt to obtain a selector that we can
>     // use in place of _dos_ds for memory access.
>
>     int descriptor = __dpmi_allocate_ldt_descriptors(1);
>
>     if (descriptor != -1) {
>
>       __mapping.selector = descriptor;
>
>       // A selector must refer to a region of memory, and in here this
>       // means our video memory mapping.
>
>       if (__dpmi_set_segment_base_address(__mapping.selector,
>__mapping.mem.address) != -1 &&
>           __dpmi_set_segment_limit(__mapping.selector, 
>__mapping.mem.size-1)
>          != -1) {
>
>         return __mapping.selector;  // Success
>
>       } // end (if selector size/location could be set)
>
>       // FAILURE:  Free the useless descriptor.
>       __dpmi_free_ldt_descriptor(__mapping.selector);
>
>     } // end (if selector could be allocated)
>   } // end (if memory could be mapped)
>
>
>   // FAILURE.
>   // Region could not be mapped, for various reasons.
>   // Free the worthless mapping.
>   __dpmi_free_physical_address_mapping(&__mapping.mem);
>   return 0;
>}
>
>void unmap_linear_framebuffer() {
>   // Only free the mapping if we actually obtained it.
>   if (__mapping.selector) {
>     __dpmi_free_physical_address_mapping(&__mapping.mem);
>     __dpmi_free_ldt_descriptor(__mapping.selector);
>   }
>}
>
>
>
>// Call at start of program
>// Returns 0 if direct access to SVGA memory is not possible
>
>unsigned char* enable_screenptr() {
>
>   // Video memory must be mapped.
>
>   if (__mapping.selector)
>
>     // Disable memory protection.
>     // Call is guaranteed to fail on Windows NT
>
>     if (__djgpp_nearptr_enable())
>
>       // Video memory is no longer protected from you.
>       // Neither is the OS or its processes!
>
>       return (unsigned char *)__mapping.mem.address;
>
>   return 0;
>}
>
>// Call at end of program
>void disable_screenptr() { __djgpp_nearptr_disable(); }
>
>void pset_8_fast(int x, int y, unsigned char color) {
>
>   unsigned char* video_mem = (unsigned char *)(screenptr +
>__djgpp_conventional_base);
>   video_mem[800 * y + x] = color;
>}
>int main() {
>
>   // ... set your SVGA mode ...
>   setmode(0x103);
>   unsigned short selector;
>   unsigned short i=100,u;;
>
>u=map_linear_framebuffer(0x103);
>
>
>     //enable_screenptr();
>/*  for(i=0;i<20;i++)pset_8_fast(i,10,10) ;
>getch();*/
>//unmap_linear_framebuffer();
>//disable_screenptr();
>   setmodetext();
>printf("%d",u);
>   return 0;
>}[/pre]
>
>_________________________________________________________________
>MSN Search, le moteur de recherche qui pense comme vous !
>http://search.msn.fr/
>

_________________________________________________________________
Dialoguez en direct et gratuitement avec vos amis sur 
http://g.msn.fr/FR1001/866 MSN Messenger !

- Raw text -


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