alberthrocks

SDLWabbitemu LCD Draw Source

Dec 29th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.18 KB | None | 0 0
  1. // gui_sdl.c
  2. // Set up lcdsurface
  3.     SDL_PixelFormat* pxlformat;
  4.     int w = 128;
  5.     int h = 64;
  6.     pxlformat=screen->format;
  7.     lcdsurface = SDL_CreateRGBSurface(SDL_SRCALPHA|SDL_SRCCOLORKEY|SDL_SWSURFACE,
  8.             w,
  9.             h,
  10.             pxlformat->BitsPerPixel,
  11.             pxlformat->Rmask,
  12.             pxlformat->Gmask,
  13.             pxlformat->Bmask,
  14.             pxlformat->Amask);
  15.  
  16. // guilcd_sdl.c
  17. void PaintLCD()
  18. {
  19.     printf_d("[SDLWabbitemu] [PaintLCD] Function called!\n");
  20.     unsigned char *thescreen;
  21.     LCD_t *lcd = lpCalc->cpu.pio.lcd;
  22.     //wxSize rc = this->mainFrame->GetClientSize();
  23.         int scale = lpCalc->scale;
  24.     int draw_width = lcd->width * scale;
  25.     int draw_height = 64 * scale;
  26.     //wxPoint drawPoint((rc.GetWidth() - draw_width) / 2, 0);
  27.     if (lpCalc->SkinEnabled) {
  28.         //drawPoint.x = lpCalc->LCDRect.GetX();
  29.         //drawPoint.y = lpCalc->LCDRect.GetY();
  30.     }
  31.     //wxMemoryDC wxMemDC;
  32.     if (lcd->active == false) {
  33.         unsigned char lcd_data[128*64];
  34.         memset(lcd_data, 0, sizeof(lcd_data));
  35.         unsigned char rgb_data[128*64*3];
  36.         int i, j;
  37.         for (i = j = 0; i < 128*64; i++, j+=3) {
  38.             rgb_data[j] = redColors[lcd_data[i]];
  39.             rgb_data[j+1] = greenColors[lcd_data[i]];
  40.             rgb_data[j+2] = blueColors[lcd_data[i]];
  41.         }
  42.         /*wxImage screenImage(128, 64, rgb_data, true);
  43.         wxBitmap bmpBuf(screenImage.Scale(128 * scale, 64 * scale).Size(rc, wxPoint(0,0)));
  44.         wxMemDC.SelectObject(bmpBuf);
  45.         //copy to the screen
  46.         wxDCDest->Blit(drawPoint.x, drawPoint.y, draw_width, draw_height, &wxMemDC, 0, 0);
  47.         wxMemDC.SelectObject(wxNullBitmap);*/
  48.         lcdsurface->pixels = rgb_data;
  49.  
  50.     } else {
  51.         thescreen = LCD_image( lpCalc->cpu.pio.lcd ) ;
  52.         unsigned char rgb_data[128*64*3];
  53.         int i, j;
  54.         for (i = j = 0; i < 128*64; i++, j+=3) {
  55.             rgb_data[j] = redColors[thescreen[i]];
  56.             rgb_data[j+1] = greenColors[thescreen[i]];
  57.             rgb_data[j+2] = blueColors[thescreen[i]];
  58.         }
  59.        
  60.         /*wxImage screenImage(128, 64, rgb_data, true);
  61.         wxBitmap bmpBuf(screenImage.Scale(128 * scale, 64 * scale).Size(rc, wxPoint(0,0)));
  62.         wxMemDC.SelectObject(bmpBuf);
  63.        
  64.         //finally copy up the screen image
  65.         wxDCDest->Blit(drawPoint.x, drawPoint.y, draw_width, draw_height, &wxMemDC, 0, 0);
  66.         wxMemDC.SelectObject(wxNullBitmap);*/
  67.         lcdsurface->pixels = rgb_data;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment