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

Add video mode switcher to handle logical sizes

This commit is contained in:
Peter Evans 2017-12-20 21:52:28 -06:00
parent 7d62548248
commit 23e113e72a
2 changed files with 40 additions and 0 deletions

View File

@ -5,6 +5,13 @@
#include "mos6502.h"
#include "vm_screen.h"
enum video_modes {
VIDEO_LORES,
VIDEO_HIRES,
VIDEO_DOUBLE_LORES,
VIDEO_DOUBLE_HIRES,
};
typedef struct {
/*
* The apple 2 hardware used an MOS-6502 processor.
@ -23,6 +30,13 @@ typedef struct {
*/
vm_screen *screen;
/*
* 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.
*/
int video_mode;
/*
* Our two disk drives.
*/
@ -37,5 +51,6 @@ extern void apple2_clear_strobe(apple2 *);
extern void apple2_release_key(apple2 *);
extern int apple2_boot(apple2 *);
extern void apple2_run_loop(apple2 *);
extern void apple2_set_video(apple2 *, int);
#endif

View File

@ -156,3 +156,28 @@ apple2_boot(apple2 *mach)
return OK;
}
void
apple2_set_video(apple2 *mach, int mode)
{
int width, height;
mach->video_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
// fewer pixels, but that is something we have to handle in our
// drawing functions rather than by changing the logical size.)
width = 280;
height = 192;
// 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
) {
width = 560;
}
vm_screen_set_logical_coords(mach->screen, width, height);
}