diff --git a/tests/apple2.c b/tests/apple2.c index a4a5bbe..585b953 100644 --- a/tests/apple2.c +++ b/tests/apple2.c @@ -28,27 +28,31 @@ Test(apple2, create) cr_assert_neq(mach->drive2, NULL); } -Test(apple2, press_key) +Test(apple2, is_double_video) { - apple2_press_key(mach, 123); - cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123 | 0x80); - cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0x80); -} - -Test(apple2, clear_strobe) -{ - apple2_press_key(mach, 123); - cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123 | 0x80); - apple2_clear_strobe(mach); - cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123); -} - -Test(apple2, release_key) -{ - apple2_press_key(mach, 123); - cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0x80); - apple2_release_key(mach); - cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0); + for (int i = 0; i <= VIDEO_DOUBLE_HIRES; i++) { + mach->video_mode = i; + switch (i) { + case VIDEO_40COL_TEXT: + 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: + 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) @@ -65,3 +69,46 @@ Test(apple2, boot) option_read_file(2, "../data/bad.img"); cr_assert_neq(apple2_boot(mach), OK); } + +Test(apple2, press_key) +{ + apple2_press_key(mach, 123); + cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123 | 0x80); + cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0x80); +} + +Test(apple2, clear_strobe) +{ + apple2_press_key(mach, 123); + cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123 | 0x80); + apple2_clear_strobe(mach); + cr_assert_eq(vm_segment_get(mach->memory, 0xC000), 123); +} + +/* + * This also tests the press_key function (as does the clear_strobe + * test, in its own way). + */ +Test(apple2, release_key) +{ + apple2_press_key(mach, 123); + cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0x80); + apple2_release_key(mach); + cr_assert_eq(vm_segment_get(mach->memory, 0xC010), 0); +} + +Test(apple2, set_color) +{ + apple2_set_color(mach, COLOR_AMBER); + cr_assert_eq(mach->color_mode, COLOR_AMBER); + apple2_set_color(mach, COLOR_FULL); + cr_assert_eq(mach->color_mode, COLOR_FULL); +} + +Test(apple2, set_video) +{ + 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); +}