mirror of
https://github.com/rkujawa/rk65c02.git
synced 2024-11-15 16:06:38 +00:00
Start implementation of display emulation.
Something like a character RAM for a start. When 65C02 writes into this space, a callback will be executed that would allow redrawing the emulated screen. Multiple backends can be supported this way.
This commit is contained in:
parent
13a4c73807
commit
85a53f89c8
@ -1,7 +1,7 @@
|
|||||||
CLI=rk65c02cli
|
CLI=rk65c02cli
|
||||||
CLI_OBJS=rk65c02cli.o
|
CLI_OBJS=rk65c02cli.o
|
||||||
|
|
||||||
LIB_OBJS=rk65c02.o bus.o instruction.o emulation.o debug.o device_ram.o device_serial.o log.o
|
LIB_OBJS=rk65c02.o bus.o instruction.o emulation.o debug.o device_ram.o device_fb.o device_serial.o log.o
|
||||||
LIB_SO=librk65c02.so
|
LIB_SO=librk65c02.so
|
||||||
LIB_STATIC=librk65c02.a
|
LIB_STATIC=librk65c02.a
|
||||||
|
|
||||||
|
87
src/device_fb.c
Normal file
87
src/device_fb.c
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "bus.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
#define FB_AS_SIZE 0x1000
|
||||||
|
|
||||||
|
#define CHAR_RAM_SIZE (80*50) /* 0xFA0 */
|
||||||
|
#define CHAR_FONT_WIDTH 8
|
||||||
|
#define CHAR_FONT_HEIGHT 8
|
||||||
|
|
||||||
|
struct fb_state {
|
||||||
|
uint8_t *cram;
|
||||||
|
|
||||||
|
void (*fb_callback_screen_update)(uint8_t *);
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t device_fb_read_1(void *, uint16_t);
|
||||||
|
void device_fb_write_1(void *, uint16_t, uint8_t);
|
||||||
|
|
||||||
|
uint8_t
|
||||||
|
device_fb_read_1(void *vd, uint16_t offset)
|
||||||
|
{
|
||||||
|
device_t *d;
|
||||||
|
struct fb_state *f;
|
||||||
|
|
||||||
|
d = (device_t *) vd;
|
||||||
|
f = d->aux;
|
||||||
|
|
||||||
|
return f->cram[offset];
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
device_fb_write_1(void *vd, uint16_t offset, uint8_t val)
|
||||||
|
{
|
||||||
|
device_t *d;
|
||||||
|
|
||||||
|
struct fb_state *f;
|
||||||
|
|
||||||
|
d = (device_t *) vd;
|
||||||
|
f = d->aux;
|
||||||
|
|
||||||
|
f->cram[offset] = val;
|
||||||
|
|
||||||
|
if (f->fb_callback_screen_update != NULL)
|
||||||
|
f->fb_callback_screen_update(f->cram);
|
||||||
|
}
|
||||||
|
|
||||||
|
device_t *
|
||||||
|
device_fb_init()
|
||||||
|
{
|
||||||
|
device_t *d;
|
||||||
|
struct fb_state *f;
|
||||||
|
|
||||||
|
d = (device_t *) malloc(sizeof(device_t));
|
||||||
|
|
||||||
|
assert(d != NULL);
|
||||||
|
|
||||||
|
d->name = "FB";
|
||||||
|
d->size = FB_AS_SIZE;
|
||||||
|
|
||||||
|
d->read_1 = device_fb_read_1;
|
||||||
|
d->write_1 = device_fb_write_1;
|
||||||
|
|
||||||
|
f = malloc(sizeof(struct fb_state));
|
||||||
|
d->aux = f;
|
||||||
|
|
||||||
|
f->cram = malloc(FB_AS_SIZE);
|
||||||
|
memset(d->aux, 0, FB_AS_SIZE);
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
device_fb_finish(device_t *d)
|
||||||
|
{
|
||||||
|
struct fb_state *f;
|
||||||
|
|
||||||
|
f = d->aux;
|
||||||
|
|
||||||
|
free(f->cram);
|
||||||
|
free(f);
|
||||||
|
}
|
||||||
|
|
9
src/device_fb.h
Normal file
9
src/device_fb.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _DEVICE_RAM_H_
|
||||||
|
#define _DEVICE_RAM_H_
|
||||||
|
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
device_t * device_fb_init();
|
||||||
|
void device_fb_finish(device_t *);
|
||||||
|
|
||||||
|
#endif /* _DEVICE_RAM_H_ */
|
Loading…
Reference in New Issue
Block a user