diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gargoyle/detection.cpp | 5 | ||||
-rw-r--r-- | engines/gargoyle/gargoyle.cpp | 11 | ||||
-rw-r--r-- | engines/gargoyle/gargoyle.h | 13 | ||||
-rw-r--r-- | engines/gargoyle/glk/glk.cpp (renamed from engines/gargoyle/glk.cpp) | 158 | ||||
-rw-r--r-- | engines/gargoyle/glk/glk.h (renamed from engines/gargoyle/glk.h) | 249 | ||||
-rw-r--r-- | engines/gargoyle/glk/glk_types.h | 272 | ||||
-rw-r--r-- | engines/gargoyle/interpreter.h | 4 | ||||
-rw-r--r-- | engines/gargoyle/interps/scott/scott.cpp (renamed from engines/gargoyle/scott/scott.cpp) | 13 | ||||
-rw-r--r-- | engines/gargoyle/interps/scott/scott.h (renamed from engines/gargoyle/scott/scott.h) | 7 | ||||
-rw-r--r-- | engines/gargoyle/module.mk | 4 |
10 files changed, 486 insertions, 250 deletions
diff --git a/engines/gargoyle/detection.cpp b/engines/gargoyle/detection.cpp index 94fb90f3c4..f10a70bdc6 100644 --- a/engines/gargoyle/detection.cpp +++ b/engines/gargoyle/detection.cpp @@ -37,6 +37,7 @@ namespace Gargoyle { struct GargoyleGameDescription { ADGameDescription desc; + InterpreterType interpType; }; uint32 GargoyleEngine::getFeatures() const { @@ -51,6 +52,10 @@ Common::Language GargoyleEngine::getLanguage() const { return _gameDescription->desc.language; } +InterpreterType GargoyleEngine::getInterpreterType() const { + return _gameDescription->interpType; +} + } // End of namespace Gargoyle static const PlainGameDescriptor GargoyleGames[] = { diff --git a/engines/gargoyle/gargoyle.cpp b/engines/gargoyle/gargoyle.cpp index 731e38d4a7..b46f2fc377 100644 --- a/engines/gargoyle/gargoyle.cpp +++ b/engines/gargoyle/gargoyle.cpp @@ -28,6 +28,7 @@ #include "graphics/scaler.h" #include "graphics/thumbnail.h" #include "gargoyle/gargoyle.h" +#include "gargoyle/interps/scott/scott.h" namespace Gargoyle { @@ -36,6 +37,7 @@ GargoyleEngine::GargoyleEngine(OSystem *syst, const GargoyleGameDescription *gam } GargoyleEngine::~GargoyleEngine() { + delete _interpreter; } void GargoyleEngine::initialize() { @@ -46,10 +48,19 @@ void GargoyleEngine::initialize() { DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling"); initGraphics(640, 480, false); + + switch (getInterpreterType()) { + case INTERPRETER_SCOTT: + _interpreter = new Scott::Scott(); + break; + default: + error("Unknown interpreter type"); + } } Common::Error GargoyleEngine::run() { initialize(); + _interpreter->execute(); return Common::kNoError; } diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h index c43b5fe6c5..375d9ad0d7 100644 --- a/engines/gargoyle/gargoyle.h +++ b/engines/gargoyle/gargoyle.h @@ -28,13 +28,14 @@ #include "common/serializer.h" #include "engines/advancedDetector.h" #include "engines/engine.h" -#include "graphics/screen.h" -#include "gargoyle/events.h" -#include "gargoyle/glk.h" -#include "gargoyle/scott/scott.h" +#include "gargoyle/interpreter.h" namespace Gargoyle { +enum InterpreterType { + INTERPRETER_SCOTT +}; + enum GargoyleDebugChannels { kDebugCore = 1 << 0, kDebugScripts = 1 << 1, @@ -42,6 +43,7 @@ enum GargoyleDebugChannels { kDebugSound = 1 << 3 }; + #define GARGOYLE_SAVEGAME_VERSION 1 struct GargoyleGameDescription; @@ -64,8 +66,6 @@ private: private: const GargoyleGameDescription *_gameDescription; int _loadSaveSlot; - Graphics::Screen _screen; - Events _events; Interpreter *_interpreter; // Engine APIs @@ -78,6 +78,7 @@ public: uint32 getFeatures() const; bool isDemo() const; Common::Language getLanguage() const; + InterpreterType getInterpreterType() const; }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/glk.cpp b/engines/gargoyle/glk/glk.cpp index 4ea4ce47cd..26755a1d37 100644 --- a/engines/gargoyle/glk.cpp +++ b/engines/gargoyle/glk/glk.cpp @@ -20,246 +20,326 @@ * */ -#include "gargoyle/glk.h" +#include "gargoyle/glk/glk.h" namespace Gargoyle { +Glk::Glk() : Interpreter(), _gliFirstEvent(false) { +} + void Glk::glk_exit(void) { + // TODO } void Glk::glk_set_interrupt_handler(void(*func)(void)) { + // This library doesn't handle interrupts. } void Glk::glk_tick(void) { + // TODO } glui32 Glk::glk_gestalt(glui32 sel, glui32 val) { + // TODO return 0; } glui32 Glk::glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen) { + // TODO return 0; } unsigned char Glk::glk_char_to_lower(unsigned char ch) { + // TODO return '\0'; } unsigned char Glk::glk_char_to_upper(unsigned char ch) { + // TODO return '\0'; } winid_t Glk::glk_window_get_root(void) { + // TODO return nullptr; } winid_t Glk::glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, glui32 rock) { + // TODO return nullptr; } void Glk::glk_window_close(winid_t win, stream_result_t *result) { + // TODO } void Glk::glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) { + // TODO } void Glk::glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keywin) { + // TODO } void Glk::glk_window_get_arrangement(winid_t win, glui32 *methodptr, glui32 *sizeptr, winid_t *keywinptr) { + // TODO } winid_t Glk::glk_window_iterate(winid_t win, glui32 *rockptr) { + // TODO return nullptr; } glui32 Glk::glk_window_get_rock(winid_t win) { + // TODO return 0; } glui32 Glk::glk_window_get_type(winid_t win) { + // TODO return 0; } winid_t Glk::glk_window_get_parent(winid_t win) { + // TODO return nullptr; } winid_t Glk::glk_window_get_sibling(winid_t win) { + // TODO return nullptr; } void Glk::glk_window_clear(winid_t win) { + // TODO } void Glk::glk_window_move_cursor(winid_t win, glui32 xpos, glui32 ypos) { + // TODO } strid_t Glk::glk_window_get_stream(winid_t win) { + // TODO return nullptr; } void Glk::glk_window_set_echo_stream(winid_t win, strid_t str) { + // TODO } strid_t Glk::glk_window_get_echo_stream(winid_t win) { + // TODO return nullptr; } void Glk::glk_set_window(winid_t win) { + // TODO } strid_t Glk::glk_stream_open_file(frefid_t fileref, glui32 fmode, glui32 rock) { + // TODO return nullptr; } strid_t Glk::glk_stream_open_memory(char *buf, glui32 buflen, glui32 fmode, glui32 rock) { + // TODO return nullptr; } void Glk::glk_stream_close(strid_t str, stream_result_t *result) { + // TODO } strid_t Glk::glk_stream_iterate(strid_t str, glui32 *rockptr) { + // TODO return nullptr; } glui32 Glk::glk_stream_get_rock(strid_t str) { + // TODO return 0; } void Glk::glk_stream_set_position(strid_t str, glsi32 pos, glui32 seekmode) { + // TODO } glui32 Glk::glk_stream_get_position(strid_t str) { + // TODO return 0; } void Glk::glk_stream_set_current(strid_t str) { + // TODO } strid_t Glk::glk_stream_get_current(void) { + // TODO return nullptr; } void Glk::glk_put_char(unsigned char ch) { + // TODO } void Glk::glk_put_char_stream(strid_t str, unsigned char ch) { + // TODO } void Glk::glk_put_string(char *s) { + // TODO } void Glk::glk_put_string_stream(strid_t str, char *s) { + // TODO } void Glk::glk_put_buffer(char *buf, glui32 len) { + // TODO } void Glk::glk_put_buffer_stream(strid_t str, char *buf, glui32 len) { + // TODO } void Glk::glk_set_style(glui32 styl) { + // TODO } void Glk::glk_set_style_stream(strid_t str, glui32 styl) { + // TODO } glsi32 Glk::glk_get_char_stream(strid_t str) { + // TODO return 0; } glui32 Glk::glk_get_line_stream(strid_t str, char *buf, glui32 len) { + // TODO return 0; } glui32 Glk::glk_get_buffer_stream(strid_t str, char *buf, glui32 len) { + // TODO return 0; } void Glk::glk_stylehint_set(glui32 wintype, glui32 styl, glui32 hint, glsi32 val) { + // TODO } void Glk::glk_stylehint_clear(glui32 wintype, glui32 styl, glui32 hint) { + // TODO } glui32 Glk::glk_style_distinguish(winid_t win, glui32 styl1, glui32 styl2) { + // TODO return 0; } glui32 Glk::glk_style_measure(winid_t win, glui32 styl, glui32 hint, glui32 *result) { + // TODO return 0; } frefid_t Glk::glk_fileref_create_temp(glui32 usage, glui32 rock) { + // TODO return nullptr; } frefid_t Glk::glk_fileref_create_by_name(glui32 usage, char *name, glui32 rock) { + // TODO return nullptr; } frefid_t Glk::glk_fileref_create_by_prompt(glui32 usage, glui32 fmode, glui32 rock) { + // TODO return nullptr; } frefid_t Glk::glk_fileref_create_from_fileref(glui32 usage, frefid_t fref, glui32 rock) { + // TODO return nullptr; } void Glk::glk_fileref_destroy(frefid_t fref) { + // TODO } frefid_t Glk::glk_fileref_iterate(frefid_t fref, glui32 *rockptr) { + // TODO return nullptr; } glui32 Glk::glk_fileref_get_rock(frefid_t fref) { + // TODO return 0; } void Glk::glk_fileref_delete_file(frefid_t fref) { + // TODO } glui32 Glk::glk_fileref_does_file_exist(frefid_t fref) { + // TODO return 0; } void Glk::glk_select(event_t *event) { + if (!_gliFirstEvent) { + gliInputGuessFocus(); + _gliFirstEvent = true; + } + + gliSelect(event, false); } void Glk::glk_select_poll(event_t *event) { + if (!_gliFirstEvent) { + gliInputGuessFocus(); + _gliFirstEvent = true; + } + + gliSelect(event, true); } void Glk::glk_request_timer_events(glui32 millisecs) { + // TODO } void Glk::glk_request_line_event(winid_t win, char *buf, glui32 maxlen, glui32 initlen) { + // TODO } void Glk::glk_request_char_event(winid_t win) { + // TODO } void Glk::glk_request_mouse_event(winid_t win) { + // TODO } void Glk::glk_cancel_line_event(winid_t win, event_t *event) { + // TODO } void Glk::glk_cancel_char_event(winid_t win) { + // TODO } void Glk::glk_cancel_mouse_event(winid_t win) { + // TODO } #ifdef GLK_MODULE_LINE_ECHO void Glk::glk_set_echo_line_event(winid_t win, glui32 val) { + // TODO } #endif /* GLK_MODULE_LINE_ECHO */ @@ -267,6 +347,7 @@ void Glk::glk_set_echo_line_event(winid_t win, glui32 val) { #ifdef GLK_MODULE_LINE_TERMINATORS void Glk::glk_set_terminators_line_event(winid_t win, glui32 *keycodes, glui32 count) { + // TODO } #endif /* GLK_MODULE_LINE_TERMINATORS */ @@ -274,62 +355,78 @@ void Glk::glk_set_terminators_line_event(winid_t win, glui32 *keycodes, glui32 c #ifdef GLK_MODULE_UNICODE glui32 Glk::glk_buffer_to_lower_case_uni(glui32 *buf, glui32 len, glui32 numchars) { + // TODO return 0; } glui32 Glk::glk_buffer_to_upper_case_uni(glui32 *buf, glui32 len, glui32 numchars) { + // TODO return 0; } glui32 Glk::glk_buffer_to_title_case_uni(glui32 *buf, glui32 len, glui32 numchars, glui32 lowerrest) { + // TODO return 0; } void Glk::glk_put_char_uni(glui32 ch) { + // TODO } void Glk::glk_put_string_uni(glui32 *s) { + // TODO } void Glk::glk_put_buffer_uni(glui32 *buf, glui32 len) { + // TODO } void Glk::glk_put_char_stream_uni(strid_t str, glui32 ch) { + // TODO } void Glk::glk_put_string_stream_uni(strid_t str, glui32 *s) { + // TODO } void Glk::glk_put_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len) { + // TODO } glsi32 Glk::glk_get_char_stream_uni(strid_t str) { + // TODO return 0; } glui32 Glk::glk_get_buffer_stream_uni(strid_t str, glui32 *buf, glui32 len) { + // TODO return 0; } glui32 Glk::glk_get_line_stream_uni(strid_t str, glui32 *buf, glui32 len) { + // TODO return 0; } strid_t Glk::glk_stream_open_file_uni(frefid_t fileref, glui32 fmode, glui32 rock) { + // TODO return nullptr; } strid_t Glk::glk_stream_open_memory_uni(glui32 *buf, glui32 buflen, glui32 fmode, glui32 rock) { + // TODO return nullptr; } void Glk::glk_request_char_event_uni(winid_t win) { + // TODO } void Glk::glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 maxlen, glui32 initlen) { + // TODO } #endif /* GLK_MODULE_UNICODE */ @@ -338,6 +435,7 @@ void Glk::glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 Glk::glk_buffer_canon_decompose_uni(glui32 *buf, glui32 len, glui32 numchars) { + // TODO return 0; } @@ -350,30 +448,37 @@ glui32 Glk::glk_buffer_canon_normalize_uni(glui32 *buf, glui32 len, glui32 numch #ifdef GLK_MODULE_IMAGE glui32 Glk::glk_image_draw(winid_t win, glui32 image, glsi32 val1, glsi32 val2) { + // TODO return 0; } glui32 Glk::glk_image_draw_scaled(winid_t win, glui32 image, glsi32 val1, glsi32 val2, glui32 width, glui32 height) { + // TODO return 0; } glui32 Glk::glk_image_get_info(glui32 image, glui32 *width, glui32 *height) { + // TODO return 0; } void Glk::glk_window_flow_break(winid_t win) { + // TODO } void Glk::glk_window_erase_rect(winid_t win, glsi32 left, glsi32 top, glui32 width, glui32 height) { + // TODO } void Glk::glk_window_fill_rect(winid_t win, glui32 color, glsi32 left, glsi32 top, glui32 width, glui32 height) { + // TODO } void Glk::glk_window_set_background_color(winid_t win, glui32 color) { + // TODO } #endif /* GLK_MODULE_IMAGE */ @@ -381,56 +486,70 @@ void Glk::glk_window_set_background_color(winid_t win, glui32 color) { #ifdef GLK_MODULE_SOUND schanid_t Glk::glk_schannel_create(glui32 rock) { + // TODO return nullptr; } void Glk::glk_schannel_destroy(schanid_t chan) { + // TODO } schanid_t Glk::glk_schannel_iterate(schanid_t chan, glui32 *rockptr) { + // TODO return nullptr; } glui32 Glk::glk_schannel_get_rock(schanid_t chan) { + // TODO return 0; } glui32 Glk::glk_schannel_play(schanid_t chan, glui32 snd) { + // TODO return 0; } glui32 Glk::glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify) { + // TODO return 0; } void Glk::glk_schannel_stop(schanid_t chan) { + // TODO } void Glk::glk_schannel_set_volume(schanid_t chan, glui32 vol) { + // TODO } void Glk::glk_sound_load_hint(glui32 snd, glui32 flag) { + // TODO } #ifdef GLK_MODULE_SOUND2 schanid_t Glk::glk_schannel_create_ext(glui32 rock, glui32 volume) { + // TODO return nullptr; } glui32 Glk::glk_schannel_play_multi(schanid_t *chanarray, glui32 chancount, glui32 *sndarray, glui32 soundcount, glui32 notify) { + // TODO return 0; } void Glk::glk_schannel_pause(schanid_t chan) { + // TODO } void Glk::glk_schannel_unpause(schanid_t chan) { + // TODO } void Glk::glk_schannel_set_volume_ext(schanid_t chan, glui32 vol, glui32 duration, glui32 notify) { + // TODO } #endif /* GLK_MODULE_SOUND2 */ @@ -439,15 +558,19 @@ void Glk::glk_schannel_set_volume_ext(schanid_t chan, glui32 vol, #ifdef GLK_MODULE_HYPERLINKS void Glk::glk_set_hyperlink(glui32 linkval) { + // TODO } void Glk::glk_set_hyperlink_stream(strid_t str, glui32 linkval) { + // TODO } void Glk::glk_request_hyperlink_event(winid_t win) { + // TODO } void Glk::glk_cancel_hyperlink_event(winid_t win) { + // TODO } #endif /* GLK_MODULE_HYPERLINKS */ @@ -455,35 +578,45 @@ void Glk::glk_cancel_hyperlink_event(winid_t win) { #ifdef GLK_MODULE_DATETIME void Glk::glk_current_time(glktimeval_t *time) { + // TODO } glsi32 Glk::glk_current_simple_time(glui32 factor) { + // TODO return 0; } void Glk::glk_time_to_date_utc(glktimeval_t *time, glkdate_t *date) { + // TODO } void Glk::glk_time_to_date_local(glktimeval_t *time, glkdate_t *date) { + // TODO } void Glk::glk_simple_time_to_date_utc(glsi32 time, glui32 factor, glkdate_t *date) { + // TODO } void Glk::glk_simple_time_to_date_local(glsi32 time, glui32 factor, glkdate_t *date) { + // TODO } void Glk::glk_date_to_time_utc(glkdate_t *date, glktimeval_t *time) { + // TODO } void Glk::glk_date_to_time_local(glkdate_t *date, glktimeval_t *time) { + // TODO } glsi32 Glk::glk_date_to_simple_time_utc(glkdate_t *date, glui32 factor) { + // TODO return 0; } glsi32 Glk::glk_date_to_simple_time_local(glkdate_t *date, glui32 factor) { + // TODO return 0; } @@ -492,42 +625,65 @@ glsi32 Glk::glk_date_to_simple_time_local(glkdate_t *date, glui32 factor) { /* XXX non-official Glk functions that may or may not exist */ char *garglk_fileref_get_name(frefid_t fref) { + // TODO return nullptr; } void Glk::garglk_set_program_name(const char *name) { + // TODO } void Glk::garglk_set_program_info(const char *info) { + // TODO } void Glk::garglk_set_story_name(const char *name) { + // TODO } void Glk::garglk_set_story_title(const char *title) { + // TODO } void Glk::garglk_set_config(const char *name) { + // TODO } /* garglk_unput_string - removes the specified string from the end of the output buffer, if * indeed it is there. */ void Glk::garglk_unput_string(char *str) { + // TODO } void Glk::garglk_unput_string_uni(glui32 *str) { + // TODO } void Glk::garglk_set_zcolors(glui32 fg, glui32 bg) { + // TODO } void Glk::garglk_set_zcolors_stream(strid_t str, glui32 fg, glui32 bg) { + // TODO } void Glk::garglk_set_reversevideo(glui32 reverse) { + // TODO } void Glk::garglk_set_reversevideo_stream(strid_t str, glui32 reverse) { + // TODO +} + +/*--------------------------------------------------------------------------*/ + +void Glk::gliInputGuessFocus() { + // TODO +} + +void Glk::gliSelect(event_t *event, bool polled) { + // TODO + event->type = evtype_Quit; } } // End of namespace Gargoyle diff --git a/engines/gargoyle/glk.h b/engines/gargoyle/glk/glk.h index 2e5637b56e..11c8cba2cf 100644 --- a/engines/gargoyle/glk.h +++ b/engines/gargoyle/glk/glk.h @@ -25,257 +25,28 @@ #include "graphics/managed_surface.h" #include "gargoyle/interpreter.h" +#include "gargoyle/glk/glk_types.h" namespace Gargoyle { -typedef uint32 glui32; -typedef int32 glsi32; - -/** - * These are the compile-time conditionals that reveal various Glk optional modules. - */ -#define GLK_MODULE_LINE_ECHO -#define GLK_MODULE_LINE_TERMINATORS -#define GLK_MODULE_UNICODE -#define GLK_MODULE_UNICODE_NORM -#define GLK_MODULE_IMAGE -#define GLK_MODULE_SOUND -#define GLK_MODULE_SOUND2 -#define GLK_MODULE_HYPERLINKS -#define GLK_MODULE_DATETIME -#define GLK_MODULE_GARGLKTEXT - -/** - * These types are opaque object identifiers. They're pointers to opaque - * C structures, which are defined differently by each library. - */ -typedef struct glk_window_struct *winid_t; -typedef struct glk_stream_struct *strid_t; -typedef struct glk_fileref_struct *frefid_t; -typedef struct glk_schannel_struct *schanid_t; - -enum Gestalt { - gestalt_Version = 0, - gestalt_CharInput = 1, - gestalt_LineInput = 2, - gestalt_CharOutput = 3, - gestalt_CharOutput_CannotPrint = 0, - gestalt_CharOutput_ApproxPrint = 1, - gestalt_CharOutput_ExactPrint = 2, - gestalt_MouseInput = 4, - gestalt_Timer = 5, - gestalt_Graphics = 6, - gestalt_DrawImage = 7, - gestalt_Sound = 8, - gestalt_SoundVolume = 9, - gestalt_SoundNotify = 10, - gestalt_Hyperlinks = 11, - gestalt_HyperlinkInput = 12, - gestalt_SoundMusic = 13, - gestalt_GraphicsTransparency = 14, - gestalt_Unicode = 15, - gestalt_UnicodeNorm = 16, - gestalt_LineInputEcho = 17, - gestalt_LineTerminators = 18, - gestalt_LineTerminatorKey = 19, - gestalt_DateTime = 20, - gestalt_Sound2 = 21, - gestalt_GarglkText = 0x1100, -}; - -enum EvType { - evtype_None = 0, - evtype_Timer = 1, - evtype_CharInput = 2, - evtype_LineInput = 3, - evtype_MouseInput = 4, - evtype_Arrange = 5, - evtype_Redraw = 6, - evtype_SoundNotify = 7, - evtype_Hyperlink = 8, - evtype_VolumeNotify = 9, -}; - -enum Keycode { - keycode_Unknown = 0xffffffffU, - keycode_Left = 0xfffffffeU, - keycode_Right = 0xfffffffdU, - keycode_Up = 0xfffffffcU, - keycode_Down = 0xfffffffbU, - keycode_Return = 0xfffffffaU, - keycode_Delete = 0xfffffff9U, - keycode_Escape = 0xfffffff8U, - keycode_Tab = 0xfffffff7U, - keycode_PageUp = 0xfffffff6U, - keycode_PageDown = 0xfffffff5U, - keycode_Home = 0xfffffff4U, - keycode_End = 0xfffffff3U, - keycode_Func1 = 0xffffffefU, - keycode_Func2 = 0xffffffeeU, - keycode_Func3 = 0xffffffedU, - keycode_Func4 = 0xffffffecU, - keycode_Func5 = 0xffffffebU, - keycode_Func6 = 0xffffffeaU, - keycode_Func7 = 0xffffffe9U, - keycode_Func8 = 0xffffffe8U, - keycode_Func9 = 0xffffffe7U, - keycode_Func10 = 0xffffffe6U, - keycode_Func11 = 0xffffffe5U, - keycode_Func12 = 0xffffffe4U, - - // non standard keycodes - keycode_Erase = 0xffffef7fU, - keycode_MouseWheelUp = 0xffffeffeU, - keycode_MouseWheelDown = 0xffffefffU, - keycode_SkipWordLeft = 0xfffff000U, - keycode_SkipWordRight = 0xfffff001U, - - // The last keycode is always = 0x100000000 - keycode_MAXVAL) - keycode_MAXVAL = 28U -}; - -enum Style { - style_Normal = 0, - style_Emphasized = 1, - style_Preformatted = 2, - style_Header = 3, - style_Subheader = 4, - style_Alert = 5, - style_Note = 6, - style_BlockQuote = 7, - style_Input = 8, - style_User1 = 9, - style_User2 = 10, - style_NUMSTYLES = 11, -}; - -enum WinType { - wintype_AllTypes = 0, - wintype_Pair = 1, - wintype_Blank = 2, - wintype_TextBuffer = 3, - wintype_TextGrid = 4, - wintype_Graphics = 5, -}; - -enum WinMethod { - winmethod_Left = 0x00, - winmethod_Right = 0x01, - winmethod_Above = 0x02, - winmethod_Below = 0x03, - winmethod_DirMask = 0x0f, - - winmethod_Fixed = 0x10, - winmethod_Proportional = 0x20, - winmethod_DivisionMask = 0xf0, - - winmethod_Border = 0x000, - winmethod_NoBorder = 0x100, - winmethod_BorderMask = 0x100, -}; - -enum FileUsage { - fileusage_Data = 0x00, - fileusage_SavedGame = 0x01, - fileusage_Transcript = 0x02, - fileusage_InputRecord = 0x03, - fileusage_TypeMask = 0x0f, - - fileusage_TextMode = 0x100, - fileusage_BinaryMode = 0x000, -}; - -enum FileMode { - filemode_Write = 0x01, - filemode_Read = 0x02, - filemode_ReadWrite = 0x03, - filemode_WriteAppend = 0x05, -}; - -enum SeekMode { - seekmode_Start = 0, - seekmode_Current = 1, - seekmode_End = 2, -}; - -enum StyleHint { - stylehint_Indentation = 0, - stylehint_ParaIndentation = 1, - stylehint_Justification = 2, - stylehint_Size = 3, - stylehint_Weight = 4, - stylehint_Oblique = 5, - stylehint_Proportional = 6, - stylehint_TextColor = 7, - stylehint_BackColor = 8, - stylehint_ReverseColor = 9, - stylehint_NUMHINTS = 10, - - stylehint_just_LeftFlush = 0, - stylehint_just_LeftRight = 1, - stylehint_just_Centered = 2, - stylehint_just_RightFlush = 3, -}; - -#ifdef GLK_MODULE_IMAGE - -enum ImageAlign { - imagealign_InlineUp = 1, - imagealign_InlineDown = 2, - imagealign_InlineCenter = 3, - imagealign_MarginLeft = 4, - imagealign_MarginRight = 5 -}; - -#endif /* GLK_MODULE_IMAGE */ - -struct event_struct { - glui32 type; - winid_t win; - glui32 val1, val2; -}; -typedef event_struct *event_t; - -struct stream_result_struct { - glui32 readcount; - glui32 writecount; -}; -typedef stream_result_struct *stream_result_t; - -#ifdef GLK_MODULE_DATETIME - -struct glktimeval_struct { - glsi32 high_sec; - glui32 low_sec; - glsi32 microsec; -}; -typedef glktimeval_struct *glktimeval_t; - -struct glkdate_struct { - glsi32 year; /* full (four-digit) year */ - glsi32 month; /* 1-12, 1 is January */ - glsi32 day; /* 1-31 */ - glsi32 weekday; /* 0-6, 0 is Sunday */ - glsi32 hour; /* 0-23 */ - glsi32 minute; /* 0-59 */ - glsi32 second; /* 0-59, maybe 60 during a leap second */ - glsi32 microsec; /* 0-999999 */ -}; -typedef glkdate_struct *glkdate_t; - -#endif /* GLK_MODULE_DATETIME */ - /** * Implements the GLK interface */ class Glk : public Interpreter { private: - Graphics::ManagedSurface *_surface; + bool _gliFirstEvent; +private: + /** + * Pick first window which might want input. This is called after every keystroke. + */ + void gliInputGuessFocus(); + + void gliSelect(event_t *event, bool polled); public: /** * Constructor */ - Glk() {} + Glk(); void glk_exit(void); void glk_set_interrupt_handler(void(*func)(void)); diff --git a/engines/gargoyle/glk/glk_types.h b/engines/gargoyle/glk/glk_types.h new file mode 100644 index 0000000000..a8227411df --- /dev/null +++ b/engines/gargoyle/glk/glk_types.h @@ -0,0 +1,272 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GARGOYLE_GLK_TYPES_H +#define GARGOYLE_GLK_TYPES_H + +#include "common/scummsys.h" + +namespace Gargoyle { + +typedef uint32 glui32; +typedef int32 glsi32; + +/** + * These are the compile-time conditionals that reveal various Glk optional modules. + */ +#define GLK_MODULE_LINE_ECHO +#define GLK_MODULE_LINE_TERMINATORS +#define GLK_MODULE_UNICODE +#define GLK_MODULE_UNICODE_NORM +#define GLK_MODULE_IMAGE +#define GLK_MODULE_SOUND +#define GLK_MODULE_SOUND2 +#define GLK_MODULE_HYPERLINKS +#define GLK_MODULE_DATETIME +#define GLK_MODULE_GARGLKTEXT + +/** + * These types are opaque object identifiers. They're pointers to opaque + * C structures, which are defined differently by each library. + */ +typedef struct glk_window_struct *winid_t; +typedef struct glk_stream_struct *strid_t; +typedef struct glk_fileref_struct *frefid_t; +typedef struct glk_schannel_struct *schanid_t; + +enum Gestalt { + gestalt_Version = 0, + gestalt_CharInput = 1, + gestalt_LineInput = 2, + gestalt_CharOutput = 3, + gestalt_CharOutput_CannotPrint = 0, + gestalt_CharOutput_ApproxPrint = 1, + gestalt_CharOutput_ExactPrint = 2, + gestalt_MouseInput = 4, + gestalt_Timer = 5, + gestalt_Graphics = 6, + gestalt_DrawImage = 7, + gestalt_Sound = 8, + gestalt_SoundVolume = 9, + gestalt_SoundNotify = 10, + gestalt_Hyperlinks = 11, + gestalt_HyperlinkInput = 12, + gestalt_SoundMusic = 13, + gestalt_GraphicsTransparency = 14, + gestalt_Unicode = 15, + gestalt_UnicodeNorm = 16, + gestalt_LineInputEcho = 17, + gestalt_LineTerminators = 18, + gestalt_LineTerminatorKey = 19, + gestalt_DateTime = 20, + gestalt_Sound2 = 21, + gestalt_GarglkText = 0x1100, +}; + +enum EvType { + evtype_None = 0, + evtype_Timer = 1, + evtype_CharInput = 2, + evtype_LineInput = 3, + evtype_MouseInput = 4, + evtype_Arrange = 5, + evtype_Redraw = 6, + evtype_SoundNotify = 7, + evtype_Hyperlink = 8, + evtype_VolumeNotify = 9, + + // ScummVM custom events + evtype_Quit = 99 +}; + +enum Keycode { + keycode_Unknown = 0xffffffffU, + keycode_Left = 0xfffffffeU, + keycode_Right = 0xfffffffdU, + keycode_Up = 0xfffffffcU, + keycode_Down = 0xfffffffbU, + keycode_Return = 0xfffffffaU, + keycode_Delete = 0xfffffff9U, + keycode_Escape = 0xfffffff8U, + keycode_Tab = 0xfffffff7U, + keycode_PageUp = 0xfffffff6U, + keycode_PageDown = 0xfffffff5U, + keycode_Home = 0xfffffff4U, + keycode_End = 0xfffffff3U, + keycode_Func1 = 0xffffffefU, + keycode_Func2 = 0xffffffeeU, + keycode_Func3 = 0xffffffedU, + keycode_Func4 = 0xffffffecU, + keycode_Func5 = 0xffffffebU, + keycode_Func6 = 0xffffffeaU, + keycode_Func7 = 0xffffffe9U, + keycode_Func8 = 0xffffffe8U, + keycode_Func9 = 0xffffffe7U, + keycode_Func10 = 0xffffffe6U, + keycode_Func11 = 0xffffffe5U, + keycode_Func12 = 0xffffffe4U, + + // non standard keycodes + keycode_Erase = 0xffffef7fU, + keycode_MouseWheelUp = 0xffffeffeU, + keycode_MouseWheelDown = 0xffffefffU, + keycode_SkipWordLeft = 0xfffff000U, + keycode_SkipWordRight = 0xfffff001U, + + // The last keycode is always = 0x100000000 - keycode_MAXVAL) + keycode_MAXVAL = 28U +}; + +enum Style { + style_Normal = 0, + style_Emphasized = 1, + style_Preformatted = 2, + style_Header = 3, + style_Subheader = 4, + style_Alert = 5, + style_Note = 6, + style_BlockQuote = 7, + style_Input = 8, + style_User1 = 9, + style_User2 = 10, + style_NUMSTYLES = 11, +}; + +enum WinType { + wintype_AllTypes = 0, + wintype_Pair = 1, + wintype_Blank = 2, + wintype_TextBuffer = 3, + wintype_TextGrid = 4, + wintype_Graphics = 5, +}; + +enum WinMethod { + winmethod_Left = 0x00, + winmethod_Right = 0x01, + winmethod_Above = 0x02, + winmethod_Below = 0x03, + winmethod_DirMask = 0x0f, + + winmethod_Fixed = 0x10, + winmethod_Proportional = 0x20, + winmethod_DivisionMask = 0xf0, + + winmethod_Border = 0x000, + winmethod_NoBorder = 0x100, + winmethod_BorderMask = 0x100, +}; + +enum FileUsage { + fileusage_Data = 0x00, + fileusage_SavedGame = 0x01, + fileusage_Transcript = 0x02, + fileusage_InputRecord = 0x03, + fileusage_TypeMask = 0x0f, + + fileusage_TextMode = 0x100, + fileusage_BinaryMode = 0x000, +}; + +enum FileMode { + filemode_Write = 0x01, + filemode_Read = 0x02, + filemode_ReadWrite = 0x03, + filemode_WriteAppend = 0x05, +}; + +enum SeekMode { + seekmode_Start = 0, + seekmode_Current = 1, + seekmode_End = 2, +}; + +enum StyleHint { + stylehint_Indentation = 0, + stylehint_ParaIndentation = 1, + stylehint_Justification = 2, + stylehint_Size = 3, + stylehint_Weight = 4, + stylehint_Oblique = 5, + stylehint_Proportional = 6, + stylehint_TextColor = 7, + stylehint_BackColor = 8, + stylehint_ReverseColor = 9, + stylehint_NUMHINTS = 10, + + stylehint_just_LeftFlush = 0, + stylehint_just_LeftRight = 1, + stylehint_just_Centered = 2, + stylehint_just_RightFlush = 3, +}; + +#ifdef GLK_MODULE_IMAGE + +enum ImageAlign { + imagealign_InlineUp = 1, + imagealign_InlineDown = 2, + imagealign_InlineCenter = 3, + imagealign_MarginLeft = 4, + imagealign_MarginRight = 5 +}; + +#endif /* GLK_MODULE_IMAGE */ + +struct event_struct { + glui32 type; + winid_t win; + glui32 val1, val2; +}; +typedef event_struct event_t; + +struct stream_result_struct { + glui32 readcount; + glui32 writecount; +}; +typedef stream_result_struct stream_result_t; + +#ifdef GLK_MODULE_DATETIME + +struct glktimeval_struct { + glsi32 high_sec; + glui32 low_sec; + glsi32 microsec; +}; +typedef glktimeval_struct glktimeval_t; + +struct glkdate_struct { + glsi32 year; ///< full (four-digit) year */ + glsi32 month; ///< 1-12, 1 is January + glsi32 day; ///< 1-31 + glsi32 weekday; ///< 0-6, 0 is Sunday + glsi32 hour; ///< 0-23 + glsi32 minute; ///< 0-59 + glsi32 second; ///< 0-59, maybe 60 during a leap second + glsi32 microsec; ///< 0-999999 +}; +typedef glkdate_struct glkdate_t; + +#endif /* GLK_MODULE_DATETIME */ + +} // End of namespace Gargoyle + +#endif diff --git a/engines/gargoyle/interpreter.h b/engines/gargoyle/interpreter.h index df9172d9e1..748d4179fe 100644 --- a/engines/gargoyle/interpreter.h +++ b/engines/gargoyle/interpreter.h @@ -23,12 +23,16 @@ #ifndef GARGOYLE_INTERPRETER_H #define GARGOYLE_INTERPRETER_H +#include "graphics/screen.h" + namespace Gargoyle { /** * Base class for specific interpreters */ class Interpreter { +protected: + Graphics::Screen _screen; public: /** * Constructor diff --git a/engines/gargoyle/scott/scott.cpp b/engines/gargoyle/interps/scott/scott.cpp index b5e537caad..b2ea5e29fb 100644 --- a/engines/gargoyle/scott/scott.cpp +++ b/engines/gargoyle/interps/scott/scott.cpp @@ -20,11 +20,22 @@ * */ -#include "gargoyle/scott/scott.h" +#include "gargoyle/interps/scott/scott.h" namespace Gargoyle { namespace Scott { +void Scott::execute() { + event_t ev; + do { + glk_select(&ev); + switch (ev.type) { + default: + /* do nothing */ + break; + } + } while (ev.type != evtype_Quit); +} } // End of namespace Scott } // End of namespace Gargoyle diff --git a/engines/gargoyle/scott/scott.h b/engines/gargoyle/interps/scott/scott.h index bf13cf8c53..7d87ca5809 100644 --- a/engines/gargoyle/scott/scott.h +++ b/engines/gargoyle/interps/scott/scott.h @@ -28,7 +28,7 @@ */ #include "common/scummsys.h" -#include "gargoyle/glk.h" +#include "gargoyle/glk/glk.h" namespace Gargoyle { namespace Scott { @@ -93,6 +93,11 @@ public: * Constructor */ Scott() : Glk() {} + + /** + * Execute the game + */ + virtual void execute(); }; } // End of namespace Scott diff --git a/engines/gargoyle/module.mk b/engines/gargoyle/module.mk index 937b814453..6e11ba746f 100644 --- a/engines/gargoyle/module.mk +++ b/engines/gargoyle/module.mk @@ -4,9 +4,9 @@ MODULE_OBJS := \ detection.o \ events.o \ gargoyle.o \ - glk.o \ + glk/glk.o \ interpreter.o \ - scott/scott.o + interps/scott/scott.o # This module can be built as a plugin ifeq ($(ENABLE_GARGOYLE), DYNAMIC_PLUGIN) |