diff --git a/include/vm_screen.h b/include/vm_screen.h index 2152fb9..88b7e31 100644 --- a/include/vm_screen.h +++ b/include/vm_screen.h @@ -7,14 +7,6 @@ #define VM_SCREEN_DEFWIDTH 800 #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 { int xoff; int yoff; @@ -54,7 +46,7 @@ extern int vm_screen_init(); extern int vm_screen_xcoords(vm_screen *); extern int vm_screen_ycoords(vm_screen *); 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_free(vm_screen *); extern void vm_screen_refresh(vm_screen *); diff --git a/src/apple2.draw.c b/src/apple2.draw.c index b0bc4e8..a8da6e7 100644 --- a/src/apple2.draw.c +++ b/src/apple2.draw.c @@ -42,7 +42,7 @@ apple2_draw_pixel_lores(apple2 *mach, vm_16bit addr) { vm_8bit color = vm_segment_get(mach->memory, addr); vm_8bit top, bottom; - SDL_Rect loc; + vm_area loc; int *colors; // 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; // The next thing we need to consider is where we draw the pixel - loc.x = (addr & 0xff) * mach->sysfont->width; - loc.y = (addr >> 8) * mach->sysfont->height; - loc.w = mach->sysfont->width; - loc.h = mach->sysfont->height / 2; + loc.xoff = (addr & 0xff) * mach->sysfont->width; + loc.yoff = (addr >> 8) * mach->sysfont->height; + loc.width = mach->sysfont->width; + loc.height = mach->sysfont->height / 2; colors = lores_colors[top]; 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]; 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 diff --git a/src/vm_screen.c b/src/vm_screen.c index 7b1a3cd..b946323 100644 --- a/src/vm_screen.c +++ b/src/vm_screen.c @@ -204,20 +204,11 @@ vm_screen_set_color(vm_screen *screen, * set of x/y dimensions, with a given screen. */ void -vm_screen_draw_rect(vm_screen *screen, - int xpos, - int ypos, - int xsize, - int ysize) +vm_screen_draw_rect(vm_screen *screen, vm_area *area) { - SDL_Rect rect; - // The renderer will take care of translating the positions and // sizes into whatever the window is really at. - rect.x = xpos; - rect.y = ypos; - rect.w = xsize; - rect.h = ysize; + MAKE_SDL_RECT(rect, *area); SDL_RenderFillRect(screen->render, &rect); }