1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-06-19 14:29:35 +00:00
rk65c02/src/bus.c
2017-01-16 19:35:28 +01:00

47 lines
551 B
C

#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#define RK65C02_BUS_SIZE 64*1024
struct bus_tag {
uint8_t *space;
};
typedef struct bus_tag bus_t;
uint8_t
bus_read_1(bus_t *t, uint16_t addr)
{
return t->space[addr];
}
void
bus_write_1(bus_t *t, uint16_t addr, uint8_t val)
{
t->space[addr] = val;
}
bus_t
bus_init()
{
bus_t t;
t.space = (uint8_t *) malloc(RK65C02_BUS_SIZE);
assert(t.space != NULL);
memset(t.space, 0, RK65C02_BUS_SIZE);
return t;
}
void
bus_finish(bus_t *t)
{
free(t->space);
}