mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-11 05:29:43 +00:00
videoctrl: generate VBL interrupts.
This commit is contained in:
parent
ddf139a659
commit
337a9d6dd0
@ -155,15 +155,33 @@ void VideoCtrlBase::start_refresh_task() {
|
||||
this->refresh_task_id = TimerManager::get_instance()->add_cyclic_timer(
|
||||
refresh_interval,
|
||||
[this]() {
|
||||
// assert VBL interrupt
|
||||
if (this->int_ctrl)
|
||||
this->int_ctrl->ack_int(this->irq_id, 1);
|
||||
this->update_screen();
|
||||
}
|
||||
);
|
||||
|
||||
uint64_t vbl_duration = static_cast<uint64_t>(1.0f / ((double)(this->pixel_clock) /
|
||||
hori_total / vert_blank) * NS_PER_SEC + 0.5);
|
||||
this->vbl_end_task_id = TimerManager::get_instance()->add_cyclic_timer(
|
||||
refresh_interval,
|
||||
refresh_interval + vbl_duration,
|
||||
[this]() {
|
||||
// deassert VBL interrupt
|
||||
if (this->int_ctrl)
|
||||
this->int_ctrl->ack_int(this->irq_id, 0);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void VideoCtrlBase::stop_refresh_task() {
|
||||
if (this->refresh_task_id) {
|
||||
TimerManager::get_instance()->cancel_timer(this->refresh_task_id);
|
||||
}
|
||||
if (this->vbl_end_task_id) {
|
||||
TimerManager::get_instance()->cancel_timer(this->vbl_end_task_id);
|
||||
}
|
||||
}
|
||||
|
||||
void VideoCtrlBase::get_palette_colors(uint8_t index, uint8_t& r, uint8_t& g,
|
||||
|
@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#define VIDEO_CTRL_H
|
||||
|
||||
#include <core/hostevents.h>
|
||||
#include <devices/common/hwinterrupt.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include <cinttypes>
|
||||
@ -66,6 +67,8 @@ protected:
|
||||
int active_height; // height of the visible display area
|
||||
int hori_total = 0;
|
||||
int vert_total = 0;
|
||||
int hori_blank = 0;
|
||||
int vert_blank = 0;
|
||||
int pixel_depth;
|
||||
float pixel_clock;
|
||||
float refresh_rate;
|
||||
@ -76,6 +79,11 @@ protected:
|
||||
uint8_t* fb_ptr;
|
||||
int fb_pitch;
|
||||
uint32_t refresh_task_id = 0;
|
||||
uint32_t vbl_end_task_id = 0;
|
||||
|
||||
// interrupt suff
|
||||
InterruptCtrl* int_ctrl = nullptr;
|
||||
uint32_t irq_id = 0;
|
||||
|
||||
std::function<void(uint8_t *dst_buf, int dst_pitch)> convert_fb_cb;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user