show (M)IPS in ncurses
This commit is contained in:
parent
1b2ad838b6
commit
07cd3100d1
5 changed files with 36 additions and 3 deletions
|
@ -102,6 +102,7 @@ void console::operator()()
|
||||||
if (c == 3) // ^c
|
if (c == 3) // ^c
|
||||||
*terminate = true;
|
*terminate = true;
|
||||||
else if (c == 12) { // ^l
|
else if (c == 12) { // ^l
|
||||||
|
// FIXME for other consoles (e.g. ncurses) this doesn't work too well
|
||||||
put_string_ll(format("\033[2J\033[?7l"));
|
put_string_ll(format("\033[2J\033[?7l"));
|
||||||
|
|
||||||
fprintf(stderr, "%d %d\n", tx, ty);
|
fprintf(stderr, "%d %d\n", tx, ty);
|
||||||
|
|
|
@ -116,8 +116,12 @@ void console_ncurses::panel_update_thread()
|
||||||
{
|
{
|
||||||
cpu *const c = b->getCpu();
|
cpu *const c = b->getCpu();
|
||||||
|
|
||||||
|
uint64_t prev_instr_cnt = c->get_instructions_executed_count();
|
||||||
|
|
||||||
|
constexpr int refresh_rate = 50;
|
||||||
|
|
||||||
while(!*terminate) {
|
while(!*terminate) {
|
||||||
myusleep(1000000 / 50); // 50 updates/sec
|
myusleep(1000000 / refresh_rate);
|
||||||
|
|
||||||
// note that these are approximately as there's no mutex on the emulation
|
// note that these are approximately as there's no mutex on the emulation
|
||||||
uint16_t current_PC = c->getPC();
|
uint16_t current_PC = c->getPC();
|
||||||
|
@ -151,6 +155,12 @@ void console_ncurses::panel_update_thread()
|
||||||
|
|
||||||
wattron(w_panel->win, COLOR_PAIR(0));
|
wattron(w_panel->win, COLOR_PAIR(0));
|
||||||
|
|
||||||
|
uint64_t cur_instr_cnt = c->get_instructions_executed_count();
|
||||||
|
|
||||||
|
mvwprintw(w_panel->win, 1, 1 + 39, "%8ld", (cur_instr_cnt - prev_instr_cnt) * refresh_rate);
|
||||||
|
|
||||||
|
prev_instr_cnt = cur_instr_cnt;
|
||||||
|
|
||||||
wmove(w_main->win, ty, tx);
|
wmove(w_main->win, ty, tx);
|
||||||
|
|
||||||
mydoupdate();
|
mydoupdate();
|
||||||
|
|
15
cpu.cpp
15
cpu.cpp
|
@ -23,6 +23,19 @@ cpu::~cpu()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpu::emulation_start()
|
||||||
|
{
|
||||||
|
running_since = get_ms();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t cpu::get_instructions_executed_count()
|
||||||
|
{
|
||||||
|
// this may wreck havoc as it is not protected by a mutex
|
||||||
|
// but a mutex would slow things down too much (as would
|
||||||
|
// do an atomic)
|
||||||
|
return instruction_count;
|
||||||
|
}
|
||||||
|
|
||||||
void cpu::reset()
|
void cpu::reset()
|
||||||
{
|
{
|
||||||
memset(regs0_5, 0x00, sizeof regs0_5);
|
memset(regs0_5, 0x00, sizeof regs0_5);
|
||||||
|
@ -1800,6 +1813,8 @@ void cpu::disassemble()
|
||||||
|
|
||||||
void cpu::step()
|
void cpu::step()
|
||||||
{
|
{
|
||||||
|
instruction_count++;
|
||||||
|
|
||||||
check_queued_interrupts();
|
check_queued_interrupts();
|
||||||
|
|
||||||
if (scheduled_trap) {
|
if (scheduled_trap) {
|
||||||
|
|
9
cpu.h
9
cpu.h
|
@ -20,8 +20,10 @@ private:
|
||||||
uint16_t fpsr { 0 };
|
uint16_t fpsr { 0 };
|
||||||
uint16_t stackLimitRegister { 0 };
|
uint16_t stackLimitRegister { 0 };
|
||||||
uint8_t scheduled_trap { 0 };
|
uint8_t scheduled_trap { 0 };
|
||||||
bool runMode { false };
|
bool runMode { false };
|
||||||
bool emulateMFPT { false };
|
bool emulateMFPT { false };
|
||||||
|
uint64_t instruction_count { 0 };
|
||||||
|
uint64_t running_since { 0 };
|
||||||
|
|
||||||
// level, vector
|
// level, vector
|
||||||
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
|
std::map<uint8_t, std::set<uint8_t> > queued_interrupts;
|
||||||
|
@ -58,6 +60,9 @@ public:
|
||||||
|
|
||||||
bus *getBus() { return b; }
|
bus *getBus() { return b; }
|
||||||
|
|
||||||
|
void emulation_start();
|
||||||
|
uint64_t get_instructions_executed_count();
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void step();
|
void step();
|
||||||
|
|
2
main.cpp
2
main.cpp
|
@ -259,6 +259,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
*running = true;
|
*running = true;
|
||||||
|
|
||||||
|
c->emulation_start(); // for statistics
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
c->step();
|
c->step();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue