1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-11 18:49:16 +00:00

Make RAM size configurable.

This commit is contained in:
Radosław Kujawa 2018-03-24 23:05:28 +01:00
parent eeb337a0d6
commit 363bb56fc6
3 changed files with 8 additions and 8 deletions

View File

@ -135,7 +135,7 @@ bus_init_with_default_devs()
t = bus_init(); t = bus_init();
bus_device_add(&t, device_ram_init(), 0x0); bus_device_add(&t, device_ram_init(0xDFFF), 0x0);
return t; return t;
} }
@ -177,6 +177,8 @@ bus_load_file(bus_t *t, uint16_t addr, const char *filename)
close(fd); close(fd);
rk65c02_log(LOG_DEBUG, "Loaded file %s at %x.", filename, addr);
return true; return true;
} }

View File

@ -6,8 +6,6 @@
#include "bus.h" #include "bus.h"
#include "device.h" #include "device.h"
#define RAM_SIZE 0xDFFF /* should be configurable */
uint8_t device_ram_read_1(void *, uint16_t); uint8_t device_ram_read_1(void *, uint16_t);
void device_ram_write_1(void *, uint16_t, uint8_t); void device_ram_write_1(void *, uint16_t, uint8_t);
@ -36,7 +34,7 @@ device_ram_write_1(void *vd, uint16_t offset, uint8_t val)
} }
device_t * device_t *
device_ram_init() device_ram_init(uint16_t size)
{ {
device_t *d; device_t *d;
@ -45,13 +43,13 @@ device_ram_init()
assert(d != NULL); assert(d != NULL);
d->name = "RAM"; d->name = "RAM";
d->size = RAM_SIZE; d->size = size;
d->read_1 = device_ram_read_1; d->read_1 = device_ram_read_1;
d->write_1 = device_ram_write_1; d->write_1 = device_ram_write_1;
d->aux = malloc(RAM_SIZE); d->aux = malloc(size);
memset(d->aux, 0, RAM_SIZE); memset(d->aux, 0, size);
return d; return d;
} }

View File

@ -3,7 +3,7 @@
#include "device.h" #include "device.h"
device_t * device_ram_init(); device_t * device_ram_init(uint16_t);
void device_ram_finish(device_t *); void device_ram_finish(device_t *);
#endif /* _DEVICE_RAM_H_ */ #endif /* _DEVICE_RAM_H_ */