]> git.sur5r.net Git - cc65/blobdiff - src/sim65/chips/console.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / sim65 / chips / console.c
index ad520c5d49df1aacbe494bf5910313526594469b..526cc04f1c6966723e78fb93dcfc2b76d4a14fed 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003-2009, Ullrich von Bassewitz                                      */
+/* (C) 2003-2012, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -106,7 +106,7 @@ static const struct ChipData CData[] = {
         /* -- Exported functions -- */
         ScreenInitChip,
         ScreenCreateInstance,
-       ScreenDestroyInstance,
+        ScreenDestroyInstance,
         ScreenWrite,
         ScreenWrite,
         ScreenRead,
@@ -115,8 +115,14 @@ static const struct ChipData CData[] = {
 };
 
 /* Defines for console screen */
-static const XColor FgColor = {
-    0,  32*256, 141*256, 32*256, 0, 0          /* green */
+static const XColor GreenColor = {
+    0,  32*256, 141*256, 32*256, 0, 0           /* green */
+};
+static const XColor AmberColor = {
+    0,  255*256, 204*256, 51*256, 0, 0          /* amber */
+};
+static const XColor WhiteColor = {
+    0,  224*256, 224*256, 224*256, 0, 0         /* white */
 };
 static const XColor BgColor = {
     0,  0*256, 0*256, 0*256, 0, 0               /* black */
@@ -147,7 +153,7 @@ struct ScreenInstance {
     unsigned            Rows;
     unsigned            Cols;
 
-    /* Window dimensions, 384*288 (PAL) */
+    /* Window dimensions, determined by char resolution and char set */
     unsigned            XTotal;
     unsigned            YTotal;
 
@@ -263,6 +269,8 @@ static void* ScreenCreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
     XSizeHints  SizeHints;
     XWMHints    WMHints;
     Cursor      C;
+    unsigned    CharColor;
+
 
     /* Allocate the instance data */
     ScreenInstance* V = VScreen = Sim->Malloc (sizeof (ScreenInstance));
@@ -354,8 +362,15 @@ static void* ScreenCreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
         Sim->Error ("Screen: Need color display");
     }
 
+    /* Determine the character color */
+    CharColor = (unsigned) CfgGetNum (CfgInfo, "charcolor", 0, 2, 0);
+
     /* Get all needed colors */
-    V->FgColor = FgColor;
+    switch (CharColor) {
+        case 1:         V->FgColor = AmberColor;        break;
+        case 2:         V->FgColor = WhiteColor;        break;
+        default:        V->FgColor = GreenColor;        break;
+    }
     V->BgColor = BgColor;
     CM = DefaultColormap (V->ScreenDisplay, V->Screen);
     if (XAllocColor (V->ScreenDisplay, CM, &V->FgColor) == 0) {
@@ -410,7 +425,7 @@ static void* ScreenCreateInstance (unsigned Addr, unsigned Range, void* CfgInfo)
     XDefineCursor (V->ScreenDisplay, V->ScreenWindow, C);
 
     /* Select input events */
-    XSelectInput (V->ScreenDisplay, V->ScreenWindow, ExposureMask | StructureNotifyMask);
+    XSelectInput (V->ScreenDisplay, V->ScreenWindow, ExposureMask | StructureNotifyMask | KeyPressMask);
 
     /* Show the window */
     XMapRaised (V->ScreenDisplay, V->ScreenWindow);
@@ -609,7 +624,7 @@ static void ScreenEventLoop (void)
         switch (Event.type) {
 
             case Expose:
-               /* Calculate the area to redraw, then update the screen */
+                /* Calculate the area to redraw, then update the screen */
                 X1 = Event.xexpose.x;
                 Y1 = Event.xexpose.y;
                 X2 = Event.xexpose.x + Event.xexpose.width - 1;
@@ -626,6 +641,13 @@ static void ScreenEventLoop (void)
                 XRefreshKeyboardMapping (&Event.xmapping);
                 break;
 
+            case KeyPress:
+                break;
+
+            default:
+                /* Ignore anything else */
+                break;
+
         }
     }