From 0f0c2c97e13d01cd77ba9fb489aec77398ce6945 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Jul 2019 18:57:06 -0700 Subject: GLK: ALAN3: Move some Glk interface methods to glkio.cpp --- engines/glk/alan3/exe.cpp | 53 --------------------------------------------- engines/glk/alan3/exe.h | 3 --- engines/glk/alan3/glkio.cpp | 48 ++++++++++++++++++++++++++++++++++++++++ engines/glk/alan3/glkio.h | 10 +++++---- 4 files changed, 54 insertions(+), 60 deletions(-) (limited to 'engines') diff --git a/engines/glk/alan3/exe.cpp b/engines/glk/alan3/exe.cpp index 39cec13c60..f30ebc2c6b 100644 --- a/engines/glk/alan3/exe.cpp +++ b/engines/glk/alan3/exe.cpp @@ -67,28 +67,6 @@ bool printFlag; // Printing already? #define WIDTH 80 - -/*======================================================================*/ -void setStyle(int style) { - switch (style) { - case NORMAL_STYLE: - g_vm->glk_set_style(style_Normal); - break; - case EMPHASIZED_STYLE: - g_vm->glk_set_style(style_Emphasized); - break; - case PREFORMATTED_STYLE: - g_vm->glk_set_style(style_Preformatted); - break; - case ALERT_STYLE: - g_vm->glk_set_style(style_Alert); - break; - case QUOTE_STYLE: - g_vm->glk_set_style(style_BlockQuote); - break; - } -} - /*======================================================================*/ void print(Aword fpos, Aword len) { char str[2 * WIDTH]; /* String buffer */ @@ -545,37 +523,6 @@ int getContainerMember(int container, int index, bool directly) { \***********************************************************************/ -/*======================================================================*/ -void showImage(int image, int align) { - uint ecode; - - if ((g_vm->glk_gestalt(gestalt_Graphics, 0) == 1) && - (g_vm->glk_gestalt(gestalt_DrawImage, wintype_TextBuffer) == 1)) { - g_vm->glk_window_flow_break(glkMainWin); - printf("\n"); - ecode = g_vm->glk_image_draw(glkMainWin, image, imagealign_MarginLeft, 0); - (void)ecode; - } -} - - -/*======================================================================*/ -void playSound(int sound) { -#ifdef GLK_MODULE_SOUND - static schanid_t soundChannel = NULL; - - if (g_vm->glk_gestalt(gestalt_Sound, 0) == 1) { - if (soundChannel == NULL) - soundChannel = g_vm->glk_schannel_create(0); - if (soundChannel != NULL) { - g_vm->glk_schannel_stop(soundChannel); - (void)g_vm->glk_schannel_play(soundChannel, sound); - } - } -#endif -} - - /*======================================================================*/ void empty(CONTEXT, int cnt, int whr) { uint i; diff --git a/engines/glk/alan3/exe.h b/engines/glk/alan3/exe.h index a039d6f736..79e77207dd 100644 --- a/engines/glk/alan3/exe.h +++ b/engines/glk/alan3/exe.h @@ -59,9 +59,6 @@ extern Aptr strip(bool stripFromBeginningNotEnd, int count, bool stripWordsNotCh extern Aptr concat(Aptr s1, Aptr s2); extern char *getStringFromFile(Aword fpos, Aword len); extern void print(Aword fpos, Aword len); -extern void setStyle(int style); -extern void showImage(int image, int align); -extern void playSound(int sound); extern void score(Aword sc); extern void visits(Aword v); extern void undo(void); diff --git a/engines/glk/alan3/glkio.cpp b/engines/glk/alan3/glkio.cpp index 4d0963b65d..6cc264f30a 100644 --- a/engines/glk/alan3/glkio.cpp +++ b/engines/glk/alan3/glkio.cpp @@ -22,6 +22,7 @@ #include "glk/alan3/alan3.h" #include "glk/alan3/glkio.h" +#include "glk/alan3/acode.h" namespace Glk { namespace Alan3 { @@ -49,5 +50,52 @@ void glkio_printf(const char *fmt, ...) { va_end(argp); } +void showImage(int image, int align) { + uint ecode; + + if ((g_vm->glk_gestalt(gestalt_Graphics, 0) == 1) && + (g_vm->glk_gestalt(gestalt_DrawImage, wintype_TextBuffer) == 1)) { + g_vm->glk_window_flow_break(glkMainWin); + printf("\n"); + ecode = g_vm->glk_image_draw(glkMainWin, image, imagealign_MarginLeft, 0); + (void)ecode; + } +} + +void playSound(int sound) { +#ifdef GLK_MODULE_SOUND + static schanid_t soundChannel = NULL; + + if (g_vm->glk_gestalt(gestalt_Sound, 0) == 1) { + if (soundChannel == NULL) + soundChannel = g_vm->glk_schannel_create(0); + if (soundChannel != NULL) { + g_vm->glk_schannel_stop(soundChannel); + (void)g_vm->glk_schannel_play(soundChannel, sound); + } + } +#endif +} + +void setStyle(int style) { + switch (style) { + case NORMAL_STYLE: + g_vm->glk_set_style(style_Normal); + break; + case EMPHASIZED_STYLE: + g_vm->glk_set_style(style_Emphasized); + break; + case PREFORMATTED_STYLE: + g_vm->glk_set_style(style_Preformatted); + break; + case ALERT_STYLE: + g_vm->glk_set_style(style_Alert); + break; + case QUOTE_STYLE: + g_vm->glk_set_style(style_BlockQuote); + break; + } +} + } // End of namespace Alan3 } // End of namespace Glk diff --git a/engines/glk/alan3/glkio.h b/engines/glk/alan3/glkio.h index b77e659cc5..32ce758d01 100644 --- a/engines/glk/alan3/glkio.h +++ b/engines/glk/alan3/glkio.h @@ -23,8 +23,6 @@ #ifndef GLK_ALAN3_GLKIO #define GLK_ALAN3_GLKIO -/* Header file for Glk output for Alan interpreter */ - #include "glk/alan3/alan3.h" #include "glk/windows.h" @@ -34,12 +32,16 @@ namespace Alan3 { extern winid_t glkMainWin; extern winid_t glkStatusWin; -/* NB: this header must be included in any file which calls printf() */ - #undef printf #define printf glkio_printf extern void glkio_printf(const char *, ...); +extern void showImage(int image, int align); + +extern void playSound(int sound); + +extern void setStyle(int style); + } // End of namespace Alan3 } // End of namespace Glk -- cgit v1.2.3