Update old coding style

This commit is contained in:
Lior Halphon 2020-04-09 14:32:52 +03:00
parent a9cd3f2c11
commit a6567d9ee1
12 changed files with 44 additions and 44 deletions

View File

@ -731,8 +731,8 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
NSRect rect = window.contentView.frame;
int titlebarSize = window.contentView.superview.frame.size.height - rect.size.height;
int step = width / [[window screen] backingScaleFactor];
unsigned titlebarSize = window.contentView.superview.frame.size.height - rect.size.height;
unsigned step = width / [[window screen] backingScaleFactor];
rect.size.width = floor(rect.size.width / step) * step + step;
rect.size.height = rect.size.width * height / width + titlebarSize;
@ -1468,7 +1468,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
NSUInteger columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
if (tableView == self.paletteTableView) {
if (columnIndex == 0) {
return [NSString stringWithFormat:@"%s %d", row >=8 ? "Object" : "Background", (int)(row & 7)];
return [NSString stringWithFormat:@"%s %u", row >=8 ? "Object" : "Background", (unsigned)(row & 7)];
}
uint8_t *palette_data = GB_get_direct_access(&gb, row >= 8? GB_DIRECT_ACCESS_OBP : GB_DIRECT_ACCESS_BGP, NULL, NULL);
@ -1486,9 +1486,9 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
height:oamHeight
scale:16.0/oamHeight];
case 1:
return @((int)oamInfo[row].x - 8);
return @((unsigned)oamInfo[row].x - 8);
case 2:
return @((int)oamInfo[row].y - 16);
return @((unsigned)oamInfo[row].y - 16);
case 3:
return [NSString stringWithFormat:@"$%02x", oamInfo[row].tile];
case 4:

View File

@ -548,7 +548,7 @@ uint8_t GB_apu_read(GB_gameboy_t *gb, uint8_t reg)
{
if (reg == GB_IO_NR52) {
uint8_t value = 0;
for (int i = 0; i < GB_N_CHANNELS; i++) {
for (unsigned i = 0; i < GB_N_CHANNELS; i++) {
value >>= 1;
if (gb->apu.is_active[i]) {
value |= 0x8;

View File

@ -1,17 +1,17 @@
#include "gb.h"
static int noise_seed = 0;
static signed noise_seed = 0;
/* This is not a complete emulation of the camera chip. Only the features used by the GameBoy Camera ROMs are supported.
We also do not emulate the timing of the real cart, as it might be actually faster than the webcam. */
static uint8_t generate_noise(uint8_t x, uint8_t y)
{
int value = (x + y * 128 + noise_seed);
signed value = (x + y * 128 + noise_seed);
uint8_t *data = (uint8_t *) &value;
unsigned hash = 0;
while ((int *) data != &value + 1) {
while ((signed *) data != &value + 1) {
hash ^= (*data << 8);
if (hash & 0x8000) {
hash ^= 0x8a00;

View File

@ -568,7 +568,7 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
signed depth = 0;
unsigned operator_index = -1;
unsigned operator_pos = 0;
for (int i = 0; i < length; i++) {
for (unsigned i = 0; i < length; i++) {
if (string[i] == '(') depth++;
else if (string[i] == ')') depth--;
else if (string[i] == '[') depth++;
@ -841,8 +841,8 @@ static uint16_t find_breakpoint(GB_gameboy_t *gb, value_t addr)
uint32_t key = BP_KEY(addr);
int min = 0;
int max = gb->n_breakpoints;
unsigned min = 0;
unsigned max = gb->n_breakpoints;
while (min < max) {
uint16_t pivot = (min + max) / 2;
if (gb->breakpoints[pivot].key == key) return pivot;
@ -1008,8 +1008,8 @@ static uint16_t find_watchpoint(GB_gameboy_t *gb, value_t addr)
return 0;
}
uint32_t key = WP_KEY(addr);
int min = 0;
int max = gb->n_watchpoints;
unsigned min = 0;
unsigned max = gb->n_watchpoints;
while (min < max) {
uint16_t pivot = (min + max) / 2;
if (gb->watchpoints[pivot].key == key) return pivot;
@ -1342,7 +1342,7 @@ static bool examine(GB_gameboy_t *gb, char *arguments, char *modifiers, const de
while (count) {
GB_log(gb, "%02x:%04x: ", addr.bank, addr.value);
for (int i = 0; i < 16 && count; i++) {
for (unsigned i = 0; i < 16 && count; i++) {
GB_log(gb, "%02x ", GB_read_memory(gb, addr.value + i));
count--;
}
@ -1355,7 +1355,7 @@ static bool examine(GB_gameboy_t *gb, char *arguments, char *modifiers, const de
else {
while (count) {
GB_log(gb, "%04x: ", addr.value);
for (int i = 0; i < 16 && count; i++) {
for (unsigned i = 0; i < 16 && count; i++) {
GB_log(gb, "%02x ", GB_read_memory(gb, addr.value + i));
count--;
}
@ -1493,7 +1493,7 @@ static bool ticks(GB_gameboy_t *gb, char *arguments, char *modifiers, const debu
return true;
}
GB_log(gb, "Ticks: %lu. (Resetting)\n", gb->debugger_ticks);
GB_log(gb, "Ticks: %llu. (Resetting)\n", (unsigned long long)gb->debugger_ticks);
gb->debugger_ticks = 0;
return true;
@ -2197,13 +2197,13 @@ void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path)
void GB_debugger_clear_symbols(GB_gameboy_t *gb)
{
for (int i = sizeof(gb->bank_symbols) / sizeof(gb->bank_symbols[0]); i--;) {
for (unsigned i = sizeof(gb->bank_symbols) / sizeof(gb->bank_symbols[0]); i--;) {
if (gb->bank_symbols[i]) {
GB_map_free(gb->bank_symbols[i]);
gb->bank_symbols[i] = 0;
}
}
for (int i = sizeof(gb->reversed_symbol_map.buckets) / sizeof(gb->reversed_symbol_map.buckets[0]); i--;) {
for (unsigned i = sizeof(gb->reversed_symbol_map.buckets) / sizeof(gb->reversed_symbol_map.buckets[0]); i--;) {
while (gb->reversed_symbol_map.buckets[i]) {
GB_symbol_t *next = gb->reversed_symbol_map.buckets[i]->next;
free(gb->reversed_symbol_map.buckets[i]);

View File

@ -1421,7 +1421,7 @@ uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *sprite_h
GB_object_t *sprite = (GB_object_t *) &gb->oam;
uint8_t sprites_in_line = 0;
for (uint8_t i = 0; i < 40; i++, sprite++) {
int sprite_y = sprite->y - 16;
signed sprite_y = sprite->y - 16;
bool obscured = false;
// Is sprite not in this line?
if (sprite_y > y || sprite_y + *sprite_height <= y) continue;

View File

@ -709,7 +709,7 @@ void GB_set_infrared_input(GB_gameboy_t *gb, bool state)
gb->ir_queue_length = 0;
}
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, long cycles_after_previous_change)
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, uint64_t cycles_after_previous_change)
{
if (gb->ir_queue_length == GB_MAX_IR_QUEUE) {
GB_log(gb, "IR Queue is full\n");

View File

@ -265,7 +265,7 @@ typedef void (*GB_vblank_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_log_callback_t)(GB_gameboy_t *gb, const char *string, GB_log_attributes attributes);
typedef char *(*GB_input_callback_t)(GB_gameboy_t *gb);
typedef uint32_t (*GB_rgb_encode_callback_t)(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b);
typedef void (*GB_infrared_callback_t)(GB_gameboy_t *gb, bool on, long cycles_since_last_update);
typedef void (*GB_infrared_callback_t)(GB_gameboy_t *gb, bool on, uint64_t cycles_since_last_update);
typedef void (*GB_rumble_callback_t)(GB_gameboy_t *gb, bool rumble_on);
typedef void (*GB_serial_transfer_bit_start_callback_t)(GB_gameboy_t *gb, bool bit_to_send);
typedef bool (*GB_serial_transfer_bit_end_callback_t)(GB_gameboy_t *gb);
@ -278,7 +278,7 @@ typedef void (*GB_boot_rom_load_callback_t)(GB_gameboy_t *gb, GB_boot_rom_t type
typedef struct {
bool state;
long delay;
uint64_t delay;
} GB_ir_queue_item_t;
struct GB_breakpoint_s;
@ -587,8 +587,8 @@ struct GB_gameboy_internal_s {
GB_boot_rom_load_callback_t boot_rom_load_callback;
/* IR */
long cycles_since_ir_change; // In 8MHz units
long cycles_since_input_ir_change; // In 8MHz units
uint64_t cycles_since_ir_change; // In 8MHz units
uint64_t cycles_since_input_ir_change; // In 8MHz units
GB_ir_queue_item_t ir_queue[GB_MAX_IR_QUEUE];
size_t ir_queue_length;
@ -605,7 +605,7 @@ struct GB_gameboy_internal_s {
/* SLD (Todo: merge with backtrace) */
bool stack_leak_detection;
int debug_call_depth;
signed debug_call_depth;
uint16_t sp_for_call_depth[0x200]; /* Should be much more than enough */
uint16_t addr_for_call_depth[0x200];
@ -626,7 +626,7 @@ struct GB_gameboy_internal_s {
GB_reversed_symbol_map_t reversed_symbol_map;
/* Ticks command */
unsigned long debugger_ticks;
uint64_t debugger_ticks;
/* Rewind */
#define GB_REWIND_FRAMES_PER_KEY 255
@ -732,7 +732,7 @@ void GB_set_pixels_output(GB_gameboy_t *gb, uint32_t *output);
void GB_set_border_mode(GB_gameboy_t *gb, GB_border_mode_t border_mode);
void GB_set_infrared_input(GB_gameboy_t *gb, bool state);
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, long cycles_after_previous_change); /* In 8MHz units*/
void GB_queue_infrared_input(GB_gameboy_t *gb, bool state, uint64_t cycles_after_previous_change); /* In 8MHz units*/
void GB_set_vblank_callback(GB_gameboy_t *gb, GB_vblank_callback_t callback);
void GB_set_log_callback(GB_gameboy_t *gb, GB_log_callback_t callback);

View File

@ -132,7 +132,7 @@ void GB_configure_cart(GB_gameboy_t *gb)
gb->mbc_ram_size = 0x200;
}
else {
static const int ram_sizes[256] = {0, 0x800, 0x2000, 0x8000, 0x20000, 0x10000};
static const unsigned ram_sizes[256] = {0, 0x800, 0x2000, 0x8000, 0x20000, 0x10000};
gb->mbc_ram_size = ram_sizes[gb->rom[0x149]];
}
gb->mbc_ram = malloc(gb->mbc_ram_size);

View File

@ -471,7 +471,7 @@ static void add_hl_rr(GB_gameboy_t *gb, uint8_t opcode)
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if ( ((unsigned long) hl + (unsigned long) rr) & 0x10000) {
if ( ((unsigned) hl + (unsigned) rr) & 0x10000) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}
@ -802,7 +802,7 @@ static void add_a_r(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if (((unsigned long) a) + ((unsigned long) value) > 0xFF) {
if (((unsigned) a) + ((unsigned) value) > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}
@ -821,7 +821,7 @@ static void adc_a_r(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) + carry > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if (((unsigned long) a) + ((unsigned long) value) + carry > 0xFF) {
if (((unsigned) a) + ((unsigned) value) + carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}
@ -857,7 +857,7 @@ static void sbc_a_r(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) < (value & 0xF) + carry) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if (((unsigned long) a) - ((unsigned long) value) - carry > 0xFF) {
if (((unsigned) a) - ((unsigned) value) - carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}
@ -1001,7 +1001,7 @@ static void add_a_d8(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if (((unsigned long) a) + ((unsigned long) value) > 0xFF) {
if (((unsigned) a) + ((unsigned) value) > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}
@ -1020,7 +1020,7 @@ static void adc_a_d8(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) + (value & 0xF) + carry > 0x0F) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if (((unsigned long) a) + ((unsigned long) value) + carry > 0xFF) {
if (((unsigned) a) + ((unsigned) value) + carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}
@ -1056,7 +1056,7 @@ static void sbc_a_d8(GB_gameboy_t *gb, uint8_t opcode)
if ((a & 0xF) < (value & 0xF) + carry) {
gb->registers[GB_REGISTER_AF] |= GB_HALF_CARRY_FLAG;
}
if (((unsigned long) a) - ((unsigned long) value) - carry > 0xFF) {
if (((unsigned) a) - ((unsigned) value) - carry > 0xFF) {
gb->registers[GB_REGISTER_AF] |= GB_CARRY_FLAG;
}
}

View File

@ -71,9 +71,9 @@ void GB_map_free(GB_symbol_map_t *map)
free(map);
}
static int hash_name(const char *name)
static unsigned hash_name(const char *name)
{
int r = 0;
unsigned r = 0;
while (*name) {
r <<= 1;
if (r & 0x400) {
@ -87,7 +87,7 @@ static int hash_name(const char *name)
void GB_reversed_map_add_symbol(GB_reversed_symbol_map_t *map, uint16_t bank, GB_bank_symbol_t *bank_symbol)
{
int hash = hash_name(bank_symbol->name);
unsigned hash = hash_name(bank_symbol->name);
GB_symbol_t *symbol = malloc(sizeof(*symbol));
symbol->name = bank_symbol->name;
symbol->addr = bank_symbol->addr;
@ -98,7 +98,7 @@ void GB_reversed_map_add_symbol(GB_reversed_symbol_map_t *map, uint16_t bank, GB
const GB_symbol_t *GB_reversed_map_find_symbol(GB_reversed_symbol_map_t *map, const char *name)
{
int hash = hash_name(name);
unsigned hash = hash_name(name);
GB_symbol_t *symbol = map->buckets[hash];
while (symbol) {

View File

@ -142,8 +142,8 @@ void update_viewport(void)
double y_factor = win_height / (double) GB_get_screen_height(&gb);
if (configuration.scaling_mode == GB_SDL_SCALING_INTEGER_FACTOR) {
x_factor = (int)(x_factor);
y_factor = (int)(y_factor);
x_factor = (unsigned)(x_factor);
y_factor = (unsigned)(y_factor);
}
if (configuration.scaling_mode != GB_SDL_SCALING_ENTIRE_WINDOW) {
@ -1265,7 +1265,7 @@ void run_gui(bool is_running)
}
if (item->value_getter && !item->backwards_handler) {
char line[25];
snprintf(line, sizeof(line), "%s%*s", item->string, 24 - (int)strlen(item->string), item->value_getter(i));
snprintf(line, sizeof(line), "%s%*s", item->string, 24 - (unsigned)strlen(item->string), item->value_getter(i));
draw_text_centered(pixels, width, height, y + y_offset, line, gui_palette_native[3], gui_palette_native[0],
i == current_selection ? DECORATION_SELECTION : DECORATION_NONE);
y += 12;

View File

@ -75,7 +75,7 @@ bool init_shader_with_name(shader_t *shader, const char *name)
static char master_shader_code[0x801] = {0,};
static char shader_code[0x10001] = {0,};
static char final_shader_code[0x10801] = {0,};
static signed long filter_token_location = 0;
static ssize_t filter_token_location = 0;
if (!master_shader_code[0]) {
FILE *master_shader_f = fopen(resource_path("Shaders/MasterShader.fsh"), "r");