Changeset caff491 in buchla-emu for emu


Ignore:
Timestamp:
07/30/2017 06:06:21 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
1efc42c
Parents:
a6da9fb
Message:

Moved serial console window to ser emulation.

Location:
emu
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • emu/all.h

    ra6da9fb rcaff491  
    6161extern int32_t led_verbose;
    6262extern int32_t kbd_verbose;
    63 
    64 extern SDL_Window *sdl_win;
    65 extern SDL_Renderer *sdl_ren;
    6663
    6764extern void sdl_init(void);
  • emu/sdl.c

    ra6da9fb rcaff491  
    2424#define ver3(...) _ver(sdl_verbose, 2, __VA_ARGS__)
    2525
    26 SDL_Window *sdl_win;
    27 SDL_Renderer *sdl_ren;
    28 
    2926void sdl_init(void)
    3027{
     
    4138
    4239        SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
    43 
    44         sdl_win = SDL_CreateWindow("Emu", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
    45                         WIN_W, WIN_H, 0);
    46 
    47         if (sdl_win == NULL) {
    48                 fail("SDL_CreateWindow() failed: %s", SDL_GetError());
    49         }
    50 
    51         sdl_ren = SDL_CreateRenderer(sdl_win, -1, 0);
    52 
    53         if (sdl_ren == NULL) {
    54                 fail("SDL_CreateRenderer() failed: %s", SDL_GetError());
    55         }
    56 
    5740        SDL_StartTextInput();
    5841}
     
    6043void sdl_quit(void)
    6144{
    62         SDL_DestroyRenderer(sdl_ren);
    63         SDL_DestroyWindow(sdl_win);
    6445        TTF_Quit();
    6546        SDL_Quit();
  • emu/ser.c

    ra6da9fb rcaff491  
    5555static uint8_t mem[CON_H][CON_W + 1];
    5656
     57static SDL_Window *win;
     58static SDL_Renderer *ren;
     59
    5760static TTF_Font *fon;
    5861static int32_t fon_w, fon_h;
     
    6366static int32_t cur_x = 0, cur_y = 0;
    6467static int32_t bel = 0;
    65 
    66 static void out(int32_t un, uint8_t c)
    67 {
    68         state[un].rdr = c;
    69         state[un].rdr_ok = true;
    70         state[un].irq_r = true;
    71 }
    7268
    7369static void update(void)
     
    105101        }
    106102
    107         SDL_Texture *tex = SDL_CreateTextureFromSurface(sdl_ren, sur);
     103        SDL_Texture *tex = SDL_CreateTextureFromSurface(ren, sur);
    108104
    109105        if (tex == NULL) {
     
    111107        }
    112108
    113         if (SDL_RenderCopy(sdl_ren, tex, NULL, NULL) < 0) {
     109        if (SDL_RenderCopy(ren, tex, NULL, NULL) < 0) {
    114110                fail("SDL_RenderCopy() failed: %s", SDL_GetError());
    115111        }
    116112
    117113        SDL_DestroyTexture(tex);
    118         SDL_RenderPresent(sdl_ren);
     114        SDL_RenderPresent(ren);
    119115}
    120116
     
    201197}
    202198
     199static void out(int32_t un, uint8_t c)
     200{
     201        state[un].rdr = c;
     202        state[un].rdr_ok = true;
     203        state[un].irq_r = true;
     204}
     205
    203206void ser_key(SDL_KeyboardEvent *ev)
    204207{
     
    233236        ver("ser init");
    234237
     238        win = SDL_CreateWindow("Serial Console", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
     239                        WIN_W, WIN_H, 0);
     240
     241        if (win == NULL) {
     242                fail("SDL_CreateWindow() failed: %s", SDL_GetError());
     243        }
     244
     245        ren = SDL_CreateRenderer(win, -1, 0);
     246
     247        if (ren == NULL) {
     248                fail("SDL_CreateRenderer() failed: %s", SDL_GetError());
     249        }
     250
    235251        SDL_RWops *ops = SDL_RWFromFile(CON_FONT, "rb");
    236252
     
    277293        SDL_FreeSurface(sur);
    278294        TTF_CloseFont(fon);
     295
     296        SDL_DestroyRenderer(ren);
     297        SDL_DestroyWindow(win);
    279298}
    280299
Note: See TracChangeset for help on using the changeset viewer.