Skip to content

feat: Update deps to support esp-idf v6.0#109

Open
finger563 wants to merge 1 commit into
mainfrom
feat/update-deps
Open

feat: Update deps to support esp-idf v6.0#109
finger563 wants to merge 1 commit into
mainfrom
feat/update-deps

Conversation

@finger563

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 13, 2026 20:39
@github-actions

Copy link
Copy Markdown

⚡ Static analysis result ⚡

🔴 cppcheck found 33 issues! Click here to see details.

uint16_t *dst_buffer = (uint16_t*)decoded_data_;
const uint16_t *src_buffer = (const uint16_t*)pDraw->pPixels;
// two bytes per pixel for RGB565
uint16_t num_bytes_per_row = width * 2;
for (uint16_t i = 0; i < height; i++) {
uint16_t y = ys + i;

!Line: 106 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

static int on_data_decode(JPEGDRAW *pDraw) {
auto width = pDraw->iWidth;
auto height = pDraw->iHeight;
auto xs = pDraw->x;
auto ys = pDraw->y;
uint16_t *dst_buffer = (uint16_t*)decoded_data_;

!Line: 101 - style: Parameter 'pDraw' can be declared as pointer to const. However it seems that 'on_data_decode' is a callback function, if 'pDraw' is declared with const you might also need to cast function pointer(s). [constParameterCallback]

!Line: 38 - note: You might need to cast the function pointer here
!Line: 101 - note: Parameter 'pDraw' can be declared as pointer to const

fclose(f);
}
}
void save_sms(std::string_view save_path) {
// open the save path as a file descriptor

!Line: 227 - warning: inconclusive: If resource allocation fails, then there is a possible null pointer dereference: f [nullPointerOutOfResources]

!Line: 225 - note: Assuming allocation function fails
!Line: 225 - note: Assignment 'f=fopen(save_path.data(),"rb")', assigned value is 0
!Line: 227 - note: Null pointer dereference

fclose(f);
}
std::span<uint8_t> get_sms_video_buffer() {
int height = is_gg ? GG_VISIBLE_HEIGHT : SMS_VISIBLE_HEIGHT;
int width = is_gg ? GG_SCREEN_WIDTH : SMS_SCREEN_WIDTH;

!Line: 235 - warning: inconclusive: If resource allocation fails, then there is a possible null pointer dereference: f [nullPointerOutOfResources]

!Line: 233 - note: Assuming allocation function fails
!Line: 233 - note: Assignment 'f=fopen(save_path.data(),"wb")', assigned value is 0
!Line: 235 - note: Null pointer dereference

BoxEmu::get().play_audio((uint8_t*)sms_audio_buffer, sms_audio_buffer_len * 2 * 2); // 2 channels, 2 bytes per sample
// update unlock based on x button
static bool last_x = false;
if (state.x && !last_x) {
unlock = !unlock;

!Line: 203 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

box.play_audio((uint8_t*)audio_buffer, audio_buffer_offset * sizeof(int16_t));
audio_buffer_offset = 0;
currentAudioBuffer = currentAudioBuffer ? 0 : 1;
audio_buffer = audio_buffers[currentAudioBuffer];
}
memcpy(audio_buffer + audio_buffer_offset, Data, Length * sizeof(int16_t));

!Line: 405 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

return std::span<uint8_t>((uint8_t*)framebuffer, MSX_SCREEN_WIDTH * MSX_SCREEN_HEIGHT * 2);
}
void deinit_msx() {
TrashMSX();
TrashMachine();

!Line: 541 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

BoxEmu::get().play_audio((uint8_t*)audio_frame, num_bytes);
}
extern "C" void osd_setsound(void (*playfunc)(void *buffer, int length))
{
//Indicates we should call playfunc() to get more data.

!Line: 50 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

return (uint16_t*)myPalette;
}
/* clear all frames to a particular color */
static void clear(uint8 color)
{

!Line: 160 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

BoxEmu::get().play_audio((uint8_t*)gwenesis_ym2612_buffer, audio_len * sizeof(int16_t));
}
// manage statistics
auto end = esp_timer_get_time();
uint64_t elapsed = end - start;

!Line: 336 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

uint16_t *frame_ptr = (uint16_t*)frame.data();
for (int i = 0; i < (height*width); i++) {
uint8_t index = buffer[i];
frame_ptr[i] = palette[index % PALETTE_SIZE];
}
return frame;

!Line: 382 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

return (SaveState*)1;
}
extern "C" SaveState* saveGwenesisStateOpenForWrite(const char* fileName)
{
return (SaveState*)1;

!Line: 72 - portability: Casting non-zero decimal integer literal to pointer. [intToPointerCast]

return (SaveState*)1;
}
extern "C" int saveGwenesisStateGet(SaveState* state, const char* tagName)
{
int value = 0;

!Line: 77 - portability: Casting non-zero decimal integer literal to pointer. [intToPointerCast]

screens[0].data = (uint8_t*)framebuffer;
screens[0].not_on_heap = true;
// statusbar
screens[4].width = SCREENWIDTH;
screens[4].height = (ST_SCALED_HEIGHT + 1);

!Line: 247 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

box.play_audio((const uint8_t*)mixbuffer, AUDIO_BUFFER_LENGTH * sizeof(int16_t));
std::this_thread::sleep_for(std::chrono::microseconds(1'000'000 / TICRATE));
return false;
}
void I_InitSound(void) {

!Line: 390 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

uint8_t *span_ptr = (uint8_t*)(currentBuffer ? displayBuffer[0] : displayBuffer[1]);
std::span<uint8_t> frame(span_ptr, num_pixels * sizeof(uint16_t));
// use the palette to convert the framebuffer to RGB565
const uint8_t *buf = (const uint8_t*)framebuffer;
const uint16_t *palette = BoxEmu::get().palette();

!Line: 639 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

const uint8_t *buf = (const uint8_t*)framebuffer;
const uint16_t *palette = BoxEmu::get().palette();
if (palette) {
for (int i = 0; i < num_pixels; i++) {
uint8_t pal_index = buf[i];
uint16_t color = palette[pal_index];

!Line: 643 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

return (ptr >= (void*)memory_pool && ptr < (void*)memory_pool + memory_pool_size);
}
void* pool_alloc(size_t size) {
size = ALIGN4(size);
BlockHeader* curr = free_list;

!Line: 32 - portability: '(void*)memory_pool' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer]

fclose(f);
vram_dirty();
pal_dirty();
sound_dirty();
mem_updatemap();
}

!Line: 197 - warning: inconclusive: If resource allocation fails, then there is a possible null pointer dereference: f [nullPointerOutOfResources]

!Line: 195 - note: Assuming allocation function fails
!Line: 195 - note: Assignment 'f=fopen(save_path.data(),"rb")', assigned value is 0
!Line: 197 - note: Null pointer dereference

fclose(f);
}
std::span<uint8_t> get_gameboy_video_buffer() {
return std::span<uint8_t>((uint8_t*)framebuffer, GAMEBOY_SCREEN_WIDTH * GAMEBOY_SCREEN_HEIGHT * 2);
}

!Line: 209 - warning: inconclusive: If resource allocation fails, then there is a possible null pointer dereference: f [nullPointerOutOfResources]

!Line: 207 - note: Assuming allocation function fails
!Line: 207 - note: Assignment 'f=fopen(save_path.data(),"wb")', assigned value is 0
!Line: 209 - note: Null pointer dereference

fb.ptr = (uint8_t*)framebuffer;
}
rtc_tick();
sound_mix();

!Line: 68 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

pcm.buf = (int16_t*)audio;
static constexpr int GBC_AUDIO_BUFFER_SIZE = GAMEBOY_AUDIO_SAMPLE_RATE * 2 * 2 / 5; // TODO: 5 is a hack to make it work
pcm.len = GBC_AUDIO_BUFFER_SIZE / sizeof(int16_t);
// set native size
BoxEmu::get().native_size(GAMEBOY_SCREEN_WIDTH, GAMEBOY_SCREEN_HEIGHT);

!Line: 118 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

fb.ptr = (uint8_t*)displayBuffer[0];
fb.enabled = 1;
fb.dirty = 0;
framebuffer = displayBuffer[0];
BoxEmu::get().audio_sample_rate(GAMEBOY_AUDIO_SAMPLE_RATE);

!Line: 135 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

return std::span<uint8_t>((uint8_t*)framebuffer, GAMEBOY_SCREEN_WIDTH * GAMEBOY_SCREEN_HEIGHT * 2);
}
void deinit_gameboy() {
// Free shared memory
gbc_free_shared_memory();

!Line: 213 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

size_t wav_size = (wav_end - wav_start) - 1;
FILE *fp = fmemopen((void *)wav_start, wav_size, "rb");
// read the file into the audio_bytes vector
audio_bytes.resize(wav_size);
fread(audio_bytes.data(), 1, wav_size, fp);
fclose(fp);

!Line: 166 - error: Subtracting pointers that point to different objects [subtractPointers]

!Line: 158 - note: Variable declared here.
!Line: 166 - note: Array decayed to pointer here.
!Line: 157 - note: Variable declared here.
!Line: 166 - note: Array decayed to pointer here.
!Line: 166 - note: Subtracting pointers that point to different objects

box.write_lcd_frame(0, y + _y_offset, lcd_width(), num_lines, (uint8_t*)&_buf[0]);
}
// now return
return false;
}

!Line: 777 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

box.write_lcd_frame(_x_offset, y + _y_offset, display_width_, num_lines, (uint8_t*)&_buf[0]);
}
} else {
// no palette
for (int y=0; y<display_height_; y+= num_lines_to_write) {
uint16_t* _buf = (uint16_t*)((uint32_t)vram0 * (vram_index ^ 0x01) + (uint32_t)vram1 * vram_index);

!Line: 800 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

box.write_lcd_frame(_x_offset, y + _y_offset, display_width_, num_lines, (uint8_t*)&_buf[0]);
}
}
} else {
// we are scaling the screen (and possibly using a custom palette)
// if we don't have a custom palette, we just need to scale/fill the frame

!Line: 819 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

box.write_lcd_frame(0 + _x_offset, y, max_x, i, (uint8_t*)&_buf[0]);
}
} else {
// no palette
for (int y=0; y<max_y; y+=num_lines_to_write) {
// each iteration of the loop, we swap the vram index so that we can

!Line: 854 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

box.write_lcd_frame(0 + _x_offset, y, max_x, i, (uint8_t*)&_buf[0]);
}
}
}
return false;
}

!Line: 880 - warning: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast [dangerousTypeCast]

extern const char wav_start[] asm("_binary_click_wav_start"); // cppcheck-suppress syntaxError
extern const char wav_end[] asm("_binary_click_wav_end"); // cppcheck-suppress syntaxError
// -1 due to the size being 1 byte too large, I think because end is the byte
// immediately after the last byte in the memory but I'm not sure - cmm 2022-08-20
//

!Line: 157 - information: Unmatched suppression: syntaxError [unmatchedSuppression]

extern const char wav_end[] asm("_binary_click_wav_end"); // cppcheck-suppress syntaxError
// -1 due to the size being 1 byte too large, I think because end is the byte
// immediately after the last byte in the memory but I'm not sure - cmm 2022-08-20
//
// Suppression as these are linker symbols and cppcheck doesn't know how to ensure

!Line: 158 - information: Unmatched suppression: syntaxError [unmatchedSuppression]

size_t wav_size = (wav_end - wav_start) - 1;
FILE *fp = fmemopen((void *)wav_start, wav_size, "rb");
// read the file into the audio_bytes vector
audio_bytes.resize(wav_size);
fread(audio_bytes.data(), 1, wav_size, fp);
fclose(fp);

!Line: 166 - information: Unmatched suppression: comparePointers [unmatchedSuppression]


Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates several emulator components and build settings to compile cleanly against newer ESP-IDF / toolchain behavior (esp-idf v6.0 per PR title), primarily by tightening C/C++ standards flags, adjusting warning handling, and updating a few code paths to match updated headers/struct layouts.

Changes:

  • Add per-language compile options (e.g., -std=gnu17) and targeted warning/error suppressions across multiple components’ CMakeLists.txt.
  • Modernize/adjust C code for stricter compilation (e.g., stdbool.h, explicit (void) prototypes, cheat handler refactor).
  • Update a few runtime settings/initializations (USB FAT mount config, audio sample rates, MSX Image struct initialization).

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
components/sms/CMakeLists.txt Adds C-only gnu17 and additional warning controls for esp-idf/toolchain changes.
components/pool_allocator/src/pool_allocator.c Adjusts pointer range checking logic in pool_contains.
components/nes/src/nes.cpp Makes NES audio sample rate explicit (no functional change vs 44100/2).
components/nes/nofrendo/noftypes.h Switches custom bool typedef to <stdbool.h>.
components/nes/CMakeLists.txt Adds C-only gnu17 and warning controls.
components/msx/src/msx.cpp Extends Image designated initializer to include additional fields.
components/msx/CMakeLists.txt Applies -Wno-register only for C++ compilation units.
components/gbc/src/gameboy.cpp Changes Game Boy audio sample rate constant.
components/gbc/CMakeLists.txt Restricts -Wno-discarded-qualifiers to C sources.
components/doom/prboom/m_cheat.h Tightens cheat handler function pointer type to void (*)(void).
components/doom/prboom/m_cheat.c Refactors cheat argument passing to use globals and updates prototypes/calls.
components/doom/CMakeLists.txt Adds C-only gnu17 and relaxes some warnings-as-errors.
components/box-emu/src/box-emu.cpp Adds .use_one_fat = true to FAT mount config for USB MSC.
components/box-emu/include/box-emu.hpp Comments out a HAL header include in favor of esp_private/usb_phy.h.
components/box-emu/idf_component.yml Adjusts quoting style and adds espressif/usb dependency.

Comment on lines 31 to 33
int pool_contains(const void* ptr) {
return (ptr >= memory_pool && ptr < memory_pool + memory_pool_size);
return (ptr >= (void*)memory_pool && ptr < (void*)memory_pool + memory_pool_size);
}
static const size_t GAMEBOY_SCREEN_WIDTH = 160;
static const size_t GAMEBOY_SCREEN_HEIGHT = 144;
static const int GAMEBOY_AUDIO_SAMPLE_RATE = 32000;
static const int GAMEBOY_AUDIO_SAMPLE_RATE = 32768;
Comment on lines 9 to 11

#include <hal/usb_phy_types.h>
// #include <hal/usb_phy_types.h>
#include <esp_private/usb_phy.h>
espp/task: '>=1.0'
espp/timer: '>=1.0'
espp/serialization: '>=1.0'
espressif/usb: '*'
@github-actions

Copy link
Copy Markdown

ESP-IDF Size Report for 'Esp Box Emu'

Metric Base PR Delta
FLASH 3,225,092 bytes (51.26%) 3,225,168 bytes (51.26%) 🔺 +76 bytes (0.00%)
DRAM 268,739 bytes (78.63%) 268,739 bytes (78.63%) 0 bytes (0.00%)
IRAM 16,384 bytes (100.00%) 16,384 bytes (100.00%) 0 bytes (0.00%)
RAM (DRAM+IRAM) 285,123 bytes 285,123 bytes 0 bytes (0.00%)

FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available.
DRAM/IRAM usage does not include memory used by the heap allocator at runtime.
This report was generated by esp-idf-size-delta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants