1.1.0 release

This commit is contained in:
patrick_pluto 2024-08-22 21:17:58 +02:00
parent d77733d29f
commit 98167a9d93
2 changed files with 140 additions and 0 deletions

15
cpu.hpp
View file

@ -15,6 +15,9 @@ You should have received a copy of the GNU General Public License along with thi
#include <fstream>
#include <cstdlib>
#include <cstdint>
#include <chrono>
#include <thread>
#include "tpu.hpp"
using namespace std;
@ -61,10 +64,22 @@ void cpuInstructions ( uint8_t *rom ) {
}
void cpuEmulation ( uint8_t *rom ) {
const int targetFPS = 20;
const int frameDuration = 1000 / targetFPS;
*pointer = 0;
while ( true ) {
auto start = chrono::high_resolution_clock::now();
cpuInstructions ( rom );
textProcessing ( registers[7] );
auto end = chrono::high_resolution_clock::now();
chrono::duration<double, milli> elapsed = end - start;
if ( elapsed.count() < frameDuration ) {
this_thread::sleep_for ( chrono::milliseconds ( frameDuration ) - elapsed );
}
}
}

125
tpu.hpp Normal file
View file

@ -0,0 +1,125 @@
#pragma once
#include <iostream>
#include <cstdlib>
#include <cstdint>
using namespace std;
void textProcessing ( uint8_t ch ) {
switch ( ch ) {
case 0x01:
cout << "0";
break;
case 0x02:
cout << "1";
break;
case 0x03:
cout << "2";
break;
case 0x04:
cout << "3";
break;
case 0x05:
cout << "4";
break;
case 0x06:
cout << "5";
break;
case 0x07:
cout << "6";
break;
case 0x08:
cout << "7";
break;
case 0x09:
cout << "8";
break;
case 0x0A:
cout << "9";
break;
case 0x0B:
cout << "A";
break;
case 0x0C:
cout << "B";
break;
case 0x0D:
cout << "C";
break;
case 0x0E:
cout << "D";
break;
case 0x0F:
cout << "E";
break;
case 0x10:
cout << "F";
break;
case 0x11:
cout << "G";
break;
case 0x12:
cout << "H";
break;
case 0x13:
cout << "I";
break;
case 0x14:
cout << "J";
break;
case 0x15:
cout << "K";
break;
case 0x16:
cout << "L";
break;
case 0x17:
cout << "M";
break;
case 0x18:
cout << "N";
break;
case 0x19:
cout << "O";
break;
case 0x1A:
cout << "P";
break;
case 0x1B:
cout << "Q";
break;
case 0x1C:
cout << "R";
break;
case 0x1D:
cout << "S";
break;
case 0x1E:
cout << "T";
break;
case 0x1F:
cout << "U";
break;
case 0x20:
cout << "V";
break;
case 0x21:
cout << "W";
break;
case 0x22:
cout << "X";
break;
case 0x23:
cout << "Y";
break;
case 0x24:
cout << "Z";
break;
case 0x25:
cout << endl;
break;
default:
break;
}
}