mirror of
https://github.com/pevans/erc-c.git
synced 2024-08-20 09:29:01 +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
|
#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 {
|
enum color_modes {
|
||||||
COLOR_GREEN,
|
COLOR_GREEN,
|
||||||
COLOR_AMBER,
|
COLOR_AMBER,
|
||||||
@ -154,6 +145,50 @@ enum memory_mode {
|
|||||||
MEMORY_SLOTC3ROM = 0x80,
|
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 {
|
enum bank_switch {
|
||||||
/*
|
/*
|
||||||
* In nominal bank-switch mode, reads in the bank-switchable address
|
* 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
|
* 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
|
* 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
|
* 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_bank_switch(apple2 *, vm_8bit);
|
||||||
extern void apple2_set_color(apple2 *, int);
|
extern void apple2_set_color(apple2 *, int);
|
||||||
extern void apple2_set_memory_mode(apple2 *, vm_8bit);
|
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
|
#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);
|
apple2_set_color(mach, COLOR_FULL);
|
||||||
|
|
||||||
// We default to lo-res mode.
|
// We default to lo-res mode.
|
||||||
apple2_set_video(mach, VIDEO_LORES);
|
apple2_set_display(mach, DISPLAY_DEFAULT);
|
||||||
|
|
||||||
// Let's install our bitmap font.
|
// Let's install our bitmap font.
|
||||||
mach->sysfont = vm_bitfont_create(mach->screen,
|
mach->sysfont = vm_bitfont_create(mach->screen,
|
||||||
@ -193,9 +193,7 @@ bool
|
|||||||
apple2_is_double_video(apple2 *mach)
|
apple2_is_double_video(apple2 *mach)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
mach->video_mode == VIDEO_DOUBLE_HIRES ||
|
mach->display_mode & DISPLAY_DHIRES;
|
||||||
mach->video_mode == VIDEO_DOUBLE_LORES ||
|
|
||||||
mach->video_mode == VIDEO_80COL_TEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -255,7 +253,7 @@ apple2_reset(apple2 *mach)
|
|||||||
mach->cpu->S = 0;
|
mach->cpu->S = 0;
|
||||||
|
|
||||||
// Switch video mode back to 40 column text
|
// 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
|
// Switch us back to defaults
|
||||||
apple2_set_bank_switch(mach, BANK_DEFAULT);
|
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.)
|
* resolution (text by which number of columns, lo-res, hi-res, etc.)
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
apple2_set_video(apple2 *mach, int mode)
|
apple2_set_display(apple2 *mach, vm_8bit mode)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
mach->video_mode = mode;
|
mach->display_mode = mode;
|
||||||
|
|
||||||
// In the traditional video modes that Apple II first came in, you
|
// 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
|
// 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
|
// In double video modes, the width is effectively doubled, but the
|
||||||
// height is untouched.
|
// height is untouched.
|
||||||
if (mach->video_mode == VIDEO_DOUBLE_LORES ||
|
if (apple2_is_double_video(mach)) {
|
||||||
mach->video_mode == VIDEO_DOUBLE_HIRES
|
|
||||||
) {
|
|
||||||
width = 560;
|
width = 560;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,29 +34,10 @@ Test(apple2, create)
|
|||||||
|
|
||||||
Test(apple2, is_double_video)
|
Test(apple2, is_double_video)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= VIDEO_DOUBLE_HIRES; i++) {
|
mach->display_mode = DISPLAY_DEFAULT;
|
||||||
mach->video_mode = i;
|
|
||||||
switch (i) {
|
|
||||||
case VIDEO_40COL_TEXT:
|
|
||||||
cr_assert_eq(apple2_is_double_video(mach), false);
|
cr_assert_eq(apple2_is_double_video(mach), false);
|
||||||
break;
|
mach->display_mode = DISPLAY_DHIRES;
|
||||||
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:
|
|
||||||
cr_assert_eq(apple2_is_double_video(mach), true);
|
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)
|
Test(apple2, boot)
|
||||||
@ -109,12 +90,12 @@ Test(apple2, set_color)
|
|||||||
cr_assert_eq(mach->color_mode, COLOR_FULL);
|
cr_assert_eq(mach->color_mode, COLOR_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(apple2, set_video)
|
Test(apple2, set_display)
|
||||||
{
|
{
|
||||||
apple2_set_video(mach, VIDEO_DOUBLE_HIRES);
|
apple2_set_display(mach, DISPLAY_DHIRES);
|
||||||
cr_assert_eq(mach->video_mode, VIDEO_DOUBLE_HIRES);
|
cr_assert_eq(mach->display_mode, DISPLAY_DHIRES);
|
||||||
apple2_set_video(mach, VIDEO_LORES);
|
apple2_set_display(mach, DISPLAY_TEXT);
|
||||||
cr_assert_eq(mach->video_mode, VIDEO_LORES);
|
cr_assert_eq(mach->display_mode, DISPLAY_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(apple2, set_bank_switch)
|
Test(apple2, set_bank_switch)
|
||||||
|
Loading…
Reference in New Issue
Block a user