| 
						
						
						
					 | 
					 | 
					@ -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];
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					} | 
					 | 
					 | 
					 | 
					} |