mirror of
https://github.com/buserror/mii_emu.git
synced 2024-11-25 05:32:20 +00:00
mish: Removed globals.
Removed big horrible global used by mish commands, now use the parameter made for it. Signed-off-by: Michel Pollet <buserror@gmail.com>
This commit is contained in:
parent
f030ed758e
commit
3ee2a36d38
@ -117,7 +117,7 @@ main(
|
|||||||
struct nk_colorf bg;
|
struct nk_colorf bg;
|
||||||
|
|
||||||
mii_init(&g_mii);
|
mii_init(&g_mii);
|
||||||
int idx = 0;
|
int idx = 1;
|
||||||
uint32_t flags = MII_INIT_DEFAULT;
|
uint32_t flags = MII_INIT_DEFAULT;
|
||||||
int r = mii_argv_parse(&g_mii, argc, argv, &idx, &flags);
|
int r = mii_argv_parse(&g_mii, argc, argv, &idx, &flags);
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
@ -126,6 +126,7 @@ main(
|
|||||||
exit(1);
|
exit(1);
|
||||||
mii_prepare(&g_mii, flags);
|
mii_prepare(&g_mii, flags);
|
||||||
mish_prepare(1);
|
mish_prepare(1);
|
||||||
|
mish_set_command_parameter(MISH_FCC('m','i','i',' '), &g_mii);
|
||||||
printf("MISH_TELNET_PORT = %s\n", getenv("MISH_TELNET_PORT"));
|
printf("MISH_TELNET_PORT = %s\n", getenv("MISH_TELNET_PORT"));
|
||||||
|
|
||||||
memset(&win, 0, sizeof(win));
|
memset(&win, 0, sizeof(win));
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "mii_65c02_ops.h"
|
#include "mii_65c02_ops.h"
|
||||||
#include "mii_65c02_disasm.h"
|
#include "mii_65c02_disasm.h"
|
||||||
|
|
||||||
extern mii_t g_mii;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_mii_mish_text(
|
_mii_mish_text(
|
||||||
@ -29,7 +28,7 @@ _mii_mish_text(
|
|||||||
{
|
{
|
||||||
// load 0x400, calculate the 24 line addresses from the code in video
|
// load 0x400, calculate the 24 line addresses from the code in video
|
||||||
// and show the 40 or 80 chars, depending on col80
|
// and show the 40 or 80 chars, depending on col80
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
uint16_t a = 0x400;
|
uint16_t a = 0x400;
|
||||||
int page2 = mii_read_one(mii, SWPAGE2);
|
int page2 = mii_read_one(mii, SWPAGE2);
|
||||||
// int col80 = mii_read_one(mii, SW80COL);
|
// int col80 = mii_read_one(mii, SW80COL);
|
||||||
@ -53,7 +52,7 @@ _mii_mish_cmd(
|
|||||||
const char * argv[])
|
const char * argv[])
|
||||||
{
|
{
|
||||||
const char * state[] = { "RUNNING", "STOPPED", "STEP" };
|
const char * state[] = { "RUNNING", "STOPPED", "STEP" };
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
if (!argv[1]) {
|
if (!argv[1]) {
|
||||||
show_state:
|
show_state:
|
||||||
printf("mii: %s Target speed: %.3fMHz Current: %.3fMHz\n",
|
printf("mii: %s Target speed: %.3fMHz Current: %.3fMHz\n",
|
||||||
@ -131,6 +130,11 @@ show_state:
|
|||||||
mii->state = MII_STOPPED;
|
mii->state = MII_STOPPED;
|
||||||
goto show_state;
|
goto show_state;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(argv[1], "quit") || !strcmp(argv[1], "exit")) {
|
||||||
|
mii->state = MII_TERMINATE;
|
||||||
|
printf("mii: terminating\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
printf("mii: unknown command %s\n", argv[1]);
|
printf("mii: unknown command %s\n", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +144,7 @@ _mii_mish_bp(
|
|||||||
int argc,
|
int argc,
|
||||||
const char * argv[])
|
const char * argv[])
|
||||||
{
|
{
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
if (!argv[1] || !strcmp(argv[1], "list")) {
|
if (!argv[1] || !strcmp(argv[1], "list")) {
|
||||||
printf("breakpoints: map %04x\n", mii->debug.bp_map);
|
printf("breakpoints: map %04x\n", mii->debug.bp_map);
|
||||||
for (int i = 0; i < (int)sizeof(mii->debug.bp_map)*8; i++) {
|
for (int i = 0; i < (int)sizeof(mii->debug.bp_map)*8; i++) {
|
||||||
@ -206,7 +210,7 @@ _mii_mish_il(
|
|||||||
if (addr >= 0xffff)
|
if (addr >= 0xffff)
|
||||||
addr = 0xfff0;
|
addr = 0xfff0;
|
||||||
}
|
}
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
|
|
||||||
for (int li = 0; li < 20; li++) {
|
for (int li = 0; li < 20; li++) {
|
||||||
uint8_t op[16];
|
uint8_t op[16];
|
||||||
@ -231,7 +235,7 @@ _mii_mish_dm(
|
|||||||
if (addr >= 0xffff)
|
if (addr >= 0xffff)
|
||||||
addr = 0xfff0;
|
addr = 0xfff0;
|
||||||
}
|
}
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
if (!strcmp(argv[0], "dm")) {
|
if (!strcmp(argv[0], "dm")) {
|
||||||
printf("dm: %04x\n", addr);
|
printf("dm: %04x\n", addr);
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
@ -266,7 +270,7 @@ _mii_mish_step(
|
|||||||
const char * argv[])
|
const char * argv[])
|
||||||
{
|
{
|
||||||
if (argv[0][0] == 's') {
|
if (argv[0][0] == 's') {
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
if (argv[1]) {
|
if (argv[1]) {
|
||||||
int n = strtol(argv[1], NULL, 10);
|
int n = strtol(argv[1], NULL, 10);
|
||||||
mii->trace.step_inst = n;
|
mii->trace.step_inst = n;
|
||||||
@ -276,7 +280,7 @@ _mii_mish_step(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argv[0][0] == 'n') {
|
if (argv[0][0] == 'n') {
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
// read current opcode, find how how many bytes it take,
|
// read current opcode, find how how many bytes it take,
|
||||||
// then put a temporary breakpoint to the next PC.
|
// then put a temporary breakpoint to the next PC.
|
||||||
// all of that if this is not a relative branch of course, in
|
// all of that if this is not a relative branch of course, in
|
||||||
@ -304,21 +308,19 @@ _mii_mish_step(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argv[0][0] == 'c') {
|
if (argv[0][0] == 'c') {
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
mii->trace.step_inst = 0;
|
mii->trace.step_inst = 0;
|
||||||
mii->state = MII_RUNNING;
|
mii->state = MII_RUNNING;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (argv[0][0] == 'h') {
|
if (argv[0][0] == 'h') {
|
||||||
mii_t * mii = &g_mii;
|
mii_t * mii = param;
|
||||||
mii->trace.step_inst = 0;
|
mii->trace.step_inst = 0;
|
||||||
mii->state = MII_STOPPED;
|
mii->state = MII_STOPPED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int g_mii_audio_record_fd;
|
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -327,28 +329,29 @@ _mii_mish_audio(
|
|||||||
int argc,
|
int argc,
|
||||||
const char * argv[])
|
const char * argv[])
|
||||||
{
|
{
|
||||||
|
mii_t * mii = param;
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("audio: missing argument\n");
|
printf("audio: missing argument\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcmp(argv[1], "record")) {
|
if (!strcmp(argv[1], "record")) {
|
||||||
if (g_mii_audio_record_fd != -1) {
|
if (mii->speaker.debug_fd != -1) {
|
||||||
close(g_mii_audio_record_fd);
|
close(mii->speaker.debug_fd);
|
||||||
g_mii_audio_record_fd = -1;
|
mii->speaker.debug_fd = -1;
|
||||||
printf("audio: stop recording\n");
|
printf("audio: stop recording\n");
|
||||||
} else {
|
} else {
|
||||||
g_mii_audio_record_fd = open("audio.raw",
|
mii->speaker.debug_fd = open("audio.raw",
|
||||||
O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||||
printf("audio: start recording\n");
|
printf("audio: start recording\n");
|
||||||
}
|
}
|
||||||
} else if (!strcmp(argv[1], "mute")) {
|
} else if (!strcmp(argv[1], "mute")) {
|
||||||
if (argv[2] && !strcmp(argv[2], "off"))
|
if (argv[2] && !strcmp(argv[2], "off"))
|
||||||
g_mii.speaker.muted = false;
|
mii->speaker.muted = false;
|
||||||
else if (argv[2] && !strcmp(argv[2], "on"))
|
else if (argv[2] && !strcmp(argv[2], "on"))
|
||||||
g_mii.speaker.muted = true;
|
mii->speaker.muted = true;
|
||||||
else if (!argv[2] || (argv[2] && !strcmp(argv[2], "toggle")))
|
else if (!argv[2] || (argv[2] && !strcmp(argv[2], "toggle")))
|
||||||
g_mii.speaker.muted = !g_mii.speaker.muted;
|
mii->speaker.muted = !mii->speaker.muted;
|
||||||
printf("audio: %s\n", g_mii.speaker.muted ? "muted" : "unmuted");
|
printf("audio: %s\n", mii->speaker.muted ? "muted" : "unmuted");
|
||||||
} else if (!strcmp(argv[1], "volume")) {
|
} else if (!strcmp(argv[1], "volume")) {
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
printf("audio: missing volume\n");
|
printf("audio: missing volume\n");
|
||||||
@ -358,9 +361,9 @@ _mii_mish_audio(
|
|||||||
float vol = atof(argv[2]);
|
float vol = atof(argv[2]);
|
||||||
if (vol < 0) vol = 0;
|
if (vol < 0) vol = 0;
|
||||||
else if (vol > 10) vol = 10;
|
else if (vol > 10) vol = 10;
|
||||||
mii_speaker_volume(&g_mii.speaker, vol);
|
mii_speaker_volume(&mii->speaker, vol);
|
||||||
printf("audio: volume %.3f (amp: %.4f)\n",
|
printf("audio: volume %.3f (amp: %.4f)\n",
|
||||||
vol, g_mii.speaker.vol_multiplier);
|
vol, mii->speaker.vol_multiplier);
|
||||||
} else {
|
} else {
|
||||||
printf("audio: unknown command %s\n", argv[1]);
|
printf("audio: unknown command %s\n", argv[1]);
|
||||||
}
|
}
|
||||||
@ -378,9 +381,10 @@ MISH_CMD_HELP(mii,
|
|||||||
" poke <addr> <val> : poke a value in memory (respect SW)",
|
" poke <addr> <val> : poke a value in memory (respect SW)",
|
||||||
" peek <addr> : peek a value in memory (respect SW)",
|
" peek <addr> : peek a value in memory (respect SW)",
|
||||||
" speed <speed> : set speed in MHz",
|
" speed <speed> : set speed in MHz",
|
||||||
" stop : stop the cpu"
|
" stop : stop the cpu",
|
||||||
|
" quit|exit : quit the emulator"
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(mii, _mii_mish_cmd);
|
MII_MISH(mii, _mii_mish_cmd);
|
||||||
|
|
||||||
MISH_CMD_NAMES(bp, "bp");
|
MISH_CMD_NAMES(bp, "bp");
|
||||||
MISH_CMD_HELP(bp,
|
MISH_CMD_HELP(bp,
|
||||||
@ -389,7 +393,7 @@ MISH_CMD_HELP(bp,
|
|||||||
" +<addr>[r|w][s] [size]: add at <addr> for read/write, sticky",
|
" +<addr>[r|w][s] [size]: add at <addr> for read/write, sticky",
|
||||||
" -<index> : disable (don't clear) breakpoint <index>"
|
" -<index> : disable (don't clear) breakpoint <index>"
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(bp, _mii_mish_bp);
|
MII_MISH(bp, _mii_mish_bp);
|
||||||
|
|
||||||
MISH_CMD_NAMES(il, "il");
|
MISH_CMD_NAMES(il, "il");
|
||||||
MISH_CMD_HELP(il,
|
MISH_CMD_HELP(il,
|
||||||
@ -397,7 +401,7 @@ MISH_CMD_HELP(il,
|
|||||||
" <default> : list next 20 instructions.",
|
" <default> : list next 20 instructions.",
|
||||||
" [addr]: start at address addr"
|
" [addr]: start at address addr"
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(il, _mii_mish_il);
|
MII_MISH(il, _mii_mish_il);
|
||||||
|
|
||||||
MISH_CMD_NAMES(dm, "dm","db","dw","da");
|
MISH_CMD_NAMES(dm, "dm","db","dw","da");
|
||||||
MISH_CMD_HELP(dm,
|
MISH_CMD_HELP(dm,
|
||||||
@ -408,7 +412,7 @@ MISH_CMD_HELP(dm,
|
|||||||
" da [<addr>]: dump one address.",
|
" da [<addr>]: dump one address.",
|
||||||
" [addr]: start at address addr"
|
" [addr]: start at address addr"
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(dm, _mii_mish_dm);
|
MII_MISH(dm, _mii_mish_dm);
|
||||||
|
|
||||||
MISH_CMD_NAMES(step, "s","step","n","next","cont","h","halt");
|
MISH_CMD_NAMES(step, "s","step","n","next","cont","h","halt");
|
||||||
MISH_CMD_HELP(step,
|
MISH_CMD_HELP(step,
|
||||||
@ -417,14 +421,14 @@ MISH_CMD_HELP(step,
|
|||||||
" n|next : step one instruction, skip subroutines.",
|
" n|next : step one instruction, skip subroutines.",
|
||||||
" cont : continue execution."
|
" cont : continue execution."
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(step, _mii_mish_step);
|
MII_MISH(step, _mii_mish_step);
|
||||||
|
|
||||||
MISH_CMD_NAMES(text, "text");
|
MISH_CMD_NAMES(text, "text");
|
||||||
MISH_CMD_HELP(text,
|
MISH_CMD_HELP(text,
|
||||||
"mii: show text page [buggy]",
|
"mii: show text page [buggy]",
|
||||||
" <default> : that's it"
|
" <default> : that's it"
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(text, _mii_mish_text);
|
MII_MISH(text, _mii_mish_text);
|
||||||
|
|
||||||
MISH_CMD_NAMES(audio, "audio");
|
MISH_CMD_NAMES(audio, "audio");
|
||||||
MISH_CMD_HELP(audio,
|
MISH_CMD_HELP(audio,
|
||||||
@ -433,4 +437,4 @@ MISH_CMD_HELP(audio,
|
|||||||
" mute: mute/unmute audio.",
|
" mute: mute/unmute audio.",
|
||||||
" volume: set volume (0.0 to 1.0)."
|
" volume: set volume (0.0 to 1.0)."
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(audio, _mii_mish_audio);
|
MII_MISH(audio, _mii_mish_audio);
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
#include "mii.h"
|
#include "mii.h"
|
||||||
|
|
||||||
extern mii_t g_mii;
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_mii_mish_dd(
|
_mii_mish_dd(
|
||||||
@ -22,8 +20,9 @@ _mii_mish_dd(
|
|||||||
int argc,
|
int argc,
|
||||||
const char * argv[])
|
const char * argv[])
|
||||||
{
|
{
|
||||||
|
mii_t * mii = param;
|
||||||
if (!argv[1] || !strcmp(argv[1], "list")) {
|
if (!argv[1] || !strcmp(argv[1], "list")) {
|
||||||
mii_dd_t *d = g_mii.dd.drive;
|
mii_dd_t *d = mii->dd.drive;
|
||||||
printf(" ID %-16s %-20s\n", "Card", "Name");
|
printf(" ID %-16s %-20s\n", "Card", "Name");
|
||||||
while (d) {
|
while (d) {
|
||||||
printf("%d:%d %-16s %-20s : %s\n",
|
printf("%d:%d %-16s %-20s : %s\n",
|
||||||
@ -43,4 +42,4 @@ MISH_CMD_HELP(dd,
|
|||||||
"mii: disk commands",
|
"mii: disk commands",
|
||||||
" <default>|list: list all disk drives"
|
" <default>|list: list all disk drives"
|
||||||
);
|
);
|
||||||
MISH_CMD_REGISTER(dd, _mii_mish_dd);
|
MII_MISH(dd, _mii_mish_dd);
|
||||||
|
@ -278,3 +278,11 @@ uint8_t
|
|||||||
mii_register_trap(
|
mii_register_trap(
|
||||||
mii_t *mii,
|
mii_t *mii,
|
||||||
mii_trap_handler_cb cb);
|
mii_trap_handler_cb cb);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this is used if libmish is active, to register the 'mii' commands
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MII_MISH_KIND MISH_FCC('m','i','i',' ')
|
||||||
|
#define MII_MISH(_name,_cmd) \
|
||||||
|
MISH_CMD_REGISTER_KIND(_name, _cmd, 0, MII_MISH_KIND)
|
||||||
|
Loading…
Reference in New Issue
Block a user