Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

display_epoc32.i

Go to the documentation of this file.
00001 
00012 #define BOOL bool
00013 #include <eikon.rsg>
00014 
00015 
00016 // 0  black
00017 // 1  dark grey
00018 // 2  dark red
00019 // 3  (green)
00020 // 4  dark yellow/green
00021 // 5  light red
00022 // 6  light yellow
00023 // 7  light green
00024 // 8  pink
00025 // 9  dark blue   !!!!
00026 // a  cyan
00027 // b  purple
00028 // c  darker blue !!!!
00029 // d  green/blur ?
00030 // e  light grey
00031 // f  white!
00032 
00033 
00034 void C64Display::NewPrefs(Prefs *prefs)
00035         {
00036         colors_changed = TRUE;
00037         }
00038 
00039 
00040 void C64Display::ResetKeyboardState()
00041         {
00042         CE32FrodoAppUi* theAppUi = TheC64->iFrodoPtr->iDocPtr->iAppUiPtr;
00043         memset(theAppUi->keystate, 0, sizeof(theAppUi->keystate));
00044         memset(theAppUi->key_matrix, 0xff, sizeof(theAppUi->key_matrix));
00045         memset(theAppUi->rev_matrix, 0xff, sizeof(theAppUi->rev_matrix));
00046 //      joystate = 0xff;
00047         }
00048 
00049 
00050 bool C64Display::BuildColorTable()
00054         {
00055         ELOG1(_L8("building color table\n"));
00056 
00057         for (int j = 0; j < 16; j++)
00058 #if COLOR_DEPTH == 4
00059                 {
00060                 uint8 nib_right = TheC64->ThePrefs.ColorTbl[j] & 0x0f;
00061                 colors[j] = nib_right << 4 | nib_right;
00062                 }
00063 #elif COLOR_DEPTH == 8
00064                 colors[j] = TheC64->ThePrefs.ColorTbl[j];
00065 #elif
00066 error
00067 #endif
00068 
00069         // Replicate the physical colors into the rest of the color array.
00070         for (int k = 16; k < 256; k++)
00071                 colors[k] = colors[k & 0x0f];
00072 
00073         // Tell the VIC all about it;
00074 //      if (!in_constructor)
00075                 TheC64->TheVIC->ReInitColors();
00076 
00077         ELOG1(_L8("Dumping colors: (16 of them)\n"));
00078         ELOG(for(TInt l = 0; l < 16; l++){ )
00079                 ELOG3(_L8("[%d:%d] "), l, colors[l]);
00080                 ELOG(})
00081         ELOG1(_L8("\n"));
00082 
00083         return TRUE;
00084         }
00085 
00086 
00087 /*
00088 
00089 //
00090  *  Draw LED bar at the bottom of the window
00091  //
00092 
00093 void C64Display::draw_led_bar()
00094 {
00095 }
00096 
00097 //
00098  *  Draw one LED
00099  //
00100 
00101 void C64Display::draw_leds(BOOL force)
00102 {
00103 }
00104 
00105 void C64Display::led_rect(int n, RECT &rc, RECT &led)
00106 {
00107 }
00108 
00109 */
00110 
00111 
00112 
00113 C64Display::C64Display(C64 *the_c64) 
00114 
00117         :TheC64(the_c64)
00118          ,max_speed(0)
00119          ,colors_changed(TRUE)
00120          ,colors_depth(4)
00121         {
00122 
00123         __CHECK_NULL(the_c64);
00124 
00125 //      BuildColorTable();
00126         quit_requested=false;
00127 //      ResetKeyboardState();
00128 
00129         // view Toolbar or not
00130         TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->ViewToolbar(TheC64->ThePrefs.iShowToolbar);
00131 
00132         CTOR(C64Display);
00133         }
00134 
00135 
00136 C64Display::~C64Display()
00140         {
00141         DTOR(C64Display);
00142         }
00143 
00144 
00145 void C64Display::Speedometer(int speed)
00149         {
00150         if ((iSpeedCount++)%50)
00151                 return;
00152         
00153         // get peak speed
00154         if(speed > max_speed)
00155                 max_speed = speed;
00156 
00157         TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->iAppView->DrawSpeed(speed, max_speed);
00158         }
00159 
00160 
00161 uint8* C64Display::BitmapBase()
00165         {
00166 #ifndef __SYMBIAN32__
00167         static uint8 display[DISPLAY_X * DISPLAY_Y];
00168 #endif
00169 
00170 #if defined(__ER6__)
00171         return (uint8*)TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->iAppView->iMyScreenBuffer;
00172 #else
00173         return (uint8*)TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->iAppView->iTheBitMap.DataAddress();
00174 #endif
00175         }
00176 
00177 
00178 void C64Display::PollKeyboard(uint8 *CIA_key_matrix, uint8 *CIA_rev_matrix, uint8 *joystick)
00182         {
00183         CE32FrodoAppUi* theAppUi = TheC64->iFrodoPtr->iDocPtr->iAppUiPtr;
00184         memcpy(CIA_key_matrix, theAppUi->key_matrix, sizeof(theAppUi->key_matrix));
00185         memcpy(CIA_rev_matrix, theAppUi->rev_matrix, sizeof(theAppUi->rev_matrix));
00186 
00187         *joystick = (uint8)theAppUi->iJoyKey;
00188         }
00189 
00190 
00191 
00192 void C64Display::InitColors(uint8 *array)
00196         {
00197         if (colors_depth == 4)
00198                 {
00199                 for (int i = 0; i < 256; i++)
00200                         array[i] = (uint8)colors[i & 0x0f];
00201                 }
00202         else
00203                 {
00204                 for (int i = 0; i < 256; i++)
00205                         array[i] = TUint8(i & 0x0f);
00206                 }
00207         }
00208 
00209 
00210 void C64Display::Update()
00211         {
00212         if(colors_changed)
00213                 {
00214                 colors_changed = FALSE;
00215                 BuildColorTable();
00216                 ResetKeyboardState();
00217                 }
00218 
00219 #ifdef BACKGND_UPDATE
00220         TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->iAppView->DrawBuf(TheC64->TheVIC->ec_changed > 0);
00221 #else
00222         TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->iAppView->DrawBuf(true);
00223 #endif
00224 
00225     draw_leds(ETrue);
00226         }
00227 
00228 
00232 void C64Display::draw_leds(TBool force)
00233 {
00234     const TPoint ledpos(395, 190);
00235     const TInt ledgap(16);
00236 
00237         if (!force) {
00238                 int i;
00239                 for (i = 0; i < 4; i++) {
00240                         if (led_state[i] != old_led_state[i])
00241                                 break;
00242                 }
00243                 if (i == 4)
00244                         return;
00245         }
00246 
00247         for (int i = 0; i < 4; i++) {
00248         TheC64->iFrodoPtr->iDocPtr->iAppUiPtr->iAppView->DrawLed(ledpos+TPoint(i*ledgap,0), led_state[i]);
00249         }
00250 }
00251 
00252 #define MATRIX(a,b) (((a) << 3) | (b))
00253 
00254 
00255 int C64Display::VirtKey2C64(const TKeyEvent& aVirtKey, TUint8& aJoyKey)
00279         {
00280         int result = -1;
00281         const TUint modifiers = aVirtKey.iModifiers;
00282         TBool caps = modifiers & EModifierShift;
00283         const TBool func = modifiers & EModifierFunc;
00284 
00285         // improved keyboard handling
00286 
00287         TChar inChar = aVirtKey.iCode;
00288         inChar.UpperCase();
00289 
00290         //
00291         // iCode == 0 means that it's a modifier
00292         //
00293         if(aVirtKey.iCode == 0) // modifier
00294                 {
00295                 if( modifiers & EModifierLeftShift || modifiers & EModifierShift )
00296                     {
00297                         result = MATRIX(1,7);   // shift left
00298                     }
00299 
00300                 if( modifiers & EModifierLeftShift )
00301                     {
00302                         result = MATRIX(6,4);   // shift right
00303                     }
00304 
00305                 if( modifiers & EModifierLeftCtrl || modifiers & EModifierRightCtrl || modifiers & EModifierCtrl )
00306                     {
00307                         result = MATRIX(7,2);   // CTRL
00308                     }
00309                 }
00310         else                    // normal keys
00311                 switch (inChar)
00312                         {
00313 
00314         //
00315         // ORing the result with 0x80 means that Shift is also down in C64 world!
00316         //
00317 
00318                 // Function keys:
00319                 //
00320                 // F1 - Fn+A
00321                 // F2 - Fn+S
00322                 // F3 - Fn+D
00323                 // F4 - Fn+F
00324                 // F5 - Fn+G
00325                 // F6 - Fn+H
00326                 // F7 - Fn+J
00327                 // F8 - Fn+K
00328         
00329         //
00330         // Alphabet - if func is true, return F1-F8 for some letters
00331         //
00332         case 'A': result = func ? MATRIX(0,4) : MATRIX(1,2); break;
00333         case 'B': result = MATRIX(3,4); break;
00334         case 'C': result = MATRIX(2,4); break;
00335         case 'D': result = func ? MATRIX(0,5) : MATRIX(2,2); break;
00336         case 'E': result = MATRIX(1,6); break;
00337         case 'F': result = func ? MATRIX(0,5) | 0x80 : MATRIX(2,5); break;
00338         case 'G': result = func ? MATRIX(0,6) : MATRIX(3,2); break;
00339         case 'H': result = func ? MATRIX(0,6) | 0x80 : MATRIX(3,5); break;
00340         case 'I': result = MATRIX(4,1); break;
00341         case 'J': result = func ? MATRIX(0,3) : MATRIX(4,2); break;
00342         case 'K': result = func ? MATRIX(0,3) | 0x80 : MATRIX(4,5); break;
00343         case 'L': result = MATRIX(5,2); break;
00344         case 'M': result = MATRIX(4,4); break;
00345         case 'N': result = MATRIX(4,7); break;
00346         case 'O': result = MATRIX(4,6); break;
00347         case 'P': result = MATRIX(5,1); break;
00348         case 'Q': result = MATRIX(7,6); break;
00349         case 'R': result = MATRIX(2,1); break;
00350         case 'S': result = func ? MATRIX(0,4) | 0x80 : MATRIX(1,5); break;
00351         case 'T': result = MATRIX(2,6); break;
00352         case 'U': result = MATRIX(3,6); break;
00353         case 'V': result = MATRIX(3,7); break;
00354         case 'W': result = MATRIX(1,1); break;
00355         case 'X': result = MATRIX(2,7); break;
00356         case 'Y': result = MATRIX(3,1); break;
00357         case 'Z': result = MATRIX(1,4); break;
00358 
00359         // numeric
00360         case '0': result = MATRIX(4,3); break;
00361         case '1': result = MATRIX(7,0); break;
00362         case '2': result = MATRIX(7,3); break;
00363         case '3': result = MATRIX(1,0); break;
00364         case '4': result = MATRIX(1,3); break;
00365         case '5': result = MATRIX(2,0); break;
00366         case '6': result = MATRIX(2,3); break;
00367         case '7': result = MATRIX(3,0); break;
00368         case '8': result = MATRIX(3,3); break;
00369         case '9': result = MATRIX(4,0); break;
00370 
00371 
00373         case '+':       result = MATRIX(5,0); caps = EFalse; break;
00374         case '-':       result = MATRIX(5,3); break;    // ?
00375         case 0xa3:      result = MATRIX(6,0); caps = EFalse; break;
00376         case '=':       result = MATRIX(6,5); break;    // ?
00377         case '*':       result = MATRIX(6,1); caps = EFalse; break;
00378         case '@':       result = MATRIX(5,6); caps = EFalse; break;
00379         case '^':       result = MATRIX(6,6); caps = EFalse; break;     // arrow up sign (Fn+6)
00380         case '_':       result = MATRIX(7,1); break;    // arrow left sign (Fn+1)
00381         case ':':       result = MATRIX(5,5); caps = EFalse; break;     // colon
00382         case ';':       result = MATRIX(6,2); break;    // semicolon
00383         case '.':       result = MATRIX(5,4); break;    // dot
00384         case ',':       result = MATRIX(5,7); break;    // comma
00385         case '/':       result = MATRIX(6,7); caps = EFalse; break;     // slash
00386 
00387         case EKeyHome:  result = MATRIX(6,3); break;
00388         case 0x08:              result = MATRIX(0,0); break;    // DELete key
00389         case EKeyEscape:result = MATRIX(7,7); break;    // Escape -> RunStop key
00390         case EKeyEnter: result = MATRIX(0,1); break;    // Return
00391 
00392         // direction keys
00393         case EKeyUpArrow:
00394                 result = MATRIX(0,7) | 0x80; 
00395                 break;
00396         case EKeyDownArrow:             
00397                 result = MATRIX(0,7); 
00398                 break;
00399         case EKeyLeftArrow:
00400                 result = MATRIX(0,2) | 0x80;
00401                 break;
00402         case EKeyRightArrow:
00403                 result = MATRIX(0,2);
00404                 break;
00405         case ' ': // space
00406                 result = MATRIX(7,4); 
00407                 break;
00408 
00409         // control keys
00410         case EKeyRightShift:    result = MATRIX(6,4); break;    // shift right
00411         case EKeyLeftShift:             result = MATRIX(1,7); break;    // shift left
00412         case EKeyLeftCtrl:
00413         case EKeyRightCtrl:             result = MATRIX(7,2); break;    // CTRL key
00414         case EKeyTab:                   result = MATRIX(7,5); break;    // Commodore key
00415 
00416         // function keys (F1-F8)
00417         // NB! This is for WINS and future versions only
00418         case EKeyF1: result = MATRIX(0,4); break;
00419         case EKeyF2: result = MATRIX(0,4) | 0x80; break; 
00420         case EKeyF3: result = MATRIX(0,5); break;
00421         case EKeyF4: result = MATRIX(0,5) | 0x80; break;
00422         case EKeyF5: result = MATRIX(0,6); break;
00423         case EKeyF6: result = MATRIX(0,6) | 0x80; break;
00424         case EKeyF7: result = MATRIX(0,3); break;
00425         case EKeyF8: result = MATRIX(0,3) | 0x80; break;
00426 
00428 
00429         case '!':       result = MATRIX(7,0) | 0x80; break;
00430         case '\"':      result = MATRIX(7,3) | 0x80; break;
00431         case '#':       result = MATRIX(1,0) | 0x80; break;
00432         case '$':       result = MATRIX(1,3) | 0x80; break;
00433         case '%':       result = MATRIX(2,0) | 0x80; break;
00434         case '&':       result = MATRIX(2,3) | 0x80; break;
00435         case '\'':      result = MATRIX(3,0) | 0x80; break;
00436         case '(':       result = MATRIX(3,3) | 0x80; break;
00437         case ')':       result = MATRIX(4,0) | 0x80; break;
00438 //      case '0':       result = MATRIX(4,3) | 0x80; break;     //Shift+Zero is nothing...
00439 
00440         case '[':       result = MATRIX(5,5) | 0x80; break;     // Shift+colon
00441         case ']':       result = MATRIX(6,2) | 0x80; break;     // Shift+semicolon
00442         case '<':       result = MATRIX(5,7) | 0x80; break;     // Shift+comma
00443         case '>':       result = MATRIX(5,4) | 0x80; break;     // Shift+dot
00444 
00445         case '?':       result = MATRIX(6,7) | 0x80; break;     // Shift+slash
00446 
00447 
00449 
00450         case '{':       
00451         case '}':       
00452         case '~':       
00453         case '\\':      
00454                 return -1;
00455 
00456         default:
00457                 ELOG3(_L8("Unknown Key [code=0x%08x, scan=0x%08x]"), aVirtKey.iCode, aVirtKey.iScanCode);
00458                 break;
00459         }
00460 
00461         // Shift modifier
00462         if (result != -1 && caps)
00463                 result |= 0x80;
00464 
00465         return result;
00466 
00467         } // end, C64Display::VirtKey2C64
00468 
00469 
00470 long int ShowRequester(char *a,char *b,char *)
00474         {
00475     TBuf8<32> a8;
00476     TBuf8<32> b8;
00477         ELOG3(_L8("ShowRequester: %S %S"), &a8, &b8);
00478         TBuf<32> _a;
00479         _a.Copy(a8);
00480         TBuf<32> _b;
00481         _b.Copy(b8);
00482 
00483         CEikInfoDialog* info = new CEikInfoDialog(_a, _b);
00484         if(info)
00485                 {
00486                 TRAPD(ret, info->ExecuteLD(R_EIK_DIALOG_INFO));
00487                 if(ret != KErrNone)
00488                         {
00489                         ELOG2(_L8("hmm. ExecuteLD returned %d"), ret);
00490                         }
00491                 }
00492         else
00493                 {
00494                 ELOG1(_L8("hmm. could not create CEikInfoDialog"));
00495                 }
00496 
00497         return 1;
00498         }
00499 
00500 
00501 int C64Display::BitmapXMod() const
00505         {
00506         return DISPLAY_X;
00507         }
00508 
00509 
00510 // EOF - display_epoc32.i

Generated on Tue Feb 8 04:07:48 2005 for E32frodo by doxygen 1.3.3