diff --git a/bsnes/emulator/emulator.hpp b/bsnes/emulator/emulator.hpp index 7d861898..ae546402 100644 --- a/bsnes/emulator/emulator.hpp +++ b/bsnes/emulator/emulator.hpp @@ -32,7 +32,7 @@ using namespace nall; namespace Emulator { static const string Name = "bsnes"; - static const string Version = "107.7"; + static const string Version = "107.8"; static const string Author = "byuu"; static const string License = "GPLv3"; static const string Website = "https://byuu.org/"; diff --git a/bsnes/filter/snes_ntsc/snes_ntsc.c b/bsnes/filter/snes_ntsc/snes_ntsc.c old mode 100644 new mode 100755 diff --git a/bsnes/filter/snes_ntsc/snes_ntsc.h b/bsnes/filter/snes_ntsc/snes_ntsc.h old mode 100644 new mode 100755 diff --git a/bsnes/filter/snes_ntsc/snes_ntsc_config.h b/bsnes/filter/snes_ntsc/snes_ntsc_config.h old mode 100644 new mode 100755 diff --git a/bsnes/filter/snes_ntsc/snes_ntsc_impl.h b/bsnes/filter/snes_ntsc/snes_ntsc_impl.h old mode 100644 new mode 100755 diff --git a/sameboy/Core/apu.c b/bsnes/gb/Core/apu.c similarity index 97% rename from sameboy/Core/apu.c rename to bsnes/gb/Core/apu.c index 5e975cb1..ee581385 100644 --- a/sameboy/Core/apu.c +++ b/bsnes/gb/Core/apu.c @@ -506,6 +506,11 @@ void GB_apu_run(GB_gameboy_t *gb) void GB_apu_init(GB_gameboy_t *gb) { memset(&gb->apu, 0, sizeof(gb->apu)); + /* Restore the wave form */ + for (unsigned reg = GB_IO_WAV_START; reg <= GB_IO_WAV_END; reg++) { + gb->apu.wave_channel.wave_form[(reg - GB_IO_WAV_START) * 2] = gb->io_registers[reg] >> 4; + gb->apu.wave_channel.wave_form[(reg - GB_IO_WAV_START) * 2 + 1] = gb->io_registers[reg] & 0xF; + } gb->apu.lf_div = 1; /* APU glitch: When turning the APU on while DIV's bit 4 (or 5 in double speed mode) is on, the first DIV/APU event is skipped. */ @@ -556,14 +561,14 @@ uint8_t GB_apu_read(GB_gameboy_t *gb, uint8_t reg) void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) { - if (!gb->apu.global_enable && reg != GB_IO_NR52 && (GB_is_cgb(gb) || - ( - reg != GB_IO_NR11 && - reg != GB_IO_NR21 && - reg != GB_IO_NR31 && - reg != GB_IO_NR41 - ) - )) { + if (!gb->apu.global_enable && reg != GB_IO_NR52 && reg < GB_IO_WAV_START && (GB_is_cgb(gb) || + ( + reg != GB_IO_NR11 && + reg != GB_IO_NR21 && + reg != GB_IO_NR31 && + reg != GB_IO_NR41 + ) + )) { return; } diff --git a/sameboy/Core/apu.h b/bsnes/gb/Core/apu.h similarity index 100% rename from sameboy/Core/apu.h rename to bsnes/gb/Core/apu.h diff --git a/sameboy/Core/camera.c b/bsnes/gb/Core/camera.c similarity index 100% rename from sameboy/Core/camera.c rename to bsnes/gb/Core/camera.c diff --git a/sameboy/Core/camera.h b/bsnes/gb/Core/camera.h similarity index 100% rename from sameboy/Core/camera.h rename to bsnes/gb/Core/camera.h diff --git a/sameboy/Core/debugger.c b/bsnes/gb/Core/debugger.c similarity index 99% rename from sameboy/Core/debugger.c rename to bsnes/gb/Core/debugger.c index 357a896d..df480f34 100644 --- a/sameboy/Core/debugger.c +++ b/bsnes/gb/Core/debugger.c @@ -2172,7 +2172,7 @@ void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path) unsigned bank, address; char symbol[length]; - if (sscanf(line, "%02x:%04x %s", &bank, &address, symbol) == 3) { + if (sscanf(line, "%x:%x %s", &bank, &address, symbol) == 3) { bank &= 0x1FF; if (!gb->bank_symbols[bank]) { gb->bank_symbols[bank] = GB_map_alloc(); diff --git a/sameboy/Core/debugger.h b/bsnes/gb/Core/debugger.h similarity index 100% rename from sameboy/Core/debugger.h rename to bsnes/gb/Core/debugger.h diff --git a/sameboy/Core/display.c b/bsnes/gb/Core/display.c similarity index 97% rename from sameboy/Core/display.c rename to bsnes/gb/Core/display.c index cf532167..0143f2b1 100644 --- a/sameboy/Core/display.c +++ b/bsnes/gb/Core/display.c @@ -123,23 +123,22 @@ static void display_vblank(GB_gameboy_t *gb) { gb->vblank_just_occured = true; - /* TODO: Slow in trubo mode! */ - if (GB_is_sgb(gb)) { + /* TODO: Slow in turbo mode! */ + if (GB_is_hle_sgb(gb)) { GB_sgb_render(gb); } - + if (gb->turbo) { if (GB_timing_sync_turbo(gb)) { return; } } - + if (!gb->disable_rendering && ((!(gb->io_registers[GB_IO_LCDC] & 0x80) || gb->stopped) || gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON)) { /* LCD is off, set screen to white or black (if LCD is on in stop mode) */ if (gb->sgb) { - uint8_t color = (gb->io_registers[GB_IO_LCDC] & 0x80) && gb->stopped && GB_is_cgb(gb) ? 0x3 : 0x0; for (unsigned i = 0; i < WIDTH * LINES; i++) { - gb->sgb->screen_buffer[i] = color; + gb->sgb->screen_buffer[i] = 0x0; } } else { @@ -376,6 +375,8 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) bg_enabled = false; } } + + uint8_t icd_pixel = 0; { uint8_t pixel = bg_enabled? fifo_item->pixel : 0; @@ -387,7 +388,13 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) } if (gb->sgb) { if (gb->current_lcd_line < LINES) { - gb->sgb->screen_buffer[gb->position_in_line + gb->current_lcd_line * WIDTH] = pixel; + gb->sgb->screen_buffer[gb->position_in_line + gb->current_lcd_line * WIDTH] = gb->stopped? 0 : pixel; + } + } + else if (gb->model & GB_MODEL_NO_SFC_BIT) { + if (gb->icd_pixel_callback) { + icd_pixel = pixel; + //gb->icd_pixel_callback(gb, pixel); } } else { @@ -403,13 +410,26 @@ static void render_pixel_if_possible(GB_gameboy_t *gb) } if (gb->sgb) { if (gb->current_lcd_line < LINES) { - gb->sgb->screen_buffer[gb->position_in_line + gb->current_lcd_line * WIDTH] = pixel; + gb->sgb->screen_buffer[gb->position_in_line + gb->current_lcd_line * WIDTH] = gb->stopped? 0 : pixel; + } + } + else if (gb->model & GB_MODEL_NO_SFC_BIT) { + if (gb->icd_pixel_callback) { + icd_pixel = pixel; + //gb->icd_pixel_callback(gb, pixel); } } else { gb->screen[gb->position_in_line + gb->current_line * WIDTH] = gb->sprite_palettes_rgb[oam_fifo_item->palette * 4 + pixel]; } } + + /* byuu: gotta do this later so it's only done once ... you'll probably wanna refactor this somehow :/ */ + if (gb->model & GB_MODEL_NO_SFC_BIT) { + if (gb->icd_pixel_callback) { + gb->icd_pixel_callback(gb, icd_pixel); + } + } gb->position_in_line++; } @@ -890,6 +910,11 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) } GB_SLEEP(gb, display, 11, LINE_LENGTH - gb->cycles_for_line); gb->mode_for_interrupt = 2; + + /* TODO: Can this timing even be verified? */ + if (gb->icd_hreset_callback) { + gb->icd_hreset_callback(gb); + } } /* Lines 144 - 152 */ @@ -961,7 +986,11 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles) gb->wy_diff = 0; gb->window_disabled_while_active = false; gb->current_line = 0; - gb->current_lcd_line = -1; // TODO: not the correct timing + // TODO: not the correct timing + gb->current_lcd_line = -1; + if (gb->icd_vreset_callback) { + gb->icd_vreset_callback(gb); + } } } diff --git a/sameboy/Core/display.h b/bsnes/gb/Core/display.h similarity index 100% rename from sameboy/Core/display.h rename to bsnes/gb/Core/display.h diff --git a/sameboy/Core/gb.c b/bsnes/gb/Core/gb.c similarity index 93% rename from sameboy/Core/gb.c rename to bsnes/gb/Core/gb.c index 744446e4..1e940cfe 100644 --- a/sameboy/Core/gb.c +++ b/bsnes/gb/Core/gb.c @@ -112,6 +112,11 @@ void GB_init(GB_gameboy_t *gb, GB_model_t model) gb->cartridge_type = &GB_cart_defs[0]; // Default cartridge type gb->clock_multiplier = 1.0; + if (model & GB_MODEL_NO_SFC_BIT) { + /* Disable time syncing. Timing should be done by the SFC emulator. */ + gb->turbo = true; + } + GB_reset(gb); } @@ -193,26 +198,27 @@ int GB_load_rom(GB_gameboy_t *gb, const char *path) } gb->rom = malloc(gb->rom_size); memset(gb->rom, 0xFF, gb->rom_size); /* Pad with 0xFFs */ - fread(gb->rom, gb->rom_size, 1, f); + fread(gb->rom, 1, gb->rom_size, f); fclose(f); GB_configure_cart(gb); return 0; } -/* byuu */ -int GB_load_rom_from_buffer(GB_gameboy_t* gb, const unsigned char* buffer, size_t size) { - gb->rom_size = (size + 0x3fff) & ~0x3fff; - while(gb->rom_size & (gb->rom_size - 1)) { - gb->rom_size |= gb->rom_size >> 1; - gb->rom_size++; - } - if(gb->rom) free(gb->rom); - gb->rom = (uint8_t*)malloc(gb->rom_size); - memset(gb->rom, 0xff, gb->rom_size); - memcpy(gb->rom, buffer, size); - GB_configure_cart(gb); - return 0; +void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size) +{ + gb->rom_size = (size + 0x3fff) & ~0x3fff; + while (gb->rom_size & (gb->rom_size - 1)) { + gb->rom_size |= gb->rom_size >> 1; + gb->rom_size++; + } + if (gb->rom) { + free(gb->rom); + } + gb->rom = malloc(gb->rom_size); + memset(gb->rom, 0xff, gb->rom_size); + memcpy(gb->rom, buffer, size); + GB_configure_cart(gb); } typedef struct { @@ -548,6 +554,11 @@ bool GB_is_cgb(GB_gameboy_t *gb) } bool GB_is_sgb(GB_gameboy_t *gb) +{ + return (gb->model & ~GB_MODEL_PAL_BIT & ~GB_MODEL_NO_SFC_BIT) == GB_MODEL_SGB || (gb->model & ~GB_MODEL_NO_SFC_BIT) == GB_MODEL_SGB2; +} + +bool GB_is_hle_sgb(GB_gameboy_t *gb) { return (gb->model & ~GB_MODEL_PAL_BIT) == GB_MODEL_SGB || gb->model == GB_MODEL_SGB2; } @@ -586,6 +597,7 @@ static void reset_ram(GB_gameboy_t *gb) case GB_MODEL_DMG_B: case GB_MODEL_SGB_NTSC: /* Unverified*/ case GB_MODEL_SGB_PAL: /* Unverified */ + case GB_MODEL_SGB_NO_SFC: for (unsigned i = 0; i < gb->ram_size; i++) { gb->ram[i] = GB_random(); if (i & 0x100) { @@ -598,6 +610,7 @@ static void reset_ram(GB_gameboy_t *gb) break; case GB_MODEL_SGB2: + case GB_MODEL_SGB2_NO_SFC: for (unsigned i = 0; i < gb->ram_size; i++) { gb->ram[i] = 0x55; gb->ram[i] ^= GB_random() & GB_random() & GB_random(); @@ -630,7 +643,9 @@ static void reset_ram(GB_gameboy_t *gb) case GB_MODEL_DMG_B: case GB_MODEL_SGB_NTSC: /* Unverified*/ case GB_MODEL_SGB_PAL: /* Unverified */ + case GB_MODEL_SGB_NO_SFC: case GB_MODEL_SGB2: + case GB_MODEL_SGB2_NO_SFC: for (unsigned i = 0; i < sizeof(gb->hram); i++) { if (i & 1) { gb->hram[i] = GB_random() | GB_random() | GB_random(); @@ -651,9 +666,11 @@ static void reset_ram(GB_gameboy_t *gb) break; case GB_MODEL_DMG_B: - case GB_MODEL_SGB_NTSC: /* Unverified*/ + case GB_MODEL_SGB_NTSC: /* Unverified */ case GB_MODEL_SGB_PAL: /* Unverified */ + case GB_MODEL_SGB_NO_SFC: /* Unverified */ case GB_MODEL_SGB2: + case GB_MODEL_SGB2_NO_SFC: for (unsigned i = 0; i < 8; i++) { if (i & 2) { gb->oam[i] = GB_random() & GB_random() & GB_random(); @@ -679,7 +696,9 @@ static void reset_ram(GB_gameboy_t *gb) case GB_MODEL_DMG_B: case GB_MODEL_SGB_NTSC: /* Unverified*/ case GB_MODEL_SGB_PAL: /* Unverified */ - case GB_MODEL_SGB2: { + case GB_MODEL_SGB_NO_SFC: /* Unverified */ + case GB_MODEL_SGB2: + case GB_MODEL_SGB2_NO_SFC: { uint8_t temp; for (unsigned i = 0; i < GB_IO_WAV_END - GB_IO_WAV_START; i++) { if (i & 1) { @@ -760,7 +779,7 @@ void GB_reset(GB_gameboy_t *gb) gb->accessed_oam_row = -1; - if (GB_is_sgb(gb)) { + if (GB_is_hle_sgb(gb)) { if (!gb->sgb) { gb->sgb = malloc(sizeof(*gb->sgb)); } @@ -894,17 +913,17 @@ uint32_t GB_get_clock_rate(GB_gameboy_t *gb) unsigned GB_get_screen_width(GB_gameboy_t *gb) { - return GB_is_sgb(gb)? 256 : 160; + return GB_is_hle_sgb(gb)? 256 : 160; } unsigned GB_get_screen_height(GB_gameboy_t *gb) { - return GB_is_sgb(gb)? 224 : 144; + return GB_is_hle_sgb(gb)? 224 : 144; } unsigned GB_get_player_count(GB_gameboy_t *gb) { - return GB_is_sgb(gb)? gb->sgb->player_count : 1; + return GB_is_hle_sgb(gb)? gb->sgb->player_count : 1; } void GB_set_update_input_hint_callback(GB_gameboy_t *gb, GB_update_input_hint_callback_t callback) @@ -916,3 +935,24 @@ double GB_get_usual_frame_rate(GB_gameboy_t *gb) { return GB_get_clock_rate(gb) / (double)LCDC_PERIOD; } + +void GB_set_joyp_write_callback(GB_gameboy_t *gb, GB_joyp_write_callback_t callback) +{ + gb->joyp_write_callback = callback; +} + +void GB_set_icd_pixel_callback(GB_gameboy_t *gb, GB_icd_pixel_callback_t callback) +{ + gb->icd_pixel_callback = callback; +} + +void GB_set_icd_hreset_callback(GB_gameboy_t *gb, GB_icd_hreset_callback_t callback) +{ + gb->icd_hreset_callback = callback; +} + + +void GB_set_icd_vreset_callback(GB_gameboy_t *gb, GB_icd_vreset_callback_t callback) +{ + gb->icd_vreset_callback = callback; +} diff --git a/sameboy/Core/gb.h b/bsnes/gb/Core/gb.h similarity index 94% rename from sameboy/Core/gb.h rename to bsnes/gb/Core/gb.h index 63177dd3..e12fcfac 100644 --- a/sameboy/Core/gb.h +++ b/bsnes/gb/Core/gb.h @@ -23,13 +23,14 @@ #define GB_STRUCT_VERSION 13 -#ifdef GB_INTERNAL #define GB_MODEL_FAMILY_MASK 0xF00 #define GB_MODEL_DMG_FAMILY 0x000 #define GB_MODEL_MGB_FAMILY 0x100 #define GB_MODEL_CGB_FAMILY 0x200 #define GB_MODEL_PAL_BIT 0x1000 +#define GB_MODEL_NO_SFC_BIT 0x2000 +#ifdef GB_INTERNAL #if __clang__ #define UNROLL _Pragma("unroll") #elif __GNUC__ @@ -67,9 +68,11 @@ typedef enum { // GB_MODEL_DMG_C = 0x003, GB_MODEL_SGB = 0x004, GB_MODEL_SGB_NTSC = GB_MODEL_SGB, - GB_MODEL_SGB_PAL = 0x1004, + GB_MODEL_SGB_PAL = GB_MODEL_SGB | GB_MODEL_PAL_BIT, + GB_MODEL_SGB_NO_SFC = GB_MODEL_SGB | GB_MODEL_NO_SFC_BIT, // GB_MODEL_MGB = 0x100, GB_MODEL_SGB2 = 0x101, + GB_MODEL_SGB2_NO_SFC = GB_MODEL_SGB2 | GB_MODEL_NO_SFC_BIT, // GB_MODEL_CGB_0 = 0x200, // GB_MODEL_CGB_A = 0x201, // GB_MODEL_CGB_B = 0x202, @@ -239,6 +242,10 @@ 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); typedef void (*GB_update_input_hint_callback_t)(GB_gameboy_t *gb); +typedef void (*GB_joyp_write_callback_t)(GB_gameboy_t *gb, uint8_t value); +typedef void (*GB_icd_pixel_callback_t)(GB_gameboy_t *gb, uint8_t row); +typedef void (*GB_icd_hreset_callback_t)(GB_gameboy_t *gb); +typedef void (*GB_icd_vreset_callback_t)(GB_gameboy_t *gb); typedef struct { bool state; @@ -444,7 +451,8 @@ struct GB_gameboy_internal_s { /* The LCDC will skip the first frame it renders after turning it on. On the CGB, a frame is not skipped if the previous frame was skipped as well. See https://www.reddit.com/r/EmuDev/comments/6exyxu/ */ - /* TODO: Drop this and properly emulate the dropped vreset signal*/ + + /* TODO: Drop this and properly emulate the dropped vreset signal*/ enum { GB_FRAMESKIP_LCD_TURNED_ON, // On a DMG, the LCD renders a blank screen during this state, // on a CGB, the previous frame is repeated (which might be @@ -530,6 +538,10 @@ struct GB_gameboy_internal_s { GB_serial_transfer_bit_start_callback_t serial_transfer_bit_start_callback; GB_serial_transfer_bit_end_callback_t serial_transfer_bit_end_callback; GB_update_input_hint_callback_t update_input_hint_callback; + GB_joyp_write_callback_t joyp_write_callback; + GB_icd_pixel_callback_t icd_pixel_callback; + GB_icd_vreset_callback_t icd_hreset_callback; + GB_icd_vreset_callback_t icd_vreset_callback; /* IR */ long cycles_since_ir_change; // In 8MHz units @@ -617,13 +629,14 @@ __attribute__((__format__ (__printf__, fmtarg, firstvararg))) void GB_init(GB_gameboy_t *gb, GB_model_t model); bool GB_is_inited(GB_gameboy_t *gb); bool GB_is_cgb(GB_gameboy_t *gb); -bool GB_is_sgb(GB_gameboy_t *gb); +bool GB_is_sgb(GB_gameboy_t *gb); // Returns true if the model is SGB or SGB2 +bool GB_is_hle_sgb(GB_gameboy_t *gb); // Returns true if the model is SGB or SGB2 and the SFC/SNES side is HLE'd GB_model_t GB_get_model(GB_gameboy_t *gb); void GB_free(GB_gameboy_t *gb); void GB_reset(GB_gameboy_t *gb); void GB_switch_model_and_reset(GB_gameboy_t *gb, GB_model_t model); -/* Returns the time passed, in 4MHz ticks. */ +/* Returns the time passed, in 8MHz ticks. */ uint8_t GB_run(GB_gameboy_t *gb); /* Returns the time passed since the last frame, in nanoseconds */ uint64_t GB_run_frame(GB_gameboy_t *gb); @@ -654,7 +667,7 @@ void GB_set_user_data(GB_gameboy_t *gb, void *data); int GB_load_boot_rom(GB_gameboy_t *gb, const char *path); void GB_load_boot_rom_from_buffer(GB_gameboy_t *gb, const unsigned char *buffer, size_t size); int GB_load_rom(GB_gameboy_t *gb, const char *path); -int GB_load_rom_from_buffer(GB_gameboy_t* gb, const unsigned char* buffer, size_t size); +void GB_load_rom_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t size); int GB_save_battery(GB_gameboy_t *gb, const char *path); void GB_load_battery(GB_gameboy_t *gb, const char *path); @@ -688,7 +701,13 @@ bool GB_serial_get_data_bit(GB_gameboy_t *gb); void GB_serial_set_data_bit(GB_gameboy_t *gb, bool data); void GB_disconnect_serial(GB_gameboy_t *gb); - + +/* For integration with SFC/SNES emulators */ +void GB_set_joyp_write_callback(GB_gameboy_t *gb, GB_joyp_write_callback_t callback); +void GB_set_icd_pixel_callback(GB_gameboy_t *gb, GB_icd_pixel_callback_t callback); +void GB_set_icd_hreset_callback(GB_gameboy_t *gb, GB_icd_hreset_callback_t callback); +void GB_set_icd_vreset_callback(GB_gameboy_t *gb, GB_icd_vreset_callback_t callback); + #ifdef GB_INTERNAL uint32_t GB_get_clock_rate(GB_gameboy_t *gb); #endif diff --git a/sameboy/Core/gb_struct_def.h b/bsnes/gb/Core/gb_struct_def.h similarity index 100% rename from sameboy/Core/gb_struct_def.h rename to bsnes/gb/Core/gb_struct_def.h diff --git a/sameboy/Core/joypad.c b/bsnes/gb/Core/joypad.c similarity index 82% rename from sameboy/Core/joypad.c rename to bsnes/gb/Core/joypad.c index 4ae6e676..6c0eaff7 100644 --- a/sameboy/Core/joypad.c +++ b/bsnes/gb/Core/joypad.c @@ -3,6 +3,8 @@ void GB_update_joyp(GB_gameboy_t *gb) { + if (gb->model & GB_MODEL_SGB_NO_SFC) return; + uint8_t key_selection = 0; uint8_t previous_state = 0; @@ -53,14 +55,27 @@ void GB_update_joyp(GB_gameboy_t *gb) break; } + /* Todo: This assumes the keys *always* bounce, which is incorrect when emulating an SGB */ if (previous_state != (gb->io_registers[GB_IO_JOYP] & 0xF)) { - /* The joypad interrupt DOES occur on CGB (Tested on CGB-CPU-06), unlike what some documents say. */ + /* The joypad interrupt DOES occur on CGB (Tested on CGB-E), unlike what some documents say. */ gb->io_registers[GB_IO_IF] |= 0x10; } gb->io_registers[GB_IO_JOYP] |= 0xC0; } +void GB_icd_set_joyp(GB_gameboy_t *gb, uint8_t value) +{ + uint8_t previous_state = gb->io_registers[GB_IO_JOYP] & 0xF; + gb->io_registers[GB_IO_JOYP] &= 0xF0; + gb->io_registers[GB_IO_JOYP] |= value & 0xF; + + if (previous_state & ~(gb->io_registers[GB_IO_JOYP] & 0xF)) { + gb->io_registers[GB_IO_IF] |= 0x10; + } + +} + void GB_set_key_state(GB_gameboy_t *gb, GB_key_t index, bool pressed) { assert(index >= 0 && index < GB_KEY_MAX); diff --git a/sameboy/Core/joypad.h b/bsnes/gb/Core/joypad.h similarity index 90% rename from sameboy/Core/joypad.h rename to bsnes/gb/Core/joypad.h index 768d685a..21fad534 100644 --- a/sameboy/Core/joypad.h +++ b/bsnes/gb/Core/joypad.h @@ -17,6 +17,7 @@ typedef enum { void GB_set_key_state(GB_gameboy_t *gb, GB_key_t index, bool pressed); void GB_set_key_state_for_player(GB_gameboy_t *gb, GB_key_t index, unsigned player, bool pressed); +void GB_icd_set_joyp(GB_gameboy_t *gb, uint8_t value); #ifdef GB_INTERNAL void GB_update_joyp(GB_gameboy_t *gb); diff --git a/sameboy/Core/mbc.c b/bsnes/gb/Core/mbc.c similarity index 100% rename from sameboy/Core/mbc.c rename to bsnes/gb/Core/mbc.c diff --git a/sameboy/Core/mbc.h b/bsnes/gb/Core/mbc.h similarity index 100% rename from sameboy/Core/mbc.h rename to bsnes/gb/Core/mbc.h diff --git a/sameboy/Core/memory.c b/bsnes/gb/Core/memory.c similarity index 99% rename from sameboy/Core/memory.c rename to bsnes/gb/Core/memory.c index 99ae1909..76d8821d 100644 --- a/sameboy/Core/memory.c +++ b/bsnes/gb/Core/memory.c @@ -273,7 +273,9 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr) case GB_MODEL_DMG_B: case GB_MODEL_SGB_NTSC: case GB_MODEL_SGB_PAL: + case GB_MODEL_SGB_NO_SFC: case GB_MODEL_SGB2: + case GB_MODEL_SGB2_NO_SFC: ; } } @@ -584,7 +586,9 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) case GB_MODEL_DMG_B: case GB_MODEL_SGB_NTSC: case GB_MODEL_SGB_PAL: + case GB_MODEL_SGB_NO_SFC: case GB_MODEL_SGB2: + case GB_MODEL_SGB2_NO_SFC: case GB_MODEL_CGB_E: case GB_MODEL_AGB: break; @@ -663,7 +667,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) /* These are the states when LY changes, let the display routine call GB_STAT_update for use so it correctly handles T-cycle accurate LYC writes */ if (!GB_is_cgb(gb) || ( - gb->display_state != 6 && + gb->display_state != 35 && gb->display_state != 26 && gb->display_state != 15 && gb->display_state != 16)) { @@ -737,8 +741,8 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) return; case GB_IO_JOYP: - GB_sgb_write(gb, value); gb->io_registers[GB_IO_JOYP] = value & 0xF0; + GB_sgb_write(gb, value); GB_update_joyp(gb); return; diff --git a/sameboy/Core/memory.h b/bsnes/gb/Core/memory.h similarity index 100% rename from sameboy/Core/memory.h rename to bsnes/gb/Core/memory.h diff --git a/sameboy/Core/printer.c b/bsnes/gb/Core/printer.c similarity index 100% rename from sameboy/Core/printer.c rename to bsnes/gb/Core/printer.c diff --git a/sameboy/Core/printer.h b/bsnes/gb/Core/printer.h similarity index 100% rename from sameboy/Core/printer.h rename to bsnes/gb/Core/printer.h diff --git a/sameboy/Core/random.c b/bsnes/gb/Core/random.c similarity index 100% rename from sameboy/Core/random.c rename to bsnes/gb/Core/random.c diff --git a/sameboy/Core/random.h b/bsnes/gb/Core/random.h similarity index 100% rename from sameboy/Core/random.h rename to bsnes/gb/Core/random.h diff --git a/sameboy/Core/rewind.c b/bsnes/gb/Core/rewind.c similarity index 100% rename from sameboy/Core/rewind.c rename to bsnes/gb/Core/rewind.c diff --git a/sameboy/Core/rewind.h b/bsnes/gb/Core/rewind.h similarity index 100% rename from sameboy/Core/rewind.h rename to bsnes/gb/Core/rewind.h diff --git a/sameboy/Core/save_state.c b/bsnes/gb/Core/save_state.c similarity index 97% rename from sameboy/Core/save_state.c rename to bsnes/gb/Core/save_state.c index 5a7d9207..8ef99aed 100644 --- a/sameboy/Core/save_state.c +++ b/bsnes/gb/Core/save_state.c @@ -36,7 +36,7 @@ int GB_save_state(GB_gameboy_t *gb, const char *path) if (!DUMP_SECTION(gb, f, rtc )) goto error; if (!DUMP_SECTION(gb, f, video )) goto error; - if (GB_is_sgb(gb)) { + if (GB_is_hle_sgb(gb)) { if (!dump_section(f, gb->sgb, sizeof(*gb->sgb))) goto error; } @@ -73,7 +73,7 @@ size_t GB_get_save_state_size(GB_gameboy_t *gb) + GB_SECTION_SIZE(apu ) + sizeof(uint32_t) + GB_SECTION_SIZE(rtc ) + sizeof(uint32_t) + GB_SECTION_SIZE(video ) + sizeof(uint32_t) - + (GB_is_sgb(gb)? sizeof(*gb->sgb) + sizeof(uint32_t) : 0) + + (GB_is_hle_sgb(gb)? sizeof(*gb->sgb) + sizeof(uint32_t) : 0) + gb->mbc_ram_size + gb->ram_size + gb->vram_size; @@ -105,7 +105,7 @@ void GB_save_state_to_buffer(GB_gameboy_t *gb, uint8_t *buffer) DUMP_SECTION(gb, buffer, rtc ); DUMP_SECTION(gb, buffer, video ); - if (GB_is_sgb(gb)) { + if (GB_is_hle_sgb(gb)) { buffer_dump_section(&buffer, gb->sgb, sizeof(*gb->sgb)); } @@ -161,8 +161,8 @@ static bool verify_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t *save) return false; } - if (GB_is_sgb(gb) != GB_is_sgb(save)) { - GB_log(gb, "The save state is %sfor a Super Game Boy. Try changing the emulated model.\n", GB_is_sgb(save)? "" : "not "); + if (GB_is_hle_sgb(gb) != GB_is_hle_sgb(save)) { + GB_log(gb, "The save state is %sfor a Super Game Boy. Try changing the emulated model.\n", GB_is_hle_sgb(save)? "" : "not "); return false; } @@ -223,7 +223,7 @@ int GB_load_state(GB_gameboy_t *gb, const char *path) goto error; } - if (GB_is_sgb(gb)) { + if (GB_is_hle_sgb(gb)) { if (!read_section(f, gb->sgb, sizeof(*gb->sgb))) goto error; } @@ -334,7 +334,7 @@ int GB_load_state_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t le return -1; } - if (GB_is_sgb(gb)) { + if (GB_is_hle_sgb(gb)) { if (!buffer_read_section(&buffer, &length, gb->sgb, sizeof(*gb->sgb))) return -1; } diff --git a/sameboy/Core/save_state.h b/bsnes/gb/Core/save_state.h similarity index 100% rename from sameboy/Core/save_state.h rename to bsnes/gb/Core/save_state.h diff --git a/sameboy/Core/sgb.c b/bsnes/gb/Core/sgb.c similarity index 99% rename from sameboy/Core/sgb.c rename to bsnes/gb/Core/sgb.c index 5bcb72d7..ccc439ab 100644 --- a/sameboy/Core/sgb.c +++ b/bsnes/gb/Core/sgb.c @@ -295,7 +295,14 @@ static void command_ready(GB_gameboy_t *gb) void GB_sgb_write(GB_gameboy_t *gb, uint8_t value) { + if (gb->joyp_write_callback) { + gb->joyp_write_callback(gb, value); + } if (!GB_is_sgb(gb)) return; + if (!GB_is_hle_sgb(gb)) { + /* Notify via callback */ + return; + } if (gb->sgb->disable_commands) return; if (gb->sgb->command_write_index >= sizeof(gb->sgb->command) * 8) return; diff --git a/sameboy/Core/sgb.h b/bsnes/gb/Core/sgb.h similarity index 100% rename from sameboy/Core/sgb.h rename to bsnes/gb/Core/sgb.h diff --git a/sameboy/Core/sgb_animation_logo.inc b/bsnes/gb/Core/sgb_animation_logo.inc similarity index 100% rename from sameboy/Core/sgb_animation_logo.inc rename to bsnes/gb/Core/sgb_animation_logo.inc diff --git a/sameboy/Core/sgb_border.inc b/bsnes/gb/Core/sgb_border.inc similarity index 100% rename from sameboy/Core/sgb_border.inc rename to bsnes/gb/Core/sgb_border.inc diff --git a/sameboy/Core/sm83_cpu.c b/bsnes/gb/Core/sm83_cpu.c similarity index 100% rename from sameboy/Core/sm83_cpu.c rename to bsnes/gb/Core/sm83_cpu.c diff --git a/sameboy/Core/sm83_cpu.h b/bsnes/gb/Core/sm83_cpu.h similarity index 100% rename from sameboy/Core/sm83_cpu.h rename to bsnes/gb/Core/sm83_cpu.h diff --git a/sameboy/Core/sm83_disassembler.c b/bsnes/gb/Core/sm83_disassembler.c similarity index 100% rename from sameboy/Core/sm83_disassembler.c rename to bsnes/gb/Core/sm83_disassembler.c diff --git a/sameboy/Core/symbol_hash.c b/bsnes/gb/Core/symbol_hash.c similarity index 100% rename from sameboy/Core/symbol_hash.c rename to bsnes/gb/Core/symbol_hash.c diff --git a/sameboy/Core/symbol_hash.h b/bsnes/gb/Core/symbol_hash.h similarity index 100% rename from sameboy/Core/symbol_hash.h rename to bsnes/gb/Core/symbol_hash.h diff --git a/sameboy/Core/timing.c b/bsnes/gb/Core/timing.c similarity index 100% rename from sameboy/Core/timing.c rename to bsnes/gb/Core/timing.c diff --git a/sameboy/Core/timing.h b/bsnes/gb/Core/timing.h similarity index 100% rename from sameboy/Core/timing.h rename to bsnes/gb/Core/timing.h diff --git a/bsnes/gb/GNUmakefile b/bsnes/gb/GNUmakefile index cf48dbdd..bfb7219c 100644 --- a/bsnes/gb/GNUmakefile +++ b/bsnes/gb/GNUmakefile @@ -1,38 +1,24 @@ -processors += sm83 - -objects += gb-interface gb-system -objects += gb-memory gb-cartridge -objects += gb-cpu gb-ppu gb-apu - -obj/gb-interface.o: gb/interface/interface.cpp -obj/gb-system.o: gb/system/system.cpp -obj/gb-cartridge.o: gb/cartridge/cartridge.cpp -obj/gb-memory.o: gb/memory/memory.cpp -obj/gb-cpu.o: gb/cpu/cpu.cpp -obj/gb-ppu.o: gb/ppu/ppu.cpp -obj/gb-apu.o: gb/apu/apu.cpp - flags += -DGB_INTERNAL -Wno-multichar -Dtypeof=__typeof__ options += -I../sameboy -objects += sb-apu sb-camera sb-debugger sb-display sb-gb sb-joypad sb-mbc -objects += sb-memory sb-printer sb-random sb-rewind sb-save_state sb-sgb -objects += sb-sm83_cpu sb-sm83_disassembler sb-symbol_hash sb-timing +objects += gb-apu gb-camera gb-debugger gb-display gb-gb gb-joypad gb-mbc +objects += gb-memory gb-printer gb-random gb-rewind gb-save_state gb-sgb +objects += gb-sm83_cpu gb-sm83_disassembler gb-symbol_hash gb-timing -obj/sb-apu.o: ../sameboy/Core/apu.c -obj/sb-camera.o: ../sameboy/Core/camera.c -obj/sb-debugger.o: ../sameboy/Core/debugger.c -obj/sb-display.o: ../sameboy/Core/display.c -obj/sb-gb.o: ../sameboy/Core/gb.c -obj/sb-joypad.o: ../sameboy/Core/joypad.c -obj/sb-mbc.o: ../sameboy/Core/mbc.c -obj/sb-memory.o: ../sameboy/Core/memory.c -obj/sb-printer.o: ../sameboy/Core/printer.c -obj/sb-random.o: ../sameboy/Core/random.c -obj/sb-rewind.o: ../sameboy/Core/rewind.c -obj/sb-save_state.o: ../sameboy/Core/save_state.c -obj/sb-sgb.o: ../sameboy/Core/sgb.c -obj/sb-sm83_cpu.o: ../sameboy/Core/sm83_cpu.c -obj/sb-sm83_disassembler.o: ../sameboy/Core/sm83_disassembler.c -obj/sb-symbol_hash.o: ../sameboy/Core/symbol_hash.c -obj/sb-timing.o: ../sameboy/Core/timing.c +obj/gb-apu.o: gb/Core/apu.c +obj/gb-camera.o: gb/Core/camera.c +obj/gb-debugger.o: gb/Core/debugger.c +obj/gb-display.o: gb/Core/display.c +obj/gb-gb.o: gb/Core/gb.c +obj/gb-joypad.o: gb/Core/joypad.c +obj/gb-mbc.o: gb/Core/mbc.c +obj/gb-memory.o: gb/Core/memory.c +obj/gb-printer.o: gb/Core/printer.c +obj/gb-random.o: gb/Core/random.c +obj/gb-rewind.o: gb/Core/rewind.c +obj/gb-save_state.o: gb/Core/save_state.c +obj/gb-sgb.o: gb/Core/sgb.c +obj/gb-sm83_cpu.o: gb/Core/sm83_cpu.c +obj/gb-sm83_disassembler.o: gb/Core/sm83_disassembler.c +obj/gb-symbol_hash.o: gb/Core/symbol_hash.c +obj/gb-timing.o: gb/Core/timing.c diff --git a/sameboy/LICENSE b/bsnes/gb/LICENSE similarity index 100% rename from sameboy/LICENSE rename to bsnes/gb/LICENSE diff --git a/bsnes/gb/apu/apu.cpp b/bsnes/gb/apu/apu.cpp deleted file mode 100644 index 681b57f6..00000000 --- a/bsnes/gb/apu/apu.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include - -namespace GameBoy { - -#include "sequencer.cpp" -#include "square1.cpp" -#include "square2.cpp" -#include "wave.cpp" -#include "noise.cpp" -#include "serialization.cpp" -APU apu; - -auto APU::Enter() -> void { - while(true) scheduler.synchronize(), apu.main(); -} - -auto APU::main() -> void { - square1.run(); - square2.run(); - wave.run(); - noise.run(); - sequencer.run(); - - if(!Model::SuperGameBoy()) { - stream->sample(float(sequencer.left / 32768.0), float(sequencer.right / 32768.0)); - } else { - float samples[] = {float(sequencer.left / 32768.0), float(sequencer.right / 32768.0)}; - superGameBoy->audioSample(samples, 2); - } - - if(cycle == 0) { //512hz - if(phase == 0 || phase == 2 || phase == 4 || phase == 6) { //256hz - square1.clockLength(); - square2.clockLength(); - wave.clockLength(); - noise.clockLength(); - } - if(phase == 2 || phase == 6) { //128hz - square1.clockSweep(); - } - if(phase == 7) { //64hz - square1.clockEnvelope(); - square2.clockEnvelope(); - noise.clockEnvelope(); - } - phase++; - } - cycle++; - - Thread::step(1); - synchronize(cpu); -} - -auto APU::power() -> void { - create(Enter, 2 * 1024 * 1024); - if(!Model::SuperGameBoy()) { - stream = Emulator::audio.createStream(2, frequency()); - stream->addHighPassFilter(20.0, Emulator::Filter::Order::First); - stream->addDCRemovalFilter(); - } - for(uint n = 0xff10; n <= 0xff3f; n++) bus.mmio[n] = this; - - square1.power(); - square2.power(); - wave.power(); - noise.power(); - sequencer.power(); - phase = 0; - cycle = 0; - - PRNG::PCG prng; - for(auto& n : wave.pattern) n = prng.random(); -} - -auto APU::readIO(uint16 addr) -> uint8 { - if(addr >= 0xff10 && addr <= 0xff14) return square1.read(addr); - if(addr >= 0xff15 && addr <= 0xff19) return square2.read(addr); - if(addr >= 0xff1a && addr <= 0xff1e) return wave.read(addr); - if(addr >= 0xff1f && addr <= 0xff23) return noise.read(addr); - if(addr >= 0xff24 && addr <= 0xff26) return sequencer.read(addr); - if(addr >= 0xff30 && addr <= 0xff3f) return wave.read(addr); - return 0xff; -} - -auto APU::writeIO(uint16 addr, uint8 data) -> void { - if(!sequencer.enable) { - bool valid = addr == 0xff26; //NR52 - if(!Model::GameBoyColor()) { - //NRx1 length is writable only on DMG,SGB; not on CGB - if(addr == 0xff11) valid = true, data &= 0x3f; //NR11; duty is not writable (remains 0) - if(addr == 0xff16) valid = true, data &= 0x3f; //NR21; duty is not writable (remains 0) - if(addr == 0xff1b) valid = true; //NR31 - if(addr == 0xff20) valid = true; //NR41 - } - if(!valid) return; - } - - if(addr >= 0xff10 && addr <= 0xff14) return square1.write(addr, data); - if(addr >= 0xff15 && addr <= 0xff19) return square2.write(addr, data); - if(addr >= 0xff1a && addr <= 0xff1e) return wave.write(addr, data); - if(addr >= 0xff1f && addr <= 0xff23) return noise.write(addr, data); - if(addr >= 0xff24 && addr <= 0xff26) return sequencer.write(addr, data); - if(addr >= 0xff30 && addr <= 0xff3f) return wave.write(addr, data); -} - -} diff --git a/bsnes/gb/apu/apu.hpp b/bsnes/gb/apu/apu.hpp deleted file mode 100644 index ddc86b1a..00000000 --- a/bsnes/gb/apu/apu.hpp +++ /dev/null @@ -1,171 +0,0 @@ -struct APU : Thread, MMIO { - shared_pointer stream; - - static auto Enter() -> void; - auto main() -> void; - auto power() -> void; - - auto readIO(uint16 addr) -> uint8; - auto writeIO(uint16 addr, uint8 data) -> void; - - auto serialize(serializer&) -> void; - - //square1.cpp - struct Square1 { - auto dacEnable() const -> bool; - - auto run() -> void; - auto sweep(bool update) -> void; - auto clockLength() -> void; - auto clockSweep() -> void; - auto clockEnvelope() -> void; - auto read(uint16 addr) -> uint8; - auto write(uint16 addr, uint8 data) -> void; - auto power(bool initializeLength = true) -> void; - - auto serialize(serializer&) -> void; - - bool enable; - - uint3 sweepFrequency; - bool sweepDirection; - uint3 sweepShift; - bool sweepNegate; - uint2 duty; - uint length; - uint4 envelopeVolume; - bool envelopeDirection; - uint3 envelopeFrequency; - uint11 frequency; - bool counter; - - int16 output; - bool dutyOutput; - uint3 phase; - uint period; - uint3 envelopePeriod; - uint3 sweepPeriod; - int frequencyShadow; - bool sweepEnable; - uint4 volume; - } square1; - - //square2.cpp - struct Square2 { - auto dacEnable() const -> bool; - - auto run() -> void; - auto clockLength() -> void; - auto clockEnvelope() -> void; - auto read(uint16 addr) -> uint8; - auto write(uint16 addr, uint8 data) -> void; - auto power(bool initializeLength = true) -> void; - - auto serialize(serializer&) -> void; - - bool enable; - - uint2 duty; - uint length; - uint4 envelopeVolume; - bool envelopeDirection; - uint3 envelopeFrequency; - uint11 frequency; - bool counter; - - int16 output; - bool dutyOutput; - uint3 phase; - uint period; - uint3 envelopePeriod; - uint4 volume; - } square2; - - struct Wave { - auto getPattern(uint5 offset) const -> uint4; - - auto run() -> void; - auto clockLength() -> void; - auto read(uint16 addr) -> uint8; - auto write(uint16 addr, uint8 data) -> void; - auto power(bool initializeLength = true) -> void; - - auto serialize(serializer&) -> void; - - bool enable; - - bool dacEnable; - uint2 volume; - uint11 frequency; - bool counter; - uint8 pattern[16]; - - int16 output; - uint length; - uint period; - uint5 patternOffset; - uint4 patternSample; - uint patternHold; - } wave; - - struct Noise { - auto dacEnable() const -> bool; - auto getPeriod() const -> uint; - - auto run() -> void; - auto clockLength() -> void; - auto clockEnvelope() -> void; - auto read(uint16 addr) -> uint8; - auto write(uint16 addr, uint8 data) -> void; - auto power(bool initializeLength = true) -> void; - - auto serialize(serializer&) -> void; - - bool enable; - - uint4 envelopeVolume; - bool envelopeDirection; - uint3 envelopeFrequency; - uint4 frequency; - bool narrow; - uint3 divisor; - bool counter; - - int16 output; - uint length; - uint3 envelopePeriod; - uint4 volume; - uint period; - uint15 lfsr; - } noise; - - struct Sequencer { - auto run() -> void; - auto read(uint16 addr) -> uint8; - auto write(uint16 addr, uint8 data) -> void; - auto power() -> void; - - auto serialize(serializer&) -> void; - - bool leftEnable; - uint3 leftVolume; - bool rightEnable; - uint3 rightVolume; - - struct Channel { - bool leftEnable; - bool rightEnable; - } square1, square2, wave, noise; - - bool enable; - - int16 center; - int16 left; - int16 right; - } sequencer; - - uint3 phase; //high 3-bits of clock counter - uint12 cycle; //low 12-bits of clock counter -}; - -extern APU apu; diff --git a/bsnes/gb/apu/noise.cpp b/bsnes/gb/apu/noise.cpp deleted file mode 100644 index 3b44c1ea..00000000 --- a/bsnes/gb/apu/noise.cpp +++ /dev/null @@ -1,140 +0,0 @@ -auto APU::Noise::dacEnable() const -> bool { - return (envelopeVolume || envelopeDirection); -} - -auto APU::Noise::getPeriod() const -> uint { - static const uint table[] = {4, 8, 16, 24, 32, 40, 48, 56}; - return table[divisor] << frequency; -} - -auto APU::Noise::run() -> void { - if(period && --period == 0) { - period = getPeriod(); - if(frequency < 14) { - bool bit = (lfsr ^ (lfsr >> 1)) & 1; - lfsr = (lfsr >> 1) ^ (bit << (narrow ? 6 : 14)); - } - } - - uint4 sample = lfsr & 1 ? 0 : (uint)volume; - if(!enable) sample = 0; - - output = sample; -} - -auto APU::Noise::clockLength() -> void { - if(counter) { - if(length && --length == 0) enable = false; - } -} - -auto APU::Noise::clockEnvelope() -> void { - if(enable && envelopeFrequency && --envelopePeriod == 0) { - envelopePeriod = envelopeFrequency ? (uint)envelopeFrequency : 8; - if(envelopeDirection == 0 && volume > 0) volume--; - if(envelopeDirection == 1 && volume < 15) volume++; - } -} - -auto APU::Noise::read(uint16 addr) -> uint8 { - if(addr == 0xff1f) { //NR40 - return 0xff; - } - - if(addr == 0xff20) { //NR41 - return 0xff; - } - - if(addr == 0xff21) { //NR42 - return envelopeVolume << 4 | envelopeDirection << 3 | envelopeFrequency; - } - - if(addr == 0xff22) { //NR43 - return frequency << 4 | narrow << 3 | divisor; - } - - if(addr == 0xff23) { //NR44 - return 0x80 | counter << 6 | 0x3f; - } - - return 0xff; -} - -auto APU::Noise::write(uint16 addr, uint8 data) -> void { - if(addr == 0xff20) { //NR41 - length = 64 - bits(data,0-5); - } - - if(addr == 0xff21) { //NR42 - envelopeVolume = bits(data,4-7); - envelopeDirection = bit1(data,3); - envelopeFrequency = bits(data,0-2); - if(!dacEnable()) enable = false; - } - - if(addr == 0xff22) { //NR43 - frequency = bits(data,4-7); - narrow = bit1(data,3); - divisor = bits(data,0-2); - period = getPeriod(); - } - - if(addr == 0xff23) { //NR44 - if(bit1(apu.phase,0) && !counter && bit1(data,6)) { - if(length && --length == 0) enable = false; - } - - counter = bit1(data,6); - - if(bit1(data,7)) { - enable = dacEnable(); - lfsr = -1; - envelopePeriod = envelopeFrequency ? (uint)envelopeFrequency : 8; - volume = envelopeVolume; - - if(!length) { - length = 64; - if(bit1(apu.phase,0) && counter) length--; - } - } - } -} - -auto APU::Noise::power(bool initializeLength) -> void { - enable = 0; - - envelopeVolume = 0; - envelopeDirection = 0; - envelopeFrequency = 0; - frequency = 0; - narrow = 0; - divisor = 0; - counter = 0; - - output = 0; - envelopePeriod = 0; - volume = 0; - period = 0; - lfsr = 0; - - if(initializeLength) length = 64; -} - -auto APU::Noise::serialize(serializer& s) -> void { - s.integer(enable); - - s.integer(envelopeVolume); - s.integer(envelopeDirection); - s.integer(envelopeFrequency); - s.integer(frequency); - s.integer(narrow); - s.integer(divisor); - s.integer(counter); - - s.integer(output); - s.integer(length); - s.integer(envelopePeriod); - s.integer(volume); - s.integer(period); - s.integer(lfsr); -} diff --git a/bsnes/gb/apu/sequencer.cpp b/bsnes/gb/apu/sequencer.cpp deleted file mode 100644 index f93667fb..00000000 --- a/bsnes/gb/apu/sequencer.cpp +++ /dev/null @@ -1,142 +0,0 @@ -auto APU::Sequencer::run() -> void { - if(enable == false) { - center = 0; - left = 0; - right = 0; - return; - } - - int sample = 0; - sample += apu.square1.output; - sample += apu.square2.output; - sample += apu.wave.output; - sample += apu.noise.output; - center = (sample * 512) - 16384; - - sample = 0; - if(square1.leftEnable) sample += apu.square1.output; - if(square2.leftEnable) sample += apu.square2.output; - if( wave.leftEnable) sample += apu.wave.output; - if( noise.leftEnable) sample += apu.noise.output; - sample = (sample * 512) - 16384; - sample = (sample * (leftVolume + 1)) / 8; - left = sample; - - sample = 0; - if(square1.rightEnable) sample += apu.square1.output; - if(square2.rightEnable) sample += apu.square2.output; - if( wave.rightEnable) sample += apu.wave.output; - if( noise.rightEnable) sample += apu.noise.output; - sample = (sample * 512) - 16384; - sample = (sample * (rightVolume + 1)) / 8; - right = sample; - - //reduce audio volume - center >>= 1; - left >>= 1; - right >>= 1; -} - -auto APU::Sequencer::read(uint16 addr) -> uint8 { - if(addr == 0xff24) { //NR50 - return leftEnable << 7 | leftVolume << 4 | rightEnable << 3 | rightVolume; - } - - if(addr == 0xff25) { //NR51 - return noise.leftEnable << 7 - | wave.leftEnable << 6 - | square2.leftEnable << 5 - | square1.leftEnable << 4 - | noise.rightEnable << 3 - | wave.rightEnable << 2 - | square2.rightEnable << 1 - | square1.rightEnable << 0; - } - - if(addr == 0xff26) { //NR52 - return enable << 7 | 0x70 - | apu.noise.enable << 3 - | apu.wave.enable << 2 - | apu.square2.enable << 1 - | apu.square1.enable << 0; - } - - return 0xff; -} - -auto APU::Sequencer::write(uint16 addr, uint8 data) -> void { - if(addr == 0xff24) { //NR50 - leftEnable = bit1(data,7); - leftVolume = bits(data,4-6); - rightEnable = bit1(data,3); - rightVolume = bits(data,0-2); - } - - if(addr == 0xff25) { //NR51 - noise.leftEnable = bit1(data,7); - wave.leftEnable = bit1(data,6); - square2.leftEnable = bit1(data,5); - square1.leftEnable = bit1(data,4); - noise.rightEnable = bit1(data,3); - wave.rightEnable = bit1(data,2); - square2.rightEnable = bit1(data,1); - square1.rightEnable = bit1(data,0); - } - - if(addr == 0xff26) { //NR52 - if(enable != bit1(data,7)) { - enable = bit1(data,7); - - if(!enable) { - //power(bool) resets length counters when true (eg for CGB only) - apu.square1.power(Model::GameBoyColor()); - apu.square2.power(Model::GameBoyColor()); - apu.wave.power(Model::GameBoyColor()); - apu.noise.power(Model::GameBoyColor()); - power(); - } else { - apu.phase = 0; - } - } - } -} - -auto APU::Sequencer::power() -> void { - leftEnable = 0; - leftVolume = 0; - rightEnable = 0; - rightVolume = 0; - noise.leftEnable = 0; - wave.leftEnable = 0; - square2.leftEnable = 0; - square1.leftEnable = 0; - noise.rightEnable = 0; - wave.rightEnable = 0; - square2.rightEnable = 0; - square1.rightEnable = 0; - enable = 0; - - center = 0; - left = 0; - right = 0; -} - -auto APU::Sequencer::serialize(serializer& s) -> void { - s.integer(leftEnable); - s.integer(leftVolume); - s.integer(rightEnable); - s.integer(rightVolume); - s.integer(noise.leftEnable); - s.integer(wave.leftEnable); - s.integer(square2.leftEnable); - s.integer(square1.leftEnable); - s.integer(noise.rightEnable); - s.integer(wave.rightEnable); - s.integer(square2.rightEnable); - s.integer(square1.rightEnable); - s.integer(enable); - - s.integer(center); - s.integer(left); - s.integer(right); -} diff --git a/bsnes/gb/apu/serialization.cpp b/bsnes/gb/apu/serialization.cpp deleted file mode 100644 index 1ae311aa..00000000 --- a/bsnes/gb/apu/serialization.cpp +++ /dev/null @@ -1,12 +0,0 @@ -auto APU::serialize(serializer& s) -> void { - Thread::serialize(s); - - square1.serialize(s); - square2.serialize(s); - wave.serialize(s); - noise.serialize(s); - sequencer.serialize(s); - - s.integer(phase); - s.integer(cycle); -} diff --git a/bsnes/gb/apu/square1.cpp b/bsnes/gb/apu/square1.cpp deleted file mode 100644 index 8f7e100c..00000000 --- a/bsnes/gb/apu/square1.cpp +++ /dev/null @@ -1,190 +0,0 @@ -auto APU::Square1::dacEnable() const -> bool { - return (envelopeVolume || envelopeDirection); -} - -auto APU::Square1::run() -> void { - if(period && --period == 0) { - period = 2 * (2048 - frequency); - phase++; - switch(duty) { - case 0: dutyOutput = (phase == 6); break; //______-_ - case 1: dutyOutput = (phase >= 6); break; //______-- - case 2: dutyOutput = (phase >= 4); break; //____---- - case 3: dutyOutput = (phase <= 5); break; //------__ - } - } - - uint4 sample = dutyOutput ? (uint)volume : 0; - if(!enable) sample = 0; - - output = sample; -} - -auto APU::Square1::sweep(bool update) -> void { - if(!sweepEnable) return; - - sweepNegate = sweepDirection; - uint delta = frequencyShadow >> sweepShift; - int freq = frequencyShadow + (sweepNegate ? -delta : delta); - - if(freq > 2047) { - enable = false; - } else if(sweepShift && update) { - frequencyShadow = freq; - frequency = freq & 2047; - period = 2 * (2048 - frequency); - } -} - -auto APU::Square1::clockLength() -> void { - if(counter) { - if(length && --length == 0) enable = false; - } -} - -auto APU::Square1::clockSweep() -> void { - if(--sweepPeriod == 0) { - sweepPeriod = sweepFrequency ? (uint)sweepFrequency : 8; - if(sweepEnable && sweepFrequency) { - sweep(1); - sweep(0); - } - } -} - -auto APU::Square1::clockEnvelope() -> void { - if(enable && envelopeFrequency && --envelopePeriod == 0) { - envelopePeriod = envelopeFrequency ? (uint)envelopeFrequency : 8; - if(envelopeDirection == 0 && volume > 0) volume--; - if(envelopeDirection == 1 && volume < 15) volume++; - } -} - -auto APU::Square1::read(uint16 addr) -> uint8 { - if(addr == 0xff10) { //NR10 - return 0x80 | sweepFrequency << 4 | sweepDirection << 3 | sweepShift; - } - - if(addr == 0xff11) { //NR11 - return duty << 6 | 0x3f; - } - - if(addr == 0xff12) { //NR12 - return envelopeVolume << 4 | envelopeDirection << 3 | envelopeFrequency; - } - - if(addr == 0xff13) { //NR13 - return 0xff; - } - - if(addr == 0xff14) { //NR14 - return 0x80 | counter << 6 | 0x3f; - } - - return 0xff; -} - -auto APU::Square1::write(uint16 addr, uint8 data) -> void { - if(addr == 0xff10) { //NR10 - if(sweepEnable && sweepNegate && !bit1(data,3)) enable = false; - sweepFrequency = bits(data,4-6); - sweepDirection = bit1(data,3); - sweepShift = bits(data,0-2); - } - - if(addr == 0xff11) { //NR11 - duty = bits(data,6-7); - length = 64 - bits(data,0-5); - } - - if(addr == 0xff12) { //NR12 - envelopeVolume = bits(data,4-7); - envelopeDirection = bit1(data,3); - envelopeFrequency = bits(data,0-2); - if(!dacEnable()) enable = false; - } - - if(addr == 0xff13) { //NR13 - bits(frequency,0-7) = data; - } - - if(addr == 0xff14) { //NR14 - if(bit1(apu.phase,0) && !counter && bit1(data,6)) { - if(length && --length == 0) enable = false; - } - - counter = bit1(data,6); - bits(frequency,8-10) = (uint)bits(data,0-2); - - if(bit1(data,7)) { - enable = dacEnable(); - period = 2 * (2048 - frequency); - envelopePeriod = envelopeFrequency ? (uint)envelopeFrequency : 8; - volume = envelopeVolume; - - if(!length) { - length = 64; - if(bit1(apu.phase,0) && counter) length--; - } - - frequencyShadow = frequency; - sweepNegate = false; - sweepPeriod = sweepFrequency ? (uint)sweepFrequency : 8; - sweepEnable = sweepPeriod || sweepShift; - if(sweepShift) sweep(0); - } - } -} - -auto APU::Square1::power(bool initializeLength) -> void { - enable = 0; - - sweepFrequency = 0; - sweepDirection = 0; - sweepShift = 0; - sweepNegate = 0; - duty = 0; - envelopeVolume = 0; - envelopeDirection = 0; - envelopeFrequency = 0; - frequency = 0; - counter = 0; - - output = 0; - dutyOutput = 0; - phase = 0; - period = 0; - envelopePeriod = 0; - sweepPeriod = 0; - frequencyShadow = 0; - sweepEnable = 0; - volume = 0; - - if(initializeLength) length = 64; -} - -auto APU::Square1::serialize(serializer& s) -> void { - s.integer(enable); - - s.integer(sweepFrequency); - s.integer(sweepDirection); - s.integer(sweepShift); - s.integer(sweepNegate); - s.integer(duty); - s.integer(length); - s.integer(envelopeVolume); - s.integer(envelopeDirection); - s.integer(envelopeFrequency); - s.integer(frequency); - s.integer(counter); - - s.integer(output); - s.integer(dutyOutput); - s.integer(phase); - s.integer(period); - s.integer(envelopePeriod); - s.integer(sweepPeriod); - s.integer(frequencyShadow); - s.integer(sweepEnable); - s.integer(volume); -} diff --git a/bsnes/gb/apu/square2.cpp b/bsnes/gb/apu/square2.cpp deleted file mode 100644 index 916e424d..00000000 --- a/bsnes/gb/apu/square2.cpp +++ /dev/null @@ -1,137 +0,0 @@ -auto APU::Square2::dacEnable() const -> bool { - return (envelopeVolume || envelopeDirection); -} - -auto APU::Square2::run() -> void { - if(period && --period == 0) { - period = 2 * (2048 - frequency); - phase++; - switch(duty) { - case 0: dutyOutput = (phase == 6); break; //______-_ - case 1: dutyOutput = (phase >= 6); break; //______-- - case 2: dutyOutput = (phase >= 4); break; //____---- - case 3: dutyOutput = (phase <= 5); break; //------__ - } - } - - uint4 sample = dutyOutput ? (uint)volume : 0; - if(!enable) sample = 0; - - output = sample; -} - -auto APU::Square2::clockLength() -> void { - if(counter) { - if(length && --length == 0) enable = false; - } -} - -auto APU::Square2::clockEnvelope() -> void { - if(enable && envelopeFrequency && --envelopePeriod == 0) { - envelopePeriod = envelopeFrequency ? (uint)envelopeFrequency : 8; - if(envelopeDirection == 0 && volume > 0) volume--; - if(envelopeDirection == 1 && volume < 15) volume++; - } -} - -auto APU::Square2::read(uint16 addr) -> uint8 { - if(addr == 0xff15) { //NR20 - return 0xff; - } - - if(addr == 0xff16) { //NR21 - return duty << 6 | 0x3f; - } - - if(addr == 0xff17) { //NR22 - return envelopeVolume << 4 | envelopeDirection << 3 | envelopeFrequency; - } - - if(addr == 0xff18) { //NR23 - return 0xff; - } - - if(addr == 0xff19) { //NR24 - return 0x80 | counter << 6 | 0x3f; - } - - return 0xff; -} - -auto APU::Square2::write(uint16 addr, uint8 data) -> void { - if(addr == 0xff16) { //NR21 - duty = bits(data,6-7); - length = 64 - bits(data,0-5); - } - - if(addr == 0xff17) { //NR22 - envelopeVolume = bits(data,4-7); - envelopeDirection = bit1(data,3); - envelopeFrequency = bits(data,0-2); - if(!dacEnable()) enable = false; - } - - if(addr == 0xff18) { //NR23 - bits(frequency,0-7) = data; - } - - if(addr == 0xff19) { //NR24 - if(bit1(apu.phase,0) && !counter && bit1(data,6)) { - if(length && --length == 0) enable = false; - } - - counter = bit1(data,6); - bits(frequency,8-10) = (uint)bits(data,0-2); - - if(bit1(data,7)) { - enable = dacEnable(); - period = 2 * (2048 - frequency); - envelopePeriod = envelopeFrequency ? (uint)envelopeFrequency : 8; - volume = envelopeVolume; - - if(!length) { - length = 64; - if(bit1(apu.phase,0) && counter) length--; - } - } - } -} - -auto APU::Square2::power(bool initializeLength) -> void { - enable = 0; - - duty = 0; - envelopeVolume = 0; - envelopeDirection = 0; - envelopeFrequency = 0; - frequency = 0; - counter = 0; - - output = 0; - dutyOutput = 0; - phase = 0; - period = 0; - envelopePeriod = 0; - volume = 0; - - if(initializeLength) length = 64; -} - -auto APU::Square2::serialize(serializer& s) -> void { - s.integer(enable); - - s.integer(duty); - s.integer(length); - s.integer(envelopeVolume); - s.integer(envelopeDirection); - s.integer(envelopeFrequency); - s.integer(frequency); - s.integer(counter); - - s.integer(output); - s.integer(dutyOutput); - s.integer(phase); - s.integer(period); - s.integer(envelopePeriod); - s.integer(volume); -} diff --git a/bsnes/gb/apu/wave.cpp b/bsnes/gb/apu/wave.cpp deleted file mode 100644 index c1e41dfd..00000000 --- a/bsnes/gb/apu/wave.cpp +++ /dev/null @@ -1,156 +0,0 @@ -auto APU::Wave::getPattern(uint5 offset) const -> uint4 { - return pattern[offset >> 1] >> (offset & 1 ? 0 : 4); -} - -auto APU::Wave::run() -> void { - if(patternHold) patternHold--; - - if(period && --period == 0) { - period = 1 * (2048 - frequency); - patternSample = getPattern(++patternOffset); - patternHold = 1; - } - - static const uint shift[] = {4, 0, 1, 2}; //0%, 100%, 50%, 25% - uint4 sample = patternSample >> shift[volume]; - if(!enable) sample = 0; - - output = sample; -} - -auto APU::Wave::clockLength() -> void { - if(counter) { - if(length && --length == 0) enable = false; - } -} - -auto APU::Wave::read(uint16 addr) -> uint8 { - if(addr == 0xff1a) { //NR30 - return dacEnable << 7 | 0x7f; - } - - if(addr == 0xff1b) { //NR31 - return 0xff; - } - - if(addr == 0xff1c) { //NR32 - return 0x80 | volume << 5 | 0x1f; - } - - if(addr == 0xff1d) { //NR33 - return 0xff; - } - - if(addr == 0xff1e) { //NR34 - return 0x80 | counter << 6 | 0x3f; - } - - if(addr >= 0xff30 && addr <= 0xff3f) { - if(enable) { - if(!Model::GameBoyColor() && !patternHold) return 0xff; - return pattern[patternOffset >> 1]; - } else { - return pattern[addr & 15]; - } - } - - return 0xff; -} - -auto APU::Wave::write(uint16 addr, uint8 data) -> void { - if(addr == 0xff1a) { //NR30 - dacEnable = bit1(data,7); - if(!dacEnable) enable = false; - } - - if(addr == 0xff1b) { //NR31 - length = 256 - data; - } - - if(addr == 0xff1c) { //NR32 - volume = bits(data,5-6); - } - - if(addr == 0xff1d) { //NR33 - bits(frequency,0-7) = data; - } - - if(addr == 0xff1e) { //NR34 - if(bit1(apu.phase,0) && !counter && bit1(data,6)) { - if(length && --length == 0) enable = false; - } - - counter = bit1(data,6); - bits(frequency,8-10) = (uint)bits(data,0-2); - - if(bit1(data,7)) { - if(!Model::GameBoyColor() && patternHold) { - //DMG,SGB trigger while channel is being read corrupts wave RAM - if((patternOffset >> 1) <= 3) { - //if current pattern is with 0-3; only byte 0 is corrupted - pattern[0] = pattern[patternOffset >> 1]; - } else { - //if current pattern is within 4-15; pattern&~3 is copied to pattern[0-3] - pattern[0] = pattern[((patternOffset >> 1) & ~3) + 0]; - pattern[1] = pattern[((patternOffset >> 1) & ~3) + 1]; - pattern[2] = pattern[((patternOffset >> 1) & ~3) + 2]; - pattern[3] = pattern[((patternOffset >> 1) & ~3) + 3]; - } - } - - enable = dacEnable; - period = 1 * (2048 - frequency); - patternOffset = 0; - patternSample = 0; - patternHold = 0; - - if(!length) { - length = 256; - if(bit1(apu.phase,0) && counter) length--; - } - } - } - - if(addr >= 0xff30 && addr <= 0xff3f) { - if(enable) { - if(!Model::GameBoyColor() && !patternHold) return; - pattern[patternOffset >> 1] = data; - } else { - pattern[addr & 15] = data; - } - } -} - -auto APU::Wave::power(bool initializeLength) -> void { - enable = 0; - - dacEnable = 0; - volume = 0; - frequency = 0; - counter = 0; - - output = 0; - period = 0; - patternOffset = 0; - patternSample = 0; - patternHold = 0; - - if(initializeLength) length = 256; -} - -auto APU::Wave::serialize(serializer& s) -> void { - s.integer(enable); - - s.integer(dacEnable); - s.integer(volume); - s.integer(frequency); - s.integer(counter); - s.array(pattern); - - s.integer(output); - s.integer(length); - s.integer(period); - s.integer(patternOffset); - s.integer(patternSample); - s.integer(patternHold); -} diff --git a/bsnes/gb/cartridge/cartridge.cpp b/bsnes/gb/cartridge/cartridge.cpp deleted file mode 100644 index 36141e53..00000000 --- a/bsnes/gb/cartridge/cartridge.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include - -namespace GameBoy { - -Cartridge cartridge; -#include "mbc0/mbc0.cpp" -#include "mbc1/mbc1.cpp" -#include "mbc1m/mbc1m.cpp" -#include "mbc2/mbc2.cpp" -#include "mbc3/mbc3.cpp" -#include "mbc5/mbc5.cpp" -#include "mbc6/mbc6.cpp" -#include "mbc7/mbc7.cpp" -#include "mmm01/mmm01.cpp" -#include "huc1/huc1.cpp" -#include "huc3/huc3.cpp" -#include "tama/tama.cpp" -#include "serialization.cpp" - -auto Cartridge::Enter() -> void { - while(true) scheduler.synchronize(), cartridge.main(); -} - -auto Cartridge::main() -> void { - mapper->main(); -} - -auto Cartridge::step(uint clocks) -> void { - Thread::step(clocks); - synchronize(cpu); -} - -auto Cartridge::load() -> bool { - information = {}; - rom = {}; - ram = {}; - rtc = {}; - mapper = &mbc0; - accelerometer = false; - rumble = false; - - if(Model::GameBoy()) { - if(auto loaded = platform->load(ID::GameBoy, "Game Boy", "gb")) { - information.pathID = loaded.pathID; - } else return false; - } - - if(Model::GameBoyColor()) { - if(auto loaded = platform->load(ID::GameBoyColor, "Game Boy Color", "gbc")) { - information.pathID = loaded.pathID; - } else return false; - } - - if(Model::SuperGameBoy()) { - if(auto loaded = platform->load(ID::SuperGameBoy, "Game Boy", "gb")) { - information.pathID = loaded.pathID; - } else return false; - } - - if(auto fp = platform->open(pathID(), "manifest.bml", File::Read, File::Required)) { - information.manifest = fp->reads(); - } else return false; - - auto document = BML::unserialize(information.manifest); - information.title = document["game/label"].text(); - - auto mapperID = document["game/board"].text(); - if(mapperID == "MBC0" ) mapper = &mbc0; - if(mapperID == "MBC1" ) mapper = &mbc1; - if(mapperID == "MBC1M") mapper = &mbc1m; - if(mapperID == "MBC2" ) mapper = &mbc2; - if(mapperID == "MBC3" ) mapper = &mbc3; - if(mapperID == "MBC5" ) mapper = &mbc5; - if(mapperID == "MBC6" ) mapper = &mbc6; - if(mapperID == "MBC7" ) mapper = &mbc7; - if(mapperID == "MMM01") mapper = &mmm01; - if(mapperID == "HuC1" ) mapper = &huc1; - if(mapperID == "HuC3" ) mapper = &huc3; - if(mapperID == "TAMA" ) mapper = &tama; - - accelerometer = (bool)document["game/board/accelerometer"]; - rumble = (bool)document["game/board/rumble"]; - - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=ROM,content=Program)"]}) { - rom.size = max(0x4000, (uint)memory.size); - rom.data = memory::allocate(rom.size, 0xff); - if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Required)) { - fp->read(rom.data, min(rom.size, fp->size())); - } - } - - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RAM,content=Save)"]}) { - ram.size = memory.size; - ram.data = memory::allocate(ram.size, 0xff); - if(memory.nonVolatile) { - if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) { - fp->read(ram.data, min(ram.size, fp->size())); - } - } - } - - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RTC,content=Time)"]}) { - rtc.size = memory.size; - rtc.data = memory::allocate(rtc.size, 0xff); - if(memory.nonVolatile) { - if(auto fp = platform->open(pathID(), memory.name(), File::Read, File::Optional)) { - fp->read(rtc.data, min(rtc.size, fp->size())); - } - } - } - - information.sha256 = Hash::SHA256({rom.data, rom.size}).digest(); - mapper->load(document); - return true; -} - -auto Cartridge::save() -> void { - auto document = BML::unserialize(information.manifest); - - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RAM,content=Save)"]}) { - if(memory.nonVolatile) { - if(auto fp = platform->open(pathID(), memory.name(), File::Write)) { - fp->write(ram.data, ram.size); - } - } - } - - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=RTC,content=Time)"]}) { - if(memory.nonVolatile) { - if(auto fp = platform->open(pathID(), memory.name(), File::Write)) { - fp->write(rtc.data, rtc.size); - } - } - } - - mapper->save(document); -} - -auto Cartridge::unload() -> void { - delete[] rom.data; - delete[] ram.data; - delete[] rtc.data; - rom = {}; - ram = {}; - rtc = {}; -} - -auto Cartridge::readIO(uint16 addr) -> uint8 { - if(addr == 0xff50) return 0xff; - - if(bootromEnable) { - const uint8* data = nullptr; - if(Model::GameBoy()) data = system.bootROM.dmg; - if(Model::GameBoyColor()) data = system.bootROM.cgb; - if(Model::SuperGameBoy()) data = system.bootROM.sgb; - if(addr >= 0x0000 && addr <= 0x00ff) return data[addr]; - if(addr >= 0x0200 && addr <= 0x08ff && Model::GameBoyColor()) return data[addr - 0x100]; - } - - return mapper->read(addr); -} - -auto Cartridge::writeIO(uint16 addr, uint8 data) -> void { - if(bootromEnable && addr == 0xff50) { - bootromEnable = false; - return; - } - - mapper->write(addr, data); -} - -auto Cartridge::power() -> void { - create(Enter, 4 * 1024 * 1024); - - for(uint n = 0x0000; n <= 0x7fff; n++) bus.mmio[n] = this; - for(uint n = 0xa000; n <= 0xbfff; n++) bus.mmio[n] = this; - bus.mmio[0xff50] = this; - - bootromEnable = true; - - mapper->power(); -} - -auto Cartridge::second() -> void { - mapper->second(); -} - -auto Cartridge::Memory::read(uint address) const -> uint8 { - if(!size) return 0xff; - if(address >= size) address %= size; - return data[address]; -} - -auto Cartridge::Memory::write(uint address, uint8 byte) -> void { - if(!size) return; - if(address >= size) address %= size; - data[address] = byte; -} - -// - -auto Cartridge::Mapper::main() -> void { - cartridge.step(cartridge.frequency()); -} - -} diff --git a/bsnes/gb/cartridge/cartridge.hpp b/bsnes/gb/cartridge/cartridge.hpp deleted file mode 100644 index 87637638..00000000 --- a/bsnes/gb/cartridge/cartridge.hpp +++ /dev/null @@ -1,68 +0,0 @@ -struct Cartridge : Thread, MMIO { - auto pathID() const -> uint { return information.pathID; } - auto hash() const -> string { return information.sha256; } - auto manifest() const -> string { return information.manifest; } - auto title() const -> string { return information.title; } - - static auto Enter() -> void; - auto load() -> bool; - auto save() -> void; - auto unload() -> void; - - auto readIO(uint16 address) -> uint8; - auto writeIO(uint16 address, uint8 data) -> void; - - auto main() -> void; - auto step(uint clocks) -> void; - auto power() -> void; - auto second() -> void; - - auto serialize(serializer&) -> void; - - struct Information { - uint pathID = 0; - string sha256; - string manifest; - string title; - } information; - - struct Memory { - auto read(uint address) const -> uint8; - auto write(uint address, uint8 data) -> void; - - uint8* data = nullptr; - uint size = 0; - } rom, ram, rtc; - - bool bootromEnable = true; - -private: - struct Mapper { - virtual auto load(Markup::Node document) -> void {} - virtual auto save(Markup::Node document) -> void {} - virtual auto main() -> void; - virtual auto second() -> void {} - virtual auto read(uint16 address) -> uint8 = 0; - virtual auto write(uint16 address, uint8 data) -> void = 0; - virtual auto power() -> void = 0; - virtual auto serialize(serializer&) -> void = 0; - }; - Mapper* mapper = nullptr; - bool accelerometer = false; - bool rumble = false; - - #include "mbc0/mbc0.hpp" - #include "mbc1/mbc1.hpp" - #include "mbc1m/mbc1m.hpp" - #include "mbc2/mbc2.hpp" - #include "mbc3/mbc3.hpp" - #include "mbc5/mbc5.hpp" - #include "mbc6/mbc6.hpp" - #include "mbc7/mbc7.hpp" - #include "mmm01/mmm01.hpp" - #include "huc1/huc1.hpp" - #include "huc3/huc3.hpp" - #include "tama/tama.hpp" -}; - -extern Cartridge cartridge; diff --git a/bsnes/gb/cartridge/huc1/huc1.cpp b/bsnes/gb/cartridge/huc1/huc1.cpp deleted file mode 100644 index 598530ce..00000000 --- a/bsnes/gb/cartridge/huc1/huc1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -auto Cartridge::HuC1::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - return cartridge.ram.read(io.ram.bank << 13 | bits(address,0-12)); - } - - return 0xff; -} - -auto Cartridge::HuC1::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.writable = bits(data,0-3) == 0x0a; - return; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.bank = data; - if(!io.rom.bank) io.rom.bank = 0x01; - return; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - io.ram.bank = data; - return; - } - - if((address & 0xe000) == 0x6000) { //$6000-7fff - io.model = data & 1; - return; - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.writable) return; - return cartridge.ram.write(io.ram.bank << 13 | bits(address,0-12), data); - } -} - -auto Cartridge::HuC1::power() -> void { - io = {}; -} - -auto Cartridge::HuC1::serialize(serializer& s) -> void { - s.integer(io.model); - s.integer(io.rom.bank); - s.integer(io.ram.writable); - s.integer(io.ram.bank); -} diff --git a/bsnes/gb/cartridge/huc1/huc1.hpp b/bsnes/gb/cartridge/huc1/huc1.hpp deleted file mode 100644 index 5aa26677..00000000 --- a/bsnes/gb/cartridge/huc1/huc1.hpp +++ /dev/null @@ -1,17 +0,0 @@ -struct HuC1 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - uint1 model; - struct ROM { - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 writable; - uint8 bank; - } ram; - } io; -} huc1; diff --git a/bsnes/gb/cartridge/huc3/huc3.cpp b/bsnes/gb/cartridge/huc3/huc3.cpp deleted file mode 100644 index f681fa4c..00000000 --- a/bsnes/gb/cartridge/huc3/huc3.cpp +++ /dev/null @@ -1,48 +0,0 @@ -auto Cartridge::HuC3::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return 0x01; //does not return open collection - return cartridge.ram.read(io.ram.bank << 13 | bits(address,0-12)); - } - - return 0xff; -} - -auto Cartridge::HuC3::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.enable = bits(data,0-3) == 0x0a; - return; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.bank = data; - return; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - io.ram.bank = data; - return; - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return; - return cartridge.ram.write(io.ram.bank << 13 | bits(address,0-12), data); - } -} - -auto Cartridge::HuC3::power() -> void { - io = {}; -} - -auto Cartridge::HuC3::serialize(serializer& s) -> void { - s.integer(io.rom.bank); - s.integer(io.ram.enable); - s.integer(io.ram.bank); -} diff --git a/bsnes/gb/cartridge/huc3/huc3.hpp b/bsnes/gb/cartridge/huc3/huc3.hpp deleted file mode 100644 index dc665f3a..00000000 --- a/bsnes/gb/cartridge/huc3/huc3.hpp +++ /dev/null @@ -1,16 +0,0 @@ -struct HuC3 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - struct ROM { - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 enable; - uint8 bank; - } ram; - } io; -} huc3; diff --git a/bsnes/gb/cartridge/mbc0/mbc0.cpp b/bsnes/gb/cartridge/mbc0/mbc0.cpp deleted file mode 100644 index 56dd77a3..00000000 --- a/bsnes/gb/cartridge/mbc0/mbc0.cpp +++ /dev/null @@ -1,24 +0,0 @@ -auto Cartridge::MBC0::read(uint16 address) -> uint8 { - if((address & 0x8000) == 0x0000) { //$0000-7fff - return cartridge.rom.read(bits(address,0-14)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - return cartridge.ram.read(bits(address,0-12)); - } - - return 0xff; -} - -auto Cartridge::MBC0::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0xa000) { //$a000-bfff - cartridge.ram.write(bits(address,0-12), data); - return; - } -} - -auto Cartridge::MBC0::power() -> void { -} - -auto Cartridge::MBC0::serialize(serializer& s) -> void { -} diff --git a/bsnes/gb/cartridge/mbc0/mbc0.hpp b/bsnes/gb/cartridge/mbc0/mbc0.hpp deleted file mode 100644 index cbcccc6f..00000000 --- a/bsnes/gb/cartridge/mbc0/mbc0.hpp +++ /dev/null @@ -1,6 +0,0 @@ -struct MBC0 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; -} mbc0; diff --git a/bsnes/gb/cartridge/mbc1/mbc1.cpp b/bsnes/gb/cartridge/mbc1/mbc1.cpp deleted file mode 100644 index 7df901a5..00000000 --- a/bsnes/gb/cartridge/mbc1/mbc1.cpp +++ /dev/null @@ -1,67 +0,0 @@ -auto Cartridge::MBC1::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - if(io.mode == 0) { - return cartridge.rom.read(io.ram.bank << 19 | io.rom.bank << 14 | bits(address,0-13)); - } else { - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return 0xff; - if(io.mode == 0) { - return cartridge.ram.read(bits(address,0-12)); - } else { - return cartridge.ram.read(io.ram.bank << 13 | bits(address,0-12)); - } - } - - return 0xff; -} - -auto Cartridge::MBC1::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.enable = bits(data,0-3) == 0x0a; - return; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.bank = bits(data,0-4); - if(!io.rom.bank) io.rom.bank = 0x01; - return; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - io.ram.bank = bits(data,0-1); - return; - } - - if((address & 0xe000) == 0x6000) { //$6000-7fff - io.mode = bit1(data,0); - return; - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return; - if(io.mode == 0) { - return cartridge.ram.write(bits(address,0-12), data); - } else { - return cartridge.ram.write(io.ram.bank << 13 | bits(address,0-12), data); - } - } -} - -auto Cartridge::MBC1::power() -> void { - io = {}; -} - -auto Cartridge::MBC1::serialize(serializer& s) -> void { - s.integer(io.mode); - s.integer(io.rom.bank); - s.integer(io.ram.enable); - s.integer(io.ram.bank); -} diff --git a/bsnes/gb/cartridge/mbc1/mbc1.hpp b/bsnes/gb/cartridge/mbc1/mbc1.hpp deleted file mode 100644 index 85cd0ef5..00000000 --- a/bsnes/gb/cartridge/mbc1/mbc1.hpp +++ /dev/null @@ -1,17 +0,0 @@ -struct MBC1 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer& s) -> void; - - struct IO { - uint1 mode; - struct ROM { - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 enable; - uint8 bank; - } ram; - } io; -} mbc1; diff --git a/bsnes/gb/cartridge/mbc1m/mbc1m.cpp b/bsnes/gb/cartridge/mbc1m/mbc1m.cpp deleted file mode 100644 index 1ed3bc36..00000000 --- a/bsnes/gb/cartridge/mbc1m/mbc1m.cpp +++ /dev/null @@ -1,43 +0,0 @@ -auto Cartridge::MBC1M::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - if(io.mode == 0) return cartridge.rom.read(bits(address,0-13)); - return cartridge.rom.read(bits(io.rom.bank,4-5) << 18 | bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - return cartridge.ram.read(bits(address,0-12)); - } - - return 0xff; -} - -auto Cartridge::MBC1M::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x2000) { //$2000-3fff - bits(io.rom.bank,0-3) = bits(data,0-3); - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - bits(io.rom.bank,4-5) = bits(data,0-1); - } - - if((address & 0xe000) == 0x6000) { //$6000-7fff - io.mode = bit1(data,0); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - cartridge.ram.write(bits(address,0-13), data); - } -} - -auto Cartridge::MBC1M::power() -> void { - io = {}; -} - -auto Cartridge::MBC1M::serialize(serializer& s) -> void { - s.integer(io.mode); - s.integer(io.rom.bank); -} diff --git a/bsnes/gb/cartridge/mbc1m/mbc1m.hpp b/bsnes/gb/cartridge/mbc1m/mbc1m.hpp deleted file mode 100644 index 5510a6d3..00000000 --- a/bsnes/gb/cartridge/mbc1m/mbc1m.hpp +++ /dev/null @@ -1,13 +0,0 @@ -struct MBC1M : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - uint1 mode; - struct ROM { - uint6 bank = 0x01; - } rom; - } io; -} mbc1m; diff --git a/bsnes/gb/cartridge/mbc2/mbc2.cpp b/bsnes/gb/cartridge/mbc2/mbc2.cpp deleted file mode 100644 index 862c7793..00000000 --- a/bsnes/gb/cartridge/mbc2/mbc2.cpp +++ /dev/null @@ -1,61 +0,0 @@ -auto Cartridge::MBC2::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xee01) == 0xa000) { //$a000-a1ff (even) - if(!io.ram.enable) return 0xff; - auto ram = cartridge.ram.read(bits(address,1-8)); - return 0xf0 | bits(ram,0-3); - } - - if((address & 0xee01) == 0xa001) { //$a000-a1ff (odd) - if(!io.ram.enable) return 0xff; - auto ram = cartridge.ram.read(bits(address,1-8)); - return 0xf0 | bits(ram,4-7); - } - - return 0xff; -} - -auto Cartridge::MBC2::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - if(!bit1(address,8)) io.ram.enable = bits(data,0-3) == 0x0a; - return; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - if(bit1(address,8)) io.rom.bank = bits(data,0-3); - if(!io.rom.bank) io.rom.bank = 0x01; - return; - } - - if((address & 0xee01) == 0xa000) { //$a000-a1ff (even) - if(!io.ram.enable) return; - auto ram = cartridge.ram.read(bits(address,1-8)); - bits(ram,0-3) = (uint)bits(data,0-3); - cartridge.ram.write(bits(address,1-8), ram); - return; - } - - if((address & 0xee01) == 0xa001) { //$a000-a1ff (odd) - if(!io.ram.enable) return; - auto ram = cartridge.ram.read(bits(address,1-8)); - bits(ram,4-7) = (uint)bits(data,0-3); - cartridge.ram.write(bits(address,1-8), ram); - return; - } -} - -auto Cartridge::MBC2::power() -> void { - io = {}; -} - -auto Cartridge::MBC2::serialize(serializer& s) -> void { - s.integer(io.rom.bank); - s.integer(io.ram.enable); -} diff --git a/bsnes/gb/cartridge/mbc2/mbc2.hpp b/bsnes/gb/cartridge/mbc2/mbc2.hpp deleted file mode 100644 index cdc62298..00000000 --- a/bsnes/gb/cartridge/mbc2/mbc2.hpp +++ /dev/null @@ -1,15 +0,0 @@ -struct MBC2 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - struct ROM { - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 enable = 0; - } ram; - } io; -} mbc2; diff --git a/bsnes/gb/cartridge/mbc3/mbc3.cpp b/bsnes/gb/cartridge/mbc3/mbc3.cpp deleted file mode 100644 index 1089f55f..00000000 --- a/bsnes/gb/cartridge/mbc3/mbc3.cpp +++ /dev/null @@ -1,113 +0,0 @@ -auto Cartridge::MBC3::second() -> void { - if(io.rtc.halt) return; - if(++io.rtc.second >= 60) { - io.rtc.second = 0; - if(++io.rtc.minute >= 60) { - io.rtc.minute = 0; - if(++io.rtc.hour >= 24) { - io.rtc.hour = 0; - if(++io.rtc.day == 0) { - io.rtc.dayCarry = true; - } - } - } - } -} - -auto Cartridge::MBC3::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return 0xff; - if(io.ram.bank <= 0x03) return cartridge.ram.read(io.ram.bank << 13 | bits(address,0-12)); - if(io.ram.bank == 0x08) return io.rtc.latchSecond; - if(io.ram.bank == 0x09) return io.rtc.latchMinute; - if(io.ram.bank == 0x0a) return io.rtc.latchHour; - if(io.ram.bank == 0x0b) return io.rtc.latchDay; - if(io.ram.bank == 0x0c) return io.rtc.latchDayCarry << 7 | io.rtc.latchDay >> 8; - return 0xff; - } - - return 0xff; -} - -auto Cartridge::MBC3::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.enable = bits(data,0-3) == 0x0a; - return; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.bank = bits(data,0-6); - if(!io.rom.bank) io.rom.bank = 0x01; - return; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - io.ram.bank = data; - return; - } - - if((address & 0xe000) == 0x6000) { //$6000-7fff - if(io.rtc.latch == 0 && data == 1) { - io.rtc.latchSecond = io.rtc.second; - io.rtc.latchMinute = io.rtc.minute; - io.rtc.latchHour = io.rtc.hour; - io.rtc.latchDay = io.rtc.day; - io.rtc.latchDayCarry = io.rtc.dayCarry; - } - io.rtc.latch = data; - return; - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return; - if(io.ram.bank <= 0x03) { - cartridge.ram.write(io.ram.bank << 13 | bits(address,0-12), data); - } else if(io.ram.bank == 0x08) { - if(data >= 60) data = 0; - io.rtc.second = data; - } else if(io.ram.bank == 0x09) { - if(data >= 60) data = 0; - io.rtc.minute = data; - } else if(io.ram.bank == 0x0a) { - if(data >= 24) data = 0; - io.rtc.hour = data; - } else if(io.ram.bank == 0x0b) { - bits(io.rtc.day,0-7) = bits(data,0-7); - } else if(io.ram.bank == 0x0c) { - bit1(io.rtc.day,8) = bit1(data,0); - io.rtc.halt = bit1(data,6); - io.rtc.dayCarry = bit1(data,7); - } - return; - } -} - -auto Cartridge::MBC3::power() -> void { - io = {}; -} - -auto Cartridge::MBC3::serialize(serializer& s) -> void { - s.integer(io.rom.bank); - s.integer(io.ram.enable); - s.integer(io.ram.bank); - s.integer(io.rtc.halt); - s.integer(io.rtc.latch); - s.integer(io.rtc.second); - s.integer(io.rtc.minute); - s.integer(io.rtc.hour); - s.integer(io.rtc.day); - s.integer(io.rtc.dayCarry); - s.integer(io.rtc.latchSecond); - s.integer(io.rtc.latchMinute); - s.integer(io.rtc.latchHour); - s.integer(io.rtc.latchDay); - s.integer(io.rtc.latchDayCarry); -} diff --git a/bsnes/gb/cartridge/mbc3/mbc3.hpp b/bsnes/gb/cartridge/mbc3/mbc3.hpp deleted file mode 100644 index 5f9e63da..00000000 --- a/bsnes/gb/cartridge/mbc3/mbc3.hpp +++ /dev/null @@ -1,33 +0,0 @@ -struct MBC3 : Mapper { - auto second() -> void; - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer& s) -> void; - - struct IO { - struct ROM { - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 enable; - uint8 bank; - } ram; - struct RTC { - uint1 halt = true; - uint1 latch; - - uint8 second; - uint8 minute; - uint8 hour; - uint9 day; - uint1 dayCarry; - - uint8 latchSecond; - uint8 latchMinute; - uint8 latchHour; - uint9 latchDay; - uint1 latchDayCarry; - } rtc; - } io; -} mbc3; diff --git a/bsnes/gb/cartridge/mbc5/mbc5.cpp b/bsnes/gb/cartridge/mbc5/mbc5.cpp deleted file mode 100644 index 439a67b2..00000000 --- a/bsnes/gb/cartridge/mbc5/mbc5.cpp +++ /dev/null @@ -1,54 +0,0 @@ -auto Cartridge::MBC5::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return 0xff; - return cartridge.ram.read(io.ram.bank << 13 | bits(address,0-12)); - } - - return 0xff; -} - -auto Cartridge::MBC5::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.enable = bits(data,0-3) == 0x0a; - return; - } - - if((address & 0xf000) == 0x2000) { //$2000-2fff - bits(io.rom.bank,0-7) = bits(data,0-7); - return; - } - - if((address & 0xf000) == 0x3000) { //$3000-3fff - bit1(io.rom.bank,8) = bit1(data,0); - return; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - if(cartridge.rumble) platform->inputRumble(ID::Port::Cartridge, ID::Device::MBC5, 0, bit1(data,3)); - io.ram.bank = bits(data,0-3); - return; - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return; - return cartridge.ram.write(io.ram.bank << 13 | bits(address,0-12), data); - } -} - -auto Cartridge::MBC5::power() -> void { - io = {}; -} - -auto Cartridge::MBC5::serialize(serializer& s) -> void { - s.integer(io.rom.bank); - s.integer(io.ram.enable); - s.integer(io.ram.bank); -} diff --git a/bsnes/gb/cartridge/mbc5/mbc5.hpp b/bsnes/gb/cartridge/mbc5/mbc5.hpp deleted file mode 100644 index 0d7b26c6..00000000 --- a/bsnes/gb/cartridge/mbc5/mbc5.hpp +++ /dev/null @@ -1,16 +0,0 @@ -struct MBC5 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - struct ROM { - uint9 bank = 0x01; - } rom; - struct RAM { - uint1 enable; - uint4 bank; - } ram; - } io; -} mbc5; diff --git a/bsnes/gb/cartridge/mbc6/mbc6.cpp b/bsnes/gb/cartridge/mbc6/mbc6.cpp deleted file mode 100644 index 7c3228cb..00000000 --- a/bsnes/gb/cartridge/mbc6/mbc6.cpp +++ /dev/null @@ -1,74 +0,0 @@ -auto Cartridge::MBC6::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - return cartridge.rom.read(io.rom.bank[0] << 13 | bits(address,0-12)); - } - - if((address & 0xe000) == 0x6000) { //$6000-7fff - return cartridge.rom.read(io.rom.bank[1] << 13 | bits(address,0-12)); - } - - if((address & 0xf000) == 0xa000) { //$a000-afff - if(!io.ram.enable) return 0xff; - return cartridge.ram.read(io.ram.bank[0] << 12 | bits(address,0-11)); - } - - if((address & 0xf000) == 0xb000) { //$b000-bfff - if(!io.ram.enable) return 0xff; - return cartridge.ram.read(io.ram.bank[1] << 12 | bits(address,0-11)); - } - - return 0xff; -} - -auto Cartridge::MBC6::write(uint16 address, uint8 data) -> void { - if((address & 0xfc00) == 0x0000) { - io.ram.enable = bits(data,0-3) == 0xa; - return; - } - - if((address & 0xfc00) == 0x0400) { - io.ram.bank[0] = data; - return; - } - - if((address & 0xfc00) == 0x0800) { - io.ram.bank[1] = data; - return; - } - - if((address & 0xf800) == 0x2000) { - io.rom.bank[0] = data; - return; - } - - if((address & 0xf800) == 0x3000) { - io.rom.bank[1] = data; - return; - } - - if((address & 0xf000) == 0xa000) { //$a000-afff - if(!io.ram.enable) return; - return cartridge.ram.write(io.ram.bank[0] << 12 | bits(address,0-11), data); - } - - if((address & 0xf000) == 0xb000) { //$b000-bfff - if(!io.ram.enable) return; - return cartridge.ram.write(io.ram.bank[1] << 12 | bits(address,0-11), data); - } -} - -auto Cartridge::MBC6::power() -> void { - io = {}; -} - -auto Cartridge::MBC6::serialize(serializer& s) -> void { - s.integer(io.rom.bank[0]); - s.integer(io.rom.bank[1]); - s.integer(io.ram.enable); - s.integer(io.ram.bank[0]); - s.integer(io.ram.bank[1]); -} diff --git a/bsnes/gb/cartridge/mbc6/mbc6.hpp b/bsnes/gb/cartridge/mbc6/mbc6.hpp deleted file mode 100644 index 927b872a..00000000 --- a/bsnes/gb/cartridge/mbc6/mbc6.hpp +++ /dev/null @@ -1,16 +0,0 @@ -struct MBC6 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - struct ROM { - uint8 bank[2]; - } rom; - struct RAM { - uint1 enable; - uint8 bank[2]; - } ram; - } io; -} mbc6; diff --git a/bsnes/gb/cartridge/mbc7/eeprom.cpp b/bsnes/gb/cartridge/mbc7/eeprom.cpp deleted file mode 100644 index ede1d84a..00000000 --- a/bsnes/gb/cartridge/mbc7/eeprom.cpp +++ /dev/null @@ -1,241 +0,0 @@ -//Microchip 93LCx6 -// 93LC46 => 1024 cells => 128 x 8-bit or 64 x 16-bit -// 93LC56 => 2048 cells => 256 x 8-bit or 128 x 16-bit -// 93LC66 => 4096 cells => 512 x 8-bit or 256 x 16-bit - -auto Cartridge::MBC7::EEPROM::load(Markup::Node document) -> void { - for(auto& byte : data) byte = 0xff; - size = 512; //EEPROM size is in bytes - width = 16; //16-bit configuration - - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=EEPROM,content=Save)"]}) { - if(memory.size == 128) size = 128; - if(memory.size == 256) size = 256; - if(memory.size == 512) size = 512; - - if(auto fp = platform->open(cartridge.pathID(), memory.name(), File::Read, File::Optional)) { - fp->read(data, min(fp->size(), sizeof(data))); - } - } - - //note: the 93LC56 alone has an extra dummy address bit - if(size == 128) input.addressLength = width == 16 ? 6 : 7; //93LC46 - if(size == 256) input.addressLength = width == 16 ? 8 : 9; //93LC56 - if(size == 512) input.addressLength = width == 16 ? 8 : 9; //93LC66 - input.dataLength = width; -} - -auto Cartridge::MBC7::EEPROM::save(Markup::Node document) -> void { - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=EEPROM,content=Save)"]}) { - if(auto fp = platform->open(cartridge.pathID(), memory.name(), File::Write)) { - fp->write(data, size); - } - } -} - -auto Cartridge::MBC7::EEPROM::main() -> void { - //step by approximately one millisecond - cartridge.step(cartridge.frequency() / 1000); - - //set during programming commands - if(busy) busy--; -} - -auto Cartridge::MBC7::EEPROM::power() -> void { - select = 0; - clock = 0; - writable = 0; - busy = 0; - - input.flush(); - output.flush(); -} - -auto Cartridge::MBC7::EEPROM::readIO() -> uint8 { - uint8 data = 0b00'1111'00; - bit1(data,7) = select; - bit1(data,6) = clock; - bit1(data,1) = input.edge(); - if(!select) { - bit1(data,0) = 1; //high-z when the chip is idle (not selected) - } else if(busy) { - bit1(data,0) = 0; //low when a programming command is in progress - } else if(output.count) { - bit1(data,0) = output.edge(); //shift register data during read commands - } else { - bit1(data,0) = 1; //high-z during all other commands - } - return data; -} - -auto Cartridge::MBC7::EEPROM::writeIO(uint8 data) -> void { - //chip enters idle state on falling CS edge - if(select && !bit1(data,7)) return power(); - - //chip leaves idle state on rising CS edge - if(!(select = bit1(data,7))) return; - - //input shift register clocks on rising edge - if(!clock.raise(bit1(data,6))) return; - - //read mode - if(output.count && !bit1(data,1)) { - if(input.start() && *input.start() == 1) { - if(input.opcode() && *input.opcode() == 0b10) { - output.read(); - if(output.count == 0) { - //sequential read mode - input.increment(); - read(); - } - } - } - return; - } - output.flush(); - - input.write(bit1(data,1)); - - //wait for start - if(!input.start()) return; - uint start = *input.start(); - - //start bit must be set - if(start != 1) return input.flush(); - - //wait for opcode - if(!input.opcode()) return; - uint opcode = *input.opcode(); - - //wait for address - if(!input.address()) return; - - if(opcode == 0b00) { - auto mode = *input.mode(); - if(mode == 0b00) return writeDisable(); - if(mode == 0b01) return writeAll(); - if(mode == 0b10) return eraseAll(); - if(mode == 0b11) return writeEnable(); - } - if(opcode == 0b01) return write(); - if(opcode == 0b10) return read(); - if(opcode == 0b11) return erase(); -} - -// - -auto Cartridge::MBC7::EEPROM::read() -> void { - uint address = *input.address() << (width == 16) & size - 1; - output.flush(); - for(uint4 index : range(width)) { - output.write(bit1(data[address + !bit1(index,3)],bits(index,0-2))); - } - output.write(0); //reads have an extra dummy data bit -} - -auto Cartridge::MBC7::EEPROM::write() -> void { - if(!input.data()) return; //wait for data - if(!writable) return input.flush(); - uint address = *input.address() << (width == 16) & size - 1; - for(uint4 index : range(width)) { - bit1(data[address + !bit1(index,3)],bits(index,0-2)) = input.read(); - } - busy = 4; //milliseconds - return input.flush(); -} - -auto Cartridge::MBC7::EEPROM::erase() -> void { - if(!writable) return input.flush(); - uint address = *input.address() << (width == 16) & size - 1; - for(uint index : range(width)) { - bit1(data[address + index / 8],index % 8) = 1; - } - busy = 4; //milliseconds - return input.flush(); -} - -auto Cartridge::MBC7::EEPROM::writeAll() -> void { - if(!input.data()) return; //wait for data - if(!writable) return input.flush(); - auto word = *input.data(); - for(uint address = 0; address < 512;) { - data[address++] = bit8(word,width == 16); - data[address++] = bit8(word,0); - } - busy = 16; //milliseconds - return input.flush(); -} - -auto Cartridge::MBC7::EEPROM::eraseAll() -> void { - if(!writable) return input.flush(); - for(auto& byte : data) byte = 0xff; - busy = 8; //milliseconds - return input.flush(); -} - -auto Cartridge::MBC7::EEPROM::writeEnable() -> void { - writable = true; - return input.flush(); -} - -auto Cartridge::MBC7::EEPROM::writeDisable() -> void { - writable = false; - return input.flush(); -} - -// - -auto Cartridge::MBC7::EEPROM::ShiftRegister::flush() -> void { - value = 0; - count = 0; -} - -auto Cartridge::MBC7::EEPROM::ShiftRegister::edge() -> uint1 { - return value & 1; -} - -auto Cartridge::MBC7::EEPROM::ShiftRegister::read() -> uint1 { - uint1 bit = value & 1; - value >>= 1; - count--; - return bit; -} - -auto Cartridge::MBC7::EEPROM::ShiftRegister::write(uint1 bit) -> void { - value <<= 1; - bit1(value,0) = bit; - count++; -} - -// - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::start() -> maybe { - if(count < 1) return {}; - return {value >> count - 1 & 1}; -} - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::opcode() -> maybe { - if(count < 1 + 2) return {}; - return {value >> count - 3 & 3}; -} - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::mode() -> maybe { - if(count < 1 + 2 + addressLength) return {}; - return {value >> count - 5 & 3}; -} - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::address() -> maybe { - if(count < 1 + 2 + addressLength) return {}; - return {value >> count - (3 + addressLength) & (1 << addressLength) - 1}; -} - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::data() -> maybe { - if(count < 1 + 2 + addressLength + dataLength) return {}; - uint16 data = value >> count - (3 + addressLength + dataLength) & (1 << dataLength) - 1; - return data; -} - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::increment() -> void { - uint mask = (1 << addressLength) - 1; - value = value & ~mask | (value + 1 & mask); -} diff --git a/bsnes/gb/cartridge/mbc7/mbc7.cpp b/bsnes/gb/cartridge/mbc7/mbc7.cpp deleted file mode 100644 index 53a7ff65..00000000 --- a/bsnes/gb/cartridge/mbc7/mbc7.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "eeprom.cpp" -#include "serialization.cpp" - -auto Cartridge::MBC7::load(Markup::Node document) -> void { - eeprom.load(document); -} - -auto Cartridge::MBC7::save(Markup::Node document) -> void { - eeprom.save(document); -} - -auto Cartridge::MBC7::main() -> void { - eeprom.main(); -} - -auto Cartridge::MBC7::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xf000) == 0xa000) { //$a000-afff - if(!io.ram.enable[0] || !io.ram.enable[1]) return 0xff; - - switch(bits(address,4-7)) { - case 2: return bit8(io.accelerometer.x,0); - case 3: return bit8(io.accelerometer.x,1); - case 4: return bit8(io.accelerometer.y,0); - case 5: return bit8(io.accelerometer.y,1); - case 6: return 0x00; //z? - case 7: return 0xff; //z? - case 8: return eeprom.readIO(); - } - - return 0xff; - } - - return 0xff; -} - -auto Cartridge::MBC7::write(uint16 address, uint8 data) -> void { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.enable[0] = bits(data,0-3) == 0xa; - if(!io.ram.enable[0]) io.ram.enable[1] = false; - return; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.bank = data; - if(!io.rom.bank) io.rom.bank = 1; - return; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - if(!io.ram.enable[0]) return; - io.ram.enable[1] = data == 0x40; - } - - if((address & 0xf000) == 0xa000) { //$a000-afff - if(!io.ram.enable[0] || !io.ram.enable[1]) return; - - switch(bits(address,4-7)) { - case 0: { - if(data != 0x55) break; - io.accelerometer.x = Center; - io.accelerometer.y = Center; - break; - } - - case 1: { - if(data != 0xaa) break; - io.accelerometer.x = Center - platform->inputPoll(ID::Port::Cartridge, ID::Device::MBC7, 0); - io.accelerometer.y = Center + platform->inputPoll(ID::Port::Cartridge, ID::Device::MBC7, 1); - break; - } - - case 8: { - eeprom.writeIO(data); - break; - } - } - - return; - } -} - -auto Cartridge::MBC7::power() -> void { - eeprom.power(); - io = {}; -} diff --git a/bsnes/gb/cartridge/mbc7/mbc7.hpp b/bsnes/gb/cartridge/mbc7/mbc7.hpp deleted file mode 100644 index 9bb731c5..00000000 --- a/bsnes/gb/cartridge/mbc7/mbc7.hpp +++ /dev/null @@ -1,91 +0,0 @@ -struct MBC7 : Mapper { - enum : uint { Center = 0x81d0 }; //not 0x8000 - - //mbc7.cpp - auto load(Markup::Node document) -> void override; - auto save(Markup::Node document) -> void override; - auto main() -> void override; - auto read(uint16 address) -> uint8 override; - auto write(uint16 address, uint8 data) -> void override; - auto power() -> void override; - - //serialization.cpp - auto serialize(serializer&) -> void override; - - struct EEPROM { - //eeprom.cpp - auto load(Markup::Node document) -> void; - auto save(Markup::Node document) -> void; - auto main() -> void; - auto power() -> void; - - //Game Boy MBC7 interface - auto readIO() -> uint8; - auto writeIO(uint8 data) -> void; - - //chip commands - auto read() -> void; - auto write() -> void; - auto erase() -> void; - auto writeAll() -> void; - auto eraseAll() -> void; - auto writeEnable() -> void; - auto writeDisable() -> void; - - //serialization.cpp - auto serialize(serializer&) -> void; - - //it is awkward no matter if data is uint1[4096], uint8[512], or uint16[256] - uint8 data[512]; //uint8 was chosen solely for easier serialization and saving - uint size; //in bytes - uint width; //8-bit (ORG=0) or 16-bit (ORG=1) configuration - - boolean select; //CS - boolean clock; //CLK - boolean writable; //EWEN, EWDS - uint busy; //busy cycles in milliseconds remaining for programming (write) operations to complete - - struct ShiftRegister { - auto flush() -> void; - auto edge() -> uint1; - auto read() -> uint1; - auto write(uint1 data) -> void; - - uint32 value; - uint32 count; - }; - - struct InputShiftRegister : ShiftRegister { - auto start() -> maybe; - auto opcode() -> maybe; - auto mode() -> maybe; - auto address() -> maybe; - auto data() -> maybe; - auto increment() -> void; - - //serialization.cpp - auto serialize(serializer&) -> void; - - uint32 addressLength; - uint32 dataLength; - } input; - - struct OutputShiftRegister : ShiftRegister { - //serialization.cpp - auto serialize(serializer&) -> void; - } output; - } eeprom; - - struct IO { - struct ROM { - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 enable[2]; - } ram; - struct Accelerometer { - uint16 x = Center; - uint16 y = Center; - } accelerometer; - } io; -} mbc7; diff --git a/bsnes/gb/cartridge/mbc7/serialization.cpp b/bsnes/gb/cartridge/mbc7/serialization.cpp deleted file mode 100644 index 996acee1..00000000 --- a/bsnes/gb/cartridge/mbc7/serialization.cpp +++ /dev/null @@ -1,32 +0,0 @@ -auto Cartridge::MBC7::serialize(serializer& s) -> void { - eeprom.serialize(s); - s.integer(io.rom.bank); - s.integer(io.ram.enable[0]); - s.integer(io.ram.enable[1]); - s.integer(io.accelerometer.x); - s.integer(io.accelerometer.y); -} - -auto Cartridge::MBC7::EEPROM::serialize(serializer& s) -> void { - s.array(data); - s.integer(size); - s.integer(width); - s.boolean(select); - s.boolean(clock); - s.boolean(writable); - s.integer(busy); - input.serialize(s); - output.serialize(s); -} - -auto Cartridge::MBC7::EEPROM::InputShiftRegister::serialize(serializer& s) -> void { - s.integer(value); - s.integer(count); - s.integer(addressLength); - s.integer(dataLength); -} - -auto Cartridge::MBC7::EEPROM::OutputShiftRegister::serialize(serializer& s) -> void { - s.integer(value); - s.integer(count); -} diff --git a/bsnes/gb/cartridge/mmm01/mmm01.cpp b/bsnes/gb/cartridge/mmm01/mmm01.cpp deleted file mode 100644 index 22ebfb87..00000000 --- a/bsnes/gb/cartridge/mmm01/mmm01.cpp +++ /dev/null @@ -1,65 +0,0 @@ -auto Cartridge::MMM01::read(uint16 address) -> uint8 { - if(io.mode == 0) { - if((address & 0x8000) == 0x0000) { //$0000-7fff - return cartridge.rom.read(cartridge.rom.size - 0x8000 + bits(address,0-14)); - } - - return 0xff; - } else { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read((io.rom.base << 14) + bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read((io.rom.base << 14) + (io.rom.bank << 14) + bits(address,0-13)); - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return 0xff; - return cartridge.ram.read(io.ram.bank << 13 | bits(address,0-12)); - } - - return 0xff; - } -} - -auto Cartridge::MMM01::write(uint16 address, uint8 data) -> void { - if(io.mode == 0) { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.mode = 1; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.base = bits(data,0-5); - } - } else { - if((address & 0xe000) == 0x0000) { //$0000-1fff - io.ram.enable = bits(data,0-3) == 0x0a; - } - - if((address & 0xe000) == 0x2000) { //$2000-3fff - io.rom.bank = data; - } - - if((address & 0xe000) == 0x4000) { //$4000-5fff - io.ram.bank = data; - } - - if((address & 0xe000) == 0xa000) { //$a000-bfff - if(!io.ram.enable) return; - cartridge.ram.write(io.ram.bank << 13 | bits(address,0-12), data); - } - } -} - -auto Cartridge::MMM01::power() -> void { - io = {}; -} - -auto Cartridge::MMM01::serialize(serializer& s) -> void { - s.integer(io.mode); - s.integer(io.rom.base); - s.integer(io.rom.bank); - s.integer(io.ram.enable); - s.integer(io.ram.bank); -} diff --git a/bsnes/gb/cartridge/mmm01/mmm01.hpp b/bsnes/gb/cartridge/mmm01/mmm01.hpp deleted file mode 100644 index 04c650d3..00000000 --- a/bsnes/gb/cartridge/mmm01/mmm01.hpp +++ /dev/null @@ -1,18 +0,0 @@ -struct MMM01 : Mapper { - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer& s) -> void; - - struct IO { - uint1 mode; - struct ROM { - uint6 base; - uint8 bank = 0x01; - } rom; - struct RAM { - uint1 enable; - uint8 bank; - } ram; - } io; -} mmm01; diff --git a/bsnes/gb/cartridge/serialization.cpp b/bsnes/gb/cartridge/serialization.cpp deleted file mode 100644 index d6211178..00000000 --- a/bsnes/gb/cartridge/serialization.cpp +++ /dev/null @@ -1,9 +0,0 @@ -auto Cartridge::serialize(serializer& s) -> void { - Thread::serialize(s); - if(ram.size) s.array(ram.data, ram.size); - if(rtc.size) s.array(rtc.data, rtc.size); - - s.integer(bootromEnable); - - mapper->serialize(s); -} diff --git a/bsnes/gb/cartridge/tama/tama.cpp b/bsnes/gb/cartridge/tama/tama.cpp deleted file mode 100644 index 81d9f61d..00000000 --- a/bsnes/gb/cartridge/tama/tama.cpp +++ /dev/null @@ -1,236 +0,0 @@ -//U1: TAMA7: Mask ROM (512KB) -//U2: TAMA5: Game Boy cartridge connector interface -//U3: TAMA6: Toshiba TMP47C243M (4-bit MCU) -//U4: RTC: Toshiba TC8521AM - -//note: the TMP47C243M's 2048 x 8-bit program ROM is currently undumped -//as such, high level emulation is used as a necessary evil - -auto Cartridge::TAMA::second() -> void { - if(++rtc.second >= 60) { - rtc.second = 0; - - if(++rtc.minute >= 60) { - rtc.minute = 0; - - if(rtc.hourMode == 0 && ++rtc.hour >= 12) { - rtc.hour = 0; - rtc.meridian++; - } - - if(rtc.hourMode == 1 && ++rtc.hour >= 24) { - rtc.hour = 0; - rtc.meridian = rtc.hour >= 12; - } - - if((rtc.hourMode == 0 && rtc.hour == 0 && rtc.meridian == 0) - || (rtc.hourMode == 1 && rtc.hour == 0) - ) { - uint days[12] = {31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31}; - if(rtc.leapYear == 0) days[1] = 29; //extra day in February for leap years - - if(++rtc.day > days[(rtc.month - 1) % 12]) { - rtc.day = 1; - - if(++rtc.month > 12) { - rtc.month = 1; - rtc.leapYear++; - - if(++rtc.year >= 100) { - rtc.year = 0; - } - } - } - } - } - } -} - -auto Cartridge::TAMA::read(uint16 address) -> uint8 { - if((address & 0xc000) == 0x0000) { //$0000-3fff - return cartridge.rom.read(bits(address,0-13)); - } - - if((address & 0xc000) == 0x4000) { //$4000-7fff - return cartridge.rom.read(io.rom.bank << 14 | bits(address,0-13)); - } - - if((address & 0xe001) == 0xa000) { //$a000-bfff (even) - if(io.select == 0x0a) { - return 0xf0 | io.ready; - } - - if(io.mode == 0 || io.mode == 1) { - if(io.select == 0x0c) { - return 0xf0 | bits(io.output,0-3); - } - - if(io.select == 0x0d) { - return 0xf0 | bits(io.output,4-7); - } - } - - if(io.mode == 2 || io.mode == 4) { - if(io.select == 0x0c || io.select == 0x0d) { - uint4 data; - if(rtc.index == 0) data = rtc.minute % 10; - if(rtc.index == 1) data = rtc.minute / 10; - if(rtc.index == 2) data = rtc.hour % 10; - if(rtc.index == 3) data = rtc.hour / 10; - if(rtc.index == 4) data = rtc.day / 10; - if(rtc.index == 5) data = rtc.day % 10; - if(rtc.index == 6) data = rtc.month / 10; - if(rtc.index == 7) data = rtc.month % 10; - rtc.index++; - return 0xf0 | data; - } - } - - return 0xff; - } - - if((address & 0xe001) == 0xa001) { //$a000-bfff (odd) - return 0xff; - } - - return 0xff; -} - -auto Cartridge::TAMA::write(uint16 address, uint8 data) -> void { - auto toBCD = [](uint8 data) -> uint8 { return (data / 10) * 16 + (data % 10); }; - auto fromBCD = [](uint8 data) -> uint8 { return (data / 16) * 10 + (data % 16); }; - - if((address & 0xe001) == 0xa000) { //$a000-bfff (even) - if(io.select == 0x00) { - bits(io.rom.bank,0-3) = (uint)bits(data,0-3); - } - - if(io.select == 0x01) { - bit1(io.rom.bank,4) = (uint)bit1(data,0); - } - - if(io.select == 0x04) { - bits(io.input,0-3) = (uint)bits(data,0-3); - } - - if(io.select == 0x05) { - bits(io.input,4-7) = (uint)bits(data,0-3); - } - - if(io.select == 0x06) { - bit1(io.index,4) = (uint)bit1(data,0); - io.mode = bits(data,1-3); - } - - if(io.select == 0x07) { - bits(io.index,0-3) = (uint)bits(data,0-3); - - if(io.mode == 0) { - cartridge.ram.write(io.index, io.input); - } - - if(io.mode == 1) { - io.output = cartridge.ram.read(io.index); - } - - if(io.mode == 2 && io.index == 0x04) { - rtc.minute = fromBCD(io.input); - } - - if(io.mode == 2 && io.index == 0x05) { - rtc.hour = fromBCD(io.input); - rtc.meridian = rtc.hour >= 12; - } - - if(io.mode == 4 && io.index == 0x00 && bits(io.input,0-3) == 0x7) { - uint8 day = toBCD(rtc.day); - bits(day,0-3) = (uint)bits(io.input,4-7); - rtc.day = fromBCD(day); - } - - if(io.mode == 4 && io.index == 0x00 && bits(io.input,0-3) == 0x8) { - uint8 day = toBCD(rtc.day); - bits(day,4-7) = (uint)bits(io.input,4-7); - rtc.day = fromBCD(day); - } - - if(io.mode == 4 && io.index == 0x00 && bits(io.input,0-3) == 0x9) { - uint8 month = toBCD(rtc.month); - bits(month,0-3) = (uint)bits(io.input,4-7); - rtc.month = fromBCD(month); - } - - if(io.mode == 4 && io.index == 0x00 && bits(io.input,0-3) == 0xa) { - uint8 month = toBCD(rtc.month); - bits(month,4-7) = (uint)bits(io.input,4-7); - rtc.month = fromBCD(month); - } - - if(io.mode == 4 && io.index == 0x00 && bits(io.input,0-3) == 0xb) { - uint8 year = toBCD(rtc.year); - bits(year,0-3) = (uint)bits(io.input,4-7); - rtc.year = fromBCD(year); - } - - if(io.mode == 4 && io.index == 0x00 && bits(io.input,0-3) == 0xc) { - uint8 year = toBCD(rtc.year); - bits(year,4-7) = (uint)bits(io.input,4-7); - rtc.year = fromBCD(year); - } - - if(io.mode == 4 && io.index == 0x02 && bits(io.input,0-3) == 0xa) { - rtc.hourMode = bit1(io.input,4); - rtc.second = 0; //hack: unclear where this is really being set (if it is at all) - } - - if(io.mode == 4 && io.index == 0x02 && bits(io.input,0-3) == 0xb) { - rtc.leapYear = bits(data,4-5); - } - - if(io.mode == 4 && io.index == 0x02 && bits(io.input,0-3) == 0xe) { - rtc.test = bits(io.input,4-7); - } - - if(io.mode == 2 && io.index == 0x06) { - rtc.index = 0; - } - } - - return; - } - - if((address & 0xe001) == 0xa001) { //$a000-bfff (odd) - io.select = bits(data,0-3); - - if(io.select == 0x0a) { - io.ready = true; - } - - return; - } -} - -auto Cartridge::TAMA::power() -> void { - io = {}; -} - -auto Cartridge::TAMA::serialize(serializer& s) -> void { - s.integer(io.ready); - s.integer(io.select); - s.integer(io.mode); - s.integer(io.index); - s.integer(io.input); - s.integer(io.output); - s.integer(io.rom.bank); - - s.integer(rtc.year); - s.integer(rtc.month); - s.integer(rtc.day); - s.integer(rtc.hour); - s.integer(rtc.minute); - s.integer(rtc.second); - s.integer(rtc.meridian); - s.integer(rtc.leapYear); - s.integer(rtc.hourMode); - s.integer(rtc.test); -} diff --git a/bsnes/gb/cartridge/tama/tama.hpp b/bsnes/gb/cartridge/tama/tama.hpp deleted file mode 100644 index 09244445..00000000 --- a/bsnes/gb/cartridge/tama/tama.hpp +++ /dev/null @@ -1,33 +0,0 @@ -struct TAMA : Mapper { - auto second() -> void; - auto read(uint16 address) -> uint8; - auto write(uint16 address, uint8 data) -> void; - auto power() -> void; - auto serialize(serializer&) -> void; - - struct IO { - uint1 ready; - uint4 select; - uint3 mode; - uint5 index; - uint8 input; - uint8 output; - struct ROM { - uint5 bank; - } rom; - } io; - - struct RTC { - uint8 year; //0 - 99 - uint8 month; //1 - 12 - uint8 day; //1 - 31 - uint8 hour; //0 - 23 - uint8 minute; //0 - 59 - uint8 second; //0 - 59 - uint1 meridian; //0 = AM; 1 = PM - uint2 leapYear; //0 = leap year; 1-3 = non-leap year - uint1 hourMode; //0 = 12-hour; 1 = 24-hour - uint4 test; - uint8 index; - } rtc; -} tama; diff --git a/bsnes/gb/cpu/cpu.cpp b/bsnes/gb/cpu/cpu.cpp deleted file mode 100644 index bc1d96e3..00000000 --- a/bsnes/gb/cpu/cpu.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include - -namespace GameBoy { - -#include "io.cpp" -#include "memory.cpp" -#include "timing.cpp" -#include "serialization.cpp" -CPU cpu; - -auto CPU::Enter() -> void { - while(true) scheduler.synchronize(), cpu.main(); -} - -auto CPU::main() -> void { - interruptTest(); - instruction(); -} - -auto CPU::raise(CPU::Interrupt id) -> void { - if(id == Interrupt::Vblank) { - status.interruptRequestVblank = 1; - if(status.interruptEnableVblank) r.halt = false; - } - - if(id == Interrupt::Stat) { - status.interruptRequestStat = 1; - if(status.interruptEnableStat) r.halt = false; - } - - if(id == Interrupt::Timer) { - status.interruptRequestTimer = 1; - if(status.interruptEnableTimer) r.halt = false; - } - - if(id == Interrupt::Serial) { - status.interruptRequestSerial = 1; - if(status.interruptEnableSerial) r.halt = false; - } - - if(id == Interrupt::Joypad) { - status.interruptRequestJoypad = 1; - if(status.interruptEnableJoypad) r.halt = r.stop = false; - } -} - -auto CPU::interruptTest() -> void { - if(!r.ime) return; - - if(status.interruptRequestVblank && status.interruptEnableVblank) { - status.interruptRequestVblank = 0; - return interrupt(0x0040); - } - - if(status.interruptRequestStat && status.interruptEnableStat) { - status.interruptRequestStat = 0; - return interrupt(0x0048); - } - - if(status.interruptRequestTimer && status.interruptEnableTimer) { - status.interruptRequestTimer = 0; - return interrupt(0x0050); - } - - if(status.interruptRequestSerial && status.interruptEnableSerial) { - status.interruptRequestSerial = 0; - return interrupt(0x0058); - } - - if(status.interruptRequestJoypad && status.interruptEnableJoypad) { - status.interruptRequestJoypad = 0; - return interrupt(0x0060); - } -} - -auto CPU::stop() -> bool { - if(status.speedSwitch) { - status.speedSwitch = 0; - status.speedDouble ^= 1; - if(status.speedDouble == 0) setFrequency(4 * 1024 * 1024); - if(status.speedDouble == 1) setFrequency(8 * 1024 * 1024); - return true; - } - return false; -} - -auto CPU::power() -> void { - create(Enter, 4 * 1024 * 1024); - SM83::power(); - - for(uint n = 0xc000; n <= 0xdfff; n++) bus.mmio[n] = this; //WRAM - for(uint n = 0xe000; n <= 0xfdff; n++) bus.mmio[n] = this; //WRAM (mirror) - for(uint n = 0xff80; n <= 0xfffe; n++) bus.mmio[n] = this; //HRAM - - bus.mmio[0xff00] = this; //JOYP - bus.mmio[0xff01] = this; //SB - bus.mmio[0xff02] = this; //SC - bus.mmio[0xff04] = this; //DIV - bus.mmio[0xff05] = this; //TIMA - bus.mmio[0xff06] = this; //TMA - bus.mmio[0xff07] = this; //TAC - bus.mmio[0xff0f] = this; //IF - bus.mmio[0xffff] = this; //IE - - if(Model::GameBoyColor()) { - bus.mmio[0xff4d] = this; //KEY1 - bus.mmio[0xff51] = this; //HDMA1 - bus.mmio[0xff52] = this; //HDMA2 - bus.mmio[0xff53] = this; //HDMA3 - bus.mmio[0xff54] = this; //HDMA4 - bus.mmio[0xff55] = this; //HDMA5 - bus.mmio[0xff56] = this; //RP - bus.mmio[0xff6c] = this; //??? - bus.mmio[0xff70] = this; //SVBK - bus.mmio[0xff72] = this; //??? - bus.mmio[0xff73] = this; //??? - bus.mmio[0xff74] = this; //??? - bus.mmio[0xff75] = this; //??? - bus.mmio[0xff76] = this; //??? - bus.mmio[0xff77] = this; //??? - } - - for(auto& n : wram) n = 0x00; - for(auto& n : hram) n = 0x00; - - status = {}; -} - -} diff --git a/bsnes/gb/cpu/cpu.hpp b/bsnes/gb/cpu/cpu.hpp deleted file mode 100644 index 76cdb349..00000000 --- a/bsnes/gb/cpu/cpu.hpp +++ /dev/null @@ -1,112 +0,0 @@ -struct CPU : Processor::SM83, Thread, MMIO { - enum class Interrupt : uint { Vblank, Stat, Timer, Serial, Joypad }; - - static auto Enter() -> void; - auto main() -> void; - auto raise(Interrupt id) -> void; - auto interruptTest() -> void; - auto stop() -> bool; - auto power() -> void; - - auto serialize(serializer&) -> void; - - //io.cpp - auto wramAddress(uint16 addr) const -> uint; - auto joypPoll() -> void; - auto readIO(uint16 addr) -> uint8; - auto writeIO(uint16 addr, uint8 data) -> void; - - //memory.cpp - auto idle() -> void override; - auto read(uint16 addr) -> uint8 override; - auto write(uint16 addr, uint8 data) -> void override; - auto cycleEdge() -> void; - auto readDMA(uint16 addr) -> uint8; - auto writeDMA(uint16 addr, uint8 data) -> void; - auto readDebugger(uint16 addr) -> uint8 override; - - //timing.cpp - auto step(uint clocks) -> void; - auto timer262144hz() -> void; - auto timer65536hz() -> void; - auto timer16384hz() -> void; - auto timer8192hz() -> void; - auto timer4096hz() -> void; - auto hblank() -> void; - - struct Status { - uint22 clock; - - //$ff00 JOYP - bool p15 = 0; - bool p14 = 0; - uint8 joyp; - - //$ff01 SB - uint8 serialData; - uint serialBits = 0; - - //$ff02 SC - bool serialTransfer = 0; - bool serialClock = 0; - - //$ff04 DIV - uint16 div; - - //$ff05 TIMA - uint8 tima; - - //$ff06 TMA - uint8 tma; - - //$ff07 TAC - bool timerEnable = 0; - uint timerClock = 0; - - //$ff0f IF - bool interruptRequestJoypad = 0; - bool interruptRequestSerial = 0; - bool interruptRequestTimer = 0; - bool interruptRequestStat = 0; - bool interruptRequestVblank = 0; - - //$ff4d KEY1 - bool speedDouble = 0; - bool speedSwitch = 0; - - //$ff51,$ff52 HDMA1,HDMA2 - uint16 dmaSource; - - //$ff53,$ff54 HDMA3,HDMA4 - uint16 dmaTarget; - - //$ff55 HDMA5 - bool dmaMode = 0; - uint16 dmaLength; - bool dmaCompleted = 1; - - //$ff6c ??? - uint8 ff6c; - - //$ff70 SVBK - uint3 wramBank = 1; - - //$ff72-$ff75 ??? - uint8 ff72; - uint8 ff73; - uint8 ff74; - uint8 ff75; - - //$ffff IE - bool interruptEnableJoypad = 0; - bool interruptEnableSerial = 0; - bool interruptEnableTimer = 0; - bool interruptEnableStat = 0; - bool interruptEnableVblank = 0; - } status; - - uint8 wram[32768]; //GB=8192, GBC=32768 - uint8 hram[128]; -}; - -extern CPU cpu; diff --git a/bsnes/gb/cpu/io.cpp b/bsnes/gb/cpu/io.cpp deleted file mode 100644 index a3319975..00000000 --- a/bsnes/gb/cpu/io.cpp +++ /dev/null @@ -1,283 +0,0 @@ -auto CPU::wramAddress(uint16 addr) const -> uint { - addr &= 0x1fff; - if(addr < 0x1000) return addr; - auto bank = status.wramBank + (status.wramBank == 0); - return (bank * 0x1000) + (addr & 0x0fff); -} - -auto CPU::joypPoll() -> void { - function int16> inputPoll = {&Emulator::Platform::inputPoll, platform}; - if(Model::SuperGameBoy()) inputPoll = {&SuperGameBoyInterface::inputPoll, superGameBoy}; - - uint button = 0; - button |= inputPoll(0, 0, (uint)Input::Start) << 3; - button |= inputPoll(0, 0, (uint)Input::Select) << 2; - button |= inputPoll(0, 0, (uint)Input::B) << 1; - button |= inputPoll(0, 0, (uint)Input::A) << 0; - - uint dpad = 0; - dpad |= inputPoll(0, 0, (uint)Input::Down) << 3; - dpad |= inputPoll(0, 0, (uint)Input::Up) << 2; - dpad |= inputPoll(0, 0, (uint)Input::Left) << 1; - dpad |= inputPoll(0, 0, (uint)Input::Right) << 0; - - if(!Model::SuperGameBoy()) { - //D-pad pivot makes it impossible to press opposing directions at the same time - //however, Super Game Boy BIOS is able to set these bits together - if(dpad & 4) dpad &= ~8; //disallow up+down - if(dpad & 2) dpad &= ~1; //disallow left+right - } - - status.joyp = 0x0f; - if(status.p15 == 1 && status.p14 == 1 && Model::SuperGameBoy()) { - status.joyp = superGameBoy->joypRead(); - } - if(status.p15 == 0) status.joyp &= button ^ 0x0f; - if(status.p14 == 0) status.joyp &= dpad ^ 0x0f; - if(status.joyp != 0x0f) raise(Interrupt::Joypad); -} - -auto CPU::readIO(uint16 addr) -> uint8 { - if(addr >= 0xc000 && addr <= 0xfdff) return wram[wramAddress(addr)]; - if(addr >= 0xff80 && addr <= 0xfffe) return hram[addr & 0x7f]; - - if(addr == 0xff00) { //JOYP - joypPoll(); - return 0xc0 - | (status.p15 << 5) - | (status.p14 << 4) - | (status.joyp << 0); - } - - if(addr == 0xff01) { //SB - return 0x00; - } - - if(addr == 0xff02) { //SC - return (status.serialTransfer << 7) - | 0x7e - | (status.serialClock << 0); - } - - if(addr == 0xff04) { //DIV - return status.div >> 8; - } - - if(addr == 0xff05) { //TIMA - return status.tima; - } - - if(addr == 0xff06) { //TMA - return status.tma; - } - - if(addr == 0xff07) { //TAC - return 0xf8 - | (status.timerEnable << 2) - | (status.timerClock << 0); - } - - if(addr == 0xff0f) { //IF - return 0xe0 - | (status.interruptRequestJoypad << 4) - | (status.interruptRequestSerial << 3) - | (status.interruptRequestTimer << 2) - | (status.interruptRequestStat << 1) - | (status.interruptRequestVblank << 0); - } - - if(addr == 0xff4d) { //KEY1 - return (status.speedDouble << 7); - } - - if(addr == 0xff55) { //HDMA5 - return (status.dmaCompleted << 7) - | (((status.dmaLength / 16) - 1) & 0x7f); - } - - if(addr == 0xff56) { //RP - return 0x02; - } - - if(addr == 0xff6c) { //??? - return 0xfe | status.ff6c; - } - - if(addr == 0xff70) { //SVBK - return status.wramBank; - } - - if(addr == 0xff72) { //??? - return status.ff72; - } - - if(addr == 0xff73) { //??? - return status.ff73; - } - - if(addr == 0xff74) { //??? - return status.ff74; - } - - if(addr == 0xff75) { //??? - return 0x8f | status.ff75; - } - - if(addr == 0xff76) { //??? - return 0xff; - } - - if(addr == 0xff77) { //??? - return 0xff; - } - - if(addr == 0xffff) { //IE - return 0xe0 - | (status.interruptEnableJoypad << 4) - | (status.interruptEnableSerial << 3) - | (status.interruptEnableTimer << 2) - | (status.interruptEnableStat << 1) - | (status.interruptEnableVblank << 0); - } - - return 0xff; -} - -auto CPU::writeIO(uint16 addr, uint8 data) -> void { - if(addr >= 0xc000 && addr <= 0xfdff) { wram[wramAddress(addr)] = data; return; } - if(addr >= 0xff80 && addr <= 0xfffe) { hram[addr & 0x7f] = data; return; } - - if(addr == 0xff00) { //JOYP - status.p15 = data & 0x20; - status.p14 = data & 0x10; - if(Model::SuperGameBoy()) superGameBoy->joypWrite(status.p15, status.p14); - return; - } - - if(addr == 0xff01) { //SB - status.serialData = data; - return; - } - - if(addr == 0xff02) { //SC - status.serialTransfer = data & 0x80; - status.serialClock = data & 0x01; - if(status.serialTransfer) status.serialBits = 8; - return; - } - - if(addr == 0xff04) { //DIV - status.div = 0; - return; - } - - if(addr == 0xff05) { //TIMA - status.tima = data; - return; - } - - if(addr == 0xff06) { //TMA - status.tma = data; - return; - } - - if(addr == 0xff07) { //TAC - status.timerEnable = data & 0x04; - status.timerClock = data & 0x03; - return; - } - - if(addr == 0xff0f) { //IF - status.interruptRequestJoypad = data & 0x10; - status.interruptRequestSerial = data & 0x08; - status.interruptRequestTimer = data & 0x04; - status.interruptRequestStat = data & 0x02; - status.interruptRequestVblank = data & 0x01; - return; - } - - if(addr == 0xff4d) { //KEY1 - status.speedSwitch = data & 0x01; - return; - } - - if(addr == 0xff51) { //HDMA1 - status.dmaSource = (status.dmaSource & 0x00ff) | (data << 8); - return; - } - - if(addr == 0xff52) { //HDMA2 - status.dmaSource = (status.dmaSource & 0xff00) | (data & 0xf0); - return; - } - - if(addr == 0xff53) { //HDMA3 - status.dmaTarget = (status.dmaTarget & 0x00ff) | (data << 8); - return; - } - - if(addr == 0xff54) { //HDMA4 - status.dmaTarget = (status.dmaTarget & 0xff00) | (data & 0xf0); - return; - } - - if(addr == 0xff55) { //HDMA5 - status.dmaMode = data & 0x80; - status.dmaLength = ((data & 0x7f) + 1) * 16; - status.dmaCompleted = !status.dmaMode; - - if(status.dmaMode == 0) { - do { - for(auto n : range(16)) { - writeDMA(status.dmaTarget++, readDMA(status.dmaSource++)); - } - step(8 << status.speedDouble); - status.dmaLength -= 16; - } while(status.dmaLength); - } - return; - } - - if(addr == 0xff56) { //RP - return; - } - - if(addr == 0xff6c) { //??? - status.ff6c = data & 0x01; - return; - } - - if(addr == 0xff72) { //??? - status.ff72 = data; - return; - } - - if(addr == 0xff73) { //??? - status.ff73 = data; - return; - } - - if(addr == 0xff74) { //??? - status.ff74 = data; - return; - } - - if(addr == 0xff75) { //??? - status.ff75 = data & 0x70; - return; - } - - if(addr == 0xff70) { //SVBK - status.wramBank = data & 0x07; - return; - } - - if(addr == 0xffff) { //IE - status.interruptEnableJoypad = data & 0x10; - status.interruptEnableSerial = data & 0x08; - status.interruptEnableTimer = data & 0x04; - status.interruptEnableStat = data & 0x02; - status.interruptEnableVblank = data & 0x01; - return; - } -} diff --git a/bsnes/gb/cpu/memory.cpp b/bsnes/gb/cpu/memory.cpp deleted file mode 100644 index 05db77c9..00000000 --- a/bsnes/gb/cpu/memory.cpp +++ /dev/null @@ -1,41 +0,0 @@ -auto CPU::idle() -> void { - cycleEdge(); - step(4); -} - -auto CPU::read(uint16 addr) -> uint8 { - cycleEdge(); - step(4); - return bus.read(addr); -} - -auto CPU::write(uint16 addr, uint8 data) -> void { - cycleEdge(); - step(4); - bus.write(addr, data); -} - -auto CPU::cycleEdge() -> void { - if(r.ei) { - r.ei = false; - r.ime = 1; - } -} - -//VRAM DMA source can only be ROM or RAM -auto CPU::readDMA(uint16 addr) -> uint8 { - if(addr < 0x8000) return bus.read(addr); //0000-7fff - if(addr < 0xa000) return 0xff; //8000-9fff - if(addr < 0xe000) return bus.read(addr); //a000-dfff - return 0xff; //e000-ffff -} - -//VRAM DMA target is always VRAM -auto CPU::writeDMA(uint16 addr, uint8 data) -> void { - addr = 0x8000 | (addr & 0x1fff); //8000-9fff - return bus.write(addr, data); -} - -auto CPU::readDebugger(uint16 addr) -> uint8 { - return bus.read(addr); -} diff --git a/bsnes/gb/cpu/serialization.cpp b/bsnes/gb/cpu/serialization.cpp deleted file mode 100644 index 17fc7767..00000000 --- a/bsnes/gb/cpu/serialization.cpp +++ /dev/null @@ -1,55 +0,0 @@ -auto CPU::serialize(serializer& s) -> void { - SM83::serialize(s); - Thread::serialize(s); - - s.array(wram); - s.array(hram); - - s.integer(status.clock); - - s.integer(status.p15); - s.integer(status.p14); - s.integer(status.joyp); - - s.integer(status.serialData); - s.integer(status.serialBits); - - s.integer(status.serialTransfer); - s.integer(status.serialClock); - - s.integer(status.div); - s.integer(status.tima); - s.integer(status.tma); - s.integer(status.timerEnable); - s.integer(status.timerClock); - - s.integer(status.interruptRequestJoypad); - s.integer(status.interruptRequestSerial); - s.integer(status.interruptRequestTimer); - s.integer(status.interruptRequestStat); - s.integer(status.interruptRequestVblank); - - s.integer(status.speedDouble); - s.integer(status.speedSwitch); - - s.integer(status.dmaSource); - s.integer(status.dmaTarget); - s.integer(status.dmaMode); - s.integer(status.dmaLength); - s.integer(status.dmaCompleted); - - s.integer(status.ff6c); - - s.integer(status.wramBank); - - s.integer(status.ff72); - s.integer(status.ff73); - s.integer(status.ff74); - s.integer(status.ff75); - - s.integer(status.interruptEnableJoypad); - s.integer(status.interruptEnableSerial); - s.integer(status.interruptEnableTimer); - s.integer(status.interruptEnableStat); - s.integer(status.interruptEnableVblank); -} diff --git a/bsnes/gb/cpu/timing.cpp b/bsnes/gb/cpu/timing.cpp deleted file mode 100644 index 51dc892a..00000000 --- a/bsnes/gb/cpu/timing.cpp +++ /dev/null @@ -1,84 +0,0 @@ -//70224 clocks/frame -// 456 clocks/scanline -// 154 scanlines/frame - -auto CPU::step(uint clocks) -> void { - for(auto n : range(clocks)) { - if(++status.clock == 0) { - cartridge.second(); - } - - //4MHz / N(hz) - 1 = mask - status.div++; - if((status.div & 15) == 0) timer262144hz(); - if((status.div & 63) == 0) timer65536hz(); - if((status.div & 255) == 0) timer16384hz(); - if((status.div & 511) == 0) timer8192hz(); - if((status.div & 1023) == 0) timer4096hz(); - - Thread::step(1); - synchronize(ppu); - synchronize(apu); - synchronize(cartridge); - } - - if(Model::SuperGameBoy()) { - system._clocksExecuted += clocks; - scheduler.exit(Scheduler::Event::Step); - } -} - -auto CPU::timer262144hz() -> void { - if(status.timerEnable && status.timerClock == 1) { - if(++status.tima == 0) { - status.tima = status.tma; - raise(Interrupt::Timer); - } - } -} - -auto CPU::timer65536hz() -> void { - if(status.timerEnable && status.timerClock == 2) { - if(++status.tima == 0) { - status.tima = status.tma; - raise(Interrupt::Timer); - } - } -} - -auto CPU::timer16384hz() -> void { - if(status.timerEnable && status.timerClock == 3) { - if(++status.tima == 0) { - status.tima = status.tma; - raise(Interrupt::Timer); - } - } -} - -auto CPU::timer8192hz() -> void { - if(status.serialTransfer && status.serialClock) { - if(--status.serialBits == 0) { - status.serialTransfer = 0; - raise(Interrupt::Serial); - } - } -} - -auto CPU::timer4096hz() -> void { - if(status.timerEnable && status.timerClock == 0) { - if(++status.tima == 0) { - status.tima = status.tma; - raise(Interrupt::Timer); - } - } -} - -auto CPU::hblank() -> void { - if(status.dmaMode == 1 && status.dmaLength && ppu.status.ly < 144) { - for(auto n : range(16)) { - writeDMA(status.dmaTarget++, readDMA(status.dmaSource++)); - status.dmaLength--; - if(n & 1) step(1 << status.speedDouble); - } - } -} diff --git a/bsnes/gb/gb.hpp b/bsnes/gb/gb.hpp deleted file mode 100644 index 35eb3253..00000000 --- a/bsnes/gb/gb.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -//license: GPLv3 -//started: 2010-12-27 - -#include -#include -#include -#include - -#include - -namespace GameBoy { - #define platform Emulator::platform - namespace File = Emulator::File; - using Scheduler = Emulator::Scheduler; - using Cheat = Emulator::Cheat; - extern Scheduler scheduler; - extern Cheat cheat; - - struct Thread : Emulator::Thread { - auto create(auto (*entrypoint)() -> void, double frequency) -> void { - Emulator::Thread::create(entrypoint, frequency); - scheduler.append(*this); - } - - inline auto synchronize(Thread& thread) -> void { - if(clock() >= thread.clock()) scheduler.resume(thread); - } - }; - - struct Model { - inline static auto GameBoy() -> bool; - inline static auto GameBoyColor() -> bool; - inline static auto SuperGameBoy() -> bool; - }; - - #include - #include - #include - #include - #include - #include -} - -#include diff --git a/bsnes/gb/interface/game-boy-color.cpp b/bsnes/gb/interface/game-boy-color.cpp deleted file mode 100644 index d1ec017b..00000000 --- a/bsnes/gb/interface/game-boy-color.cpp +++ /dev/null @@ -1,23 +0,0 @@ -auto GameBoyColorInterface::information() -> Information { - Information information; - information.manufacturer = "Nintendo"; - information.name = "Game Boy Color"; - information.extension = "gbc"; - return information; -} - -auto GameBoyColorInterface::color(uint32 color) -> uint64 { - uint r = bits(color, 0- 4); - uint g = bits(color, 5- 9); - uint b = bits(color,10-14); - - uint64 R = image::normalize(r, 5, 16); - uint64 G = image::normalize(g, 5, 16); - uint64 B = image::normalize(b, 5, 16); - - return R << 32 | G << 16 | B << 0; -} - -auto GameBoyColorInterface::load() -> bool { - return system.load(this, System::Model::GameBoyColor); -} diff --git a/bsnes/gb/interface/game-boy.cpp b/bsnes/gb/interface/game-boy.cpp deleted file mode 100644 index 76fd1ae0..00000000 --- a/bsnes/gb/interface/game-boy.cpp +++ /dev/null @@ -1,16 +0,0 @@ -auto GameBoyInterface::information() -> Information { - Information information; - information.manufacturer = "Nintendo"; - information.name = "Game Boy"; - information.extension = "gb"; - return information; -} - -auto GameBoyInterface::color(uint32 color) -> uint64 { - uint64 L = image::normalize(3 - color, 2, 16); - return L << 32 | L << 16 | L << 0; -} - -auto GameBoyInterface::load() -> bool { - return system.load(this, System::Model::GameBoy); -} diff --git a/bsnes/gb/interface/interface.cpp b/bsnes/gb/interface/interface.cpp deleted file mode 100644 index 8f6d6fc5..00000000 --- a/bsnes/gb/interface/interface.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include - -namespace GameBoy { - -SuperGameBoyInterface* superGameBoy = nullptr; -#include "game-boy.cpp" -#include "game-boy-color.cpp" - -auto Interface::display() -> Display { - Display display; - display.type = Display::Type::LCD; - display.colors = Model::GameBoyColor() ? 1 << 15 : 1 << 2; - display.width = 160; - display.height = 144; - display.internalWidth = 160; - display.internalHeight = 144; - display.aspectCorrection = 1.0; - return display; -} - -auto Interface::loaded() -> bool { - return system.loaded(); -} - -auto Interface::hashes() -> vector { - return {cartridge.hash()}; -} - -auto Interface::manifests() -> vector { - return {cartridge.manifest()}; -} - -auto Interface::titles() -> vector { - return {cartridge.title()}; -} - -auto Interface::save() -> void { - system.save(); -} - -auto Interface::unload() -> void { - save(); - system.unload(); -} - -auto Interface::ports() -> vector { return { - {ID::Port::Hardware, "Hardware"}, - {ID::Port::Cartridge, "Cartridge"}}; -} - -auto Interface::devices(uint port) -> vector { - if(port == ID::Port::Hardware) return { - {ID::Device::Controls, "Controls"} - }; - - if(port == ID::Port::Cartridge) return { - {ID::Device::MBC5, "MBC5"}, - {ID::Device::MBC7, "MBC7"} - }; - - return {}; -} - -auto Interface::inputs(uint device) -> vector { - using Type = Input::Type; - - if(device == ID::Device::Controls) return { - {Type::Hat, "Up" }, - {Type::Hat, "Down" }, - {Type::Hat, "Left" }, - {Type::Hat, "Right" }, - {Type::Button, "B" }, - {Type::Button, "A" }, - {Type::Control, "Select"}, - {Type::Control, "Start" } - }; - - if(device == ID::Device::MBC5) return { - {Type::Rumble, "Rumble"} - }; - - if(device == ID::Device::MBC7) return { - {Type::Axis, "Accelerometer - X-axis"}, - {Type::Axis, "Accelerometer - Y-axis"} - }; - - return {}; -} - -auto Interface::power() -> void { - system.power(); -} - -auto Interface::run() -> void { - system.run(); -} - -auto Interface::serialize() -> serializer { - system.runToSave(); - return system.serialize(); -} - -auto Interface::unserialize(serializer& s) -> bool { - return system.unserialize(s); -} - -auto Interface::cheats(const vector& list) -> void { - cheat.assign(list); -} - -auto Interface::cap(const string& name) -> bool { - return false; -} - -auto Interface::get(const string& name) -> any { - return {}; -} - -auto Interface::set(const string& name, const any& value) -> bool { - return false; -} - -} diff --git a/bsnes/gb/interface/interface.hpp b/bsnes/gb/interface/interface.hpp deleted file mode 100644 index 84ac5727..00000000 --- a/bsnes/gb/interface/interface.hpp +++ /dev/null @@ -1,79 +0,0 @@ -namespace GameBoy { - -struct ID { - enum : uint { - System, - GameBoy, - SuperGameBoy, - GameBoyColor, - }; - - struct Port { enum : uint { - Hardware, - Cartridge, - };}; - - struct Device { enum : uint { - Controls, - MBC5, - MBC7, - };}; -}; - -struct Interface : Emulator::Interface { - auto display() -> Display override; - - auto loaded() -> bool override; - auto hashes() -> vector override; - auto manifests() -> vector override; - auto titles() -> vector override; - - auto save() -> void override; - auto unload() -> void override; - - auto ports() -> vector override; - auto devices(uint port) -> vector override; - auto inputs(uint device) -> vector override; - - auto power() -> void override; - auto run() -> void override; - - auto serialize() -> serializer override; - auto unserialize(serializer&) -> bool override; - - auto cheats(const vector&) -> void override; - - auto cap(const string& name) -> bool override; - auto get(const string& name) -> any override; - auto set(const string& name, const any& value) -> bool override; -}; - -struct GameBoyInterface : Interface { - auto information() -> Information override; - - auto color(uint32 color) -> uint64 override; - - auto load() -> bool override; -}; - -struct GameBoyColorInterface : Interface { - auto information() -> Information override; - - auto color(uint32 color) -> uint64 override; - - auto load() -> bool override; -}; - -struct SuperGameBoyInterface { - virtual auto audioSample(const float* samples, uint channels) -> void = 0; - virtual auto inputPoll(uint port, uint device, uint id) -> int16 = 0; - - virtual auto lcdScanline() -> void = 0; - virtual auto lcdOutput(uint2 color) -> void = 0; - virtual auto joypRead() -> uint4 = 0; - virtual auto joypWrite(bool p15, bool p14) -> void = 0; -}; - -extern SuperGameBoyInterface* superGameBoy; - -} diff --git a/bsnes/gb/memory/memory.cpp b/bsnes/gb/memory/memory.cpp deleted file mode 100644 index 51ad6adf..00000000 --- a/bsnes/gb/memory/memory.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include - -namespace GameBoy { - -Unmapped unmapped; -Bus bus; - -Memory::~Memory() { - free(); -} - -auto Memory::operator[](uint addr) -> uint8& { - return data[addr]; -} - -auto Memory::allocate(uint size_) -> void { - free(); - size = size_; - data = new uint8[size]; -} - -auto Memory::copy(const uint8* data_, unsigned size_) -> void { - free(); - size = size_; - data = new uint8[size]; - memcpy(data, data_, size); -} - -auto Memory::free() -> void { - if(data) { - delete[] data; - data = nullptr; - } -} - -// - -auto Bus::read(uint16 addr) -> uint8 { - uint8 data = mmio[addr]->readIO(addr); - - if(cheat) { - if(auto result = cheat.find(addr, data)) return result(); - } - - return data; -} - -auto Bus::write(uint16 addr, uint8 data) -> void { - mmio[addr]->writeIO(addr, data); -} - -auto Bus::power() -> void { - for(auto n : range(65536)) mmio[n] = &unmapped; -} - -} diff --git a/bsnes/gb/memory/memory.hpp b/bsnes/gb/memory/memory.hpp deleted file mode 100644 index 80a2c47f..00000000 --- a/bsnes/gb/memory/memory.hpp +++ /dev/null @@ -1,32 +0,0 @@ -struct Memory { - ~Memory(); - - auto operator[](uint addr) -> uint8&; - auto allocate(uint size) -> void; - auto copy(const uint8* data, uint size) -> void; - auto free() -> void; - - uint8* data = nullptr; - uint size = 0; -}; - -struct MMIO { - virtual auto readIO(uint16 addr) -> uint8 = 0; - virtual auto writeIO(uint16 addr, uint8 data) -> void = 0; -}; - -struct Unmapped : MMIO { - auto readIO(uint16) -> uint8 { return 0xff; } - auto writeIO(uint16, uint8) -> void {} -}; - -struct Bus { - auto read(uint16 addr) -> uint8; - auto write(uint16 addr, uint8 data) -> void; - auto power() -> void; - - MMIO* mmio[65536]; -}; - -extern Unmapped unmapped; -extern Bus bus; diff --git a/bsnes/gb/ppu/cgb.cpp b/bsnes/gb/ppu/cgb.cpp deleted file mode 100644 index c6b2bc5c..00000000 --- a/bsnes/gb/ppu/cgb.cpp +++ /dev/null @@ -1,158 +0,0 @@ -//BG attributes: -//0x80: 0 = OAM priority, 1 = BG priority -//0x40: vertical flip -//0x20: horizontal flip -//0x08: VRAM bank# -//0x07: palette# - -//OB attributes: -//0x80: 0 = OBJ above BG, 1 = BG above OBJ -//0x40: vertical flip -//0x20: horizontal flip -//0x08: VRAM bank# -//0x07: palette# - -auto PPU::readTileCGB(bool select, uint x, uint y, uint& attr, uint& data) -> void { - uint tmaddr = 0x1800 + (select << 10); - tmaddr += (((y >> 3) << 5) + (x >> 3)) & 0x03ff; - - uint tile = vram[0x0000 + tmaddr]; - attr = vram[0x2000 + tmaddr]; - - uint tdaddr = attr & 0x08 ? 0x2000 : 0x0000; - if(status.bgTiledataSelect == 0) { - tdaddr += 0x1000 + ((int8)tile << 4); - } else { - tdaddr += 0x0000 + (tile << 4); - } - - y &= 7; - if(attr & 0x40) y ^= 7; - tdaddr += y << 1; - - data = vram[tdaddr++] << 0; - data |= vram[tdaddr++] << 8; - if(attr & 0x20) data = hflip(data); -} - -auto PPU::scanlineCGB() -> void { - px = 0; - - const uint Height = (status.obSize == 0 ? 8 : 16); - sprites = 0; - - //find first ten sprites on this scanline - for(uint n = 0; n < 40 * 4; n += 4) { - Sprite& s = sprite[sprites]; - s.y = oam[n + 0] - 16; - s.x = oam[n + 1] - 8; - s.tile = oam[n + 2] & ~status.obSize; - s.attr = oam[n + 3]; - - s.y = status.ly - s.y; - if(s.y >= Height) continue; - - if(s.attr & 0x40) s.y ^= (Height - 1); - uint tdaddr = (s.attr & 0x08 ? 0x2000 : 0x0000) + (s.tile << 4) + (s.y << 1); - s.data = vram[tdaddr + 0] << 0; - s.data |= vram[tdaddr + 1] << 8; - if(s.attr & 0x20) s.data = hflip(s.data); - - if(++sprites == 10) break; - } -} - -auto PPU::runCGB() -> void { - ob.color = 0; - ob.palette = 0; - ob.priority = 0; - - uint color = 0x7fff; - runBackgroundCGB(); - if(status.windowDisplayEnable) runWindowCGB(); - if(status.obEnable) runObjectsCGB(); - - if(ob.palette == 0) { - color = bg.color; - } else if(bg.palette == 0) { - color = ob.color; - } else if(status.bgEnable == 0) { - color = ob.color; - } else if(bg.priority) { - color = bg.color; - } else if(ob.priority) { - color = ob.color; - } else { - color = bg.color; - } - - uint32* output = screen + status.ly * 160 + px++; - *output = color; -} - -auto PPU::runBackgroundCGB() -> void { - uint scrolly = (status.ly + status.scy) & 255; - uint scrollx = (px + status.scx) & 255; - uint tx = scrollx & 7; - if(tx == 0 || px == 0) readTileCGB(status.bgTilemapSelect, scrollx, scrolly, background.attr, background.data); - - uint index = 0; - index |= (background.data & (0x0080 >> tx)) ? 1 : 0; - index |= (background.data & (0x8000 >> tx)) ? 2 : 0; - uint palette = ((background.attr & 0x07) << 2) + index; - uint color = 0; - color |= bgpd[(palette << 1) + 0] << 0; - color |= bgpd[(palette << 1) + 1] << 8; - color &= 0x7fff; - - bg.color = color; - bg.palette = index; - bg.priority = background.attr & 0x80; -} - -auto PPU::runWindowCGB() -> void { - uint scrolly = status.ly - status.wy; - uint scrollx = px + 7 - status.wx; - if(scrolly >= 144u) return; //also matches underflow (scrolly < 0) - if(scrollx >= 160u) return; //also matches underflow (scrollx < 0) - uint tx = scrollx & 7; - if(tx == 0 || px == 0) readTileCGB(status.windowTilemapSelect, scrollx, scrolly, window.attr, window.data); - - uint index = 0; - index |= (window.data & (0x0080 >> tx)) ? 1 : 0; - index |= (window.data & (0x8000 >> tx)) ? 2 : 0; - uint palette = ((window.attr & 0x07) << 2) + index; - uint color = 0; - color |= bgpd[(palette << 1) + 0] << 0; - color |= bgpd[(palette << 1) + 1] << 8; - color &= 0x7fff; - - bg.color = color; - bg.palette = index; - bg.priority = window.attr & 0x80; -} - -auto PPU::runObjectsCGB() -> void { - //render backwards, so that first sprite has priority - for(int n = sprites - 1; n >= 0; n--) { - Sprite& s = sprite[n]; - - int tx = px - s.x; - if(tx < 0 || tx > 7) continue; - - uint index = 0; - index |= (s.data & (0x0080 >> tx)) ? 1 : 0; - index |= (s.data & (0x8000 >> tx)) ? 2 : 0; - if(index == 0) continue; - - uint palette = ((s.attr & 0x07) << 2) + index; - uint color = 0; - color |= obpd[(palette << 1) + 0] << 0; - color |= obpd[(palette << 1) + 1] << 8; - color &= 0x7fff; - - ob.color = color; - ob.palette = index; - ob.priority = !(s.attr & 0x80); - } -} diff --git a/bsnes/gb/ppu/dmg.cpp b/bsnes/gb/ppu/dmg.cpp deleted file mode 100644 index 10c3ff46..00000000 --- a/bsnes/gb/ppu/dmg.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//OB attributes: -//0x80: 0 = OBJ above BG, 1 = BG above OBJ -//0x40: vertical flip -//0x20: horizontal flip -//0x10: palette# - -auto PPU::readTileDMG(bool select, uint x, uint y, uint& data) -> void { - uint tmaddr = 0x1800 + (select << 10), tdaddr; - tmaddr += (((y >> 3) << 5) + (x >> 3)) & 0x03ff; - if(status.bgTiledataSelect == 0) { - tdaddr = 0x1000 + ((int8)vram[tmaddr] << 4); - } else { - tdaddr = 0x0000 + (vram[tmaddr] << 4); - } - tdaddr += (y & 7) << 1; - data = vram[tdaddr + 0] << 0; - data |= vram[tdaddr + 1] << 8; -} - -auto PPU::scanlineDMG() -> void { - px = 0; - - const uint Height = (status.obSize == 0 ? 8 : 16); - sprites = 0; - - //find first ten sprites on this scanline - for(uint n = 0; n < 40 * 4; n += 4) { - Sprite& s = sprite[sprites]; - s.y = oam[n + 0] - 16; - s.x = oam[n + 1] - 8; - s.tile = oam[n + 2] & ~status.obSize; - s.attr = oam[n + 3]; - - s.y = status.ly - s.y; - if(s.y >= Height) continue; - - if(s.attr & 0x40) s.y ^= (Height - 1); - uint tdaddr = (s.tile << 4) + (s.y << 1); - s.data = vram[tdaddr + 0] << 0; - s.data |= vram[tdaddr + 1] << 8; - if(s.attr & 0x20) s.data = hflip(s.data); - - if(++sprites == 10) break; - } - - //sort by X-coordinate - for(uint lo = 0; lo < sprites; lo++) { - for(uint hi = lo + 1; hi < sprites; hi++) { - if(sprite[hi].x < sprite[lo].x) swap(sprite[lo], sprite[hi]); - } - } -} - -auto PPU::runDMG() -> void { - bg.color = 0; - bg.palette = 0; - - ob.color = 0; - ob.palette = 0; - - uint color = 0; - if(status.bgEnable) runBackgroundDMG(); - if(status.windowDisplayEnable) runWindowDMG(); - if(status.obEnable) runObjectsDMG(); - - if(ob.palette == 0) { - color = bg.color; - } else if(bg.palette == 0) { - color = ob.color; - } else if(ob.priority) { - color = ob.color; - } else { - color = bg.color; - } - - uint32* output = screen + status.ly * 160 + px++; - *output = color; - if(Model::SuperGameBoy()) superGameBoy->lcdOutput(color); -} - -auto PPU::runBackgroundDMG() -> void { - uint scrolly = (status.ly + status.scy) & 255; - uint scrollx = (px + status.scx) & 255; - uint tx = scrollx & 7; - if(tx == 0 || px == 0) readTileDMG(status.bgTilemapSelect, scrollx, scrolly, background.data); - - uint index = 0; - index |= (background.data & (0x0080 >> tx)) ? 1 : 0; - index |= (background.data & (0x8000 >> tx)) ? 2 : 0; - - bg.color = bgp[index]; - bg.palette = index; -} - -auto PPU::runWindowDMG() -> void { - uint scrolly = status.ly - status.wy; - uint scrollx = px + 7 - status.wx; - if(scrolly >= 144u) return; //also matches underflow (scrolly < 0) - if(scrollx >= 160u) return; //also matches underflow (scrollx < 0) - uint tx = scrollx & 7; - if(tx == 0 || px == 0) readTileDMG(status.windowTilemapSelect, scrollx, scrolly, window.data); - - uint index = 0; - index |= (window.data & (0x0080 >> tx)) ? 1 : 0; - index |= (window.data & (0x8000 >> tx)) ? 2 : 0; - - bg.color = bgp[index]; - bg.palette = index; -} - -auto PPU::runObjectsDMG() -> void { - //render backwards, so that first sprite has priority - for(int n = sprites - 1; n >= 0; n--) { - Sprite& s = sprite[n]; - - int tx = px - s.x; - if(tx < 0 || tx > 7) continue; - - uint index = 0; - index |= (s.data & (0x0080 >> tx)) ? 1 : 0; - index |= (s.data & (0x8000 >> tx)) ? 2 : 0; - if(index == 0) continue; - - ob.color = obp[(bool)(s.attr & 0x10)][index]; - ob.palette = index; - ob.priority = !(s.attr & 0x80); - } -} diff --git a/bsnes/gb/ppu/io.cpp b/bsnes/gb/ppu/io.cpp deleted file mode 100644 index 1dccd298..00000000 --- a/bsnes/gb/ppu/io.cpp +++ /dev/null @@ -1,240 +0,0 @@ -auto PPU::vramAddress(uint16 addr) const -> uint { - return status.vramBank << 13 | (uint13)addr; -} - -auto PPU::readIO(uint16 addr) -> uint8 { - if(addr >= 0x8000 && addr <= 0x9fff) { - return vram[vramAddress(addr)]; - } - - if(addr >= 0xfe00 && addr <= 0xfe9f) { - if(status.dmaActive && status.dmaClock >= 8) return 0xff; - return oam[addr & 0xff]; - } - - if(addr == 0xff40) { //LCDC - return (status.displayEnable << 7) - | (status.windowTilemapSelect << 6) - | (status.windowDisplayEnable << 5) - | (status.bgTiledataSelect << 4) - | (status.bgTilemapSelect << 3) - | (status.obSize << 2) - | (status.obEnable << 1) - | (status.bgEnable << 0); - } - - if(addr == 0xff41) { //STAT - return (status.interruptLYC << 6) - | (status.interruptOAM << 5) - | (status.interruptVblank << 4) - | (status.interruptHblank << 3) - | ((status.ly == status.lyc) << 2) - | (status.mode << 0); - } - - if(addr == 0xff42) { //SCY - return status.scy; - } - - if(addr == 0xff43) { //SCX - return status.scx; - } - - if(addr == 0xff44) { //LY - return status.ly; - } - - if(addr == 0xff45) { //LYC - return status.lyc; - } - - if(addr == 0xff47) { //BGP - return (bgp[3] << 6) - | (bgp[2] << 4) - | (bgp[1] << 2) - | (bgp[0] << 0); - } - - if(addr == 0xff48) { //OBP0 - return (obp[0][3] << 6) - | (obp[0][2] << 4) - | (obp[0][1] << 2) - | (obp[0][0] << 0); - } - - if(addr == 0xff49) { //OBP1 - return (obp[1][3] << 6) - | (obp[1][2] << 4) - | (obp[1][1] << 2) - | (obp[1][0] << 0); - } - - if(addr == 0xff4a) { //WY - return status.wy; - } - - if(addr == 0xff4b) { //WX - return status.wx; - } - - if(addr == 0xff4f) { //VBK - return status.vramBank; - } - - if(addr == 0xff68) { //BGPI - return status.bgpiIncrement << 7 | status.bgpi; - } - - if(addr == 0xff69) { //BGPD - return bgpd[status.bgpi]; - } - - if(addr == 0xff6a) { //OBPI - return status.obpiIncrement << 7 | status.obpi; - } - - if(addr == 0xff6b) { //OBPD - return obpd[status.obpi]; - } - - return 0xff; //should never occur -} - -auto PPU::writeIO(uint16 addr, uint8 data) -> void { - if(addr >= 0x8000 && addr <= 0x9fff) { - vram[vramAddress(addr)] = data; - return; - } - - if(addr >= 0xfe00 && addr <= 0xfe9f) { - if(status.dmaActive && status.dmaClock >= 8) return; - oam[addr & 0xff] = data; - return; - } - - if(addr == 0xff40) { //LCDC - if(status.displayEnable && !(data & 0x80)) { - status.mode = 0; - status.ly = 0; - status.lx = 0; - - //restart cothread to begin new frame - auto clock = Thread::clock(); - create(Enter, 4 * 1024 * 1024); - Thread::setClock(clock); - } - - status.displayEnable = data & 0x80; - status.windowTilemapSelect = data & 0x40; - status.windowDisplayEnable = data & 0x20; - status.bgTiledataSelect = data & 0x10; - status.bgTilemapSelect = data & 0x08; - status.obSize = data & 0x04; - status.obEnable = data & 0x02; - status.bgEnable = data & 0x01; - return; - } - - if(addr == 0xff41) { //STAT - status.interruptLYC = data & 0x40; - status.interruptOAM = data & 0x20; - status.interruptVblank = data & 0x10; - status.interruptHblank = data & 0x08; - - //hardware bug: writes to STAT on DMG,SGB during vblank triggers STAT IRQ - //note: this behavior isn't entirely correct; more research is needed ... - if(!Model::GameBoyColor() && status.mode == 1) { - cpu.raise(CPU::Interrupt::Stat); - } - - return; - } - - if(addr == 0xff42) { //SCY - status.scy = data; - return; - } - - if(addr == 0xff43) { //SCX - status.scx = data; - return; - } - - if(addr == 0xff44) { //LY - status.ly = 0; - return; - } - - if(addr == 0xff45) { //LYC - status.lyc = data; - return; - } - - if(addr == 0xff46) { //DMA - status.dmaActive = true; - status.dmaClock = 0; - status.dmaBank = data; - return; - } - - if(addr == 0xff47) { //BGP - bgp[3] = (data >> 6) & 3; - bgp[2] = (data >> 4) & 3; - bgp[1] = (data >> 2) & 3; - bgp[0] = (data >> 0) & 3; - return; - } - - if(addr == 0xff48) { //OBP0 - obp[0][3] = (data >> 6) & 3; - obp[0][2] = (data >> 4) & 3; - obp[0][1] = (data >> 2) & 3; - obp[0][0] = (data >> 0) & 3; - return; - } - - if(addr == 0xff49) { //OBP1 - obp[1][3] = (data >> 6) & 3; - obp[1][2] = (data >> 4) & 3; - obp[1][1] = (data >> 2) & 3; - obp[1][0] = (data >> 0) & 3; - return; - } - - if(addr == 0xff4a) { //WY - status.wy = data; - return; - } - - if(addr == 0xff4b) { //WX - status.wx = data; - return; - } - - if(addr == 0xff4f) { //VBK - status.vramBank = data & 1; - return; - } - - if(addr == 0xff68) { //BGPI - status.bgpiIncrement = data & 0x80; - status.bgpi = data & 0x3f; - return; - } - - if(addr == 0xff69) { //BGPD - bgpd[status.bgpi] = data; - if(status.bgpiIncrement) status.bgpi++; - return; - } - - if(addr == 0xff6a) { //OBPI - status.obpiIncrement = data & 0x80; - status.obpi = data & 0x3f; - } - - if(addr == 0xff6b) { //OBPD - obpd[status.obpi] = data; - if(status.obpiIncrement) status.obpi++; - } -} diff --git a/bsnes/gb/ppu/ppu.cpp b/bsnes/gb/ppu/ppu.cpp deleted file mode 100644 index 3d15d669..00000000 --- a/bsnes/gb/ppu/ppu.cpp +++ /dev/null @@ -1,182 +0,0 @@ -#include - -namespace GameBoy { - -PPU ppu; -#include "io.cpp" -#include "dmg.cpp" -#include "cgb.cpp" -#include "serialization.cpp" - -auto PPU::Enter() -> void { - while(true) scheduler.synchronize(), ppu.main(); -} - -auto PPU::main() -> void { - if(!status.displayEnable) { - for(uint n : range(160 * 144)) screen[n] = Model::GameBoy() ? 0 : 0x7fff; - Thread::step(154 * 456); - synchronize(cpu); - scheduler.exit(Scheduler::Event::Frame); - return; - } - - status.lx = 0; - if(Model::SuperGameBoy()) superGameBoy->lcdScanline(); - - if(status.ly <= 143) { - status.mode = 2; - scanline(); - step(92); - - status.mode = 3; - for(auto n : range(160)) { - run(); - step(1); - } - - status.mode = 0; - cpu.hblank(); - step(204); - } else { - status.mode = 1; - step(456); - } - - status.ly++; - - if(status.ly == 144) { - cpu.raise(CPU::Interrupt::Vblank); - scheduler.exit(Scheduler::Event::Frame); - } - - if(status.ly == 154) { - status.ly = 0; - } -} - -auto PPU::stat() -> void { - bool irq = status.irq; - - status.irq = status.interruptHblank && status.mode == 0; - status.irq |= status.interruptVblank && status.mode == 1; - status.irq |= status.interruptOAM && status.mode == 2; - status.irq |= status.interruptLYC && coincidence(); - - if(!irq && status.irq) cpu.raise(CPU::Interrupt::Stat); -} - -auto PPU::coincidence() -> bool { - uint ly = status.ly; - if(ly == 153 && status.lx >= 92) ly = 0; //LYC=0 triggers early during LY=153 - return ly == status.lyc; -} - -auto PPU::refresh() -> void { - if(!Model::SuperGameBoy()) Emulator::video.refresh(screen, 160 * sizeof(uint32), 160, 144); -} - -auto PPU::step(uint clocks) -> void { - while(clocks--) { - stat(); - if(status.dmaActive) { - uint hi = status.dmaClock++; - uint lo = hi & (cpu.status.speedDouble ? 1 : 3); - hi >>= cpu.status.speedDouble ? 1 : 2; - if(lo == 0) { - if(hi == 0) { - //warm-up - } else if(hi == 161) { - //cool-down; disable - status.dmaActive = false; - } else { - oam[hi - 1] = bus.read(status.dmaBank << 8 | hi - 1); - } - } - } - - status.lx++; - Thread::step(1); - synchronize(cpu); - } -} - -auto PPU::hflip(uint data) const -> uint { - return (data & 0x8080) >> 7 | (data & 0x4040) >> 5 - | (data & 0x2020) >> 3 | (data & 0x1010) >> 1 - | (data & 0x0808) << 1 | (data & 0x0404) << 3 - | (data & 0x0202) << 5 | (data & 0x0101) << 7; -} - -auto PPU::power() -> void { - create(Enter, 4 * 1024 * 1024); - - if(Model::GameBoyColor()) { - scanline = {&PPU::scanlineCGB, this}; - run = {&PPU::runCGB, this}; - } else { - scanline = {&PPU::scanlineDMG, this}; - run = {&PPU::runDMG, this}; - } - - for(uint n = 0x8000; n <= 0x9fff; n++) bus.mmio[n] = this; //VRAM - for(uint n = 0xfe00; n <= 0xfe9f; n++) bus.mmio[n] = this; //OAM - - bus.mmio[0xff40] = this; //LCDC - bus.mmio[0xff41] = this; //STAT - bus.mmio[0xff42] = this; //SCY - bus.mmio[0xff43] = this; //SCX - bus.mmio[0xff44] = this; //LY - bus.mmio[0xff45] = this; //LYC - bus.mmio[0xff46] = this; //DMA - bus.mmio[0xff47] = this; //BGP - bus.mmio[0xff48] = this; //OBP0 - bus.mmio[0xff49] = this; //OBP1 - bus.mmio[0xff4a] = this; //WY - bus.mmio[0xff4b] = this; //WX - - if(Model::GameBoyColor()) { - bus.mmio[0xff4f] = this; //VBK - bus.mmio[0xff68] = this; //BGPI - bus.mmio[0xff69] = this; //BGPD - bus.mmio[0xff6a] = this; //OBPI - bus.mmio[0xff6b] = this; //OBPD - } - - for(auto& n : vram) n = 0x00; - for(auto& n : oam) n = 0x00; - for(auto& n : bgp) n = 0x00; - for(auto& n : obp[0]) n = 3; - for(auto& n : obp[1]) n = 3; - for(auto& n : bgpd) n = 0x0000; - for(auto& n : obpd) n = 0x0000; - - status = {}; - - for(auto& n : screen) n = 0; - - bg.color = 0; - bg.palette = 0; - bg.priority = 0; - - ob.color = 0; - ob.palette = 0; - ob.priority = 0; - - for(auto& s : sprite) { - s.x = 0; - s.y = 0; - s.tile = 0; - s.attr = 0; - s.data = 0; - } - sprites = 0; - - background.attr = 0; - background.data = 0; - - window.attr = 0; - window.data = 0; -} - -} diff --git a/bsnes/gb/ppu/ppu.hpp b/bsnes/gb/ppu/ppu.hpp deleted file mode 100644 index 88454ad2..00000000 --- a/bsnes/gb/ppu/ppu.hpp +++ /dev/null @@ -1,132 +0,0 @@ -struct PPU : Thread, MMIO { - static auto Enter() -> void; - auto main() -> void; - auto stat() -> void; - auto coincidence() -> bool; - auto refresh() -> void; - auto step(uint clocks) -> void; - - auto hflip(uint data) const -> uint; - - //io.cpp - auto vramAddress(uint16 addr) const -> uint; - auto readIO(uint16 addr) -> uint8; - auto writeIO(uint16 addr, uint8 data) -> void; - - //dmg.cpp - auto readTileDMG(bool select, uint x, uint y, uint& data) -> void; - auto scanlineDMG() -> void; - auto runDMG() -> void; - auto runBackgroundDMG() -> void; - auto runWindowDMG() -> void; - auto runObjectsDMG() -> void; - - //cgb.cpp - auto readTileCGB(bool select, uint x, uint y, uint& attr, uint& data) -> void; - auto scanlineCGB() -> void; - auto runCGB() -> void; - auto runBackgroundCGB() -> void; - auto runWindowCGB() -> void; - auto runObjectsCGB() -> void; - - auto power() -> void; - - auto serialize(serializer&) -> void; - - uint8 vram[16384]; //GB = 8192, GBC = 16384 - uint8 oam[160]; - uint8 bgp[4]; - uint8 obp[2][4]; - uint8 bgpd[64]; - uint8 obpd[64]; - - function void> scanline; - function void> run; - - struct Status { - bool irq = 0; //STAT IRQ line - uint lx = 0; - - //$ff40 LCDC - bool displayEnable = 0; - bool windowTilemapSelect = 0; - bool windowDisplayEnable = 0; - bool bgTiledataSelect = 0; - bool bgTilemapSelect = 0; - bool obSize = 0; - bool obEnable = 0; - bool bgEnable = 0; - - //$ff41 STAT - bool interruptLYC = 0; - bool interruptOAM = 0; - bool interruptVblank = 0; - bool interruptHblank = 0; - uint2 mode; - - //$ff42 SCY - uint8 scy; - - //$ff43 SCX - uint8 scx; - - //$ff44 LY - uint8 ly; - - //$ff45 LYC - uint8 lyc; - - //$ff46 DMA - bool dmaActive = 0; - uint dmaClock = 0; - uint8 dmaBank; - - //$ff4a WY - uint8 wy; - - //$ff4b WX - uint8 wx; - - //$ff4f VBK - bool vramBank = 0; - - //$ff68 BGPI - bool bgpiIncrement = 0; - uint6 bgpi; - - //$ff6a OBPI - bool obpiIncrement = 0; - uint8 obpi; - } status; - - uint32 screen[160 * 144]; - - struct Pixel { - uint16 color; - uint8 palette; - bool priority = 0; - }; - Pixel bg; - Pixel ob; - - struct Sprite { - uint x = 0; - uint y = 0; - uint tile = 0; - uint attr = 0; - uint data = 0; - }; - Sprite sprite[10]; - uint sprites = 0; - - uint px = 0; - - struct Background { - uint attr = 0; - uint data = 0; - }; - Background background; - Background window; -}; - -extern PPU ppu; diff --git a/bsnes/gb/ppu/serialization.cpp b/bsnes/gb/ppu/serialization.cpp deleted file mode 100644 index 2655c919..00000000 --- a/bsnes/gb/ppu/serialization.cpp +++ /dev/null @@ -1,74 +0,0 @@ -auto PPU::serialize(serializer& s) -> void { - Thread::serialize(s); - - s.array(vram); - s.array(oam); - s.array(bgp); - s.array(obp[0]); - s.array(obp[1]); - s.array(bgpd); - s.array(obpd); - - s.integer(status.irq); - s.integer(status.lx); - - s.integer(status.displayEnable); - s.integer(status.windowTilemapSelect); - s.integer(status.windowDisplayEnable); - s.integer(status.bgTiledataSelect); - s.integer(status.bgTilemapSelect); - s.integer(status.obSize); - s.integer(status.obEnable); - s.integer(status.bgEnable); - - s.integer(status.interruptLYC); - s.integer(status.interruptOAM); - s.integer(status.interruptVblank); - s.integer(status.interruptHblank); - s.integer(status.mode); - - s.integer(status.scy); - s.integer(status.scx); - - s.integer(status.ly); - s.integer(status.lyc); - - s.integer(status.dmaActive); - s.integer(status.dmaClock); - s.integer(status.dmaBank); - - s.integer(status.wy); - s.integer(status.wx); - - s.integer(status.vramBank); - - s.integer(status.bgpiIncrement); - s.integer(status.bgpi); - - s.integer(status.obpiIncrement); - s.integer(status.obpi); - - s.array(screen); - - s.integer(bg.color); - s.integer(bg.palette); - s.integer(bg.priority); - - s.integer(ob.color); - s.integer(ob.palette); - s.integer(ob.priority); - - for(auto& o : sprite) { - s.integer(o.x); - s.integer(o.y); - s.integer(o.tile); - s.integer(o.attr); - } - s.integer(sprites); - - s.integer(background.attr); - s.integer(background.data); - - s.integer(window.attr); - s.integer(window.data); -} diff --git a/bsnes/gb/system/serialization.cpp b/bsnes/gb/system/serialization.cpp deleted file mode 100644 index 3af96d27..00000000 --- a/bsnes/gb/system/serialization.cpp +++ /dev/null @@ -1,59 +0,0 @@ -auto System::serialize() -> serializer { - serializer s(_serializeSize); - - uint signature = 0x31545342; - char version[16] = {0}; - char description[512] = {0}; - memory::copy(&version, (const char*)Emulator::SerializerVersion, Emulator::SerializerVersion.size()); - - s.integer(signature); - s.array(version); - s.array(description); - - serializeAll(s); - return s; -} - -auto System::unserialize(serializer& s) -> bool { - uint signature; - char version[16] = {0}; - char description[512]; - - s.integer(signature); - s.array(version); - s.array(description); - - if(signature != 0x31545342) return false; - if(string{version} != Emulator::SerializerVersion) return false; - - power(); - serializeAll(s); - return true; -} - -auto System::serialize(serializer& s) -> void { - s.integer(_clocksExecuted); -} - -auto System::serializeAll(serializer& s) -> void { - cartridge.serialize(s); - system.serialize(s); - cpu.serialize(s); - ppu.serialize(s); - apu.serialize(s); -} - -auto System::serializeInit() -> void { - serializer s; - - uint signature = 0; - char version[16] = {0}; - char description[512] = {0}; - - s.integer(signature); - s.array(version); - s.array(description); - - serializeAll(s); - _serializeSize = s.size(); -} diff --git a/bsnes/gb/system/system.cpp b/bsnes/gb/system/system.cpp deleted file mode 100644 index 287e60dc..00000000 --- a/bsnes/gb/system/system.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include - -namespace GameBoy { - -#include "serialization.cpp" -System system; -Scheduler scheduler; -Cheat cheat; - -auto System::run() -> void { - if(scheduler.enter() == Scheduler::Event::Frame) ppu.refresh(); -} - -auto System::runToSave() -> void { - scheduler.synchronize(cpu); - scheduler.synchronize(ppu); - scheduler.synchronize(apu); - scheduler.synchronize(cartridge); -} - -auto System::init() -> void { - assert(interface != nullptr); -} - -auto System::load(Emulator::Interface* interface, Model model_, maybe systemID) -> bool { - _model = model_; - - if(model() == Model::GameBoy) { - if(auto fp = platform->open(ID::System, "manifest.bml", File::Read, File::Required)) { - information.manifest = fp->reads(); - } else return false; - - auto document = BML::unserialize(information.manifest); - if(auto name = document["system/cpu/rom/name"].text()) { - if(auto fp = platform->open(ID::System, name, File::Read, File::Required)) { - fp->read(bootROM.dmg, 256); - } - } - } - - if(model() == Model::GameBoyColor) { - if(auto fp = platform->open(ID::System, "manifest.bml", File::Read, File::Required)) { - information.manifest = fp->reads(); - } else return false; - - auto document = BML::unserialize(information.manifest); - if(auto name = document["system/cpu/rom/name"].text()) { - if(auto fp = platform->open(ID::System, name, File::Read, File::Required)) { - fp->read(bootROM.cgb, 2048); - } - } - } - - if(model() == Model::SuperGameBoy) { - if(auto fp = platform->open(systemID(), "manifest.bml", File::Read, File::Required)) { - information.manifest = fp->reads(); - } else return false; - - auto document = BML::unserialize(information.manifest); - if(auto memory = Emulator::Game::Memory{document["game/board/memory(type=ROM,content=Boot,architecture=LR35902)"]}) { - if(auto fp = platform->open(systemID(), memory.name(), File::Read, File::Required)) { - fp->read(bootROM.sgb, 256); - } - } - } - - if(!cartridge.load()) return false; - serializeInit(); - this->interface = interface; - return _loaded = true; -} - -auto System::save() -> void { - if(!loaded()) return; - cartridge.save(); -} - -auto System::unload() -> void { - if(!loaded()) return; - cartridge.unload(); - _loaded = false; -} - -auto System::power() -> void { - if(model() != Model::SuperGameBoy) { - Emulator::video.reset(interface); - Emulator::video.setPalette(); - Emulator::audio.reset(interface); - } - - scheduler.reset(); - bus.power(); - cartridge.power(); - cpu.power(); - ppu.power(); - apu.power(); - scheduler.primary(cpu); - - _clocksExecuted = 0; -} - -} diff --git a/bsnes/gb/system/system.hpp b/bsnes/gb/system/system.hpp deleted file mode 100644 index 957a7c32..00000000 --- a/bsnes/gb/system/system.hpp +++ /dev/null @@ -1,61 +0,0 @@ -enum class Input : uint { - Up, Down, Left, Right, B, A, Select, Start, -}; - -struct System { - enum class Model : uint { - GameBoy, - GameBoyColor, - SuperGameBoy, - }; - - inline auto loaded() const -> bool { return _loaded; } - inline auto model() const -> Model { return _model; } - inline auto clocksExecuted() const -> uint { return _clocksExecuted; } - - auto run() -> void; - auto runToSave() -> void; - - auto init() -> void; - auto load(Emulator::Interface*, Model, maybe = nothing) -> bool; - auto save() -> void; - auto unload() -> void; - auto power() -> void; - - //video.cpp - auto configureVideoPalette() -> void; - auto configureVideoEffects() -> void; - - //serialization.cpp - auto serialize() -> serializer; - auto unserialize(serializer&) -> bool; - - auto serialize(serializer&) -> void; - auto serializeAll(serializer&) -> void; - auto serializeInit() -> void; - - Emulator::Interface* interface = nullptr; - - struct BootROM { - uint8 dmg[ 256]; - uint8 sgb[ 256]; - uint8 cgb[2048]; - } bootROM; - - struct Information { - string manifest; - } information; - - bool _loaded = false; - Model _model = Model::GameBoy; - uint _serializeSize = 0; - uint _clocksExecuted = 0; -}; - -#include - -extern System system; - -auto Model::GameBoy() -> bool { return system.model() == System::Model::GameBoy; } -auto Model::GameBoyColor() -> bool { return system.model() == System::Model::GameBoyColor; } -auto Model::SuperGameBoy() -> bool { return system.model() == System::Model::SuperGameBoy; } diff --git a/bsnes/processor/sm83/instructions.cpp b/bsnes/processor/sm83/instructions.cpp index 66693160..df96d94f 100644 --- a/bsnes/processor/sm83/instructions.cpp +++ b/bsnes/processor/sm83/instructions.cpp @@ -138,7 +138,7 @@ auto SM83::instructionEI() -> void { auto SM83::instructionHALT() -> void { r.halt = 1; - while(r.halt) idle(); + while(r.halt) halt(); } auto SM83::instructionINC_Direct(uint8& data) -> void { @@ -428,9 +428,9 @@ auto SM83::instructionSRL_Indirect(uint16& address) -> void { } auto SM83::instructionSTOP() -> void { - if(stop()) return; + if(!stoppable()) return; r.stop = 1; - while(r.stop) idle(); + while(r.stop) stop(); } auto SM83::instructionSUB_Direct_Data(uint8& target) -> void { diff --git a/bsnes/processor/sm83/sm83.hpp b/bsnes/processor/sm83/sm83.hpp index d608c984..28da1a35 100644 --- a/bsnes/processor/sm83/sm83.hpp +++ b/bsnes/processor/sm83/sm83.hpp @@ -9,10 +9,12 @@ namespace Processor { struct SM83 { + virtual auto stoppable() -> bool = 0; + virtual auto stop() -> void = 0; + virtual auto halt() -> void = 0; virtual auto idle() -> void = 0; virtual auto read(uint16 address) -> uint8 = 0; virtual auto write(uint16 address, uint8 data) -> void = 0; - virtual auto stop() -> bool = 0; //lr35902.cpp auto power() -> void; diff --git a/bsnes/processor/wdc65816/algorithms.cpp b/bsnes/processor/wdc65816/algorithms.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/disassembler.cpp b/bsnes/processor/wdc65816/disassembler.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/instructions-modify.cpp b/bsnes/processor/wdc65816/instructions-modify.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/instructions-other.cpp b/bsnes/processor/wdc65816/instructions-other.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/instructions-pc.cpp b/bsnes/processor/wdc65816/instructions-pc.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/instructions-read.cpp b/bsnes/processor/wdc65816/instructions-read.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/instructions-write.cpp b/bsnes/processor/wdc65816/instructions-write.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/serialization.cpp b/bsnes/processor/wdc65816/serialization.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/wdc65816.cpp b/bsnes/processor/wdc65816/wdc65816.cpp old mode 100644 new mode 100755 diff --git a/bsnes/processor/wdc65816/wdc65816.hpp b/bsnes/processor/wdc65816/wdc65816.hpp old mode 100644 new mode 100755 diff --git a/bsnes/sfc/cartridge/cartridge.cpp b/bsnes/sfc/cartridge/cartridge.cpp index 0a1cd60e..3f574b38 100644 --- a/bsnes/sfc/cartridge/cartridge.cpp +++ b/bsnes/sfc/cartridge/cartridge.cpp @@ -101,14 +101,6 @@ auto Cartridge::load() -> bool { return true; } -auto Cartridge::loadGameBoy() -> bool { - //invoked from ICD::load() - information.sha256 = GameBoy::cartridge.hash(); - slotGameBoy.load(GameBoy::cartridge.manifest()); - loadCartridgeGameBoy(slotGameBoy.document); - return true; -} - auto Cartridge::loadBSMemory() -> bool { if(auto fp = platform->open(bsmemory.pathID, "manifest.bml", File::Read, File::Required)) { slotBSMemory.load(fp->reads()); diff --git a/bsnes/sfc/cartridge/cartridge.hpp b/bsnes/sfc/cartridge/cartridge.hpp index d6b821b2..867bafea 100644 --- a/bsnes/sfc/cartridge/cartridge.hpp +++ b/bsnes/sfc/cartridge/cartridge.hpp @@ -59,7 +59,6 @@ private: Markup::Node board; //cartridge.cpp - auto loadGameBoy() -> bool; auto loadBSMemory() -> bool; auto loadSufamiTurboA() -> bool; auto loadSufamiTurboB() -> bool; @@ -67,7 +66,6 @@ private: //load.cpp auto loadBoard(string) -> Markup::Node; auto loadCartridge(Markup::Node) -> void; - auto loadCartridgeGameBoy(Markup::Node) -> void; auto loadCartridgeBSMemory(Markup::Node) -> void; auto loadCartridgeSufamiTurboA(Markup::Node) -> void; auto loadCartridgeSufamiTurboB(Markup::Node) -> void; diff --git a/bsnes/sfc/cartridge/load.cpp b/bsnes/sfc/cartridge/load.cpp index f313abd3..0f94f43e 100644 --- a/bsnes/sfc/cartridge/load.cpp +++ b/bsnes/sfc/cartridge/load.cpp @@ -72,9 +72,6 @@ auto Cartridge::loadCartridge(Markup::Node node) -> void { if(auto fp = platform->open(pathID(), "msu1/data.rom", File::Read)) loadMSU1(); } -auto Cartridge::loadCartridgeGameBoy(Markup::Node node) -> void { -} - auto Cartridge::loadCartridgeBSMemory(Markup::Node node) -> void { if(auto memory = Emulator::Game::Memory{node["game/board/memory(content=Program)"]}) { bsmemory.ROM = memory.type == "ROM"; @@ -446,8 +443,14 @@ auto Cartridge::loadHitachiDSP(Markup::Node node, uint roms) -> void { if(auto memory = node["memory(type=ROM,content=Data,architecture=HG51BS169)"]) { if(auto file = game.memory(memory)) { - if(auto fp = platform->open(ID::SuperFamicom, file->name(), File::Read, File::Required)) { + if(auto fp = platform->open(ID::SuperFamicom, file->name(), File::Read)) { for(auto n : range(1 * 1024)) hitachidsp.dataROM[n] = fp->readl(3); + } else { + for(auto n : range(1 * 1024)) { + hitachidsp.dataROM[n] = hitachidsp.staticDataROM[n * 3 + 0] << 0; + hitachidsp.dataROM[n] |= hitachidsp.staticDataROM[n * 3 + 1] << 8; + hitachidsp.dataROM[n] |= hitachidsp.staticDataROM[n * 3 + 2] << 16; + } } } } diff --git a/bsnes/sfc/coprocessor/hitachidsp/data-rom.cpp b/bsnes/sfc/coprocessor/hitachidsp/data-rom.cpp new file mode 100644 index 00000000..6d1d0e38 --- /dev/null +++ b/bsnes/sfc/coprocessor/hitachidsp/data-rom.cpp @@ -0,0 +1,100 @@ +/* note: this is not copyrightable, as it is purely math tables such as sin and cos */ + +const uint8_t HitachiDSP::staticDataROM[3072] = { + 255,255,255,0,0,128,0,0,64,170,170,42,0,0,32,153,153,25,85,85,21,36,73,18,0,0,16,227,56,14,204,204, + 12,232,162,11,170,170,10,157,216,9,146,36,9,136,136,8,0,0,8,135,135,7,113,28,7,161,188,6,102,102,6,97, + 24,6,116,209,5,178,144,5,85,85,5,184,30,5,78,236,4,161,189,4,73,146,4,238,105,4,68,68,4,8,33,4, + 0,0,4,248,224,3,195,195,3,58,168,3,56,142,3,159,117,3,80,94,3,52,72,3,51,51,3,56,31,3,48,12, + 3,11,250,2,186,232,2,45,216,2,89,200,2,49,185,2,170,170,2,188,156,2,92,143,2,130,130,2,39,118,2,67, + 106,2,208,94,2,200,83,2,36,73,2,224,62,2,247,52,2,99,43,2,34,34,2,46,25,2,132,16,2,32,8,2, + 0,0,2,31,248,1,124,240,1,19,233,1,225,225,1,230,218,1,29,212,1,133,205,1,28,199,1,224,192,1,207,186, + 1,232,180,1,40,175,1,142,169,1,26,164,1,200,158,1,153,153,1,139,148,1,156,143,1,203,138,1,24,134,1,129, + 129,1,5,125,1,164,120,1,93,116,1,46,112,1,22,108,1,22,104,1,44,100,1,88,96,1,152,92,1,237,88,1, + 85,85,1,208,81,1,94,78,1,253,74,1,174,71,1,111,68,1,65,65,1,34,62,1,19,59,1,19,56,1,33,53, + 1,62,50,1,104,47,1,159,44,1,228,41,1,53,39,1,146,36,1,251,33,1,112,31,1,240,28,1,123,26,1,17, + 24,1,177,21,1,92,19,1,17,17,1,207,14,1,151,12,1,104,10,1,66,8,1,36,6,1,16,4,1,4,2,1, + 0,0,1,3,254,0,15,252,0,35,250,0,62,248,0,96,246,0,137,244,0,185,242,0,240,240,0,46,239,0,115,237, + 0,189,235,0,14,234,0,101,232,0,194,230,0,37,229,0,142,227,0,252,225,0,112,224,0,233,222,0,103,221,0,235, + 219,0,116,218,0,1,217,0,148,215,0,43,214,0,199,212,0,104,211,0,13,210,0,182,208,0,100,207,0,22,206,0, + 204,204,0,135,203,0,69,202,0,7,201,0,206,199,0,152,198,0,101,197,0,55,196,0,12,195,0,228,193,0,192,192, + 0,160,191,0,130,190,0,105,189,0,82,188,0,62,187,0,46,186,0,33,185,0,23,184,0,15,183,0,11,182,0,9, + 181,0,11,180,0,15,179,0,22,178,0,31,177,0,44,176,0,58,175,0,76,174,0,96,173,0,118,172,0,143,171,0, + 170,170,0,200,169,0,232,168,0,10,168,0,47,167,0,85,166,0,126,165,0,169,164,0,215,163,0,6,163,0,55,162, + 0,107,161,0,160,160,0,216,159,0,17,159,0,76,158,0,137,157,0,200,156,0,9,156,0,76,155,0,144,154,0,215, + 153,0,31,153,0,104,152,0,180,151,0,1,151,0,79,150,0,160,149,0,242,148,0,69,148,0,154,147,0,241,146,0, + 73,146,0,162,145,0,253,144,0,90,144,0,184,143,0,23,143,0,120,142,0,218,141,0,61,141,0,162,140,0,8,140, + 0,112,139,0,216,138,0,66,138,0,174,137,0,26,137,0,136,136,0,247,135,0,103,135,0,217,134,0,75,134,0,191, + 133,0,52,133,0,169,132,0,33,132,0,153,131,0,18,131,0,140,130,0,8,130,0,132,129,0,2,129,0,128,128,0, + 0,0,0,0,0,16,158,160,22,122,182,27,0,0,32,239,198,35,28,49,39,255,84,42,60,65,45,0,0,48,176,152, + 50,229,16,53,245,108,55,86,176,57,212,221,59,189,247,61,0,0,64,61,248,65,219,225,67,12,190,69,222,141,71,58, + 82,73,241,11,75,185,187,76,56,98,78,0,0,80,149,149,81,112,35,83,254,169,84,162,41,86,183,162,87,144,21,89, + 121,130,90,186,233,91,148,75,93,67,168,94,0,0,96,254,82,97,112,161,98,131,235,99,96,49,101,50,115,102,29,177, + 103,68,235,104,202,33,106,205,84,107,108,132,108,194,176,109,235,217,110,0,0,112,24,35,113,74,67,114,173,96,115,84, + 123,116,84,147,117,191,168,118,168,187,119,31,204,120,52,218,121,249,229,122,122,239,123,200,246,124,239,251,125,253,254,126, + 0,0,128,1,255,128,15,252,129,52,247,130,123,240,131,238,231,132,152,221,133,130,209,134,182,195,135,61,180,136,31,163, + 137,102,144,138,25,124,139,65,102,140,228,78,141,11,54,142,188,27,143,0,0,144,219,226,144,86,196,145,117,164,146,65, + 131,147,189,96,148,241,60,149,226,23,150,150,241,150,17,202,151,89,161,152,115,119,153,100,76,154,49,32,155,222,242,155, + 112,196,156,235,148,157,84,100,158,175,50,159,0,0,160,74,204,160,146,151,161,220,97,162,42,43,163,130,243,163,230,186, + 164,90,129,165,225,70,166,126,11,167,53,207,167,9,146,168,253,83,169,19,21,170,80,213,170,180,148,171,69,83,172,3, + 17,173,242,205,173,21,138,174,110,69,175,0,0,176,204,185,176,214,114,177,32,43,178,172,226,178,124,153,179,147,79,180, + 243,4,181,157,185,181,149,109,182,220,32,183,117,211,183,96,133,184,160,54,185,56,231,185,40,151,186,115,70,187,26,245, + 187,32,163,188,134,80,189,78,253,189,121,169,190,9,85,191,0,0,192,95,170,192,40,84,193,92,253,193,253,165,194,13, + 78,195,140,245,195,125,156,196,225,66,197,184,232,197,5,142,198,201,50,199,6,215,199,187,122,200,235,29,201,152,192,201, + 193,98,202,105,4,203,145,165,203,58,70,204,100,230,204,18,134,205,68,37,206,252,195,206,58,98,207,0,0,208,78,157, + 208,38,58,209,137,214,209,119,114,210,243,13,211,252,168,211,148,67,212,188,221,212,116,119,213,190,16,214,155,169,214,11, + 66,215,15,218,215,169,113,216,216,8,217,159,159,217,254,53,218,245,203,218,133,97,219,176,246,219,118,139,220,216,31,221, + 215,179,221,115,71,222,173,218,222,134,109,223,0,0,224,25,146,224,212,35,225,48,181,225,48,70,226,210,214,226,25,103, + 227,4,247,227,148,134,228,203,21,229,168,164,229,45,51,230,90,193,230,47,79,231,173,220,231,214,105,232,169,246,232,38, + 131,233,80,15,234,38,155,234,168,38,235,217,177,235,183,60,236,67,199,236,127,81,237,106,219,237,6,101,238,82,238,238, + 80,119,239,0,0,240,97,136,240,118,16,241,62,152,241,186,31,242,234,166,242,207,45,243,105,180,243,185,58,244,192,192, + 244,125,70,245,242,203,245,30,81,246,2,214,246,159,90,247,245,222,247,5,99,248,206,230,248,82,106,249,144,237,249,138, + 112,250,63,243,250,177,117,251,223,247,251,202,121,252,114,251,252,216,124,253,251,253,253,222,126,254,127,255,254,223,127,255, + 0,0,0,58,36,3,85,72,6,50,108,9,178,143,12,183,178,15,32,213,18,208,246,21,166,23,25,133,55,28,78,86, + 31,225,115,34,32,144,37,237,170,40,40,196,43,179,219,46,112,241,49,64,5,53,4,23,56,159,38,59,242,51,62,224, + 62,65,73,71,68,16,77,71,24,80,74,67,80,77,114,77,80,137,71,83,105,62,86,247,49,89,20,34,92,164,14,95, + 138,247,97,169,220,100,229,189,103,32,155,106,64,116,109,39,73,112,186,25,115,221,229,117,116,173,120,101,112,123,147,46, + 126,228,231,128,60,156,131,130,75,134,154,245,136,107,154,139,217,57,142,204,211,144,42,104,147,217,246,149,191,127,152,197, + 2,155,209,127,157,202,246,159,153,103,162,36,210,164,85,54,167,20,148,169,73,235,171,221,59,174,186,133,176,201,200,178, + 243,4,181,34,58,183,65,104,185,58,143,187,249,174,189,103,199,191,112,216,193,0,226,195,3,228,197,101,222,199,18,209, + 201,247,187,203,2,159,205,31,122,207,61,77,209,72,24,211,49,219,212,228,149,214,82,72,216,105,242,217,26,148,219,83, + 45,221,5,190,222,33,70,224,151,197,225,89,60,227,89,170,228,135,15,230,215,107,231,59,191,232,166,9,234,11,75,235, + 94,131,236,147,178,237,157,216,238,115,245,239,8,9,241,82,19,242,71,20,243,221,11,244,10,250,244,198,222,245,7,186, + 246,197,139,247,247,83,248,151,18,249,157,199,249,1,115,250,190,20,251,205,172,251,39,59,252,201,191,252,171,58,253,203, + 171,253,35,19,254,175,112,254,109,196,254,87,14,255,109,78,255,171,132,255,15,177,255,151,211,255,67,236,255,16,251,255, + 0,0,0,249,162,0,246,69,1,248,232,1,1,140,2,20,47,3,52,210,3,100,117,4,165,24,5,251,187,5,104,95, + 6,239,2,7,146,166,7,84,74,8,56,238,8,64,146,9,110,54,10,199,218,10,76,127,11,1,36,12,231,200,12,2, + 110,13,85,19,14,227,184,14,174,94,15,185,4,16,8,171,16,158,81,17,125,248,17,169,159,18,37,71,19,244,238,19, + 25,151,20,153,63,21,117,232,21,178,145,22,83,59,23,92,229,23,209,143,24,180,58,25,10,230,25,216,145,26,32,62, + 27,231,234,27,49,152,28,2,70,29,95,244,29,76,163,30,206,82,31,234,2,32,163,179,32,0,101,33,5,23,34,184, + 201,34,30,125,35,60,49,36,24,230,36,185,155,37,36,82,38,95,9,39,113,193,39,97,122,40,54,52,41,246,238,41, + 170,170,42,89,103,43,10,37,44,199,227,44,152,163,45,133,100,46,153,38,47,220,233,47,89,174,48,27,116,49,44,59, + 50,152,3,51,107,205,51,177,152,52,120,101,53,206,51,54,193,3,55,96,213,55,187,168,56,228,125,57,236,84,58,230, + 45,59,230,8,60,1,230,60,77,197,61,227,166,62,220,138,63,82,113,64,98,90,65,44,70,66,208,52,67,113,38,68, + 55,27,69,74,19,70,214,14,71,12,14,72,32,17,73,76,24,74,205,35,75,234,51,76,236,72,77,39,99,78,249,130, + 79,201,168,80,10,213,81,63,8,83,252,66,84,234,133,85,204,209,86,130,39,88,21,136,89,188,244,90,237,110,92,108, + 248,93,105,147,95,163,66,97,165,9,99,30,237,100,129,243,102,23,38,105,34,147,107,165,82,110,124,147,113,180,206,117, + 0,0,0,36,3,0,72,6,0,109,9,0,147,12,0,186,15,0,226,18,0,11,22,0,54,25,0,99,28,0,147,31, + 0,196,34,0,249,37,0,48,41,0,107,44,0,169,47,0,235,50,0,50,54,0,124,57,0,203,60,0,31,64,0,121, + 67,0,216,70,0,61,74,0,168,77,0,25,81,0,146,84,0,17,88,0,153,91,0,40,95,0,192,98,0,96,102,0, + 9,106,0,188,109,0,122,113,0,65,117,0,20,121,0,242,124,0,220,128,0,210,132,0,213,136,0,230,140,0,5,145, + 0,51,149,0,112,153,0,190,157,0,28,162,0,139,166,0,13,171,0,162,175,0,75,180,0,9,185,0,220,189,0,198, + 194,0,200,199,0,227,204,0,24,210,0,103,215,0,211,220,0,93,226,0,6,232,0,207,237,0,187,243,0,202,249,0, + 0,0,1,92,6,1,226,12,1,148,19,1,115,26,1,131,33,1,198,40,1,62,48,1,239,55,1,220,63,1,8,72, + 1,119,80,1,45,89,1,45,98,1,125,107,1,34,117,1,33,127,1,128,137,1,68,148,1,118,159,1,28,171,1,62, + 183,1,231,195,1,31,209,1,241,222,1,105,237,1,149,252,1,131,12,2,68,29,2,233,46,2,134,65,2,51,85,2, + 9,106,2,37,128,2,167,151,2,181,176,2,120,203,2,35,232,2,236,6,3,21,40,3,235,75,3,198,114,3,16,157, + 3,71,203,3,2,254,3,247,53,4,5,116,4,63,185,4,255,6,5,249,94,5,93,195,5,9,55,6,207,189,6,230, + 92,7,151,27,8,109,4,9,54,39,10,198,156,11,129,142,13,233,70,16,255,90,20,113,38,27,72,188,40,181,123,81, + 255,255,255,16,251,255,67,236,255,151,211,255,15,177,255,171,132,255,109,78,255,87,14,255,109,196,254,175,112,254,35,19, + 254,203,171,253,171,58,253,201,191,252,39,59,252,205,172,251,190,20,251,1,115,250,157,199,249,151,18,249,247,83,248,197, + 139,247,7,186,246,198,222,245,10,250,244,221,11,244,71,20,243,82,19,242,8,9,241,115,245,239,157,216,238,147,178,237, + 94,131,236,11,75,235,166,9,234,59,191,232,215,107,231,135,15,230,89,170,228,89,60,227,151,197,225,33,70,224,5,190, + 222,83,45,221,26,148,219,105,242,217,82,72,216,228,149,214,49,219,212,72,24,211,61,77,209,31,122,207,2,159,205,247, + 187,203,18,209,201,101,222,199,3,228,197,0,226,195,112,216,193,103,199,191,249,174,189,58,143,187,65,104,185,34,58,183, + 243,4,181,201,200,178,186,133,176,221,59,174,73,235,171,20,148,169,85,54,167,36,210,164,153,103,162,202,246,159,209,127, + 157,197,2,155,191,127,152,217,246,149,42,104,147,204,211,144,217,57,142,107,154,139,154,245,136,130,75,134,60,156,131,228, + 231,128,147,46,126,101,112,123,116,173,120,221,229,117,186,25,115,39,73,112,64,116,109,32,155,106,229,189,103,169,220,100, + 138,247,97,164,14,95,20,34,92,247,49,89,105,62,86,137,71,83,114,77,80,67,80,77,24,80,74,16,77,71,73,71, + 68,224,62,65,242,51,62,159,38,59,4,23,56,64,5,53,112,241,49,179,219,46,40,196,43,237,170,40,32,144,37,225, + 115,34,78,86,31,133,55,28,166,23,25,208,246,21,32,213,18,183,178,15,178,143,12,50,108,9,85,72,6,58,36,3, +}; diff --git a/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.cpp b/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.cpp index 7ea055d2..8aa6b5e9 100644 --- a/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.cpp +++ b/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.cpp @@ -4,6 +4,7 @@ namespace SuperFamicom { #include "memory.cpp" #include "serialization.cpp" +#include "data-rom.cpp" HitachiDSP hitachidsp; auto HitachiDSP::Enter() -> void { diff --git a/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.hpp b/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.hpp index 2b5fd18b..afc0475a 100644 --- a/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.hpp +++ b/bsnes/sfc/coprocessor/hitachidsp/hitachidsp.hpp @@ -43,6 +43,9 @@ struct HitachiDSP : Processor::HG51B, Thread { uint Frequency; uint Roms; bool Mapping; + + //data-rom.cpp + static const uint8_t staticDataROM[3072]; }; extern HitachiDSP hitachidsp; diff --git a/bsnes/sfc/coprocessor/icd/icd.cpp b/bsnes/sfc/coprocessor/icd/icd.cpp index 56670342..7d93a4bc 100644 --- a/bsnes/sfc/coprocessor/icd/icd.cpp +++ b/bsnes/sfc/coprocessor/icd/icd.cpp @@ -3,22 +3,48 @@ namespace SuperFamicom { ICD icd; - -#include "platform.cpp" #include "interface.cpp" #include "io.cpp" #include "boot-roms.cpp" #include "serialization.cpp" namespace SameBoy { - static auto rgbEncode(GB_gameboy_t*, uint8_t r, uint8_t g, uint8_t b) -> uint32_t { + static auto hreset(GB_gameboy_t*) -> void { + icd.ly++; + icd.ppuScanline(); + } + + static auto vreset(GB_gameboy_t*) -> void { + icd.ly = 0; + icd.ppuScanline(); + } + + static auto icd_pixel(GB_gameboy_t*, uint8_t pixel) -> void { + icd.ppuOutput(pixel); + } + + static auto joyp_write(GB_gameboy_t*, uint8_t value) -> void { + bool p14 = value & 0x10; + bool p15 = value & 0x20; + icd.joypWrite(p14, p15); + } + + static auto rgb_encode(GB_gameboy_t*, uint8_t r, uint8_t g, uint8_t b) -> uint32_t { return r << 16 | g << 8 | b << 0; } + + static auto sample(GB_gameboy_t*, GB_sample_t* sample) -> void { + float left = sample->left / 32768.0f; + float right = sample->right / 32768.0f; + icd.apuOutput(left, right); + } + + static auto vblank(GB_gameboy_t*) -> void { + } } auto ICD::Enter() -> void { while(true) { - if(scheduler.synchronizing()) GameBoy::system.runToSave(); scheduler.synchronize(); icd.main(); } @@ -26,12 +52,11 @@ auto ICD::Enter() -> void { auto ICD::main() -> void { if(r6003 & 0x80) { - GameBoy::system.run(); - step(GameBoy::system._clocksExecuted); - GameBoy::system._clocksExecuted = 0; + auto clocks = GB_run(&sameboy); + step(clocks >> 1); } else { //DMG halted stream->sample(float(0.0), float(0.0)); - step(2); //two clocks per audio sample + step(128); } synchronize(cpu); } @@ -40,40 +65,50 @@ auto ICD::load() -> bool { information = {}; GB_random_set_enabled(false); - GB_init(&sameboy, GB_MODEL_DMG_B); if(Frequency == 0) { - GB_load_boot_rom_from_buffer(&sameboy, (const unsigned char*)&SGB1BootROM, 256); + GB_init(&sameboy, GB_MODEL_SGB_NO_SFC); + GB_load_boot_rom_from_buffer(&sameboy, (const unsigned char*)&SGB1BootROM[0], 256); + GB_set_sample_rate(&sameboy, uint(system.cpuFrequency() / 5.0 / 128.0)); } else { - GB_load_boot_rom_from_buffer(&sameboy, (const unsigned char*)&SGB2BootROM, 256); + GB_init(&sameboy, GB_MODEL_SGB2_NO_SFC); + GB_load_boot_rom_from_buffer(&sameboy, (const unsigned char*)&SGB2BootROM[0], 256); + GB_set_sample_rate(&sameboy, uint(Frequency / 5.0 / 128.0)); } - GB_set_pixels_output(&sameboy, bitmap); - GB_set_rgb_encode_callback(&sameboy, SameBoy::rgbEncode); + GB_set_highpass_filter_mode(&sameboy, GB_HIGHPASS_ACCURATE); + GB_set_icd_hreset_callback(&sameboy, &SameBoy::hreset); + GB_set_icd_vreset_callback(&sameboy, &SameBoy::vreset); + GB_set_icd_pixel_callback(&sameboy, &SameBoy::icd_pixel); + GB_set_joyp_write_callback(&sameboy, &SameBoy::joyp_write); + GB_set_rgb_encode_callback(&sameboy, &SameBoy::rgb_encode); + GB_apu_set_sample_callback(&sameboy, &SameBoy::sample); + GB_set_vblank_callback(&sameboy, &SameBoy::vblank); + GB_set_pixels_output(&sameboy, &bitmap[0]); if(auto loaded = platform->load(ID::GameBoy, "Game Boy", "gb")) { information.pathID = loaded.pathID; - } else return false; + } else return unload(), false; + if(auto fp = platform->open(pathID(), "manifest.bml", File::Read, File::Required)) { + auto manifest = fp->reads(); + cartridge.slotGameBoy.load(manifest); + } else return unload(), false; if(auto fp = platform->open(pathID(), "program.rom", File::Read, File::Required)) { auto size = fp->size(); auto data = (uint8_t*)malloc(size); + cartridge.information.sha256 = Hash::SHA256({data, (uint64_t)size}).digest(); fp->read(data, size); GB_load_rom_from_buffer(&sameboy, data, size); - } else return false; - GameBoy::superGameBoy = this; - GameBoy::system.load(&gameBoyInterface, GameBoy::System::Model::SuperGameBoy, cartridge.pathID()); - return cartridge.loadGameBoy(); + } else return unload(), false; + ly = 0; + return true; } auto ICD::unload() -> void { GB_free(&sameboy); - GameBoy::system.save(); - GameBoy::system.unload(); } auto ICD::power() -> void { //SGB1 uses CPU oscillator; SGB2 uses dedicated oscillator create(ICD::Enter, (Frequency ? Frequency : system.cpuFrequency()) / 5.0); - stream = Emulator::audio.createStream(2, frequency() / 2.0); - stream->addHighPassFilter(20.0, Emulator::Filter::Order::First); - stream->addDCRemovalFilter(); + stream = Emulator::audio.createStream(2, uint((Frequency ? Frequency : system.cpuFrequency()) / 5.0 / 128.0)); r6003 = 0x00; r6004 = 0xff; @@ -95,8 +130,7 @@ auto ICD::power() -> void { joyp14Lock = 0; pulseLock = true; - GameBoy::system.init(); - GameBoy::system.power(); + GB_reset(&sameboy); } auto ICD::reset() -> void { @@ -122,8 +156,7 @@ auto ICD::reset() -> void { joyp14Lock = 0; pulseLock = true; - GameBoy::system.init(); - GameBoy::system.power(); + GB_reset(&sameboy); } } diff --git a/bsnes/sfc/coprocessor/icd/icd.hpp b/bsnes/sfc/coprocessor/icd/icd.hpp index 4c92202f..4aa6a714 100644 --- a/bsnes/sfc/coprocessor/icd/icd.hpp +++ b/bsnes/sfc/coprocessor/icd/icd.hpp @@ -1,4 +1,4 @@ -struct ICD : Emulator::Platform, GameBoy::SuperGameBoyInterface, Thread { +struct ICD : Emulator::Platform, Thread { shared_pointer stream; inline auto pathID() const -> uint { return information.pathID; } @@ -11,15 +11,11 @@ struct ICD : Emulator::Platform, GameBoy::SuperGameBoyInterface, Thread { auto power() -> void; auto reset() -> void; //software reset - //platform.cpp - auto audioSample(const float* samples, uint channels) -> void override; - auto inputPoll(uint port, uint device, uint id) -> int16 override; - //interface.cpp - auto lcdScanline() -> void override; - auto lcdOutput(uint2 color) -> void override; - auto joypRead() -> uint4 override; - auto joypWrite(bool p15, bool p14) -> void override; + auto ppuScanline() -> void; + auto ppuOutput(uint2 color) -> void; + auto apuOutput(float left, float right) -> void; + auto joypWrite(bool p14, bool p15) -> void; //io.cpp auto readIO(uint addr, uint8 data) -> uint8; @@ -67,14 +63,17 @@ private: uint writeBank; uint writeAddress; - GameBoy::GameBoyInterface gameBoyInterface; - struct Information { uint pathID = 0; } information; +public: + //warning: the size of this object will be too large due to C++ size rules differing from C rules. + //in practice, this won't pose a problem so long as the struct is never accessed from C++ code, + //as the offsets of all member variables will be wrong compared to what the C SameBoy code expects. GB_gameboy_t sameboy; uint32_t bitmap[160 * 144]; + uint ly = 0; }; extern ICD icd; diff --git a/bsnes/sfc/coprocessor/icd/interface.cpp b/bsnes/sfc/coprocessor/icd/interface.cpp index 33121900..0407649d 100644 --- a/bsnes/sfc/coprocessor/icd/interface.cpp +++ b/bsnes/sfc/coprocessor/icd/interface.cpp @@ -1,25 +1,26 @@ -auto ICD::lcdScanline() -> void { - if(GameBoy::ppu.status.ly > 143) return; //Vblank - if((GameBoy::ppu.status.ly & 7) == 0) { +auto ICD::ppuScanline() -> void { + if(ly > 143) return; //Vblank + if((ly & 7) == 0) { writeBank = (writeBank + 1) & 3; writeAddress = 0; } } -auto ICD::lcdOutput(uint2 color) -> void { +auto ICD::ppuOutput(uint2 color) -> void { uint y = writeAddress / 160; uint x = writeAddress % 160; uint addr = writeBank * 512 + y * 2 + x / 8 * 16; - output[addr + 0] = (output[addr + 0] << 1) | color.bit(0); - output[addr + 1] = (output[addr + 1] << 1) | color.bit(1); + output[addr + 0] = (output[addr + 0] << 1) | !!(color & 1); + output[addr + 1] = (output[addr + 1] << 1) | !!(color & 2); writeAddress = (writeAddress + 1) % 1280; } -auto ICD::joypRead() -> uint4 { - return 0xf - joypID; +auto ICD::apuOutput(float left, float right) -> void { + float samples[] = {left, right}; + stream->write(samples); } -auto ICD::joypWrite(bool p15, bool p14) -> void { +auto ICD::joypWrite(bool p14, bool p15) -> void { //joypad handling if(p15 == 1 && p14 == 1) { if(joyp15Lock == 0 && joyp14Lock == 0) { @@ -33,6 +34,19 @@ auto ICD::joypWrite(bool p15, bool p14) -> void { } } + uint8 joypad; + if(joypID == 0) joypad = r6004; + if(joypID == 1) joypad = r6005; + if(joypID == 2) joypad = r6006; + if(joypID == 3) joypad = r6007; + + uint4 input = 0xf; + if(p15 == 1 && p14 == 1) input = 0xf - joypID; + if(p14 == 0) input &= bits(joypad,0-3); //d-pad + if(p15 == 0) input &= bits(joypad,4-7); //buttons + + GB_icd_set_joyp(&sameboy, input); + if(p15 == 0 && p14 == 1) joyp15Lock = 0; if(p15 == 1 && p14 == 0) joyp14Lock = 0; diff --git a/bsnes/sfc/coprocessor/icd/io.cpp b/bsnes/sfc/coprocessor/icd/io.cpp index 15f017b9..b3a64a47 100644 --- a/bsnes/sfc/coprocessor/icd/io.cpp +++ b/bsnes/sfc/coprocessor/icd/io.cpp @@ -3,7 +3,7 @@ auto ICD::readIO(uint addr, uint8 data) -> uint8 { //LY counter if(addr == 0x6000) { - uint y = min((uint8)143, GameBoy::ppu.status.ly); + uint y = min((uint8)143, ly); return (y & ~7) | writeBank; } diff --git a/bsnes/sfc/coprocessor/icd/platform.cpp b/bsnes/sfc/coprocessor/icd/platform.cpp deleted file mode 100644 index b1654153..00000000 --- a/bsnes/sfc/coprocessor/icd/platform.cpp +++ /dev/null @@ -1,26 +0,0 @@ -auto ICD::audioSample(const float* samples, uint channels) -> void { - stream->write(samples); -} - -auto ICD::inputPoll(uint port, uint device, uint id) -> int16 { - uint8 data = 0x00; - switch(joypID) { - case 0: data = ~r6004; break; - case 1: data = ~r6005; break; - case 2: data = ~r6006; break; - case 3: data = ~r6007; break; - } - - switch((GameBoy::Input)id) { - case GameBoy::Input::Right: return bit1(data,0); - case GameBoy::Input::Left: return bit1(data,1); - case GameBoy::Input::Up: return bit1(data,2); - case GameBoy::Input::Down: return bit1(data,3); - case GameBoy::Input::A: return bit1(data,4); - case GameBoy::Input::B: return bit1(data,5); - case GameBoy::Input::Select: return bit1(data,6); - case GameBoy::Input::Start: return bit1(data,7); - } - - return 0; -} diff --git a/bsnes/sfc/coprocessor/icd/serialization.cpp b/bsnes/sfc/coprocessor/icd/serialization.cpp index 36edfacf..a0ce490d 100644 --- a/bsnes/sfc/coprocessor/icd/serialization.cpp +++ b/bsnes/sfc/coprocessor/icd/serialization.cpp @@ -1,6 +1,16 @@ auto ICD::serialize(serializer& s) -> void { Thread::serialize(s); - GameBoy::system.serializeAll(s); + + auto size = GB_get_save_state_size(&sameboy); + auto data = new uint8_t[size]; + s.array(data, size); + if(s.mode() == serializer::Load) { + GB_load_state_from_buffer(&sameboy, data, size); + } + if(s.mode() == serializer::Save) { + GB_save_state_to_buffer(&sameboy, data); + } + delete[] data; for(auto n : range(64)) s.array(packet[n].data); s.integer(packetSize); diff --git a/bsnes/sfc/interface/interface.cpp b/bsnes/sfc/interface/interface.cpp index 49c1b074..59f2d256 100644 --- a/bsnes/sfc/interface/interface.cpp +++ b/bsnes/sfc/interface/interface.cpp @@ -245,7 +245,7 @@ auto Interface::unserialize(serializer& s) -> bool { } auto Interface::cheats(const vector& list) -> void { - if(cartridge.has.ICD) return GameBoy::cheat.assign(list); + if(cartridge.has.ICD) return; //TODO: SameBoy cheat code support //make all ROM data writable temporarily Memory::GlobalWriteEnable = true; diff --git a/bsnes/sfc/sfc.hpp b/bsnes/sfc/sfc.hpp index 932ec02b..dc317ca6 100644 --- a/bsnes/sfc/sfc.hpp +++ b/bsnes/sfc/sfc.hpp @@ -16,10 +16,9 @@ #include #include -#include extern "C" { - #include - #include + #include + #include } namespace SuperFamicom { diff --git a/bsnes/sfc/system/system.cpp b/bsnes/sfc/system/system.cpp index 512731d0..bc0c5cb0 100644 --- a/bsnes/sfc/system/system.cpp +++ b/bsnes/sfc/system/system.cpp @@ -50,7 +50,9 @@ auto System::load(Emulator::Interface* interface) -> bool { information.cpuFrequency = Emulator::Constants::Colorburst::PAL * 4.8; } - if(cartridge.has.ICD) icd.load(); + if(cartridge.has.ICD) { + if(!icd.load()) return false; + } if(cartridge.has.BSMemorySlot) bsmemory.load(); serializeInit(); diff --git a/bsnes/target-bsnes/GNUmakefile b/bsnes/target-bsnes/GNUmakefile index b6c06e1a..89904a5c 100644 --- a/bsnes/target-bsnes/GNUmakefile +++ b/bsnes/target-bsnes/GNUmakefile @@ -53,7 +53,6 @@ else ifneq ($(filter $(platform),linux bsd),) cp $(ui)/resource/$(name).png $(prefix)/share/icons/$(name).png cp Database/* $(prefix)/share/$(name)/Database/ cp ../icarus/Database/* $(prefix)/share/$(name)/Database/ - cp Firmware/* $(prefix)/share/$(name)/Firmware/ cp Locale/* $(prefix)/share/$(name)/Locale/ endif diff --git a/bsnes/target-bsnes/presentation/presentation.cpp b/bsnes/target-bsnes/presentation/presentation.cpp index c6ac6360..61c14a87 100644 --- a/bsnes/target-bsnes/presentation/presentation.cpp +++ b/bsnes/target-bsnes/presentation/presentation.cpp @@ -164,15 +164,26 @@ auto Presentation::create() -> void { helpMenu.setText(tr("Help")); documentation.setIcon(Icon::Application::Browser).setText({tr("Documentation"), " ..."}).onActivate([&] { - invoke("https://doc.byuu.org/bsnes/"); + invoke("https://doc.byuu.org/bsnes"); }); - about.setIcon(Icon::Prompt::Question).setText({tr("About"), " ..."}).onActivate([&] { + about.setIcon(Icon::Prompt::Question).setText({tr("About bsnes"), " ..."}).onActivate([&] { AboutDialog() .setLogo(Resource::Logo) .setVersion(Emulator::Version) .setAuthor("byuu") .setLicense("GPLv3") - .setWebsite("https://byuu.org/") + .setWebsite("https://byuu.org") + .setAlignment(*this) + .show(); + }); + aboutSameBoy.setIcon(Icon::Prompt::Question).setText({tr("About SameBoy"), " ..."}).onActivate([&] { + AboutDialog() + .setName("SameBoy") + .setLogo(Resource::SameBoy) + .setVersion("0.12.1") + .setAuthor("Lior Halphon") + .setLicense("MIT") + .setWebsite("https://sameboy.github.io") .setAlignment(*this) .show(); }); diff --git a/bsnes/target-bsnes/presentation/presentation.hpp b/bsnes/target-bsnes/presentation/presentation.hpp index fd73a35c..86a8a161 100644 --- a/bsnes/target-bsnes/presentation/presentation.hpp +++ b/bsnes/target-bsnes/presentation/presentation.hpp @@ -112,6 +112,7 @@ struct Presentation : Window { MenuItem documentation{&helpMenu}; MenuSeparator helpSeparator{&helpMenu}; MenuItem about{&helpMenu}; + MenuItem aboutSameBoy{&helpMenu}; VerticalLayout layout{this}; HorizontalLayout viewportLayout{&layout, Size{~0, ~0}, 0}; diff --git a/bsnes/target-bsnes/resource/locales/.gitignore b/bsnes/target-bsnes/resource/locales/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/bsnes/target-bsnes/resource/resource.bml b/bsnes/target-bsnes/resource/resource.bml index 041d1626..1bdc14b0 100644 --- a/bsnes/target-bsnes/resource/resource.bml +++ b/bsnes/target-bsnes/resource/resource.bml @@ -1,6 +1,7 @@ namespace name=Resource binary name=Icon file=icon.png binary name=Logo file=logo.png + binary name=SameBoy file=sameboy.png namespace name=System binary name=Boards file="system/boards.bml" binary name=IPLROM file="system/ipl.rom" diff --git a/bsnes/target-bsnes/resource/resource.cpp b/bsnes/target-bsnes/resource/resource.cpp index f620a235..ae4bc076 100644 --- a/bsnes/target-bsnes/resource/resource.cpp +++ b/bsnes/target-bsnes/resource/resource.cpp @@ -848,6 +848,1020 @@ const unsigned char Logo[23467] = { 47,109,101,100,105,97,47,98,115,110,101,115,47,108,111,103,111,47,98,115,110,101,115,46,115,118,103,101,204,160,208,0, 0,0,0,73,69,78,68,174,66,96,130, }; +const unsigned char SameBoy[32358] = { + 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,144,0,0,0,60,16,2,0,0,0,151,228,167, + 249,0,0,0,4,103,65,77,65,0,0,177,143,11,252,97,5,0,0,0,32,99,72,82,77,0,0,122,38,0,0,128, + 132,0,0,250,0,0,0,128,232,0,0,117,48,0,0,234,96,0,0,58,152,0,0,23,112,156,186,81,60,0,0,0, + 9,112,72,89,115,0,0,0,96,0,0,0,96,0,240,107,66,207,0,0,0,7,116,73,77,69,7,227,7,18,4,18, + 58,173,197,129,53,0,0,0,6,98,75,71,68,0,0,0,0,0,0,249,67,187,127,0,0,125,85,73,68,65,84,120, + 218,237,125,5,84,28,217,210,255,224,129,24,113,39,238,238,174,204,12,18,44,184,37,193,18,226,196,5,226,196,167,123, + 6,119,119,13,4,130,187,59,129,224,238,238,48,192,48,214,255,158,102,119,255,239,157,111,247,219,208,3,9,236,183,157, + 115,238,227,240,150,238,186,117,235,214,173,91,242,43,12,52,233,31,202,94,234,121,250,139,94,77,114,226,200,210,14,131, + 190,85,67,149,29,211,123,99,134,192,94,14,242,61,74,251,112,200,72,55,253,28,244,239,243,239,243,239,243,239,243,239, + 243,239,243,75,31,230,118,166,47,180,121,132,155,218,71,239,38,175,29,190,67,13,233,223,63,196,49,50,56,180,135,82, + 78,179,167,98,105,25,140,135,255,114,233,255,206,131,249,197,223,247,133,18,161,114,74,37,181,149,222,95,24,80,251,178, + 243,105,192,247,148,162,202,37,70,251,63,151,230,12,60,158,109,191,60,73,250,242,53,35,179,168,179,106,211,63,60,8, + 213,148,235,52,220,17,188,82,78,236,181,125,144,175,234,139,15,92,161,203,47,5,145,186,163,120,31,113,217,1,137,13, + 36,203,207,231,114,204,253,242,147,82,202,99,243,61,170,31,119,72,14,174,166,108,161,237,135,94,65,174,80,218,191,139, + 253,239,243,239,51,14,15,21,162,65,140,127,217,240,151,15,29,230,14,243,95,54,252,163,158,86,168,23,26,98,52,48, + 111,67,28,205,67,93,245,228,220,68,114,65,96,163,185,247,182,248,138,50,65,163,45,159,83,115,232,250,203,28,138,147, + 247,235,45,177,40,142,219,170,107,109,124,47,170,79,227,53,160,30,30,122,62,248,19,54,204,81,251,5,241,106,228,180, + 171,215,77,252,162,195,238,197,216,44,73,56,254,182,221,243,69,198,9,235,69,33,215,242,201,65,49,105,13,85,38,133, + 165,181,22,157,209,3,233,195,75,169,222,208,65,232,22,228,254,11,102,90,5,181,192,115,253,247,97,255,249,14,85,67, + 29,191,192,192,234,151,30,90,62,82,145,35,90,129,107,187,241,54,206,115,103,198,77,49,57,3,195,207,247,54,125,208, + 86,117,212,157,95,166,160,109,81,204,69,17,91,75,18,195,96,206,240,124,162,195,227,94,194,116,120,244,38,200,193,35, + 153,240,18,30,233,132,247,240,24,72,80,132,199,35,132,153,240,168,73,56,202,229,38,90,74,90,52,239,164,188,164,133, + 208,134,54,173,253,14,9,167,194,30,204,241,177,125,90,228,20,158,114,45,57,163,104,105,147,74,143,49,121,19,197,242, + 159,183,154,29,135,122,59,135,18,66,8,25,141,213,73,126,225,73,216,242,16,127,92,82,82,5,215,88,71,191,91,137, + 181,229,79,98,252,190,249,212,227,71,10,104,215,25,139,38,207,28,25,38,204,83,204,174,220,15,149,66,109,35,254,194, + 73,49,229,16,186,57,254,16,31,174,37,86,151,63,138,63,147,31,208,240,145,252,118,56,156,218,52,137,110,201,213,208, + 14,232,105,225,215,90,245,206,32,191,153,137,96,185,240,196,241,225,55,110,164,39,237,47,247,13,51,203,58,88,227,210, + 27,70,142,28,217,201,150,172,158,238,19,24,74,248,226,144,182,172,138,207,127,122,18,169,188,113,162,233,159,112,254,148, + 39,137,149,135,231,228,87,104,183,125,164,159,103,200,51,207,143,149,39,52,65,186,62,163,38,163,173,52,170,165,207,111, + 115,162,85,185,248,47,152,203,236,36,155,242,142,128,254,148,244,202,29,209,28,185,198,117,198,233,115,74,46,182,44,171, + 200,104,242,234,229,107,55,232,213,28,210,234,235,31,204,25,9,160,82,233,26,140,164,127,246,249,216,127,127,104,199,200, + 64,222,242,170,29,237,33,38,245,129,193,223,246,170,222,126,111,29,186,101,175,246,117,67,55,112,165,160,122,160,173,228, + 28,73,217,88,243,67,220,252,98,219,72,10,240,25,36,67,88,131,193,156,174,248,84,8,255,188,149,192,13,143,119,9, + 123,224,209,136,112,26,30,21,8,43,225,113,201,167,17,248,191,73,249,148,140,193,224,116,128,154,105,97,18,46,198,55, + 23,94,81,124,105,233,188,201,65,251,142,163,197,137,229,247,52,189,79,220,156,105,46,27,59,63,224,83,202,229,138,140, + 250,35,237,39,250,93,41,134,84,115,186,211,68,207,186,91,114,64,145,194,243,117,115,122,69,245,10,63,74,146,70,121, + 218,56,200,149,77,242,180,138,29,69,38,117,60,93,235,160,105,144,56,100,250,139,207,17,3,230,122,102,77,150,92,153, + 115,171,137,95,101,210,229,242,204,113,217,65,25,21,124,126,35,172,147,55,176,59,245,94,165,127,211,140,78,157,129,174, + 159,100,96,181,242,116,27,12,238,247,26,138,175,46,91,32,183,226,245,133,32,213,121,215,228,223,89,8,113,187,138,61, + 34,125,196,96,176,170,192,69,12,70,120,16,88,5,255,220,7,68,193,194,151,8,30,195,96,240,39,64,216,144,194,227, + 65,240,111,199,195,224,27,248,175,210,192,147,240,200,13,164,195,239,225,1,182,192,239,204,4,102,112,61,17,141,33,45, + 154,189,231,220,73,179,29,98,58,6,123,253,235,93,4,162,74,139,200,245,26,237,215,250,227,166,186,34,160,188,162,90, + 210,125,94,27,187,115,166,31,19,60,112,142,207,236,4,127,184,68,169,177,61,127,150,164,138,113,247,152,199,207,103,183, + 24,153,237,222,116,181,193,213,184,92,188,209,162,231,208,228,153,233,160,35,229,49,77,77,193,230,141,78,112,9,127,166, + 36,183,113,36,202,57,254,24,31,212,141,190,238,253,120,61,209,45,44,63,182,250,99,199,141,201,195,135,38,114,215,108, + 242,1,49,61,248,90,34,204,239,114,246,142,81,226,4,242,97,116,140,60,123,209,40,120,215,244,43,195,46,125,205,60, + 157,245,100,53,118,232,15,222,157,254,188,202,107,198,160,180,190,233,41,254,36,201,221,198,69,19,78,255,68,142,170,8, + 127,222,24,125,123,185,221,85,51,213,153,182,153,254,129,145,61,86,158,52,219,117,57,147,157,165,84,94,236,12,4,249, + 221,197,141,140,14,253,130,185,36,73,202,27,183,11,172,147,180,55,89,48,61,76,42,209,36,125,166,152,116,160,233,197, + 121,138,240,149,245,204,118,43,93,25,231,193,115,23,95,73,126,201,120,234,236,100,158,178,215,87,54,209,181,124,99,241, + 141,186,244,46,81,250,69,134,2,19,63,133,221,142,111,24,183,153,47,139,252,235,212,187,22,57,9,68,138,21,109,144, + 203,53,228,10,26,89,72,82,252,106,233,206,171,34,174,100,52,23,62,89,204,192,109,240,153,226,64,232,132,207,23,61, + 224,6,252,27,33,160,4,30,19,192,163,240,25,116,136,117,6,253,208,105,133,3,1,120,228,4,47,193,127,251,14,92, + 12,191,173,26,248,12,191,121,136,117,2,10,127,38,116,114,92,19,193,17,215,11,44,148,196,24,123,110,0,181,142,59, + 184,222,46,180,218,30,87,29,61,55,55,174,206,165,151,155,252,146,50,60,17,124,232,172,233,223,48,124,233,196,206,123, + 239,188,63,240,167,72,16,140,239,142,131,92,213,75,10,24,199,200,197,24,206,13,94,61,180,153,146,65,115,251,181,107, + 157,44,90,248,190,137,107,211,44,109,93,71,73,254,24,137,17,227,175,227,160,1,178,36,167,27,199,204,216,41,25,101, + 178,81,237,198,7,239,208,39,13,237,29,33,3,111,38,208,192,26,202,27,57,75,203,8,186,149,230,92,117,68,210,249, + 249,181,192,173,51,64,233,229,38,12,88,164,214,2,229,240,216,7,170,192,66,182,10,124,8,143,39,193,15,63,40,154, + 99,29,207,128,4,120,92,15,62,134,191,72,3,97,51,14,183,18,40,225,223,37,209,106,28,42,220,240,232,138,111,173, + 247,209,132,229,101,235,201,47,135,35,168,83,210,53,26,7,229,7,54,92,94,21,113,158,106,39,9,111,212,59,192,53, + 120,190,51,192,171,240,40,0,94,25,251,136,125,3,60,90,28,174,44,103,229,23,126,32,123,73,45,231,228,153,105,207, + 156,129,60,10,97,75,202,37,123,167,80,120,29,101,129,33,180,115,252,145,17,86,157,197,115,236,228,86,153,63,140,236, + 203,161,214,237,152,20,190,171,139,204,124,232,148,163,114,196,183,194,103,211,30,73,104,27,203,193,116,22,129,34,19,201, + 135,255,47,21,39,206,221,211,242,86,161,56,80,223,210,131,81,222,29,195,152,242,76,38,17,227,127,42,103,45,235,6, + 15,114,194,239,159,62,177,148,79,244,136,235,1,149,49,220,184,27,192,160,109,93,216,227,2,148,23,146,130,184,26,102, + 231,129,173,107,46,133,59,193,7,54,22,11,200,254,146,25,141,174,5,63,168,139,28,255,218,240,236,232,136,206,236,2, + 21,225,49,25,60,14,143,198,160,16,60,174,0,74,120,157,207,174,49,210,221,179,244,106,178,171,220,195,87,118,179,18, + 223,229,92,170,80,106,123,205,240,101,202,48,7,39,191,230,100,238,103,6,65,187,242,195,170,31,118,28,48,40,119,218, + 149,194,177,123,225,85,89,215,21,92,12,49,121,146,52,60,199,59,160,0,60,118,178,230,142,95,10,222,133,199,131,160, + 33,98,30,129,19,116,90,141,142,194,200,153,181,29,124,254,135,140,101,130,167,225,81,13,196,44,152,166,160,110,209,173, + 206,245,81,40,52,51,52,35,51,180,102,207,200,117,218,2,198,218,113,243,238,60,101,238,100,214,130,11,253,98,179,245, + 57,24,34,223,136,48,31,240,124,108,239,17,30,32,117,137,131,10,175,53,127,118,92,121,94,219,182,95,181,226,117,86, + 109,189,253,146,248,176,39,55,252,232,24,99,156,55,203,92,198,243,176,204,92,118,246,203,232,30,193,118,1,49,7,57, + 111,210,61,54,229,17,171,30,181,59,140,126,113,66,12,172,218,103,109,252,253,43,111,223,176,12,139,75,95,168,170,120, + 217,82,7,254,60,23,176,21,38,197,148,181,57,241,18,160,241,132,10,232,255,62,74,130,38,136,200,158,130,239,10,113, + 4,250,220,32,57,113,243,199,90,15,64,223,8,189,226,53,117,26,93,234,83,197,180,234,236,234,95,51,252,86,186,249, + 165,220,151,71,240,140,30,34,188,21,97,151,63,56,19,80,104,218,83,137,105,198,130,230,143,131,190,230,157,157,60,243, + 45,38,214,115,117,189,91,64,81,60,107,169,1,211,249,2,156,59,161,114,178,19,124,193,113,13,55,0,202,56,250,71, + 46,47,90,8,133,66,57,80,229,175,229,64,155,78,143,237,96,205,97,224,246,1,207,149,48,7,212,1,42,76,167,24, + 72,154,80,62,96,225,219,246,0,62,27,172,185,116,151,68,141,108,165,151,48,194,153,22,232,232,31,158,63,2,210,103, + 232,222,51,126,16,13,155,86,184,47,224,158,95,168,7,198,105,196,41,3,20,193,6,217,231,230,71,194,20,179,142,214, + 120,162,227,76,60,46,63,187,193,107,22,81,166,193,108,39,252,78,95,68,245,79,230,185,35,82,135,107,103,25,31,194, + 81,0,7,166,7,95,10,66,235,95,107,74,58,220,253,196,237,179,57,107,103,215,197,126,181,225,224,201,169,57,235,112, + 109,25,253,186,175,18,220,228,211,12,54,174,214,114,116,232,227,90,36,42,75,76,135,231,146,15,8,252,97,82,136,130, + 196,73,197,115,68,183,227,118,2,181,240,121,106,13,188,90,44,171,84,96,165,169,199,103,241,54,110,87,197,252,166,29, + 61,110,80,31,52,50,46,154,54,163,126,107,215,211,141,77,218,55,29,37,224,111,117,3,209,240,215,197,65,35,212,123, + 164,22,148,230,57,37,102,76,250,240,106,139,219,210,180,141,208,114,72,5,178,248,153,43,62,176,111,40,128,122,244,86, + 170,133,81,108,2,119,129,232,92,162,53,76,85,48,184,151,205,21,145,5,205,97,254,12,3,233,107,60,47,154,216,207, + 142,45,204,43,171,143,253,207,239,142,159,129,181,19,82,133,220,211,247,151,120,55,215,159,158,249,192,220,231,46,231,121, + 145,74,226,7,36,228,23,1,147,178,27,124,57,9,69,246,24,43,4,137,227,5,210,56,102,227,131,192,156,253,34,55, + 190,185,159,138,27,206,183,104,16,153,212,119,47,3,38,21,18,53,229,11,44,251,38,205,215,112,246,133,209,55,228,222, + 121,25,217,132,236,114,120,7,248,2,179,81,88,128,240,230,158,130,205,218,120,136,145,203,124,192,156,20,73,205,1,47, + 83,18,43,231,207,244,148,217,103,234,3,175,90,40,184,111,66,101,3,145,85,108,36,96,163,31,233,120,53,89,158,250, + 148,206,199,120,253,203,38,111,2,57,65,133,198,47,3,190,228,86,241,235,75,40,25,171,192,28,136,2,15,252,132,61, + 2,223,167,185,114,196,166,147,132,137,206,254,225,57,74,204,66,104,3,164,143,210,7,249,141,44,70,201,62,73,187,95, + 236,163,12,211,31,3,30,154,250,6,22,118,13,112,100,235,198,75,102,78,237,185,81,149,167,219,167,141,153,41,79,33, + 55,40,193,165,37,90,191,248,25,70,24,191,138,229,107,255,205,135,49,85,248,112,150,117,244,226,250,64,37,152,27,23, + 129,203,188,181,103,103,25,61,80,54,127,247,46,132,179,194,170,233,73,143,221,100,208,30,228,118,10,31,109,189,239,72, + 210,244,242,199,199,230,221,113,240,82,225,122,47,154,76,18,132,105,126,0,232,193,244,231,129,184,223,231,50,169,185,61, + 122,134,34,145,31,108,57,240,153,131,42,178,16,164,28,16,185,105,231,158,250,229,92,106,83,101,47,253,8,227,48,243, + 56,91,105,39,119,168,102,116,210,163,66,123,229,36,78,206,13,120,78,80,30,254,226,92,240,22,91,151,52,140,240,42, + 130,237,73,234,253,36,159,109,77,198,157,205,228,159,148,124,66,151,96,200,51,21,204,91,131,249,242,108,102,230,201,8, + 153,178,156,17,167,128,78,54,29,61,18,44,55,13,54,28,248,184,100,183,178,139,85,170,55,127,194,242,50,117,230,71, + 248,164,84,159,16,3,43,166,237,91,69,253,167,221,229,215,174,186,166,33,46,229,179,48,17,11,192,219,83,72,77,236, + 130,13,11,150,87,96,104,183,208,213,22,215,123,201,42,133,129,77,230,208,107,88,253,165,78,54,3,43,219,179,124,160, + 77,96,203,30,157,26,39,117,120,153,115,1,143,241,86,202,103,220,8,231,20,212,222,92,12,142,236,209,38,207,161,152, + 79,134,89,127,172,245,217,159,73,230,61,39,94,98,164,0,175,84,55,226,186,159,104,255,132,40,208,171,240,245,13,240, + 149,171,207,120,16,24,249,101,124,168,18,110,78,235,53,56,242,245,118,178,103,27,172,170,186,129,245,72,134,226,135,159, + 176,47,206,128,4,222,176,179,235,140,140,66,159,102,186,213,72,64,84,136,142,182,74,174,201,182,243,11,121,199,10,3, + 181,47,54,118,191,123,145,167,176,129,133,120,20,206,244,18,94,98,165,30,149,249,82,155,12,58,211,200,211,199,202,19, + 218,94,58,129,145,255,108,189,243,161,20,9,152,39,229,136,230,156,226,60,129,245,191,2,231,75,145,120,34,112,110,205, + 203,193,47,30,141,53,157,82,3,249,191,106,239,52,250,119,206,29,8,121,180,208,46,42,49,108,190,190,28,213,188,25, + 166,16,7,116,35,33,191,55,83,223,196,199,31,103,233,1,156,26,192,88,177,73,77,222,230,141,229,182,96,106,62,223, + 208,147,145,221,52,79,118,248,150,48,235,251,241,134,246,149,196,243,187,109,221,224,83,70,3,208,98,47,66,194,10,43, + 207,125,42,151,100,158,31,144,149,58,163,82,246,231,172,126,108,83,94,66,3,223,26,193,11,52,187,48,152,134,64,196, + 107,206,142,215,31,113,97,224,86,3,21,179,61,101,116,76,63,19,249,253,175,103,127,31,222,63,98,79,231,253,159,95, + 31,7,3,43,253,75,73,118,203,181,29,197,87,54,187,192,54,53,110,30,80,12,19,177,24,188,51,9,253,85,63,226, + 244,222,11,180,115,37,225,219,192,142,199,197,14,28,73,90,67,126,35,135,105,201,147,199,180,234,109,30,156,61,34,164, + 105,14,114,134,247,113,190,192,69,129,59,97,202,49,172,108,137,241,229,134,240,16,176,230,0,225,102,141,123,113,249,222, + 70,171,158,105,191,120,218,61,16,25,26,210,142,36,250,69,242,98,28,113,15,64,94,36,175,238,201,79,48,176,194,193, + 3,59,213,174,56,187,132,180,90,244,204,25,124,247,243,167,206,216,200,232,97,70,129,122,126,85,217,16,207,87,177,110, + 82,45,76,85,44,120,112,60,194,193,63,52,46,0,245,230,196,200,109,55,39,21,183,212,43,116,177,85,199,148,118,181, + 184,176,217,122,214,117,153,64,211,94,120,22,245,160,244,148,62,216,78,129,31,145,42,230,249,23,148,63,121,134,249,80, + 45,232,51,25,47,198,236,89,145,27,38,81,179,20,60,223,184,7,179,120,146,13,158,249,7,28,249,72,56,9,7,129, + 26,92,167,69,165,136,201,183,8,22,114,177,133,195,43,70,222,211,249,126,230,222,201,21,169,200,110,163,75,52,62,171, + 10,104,224,169,20,203,34,121,194,134,66,30,224,58,46,158,254,201,54,34,215,45,172,13,240,86,48,78,86,212,124,209, + 167,57,62,207,179,68,135,159,141,244,210,87,160,12,232,247,141,208,233,186,231,237,63,9,135,233,112,224,112,231,128,118, + 248,43,171,193,71,168,41,60,2,190,131,41,220,9,28,189,229,111,97,30,183,115,40,105,68,156,214,62,113,171,95,61, + 187,229,90,239,247,83,90,15,78,249,176,146,148,76,128,23,108,94,74,197,17,11,161,7,84,228,217,46,150,74,114,189, + 211,110,189,54,222,149,252,116,216,152,250,151,23,78,182,12,172,218,61,109,115,251,138,133,133,30,173,247,53,132,63,252, + 22,201,137,217,2,62,157,114,166,21,66,45,110,0,84,229,29,17,23,33,13,107,11,130,229,17,221,213,244,214,181,125, + 98,144,12,244,2,10,152,12,166,21,227,0,99,152,25,235,84,28,57,82,116,122,102,171,204,98,83,150,10,187,129,152, + 26,226,227,239,214,198,137,2,3,11,139,20,179,45,137,201,121,69,60,77,151,127,177,123,223,119,248,43,181,3,247,224, + 241,3,63,39,248,72,75,32,92,249,163,18,103,162,101,99,22,120,125,206,13,217,46,115,229,18,143,250,178,174,111,63, + 127,238,101,226,13,197,221,223,119,4,95,89,234,242,26,86,19,245,64,240,196,172,248,95,74,194,93,80,96,79,199,245, + 157,110,55,155,174,117,134,147,215,177,51,23,199,187,17,205,133,223,166,197,74,216,25,63,68,46,6,90,83,58,251,138, + 229,167,113,23,217,65,220,245,140,233,252,33,21,165,46,237,58,223,239,50,236,184,195,251,202,5,23,25,248,157,209,255, + 132,176,233,127,222,245,177,221,64,196,60,57,249,51,22,199,253,58,146,128,114,242,132,167,79,216,65,130,144,106,28,119, + 62,119,195,162,93,42,87,117,93,47,98,102,226,10,65,113,152,183,33,224,254,95,158,1,60,193,190,67,252,73,150,209, + 143,59,9,116,205,190,120,142,195,76,138,100,246,249,70,78,58,237,56,253,17,99,8,29,63,195,52,179,228,107,84,230, + 148,202,237,51,103,201,60,0,46,99,243,156,61,3,116,109,172,210,190,224,72,40,159,221,120,183,103,221,68,200,64,143, + 205,0,133,146,175,3,145,238,69,38,112,74,136,232,16,215,35,197,64,162,168,47,165,163,127,53,23,188,206,89,46,210, + 79,244,86,46,122,23,28,34,209,190,165,87,108,232,111,78,70,148,74,129,50,159,186,147,254,254,161,187,221,245,196,16, + 222,93,162,73,164,57,240,4,114,65,225,241,174,254,131,153,34,6,143,235,88,85,135,216,32,192,108,180,154,9,30,205, + 1,216,164,195,182,3,44,167,223,123,112,17,252,223,111,64,252,25,99,53,236,142,34,57,88,251,128,102,129,11,146,73, + 38,51,111,231,89,169,198,145,219,31,245,202,14,233,78,182,176,96,165,120,83,87,239,188,221,189,215,94,186,241,193,52, + 147,192,21,191,219,212,19,178,93,215,131,6,156,118,34,241,68,101,159,247,137,107,202,72,80,47,68,30,159,4,74,84, + 70,134,82,195,80,119,202,238,149,87,59,93,89,177,124,18,161,246,167,169,45,88,174,166,117,72,36,26,27,126,61,157, + 177,171,170,17,162,33,64,146,63,199,164,94,200,168,99,6,190,229,245,248,156,177,155,243,139,232,122,98,208,31,85,177, + 63,51,199,40,1,112,84,52,126,59,243,235,178,222,53,100,3,10,218,52,255,33,88,122,104,143,65,251,160,164,179,92, + 75,68,31,18,235,225,247,175,0,239,79,105,3,75,7,228,156,73,144,153,99,106,225,116,44,242,124,17,74,196,184,242, + 168,70,106,143,230,124,134,130,137,5,171,182,58,30,60,242,15,59,248,119,176,170,225,132,169,192,86,37,131,183,239,191, + 122,118,135,12,168,81,14,78,200,134,41,130,26,161,134,40,193,220,185,117,43,119,156,211,101,184,104,35,167,3,171,244, + 103,227,207,240,118,79,58,151,193,61,112,250,146,83,202,210,86,229,129,235,83,6,42,111,67,79,32,167,177,167,187,244, + 149,12,198,140,120,136,206,214,143,241,135,247,44,206,6,92,201,230,185,115,18,252,192,125,87,236,29,201,217,105,103,164, + 104,209,9,136,15,18,131,140,198,75,4,104,235,232,47,24,165,70,60,159,179,114,133,103,106,73,59,153,222,134,105,182, + 3,215,178,233,244,153,7,222,132,53,97,0,224,44,12,62,218,226,27,89,86,211,136,235,30,248,17,122,198,110,96,121, + 65,137,80,105,244,189,220,222,186,212,229,30,170,246,54,179,224,15,95,1,52,199,37,61,80,6,52,253,189,58,76,120, + 11,193,142,107,181,168,45,177,113,110,145,92,175,249,200,242,34,181,3,54,15,87,149,93,216,97,39,187,82,227,252,92, + 91,139,69,109,74,238,86,71,5,86,74,154,154,204,68,178,82,96,131,3,203,7,236,64,18,0,31,253,152,173,138,117, + 7,128,121,119,229,117,45,132,222,61,243,218,148,241,176,95,125,104,215,72,206,100,51,173,40,187,169,39,232,118,122,141, + 150,55,226,42,57,15,138,60,36,42,195,244,11,129,15,126,194,22,189,9,242,191,110,117,223,149,190,157,214,199,224,103, + 30,252,85,28,136,182,255,54,175,158,107,5,183,154,164,141,35,188,106,0,96,240,51,51,243,184,93,196,188,72,158,132, + 195,190,7,179,90,160,83,208,61,200,247,231,204,186,164,172,62,183,171,97,131,159,214,29,135,65,36,234,95,254,211,194, + 130,255,17,52,23,46,6,102,233,167,58,130,201,82,212,50,250,57,6,74,12,27,230,94,166,7,180,235,92,242,43,175, + 47,61,152,53,216,135,128,238,239,33,131,41,156,222,94,12,120,47,61,161,34,105,173,146,228,87,184,183,105,31,58,206, + 132,60,207,96,86,151,204,120,43,173,110,186,29,169,183,146,66,157,248,188,147,101,202,224,130,193,221,200,65,184,1,30, + 109,255,98,116,67,170,20,151,32,208,3,19,93,133,58,90,44,98,11,188,91,41,173,62,104,123,47,53,188,88,190,89, + 105,34,246,75,28,53,63,186,97,237,198,217,90,159,29,154,16,243,151,23,9,105,61,152,208,136,202,104,168,113,38,120, + 29,254,162,0,144,1,207,84,20,80,128,119,77,39,176,4,30,191,3,211,224,223,8,1,135,17,105,241,66,82,233,133, + 127,2,207,71,199,189,224,43,248,187,242,128,242,126,173,155,171,221,9,223,143,84,119,117,248,140,153,173,103,161,231,80, + 128,123,64,172,97,137,22,31,215,217,219,70,207,224,55,47,2,239,177,197,177,125,184,108,240,164,228,249,231,7,2,122, + 135,94,141,204,161,141,91,150,115,148,64,78,125,45,99,217,71,149,65,107,86,42,197,70,68,103,202,128,102,108,36,179, + 27,33,101,16,215,119,246,93,113,115,177,204,40,42,141,109,137,251,113,122,198,108,96,13,164,15,175,164,154,106,202,1, + 5,17,123,225,15,231,32,241,108,246,211,171,71,253,85,51,128,236,89,124,50,231,77,179,68,57,245,111,251,151,26,174, + 113,55,72,223,241,121,91,178,91,197,205,244,216,146,225,22,181,130,27,53,229,157,18,223,94,86,182,181,43,71,249,228, + 62,175,187,97,201,29,28,145,199,188,188,201,72,63,106,221,214,179,151,148,157,94,114,28,22,89,10,82,225,183,85,128, + 18,127,26,107,31,205,181,210,4,57,132,158,170,63,176,221,105,167,20,150,92,160,57,82,66,243,101,108,135,38,229,227, + 31,156,44,85,177,122,97,153,162,190,165,49,178,81,125,126,218,29,221,31,220,169,34,243,238,123,8,129,140,31,190,75, + 253,101,185,104,78,47,34,193,34,5,254,149,18,5,198,254,200,173,116,225,79,59,74,143,194,70,0,29,255,10,12,215, + 122,11,126,136,8,102,10,49,157,161,77,19,61,95,234,23,250,34,134,251,227,135,246,247,147,244,121,150,136,234,18,91, + 80,31,189,236,140,243,193,91,156,183,240,250,96,164,157,70,88,81,129,59,52,8,141,64,84,116,51,234,160,244,157,28, + 230,62,104,124,235,177,135,6,124,240,96,9,95,216,171,72,194,209,192,11,72,29,229,193,95,55,10,167,3,28,27,108, + 180,14,57,36,54,181,118,9,144,31,160,227,12,248,213,175,42,59,150,247,178,120,163,209,37,4,149,71,7,5,79,246, + 128,47,57,222,136,40,19,113,252,165,146,151,76,166,77,55,146,250,102,226,60,253,141,84,138,137,253,127,141,70,82,185, + 38,174,2,57,82,199,76,78,97,10,241,45,96,53,172,79,184,89,0,58,88,75,86,76,0,183,31,104,252,3,161,240, + 48,248,118,28,49,159,230,130,122,156,9,34,46,68,49,247,89,177,179,75,62,141,115,174,213,185,202,157,109,113,251,26, + 110,196,185,239,65,144,14,139,17,28,169,103,227,110,90,157,6,63,33,254,48,125,248,43,22,44,95,14,246,51,96,204, + 185,74,36,148,120,105,177,170,82,161,213,237,77,144,54,217,49,98,87,244,213,104,87,253,189,187,175,171,187,189,223,246, + 225,178,189,243,163,229,150,106,243,109,158,241,173,63,251,194,136,197,115,93,224,18,226,74,152,7,191,109,45,226,14,64, + 66,123,19,97,252,225,232,160,6,198,26,191,20,188,114,179,198,188,62,54,109,240,34,229,4,77,124,172,28,174,159,217, + 190,179,31,56,46,117,215,194,139,21,77,90,7,28,103,143,183,56,46,32,121,201,67,229,72,43,102,250,227,18,187,150, + 11,227,112,29,237,174,167,116,31,58,50,112,103,166,103,1,76,97,1,203,156,29,3,244,235,95,101,92,125,0,23,11, + 97,213,207,218,174,8,89,151,145,82,125,31,122,15,249,64,233,19,99,96,141,176,194,35,217,158,229,22,109,124,139,158, + 43,201,88,50,127,135,238,100,203,246,95,5,223,48,30,195,219,79,115,151,233,85,46,151,76,167,132,200,168,34,149,150, + 131,93,125,131,99,72,172,166,241,210,159,51,34,114,51,42,37,219,170,159,242,58,113,36,183,45,255,170,198,103,3,171, + 96,108,40,96,130,108,239,27,191,39,131,99,207,3,218,91,12,117,226,156,100,253,56,18,251,203,77,233,39,24,123,153, + 90,147,211,180,170,35,182,245,245,75,159,25,126,152,231,251,12,193,14,126,134,28,249,111,127,154,129,149,8,30,221,149, + 127,213,193,245,125,231,189,190,252,97,220,175,176,173,160,112,168,192,208,192,221,40,125,13,124,164,217,34,193,193,109,8, + 4,223,207,49,50,144,227,28,59,13,216,113,194,224,158,186,55,64,225,163,174,160,127,154,232,73,103,121,150,13,180,218, + 110,42,212,54,119,140,135,103,221,11,172,249,21,121,141,184,237,64,237,60,126,121,156,197,193,208,154,172,121,53,108,97, + 217,231,180,87,220,107,123,186,65,66,179,215,193,6,230,231,98,96,63,74,170,8,120,63,48,103,209,30,165,173,86,139, + 183,94,191,148,230,188,112,235,231,75,195,206,123,127,254,184,165,85,39,192,233,178,250,243,143,15,67,27,70,2,105,114, + 104,175,103,186,73,198,70,81,33,28,219,241,68,48,240,247,195,123,204,190,180,106,192,127,121,149,218,38,27,130,231,250, + 184,59,165,111,191,174,201,88,80,141,249,186,40,99,70,21,227,191,198,53,25,243,171,57,131,245,211,45,171,252,125,130, + 19,55,151,229,218,185,133,245,23,220,126,37,230,198,159,118,93,78,224,181,86,80,208,178,121,42,77,214,1,156,49,162, + 107,137,44,56,223,115,8,156,239,33,182,171,237,70,253,88,0,240,236,163,145,207,161,172,131,140,102,230,11,104,1,251, + 59,165,230,112,235,225,62,13,9,251,103,149,1,165,28,121,120,69,208,2,254,22,23,42,35,245,175,179,154,62,32,70, + 91,17,60,122,131,155,249,115,37,47,24,247,31,248,112,243,187,199,210,135,187,237,22,38,42,187,67,177,21,37,96,220, + 242,188,130,122,70,142,78,197,209,182,19,133,252,181,187,59,31,22,175,171,179,232,58,159,119,179,202,176,61,58,49,174, + 192,174,49,206,55,37,177,189,252,242,203,187,174,183,82,233,199,6,239,58,121,197,79,127,47,101,109,226,10,191,153,138, + 192,186,110,4,170,17,51,142,48,238,102,86,18,120,124,193,87,197,153,150,123,98,30,127,107,175,95,51,86,62,211,149, + 25,231,152,23,63,57,251,164,100,217,240,24,137,237,37,9,35,248,245,199,217,64,198,146,226,46,16,205,38,109,126,30, + 235,34,157,250,10,82,129,62,64,161,40,47,111,161,125,82,67,61,154,229,224,197,136,171,220,218,162,24,34,172,97,112, + 117,108,20,208,32,151,10,44,19,72,153,247,86,126,177,57,217,210,251,171,110,62,158,90,71,151,97,68,141,149,182,49, + 24,88,76,63,104,58,116,229,131,133,55,144,25,194,233,43,42,66,12,71,124,87,0,27,91,14,68,22,73,226,84,199, + 3,188,207,243,252,19,85,148,142,37,80,9,84,6,181,178,117,251,95,72,243,97,92,136,150,254,198,91,215,116,32,230, + 166,147,59,11,54,66,15,156,129,148,137,198,31,118,208,139,247,60,156,96,248,221,178,113,61,83,151,153,9,73,79,78, + 211,138,166,74,247,99,12,188,180,114,13,72,237,228,114,16,141,33,205,69,28,209,87,127,110,253,11,171,104,124,222,18, + 121,172,121,115,233,238,134,99,221,188,191,32,189,253,196,240,101,234,23,173,104,48,62,2,190,79,156,161,17,222,253,10, + 83,67,184,31,88,185,217,93,71,219,105,121,149,87,243,80,239,139,9,12,7,251,83,191,210,147,239,207,183,113,73,184, + 199,65,199,207,98,33,56,227,87,35,216,72,63,63,4,198,5,108,220,182,238,178,148,179,226,183,121,149,111,218,217,242, + 239,126,142,73,238,168,136,153,175,160,192,107,17,1,191,121,16,129,46,28,187,226,3,184,69,197,52,73,143,136,213,254, + 228,156,199,77,53,93,51,201,42,205,154,93,87,201,166,191,96,220,209,37,75,126,211,21,210,159,54,92,10,89,65,97, + 208,152,97,8,40,159,168,68,186,17,110,197,227,71,126,247,96,25,147,33,68,35,190,252,79,40,86,138,9,36,158,114, + 125,176,200,231,50,195,148,121,144,57,48,230,227,83,139,113,158,121,185,247,5,57,108,100,110,65,87,45,111,167,222,35, + 43,187,142,164,61,139,249,149,130,173,116,97,61,224,192,10,44,178,159,255,135,45,0,188,245,251,28,157,146,13,168,62, + 244,173,12,91,118,36,106,232,217,200,82,90,244,189,57,54,60,241,254,92,175,96,115,112,244,52,57,49,46,201,42,163, + 26,102,45,130,53,181,6,16,22,180,59,103,102,102,36,45,254,194,52,48,208,63,47,121,103,133,88,235,154,110,223,65, + 157,145,15,52,69,198,210,49,115,123,11,67,152,41,219,46,208,187,116,104,227,215,174,140,203,213,88,121,75,195,115,193, + 183,230,76,151,213,48,159,9,127,81,5,16,71,48,26,63,142,163,174,147,66,224,181,29,192,69,240,149,224,110,232,8, + 69,136,170,68,191,61,86,202,11,85,107,143,116,62,220,30,175,251,222,153,2,75,44,157,213,216,103,244,10,138,18,25, + 107,39,193,235,148,218,131,249,62,151,26,22,116,44,26,88,56,230,83,50,139,222,201,92,246,177,222,231,104,150,218,180, + 45,18,139,141,89,65,246,79,224,18,4,78,220,24,173,73,141,51,5,151,79,123,37,33,107,188,244,85,151,155,121,26, + 137,242,152,122,139,238,140,78,74,199,96,96,81,213,105,189,140,55,98,51,13,12,62,171,98,120,96,91,187,18,53,115, + 71,171,75,92,128,247,27,90,181,148,29,231,38,85,23,238,104,154,144,62,86,89,223,203,23,180,86,29,61,117,103,131, + 151,184,72,153,254,115,255,144,252,151,213,215,58,68,161,73,255,196,17,242,165,26,118,46,253,168,114,223,218,12,94,114, + 16,92,142,34,114,63,170,16,247,131,175,209,214,220,225,134,193,243,2,45,82,59,77,110,6,234,164,30,170,52,248,249, + 124,104,180,239,92,53,16,117,230,242,67,61,223,157,176,204,108,3,126,73,17,59,246,11,96,182,52,65,197,211,250,94, + 116,193,183,157,117,69,19,55,223,140,35,165,23,91,2,150,63,85,101,216,192,135,46,206,17,92,247,211,50,54,254,39, + 22,90,57,225,14,214,227,49,191,223,209,150,37,93,141,228,114,118,230,101,116,241,51,148,187,157,59,67,20,32,205,70, + 192,8,78,161,74,143,253,56,237,172,132,164,177,100,18,165,240,120,19,55,52,197,159,42,187,150,165,189,249,187,84,175, + 106,185,194,7,170,176,17,234,210,141,60,124,1,216,122,57,192,40,33,202,147,46,139,166,213,244,159,104,251,122,250,62, + 70,190,227,222,136,208,194,50,193,54,217,199,230,188,127,52,21,97,103,31,21,1,190,250,170,142,130,201,130,212,231,116, + 78,198,51,148,196,197,195,198,108,147,7,33,182,177,244,176,224,106,217,185,102,129,8,166,218,201,241,171,174,197,49,65, + 13,142,39,34,219,136,251,14,39,220,62,236,41,225,118,33,230,124,201,252,62,155,193,247,35,143,38,66,18,6,226,134, + 122,168,175,156,157,163,110,20,249,236,188,121,165,204,229,3,2,40,160,143,20,130,140,99,174,45,142,23,72,95,170,172, + 162,106,189,51,213,183,248,126,243,145,49,103,82,238,99,186,67,11,239,123,216,10,38,24,115,81,97,163,214,7,105,203, + 118,13,53,61,103,128,46,193,28,217,253,102,53,159,149,146,219,43,116,198,74,79,176,102,250,131,170,232,197,234,74,12, + 43,214,41,249,4,20,68,45,3,163,110,139,93,224,11,174,153,34,65,68,35,221,219,198,103,163,66,123,249,201,15,40, + 181,236,172,236,24,12,172,102,183,174,24,50,184,101,129,78,173,211,121,120,171,204,4,118,161,102,235,0,168,198,57,11, + 31,11,198,235,215,58,154,39,43,80,19,233,219,25,222,19,33,184,204,126,232,8,244,177,200,187,110,78,215,158,234,5, + 45,146,189,35,147,95,237,182,119,244,126,30,186,41,205,247,226,113,96,26,199,121,156,42,192,64,130,98,207,80,224,208, + 212,128,98,156,243,68,50,136,79,49,187,241,87,65,87,116,24,72,60,28,98,125,164,244,119,142,94,60,25,36,168,15, + 34,67,195,63,147,27,69,94,117,10,93,243,214,60,186,120,217,158,3,158,209,17,160,229,151,212,139,93,1,185,166,7, + 73,185,153,100,216,93,13,115,47,152,144,110,240,212,8,250,110,134,231,149,21,38,2,209,219,48,182,120,121,86,193,199, + 47,195,149,62,129,32,60,41,19,22,170,183,127,188,31,218,79,75,165,215,48,151,160,155,23,253,21,227,30,83,249,238, + 35,235,139,241,240,92,206,60,36,28,68,160,17,223,163,88,133,58,80,114,89,173,170,130,205,154,202,219,205,203,123,103, + 76,117,3,43,126,118,190,65,195,5,161,72,245,103,182,103,144,68,90,148,72,217,92,56,81,79,18,23,248,216,143,146, + 93,200,252,200,236,131,84,198,139,194,254,140,161,71,212,245,10,159,222,92,10,206,133,249,111,5,174,102,51,68,248,17, + 120,250,222,217,203,52,115,1,195,147,137,99,118,160,163,170,188,188,137,179,231,224,254,55,55,103,184,127,64,242,128,253, + 198,37,15,120,52,148,38,8,124,227,63,47,209,101,108,167,237,78,188,27,41,80,162,88,111,214,149,242,147,4,226,41, + 228,12,37,164,217,150,44,105,174,56,17,127,47,207,59,21,195,133,187,138,244,235,92,195,6,250,212,127,238,160,54,80, + 142,171,88,132,78,244,50,232,112,18,77,153,14,159,142,122,144,251,152,195,253,179,43,150,181,29,92,236,161,44,109,149, + 10,191,211,131,141,182,78,194,44,127,45,86,18,208,186,97,101,126,48,118,193,144,12,133,73,243,251,17,26,190,175,169, + 14,235,80,59,72,190,245,197,67,13,51,3,55,7,248,254,135,43,1,29,254,37,25,60,207,177,12,71,5,15,74,11, + 191,160,7,230,214,197,182,115,246,63,103,127,73,199,96,96,101,236,46,221,217,226,32,180,67,125,189,237,34,152,41,86, + 192,107,212,247,152,30,32,114,254,128,194,19,139,150,192,132,212,171,149,247,160,127,159,81,135,231,60,250,67,70,62,81, + 208,255,110,118,51,255,126,137,99,198,199,224,133,87,2,232,99,114,20,143,182,173,80,6,168,75,207,169,220,181,222,119, + 196,251,118,174,103,17,151,144,232,123,34,25,133,31,107,47,44,178,242,184,247,224,60,117,190,143,243,66,29,160,165,208, + 5,200,254,103,242,36,225,196,247,27,13,84,190,240,179,35,198,27,97,122,150,33,0,182,99,189,151,236,97,85,211,224, + 182,178,122,120,177,146,22,145,30,82,102,99,76,209,189,137,9,193,190,6,12,12,182,58,190,79,118,133,130,161,56,168, + 118,124,103,26,231,154,255,176,65,97,41,159,138,164,53,14,166,115,58,144,137,194,164,30,6,213,144,132,229,55,72,63, + 181,203,104,67,12,184,86,80,158,179,66,164,137,248,228,57,143,243,215,20,63,118,230,213,181,169,255,214,176,190,220,71, + 67,129,160,72,12,70,152,151,96,132,54,204,141,219,8,84,156,188,121,255,164,55,185,53,166,103,197,160,227,84,223,239, + 46,152,168,193,226,121,51,100,164,175,154,194,151,85,156,34,48,130,46,209,130,231,171,184,162,209,170,16,239,204,185,213, + 53,80,23,212,63,142,87,160,149,144,2,100,109,218,248,229,222,183,16,152,66,41,128,204,86,103,79,121,92,57,40,226, + 56,16,121,165,104,7,212,12,83,58,230,80,230,200,18,26,134,222,161,175,236,208,153,68,231,58,6,203,231,43,4,116, + 151,93,96,11,105,164,122,221,0,156,51,171,84,166,218,108,206,243,120,23,129,212,117,125,179,6,215,143,224,126,149,108, + 228,175,169,234,233,56,190,151,121,189,219,237,37,76,27,39,144,4,211,121,142,141,106,184,255,12,204,97,8,128,112,207, + 35,123,223,138,102,161,174,227,100,133,177,210,54,108,60,210,76,63,164,53,23,180,138,96,53,2,55,2,167,253,222,225, + 23,165,81,107,1,174,92,151,163,201,237,176,161,124,105,227,203,30,129,191,113,64,64,189,81,67,207,85,193,247,73,33, + 197,28,209,184,16,112,205,31,101,25,232,146,103,86,131,15,49,154,184,153,192,183,227,51,238,94,242,202,207,119,175,126, + 221,113,114,188,214,113,12,6,86,228,235,156,75,181,149,139,101,148,138,173,116,144,180,202,0,212,6,22,124,87,91,57, + 77,61,200,86,59,49,170,224,98,227,199,127,77,171,209,39,179,171,236,118,235,249,141,179,180,146,28,247,193,92,42,65, + 170,5,199,120,64,226,26,65,105,238,8,209,15,164,105,6,186,142,143,147,35,63,212,121,19,50,107,185,237,197,156,73, + 78,40,66,186,163,27,82,142,16,114,52,236,142,143,215,246,190,187,131,170,35,47,127,18,59,248,32,41,200,204,94,47, + 252,67,225,78,142,64,145,151,196,115,40,64,10,182,130,207,56,58,68,2,136,218,203,204,85,165,172,99,231,122,202,197, + 154,151,34,57,121,252,40,66,102,7,8,51,206,251,124,90,25,166,62,88,73,49,166,93,31,55,63,193,193,193,142,145, + 108,173,3,160,97,196,37,14,113,156,23,130,206,63,243,135,29,239,163,121,3,125,160,18,223,179,179,225,70,131,91,246, + 233,12,59,221,228,221,46,158,98,196,170,58,92,142,166,160,26,119,27,228,159,73,148,153,99,106,226,188,53,18,42,210, + 99,103,118,21,210,77,23,123,128,253,119,111,242,187,179,60,223,39,0,212,181,144,172,218,43,109,5,226,197,200,185,3, + 228,97,28,213,99,170,239,119,195,114,247,178,116,51,140,5,108,16,19,145,154,205,155,40,56,3,203,201,156,48,185,249, + 230,247,10,77,107,53,59,39,164,185,178,155,123,76,101,9,171,234,237,40,208,138,218,119,114,18,232,152,191,78,62,203, + 194,32,218,241,219,172,186,2,116,148,36,159,46,172,110,90,191,90,234,2,209,78,21,150,135,96,192,146,205,44,165,209, + 3,222,16,92,56,51,92,250,187,169,206,171,2,183,139,105,18,131,215,41,91,105,50,191,88,56,36,160,167,144,239,151, + 161,180,91,149,204,69,95,149,76,173,88,208,27,87,65,238,241,200,193,197,38,2,142,203,164,84,151,90,135,199,158,206, + 147,171,55,70,71,96,248,189,236,217,53,233,115,246,200,198,176,194,199,56,7,112,19,59,32,50,220,135,197,148,73,119, + 108,31,135,109,46,224,97,14,65,167,160,63,41,36,162,202,211,170,25,87,94,185,184,1,105,74,124,188,103,23,25,221, + 133,191,219,129,52,76,99,35,137,2,119,11,156,182,62,91,51,200,193,56,110,75,62,71,195,56,151,187,141,193,192,10, + 242,72,163,84,189,94,176,86,193,221,82,0,38,139,3,72,102,3,186,208,97,177,181,242,17,43,139,176,15,89,207,107, + 172,254,53,173,200,188,195,187,169,165,23,206,124,242,8,99,98,120,112,52,164,230,113,172,96,110,172,106,23,126,97,6, + 176,97,191,202,141,106,247,27,37,141,245,62,221,115,130,179,211,7,170,74,121,121,197,125,140,142,162,205,153,19,166,0, + 107,54,61,210,182,113,180,255,174,81,93,217,65,248,73,254,60,37,186,19,163,249,1,217,182,43,113,51,38,16,159,2, + 150,163,216,60,85,160,228,180,135,18,151,140,197,47,30,35,156,14,75,61,188,69,47,212,3,190,133,11,251,19,134,80, + 240,225,22,33,231,180,252,131,20,159,180,186,183,109,67,253,227,177,21,109,89,53,146,17,211,179,159,214,138,46,38,41, + 101,90,137,193,187,35,11,112,27,147,202,64,50,237,132,75,128,153,103,162,30,126,243,125,122,101,155,201,204,104,14,190, + 122,9,94,227,25,104,209,210,177,100,32,122,113,173,178,130,85,104,242,179,194,218,166,87,236,76,49,163,160,52,188,37, + 105,145,153,210,99,43,22,28,177,22,18,242,64,145,222,14,207,49,138,0,189,251,238,181,52,115,6,115,49,211,22,218, + 58,117,247,251,80,242,136,28,173,225,146,26,41,37,178,14,54,220,117,8,27,17,67,1,197,33,129,59,15,64,187,164, + 174,154,184,238,108,192,116,204,24,16,24,103,66,229,160,151,80,140,133,74,176,74,254,116,248,91,18,64,63,42,31,27, + 11,77,77,138,16,126,212,248,206,107,175,117,85,97,45,66,189,174,99,246,154,36,80,103,208,149,110,188,55,151,138,221, + 140,96,125,173,68,180,25,187,33,179,64,112,39,247,71,177,101,36,53,61,67,203,101,113,231,251,79,13,9,142,36,76, + 30,57,25,214,29,9,167,239,190,153,96,78,141,13,228,200,196,213,34,41,252,130,200,233,192,142,31,107,58,168,203,165, + 134,175,39,242,219,88,132,10,127,183,128,204,160,32,40,111,172,180,117,204,234,13,27,114,148,73,122,233,247,197,23,94, + 95,19,66,203,31,48,22,104,168,122,129,51,2,151,138,145,12,138,62,171,12,229,140,136,211,254,187,100,100,41,164,6, + 89,251,189,74,210,40,247,89,180,91,177,218,50,5,94,187,143,72,50,59,58,243,122,212,103,185,26,40,88,240,72,161, + 194,146,219,195,55,110,97,233,122,230,55,104,7,52,206,167,219,24,12,172,175,201,25,218,213,239,23,48,21,15,90,194, + 150,35,150,2,196,162,22,235,111,32,142,219,87,212,159,216,247,38,219,35,38,61,151,49,143,209,192,12,248,63,106,91, + 29,135,94,67,14,14,92,225,201,133,226,51,191,74,147,76,85,71,183,253,216,111,42,56,107,112,205,12,33,169,18,147, + 239,246,162,225,183,11,23,64,179,32,73,136,148,167,86,117,173,157,52,221,74,42,192,36,30,9,249,189,68,113,220,54, + 3,193,11,108,21,40,150,216,192,150,84,98,165,255,79,58,132,134,71,244,104,125,146,60,207,121,3,106,48,124,232,90, + 59,227,8,224,210,217,101,231,242,204,124,237,184,195,156,10,238,40,216,189,185,22,12,95,12,206,200,16,230,142,157,195, + 88,111,128,176,206,66,35,197,97,94,54,84,62,216,38,199,254,28,123,59,7,151,140,72,42,49,222,237,255,58,136,225, + 192,173,3,74,198,148,77,50,234,187,90,7,148,207,146,147,81,48,141,118,122,26,153,88,116,90,227,44,32,19,174,143, + 185,10,31,135,29,8,26,16,10,72,11,44,9,48,64,110,117,183,90,238,119,207,24,220,195,206,28,191,108,79,37,84, + 198,115,62,21,157,78,28,13,215,162,72,45,192,149,130,34,60,151,196,138,72,53,30,119,98,11,74,247,78,245,77,223, + 164,213,233,66,94,137,63,241,100,173,31,19,62,156,190,18,134,81,95,86,205,129,215,114,70,134,124,193,51,186,193,1, + 45,202,137,113,62,224,149,70,226,233,187,180,177,196,39,145,240,245,12,247,14,233,153,49,214,181,163,128,23,184,206,224, + 181,64,194,125,99,155,166,132,48,58,157,145,196,76,28,43,37,223,207,85,119,117,88,46,83,87,221,98,253,29,73,105, + 63,195,166,47,135,181,203,172,112,119,65,94,209,219,6,139,252,201,77,45,93,211,201,71,38,167,180,164,9,21,7,54, + 199,173,149,187,232,96,207,242,1,47,99,193,150,178,53,119,228,234,46,92,15,44,214,107,177,180,142,11,25,142,128,141, + 87,229,49,147,117,29,50,129,98,29,27,35,121,138,118,207,220,33,125,213,148,149,208,34,2,244,162,150,228,50,192,119, + 233,94,21,57,107,124,178,66,225,251,166,211,255,249,169,156,224,138,143,109,111,118,81,174,142,184,30,69,64,94,182,32, + 208,33,111,209,206,29,59,8,36,207,12,146,153,109,74,48,178,13,16,205,93,72,109,162,139,49,34,38,98,237,198,96, + 96,37,8,126,63,222,64,91,218,171,146,106,205,234,173,29,11,216,178,217,163,74,20,144,221,233,126,165,217,165,39,115, + 73,41,173,133,1,253,159,124,10,31,214,234,116,2,123,179,174,7,185,193,138,3,171,196,2,160,27,115,10,48,203,219, + 113,144,149,2,44,101,247,226,125,160,123,207,214,129,26,10,113,244,253,53,5,173,193,125,238,171,115,47,12,216,193,134, + 5,46,25,13,114,9,46,21,60,201,35,40,90,70,90,102,36,247,153,153,211,254,115,56,211,51,109,192,150,242,118,83, + 190,246,136,99,2,82,111,210,129,130,242,227,64,251,34,172,210,54,203,129,111,61,85,43,219,63,221,173,177,246,141,15, + 198,112,98,23,0,115,198,94,161,131,203,2,79,241,87,74,222,48,134,194,82,178,66,106,92,217,154,94,30,84,13,181, + 127,13,204,120,92,125,105,246,133,115,87,204,110,33,125,15,175,141,201,205,206,2,65,221,196,106,79,126,182,244,217,182, + 0,211,234,239,45,189,125,179,79,57,63,216,237,243,8,86,160,211,8,198,168,171,71,143,3,77,167,204,30,156,243,81, + 160,140,80,139,233,40,75,67,24,230,204,83,204,1,130,137,175,113,246,6,12,15,254,20,114,187,69,21,68,128,181,141, + 221,114,109,213,20,155,205,113,10,121,35,13,152,41,191,235,61,106,141,59,45,55,173,209,190,238,200,186,172,126,71,64, + 17,81,105,81,225,116,128,235,65,144,237,237,196,117,35,29,180,215,140,113,206,25,74,191,83,146,210,178,103,133,159,90, + 190,77,23,44,21,205,160,236,216,139,222,177,190,128,169,80,181,186,190,237,221,84,239,226,189,205,242,99,38,66,17,186, + 3,125,127,210,233,224,155,44,199,85,40,122,155,216,134,36,125,63,100,179,71,197,55,80,120,169,188,202,41,235,235,241, + 106,223,103,53,56,78,102,105,161,100,83,131,233,5,106,235,62,108,14,85,225,88,140,123,136,244,252,221,138,244,252,101, + 39,80,152,14,56,203,112,191,188,244,229,97,87,90,127,238,112,19,202,171,66,112,103,47,121,199,177,59,119,79,121,221, + 131,223,121,12,192,163,5,77,197,53,128,210,60,115,69,104,68,151,167,210,78,123,82,126,187,68,181,31,233,229,26,82, + 148,7,13,95,4,31,198,220,129,103,173,129,4,211,111,163,208,36,163,235,30,9,30,228,27,20,119,51,18,126,116,199, + 46,39,145,214,119,115,80,105,228,254,196,173,221,24,84,85,217,244,134,168,110,227,117,167,52,108,236,35,70,205,35,54, + 29,149,71,192,183,28,220,248,116,176,229,200,213,219,143,60,193,136,105,217,202,181,251,135,90,71,30,210,58,160,255,3, + 207,224,102,202,62,154,144,222,10,139,254,184,117,92,229,34,60,196,121,240,242,15,129,170,99,18,29,164,113,41,238,44, + 64,94,184,89,241,149,165,116,244,221,111,91,234,234,161,64,40,21,250,173,168,190,109,122,143,218,96,226,201,238,251,95, + 124,246,34,208,145,53,168,107,202,244,8,59,244,138,44,159,197,189,162,165,209,7,153,43,38,154,63,5,39,106,212,58, + 5,23,61,85,58,103,73,135,41,63,133,244,114,31,235,166,93,4,20,174,13,212,152,102,111,219,123,154,252,150,82,109, + 246,52,104,223,183,238,105,17,18,137,198,47,144,244,204,21,99,204,72,99,189,83,11,232,177,202,14,89,152,255,13,122, + 8,153,67,73,232,102,215,31,49,164,67,229,147,116,123,94,16,184,25,163,143,187,15,242,33,95,1,198,228,187,162,130, + 26,179,204,206,9,152,246,135,232,100,20,86,219,20,122,214,222,239,212,223,170,114,201,219,169,8,62,122,11,128,233,40, + 247,102,23,190,18,108,189,242,212,132,39,122,59,173,137,193,195,220,128,210,255,97,55,210,65,23,213,249,64,58,29,25, + 137,36,221,235,162,198,33,179,36,52,238,139,185,97,224,190,171,196,182,222,181,123,202,27,88,9,121,5,187,26,103,79, + 23,150,178,54,129,13,5,92,61,136,70,151,174,3,245,49,237,184,205,64,188,69,102,112,113,94,22,20,9,101,64,245, + 227,69,97,237,186,86,70,95,245,217,227,207,86,7,28,229,88,143,11,65,42,197,14,254,48,220,232,104,128,123,30,120, + 139,203,71,244,6,177,250,209,107,251,101,73,167,96,83,253,32,35,102,172,148,52,74,116,100,14,20,236,127,127,99,196, + 221,19,150,132,70,96,33,106,120,160,223,147,154,239,115,202,225,105,196,229,79,146,28,238,36,99,168,79,232,51,25,47, + 38,191,204,56,84,70,220,47,180,224,119,151,84,50,238,64,146,31,36,216,12,143,42,3,212,125,195,55,106,220,165,154, + 182,118,90,144,249,216,161,13,192,249,29,205,198,242,208,197,247,146,168,240,251,167,161,218,233,136,1,36,60,143,96,117, + 82,239,254,54,159,245,229,251,26,205,123,206,60,235,114,14,75,233,230,181,23,175,55,82,67,224,51,180,81,132,5,71, + 147,109,56,64,109,14,99,145,35,196,165,42,167,223,31,9,81,111,143,238,117,25,122,62,209,171,54,6,85,53,152,67, + 177,163,93,57,182,224,238,52,47,109,164,224,246,9,218,251,241,127,129,185,45,0,225,187,59,238,32,208,52,127,177,124, + 133,133,225,181,219,166,193,49,171,211,124,75,14,54,135,15,13,142,60,165,81,254,129,182,213,126,232,6,228,241,57,32, + 5,83,81,56,71,79,182,218,156,85,11,115,23,57,98,199,216,233,29,62,98,207,115,99,68,148,136,194,119,135,173,107, + 227,27,134,214,83,250,104,255,213,56,179,95,97,104,233,72,197,5,206,79,31,195,244,225,85,51,99,53,196,64,121,87, + 222,66,112,147,62,242,226,75,96,105,187,75,239,195,161,11,19,205,36,191,162,164,168,242,238,89,25,231,184,205,246,32, + 198,208,114,20,74,36,6,60,136,189,247,120,177,31,255,200,2,42,157,94,31,14,102,203,213,174,94,132,83,58,204,50, + 218,70,155,133,143,25,134,238,22,200,127,39,206,42,36,254,4,37,143,154,66,143,71,55,59,143,155,113,60,37,100,65, + 166,236,106,179,28,248,157,59,128,90,20,53,131,167,129,138,243,154,159,228,194,78,15,97,41,116,154,199,215,154,12,217, + 106,220,162,27,74,59,44,7,224,217,229,3,158,40,203,254,87,137,18,137,125,198,183,3,154,115,213,152,158,16,15,164, + 141,110,142,125,25,131,126,35,182,199,174,194,26,67,141,189,54,198,103,20,8,43,164,154,95,124,8,236,36,175,26,190, + 68,77,159,194,123,95,10,122,1,125,118,230,142,58,91,36,143,113,194,199,130,121,168,15,72,81,160,95,80,79,118,190, + 89,196,23,70,218,213,202,113,136,0,208,181,25,234,76,137,84,209,226,109,205,123,164,124,94,200,7,102,112,184,139,232, + 16,15,195,223,42,0,241,63,120,241,27,213,234,72,105,5,46,15,60,141,15,120,114,211,127,89,227,134,142,194,1,115, + 116,84,249,156,79,168,47,75,158,35,43,219,100,174,137,162,186,246,191,205,62,34,210,31,112,246,14,232,202,122,23,255, + 239,110,53,179,58,10,166,138,224,20,149,214,89,118,205,89,224,163,200,103,121,12,233,41,185,142,77,3,43,19,60,179, + 242,227,121,172,45,88,173,222,226,212,219,197,14,109,213,35,173,115,250,14,108,136,213,50,114,156,135,68,60,78,161,166, + 234,9,56,125,182,217,185,155,102,230,106,202,31,62,132,18,22,122,42,166,88,6,195,191,223,4,84,161,198,184,90,12, + 222,193,196,227,215,130,207,133,203,30,17,124,235,42,158,53,133,244,188,250,57,171,54,6,3,139,49,204,252,0,45,125, + 248,214,238,78,226,55,14,166,136,25,241,2,90,220,225,63,25,143,35,237,8,58,65,121,204,78,188,28,248,117,109,225, + 197,111,246,123,46,209,140,78,68,29,252,156,158,92,86,17,211,163,58,16,70,1,161,205,208,101,200,17,154,226,79,131, + 91,199,197,129,93,199,84,238,148,123,145,144,182,172,235,80,88,229,72,106,51,150,15,216,186,131,75,215,203,69,42,95, + 187,90,168,227,79,58,76,209,212,232,118,140,62,3,69,199,192,228,68,88,185,244,1,66,104,227,247,216,251,192,173,157, + 74,87,60,93,190,150,124,170,247,237,106,158,104,46,189,183,243,138,206,220,205,203,35,238,202,74,207,71,117,99,123,128, + 183,4,227,174,237,50,85,142,153,71,123,76,15,97,80,43,66,154,138,123,130,215,175,214,196,59,176,90,131,139,0,242, + 40,84,128,43,184,233,108,196,179,149,1,250,125,243,6,55,142,40,142,117,94,173,126,61,75,7,3,37,31,63,127,25, + 120,14,89,193,77,191,183,101,29,3,158,80,53,240,101,217,19,85,5,235,152,232,170,111,47,234,126,75,8,181,184,20, + 172,154,151,199,115,87,204,158,244,22,166,51,26,173,65,195,115,89,124,55,105,36,28,202,254,84,123,142,157,21,108,146, + 232,12,37,239,88,94,168,118,214,70,11,166,199,28,92,133,130,158,83,44,239,169,176,51,97,232,100,226,125,21,31,97, + 239,226,132,107,101,225,222,153,9,247,203,252,126,234,152,158,240,160,204,47,173,175,228,65,203,66,230,50,166,43,218,126, + 148,180,53,244,251,140,111,250,178,14,157,201,107,48,171,241,138,160,37,234,16,207,81,224,236,134,75,90,27,29,226,82, + 237,139,181,155,53,232,88,134,56,83,254,111,198,19,240,40,61,108,65,93,70,95,214,49,220,247,108,168,165,96,70,141, + 120,231,116,159,170,196,229,101,237,119,134,172,74,227,133,55,150,106,117,59,238,192,236,134,245,48,124,176,225,55,32,93, + 4,126,68,99,140,134,96,178,65,97,12,47,126,38,120,249,4,112,207,194,91,55,39,179,226,117,155,39,202,208,88,21, + 181,145,30,119,251,186,21,87,28,43,41,101,43,2,50,204,6,34,20,171,125,10,119,128,200,0,209,248,201,85,135,227, + 73,25,180,91,116,103,198,200,84,57,53,186,111,14,72,82,132,183,78,191,244,209,169,31,158,139,51,184,145,125,48,213, + 133,24,197,61,150,218,21,242,77,154,61,54,236,208,70,117,164,11,49,172,245,155,29,193,100,57,204,116,252,66,196,28, + 63,131,190,193,60,11,127,145,35,94,228,9,113,31,230,38,222,8,12,65,244,0,26,75,3,241,185,98,63,3,239,118, + 201,94,213,114,233,204,216,84,58,183,229,230,207,92,181,177,56,219,75,161,6,168,59,169,166,240,101,211,177,57,34,178, + 133,230,39,16,15,202,197,113,132,243,31,221,198,135,65,67,152,41,143,128,219,240,120,27,120,52,127,134,252,27,139,235, + 199,219,238,109,247,86,37,16,125,95,101,165,22,220,174,113,238,232,27,232,31,198,82,167,152,177,69,91,12,171,215,232, + 167,73,78,185,41,75,185,15,138,214,147,246,193,60,204,71,196,113,172,219,35,23,20,230,191,35,161,107,124,217,248,66, + 192,151,220,76,70,62,83,3,250,51,55,111,49,84,5,117,91,5,126,253,154,95,130,249,140,117,4,172,208,166,186,227, + 124,192,109,179,219,206,181,152,165,37,61,43,92,213,52,145,48,143,50,208,51,200,91,171,159,184,61,226,3,230,25,150, + 4,220,64,20,189,254,88,101,137,3,16,185,68,60,102,60,45,192,32,87,154,169,192,204,130,78,12,171,140,248,209,79, + 28,49,188,253,197,211,27,150,174,155,192,229,177,183,179,133,239,229,194,235,43,53,29,28,98,90,53,186,191,15,142,1, + 100,132,153,15,31,203,250,174,161,49,43,75,184,166,191,146,186,106,18,130,152,29,99,50,121,97,181,168,201,137,199,85, + 130,135,174,239,54,155,21,115,119,248,222,72,20,253,56,67,153,57,135,153,240,240,145,221,193,196,251,24,204,153,32,194, + 185,223,47,45,99,94,229,118,80,110,193,74,133,64,203,173,69,233,117,234,93,108,229,244,36,11,22,94,107,58,41,120, + 68,150,215,140,149,152,252,5,220,141,50,25,153,229,17,121,194,151,117,182,222,120,197,220,147,114,111,204,115,231,228,202, + 237,54,183,251,153,227,220,62,121,110,139,85,6,25,78,75,82,54,208,95,50,30,50,81,162,247,13,130,148,107,52,85, + 217,83,175,154,130,30,142,66,46,163,62,32,163,193,131,2,151,37,243,76,78,108,151,213,221,224,92,121,160,228,214,108, + 143,57,127,51,22,193,227,236,125,177,55,92,220,231,238,124,119,37,201,37,122,157,130,134,165,125,229,92,113,185,167,230, + 97,72,26,251,28,120,95,104,1,218,72,10,199,155,191,149,204,209,255,119,212,232,143,2,172,184,54,139,206,39,186,227, + 124,30,23,250,69,23,136,213,16,59,216,138,63,212,26,182,109,233,163,157,16,186,119,222,251,26,108,100,7,18,200,236, + 157,53,216,120,192,110,89,132,170,145,245,112,50,185,232,116,211,135,169,117,118,244,151,15,221,163,46,199,30,120,20,234, + 199,137,228,144,97,217,60,109,183,129,79,103,170,74,151,154,218,151,154,53,168,119,235,178,79,97,90,96,137,96,179,183, + 80,185,58,209,22,190,52,98,51,0,87,212,0,10,163,190,210,205,72,158,217,9,52,122,12,47,207,234,74,137,13,2, + 76,151,183,171,77,183,89,29,82,153,121,174,58,1,90,9,169,64,224,100,53,176,70,151,249,245,208,241,145,161,139,45, + 132,166,112,81,120,153,53,1,42,210,53,233,253,184,24,88,255,211,146,101,181,130,102,65,66,36,193,204,114,6,8,220, + 15,196,150,144,68,150,122,168,188,180,86,213,120,12,72,134,251,133,184,102,12,87,39,247,68,146,5,41,177,147,127,147, + 132,63,203,94,82,59,109,197,87,181,247,54,172,150,183,198,192,11,20,156,25,133,18,125,15,46,196,105,60,246,242,115, + 233,84,237,179,25,254,155,238,232,1,94,41,217,21,204,25,170,210,71,76,218,225,191,125,9,46,64,121,212,233,226,137, + 96,180,235,245,104,171,98,31,72,3,122,15,133,76,4,151,122,139,7,49,35,235,241,62,79,0,127,88,221,159,177,34, + 136,162,242,137,190,231,170,16,91,78,82,15,45,204,108,171,57,0,13,65,35,16,149,177,145,209,197,140,213,18,3,253, + 35,158,99,226,241,246,96,194,216,49,160,225,67,81,117,182,224,185,173,102,10,121,59,171,54,182,87,141,193,119,37,212, + 237,50,120,254,36,225,190,155,207,114,248,61,123,17,84,250,31,199,106,31,109,65,234,9,16,215,41,106,24,217,103,103, + 61,46,27,108,253,13,244,181,43,178,63,113,56,89,97,213,155,57,193,176,74,18,62,73,8,66,13,230,57,31,200,63, + 208,116,235,172,199,154,134,129,142,240,129,199,236,172,163,157,66,88,92,193,107,254,135,146,27,140,179,216,108,191,58,42, + 243,57,172,208,3,110,25,80,128,52,223,45,254,153,35,135,173,136,30,17,107,69,248,90,157,255,157,217,9,237,135,222, + 160,244,67,164,12,220,162,108,221,250,240,146,187,83,20,252,102,51,4,110,0,29,79,100,144,82,115,36,240,42,220,1, + 44,129,199,75,132,180,31,28,159,18,74,224,49,154,192,132,37,74,152,133,76,134,91,10,20,194,239,228,7,175,252,160, + 17,51,234,175,130,88,32,32,216,35,128,236,162,211,138,186,150,14,122,134,150,146,113,55,107,168,173,69,125,95,199,225, + 192,94,89,92,211,12,46,188,163,232,110,249,25,254,150,54,200,193,70,251,94,0,115,22,39,13,12,136,110,210,79,246, + 207,28,126,55,82,79,63,53,181,12,44,242,231,225,76,234,128,204,231,151,121,95,88,33,179,22,144,221,28,232,77,176, + 129,245,89,230,146,169,81,105,64,195,199,110,237,113,160,112,246,48,142,234,119,89,195,72,58,234,1,166,3,27,0,216, + 195,95,89,9,222,255,201,93,40,70,243,146,183,1,213,243,47,41,8,89,68,218,221,14,163,20,216,208,157,25,166,204, + 215,63,127,213,80,166,139,38,110,42,152,209,40,177,78,92,131,100,207,170,125,219,14,156,252,221,153,63,129,140,27,61, + 8,17,167,223,104,61,11,142,7,136,154,79,86,208,180,248,170,216,240,118,249,87,165,207,67,41,202,21,181,131,86,148, + 219,52,220,100,219,30,237,179,123,90,134,206,73,242,62,231,10,96,41,181,17,32,27,49,76,223,141,61,89,15,247,16, + 156,62,87,70,206,204,60,35,104,75,90,68,213,90,102,27,116,16,250,155,136,114,210,158,130,182,198,162,85,75,206,91, + 216,118,194,95,55,1,94,162,94,5,33,240,190,126,138,163,66,242,45,42,157,174,206,152,16,204,152,226,55,117,109,93, + 166,187,21,174,205,117,133,85,137,176,21,161,9,133,161,16,6,30,152,111,170,32,105,17,246,77,185,50,187,253,183,218, + 37,102,6,180,28,186,11,112,250,90,102,13,112,149,136,9,144,78,35,216,45,99,147,91,248,16,226,127,39,185,221,56, + 199,187,50,225,110,217,77,136,9,255,251,187,199,16,114,135,82,237,244,194,202,10,236,167,237,148,192,26,111,67,90,201, + 142,173,133,243,33,240,13,215,51,209,197,196,128,199,134,246,158,73,250,116,93,198,51,230,111,77,81,42,115,154,223,244, + 238,223,55,120,35,211,125,21,188,190,247,88,222,95,148,183,252,131,192,89,149,43,239,165,67,100,123,247,146,173,41,85, + 236,172,227,195,185,118,156,137,146,156,238,162,107,137,1,227,130,223,243,171,198,163,224,59,222,244,179,7,141,220,226,29, + 190,79,107,112,102,135,39,165,252,245,253,93,253,11,138,21,5,45,89,232,237,111,80,93,117,126,254,56,170,121,90,64, + 57,164,159,93,54,38,28,111,1,38,207,104,144,246,50,221,45,237,253,114,229,151,125,95,66,210,78,85,137,15,82,41, + 233,52,147,113,80,1,175,32,7,40,205,53,58,102,65,177,15,135,161,200,101,226,118,164,17,202,27,118,206,14,46,113, + 81,95,146,192,135,74,239,27,153,121,76,59,38,29,210,156,98,6,86,224,112,42,149,38,19,252,50,236,75,43,114,2, + 202,177,25,34,164,129,154,11,103,40,26,90,170,86,40,55,25,244,140,27,26,101,80,81,90,101,213,251,133,179,20,241, + 150,151,96,125,82,10,248,254,228,182,102,178,0,121,122,138,100,188,9,254,85,191,155,103,90,238,224,82,202,6,218,142, + 95,181,106,40,13,44,218,22,250,83,70,173,197,134,96,76,30,40,248,237,92,190,217,23,152,149,33,128,5,106,200,124, + 116,46,68,60,114,139,218,8,84,35,168,30,179,230,173,150,223,107,177,76,85,246,125,106,72,105,90,125,201,130,150,77, + 244,151,12,125,230,211,95,187,49,24,46,76,57,102,59,184,192,79,47,59,138,183,74,28,50,186,255,7,190,246,88,125, + 12,51,193,27,156,111,112,161,224,28,221,75,198,82,81,250,228,153,195,23,168,150,63,66,67,137,82,189,97,151,207,62, + 210,141,107,110,141,48,175,236,8,157,168,197,183,22,148,148,121,244,50,246,139,26,249,221,240,23,106,241,68,112,44,234, + 113,238,186,186,199,203,76,84,15,90,51,17,244,41,20,133,20,216,8,192,106,239,235,235,174,110,110,213,155,90,238,244, + 54,254,110,231,66,61,208,96,104,96,102,79,13,39,223,186,179,6,70,177,191,1,180,142,229,253,171,192,135,220,11,196, + 196,73,87,94,217,187,29,72,187,13,121,66,49,80,233,255,62,163,198,125,29,69,3,183,15,125,212,123,230,49,128,217, + 140,117,5,72,99,242,156,33,157,225,97,197,49,188,57,68,39,201,233,100,57,208,232,215,243,95,69,6,153,157,101,196, + 86,153,249,59,228,233,22,86,8,170,242,6,212,165,12,162,132,240,167,178,78,119,82,142,210,200,12,65,230,49,148,50, + 255,149,121,135,217,114,46,233,85,120,208,44,248,157,177,44,79,9,254,200,24,175,19,147,102,196,121,128,91,87,120,171, + 165,218,164,149,77,111,8,234,102,43,61,54,136,47,77,165,10,63,115,68,230,178,105,33,252,230,112,112,255,148,224,3, + 7,168,53,173,85,226,149,177,198,182,51,151,247,57,223,186,65,52,235,138,149,12,127,158,189,173,118,91,167,74,223,247, + 225,147,227,171,1,168,114,180,6,198,189,135,4,59,201,196,231,72,110,174,18,155,200,79,240,229,132,223,91,18,111,220, + 150,68,47,60,217,116,132,229,205,134,166,24,48,208,192,185,161,60,170,156,136,179,190,146,63,124,33,196,21,131,162,108, + 74,117,46,136,21,10,80,15,179,61,94,189,176,229,126,239,184,37,251,15,148,14,31,162,130,18,225,207,249,3,190,96, + 64,220,66,164,40,97,34,98,92,255,19,145,31,2,181,57,187,68,87,19,67,117,35,141,159,68,165,244,206,33,223,164, + 84,255,218,85,99,171,224,121,56,96,36,135,46,246,126,142,151,114,166,200,188,123,242,18,22,39,144,118,10,45,8,82, + 170,201,79,219,252,34,191,69,148,159,33,206,252,18,204,94,152,209,23,215,44,184,112,197,206,223,180,241,139,229,183,252, + 190,189,131,27,71,228,126,21,139,51,249,74,43,90,106,214,20,94,124,108,47,5,31,252,52,4,1,127,172,145,105,44, + 146,210,142,3,20,55,99,180,67,29,51,178,162,203,57,90,63,253,56,13,29,225,125,50,67,223,196,54,25,92,252,188, + 22,131,57,227,68,144,97,227,176,217,178,209,94,43,213,113,85,135,105,223,220,161,158,137,224,152,211,249,72,239,162,205, + 124,186,226,52,35,109,248,139,1,104,114,119,132,195,8,20,185,69,175,47,5,133,117,186,245,213,15,171,254,231,251,203, + 68,27,10,187,193,249,202,242,100,139,68,196,108,189,50,230,196,201,77,56,45,144,87,185,245,93,69,200,3,102,49,116, + 18,122,240,151,166,6,192,60,192,172,32,94,245,183,203,57,202,223,33,193,109,188,10,158,209,43,112,222,152,120,222,1, + 42,240,126,23,151,53,226,7,143,249,69,103,231,211,32,198,50,230,225,223,109,55,168,21,234,251,108,145,220,81,97,193, + 137,17,201,69,26,10,157,66,211,248,22,55,8,170,115,5,139,188,38,226,237,84,194,130,10,216,74,111,111,201,232,126, + 78,166,30,62,161,87,226,201,13,175,197,90,130,243,20,245,93,141,26,235,33,128,229,105,142,7,22,62,86,205,49,93, + 81,100,182,130,95,132,147,190,187,178,44,121,13,207,114,26,221,134,121,222,141,152,14,147,223,196,188,2,242,44,127,169, + 26,102,179,208,224,170,163,99,178,125,244,190,220,246,186,252,222,82,114,251,136,246,68,104,0,114,15,133,147,54,75,113, + 197,27,202,215,249,200,165,78,138,77,250,227,193,35,107,59,52,12,236,83,106,7,218,94,247,111,129,166,224,211,27,5, + 115,123,253,129,121,55,159,185,179,98,56,33,224,94,54,121,66,0,151,109,37,93,202,119,202,169,223,209,174,220,63,206, + 253,84,188,248,226,249,74,223,240,23,72,94,52,102,254,214,203,117,34,165,148,21,61,19,195,159,6,245,165,138,94,132, + 7,22,54,207,239,146,159,28,176,177,227,128,40,51,88,74,9,164,153,219,46,9,77,46,88,185,214,240,226,75,251,99, + 176,74,210,6,88,125,130,30,129,51,254,168,52,20,249,137,74,97,52,63,0,15,116,207,146,145,94,108,66,126,112,220, + 118,87,66,86,155,70,143,215,224,79,69,216,234,254,58,0,80,182,157,23,255,216,23,118,138,211,20,191,12,73,45,159, + 5,94,69,177,25,70,192,243,124,92,226,218,70,179,223,94,241,24,200,88,68,207,101,132,48,109,127,156,18,250,118,198, + 38,166,248,249,254,79,143,195,244,96,3,75,30,193,49,63,129,10,14,206,27,220,54,55,66,46,193,28,202,95,87,61, + 163,67,118,124,57,198,92,193,12,130,86,26,206,117,255,152,190,20,62,152,197,9,201,191,193,105,142,249,54,115,230,51, + 65,241,142,161,149,111,252,122,234,67,216,32,249,47,3,168,133,183,43,143,92,112,128,227,230,17,22,178,14,238,33,34, + 165,99,109,219,114,147,144,115,164,242,206,44,207,186,254,245,67,11,71,114,255,106,70,21,79,155,172,122,92,15,221,211, + 59,232,145,4,255,149,7,129,250,123,185,248,143,135,197,225,191,234,61,82,119,135,215,179,174,210,170,249,84,239,127,133, + 191,25,60,140,28,166,199,59,63,207,144,12,55,140,11,62,18,44,70,109,70,208,128,196,5,57,138,235,45,207,134,106, + 103,58,212,8,178,179,142,89,124,101,118,173,178,27,244,180,118,57,196,192,111,158,7,236,153,162,6,214,168,87,47,142, + 192,212,150,33,30,138,104,30,136,31,158,79,69,219,139,147,6,81,33,230,165,108,163,85,145,157,28,124,184,92,240,40, + 123,53,113,191,32,175,197,14,220,128,209,194,63,7,243,87,120,168,69,218,124,151,155,241,154,20,148,236,57,61,206,177, + 244,208,32,158,162,72,187,52,110,198,132,44,217,142,66,57,44,173,151,237,49,4,127,55,142,221,118,206,184,101,64,17, + 254,197,147,243,126,253,29,87,250,166,15,37,76,69,3,171,93,169,247,218,208,94,33,43,117,61,91,86,85,53,136,6, + 182,230,191,120,50,11,200,57,211,254,136,195,247,105,155,77,207,183,193,113,246,231,181,106,116,23,15,234,28,94,167,231, + 238,57,3,129,182,225,70,13,178,240,191,59,86,16,200,89,172,50,112,235,72,199,29,140,103,121,254,219,234,7,29,139, + 38,207,170,141,27,100,31,61,139,225,199,116,138,171,201,215,104,120,38,82,248,36,202,255,181,64,137,100,130,201,65,88, + 61,29,37,132,32,157,131,150,142,99,189,225,15,43,5,236,32,16,203,171,39,46,69,42,190,214,106,54,63,70,189,123, + 73,255,200,240,132,59,135,25,31,153,251,153,173,118,199,194,236,11,172,103,238,148,126,103,122,30,230,192,102,160,28,133, + 144,157,67,82,89,5,128,172,163,162,119,238,123,210,155,7,187,130,200,223,209,81,245,216,213,190,36,201,151,227,18,222, + 7,44,27,197,208,66,213,180,68,108,186,148,212,43,19,123,207,160,120,193,210,113,190,247,12,240,15,217,83,183,107,46, + 1,82,195,155,96,201,1,8,53,40,66,3,252,224,21,14,87,220,11,144,143,212,254,249,91,78,208,111,135,219,127,60, + 253,103,7,161,145,82,245,168,143,202,161,29,176,132,164,2,78,40,60,100,195,192,218,77,10,218,174,142,134,133,243,106, + 207,117,254,73,40,141,33,203,92,194,204,248,196,240,189,149,101,192,85,41,26,77,172,70,160,23,199,148,29,197,2,3, + 156,177,76,234,188,201,107,235,216,144,164,239,103,152,55,152,53,208,127,21,52,12,59,142,52,208,79,168,155,127,60,18, + 218,138,153,133,95,15,62,65,13,230,89,9,8,110,63,163,187,210,57,61,79,181,234,110,123,16,59,235,232,127,53,169, + 167,226,204,220,88,185,26,139,21,136,244,166,77,81,3,11,233,169,32,124,143,144,243,46,215,179,62,163,130,89,12,173, + 135,80,166,28,12,58,81,206,209,36,240,251,158,204,243,171,133,47,0,149,132,187,108,2,102,254,252,113,84,123,47,101, + 201,48,214,9,248,136,52,249,105,155,93,118,46,223,204,243,162,57,225,78,184,216,247,138,26,229,142,113,184,196,182,95, + 236,221,54,244,68,104,187,58,151,77,249,40,48,10,155,62,72,123,224,131,70,40,240,52,220,106,0,63,148,78,61,53, + 21,13,172,156,57,21,75,219,142,205,221,35,119,211,156,149,228,238,2,110,102,147,39,175,129,135,231,125,63,45,8,211, + 238,95,54,88,51,146,58,206,87,229,3,204,207,208,86,147,178,192,204,220,110,238,5,162,46,196,82,248,187,115,88,152, + 151,227,38,141,72,223,67,236,7,224,201,150,25,58,187,28,201,241,171,243,125,27,180,161,155,144,41,20,253,15,52,176, + 254,43,32,117,179,111,205,80,129,133,113,48,33,127,134,200,233,39,25,254,23,102,220,147,62,108,210,8,139,197,52,32, + 29,102,13,23,120,233,143,156,140,137,86,49,163,249,43,1,224,14,190,51,226,149,70,215,95,245,185,41,164,89,83,234, + 169,233,244,182,137,99,107,209,237,58,129,206,154,237,25,186,114,46,243,17,24,213,86,20,205,155,71,97,45,157,192,77, + 130,75,206,49,204,130,188,10,227,107,203,4,161,181,144,38,132,50,205,214,34,34,248,121,254,33,129,245,146,46,38,251, + 254,0,8,24,43,63,249,65,93,174,70,177,229,36,213,103,225,206,234,41,227,140,34,211,216,211,121,113,160,237,228,145, + 251,91,189,97,19,16,107,129,6,22,149,133,86,47,120,85,86,200,172,217,87,54,241,67,249,206,63,185,12,0,140,39, + 76,3,67,87,247,192,244,123,240,33,65,7,214,140,221,244,199,126,3,60,23,25,43,105,88,9,124,125,148,177,183,122, + 205,159,248,174,174,55,61,237,49,217,220,163,83,230,116,22,166,138,136,92,48,126,92,6,112,72,3,212,151,160,32,110, + 223,99,69,191,227,157,66,125,159,134,254,132,99,125,153,131,95,71,162,247,46,187,190,210,237,50,2,199,42,132,118,167, + 156,137,38,92,196,74,60,138,244,227,110,95,219,203,63,180,129,157,117,52,186,251,121,40,119,23,151,176,200,60,226,2, + 152,170,54,118,19,114,127,89,104,204,9,220,56,77,84,98,147,241,14,119,165,216,237,37,119,217,225,73,249,234,70,157, + 238,202,221,123,175,214,186,94,129,165,238,3,161,154,77,10,17,36,188,223,218,235,254,248,56,154,249,135,99,91,235,142, + 250,15,118,177,188,242,56,29,144,7,243,8,151,5,174,60,120,229,214,59,15,165,4,205,239,95,26,183,65,9,80,17, + 132,18,45,175,182,161,77,183,159,111,126,164,130,164,69,54,98,76,176,107,96,225,1,185,187,254,214,111,226,93,41,222, + 212,47,116,159,169,104,96,57,150,69,46,47,18,20,88,35,233,96,178,4,230,73,5,120,150,77,191,108,17,48,67,127, + 181,67,122,242,102,154,48,253,3,163,126,66,206,65,122,221,171,174,157,187,53,175,9,186,154,192,95,36,3,43,199,197, + 201,50,26,161,74,7,79,45,190,168,212,100,117,207,251,83,2,182,108,19,244,9,242,133,50,39,219,170,77,120,211,137, + 102,205,46,69,178,129,151,123,252,157,210,70,197,147,111,124,131,59,23,152,41,174,176,160,113,41,138,110,34,178,176,136, + 12,128,123,8,62,111,22,204,184,157,72,99,90,145,137,242,114,225,56,128,228,197,174,74,100,171,123,193,231,210,111,85, + 165,65,159,161,20,168,106,124,231,75,145,161,18,232,122,215,110,154,222,141,238,230,56,141,127,11,166,161,48,173,70,199, + 229,224,93,140,23,214,23,112,60,47,253,73,32,12,215,171,67,14,160,244,179,67,91,112,112,122,84,21,117,222,43,249, + 251,22,146,48,55,118,3,245,40,168,58,0,26,98,22,99,79,0,42,10,233,111,30,125,93,204,124,203,108,133,68,199, + 139,123,37,183,235,93,187,26,132,20,213,47,219,238,67,188,158,139,81,40,211,147,128,212,218,203,23,43,237,165,83,158, + 20,93,105,250,75,240,14,183,222,152,194,18,41,110,15,81,111,210,6,4,124,65,121,76,178,100,7,174,229,147,57,171, + 106,20,111,238,20,148,159,103,252,95,183,55,128,217,13,41,189,60,233,186,57,213,153,235,141,168,39,17,66,202,149,31, + 140,69,253,225,231,131,183,166,139,74,25,155,100,248,61,73,58,89,158,9,249,67,73,191,183,63,250,207,167,234,106,115, + 127,47,176,196,69,185,192,170,5,166,74,3,128,80,194,241,241,11,115,17,244,213,157,63,190,12,173,161,103,48,188,153, + 239,80,198,193,184,233,74,140,220,187,17,214,18,241,229,176,209,118,149,176,102,236,72,99,255,9,212,130,235,101,173,11, + 238,3,200,58,84,94,179,106,238,112,134,63,111,20,78,0,48,66,171,213,103,219,64,113,85,249,154,13,226,236,200,118, + 236,178,188,205,245,55,132,48,234,211,109,154,97,41,125,1,60,68,237,67,154,203,170,199,196,237,97,97,91,227,102,2, + 41,240,200,7,36,254,237,200,9,196,34,21,166,87,144,14,134,220,240,207,60,192,102,228,13,57,127,212,120,162,67,45, + 26,29,165,88,190,118,108,50,224,124,192,237,102,141,123,223,183,179,149,129,237,66,40,245,128,73,189,123,87,246,188,125, + 242,123,17,15,168,31,184,147,77,3,107,37,112,216,64,212,241,70,178,17,237,36,253,33,163,100,138,217,86,30,80,34, + 84,120,253,152,105,81,204,75,78,62,124,48,88,138,244,81,69,13,127,128,163,131,26,92,251,69,50,136,215,237,106,195, + 231,22,196,141,58,220,39,130,112,42,158,86,194,208,121,220,97,159,156,20,201,37,38,34,67,60,53,138,180,199,166,105, + 245,9,92,58,243,148,116,170,169,4,96,228,183,38,91,147,74,164,175,101,188,154,156,75,247,83,187,122,245,201,14,42, + 141,92,205,149,172,220,210,102,249,82,204,85,61,181,240,80,138,222,39,15,234,92,119,185,119,230,95,89,184,44,0,23, + 188,25,10,144,214,167,163,125,175,198,55,164,184,19,124,129,57,131,229,0,214,138,121,27,148,126,38,53,233,119,54,144, + 199,175,128,243,45,228,3,125,247,166,37,68,150,125,152,207,47,191,222,130,21,123,62,1,180,161,68,109,193,96,63,1, + 79,215,24,95,232,176,139,79,58,81,144,217,56,14,110,207,124,215,234,71,29,143,151,147,213,36,109,88,29,197,51,1, + 23,212,225,164,101,4,155,35,27,110,191,242,116,105,43,239,25,26,218,54,94,44,140,31,248,254,169,33,158,215,224,236, + 2,35,41,164,48,27,69,191,116,225,227,132,47,7,250,110,29,242,224,171,205,107,123,209,215,253,87,223,138,51,207,223, + 222,176,119,153,128,74,165,181,63,138,114,226,3,224,107,204,154,51,118,4,205,7,213,182,190,137,50,204,125,204,80,104, + 223,232,155,191,125,175,108,105,191,186,233,190,182,157,35,11,236,78,19,208,26,147,167,118,20,239,170,13,240,85,84,127, + 187,238,171,120,207,236,129,88,138,225,95,205,34,212,33,179,164,102,197,236,192,115,254,102,68,164,43,192,90,20,10,183, + 25,148,227,158,45,154,69,154,247,226,170,139,89,42,91,77,144,58,183,244,57,15,47,151,61,249,138,25,36,10,175,197, + 3,194,119,118,118,43,87,164,24,63,233,40,191,144,68,169,49,145,223,69,114,135,113,34,191,169,228,58,227,232,159,51, + 78,139,16,191,106,52,235,88,211,221,155,94,159,43,244,155,62,246,176,213,222,219,153,20,101,95,84,44,96,37,25,102, + 178,17,201,79,157,137,130,39,123,193,87,220,87,197,110,145,204,79,126,184,255,214,187,90,242,233,243,144,192,89,146,59, + 159,63,13,232,252,203,113,247,243,231,1,93,18,237,207,207,6,100,225,240,143,191,248,93,58,20,160,167,226,209,182,89, + 88,155,225,216,60,239,162,252,57,139,181,72,26,59,39,44,117,253,64,20,123,102,22,11,31,28,99,131,253,12,88,201, + 146,95,59,7,149,183,52,117,27,14,42,141,149,87,185,122,149,243,219,250,231,120,200,45,52,103,193,177,134,130,251,216, + 52,176,230,3,123,158,173,115,198,164,124,166,229,210,123,153,59,166,150,125,213,186,161,187,108,80,234,168,230,157,43,94, + 44,180,51,105,66,52,123,145,31,108,20,96,187,92,83,181,196,102,123,156,123,254,222,134,109,19,77,127,50,79,225,165, + 166,245,43,248,212,116,108,88,231,154,21,128,26,110,3,87,2,138,114,199,137,97,72,167,110,235,89,134,199,21,146,207, + 15,235,81,83,39,243,218,253,178,182,169,204,84,104,37,244,160,221,183,55,122,232,163,175,86,98,86,249,209,11,213,132, + 51,97,12,161,126,117,35,91,85,204,58,188,22,232,130,160,156,227,16,108,247,183,227,146,38,63,106,255,6,128,187,4, + 102,72,242,27,7,185,150,199,172,42,246,100,222,97,150,64,98,236,207,168,18,104,254,216,123,236,120,204,61,49,22,238, + 48,118,30,112,4,49,19,209,244,254,91,4,222,230,225,22,19,34,137,63,141,116,138,77,217,197,152,203,168,102,122,179, + 79,97,87,69,127,211,48,99,147,173,118,163,99,36,76,33,1,208,71,189,69,151,3,7,215,39,107,154,56,92,206,84, + 41,109,111,25,28,7,129,152,6,73,64,68,155,183,161,134,223,253,57,237,68,183,19,195,80,248,50,145,32,200,153,22, + 130,222,217,134,103,215,2,158,83,236,168,65,244,228,191,250,96,233,165,134,35,221,55,246,23,222,20,117,79,64,208,182, + 26,81,164,210,135,19,206,43,149,188,237,251,154,213,91,77,134,70,14,80,14,83,37,233,207,31,61,183,43,78,108,227, + 10,22,249,68,60,14,203,91,205,15,3,108,34,239,196,214,3,65,139,13,148,231,90,189,12,157,153,169,87,77,253,223, + 217,70,212,245,247,205,17,229,187,112,214,195,168,26,254,86,53,154,22,176,184,215,224,252,153,95,101,176,166,113,110,146, + 49,198,37,251,216,218,5,188,77,140,158,206,61,233,215,197,221,112,8,148,238,43,180,225,39,236,51,224,190,232,9,253, + 44,255,12,243,189,65,215,242,102,89,90,126,21,204,95,98,249,48,152,154,63,253,231,140,230,198,65,64,222,230,160,176, + 180,242,42,149,161,166,145,59,52,26,74,166,108,129,110,67,230,111,230,120,104,165,235,96,102,11,7,19,234,17,148,234, + 103,40,86,202,8,92,182,210,241,252,73,219,230,226,129,250,227,93,17,12,1,70,37,211,151,193,199,40,103,250,252,205, + 200,195,40,101,122,211,19,25,158,76,194,176,255,72,49,93,184,154,175,101,77,111,146,63,62,105,176,188,236,138,142,113, + 71,244,145,37,102,202,111,173,10,17,204,253,3,191,231,159,161,212,177,166,224,42,254,155,18,91,141,215,219,72,134,10, + 126,127,197,208,97,46,101,230,252,56,195,178,84,202,108,91,45,230,172,150,245,49,135,181,40,46,18,161,135,29,3,235, + 12,32,117,239,153,205,202,132,43,148,86,106,13,189,105,106,25,88,95,114,211,86,84,41,44,48,82,168,183,100,53,215, + 170,3,2,216,11,236,10,239,32,120,28,19,189,211,227,117,171,230,81,171,108,159,214,68,211,159,127,165,122,103,199,153, + 181,143,53,48,246,247,96,250,37,1,5,212,235,104,5,188,94,110,166,58,108,163,27,127,46,63,186,33,116,242,175,221, + 36,234,75,63,48,60,172,66,181,72,38,22,38,52,153,220,10,179,240,140,91,183,80,64,241,132,165,30,188,193,200,172, + 134,18,191,181,144,100,31,103,107,20,21,122,35,80,165,98,249,158,63,228,242,0,52,124,130,106,206,14,229,195,67,212, + 195,244,71,250,207,28,159,36,63,227,57,44,182,155,36,63,138,247,205,78,207,172,213,151,46,152,219,201,68,212,102,247, + 214,58,151,171,55,26,244,72,148,197,55,10,244,240,162,28,19,26,167,247,240,22,248,213,196,116,138,239,147,191,161,235, + 206,186,179,74,2,100,212,20,46,4,10,230,68,203,29,50,127,232,27,154,216,90,126,156,253,213,167,149,209,169,204,85, + 119,251,173,223,199,71,112,204,21,225,39,114,163,10,170,222,227,152,134,159,15,222,189,26,97,82,26,253,55,57,118,189, + 74,100,226,136,144,244,221,23,223,191,236,132,77,37,45,2,10,223,143,112,47,32,116,196,232,118,180,167,83,109,72,155, + 120,223,240,55,129,74,253,246,163,107,11,53,118,216,195,50,134,117,0,62,140,41,64,44,0,94,197,68,227,110,1,12, + 45,95,226,180,136,76,178,205,112,40,181,239,47,39,208,13,245,67,116,221,163,198,135,162,122,57,4,112,193,224,177,49, + 5,34,255,115,53,87,1,37,139,46,40,237,183,226,79,215,47,241,109,145,97,103,29,179,130,202,151,182,250,204,123,46, + 255,220,66,30,169,57,221,142,170,137,199,11,204,67,44,30,56,98,28,19,120,32,87,31,154,226,207,224,86,202,90,218, + 38,157,231,164,45,145,6,176,164,117,16,158,161,238,7,250,25,48,57,181,252,126,156,207,154,38,106,215,50,178,194,120, + 81,56,244,102,100,30,45,227,179,121,114,78,133,207,198,25,90,23,29,74,17,31,219,220,223,115,88,81,20,24,177,228, + 191,1,248,122,154,241,240,184,79,71,123,88,175,245,208,24,122,192,125,119,171,217,215,97,49,87,77,206,214,60,6,49, + 248,216,172,66,197,122,0,192,5,103,2,95,24,189,223,99,72,153,58,103,170,72,206,48,153,122,156,174,112,187,210,106, + 79,60,39,38,9,107,136,232,147,117,108,84,158,174,4,31,98,172,177,239,128,235,151,164,73,93,145,185,84,55,250,74, + 134,213,68,207,34,48,53,213,176,210,106,126,171,130,190,69,55,188,22,84,32,30,117,228,164,16,16,216,118,232,178,154, + 179,102,109,105,219,181,254,253,255,26,88,104,5,43,135,42,72,87,137,14,255,38,95,151,143,173,124,60,219,239,32,87, + 164,72,15,241,62,188,217,18,193,195,227,225,205,98,25,49,66,167,212,101,108,122,235,231,180,159,232,119,100,135,218,168, + 129,220,244,58,187,133,82,138,65,150,31,255,72,52,70,167,152,70,199,195,224,91,158,86,113,19,163,77,11,243,20,51, + 45,83,23,109,80,226,181,236,90,52,83,145,108,89,207,206,184,240,141,162,145,165,59,111,202,217,157,70,142,8,248,222, + 91,212,220,99,128,90,28,7,112,61,224,62,130,167,175,87,214,56,220,8,41,65,212,80,122,132,216,192,211,217,159,245, + 48,179,112,105,136,185,48,118,16,84,41,62,137,179,222,70,85,68,95,255,214,156,139,127,243,201,253,208,85,200,235,166, + 150,57,33,86,21,243,21,187,8,105,186,204,82,64,99,249,226,38,160,106,185,148,106,138,205,214,228,220,162,185,77,119, + 238,170,88,47,140,119,192,132,224,31,129,254,8,132,233,199,177,26,58,66,197,234,78,182,98,169,207,139,15,55,255,13, + 114,27,121,120,184,158,182,79,196,68,127,181,63,252,173,51,95,9,202,104,3,7,216,38,32,104,221,93,141,120,251,250, + 246,181,189,211,134,110,160,92,194,50,168,9,234,13,36,192,202,52,146,83,83,148,131,232,130,182,187,3,78,27,196,204, + 52,150,238,48,37,249,237,72,58,89,110,61,213,13,172,198,161,206,235,3,117,194,250,143,36,125,189,96,110,47,1,14, + 162,62,96,226,9,144,230,39,240,96,196,190,1,161,161,112,170,240,56,19,218,12,53,64,100,239,170,4,151,178,251,115, + 245,228,12,204,115,145,124,151,69,108,4,121,159,79,175,145,138,55,169,73,235,42,185,222,28,57,6,63,104,94,179,109, + 175,208,188,114,249,56,11,185,81,160,87,54,181,253,57,96,248,232,178,59,194,158,29,173,174,61,139,6,63,77,21,201, + 201,91,90,37,213,110,189,46,67,115,163,125,29,44,57,53,192,23,54,3,184,23,1,104,86,189,76,179,153,160,231,172, + 56,245,210,249,63,103,22,164,75,159,13,115,190,242,218,139,127,54,98,249,35,125,193,29,104,251,184,96,151,3,251,206, + 40,60,212,241,61,52,82,72,187,202,80,152,252,43,136,153,252,36,86,46,111,42,238,41,148,45,127,253,38,232,49,39, + 94,100,51,113,254,31,65,67,118,252,88,211,64,221,233,97,82,201,38,89,241,58,249,25,13,14,40,163,227,237,61,226, + 131,190,162,75,245,3,253,195,48,167,112,31,145,198,23,216,113,170,208,89,0,178,188,119,247,192,233,163,71,14,82,173, + 195,193,230,120,21,228,25,157,59,155,197,4,8,133,103,0,194,201,107,160,233,213,152,51,20,7,42,145,30,195,206,42, + 119,239,25,152,49,220,190,169,83,135,207,209,29,201,64,250,138,14,4,117,86,225,57,1,179,13,65,67,233,27,171,126, + 168,125,169,177,114,128,79,174,213,52,13,9,25,99,105,20,5,225,139,193,219,220,100,177,50,82,252,189,38,27,153,132, + 75,43,222,169,125,181,97,5,89,50,16,111,235,143,115,88,20,36,114,196,137,108,32,46,184,27,98,237,31,255,157,214, + 207,88,193,252,155,210,129,210,234,134,123,221,79,119,59,92,219,232,26,14,31,189,159,8,85,168,213,174,3,184,78,248, + 209,163,55,190,41,195,166,35,109,116,148,254,72,6,150,201,199,76,253,144,225,237,144,25,136,73,194,23,129,77,104,47, + 66,88,21,224,252,154,150,139,239,237,183,36,199,22,118,52,189,134,166,248,83,212,84,247,188,107,215,186,157,26,118,246, + 240,221,29,183,30,168,64,177,82,8,212,176,48,23,193,238,245,65,183,175,105,57,12,128,137,99,78,8,74,117,119,220, + 0,145,34,47,63,252,134,47,216,22,129,147,184,199,78,33,61,247,86,49,73,210,85,19,76,160,100,110,60,52,27,146, + 133,76,127,72,175,182,244,44,25,244,88,209,166,198,180,137,128,57,230,198,46,36,1,94,0,188,50,175,81,222,219,226, + 90,158,75,213,211,246,111,147,95,102,104,239,232,9,76,46,125,89,71,174,228,187,24,50,190,26,76,68,100,128,93,200, + 220,118,32,124,203,42,157,78,167,39,141,130,29,21,3,151,39,60,17,104,59,243,51,180,253,182,172,101,93,92,24,44, + 189,2,132,215,48,37,59,144,82,54,20,133,56,28,50,120,8,164,92,121,102,114,42,122,61,243,3,179,23,82,154,252, + 235,136,153,42,74,42,191,189,218,172,67,101,67,137,214,101,135,116,120,203,21,128,34,108,110,185,69,224,109,190,1,137, + 153,198,11,157,6,162,86,22,93,128,168,16,29,254,247,227,199,201,45,230,42,102,225,167,54,95,142,172,26,190,186,179, + 209,198,92,48,85,6,224,236,169,140,88,61,230,251,116,18,192,41,58,98,176,247,243,226,150,67,221,92,228,58,118,214, + 247,155,92,101,92,251,153,37,54,202,85,214,156,72,191,179,116,20,134,194,77,112,218,194,251,138,239,44,45,75,54,212, + 43,119,5,254,200,119,67,249,50,165,107,214,204,255,166,112,193,162,235,247,70,194,99,174,234,218,4,26,204,76,145,217, + 98,154,197,81,32,98,70,212,28,83,238,157,20,43,228,141,19,0,50,214,155,106,154,59,60,43,88,82,115,191,99,248, + 135,252,166,81,185,34,117,14,203,119,170,186,217,136,193,170,211,22,13,164,5,50,38,224,51,193,202,235,114,102,50,49, + 215,105,243,232,119,24,25,40,125,144,143,168,134,116,75,205,251,64,81,120,57,102,229,152,59,60,254,167,92,137,16,190, + 30,34,233,237,247,40,175,250,216,92,223,107,55,213,13,172,68,155,130,163,141,47,167,21,74,216,26,235,34,245,122,40, + 80,173,89,69,233,188,51,197,242,72,158,142,114,17,165,133,105,19,72,110,14,84,11,245,190,112,114,229,74,53,195,104, + 98,207,0,71,17,109,121,7,29,144,4,199,117,17,89,226,222,91,235,45,14,197,150,51,174,193,58,179,244,71,72,232, + 61,67,182,167,12,29,186,172,167,238,145,10,207,61,22,137,90,176,163,175,224,75,47,215,23,209,98,210,6,227,25,1, + 151,114,77,161,103,144,35,148,52,153,101,38,253,96,201,211,22,97,161,116,117,162,173,54,114,5,218,56,14,137,49,5, + 248,119,96,200,205,17,11,254,216,20,250,61,198,75,166,238,68,207,162,103,152,124,142,82,38,127,220,240,92,240,113,216, + 88,55,32,28,64,125,177,223,2,26,240,220,18,63,73,98,26,105,5,236,207,221,10,189,128,92,161,212,201,191,247,167, + 140,129,69,213,160,181,49,238,60,242,181,159,151,36,0,31,39,93,64,24,155,53,134,171,192,7,60,225,226,55,141,150, + 144,22,125,94,145,163,7,69,192,138,165,230,199,233,73,86,45,124,211,116,124,93,138,6,201,62,3,41,126,190,251,147, + 97,84,39,67,11,17,26,144,176,225,174,214,42,135,164,34,235,186,3,93,179,217,89,95,239,236,4,149,50,223,217,151, + 206,93,53,99,117,31,187,13,78,67,113,8,233,131,130,155,3,116,180,156,36,122,212,6,114,40,113,63,228,31,221,212, + 52,212,59,109,181,241,133,183,118,150,72,226,255,51,180,85,159,184,203,44,47,35,75,174,198,162,68,112,77,160,12,239, + 73,81,38,73,248,205,123,15,82,198,12,26,72,207,103,254,144,235,222,97,121,120,101,161,6,95,229,217,133,172,142,138, + 56,47,180,88,65,156,210,34,131,68,51,179,43,65,75,191,101,48,9,204,65,72,30,221,10,14,60,29,26,166,222,57, + 60,79,47,210,131,149,110,239,8,174,71,21,8,128,57,121,230,54,97,187,180,226,139,198,192,129,193,44,10,129,38,7, + 77,221,71,20,122,12,249,59,148,68,232,22,222,229,184,37,34,65,220,138,104,9,20,33,30,108,26,224,186,68,90,57, + 198,170,36,66,41,59,179,86,126,162,9,39,18,253,63,230,108,224,226,18,213,32,22,142,246,173,67,25,214,89,135,223, + 5,62,87,173,253,160,16,186,151,254,142,241,148,249,67,88,98,131,4,202,117,154,164,74,253,251,87,33,230,240,215,27, + 65,25,54,245,21,107,135,238,193,45,1,10,143,43,221,141,247,230,237,108,233,95,52,252,112,114,138,76,71,109,223,141, + 225,121,10,39,223,28,12,174,195,232,224,172,144,190,162,203,192,187,108,6,73,203,64,201,5,231,21,74,45,23,164,134, + 21,219,54,159,134,202,160,122,168,123,162,231,82,30,212,8,245,92,58,180,81,111,177,7,171,144,40,25,192,160,158,197, + 10,240,30,127,146,164,134,113,91,68,84,206,198,218,151,16,29,98,64,204,127,13,172,113,126,188,134,226,67,203,112,28, + 217,248,32,144,5,127,176,158,141,116,191,53,224,35,158,21,98,84,82,197,167,147,62,47,178,12,33,123,40,28,42,250, + 161,219,149,25,185,102,132,91,169,230,109,232,87,150,207,67,23,193,106,98,227,190,62,117,71,28,29,212,226,239,147,124, + 101,156,29,95,246,93,170,225,61,59,43,251,246,178,71,125,134,20,207,30,120,69,154,224,55,23,129,120,20,244,244,129, + 202,82,59,94,108,13,188,60,104,76,185,79,251,161,54,62,131,93,20,27,154,237,65,139,91,79,61,156,224,99,44,11, + 240,252,105,60,68,90,72,9,71,19,24,7,14,221,180,116,135,74,59,26,108,186,3,126,200,123,234,196,20,103,246,190, + 32,185,84,164,154,192,230,8,157,224,128,180,83,69,19,52,63,14,190,231,153,45,54,76,170,139,90,147,203,93,119,147, + 157,21,108,216,208,78,29,216,177,60,79,109,190,141,20,188,22,50,192,32,10,122,22,130,183,57,56,112,106,0,245,58, + 197,44,53,166,27,154,226,15,77,137,110,203,232,126,216,99,247,32,177,28,227,130,143,2,75,80,123,245,18,1,204,14, + 195,43,156,46,170,223,117,170,155,59,236,39,154,114,195,77,238,215,211,119,99,74,177,205,64,240,111,229,23,168,252,70, + 176,36,184,131,219,206,117,191,242,15,58,65,95,193,216,206,252,161,188,49,122,63,35,147,233,249,222,209,235,75,166,26, + 146,241,169,57,30,248,136,184,139,0,115,230,54,233,0,211,43,118,114,97,97,5,1,147,77,90,134,187,169,203,232,90, + 239,131,189,44,50,119,205,80,144,44,54,57,242,7,156,7,59,57,199,194,191,213,125,47,189,160,243,41,55,44,180,31, + 51,88,60,146,252,115,102,148,170,94,188,188,89,125,121,148,218,52,27,19,164,171,74,36,27,237,198,181,231,95,81,224, + 178,248,84,161,220,244,166,231,197,84,209,0,83,204,192,10,138,77,27,169,82,227,233,21,255,96,52,11,22,190,86,16, + 117,193,39,94,8,188,207,187,73,60,212,72,212,196,52,240,106,110,39,148,13,149,66,45,127,243,249,85,144,6,228,102, + 35,30,122,232,187,163,64,165,100,158,137,40,226,60,215,251,191,103,90,253,17,32,35,97,74,240,61,96,149,29,37,252, + 122,193,13,104,17,164,14,25,141,57,78,223,9,157,128,94,105,185,128,153,17,111,49,91,132,63,17,42,81,198,233,79, + 227,111,130,238,247,202,108,228,18,132,168,134,116,30,198,155,31,58,2,163,232,109,204,165,23,188,9,156,225,59,48,68, + 252,125,240,243,79,51,79,93,192,77,252,197,18,111,141,111,25,127,13,104,203,205,98,174,100,218,66,187,127,132,230,62, + 195,65,131,17,187,243,170,31,233,97,6,240,209,171,67,72,66,171,130,113,129,224,142,197,73,202,243,172,98,10,247,213, + 110,235,124,202,206,222,140,95,149,239,211,240,124,238,66,57,93,115,175,177,55,180,254,141,158,24,240,48,95,167,132,144, + 177,16,201,239,243,155,28,175,169,110,96,13,175,31,49,163,79,147,118,122,185,236,203,106,204,116,216,80,184,136,58,223, + 209,143,32,43,76,120,116,208,55,173,163,182,79,121,120,2,235,224,6,45,40,215,104,183,52,61,193,213,17,176,118,61, + 243,145,176,7,117,94,41,203,131,37,0,95,101,159,171,94,122,239,21,186,131,254,138,113,159,57,6,52,252,208,23,153, + 193,53,234,124,23,207,222,70,32,72,32,84,220,251,239,235,196,7,248,152,63,7,168,28,92,118,235,164,199,182,2,70, + 237,198,78,201,201,32,39,12,127,166,18,19,114,7,99,173,74,190,46,226,85,28,176,12,128,233,100,0,201,72,171,52, + 51,212,243,69,210,225,177,225,128,245,162,85,138,123,45,159,6,189,79,115,172,186,4,81,32,242,207,242,253,4,228,166, + 16,43,229,184,131,197,116,73,161,48,61,156,160,6,106,109,249,5,220,179,111,199,117,154,155,87,251,253,94,185,161,115, + 83,69,3,140,217,192,170,94,215,114,175,55,51,203,167,92,168,53,137,249,13,218,4,25,254,76,114,93,54,70,49,138, + 62,99,172,113,15,129,74,36,213,253,3,91,57,88,53,103,169,198,179,156,20,35,223,23,45,132,24,200,191,255,245,249, + 110,87,35,219,81,179,205,243,114,147,115,17,44,184,119,1,189,41,215,77,108,252,71,73,216,40,241,190,115,200,74,59, + 174,159,42,71,171,101,220,26,235,154,118,153,247,167,13,127,17,233,209,55,247,119,70,18,231,133,81,162,239,68,224,179, + 192,90,155,123,161,27,190,127,101,214,65,219,160,31,74,142,102,74,51,83,161,211,31,51,125,78,102,169,114,54,137,234, + 16,107,126,82,79,183,217,184,135,224,172,227,39,238,126,241,234,111,43,232,25,24,90,255,227,28,171,123,215,214,212,255, + 226,200,229,219,94,158,93,176,28,126,4,30,163,14,242,126,1,76,143,104,222,182,247,252,82,159,208,158,218,223,203,206, + 222,180,126,20,242,228,251,57,254,82,201,203,198,76,4,84,229,56,10,53,170,5,98,230,124,150,91,104,254,32,56,38, + 221,177,170,115,170,27,88,61,18,3,29,20,199,205,144,142,181,211,45,120,118,210,168,188,122,251,192,215,176,25,173,64, + 8,81,191,246,113,125,168,49,51,17,18,128,84,39,142,230,204,163,165,181,173,203,214,223,209,212,116,120,10,75,72,34, + 96,203,78,51,31,14,69,145,211,196,173,55,103,154,235,197,62,97,156,103,46,98,22,254,56,37,165,111,26,100,187,229, + 119,213,93,245,119,85,131,41,145,1,148,217,244,229,140,250,192,22,128,119,57,94,226,125,64,71,213,146,15,231,67,58, + 90,237,123,150,13,154,252,178,212,23,30,154,53,67,218,107,85,252,149,210,92,161,249,106,186,54,47,224,153,150,1,30, + 48,157,50,108,152,86,163,163,32,120,157,51,19,191,5,52,212,58,14,222,143,120,74,38,12,187,80,127,146,239,138,185, + 143,233,11,109,2,165,253,220,178,89,189,116,121,144,78,45,108,164,208,224,164,0,178,218,243,15,126,161,55,7,142,13, + 197,82,197,166,138,6,248,49,3,171,15,26,128,70,210,192,226,222,102,79,252,186,39,203,252,18,119,51,174,249,184,97, + 210,244,75,142,55,7,254,28,66,41,119,168,239,232,118,183,70,44,74,226,22,193,236,94,2,20,178,41,124,211,193,171, + 211,151,72,201,155,188,141,10,202,189,81,247,241,111,194,130,133,131,188,35,251,175,156,51,57,24,189,155,235,174,200,113, + 226,58,152,134,158,177,53,87,249,199,6,10,75,193,179,34,79,158,244,250,123,14,174,164,204,167,141,185,135,93,225,151, + 90,176,211,97,183,200,85,200,213,8,62,72,62,19,6,208,69,232,121,170,196,73,70,167,162,94,230,46,171,27,11,178, + 75,7,44,221,67,95,185,50,120,171,74,121,158,139,227,72,208,132,114,108,84,197,115,130,58,2,220,146,79,140,219,220, + 237,98,229,74,62,48,93,225,125,168,249,227,36,127,191,93,195,219,17,176,100,153,178,183,85,27,204,127,11,112,21,234, + 192,83,48,97,88,77,249,195,179,80,149,222,119,228,184,17,65,118,118,232,253,93,54,79,18,226,56,37,68,222,17,117, + 144,74,213,203,40,100,137,15,200,88,54,77,165,222,218,190,100,81,253,185,46,219,169,110,96,21,202,215,158,232,52,90, + 100,173,164,105,181,18,158,29,30,232,65,193,147,46,80,145,203,75,180,140,180,242,249,30,103,159,148,220,137,163,182,251, + 233,128,36,101,231,249,11,31,11,194,148,48,41,248,39,96,38,76,195,9,84,112,163,255,191,138,144,67,108,15,73,133, + 20,244,57,52,167,142,57,8,157,130,62,142,193,255,55,107,4,164,79,187,250,208,228,107,116,4,134,87,88,135,16,129, + 96,217,191,30,151,61,184,22,124,196,99,34,102,65,122,121,53,216,100,40,58,172,57,191,43,155,156,254,51,101,163,239, + 216,160,244,136,50,177,214,191,57,71,117,185,142,170,130,117,54,226,181,138,25,59,188,203,95,182,153,90,3,84,172,120, + 173,102,110,211,158,230,94,178,168,249,167,6,220,135,94,140,44,166,69,234,246,27,187,70,117,35,23,39,14,246,214,11, + 91,1,248,191,76,119,13,76,59,72,107,99,240,49,119,79,21,13,240,55,6,22,77,144,126,131,145,225,91,148,232,83, + 254,102,91,203,101,103,103,22,186,250,74,160,20,243,2,190,157,188,59,40,112,107,181,7,127,202,209,34,137,166,42,166, + 28,51,7,18,158,56,66,243,103,87,53,118,28,88,157,117,129,106,23,135,160,99,75,178,105,22,244,131,170,243,137,10, + 170,22,78,149,253,205,25,189,127,141,94,253,30,242,132,50,124,86,38,212,148,57,206,17,146,141,53,95,10,255,237,14, + 160,225,119,192,210,127,13,44,220,5,16,179,186,237,66,169,93,97,91,80,79,204,96,249,88,87,54,106,102,14,165,110, + 198,18,7,229,110,171,158,209,38,202,40,104,16,6,186,87,184,171,85,217,196,229,93,172,186,223,30,59,86,26,138,196, + 234,86,119,22,205,147,148,127,97,177,247,143,156,143,137,224,216,104,7,248,59,192,109,233,173,47,194,3,191,183,199,247, + 218,13,25,140,69,43,67,67,16,37,236,75,86,124,205,13,110,119,177,80,146,3,106,60,51,164,236,255,76,29,193,224, + 153,144,51,87,138,11,195,138,41,204,28,66,153,105,212,196,88,205,20,61,247,237,21,24,36,11,191,147,74,32,161,197, + 1,199,205,7,242,182,115,93,30,113,206,235,95,58,152,55,66,155,234,6,214,231,132,228,239,21,207,102,11,158,219,96, + 118,2,158,157,9,154,86,220,56,91,112,237,12,59,105,45,211,45,46,124,81,222,69,19,130,66,222,186,182,59,112,240, + 221,221,10,107,32,129,151,183,251,236,17,35,75,228,26,192,110,230,211,1,208,144,95,79,114,153,113,90,244,249,220,146, + 186,102,168,27,190,168,83,198,74,155,247,251,132,13,101,215,231,220,150,149,55,159,246,7,76,165,200,248,92,117,112,102, + 224,42,30,31,49,30,210,22,217,184,215,167,130,148,50,221,202,228,91,185,104,201,244,38,230,146,137,224,51,109,128,49, + 143,41,156,231,86,85,221,158,114,177,128,16,28,62,109,70,132,244,67,211,173,72,32,207,12,9,8,154,143,135,105,133, + 199,128,90,60,175,197,167,147,154,95,55,184,107,164,209,104,195,140,89,204,51,63,83,242,97,99,29,71,217,126,58,241, + 65,155,15,5,129,191,65,15,180,177,17,124,202,97,130,55,3,93,221,108,99,222,151,44,131,58,33,50,68,157,242,6, + 86,143,29,153,155,226,0,56,250,237,203,126,182,112,181,130,165,229,33,152,77,226,192,16,60,225,217,224,245,63,80,154, + 222,131,139,55,56,106,86,59,220,180,29,9,51,40,216,214,181,170,127,255,240,139,241,37,177,222,174,61,172,127,72,86, + 228,53,95,144,40,199,30,124,44,152,11,127,253,8,248,142,77,179,192,3,220,122,234,253,253,78,159,99,221,123,7,4, + 135,255,50,56,88,213,208,162,213,235,113,64,236,230,55,119,22,134,141,58,64,69,112,138,141,217,188,91,16,88,205,107, + 133,37,9,161,240,129,196,36,188,69,16,110,62,252,172,241,76,47,129,229,252,223,2,156,66,192,0,95,178,9,94,103, + 0,10,206,219,46,191,211,98,101,218,210,98,255,230,15,99,93,95,167,172,40,142,162,99,60,106,98,11,72,235,225,183, + 85,130,82,40,66,93,155,128,227,199,238,222,93,226,21,86,123,167,109,113,223,152,13,133,198,251,157,11,7,130,247,87, + 220,36,185,123,34,109,176,27,38,198,119,133,173,4,252,23,172,85,184,103,201,21,240,36,197,186,114,35,20,12,165,67, + 149,99,112,188,115,50,141,160,249,196,151,254,225,217,253,28,175,69,206,19,15,162,61,2,113,133,32,158,219,78,52,151, + 180,217,142,35,108,111,193,13,118,118,104,227,129,14,198,192,147,35,26,183,195,61,77,97,25,155,77,48,71,121,4,174, + 195,11,128,186,231,92,94,1,95,26,134,35,169,203,232,91,152,52,72,11,186,204,36,67,231,33,173,95,54,246,66,23, + 33,109,102,6,180,1,146,135,162,160,76,168,226,199,57,243,33,209,251,69,38,129,119,167,120,129,145,44,34,219,104,26, + 25,225,128,158,5,161,138,243,45,197,82,61,139,157,155,31,143,131,74,109,132,106,97,189,218,210,94,56,176,208,91,55, + 65,163,76,82,140,219,64,251,179,48,207,53,113,97,210,16,210,200,124,253,184,92,189,44,193,53,219,95,234,110,116,78, + 105,8,234,184,58,32,139,142,216,206,119,125,209,195,56,236,201,71,223,252,184,48,226,216,72,192,18,117,27,159,63,67, + 156,55,30,197,207,195,24,224,47,128,150,171,211,47,184,218,221,50,148,119,191,157,142,47,48,169,137,238,60,1,237,135, + 116,32,31,182,130,128,158,244,229,12,66,110,64,165,72,91,163,33,222,253,101,186,238,186,35,26,159,237,107,56,248,241, + 203,192,219,163,224,159,72,191,135,241,185,174,111,103,101,175,226,52,0,170,212,177,231,253,129,238,45,38,221,210,131,66, + 63,223,176,104,148,232,24,25,32,173,40,82,203,182,41,30,133,245,70,45,69,7,128,150,5,214,10,67,150,203,227,230, + 230,181,214,183,64,83,234,249,19,3,171,46,189,141,214,255,234,70,166,249,210,88,206,25,100,41,53,147,0,120,146,138, + 0,253,247,91,239,255,188,145,227,22,0,185,179,183,156,91,111,38,164,240,249,205,131,224,136,224,156,244,162,170,204,126, + 167,161,107,35,189,76,87,136,11,210,30,179,165,255,145,158,201,128,82,43,139,227,154,113,178,158,175,245,130,84,121,119, + 137,175,39,245,194,223,74,0,143,142,67,201,238,76,156,40,208,255,170,192,237,121,218,37,90,42,189,149,185,224,79,54, + 134,18,173,154,161,245,96,208,110,86,162,4,23,89,244,4,49,145,189,30,230,191,181,232,33,128,75,133,130,213,245,109, + 177,143,190,217,115,37,237,51,124,231,254,42,253,225,235,111,110,244,244,117,63,103,124,27,226,57,63,227,142,188,157,161, + 91,240,13,46,7,81,58,105,3,76,213,8,250,4,82,92,60,120,84,96,64,234,160,201,3,71,225,8,247,194,176,31, + 95,101,198,60,70,59,51,238,181,167,187,108,26,19,62,152,21,9,110,200,234,16,199,158,2,44,60,143,96,162,226,249, + 126,107,136,123,175,32,89,141,210,48,86,121,235,181,37,215,141,8,169,244,188,247,9,73,130,205,32,69,64,125,220,13, + 172,229,176,228,188,198,221,4,232,106,139,62,60,15,221,216,151,59,232,59,18,54,86,58,71,40,52,43,6,246,210,3, + 146,69,164,29,70,19,255,2,12,68,157,125,85,4,120,47,106,81,50,179,58,29,106,146,233,91,195,86,251,219,12,158, + 210,185,45,23,54,28,209,164,58,216,192,111,22,2,208,162,22,109,193,95,2,157,55,94,211,42,114,92,175,97,1,232, + 135,27,107,165,17,231,71,124,210,138,35,206,138,120,247,203,198,72,208,60,226,240,227,76,251,204,164,215,109,222,61,17, + 67,124,63,196,148,90,168,13,234,215,185,78,218,22,121,29,227,140,45,4,252,144,38,39,40,178,229,112,66,64,241,138, + 24,117,14,155,232,210,141,13,248,46,90,175,26,185,132,146,214,123,152,28,67,9,255,147,81,138,156,75,137,239,188,213, + 23,59,188,191,193,175,227,245,192,179,18,163,250,212,174,184,184,250,252,39,13,71,29,77,35,183,20,86,222,189,105,173, + 26,31,127,70,240,129,143,79,251,140,36,233,103,166,199,224,175,28,2,154,225,47,238,66,174,91,108,215,235,33,94,213, + 189,56,30,32,236,65,150,173,126,226,98,74,22,53,134,30,199,142,140,57,74,71,36,21,90,241,207,151,24,49,102,25, + 37,20,240,194,184,208,249,159,35,18,152,99,93,125,57,114,69,108,136,186,187,246,92,157,235,186,238,225,21,59,254,68, + 249,47,235,83,139,43,109,42,129,102,249,222,213,131,37,148,44,218,21,106,7,93,138,17,70,83,167,59,49,218,104,11, + 232,122,140,204,145,118,154,33,67,186,67,175,183,109,136,156,181,167,236,115,171,132,237,174,80,102,1,247,165,40,35,254, + 200,174,45,47,117,146,157,142,114,44,22,225,4,59,224,175,36,33,25,138,200,233,57,110,244,35,70,39,118,43,128,223, + 208,173,101,226,192,76,196,23,44,106,148,249,85,134,69,198,195,82,139,22,195,153,60,210,121,166,39,96,218,184,192,75, + 168,53,21,31,176,117,151,202,85,45,215,221,133,71,107,113,157,247,167,166,129,101,1,91,233,223,190,93,169,252,222,254, + 64,156,215,160,235,243,91,238,20,49,93,146,30,210,179,175,28,73,184,51,253,95,24,129,84,58,224,110,177,48,199,177, + 206,192,211,249,100,133,233,22,30,216,162,199,130,126,26,132,15,190,250,89,213,233,55,74,190,180,44,173,21,106,109,238, + 75,104,241,235,86,27,92,219,94,217,235,57,100,212,118,163,199,107,176,166,209,181,115,239,64,66,185,100,163,79,207,198, + 47,148,180,243,85,34,186,239,141,175,71,79,19,170,81,175,180,93,193,177,83,100,54,200,68,154,52,239,254,29,152,145, + 29,19,7,235,1,16,150,71,170,118,216,92,72,58,83,200,219,216,250,39,92,137,134,50,160,250,175,125,25,164,234,43, + 75,139,85,118,88,31,68,112,104,220,216,116,71,151,128,120,158,79,98,145,164,168,119,84,175,25,153,24,106,14,125,37, + 35,12,170,130,10,33,26,100,5,185,64,149,63,105,68,158,16,165,140,132,106,235,5,170,10,81,150,172,122,76,78,32, + 21,245,236,120,65,93,206,24,145,60,226,157,7,62,182,177,9,237,63,46,124,253,138,67,243,71,58,47,206,39,28,10, + 223,4,115,120,29,128,34,45,122,180,25,203,25,77,194,238,71,79,237,167,37,182,50,119,49,189,161,157,99,221,6,244, + 103,140,215,204,139,47,52,93,178,83,85,96,115,205,128,80,52,238,129,212,231,160,224,226,51,202,211,173,158,199,87,126, + 215,105,168,66,183,93,7,175,83,20,104,18,71,19,239,220,246,100,237,8,67,112,62,234,236,171,84,128,115,251,35,93, + 101,103,114,126,99,181,87,135,1,59,74,196,95,58,121,89,197,12,65,72,54,205,28,190,252,224,214,161,66,42,255,143, + 194,126,236,61,224,22,6,115,58,225,83,58,60,122,126,10,255,213,227,169,253,31,11,14,60,187,25,235,49,173,161,162, + 131,52,240,67,248,73,253,219,134,4,70,242,69,60,244,85,253,45,97,249,180,39,72,253,142,151,54,102,158,204,2,175, + 241,202,137,183,25,41,111,54,214,185,235,180,96,107,244,229,121,206,220,91,3,46,11,56,65,127,50,134,93,22,116,230, + 220,114,70,167,205,233,230,134,97,45,35,71,190,53,87,46,138,216,85,47,121,161,156,108,213,54,83,73,26,50,125,197, + 234,15,193,242,154,156,161,17,12,255,8,92,142,23,134,31,226,137,193,30,5,206,174,230,58,207,176,227,79,250,84,184, + 190,177,131,253,131,170,51,191,159,111,88,85,58,241,229,206,64,42,76,243,37,36,150,34,62,1,73,26,163,137,31,11, + 89,241,25,225,86,96,1,198,24,239,1,198,204,35,203,39,91,92,95,39,170,97,98,31,179,199,231,250,12,183,229,216, + 151,143,242,125,201,18,67,207,186,3,130,69,28,245,165,253,47,31,30,188,45,233,121,102,235,174,75,158,78,229,43,18, + 212,50,108,210,167,127,145,202,53,249,6,191,103,16,88,5,243,68,16,216,131,224,228,61,26,151,16,231,127,142,200,233, + 140,165,1,241,139,246,42,218,89,58,123,234,198,117,149,218,211,203,25,81,76,179,95,96,83,176,2,193,195,206,7,163, + 54,23,121,242,13,75,8,24,175,28,45,41,67,123,110,158,137,33,156,63,91,253,76,49,192,184,93,187,87,105,232,230, + 20,51,176,70,24,52,71,198,249,32,238,180,189,85,243,119,57,92,73,119,161,193,226,27,199,178,175,113,169,224,201,49, + 245,212,27,21,154,245,224,19,228,192,102,225,173,203,1,116,174,167,162,206,68,72,224,157,100,151,137,244,218,32,13,156, + 61,225,104,229,157,72,175,11,248,57,79,230,249,117,157,126,244,160,201,39,100,207,230,107,69,174,61,139,230,43,241,90, + 54,240,74,139,103,27,169,98,154,241,93,32,5,105,23,202,234,28,206,131,36,204,138,163,15,99,253,209,30,231,50,167, + 34,46,1,60,125,197,193,68,44,250,21,249,241,112,16,245,79,82,255,154,4,58,175,15,52,138,94,210,127,242,153,3, + 179,80,152,10,236,68,242,9,94,179,147,139,0,207,101,31,112,14,43,241,200,195,79,168,206,182,173,177,95,247,215,46, + 252,55,124,37,208,126,100,27,215,229,21,206,240,13,67,184,19,88,194,94,241,179,240,26,130,153,140,229,203,174,47,170, + 84,87,250,252,31,131,72,104,138,237,100,144,37,143,122,220,241,241,82,130,165,5,131,148,37,143,213,112,201,2,79,113, + 95,21,245,35,173,50,219,245,197,243,91,37,59,60,113,190,25,37,87,148,194,51,87,108,1,137,101,40,84,163,9,86, + 254,233,145,67,194,92,194,159,0,237,111,116,154,27,198,222,27,169,160,153,48,68,208,81,216,112,170,99,239,192,62,33, + 7,245,91,182,240,161,136,155,5,100,163,46,251,247,39,40,156,105,121,152,230,171,223,165,223,255,126,56,154,29,190,25, + 185,5,108,206,61,199,161,136,75,1,207,192,239,231,67,147,222,62,169,59,22,180,1,139,47,202,16,174,135,239,232,223, + 51,72,27,249,33,180,188,146,173,245,239,187,236,119,191,189,38,235,106,1,191,129,72,104,96,75,126,48,184,33,240,60, + 172,67,118,0,88,120,228,7,118,252,237,184,140,213,241,16,123,10,144,68,12,86,216,92,192,150,178,188,104,56,77,36, + 221,88,0,188,194,94,98,192,95,238,199,124,16,199,187,82,52,133,180,224,145,176,93,102,98,27,229,50,149,68,255,50, + 94,90,43,225,200,119,189,6,104,213,220,243,86,182,161,240,140,158,2,15,126,111,44,61,65,37,41,172,25,13,179,56, + 143,91,196,234,241,128,61,15,104,192,227,1,64,4,209,87,137,72,43,179,105,240,184,19,168,130,127,255,24,184,129,232, + 121,97,120,244,4,88,151,234,251,44,167,3,126,3,235,76,156,16,24,106,100,238,184,43,32,247,236,143,231,62,152,153, + 144,4,63,43,230,24,81,99,232,251,25,222,191,236,104,17,134,30,65,126,79,4,28,14,39,101,115,118,136,222,33,54, + 33,56,236,79,81,249,65,223,192,154,202,144,112,250,202,38,227,158,232,35,244,11,140,135,76,181,41,102,96,125,176,240, + 22,206,124,190,114,191,122,187,173,50,210,3,142,133,3,116,116,156,34,220,184,255,143,115,141,223,207,50,80,112,225,224, + 1,120,60,6,180,33,21,67,233,136,3,188,116,180,201,9,18,168,186,240,123,91,71,148,183,189,255,117,171,96,239,0, + 87,214,99,53,159,58,156,201,136,43,125,221,146,253,39,161,201,253,244,183,140,250,15,15,96,158,88,243,38,136,119,25, + 193,11,140,231,6,181,217,84,58,187,129,186,185,18,114,75,204,13,189,15,196,167,148,109,152,12,11,223,162,209,141,25, + 228,63,253,246,193,103,159,90,88,136,75,8,55,217,187,87,9,111,39,184,31,10,211,123,226,209,83,47,211,254,169,63, + 241,71,104,40,203,109,148,239,174,93,74,80,177,177,150,129,185,148,131,6,45,26,219,7,68,207,47,81,144,178,72,12, + 24,74,73,174,228,99,135,39,81,78,185,164,186,199,75,232,42,146,214,135,224,55,103,3,238,227,113,27,198,182,2,97, + 107,55,92,76,177,63,153,165,91,214,210,74,100,135,194,88,189,188,43,245,183,230,133,201,155,88,176,192,60,85,0,26, + 10,170,88,97,160,121,176,209,32,168,174,249,241,106,104,11,3,98,190,134,80,86,229,140,244,208,220,24,74,119,146,172, + 138,226,173,96,41,74,35,104,255,195,250,25,32,26,76,120,46,193,244,229,87,215,143,105,220,12,105,38,23,51,243,71, + 56,19,61,252,237,90,253,242,229,149,106,226,54,172,38,181,230,192,235,127,112,177,203,104,168,238,32,235,56,132,141,254, + 239,199,6,238,26,122,229,87,13,181,168,244,186,143,175,214,162,0,84,59,186,39,105,195,231,245,57,129,179,76,165,63, + 153,42,34,109,166,50,199,61,92,56,246,51,238,103,127,247,52,210,252,56,14,112,16,60,120,206,192,236,252,43,15,55, + 209,52,243,254,174,33,23,234,182,95,123,178,48,79,50,163,161,125,178,213,175,53,130,220,49,27,176,116,228,218,124,12, + 85,201,203,55,16,203,109,32,26,72,154,246,158,219,75,53,115,9,52,5,31,140,160,134,236,98,51,86,129,232,126,36, + 115,66,17,180,26,119,7,230,175,29,71,211,24,195,192,3,51,248,165,28,76,194,204,200,65,251,242,118,48,134,153,250, + 208,159,228,93,165,223,40,105,109,209,18,122,172,254,193,246,1,130,210,206,197,102,181,224,104,222,85,54,136,189,248,158, + 240,60,124,211,208,33,74,34,109,82,244,192,98,8,51,170,153,185,170,74,239,173,67,190,33,71,227,121,196,176,70,93, + 58,128,21,7,228,215,60,184,168,106,199,76,158,93,232,208,116,250,71,104,136,59,147,191,173,62,141,151,113,86,195,200, + 6,109,113,50,118,38,176,99,67,133,214,91,7,114,246,131,242,160,54,14,118,120,82,188,165,46,189,75,116,79,193,117, + 172,27,14,62,86,237,8,29,108,26,214,205,160,52,247,61,145,79,68,131,167,71,157,30,166,44,161,134,208,143,51,216, + 50,176,44,87,7,51,242,106,248,83,36,239,27,183,194,239,15,6,247,162,160,170,3,84,224,142,23,51,38,217,188,146, + 113,219,159,198,22,254,126,199,213,190,25,67,185,210,13,47,247,125,57,139,248,65,151,254,195,42,100,139,64,49,238,84, + 177,13,164,83,142,199,35,82,11,29,199,224,13,189,19,245,160,40,102,154,202,217,66,163,46,164,113,208,198,127,176,105, + 181,7,124,5,239,196,94,32,106,29,70,99,189,125,98,252,140,124,245,134,39,19,167,187,6,46,13,69,80,159,223,226, + 182,224,140,173,228,157,37,126,203,104,230,184,36,144,76,21,110,143,194,135,42,1,18,243,94,202,111,181,216,9,4,250, + 221,205,246,25,122,52,178,150,22,56,25,78,150,238,249,3,203,134,51,14,172,190,105,233,238,2,235,132,151,132,50,180, + 6,40,110,35,80,53,231,133,220,34,115,45,111,167,132,39,101,210,83,210,192,210,27,180,188,22,103,53,131,91,106,192, + 132,229,85,50,2,87,252,99,238,160,163,153,79,57,32,150,151,71,252,8,169,254,70,129,249,142,216,165,253,87,134,56, + 169,243,254,36,198,191,183,47,115,120,153,252,113,67,191,96,97,140,9,46,22,73,165,223,8,234,179,5,38,137,193,153, + 131,171,214,122,105,96,237,141,115,166,85,236,106,155,55,217,150,95,63,216,241,104,242,77,206,112,145,1,162,53,2,93, + 161,130,250,40,210,4,160,25,71,164,119,152,46,244,144,140,109,41,33,255,205,135,231,64,50,144,177,165,102,48,53,159, + 139,203,64,52,139,180,4,173,89,47,188,142,224,112,168,64,143,228,201,211,182,171,7,24,100,171,198,164,239,240,160,244, + 136,130,196,130,103,166,1,58,72,71,60,244,181,84,103,144,251,37,47,176,115,87,205,85,130,171,65,145,110,221,226,174, + 25,236,175,215,109,37,203,196,56,87,142,116,188,38,178,67,103,128,215,80,172,148,35,184,97,166,162,52,205,20,244,212, + 138,75,43,101,11,40,184,50,164,249,118,239,201,29,111,175,172,114,185,14,207,151,12,68,255,195,186,109,166,1,206,75, + 60,148,201,214,211,34,57,115,176,181,95,127,232,6,47,196,116,129,214,26,22,187,71,165,159,199,240,8,207,35,188,255, + 61,140,254,15,60,242,71,19,66,182,2,53,155,46,106,147,28,237,131,158,165,121,85,93,101,158,101,134,64,39,39,90, + 119,117,12,244,169,13,175,189,156,96,196,136,186,203,103,125,246,163,81,60,210,20,121,195,63,184,39,236,38,132,219,135, + 1,234,186,66,141,1,251,2,219,182,48,221,130,179,35,143,105,155,25,184,201,115,166,124,91,93,121,175,141,182,158,83, + 115,158,3,39,82,223,125,10,245,238,123,5,60,92,25,122,94,217,54,61,43,174,252,84,107,242,148,52,176,186,190,247, + 231,13,55,61,104,182,155,153,40,60,163,76,250,168,233,28,120,98,186,192,5,164,91,223,131,41,42,172,163,126,163,93, + 64,29,183,160,104,3,105,211,249,37,31,139,194,102,52,233,117,198,144,255,204,195,33,0,157,131,172,45,119,126,93,159, + 191,102,198,39,105,110,19,216,226,198,157,1,186,81,187,157,71,77,171,4,240,56,207,26,49,19,210,195,119,97,94,203, + 50,108,168,23,104,93,140,103,147,109,249,237,227,194,195,11,104,211,27,164,90,77,74,17,200,202,213,168,121,190,1,54, + 70,223,97,23,1,123,223,155,120,197,101,206,128,60,161,120,168,236,47,147,202,223,48,158,48,245,244,170,45,245,226,238, + 115,136,139,236,38,46,71,241,69,150,219,153,75,56,146,64,145,162,188,72,12,236,101,112,49,106,152,81,108,177,67,23, + 122,9,37,94,233,51,57,20,173,135,57,138,189,5,92,71,146,82,31,162,48,98,218,64,121,190,155,226,33,70,82,31, + 104,222,234,153,46,204,89,76,115,136,45,23,247,48,118,36,157,198,148,249,244,50,234,11,108,244,159,241,32,200,160,173, + 66,194,41,0,148,5,110,10,84,203,147,217,210,229,250,173,93,236,80,149,115,161,66,164,237,158,224,190,115,125,102,1, + 136,199,78,246,31,150,125,21,74,160,238,244,190,82,238,146,93,240,188,230,107,231,180,31,242,175,164,14,239,164,26,107, + 243,16,79,71,180,192,111,208,39,20,254,99,120,50,122,22,172,99,29,243,216,114,192,143,83,80,196,154,168,114,56,80, + 175,215,19,23,211,252,173,163,254,35,195,156,121,138,217,244,51,53,88,219,249,30,175,193,222,251,51,108,72,9,226,51, + 205,165,211,76,53,97,218,164,0,214,238,88,137,156,95,19,144,103,246,83,185,189,155,85,215,137,237,0,66,57,23,137, + 152,16,21,143,26,222,185,230,181,58,90,38,183,178,46,137,110,202,48,100,94,155,108,103,74,224,166,212,249,149,135,22, + 44,87,112,183,160,194,148,119,163,239,63,40,60,2,44,223,177,90,183,206,133,191,115,126,159,253,240,134,41,105,96,141, + 254,15,121,215,240,99,170,151,209,242,128,185,185,139,133,242,213,65,219,149,72,33,119,20,172,52,189,193,173,83,194,245, + 250,187,49,196,66,27,186,15,232,77,95,46,181,196,68,231,114,140,177,64,212,221,86,137,238,206,193,191,188,81,229,205, + 169,82,108,127,186,109,201,229,43,206,251,225,191,125,3,220,103,179,62,133,213,218,98,27,86,30,80,17,158,251,136,207, + 247,93,173,97,219,150,190,236,201,185,252,9,161,223,227,26,119,47,48,87,232,176,220,7,175,245,65,164,84,155,13,124, + 47,225,57,4,51,157,87,36,217,72,3,178,215,112,30,245,47,91,175,140,52,209,64,198,49,145,133,79,190,251,139,97, + 102,227,238,129,2,40,190,184,4,188,195,169,36,18,68,124,124,247,134,245,190,248,113,83,235,68,59,255,151,57,155,248, + 162,207,102,25,145,97,158,68,178,178,6,199,108,220,107,130,28,7,54,223,140,112,167,54,21,116,82,201,39,216,167,170, + 170,183,229,90,175,195,193,129,91,35,30,172,250,166,147,132,96,212,190,198,35,64,219,58,62,141,91,246,81,157,75,250, + 108,135,55,161,21,29,232,59,84,255,249,64,242,211,10,45,174,21,162,175,136,205,191,36,19,101,34,245,9,136,116,226, + 195,227,55,62,57,228,87,210,189,116,96,195,112,227,143,48,166,201,168,179,150,188,239,180,196,131,116,159,92,36,17,251, + 222,212,231,195,111,146,51,141,149,53,139,229,1,86,47,205,85,113,179,190,173,231,107,121,32,110,107,213,145,230,129,94, + 229,95,171,199,6,183,82,102,210,196,140,87,7,36,229,58,9,25,171,95,176,25,134,169,61,15,80,144,48,250,126,54, + 145,11,127,145,105,133,11,97,5,61,177,151,128,203,11,213,21,175,88,106,223,234,180,40,141,219,93,45,211,242,169,111, + 221,100,54,41,140,142,124,174,205,161,241,36,139,133,146,188,145,228,156,253,40,171,137,87,225,246,0,13,103,169,207,46, + 5,124,160,149,210,33,230,150,41,108,96,253,230,87,168,98,132,49,173,99,143,228,45,172,79,146,29,126,173,19,84,202, + 31,46,185,212,56,5,102,211,81,160,29,233,109,116,99,18,186,187,17,208,81,92,31,43,188,133,35,129,115,86,199,93, + 16,182,59,65,48,247,5,179,103,245,186,145,107,71,118,254,229,182,84,164,40,211,196,180,34,136,251,34,140,48,247,224, + 69,253,136,180,134,248,200,94,22,26,238,28,48,60,71,77,182,193,92,217,167,45,81,171,124,197,100,94,254,198,59,29, + 213,3,158,171,60,207,127,183,59,58,154,142,205,102,72,69,17,80,59,173,253,32,216,39,180,49,183,19,59,240,237,47, + 221,251,249,125,26,67,195,155,200,218,67,142,223,224,191,122,13,160,241,18,245,130,202,211,212,37,180,140,165,44,155,191, + 186,231,191,26,47,158,124,141,207,184,82,189,113,110,172,92,173,121,45,2,174,219,63,38,170,6,64,85,254,25,18,137, + 198,79,29,54,68,76,47,220,195,32,51,63,64,139,216,167,42,241,104,193,180,198,19,171,250,47,204,178,99,225,62,223, + 0,174,161,150,207,66,16,47,34,246,132,226,127,98,72,128,146,66,123,135,50,135,239,12,3,98,198,191,141,247,220,148, + 177,136,227,177,136,34,113,223,63,44,28,131,180,27,23,142,4,184,53,174,0,252,225,110,204,33,232,212,143,245,93,45, + 9,172,255,218,205,179,50,229,252,62,219,42,4,134,119,214,20,154,245,73,68,183,175,71,240,186,184,64,157,63,202,146, + 228,0,242,226,2,101,14,171,55,23,152,132,53,97,3,81,124,57,85,117,115,71,214,82,25,244,226,201,163,205,232,25, + 12,47,166,109,156,86,254,140,134,195,50,7,94,126,248,162,203,71,56,107,96,100,135,224,56,194,38,23,126,62,120,11, + 209,240,147,49,92,123,24,233,199,48,139,21,244,199,25,131,43,166,17,37,4,140,133,197,190,26,184,124,6,190,4,165, + 173,168,44,26,142,163,98,232,39,38,243,105,194,88,198,24,102,250,221,169,176,234,138,151,129,47,39,207,8,7,255,152, + 23,10,76,50,206,249,34,169,196,199,247,195,108,186,19,188,152,92,76,18,180,108,202,27,88,255,229,122,117,235,201,24, + 154,109,117,230,235,183,124,223,61,207,174,61,119,13,153,118,77,66,216,152,133,116,149,207,170,174,194,58,2,176,152,226, + 200,72,214,206,217,159,232,134,29,69,66,103,176,250,114,99,159,179,110,135,184,125,64,243,12,3,105,109,83,14,133,47, + 111,108,131,235,19,21,11,112,141,111,168,23,105,20,198,167,191,156,119,26,84,0,181,120,94,142,43,46,189,41,120,85, + 150,223,140,229,171,139,1,15,141,67,65,126,16,94,26,36,105,220,7,68,194,155,200,94,195,153,212,222,201,188,252,67, + 91,40,25,52,191,35,27,110,235,122,198,192,28,80,3,152,108,38,5,223,0,249,132,44,212,141,108,207,20,237,173,29, + 233,108,254,171,239,102,241,151,153,183,190,89,166,161,186,214,186,2,94,199,18,192,7,197,183,210,193,83,179,212,100,2, + 76,7,162,141,191,205,171,11,31,47,158,148,43,53,186,245,236,93,17,169,86,98,83,13,211,86,131,0,133,252,88,222, + 213,39,248,72,238,5,86,137,186,235,247,248,183,55,71,117,57,146,199,173,137,172,231,238,184,135,165,91,4,162,37,19, + 76,22,33,8,88,11,81,174,209,125,188,41,24,117,139,104,33,29,27,67,189,74,235,98,160,76,70,30,121,71,147,96, + 44,184,112,234,147,87,216,59,140,48,94,13,180,254,135,165,183,215,128,82,220,223,197,98,72,158,134,107,220,31,164,143, + 161,75,99,162,91,193,187,198,88,190,240,179,57,198,44,211,106,27,170,2,245,137,27,183,128,207,144,178,155,211,191,123, + 172,177,111,128,39,176,220,6,17,134,224,159,69,1,53,174,199,162,137,164,21,211,157,164,156,77,188,182,127,210,21,119, + 238,125,210,235,144,146,52,24,183,45,111,184,97,198,0,215,144,53,245,216,228,63,216,154,91,187,154,200,229,118,60,97, + 233,5,39,15,143,220,94,236,249,148,239,241,89,123,163,50,120,142,110,192,27,120,52,99,141,184,14,80,254,151,84,32, + 142,230,7,23,128,162,48,37,39,0,9,248,231,253,64,43,255,123,201,213,198,169,199,124,239,238,246,250,100,95,17,222, + 84,120,163,177,176,243,208,64,253,84,49,38,186,19,7,136,148,147,10,130,111,22,6,179,224,21,18,8,58,168,93,21, + 71,193,247,60,207,196,79,26,113,218,69,132,117,21,248,64,68,200,15,202,249,71,25,88,191,37,108,234,51,27,33,153, + 166,237,157,111,6,234,92,34,163,149,138,103,137,236,213,95,227,47,179,244,140,114,150,21,3,115,17,255,4,76,129,55, + 231,44,86,115,12,220,116,164,92,118,57,120,119,28,35,223,163,162,143,52,248,28,205,139,18,222,195,194,251,198,245,131, + 74,203,53,84,15,90,135,74,127,126,185,234,203,1,255,248,228,109,21,155,123,243,6,49,35,27,127,100,218,197,185,117, + 204,46,211,189,107,175,47,112,131,213,223,169,213,31,179,97,129,56,75,88,10,143,138,132,213,104,199,211,207,63,217,173, + 62,123,225,131,157,90,238,230,138,252,54,235,201,191,252,212,53,180,4,198,133,139,115,9,114,225,24,120,22,102,4,60, + 123,28,56,131,35,44,192,172,131,239,31,222,17,89,217,141,181,127,217,60,213,77,32,198,160,132,83,96,141,228,23,147, + 85,48,223,46,125,2,81,112,59,228,83,236,60,41,121,73,139,149,213,85,45,73,125,171,199,139,39,228,202,225,52,218, + 161,221,231,175,205,116,77,132,191,178,229,211,213,31,164,71,224,147,252,172,60,25,75,83,134,215,158,248,29,165,116,232, + 20,244,0,26,7,52,26,230,41,102,36,180,247,13,209,67,61,29,54,245,78,58,126,148,132,191,40,66,88,134,118,141, + 132,31,16,10,45,230,4,47,204,43,102,218,50,169,144,14,58,170,6,18,134,55,80,173,119,131,215,86,185,126,129,231, + 174,245,137,192,166,228,76,178,241,52,241,147,7,127,144,164,168,113,177,215,220,248,217,165,63,4,46,10,205,135,206,65, + 230,86,93,33,43,242,201,240,193,57,31,216,11,191,77,153,176,246,151,204,66,137,176,6,145,147,197,240,40,240,169,23, + 158,81,250,167,81,93,173,207,181,65,244,19,113,112,246,220,115,98,102,74,43,236,212,114,108,98,119,168,233,150,187,28, + 23,191,250,116,238,103,218,211,111,78,22,41,183,163,228,114,133,235,48,45,138,221,91,201,173,212,107,180,65,198,211,169, + 120,188,65,65,80,30,84,213,40,209,209,51,224,102,251,40,108,233,247,106,209,79,6,156,254,101,203,108,85,55,89,187, + 97,50,240,141,32,204,153,51,249,4,248,162,142,117,7,88,93,73,234,217,237,114,251,151,230,84,57,171,81,18,86,129, + 213,37,226,140,19,65,156,211,74,244,48,209,123,205,253,11,100,187,20,217,244,215,216,32,15,247,45,49,212,18,227,54, + 90,79,245,208,38,168,6,234,135,232,83,139,217,101,109,141,106,221,212,61,82,215,18,220,224,171,197,169,25,31,195,81, + 75,239,41,194,124,30,25,241,67,164,129,228,186,162,83,77,121,208,148,125,48,99,253,131,222,91,100,111,202,112,196,64, + 142,96,173,255,203,211,174,155,82,235,197,147,13,186,63,199,174,180,59,191,194,214,133,59,85,44,153,148,136,209,199,107, + 131,14,24,89,252,107,48,8,179,11,127,21,116,197,204,193,203,130,102,24,206,191,72,153,231,64,236,220,57,120,57,208, + 28,179,21,127,9,116,194,200,224,95,130,129,152,39,120,18,24,201,249,90,116,46,209,101,169,138,10,214,122,167,56,175, + 129,243,103,175,103,58,206,91,83,252,98,58,242,4,235,21,6,119,82,246,208,246,143,97,2,27,33,61,200,38,78,54, + 127,91,61,89,247,176,177,96,148,187,182,42,56,28,225,172,125,137,168,29,209,8,143,90,40,70,109,162,70,68,157,246, + 18,144,47,98,185,155,127,140,103,137,238,72,29,237,3,3,63,249,151,159,209,206,52,128,22,7,20,165,36,86,222,214, + 57,70,132,34,69,81,114,224,247,17,230,161,78,56,73,57,210,32,229,97,145,87,147,55,84,2,53,65,127,130,237,30, + 121,32,71,169,54,73,183,218,216,33,170,73,91,153,200,23,225,55,230,111,201,17,185,35,124,12,98,156,230,36,87,144, + 131,135,115,168,3,227,197,19,90,59,131,143,185,197,44,38,104,254,183,74,237,91,196,61,17,41,127,67,137,14,81,51, + 162,65,123,3,144,24,94,249,238,186,103,121,198,211,222,124,114,245,200,184,161,209,208,206,211,93,25,45,158,239,226,190, + 151,42,106,243,1,102,225,169,236,200,170,78,18,73,35,242,117,254,242,170,225,14,182,90,179,15,136,15,85,83,95,62, + 186,111,247,45,145,172,125,20,4,34,52,216,148,156,201,53,158,4,83,35,12,111,95,182,204,140,11,41,127,211,24,212, + 179,247,135,76,225,5,76,39,104,245,23,153,180,197,149,190,58,178,36,193,72,201,95,70,255,89,162,116,68,169,78,46, + 233,102,36,112,173,216,52,54,70,243,142,184,213,245,248,35,47,84,92,210,82,53,137,190,254,177,57,242,110,80,236,202, + 146,171,241,71,242,243,27,116,107,172,91,77,251,136,212,50,186,56,35,14,122,5,185,66,105,208,63,244,25,104,24,94, + 70,5,162,159,124,219,81,231,240,214,210,83,35,67,95,129,211,176,57,88,97,243,51,157,205,78,115,4,62,74,182,154, + 220,193,88,224,125,192,92,204,45,188,9,24,133,145,67,78,177,131,248,91,160,7,102,61,94,19,62,215,150,225,85,65, + 107,204,92,228,180,18,68,206,181,165,120,21,248,55,27,225,83,207,17,179,15,127,3,116,67,206,175,47,152,7,120,91, + 48,1,99,133,119,2,19,167,207,151,122,98,242,120,247,138,107,243,93,1,213,87,239,243,67,231,124,204,247,121,151,53, + 47,67,178,84,182,197,100,56,111,132,65,63,63,213,121,91,119,170,45,188,95,238,177,163,253,247,164,15,218,88,240,117, + 132,50,74,233,85,34,10,71,124,191,213,108,81,17,135,105,223,219,43,50,164,244,127,200,192,250,159,79,211,206,78,67, + 242,204,180,23,197,253,205,33,110,205,49,185,37,215,239,49,109,36,18,180,164,240,207,91,2,13,183,191,208,85,112,89, + 59,251,243,185,106,179,91,28,157,34,223,136,231,16,208,209,255,31,151,101,69,196,139,240,237,96,183,32,32,123,207,172, + 107,243,58,157,45,142,197,103,109,159,97,2,86,220,59,99,157,28,223,234,188,33,178,191,40,38,169,182,80,162,137,167, + 209,175,115,227,64,39,84,197,106,86,138,242,185,14,217,65,17,148,2,106,13,61,106,208,154,114,159,38,50,180,138,82, + 65,123,15,143,197,180,55,40,71,33,74,33,237,245,96,39,37,3,54,171,46,194,106,150,60,101,214,159,2,141,64,16, + 125,9,99,37,83,105,232,48,165,149,102,204,22,31,70,199,29,148,90,218,39,218,81,186,29,35,25,106,128,186,160,190, + 63,241,156,121,210,231,48,252,134,22,83,178,105,159,134,22,81,10,104,175,199,252,149,121,148,124,218,43,74,8,213,131, + 158,13,221,131,44,161,241,43,226,45,132,165,171,131,122,137,214,197,184,53,180,129,82,73,251,240,55,148,172,164,20,209, + 222,12,14,82,114,105,6,212,203,116,30,198,229,113,94,35,5,232,45,20,50,242,132,134,103,204,25,108,162,196,211,30, + 178,181,58,199,41,237,52,19,230,50,166,17,116,132,45,191,26,142,153,8,29,31,158,55,242,145,70,30,226,164,100,210, + 158,141,131,228,76,158,145,151,53,163,225,109,35,102,116,110,166,33,179,10,186,250,67,76,73,133,47,20,13,35,157,52, + 79,198,230,161,181,148,50,218,219,95,70,255,44,74,58,237,233,240,226,17,144,70,161,157,160,191,101,116,64,159,161,24, + 168,17,250,247,249,31,79,231,145,190,216,225,217,185,103,43,190,181,37,135,124,203,92,86,93,67,12,242,183,207,145,185, + 82,96,114,34,90,78,42,245,197,201,64,223,189,45,55,86,184,85,173,221,125,49,212,222,108,201,77,229,34,171,38,193, + 114,89,103,115,161,217,7,207,157,50,115,88,156,161,124,196,202,123,253,109,77,61,135,91,187,55,95,109,113,117,57,91, + 252,236,94,128,157,222,124,11,203,184,197,70,250,1,179,114,154,190,138,103,200,87,31,47,248,88,83,213,185,161,151,147, + 124,133,50,240,207,227,36,227,3,115,59,179,123,200,115,100,27,173,120,136,31,214,207,47,81,74,239,66,74,30,237,213, + 112,46,149,143,126,18,226,128,176,208,251,169,203,147,255,7,68,104,35,79,138,61,209,160,0,0,0,37,116,69,88,116, + 100,97,116,101,58,99,114,101,97,116,101,0,50,48,49,57,45,48,55,45,49,55,84,49,57,58,49,56,58,53,56,43, + 48,57,58,48,48,42,183,222,81,0,0,0,37,116,69,88,116,100,97,116,101,58,109,111,100,105,102,121,0,50,48,49, + 57,45,48,55,45,49,55,84,49,57,58,49,56,58,53,56,43,48,57,58,48,48,91,234,102,237,0,0,0,0,73,69, + 78,68,174,66,96,130, +}; namespace System { const unsigned char Boards[30838] = { 100,97,116,97,98,97,115,101,10,32,32,114,101,118,105,115,105,111,110,58,32,50,48,49,56,45,48,55,45,50,53,10, diff --git a/bsnes/target-bsnes/resource/resource.hpp b/bsnes/target-bsnes/resource/resource.hpp index d95577ff..5d6e32a2 100644 --- a/bsnes/target-bsnes/resource/resource.hpp +++ b/bsnes/target-bsnes/resource/resource.hpp @@ -1,6 +1,7 @@ namespace Resource { extern const unsigned char Icon[3463]; extern const unsigned char Logo[23467]; +extern const unsigned char SameBoy[32358]; namespace System { extern const unsigned char Boards[30838]; extern const unsigned char IPLROM[64]; diff --git a/bsnes/target-bsnes/resource/sameboy.png b/bsnes/target-bsnes/resource/sameboy.png new file mode 100644 index 00000000..f63b422f Binary files /dev/null and b/bsnes/target-bsnes/resource/sameboy.png differ diff --git a/hiro/GNUmakefile b/hiro/GNUmakefile old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/action.cpp b/hiro/cocoa/action/action.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/action.hpp b/hiro/cocoa/action/action.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-check-item.cpp b/hiro/cocoa/action/menu-check-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-check-item.hpp b/hiro/cocoa/action/menu-check-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-item.cpp b/hiro/cocoa/action/menu-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-item.hpp b/hiro/cocoa/action/menu-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-radio-item.cpp b/hiro/cocoa/action/menu-radio-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-radio-item.hpp b/hiro/cocoa/action/menu-radio-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-separator.cpp b/hiro/cocoa/action/menu-separator.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu-separator.hpp b/hiro/cocoa/action/menu-separator.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu.cpp b/hiro/cocoa/action/menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/action/menu.hpp b/hiro/cocoa/action/menu.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/application.cpp b/hiro/cocoa/application.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/application.hpp b/hiro/cocoa/application.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/browser-window.cpp b/hiro/cocoa/browser-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/browser-window.hpp b/hiro/cocoa/browser-window.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/desktop.cpp b/hiro/cocoa/desktop.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/desktop.hpp b/hiro/cocoa/desktop.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/font.cpp b/hiro/cocoa/font.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/font.hpp b/hiro/cocoa/font.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/header.hpp b/hiro/cocoa/header.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/keyboard.cpp b/hiro/cocoa/keyboard.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/keyboard.hpp b/hiro/cocoa/keyboard.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/message-window.cpp b/hiro/cocoa/message-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/message-window.hpp b/hiro/cocoa/message-window.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/monitor.cpp b/hiro/cocoa/monitor.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/monitor.hpp b/hiro/cocoa/monitor.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/mouse.cpp b/hiro/cocoa/mouse.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/mouse.hpp b/hiro/cocoa/mouse.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/object.cpp b/hiro/cocoa/object.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/object.hpp b/hiro/cocoa/object.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/platform.cpp b/hiro/cocoa/platform.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/platform.hpp b/hiro/cocoa/platform.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/timer.cpp b/hiro/cocoa/timer.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/timer.hpp b/hiro/cocoa/timer.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/utility.cpp b/hiro/cocoa/utility.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/button.cpp b/hiro/cocoa/widget/button.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/button.hpp b/hiro/cocoa/widget/button.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/canvas.cpp b/hiro/cocoa/widget/canvas.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/canvas.hpp b/hiro/cocoa/widget/canvas.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/check-button.cpp b/hiro/cocoa/widget/check-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/check-button.hpp b/hiro/cocoa/widget/check-button.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/check-label.cpp b/hiro/cocoa/widget/check-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/check-label.hpp b/hiro/cocoa/widget/check-label.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/combo-button.cpp b/hiro/cocoa/widget/combo-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/combo-button.hpp b/hiro/cocoa/widget/combo-button.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/console.cpp b/hiro/cocoa/widget/console.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/console.hpp b/hiro/cocoa/widget/console.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/frame.cpp b/hiro/cocoa/widget/frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/frame.hpp b/hiro/cocoa/widget/frame.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/hex-edit.cpp b/hiro/cocoa/widget/hex-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/hex-edit.hpp b/hiro/cocoa/widget/hex-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/horizontal-scroll-bar.cpp b/hiro/cocoa/widget/horizontal-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/horizontal-scroll-bar.hpp b/hiro/cocoa/widget/horizontal-scroll-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/horizontal-slider.cpp b/hiro/cocoa/widget/horizontal-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/horizontal-slider.hpp b/hiro/cocoa/widget/horizontal-slider.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/label.cpp b/hiro/cocoa/widget/label.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/label.hpp b/hiro/cocoa/widget/label.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/line-edit.cpp b/hiro/cocoa/widget/line-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/line-edit.hpp b/hiro/cocoa/widget/line-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/progress-bar.cpp b/hiro/cocoa/widget/progress-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/progress-bar.hpp b/hiro/cocoa/widget/progress-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/radio-button.cpp b/hiro/cocoa/widget/radio-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/radio-button.hpp b/hiro/cocoa/widget/radio-button.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/radio-label.cpp b/hiro/cocoa/widget/radio-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/radio-label.hpp b/hiro/cocoa/widget/radio-label.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/tab-frame.cpp b/hiro/cocoa/widget/tab-frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/tab-frame.hpp b/hiro/cocoa/widget/tab-frame.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/table-view.cpp b/hiro/cocoa/widget/table-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/table-view.hpp b/hiro/cocoa/widget/table-view.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/text-edit.cpp b/hiro/cocoa/widget/text-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/text-edit.hpp b/hiro/cocoa/widget/text-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/vertical-scroll-bar.cpp b/hiro/cocoa/widget/vertical-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/vertical-scroll-bar.hpp b/hiro/cocoa/widget/vertical-scroll-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/vertical-slider.cpp b/hiro/cocoa/widget/vertical-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/vertical-slider.hpp b/hiro/cocoa/widget/vertical-slider.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/viewport.cpp b/hiro/cocoa/widget/viewport.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/viewport.hpp b/hiro/cocoa/widget/viewport.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/widget.cpp b/hiro/cocoa/widget/widget.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/widget/widget.hpp b/hiro/cocoa/widget/widget.hpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/window.cpp b/hiro/cocoa/window.cpp old mode 100644 new mode 100755 diff --git a/hiro/cocoa/window.hpp b/hiro/cocoa/window.hpp old mode 100644 new mode 100755 diff --git a/hiro/core/action/action.cpp b/hiro/core/action/action.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/action/menu-check-item.cpp b/hiro/core/action/menu-check-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/action/menu-item.cpp b/hiro/core/action/menu-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/action/menu-radio-item.cpp b/hiro/core/action/menu-radio-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/action/menu-separator.cpp b/hiro/core/action/menu-separator.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/action/menu.cpp b/hiro/core/action/menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/application.cpp b/hiro/core/application.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/browser-window.cpp b/hiro/core/browser-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/color.cpp b/hiro/core/color.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/core.cpp b/hiro/core/core.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/core.hpp b/hiro/core/core.hpp old mode 100644 new mode 100755 diff --git a/hiro/core/desktop.cpp b/hiro/core/desktop.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/font.cpp b/hiro/core/font.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/geometry.cpp b/hiro/core/geometry.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/hotkey.cpp b/hiro/core/hotkey.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/keyboard.cpp b/hiro/core/keyboard.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/menu-bar.cpp b/hiro/core/menu-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/message-window.cpp b/hiro/core/message-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/monitor.cpp b/hiro/core/monitor.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/mouse.cpp b/hiro/core/mouse.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/object.cpp b/hiro/core/object.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/popup-menu.cpp b/hiro/core/popup-menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/position.cpp b/hiro/core/position.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/sizable.cpp b/hiro/core/sizable.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/size.cpp b/hiro/core/size.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/status-bar.cpp b/hiro/core/status-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/timer.cpp b/hiro/core/timer.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/button.cpp b/hiro/core/widget/button.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/canvas.cpp b/hiro/core/widget/canvas.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/check-button.cpp b/hiro/core/widget/check-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/check-label.cpp b/hiro/core/widget/check-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/combo-button-item.cpp b/hiro/core/widget/combo-button-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/combo-button.cpp b/hiro/core/widget/combo-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/console.cpp b/hiro/core/widget/console.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/frame.cpp b/hiro/core/widget/frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/hex-edit.cpp b/hiro/core/widget/hex-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/horizontal-scroll-bar.cpp b/hiro/core/widget/horizontal-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/horizontal-slider.cpp b/hiro/core/widget/horizontal-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/icon-view-item.cpp b/hiro/core/widget/icon-view-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/icon-view.cpp b/hiro/core/widget/icon-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/label.cpp b/hiro/core/widget/label.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/line-edit.cpp b/hiro/core/widget/line-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/progress-bar.cpp b/hiro/core/widget/progress-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/radio-button.cpp b/hiro/core/widget/radio-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/radio-label.cpp b/hiro/core/widget/radio-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/source-edit.cpp b/hiro/core/widget/source-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/tab-frame-item.cpp b/hiro/core/widget/tab-frame-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/tab-frame.cpp b/hiro/core/widget/tab-frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/table-view-column.cpp b/hiro/core/widget/table-view-column.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/table-view-item.cpp b/hiro/core/widget/table-view-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/table-view.cpp b/hiro/core/widget/table-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/text-edit.cpp b/hiro/core/widget/text-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/tree-view-item.cpp b/hiro/core/widget/tree-view-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/tree-view.cpp b/hiro/core/widget/tree-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/vertical-scroll-bar.cpp b/hiro/core/widget/vertical-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/vertical-slider.cpp b/hiro/core/widget/vertical-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/viewport.cpp b/hiro/core/widget/viewport.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/widget/widget.cpp b/hiro/core/widget/widget.cpp old mode 100644 new mode 100755 diff --git a/hiro/core/window.cpp b/hiro/core/window.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/about-dialog.cpp b/hiro/extension/about-dialog.cpp index 222183d0..3b1d1d24 100644 --- a/hiro/extension/about-dialog.cpp +++ b/hiro/extension/about-dialog.cpp @@ -62,7 +62,7 @@ auto AboutDialog::show() -> void { nameLabel.setForegroundColor({0, 0, 0}); nameLabel.setFont(Font().setFamily("Georgia").setBold().setSize(36.0)); nameLabel.setText(state.name ? state.name : Application::name()); - nameLabel.setVisible((bool)state.name); + nameLabel.setVisible((bool)state.name && !(bool)state.logo); Canvas logoCanvas{&layout, Size{~0, 0}}; logoCanvas.setCollapsible(); diff --git a/hiro/extension/browser-dialog.cpp b/hiro/extension/browser-dialog.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/browser-dialog.hpp b/hiro/extension/browser-dialog.hpp old mode 100644 new mode 100755 diff --git a/hiro/extension/extension.cpp b/hiro/extension/extension.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/extension.hpp b/hiro/extension/extension.hpp old mode 100644 new mode 100755 diff --git a/hiro/extension/fixed-layout.cpp b/hiro/extension/fixed-layout.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/fixed-layout.hpp b/hiro/extension/fixed-layout.hpp old mode 100644 new mode 100755 diff --git a/hiro/extension/horizontal-layout.cpp b/hiro/extension/horizontal-layout.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/horizontal-layout.hpp b/hiro/extension/horizontal-layout.hpp old mode 100644 new mode 100755 diff --git a/hiro/extension/message-dialog.cpp b/hiro/extension/message-dialog.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/message-dialog.hpp b/hiro/extension/message-dialog.hpp old mode 100644 new mode 100755 diff --git a/hiro/extension/shared.hpp b/hiro/extension/shared.hpp old mode 100644 new mode 100755 diff --git a/hiro/extension/vertical-layout.cpp b/hiro/extension/vertical-layout.cpp old mode 100644 new mode 100755 diff --git a/hiro/extension/vertical-layout.hpp b/hiro/extension/vertical-layout.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/action.cpp b/hiro/gtk/action/action.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/action.hpp b/hiro/gtk/action/action.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-check-item.cpp b/hiro/gtk/action/menu-check-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-check-item.hpp b/hiro/gtk/action/menu-check-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-item.cpp b/hiro/gtk/action/menu-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-item.hpp b/hiro/gtk/action/menu-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-radio-item.cpp b/hiro/gtk/action/menu-radio-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-radio-item.hpp b/hiro/gtk/action/menu-radio-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-separator.cpp b/hiro/gtk/action/menu-separator.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu-separator.hpp b/hiro/gtk/action/menu-separator.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu.cpp b/hiro/gtk/action/menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/action/menu.hpp b/hiro/gtk/action/menu.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/application.cpp b/hiro/gtk/application.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/application.hpp b/hiro/gtk/application.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/browser-window.cpp b/hiro/gtk/browser-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/browser-window.hpp b/hiro/gtk/browser-window.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/desktop.cpp b/hiro/gtk/desktop.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/desktop.hpp b/hiro/gtk/desktop.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/font.cpp b/hiro/gtk/font.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/font.hpp b/hiro/gtk/font.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/header.hpp b/hiro/gtk/header.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/keyboard.cpp b/hiro/gtk/keyboard.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/keyboard.hpp b/hiro/gtk/keyboard.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/menu-bar.cpp b/hiro/gtk/menu-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/menu-bar.hpp b/hiro/gtk/menu-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/message-window.cpp b/hiro/gtk/message-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/message-window.hpp b/hiro/gtk/message-window.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/monitor.cpp b/hiro/gtk/monitor.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/monitor.hpp b/hiro/gtk/monitor.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/mouse.cpp b/hiro/gtk/mouse.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/mouse.hpp b/hiro/gtk/mouse.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/object.cpp b/hiro/gtk/object.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/object.hpp b/hiro/gtk/object.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/platform.cpp b/hiro/gtk/platform.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/platform.hpp b/hiro/gtk/platform.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/popup-menu.cpp b/hiro/gtk/popup-menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/popup-menu.hpp b/hiro/gtk/popup-menu.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/settings.cpp b/hiro/gtk/settings.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/settings.hpp b/hiro/gtk/settings.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/sizable.cpp b/hiro/gtk/sizable.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/sizable.hpp b/hiro/gtk/sizable.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/status-bar.cpp b/hiro/gtk/status-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/status-bar.hpp b/hiro/gtk/status-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/timer.cpp b/hiro/gtk/timer.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/timer.hpp b/hiro/gtk/timer.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/utility.cpp b/hiro/gtk/utility.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/button.cpp b/hiro/gtk/widget/button.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/button.hpp b/hiro/gtk/widget/button.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/canvas.cpp b/hiro/gtk/widget/canvas.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/canvas.hpp b/hiro/gtk/widget/canvas.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/check-button.cpp b/hiro/gtk/widget/check-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/check-button.hpp b/hiro/gtk/widget/check-button.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/check-label.cpp b/hiro/gtk/widget/check-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/check-label.hpp b/hiro/gtk/widget/check-label.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/combo-button-item.cpp b/hiro/gtk/widget/combo-button-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/combo-button-item.hpp b/hiro/gtk/widget/combo-button-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/combo-button.cpp b/hiro/gtk/widget/combo-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/combo-button.hpp b/hiro/gtk/widget/combo-button.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/console.cpp b/hiro/gtk/widget/console.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/console.hpp b/hiro/gtk/widget/console.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/frame.cpp b/hiro/gtk/widget/frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/frame.hpp b/hiro/gtk/widget/frame.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/hex-edit.cpp b/hiro/gtk/widget/hex-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/hex-edit.hpp b/hiro/gtk/widget/hex-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/horizontal-scroll-bar.cpp b/hiro/gtk/widget/horizontal-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/horizontal-scroll-bar.hpp b/hiro/gtk/widget/horizontal-scroll-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/horizontal-slider.cpp b/hiro/gtk/widget/horizontal-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/horizontal-slider.hpp b/hiro/gtk/widget/horizontal-slider.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/icon-view-item.cpp b/hiro/gtk/widget/icon-view-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/icon-view-item.hpp b/hiro/gtk/widget/icon-view-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/icon-view.cpp b/hiro/gtk/widget/icon-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/icon-view.hpp b/hiro/gtk/widget/icon-view.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/label.cpp b/hiro/gtk/widget/label.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/label.hpp b/hiro/gtk/widget/label.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/line-edit.cpp b/hiro/gtk/widget/line-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/line-edit.hpp b/hiro/gtk/widget/line-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/progress-bar.cpp b/hiro/gtk/widget/progress-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/progress-bar.hpp b/hiro/gtk/widget/progress-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/radio-button.cpp b/hiro/gtk/widget/radio-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/radio-button.hpp b/hiro/gtk/widget/radio-button.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/radio-label.cpp b/hiro/gtk/widget/radio-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/radio-label.hpp b/hiro/gtk/widget/radio-label.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/source-edit.cpp b/hiro/gtk/widget/source-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/source-edit.hpp b/hiro/gtk/widget/source-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tab-frame-item.cpp b/hiro/gtk/widget/tab-frame-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tab-frame-item.hpp b/hiro/gtk/widget/tab-frame-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tab-frame.cpp b/hiro/gtk/widget/tab-frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tab-frame.hpp b/hiro/gtk/widget/tab-frame.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/table-view-column.cpp b/hiro/gtk/widget/table-view-column.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/table-view-column.hpp b/hiro/gtk/widget/table-view-column.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/table-view-item.cpp b/hiro/gtk/widget/table-view-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/table-view-item.hpp b/hiro/gtk/widget/table-view-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/table-view.cpp b/hiro/gtk/widget/table-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/table-view.hpp b/hiro/gtk/widget/table-view.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/text-edit.cpp b/hiro/gtk/widget/text-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/text-edit.hpp b/hiro/gtk/widget/text-edit.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tree-view-item.cpp b/hiro/gtk/widget/tree-view-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tree-view-item.hpp b/hiro/gtk/widget/tree-view-item.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tree-view.cpp b/hiro/gtk/widget/tree-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/tree-view.hpp b/hiro/gtk/widget/tree-view.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/vertical-scroll-bar.cpp b/hiro/gtk/widget/vertical-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/vertical-scroll-bar.hpp b/hiro/gtk/widget/vertical-scroll-bar.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/vertical-slider.cpp b/hiro/gtk/widget/vertical-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/vertical-slider.hpp b/hiro/gtk/widget/vertical-slider.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/viewport.cpp b/hiro/gtk/widget/viewport.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/viewport.hpp b/hiro/gtk/widget/viewport.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/widget.cpp b/hiro/gtk/widget/widget.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/widget/widget.hpp b/hiro/gtk/widget/widget.hpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/window.cpp b/hiro/gtk/window.cpp old mode 100644 new mode 100755 diff --git a/hiro/gtk/window.hpp b/hiro/gtk/window.hpp old mode 100644 new mode 100755 diff --git a/hiro/hiro.cpp b/hiro/hiro.cpp old mode 100644 new mode 100755 diff --git a/hiro/hiro.hpp b/hiro/hiro.hpp old mode 100644 new mode 100755 diff --git a/hiro/qt/action/action.cpp b/hiro/qt/action/action.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/action/menu-check-item.cpp b/hiro/qt/action/menu-check-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/action/menu-item.cpp b/hiro/qt/action/menu-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/action/menu-radio-item.cpp b/hiro/qt/action/menu-radio-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/action/menu-separator.cpp b/hiro/qt/action/menu-separator.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/action/menu.cpp b/hiro/qt/action/menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/application.cpp b/hiro/qt/application.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/browser-window.cpp b/hiro/qt/browser-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/desktop.cpp b/hiro/qt/desktop.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/header.hpp b/hiro/qt/header.hpp old mode 100644 new mode 100755 diff --git a/hiro/qt/keyboard.cpp b/hiro/qt/keyboard.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/message-window.cpp b/hiro/qt/message-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/monitor.cpp b/hiro/qt/monitor.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/mouse.cpp b/hiro/qt/mouse.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/platform.cpp b/hiro/qt/platform.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/platform.hpp b/hiro/qt/platform.hpp old mode 100644 new mode 100755 diff --git a/hiro/qt/popup-menu.cpp b/hiro/qt/popup-menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/settings.cpp b/hiro/qt/settings.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/timer.cpp b/hiro/qt/timer.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/utility.cpp b/hiro/qt/utility.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/button.cpp b/hiro/qt/widget/button.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/canvas.cpp b/hiro/qt/widget/canvas.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/check-button.cpp b/hiro/qt/widget/check-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/check-label.cpp b/hiro/qt/widget/check-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/combo-button.cpp b/hiro/qt/widget/combo-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/frame.cpp b/hiro/qt/widget/frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/hex-edit.cpp b/hiro/qt/widget/hex-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/horizontal-scroll-bar.cpp b/hiro/qt/widget/horizontal-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/horizontal-slider.cpp b/hiro/qt/widget/horizontal-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/label.cpp b/hiro/qt/widget/label.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/line-edit.cpp b/hiro/qt/widget/line-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/progress-bar.cpp b/hiro/qt/widget/progress-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/radio-button.cpp b/hiro/qt/widget/radio-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/radio-label.cpp b/hiro/qt/widget/radio-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/tab-frame.cpp b/hiro/qt/widget/tab-frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/table-view.cpp b/hiro/qt/widget/table-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/text-edit.cpp b/hiro/qt/widget/text-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/vertical-scroll-bar.cpp b/hiro/qt/widget/vertical-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/vertical-slider.cpp b/hiro/qt/widget/vertical-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/viewport.cpp b/hiro/qt/widget/viewport.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/widget/widget.cpp b/hiro/qt/widget/widget.cpp old mode 100644 new mode 100755 diff --git a/hiro/qt/window.cpp b/hiro/qt/window.cpp old mode 100644 new mode 100755 diff --git a/hiro/resource/GNUmakefile b/hiro/resource/GNUmakefile old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/add.png b/hiro/resource/icon/action/add.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/attach.png b/hiro/resource/icon/action/attach.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/bookmark.png b/hiro/resource/icon/action/bookmark.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/close.png b/hiro/resource/icon/action/close.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/full-screen.png b/hiro/resource/icon/action/full-screen.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/mute.png b/hiro/resource/icon/action/mute.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/new-file.png b/hiro/resource/icon/action/new-file.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/new-folder.png b/hiro/resource/icon/action/new-folder.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/open.png b/hiro/resource/icon/action/open.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/properties.png b/hiro/resource/icon/action/properties.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/quit.png b/hiro/resource/icon/action/quit.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/refresh.png b/hiro/resource/icon/action/refresh.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/remove.png b/hiro/resource/icon/action/remove.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/save.png b/hiro/resource/icon/action/save.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/search.png b/hiro/resource/icon/action/search.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/settings.png b/hiro/resource/icon/action/settings.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/action/stop.png b/hiro/resource/icon/action/stop.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/browser.png b/hiro/resource/icon/application/browser.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/calculator.png b/hiro/resource/icon/application/calculator.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/calendar.png b/hiro/resource/icon/application/calendar.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/chat.png b/hiro/resource/icon/application/chat.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/file-manager.png b/hiro/resource/icon/application/file-manager.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/mail.png b/hiro/resource/icon/application/mail.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/monitor.png b/hiro/resource/icon/application/monitor.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/terminal.png b/hiro/resource/icon/application/terminal.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/application/text-editor.png b/hiro/resource/icon/application/text-editor.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/clock.png b/hiro/resource/icon/device/clock.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/display.png b/hiro/resource/icon/device/display.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/joypad.png b/hiro/resource/icon/device/joypad.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/keyboard.png b/hiro/resource/icon/device/keyboard.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/microphone.png b/hiro/resource/icon/device/microphone.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/mouse.png b/hiro/resource/icon/device/mouse.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/network.png b/hiro/resource/icon/device/network.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/optical.png b/hiro/resource/icon/device/optical.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/printer.png b/hiro/resource/icon/device/printer.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/speaker.png b/hiro/resource/icon/device/speaker.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/device/storage.png b/hiro/resource/icon/device/storage.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/clear.png b/hiro/resource/icon/edit/clear.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/copy.png b/hiro/resource/icon/edit/copy.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/cut.png b/hiro/resource/icon/edit/cut.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/delete.png b/hiro/resource/icon/edit/delete.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/find.png b/hiro/resource/icon/edit/find.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/paste.png b/hiro/resource/icon/edit/paste.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/redo.png b/hiro/resource/icon/edit/redo.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/replace.png b/hiro/resource/icon/edit/replace.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/edit/undo.png b/hiro/resource/icon/edit/undo.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/archive.png b/hiro/resource/icon/emblem/archive.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/audio.png b/hiro/resource/icon/emblem/audio.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/binary.png b/hiro/resource/icon/emblem/binary.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/file.png b/hiro/resource/icon/emblem/file.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/folder-open.png b/hiro/resource/icon/emblem/folder-open.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/folder-template.png b/hiro/resource/icon/emblem/folder-template.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/folder.png b/hiro/resource/icon/emblem/folder.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/font.png b/hiro/resource/icon/emblem/font.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/image.png b/hiro/resource/icon/emblem/image.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/markup.png b/hiro/resource/icon/emblem/markup.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/program.png b/hiro/resource/icon/emblem/program.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/script.png b/hiro/resource/icon/emblem/script.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/text.png b/hiro/resource/icon/emblem/text.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/emblem/video.png b/hiro/resource/icon/emblem/video.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/go/down.png b/hiro/resource/icon/go/down.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/go/home.png b/hiro/resource/icon/go/home.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/go/left.png b/hiro/resource/icon/go/left.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/go/right.png b/hiro/resource/icon/go/right.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/go/up.png b/hiro/resource/icon/go/up.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/back.png b/hiro/resource/icon/media/back.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/eject.png b/hiro/resource/icon/media/eject.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/flash.png b/hiro/resource/icon/media/flash.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/floppy.png b/hiro/resource/icon/media/floppy.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/next.png b/hiro/resource/icon/media/next.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/optical.png b/hiro/resource/icon/media/optical.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/pause.png b/hiro/resource/icon/media/pause.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/play.png b/hiro/resource/icon/media/play.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/record.png b/hiro/resource/icon/media/record.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/rewind.png b/hiro/resource/icon/media/rewind.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/skip.png b/hiro/resource/icon/media/skip.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/media/stop.png b/hiro/resource/icon/media/stop.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/place/bookmarks.png b/hiro/resource/icon/place/bookmarks.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/place/desktop.png b/hiro/resource/icon/place/desktop.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/place/home.png b/hiro/resource/icon/place/home.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/place/server.png b/hiro/resource/icon/place/server.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/place/share.png b/hiro/resource/icon/place/share.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/prompt/error.png b/hiro/resource/icon/prompt/error.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/prompt/information.png b/hiro/resource/icon/prompt/information.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/prompt/question.png b/hiro/resource/icon/prompt/question.png old mode 100644 new mode 100755 diff --git a/hiro/resource/icon/prompt/warning.png b/hiro/resource/icon/prompt/warning.png old mode 100644 new mode 100755 diff --git a/hiro/resource/resource.bml b/hiro/resource/resource.bml old mode 100644 new mode 100755 diff --git a/hiro/resource/resource.cpp b/hiro/resource/resource.cpp old mode 100644 new mode 100755 diff --git a/hiro/resource/resource.hpp b/hiro/resource/resource.hpp old mode 100644 new mode 100755 diff --git a/hiro/windows/action/action.cpp b/hiro/windows/action/action.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/action/menu-check-item.cpp b/hiro/windows/action/menu-check-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/action/menu-item.cpp b/hiro/windows/action/menu-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/action/menu-radio-item.cpp b/hiro/windows/action/menu-radio-item.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/action/menu-separator.cpp b/hiro/windows/action/menu-separator.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/action/menu.cpp b/hiro/windows/action/menu.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/application.cpp b/hiro/windows/application.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/browser-window.cpp b/hiro/windows/browser-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/desktop.cpp b/hiro/windows/desktop.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/font.cpp b/hiro/windows/font.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/header.hpp b/hiro/windows/header.hpp old mode 100644 new mode 100755 diff --git a/hiro/windows/hiro.Manifest b/hiro/windows/hiro.Manifest old mode 100644 new mode 100755 diff --git a/hiro/windows/hiro.rc b/hiro/windows/hiro.rc old mode 100644 new mode 100755 diff --git a/hiro/windows/keyboard.cpp b/hiro/windows/keyboard.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/message-window.cpp b/hiro/windows/message-window.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/monitor.cpp b/hiro/windows/monitor.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/mouse.cpp b/hiro/windows/mouse.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/object.cpp b/hiro/windows/object.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/platform.cpp b/hiro/windows/platform.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/platform.hpp b/hiro/windows/platform.hpp old mode 100644 new mode 100755 diff --git a/hiro/windows/timer.cpp b/hiro/windows/timer.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/utility.cpp b/hiro/windows/utility.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/button.cpp b/hiro/windows/widget/button.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/canvas.cpp b/hiro/windows/widget/canvas.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/check-button.cpp b/hiro/windows/widget/check-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/check-label.cpp b/hiro/windows/widget/check-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/combo-button.cpp b/hiro/windows/widget/combo-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/frame.cpp b/hiro/windows/widget/frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/hex-edit.cpp b/hiro/windows/widget/hex-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/horizontal-scroll-bar.cpp b/hiro/windows/widget/horizontal-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/horizontal-slider.cpp b/hiro/windows/widget/horizontal-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/label.cpp b/hiro/windows/widget/label.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/line-edit.cpp b/hiro/windows/widget/line-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/progress-bar.cpp b/hiro/windows/widget/progress-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/radio-button.cpp b/hiro/windows/widget/radio-button.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/radio-label.cpp b/hiro/windows/widget/radio-label.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/tab-frame.cpp b/hiro/windows/widget/tab-frame.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/table-view.cpp b/hiro/windows/widget/table-view.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/text-edit.cpp b/hiro/windows/widget/text-edit.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/vertical-scroll-bar.cpp b/hiro/windows/widget/vertical-scroll-bar.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/vertical-slider.cpp b/hiro/windows/widget/vertical-slider.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/viewport.cpp b/hiro/windows/widget/viewport.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/widget/widget.cpp b/hiro/windows/widget/widget.cpp old mode 100644 new mode 100755 diff --git a/hiro/windows/window.cpp b/hiro/windows/window.cpp old mode 100644 new mode 100755 diff --git a/icarus/obj/.gitignore b/icarus/obj/.gitignore deleted file mode 100644 index 6142305d..00000000 --- a/icarus/obj/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -*.d diff --git a/icarus/out/.gitignore b/icarus/out/.gitignore deleted file mode 100644 index 094b84a5..00000000 --- a/icarus/out/.gitignore +++ /dev/null @@ -1 +0,0 @@ -icarus diff --git a/libco/amd64.c b/libco/amd64.c old mode 100644 new mode 100755 diff --git a/libco/doc/style.css b/libco/doc/style.css old mode 100644 new mode 100755 diff --git a/libco/doc/targets.html b/libco/doc/targets.html old mode 100644 new mode 100755 diff --git a/libco/doc/usage.html b/libco/doc/usage.html old mode 100644 new mode 100755 diff --git a/libco/fiber.c b/libco/fiber.c old mode 100644 new mode 100755 diff --git a/libco/libco.c b/libco/libco.c old mode 100644 new mode 100755 index 6f446971..e60cedb1 --- a/libco/libco.c +++ b/libco/libco.c @@ -11,7 +11,7 @@ #include "arm.c" #elif defined(__aarch64__) #include "aarch64.c" - #elif defined(_ARCH_PPC) + #elif defined(_ARCH_PPC) && !defined(__LITTLE_ENDIAN__) #include "ppc.c" #elif defined(_WIN32) #include "fiber.c" diff --git a/libco/libco.h b/libco/libco.h old mode 100644 new mode 100755 diff --git a/libco/ppc.c b/libco/ppc.c old mode 100644 new mode 100755 index f071fab2..969fcec2 --- a/libco/ppc.c +++ b/libco/ppc.c @@ -1,3 +1,5 @@ +/* ppc64le (ELFv2) is not currently supported */ + #define LIBCO_C #include "libco.h" #include "settings.h" @@ -36,7 +38,7 @@ static thread_local cothread_t co_active_handle = 0; /* whether function calls are indirect through a descriptor, or are directly to function */ #ifndef LIBCO_PPCDESC - #if !_CALL_SYSV && (_CALL_AIX || _CALL_AIXDESC || LIBCO_PPC64) + #if !_CALL_SYSV && (_CALL_AIX || _CALL_AIXDESC || (LIBCO_PPC64 && (!defined(_CALL_ELF) || _CALL_ELF == 1))) #define LIBCO_PPCDESC 1 #endif #endif diff --git a/libco/sjlj.c b/libco/sjlj.c old mode 100644 new mode 100755 diff --git a/libco/ucontext.c b/libco/ucontext.c old mode 100644 new mode 100755 diff --git a/libco/x86.c b/libco/x86.c old mode 100644 new mode 100755 diff --git a/nall/GNUmakefile b/nall/GNUmakefile old mode 100644 new mode 100755 diff --git a/nall/algorithm.hpp b/nall/algorithm.hpp old mode 100644 new mode 100755 diff --git a/nall/any.hpp b/nall/any.hpp old mode 100644 new mode 100755 diff --git a/nall/atoi.hpp b/nall/atoi.hpp old mode 100644 new mode 100755 diff --git a/nall/bit-vector.hpp b/nall/bit-vector.hpp old mode 100644 new mode 100755 diff --git a/nall/bit.hpp b/nall/bit.hpp old mode 100644 new mode 100755 diff --git a/nall/decode/gzip.hpp b/nall/decode/gzip.hpp old mode 100644 new mode 100755 diff --git a/nall/decode/inflate.hpp b/nall/decode/inflate.hpp old mode 100644 new mode 100755 diff --git a/nall/decode/png.hpp b/nall/decode/png.hpp old mode 100644 new mode 100755 diff --git a/nall/decode/zip.hpp b/nall/decode/zip.hpp old mode 100644 new mode 100755 diff --git a/nall/directory.hpp b/nall/directory.hpp old mode 100644 new mode 100755 diff --git a/nall/dl.hpp b/nall/dl.hpp old mode 100644 new mode 100755 diff --git a/nall/encode/zip.hpp b/nall/encode/zip.hpp old mode 100644 new mode 100755 diff --git a/nall/endian.hpp b/nall/endian.hpp old mode 100644 new mode 100755 diff --git a/nall/file-map.hpp b/nall/file-map.hpp old mode 100644 new mode 100755 diff --git a/nall/file.hpp b/nall/file.hpp old mode 100644 new mode 100755 diff --git a/nall/function.hpp b/nall/function.hpp old mode 100644 new mode 100755 diff --git a/nall/hash/crc16.hpp b/nall/hash/crc16.hpp old mode 100644 new mode 100755 diff --git a/nall/hash/crc32.hpp b/nall/hash/crc32.hpp old mode 100644 new mode 100755 diff --git a/nall/hash/sha256.hpp b/nall/hash/sha256.hpp old mode 100644 new mode 100755 diff --git a/nall/hashset.hpp b/nall/hashset.hpp old mode 100644 new mode 100755 diff --git a/nall/hid.hpp b/nall/hid.hpp old mode 100644 new mode 100755 diff --git a/nall/http/client.hpp b/nall/http/client.hpp old mode 100644 new mode 100755 diff --git a/nall/http/message.hpp b/nall/http/message.hpp old mode 100644 new mode 100755 diff --git a/nall/http/request.hpp b/nall/http/request.hpp old mode 100644 new mode 100755 diff --git a/nall/http/response.hpp b/nall/http/response.hpp old mode 100644 new mode 100755 diff --git a/nall/http/role.hpp b/nall/http/role.hpp old mode 100644 new mode 100755 diff --git a/nall/http/server.hpp b/nall/http/server.hpp old mode 100644 new mode 100755 diff --git a/nall/image.hpp b/nall/image.hpp old mode 100644 new mode 100755 diff --git a/nall/image/blend.hpp b/nall/image/blend.hpp old mode 100644 new mode 100755 diff --git a/nall/image/core.hpp b/nall/image/core.hpp old mode 100644 new mode 100755 diff --git a/nall/image/fill.hpp b/nall/image/fill.hpp old mode 100644 new mode 100755 diff --git a/nall/image/interpolation.hpp b/nall/image/interpolation.hpp old mode 100644 new mode 100755 diff --git a/nall/image/load.hpp b/nall/image/load.hpp old mode 100644 new mode 100755 diff --git a/nall/image/scale.hpp b/nall/image/scale.hpp old mode 100644 new mode 100755 diff --git a/nall/image/static.hpp b/nall/image/static.hpp old mode 100644 new mode 100755 diff --git a/nall/image/utility.hpp b/nall/image/utility.hpp old mode 100644 new mode 100755 diff --git a/nall/inode.hpp b/nall/inode.hpp old mode 100644 new mode 100755 diff --git a/nall/interpolation.hpp b/nall/interpolation.hpp old mode 100644 new mode 100755 diff --git a/nall/intrinsics.hpp b/nall/intrinsics.hpp old mode 100644 new mode 100755 diff --git a/nall/location.hpp b/nall/location.hpp old mode 100644 new mode 100755 diff --git a/nall/main.hpp b/nall/main.hpp old mode 100644 new mode 100755 diff --git a/nall/map.hpp b/nall/map.hpp old mode 100644 new mode 100755 diff --git a/nall/matrix-multiply.hpp b/nall/matrix-multiply.hpp old mode 100644 new mode 100755 diff --git a/nall/maybe.hpp b/nall/maybe.hpp old mode 100644 new mode 100755 diff --git a/nall/memory.hpp b/nall/memory.hpp old mode 100644 new mode 100755 diff --git a/nall/merge-sort.hpp b/nall/merge-sort.hpp old mode 100644 new mode 100755 diff --git a/nall/nall.hpp b/nall/nall.hpp old mode 100644 new mode 100755 diff --git a/nall/platform.hpp b/nall/platform.hpp old mode 100644 new mode 100755 diff --git a/nall/random.hpp b/nall/random.hpp old mode 100644 new mode 100755 diff --git a/nall/range.hpp b/nall/range.hpp old mode 100644 new mode 100755 diff --git a/nall/run.hpp b/nall/run.hpp old mode 100644 new mode 100755 diff --git a/nall/serial.hpp b/nall/serial.hpp old mode 100644 new mode 100755 diff --git a/nall/serializer.hpp b/nall/serializer.hpp old mode 100644 new mode 100755 diff --git a/nall/service.hpp b/nall/service.hpp old mode 100644 new mode 100755 diff --git a/nall/set.hpp b/nall/set.hpp old mode 100644 new mode 100755 diff --git a/nall/shared-memory.hpp b/nall/shared-memory.hpp old mode 100644 new mode 100755 diff --git a/nall/shared-pointer.hpp b/nall/shared-pointer.hpp old mode 100644 new mode 100755 diff --git a/nall/smtp.hpp b/nall/smtp.hpp old mode 100644 new mode 100755 diff --git a/nall/stdint.hpp b/nall/stdint.hpp old mode 100644 new mode 100755 diff --git a/nall/string.hpp b/nall/string.hpp old mode 100644 new mode 100755 diff --git a/nall/string/allocator/adaptive.hpp b/nall/string/allocator/adaptive.hpp old mode 100644 new mode 100755 diff --git a/nall/string/allocator/copy-on-write.hpp b/nall/string/allocator/copy-on-write.hpp old mode 100644 new mode 100755 diff --git a/nall/string/allocator/small-string-optimization.hpp b/nall/string/allocator/small-string-optimization.hpp old mode 100644 new mode 100755 diff --git a/nall/string/allocator/vector.hpp b/nall/string/allocator/vector.hpp old mode 100644 new mode 100755 diff --git a/nall/string/cast.hpp b/nall/string/cast.hpp old mode 100644 new mode 100755 diff --git a/nall/string/compare.hpp b/nall/string/compare.hpp old mode 100644 new mode 100755 diff --git a/nall/string/convert.hpp b/nall/string/convert.hpp old mode 100644 new mode 100755 diff --git a/nall/string/core.hpp b/nall/string/core.hpp old mode 100644 new mode 100755 diff --git a/nall/string/eval/evaluator.hpp b/nall/string/eval/evaluator.hpp old mode 100644 new mode 100755 diff --git a/nall/string/eval/literal.hpp b/nall/string/eval/literal.hpp old mode 100644 new mode 100755 diff --git a/nall/string/eval/node.hpp b/nall/string/eval/node.hpp old mode 100644 new mode 100755 diff --git a/nall/string/eval/parser.hpp b/nall/string/eval/parser.hpp old mode 100644 new mode 100755 diff --git a/nall/string/find.hpp b/nall/string/find.hpp old mode 100644 new mode 100755 diff --git a/nall/string/format.hpp b/nall/string/format.hpp old mode 100644 new mode 100755 diff --git a/nall/string/markup/bml.hpp b/nall/string/markup/bml.hpp old mode 100644 new mode 100755 diff --git a/nall/string/markup/node.hpp b/nall/string/markup/node.hpp old mode 100644 new mode 100755 diff --git a/nall/string/markup/xml.hpp b/nall/string/markup/xml.hpp old mode 100644 new mode 100755 diff --git a/nall/string/match.hpp b/nall/string/match.hpp old mode 100644 new mode 100755 diff --git a/nall/string/replace.hpp b/nall/string/replace.hpp old mode 100644 new mode 100755 diff --git a/nall/string/split.hpp b/nall/string/split.hpp old mode 100644 new mode 100755 diff --git a/nall/string/transform/cml.hpp b/nall/string/transform/cml.hpp old mode 100644 new mode 100755 diff --git a/nall/string/transform/dml.hpp b/nall/string/transform/dml.hpp old mode 100644 new mode 100755 diff --git a/nall/string/trim.hpp b/nall/string/trim.hpp old mode 100644 new mode 100755 diff --git a/nall/string/utility.hpp b/nall/string/utility.hpp old mode 100644 new mode 100755 diff --git a/nall/string/vector.hpp b/nall/string/vector.hpp old mode 100644 new mode 100755 diff --git a/nall/string/view.hpp b/nall/string/view.hpp old mode 100644 new mode 100755 diff --git a/nall/thread.hpp b/nall/thread.hpp old mode 100644 new mode 100755 diff --git a/nall/traits.hpp b/nall/traits.hpp old mode 100644 new mode 100755 diff --git a/nall/utility.hpp b/nall/utility.hpp old mode 100644 new mode 100755 diff --git a/nall/varint.hpp b/nall/varint.hpp old mode 100644 new mode 100755 diff --git a/nall/windows/detour.hpp b/nall/windows/detour.hpp old mode 100644 new mode 100755 diff --git a/nall/windows/guid.hpp b/nall/windows/guid.hpp old mode 100644 new mode 100755 diff --git a/nall/windows/launcher.hpp b/nall/windows/launcher.hpp old mode 100644 new mode 100755 diff --git a/nall/windows/registry.hpp b/nall/windows/registry.hpp old mode 100644 new mode 100755 diff --git a/nall/windows/utf8.hpp b/nall/windows/utf8.hpp old mode 100644 new mode 100755 diff --git a/nall/xorg/guard.hpp b/nall/xorg/guard.hpp old mode 100644 new mode 100755 diff --git a/nall/xorg/xorg.hpp b/nall/xorg/xorg.hpp old mode 100644 new mode 100755 diff --git a/ruby/GNUmakefile b/ruby/GNUmakefile old mode 100644 new mode 100755 diff --git a/ruby/audio/alsa.cpp b/ruby/audio/alsa.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/ao.cpp b/ruby/audio/ao.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/directsound.cpp b/ruby/audio/directsound.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/openal.cpp b/ruby/audio/openal.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/oss.cpp b/ruby/audio/oss.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/pulseaudio-simple.cpp b/ruby/audio/pulseaudio-simple.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/pulseaudio.cpp b/ruby/audio/pulseaudio.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/xaudio2.cpp b/ruby/audio/xaudio2.cpp old mode 100644 new mode 100755 diff --git a/ruby/audio/xaudio2.hpp b/ruby/audio/xaudio2.hpp old mode 100644 new mode 100755 diff --git a/ruby/input/carbon.cpp b/ruby/input/carbon.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/joypad/directinput.cpp b/ruby/input/joypad/directinput.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/joypad/sdl.cpp b/ruby/input/joypad/sdl.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/joypad/udev.cpp b/ruby/input/joypad/udev.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/joypad/xinput.cpp b/ruby/input/joypad/xinput.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/keyboard/rawinput.cpp b/ruby/input/keyboard/rawinput.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/keyboard/xlib.cpp b/ruby/input/keyboard/xlib.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/mouse/rawinput.cpp b/ruby/input/mouse/rawinput.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/mouse/xlib.cpp b/ruby/input/mouse/xlib.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/sdl.cpp b/ruby/input/sdl.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/shared/rawinput.cpp b/ruby/input/shared/rawinput.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/udev.cpp b/ruby/input/udev.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/windows.cpp b/ruby/input/windows.cpp old mode 100644 new mode 100755 diff --git a/ruby/input/xlib.cpp b/ruby/input/xlib.cpp old mode 100644 new mode 100755 diff --git a/ruby/ruby.cpp b/ruby/ruby.cpp old mode 100644 new mode 100755 diff --git a/ruby/ruby.hpp b/ruby/ruby.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/cgl.cpp b/ruby/video/cgl.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/direct3d.cpp b/ruby/video/direct3d.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/directdraw.cpp b/ruby/video/directdraw.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/gdi.cpp b/ruby/video/gdi.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/glx.cpp b/ruby/video/glx.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/bind.hpp b/ruby/video/opengl/bind.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/main.hpp b/ruby/video/opengl/main.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/opengl.hpp b/ruby/video/opengl/opengl.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/program.hpp b/ruby/video/opengl/program.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/shaders.hpp b/ruby/video/opengl/shaders.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/surface.hpp b/ruby/video/opengl/surface.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/texture.hpp b/ruby/video/opengl/texture.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/opengl/utility.hpp b/ruby/video/opengl/utility.hpp old mode 100644 new mode 100755 diff --git a/ruby/video/wgl.cpp b/ruby/video/wgl.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/xshm.cpp b/ruby/video/xshm.cpp old mode 100644 new mode 100755 diff --git a/ruby/video/xvideo.cpp b/ruby/video/xvideo.cpp old mode 100644 new mode 100755 diff --git a/shaders/Curvature.shader/curvature.fs b/shaders/Curvature.shader/curvature.fs deleted file mode 100644 index d6db5b83..00000000 --- a/shaders/Curvature.shader/curvature.fs +++ /dev/null @@ -1,21 +0,0 @@ -#version 150 -#define distortion 0.2 - -uniform sampler2D source[]; -uniform vec4 sourceSize[]; - -in Vertex { - vec2 texCoord; -}; - -out vec4 fragColor; - -vec2 radialDistortion(vec2 coord) { - vec2 cc = coord - vec2(0.5); - float dist = dot(cc, cc) * distortion; - return coord + cc * (1.0 - dist) * dist; -} - -void main() { - fragColor = texture(source[0], radialDistortion(texCoord)); -} diff --git a/shaders/Curvature.shader/manifest.bml b/shaders/Curvature.shader/manifest.bml deleted file mode 100644 index 7bec4709..00000000 --- a/shaders/Curvature.shader/manifest.bml +++ /dev/null @@ -1,4 +0,0 @@ -program - filter: linear - wrap: border - fragment: curvature.fs diff --git a/shaders/Edge Detection.shader/edge-detection.fs b/shaders/Edge Detection.shader/edge-detection.fs deleted file mode 100644 index bf00fc25..00000000 --- a/shaders/Edge Detection.shader/edge-detection.fs +++ /dev/null @@ -1,25 +0,0 @@ -#version 150 - -uniform sampler2D source[]; -uniform vec4 sourceSize[]; - -in Vertex { - vec2 texCoord; -}; - -out vec4 fragColor; - -vec3 grayscale(vec3 color) { - return vec3(dot(color, vec3(0.3, 0.59, 0.11))); -} - -void main() { - vec2 offset = fract(texCoord * sourceSize[0].xy) - 0.5; - offset /= sourceSize[0].xy; - - vec3 cx = texture(source[0], texCoord - offset).xyz; - vec3 cy = texture(source[0], texCoord).xyz; - vec3 cz = vec3(5.0 * grayscale(abs(cx - cy))); - - fragColor = vec4(clamp(cz, 0.0, 1.0), 1.0); -} diff --git a/shaders/Edge Detection.shader/manifest.bml b/shaders/Edge Detection.shader/manifest.bml deleted file mode 100644 index 166db6de..00000000 --- a/shaders/Edge Detection.shader/manifest.bml +++ /dev/null @@ -1,4 +0,0 @@ -program - filter: linear - wrap: edge - fragment: edge-detection.fs diff --git a/shaders/Makefile b/shaders/Makefile deleted file mode 100644 index 889a0f87..00000000 --- a/shaders/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -install: - mkdir -p ~/.local/share/higan/Video\ Shaders - cp -a *.shader ~/.local/share/higan/Video\ Shaders diff --git a/shaders/Scanline.shader/manifest.bml b/shaders/Scanline.shader/manifest.bml deleted file mode 100644 index a5db6351..00000000 --- a/shaders/Scanline.shader/manifest.bml +++ /dev/null @@ -1,4 +0,0 @@ -program - filter: linear - wrap: border - fragment: scanline.fs diff --git a/shaders/Scanline.shader/scanline.fs b/shaders/Scanline.shader/scanline.fs deleted file mode 100644 index 42a9603a..00000000 --- a/shaders/Scanline.shader/scanline.fs +++ /dev/null @@ -1,20 +0,0 @@ -#version 150 - -uniform sampler2D source[]; - -in Vertex { - vec2 texCoord; -}; - -out vec4 fragColor; - -void main() { - vec4 rgba = texture(source[0], texCoord); - vec4 intensity; - if(fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5) { - intensity = vec4(0); - } else { - intensity = smoothstep(0.2, 0.8, rgba) + normalize(rgba); - } - fragColor = intensity * -0.25 + rgba * 1.1; -} diff --git a/sourcery/GNUmakefile b/sourcery/GNUmakefile old mode 100644 new mode 100755 diff --git a/sourcery/sourcery.cpp b/sourcery/sourcery.cpp old mode 100644 new mode 100755