From 3075ed87fa0c444678832cc815e83d68a9d24e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kujawa?= Date: Thu, 2 Feb 2017 12:06:41 +0100 Subject: [PATCH] Add ability to load things onto bus from buffer. --- src/bus.c | 17 +++++++++++++++++ src/bus.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/bus.c b/src/bus.c index 4068c69..85c7771 100644 --- a/src/bus.c +++ b/src/bus.c @@ -47,6 +47,23 @@ bus_init() return t; } +bool +bus_load_buf(bus_t *t, uint16_t addr, uint8_t *buf, uint16_t bufsize) +{ + uint16_t i; + + i = 0; + + /* XXX: add sanity checks */ + + while (i < bufsize) { + t->space[i] = buf[i]; // XXX: overflow addr + i++; + } + + return true; +} + bool bus_load_file(bus_t *t, uint16_t addr, const char *filename) { diff --git a/src/bus.h b/src/bus.h index 91c97cc..6e4d31c 100644 --- a/src/bus.h +++ b/src/bus.h @@ -17,6 +17,7 @@ void bus_write_1(bus_t *, uint16_t, uint8_t); bus_t bus_init(); void bus_finish(bus_t *); bool bus_load_file(bus_t *, uint16_t, const char *); +bool bus_load_buf(bus_t *, uint16_t, uint8_t *, uint16_t); #endif /* _BUS_H_ */