1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-06-25 12:29:34 +00:00

Add hires graphics file; draw hires graphics

This commit is contained in:
Peter Evans 2018-03-13 16:08:31 -05:00
parent 52e5f8afa7
commit 4d34663435
6 changed files with 64 additions and 0 deletions

View File

@ -6,6 +6,7 @@
extern void apple2_draw(apple2 *);
extern void apple2_draw_40col(apple2 *);
extern void apple2_draw_hires(apple2 *);
extern void apple2_draw_lores(apple2 *);
extern void apple2_draw_pixel(apple2 *, vm_16bit);

8
include/apple2.hires.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef _APPLE2_HIRES_H_
#define _APPLE2_HIRES_H_
#include "apple2.h"
extern void apple2_hires_draw(apple2 *, size_t);
#endif

View File

@ -6,6 +6,7 @@ set(erc_sources
apple2.dec.c
apple2.draw.c
apple2.enc.c
apple2.hires.c
apple2.kb.c
apple2.lores.c
apple2.mem.c

View File

@ -7,6 +7,7 @@
*/
#include "apple2.h"
#include "apple2.hires.h"
#include "apple2.lores.h"
#include "apple2.text.h"
@ -96,6 +97,21 @@ apple2_draw_lores(apple2 *mach)
}
}
/*
* Draw high-resolution graphics on the screen
*/
void
apple2_draw_hires(apple2 *mach)
{
size_t addr;
vm_screen_prepare(mach->screen);
for (addr = 0x2000; addr < 0x4000; addr++) {
apple2_hires_draw(mach, addr);
}
}
/*
* Find the right draw method for the machine, based on its display
* mode, and use that to refresh the screen.
@ -106,7 +122,11 @@ apple2_draw(apple2 *mach)
if (mach->display_mode & DISPLAY_TEXT) {
apple2_draw_40col(mach);
return;
} else if (mach->memory_mode & MEMORY_HIRES) {
apple2_draw_hires(mach);
return;
}
// The fallback mode is to draw lores graphics
apple2_draw_lores(mach);
}

24
src/apple2.hires.c Normal file
View File

@ -0,0 +1,24 @@
/*
* apple2.hires.c
*
* High resolution graphics in Apple are a significant change from its
* low-resolution graphics. Where one byte can hold the color data for
* two onscreen cells in lores graphics, in hires, each _bit_
* corresponds to a pixel. The colors you can show depend on the pattern
* of high and low bits within a given data byte. Certain rows have
* black, purple, or blue available; alternating rows can be black,
* green, or orange.
*
* Some of this has to do with the space constraints available to the
* Apple II: the hires graphics buffer is held between $2000 and $3FFF,
* which is only 8k RAM. Some of this has to do with the peculiarities
* of the NTSC format, because the Apple II was designed to work with
* standard television screens.
*/
#include "apple2.hires.h"
void
apple2_hires_draw(apple2 *mach, size_t addr)
{
}

10
tests/apple2.hires.c Normal file
View File

@ -0,0 +1,10 @@
#include <criterion/criterion.h>
#include "apple2.hires.h"
#include "apple2.tests.h"
TestSuite(apple2_hires, .init = setup, .fini = teardown);
Test(apple2_hires, draw)
{
}