Use "bool" type and true/false whenever appropriate, for better semantics.
This commit is contained in:
parent
e2b44f3bf0
commit
93f02bc99d
|
@ -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
|
* @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) {
|
switch(device) {
|
||||||
case BDEV_FDC:
|
case BDEV_FDC:
|
||||||
// The SDC and HDC boot off the MBR...
|
// 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)) &&
|
if ((sector[BOOT_SIG_VBR_OFF] == ((BOOT_SIG >> 8) & 0x00FF)) &&
|
||||||
(sector[BOOT_SIG_VBR_OFF+1] == (BOOT_SIG & 0x00FF))) {
|
(sector[BOOT_SIG_VBR_OFF+1] == (BOOT_SIG & 0x00FF))) {
|
||||||
// The CPU is supported, and the boot signature is correct
|
// The CPU is supported, and the boot signature is correct
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -132,7 +132,7 @@ short is_bootable(unsigned char * sector, short device) {
|
||||||
if ((sector[BOOT_SIG_MBR_OFF] == ((BOOT_SIG >> 8) & 0x00FF)) &&
|
if ((sector[BOOT_SIG_MBR_OFF] == ((BOOT_SIG >> 8) & 0x00FF)) &&
|
||||||
(sector[BOOT_SIG_MBR_OFF+1] == (BOOT_SIG & 0x00FF))) {
|
(sector[BOOT_SIG_MBR_OFF+1] == (BOOT_SIG & 0x00FF))) {
|
||||||
// The CPU is supported, and the boot signature is correct
|
// The CPU is supported, and the boot signature is correct
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -143,7 +143,7 @@ short is_bootable(unsigned char * sector, short device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have reached this point, the sector is not bootable
|
// If we have reached this point, the sector is not bootable
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,17 +56,17 @@
|
||||||
* Check to see if the path points to a directory
|
* Check to see if the path points to a directory
|
||||||
*
|
*
|
||||||
* @param path the path to check
|
* @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;
|
t_file_info file;
|
||||||
|
|
||||||
short result = sys_fsys_stat(path, &file);
|
short result = sys_fsys_stat(path, &file);
|
||||||
if ((result < 0) || ((file.attributes & FSYS_AM_DIR) == 0)) {
|
if ((result < 0) || ((file.attributes & FSYS_AM_DIR) == 0)) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -94,15 +94,15 @@ const t_ansi_seq ansi_sequence[] = {
|
||||||
* c = the character to test
|
* c = the character to test
|
||||||
*
|
*
|
||||||
* Returns:
|
* 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) {
|
switch (c) {
|
||||||
case '\x1b':
|
case '\x1b':
|
||||||
return 1;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ short con_write(p_channel chan, const uint8_t * buffer, short size) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
short con_has_input(p_channel chan) {
|
bool con_has_input(p_channel chan) {
|
||||||
p_console_data con_data;
|
p_console_data con_data;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ short con_has_input(p_channel chan) {
|
||||||
|
|
||||||
if (con_data->key_buffer != 0) {
|
if (con_data->key_buffer != 0) {
|
||||||
/* If we already peeked and have a character... return true */
|
/* If we already peeked and have a character... return true */
|
||||||
return 1;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Otherwise, peek at the keyboard to see if there is a valid key */
|
/* 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) {
|
if (c == 0) {
|
||||||
/* No: return false */
|
/* No: return false */
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Yes: save the key we got and return true */
|
/* Yes: save the key we got and return true */
|
||||||
con_data->key_buffer = c;
|
con_data->key_buffer = c;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,16 +114,16 @@ void fdc_media_change() {
|
||||||
* Check to see if the media has changed
|
* Check to see if the media has changed
|
||||||
* If so, recalibrate the drive and flag the change
|
* 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
|
// Check for the a disk change
|
||||||
if (*FDC_DIR & 0x80) {
|
if (*FDC_DIR & 0x80) {
|
||||||
// The disk has changed... recalibrate and set that it's changed
|
// The disk has changed... recalibrate and set that it's changed
|
||||||
fdc_recalibrate();
|
fdc_recalibrate();
|
||||||
fdc_seek(1);
|
fdc_seek(1);
|
||||||
g_fdc_stat = FDC_STAT_NOINIT;
|
g_fdc_stat = FDC_STAT_NOINIT;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1277,14 +1277,14 @@ static bool loader_exists(const char * extension) {
|
||||||
for (i = 0; i < MAX_LOADERS; i++) {
|
for (i = 0; i < MAX_LOADERS; i++) {
|
||||||
if (g_file_loader[i].status) {
|
if (g_file_loader[i].status) {
|
||||||
if (strcmp(g_file_loader[i].extension, extension) == 0) {
|
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, '.');
|
char * point = strrchr(path, '.');
|
||||||
extension[0] = 0;
|
extension[0] = 0;
|
||||||
if (point != 0) {
|
if (point != 0) {
|
||||||
|
@ -1295,11 +1295,11 @@ static int get_app_ext(const char * path, char * extension) {
|
||||||
extension[i] = toupper(c);
|
extension[i] = toupper(c);
|
||||||
} else {
|
} else {
|
||||||
extension[i] = 0;
|
extension[i] = 0;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,21 +274,21 @@ void kbdmo_flush_out() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if a BREAK code has been pressed recently
|
* 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
|
* BREAK will be F-ESC on the A2560K
|
||||||
*
|
*
|
||||||
* Returns:
|
* 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) {
|
if (g_kbdmo_control.status & KBD_STAT_BREAK) {
|
||||||
/* BREAK was pressed: clear the flag and return a 1 */
|
/* BREAK was pressed: clear the flag and return a 1 */
|
||||||
g_kbdmo_control.status &= ~KBD_STAT_BREAK;
|
g_kbdmo_control.status &= ~KBD_STAT_BREAK;
|
||||||
return 1;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
/* BREAK was not pressed: return a 0 */
|
/* BREAK was not pressed: return a 0 */
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,14 @@ void kbdmo_set_led_matrix_fill(unsigned short color);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if a BREAK code has been pressed recently
|
* 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
|
* BREAK will be F-ESC on the A2560K
|
||||||
*
|
*
|
||||||
* Returns:
|
* 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.
|
* Try to retrieve the next scancode from the keyboard.
|
||||||
|
|
|
@ -18,37 +18,37 @@ const long midi_timeout = 60;
|
||||||
/**
|
/**
|
||||||
* Wait for data to be ready to read...
|
* 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;
|
long target = timers_jiffies() + midi_timeout;
|
||||||
do {
|
do {
|
||||||
if ((*MIDI_STAT & MIDI_STAT_RX_EMPTY) == 0) {
|
if ((*MIDI_STAT & MIDI_STAT_RX_EMPTY) == 0) {
|
||||||
// There is data waiting
|
// There is data waiting
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
} while (target > timers_jiffies());
|
} while (target > timers_jiffies());
|
||||||
|
|
||||||
// We have waited too long
|
// We have waited too long
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the MIDI transmiter to be empty...
|
* 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() {
|
short midi_can_write() {
|
||||||
long target = timers_jiffies() + midi_timeout;
|
long target = timers_jiffies() + midi_timeout;
|
||||||
do {
|
do {
|
||||||
if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) != 0) {
|
if ((*MIDI_STAT & MIDI_STAT_TX_BUSY) != 0) {
|
||||||
// The transmit buffer is empty
|
// The transmit buffer is empty
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
} while (target > timers_jiffies());
|
} while (target > timers_jiffies());
|
||||||
|
|
||||||
// We have waited too long
|
// We have waited too long
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -104,40 +104,24 @@ void uart_init(short uart) {
|
||||||
* uart = the number of the UART: 0 for COM1, 1 for COM2
|
* uart = the number of the UART: 0 for COM1, 1 for COM2
|
||||||
*
|
*
|
||||||
* Returns:
|
* 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);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
|
|
||||||
if (uart_base) {
|
return uart_base && (uart_base[UART_LSR] & LSR_DATA_AVAIL) ? true : false;
|
||||||
if (uart_base[UART_LSR] & LSR_DATA_AVAIL) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true (non-zero) if the UART transmit FIFO is not full
|
* 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
|
* @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);
|
volatile unsigned char * uart_base = uart_get_base(uart);
|
||||||
|
|
||||||
if (uart_base) {
|
return uart_base && (uart_base[UART_LSR] & LSR_XMIT_EMPTY) ? true : false;
|
||||||
if (uart_base[UART_LSR] & LSR_XMIT_EMPTY) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern void uart_init(short uart);
|
||||||
* Returns:
|
* Returns:
|
||||||
* non-zero if there is data to read, 0 if there is no data.
|
* 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.
|
* Send a byte to the UART. Blocks until the FIFO is ready to recieve a byte.
|
||||||
|
|
Loading…
Reference in a new issue