Some questions..

Search this archive.

From: Turgut Hakki Ozdemir (extronus@bigfoot.com)
Date: Tue 16 Jan 2001 - 09:26:44 IST


 zELAm,

   I'm working on a game-sdk for myself (I'm unsure but i may release it 
later) I have two important goals for that lib. A very clean API and High 
level portability. An application developed using this library under Linux 
must be compiled another os (eg windows) without changing one line of code.

  This library is a layer between the OS and developer. (Think it is a 
virtual operating system :)) To achieve the goal of that portability level 
i've made the library very modular manner. With an exception of some basic 
functions like error handlers, module loader, network manger etc.. (I call 
them as kernel) all code of the library is dynamic (Drivers) and the 
application is able to load/unload and load again them runtime.

  A schema of the library can be drawed like this

                          (Kernel)
                             |
                          (Console) (This and below are modules!)
                             |
        +----------+--------------+----------------+
        |          |              |                |
    (Graphics)   (Sound)   (Non-Keyboard Input)  (More)
    (Display)    (Voice)   (Mouse)
    (2d)         (Music)   (Joystick)
    (3d)         etc..     etc...
    etc...

 Now I'm coming to svgalib related part.

 As i said before the library sets a level between OS and Developer. Our 
application will never need to know where it is running. :) Under Linux 
there is two "Environments" for games. First is the Console and second is 
the X-Window System.

 The ConsoleSystem is exist for handling keyboard input, managing VT/Window 
switching, and doing some kind of "housing" for remaining modules. For 
example: SvgalibDisplayModule runs under Linux/Console ConsoleModule and 
X-Display module runs under X-Console module.

 There is some problems with SVGALIB under "Linux/Console" environment due 
the nature of both libraries. My library (I call it Ghargharhannath) is able
to handle all the important signals (SIGSEGV, SIGFPE, SIGPIPE etc...) and 
convert them internal errors or signals. The ConsoleModule for 
"Linux/Console" currently does VT switching, etc work perfectly.

 The problems are :
   * VT Switching battle!
   * Glued signal handlers!
   * Detonation of atexit() bomb!
   * Lacking of a windows port! (Please don't kill me! 90 percent of     
gamers uses windows theese days :))

 By the nature of Ghargharhannath, ConsoleModule gets rid of VT switching 
problem automatically (Shortly by installing VT switch signals and handlers 
after initializing Svgalib) But I don't know how it is legal... (It looks 
like working fine)

 Signal handlers: I must prevent svgalib from handling some signals. If they
handled by svgalib first i cannot stop some unwanted results from occuring.

 I've tried to do that like this in SvgalibDisplayModule:

    SaveCurrentHandlers();
    PreInitializeSvgaLib() {vga_init(); etc..}
    RestoreHandlers();

    OpenDisplay() {vga_setmode(GRAPH); etc..}
    RestoreHandlers();

    GoBackground(vga_setmode(TEXT); etc..}
    RestoreHandlers();

    GoForeground(vga_setmode(GRAPH); etc..}
    RestoreHandlers();

    bablalbalal....

 In theory, this must work! But it isn't looks too much stable.
 When i raise SIGSEGV, SIGPIPE etc.. the result is like there is no signal 
handlers installed at all!

 ---Like this!---
 int main()
 {
   raise(SIGSEGV);
 }
 ----------------

 How can i prevent svgalib from installing handlers or how can i clear them?

 Finally the atexit(); bomb! :)
  Here i must prevent svgalib from installing atexit(); function. Since the 
module which svgalib linked with is dynamic. (svgalibdisplay.mod.so)

  During the initialization of svgalib, it installs that handler with 
application's atexit(); queue but when application closes display, 
Ghargharhannath unloads display module (and svgalib) from memory. :)) This 
causes a pretty "Segmentation fault" message after programs exit :) I know 
it's not too much important and it looks like a joke more than a real one 
but it's a REAL segv...

 Please help me. Under linux, i have started with svgalib (It's my first) 
and i don't want to drop svgalib support...

 ps: It's 5.30 here in Turkiye currently (Do not look message time it's 
wrong) and ..gulp!..gulp! a few minutes b... gulp! earthquake... ! gulp! tv 
says it is 4.2 gulp! a few kilometers from me! gulp! help! gulp! still 
shaking me! gulp! fear! gulp!

 eXtronuS
 ... svgaquakegulp!

------------------------------------------------------------------
Unsubscribe:  To:   listbot@svgalib.org
              Body: unsubscribe linux-svgalib


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST