Emulator: Run clang-format
This commit is contained in:
+2
-1
@@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
#include "apu.h"
|
#include "apu.h"
|
||||||
|
|
||||||
APU::APU(unsigned int frequency) : ProcessingUnit(frequency)
|
APU::APU(unsigned int frequency)
|
||||||
|
: ProcessingUnit(frequency)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -9,7 +9,8 @@
|
|||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
CPU::CPU(unsigned int frequency) : ProcessingUnit(frequency)
|
CPU::CPU(unsigned int frequency)
|
||||||
|
: ProcessingUnit(frequency)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,8 +18,9 @@ CPU::~CPU()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPU::update() {
|
void CPU::update()
|
||||||
|
{
|
||||||
printf("This is an update from the CPU\n");
|
printf("This is an update from the CPU\n");
|
||||||
Emu::the().writeMemory("RAM", 123, 42);
|
Emu::the().writeMemory("RAM", 123, 42);
|
||||||
printf("fff");
|
printf("fff");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
virtual ~CPU();
|
virtual ~CPU();
|
||||||
|
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
// 8-bit Arithmetic and Logic Instructions
|
// 8-bit Arithmetic and Logic Instructions
|
||||||
|
|
||||||
// 16-bit Arithmetic Instructions
|
// 16-bit Arithmetic Instructions
|
||||||
|
|||||||
+18
-11
@@ -1,12 +1,15 @@
|
|||||||
#include "emu.h"
|
|
||||||
#include "cpu.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void Emu::init(unsigned int frequency) {
|
#include "cpu.h"
|
||||||
|
#include "emu.h"
|
||||||
|
|
||||||
|
void Emu::init(unsigned int frequency)
|
||||||
|
{
|
||||||
m_frequency = frequency;
|
m_frequency = frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emu::update() {
|
void Emu::update()
|
||||||
|
{
|
||||||
for (auto unit : m_processing_units) {
|
for (auto unit : m_processing_units) {
|
||||||
if (m_cycle % (m_frequency / unit->frequency()) == 0) {
|
if (m_cycle % (m_frequency / unit->frequency()) == 0) {
|
||||||
unit->update();
|
unit->update();
|
||||||
@@ -15,20 +18,24 @@ void Emu::update() {
|
|||||||
m_cycle++;
|
m_cycle++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emu::addProcessingUnit(ProcessingUnit* processing_unit) {
|
void Emu::addProcessingUnit(ProcessingUnit* processing_unit)
|
||||||
|
{
|
||||||
m_processing_units.push_back(processing_unit);
|
m_processing_units.push_back(processing_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emu::addMemorySpace(const char* name, int size) {
|
void Emu::addMemorySpace(const char* name, int size)
|
||||||
|
{
|
||||||
std::vector<uint8_t> memory(size);
|
std::vector<uint8_t> memory(size);
|
||||||
m_memory_spaces.emplace(name, memory);
|
m_memory_spaces.emplace(name, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emu::writeMemory(const char* memory_space, unsigned int location, uint8_t value) {
|
void Emu::writeMemory(const char* memory_space, unsigned int location, uint8_t value)
|
||||||
// printf("%s %d %d", memory_space, location, value);
|
{
|
||||||
// m_memory_spaces[memory_space][location] = value;
|
printf("%s %d %d\n", memory_space, location, value);
|
||||||
|
m_memory_spaces[memory_space][location] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Emu::readMemory(const char* memory_space, unsigned int location){
|
uint8_t Emu::readMemory(const char* memory_space, unsigned int location)
|
||||||
|
{
|
||||||
// return m_memory_spaces[memory_space][location];
|
// return m_memory_spaces[memory_space][location];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "processing-unit.h"
|
#include "processing-unit.h"
|
||||||
#include "ruc/singleton.h"
|
#include "ruc/singleton.h"
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "emu.h"
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
#include "emu.h"
|
||||||
#include "ppu.h"
|
#include "ppu.h"
|
||||||
#include "ruc/timer.h"
|
#include "ruc/timer.h"
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
Emu::the().addMemorySpace("RAM", 1024);
|
Emu::the().addMemorySpace("RAM", 1024);
|
||||||
|
|
||||||
for(int i = 0; i < 1000; i++) {
|
for (int i = 0; i < 1000; i++) {
|
||||||
Emu::the().update();
|
Emu::the().update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -8,7 +8,8 @@
|
|||||||
#include "ppu.h"
|
#include "ppu.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
PPU ::PPU(unsigned int frequency) : ProcessingUnit(frequency)
|
PPU ::PPU(unsigned int frequency)
|
||||||
|
: ProcessingUnit(frequency)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ PPU ::~PPU()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPU::update() {
|
void PPU::update()
|
||||||
|
{
|
||||||
printf("ppu update\n");
|
printf("ppu update\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ class PPU final : public ProcessingUnit {
|
|||||||
public:
|
public:
|
||||||
PPU(unsigned int frequency);
|
PPU(unsigned int frequency);
|
||||||
virtual ~PPU();
|
virtual ~PPU();
|
||||||
|
|
||||||
virtual void update() override;
|
virtual void update() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,10 +5,12 @@
|
|||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "processing-unit.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
ProcessingUnit::ProcessingUnit(unsigned int frequency) : m_frequency(frequency)
|
#include "processing-unit.h"
|
||||||
|
|
||||||
|
ProcessingUnit::ProcessingUnit(unsigned int frequency)
|
||||||
|
: m_frequency(frequency)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,6 +18,7 @@ ProcessingUnit::~ProcessingUnit()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ProcessingUnit::frequency() {
|
unsigned int ProcessingUnit::frequency()
|
||||||
|
{
|
||||||
return m_frequency;
|
return m_frequency;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,5 +17,5 @@ public:
|
|||||||
unsigned int frequency();
|
unsigned int frequency();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int m_frequency;
|
unsigned int m_frequency;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user