36 lines
600 B
C
36 lines
600 B
C
|
#include <cstring>
|
||
|
#include <string.h>
|
||
|
#include <stdint.h>
|
||
|
#include "../bus.h"
|
||
|
|
||
|
#define VIDEO_BASE_ADDR 0xFFFB8000
|
||
|
|
||
|
static uint16_t memory[320*200];
|
||
|
|
||
|
static int
|
||
|
read(uint32_t addr, void *data, size_t sz)
|
||
|
{
|
||
|
addr = addr - VIDEO_BASE_ADDR;
|
||
|
|
||
|
memcpy(data, ((uint8_t *)memory) + addr, sz);
|
||
|
|
||
|
return (sz);
|
||
|
}
|
||
|
|
||
|
static int
|
||
|
write(uint32_t addr, const void *data, size_t sz)
|
||
|
{
|
||
|
addr = addr - VIDEO_BASE_ADDR;
|
||
|
|
||
|
memcpy(((uint8_t *)memory) + addr, data, sz);
|
||
|
|
||
|
return (sz);
|
||
|
}
|
||
|
|
||
|
struct bus video_memory = {
|
||
|
"video-memory",
|
||
|
{VIDEO_BASE_ADDR, VIDEO_BASE_ADDR + (320 * 200 * sizeof(uint16_t))},
|
||
|
&read,
|
||
|
&write,
|
||
|
};
|