Thread: Help with mode13 with djgpp on win XP

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    118

    Help with mode13 with djgpp on win XP

    I really want to be able to use mode13, but for some reason I cant seem to access the video memory at 0xA0000, if I call my plot pixel function the program just exits, here is my plot pixel function:
    Code:
    void plotPixel(int x, int y, byte color)
    {
    	VGA[y*SCREEN_WIDTH+x] = color;
    }
    however if I change it to:
    Code:
    void plotPixel(int x, int y, byte color)
    {
    	union REGS regs;
    	regs.h.ah = 0x0C; 
    	regs.h.al = color;
    	regs.x.cx = x;      
    	regs.x.dx = y;      
    	int86(0x10,&regs,&regs);
    }
    it does work, but it is too slow. Does anyone know what I can do to access the memory directly? I have a Geforce4 440 mx with the latest drivers if it is important

    Here is the complete code.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <dos.h>
    #include <conio.h>
    
    #define SCREEN_WIDTH 320
    #define SCREEN_HEIGHT 200
    
    typedef unsigned char byte;
    
    byte *VGA = (byte*)0xA0000;
    
    void enterMode13()
    {
    	union REGS regs;
    	regs.h.ah = 0x00;
    	regs.h.al = 0x13;
    	int86(0x10, &regs, &regs);
    }
    
    void exitMode13()
    {
    	union REGS regs;
    	regs.h.ah = 0x00;
    	regs.h.al = 0x03;
    	int86(0x10, &regs, &regs);
    }
    
    void plotPixel(int x, int y, byte color);
    
    int main()
    {
    	enterMode13();
    	plotPixel(0, 0, 5);
    	getch();
    	exitMode13();
    	
    	return 0;
    }
    
    void plotPixel(int x, int y, byte color)
    {
    	VGA[y*SCREEN_WIDTH+x] = color;
    }
    Why drink and drive when you can smoke and fly?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You don't have direct memory access on XP.
    Fakery of old systems for backward compatibility can only take you so far - obviously not far enough for what you want to do.

    Try getting dev-c++ (another port of gcc) and get the libsdl graphics package if you want to do graphics.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    I see, so there is NO way to access the video memory on XP?
    If I used linux (ubuntu) would I be able to directly access the memory?
    Why drink and drive when you can smoke and fly?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > NO way to access the video memory on XP?
    Use a graphics library (or write your own)
    Of course writing a graphics library which accesses video memory needs a lot more knowledge about the innards of the XP driver model than I know about.

    > would I be able to directly access the memory?
    Sure (it too has graphics and graphics libraries doesn't it?)
    Again, the driver model will be completely different.
    This is why libraries like OpenGL exist to hide all that awkward detail.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    Even direct pixel access using a graphics library/API is rather slow anyway

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You can access the memory directly in DJGPP but you must use farnspokeb and/or farnspoke(x) family of functions. XP does not allow you to map 0xA000 into your address space and therefore the old DJGPP near-pointer hack solution does not work anymore.

    This also applies to the LFB modes. You cannot extract the LFB address from the card using the near-pointer hack from the DOS/95/98 days.
    Last edited by VirtualAce; 10-17-2005 at 01:02 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 05-07-2009, 11:31 AM
  2. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  3. help with this
    By tyrantil in forum C Programming
    Replies: 18
    Last Post: 01-30-2005, 04:53 PM
  4. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  5. Dual Booting Win XP & Win 98
    By netboy in forum Tech Board
    Replies: 2
    Last Post: 08-18-2003, 02:29 AM