mirror of
https://github.com/pevans/erc-c.git
synced 2025-02-17 07:32:05 +00:00
Use vm_area for draw_rect.
This simplifies and to some degree normalizes the way we reference areas in the vm subsystem.
This commit is contained in:
parent
c7b830bb4a
commit
efb8f04555
@ -7,14 +7,6 @@
|
|||||||
#define VM_SCREEN_DEFWIDTH 800
|
#define VM_SCREEN_DEFWIDTH 800
|
||||||
#define VM_SCREEN_DEFHEIGHT 600
|
#define VM_SCREEN_DEFHEIGHT 600
|
||||||
|
|
||||||
/*
|
|
||||||
* If you just want to plot a single pixel, you can use this macro to
|
|
||||||
* abstract away the need to indicate the x/y dimensions (as those must
|
|
||||||
* necessarily be 1x1).
|
|
||||||
*/
|
|
||||||
#define vm_screen_draw_pixel(screen, xpos, ypos) \
|
|
||||||
vm_screen_draw_rect(screen, xpos, ypos, 1, 1)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int xoff;
|
int xoff;
|
||||||
int yoff;
|
int yoff;
|
||||||
@ -54,7 +46,7 @@ extern int vm_screen_init();
|
|||||||
extern int vm_screen_xcoords(vm_screen *);
|
extern int vm_screen_xcoords(vm_screen *);
|
||||||
extern int vm_screen_ycoords(vm_screen *);
|
extern int vm_screen_ycoords(vm_screen *);
|
||||||
extern vm_screen *vm_screen_create();
|
extern vm_screen *vm_screen_create();
|
||||||
extern void vm_screen_draw_rect(vm_screen *, int, int, int, int);
|
extern void vm_screen_draw_rect(vm_screen *, vm_area *);
|
||||||
extern void vm_screen_finish();
|
extern void vm_screen_finish();
|
||||||
extern void vm_screen_free(vm_screen *);
|
extern void vm_screen_free(vm_screen *);
|
||||||
extern void vm_screen_refresh(vm_screen *);
|
extern void vm_screen_refresh(vm_screen *);
|
||||||
|
@ -42,7 +42,7 @@ apple2_draw_pixel_lores(apple2 *mach, vm_16bit addr)
|
|||||||
{
|
{
|
||||||
vm_8bit color = vm_segment_get(mach->memory, addr);
|
vm_8bit color = vm_segment_get(mach->memory, addr);
|
||||||
vm_8bit top, bottom;
|
vm_8bit top, bottom;
|
||||||
SDL_Rect loc;
|
vm_area loc;
|
||||||
int *colors;
|
int *colors;
|
||||||
|
|
||||||
// The top color is the low order nibble, so we can blank out the
|
// The top color is the low order nibble, so we can blank out the
|
||||||
@ -53,18 +53,23 @@ apple2_draw_pixel_lores(apple2 *mach, vm_16bit addr)
|
|||||||
bottom = color >> 4;
|
bottom = color >> 4;
|
||||||
|
|
||||||
// The next thing we need to consider is where we draw the pixel
|
// The next thing we need to consider is where we draw the pixel
|
||||||
loc.x = (addr & 0xff) * mach->sysfont->width;
|
loc.xoff = (addr & 0xff) * mach->sysfont->width;
|
||||||
loc.y = (addr >> 8) * mach->sysfont->height;
|
loc.yoff = (addr >> 8) * mach->sysfont->height;
|
||||||
loc.w = mach->sysfont->width;
|
loc.width = mach->sysfont->width;
|
||||||
loc.h = mach->sysfont->height / 2;
|
loc.height = mach->sysfont->height / 2;
|
||||||
|
|
||||||
colors = lores_colors[top];
|
colors = lores_colors[top];
|
||||||
vm_screen_set_color(mach->screen, colors[0], colors[1], colors[2], 255);
|
vm_screen_set_color(mach->screen, colors[0], colors[1], colors[2], 255);
|
||||||
vm_screen_draw_rect(mach->screen, loc.x, loc.y, loc.w, loc.h);
|
vm_screen_draw_rect(mach->screen, &loc);
|
||||||
|
|
||||||
|
// The bottom pixel we need to draw now must be offset by the height
|
||||||
|
// of the pixel we just drew. (Remember, positive equals down in the
|
||||||
|
// y-axis.)
|
||||||
|
loc.yoff += loc.height;
|
||||||
|
|
||||||
colors = lores_colors[bottom];
|
colors = lores_colors[bottom];
|
||||||
vm_screen_set_color(mach->screen, colors[0], colors[1], colors[2], 255);
|
vm_screen_set_color(mach->screen, colors[0], colors[1], colors[2], 255);
|
||||||
vm_screen_draw_rect(mach->screen, loc.x, loc.y + loc.h, loc.w, loc.h);
|
vm_screen_draw_rect(mach->screen, &loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -204,20 +204,11 @@ vm_screen_set_color(vm_screen *screen,
|
|||||||
* set of x/y dimensions, with a given screen.
|
* set of x/y dimensions, with a given screen.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
vm_screen_draw_rect(vm_screen *screen,
|
vm_screen_draw_rect(vm_screen *screen, vm_area *area)
|
||||||
int xpos,
|
|
||||||
int ypos,
|
|
||||||
int xsize,
|
|
||||||
int ysize)
|
|
||||||
{
|
{
|
||||||
SDL_Rect rect;
|
|
||||||
|
|
||||||
// The renderer will take care of translating the positions and
|
// The renderer will take care of translating the positions and
|
||||||
// sizes into whatever the window is really at.
|
// sizes into whatever the window is really at.
|
||||||
rect.x = xpos;
|
MAKE_SDL_RECT(rect, *area);
|
||||||
rect.y = ypos;
|
|
||||||
rect.w = xsize;
|
|
||||||
rect.h = ysize;
|
|
||||||
|
|
||||||
SDL_RenderFillRect(screen->render, &rect);
|
SDL_RenderFillRect(screen->render, &rect);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user