diff --git a/include/mega65/conio.h b/include/mega65/conio.h index 9e17579..c793864 100644 --- a/include/mega65/conio.h +++ b/include/mega65/conio.h @@ -212,7 +212,7 @@ void setlowercase(void); void setuppercase(void); /* \m65libsummary{setscreenaddr}{Sets the screen RAM start address} - \m65libsyntax {void setscreenaddr(long addr);} + \m65libsyntax {void setscreenaddr(unsigned long addr);} \m65libparam {addr}{The address to set as start of screen RAM} \m65example { // Set beginning of screen RAM at $48000 @@ -225,17 +225,17 @@ void setuppercase(void); * @param addr The address to set as start of screen RAM * @remarks No bounds check is performed on the selected address */ -void setscreenaddr(long addr); +void setscreenaddr(unsigned long addr); /* \m65libsummary{getscreenaddr}{Returns the screen RAM start address} - \m65libsyntax {long getscreenaddr(void);} + \m65libsyntax {unsigned long getscreenaddr(void);} \m65libretval {The current screen RAM address start address.} */ /** * @brief Returns the screen RAM start address * @return The current screen RAM address start address. */ -long getscreenaddr(void); +unsigned long getscreenaddr(void); /* \m65libsummary{setcolramoffset}{Sets the color RAM start offset value} \m65libsyntax {void setcolramoffset(long offset);} @@ -262,7 +262,7 @@ void setcolramoffset(unsigned int addr); unsigned int getcolramoffset(void); /* \m65libsummary{setcharsetaddr}{Sets the character set start address} - \m65libsyntax {void setcharsetaddr(long addr);} + \m65libsyntax {void setcharsetaddr(unsigned long addr);} \m65libparam {addr}{The address to set as start of character set} \m65libremarks {No bounds check is performed on the selected address} */ @@ -271,7 +271,7 @@ unsigned int getcolramoffset(void); * @param addr The address to set as start of character set * @remarks No bounds check is performed on the selected address */ -void setcharsetaddr(long addr); +void setcharsetaddr(unsigned long addr); /* \m65libsummary{getcharsetaddr}{Returns the current character set start address} \m65libsyntax {long getscreenaddr(void);} \m65libretval {The @@ -907,7 +907,7 @@ void fastcall cputc(unsigned char c); void fastcall cputnc(unsigned char count, unsigned char c); /* \m65libsummary{cputhex}{Output an hex-formatted number at current position} - \m65libsyntax {void cputhex(long n, unsigned char prec)} + \m65libsyntax {void cputhex(unsigned long n, unsigned char prec)} \m65libparam {n}{The number to write} \m65libparam {prec}{The precision of the hex number, in digits. Leading zeros will be printed accordingly} \m65libremarks {The $ symbol will be @@ -920,10 +920,10 @@ void fastcall cputnc(unsigned char count, unsigned char c); * printed accordingly * @remarks The $ symbol will be automatically added at beginning of string */ -void cputhex(long n, unsigned char prec); +void cputhex(unsigned long n, unsigned char prec); /* \m65libsummary{cputdec}{Output a decimal number at current position} - \m65libsyntax {void cputdec(long n, unsigned char padding, unsigned char + \m65libsyntax {void cputdec(unsigned long n, unsigned char padding, unsigned char leadingZ)} \m65libparam {n}{The number to write} \m65libparam {padding}{The padding space to add before number} \m65libparam {leadingZ}{The leading zeros to print} @@ -931,10 +931,10 @@ void cputhex(long n, unsigned char prec); /** * @brief Output a decimal number at current position * @param n The number to write - * @param padding The padding space to add before number + * @param padding The padding space to add before number (currently ignored) * @param leadingZ The leading zeros to print */ -void cputdec(long n, unsigned char padding, unsigned char leadingZ); +void cputdec(unsigned long n, unsigned char padding, unsigned char leadingZ); /* \m65libsummary{cputs}{Output screen codes at current position} \m65libsyntax {void cputs(const unsigned char* s)} diff --git a/src/conio.c b/src/conio.c index 714b4a6..992b562 100644 --- a/src/conio.c +++ b/src/conio.c @@ -40,8 +40,8 @@ #define SCREEN_RAM_BASE_B2 (PEEK(VIC_BASE + 0x62)) #define SCREEN_RAM_BASE_B3 (PEEK(VIC_BASE + 0x63) & 7) // upper nybble #define SCREEN_RAM_BASE \ - (((long)SCREEN_RAM_BASE_B3 << 24) | ((long)SCREEN_RAM_BASE_B2 << 16) \ - | ((long)SCREEN_RAM_BASE_B1 << 8) | (SCREEN_RAM_BASE_B0)) + (((unsigned long)SCREEN_RAM_BASE_B3 << 24) | ((unsigned long)SCREEN_RAM_BASE_B2 << 16) \ + | ((unsigned long)SCREEN_RAM_BASE_B1 << 8) | ((unsigned long)SCREEN_RAM_BASE_B0)) #define COLOR_RAM_BASE 0xFF80000UL #define PRINTF_IN_FORMAT_SPEC 0x1 @@ -99,16 +99,18 @@ static unsigned char hash(const unsigned char* str, const unsigned char maxLen) return (unsigned char)hash; } -static void clrscr_(unsigned char) +static void clrscr_(unsigned char ignored __attribute__((unused))) { clrscr(); gohome(); } // Callable from Escape Code table -static void gohome_(unsigned char) + +static void gohome_(unsigned char ignored __attribute__((unused))) { gohome(); } // Callable from Escape Code table -static void escNOP(unsigned char) + +static void escNOP(unsigned char ignored __attribute__((unused))) { /* do nothing */ } @@ -218,7 +220,7 @@ char* petsciitoscreencode_s(char* s) return p2sbuf; } -void setscreenaddr(long address) +void setscreenaddr(unsigned long address) { POKE(VIC_BASE + 0x60, address & 0x0000FFUL); POKE(VIC_BASE + 0x61, (address & 0xFF00UL) >> 8); @@ -227,12 +229,12 @@ void setscreenaddr(long address) (PEEK(VIC_BASE + 0x63) & 0xF) | ((address & 0xF000000UL) >> 24)); } -long getscreenaddr(void) +unsigned long getscreenaddr(void) { return SCREEN_RAM_BASE; } -void setcharsetaddr(long address) +void setcharsetaddr(unsigned long address) { POKE(VIC_BASE + 0x68, address & 0x0000FFUL); POKE(VIC_BASE + 0x69, (address & 0xFF00UL) >> 8); @@ -536,7 +538,7 @@ unsigned char _cprintf( } } -void cputhex(long n, unsigned char prec) +void cputhex(unsigned long n, unsigned char prec) { unsigned char buffer[10]; buffer[0] = '$'; @@ -553,17 +555,12 @@ void cputhex(long n, unsigned char prec) cputs(&buffer[8 - prec]); } -#ifdef __clang__ -void cputdec(long n, __attribute__ ((unused)) unsigned char padding, unsigned char leadingZeros) -#else -void cputdec(long n, unsigned char padding, unsigned char leadingZeros) -#endif - +void cputdec(unsigned long n, unsigned char padding __attribute__((unused)), unsigned char leadingZeros) { unsigned char buffer[11]; unsigned char rem = 0; - char digit = 9; - padding = 0; // NOTE: done to suppress compiler warning + unsigned char digit = 9; + buffer[10] = '\0'; do { rem = n % 10; @@ -585,9 +582,9 @@ void cputs(const unsigned char* s) void cputsxy(unsigned char x, unsigned char y, const unsigned char* s) { - const unsigned char len = strlen((const char*)s); + const unsigned char len = (unsigned char)strlen((const char*)s); const unsigned int offset = (y * (unsigned int)g_curScreenW) + x; - lcopy((long)s, SCREEN_RAM_BASE + offset, len); + lcopy((unsigned long)s, SCREEN_RAM_BASE + offset, len); lfill(COLOR_RAM_BASE + offset, g_curTextColor, len); g_curY = y + ((x + len) / g_curScreenW); g_curX = (x + len) % g_curScreenW; @@ -715,8 +712,8 @@ unsigned char cinput( unsigned char* buffer, unsigned char buflen, unsigned char flags) { register unsigned char numch = 0, i, ch; - const int sx = wherex(); - const int sy = wherey(); + const unsigned char sx = wherex(); + const unsigned char sy = wherey(); if (buffer == NULL || buflen == 0) { return 0; @@ -764,7 +761,7 @@ unsigned char cinput( void setpalbank(unsigned char bank) { - POKE(0xD070U, (PEEK(0xD070U) & ~0x30) | ((bank & 0x3) << 4)); + POKE(0xD070U, (PEEK(0xD070U) & ~0x30) | (unsigned char)((bank & 0x3) << 4) ); } void setpalbanka(unsigned char bank) @@ -784,7 +781,7 @@ unsigned char getpalbanka(void) void setmapedpal(unsigned char bank) { - POKE(0xD070U, (PEEK(0xD070U) & ~0xC0) | ((bank & 0x3) << 6)); + POKE(0xD070U, (PEEK(0xD070U) & ~0xC0) | (unsigned char)((bank & 0x3) << 6) ); } unsigned char getmapedpal(void) diff --git a/src/fat32.c b/src/fat32.c index b92be71..a731963 100644 --- a/src/fat32.c +++ b/src/fat32.c @@ -14,10 +14,10 @@ The root directory is the start of cluster 2, and clusters are assumed to be 4KB in size, to keep things simple. - Returns first sector of file if successful, or -1 on failure. + Returns first sector of file if successful, or 0xffffffff on failure. */ -long mega65_fat32_create_contiguous_file(char* name, long size, - long root_dir_sector, long fat1_sector, long fat2_sector) +unsigned long mega65_fat32_create_contiguous_file(char* name, unsigned long size, + unsigned long root_dir_sector, unsigned long fat1_sector, unsigned long fat2_sector) { unsigned char i; unsigned short offset; @@ -51,9 +51,9 @@ long mega65_fat32_create_contiguous_file(char* name, long size, for (offset = 0; offset < 512; offset += 4) { next_cluster = sector_buffer[offset]; - next_cluster |= ((long)sector_buffer[offset + 1] << 8L); - next_cluster |= ((long)sector_buffer[offset + 2] << 16L); - next_cluster |= ((long)sector_buffer[offset + 3] << 24L); + next_cluster |= ((unsigned long)sector_buffer[offset + 1] << 8L); + next_cluster |= ((unsigned long)sector_buffer[offset + 2] << 16L); + next_cluster |= ((unsigned long)sector_buffer[offset + 3] << 24L); if (!next_cluster) { if (!start_cluster) { start_cluster = (offset / 4) + fat_offset * (512 / 4); @@ -96,7 +96,7 @@ long mega65_fat32_create_contiguous_file(char* name, long size, if ((!start_cluster) || (contiguous_clusters != clusters)) { // write_line("ERROR: Could not find enough free clusters in file // system",0); - return -1; + return 0xffffffffUL; } // Commit sector to disk (in both copies of FAT) @@ -116,7 +116,7 @@ long mega65_fat32_create_contiguous_file(char* name, long size, if (offset == 512) { // write_line("ERROR: First sector of root directory already // full.",0); - return -1; + return 0xffffffffUL; } // Build directory entry @@ -127,16 +127,16 @@ long mega65_fat32_create_contiguous_file(char* name, long size, sector_buffer[offset + i] = name[i]; } sector_buffer[offset + 0x0b] = 0x20; // Archive bit set - sector_buffer[offset + 0x1A] = start_cluster; - sector_buffer[offset + 0x1B] = start_cluster >> 8; - sector_buffer[offset + 0x14] = start_cluster >> 16; - sector_buffer[offset + 0x15] = start_cluster >> 24; + sector_buffer[offset + 0x1A] = (unsigned char)start_cluster; + sector_buffer[offset + 0x1B] = (unsigned char)(start_cluster >> 8); + sector_buffer[offset + 0x14] = (unsigned char)(start_cluster >> 16); + sector_buffer[offset + 0x15] = (unsigned char)(start_cluster >> 24); sector_buffer[offset + 0x1C] = (size >> 0) & 0xff; - sector_buffer[offset + 0x1D] = (size >> 8L) & 0xff; - sector_buffer[offset + 0x1E] = (size >> 16L) & 0xff; - sector_buffer[offset + 0x1F] = (size >> 24l) & 0xff; + sector_buffer[offset + 0x1D] = (unsigned char)(size >> 8L) & 0xff; + sector_buffer[offset + 0x1E] = (unsigned char)(size >> 16L) & 0xff; + sector_buffer[offset + 0x1F] = (unsigned char)(size >> 24l) & 0xff; mega65_sdcard_writesector(root_dir_sector); - return root_dir_sector + (long)(start_cluster - 2) * 8; + return root_dir_sector + (unsigned long)(start_cluster - 2) * 8; } diff --git a/src/mouse.c b/src/mouse.c index 891aede..95987a5 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -77,32 +77,32 @@ char mouse_clicked(void) void mouse_update_pointer(void) { if (mouse_sprite_number < 8) { - POKE(0xD000 + (mouse_sprite_number << 1), mouse_x & 0xff); + POKE(0xD000U + (unsigned char)(mouse_sprite_number << 1), mouse_x & 0xff); if (mouse_x & 0x100) { - POKE(0xD010, PEEK(0xD010) | (1 << mouse_sprite_number)); + POKE(0xD010U, PEEK(0xD010U) | (unsigned char)(1 << mouse_sprite_number)); } else { - POKE(0xD010, PEEK(0xD010) & (0xFF - (1 << mouse_sprite_number))); + POKE(0xD010U, PEEK(0xD010U) & (0xFF - (unsigned char)(1 << mouse_sprite_number))); } if (mouse_x & 0x200) { - POKE(0xD05F, PEEK(0xD05F) | (1 << mouse_sprite_number)); + POKE(0xD05FU, PEEK(0xD05FU) | (unsigned char)(1 << mouse_sprite_number)); } else { - POKE(0xD05F, PEEK(0xD05F) & (0xFF - (1 << mouse_sprite_number))); + POKE(0xD05FU, PEEK(0xD05FU) & (0xFF - (unsigned char)(1 << mouse_sprite_number))); } - POKE(0xD001 + (mouse_sprite_number << 1), mouse_y & 0xff); + POKE(0xD001U + (unsigned char)(mouse_sprite_number << 1), mouse_y & 0xff); if (mouse_y & 0x100) { - POKE(0xD077, PEEK(0xD077) | (1 << mouse_sprite_number)); + POKE(0xD077U, PEEK(0xD077U) | (unsigned char)(1 << mouse_sprite_number)); } else { - POKE(0xD077, PEEK(0xD077) & (0xFF - (1 << mouse_sprite_number))); + POKE(0xD077U, PEEK(0xD077U) & (0xFF - (1 << mouse_sprite_number))); } if (mouse_y & 0x200) { - POKE(0xD05F, PEEK(0xD05F) | (1 << mouse_sprite_number)); + POKE(0xD05FU, PEEK(0xD05FU) | (unsigned char)(1 << mouse_sprite_number)); } else { - POKE(0xD078, PEEK(0xD078) & (0xFF - (1 << mouse_sprite_number))); + POKE(0xD078U, PEEK(0xD078U) & (0xFF - (1 << mouse_sprite_number))); } } } diff --git a/src/random.c b/src/random.c index f813023..61f43f8 100644 --- a/src/random.c +++ b/src/random.c @@ -13,7 +13,7 @@ void generate_random_byte(void) while (random_step--) { random_byte - = (random_byte << 1) | ((random_byte >> 7) ^ (PEEK(0xD6DE) & 0x01)); + = (unsigned char)(random_byte << 1) | ((random_byte >> 7) ^ (PEEK(0xD6DE) & 0x01)); // We then have to wait 10usec before the next value is ready. // 1 raster line is more than that, so just wait one raster line raster_temp = PEEK(0xD052); diff --git a/src/sdcard.c b/src/sdcard.c index bebc10c..77d5d32 100644 --- a/src/sdcard.c +++ b/src/sdcard.c @@ -273,7 +273,7 @@ uint8_t mega65_sdcard_writesector(const uint32_t sector_number) // Copy buffer into the SD card buffer, and then execute the write job uint32_t sector_address; int i; - char tries = 0, result; + char tries = 0; // , result; uint16_t counter = 0; while (PEEK(sd_ctl) & 3) { @@ -363,7 +363,7 @@ uint8_t mega65_sdcard_writesector(const uint32_t sector_number) POKE(0xD020, write_count & 0x0f); // Note result - result = PEEK(sd_ctl); + // result = PEEK(sd_ctl); if (!(PEEK(sd_ctl) & 0x67)) { write_count++; diff --git a/src/time.c b/src/time.c index 232c9d0..1071760 100644 --- a/src/time.c +++ b/src/time.c @@ -185,7 +185,7 @@ void setrtc(struct m65_tm* tm) lpoke(0xffd7114, tobcd(tm->tm_mon)); if (tm->tm_year >= 100 && tm->tm_year <= 199) { usleep(I2CDELAY); - lpoke(0xffd7115, tobcd(tm->tm_year - 100)); + lpoke(0xffd7115, tobcd((unsigned char)tm->tm_year - 100)); } usleep(I2CDELAY); lpoke(0xffd7116, tobcd(tm->tm_wday < 7 ? tm->tm_wday : 0));