[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bochs-cvs
Subject:    [Bochs-cvs] CVS: bochs/gui carbon.cc,1.33,1.34
From:       Stanislav Shwartsman <sshwarts () users ! sourceforge ! net>
Date:       2007-03-23 8:30:25
Message-ID: E1HUfAH-0003q9-CS () sc8-pr-cvs3 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/bochs/bochs/gui
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14326

Modified Files:
	carbon.cc 
Log Message:
Merged Carbon GUI patch by Dave Poirier


Index: carbon.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/gui/carbon.cc,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- carbon.cc	8 Aug 2006 17:10:30 -0000	1.33
+++ carbon.cc	23 Mar 2007 08:30:22 -0000	1.34
@@ -1,4 +1,4 @@
-/////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
 // $Id$
 /////////////////////////////////////////////////////////////////////////
 //
@@ -108,8 +108,8 @@
 #define SLEEP_TIME  0 // Number of ticks to surrender the processor during a WaitNextEvent()
 // Change this to 15 or higher if you don't want Bochs to hog the processor!
 
-#define FONT_WIDTH    8
-#define FONT_HEIGHT  16
+int font_width;
+int font_height;
 
 #define WINBITMAP(w)  GetPortBitMapForCopyBits(GetWindowPort(w))  //  (((GrafPtr)(w))->portBits)
 
@@ -208,7 +208,7 @@
 void CreateMenus(void);
 void CreateWindows(void);
 void CreateKeyMap(void);
-void CreateVGAFont(void);
+void CreateVGAFont(unsigned char *vga_charmap);
 BitMap *CreateBitMap(unsigned width,  unsigned height);
 PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
                           unsigned height, unsigned depth, CTabHandle clut);
@@ -246,7 +246,7 @@
 
   theCommandID = commandStruct.commandID;
   
-  if(theCommandID < toolPixMaps ) {
+  if(theCommandID < toolPixMaps) {
     bx_tool_pixmap[theCommandID].f();
   }
   
@@ -289,10 +289,11 @@
   GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32,
                      NULL, sizeof(UInt32), NULL, &keyModifiers);
 
-//  if (!IsWindowActive(win))
-//  {
+//if (!IsWindowActive(win))
+//{
 //    SelectWindow(win);
-//  }
+//}
+
   if (keyModifiers & cmdKey)
     mouse_button_state |= 0x02;
   else
@@ -808,10 +809,15 @@
 
 void bx_carbon_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned tileheight,
   unsigned headerbar_y)
-{ 
+{
+  int i;
+
   put("MGUI");
   InitToolbox();
-  
+
+  font_width = 8;
+  font_height = 16;
+
   gheaderbar_y = headerbar_y + TOOL_MARGIN_SPACE + TOOL_MARGIN_SPACE;
   
   CreateKeyMap();
@@ -819,11 +825,13 @@
   gCTable = GetCTable(128);
   BX_ASSERT (gCTable != NULL);
   CTabChanged(gCTable); //(*gCTable)->ctSeed = GetCTSeed(); 
-  SetRect(&srcTextRect, 0, 0, FONT_WIDTH, FONT_HEIGHT);
   SetRect(&srcTileRect, 0, 0, tilewidth, tileheight);
-  
+
+  for(i=0; i<256; i++) {
+    vgafont[i] = NULL;
+  }
   CreateMenus();
-  CreateVGAFont();
+  CreateVGAFont(vga_charmap);
   CreateTile();
   CreateWindows();
   
@@ -861,7 +869,7 @@
 {
   UInt32    key;
   UInt32    trans;
-  OSStatus    status;
+  OSStatus  status;
   UInt32    modifiers;
   
   static UInt32 transState = 0;
@@ -1161,6 +1169,11 @@
   OSErr         theError;
   
   screen_state = TEXT_MODE;
+
+  if( charmap_updated == 1 ) {
+    CreateVGAFont(vga_charmap);
+    charmap_updated = 0;
+  }
   
 /*  if (gOffWorld != NULL) //(SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get ())
   {
@@ -1172,7 +1185,7 @@
   
   SetPortWindowPort(win);
 
-  ncols = width/8;
+  ncols = width/font_width;
 
   //current cursor position
   cursori = (cursor_y*ncols + cursor_x)*2;
@@ -1182,15 +1195,15 @@
   
   for (i=0; i<nchars*2; i+=2)
   {
-    if ( i == cursori || i == previ || new_text[i] != old_text[i] || new_text[i+1] != old_text[i+1])
+    if (i == cursori || i == previ || new_text[i] != old_text[i] || new_text[i+1] != old_text[i+1])
     {
       achar = new_text[i];
       
-//      fgColor = (**gCTable).ctTable[new_text[i+1] & 0x0F].rgb;
-//      bgColor = (**gCTable).ctTable[(new_text[i+1] & 0xF0) >> 4].rgb;
+//    fgColor = (**gCTable).ctTable[new_text[i+1] & 0x0F].rgb;
+//    bgColor = (**gCTable).ctTable[(new_text[i+1] & 0xF0) >> 4].rgb;
       
-//      RGBForeColor(&fgColor);
-//      RGBBackColor(&bgColor);
+//    RGBForeColor(&fgColor);
+//    RGBBackColor(&bgColor);
       
       if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
       {
@@ -1205,17 +1218,18 @@
         RGBForeColor(&fgColor);
         RGBBackColor(&bgColor);
       }
-      
-      x = ((i/2) % ncols)*FONT_WIDTH;
-      y = ((i/2) / ncols)*FONT_HEIGHT;
+
+      x = ((i/2) % ncols)*font_width;
+      y = ((i/2) / ncols)*font_height;
 
       SetRect(&destRect, x, y,
-        x+FONT_WIDTH, y+FONT_HEIGHT);
+        x+font_width, y+font_height);
         
       CopyBits( vgafont[achar], WINBITMAP(win),
         &srcTextRect, &destRect, srcCopy, NULL);
-  if ((theError = QDError()) != noErr)
-    BX_ERROR(("mac: CopyBits returned %hd", theError));
+
+      if ((theError = QDError()) != noErr)
+        BX_ERROR(("mac: CopyBits returned %hd", theError));
 
       if (i == cursori)   //invert the current cursor block
       {
@@ -1235,8 +1249,7 @@
   windowUpdatesPending = true;
 }
 
-  int
-bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
+int bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
 {
   ScrapRef         theScrap;
   ScrapFlavorFlags theScrapFlags;
@@ -1263,8 +1276,7 @@
   return (err == noErr);
 }
 
-  int
-bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
+int bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
 {
   ScrapRef theScrap;
   
@@ -1433,14 +1445,15 @@
     vga_bpp = bpp;
     CreateTile();
   }
+
   if (fheight > 0) {
-    if (fwidth != 8) {
-      x = x * 8 / fwidth;
-    }
-    if (fheight != 16) {
-      y = y * 16 / fheight;
+    if( fwidth != font_width || fheight != font_height ) {
+       font_width = fwidth;
+       font_height = fheight;
+       CreateVGAFont(vga_charmap);
     }
   }
+
   if (x != width || y != height)
   {
 #if 1
@@ -1495,7 +1508,7 @@
   long row_bytes, bytecount;
   
   bx_cicn[numPixMaps] = GetCIcon(numPixMaps+128);
-  BX_ASSERT(bx_cicn[numPixMaps]);
+//  BX_ASSERT(bx_cicn[numPixMaps]);
   
   numPixMaps++;
 
@@ -1524,8 +1537,8 @@
   
   toolPixMaps++;
   hb_index = toolPixMaps-1;
-//  bx_tool_pixmap[hb_index].pm = bx_pixmap[bmap_id];
-//  bx_tool_pixmap[hb_index].cicn = bx_cicn[bmap_id];
+//bx_tool_pixmap[hb_index].pm = bx_pixmap[bmap_id];
+//bx_tool_pixmap[hb_index].cicn = bx_cicn[bmap_id];
   bx_tool_pixmap[hb_index].alignment = alignment;
   bx_tool_pixmap[hb_index].f = f;
 
@@ -1533,13 +1546,13 @@
   {
     bx_tool_pixmap[hb_index].xorigin = bx_bitmap_left_xorigin;
     bx_tool_pixmap[hb_index].yorigin = TOOL_MARGIN_SPACE;
-//    bx_bitmap_left_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
+//  bx_bitmap_left_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
     bx_bitmap_left_xorigin += 32 + TOOL_SPACING;
     xorigin = bx_tool_pixmap[hb_index].xorigin;
   }
   else
   {
-//    bx_bitmap_right_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
+//  bx_bitmap_right_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
     bx_bitmap_right_xorigin += 32;
     bx_tool_pixmap[hb_index].xorigin = bx_bitmap_right_xorigin;
     bx_tool_pixmap[hb_index].yorigin = TOOL_MARGIN_SPACE;
@@ -1585,8 +1598,8 @@
 
 void bx_carbon_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
 {
-//  bx_tool_pixmap[hbar_id].pm = bx_pixmap[bmap_id];
-//  bx_tool_pixmap[hbar_id].cicn = bx_cicn[bmap_id];
+//bx_tool_pixmap[hbar_id].pm = bx_pixmap[bmap_id];
+//bx_tool_pixmap[hbar_id].cicn = bx_cicn[bmap_id];
   ControlButtonContentInfo info;
 
   info.contentType = kControlContentCIconHandle;
@@ -1974,24 +1987,27 @@
 //
 // Create an array of PixMaps for the PC screen font
 
-void CreateVGAFont(void)
+void CreateVGAFont(unsigned char *vga_charmap)
 {
   int i, x;
   unsigned char *fontData, curPixel;
   long row_bytes, bytecount;
-  
+
+  SetRect(&srcTextRect, 0, 0, font_width, font_height);
   for (i=0; i<256; i++)
   {
-    vgafont[i] = CreateBitMap(FONT_WIDTH, FONT_HEIGHT);
+    if(vgafont[i] != NULL) free(vgafont[i]);
+    vgafont[i] = CreateBitMap(font_width, font_height);
     row_bytes = (*(vgafont[i])).rowBytes;
-    bytecount = row_bytes * FONT_HEIGHT;
+    bytecount = row_bytes * font_height;
     fontData = (unsigned char *)NewPtrClear(bytecount);
 
-    for (x=0; x<16; x++)
+    for (x=0; x<font_height; x++)
     {
       //curPixel = ~(bx_vgafont[i].data[x]);
-      curPixel = (bx_vgafont[i].data[x]);
-      fontData[x*row_bytes] = reverse_bitorder(curPixel);
+                        curPixel = (vga_charmap[(i*32) + x]);
+      fontData[x*row_bytes] = curPixel;
+                        fontData[x*row_bytes + 1] = curPixel << 7;
     }
     vgafont[i]->baseAddr = Ptr(fontData);
   }
@@ -2021,7 +2037,7 @@
 // CreatePixMap()
 // Allocate a new pixmap handle and fill in the fields with appropriate
 // values.
-
+/*
 PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
   unsigned height, unsigned depth, CTabHandle clut)
 {
@@ -2045,7 +2061,7 @@
   // use one we created earlier.
     
   return pm;
-}
+}*/
 
 unsigned char reverse_bitorder(unsigned char b)
 {
@@ -2080,7 +2096,7 @@
 {
   event->retcode = 0;  // default return code
   
-  if( event->type == BX_ASYNC_EVT_LOG_MSG || event->type == BX_SYNC_EVT_LOG_ASK)
+  if(event->type == BX_ASYNC_EVT_LOG_MSG || event->type == BX_SYNC_EVT_LOG_ASK)
   {
     DialogRef                     alertDialog;
     CFStringRef                   title;


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bochs-cvs mailing list
Bochs-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bochs-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic