diff --git a/components/box-emu/src/box-emu.cpp b/components/box-emu/src/box-emu.cpp index eaca075..a30e9b4 100644 --- a/components/box-emu/src/box-emu.cpp +++ b/components/box-emu/src/box-emu.cpp @@ -487,12 +487,12 @@ void BoxEmu::palette(const uint16_t *palette, size_t size) { palette_size_ = size; } -void BoxEmu::push_frame(const void* frame) { +void IRAM_ATTR BoxEmu::push_frame(const void* frame) { if (video_queue_ == nullptr) { logger_.error("video queue is null, make sure to call initialize_video() first!"); return; } - xQueueSend(video_queue_, &frame, 10 / portTICK_PERIOD_MS); + xQueueSend(video_queue_, &frame, 5 / portTICK_PERIOD_MS); } VideoSetting BoxEmu::video_setting() const { @@ -717,28 +717,23 @@ const uint16_t* BoxEmu::palette() const { bool BoxEmu::video_task_callback(std::mutex &m, std::condition_variable& cv) { const void *_frame_ptr; - if (xQueuePeek(video_queue_, &_frame_ptr, 100 / portTICK_PERIOD_MS) != pdTRUE) { - // we couldn't get anything from the queue, return - return false; - } - if (_frame_ptr == nullptr) { - // make sure we clear the queue - xQueueReceive(video_queue_, &_frame_ptr, 10 / portTICK_PERIOD_MS); - // we got a nullptr, return + if (xQueueReceive(video_queue_, &_frame_ptr, portMAX_DELAY) != pdTRUE) { return false; } static constexpr int num_lines_to_write = num_rows_in_framebuffer; auto &box = espp::EspBox::get(); - static int vram_index = 0; // has to be static so that it persists between calls + static uint16_t vram_index = 0; // has to be static so that it persists between calls const int _x_offset = x_offset(); const int _y_offset = y_offset(); const uint16_t* _palette = palette(); + uint16_t *vram0 = (uint16_t*)box.vram0(); + uint16_t *vram1 = (uint16_t*)box.vram1(); if (is_native()) { - for (int y=0; y(num_lines_to_write, display_height_-y); - if (has_palette()) { + if (has_palette()) { + for (int y=0; y(num_lines_to_write, display_height_-y); const uint8_t* _frame = (const uint8_t*)_frame_ptr; for (int i=0; i(num_lines_to_write, display_height_-y); const uint16_t* _frame = (const uint16_t*)_frame_ptr; for (int i=0; i(x_scale * native_width_, 0, espp::EspBox::lcd_width()); - for (int y=0; y= max_y) { - break; - } - int source_y = (float)_y * inv_y_scale; - // shoudl i put this around the outer loop or is this loop a good - // balance for perfomance of the check? - if (has_palette()) { + if (has_palette()) { + for (int y=0; y= max_y) { + break; + } + int source_y = (float)_y * inv_y_scale; const uint8_t* _frame = (const uint8_t*)_frame_ptr; // write two pixels (32 bits) at a time because it's faster for (int x=0; x= max_y) { + break; + } + int source_y = (float)_y * inv_y_scale; const uint16_t* _frame = (const uint16_t*)_frame_ptr; // write two pixels (32 bits) at a time because it's faster for (int x=0; x