From 5f2eb3e8bfc1934f9d09e95d466ad3cfc87d0b37 Mon Sep 17 00:00:00 2001 From: nataliapc Date: Wed, 13 Nov 2019 13:20:09 +0100 Subject: [PATCH] Not fully implemented condacts shows a ErrCode8 --- README.md | 2 +- include/daad_platform_msx2.h | 15 +- include/vdp.h | 1 + src/daad.c | 4 +- src/daad_condacts.c | 388 ++++++++--------------------------- src/daad_platform_msx2.c | 174 ++++++++-------- src/libs/vdp_setborder.s | 19 ++ 7 files changed, 212 insertions(+), 391 deletions(-) create mode 100644 src/libs/vdp_setborder.s diff --git a/README.md b/README.md index 412d94b..f4c0f02 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This project is a **DAAD** interpreter created from scratch for **MSX2**/**MSX2+ You can see the classic interpreters [here](https://github.com/daad-adventure-writer/daad). -**MSX2DAAD** is also compatible with [Maluva DAAD extension](https://github.com/Utodev/MALUVA), that add new functionalities to the classic interpreters like: +**MSX2DAAD** is also compatible with [Maluva DAAD extension](https://github.com/Utodev/MALUVA) emulating his new functionalities to the classic interpreters like: - Load bitmap images from disk. - Load/Save your gameplay from/to disk. diff --git a/include/daad_platform_msx2.h b/include/daad_platform_msx2.h index bc9fcae..901835a 100644 --- a/include/daad_platform_msx2.h +++ b/include/daad_platform_msx2.h @@ -89,7 +89,7 @@ #ifdef LANG_ES #define LANG ES #endif -#define VERSION "MSX2DAAD v1.0#"STRINGIFY(LANG)"#"STRINGIFY(SCREEN)"_"STRINGIFY(FONTWIDTH) +#define VERSION "MSX2DAAD v1.1#"STRINGIFY(LANG)"#"STRINGIFY(SCREEN)"_"STRINGIFY(FONTWIDTH) #if SCREEN==6 || SCREEN==7 #define SCREEN_WIDTH 512 @@ -140,10 +140,11 @@ // System calls #define CALSLT 0x1C // Interslot call // System variables -#define CLIKSW 0xf3db // (BYTE) SCREEN ,,n will write to this address (0:disables_keys_click 1:enables_keys_click) -#define FNKSTR 0xf87f // (10*16 bytes) Value of the function keys -#define HTIMI 0xfd9f // Hook VBLANK interrupt -#define MODE 0xfafc /*Flag for screen mode. (1B/R) +#define TPA_LIMIT 0x0006 +#define CLIKSW 0xf3db // (BYTE) SCREEN ,,n will write to this address (0:disables_keys_click 1:enables_keys_click) +#define FNKSTR 0xf87f // (10*16 bytes) Value of the function keys +#define HTIMI 0xfd9f // Hook VBLANK interrupt +#define MODE 0xfafc /*Flag for screen mode. (1B/R) bit 7: 1 = conversion to Katakana; 0 = conversion to Hiragana. (MSX2+~) bit 6: 1 if Kanji ROM level 2. (MSX2+~) bit 5: 0/1 to draw in RGB / YJK mode SCREEN 10 or 11. (MSX2+~) @@ -155,8 +156,8 @@ 10 for 128kB 11 for 192kB bit 0: 1 if the conversion of Romaji to Kana is possible. (MSX2~)*/ -#define NEWKEY 0xfbe5 // (11 bytes) with key matrix -#define JIFFY 0xfc9e // (WORD) Contains value of the software clock, each interrupt of the VDP +#define NEWKEY 0xfbe5 // (11 bytes) with key matrix +#define JIFFY 0xfc9e // (WORD) Contains value of the software clock, each interrupt of the VDP // it is increased by 1 (50/60Hz) diff --git a/include/vdp.h b/include/vdp.h index 5c42b1f..135be87 100644 --- a/include/vdp.h +++ b/include/vdp.h @@ -83,6 +83,7 @@ void setPalette(char *paletteAddress); void setColorPal(uint8_t colIndex, uint16_t grb); // grb bitfield: 00000GGG.0RRR0BBB void setColor(char forecolor, char background, char border); +void setBorder(char border); void clearSC5(); void clearSC5lines(uint16_t startline, uint16_t numLines); diff --git a/src/daad.c b/src/daad.c index eb902fe..46e9761 100644 --- a/src/daad.c +++ b/src/daad.c @@ -8,10 +8,12 @@ */ #include #include -#include #include #include #include "daad.h" +#if defined(DEBUG) || defined(VERBOSE) || defined(VERBOSE2) + #include +#endif // External diff --git a/src/daad_condacts.c b/src/daad_condacts.c index 4645b3d..3a37fea 100644 --- a/src/daad_condacts.c +++ b/src/daad_condacts.c @@ -8,285 +8,79 @@ #include #include #include -#include #include "daad.h" #include "daad_condacts.h" - +#if defined(DEBUG) || defined(VERBOSE) || defined(VERBOSE2) + #include +#endif #define NUM_PROCS 10 #define pPROC currProc->condact -PROCstack procStack[NUM_PROCS]; -PROCstack *currProc; +PROCstack procStack[NUM_PROCS];// Stack of calls using PROCESS condact. +PROCstack *currProc; // Pointer to current active condact. -uint8_t indirection; -uint8_t checkEntry; -uint8_t isDone, lastIsDone; -uint8_t lastPicLocation; -uint8_t lastPicShow; +bool indirection; // True if the current condact use indirection for the first argument. +bool checkEntry; // Boolean to check if a Process entry must continue or a condition fails. +bool isDone, lastIsDone; // Variables for ISDONE/ISNOTDONE condacts. +bool lastPicShow; // True if last location picture was drawed. +uint8_t lastPicLocation; // Location number of last pictured drawed. const CONDACT_LIST condactList[] = { - { do_AT, 0 }, - { do_NOTAT, 0 }, - { do_ATGT, 0 }, - { do_ATLT, 0 }, - { do_PRESENT, 0 }, - { do_ABSENT, 0 }, - { do_WORN, 0 }, - { do_NOTWORN, 0 }, - { do_CARRIED, 0 }, - { do_NOTCARR, 0 }, - { do_CHANCE, 0 }, - { do_ZERO, 0 }, - { do_NOTZERO, 0 }, - { do_EQ, 0 }, - { do_GT, 0 }, - { do_LT, 0 }, - { do_ADJECT1, 0 }, - { do_ADVERB, 0 }, - { do_SFX, 1 }, - { do_DESC, 1 }, - { do_QUIT, 0 }, - { do_END, 1 }, - { do_DONE, 1 }, - { do_OK, 1 }, - { do_ANYKEY, 1 }, - { do_SAVE, 1 }, - { do_LOAD, 1 }, - { do_DPRINT, 1 }, - { do_DISPLAY, 1 }, - { do_CLS, 1 }, - { do_DROPALL, 1 }, - { do_AUTOG, 1 }, - { do_AUTOD, 1 }, - { do_AUTOW, 1 }, - { do_AUTOR, 1 }, - { do_PAUSE, 1 }, - { do_SYNONYM, 1 }, - { do_GOTO, 1 }, - { do_MESSAGE, 1 }, - { do_REMOVE, 1 }, - { do_GET, 1 }, - { do_DROP, 1 }, - { do_WEAR, 1 }, - { do_DESTROY, 1 }, - { do_CREATE, 1 }, - { do_SWAP, 1 }, - { do_PLACE, 1 }, - { do_SET, 1 }, - { do_CLEAR, 1 }, - { do_PLUS, 1 }, - { do_MINUS, 1 }, - { do_LET, 1 }, - { do_NEWLINE, 1 }, - { do_PRINT, 1 }, - { do_SYSMESS, 1 }, - { do_ISAT, 0 }, - { do_SETCO, 1 }, - { do_SPACE, 1 }, - { do_HASAT, 0 }, - { do_HASNAT, 0 }, - { do_LISTOBJ, 1 }, - { do_EXTERN, 1 }, - { do_RAMSAVE, 1 }, - { do_RAMLOAD, 1 }, - { do_BEEP, 1 }, - { do_PAPER, 1 }, - { do_INK, 1 }, - { do_BORDER, 1 }, - { do_PREP, 0 }, - { do_NOUN2, 0 }, - { do_ADJECT2, 0 }, - { do_ADD, 1 }, - { do_SUB, 1 }, - { do_PARSE, 1 }, - { do_LISTAT, 1 }, - { do_PROCESS, 1 }, - { do_SAME, 0 }, - { do_MES, 1 }, - { do_WINDOW, 1 }, - { do_NOTEQ, 0 }, - { do_NOTSAME, 0 }, - { do_MODE, 1 }, - { do_WINAT, 1 }, - { do_TIME, 1 }, - { do_PICTURE, 1 }, - { do_DOALL, 1 }, - { do_MOUSE, 1 }, - { do_GFX, 1 }, - { do_ISNOTAT, 0 }, - { do_WEIGH, 1 }, - { do_PUTIN, 1 }, - { do_TAKEOUT, 1 }, - { do_NEWTEXT, 1 }, - { do_ABILITY, 1 }, - { do_WEIGHT, 1 }, - { do_RANDOM, 1 }, - { do_INPUT, 1 }, - { do_SAVEAT, 1 }, - { do_BACKAT, 1 }, - { do_PRINTAT, 1 }, - { do_WHATO, 1 }, - { do_CALL, 1 }, - { do_PUTO, 1 }, - { do_NOTDONE, 0 }, - { do_AUTOP, 1 }, - { do_AUTOT, 1 }, - { do_MOVE, 1 }, - { do_WINSIZE, 1 }, - { do_REDO, 1 }, - { do_CENTRE, 1 }, - { do_EXIT, 1 }, - { do_INKEY, 0 }, - { do_BIGGER, 0 }, - { do_SMALLER, 0 }, - { do_ISDONE, 0 }, - { do_ISNDONE, 0 }, - { do_SKIP, 1 }, - { do_RESTART, 1 }, - { do_TAB, 1 }, - { do_COPYOF, 1 }, - { do_NOT_USED, 1 }, - { do_COPYOO, 1 }, - { do_NOT_USED, 1 }, - { do_COPYFO, 1 }, - { do_NOT_USED, 1 }, - { do_COPYFF, 1 }, - { do_COPYBF, 1 }, - { do_RESET, 1 }, + { do_AT, 0 }, { do_NOTAT, 0 }, { do_ATGT, 0 }, { do_ATLT, 0 }, { do_PRESENT, 0 }, // 0-4 + { do_ABSENT, 0 }, { do_WORN, 0 }, { do_NOTWORN, 0 }, { do_CARRIED, 0 }, { do_NOTCARR, 0 }, // 5-9 + { do_CHANCE, 0 }, { do_ZERO, 0 }, { do_NOTZERO, 0 }, { do_EQ, 0 }, { do_GT, 0 }, // 10-14 + { do_LT, 0 }, { do_ADJECT1, 0 }, { do_ADVERB, 0 }, { do_SFX, 1 }, { do_DESC, 1 }, // 15-19 + { do_QUIT, 0 }, { do_END, 1 }, { do_DONE, 1 }, { do_OK, 1 }, { do_ANYKEY, 1 }, // 20-24 + { do_SAVE, 1 }, { do_LOAD, 1 }, { do_DPRINT, 1 }, { do_DISPLAY, 1 }, { do_CLS, 1 }, // 25-29 + { do_DROPALL, 1 }, { do_AUTOG, 1 }, { do_AUTOD, 1 }, { do_AUTOW, 1 }, { do_AUTOR, 1 }, // 30-34 + { do_PAUSE, 1 }, { do_SYNONYM, 1 }, { do_GOTO, 1 }, { do_MESSAGE, 1 }, { do_REMOVE, 1 }, // 35-39 + { do_GET, 1 }, { do_DROP, 1 }, { do_WEAR, 1 }, { do_DESTROY, 1 }, { do_CREATE, 1 }, // 40-44 + { do_SWAP, 1 }, { do_PLACE, 1 }, { do_SET, 1 }, { do_CLEAR, 1 }, { do_PLUS, 1 }, // 45-49 + { do_MINUS, 1 }, { do_LET, 1 }, { do_NEWLINE, 1 }, { do_PRINT, 1 }, { do_SYSMESS, 1 }, // 50-54 + { do_ISAT, 0 }, { do_SETCO, 1 }, { do_SPACE, 1 }, { do_HASAT, 0 }, { do_HASNAT, 0 }, // 55-59 + { do_LISTOBJ, 1 }, { do_EXTERN, 1 }, { do_RAMSAVE, 1 }, { do_RAMLOAD, 1 }, { do_BEEP, 1 }, // 60-64 + { do_PAPER, 1 }, { do_INK, 1 }, { do_BORDER, 1 }, { do_PREP, 0 }, { do_NOUN2, 0 }, // 65-69 + { do_ADJECT2, 0 }, { do_ADD, 1 }, { do_SUB, 1 }, { do_PARSE, 1 }, { do_LISTAT, 1 }, // 70-74 + { do_PROCESS, 1 }, { do_SAME, 0 }, { do_MES, 1 }, { do_WINDOW, 1 }, { do_NOTEQ, 0 }, // 75-79 + { do_NOTSAME, 0 }, { do_MODE, 1 }, { do_WINAT, 1 }, { do_TIME, 1 }, { do_PICTURE, 1 }, // 80-84 + { do_DOALL, 1 }, { do_MOUSE, 1 }, { do_GFX, 1 }, { do_ISNOTAT, 0 }, { do_WEIGH, 1 }, // 85-89 + { do_PUTIN, 1 }, { do_TAKEOUT, 1 }, { do_NEWTEXT, 1 }, { do_ABILITY, 1 }, { do_WEIGHT, 1 }, // 90-94 + { do_RANDOM, 1 }, { do_INPUT, 1 }, { do_SAVEAT, 1 }, { do_BACKAT, 1 }, { do_PRINTAT, 1 }, // 95-99 + { do_WHATO, 1 }, { do_CALL, 1 }, { do_PUTO, 1 }, { do_NOTDONE, 0 }, { do_AUTOP, 1 }, // 100-104 + { do_AUTOT, 1 }, { do_MOVE, 1 }, { do_WINSIZE, 1 }, { do_REDO, 1 }, { do_CENTRE, 1 }, // 105-109 + { do_EXIT, 1 }, { do_INKEY, 0 }, { do_BIGGER, 0 }, { do_SMALLER, 0 }, { do_ISDONE, 0 }, // 110-114 + { do_ISNDONE, 0 }, { do_SKIP, 1 }, { do_RESTART, 1 }, { do_TAB, 1 }, { do_COPYOF, 1 }, // 115-119 + { do_NOT_USED, 1 }, { do_COPYOO, 1 }, { do_NOT_USED, 1 }, { do_COPYFO, 1 }, { do_NOT_USED, 1 }, // 120-124 + { do_COPYFF, 1 }, { do_COPYBF, 1 }, { do_RESET, 1 }, // 125-127 }; #ifdef VERBOSE +// CONDACT Name + Num.arguments to show in VERBOSE mode const CondactArgs const CONDACTS[128] = { - { "AT", 1 }, - { "NOTAT", 1 }, - { "ATGT", 1 }, - { "ATLT", 1 }, - { "PRESENT", 1 }, - { "ABSENT", 1 }, - { "WORN", 1 }, - { "NOTWORN", 1 }, - { "CARRIED", 1 }, - { "NOTCARR", 1 }, - { "CHANCE", 1 }, - { "ZERO", 1 }, - { "NOTZERO", 1 }, - { "EQ", 2 }, - { "GT", 2 }, - { "LT", 2 }, - { "ADJECT1", 1 }, - { "ADVERB", 1 }, - { "SFX", 2 }, - { "DESC", 1 }, - { "QUIT", 0 }, - { "END", 0 }, - { "DONE", 0 }, - { "OK", 0 }, - { "ANYKEY", 0 }, - { "SAVE", 1 }, - { "LOAD", 1 }, - { "DPRINT", 1 }, - { "DISPLAY", 1 }, - { "CLS", 0 }, - { "DROPALL", 0 }, - { "AUTOG", 0 }, - { "AUTOD", 0 }, - { "AUTOW", 0 }, - { "AUTOR", 0 }, - { "PAUSE", 1 }, - { "SYNONYM", 2 }, - { "GOTO", 1 }, - { "MESSAGE", 1 }, - { "REMOVE", 1 }, - { "GET", 1 }, - { "DROP", 1 }, - { "WEAR", 1 }, - { "DESTROY", 1 }, - { "CREATE", 1 }, - { "SWAP", 2 }, - { "PLACE", 2 }, - { "SET", 1 }, - { "CLEAR", 1 }, - { "PLUS", 2 }, - { "MINUS", 2 }, - { "LET", 2 }, - { "NEWLINE", 0 }, - { "PRINT", 1 }, - { "SYSMESS", 1 }, - { "ISAT", 2 }, - { "SETCO", 1 }, - { "SPACE", 0 }, - { "HASAT", 1 }, - { "HASNAT", 1 }, - { "LISTOBJ", 0 }, - { "EXTERN", 2 }, - { "RAMSAVE", 0 }, - { "RAMLOAD", 1 }, - { "BEEP", 2 }, - { "PAPER", 1 }, - { "INK", 1 }, - { "BORDER", 1 }, - { "PREP", 1 }, - { "NOUN2", 1 }, - { "ADJECT2", 1 }, - { "ADD", 2 }, - { "SUB", 2 }, - { "PARSE", 1 }, - { "LISTAT", 1 }, - { "PROCESS", 1 }, - { "SAME", 2 }, - { "MES", 1 }, - { "WINDOW", 1 }, - { "NOTEQ", 2 }, - { "NOTSAME", 2 }, - { "MODE", 1 }, - { "WINAT", 2 }, - { "TIME", 2 }, - { "PICTURE", 1 }, - { "DOALL", 1 }, - { "MOUSE", 1 }, - { "GFX", 2 }, - { "ISNOTAT", 2 }, - { "WEIGH", 2 }, - { "PUTIN", 2 }, - { "TAKEOUT", 2 }, - { "NEWTEXT", 0 }, - { "ABILITY", 2 }, - { "WEIGHT", 1 }, - { "RANDOM", 1 }, - { "INPUT", 2 }, - { "SAVEAT", 0 }, - { "BACKAT", 0 }, - { "PRINTAT", 2 }, - { "WHATO", 0 }, - { "CALL", 1 }, - { "PUTO", 1 }, - { "NOTDONE", 0 }, - { "AUTOP", 1 }, - { "AUTOT", 1 }, - { "MOVE", 1 }, - { "WINSIZE", 2 }, - { "REDO", 0 }, - { "CENTRE", 0 }, - { "EXIT", 1 }, - { "INKEY", 0 }, - { "BIGGER", 2 }, - { "SMALLER", 2 }, - { "ISDONE", 0 }, - { "ISNDONE", 0 }, - { "SKIP", 1 }, - { "RESTART", 0 }, - { "TAB", 1 }, - { "COPYOF", 2 }, - { "NOT_USED1", 0 }, - { "COPYOO", 2 }, - { "NOT_USED2", 0 }, - { "COPYFO", 2 }, - { "NOT_USED3", 0 }, - { "COPYFF", 2 }, - { "COPYBF", 2 }, - { "RESET", 0 } + { "AT", 1 }, { "NOTAT", 1 }, { "ATGT", 1 }, { "ATLT", 1 }, { "PRESENT", 1 }, { "ABSENT", 1 }, + { "WORN", 1 }, { "NOTWORN", 1 }, { "CARRIED", 1 }, { "NOTCARR", 1 }, { "CHANCE", 1 }, { "ZERO", 1 }, + { "NOTZERO", 1 }, { "EQ", 2 }, { "GT", 2 }, { "LT", 2 }, { "ADJECT1", 1 }, { "ADVERB", 1 }, + { "SFX", 2 }, { "DESC", 1 }, { "QUIT", 0 }, { "END", 0 }, { "DONE", 0 }, { "OK", 0 }, + { "ANYKEY", 0 }, { "SAVE", 1 }, { "LOAD", 1 }, { "DPRINT", 1 }, { "DISPLAY", 1 }, { "CLS", 0 }, + { "DROPALL", 0 }, { "AUTOG", 0 }, { "AUTOD", 0 }, { "AUTOW", 0 }, { "AUTOR", 0 }, { "PAUSE", 1 }, + { "SYNONYM", 2 }, { "GOTO", 1 }, { "MESSAGE", 1 }, { "REMOVE", 1 }, { "GET", 1 }, { "DROP", 1 }, + { "WEAR", 1 }, { "DESTROY", 1 }, { "CREATE", 1 }, { "SWAP", 2 }, { "PLACE", 2 }, { "SET", 1 }, + { "CLEAR", 1 }, { "PLUS", 2 }, { "MINUS", 2 }, { "LET", 2 }, { "NEWLINE", 0 }, { "PRINT", 1 }, + { "SYSMESS", 1 }, { "ISAT", 2 }, { "SETCO", 1 }, { "SPACE", 0 }, { "HASAT", 1 }, { "HASNAT", 1 }, + { "LISTOBJ", 0 }, { "EXTERN", 2 }, { "RAMSAVE", 0 }, { "RAMLOAD", 1 }, { "BEEP", 2 }, { "PAPER", 1 }, + { "INK", 1 }, { "BORDER", 1 }, { "PREP", 1 }, { "NOUN2", 1 }, { "ADJECT2", 1 }, { "ADD", 2 }, + { "SUB", 2 }, { "PARSE", 1 }, { "LISTAT", 1 }, { "PROCESS", 1 }, { "SAME", 2 }, { "MES", 1 }, + { "WINDOW", 1 }, { "NOTEQ", 2 }, { "NOTSAME", 2 }, { "MODE", 1 }, { "WINAT", 2 }, { "TIME", 2 }, + { "PICTURE", 1 }, { "DOALL", 1 }, { "MOUSE", 1 }, { "GFX", 2 }, { "ISNOTAT", 2 }, { "WEIGH", 2 }, + { "PUTIN", 2 }, { "TAKEOUT", 2 }, { "NEWTEXT", 0 }, { "ABILITY", 2 }, { "WEIGHT", 1 }, { "RANDOM", 1 }, + { "INPUT", 2 }, { "SAVEAT", 0 }, { "BACKAT", 0 }, { "PRINTAT", 2 }, { "WHATO", 0 }, { "CALL", 1 }, + { "PUTO", 1 }, { "NOTDONE", 0 }, { "AUTOP", 1 }, { "AUTOT", 1 }, { "MOVE", 1 }, { "WINSIZE", 2 }, + { "REDO", 0 }, { "CENTRE", 0 }, { "EXIT", 1 }, { "INKEY", 0 }, { "BIGGER", 2 }, { "SMALLER", 2 }, + { "ISDONE", 0 }, { "ISNDONE", 0 }, { "SKIP", 1 }, { "RESTART", 0 }, { "TAB", 1 }, { "COPYOF", 2 }, + { "NOT_USED1", 0 }, { "COPYOO", 2 }, { "NOT_USED2", 0 }, { "COPYFO", 2 }, { "NOT_USED3", 0 }, { "COPYFF", 2 }, + { "COPYBF", 2 }, { "RESET", 0 } }; #endif //VERBOSE @@ -422,17 +216,17 @@ printf(" ======================> VERB+NOUN OK\n"); // INPUT // // TODO Low Priority: -// CALL +// GFX //TODO implement MSX2 compliant routines // SAVE //TODO get filename from player // LOAD //TODO get filename from player // PARSE //TODO PARSE 1 // GET //TODO cancel DOALL loop // TAKEOUT //TODO cancel DOALL loop // RESTART //TODO cancel DOALL loop +// CALL // // TODO Undocumented: // SFX //Undocumented -// GFX //Undocumented // MOUSE //Undocumented //=============================================== @@ -687,7 +481,7 @@ void do_SMALLER() // flagno1 flagno2 #ifndef DISABLE_ADJECT1 void do_ADJECT1() { - checkEntry = (flags[fAdject1] == *pPROC++); + checkEntry = (flags[fAdject1] == getValueOrIndirection()); } #endif @@ -697,7 +491,7 @@ void do_ADJECT1() #ifndef DISABLE_ADVERB void do_ADVERB() { - checkEntry = (flags[fAdverb] == *pPROC++); + checkEntry = (flags[fAdverb] == getValueOrIndirection()); } #endif @@ -707,7 +501,7 @@ void do_ADVERB() #ifndef DISABLE_PREP void do_PREP() { - checkEntry = (flags[fPrep] == *pPROC++); + checkEntry = (flags[fPrep] == getValueOrIndirection()); } #endif @@ -717,7 +511,7 @@ void do_PREP() #ifndef DISABLE_NOUN2 void do_NOUN2() { - checkEntry = (flags[fNoun2] == *pPROC++); + checkEntry = (flags[fNoun2] == getValueOrIndirection()); } #endif @@ -727,7 +521,7 @@ void do_NOUN2() #ifndef DISABLE_ADJECT2 void do_ADJECT2() { - checkEntry = (flags[fAdject2] == *pPROC++); + checkEntry = (flags[fAdject2] == getValueOrIndirection()); } #endif @@ -1700,7 +1494,7 @@ void do_COPYBF() // flagno1 flagno2 #ifndef DISABLE_RANDOM void do_RANDOM() // flagno { - flags[*pPROC++] = (rand()%100)+1; + flags[getValueOrIndirection()] = (rand()%100)+1; } #endif @@ -1806,7 +1600,8 @@ void do_MODE() { // option 4 - Reprint current text of input after a timeout. */ #ifndef DISABLE_INPUT void do_INPUT() { // stream option - printf("===== INPUT not implemented\n"); pPROC+=2; + //TODO: INPUT not implemented yet + do_NOT_USED(); } #endif @@ -1954,11 +1749,15 @@ void do_INK() // colour // ============================================================================= -/* Set border colour acording to the lookup table given in the graphics editors */ +/* Set border colour acording to the lookup table given in the graphics editors. + + MSX2 note: For Screen 8/12 the color value is using a standard EGA palette + unless you use the GFX condact to change it. But Screen 5/6/7 are + paletted modes and must use the current Picture palette. */ #ifndef DISABLE_BORDER void do_BORDER() // colour { - do_PAPER(); + gfxSetBorderCol(getValueOrIndirection()); } #endif @@ -1969,7 +1768,7 @@ void do_BORDER() // colour #ifndef DISABLE_PRINTAT void do_PRINTAT() // line col { - cw->cursorY = *pPROC++; + cw->cursorY = getValueOrIndirection(); cw->cursorX = *pPROC++; } #endif @@ -1980,7 +1779,7 @@ void do_PRINTAT() // line col #ifndef DISABLE_TAB void do_TAB() // col { - cw->cursorX = *pPROC++; + cw->cursorX = getValueOrIndirection(); } #endif @@ -2103,7 +1902,7 @@ void do_LISTOBJ() { #ifndef DISABLE_LISTAT void do_LISTAT() // locno+ { - uint8_t loc = *pPROC++; + uint8_t loc = getValueOrIndirection(); flags[fOFlags] &= (F53_LISTED ^ 255); for (int i=0; inumObjDsc; i++) { if (objects[i].location == loc) { @@ -2248,8 +2047,8 @@ void do_PARSE() if (getValueOrIndirection()==0) { checkEntry = !getLogicalSentence(); } else { - //TODO PARSE 1 not implemented - printf("===== 'PARSE 1' not implemented\n"); + //TODO: PARSE 1 not implemented + do_NOT_USED(); } } #endif @@ -2343,7 +2142,8 @@ void do_REDO() be included in a DOALL. */ #ifndef DISABLE_DOALL void do_DOALL() { // locno+ - printf("===== DOALL not implemented\n"); pPROC++; + //TODO: DOALL not implemented yet + do_NOT_USED(); } #endif @@ -2355,7 +2155,7 @@ void do_DOALL() { // locno+ #ifndef DISABLE_SKIP void do_SKIP() // distance { - stepPROCEntryCondacts(*pPROC++); + stepPROCEntryCondacts(getValueOrIndirection()); } #endif @@ -2511,13 +2311,10 @@ void do_EXTERN() // value routine /* Allows 'address' in memory (or in the database segment for 16bit) to be executed. See the extern secion for more details. */ #ifndef DISABLE_CALL -void do_CALL() // address +void do_CALL() // address(dword) { - //TODOCALL not implemented - #ifdef DEBUG - printf("===== CALL not implemented\n"); - #endif - pPROC+=2; + //TODO: CALL not implemented yet + do_NOT_USED(); } #endif @@ -2531,11 +2328,8 @@ void do_CALL() // address #ifndef DISABLE_SFX void do_SFX() // value1 value2 { - //TODO SFX not implemented - #ifdef DEBUG - printf("===== SFX not implemented\n"); - #endif - pPROC+=2; + //TODO: SFX not implemented yet + do_NOT_USED(); } #endif @@ -2651,10 +2445,8 @@ void do_DISPLAY() // value mouse handler on the IBM. */ #ifndef DISABLE_MOUSE void do_MOUSE() { // option - //TODO MOUSE not implemented - #ifdef DEBUG - printf("===== MOUSE not implemented\n"); - #endif + //TODO: MOUSE not implemented yet + do_NOT_USED(); } #endif diff --git a/src/daad_platform_msx2.c b/src/daad_platform_msx2.c index f535121..12ab9a7 100644 --- a/src/daad_platform_msx2.c +++ b/src/daad_platform_msx2.c @@ -13,12 +13,15 @@ #include #include #include -#include #include "daad_condacts.h" #include "daad_platform_msx2.h" #include "daad.h" #include "vdp.h" #include "dos.h" +#if defined(DEBUG) || defined(VERBOSE) || defined(VERBOSE2) + #include +#endif + //========================================================= // Constants @@ -52,6 +55,7 @@ const char CHARS_MSX[] = "\xA6\xAD\xA8\xAE\xAF\xA0\x82\xA1\xA2\xA3\xA4\xA5\x87\ const char FUNC_KEYS[5][8] = { "examine ", "get \0 ", "drop \0 ", "search \0", "throw \0 " }; #endif + //========================================================= // Variables //========================================================= @@ -66,6 +70,7 @@ uint32_t posVRAM; uint8_t FIRST_RAMSEG[4]; #endif + //========================================================= // SYSTEM FUNCTIONS //========================================================= @@ -111,7 +116,7 @@ bool checkPlatformSystem() */ uint16_t getFreeMemory() { - return ADDR_POINTER_WORD(0x0006)-heap_top+hdr->fileLength; + return ADDR_POINTER_WORD(TPA_LIMIT) - heap_top + hdr->fileLength; } /* @@ -176,77 +181,6 @@ void waitingForInput() { } -//========================================================= -// EXTERNAL TEXTS -//========================================================= - -#ifndef DISABLE_EXTERN -#ifdef RAM_MAPPER - -void loadExtendedTexts(char *filename) -{ - uint16_t toRead = 16384, - size, - fp; - uint8_t page = 0; - - size = filesize(filename); - fp = fopen(filename, O_RDONLY); - - if (fp < 0xff00) { -#ifdef DEBUG - printf("Loading %s (%u bytes): ", filename, size); -#endif - while (size) { - if (size>14)]); - printMsg((char*)(0x8000 + (address & 0x3FFF)), true); - restoreMapperPage2(); - } else - #endif //RAM_MAPPER - { - //Print from file - uint16_t fp = fopen(FILE_XDB, O_RDONLY); - if (fp < 0xff00) { - fseek(fp, address, SEEK_SET); - fread((char*)heap_top, 512, fp); - fclose(fp); - printMsg((char*)heap_top, true); - } - } -} - -#endif //DISABLE_EXTERN //========================================================= // FILESYSTEM @@ -290,9 +224,9 @@ uint16_t loadFile(char *filename, uint8_t *destaddress, uint16_t size) */ void loadFilesBin(int argc, char **argv) { - bool loadingOk; char *aux; - uint16_t size = 0; + size_t size = 0; + // Commandline parameter with new FILES_BIN? if (argc>0) { memcpy(FILES_BIN, argv[0], 13); @@ -311,7 +245,7 @@ void loadFilesBin(int argc, char **argv) //Show LOADING picture memcpy(FILE_IMG, FILE_LOAD, 13); posVRAM = 0; - loadingOk = gfxPictureShow(); + gfxPictureShow(); // Load image FONT (old DMG) to VRAM 2nd page memcpy(FILE_IMG, FILE_FONT, 13); @@ -323,6 +257,7 @@ void loadFilesBin(int argc, char **argv) // Load DDB file size = filesize(FILE_DDB); + if (getFreeMemory() - size < 0) die("Max. DDB size exceeded."); ddb = malloc(size); loadFile(FILE_DDB, ddb, size); @@ -333,10 +268,81 @@ void loadFilesBin(int argc, char **argv) loadExtendedTexts(FILE_XDB); } #endif +} + + +//========================================================= +// EXTERNAL TEXTS +//========================================================= + +#ifndef DISABLE_EXTERN +#ifdef RAM_MAPPER + +void loadExtendedTexts(char *filename) +{ + uint16_t toRead = 16384, + size, + fp; + uint8_t page = 0; + + size = filesize(filename); + fp = fopen(filename, O_RDONLY); -// if (loadingOk) do_INKEY(); + if (fp < 0xff00) { +#ifdef DEBUG + printf("Loading %s (%u bytes): ", filename, size); +#endif + while (size) { + if (size>14)]); + printMsg((char*)(0x8000 + (address & 0x3FFF)), true); + restoreMapperPage2(); + } else + #endif //RAM_MAPPER + { + //Print from file + uint16_t fp = fopen(FILE_XDB, O_RDONLY); + if (fp < 0xff00) { + fseek(fp, address, SEEK_SET); + fread((char*)heap_top, 512, fp); + fclose(fp); + printMsg((char*)heap_top, true); + } + } +} + +#endif //DISABLE_EXTERN + //========================================================= // GRAPHICS (GFX) @@ -571,9 +577,9 @@ void gfxSetPaperCol(uint8_t col) { col; #if SCREEN == 8 - COLOR_PAPER = colorTranslation[col]; + COLOR_PAPER = colorTranslation[col % 16]; #elif SCREEN < 8 - setColorPal(COLOR_PAPER, colorTranslation[col]); + setColorPal(COLOR_PAPER, colorTranslation[col] % 16); #else // No PAPER color change #endif @@ -591,7 +597,7 @@ void gfxSetInkCol(uint8_t col) { col; #if SCREEN == 8 - COLOR_INK = colorTranslation[col]; + COLOR_INK = colorTranslation[col % 16]; #elif SCREEN < 8 setColorPal(COLOR_INK, colorTranslation[col]); #else @@ -602,14 +608,15 @@ void gfxSetInkCol(uint8_t col) /* * Function: gfxSetBorderCol * -------------------------------- - * Set BORDER colour from a EGA like palette. + * Set BORDER colour from a EGA like palette (SCR 8/12), or the current + * Picture palette (SCR 5/6/7). * * @param col EGA color to set. * @return none. */ -inline void gfxSetBorderCol(uint8_t col) +void gfxSetBorderCol(uint8_t col) { - gfxSetPaperCol(col); //TODO revise for real border change code + setBorder(colorTranslation[col % 16]); } /* @@ -777,7 +784,6 @@ bool gfxPictureShow() // SOUND (SFX) //========================================================= - #ifndef DISABLE_BEEP // MSX PSG Tones from https://www.konamiman.com/msx/msx2th/th-5a.txt and upgraded const uint16_t sfxFreqPSG[] = { diff --git a/src/libs/vdp_setborder.s b/src/libs/vdp_setborder.s new file mode 100644 index 0000000..34a23c7 --- /dev/null +++ b/src/libs/vdp_setborder.s @@ -0,0 +1,19 @@ +;=============================================================================== +; In: A Border color +; Out: - +; Chg: A +; +.include "vdp.s" + +_setBorder:: + pop de + pop bc + push bc + push de + ld a,c + +setBorder:: + out (0x99),a + ld a,#0x87 + out (0x99),a + ret