Skip to content

Commit

Permalink
Add Apple IIGS autoswitch option without manual override
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSB committed Aug 4, 2021
1 parent 3960732 commit c3b3078
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
16 changes: 9 additions & 7 deletions src/defs.h
Expand Up @@ -474,13 +474,15 @@ typedef struct {
#define PALETTECONTROL_ATARI_GTIA 6
#define NUM_CONTROLS 7

#define AUTOSWITCH_OFF 0
#define AUTOSWITCH_PC 1
#define AUTOSWITCH_MODE7 2
#define AUTOSWITCH_VSYNC 3
#define AUTOSWITCH_IIGS 4
#define AUTOSWITCH_MANUAL 5
#define NUM_AUTOSWITCHES 6
#define AUTOSWITCH_OFF 0
#define AUTOSWITCH_PC 1
#define AUTOSWITCH_MODE7 2
#define AUTOSWITCH_VSYNC 3
#define AUTOSWITCH_IIGS 4
#define AUTOSWITCH_IIGS_MANUAL 5
#define AUTOSWITCH_MANUAL 6

#define NUM_AUTOSWITCHES 7

#define VSYNC_AUTO 0
#define VSYNC_INTERLACED 1
Expand Down
7 changes: 4 additions & 3 deletions src/osd.c
Expand Up @@ -175,6 +175,7 @@ static const char *autoswitch_names[] = {
"Sub + BBC Mode 7",
"Sub + Vsync",
"Sub + Apple IIGS",
"Sub + IIGS + Manual",
"Sub + Manual"
};

Expand Down Expand Up @@ -1030,7 +1031,7 @@ void set_menu_table() {
main_menu.items[index++] = (base_menu_item_t *) &profile_ref;
main_menu.items[index++] = (base_menu_item_t *) &autoswitch_ref;
main_menu.items[index++] = (base_menu_item_t *) &subprofile_ref;
if (get_autoswitch() == AUTOSWITCH_IIGS || get_autoswitch() == AUTOSWITCH_MANUAL) main_menu.items[index++] = (base_menu_item_t *) &timingset_ref;
if (get_autoswitch() == AUTOSWITCH_IIGS_MANUAL || get_autoswitch() == AUTOSWITCH_MANUAL) main_menu.items[index++] = (base_menu_item_t *) &timingset_ref;
if (single_button_mode) main_menu.items[index++] = (base_menu_item_t *) &direction_ref;
main_menu.items[index++] = NULL;
}
Expand Down Expand Up @@ -4685,7 +4686,7 @@ int osd_key(int key) {
int action;
if (single_button_mode) {
if (key_pressed == 0) {
if (get_autoswitch() == AUTOSWITCH_IIGS || get_autoswitch() == AUTOSWITCH_MANUAL) {
if (get_autoswitch() == AUTOSWITCH_IIGS_MANUAL || get_autoswitch() == AUTOSWITCH_MANUAL) {
set_feature(F_TIMINGSET, 1 - get_feature(F_TIMINGSET));
osd_state = TIMINGSET_MESSAGE;
} else {
Expand Down Expand Up @@ -4741,7 +4742,7 @@ int osd_key(int key) {
break;

case A2_CLOCK_CAL:
if (get_autoswitch() == AUTOSWITCH_IIGS || get_autoswitch() == AUTOSWITCH_MANUAL) {
if (get_autoswitch() == AUTOSWITCH_IIGS_MANUAL || get_autoswitch() == AUTOSWITCH_MANUAL) {
set_feature(F_TIMINGSET, 1 - get_feature(F_TIMINGSET));
ret = 1;
osd_state = TIMINGSET_MESSAGE;
Expand Down
20 changes: 13 additions & 7 deletions src/rgb_to_fb.S
Expand Up @@ -465,22 +465,27 @@ glitch_detected:

no_vsync_test:
cmp r9, #AUTOSWITCH_IIGS
cmpne r9, #AUTOSWITCH_IIGS_MANUAL
bne no_mode_test
ldr r9, frame_countdown
cmp r9, #0
ldr r10, frame_countdown
cmp r10, #0
bne no_mode_test
ldr r7, vsync_detected
ldr r8, ntsc_status
mov r9, r8
mov r10, r8
cmp r7, #IIGS_DETECTED_LINE_COUNT
biclt r8, #NTSC_LAST_IIGS // set1
orrge r8, #NTSC_LAST_IIGS // set2
str r8, ntsc_status
eor r9, r9, r8
tst r9, #NTSC_LAST_IIGS
eor r10, r10, r8
mov r8, r8, lsr #NTSC_LAST_IIGS_SHIFT
and r8, r8, #1
cmp r9, #AUTOSWITCH_IIGS
moveq r0, r8
moveq r10, #0 //so branch test fails
tst r10, #NTSC_LAST_IIGS
beq no_mode_test
mov r0, r8, lsr #NTSC_LAST_IIGS_SHIFT
and r0, r0, #1
mov r0, r8
push {r0 - r12}
bl set_timingset
pop {r0 - r12}
Expand Down Expand Up @@ -792,6 +797,7 @@ mod10:
bic r3, #BITDUP_IIGS_DETECT
ldr r0, param_autoswitch
cmp r0, #AUTOSWITCH_IIGS
cmpne r0, #AUTOSWITCH_IIGS_MANUAL
orreq r3, #BITDUP_IIGS_DETECT

bic r3, #BITDUP_FFOSD_DETECTED
Expand Down
4 changes: 2 additions & 2 deletions src/rgb_to_hdmi.c
Expand Up @@ -3332,14 +3332,14 @@ void rgb_to_hdmi_main() {

last_modeset = modeset;

if (autoswitch == AUTOSWITCH_MODE7 || autoswitch == AUTOSWITCH_VSYNC) {
if (autoswitch == AUTOSWITCH_MODE7 || autoswitch == AUTOSWITCH_VSYNC || autoswitch == AUTOSWITCH_IIGS) {
if (result & RET_MODESET) {
modeset = MODE_SET2;
} else {
modeset = MODE_SET1;
}

} else if (autoswitch == AUTOSWITCH_MANUAL || autoswitch == AUTOSWITCH_IIGS) {
} else if (autoswitch == AUTOSWITCH_MANUAL || autoswitch == AUTOSWITCH_IIGS_MANUAL) {
modeset = timingset;
} else {
modeset = MODE_SET1;
Expand Down

0 comments on commit c3b3078

Please sign in to comment.