# HG changeset patch # User Michael Pavone # Date 1678676615 25200 # Node ID 0343f0d5add036adbbb36f84477816ebe75e2e45 # Parent d30ea441b92e5a24d5870161f784c1e7c51a232e Fix libretro build for real diff -r d30ea441b92e -r 0343f0d5add0 Makefile --- a/Makefile Thu Mar 09 23:10:41 2023 -0800 +++ b/Makefile Sun Mar 12 20:03:35 2023 -0700 @@ -196,7 +196,7 @@ endif endif endif -AUDIOOBJS=ym2612.o psg.o wave.o flac.o vgm.o event_log.o render_audio.o rf5c164.o oscilloscope.o +AUDIOOBJS=ym2612.o psg.o wave.o flac.o vgm.o event_log.o render_audio.o rf5c164.o CONFIGOBJS=config.o tern.o util.o paths.o NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o RENDEROBJS=ppm.o controller_info.o @@ -215,9 +215,9 @@ MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o $(RENDEROBJS) io.o romdb.o hash.o menu.o xband.o \ realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \ $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o gen_player.o \ - segacd.o lc8951.o cdimage.o cdd_mcu.o cd_graphics.o cdd_fader.o sft_mapper.o mediaplayer.o + segacd.o lc8951.o cdimage.o cdd_mcu.o cd_graphics.o cdd_fader.o sft_mapper.o mediaplayer.o oscilloscope.o -LIBOBJS=libblastem.o system.o genesis.o debug.o gdb_remote.o vdp.o io.o romdb.o hash.o xband.o realtec.o \ +LIBOBJS=libblastem.o system.o genesis.o vdp.o io.o romdb.o hash.o xband.o realtec.o \ i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \ $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o jcart.o rom.db.o gen_player.o $(LIBZOBJS) \ segacd.o lc8951.o cdimage.o cdd_mcu.o cd_graphics.o cdd_fader.o sft_mapper.o mediaplayer.o diff -r d30ea441b92e -r 0343f0d5add0 debug.c --- a/debug.c Thu Mar 09 23:10:41 2023 -0800 +++ b/debug.c Sun Mar 12 20:03:35 2023 -0700 @@ -1055,7 +1055,9 @@ #endif do { process_events(); +#ifndef IS_LIB render_update_display(); +#endif #ifndef _WIN32 timeout.tv_sec = 0; timeout.tv_usec = 16667; diff -r d30ea441b92e -r 0343f0d5add0 genesis.c --- a/genesis.c Thu Mar 09 23:10:41 2023 -0800 +++ b/genesis.c Sun Mar 12 20:03:35 2023 -0700 @@ -418,7 +418,9 @@ z80_run(z_context, z_context->current_cycle + 4); } gen->enter_z80_debugger = 0; +#ifndef IS_LIB zdebugger(z_context, z_context->pc); +#endif } z80_run(z_context, mclks); } else @@ -485,9 +487,11 @@ gen->reset_cycle = CYCLE_NEVER; } if (v_context->frame != gen->last_frame) { +#ifndef IS_LIB if (gen->ym->scope) { scope_render(gen->ym->scope); } +#endif //printf("reached frame end %d | MCLK Cycles: %d, Target: %d, VDP cycles: %d, vcounter: %d, hslot: %d\n", gen->last_frame, mclks, gen->frame_end, v_context->cycles, v_context->vcounter, v_context->hslot); uint32_t elapsed = v_context->frame - gen->last_frame; gen->last_frame = v_context->frame; @@ -556,11 +560,13 @@ if (address) { if (gen->header.enter_debugger) { gen->header.enter_debugger = 0; +#ifndef IS_LIB if (gen->header.debugger_type == DEBUGGER_NATIVE) { debugger(context, address); } else { gdb_debug_enter(context, address); } +#endif } #ifdef NEW_CORE if (gen->header.save_state) { @@ -1483,16 +1489,20 @@ printf("Loaded %s\n", statefile); if (gen->header.enter_debugger) { gen->header.enter_debugger = 0; +#ifndef IS_LIB insert_breakpoint(gen->m68k, pc, gen->header.debugger_type == DEBUGGER_NATIVE ? debugger : gdb_debug_enter); +#endif } adjust_int_cycle(gen->m68k, gen->vdp); start_68k_context(gen->m68k, pc); } else { if (gen->header.enter_debugger) { gen->header.enter_debugger = 0; +#ifndef IS_LIB uint32_t address = read_word(4, (void **)gen->m68k->mem_pointers, &gen->m68k->options->gen, gen->m68k) << 16 | read_word(6, (void **)gen->m68k->mem_pointers, &gen->m68k->options->gen, gen->m68k); insert_breakpoint(gen->m68k, address, gen->header.debugger_type == DEBUGGER_NATIVE ? debugger : gdb_debug_enter); +#endif } m68k_reset(gen->m68k); } @@ -1773,6 +1783,7 @@ static void toggle_debug_view(system_header *system, uint8_t debug_view) { +#ifndef IS_LIB genesis_context *gen = (genesis_context *)system; if (debug_view < DEBUG_OSCILLOSCOPE) { vdp_toggle_debug_view(gen->vdp, debug_view); @@ -1798,6 +1809,7 @@ } else if (debug_view == DEBUG_CD_GRAPHICS && gen->expansion) { scd_toggle_graphics_debug(gen->expansion); } +#endif } static void *tmss_rom_write_16(uint32_t address, void *context, uint16_t value) diff -r d30ea441b92e -r 0343f0d5add0 libblastem.c --- a/libblastem.c Thu Mar 09 23:10:41 2023 -0800 +++ b/libblastem.c Sun Mar 12 20:03:35 2023 -0700 @@ -77,7 +77,11 @@ tern_node *config; uint8_t use_native_states = 1; system_header *current_system; -system_media media; +static system_media media; +const system_media *current_media(void) +{ + return &media; +} RETRO_API void retro_init(void) { @@ -238,10 +242,10 @@ media.size = game->size; stype = detect_system_type(&media); current_system = alloc_config_system(stype, &media, 0, 0); - + unsigned format = RETRO_PIXEL_FORMAT_XRGB8888; retro_environment(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &format); - + return current_system != NULL; } diff -r d30ea441b92e -r 0343f0d5add0 mediaplayer.c --- a/mediaplayer.c Thu Mar 09 23:10:41 2023 -0800 +++ b/mediaplayer.c Sun Mar 12 20:03:35 2023 -0700 @@ -611,10 +611,15 @@ } break; case STATE_PAUSED: +#ifndef IS_LIB render_sleep_ms(15); +#endif break; } + //TODO: Fix this for libretro build properly +#ifndef IS_LIB render_update_display(); +#endif } } diff -r d30ea441b92e -r 0343f0d5add0 psg.c --- a/psg.c Thu Mar 09 23:10:41 2023 -0800 +++ b/psg.c Sun Mar 12 20:03:35 2023 -0700 @@ -23,6 +23,7 @@ void psg_enable_scope(psg_context *context, oscilloscope *scope, uint32_t master_clock) { +#ifndef IS_LIB context->scope = scope; static const char *names[] = { "PSG #1", @@ -34,6 +35,7 @@ { context->scope_channel[i] = scope_add_channel(scope, names[i], master_clock / context->clock_inc); } +#endif } void psg_free(psg_context *context) @@ -146,9 +148,11 @@ } else { value = 0; } +#ifndef IS_LIB if (context->scope) { scope_add_sample(context->scope, context->scope_channel[i], value, trigger[i]); } +#endif } value = 0; if (context->noise_out) { @@ -160,9 +164,11 @@ right_accum += value; } } +#ifndef IS_LIB if (context->scope) { scope_add_sample(context->scope, context->scope_channel[3], value, trigger[3]); } +#endif render_put_stereo_sample(context->audio, left_accum, right_accum); diff -r d30ea441b92e -r 0343f0d5add0 rf5c164.c --- a/rf5c164.c Thu Mar 09 23:10:41 2023 -0800 +++ b/rf5c164.c Sun Mar 12 20:03:35 2023 -0700 @@ -154,14 +154,20 @@ int16_t left = (sample * (pcm->channels[pcm->cur_channel].regs[PAN] >> 4)) >> 5; int16_t right = (sample * (pcm->channels[pcm->cur_channel].regs[PAN] & 0xF)) >> 5; //printf("chan %d, raw %X, sample %d, left %d, right %d, ptr %X (raw %X)\n", pcm->cur_channel, pcm->channels[pcm->cur_channel].sample, sample, left, right, pcm->channels[pcm->cur_channel].cur_ptr >> 11, pcm->channels[pcm->cur_channel].cur_ptr); +#ifndef IS_LIB if (pcm->scope) { scope_add_sample(pcm->scope, pcm->channels[pcm->cur_channel].scope_channel, sample, pcm->channels[pcm->cur_channel].trigger); } +#endif pcm->left += left; pcm->right += right; +#ifdef IS_LIB + } +#else } else if (pcm->scope) { scope_add_sample(pcm->scope, pcm->channels[pcm->cur_channel].scope_channel, 0, 0); } +#endif write_if_not_sounding(pcm); CHECK; case 10: @@ -246,6 +252,7 @@ void rf5c164_enable_scope(rf5c164* pcm, oscilloscope *scope) { +#ifndef IS_LIB static const char *names[] = { "Richo #1", "Richo #2", @@ -261,6 +268,7 @@ { pcm->channels[i].scope_channel = scope_add_channel(scope, names[i], 50000000 / (pcm->clock_step * 96)); } +#endif } void rf5c164_serialize(rf5c164* pcm, serialize_buffer *buf) diff -r d30ea441b92e -r 0343f0d5add0 segacd.c --- a/segacd.c Thu Mar 09 23:10:41 2023 -0800 +++ b/segacd.c Sun Mar 12 20:03:35 2023 -0700 @@ -1136,11 +1136,13 @@ if (cd->enter_debugger) { genesis_context *gen = cd->genesis; cd->enter_debugger = 0; +#ifndef IS_LIB if (gen->header.debugger_type == DEBUGGER_NATIVE) { debugger(context, address); } else { gdb_debug_enter(context, address); } +#endif } cd->m68k_pc = address; } diff -r d30ea441b92e -r 0343f0d5add0 sms.c --- a/sms.c Thu Mar 09 23:10:41 2023 -0800 +++ b/sms.c Sun Mar 12 20:03:35 2023 -0700 @@ -426,9 +426,11 @@ } if (sms->vdp->frame != sms->last_frame) { +#ifndef IS_LIB if (sms->psg->scope) { scope_render(sms->psg->scope); } +#endif uint32_t elapsed = sms->vdp->frame - sms->last_frame; sms->last_frame = sms->vdp->frame; if (system->enter_debugger_frames) { @@ -450,7 +452,9 @@ } if (system->enter_debugger && sms->z80->pc) { system->enter_debugger = 0; +#ifndef IS_LIB zdebugger(sms->z80, sms->z80->pc); +#endif } #ifdef NEW_CORE if (sms->z80->nmi_cycle == CYCLE_NEVER) { @@ -523,7 +527,9 @@ if (system->enter_debugger) { system->enter_debugger = 0; +#ifndef IS_LIB zinsert_breakpoint(sms->z80, sms->z80->pc, (uint8_t *)zdebugger); +#endif } run_sms(system); @@ -653,6 +659,7 @@ static void toggle_debug_view(system_header *system, uint8_t debug_view) { +#ifndef IS_LIB sms_context *sms = (sms_context *)system; if (debug_view < DEBUG_OSCILLOSCOPE) { vdp_toggle_debug_view(sms->vdp, debug_view); @@ -666,6 +673,7 @@ psg_enable_scope(sms->psg, scope, sms->normal_clock); } } +#endif } sms_context *alloc_configure_sms(system_media *media, uint32_t opts, uint8_t force_region) diff -r d30ea441b92e -r 0343f0d5add0 ym2612.c --- a/ym2612.c Thu Mar 09 23:10:41 2023 -0800 +++ b/ym2612.c Sun Mar 12 20:03:35 2023 -0700 @@ -635,9 +635,11 @@ if (context->channels[i].logfile) { fwrite(&value, sizeof(value), 1, context->channels[i].logfile); } +#ifndef IS_LIB if (context->scope) { scope_add_sample(context->scope, context->channels[i].scope_channel, value, context->channels[i].phase_overflow); } +#endif if (context->channels[i].lr & 0x80) { left += (value * context->volume_mult) / context->volume_div; } else if (context->zero_offset) { @@ -1400,6 +1402,7 @@ void ym_enable_scope(ym2612_context *context, oscilloscope *scope, uint32_t master_clock) { +#ifndef IS_LIB static const char *names[] = { "YM2612 #1", "YM2612 #2", @@ -1413,4 +1416,5 @@ { context->channels[i].scope_channel = scope_add_channel(scope, names[i], master_clock / (context->clock_inc * NUM_OPERATORS)); } +#endif }