- [NEW] Treballant en modularitzar la memòria, per a començar a implementar soport per als demes Spectrums
This commit is contained in:
61
zx_48mem.cpp
Normal file
61
zx_48mem.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "zx_48mem.h"
|
||||
#include "z80mem.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
zx_48mem::zx_48mem()
|
||||
{
|
||||
z80mem::singleton = this;
|
||||
}
|
||||
|
||||
uint8_t zx_48mem::readMem(uint16_t address)
|
||||
{
|
||||
return memory[address];
|
||||
}
|
||||
|
||||
void zx_48mem::writeMem(uint16_t address, uint8_t value)
|
||||
{
|
||||
memory[address] = value;
|
||||
}
|
||||
|
||||
void zx_48mem::loadMem(uint16_t address, uint16_t len, uint8_t *buffer)
|
||||
{
|
||||
memcpy(&memory[address], buffer, len);
|
||||
}
|
||||
|
||||
uint8_t zx_48mem::getTag(uint16_t address)
|
||||
{
|
||||
return tags[address];
|
||||
}
|
||||
|
||||
void zx_48mem::setTag(uint16_t address, uint8_t value)
|
||||
{
|
||||
tags[address] = value;
|
||||
}
|
||||
|
||||
void zx_48mem::reset()
|
||||
{
|
||||
FILE* f = fopen("48.rom", "rb");
|
||||
fread(memory, 1024, 16, f);
|
||||
fclose(f);
|
||||
|
||||
for (int i=0x4000; i<=0xFFFF; ++i) memory[i] = 0;
|
||||
for (int i=0; i<65536; ++i) tags[i] = MEMTAG_NONE;
|
||||
}
|
||||
|
||||
void zx_48mem::saveState(FILE *f)
|
||||
{
|
||||
fwrite(&memory[0x4000], 0xc000, 1, f);
|
||||
}
|
||||
|
||||
void zx_48mem::loadState(FILE *f)
|
||||
{
|
||||
fread(&memory[0x4000], 0xc000, 1, f);
|
||||
}
|
||||
|
||||
uint32_t zx_48mem::getSize()
|
||||
{
|
||||
return 65536;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user