Emulator: Prefer uint32_t over unsigned int
This commit is contained in:
+7
-5
@@ -1,8 +1,10 @@
|
||||
#include "emu.h"
|
||||
#include <cstdint> // uint8_t, uint32_t
|
||||
|
||||
#include "cpu.h"
|
||||
#include "emu.h"
|
||||
#include "ruc/format/print.h"
|
||||
|
||||
void Emu::init(unsigned int frequency)
|
||||
void Emu::init(uint32_t frequency)
|
||||
{
|
||||
m_frequency = frequency;
|
||||
}
|
||||
@@ -28,13 +30,13 @@ void Emu::addMemorySpace(const char* name, int size)
|
||||
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, uint32_t location, uint8_t value)
|
||||
{
|
||||
print("{} {} {}\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, uint32_t location)
|
||||
{
|
||||
// return m_memory_spaces[memory_space][location];
|
||||
return m_memory_spaces[memory_space][location];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdint> // uint8_t, uint32_t
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@@ -11,20 +11,20 @@ class Emu final : public ruc::Singleton<Emu> {
|
||||
public:
|
||||
Emu(s) {}
|
||||
|
||||
void init(unsigned int frequency);
|
||||
void init(uint32_t frequency);
|
||||
|
||||
void update();
|
||||
|
||||
void addProcessingUnit(ProcessingUnit* processing_unit);
|
||||
void addMemorySpace(const char* name, int size);
|
||||
|
||||
void writeMemory(const char* memory_space, unsigned int location, uint8_t value);
|
||||
void writeMemory(const char* memory_space, uint32_t location, uint8_t value);
|
||||
|
||||
uint8_t readMemory(const char* memory_space, unsigned int location);
|
||||
uint8_t readMemory(const char* memory_space, uint32_t location);
|
||||
|
||||
private:
|
||||
unsigned int m_frequency;
|
||||
unsigned int m_cycle = 0;
|
||||
uint32_t m_frequency;
|
||||
uint32_t m_cycle = 0;
|
||||
|
||||
std::vector<ProcessingUnit*> m_processing_units;
|
||||
std::unordered_map<const char*, std::vector<uint8_t>> m_memory_spaces;
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdint> // uint32_t
|
||||
|
||||
#include "processing-unit.h"
|
||||
|
||||
ProcessingUnit::ProcessingUnit(unsigned int frequency)
|
||||
ProcessingUnit::ProcessingUnit(uint32_t frequency)
|
||||
: m_frequency(frequency)
|
||||
{
|
||||
}
|
||||
@@ -18,7 +18,7 @@ ProcessingUnit::~ProcessingUnit()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int ProcessingUnit::frequency()
|
||||
uint32_t ProcessingUnit::frequency()
|
||||
{
|
||||
return m_frequency;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint> // uint32_t
|
||||
|
||||
class ProcessingUnit {
|
||||
public:
|
||||
ProcessingUnit(unsigned int frequency);
|
||||
ProcessingUnit(uint32_t frequency);
|
||||
virtual ~ProcessingUnit();
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
unsigned int frequency();
|
||||
uint32_t frequency();
|
||||
|
||||
private:
|
||||
unsigned int m_frequency { 0 };
|
||||
uint32_t m_frequency { 0 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user