Exemplo n.º 1
0
  void init()
  {
    if( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) <0 )
      {
        printf("Unable to init SDL: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
      }
    atexit(SDL_Quit);

    screen = SDL_SetVideoMode(640, 480, 0,
                              SDL_HWSURFACE|SDL_DOUBLEBUF);

    if ( screen == NULL )
      {
        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
      }

    SDL_Rect rect;
    rect.x = 0;
    rect.y = 0;
    rect.w = 640;
    rect.h = 480;

    SDL_SetClipRect(screen, &rect);

    {
      //SDL_Surface* temp = TTY_CreateRGBSurface(font8x12);
      const char* font_file = "c64_16x16.png";
      SDL_Surface* temp = IMG_Load(font_file);
      if (!temp)
        {
          printf("Error: Couldn't load %s\n", font_file);
          exit(EXIT_FAILURE);
        }

      TTY_Font* font = FNT_Create(temp, 16, 16,
                                  "\x7f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                  "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
      tty = TTY_Create(40, 30, font);
      SDL_FreeSurface(temp);
    }

    TTY_printf(tty, "\n    **** COMMODORE 64 BASIC V2 ****\n\n");
    TTY_printf(tty, " 64k RAM SYSTEM  38911 BASIC BYTES FREE\n\n");
    TTY_printf(tty, "READY.\n\n");
  }
Exemplo n.º 2
0
TextView::TextView(const Rect& rect)
    : Widget(rect)
{
    SDL_Surface* temp = IMG_Load(DATADIR "/fonts/8x8font.png");
    if (!temp)
    {
        std::ostringstream out;
        out << "Couldn't open " << DATADIR "/fonts/8x8font.png";
        throw std::runtime_error(out.str());
    }

    font = TTY_CreateFont(temp, 8, 8,
                          "\x7f                                "
                          "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                          "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
    tty = TTY_Create(rect.get_width()/8, rect.get_height()/8+1, font);
}