REDESIGN FOR X11

Instead of duplicating all of screen.c like I did for SDL, I want to just duplicate the hardware-specific code, and leave the code for updating the CGA back buffer in screen.c or a common file. This is more complicated than expected, as different modules need access to the same global variables.


Type name clashes

X11 defines a type called Screen, which clashes with CGALIB's screen. In order to get around this, all calls to X11 will have to be isolated into a wrapper module that knows nothing of CGALIB's own types. Attributes from the Screen variable must be passed through to the wrapper module as primitives (char, int and the like).


Organisation of the Modules

I propose three modules to support both CGA hardware and CGA emulation for X11. These are a CGA hardware module, and X11 emulation module, and a common screen module that handles the data structures that both need.

screen.c	Common screen module
screend.c	CGA hardware module
screenx.c	CGA emulation module for X11


Common Screen Module

This module handles the display list, records which screen is currently displayed, and all the graphics functions that interact with the back buffer.


CGA Hardware Module

This module controls the CGA screen hardware. It needs to access the display list, and check which screen is the currently displayed one. It need to determine whether the hardware is true CGA compatible, or whether it is being used with a Hercules screen. It needs to record hardware parameters (which are different for CGA and Hercules).


CGA Hardware Emulation for X11

This module handles the X11 screen (or an X11 window). It needs to access the display list, and check which screen is the currently displayed one. It needs to handle the opening and closing of the X11 display window, and it needs to relay updates to the X11 display.


Access to the Display List

A separate header, screen_u.h, should contain declarations for the screen display update functions. This shouldn't be automatically included with cgalib.h (or via screen.h), but should be included explicitly by screen hardware modules. This screen header should also define DislpayList as the hardware modules will need to access it to update the display.


Access to the Current Screen

There will be no access the the 'current' screen variable, as this is static within screen.c. Instead, a 'shown' attribute will have to be added to the Screen structure. One screen should not have access to the pointers to other screens, so instead a screen can set itself current by calling the show() method, or unset itself by calling a new hide() parameter.
