Skip to content

Commit daeff74

Browse files
committed
MEGA65: matrix mode minor changes
Allow to use CTRL-TAB to toggle, no need to release CTRL. Also, using boolean type in some cases.
1 parent 66613f0 commit daeff74

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

targets/mega65/io_mapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ void io_write ( unsigned int addr, Uint8 data )
581581
virtkey(addr - 0x15, data & 0x7F);
582582
return;
583583
case 0x72: // "$D672.6 HCPU:MATRIXEN Enable composited Matrix Mode, and disable UART access to serial monitor."
584-
matrix_mode_toggle(data & 0x40);
584+
matrix_mode_toggle(!!(data & 0x40));
585585
return;
586586
case 0x7C: // hypervisor serial monitor port
587587
hypervisor_serial_monitor_push_char(data);

targets/mega65/matrix_mode.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
3939
#define DEBUGMATRIX(...)
4040

4141

42-
int in_the_matrix = 0;
42+
bool in_the_matrix = false;
4343

4444

4545
// TODO: many inventions here eventlually should be moved into some common place as
@@ -89,7 +89,6 @@ static int chrscreen_xsize, chrscreen_ysize;
8989
static Uint8 *vmem = NULL, *vmem_prev = NULL, *vmem_backup = NULL;
9090
static int current_x = 0, current_y = 0;
9191
static int need_update = 0;
92-
static int init_done = 0;
9392
static Uint8 queued_input;
9493
static unsigned int matrix_counter = 0;
9594
static int live_update_enabled = 1;
@@ -297,7 +296,7 @@ static void dump_map ( void )
297296

298297
static void cmd_off ( char *p )
299298
{
300-
matrix_mode_toggle(0);
299+
matrix_mode_toggle(false);
301300
}
302301

303302

@@ -785,7 +784,7 @@ static int kbd_cb_keyevent ( SDL_KeyboardEvent *ev )
785784
// Monitor ctrl-tab, as the main handler is defunct at this point, we "hijacked" it!
786785
// So we must give up the matrix mode themselves here
787786
if (sym == SDLK_TAB && (ev->keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)))
788-
matrix_mode_toggle(0);
787+
matrix_mode_toggle(false);
789788
else
790789
queued_input = sym;
791790
}
@@ -803,22 +802,22 @@ static int kbd_cb_textevent ( SDL_TextInputEvent *ev )
803802
}
804803

805804

806-
void matrix_mode_toggle ( int status )
805+
void matrix_mode_toggle ( const bool status )
807806
{
808807
if (!is_osd_enabled()) {
809808
ERROR_WINDOW("OSD is not enabled to be able to use Matrix mode.");
810809
return;
811810
}
812-
status = !!status;
813-
if (status == !!in_the_matrix)
811+
if (status == in_the_matrix)
814812
return;
815813
in_the_matrix = status;
816814
static int saved_allow_mouse_grab;
817815
if (in_the_matrix) {
816+
static bool init_done = false;
818817
D6XX_registers[0x72] |= 0x40; // be sure we're sync with the matrix bit!
819818
osd_hijack(matrix_updater_callback, &backend_xsize, &backend_ysize, &backend_pixels);
820819
if (!init_done) {
821-
init_done = 1;
820+
init_done = true;
822821
init_colour_mappings();
823822
chrscreen_xsize = backend_xsize / 8;
824823
chrscreen_ysize = backend_ysize / 8;
@@ -869,5 +868,10 @@ void matrix_mode_toggle ( int status )
869868
hid_register_sdl_textinput_event_callback(HID_CB_LEVEL_CONSOLE, NULL);
870869
allow_mouse_grab = saved_allow_mouse_grab;
871870
}
872-
clear_emu_events(); // cure problems, that triggering/switching-on/off matrix screen cause that ALT key remains latched etc ...
871+
// Original intent: cure problems, that triggering/switching-on/off matrix screen cause that ALT key remains latched etc ...
872+
// However it breaks the "rapid CTRL-TAB cycling" between matrix/normal mode (without releasing CTRL).
873+
// Now it seems, removing this call does not have any notable side-effect besides the original intent, so I try to remove it now.
874+
#if 0
875+
clear_emu_events();
876+
#endif
873877
}

targets/mega65/matrix_mode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1919
#ifndef XEMU_MEGA65_MATRIX_MODE_H_INCLUDED
2020
#define XEMU_MEGA65_MATRIX_MODE_H_INCLUDED
2121

22-
extern int in_the_matrix;
22+
extern bool in_the_matrix;
2323

24-
extern void matrix_mode_toggle ( int status );
24+
extern void matrix_mode_toggle ( const bool status );
2525

2626
#endif

targets/mega65/mega65.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ int main ( int argc, char **argv )
824824
emulation_is_running = 1;
825825
update_emulated_time_sources();
826826
if (configdb.matrixstart)
827-
matrix_mode_toggle(1);
827+
matrix_mode_toggle(true);
828828
// FIXME: for emscripten (anyway it does not work too much currently) there should be 50 or 60 (PAL/NTSC) instead of (fixed, and wrong!) 25!!!!!!
829829
XEMU_MAIN_LOOP(emulation_loop, 25, 1);
830830
return 0;

0 commit comments

Comments
 (0)