AgonConsole8 / agon-vdp

Official Firmware for the Agon Console8: ESP32 VDP
MIT License
38 stars 17 forks source link

Optimizations for buffered commands API #186

Closed calc84maniac closed 4 months ago

calc84maniac commented 5 months ago

Use pass-by-reference and move semantics where possible to avoid unnecessary copies, and use result iterator of std::unordered_map::find() to avoid repeated hash table lookups.

Reduce time complexity for seeking and iteration in multi-block buffers by using advanced offset information directly. Also defer advanced offset block lookups until the buffer is resolved and accessed, which should fix some bugs when using the identity buffer ID (65535) in jumps/calls with block-based offsets.

For the buffer adjust command, process contiguous spans of data with highly optimized inner loops, which process 4 bytes at a time with 32-bit memory accesses and operations when possible.

Also fix seeking issues in buffer call/return which were identified during testing.