1
0
mirror of https://github.com/pevans/erc-c.git synced 2025-03-05 21:30:45 +00:00

Reorganize

This commit is contained in:
Peter Evans 2017-12-26 16:39:23 -06:00
parent f50d599545
commit f5af03786d

@ -78,23 +78,57 @@ apple2_create(int width, int height)
return mach; return mach;
} }
void bool
apple2_set_color(apple2 *mach, int mode) apple2_is_double_video(apple2 *mach)
{ {
mach->color_mode = mode; return
mach->video_mode == VIDEO_DOUBLE_HIRES ||
// FIXME: doing this should force us to redraw everything in the mach->video_mode == VIDEO_DOUBLE_LORES ||
// correct color interpretation mach->video_mode == VIDEO_80COL_TEXT;
} }
void int
apple2_run_loop(apple2 *mach) apple2_boot(apple2 *mach)
{ {
while (vm_screen_active(mach->screen)) { FILE *stream;
vm_screen_refresh(mach->screen); int err;
// Do we have any disks?
stream = option_get_input(1);
if (stream) {
err = apple2dd_insert(mach->drive1, stream);
if (err != OK) {
log_critical("Unable to insert disk1 into drive");
return err;
} }
} }
stream = option_get_input(2);
if (stream) {
err = apple2dd_insert(mach->drive2, stream);
if (err != OK) {
log_critical("Unable to insert disk2 into drive");
return err;
}
}
return OK;
}
/*
* This function will clear the 8th bit, which is the "strobe" bit, from
* the position in memory where the value of the last key that was
* pressed is held.
*/
void
apple2_clear_strobe(apple2 *mach)
{
vm_8bit ch;
ch = vm_segment_get(mach->memory, LAST_KEY);
vm_segment_set(mach->memory, LAST_KEY, ch & 0x7F);
}
/* /*
* Free the memory reserved for an apple2 struct. * Free the memory reserved for an apple2 struct.
*/ */
@ -130,20 +164,6 @@ apple2_press_key(apple2 *mach, vm_8bit ch)
vm_segment_set(mach->memory, ANY_KEY_DOWN, 0x80); vm_segment_set(mach->memory, ANY_KEY_DOWN, 0x80);
} }
/*
* This function will clear the 8th bit, which is the "strobe" bit, from
* the position in memory where the value of the last key that was
* pressed is held.
*/
void
apple2_clear_strobe(apple2 *mach)
{
vm_8bit ch;
ch = vm_segment_get(mach->memory, LAST_KEY);
vm_segment_set(mach->memory, LAST_KEY, ch & 0x7F);
}
/* /*
* This function will clear the value of the any-key-down switch/flag. * This function will clear the value of the any-key-down switch/flag.
*/ */
@ -153,32 +173,21 @@ apple2_release_key(apple2 *mach)
vm_segment_set(mach->memory, ANY_KEY_DOWN, 0); vm_segment_set(mach->memory, ANY_KEY_DOWN, 0);
} }
int void
apple2_boot(apple2 *mach) apple2_run_loop(apple2 *mach)
{ {
FILE *stream; while (vm_screen_active(mach->screen)) {
int err; vm_screen_refresh(mach->screen);
// Do we have any disks?
stream = option_get_input(1);
if (stream) {
err = apple2dd_insert(mach->drive1, stream);
if (err != OK) {
log_critical("Unable to insert disk1 into drive");
return err;
} }
} }
stream = option_get_input(2); void
if (stream) { apple2_set_color(apple2 *mach, int mode)
err = apple2dd_insert(mach->drive2, stream); {
if (err != OK) { mach->color_mode = mode;
log_critical("Unable to insert disk2 into drive");
return err;
}
}
return OK; // FIXME: doing this should force us to redraw everything in the
// correct color interpretation
} }
void void
@ -205,12 +214,3 @@ apple2_set_video(apple2 *mach, int mode)
vm_screen_set_logical_coords(mach->screen, width, height); vm_screen_set_logical_coords(mach->screen, width, height);
} }
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;
}