Changeset bb4fd0c in buchla-emu for emu/cpu.c


Ignore:
Timestamp:
07/23/2017 10:17:42 AM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
a23f3d9
Parents:
a1fd5d5
Message:

Started serial console.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/cpu.c

    ra1fd5d5 rbb4fd0c  
    9292static void hw_init(void)
    9393{
    94         inf("initializing hardware");
     94        inf("starting hardware");
    9595
    9696        for (int32_t i = 0; i < ARRAY_COUNT(hw_map); ++i) {
    9797                hw_map[i].init();
     98        }
     99}
     100
     101static void hw_quit(void)
     102{
     103        inf("halting hardware");
     104
     105        for (int32_t i = 0; i < ARRAY_COUNT(hw_map); ++i) {
     106                hw_map[i].quit();
    98107        }
    99108}
     
    611620
    612621        bool run = true;
     622        bool down = false;
    613623
    614624        while (run) {
     
    621631
    622632                while (SDL_PollEvent(&ev) > 0) {
    623                         if (ev.type == SDL_QUIT) {
     633                        // Work around duplicate key-down events on Linux.
     634
     635                        if (ev.type == SDL_KEYDOWN) {
     636                                if (down) {
     637                                        continue;
     638                                }
     639
     640                                down = true;
     641                        }
     642                        else if (ev.type == SDL_KEYUP) {
     643                                down = false;
     644                        }
     645
     646                        if (ev.type == SDL_QUIT ||
     647                                        (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_ESCAPE)) {
    624648                                run = false;
     649                                continue;
     650                        }
     651
     652                        if (ev.type == SDL_TEXTINPUT) {
     653                                ser_text(&ev.text);
     654                                continue;
     655                        }
     656
     657                        if (ev.type == SDL_KEYDOWN) {
     658                                ser_key(&ev.key);
     659                                continue;
    625660                        }
    626661                }
     
    632667
    633668        inf("leaving CPU loop");
    634 }
     669        hw_quit();
     670}
Note: See TracChangeset for help on using the changeset viewer.