From 69c1d23cb3a6b860a9d847270415a30034e29495 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 6 Apr 2008 12:19:27 +0000 Subject: [PATCH] now with a movfeat command --- hostside/commands.c | 26 ++++++++++++++++++++++++++ hostside/common.h | 13 ++++++++++--- hostside/parseutils.c | 13 +++++++------ hostside/realtime.c | 12 ++++++++++++ hostside/realtime.h | 2 ++ 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/hostside/commands.c b/hostside/commands.c index 9dd5434..55fcc3b 100644 --- a/hostside/commands.c +++ b/hostside/commands.c @@ -187,9 +187,35 @@ static void cmd_pic(ParseState *ps, const CmdInfo *ci) { ouack(ci); } +static void cmd_movfeat(ParseState *ps, const CmdInfo *ci) { + Segment *back, *move, *fwd; + long ms; + ErrorCode ec; + + if (!ps_needsegment(ps,&back,0) || + !ps_needsegment(ps,&move,0) || + !ps_needsegment(ps,&fwd,0)) return; + + ms= INT_MAX; + if (ps->remain) + if (!ps_neednumber(ps,&ms,0,INT_MAX,"milliseconds")) return; + + if (!ps_neednoargs(ps)) return; + + ec= movpos_change(back,move,fwd,ms,0); + if (ec) + badcmd(ps,"movfeat %s %s %s %ld %s", + back->i->pname, move->i->pname, fwd->i->pname, + ms==INT_MAX ? -1L : ms, + errorcodelist[ec]); + + ouack(ci); +} + const CmdInfo toplevel_cmds[]= { { "pic", cmd_pic }, { "nmra", cmd_nmra, }, { "noop", cmd_noop }, + { "movfeat", cmd_movfeat }, { 0 } }; diff --git a/hostside/common.h b/hostside/common.h index ef4d3e7..72b18da 100644 --- a/hostside/common.h +++ b/hostside/common.h @@ -64,13 +64,20 @@ int ps_neednoargs(ParseState *ps); ((const typeof(infos[0])*) \ any_lookup((ps),(infos),sizeof((infos)[0]))) +#define some_needword_lookup_counted(ps, infos, ninfos, what) \ + ((const typeof(infos[0])*) \ + any_needword_lookup((ps), \ + (infos), (ninfos), sizeof((infos)[0]), \ + (what))) + #define some_needword_lookup(ps, infos, what) \ ((const typeof(infos[0])*) \ - any_needword_lookup((ps),(infos),sizeof((infos)[0]),(what))) + any_needword_lookup((ps),(infos),INT_MAX,sizeof((infos)[0]),(what))) -const void *any_lookup(ParseState *ps, const void *infos, size_t infosz); +const void *any_lookup(ParseState *ps, + const void *infos, int ninfsmax, size_t infosz); const void *any_needword_lookup(ParseState *ps, const void *infos, - size_t sz, const char *what); + int ninfsmax, size_t sz, const char *what); /*---------- from client.c ----------*/ diff --git a/hostside/parseutils.c b/hostside/parseutils.c index 7cb962a..d1509f3 100644 --- a/hostside/parseutils.c +++ b/hostside/parseutils.c @@ -93,23 +93,24 @@ int ps_needhextoend(ParseState *ps, Byte *d, int *len_io) { return 1; } - -const void *any_lookup(ParseState *ps, const void *inf, size_t sz) { +const void *any_lookup(ParseState *ps, const void *inf, int ninfsmax, + size_t sz) { const char *tname; + int i; - for (; - (tname= *(const char *const*)inf); + for (i=0; + ithisword); + if (!segi) return 0; + if (segi_r) *segi_r= segi; + if (seg_r) *seg_r= segments + (segi - info_segments); + return 1; +} + /*---------- serial input (via oop) ----------*/ static PicInsn serial_buf; diff --git a/hostside/realtime.h b/hostside/realtime.h index f74ae99..ca5e101 100644 --- a/hostside/realtime.h +++ b/hostside/realtime.h @@ -111,6 +111,8 @@ void oupicio(const char *dirn, const PicInsnInfo *pii, int objnum); void ouhex(const char *word, const Byte *command, int length); void serial_transmit(const PicInsn *pi); +int ps_needsegment(ParseState *ps, Segment **seg_r, + const SegmentInfo **segi_r); /*---------- from actual.c ----------*/ -- 2.30.2