mirror of
https://github.com/satoshinm/pill_6502.git
synced 2024-12-27 17:29:19 +00:00
Merge emulated frequency measurement into ^T command
This commit is contained in:
parent
01a0f0f63c
commit
b79a6744a0
@ -22,10 +22,9 @@ Special commands built-in, not passed to the ACIA and 6502:
|
||||
| --------- | ------ |
|
||||
| ^V | Show `pill_6502` version |
|
||||
| ^P | Pause/resume 6502 processor execution |
|
||||
| ^F | Show frequency |
|
||||
| ^R | Reset the 6502 processor (also reset on USB reset) |
|
||||
| ^E | Local echo toggle, off by default |
|
||||
| ^T | Show clock ticks and instruction count |
|
||||
| ^T | Show clock ticks, instruction count, and frequency since last ^T |
|
||||
| ^G | Show help |
|
||||
|
||||
Intended to be somewhat compatible with [Grant Searle's Simple6502](http://searle.hostei.com/grant/6502/Simple6502.html),
|
||||
|
35
src/main.c
35
src/main.c
@ -113,24 +113,6 @@ char *process_serial_command(char b) {
|
||||
paused = !paused;
|
||||
return paused ? "paused" : "resumed";
|
||||
} else if (b == '\x06') { // ^F
|
||||
static uint32_t last_ticks = 0;
|
||||
static uint32_t last_millis = 0;
|
||||
if (last_ticks == 0) {
|
||||
last_ticks = clockticks6502;
|
||||
last_millis = millis;
|
||||
|
||||
return "press ^F again to measure frequency";
|
||||
}
|
||||
|
||||
uint32_t hz = (clockticks6502 - last_ticks) * 1000 / (millis - last_millis);
|
||||
|
||||
static char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%ld Hz", hz);
|
||||
|
||||
last_ticks = clockticks6502;
|
||||
last_millis = millis;
|
||||
|
||||
return buf;
|
||||
} else if (b == '\x12') { // ^R
|
||||
reset6502();
|
||||
paused = false;
|
||||
@ -139,11 +121,24 @@ char *process_serial_command(char b) {
|
||||
local_echo = !local_echo;
|
||||
return local_echo ? "local echo enabled" : "local echo disabled";
|
||||
} else if (b == '\x14') { // ^T
|
||||
static uint32_t last_ticks = 0;
|
||||
static uint32_t last_millis = 0;
|
||||
uint32_t hz = 0;
|
||||
if (last_ticks != 0) {
|
||||
uint32_t elapsed_ticks = clockticks6502 - last_ticks;
|
||||
uint32_t elapsed_millis = millis - last_millis;
|
||||
|
||||
if (elapsed_millis != 0) hz = elapsed_ticks * 1000 / elapsed_millis;
|
||||
}
|
||||
|
||||
last_ticks = clockticks6502;
|
||||
last_millis = millis;
|
||||
|
||||
static char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%ld ticks\r\n%ld instructions", clockticks6502, instructions);
|
||||
snprintf(buf, sizeof(buf), "%ld ticks\r\n%ld instructions\r\n%ld Hz", clockticks6502, instructions, hz);
|
||||
return buf;
|
||||
} else if (b == '\x07') { // ^G
|
||||
return "^V=version ^R=reset ^E=echo ^P=pause ^F=freq ^T=ticks ^G=help";
|
||||
return "^V=version ^R=reset ^E=echo ^P=pause ^T=timing ^G=help";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user