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


Ignore:
Timestamp:
07/20/2017 08:18:39 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
4c71d39
Parents:
2147e53
Message:

Throttle CPU to 7 MHz.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/cpu.c

    r2147e53 rebc8f69  
    2626bool cpu_verbose = false;
    2727
    28 #define CYCLES 70
     28#define CPU_FREQ 7000000
     29#define PER_SEC 100000
    2930
    3031#define APP_START 0x10000
     
    450451        m68k_pulse_reset();
    451452
     453        uint64_t freq = SDL_GetPerformanceFrequency();
     454        uint64_t quan = freq / PER_SEC;
     455        inf("freq %" PRIu64 " quan %" PRIu64, freq, quan);
     456
    452457        bool run = true;
    453458
    454459        while (run) {
    455                 m68k_execute(CYCLES);
     460                uint64_t until = SDL_GetPerformanceCounter() + quan;
     461
     462                m68k_execute(CPU_FREQ / PER_SEC);
    456463                hw_exec();
    457464
     
    461468                        if (ev.type == SDL_QUIT) {
    462469                                run = false;
    463                                 break;
    464470                        }
    465471                }
     472
     473                while (SDL_GetPerformanceCounter() < until) {
     474                        _mm_pause();
     475                }
    466476        }
    467477
Note: See TracChangeset for help on using the changeset viewer.