diff --git a/boxart/metal_gear_solid_gbc.jpg b/boxart/metal_gear_solid_gbc.jpg new file mode 100644 index 00000000..090e2107 Binary files /dev/null and b/boxart/metal_gear_solid_gbc.jpg differ diff --git a/boxart/shantae.jpg b/boxart/shantae.jpg new file mode 100644 index 00000000..f17482cc Binary files /dev/null and b/boxart/shantae.jpg differ diff --git a/boxart/source/metal_gear_solid_gbc.jpg b/boxart/source/metal_gear_solid_gbc.jpg new file mode 100644 index 00000000..710ae6e8 Binary files /dev/null and b/boxart/source/metal_gear_solid_gbc.jpg differ diff --git a/boxart/source/shantae.jpg b/boxart/source/shantae.jpg new file mode 100644 index 00000000..974ca57b Binary files /dev/null and b/boxart/source/shantae.jpg differ diff --git a/boxart/source/star_wars_arcade_32x_genesis.jpg b/boxart/source/star_wars_arcade_32x_genesis.jpg new file mode 100644 index 00000000..a191e5a1 Binary files /dev/null and b/boxart/source/star_wars_arcade_32x_genesis.jpg differ diff --git a/boxart/source/super_mario_bros_deluxe.jpg b/boxart/source/super_mario_bros_deluxe.jpg new file mode 100644 index 00000000..b645049b Binary files /dev/null and b/boxart/source/super_mario_bros_deluxe.jpg differ diff --git a/boxart/source/toy-story-genesis.jpg b/boxart/source/toy-story-genesis.jpg new file mode 100644 index 00000000..301bff0e Binary files /dev/null and b/boxart/source/toy-story-genesis.jpg differ diff --git a/boxart/star_wars_arcade_32x_genesis.jpg b/boxart/star_wars_arcade_32x_genesis.jpg new file mode 100644 index 00000000..15cc040d Binary files /dev/null and b/boxart/star_wars_arcade_32x_genesis.jpg differ diff --git a/boxart/super_mario_bros_deluxe.jpg b/boxart/super_mario_bros_deluxe.jpg new file mode 100644 index 00000000..608e7466 Binary files /dev/null and b/boxart/super_mario_bros_deluxe.jpg differ diff --git a/boxart/toy-story-genesis.jpg b/boxart/toy-story-genesis.jpg new file mode 100644 index 00000000..fa706444 Binary files /dev/null and b/boxart/toy-story-genesis.jpg differ diff --git a/components/box-emu/CMakeLists.txt b/components/box-emu/CMakeLists.txt index 4238c715..c9017d71 100644 --- a/components/box-emu/CMakeLists.txt +++ b/components/box-emu/CMakeLists.txt @@ -10,8 +10,6 @@ idf_component_register( "hal" "usb" "esp_tinyusb" - "spi_flash" - "nvs_flash" "codec" "adc" "aw9523" diff --git a/components/box-emu/include/box-emu.hpp b/components/box-emu/include/box-emu.hpp index 51ad6821..3ce223a5 100644 --- a/components/box-emu/include/box-emu.hpp +++ b/components/box-emu/include/box-emu.hpp @@ -3,8 +3,6 @@ #include #include -#include -#include #include #include #include @@ -155,7 +153,7 @@ class BoxEmu : public espp::BaseComponent { int x_offset() const; int y_offset() const; const uint16_t *palette() const; - bool video_task_callback(std::mutex &m, std::condition_variable &cv); + bool video_task_callback(std::mutex &m, std::condition_variable &cv, bool &task_notified); class InputBase { public: @@ -279,7 +277,7 @@ class BoxEmu : public espp::BaseComponent { static constexpr gpio_num_t sdcard_sclk = GPIO_NUM_12; static constexpr auto sdcard_spi_num = SPI3_HOST; - static constexpr int num_rows_in_framebuffer = 50; + static constexpr int num_rows_in_framebuffer = 30; Version version_{Version::UNKNOWN}; @@ -315,7 +313,7 @@ class BoxEmu : public espp::BaseComponent { // video std::atomic video_setting_{VideoSetting::FIT}; - std::shared_ptr video_task_{nullptr}; + std::unique_ptr video_task_{nullptr}; QueueHandle_t video_queue_{nullptr}; size_t display_width_{espp::EspBox::lcd_width()}; diff --git a/components/box-emu/src/box-emu.cpp b/components/box-emu/src/box-emu.cpp index 4ffc37a6..caa47eb3 100644 --- a/components/box-emu/src/box-emu.cpp +++ b/components/box-emu/src/box-emu.cpp @@ -459,12 +459,15 @@ bool BoxEmu::initialize_video() { logger_.info("initializing video task"); video_queue_ = xQueueCreate(1, sizeof(uint16_t*)); - video_task_ = std::make_shared(espp::Task::Config{ - .name = "video task", - .callback = std::bind(&BoxEmu::video_task_callback, this, std::placeholders::_1, std::placeholders::_2), - .stack_size_bytes = 4*1024, - .priority = 20, - .core_id = 1 + using namespace std::placeholders; + video_task_ = espp::Task::make_unique({ + .callback = std::bind(&BoxEmu::video_task_callback, this, _1, _2, _3), + .task_config = { + .name = "video task", + .stack_size_bytes = 4*1024, + .priority = 20, + .core_id = 1 + }, }); video_task_->start(); @@ -715,7 +718,7 @@ const uint16_t* BoxEmu::palette() const { return palette_; } -bool BoxEmu::video_task_callback(std::mutex &m, std::condition_variable& cv) { +bool BoxEmu::video_task_callback(std::mutex &m, std::condition_variable& cv, bool &task_notified) { const void *_frame_ptr; if (xQueueReceive(video_queue_, &_frame_ptr, portMAX_DELAY) != pdTRUE) { return false; diff --git a/components/espp b/components/espp index 2ded708a..914e0b59 160000 --- a/components/espp +++ b/components/espp @@ -1 +1 @@ -Subproject commit 2ded708a25ce30009a061a5fc0f6a7f90be6e694 +Subproject commit 914e0b59c170f74dfa94659648f6f5f3d11c3c28 diff --git a/components/gbc/CMakeLists.txt b/components/gbc/CMakeLists.txt index 5266204c..f4f7c55d 100644 --- a/components/gbc/CMakeLists.txt +++ b/components/gbc/CMakeLists.txt @@ -2,6 +2,7 @@ idf_component_register( INCLUDE_DIRS "include" SRC_DIRS "src" "gnuboy/src" PRIV_INCLUDE_DIRS "gnuboy/include" + # LDFRAGMENTS "linker.lf" REQUIRES "box-emu" "statistics" ) diff --git a/components/gbc/gnuboy/src/cpu.c b/components/gbc/gnuboy/src/cpu.c index c36a8c20..8c3ea7b7 100644 --- a/components/gbc/gnuboy/src/cpu.c +++ b/components/gbc/gnuboy/src/cpu.c @@ -279,7 +279,7 @@ void cpu_reset() /* FIXME: employ common unit to drive whatever_advance(), (double-speed machine cycles (2MHz) is a good candidate) handle differences in place */ -void IRAM_ATTR div_advance(int cnt) +void div_advance(int cnt) { cpu.div += (cnt<<1); if (cpu.div >= 256) @@ -295,7 +295,7 @@ void IRAM_ATTR div_advance(int cnt) /* FIXME: employ common unit to drive whatever_advance(), (double-speed machine cycles (2MHz) is a good candidate) handle differences in place */ -void IRAM_ATTR timer_advance(int cnt) +void timer_advance(int cnt) { int unit, tima; @@ -336,7 +336,7 @@ inline void sound_advance(int cnt) } /* cnt - time to emulate, expressed in 2MHz units */ -void IRAM_ATTR cpu_timers(int cnt) +void cpu_timers(int cnt) { div_advance(cnt << cpu.speed); timer_advance(cnt << cpu.speed); @@ -351,7 +351,7 @@ void IRAM_ATTR cpu_timers(int cnt) returns number of cycles skipped */ /* FIXME: bring cpu_timers() out, make caller advance system */ -int IRAM_ATTR cpu_idle(int max) +int cpu_idle(int max) { int cnt, unit; @@ -397,7 +397,7 @@ int IRAM_ATTR cpu_idle(int max) Might emulate up to cycles+(11) time units (longest op takes 12 cycles in single-speed mode) */ -int IRAM_ATTR cpu_emulate(int cycles) +int cpu_emulate(int cycles) { int i; byte op, cbop; @@ -970,7 +970,7 @@ int IRAM_ATTR cpu_emulate(int cycles) #ifndef ASM_CPU_STEP /* Outdated equivalent of emu.c:emu_step() probably? Doesn't seem to be used. */ -int IRAM_ATTR cpu_step(int max) +int cpu_step(int max) { int cnt; if ((cnt = cpu_idle(max))) return cnt; diff --git a/components/gbc/gnuboy/src/hw.c b/components/gbc/gnuboy/src/hw.c index ecdae040..cef4f76c 100644 --- a/components/gbc/gnuboy/src/hw.c +++ b/components/gbc/gnuboy/src/hw.c @@ -24,7 +24,7 @@ struct hw hw; * lines that transition from low to high. */ -void IRAM_ATTR hw_interrupt(byte i, byte mask) +void hw_interrupt(byte i, byte mask) { byte oldif = R_IF; i &= 0x1F & mask; @@ -47,7 +47,7 @@ void IRAM_ATTR hw_interrupt(byte i, byte mask) * stall the cpu are necessary. */ -void IRAM_ATTR hw_dma(byte b) +void hw_dma(byte b) { int i; addr a; @@ -59,7 +59,7 @@ void IRAM_ATTR hw_dma(byte b) -void IRAM_ATTR hw_hdma_cmd(byte c) +void hw_hdma_cmd(byte c) { int cnt; addr sa; @@ -90,7 +90,7 @@ void IRAM_ATTR hw_hdma_cmd(byte c) } -void IRAM_ATTR hw_hdma() +void hw_hdma() { int cnt; addr sa; @@ -116,7 +116,7 @@ void IRAM_ATTR hw_hdma() * interrupt line) if a transition has been made. */ -void IRAM_ATTR pad_refresh() +void pad_refresh() { byte oldp1; oldp1 = R_P1; diff --git a/components/gbc/gnuboy/src/lcd.c b/components/gbc/gnuboy/src/lcd.c index d5e5f09b..81984d42 100755 --- a/components/gbc/gnuboy/src/lcd.c +++ b/components/gbc/gnuboy/src/lcd.c @@ -76,7 +76,7 @@ static byte *vdest; static byte pix[8]; __attribute__((optimize("unroll-loops"))) -static const byte* IRAM_ATTR get_patpix(int i, int x) +static const byte* get_patpix(int i, int x) { const int index = i & 0x3ff; // 1024 entries const int rotation = i >> 10; // / 1024; @@ -151,7 +151,7 @@ static const short DRAM_ATTR wraptable[64] = 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,-32 }; -static void IRAM_ATTR tilebuf() +static void tilebuf() { int i, cnt; int base; @@ -245,7 +245,7 @@ static void IRAM_ATTR tilebuf() } -static void IRAM_ATTR bg_scan() +static void bg_scan() { int cnt; byte *src, *dest; @@ -309,7 +309,7 @@ static void IRAM_ATTR bg_scan() *(dest++) = *(src++); } -static void IRAM_ATTR wnd_scan() +static void wnd_scan() { int cnt; byte *src, *dest; @@ -352,7 +352,7 @@ inline static int priused(void *attr) return (int)((a[0]|a[1]|a[2]|a[3]|a[4]|a[5]|a[6]|a[7])&0x80808080); } -static void IRAM_ATTR bg_scan_pri() +static void bg_scan_pri() { int cnt, i; byte *src, *dest; @@ -382,7 +382,7 @@ static void IRAM_ATTR bg_scan_pri() memset(dest, src[i&31]&128, cnt); } -static void IRAM_ATTR wnd_scan_pri() +static void wnd_scan_pri() { int cnt, i; byte *src, *dest; @@ -409,7 +409,7 @@ static void IRAM_ATTR wnd_scan_pri() } #ifndef ASM_BG_SCAN_COLOR -static void IRAM_ATTR bg_scan_color() +static void bg_scan_color() { int cnt; byte *src, *dest; @@ -437,7 +437,7 @@ static void IRAM_ATTR bg_scan_color() } #endif -static void IRAM_ATTR wnd_scan_color() +static void wnd_scan_color() { int cnt; byte *src, *dest; @@ -464,7 +464,7 @@ inline static void recolor(byte *buf, byte fill, int cnt) while (cnt--) *(buf++) |= fill; } -static void IRAM_ATTR spr_count() +static void spr_count() { int i; struct obj *o; @@ -487,7 +487,7 @@ static void IRAM_ATTR spr_count() static struct vissprite ts[16]; -static void IRAM_ATTR spr_enum() +static void spr_enum() { int i, j; struct obj *o; @@ -569,7 +569,7 @@ static void IRAM_ATTR spr_enum() static byte bgdup[256]; -static void IRAM_ATTR spr_scan() +static void spr_scan() { int i, x; byte pal, b, ns = NS; @@ -647,7 +647,7 @@ extern int frame; extern uint16_t* displayBuffer[2]; int lastLcdDisabled = 0; -void IRAM_ATTR lcd_refreshline() +void lcd_refreshline() { byte *dest; @@ -751,7 +751,7 @@ inline void pal_write(int i, byte b) } } -void IRAM_ATTR pal_write_dmg(int i, int mapnum, byte d) +void pal_write_dmg(int i, int mapnum, byte d) { int j; int * const cmap = dmg_pal[mapnum & 0x3]; diff --git a/components/gbc/gnuboy/src/lcdc.c b/components/gbc/gnuboy/src/lcdc.c index d4b17afa..cfca1553 100644 --- a/components/gbc/gnuboy/src/lcdc.c +++ b/components/gbc/gnuboy/src/lcdc.c @@ -25,7 +25,7 @@ * stat_trigger also updates bit 2 of R_STAT to reflect whether LY=LYC. */ -void IRAM_ATTR stat_trigger() +void stat_trigger() { static const int condbits[4] = { 0x08, 0x10, 0x20, 0x00 }; int flag = 0; @@ -44,7 +44,7 @@ void IRAM_ATTR stat_trigger() hw_interrupt(flag, IF_STAT); } -void IRAM_ATTR stat_write(byte b) +void stat_write(byte b) { R_STAT = (R_STAT & 0x07) | (b & 0x78); if (!hw.cgb && !(R_STAT & 2)) /* DMG STAT write bug => interrupt */ @@ -61,7 +61,7 @@ void IRAM_ATTR stat_write(byte b) */ /* FIXME: function now will only lower vblank interrupt, description does not match anymore */ -static void IRAM_ATTR stat_change(int stat) +static void stat_change(int stat) { stat &= 3; R_STAT = (R_STAT & 0x7C) | stat; @@ -72,7 +72,7 @@ static void IRAM_ATTR stat_change(int stat) } -void IRAM_ATTR lcdc_change(byte b) +void lcdc_change(byte b) { byte old = R_LCDC; R_LCDC = b; @@ -122,7 +122,7 @@ void IRAM_ATTR lcdc_change(byte b) /* lcdc_trans() Main LCDC emulation routine */ -void IRAM_ATTR lcdc_trans() +void lcdc_trans() { /* FIXME: lacks clarity; try and break into two switch() blocks diff --git a/components/gbc/gnuboy/src/loader.c b/components/gbc/gnuboy/src/loader.c index 7413a03f..e07372b5 100644 --- a/components/gbc/gnuboy/src/loader.c +++ b/components/gbc/gnuboy/src/loader.c @@ -4,7 +4,6 @@ #include #include -#include "nvs_flash.h" #include "esp_partition.h" #include "esp_system.h" #include "esp_heap_caps.h" diff --git a/components/gbc/gnuboy/src/mem.c b/components/gbc/gnuboy/src/mem.c index 97e6bafd..aef819d1 100644 --- a/components/gbc/gnuboy/src/mem.c +++ b/components/gbc/gnuboy/src/mem.c @@ -30,7 +30,7 @@ struct ram ram; * make the old maps potentially invalid. */ -void IRAM_ATTR mem_updatemap() +void mem_updatemap() { int n; byte **map; @@ -121,7 +121,7 @@ void IRAM_ATTR mem_updatemap() * byte value to be written. */ -void IRAM_ATTR ioreg_write(byte r, byte b) +void ioreg_write(byte r, byte b) { if (!hw.cgb) { @@ -270,7 +270,7 @@ void IRAM_ATTR ioreg_write(byte r, byte b) } -byte IRAM_ATTR ioreg_read(byte r) +byte ioreg_read(byte r) { switch(r) { @@ -327,7 +327,7 @@ byte IRAM_ATTR ioreg_read(byte r) * and a byte value written to the address. */ -void IRAM_ATTR mbc_write(int a, byte b) +void mbc_write(int a, byte b) { byte ha = (a>>12); @@ -483,7 +483,7 @@ void IRAM_ATTR mbc_write(int a, byte b) * region, it accepts writes to any address. */ -void IRAM_ATTR mem_write(int a, byte b) +void mem_write(int a, byte b) { int n; byte ha = (a>>12) & 0xE; @@ -568,7 +568,7 @@ void IRAM_ATTR mem_write(int a, byte b) * region. */ -byte IRAM_ATTR mem_read(int a) +byte mem_read(int a) { int n; byte ha = (a>>12) & 0xE; diff --git a/components/gbc/gnuboy/src/sound.c b/components/gbc/gnuboy/src/sound.c index d14f8dd4..5d462f51 100644 --- a/components/gbc/gnuboy/src/sound.c +++ b/components/gbc/gnuboy/src/sound.c @@ -154,7 +154,7 @@ void sound_reset() } -void IRAM_ATTR sound_mix() +void sound_mix() { int s, l, r, f, n; @@ -344,7 +344,7 @@ void s4_init() } -void IRAM_ATTR sound_write(byte r, byte b) +void sound_write(byte r, byte b) { #if 0 static void *timer; diff --git a/components/gbc/linker.lf b/components/gbc/linker.lf new file mode 100644 index 00000000..ced2898e --- /dev/null +++ b/components/gbc/linker.lf @@ -0,0 +1,10 @@ +# Move gbc code into IRAM for perforamnce +[mapping:gbc] +archive: libgbc.a +entries: + cpu (noflash_text) + hw (noflash_text) + lcd (noflash_text) + lcdc (noflash_text) + mem (noflash_text) + sound (noflash_text) diff --git a/components/genesis/CMakeLists.txt b/components/genesis/CMakeLists.txt index 13bb778e..e5931a3c 100644 --- a/components/genesis/CMakeLists.txt +++ b/components/genesis/CMakeLists.txt @@ -2,8 +2,10 @@ idf_component_register( INCLUDE_DIRS "include" SRC_DIRS "src" "gwenesis/src/bus" "gwenesis/src/cpus/M68K" "gwenesis/src/cpus/Z80" "gwenesis/src/io" "gwenesis/src/savestate" "gwenesis/src/sound" "gwenesis/src/vdp" PRIV_INCLUDE_DIRS "." "gwenesis/src/bus" "gwenesis/src/cpus/M68K" "gwenesis/src/cpus/Z80" "gwenesis/src/io" "gwenesis/src/savestate" "gwenesis/src/sound" "gwenesis/src/vdp" + LDFRAGMENTS "linker.lf" REQUIRES box-emu statistics ) # target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-char-subscripts -Wno-attributes -Wno-implicit-fallthrough -Wno-unused-function -Wno-unused-variable -Wno-discarded-qualifiers) target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-unused-const-variable -Wno-unused-value -Ofast) +# target_compile_definitions(${COMPONENT_LIB} PRIVATE GWENESIS_AUDIO_ACCURATE=0 BUILD_TABLES=0 TABLES_FULL=0) target_compile_definitions(${COMPONENT_LIB} PRIVATE GWENESIS_AUDIO_ACCURATE=0) diff --git a/components/genesis/gwenesis/src/cpus/M68K/m68kcpu.c b/components/genesis/gwenesis/src/cpus/M68K/m68kcpu.c index 941b7faa..fda0384a 100644 --- a/components/genesis/gwenesis/src/cpus/M68K/m68kcpu.c +++ b/components/genesis/gwenesis/src/cpus/M68K/m68kcpu.c @@ -21,8 +21,6 @@ extern int vdp_68k_irq_ack(int int_level); #endif #endif -#include - #include "m68kconf.h" #include "m68kcpu.h" #include "m68kops.h" @@ -263,7 +261,7 @@ void m68k_set_irq_delay(unsigned int int_level) m68ki_check_interrupts(); /* Level triggered (IRQ) */ } -void IRAM_ATTR m68k_run(unsigned int cycles) +void m68k_run(unsigned int cycles) { // printf("m68K_run current_cycles=%d add=%d STOP=%x\n",m68k.cycles,cycles,CPU_STOPPED); diff --git a/components/genesis/gwenesis/src/sound/gwenesis_sn76489.c b/components/genesis/gwenesis/src/sound/gwenesis_sn76489.c index 93a6211e..32cd3e90 100644 --- a/components/genesis/gwenesis/src/sound/gwenesis_sn76489.c +++ b/components/genesis/gwenesis/src/sound/gwenesis_sn76489.c @@ -209,7 +209,7 @@ static inline void gwenesis_SN76489_Update(INT16 *buffer, int length) } /* SN76589 execution */ extern int scan_line; -void IRAM_ATTR gwenesis_SN76489_run(int target) { +void gwenesis_SN76489_run(int target) { if ( sn76489_clock >= target) return; diff --git a/components/genesis/gwenesis/src/sound/ym2612.c b/components/genesis/gwenesis/src/sound/ym2612.c index 401e2f33..fb7f1716 100644 --- a/components/genesis/gwenesis/src/sound/ym2612.c +++ b/components/genesis/gwenesis/src/sound/ym2612.c @@ -2148,7 +2148,7 @@ static inline void YM2612Update(int16_t *buffer, int length) INTERNAL_TIMER_B(length); } -void IRAM_ATTR ym2612_run( int target) { +void ym2612_run( int target) { if ( ym2612_clock >= target) { return; diff --git a/components/genesis/gwenesis/src/sound/z80inst.c b/components/genesis/gwenesis/src/sound/z80inst.c index 1706eac2..5fbf1fcc 100644 --- a/components/genesis/gwenesis/src/sound/z80inst.c +++ b/components/genesis/gwenesis/src/sound/z80inst.c @@ -85,7 +85,7 @@ void z80_pulse_reset() { } static int current_timeslice = 0; -void IRAM_ATTR z80_run(int target) { +void z80_run(int target) { // we are in advance,nothind to do current_timeslice = 0; diff --git a/components/genesis/gwenesis/src/vdp/gwenesis_vdp_gfx.c b/components/genesis/gwenesis/src/vdp/gwenesis_vdp_gfx.c index 9bf96cf1..8ca4d506 100644 --- a/components/genesis/gwenesis/src/vdp/gwenesis_vdp_gfx.c +++ b/components/genesis/gwenesis/src/vdp/gwenesis_vdp_gfx.c @@ -442,7 +442,7 @@ void draw_pattern_sprite_over_planes(uint8_t *scr, uint16_t name, int paty) { } static inline __attribute__((always_inline)) -void IRAM_ATTR draw_pattern_planeB(uint8_t *scr, uint16_t name, int paty) { +void draw_pattern_planeB(uint8_t *scr, uint16_t name, int paty) { // uint16_t pat_addr = name << 5; // * 32; // uint8_t pat_palette = BITS_GEN(name, 13, 2); // unsigned int is_pat_pri = name & 0x8000; @@ -548,7 +548,7 @@ unsigned int get_hscroll_vram(int line) ******************************************************************************/ __attribute__((optimize("unroll-loops"))) static inline __attribute__((always_inline)) -void IRAM_ATTR draw_line_b(int line) +void draw_line_b(int line) { uint8_t *scr = &render_buffer[PIX_OVERFLOW]; @@ -595,7 +595,7 @@ void IRAM_ATTR draw_line_b(int line) ******************************************************************************/ __attribute__((optimize("unroll-loops"))) static inline __attribute__((always_inline)) -void IRAM_ATTR draw_line_aw(int line) { +void draw_line_aw(int line) { uint8_t *scr = &render_buffer[PIX_OVERFLOW]; @@ -690,7 +690,7 @@ void IRAM_ATTR draw_line_aw(int line) { __attribute__((optimize("unroll-loops"))) static inline __attribute__((always_inline)) -void IRAM_ATTR draw_sprites_over_planes(int line) +void draw_sprites_over_planes(int line) { uint8_t *scr; @@ -798,7 +798,7 @@ void IRAM_ATTR draw_sprites_over_planes(int line) // sprite_collision = true; } static inline __attribute__((always_inline)) -void IRAM_ATTR draw_sprites(int line) +void draw_sprites(int line) { uint8_t *scr; @@ -991,7 +991,7 @@ blit_4to5_line(uint16_t *in, uint16_t *out) { } __attribute__((optimize("unroll-loops"))) -void IRAM_ATTR gwenesis_vdp_render_line(int line) +void gwenesis_vdp_render_line(int line) { mode_h40 = REG12_MODE_H40; //mode_pal = REG1_PAL; diff --git a/components/genesis/linker.lf b/components/genesis/linker.lf new file mode 100644 index 00000000..cea5c0e7 --- /dev/null +++ b/components/genesis/linker.lf @@ -0,0 +1,14 @@ +# Move genesis code into IRAM for perforamnce +[mapping:genesis] +archive: libgenesis.a +entries: + gwenesis_bus (noflash_text) +# m68kcpu (noflash_text) + Z80 (noflash_text) + gwenesis_io (noflash_text) + gwenesis_savestate (noflash_text) + gwenesis_sn76489 (noflash_text) + ym2612 (noflash_text) + z80inst (noflash_text) + gwenesis_vdp_gfx (noflash_text) + gwenesis_vdp_mem (noflash_text) diff --git a/components/sms/smsplus/render.c b/components/sms/smsplus/render.c index dc1ea17d..c1c97b6a 100644 --- a/components/sms/smsplus/render.c +++ b/components/sms/smsplus/render.c @@ -379,7 +379,7 @@ void render_reset(void) static int prev_line = -1; /* Draw a line of the display */ -IRAM_ATTR void render_line(int line) +void render_line(int line) { int view = 1; int overscan = option.overscan; @@ -500,7 +500,7 @@ IRAM_ATTR void render_line(int line) } uint8 data[8]; -static IRAM_ATTR void* tile_get(short attr, short line) +static void* tile_get(short attr, short line) { // ---p cvhn nnnn nnnn const uint16 name = attr & 0x1ff; @@ -529,7 +529,7 @@ static IRAM_ATTR void* tile_get(short attr, short line) } /* Draw the Master System background */ -IRAM_ATTR void render_bg_sms(int line) +void render_bg_sms(int line) { int locked = 0; int yscroll_mask = (vdp.extended) ? 256 : 224; @@ -652,7 +652,7 @@ IRAM_ATTR void render_bg_sms(int line) /* Draw sprites */ -IRAM_ATTR void render_obj_sms(int line) +void render_obj_sms(int line) { int i,x,start,end,xp,yp,n; uint8 sp,bg; @@ -839,7 +839,7 @@ void palette_sync(int index) } -static IRAM_ATTR void parse_satb(int line) +static void parse_satb(int line) { /* Pointer to sprite attribute table */ uint8 *st = (uint8 *)&vdp.vram[vdp.satb]; @@ -906,7 +906,7 @@ static IRAM_ATTR void parse_satb(int line) } } -static IRAM_ATTR void update_bg_pattern_cache(void) +static void update_bg_pattern_cache(void) { #if 1 return; diff --git a/sdkconfig.defaults b/sdkconfig.defaults index 032f3c15..a0c479f7 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -30,6 +30,8 @@ CONFIG_SPIRAM=y CONFIG_SPIRAM_USE_MALLOC=y CONFIG_SPIRAM_MODE_OCT=y CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y +CONFIG_SPIRAM_RODATA=y # anything larger than this is attempted to allocate within SPIRAM first CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 # specifcally reserved internally for DMA