Advertisement Jump to content


This topic is now archived and is closed to further replies.


Mode 13 io stream and memory problems

This topic is 5364 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use Borland C++ v5.02 My mode 13 programs quit with an abnormal termination error if I use any io stream (like fstream) after I initialise Mode 13.Can anybody point a work around[Now dont say do it before mode 13, i want to do it afterwards]. Or anyway to read a file after entring mode 13(C++ not C please). Specifically I want to use fstream after entring mode 13 but currently that causes the program to crash!!. I am working on a game(snake) with unlimited multiplayer support where users can use the keyboard keys to make their controls(4 up,down,left,right). I also have major memory allocation problems.If I use the NEW operator a couple of times after mode 13 the program just locks up.I sure need this fixed even more the file reading.It's causing a delay in my game development.I really need help on this. For memory I load it before I get into mode13, into a linked list and pop it when needed. If you anybody wants to see the game(v0.5a) check but it only has two player controls by default.(just modify the .cfg files to add more controllers and players.use the following for that but all these key maps will be loaded into memory at all times.)
const char conf_file[]={"config.cfg"};
const char keys_file[]={"keys.cfg"};

struct conf
    int speed;
    int max_pnts;
    int players;
    int max_map;

struct key_map
    int up;
    int dn;
    int lf;
    int rt;
    key_map *next;

conf mconf;
key_map mkeys;

void add_key(key_map m)
  fstream f;,ios::app|ios::out);

  mconf.players += 1;

  cout<<"\nAdd Key Map:"< 

[edited by - FireNet on May 8, 2004 1:27:25 PM]   


Share this post

Link to post
Share on other sites
Im assuming you mean mode 13h and 16 bit DOS?

If you''re running in real mode, you might try using the DOS 21h file io functions instead of using streams.

As for memory allocation, you might need to reallocate your code segment to leave room for other things. IIRC in DOS, the executable is given the largest free chunk of memory. Or try using the _fmalloc function instead of new.

Share this post

Link to post
Share on other sites
Hi , I have BC++5.02 as well. I tested the code below and it worked without problems. My suggestion is to check that you are not corrupting the stack or heap. Use your basic app skeleton and add code until fstream and new do not work.

#include <iostream>
#include <fstream>
void cScreen::SetVGAMode(int mode)
//asm mov ax,mode
//asm int 0x10
regs.r_ax = mode;
gMode = mode;
key_map m;
fstream f;"hello.txt",ios::app|ios::out);

for( int i = 0;i < 100;i++)
int *s = new int;
delete s;
char* zz = new char[34];
delete []zz;

EDIT: changed tag type

[edited by - Jack Sotac on May 8, 2004 11:55:21 PM]

Share this post

Link to post
Share on other sites
Hi ya,

Yes mode13h in dos(standard) with class library and floating point support.The new operator or anything to allocate memmory works for sometime then the program locks up.10 time to be exact.

To:Jack Sotac
I dont think I am corrupting the stack or heap.The game currently starts in the following procedure:
1.Main() declares a number of variable(int).
2.loads the config.cfg file int a structure(fstream).
3.Copies this into appropriate global or local variables.
4.Declares a new snake head (an arrray with size as found in config.cfg)
5.Loads memory into linked list for snake units and for keymaps.
6.Loads the key maps from the file.

[All values are as in the .cfg files].
The linked list class can handle any type of data from strings to structes and classes.I wrote this for another project and this works quite well.

7.Enters mode 13
8.Calls the menu().//this allows all the choosing an returns a value.
9.Initializes all neccesary values and starts the game.

I will be putting up the source on my site.

[edited by - FireNet on May 9, 2004 2:42:43 AM]

Share this post

Link to post
Share on other sites
Ok,I am re-writing the entire vga header and changing much of the
drawing funtions.Upto right now the vga header works fine with everything.[Lines,boxes,circle,fstream,text is now there].I also
will be making a lot of changes to the game engine.The new header
is beig made from collections for a couple of sites and my own

The new stuff I wrote can only do the stuff I mentioned above at
present.The link to the old working code (the one which causes
problems during i/o streams and new) is:

Somebody check it out and tell me whats was worng with my code
as I got no resonable clue.We all can learn from mistakes.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!