Skip to content

feat: LVGL memory in PSRAM, espp sdcard/usb_device components, dependency update - #121

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

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

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Description

Three related changes to the box-emu component:

LVGL memory in PSRAM

LVGL is now built with CONFIG_LV_USE_CUSTOM_MALLOC, and components/box-emu/src/lvgl_mem.c implements its allocator hooks on the PSRAM heap (MALLOC_CAP_SPIRAM), falling back to internal RAM only if PSRAM is exhausted. lv_mem_monitor() reports the PSRAM heap. Before #120 LVGL used a fixed 50KB pool in internal RAM (which ran out in the pause menu and halted LVGL); #120 switched it to plain malloc(), which only lands in PSRAM by virtue of CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0. This makes the placement explicit.

The display's DMA buffers are unaffected: the BSP still allocates those with the capabilities the LCD driver needs.

espp sdcard and usb_device components

  • The uSD card is managed by espp::SdCard (SPI3, same pins), which separates card initialization from FAT mounting. BoxEmu::sdcard() still returns the sdmmc_card_t*; BoxEmu::sdcard_component() exposes the component.
  • USB mass storage uses espp::UsbDevice's MSC function. Enabling USB unmounts the card's volume from the application and hands the card to the host (same VID/PID/strings as before). If the host ejects the drive, the card is mounted for the application again automatically. Disabling USB stops the stack, reconnects the USB-Serial-JTAG console and mounts the card again.
  • This replaces the raw TinyUSB descriptors and tinyusb_msc storage code. It also removes a latent bug: jtag_phy_ was never initialized but was passed to usb_del_phy() on the first USB enable.

Dependency update

Component Before After
espp/* 1.1.1 (task 1.1.3) ≥ 1.3.4 (+ espp/sdcard, espp/usb_device)
lvgl/lvgl 9.5.0 ≥ 9.6.0
espressif/esp_tinyusb 2.2.1 ≥ 2.3.0
espressif/tinyusb 0.19.0 0.21.0 (required by usb_device)
espressif/usb 1.4.1 dropped (the USB PHY API comes from esp_hw_support)

CONFIG_TINYUSB_MSC_MOUNT_PATH is removed from sdkconfig.defaults: the mount path is passed to the MSC medium directly.

Motivation and Context

  • Keep LVGL's memory out of the limited internal RAM, explicitly.
  • Use the maintained espp components for the SD card and USB device instead of carrying TinyUSB descriptor tables and mount/unmount plumbing in this repo.
  • Pick up the latest espp / LVGL / TinyUSB releases.

How has this been tested?

  • Builds cleanly on ESP-IDF 6.1 (all cores enabled) with the resolved versions above.
  • Not yet verified on hardware: at the time of opening, no ESP-BOX was attached. To verify: boot to the rom list (SD card mounts, box art loads), enable USB in the settings screen and mount the drive on a PC, eject it, disable USB (the console should come back and the rom list should still work), then launch a game.

Notes for review

  • LVGL 9.6 deprecates lv_obj_add_flag / lv_obj_remove_flag / lv_obj_has_flag, which the SquareLine-generated files under components/gui/generated use; these are warnings only and would need regenerating the UI to clear.
  • The CI workflow builds with IDF v6.0.1; the new dependencies require IDF ≥ 5.5, so that is unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

🤖 Generated with Claude Code

https://claude.ai/code/session_01AWhoGwibqcKDhcG17mjVT1

…ts; update dependencies

- LVGL is built with CONFIG_LV_USE_CUSTOM_MALLOC: components/box-emu/src/lvgl_mem.c
  allocates from the PSRAM heap (falling back to internal RAM only if PSRAM is
  exhausted) instead of a fixed pool in internal RAM, and reports the PSRAM heap
  to lv_mem_monitor().
- The uSD card is managed by espp::SdCard (card initialization and FAT mounting
  as separate steps), replacing the hand-rolled SDSPI + esp_vfs_fat_sdspi_mount
  code.
- USB mass storage uses espp::UsbDevice's MSC function: the card's volume is
  unmounted from the application and handed to the host while USB is enabled;
  if the host ejects the drive the card is mounted for the application again.
  Disabling USB stops the stack, reconnects the USB-Serial-JTAG console and
  mounts the card. This replaces the raw TinyUSB descriptors and
  tinyusb_msc storage code (and the uninitialized JTAG PHY handle that was
  passed to usb_del_phy()).
- Dependencies: espp components 1.1.x -> >=1.3.4 (adding espp/sdcard and
  espp/usb_device), lvgl >=9.6.0, esp_tinyusb >=2.3.0 / tinyusb 0.21 (pulled in
  by usb_device). espressif/usb is no longer a dependency (the USB PHY API comes
  from esp_hw_support).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AWhoGwibqcKDhcG17mjVT1
Copilot AI lite review requested due to automatic review settings September 22, 2026 04:43
@github-actions

Copy link
Copy Markdown

⚡ Static analysis result ⚡

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

void captureScreenToMemory(u32* mem) {}
void queueScreenshot(const char* screenshotPath) {}
void startGifRecording(const char* path) {}
void stopGifRecording() {}
void updateSettings() {}
void resize(s32 width, s32 height) {}

!Line: 106 - style: Parameter 'mem' can be declared as pointer to const [constParameterPointer]

void clearVirtualDisplay(f32* color, bool clearColor) {}
void copyToVirtualDisplay(RenderTargetHandle src) {}
void copyBackbufferToRenderTarget(RenderTargetHandle dst) {}
void setPalette(const u32* palette)
{

!Line: 163 - style: Parameter 'color' can be declared as pointer to const [constParameterPointer]

void freeTexture(TextureGpu* texture) {}
void getTextureDim(TextureGpu* texture, u32* width, u32* height) { *width = 0; *height = 0; }
void* getGpuPtr(const TextureGpu* texture) { return nullptr; }
void drawIndexedTriangles(u32 triCount, u32 indexStride, u32 indexStart) {}
void drawLines(u32 lineCount) {}
void bloomPostEnable(bool enable) {}

!Line: 227 - style: Parameter 'texture' can be declared as pointer to const [constParameterPointer]

m_done = xSemaphoreCreateBinary();
}
ThreadEsp::~ThreadEsp()
{
if (m_isRunning)

!Line: 33 - performance: Variable 'm_done' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList]

ThreadFunc getFunc() { return m_func; }
void* getUserData() { return m_userData; }
protected:
static void threadEntry(void* arg);

!Line: 21 - style: inconclusive: Either there is a missing 'override', or the member function 'ThreadEsp::getFunc' can be const. [functionConst]

virtual void waitOnExit(void);
ThreadFunc getFunc() { return m_func; }
void* getUserData() { return m_userData; }
protected:

!Line: 19 - style: Virtual function 'waitOnExit' is called from destructor '~ThreadEsp()' at line 40. Dynamic binding is not used. [virtualCallInConstructor]

!Line: 40 - note: Calling waitOnExit
!Line: 19 - note: waitOnExit is a virtual function

namespace TFE_Memory
{
// Serializes all access to the pool allocator (recursive).
struct PoolLock
{
PoolLock();

!Line: 6 - error: Code 'namespaceTFE_Memory{' is invalid C code. [syntaxError]

RelativePointer region_getRelativePointer(MemoryRegion* region, void* ptr)
{
return NULL_RELATIVE_POINTER;
}
void* region_getRealPointer(MemoryRegion* region, RelativePointer ptr)

!Line: 284 - style: Parameter 'region' can be declared as pointer to const [constParameterPointer]

RelativePointer region_getRelativePointer(MemoryRegion* region, void* ptr)
{
return NULL_RELATIVE_POINTER;
}
void* region_getRealPointer(MemoryRegion* region, RelativePointer ptr)

!Line: 284 - style: Parameter 'ptr' can be declared as pointer to const [constParameterPointer]

void* region_getRealPointer(MemoryRegion* region, RelativePointer ptr)
{
return nullptr;
}
bool region_serializeToDisk(MemoryRegion* region, FileStream* file)

!Line: 289 - style: Parameter 'region' can be declared as pointer to const [constParameterPointer]

bool region_serializeToDisk(MemoryRegion* region, FileStream* file)
{
return false;
}
MemoryRegion* region_restoreFromDisk(MemoryRegion* region, FileStream* file)

!Line: 294 - style: Parameter 'region' can be declared as pointer to const [constParameterPointer]

bool region_serializeToDisk(MemoryRegion* region, FileStream* file)
{
return false;
}
MemoryRegion* region_restoreFromDisk(MemoryRegion* region, FileStream* file)

!Line: 294 - style: Parameter 'file' can be declared as pointer to const [constParameterPointer]

MemoryRegion* region_restoreFromDisk(MemoryRegion* region, FileStream* file)
{
return nullptr;
}
void region_test()

!Line: 299 - style: Parameter 'region' can be declared as pointer to const [constParameterPointer]

MemoryRegion* region_restoreFromDisk(MemoryRegion* region, FileStream* file)
{
return nullptr;
}
void region_test()

!Line: 299 - style: Parameter 'file' can be declared as pointer to const [constParameterPointer]

output = (u8*)pixelData;
return width * height;
}
void readImageFromMemory(Image* output, size_t size, const u32* pixelData)
{

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

output->data = (u32*)pixelData;
}
void writeImage(const char* path, u32 width, u32 height, u32* pixelData)
{
}

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

void setCurrentGame(IGame* game) {}
void setAppState(AppState state) {}
AppState update() { return APP_STATE_GAME; }
void draw(bool drawFrontEnd, bool noGameData, bool setDefaults, bool showFps) {}
void setCanSave(bool canSave) {}
bool getCanSave() { return true; }

!Line: 53 - style: Parameter 'game' can be declared as pointer to const [constParameterPointer]

void registerCVarInt(const char* name, u32 flags, s32* var, const char* helpString) {}
void registerCVarFloat(const char* name, u32 flags, f32* var, const char* helpString) {}
void registerCVarBool(const char* name, u32 flags, bool* var, const char* helpString) {}
void registerCVarString(const char* name, u32 flags, char* var, u32 maxLen, const char* helpString) {}
void registerCommand(const char* name, ConsoleFunc func, u32 argCount, const char* helpString, bool repeat) {}

!Line: 87 - style: Parameter 'var' can be declared as pointer to const [constParameterPointer]

void registerCVarFloat(const char* name, u32 flags, f32* var, const char* helpString) {}
void registerCVarBool(const char* name, u32 flags, bool* var, const char* helpString) {}
void registerCVarString(const char* name, u32 flags, char* var, u32 maxLen, const char* helpString) {}
void registerCommand(const char* name, ConsoleFunc func, u32 argCount, const char* helpString, bool repeat) {}
void addSerializedCVarInt(const char* name, s32 value) {}

!Line: 88 - style: Parameter 'var' can be declared as pointer to const [constParameterPointer]

void registerCVarBool(const char* name, u32 flags, bool* var, const char* helpString) {}
void registerCVarString(const char* name, u32 flags, char* var, u32 maxLen, const char* helpString) {}
void registerCommand(const char* name, ConsoleFunc func, u32 argCount, const char* helpString, bool repeat) {}
void addSerializedCVarInt(const char* name, s32 value) {}
void addSerializedCVarFloat(const char* name, f32 value) {}

!Line: 89 - style: Parameter 'var' can be declared as pointer to const [constParameterPointer]

void registerCVarString(const char* name, u32 flags, char* var, u32 maxLen, const char* helpString) {}
void registerCommand(const char* name, ConsoleFunc func, u32 argCount, const char* helpString, bool repeat) {}
void addSerializedCVarInt(const char* name, s32 value) {}
void addSerializedCVarFloat(const char* name, f32 value) {}
void addSerializedCVarBool(const char* name, bool value) {}

!Line: 90 - style: Parameter 'var' can be declared as pointer to const [constParameterPointer]

void free(Image* image) {}
void freeAll() {}
size_t writeImageToMemory(u8*& output, u32 width, u32 height, const u32* pixelData)
{
output = (u8*)pixelData;

!Line: 161 - style: Parameter 'image' can be declared as pointer to const [constParameterPointer]

void writeImage(const char* path, u32 width, u32 height, u32* pixelData)
{
}
}
/////////////////////////////////////////////

!Line: 177 - style: Parameter 'pixelData' can be declared as pointer to const [constParameterPointer]

void computeCameraTransform(RSector* sector, f32 pitch, f32 yaw, f32 camX, f32 camY, f32 camZ) {}
void transformPointByCamera(vec3_float* worldPoint, vec3_float* viewPoint) {}
void computeSkyOffsets() {}
}
namespace RClassic_Float

!Line: 236 - style: Parameter 'sector' can be declared as pointer to const [constParameterPointer]

void transformPointByCamera(vec3_float* worldPoint, vec3_float* viewPoint) {}
void computeSkyOffsets() {}
}
namespace RClassic_Float
{

!Line: 237 - style: Parameter 'worldPoint' can be declared as pointer to const [constParameterPointer]

void transformPointByCamera(vec3_float* worldPoint, vec3_float* viewPoint) {}
void computeSkyOffsets() {}
}
namespace RClassic_Float
{

!Line: 237 - style: Parameter 'viewPoint' can be declared as pointer to const [constParameterPointer]

void computeCameraTransform(RSector* sector, f32 pitch, f32 yaw, f32 camX, f32 camY, f32 camZ) {}
void computeSkyOffsets() {}
}
void TFE_Sectors_Float::destroy() {}
void TFE_Sectors_Float::reset() {}

!Line: 246 - style: Parameter 'sector' can be declared as pointer to const [constParameterPointer]

void screenGPU_setHudTextureCallbacks(s32 count, TextureListCallback* callbacks) {}
void screenGPU_beginQuads(u32 width, u32 height) {}
void screenGPU_endQuads() {}
void screenGPU_beginLines(u32 width, u32 height) {}
void screenGPU_endLines() {}
void screenGPU_beginImageQuads(u32 width, u32 height) {}

!Line: 265 - style: Parameter 'callbacks' can be declared as pointer to const [constParameterPointer]

void screenGPU_addImageQuad(s32 x0, s32 z0, s32 x1, s32 z1, TextureGpu* texture) {}
void screenGPU_addImageQuad(s32 x0, s32 z0, s32 x1, s32 z1, f32 u0, f32 u1, TextureGpu* texture) {}
void screenGPU_drawPoint(ScreenRect* rect, s32 x, s32 z, u8 color) {}
void screenGPU_drawLine(ScreenRect* rect, s32 x0, s32 z0, s32 x1, s32 z1, u8 color) {}
void screenGPU_blitTextureLit(TextureData* texture, DrawRect* rect, s32 x0, s32 y0, u8 lightLevel, JBool forceTransparency) {}
void screenGPU_drawColoredQuad(fixed16_16 x0, fixed16_16 y0, fixed16_16 x1, fixed16_16 y1, u8 color) {}

!Line: 272 - style: Parameter 'texture' can be declared as pointer to const [constParameterPointer]

void screenGPU_addImageQuad(s32 x0, s32 z0, s32 x1, s32 z1, f32 u0, f32 u1, TextureGpu* texture) {}
void screenGPU_drawPoint(ScreenRect* rect, s32 x, s32 z, u8 color) {}
void screenGPU_drawLine(ScreenRect* rect, s32 x0, s32 z0, s32 x1, s32 z1, u8 color) {}
void screenGPU_blitTextureLit(TextureData* texture, DrawRect* rect, s32 x0, s32 y0, u8 lightLevel, JBool forceTransparency) {}
void screenGPU_drawColoredQuad(fixed16_16 x0, fixed16_16 y0, fixed16_16 x1, fixed16_16 y1, u8 color) {}
void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}

!Line: 273 - style: Parameter 'texture' can be declared as pointer to const [constParameterPointer]

void screenGPU_drawPoint(ScreenRect* rect, s32 x, s32 z, u8 color) {}
void screenGPU_drawLine(ScreenRect* rect, s32 x0, s32 z0, s32 x1, s32 z1, u8 color) {}
void screenGPU_blitTextureLit(TextureData* texture, DrawRect* rect, s32 x0, s32 y0, u8 lightLevel, JBool forceTransparency) {}
void screenGPU_drawColoredQuad(fixed16_16 x0, fixed16_16 y0, fixed16_16 x1, fixed16_16 y1, u8 color) {}
void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}

!Line: 274 - style: Parameter 'rect' can be declared as pointer to const [constParameterPointer]

void screenGPU_drawLine(ScreenRect* rect, s32 x0, s32 z0, s32 x1, s32 z1, u8 color) {}
void screenGPU_blitTextureLit(TextureData* texture, DrawRect* rect, s32 x0, s32 y0, u8 lightLevel, JBool forceTransparency) {}
void screenGPU_drawColoredQuad(fixed16_16 x0, fixed16_16 y0, fixed16_16 x1, fixed16_16 y1, u8 color) {}
void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}
void texturepacker_reset() {}

!Line: 275 - style: Parameter 'rect' can be declared as pointer to const [constParameterPointer]

void screenGPU_blitTextureLit(TextureData* texture, DrawRect* rect, s32 x0, s32 y0, u8 lightLevel, JBool forceTransparency) {}
void screenGPU_drawColoredQuad(fixed16_16 x0, fixed16_16 y0, fixed16_16 x1, fixed16_16 y1, u8 color) {}
void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}
void texturepacker_reset() {}
}

!Line: 276 - style: Parameter 'texture' can be declared as pointer to const [constParameterPointer]

void screenGPU_blitTextureLit(TextureData* texture, DrawRect* rect, s32 x0, s32 y0, u8 lightLevel, JBool forceTransparency) {}
void screenGPU_drawColoredQuad(fixed16_16 x0, fixed16_16 y0, fixed16_16 x1, fixed16_16 y1, u8 color) {}
void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}
void texturepacker_reset() {}
}

!Line: 276 - style: Parameter 'rect' can be declared as pointer to const [constParameterPointer]

void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}
void texturepacker_reset() {}
}
/////////////////////////////////////////////

!Line: 278 - style: Parameter 'texture' can be declared as pointer to const [constParameterPointer]

void screenGPU_blitTextureScaled(TextureData* texture, DrawRect* rect, fixed16_16 x0, fixed16_16 y0, fixed16_16 xScale, fixed16_16 yScale, u8 lightLevel, JBool forceTransparency) {}
void texturepacker_reset() {}
}
/////////////////////////////////////////////

!Line: 278 - style: Parameter 'rect' can be declared as pointer to const [constParameterPointer]

void onSoundPlay(char* name, CaptionEnv env) {}
bool cutsceneCaptionsEnabled() { return false; }
bool gameplayCaptionsEnabled() { return false; }
}

!Line: 342 - style: Parameter 'name' can be declared as pointer to const [constParameterPointer]

s_audioThreadCallback((f32*)s_sfxBuffer, AUDIO_CALLBACK_BUFFER_SIZE, 1.0f);
unlock();
haveSfx = true;
}
memset(s_midiBuffer, 0, PCM_BYTES);
const int64_t synthStart = esp_timer_get_time();

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

static bool audioTask(std::mutex& m, std::condition_variable& cv, bool& task_notified)
{
TFE_Memory::DfAllocScope allocScope;
using namespace std::chrono;
static constexpr auto chunkPeriod = microseconds((1000000LL * AUDIO_CALLBACK_BUFFER_SIZE) / AUDIO_FREQ);
static auto nextChunk = steady_clock::now();

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

!Line: 194 - note: You might need to cast the function pointer here
!Line: 68 - note: Parameter 'm' can be declared as reference to const

static bool audioTask(std::mutex& m, std::condition_variable& cv, bool& task_notified)
{
TFE_Memory::DfAllocScope allocScope;
using namespace std::chrono;
static constexpr auto chunkPeriod = microseconds((1000000LL * AUDIO_CALLBACK_BUFFER_SIZE) / AUDIO_FREQ);
static auto nextChunk = steady_clock::now();

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

!Line: 194 - note: You might need to cast the function pointer here
!Line: 68 - note: Parameter 'cv' can be declared as reference to const

static bool audioTask(std::mutex& m, std::condition_variable& cv, bool& task_notified)
{
TFE_Memory::DfAllocScope allocScope;
using namespace std::chrono;
static constexpr auto chunkPeriod = microseconds((1000000LL * AUDIO_CALLBACK_BUFFER_SIZE) / AUDIO_FREQ);
static auto nextChunk = steady_clock::now();

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

!Line: 194 - note: You might need to cast the function pointer here
!Line: 68 - note: Parameter 'task_notified' can be declared as reference to const

bool playOneShot(SoundType type, f32 volume, const SoundBuffer* buffer, bool looping, SoundFinishedCallback finishedCallback, void* cbUserData, s32 cbArg) { return false; }
SoundSource* createSoundSource(SoundType type, f32 volume, const SoundBuffer* buffer, SoundFinishedCallback callback, void* userData) { return nullptr; }
s32 getSourceSlot(SoundSource* source) { return -1; }
SoundSource* getSourceFromSlot(s32 slot) { return nullptr; }
void playSource(SoundSource* source, bool looping) {}
void stopSource(SoundSource* source) {}

!Line: 275 - style: Parameter 'cbUserData' can be declared as pointer to const [constParameterPointer]

SoundSource* createSoundSource(SoundType type, f32 volume, const SoundBuffer* buffer, SoundFinishedCallback callback, void* userData) { return nullptr; }
s32 getSourceSlot(SoundSource* source) { return -1; }
SoundSource* getSourceFromSlot(s32 slot) { return nullptr; }
void playSource(SoundSource* source, bool looping) {}
void stopSource(SoundSource* source) {}
void freeSource(SoundSource* source) {}

!Line: 276 - style: Parameter 'userData' can be declared as pointer to const [constParameterPointer]

s32 getSourceSlot(SoundSource* source) { return -1; }
SoundSource* getSourceFromSlot(s32 slot) { return nullptr; }
void playSource(SoundSource* source, bool looping) {}
void stopSource(SoundSource* source) {}
void freeSource(SoundSource* source) {}
void setSourceVolume(SoundSource* source, f32 volume) {}

!Line: 277 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

void playSource(SoundSource* source, bool looping) {}
void stopSource(SoundSource* source) {}
void freeSource(SoundSource* source) {}
void setSourceVolume(SoundSource* source, f32 volume) {}
void setSourceBuffer(SoundSource* source, const SoundBuffer* buffer) {}
bool isSourcePlaying(SoundSource* source) { return false; }

!Line: 279 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

void stopSource(SoundSource* source) {}
void freeSource(SoundSource* source) {}
void setSourceVolume(SoundSource* source, f32 volume) {}
void setSourceBuffer(SoundSource* source, const SoundBuffer* buffer) {}
bool isSourcePlaying(SoundSource* source) { return false; }
f32 getSourceVolume(SoundSource* source) { return 0.0f; }

!Line: 280 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

void freeSource(SoundSource* source) {}
void setSourceVolume(SoundSource* source, f32 volume) {}
void setSourceBuffer(SoundSource* source, const SoundBuffer* buffer) {}
bool isSourcePlaying(SoundSource* source) { return false; }
f32 getSourceVolume(SoundSource* source) { return 0.0f; }
}

!Line: 281 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

void setSourceVolume(SoundSource* source, f32 volume) {}
void setSourceBuffer(SoundSource* source, const SoundBuffer* buffer) {}
bool isSourcePlaying(SoundSource* source) { return false; }
f32 getSourceVolume(SoundSource* source) { return 0.0f; }
}

!Line: 282 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

void setSourceBuffer(SoundSource* source, const SoundBuffer* buffer) {}
bool isSourcePlaying(SoundSource* source) { return false; }
f32 getSourceVolume(SoundSource* source) { return 0.0f; }
}
void espbox_shared_audio(bool alloc)

!Line: 283 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

bool isSourcePlaying(SoundSource* source) { return false; }
f32 getSourceVolume(SoundSource* source) { return 0.0f; }
}
void espbox_shared_audio(bool alloc)
{

!Line: 284 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

f32 getSourceVolume(SoundSource* source) { return 0.0f; }
}
void espbox_shared_audio(bool alloc)
{
ESPBOX_SHARED_ALLOC(TFE_Audio::s_sfxBuffer, TFE_Audio::AUDIO_BUFFER_SIZE);

!Line: 285 - style: Parameter 'source' can be declared as pointer to const [constParameterPointer]

namespace TFE_DarkForces
{
enum GameMissionMode
{
MISSION_MODE_LOADING = 0, // causes the loading screen to be displayed.
MISSION_MODE_MAIN = 1, // the main in-game experience.

!Line: 15 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
enum MapUpdateID
{
MAP_CENTER_PLAYER = 1,
MAP_MOVE1_UP = 2,

!Line: 10 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
void obj_addLogic(SecObject* obj, Logic* logic, LogicType type, Task* task, LogicCleanupFunc cleanupFunc);
void deleteLogicAndObject(Logic* logic);
JBool object_parseSeq(SecObject* obj, TFE_Parser* parser, size_t* bufferPos);
Logic* obj_setEnemyLogic(SecObject* obj, KEYWORD logicId, LogicSetupFunc* setupFunc);

!Line: 52 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

if ((uint8_t*)header < s_base || header->magic != sessionMagic()) { return nullptr; }
return header;
}
void* dfAlloc(size_t size, uintptr_t caller)
{

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

void* mem = poolAllocLocked(total);
if (mem)
{
uintptr_t user = ((uintptr_t)mem + sizeof(AllocHeader) + 7) & ~(uintptr_t)7;
AllocHeader* header = ((AllocHeader*)user) - 1;
header->magic = sessionMagic();

!Line: 118 - style: Variable 'mem' can be declared as pointer to const [constVariablePointer]

AllocHeader* header = liveHeader(ptr);
if (!header)
{
printf("[DarkForces] ERROR: realloc of a stale block pointer %p\n", ptr);
s_staleFrees++;
return dfAlloc(size, caller);

!Line: 166 - style: Variable 'header' can be declared as pointer to const [constVariablePointer]

void censusVisit(void* mem, size_t size, int used, void* user)
{
if (!used) { return; }
CensusState* state = (CensusState*)user;
uintptr_t userPtr = ((uintptr_t)mem + sizeof(AllocHeader) + 7) & ~(uintptr_t)7;
const AllocHeader* header = ((AllocHeader*)userPtr) - 1;

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

!Line: 296 - note: You might need to cast the function pointer here
!Line: 192 - note: Parameter 'mem' can be declared as pointer to const

namespace TFE_DarkForces
{
struct GameMessage
{
s32 id;
char* text;

!Line: 9 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
enum AgentConstants
{
MAX_LEVEL_COUNT = 14,
MAX_AGENT_COUNT = 14,

!Line: 9 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

TFE_Settings_Game* gameSettings = TFE_Settings::getGameSettings();
if (gameSettings->df_disableFightMusic)
{
s_desiredFightState = JFALSE;
fightTimer = 0;
if (gameMusic_getState() != MUS_STATE_STALK)

!Line: 273 - style: Variable 'gameSettings' can be declared as pointer to const [constVariablePointer]

void iMuseCallback1(char* marker)
{
if (!strncmp(marker, "to ", 3))
{
s32 punt = 0;
if (!strncmp(&marker[4], "slow", 4))

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

!Line: 361 - note: You might need to cast the function pointer here
!Line: 327 - note: Parameter 'marker' can be declared as pointer to const

char* lptr = parseEvent(marker);
s32 count = 0;
if (lptr)
{
// Jump to transition piece.
while (lptr[count]) { count++; }

!Line: 373 - style: Variable 'lptr' can be declared as pointer to const [constVariablePointer]

char* lptr = parseEvent(marker);
if (lptr)
{
s32 count = 0;
while (lptr[count]) { count++; }
s32 r = gameMusic_random(0, count - 1);

!Line: 409 - style: Variable 'lptr' can be declared as pointer to const [constVariablePointer]

s_objSeqArgCount = sscanf(line, " %s %s %s %s %s %s", s_objSeqArg0, s_objSeqArg1, s_objSeqArg2, s_objSeqArg3, s_objSeqArg4, s_objSeqArg5);
KEYWORD key = getKeywordIndex(s_objSeqArg0);
if (key == KW_TYPE || key == KW_LOGIC)
{
KEYWORD logicId = getKeywordIndex(s_objSeqArg1);
if (logicId == KW_PLAYER) // Player Logic.

!Line: 126 - warning: sscanf() without field width limits can crash with huge input data. [invalidscanf]

ProjectileLogic* mineLogic = (ProjectileLogic*)createProjectile(PROJ_LAND_MINE_PLACED, obj->sector, obj->posWS.x, obj->posWS.y, obj->posWS.z, obj);
freeObject(obj);
SecObject* mineObj = mineLogic->logic.obj;
mineObj->entityFlags |= ETFLAG_LANDMINE;
mineObj->projectileLogic = (Logic*)mineLogic;

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

mineObj->projectileLogic = (Logic*)mineLogic;
landmine_setup(mineObj, setupFunc);
return (Logic*)mineLogic;
} break;
case KW_KELL:

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

return (Logic*)mineLogic;
} break;
case KW_KELL:
{
return kellDragon_setup(obj, setupFunc);
} break;

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

} break;
case KW_INT_DROID:
{
obj->entityFlags = (ETFLAG_AI_ACTOR | ETFLAG_FLYING);
return intDroid_setup(obj, setupFunc);
} break;

!Line: 200 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_PROBE_DROID:
{
obj->entityFlags = (ETFLAG_AI_ACTOR | ETFLAG_FLYING);
return probeDroid_setup(obj, setupFunc);
} break;

!Line: 205 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_D_TROOP1:
{
return phaseOne_setup(obj, setupFunc);
} break;
case KW_D_TROOP2:

!Line: 210 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_D_TROOP2:
{
return phaseTwo_setup(obj, setupFunc);
} break;
case KW_D_TROOP3:

!Line: 214 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_D_TROOP3:
{
return phaseThree_setup(obj, setupFunc);
} break;
case KW_BOBA_FETT:

!Line: 218 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_BOBA_FETT:
{
return bobaFett_setup(obj, setupFunc);
} break;
case KW_COMMANDO:

!Line: 222 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_COMMANDO:
{
obj->entityFlags = ETFLAG_AI_ACTOR | ETFLAG_HAS_GRAVITY;
return commando_setup(obj, setupFunc);
} break;

!Line: 226 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_I_OFFICER:
case KW_I_OFFICER1:
case KW_I_OFFICER2:
case KW_I_OFFICER3:
case KW_I_OFFICER4:

!Line: 231 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_G_GUARD:
{
obj->entityFlags = ETFLAG_AI_ACTOR | ETFLAG_HAS_GRAVITY;
return gamor_setup(obj, setupFunc);
} break;

!Line: 248 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_REE_YEES:
{
obj->entityFlags = ETFLAG_AI_ACTOR | ETFLAG_HAS_GRAVITY;
return reeyees_setup(obj, setupFunc);
} break;

!Line: 253 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_REE_YEES2:
{
obj->entityFlags = ETFLAG_AI_ACTOR | ETFLAG_HAS_GRAVITY;
return reeyees2_setup(obj, setupFunc);
} break;

!Line: 258 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_BOSSK:
{
obj->entityFlags = ETFLAG_AI_ACTOR | ETFLAG_HAS_GRAVITY;
return bossk_setup(obj, setupFunc);
} break;

!Line: 263 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_BARREL:
{
obj->entityFlags = ETFLAG_AI_ACTOR;
return barrel_setup(obj, setupFunc);
} break;

!Line: 268 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_LAND_MINE:
{
ProjectileLogic* mineLogic = (ProjectileLogic*)createProjectile(PROJ_LAND_MINE_PLACED, obj->sector, obj->posWS.x, obj->posWS.y, obj->posWS.z, obj);
freeObject(obj);

!Line: 273 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_KELL:
{
return kellDragon_setup(obj, setupFunc);
} break;
case KW_SEWER1:

!Line: 285 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_SEWER1:
{
return sewerCreature_setup(obj, setupFunc);
} break;
case KW_REMOTE:

!Line: 289 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_REMOTE:
{
return remote_setup(obj, setupFunc);
} break;
case KW_TURRET:

!Line: 293 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_TURRET:
{
return turret_setup(obj, setupFunc);
} break;
case KW_MOUSEBOT:

!Line: 297 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_MOUSEBOT:
{
return mousebot_setup(obj, setupFunc);
} break;
case KW_WELDER:

!Line: 301 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_WELDER:
{
return welder_setup(obj, setupFunc);
} break;
case KW_SCENERY:

!Line: 305 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case KW_SCENERY:
{
obj->flags &= ~OBJ_FLAG_AIM;
obj->entityFlags = ETFLAG_SCENERY;
return scenery_setup(obj, setupFunc);

!Line: 309 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
}
TFE_System::logWrite(LOG_ERROR, "Logic", "Unknown logic type - %d.", logicId);
return nullptr;
}

!Line: 315 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

using namespace TFE_Jedi;
typedef s64 SoundSourceId;
typedef s64 SoundEffectId;
// Null or invalid sound ID
#define NULL_SOUND 0

!Line: 13 - error: Code 'using namespace TFE_Jedi' is invalid C code. [syntaxError]

using namespace TFE_Jedi;
struct OffScreenBuffer;
struct ScreenRect;
namespace TFE_DarkForces

!Line: 10 - error: Code 'using namespace TFE_Jedi' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
// The actual timer frequency used by the DOS code.
#define TIMER_FREQ 145.6521
// Integer number of ticks per second.

!Line: 15 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
void gameMusic_start(s32 level);
void gameMusic_stop();
void gameMusic_setState(MusicState state);

!Line: 20 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
struct DarkForces : IGame
{
bool runGame(s32 argCount, const char* argv[], Stream* stream) override;
void pauseGame(bool pause) override;

!Line: 10 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

namespace TFE_DarkForces
{
struct GameConfig
{
JBool headwave;
JBool wpnAutoMount;

!Line: 10 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

UpdateLogic* updateLogic = (UpdateLogic*)logic;
char* endPtr = nullptr;
if (key == KW_FLAGS)
{
updateLogic->flags = strToUInt(s_objSeqArg1);

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

*logicItem = (Logic*)updateLogic;
updateLogic->logic.obj = obj;
updateLogic->logic.type = LOGIC_UPDATE;
updateLogic->logic.parent = logicItem;
updateLogic->logic.cleanupFunc = updateLogicCleanupFunc;

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

return (Logic*)updateLogic;
}
// Serialization
void updateLogic_serialize(Logic*& logic, SecObject* obj, Stream* stream)
{

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

updateLogic = (UpdateLogic*)logic;
}
else
{
if (!s_logicUpdateList)
{

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

logic = (Logic*)updateLogic;
updateLogic->pad16 = 0;
updateLogic->logic.task = s_logicUpdateTask;
updateLogic->logic.cleanupFunc = updateLogicCleanupFunc;
}

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

InfLink* link = (InfLink*)allocator_getHead(sector->infLink);
if (link && link->type == LTYPE_SECTOR)
{
InfElevator* elev = link->elev;
JBool move = JFALSE;
/* TODO: How to get this information from the INF system.

!Line: 173 - style: Variable 'link' can be declared as pointer to const [constVariablePointer]

InfElevator* elev = link->elev;
JBool move = JFALSE;
/* TODO: How to get this information from the INF system.
if ((y == sector->floorHeight && (elev->flags & INF_EFLAG_MOVE_FLOOR)) ||
(y == sector->floorHeight + sector->secHeight && (elev->flags & INF_EFLAG_MOVE_SECHT)))
{

!Line: 176 - style: Variable 'elev' can be declared as pointer to const [constVariablePointer]

InfElevator* elev = link->elev;
JBool move = JFALSE;
/* TODO: How to get this information from the INF system.
if ((y == sector->floorHeight && (elev->flags & INF_EFLAG_MOVE_FLOOR)) ||
(y == sector->floorHeight + sector->secHeight && (elev->flags & INF_EFLAG_MOVE_SECHT)))
{

!Line: 176 - style: Variable 'elev' is assigned a value that is never used. [unreadVariable]

char programDataPath[TFE_MAX_PATH];
char sourcePath[TFE_MAX_PATH];
TFE_Paths::appendPath(PATH_USER_DOCUMENTS, "DARKPILO.CFG", documentsPath);
if (!FileUtil::exists(documentsPath))
{
// First check in /ProgramData since that is where the previous version stored it.

!Line: 531 - style: The scope of the variable 'programDataPath' can be reduced. [variableScope]

char sourcePath[TFE_MAX_PATH];
TFE_Paths::appendPath(PATH_USER_DOCUMENTS, "DARKPILO.CFG", documentsPath);
if (!FileUtil::exists(documentsPath))
{
// First check in /ProgramData since that is where the previous version stored it.
TFE_Paths::appendPath(PATH_PROGRAM_DATA, "DARKPILO.CFG", programDataPath);

!Line: 532 - style: The scope of the variable 'sourcePath' can be reduced. [variableScope]

char* displayName = strtok((char*)line, ",");
char* gamePath = strtok(nullptr, ", \t\n\r");
char* srcPath = strtok(nullptr, ", \t\n\r");
s_levelDisplayNames[i] = nullptr;
s_levelGamePaths[i] = nullptr;

!Line: 400 - style: Variable 'displayName' can be declared as pointer to const [constVariablePointer]

char* gamePath = strtok(nullptr, ", \t\n\r");
char* srcPath = strtok(nullptr, ", \t\n\r");
s_levelDisplayNames[i] = nullptr;
s_levelGamePaths[i] = nullptr;
s_levelSrcPaths[i] = nullptr;

!Line: 401 - style: Variable 'gamePath' can be declared as pointer to const [constVariablePointer]

char* srcPath = strtok(nullptr, ", \t\n\r");
s_levelDisplayNames[i] = nullptr;
s_levelGamePaths[i] = nullptr;
s_levelSrcPaths[i] = nullptr;

!Line: 402 - style: Variable 'srcPath' can be declared as pointer to const [constVariablePointer]

char* srcPath = strtok(nullptr, ", \t\n\r");
s_levelDisplayNames[i] = nullptr;
s_levelGamePaths[i] = nullptr;
s_levelSrcPaths[i] = nullptr;

!Line: 402 - style: Variable 'srcPath' is assigned a value that is never used. [unreadVariable]

namespace TFE_DarkForces
{
// language-specific hotkeys
struct LangHotkeys {
KeyboardCode k_yes;
KeyboardCode k_quit;

!Line: 10 - error: Code 'namespaceTFE_DarkForces{' is invalid C code. [syntaxError]

if (sscanf(fileData, "LEV: %s LFD: %s ANI: %s PAL: %s", mission, archive, bgAnim, palette) != 4)
{
TFE_System::logWrite(LOG_ERROR, "Briefing List", "Error reading briefing file %s on line: >>> %s", filename, fileData);
return 0;
}
else

!Line: 75 - warning: sscanf() without field width limits can crash with huge input data. [invalidscanf]

if (obj)
{
automap_drawObject(obj);
i++;
}
}

!Line: 588 - style: Condition 'obj' is always true [knownConditionTrueFalse]

SpriteAnimLogic* animLogic = (SpriteAnimLogic*)obj_setSpriteAnim(obj);
// Setup to call this task when animation is finished.
if (effect->type == HEFFECT_PLASMA_EXP || effect->type == HEFFECT_CANNON_EXP)
{
setAnimCompleteTask(animLogic, s_hitEffectTask);

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

SpriteAnimLogic* logic = (SpriteAnimLogic*)obj_setSpriteAnim(newObj);
setupAnimationFromLogic(logic, 0/*animIndex*/, 0/*firstFrame*/, 0xffffffff/*lastFrame*/, 1/*loopCount*/);
sound_playCued(s_concussionExplodeSnd, newObj->posWS);
s_msgArg1 = s_curEffectData->damage;
}

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

void automap_drawLine(fixed16_16 x0, fixed16_16 z0, fixed16_16 x1, fixed16_16 z1, u8 color)
{
ScreenRect* screenRect = vfb_getScreenRect(VFB_RECT_RENDER);
screen_drawLine(screenRect, x0, z0, x1, z1, color, s_mapFramebuffer);
}

!Line: 488 - style: inconclusive: Function 'automap_drawLine' argument 1 names different: declaration 'px1' definition 'x0'. [funcArgNamesDifferent]

!Line: 89 - note: Function 'automap_drawLine' argument 1 names different: declaration 'px1' definition 'x0'.
!Line: 488 - note: Function 'automap_drawLine' argument 1 names different: declaration 'px1' definition 'x0'.

void automap_drawLine(fixed16_16 x0, fixed16_16 z0, fixed16_16 x1, fixed16_16 z1, u8 color)
{
ScreenRect* screenRect = vfb_getScreenRect(VFB_RECT_RENDER);
screen_drawLine(screenRect, x0, z0, x1, z1, color, s_mapFramebuffer);
}

!Line: 488 - style: inconclusive: Function 'automap_drawLine' argument 2 names different: declaration 'pz1' definition 'z0'. [funcArgNamesDifferent]

!Line: 89 - note: Function 'automap_drawLine' argument 2 names different: declaration 'pz1' definition 'z0'.
!Line: 488 - note: Function 'automap_drawLine' argument 2 names different: declaration 'pz1' definition 'z0'.

void automap_drawLine(fixed16_16 x0, fixed16_16 z0, fixed16_16 x1, fixed16_16 z1, u8 color)
{
ScreenRect* screenRect = vfb_getScreenRect(VFB_RECT_RENDER);
screen_drawLine(screenRect, x0, z0, x1, z1, color, s_mapFramebuffer);
}

!Line: 488 - style: inconclusive: Function 'automap_drawLine' argument 3 names different: declaration 'px2' definition 'x1'. [funcArgNamesDifferent]

!Line: 89 - note: Function 'automap_drawLine' argument 3 names different: declaration 'px2' definition 'x1'.
!Line: 488 - note: Function 'automap_drawLine' argument 3 names different: declaration 'px2' definition 'x1'.

void automap_drawLine(fixed16_16 x0, fixed16_16 z0, fixed16_16 x1, fixed16_16 z1, u8 color)
{
ScreenRect* screenRect = vfb_getScreenRect(VFB_RECT_RENDER);
screen_drawLine(screenRect, x0, z0, x1, z1, color, s_mapFramebuffer);
}

!Line: 488 - style: inconclusive: Function 'automap_drawLine' argument 4 names different: declaration 'pz2' definition 'z1'. [funcArgNamesDifferent]

!Line: 89 - note: Function 'automap_drawLine' argument 4 names different: declaration 'pz2' definition 'z1'.
!Line: 488 - note: Function 'automap_drawLine' argument 4 names different: declaration 'pz2' definition 'z1'.

ScreenRect* screenRect = vfb_getScreenRect(VFB_RECT_RENDER);
{
u32 dispWidth, dispHeight;
vfb_getResolution(&dispWidth, &dispHeight);

!Line: 132 - style: Variable 'screenRect' can be declared as pointer to const [constVariablePointer]

RSector* sector = s_playerEye ? s_playerEye->sector : nullptr;
if (sector) { s_mapLayer = sector->layer; }
s_mapX1 = s_mapX0 = s_eyePos.x;
s_mapZ1 = s_mapZ0 = s_eyePos.z;
} break;
case MAP_MOVE1_UP:

!Line: 174 - style: Variable 'sector' can be declared as pointer to const [constVariablePointer]

void automap_drawWall(RWall* wall, u8 color)
{
vec2_fixed* w0 = wall->w0;
vec2_fixed* w1 = wall->w1;
fixed16_16 x0 = w0->x;
fixed16_16 x1 = w1->x;

!Line: 494 - style: Parameter 'wall' can be declared as pointer to const [constParameterPointer]

vec2_fixed* w0 = wall->w0;
vec2_fixed* w1 = wall->w1;
fixed16_16 x0 = w0->x;
fixed16_16 x1 = w1->x;
fixed16_16 z0 = w0->z;
fixed16_16 z1 = w1->z;

!Line: 496 - style: Variable 'w0' can be declared as pointer to const [constVariablePointer]

vec2_fixed* w1 = wall->w1;
fixed16_16 x0 = w0->x;
fixed16_16 x1 = w1->x;
fixed16_16 z0 = w0->z;
fixed16_16 z1 = w1->z;

!Line: 497 - style: Variable 'w1' can be declared as pointer to const [constVariablePointer]

RSector* curSector = wall->sector;
RSector* nextSector = wall->nextSector;
fixed16_16 curFloorHeight = curSector->floorHeight;
fixed16_16 nextFloorHeight = nextSector->floorHeight;
fixed16_16 floorDelta = TFE_Jedi::abs(curFloorHeight - nextFloorHeight);
if (floorDelta >= 0x4000) // 0.25 units

!Line: 538 - style: Variable 'curSector' can be declared as pointer to const [constVariablePointer]

RSector* nextSector = wall->nextSector;
fixed16_16 curFloorHeight = curSector->floorHeight;
fixed16_16 nextFloorHeight = nextSector->floorHeight;
fixed16_16 floorDelta = TFE_Jedi::abs(curFloorHeight - nextFloorHeight);
if (floorDelta >= 0x4000) // 0.25 units
{

!Line: 539 - style: Variable 'nextSector' can be declared as pointer to const [constVariablePointer]

RSector* sector = player->sector;
if (sector->layer == layer)
{
fixed16_16 sinYaw, cosYaw;
sinCosFixed(player->yaw, &sinYaw, &cosYaw);

!Line: 647 - style: Variable 'sector' can be declared as pointer to const [constVariablePointer]

if (s_rightHudShow)
{
if (s_rightHudVertAnim > s_rightHudVertTarget)
{
s_rightHudVertAnim--;
}

!Line: 680 - style: Condition 's_rightHudShow' is always true [knownConditionTrueFalse]

!Line: 677 - note: Assignment 's_rightHudShow=4', assigned value is 4
!Line: 680 - note: Condition 's_rightHudShow' is always true

else if (s_leftHudShow)
{
s_leftHudShow--;
}
}
}

!Line: 708 - style: Condition 's_leftHudShow' is always true [knownConditionTrueFalse]

strCopyAndZero((char*)s_hudMessage, msgText, 80);
s_hudMsgExpireTick = s_curTick + ((msg->priority <= HUD_HIGH_PRIORITY) ? HUD_MSG_LONG_DUR : HUD_MSG_SHORT_DUR);
s_hudCurrentMsgId = msgId;
s_hudMsgPriority = msg->priority;

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

strCopyAndZero((char*)s_hudMessage, msg, 80);
s_hudMsgExpireTick = s_curTick + ((priority <= HUD_HIGH_PRIORITY) ? HUD_MSG_LONG_DUR : HUD_MSG_SHORT_DUR);
s_hudCurrentMsgId = 0;
s_hudMsgPriority = priority;

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

sprintf((char*)dataStr, "X:%04d Y:%.1f Z:%04d H:%.1f S:%d%%", floor16(x), -fixed16ToFloat(s_playerEye->posWS.y), floor16(z), fixed16ToFloat(s_playerEye->worldHeight), s_secretsPercent);
displayHudMessage(s_hudFont, (DrawRect*)vfb_getScreenRect(VFB_RECT_UI), 164 + xOffset, 10, dataStr, framebuffer);
// s_screenDirtyRight[s_curFrameBufferIdx] = JTRUE;
}
#ifdef TFE_ESPBOX
TFE_Settings_Graphics* graphics = TFE_Settings::getGraphicsSettings();

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

blitTextureToScreenScaled(&image, (DrawRect*)rect, x0, y0, xScale, yScale, framebuffer);
}
// This should not be enabled in released builds - it is only kept in case the images need to be regenerated.
#if TFE_CONVERT_CAPS
u8 hud_findColorInPalette(u32 color, u32 colorCount, const u8* colors, const u8* palette)

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

u32 dispWidth, dispHeight;
vfb_getResolution(&dispWidth, &dispHeight);
if (hudSettings->hudScale == TFE_HUDSCALE_SCALED)
{
hudScaleX = floatToFixed16(hudSettings->scale);

!Line: 961 - style: Local variable 'dispWidth' shadows outer variable [shadowVariable]

!Line: 944 - note: Shadowed declaration
!Line: 961 - note: Shadow variable

u32 dispWidth, dispHeight;
vfb_getResolution(&dispWidth, &dispHeight);
if (hudSettings->hudScale == TFE_HUDSCALE_SCALED)
{
hudScaleX = floatToFixed16(hudSettings->scale);

!Line: 961 - style: Local variable 'dispHeight' shadows outer variable [shadowVariable]

!Line: 944 - note: Shadowed declaration
!Line: 961 - note: Shadow variable

void copyIntoPalette(u8* dst, u8* src, s32 count, s32 mode)
{
memcpy(dst, src, count * 3);
}
void getCameraXZ(fixed16_16* x, fixed16_16* z)

!Line: 1034 - style: Parameter 'src' can be declared as pointer to const [constParameterPointer]

void displayHudMessage(Font* font, DrawRect* rect, s32 x, s32 y, u8* msg, u8* framebuffer)
{
if (!font || !rect || !framebuffer) { return; }
u32 dispWidth, dispHeight;
vfb_getResolution(&dispWidth, &dispHeight);

!Line: 1053 - style: Parameter 'msg' can be declared as pointer to const [constParameterPointer]

void hud_drawElementToScreen(OffScreenBuffer* elem, ScreenRect* rect, s32 x0, s32 y0, u8* framebuffer)
{
s32 x1 = x0 + elem->width - 1;
u8* image = elem->image;
s32 y1 = y0 + elem->height - 1;
if (x0 > rect->right || x1 < rect->left || y0 > rect->bot || y1 < rect->top)

!Line: 1154 - style: Parameter 'rect' can be declared as pointer to const [constParameterPointer]

PlayerWeapon* prevWeapon = s_curPlayerWeapon;
s_curWeapon = wpnIndex;
s_prevWeapon = wpnIndex;
PlayerWeapon* nextWeapon = &s_playerWeaponList[wpnIndex];
s_playerInfo.curWeapon = wpnIndex;

!Line: 521 - style: Variable 'prevWeapon' can be declared as pointer to const [constVariablePointer]

ActorDispatch* actorLogic = *((ActorDispatch**)head);
actorLogic->flags &= ~1;
actorLogic->freeTask = task_getCurrent();
gen->aliveCount++;
gen->numTerminate--;

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

Generator* genLogic = (Generator*)logic;
if (key == KW_MASTER)
{
genLogic->active &= ~1;
return JTRUE;

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

obj_addLogic(obj, (Logic*)generator, LOGIC_GENERATOR, task, generatorLogicCleanupFunc);
return (Logic*)generator;
}
// Fixup

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

return (Logic*)generator;
}
// Fixup
void generatorLogic_fixup(Logic* logic)
{

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

Generator* gen = (Generator*)logic;
allocator_saveIter(gen->entities);
SecObject** entityList = (SecObject**)allocator_getHead(gen->entities);
while (entityList)
{
SecObject* obj = *entityList;

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

ActorDispatch* actorLogic = (ActorDispatch*)logic;
actorLogic->freeTask = gen->logic.task;
break;
}
logicPtr = (Logic**)allocator_getNext((Allocator*)obj->logic);
}

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

gen = (Generator*)logic;
}
else
{
gen = (Generator*)level_alloc(sizeof(Generator));
gen->entities = allocator_create(sizeof(SecObject**));

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

logic = (Logic*)gen;
Task* task = createSubTask("Generator", generatorTaskFunc);
task_setUserData(task, gen);
gen->logic.task = task;
gen->logic.cleanupFunc = generatorLogicCleanupFunc;

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

Logic* logic = *logicPtr;
if (logic->type == LOGIC_DISPATCH)
{
ActorDispatch* actorLogic = (ActorDispatch*)logic;
actorLogic->freeTask = gen->logic.task;
break;

!Line: 256 - style: Local variable 'logic' shadows outer argument [shadowArgument]

!Line: 241 - note: Shadowed declaration
!Line: 256 - note: Shadow variable

SecObject* obj = *entityList;
s32 entityId = (obj) ? obj->serializeIndex : -1;
SERIALIZE(ObjState_InitVersion, entityId, -1);
entityList = (SecObject**)allocator_getNext(gen->entities);
}
allocator_restoreIter(gen->entities);

!Line: 309 - style: Local variable 'obj' shadows outer argument [shadowArgument]

!Line: 273 - note: Shadowed declaration
!Line: 309 - note: Shadow variable

SecObject* entity = (SecObject*)s_msgEntity;
SecObject** entityList = (SecObject**)allocator_getHead(gen->entities);
while (entityList)
{
if (entity == *entityList)
{

!Line: 73 - style: Variable 'entity' can be declared as pointer to const [constVariablePointer]

void generatorLogicCleanupFunc(Logic* logic)
{
}
JBool generatorLogicSetupFunc(Logic* logic, KEYWORD key)
{

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

!Line: 289 - note: You might need to cast the function pointer here
!Line: 144 - note: Parameter 'logic' can be declared as pointer to const

sprintf((char*)dataStr, "%2d fps (%4.2f ms)", (int)(1.0 / deltaTime), deltaTime * 1000.0);
displayHudMessage(s_hudFont, (DrawRect*)vfb_getScreenRect(VFB_RECT_UI), 0, 1, dataStr, framebuffer);
}
#endif
}

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

TFE_Settings_Graphics* graphics = TFE_Settings::getGraphicsSettings();
if (graphics->showFps)
{
u8 dataStr[64];
static u64 localTimeCallback = 0;
f64 deltaTime = TFE_System::updateThreadLocal(&localTimeCallback);

!Line: 401 - style: Variable 'graphics' can be declared as pointer to const [constVariablePointer]

u8* end = &pal[768];
for (; pal < end; pal += 3)
{
// Compute the approximate luminance (red/4 + green/2 + blue/4)
u32 L = (pal[0] >> 2) + (pal[1] >> 1) + (pal[2] >> 2);
// Then assign the luminance to the requested channels.

!Line: 1415 - style: Variable 'end' can be declared as pointer to const [constVariablePointer]

u8* end = &pal[768];
for (s32 i = 0; i < 256; i++, pal += 3)
{
fixed16_16 color = intToFixed16(pal[0]);
color = mul16(color, brightness) + HALF_16;
pal[0] = floor16(color);

!Line: 1477 - style: Variable 'end' can be declared as pointer to const [constVariablePointer]

u8* end = &pal[768];
for (s32 i = 0; i < 256; i++, pal += 3)
{
fixed16_16 color = intToFixed16(pal[0]);
color = mul16(color, brightness) + HALF_16;
pal[0] = floor16(color);

!Line: 1477 - style: Variable 'end' is assigned a value that is never used. [unreadVariable]

else if (!c)
{
line = nullptr;
break;
}
line++;

!Line: 80 - warning: Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]

!Line: 74 - note: outer condition: c
!Line: 80 - note: opposite inner condition: !c

else if (!c)
{
line = nullptr;
break;
}
line++;

!Line: 104 - warning: Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]

!Line: 98 - note: outer condition: c
!Line: 104 - note: opposite inner condition: !c

ProjectileLogic* proj = (ProjectileLogic*)createProjectile(ProjectileType::PROJ_PUNCH, s_playerObject->sector, s_playerObject->posWS.x, s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset, s_playerObject->posWS.z, s_playerObject);
s_weaponFirePitch = s_playerObject->pitch + 0x638;
s_weaponFireYaw = s_playerObject->yaw + yawOffset;
proj_setTransform(proj, s_weaponFirePitch, s_weaponFireYaw);

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

projLogic = (ProjectileLogic*)createProjectile(PROJ_PISTOL_BOLT, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{

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

projLogic = (ProjectileLogic*)createProjectile(PROJ_RIFLE_BOLT, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{

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

ProjectileLogic* proj = (ProjectileLogic*)createProjectile(PROJ_THERMAL_DET, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
proj->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
proj->prevColObj = s_playerObject;
// Calculate projectile speed and duration.
if (s_secondaryFire)

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

proj[i] = (ProjectileLogic*)createProjectile(PROJ_REPEATER, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
proj[i]->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
proj_setTransform(proj[i], s_weaponFirePitch + c_repeaterPitchOffset[i], s_weaponFireYaw + c_repeaterYawOffset[i]);
proj[i]->prevColObj = s_playerObject;
}

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

ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_REPEATER, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{
proj_setYawPitch(projLogic, s_wpnPitchSin, s_wpnPitchCos, s_autoAimDirX, s_autoAimDirZ);

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

proj[i] = (ProjectileLogic*)createProjectile(PROJ_PLASMA, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
proj[i]->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
proj_setTransform(proj[i], s_weaponFirePitch, s_weaponFireYaw + s_fusionYawOffset[i]);
proj[i]->prevColObj = s_playerObject;
}

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

ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_PLASMA, s_playerObject->sector, s_playerObject->posWS.x, yPlayerPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{
proj_setYawPitch(projLogic, s_wpnPitchSin, s_wpnPitchCos, s_autoAimDirX, s_autoAimDirZ);

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

projLogic = (ProjectileLogic*)createProjectile(PROJ_MORTAR, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
proj_setTransform(projLogic, s_weaponFirePitch, s_weaponFireYaw);
if (canFire)

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

ProjectileLogic* mine = (ProjectileLogic*)createProjectile(type, s_playerObject->sector, s_playerObject->posWS.x, floorHeight, s_playerObject->posWS.z, s_playerObject);
mine->vel = { 0, 0, 0 };
if (s_mineSndId)
{
sound_stop(s_mineSndId);

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

projLogic = (ProjectileLogic*)createProjectile(PROJ_CONCUSSION, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{

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

ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_MISSILE, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{
proj_setYawPitch(projLogic, s_wpnPitchSin, s_wpnPitchCos, s_autoAimDirX, s_autoAimDirZ);

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

ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_CANNON, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{
proj_setYawPitch(projLogic, s_wpnPitchSin, s_wpnPitchCos, s_autoAimDirX, s_autoAimDirZ);

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

obj_addLogic(projObj, (Logic*)projLogic, LOGIC_PROJECTILE, s_projectileTask, projectileLogicCleanupFunc);
switch (type)
{
case PROJ_PUNCH:
{

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

return (Logic*)projLogic;
}
void projectileTaskFunc(MessageType msg)
{
struct LocalContext

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

fixed16_16 yPos = s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset;
projLogic = (ProjectileLogic*)createProjectile(PROJ_PISTOL_BOLT, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)

!Line: 324 - style: Local variable 'yPos' shadows outer variable [shadowVariable]

!Line: 282 - note: Shadowed declaration
!Line: 324 - note: Shadow variable

fixed16_16 yPos = s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset;
projLogic = (ProjectileLogic*)createProjectile(PROJ_RIFLE_BOLT, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)

!Line: 508 - style: Local variable 'yPos' shadows outer variable [shadowVariable]

!Line: 466 - note: Shadowed declaration
!Line: 508 - note: Shadow variable

fixed16_16 yPos = s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset;
ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_REPEATER, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{

!Line: 999 - style: Local variable 'yPos' shadows outer variable [shadowVariable]

!Line: 960 - note: Shadowed declaration
!Line: 999 - note: Shadow variable

fixed16_16 yPos = s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset;
projLogic = (ProjectileLogic*)createProjectile(PROJ_CONCUSSION, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)

!Line: 1742 - style: Local variable 'yPos' shadows outer variable [shadowVariable]

!Line: 1701 - note: Shadowed declaration
!Line: 1742 - note: Shadow variable

ProjectileLogic* objLogic = (ProjectileLogic*)*objLogicPtr;
// PROJ_HOMING_MISSILE can be destroyed by shooting it with a different type of projectile.
if (projLogic->type != objLogic->type && objLogic->type == PROJ_HOMING_MISSILE)
{
s_hitWallFlag = WH_STDEXP;
objLogic->duration = 0;

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

proj = (ProjectileLogic*)logic;
}
else
{
proj = (ProjectileLogic*)allocator_newItem(s_projectiles);
logic = (Logic*)proj;

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

logic = (Logic*)proj;
proj->logic.task = s_projectileTask;
proj->logic.cleanupFunc = projectileLogicCleanupFunc;
task_makeActive(s_projectileTask);
}

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

deleteLogicAndObject((Logic*)projLogic);
allocator_release(s_projectiles);
allocator_deleteItem(s_projectiles, projLogic);
return JTRUE;
} break;

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

deleteLogicAndObject((Logic*)projLogic);
allocator_release(s_projectiles);
allocator_deleteItem(s_projectiles, projLogic);
return JTRUE;
} break;
case PHIT_OUT_OF_RANGE:

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

deleteLogicAndObject((Logic*)projLogic);
allocator_release(s_projectiles);
allocator_deleteItem(s_projectiles, projLogic);
return JTRUE;
} break;
case PHIT_WATER:

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

deleteLogicAndObject((Logic*)projLogic);
allocator_release(s_projectiles);
allocator_deleteItem(s_projectiles, projLogic);
return JTRUE;
} break;
}

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

fixed16_16 yPos = s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset;
ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_MISSILE, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{

!Line: 1910 - style: Local variable 'yPos' shadows outer variable [shadowVariable]

!Line: 1875 - note: Shadowed declaration
!Line: 1910 - note: Shadow variable

fixed16_16 yPos = s_playerObject->posWS.y - s_playerObject->worldHeight + s_headwaveVerticalOffset;
ProjectileLogic* projLogic = (ProjectileLogic*)createProjectile(PROJ_CANNON, s_playerObject->sector, s_playerObject->posWS.x, yPos, s_playerObject->posWS.z, s_playerObject);
projLogic->flags &= ~PROJFLAG_CAMERA_PASS_SOUND;
projLogic->prevColObj = s_playerObject;
if (targetFound)
{

!Line: 2044 - style: Local variable 'yPos' shadows outer variable [shadowVariable]

!Line: 2010 - note: Shadowed declaration
!Line: 2044 - note: Shadow variable

} break;
case WH_STDEXP:
case WH_CUSTEXP: // CUSTEXP is not actually used but is included for completeness.
{
return PHIT_SOLID;
} break;

!Line: 1140 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case WH_BOUNCE:
{
proj_reflect(obj, projLogic);
return PHIT_NONE;
} break;

!Line: 1145 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
default:
{
return PHIT_SOLID;
}
}

!Line: 1150 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case WH_STDEXP:
{
return PHIT_SOLID;
} break;
case WH_BOUNCE:

!Line: 1180 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case WH_BOUNCE:
{
proj_reflect(obj, projLogic);
return PHIT_NONE;
} break;

!Line: 1184 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
}
}
return s_hitWater ? PHIT_WATER : PHIT_SOLID;
}

!Line: 1189 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case PHIT_SOLID:
{
// Stop the projectiles in-flight sound.
sound_stop(projLogic->flightSndId);

!Line: 1691 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case PHIT_OUT_OF_RANGE:
{
sound_stop(projLogic->flightSndId);
if (projLogic->flags & PROJFLAG_EXPLODE)
{

!Line: 1709 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
case PHIT_WATER:
{
sound_stop(projLogic->flightSndId);
spawnHitEffect(HEFFECT_SPLASH, obj->sector, obj->posWS, projLogic->excludeObj);

!Line: 1727 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

} break;
}
return JFALSE;
}

!Line: 1739 - style: Consecutive return, break, continue, goto or throw statements are unnecessary. [duplicateBreak]

void triggerLandMine(ProjectileLogic* projLogic, Tick delay)
{
projLogic->type = PROJ_LAND_MINE;
projLogic->duration = s_curTick + delay;
SecObject* obj = projLogic->logic.obj;

!Line: 833 - style: inconclusive: Function 'triggerLandMine' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 116 - note: Function 'triggerLandMine' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 833 - note: Function 'triggerLandMine' argument 1 names different: declaration 'logic' definition 'projLogic'.

ProjectileHitType stdProjectileUpdateFunc(ProjectileLogic* projLogic)
{
// Calculate how much the projectile moves this timeslice.
const fixed16_16 dt = s_deltaTime;
projLogic->delta.x = mul16(projLogic->vel.x, dt);
projLogic->delta.y = mul16(projLogic->vel.y, dt);

!Line: 855 - style: inconclusive: Function 'stdProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 97 - note: Function 'stdProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 855 - note: Function 'stdProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.

ProjectileHitType landMineUpdateFunc(ProjectileLogic* projLogic)
{
SecObject* obj = projLogic->logic.obj;
fixed16_16 ceilHeight, floorHeight;
sector_getObjFloorAndCeilHeight(obj->sector, obj->posWS.y, &floorHeight, &ceilHeight);

!Line: 867 - style: inconclusive: Function 'landMineUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 98 - note: Function 'landMineUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 867 - note: Function 'landMineUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.

ProjectileHitType arcingProjectileUpdateFunc(ProjectileLogic* projLogic)
{
const fixed16_16 dt = s_deltaTime;
// The projectile arcs due to gravity, accel = 120.0 units / s^2
projLogic->vel.y += mul16(PROJ_GRAVITY_ACCEL, dt);
// Get the frame delta from the velocity and delta time.

!Line: 887 - style: inconclusive: Function 'arcingProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 99 - note: Function 'arcingProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 887 - note: Function 'arcingProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.

ProjectileHitType homingMissileProjectileUpdateFunc(ProjectileLogic* projLogic)
{
SecObject* missileObj = projLogic->logic.obj;
SecObject* targetObj = s_playerObject;
fixed16_16 dt = s_deltaTime;

!Line: 904 - style: inconclusive: Function 'homingMissileProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 100 - note: Function 'homingMissileProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 904 - note: Function 'homingMissileProjectileUpdateFunc' argument 1 names different: declaration 'logic' definition 'projLogic'.

ProjectileHitType proj_handleMovement(ProjectileLogic* projLogic)
{
SecObject* obj = projLogic->logic.obj;
JBool envHit = proj_move(projLogic);
JBool objHit = proj_getHitObj(projLogic);
if (objHit)

!Line: 1067 - style: inconclusive: Function 'proj_handleMovement' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 120 - note: Function 'proj_handleMovement' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 1067 - note: Function 'proj_handleMovement' argument 1 names different: declaration 'logic' definition 'projLogic'.

JBool proj_move(ProjectileLogic* projLogic)
{
SecObject* obj = projLogic->logic.obj;
RSector* sector = obj->sector;
s_hitWall = nullptr;

!Line: 1202 - style: inconclusive: Function 'proj_move' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 94 - note: Function 'proj_move' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 1202 - note: Function 'proj_move' argument 1 names different: declaration 'logic' definition 'projLogic'.

JBool proj_getHitObj(ProjectileLogic* projLogic)
{
SecObject* obj = projLogic->logic.obj;
if (!projLogic->speed)
{
return JFALSE;

!Line: 1488 - style: inconclusive: Function 'proj_getHitObj' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 95 - note: Function 'proj_getHitObj' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 1488 - note: Function 'proj_getHitObj' argument 1 names different: declaration 'logic' definition 'projLogic'.

JBool handleProjectileHit(ProjectileLogic* projLogic, ProjectileHitType hitType)
{
SecObject* obj = projLogic->logic.obj;
RSector* sector = obj->sector;
switch (hitType)
{

!Line: 1674 - style: inconclusive: Function 'handleProjectileHit' argument 1 names different: declaration 'logic' definition 'projLogic'. [funcArgNamesDifferent]

!Line: 121 - note: Function 'handleProjectileHit' argument 1 names different: declaration 'logic' definition 'projLogic'.
!Line: 1674 - note: Function 'handleProjectileHit' argument 1 names different: declaration 'logic' definition 'projLogic'.

SecObject* obj = projLogic->logic.obj;
obj->yaw = (getAngleDifference(obj->yaw, wall->angle) + wall->angle) & 16383;
handleReflectVariation(projLogic, obj);
projLogic->prevColObj = nullptr;
projLogic->excludeObj = nullptr;

!Line: 1345 - style: Local variable 'obj' shadows outer variable [shadowVariable]

!Line: 1204 - note: Shadowed declaration
!Line: 1345 - note: Shadow variable

SecObject* obj = projLogic->logic.obj;
// fraction of the path where the path hits the floor.
assert(projLogic->delta.y != 0);
fixed16_16 dy = projLogic->delta.y == 0 ? 1 : projLogic->delta.y; // avoid possible divide-by-zero.
fixed16_16 u = div16(y0FloorHeight - obj->posWS.y, dy);
s_projNextPosX = obj->posWS.x + mul16(projLogic->delta.x, u);

!Line: 1403 - style: Local variable 'obj' shadows outer variable [shadowVariable]

!Line: 1204 - note: Shadowed declaration
!Line: 1403 - note: Shadow variable

SecObject* obj = projLogic->logic.obj;
// fraction of the path where the path hits the floor.
assert(projLogic->delta.y != 0);
fixed16_16 dy = projLogic->delta.y == 0 ? 1 : projLogic->delta.y; // avoid possible divide-by-zero.
fixed16_16 u = div16(y0CeilHeight - obj->posWS.y, dy);
s_projNextPosX = obj->posWS.x + mul16(projLogic->delta.x, u);

!Line: 1420 - style: Local variable 'obj' shadows outer variable [shadowVariable]

!Line: 1204 - note: Shadowed declaration
!Line: 1420 - note: Shadow variable

void proj_computeTransform3D(SecObject* obj, fixed16_16 sinPitch, fixed16_16 cosPitch, fixed16_16 sinYaw, fixed16_16 cosYaw, fixed16_16 dt)
{
fixed16_16* transform = obj->transform;
transform[0] = cosYaw;
transform[1] = mul16(sinPitch, sinYaw);
transform[2] = mul16(mul16(cosPitch, sinYaw), dt);

!Line: 985 - style: Parameter 'obj' can be declared as pointer to const [constParameterPointer]


!Maximum character count per GitHub comment has been reached! Not all warnings/errors has been parsed!

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.

Copilot review overview

🟡 Changes recommended

Unresolved USB PHY handoff and allocator/error-handling issues remain.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

This pull request moves LVGL allocations to PSRAM, replaces custom SD/USB handling with espp components, and updates dependencies.

Changes:

  • Adds custom PSRAM-backed LVGL allocation.
  • Migrates SD-card and USB MSC lifecycle management to espp.
  • Updates ESP-IDF and component requirements.
File Summary and final review comments
sdkconfig.defaults Enables custom LVGL allocation and removes the obsolete MSC mount-path setting.
main/​idf_component.yml Updates IDF and monitor requirements.
components/​box-emu/​src/​lvgl_mem.c Implements PSRAM allocation. Moderate (2 votes): add the custom-malloc setting to the standalone example or conditionally compile this implementation. Moderate (1 vote): include MALLOC_CAP_INTERNAL in the fallback mask.
components/​box-emu/​src/​box-emu.cpp Migrates SD/USB lifecycle handling. Critical (1 vote): ensure the USB-Serial-JTAG PHY is released through the supported handoff path before the first MSC initialization; this also affects line 626. Moderate (1 vote): check and propagate or log usb_new_phy failures while still remounting the card.
components/​box-emu/​include/​box-emu.hpp Exposes component APIs and ownership state. Nit (1 vote each): clarify that card ownership restrictions apply while the host owns the medium, not for the entire USB-enabled period.
components/​box-emu/​idf_component.yml Updates and adds LVGL, espp, and USB dependencies.
components/​box-emu/​CMakeLists.txt Declares the new build requirements.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +588 to +592
if (jtag_phy_) {
logger_.debug("Deleting JTAG PHY");
usb_del_phy(jtag_phy_);
jtag_phy_ = nullptr;
}
Comment on lines +3 to +7
// LVGL is built with CONFIG_LV_USE_CUSTOM_MALLOC (see sdkconfig.defaults), so
// its allocator hooks are implemented here instead of by a fixed-size pool in
// internal RAM. Everything LVGL allocates (objects, styles, draw buffers, the
// rom list of the GUI, the pause menu, ...) goes to the PSRAM heap; only if
// PSRAM is exhausted does an allocation fall back to internal RAM.
@github-actions

Copy link
Copy Markdown

ESP-IDF Size Report for 'Esp Box Emu'

Metric Base PR Delta
FLASH 3,706,772 bytes (58.92%) 3,753,200 bytes (59.66%) 🔺 +46,428 bytes (+0.74%)
DRAM 144,084 bytes (42.16%) 145,144 bytes (42.47%) 🔺 +1,060 bytes (+0.31%)
IRAM 0 bytes 0 bytes 0 bytes
RAM (DRAM+IRAM) 144,084 bytes 145,144 bytes 🔺 +1,060 bytes (+0.31%)

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