Jump to content
Sign in to follow this  
  • entries
    2
  • comments
    0
  • views
    295

Memory Mapper Coded

Sign in to follow this  
francoisdiy

498 views

Currently, I'm coding the memory mapper for the interpreter - the routine that let's the interpreter talk to SFML in order to do I/O. It is kind of like a driver or something like that. Here I show how to read/write values to the mapper.

// Basic Memory Map
//
// your program
// sprite register
// sound register
// music register
// text register
// signal register
// camera register
// collision register
// level register
// progress register
void Cclsh::Rmemory_mapper(int address, std::string field, Fvalue data) {
int prgm_low = 0;
int prgm_high = prgm_low + this->memory_size;
int sprite_addr = prgm_high;
int sound_addr = sprite_addr + 1;
int music_addr = sound_addr + 1;
int text_addr = music_addr + 1;
int signal_addr = text_addr + 1;
int camera_addr = signal_addr + 1;
int collision_addr = camera_addr + 1;
int level_addr = collision_addr + 1;
int progress_addr = level_addr + 1;
if ((address >= prgm_low) && (address < prgm_high)) {
Fblock* block = &this->memory[address];
if (data.type == 0) { // Read
if (field.length() == 0) { // Read value.
data.string = block->value.string;
data.number = block->value.number;
data.type = block->value.type;
}
else { // Read field.
if (block->fields.find(field) != block->fields.end()) {
data.string = block->fields[field].string;
data.number = block->fields[field].number;
data.type = block->fields[field].type;
}
else { // Field not defined.
data.string = "null";
data.number = 0;
data.type = 2; // String
}
}
}
else { // Write
if (field.length == 0) { // Write value.
block->value.string = data.string;
block->value.number = data.number;
block->value.type = data.type;
}
else { // Write field.
if (block->fields.find(field) != block->fields.end()) {
block->fields[field].string = data.string;
block->fields[field].number = data.number;
block->fields[field].type = data.type;
}
else {
Fvalue new_data;
new_data.string = data.string;
new_data.number = data.number;
new_data.type = data.type;
block.fields[field] = new_data;
}
}
}
}
}
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!