Changeset ebc8f69 in buchla-emu


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.

Location:
emu
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • emu/all.h

    r2147e53 rebc8f69  
    2121#include <stdio.h>
    2222#include <unistd.h>
     23
     24#include <xmmintrin.h>
    2325
    2426#include <m68k.h>
  • 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
  • emu/sdl.c

    r2147e53 rebc8f69  
    2828void sdl_init(void)
    2929{
    30         if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
     30        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) < 0) {
    3131                fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
    3232                exit(1);
Note: See TracChangeset for help on using the changeset viewer.