X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=misc.c;h=29846e23f6a5aef4aef9320ea180e8a0797a5800;hb=6ecd0010931a988792e672e1fe0a1192fca7b002;hp=9899b08681b89443a814a09c55cf891f5d9d355a;hpb=83ff9d0c0edda5c08d9966e75addc8cd806cfe6d;p=open-adventure.git diff --git a/misc.c b/misc.c index 9899b08..29846e2 100644 --- a/misc.c +++ b/misc.c @@ -50,6 +50,35 @@ void packed_to_token(long packed, char token[6]) } } +void token_to_packed(char token[6], long* packed) +{ + *packed = 0; + for (size_t i = 0; i < 5; ++i) + { + if (token[4 - i] == '\0') + continue; + char mapped = ascii_to_advent[(int) token[4 - i]]; + *packed |= (mapped << (6 * i)); + } +} + +/* Hide the fact that wods are corrently packed longs */ + +bool wordeq(token_t a, token_t b) +{ + return a == b; +} + +bool wordempty(token_t a) +{ + return a == 0; +} + +void wordclear(token_t *v) +{ + *v = 0; +} + /* I/O routines (SPEAK, PSPEAK, RSPEAK, SETPRM, GETIN, YES) */ void speak(const char* msg) @@ -250,7 +279,7 @@ char* get_input() return (input); } -bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response) +bool YES(const char* question, const char* yes_response, const char* no_response) /* Print message X, wait for yes/no answer. If yes, print Y and return true; * if no, print Z and return false. */ { @@ -258,7 +287,7 @@ bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response) bool outcome; for (;;) { - RSPEAK(question); + speak(question); reply = get_input(); @@ -276,11 +305,11 @@ bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response) free(firstword); if (yes == 0 || y == 0) { - RSPEAK(yes_response); + speak(yes_response); outcome = true; break; } else if (no == 0 || n == 0) { - RSPEAK(no_response); + speak(no_response); outcome = false; break; } else @@ -417,7 +446,7 @@ void MOVE(long object, long where) from = game.fixed[object - NOBJECTS]; else from = game.place[object]; - if (from != NOWHERE && from != CARRIED && !SPECIAL(from)) + if (from != LOC_NOWHERE && from != CARRIED && !SPECIAL(from)) CARRY(object, from); DROP(object, where); } @@ -660,8 +689,8 @@ void DATIME(long* d, long* t) void bug(enum bugtype num, const char *error_string) { - fprintf(stderr, "Fatal error %d, %s.\n", num, error_string); - exit(EXIT_FAILURE); + fprintf(stderr, "Fatal error %d, %s.\n", num, error_string); + exit(EXIT_FAILURE); } /* end */