diff --git a/src/boot.c b/src/boot.c index 71e9688..9cb69f2 100644 --- a/src/boot.c +++ b/src/boot.c @@ -108,7 +108,7 @@ void boot_animate_keyboard(unsigned long max_ticks, unsigned long ticks, unsigne * * @return 0 if not bootable, non-zero if bootable */ -short is_bootable(unsigned char * sector, short device) { +bool is_bootable(unsigned char * sector, short device) { switch(device) { case BDEV_FDC: // The SDC and HDC boot off the MBR... @@ -118,7 +118,7 @@ short is_bootable(unsigned char * sector, short device) { if ((sector[BOOT_SIG_VBR_OFF] == ((BOOT_SIG >> 8) & 0x00FF)) && (sector[BOOT_SIG_VBR_OFF+1] == (BOOT_SIG & 0x00FF))) { // The CPU is supported, and the boot signature is correct - return 1; + return true; } } break; @@ -132,7 +132,7 @@ short is_bootable(unsigned char * sector, short device) { if ((sector[BOOT_SIG_MBR_OFF] == ((BOOT_SIG >> 8) & 0x00FF)) && (sector[BOOT_SIG_MBR_OFF+1] == (BOOT_SIG & 0x00FF))) { // The CPU is supported, and the boot signature is correct - return 1; + return true; } } break; @@ -143,7 +143,7 @@ short is_bootable(unsigned char * sector, short device) { } // If we have reached this point, the sector is not bootable - return 0; + return false; } /** diff --git a/src/cli/dos_copy.c b/src/cli/dos_copy.c index e7a2403..f4fa0f6 100644 --- a/src/cli/dos_copy.c +++ b/src/cli/dos_copy.c @@ -56,17 +56,17 @@ * Check to see if the path points to a directory * * @param path the path to check - * @return 1 if the path points to a directory, 0 otherwise + * @return true if the path points to a directory, false otherwise */ -short is_directory(const char * path) { +bool is_directory(const char * path) { t_file_info file; short result = sys_fsys_stat(path, &file); if ((result < 0) || ((file.attributes & FSYS_AM_DIR) == 0)) { - return 0; + return false; } - return 1; + return true; } /** diff --git a/src/dev/console.c b/src/dev/console.c index 7f0903a..862b739 100644 --- a/src/dev/console.c +++ b/src/dev/console.c @@ -94,15 +94,15 @@ const t_ansi_seq ansi_sequence[] = { * c = the character to test * * Returns: - * 0 if the character is not an ANSI initial, 1 if it is + * false if the character is not an ANSI initial, true if it is */ -short ansi_start_code(char c) { +bool ansi_start_code(char c) { switch (c) { case '\x1b': - return 1; + return true; default: - return 0; + return false; } } @@ -650,7 +650,7 @@ short con_write(p_channel chan, const uint8_t * buffer, short size) { return i; } -short con_has_input(p_channel chan) { +bool con_has_input(p_channel chan) { p_console_data con_data; char c; @@ -659,7 +659,7 @@ short con_has_input(p_channel chan) { if (con_data->key_buffer != 0) { /* If we already peeked and have a character... return true */ - return 1; + return true; } else { /* Otherwise, peek at the keyboard to see if there is a valid key */ @@ -681,12 +681,12 @@ short con_has_input(p_channel chan) { if (c == 0) { /* No: return false */ - return 0; + return false; } else { /* Yes: save the key we got and return true */ con_data->key_buffer = c; - return 1; + return true; } } } diff --git a/src/dev/fdc.c b/src/dev/fdc.c index 22271e2..aee7b47 100644 --- a/src/dev/fdc.c +++ b/src/dev/fdc.c @@ -114,16 +114,16 @@ void fdc_media_change() { * Check to see if the media has changed * If so, recalibrate the drive and flag the change */ -short fdc_media_check_change() { +bool fdc_media_check_change() { // Check for the a disk change if (*FDC_DIR & 0x80) { // The disk has changed... recalibrate and set that it's changed fdc_recalibrate(); fdc_seek(1); g_fdc_stat = FDC_STAT_NOINIT; - return 1; + return true; } - return 0; + return false; } /* diff --git a/src/dev/fsys.c b/src/dev/fsys.c index d08ec48..8996415 100644 --- a/src/dev/fsys.c +++ b/src/dev/fsys.c @@ -1277,14 +1277,14 @@ static bool loader_exists(const char * extension) { for (i = 0; i < MAX_LOADERS; i++) { if (g_file_loader[i].status) { if (strcmp(g_file_loader[i].extension, extension) == 0) { - return 1; + return true; } } } - return 0; + return false; } -static int get_app_ext(const char * path, char * extension) { +static bool get_app_ext(const char * path, char * extension) { char * point = strrchr(path, '.'); extension[0] = 0; if (point != 0) { @@ -1295,11 +1295,11 @@ static int get_app_ext(const char * path, char * extension) { extension[i] = toupper(c); } else { extension[i] = 0; - return 1; + return true; } } } else { - return 0; + return false; } } diff --git a/src/dev/kbd_mo.c b/src/dev/kbd_mo.c index c80bc8e..5f999b1 100644 --- a/src/dev/kbd_mo.c +++ b/src/dev/kbd_mo.c @@ -274,21 +274,21 @@ void kbdmo_flush_out() { /* * Check to see if a BREAK code has been pressed recently - * If so, return 1 and reset the internal flag. + * If so, return true and reset the internal flag. * * BREAK will be F-ESC on the A2560K * * Returns: - * 1 if a BREAK has been pressed since the last check + * true if a BREAK has been pressed since the last check */ -short kbdmo_break() { +bool kbdmo_break() { if (g_kbdmo_control.status & KBD_STAT_BREAK) { /* BREAK was pressed: clear the flag and return a 1 */ g_kbdmo_control.status &= ~KBD_STAT_BREAK; - return 1; + return true; } else { /* BREAK was not pressed: return a 0 */ - return 0; + return false; } } diff --git a/src/dev/kbd_mo.h b/src/dev/kbd_mo.h index 6153c17..b44ebdc 100644 --- a/src/dev/kbd_mo.h +++ b/src/dev/kbd_mo.h @@ -35,14 +35,14 @@ void kbdmo_set_led_matrix_fill(unsigned short color); /* * Check to see if a BREAK code has been pressed recently - * If so, return 1 and reset the internal flag. + * If so, return true and reset the internal flag. * * BREAK will be F-ESC on the A2560K * * Returns: - * 1 if a BREAK has been pressed since the last check + * true if a BREAK has been pressed since the last check */ -extern short kbdmo_break(); +extern bool kbdmo_break(); /* * Try to retrieve the next scancode from the keyboard. diff --git a/src/dev/midi.c b/src/dev/midi.c index f102df7..14db987 100644 --- a/src/dev/midi.c +++ b/src/dev/midi.c @@ -18,37 +18,37 @@ const long midi_timeout = 60; /** * Wait for data to be ready to read... * - * @return 1 on success, 0 if there is a timeout + * @return true on success, false if there is a timeout */ -short midi_can_read() { +bool midi_can_read() { long target = timers_jiffies() + midi_timeout; do { if ((*MIDI_STAT & MIDI_STAT_RX_EMPTY) == 0) { // There is data waiting - return 1; + return true; } } while (target > timers_jiffies()); // We have waited too long - return 0; + return false; } /** * Wait for the MIDI transmiter to be empty... * - * @return 1 on success, 0 if there is a timeout + * @return true on success, false if there is a timeout */ short midi_can_write() { long target = timers_jiffies() + midi_timeout; do { if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) != 0) { // The transmit buffer is empty - return 1; + return true; } } while (target > timers_jiffies()); // We have waited too long - return 0; + return false; } /** diff --git a/src/dev/uart.c b/src/dev/uart.c index 57a1faa..d9edb39 100644 --- a/src/dev/uart.c +++ b/src/dev/uart.c @@ -104,40 +104,24 @@ void uart_init(short uart) { * uart = the number of the UART: 0 for COM1, 1 for COM2 * * Returns: - * non-zero if there is data to read, 0 if there is no data. + * true if there is data to read, false if there is no data. */ -short uart_has_bytes(short uart) { +bool uart_has_bytes(short uart) { volatile unsigned char * uart_base = uart_get_base(uart); - if (uart_base) { - if (uart_base[UART_LSR] & LSR_DATA_AVAIL) { - return 1; - } else { - return 0; - } - } else { - return 0; - } + return uart_base && (uart_base[UART_LSR] & LSR_DATA_AVAIL) ? true : false; } /** * Return true (non-zero) if the UART transmit FIFO is not full * * @param uart the number of the UART: 0 for COM1, 1 for COM2 - * @return non-zero if the FIFO can accept a byte, 0 if it is full + * @return non-zero if the FIFO can accept a byte, false if it is full */ -short uart_can_send(short uart) { +bool uart_can_send(short uart) { volatile unsigned char * uart_base = uart_get_base(uart); - if (uart_base) { - if (uart_base[UART_LSR] & LSR_XMIT_EMPTY) { - return 1; - } else { - return 0; - } - } else { - return 0; - } + return uart_base && (uart_base[UART_LSR] & LSR_XMIT_EMPTY) ? true : false; } /* diff --git a/src/dev/uart.h b/src/dev/uart.h index 4ac2a57..52575f0 100644 --- a/src/dev/uart.h +++ b/src/dev/uart.h @@ -47,7 +47,7 @@ extern void uart_init(short uart); * Returns: * non-zero if there is data to read, 0 if there is no data. */ -extern short uart_has_bytes(short uart); +extern bool uart_has_bytes(short uart); /* * Send a byte to the UART. Blocks until the FIFO is ready to recieve a byte.