diff --git a/src/emu_actions.c b/src/emu_actions.c index 1d334e4..1261835 100644 --- a/src/emu_actions.c +++ b/src/emu_actions.c @@ -13,9 +13,9 @@ static int interrupt_called = 0; extern long nibble_masks[ 16 ]; -bool got_alarm; +bool got_alarm = false; -int first_press = 1; // PATCH +bool first_press = true; // PATCH int conf_bank1 = 0x00000; int conf_bank2 = 0x00000; @@ -48,9 +48,9 @@ void do_in( void ) for ( i = 0; i < 9; i++ ) if ( out & ( 1 << i ) ) saturn.keybuf.rows[ i ] = 0; - first_press = 1; + first_press = true; } else - first_press = 0; + first_press = false; // FIN PATCH @@ -124,19 +124,19 @@ void do_reset( void ) } } -void do_inton( void ) { saturn.kbd_ien = 1; } +void do_inton( void ) { saturn.kbd_ien = true; } -void do_intoff( void ) { saturn.kbd_ien = 0; } +void do_intoff( void ) { saturn.kbd_ien = false; } void do_return_interupt( void ) { if ( saturn.int_pending ) { - saturn.int_pending = 0; - saturn.interruptable = 0; + saturn.int_pending = false; + saturn.interruptable = false; saturn.PC = 0xf; } else { saturn.PC = pop_return_addr(); - saturn.interruptable = 1; + saturn.interruptable = true; if ( adj_time_pending ) { schedule_event = 0; @@ -151,7 +151,7 @@ void do_interupt( void ) if ( saturn.interruptable ) { push_return_addr( saturn.PC ); saturn.PC = 0xf; - saturn.interruptable = 0; + saturn.interruptable = false; } } @@ -159,12 +159,12 @@ void do_kbd_int( void ) { do_interupt(); if ( !saturn.interruptable ) - saturn.int_pending = 1; + saturn.int_pending = true; } void do_reset_interrupt_system( void ) { - saturn.kbd_ien = 1; + saturn.kbd_ien = true; int gen_intr = 0; for ( int i = 0; i < 9; i++ ) { if ( saturn.keybuf.rows[ i ] != 0 ) { @@ -289,8 +289,8 @@ void do_shutdown( void ) start_timer( IDLE_TIMER ); if ( is_zero_register( saturn.OUT, OUT_FIELD ) ) { - saturn.interruptable = 1; - saturn.int_pending = 0; + saturn.interruptable = true; + saturn.int_pending = false; } int wake = ( in_debugger ) ? 1 : 0; @@ -500,10 +500,10 @@ void recall_n( unsigned char* reg, word_20 dat, int n ) void press_key( int hpkey ) { // Check not already pressed (may be important: avoids a useless do_kbd_int) - if ( keyboard[ hpkey ].pressed == 1 ) + if ( keyboard[ hpkey ].pressed ) return; - keyboard[ hpkey ].pressed = 1; + keyboard[ hpkey ].pressed = true; int code = keyboard[ hpkey ].code; if ( code == 0x8000 ) { /* HPKEY_ON */ @@ -527,10 +527,10 @@ void press_key( int hpkey ) void release_key( int hpkey ) { // Check not already released (not critical) - if ( keyboard[ hpkey ].pressed == 0 ) + if ( !keyboard[ hpkey ].pressed ) return; - keyboard[ hpkey ].pressed = 0; + keyboard[ hpkey ].pressed = false; int code = keyboard[ hpkey ].code; if ( code == 0x8000 ) { diff --git a/src/emu_emulate.c b/src/emu_emulate.c index 706632e..ed61c4c 100644 --- a/src/emu_emulate.c +++ b/src/emu_emulate.c @@ -27,7 +27,7 @@ unsigned long instructions = 0; unsigned long old_instr = 0; int rece_instr = 0; -int device_check = 0; +bool device_check = false; int adj_time_pending = 0; @@ -74,8 +74,6 @@ static word_20 jumpmasks[] = { 0xffffffff, 0xfffffff0, 0xffffff00, 0xfffff000, 0 saturn_t saturn; -extern int device_check; - device_t device; int decode_group_80( void ) @@ -2182,7 +2180,7 @@ inline void schedule( void ) schedule_event = sched_timer2; if ( device_check ) { - device_check = 0; + device_check = false; if ( ( sched_display -= steps ) <= 0 ) { if ( device.display_touched ) device.display_touched -= steps; @@ -2198,37 +2196,37 @@ inline void schedule( void ) } if ( device.display_touched > 0 ) - device_check = 1; + device_check = true; if ( device.contrast_touched ) { - device.contrast_touched = 0; + device.contrast_touched = false; ui_adjust_contrast(); } if ( device.ann_touched ) { - device.ann_touched = 0; + device.ann_touched = false; ui_draw_annunc(); } /* serial */ if ( device.baud_touched ) { - device.baud_touched = 0; + device.baud_touched = false; serial_baud( saturn.baud ); } if ( device.ioc_touched ) { - device.ioc_touched = 0; + device.ioc_touched = false; if ( ( saturn.io_ctrl & 0x02 ) && ( saturn.rcs & 0x01 ) ) do_interupt(); } if ( device.rbr_touched ) { - device.rbr_touched = 0; + device.rbr_touched = false; receive_char(); } if ( device.tbr_touched ) { - device.tbr_touched = 0; + device.tbr_touched = false; transmit_char(); } @@ -2237,13 +2235,13 @@ inline void schedule( void ) sched_timer1 = saturn.t1_tick; restart_timer( T1_TIMER ); set_t1 = saturn.timer1; - device.t1_touched = 0; + device.t1_touched = false; } if ( device.t2_touched ) { saturn.t2_instr = 0; sched_timer2 = saturn.t2_tick; - device.t2_touched = 0; + device.t2_touched = false; } /* end check_device() */ diff --git a/src/emu_init.c b/src/emu_init.c index fe74be3..8dbea9b 100644 --- a/src/emu_init.c +++ b/src/emu_init.c @@ -133,10 +133,10 @@ void saturn_config_init( void ) saturn.version[ 1 ] = VERSION_MINOR; saturn.version[ 2 ] = PATCHLEVEL; memset( &device, 0, sizeof( device ) ); - device.display_touched = 1; - device.contrast_touched = 1; - device.baud_touched = 1; - device.ann_touched = 1; + device.display_touched = true; + device.contrast_touched = true; + device.baud_touched = true; + device.ann_touched = true; saturn.rcs = 0x0; saturn.tcs = 0x0; saturn.lbr = 0x0; @@ -155,9 +155,9 @@ void init_saturn( void ) saturn.version[ 2 ] = PATCHLEVEL; saturn.hexmode = HEX; saturn.rstkp = -1; - saturn.interruptable = 1; - saturn.int_pending = 0; - saturn.kbd_ien = 1; + saturn.interruptable = true; + saturn.int_pending = false; + saturn.kbd_ien = true; saturn.timer1 = 0; saturn.timer2 = 0x2000; saturn.bank_switch = 0; diff --git a/src/emu_memory.c b/src/emu_memory.c index c02df12..bd27606 100644 --- a/src/emu_memory.c +++ b/src/emu_memory.c @@ -47,7 +47,7 @@ void write_dev_mem( long addr, int val ) { static int old_line_offset = -1; - device_check = 1; + device_check = true; schedule_event = 0; switch ( ( int )addr ) { case 0x100: /* DISPIO */ @@ -67,17 +67,17 @@ void write_dev_mem( long addr, int val ) saturn.contrast_ctrl = val; display.contrast &= ~0x0f; display.contrast |= val; - device.contrast_touched = 1; + device.contrast_touched = true; return; case 0x102: /* DISPLAY TEST */ display.contrast &= ~0xf0; display.contrast |= ( ( val & 0x1 ) << 4 ); - device.contrast_touched = 1; + device.contrast_touched = true; /* Fall through */ case 0x103: /* DISPLAY TEST */ saturn.disp_test &= ~nibble_masks[ addr - 0x102 ]; saturn.disp_test |= val << ( ( addr - 0x102 ) * 4 ); - device.disp_test_touched = 1; + device.disp_test_touched = true; return; case 0x104: case 0x105: @@ -88,25 +88,25 @@ void write_dev_mem( long addr, int val ) return; case 0x108: /* POWER STATUS */ saturn.power_status = val; - device.power_status_touched = 1; + device.power_status_touched = true; return; case 0x109: /* POWER CONTROL */ saturn.power_ctrl = val; - device.power_ctrl_touched = 1; + device.power_ctrl_touched = true; return; case 0x10a: /* MODE */ saturn.mode = val; - device.mode_touched = 1; + device.mode_touched = true; return; case 0x10b: case 0x10c: /* ANNUNC */ saturn.annunc &= ~nibble_masks[ addr - 0x10b ]; saturn.annunc |= val << ( ( addr - 0x10b ) * 4 ); - device.ann_touched = 1; + device.ann_touched = true; return; case 0x10d: /* BAUD */ saturn.baud = val; - device.baud_touched = 1; + device.baud_touched = true; return; case 0x10e: /* CARD CONTROL */ saturn.card_ctrl = val; @@ -114,13 +114,13 @@ void write_dev_mem( long addr, int val ) saturn.MP = 1; if ( saturn.card_ctrl & 0x01 ) do_interupt(); - device.card_ctrl_touched = 1; + device.card_ctrl_touched = true; return; case 0x10f: /* CARD STATUS */ return; case 0x110: /* IO CONTROL */ saturn.io_ctrl = val; - device.ioc_touched = 1; + device.ioc_touched = true; return; case 0x111: /* RCS */ saturn.rcs = val; @@ -139,37 +139,37 @@ void write_dev_mem( long addr, int val ) saturn.tbr &= ~nibble_masks[ addr - 0x116 ]; saturn.tbr |= val << ( ( addr - 0x116 ) * 4 ); saturn.tcs |= 0x01; - device.tbr_touched = 1; + device.tbr_touched = true; return; case 0x118: case 0x119: /* SERVICE REQ */ saturn.sreq &= ~nibble_masks[ addr - 0x118 ]; saturn.sreq |= val << ( ( addr - 0x118 ) * 4 ); - device.sreq_touched = 1; + device.sreq_touched = true; return; case 0x11a: /* IR CONTROL */ saturn.ir_ctrl = val; - device.ir_ctrl_touched = 1; + device.ir_ctrl_touched = true; return; case 0x11b: /* BASE NIB OFFSET */ saturn.base_off = val; - device.base_off_touched = 1; + device.base_off_touched = true; return; case 0x11c: /* LED CONTROL */ saturn.lcr = val; - device.lcr_touched = 1; + device.lcr_touched = true; return; case 0x11d: /* LED BUFFER */ saturn.lbr = val; - device.lbr_touched = 1; + device.lbr_touched = true; return; case 0x11e: /* SCRATCH PAD */ saturn.scratch = val; - device.scratch_touched = 1; + device.scratch_touched = true; return; case 0x11f: /* BASENIBBLE */ saturn.base_nibble = val; - device.base_nibble_touched = 1; + device.base_nibble_touched = true; return; case 0x120: case 0x121: @@ -218,15 +218,15 @@ void write_dev_mem( long addr, int val ) case 0x12d: /* Dont know yet */ saturn.unknown &= ~nibble_masks[ addr - 0x12a ]; saturn.unknown |= val << ( ( addr - 0x12a ) * 4 ); - device.unknown_touched = 1; + device.unknown_touched = true; return; case 0x12e: /* TIMER 1 CONTROL */ saturn.t1_ctrl = val; - device.t1_ctrl_touched = 1; + device.t1_ctrl_touched = true; return; case 0x12f: /* TIMER 2 CONTROL */ saturn.t2_ctrl = val; - device.t2_ctrl_touched = 1; + device.t2_ctrl_touched = true; return; case 0x130: case 0x131: @@ -245,11 +245,11 @@ void write_dev_mem( long addr, int val ) case 0x136: /* Dont know yet 2 */ saturn.unknown2 &= ~nibble_masks[ addr - 0x135 ]; saturn.unknown2 |= val << ( ( addr - 0x135 ) * 4 ); - device.unknown2_touched = 1; + device.unknown2_touched = true; return; case 0x137: /* TIMER1 */ saturn.timer1 = val; - device.t1_touched = 1; + device.t1_touched = true; return; case 0x138: case 0x139: @@ -261,7 +261,7 @@ void write_dev_mem( long addr, int val ) case 0x13f: /* TIMER2 */ saturn.timer2 &= ~nibble_masks[ addr - 0x138 ]; saturn.timer2 |= val << ( ( addr - 0x138 ) * 4 ); - device.t2_touched = 1; + device.t2_touched = true; return; default: if ( verbose ) @@ -311,8 +311,8 @@ int read_dev_mem( long addr ) case 0x114: case 0x115: /* RBR */ saturn.rcs &= 0x0e; - device.rbr_touched = 1; - device_check = 1; + device.rbr_touched = true; + device_check = true; schedule_event = 0; return ( saturn.rbr >> ( ( addr - 0x114 ) * 4 ) ) & 0x0f; case 0x116: diff --git a/src/emulator.h b/src/emulator.h index b471e21..8418c75 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -105,53 +105,53 @@ typedef struct t1_t2_ticks { typedef struct device_t { int display_touched; - char contrast_touched; + bool contrast_touched; - char disp_test_touched; + bool disp_test_touched; /* unused */ - char crc_touched; + bool crc_touched; /* unused */ - char power_status_touched; - char power_ctrl_touched; + bool power_status_touched; /* unused */ + bool power_ctrl_touched; /* unused */ - char mode_touched; + bool mode_touched; /* unused */ - char ann_touched; + bool ann_touched; - char baud_touched; + bool baud_touched; - char card_ctrl_touched; - char card_status_touched; + bool card_ctrl_touched; /* unused */ + bool card_status_touched; /* unused */ - char ioc_touched; + bool ioc_touched; - char tcs_touched; - char rcs_touched; + bool tcs_touched; /* unused */ + bool rcs_touched; /* unused */ - char rbr_touched; - char tbr_touched; + bool rbr_touched; + bool tbr_touched; - char sreq_touched; + bool sreq_touched; /* unused */ - char ir_ctrl_touched; + bool ir_ctrl_touched; /* unused */ - char base_off_touched; + bool base_off_touched; /* unused */ - char lcr_touched; - char lbr_touched; + bool lcr_touched; /* unused */ + bool lbr_touched; /* unused */ - char scratch_touched; - char base_nibble_touched; + bool scratch_touched; /* unused */ + bool base_nibble_touched; /* unused */ - char unknown_touched; + bool unknown_touched; /* unused */ - char t1_ctrl_touched; - char t2_ctrl_touched; + bool t1_ctrl_touched; /* unused */ + bool t2_ctrl_touched; /* unused */ - char unknown2_touched; + bool unknown2_touched; /* unused */ - char t1_touched; - char t2_touched; + bool t1_touched; + bool t2_touched; } device_t; typedef struct keystate_t { @@ -160,7 +160,7 @@ typedef struct keystate_t { typedef struct hpkey_t { int code; - short pressed; + bool pressed; } hpkey_t; typedef struct display_t { @@ -214,9 +214,9 @@ typedef struct saturn_t { keystate_t keybuf; - unsigned char interruptable; - unsigned char int_pending; - unsigned char kbd_ien; + unsigned char interruptable; /* bool */ + unsigned char int_pending; /* bool */ + unsigned char kbd_ien; /* bool */ word_4 disp_io; @@ -307,7 +307,7 @@ extern display_t display; extern saturn_t saturn; -extern int device_check; +extern bool device_check; extern short port1_is_ram; extern long port1_mask; extern short port2_is_ram;