mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-27 20:51:17 +00:00
Rename video_mode -> display_mode
This also changes the _kind_ of field from an incrementally enumerated one to a collection of bit flags.
This commit is contained in:
parent
bcf6b213a6
commit
2c39120098
@ -35,15 +35,6 @@
|
||||
*/
|
||||
#define APPLE2_APPLESOFT_MAIN 0xE000
|
||||
|
||||
enum video_modes {
|
||||
VIDEO_40COL_TEXT,
|
||||
VIDEO_LORES,
|
||||
VIDEO_HIRES,
|
||||
VIDEO_80COL_TEXT,
|
||||
VIDEO_DOUBLE_LORES,
|
||||
VIDEO_DOUBLE_HIRES,
|
||||
};
|
||||
|
||||
enum color_modes {
|
||||
COLOR_GREEN,
|
||||
COLOR_AMBER,
|
||||
@ -154,6 +145,50 @@ enum memory_mode {
|
||||
MEMORY_SLOTC3ROM = 0x80,
|
||||
};
|
||||
|
||||
enum display_mode {
|
||||
DISPLAY_DEFAULT = 0x0,
|
||||
|
||||
/*
|
||||
* Display text in the "alternate" character set
|
||||
*/
|
||||
DISPLAY_ALTCHAR = 0x1,
|
||||
|
||||
/*
|
||||
* Show text in 80 columns, rather than the default 40 columns
|
||||
*/
|
||||
DISPLAY_80COL = 0x2,
|
||||
|
||||
/*
|
||||
* Display only text. By default, we display lo-res graphics and
|
||||
* perhaps mixed graphics and text if the MIXED bit is high.
|
||||
*/
|
||||
DISPLAY_TEXT = 0x4,
|
||||
|
||||
/*
|
||||
* If TEXT is not high, then we are directed to display both text
|
||||
* and graphics.
|
||||
*/
|
||||
DISPLAY_MIXED = 0x8,
|
||||
|
||||
/*
|
||||
* If this is high, we will show high-resolution graphics; if not,
|
||||
* low-resolution. This bit is overridden by TEXT; if TEXT is high,
|
||||
* we will only show text.
|
||||
*/
|
||||
DISPLAY_HIRES = 0x10,
|
||||
|
||||
/*
|
||||
* Enable IOU access for $C058..$C05F when this bit is on; NOTE: the
|
||||
* tech ref says that this is left on by the firmware
|
||||
*/
|
||||
DISPLAY_IOUDIS = 0x20,
|
||||
|
||||
/*
|
||||
* Display double-high-resolution graphics
|
||||
*/
|
||||
DISPLAY_DHIRES = 0x40,
|
||||
};
|
||||
|
||||
enum bank_switch {
|
||||
/*
|
||||
* In nominal bank-switch mode, reads in the bank-switchable address
|
||||
@ -243,9 +278,9 @@ typedef struct {
|
||||
/*
|
||||
* This is the mode in which we must interpret graphics. This will
|
||||
* tell us not only if we're in lo- or hi-res, but also if we are in
|
||||
* single or double view mode.
|
||||
* single or double view mode. Among other things!
|
||||
*/
|
||||
int video_mode;
|
||||
vm_8bit display_mode;
|
||||
|
||||
/*
|
||||
* This is the color mode we want to emulate. You can have a few
|
||||
@ -288,6 +323,6 @@ extern void apple2_run_loop(apple2 *);
|
||||
extern void apple2_set_bank_switch(apple2 *, vm_8bit);
|
||||
extern void apple2_set_color(apple2 *, int);
|
||||
extern void apple2_set_memory_mode(apple2 *, vm_8bit);
|
||||
extern void apple2_set_video(apple2 *, int);
|
||||
extern void apple2_set_display(apple2 *, vm_8bit);
|
||||
|
||||
#endif
|
||||
|
18
src/apple2.c
18
src/apple2.c
@ -125,7 +125,7 @@ apple2_create(int width, int height)
|
||||
apple2_set_color(mach, COLOR_FULL);
|
||||
|
||||
// We default to lo-res mode.
|
||||
apple2_set_video(mach, VIDEO_LORES);
|
||||
apple2_set_display(mach, DISPLAY_DEFAULT);
|
||||
|
||||
// Let's install our bitmap font.
|
||||
mach->sysfont = vm_bitfont_create(mach->screen,
|
||||
@ -193,9 +193,7 @@ bool
|
||||
apple2_is_double_video(apple2 *mach)
|
||||
{
|
||||
return
|
||||
mach->video_mode == VIDEO_DOUBLE_HIRES ||
|
||||
mach->video_mode == VIDEO_DOUBLE_LORES ||
|
||||
mach->video_mode == VIDEO_80COL_TEXT;
|
||||
mach->display_mode & DISPLAY_DHIRES;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -255,7 +253,7 @@ apple2_reset(apple2 *mach)
|
||||
mach->cpu->S = 0;
|
||||
|
||||
// Switch video mode back to 40 column text
|
||||
apple2_set_video(mach, VIDEO_40COL_TEXT);
|
||||
apple2_set_display(mach, DISPLAY_DEFAULT);
|
||||
|
||||
// Switch us back to defaults
|
||||
apple2_set_bank_switch(mach, BANK_DEFAULT);
|
||||
@ -388,15 +386,15 @@ apple2_set_color(apple2 *mach, int mode)
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the video mode of the display. This would be the type of
|
||||
* Set the display mode of the display. This would be the type of
|
||||
* resolution (text by which number of columns, lo-res, hi-res, etc.)
|
||||
*/
|
||||
void
|
||||
apple2_set_video(apple2 *mach, int mode)
|
||||
apple2_set_display(apple2 *mach, vm_8bit mode)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
mach->video_mode = mode;
|
||||
mach->display_mode = mode;
|
||||
|
||||
// In the traditional video modes that Apple II first came in, you
|
||||
// would have a maximum width of 280 pixels. (In lo-res, you have
|
||||
@ -407,9 +405,7 @@ apple2_set_video(apple2 *mach, int mode)
|
||||
|
||||
// In double video modes, the width is effectively doubled, but the
|
||||
// height is untouched.
|
||||
if (mach->video_mode == VIDEO_DOUBLE_LORES ||
|
||||
mach->video_mode == VIDEO_DOUBLE_HIRES
|
||||
) {
|
||||
if (apple2_is_double_video(mach)) {
|
||||
width = 560;
|
||||
}
|
||||
|
||||
|
@ -34,29 +34,10 @@ Test(apple2, create)
|
||||
|
||||
Test(apple2, is_double_video)
|
||||
{
|
||||
for (int i = 0; i <= VIDEO_DOUBLE_HIRES; i++) {
|
||||
mach->video_mode = i;
|
||||
switch (i) {
|
||||
case VIDEO_40COL_TEXT:
|
||||
mach->display_mode = DISPLAY_DEFAULT;
|
||||
cr_assert_eq(apple2_is_double_video(mach), false);
|
||||
break;
|
||||
case VIDEO_LORES:
|
||||
cr_assert_eq(apple2_is_double_video(mach), false);
|
||||
break;
|
||||
case VIDEO_HIRES:
|
||||
cr_assert_eq(apple2_is_double_video(mach), false);
|
||||
break;
|
||||
case VIDEO_80COL_TEXT:
|
||||
mach->display_mode = DISPLAY_DHIRES;
|
||||
cr_assert_eq(apple2_is_double_video(mach), true);
|
||||
break;
|
||||
case VIDEO_DOUBLE_LORES:
|
||||
cr_assert_eq(apple2_is_double_video(mach), true);
|
||||
break;
|
||||
case VIDEO_DOUBLE_HIRES:
|
||||
cr_assert_eq(apple2_is_double_video(mach), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Test(apple2, boot)
|
||||
@ -109,12 +90,12 @@ Test(apple2, set_color)
|
||||
cr_assert_eq(mach->color_mode, COLOR_FULL);
|
||||
}
|
||||
|
||||
Test(apple2, set_video)
|
||||
Test(apple2, set_display)
|
||||
{
|
||||
apple2_set_video(mach, VIDEO_DOUBLE_HIRES);
|
||||
cr_assert_eq(mach->video_mode, VIDEO_DOUBLE_HIRES);
|
||||
apple2_set_video(mach, VIDEO_LORES);
|
||||
cr_assert_eq(mach->video_mode, VIDEO_LORES);
|
||||
apple2_set_display(mach, DISPLAY_DHIRES);
|
||||
cr_assert_eq(mach->display_mode, DISPLAY_DHIRES);
|
||||
apple2_set_display(mach, DISPLAY_TEXT);
|
||||
cr_assert_eq(mach->display_mode, DISPLAY_TEXT);
|
||||
}
|
||||
|
||||
Test(apple2, set_bank_switch)
|
||||
|
Loading…
Reference in New Issue
Block a user