Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Problems when switching BP7.0 real mode to protected mode

  1. #1

    Problems when switching BP7.0 real mode to protected mode

    System: Windows 98SE, AMD K6, 124 MB RAM
    Compiler/IDE: Borland Pascal 7.0 Protected Mode
    Libraries: None

    ---

    Hello all,

    I've been working on a game for over a year now and am getting close to completion. However, I've run in to some serious problems. During programming in real mode I've had the game split in two separate programs, that have both functioned perfectly. Now I needed to join these two separate programs to one. I quickly discovered that combined, these two programs took up too much memory and wouldn't compile in real mode. So I switched to protected mode. After installing a new mouse unit that functioned in protected mode, I managed to compile the game, but I keep getting runtime errors, especially the 216 error. I really can't figure out what I'm doing wrong, especially since the two programs ran perfectly in protected mode when they were separate, but now when I'm calling these two programs (now just units) from the main game program, they don't work and crash.

    I got some strange results from some of my arrays (the contents of the strings of the arrays would change when the game loop was running, even though nothing in the game loop should alter them!), but when I changed that particular array to a pointer that was allocated with New() and Dispose(), those strange results disappeared. So, I tried to change some other arrays that were behaving strangely, but then I couldn't get the program to run at all.

    I'm dumbfounded as to what is causing these errors, as I'm pretty sure I'm allocating everything properly -- and both programs worked when running separately!

    Any ideas what's going on? I'm just about to lose my mind here...

    PS. The game is a console program using only ASCII 'graphics'.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  2. #2

    Problems when switching BP7.0 real mode to protected mode

    Enabled range checking, overflow checking etc. and generate a stack backtrace. That should give an idea as to where the bug is.

  3. #3

    Problems when switching BP7.0 real mode to protected mode

    Yeah, I'm getting some new errors with range checking and overflow checking enabled, so I'll have to figure out what's causing them.

    As to generating a stack backtrace... how do I do this? After some googling I can see that Free Pascal has the two units 'lineinfo' and 'heaptrc' which help with localizing runtime errors in the source code. Does BP7.0 have anything similar? I'm not that experienced with programming and memory addressing, so the memory addresses given with a runtime error is pretty much gibberish to me... and sadly BP7.0 doesn't pinpoint the place of an error in your code in Protected Mode like it does in Real Mode.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  4. #4

    Problems when switching BP7.0 real mode to protected mode

    I've tried to get parts of my program to run in real mode and then enable range and overflow checking to get BP7.0 to pinpoint where the problems are, but I'm getting errors I can't figure out. For example, the below code excerpt sometimes returns an Error 215: Arithmetic overflow.

    The variables X and Y are both Words:

    [pascal]IF (X > 50) AND (Y > 50) AND (X < 50000) AND (Y < 50000) THEN BEGIN
    X := X + (20 - Random(40));
    Y := Y + (20 - Random(40));
    END;
    [/pascal]

    I really don't understand how this could cause an error, since the values assigned to X and Y will always be within the range of a Word.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Problems when switching BP7.0 real mode to protected mode

    You are probably seeing this coming a mile away, but why are you trying to use BP7? Any reason not to switch to using Free Pascal?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  6. #6

    Problems when switching BP7.0 real mode to protected mode

    Yeah, I was kinda expecting this question to pop up...

    I wouldn't exactly say that I'm trying to use BP7.0 since I've been programming with that for some years now and have been working on the program in question for more than a year (and was close to completion when I had to switch to Protected Mode and ran into a hornet's nest of runtime errors).

    Quite a few units I'm using in my program I've found on the internet and I couldn't get them to run in Free Pascal (such as the GAMES.PAS unit, which allows reading multiple and simultaneous keypresses), so I decided to program it in BP7.0 and stick with what I know.
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  7. #7

    Problems when switching BP7.0 real mode to protected mode

    I've gathered up my code in a zip file and written a short description of the game and the various PAS files. If any kind soul would take a look at it and hopefully tell me where the bugs are, I would be forever in his/her debt!
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

  8. #8

    Problems when switching BP7.0 real mode to protected mode

    Quote Originally Posted by PP2005
    As to generating a stack backtrace... how do I do this?
    Press ctrl+F3 when the range check error appears.

  9. #9

    Problems when switching BP7.0 real mode to protected mode

    Quote Originally Posted by PP2005
    I really don't understand how this could cause an error, since the values assigned to X and Y will always be within the range of a Word.
    Check the intermediate results 20 - random(40) can go below zero, which can cause problems if you mix it with a word. It is probably something like this. Split the expression up in smaller parts, this should give a clue.

  10. #10

    Problems when switching BP7.0 real mode to protected mode

    Quote Originally Posted by dmantione
    Quote Originally Posted by PP2005
    I really don't understand how this could cause an error, since the values assigned to X and Y will always be within the range of a Word.
    Check the intermediate results 20 - random(40) can go below zero, which can cause problems if you mix it with a word. It is probably something like this. Split the expression up in smaller parts, this should give a clue.
    But in the code excerpt I'm making sure that the X and Y values are both higher than 50. Since the lowest value of "20 - Random(40)" is -19, how can this be a problem? 50 - 19 is well within the range of a Word. Is it just that BP7.0 doesn't like mixing Words with arithmetic operations that can go below zero?
    Laserbrain Studios - Currently developing Hidden Asset!
    Ascii Sector
    - Real-time roguelike in space!

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •