! La Pietra della Luna ! Avventura Testuale realizzata da Paolo Lucchesi ! da un'idea di Paolo Lucchesi, Andrea Gnesi e Stefano Masi ! Questo prodotto e' libero, rilasciato sotto licenza GPL (Gnu Public License), ! riportata nel file allegato gpl.txt. ! Questo prodotto e' distribuito senza alcuna garanzia. L'autore non pu@`o essere ! ritenuto responsabile per qualsiasi danno dovuto direttamente o indirettamente ! all'uso del prodotto. ! ------------------------------------------ ! Glk/Glulx Stuff ! ------------------------------------------ #IfDef TARGET_GLULX; !Constant GG_GXWIN_ROCK 210; Constant GG_LEFTBRD_ROCK 220; Constant GG_RIGHTBRD_ROCK 225; Constant GG_BUTTBRD_ROCK 230; Constant GG_TOPWIN_ROCK 240; Constant GG_BUTTWIN_ROCK 245; Constant GG_LEFTWIN_ROCK 250; Constant GG_RIGHTWIN_ROCK 255; Constant GG_TOPSEP_ROCK 260; Constant GG_BUTTSEP_ROCK 265; Constant GG_LEFTSEP_ROCK 270; Constant GG_RIGHTSEP_ROCK 275; Global gg_leftbrd = 0; Global gg_rightbrd = 0; Global gg_buttbrd = 0; !Global gg_gxwin = 0; Global gg_topwin = 0; Global gg_buttwin = 0; Global gg_leftwin = 0; Global gg_rightwin = 0; Global gg_topsep = 0; Global gg_buttsep = 0; Global gg_leftsep = 0; Global gg_rightsep = 0; #Ifndef NOSOUND; Constant GG_MUSICCHAN_ROCK 410; Global gg_musicchan = 0; #Endif; Constant SCBACK $f0e8dc; Constant SCTEXT $503010; Constant SCSOFT $b09070; Constant SCEMPH $704020; Constant SCHEAD $603818; Constant SCINPU $505010; Constant SLBACK $c8c0b0; Constant SLTEXT $302b20; Constant SLEMPH $403020; Constant SLFRAM $000000; [ InitGlkWindow winrock; switch (winrock) { GG_MAINWIN_ROCK: glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_TextColor, SCTEXT); glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Justification, stylehint_just_LeftRight); glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_TextColor, SCEMPH); glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_TextColor, SCEMPH); glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_TextColor, SCHEAD); glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_TextColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_BackColor, SCTEXT); glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_TextColor, SCINPU); glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Blockquote, stylehint_TextColor, SCINPU); glk_stylehint_set(wintype_AllTypes, style_Blockquote, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Input, stylehint_TextColor, SCINPU); glk_stylehint_set(wintype_AllTypes, style_Input, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_TextColor, SCINPU); glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_User1, stylehint_TextColor, SCSOFT); glk_stylehint_set(wintype_AllTypes, style_User1, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_User2, stylehint_TextColor, SCSOFT); glk_stylehint_set(wintype_AllTypes, style_User2, stylehint_BackColor, SCBACK); glk_stylehint_set(wintype_AllTypes, style_User2, stylehint_Justification, stylehint_just_Centered); GG_STATUSWIN_ROCK: glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_TextColor, SLTEXT); glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Justification, stylehint_just_LeftRight); glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_TextColor, SLEMPH); glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_TextColor, SLEMPH); glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_TextColor, SLEMPH); glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_TextColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_BackColor, SLTEXT); glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_TextColor, SLTEXT); glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Blockquote, stylehint_TextColor, SLTEXT); glk_stylehint_set(wintype_AllTypes, style_Blockquote, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Input, stylehint_TextColor, SLTEXT); glk_stylehint_set(wintype_AllTypes, style_Input, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_TextColor, SLTEXT); glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_BackColor, SLBACK); glk_stylehint_set(wintype_AllTypes, style_User1, stylehint_TextColor, SLEMPH); glk_stylehint_set(wintype_AllTypes, style_User1, stylehint_BackColor, SLBACK); } !if (winrock == GG_STATUSWIN_ROCK) rtrue; rfalse; ]; ! --- Capabilities testing Global gs_graphic=false; Global gs_timer=false; Global gs_imgfade=false; #IfnDef NOSOUND; Global gs_music=false; !Global gs_musicfade=false; #Endif; [ TestGlkCapabilities; if (glk_gestalt(gestalt_Graphics)) gs_graphic=true; if (glk_gestalt(gestalt_Timer)) gs_timer=true; if (gs_graphic && gs_timer && glk_gestalt(gestalt_GraphicsTransparency)) gs_imgfade=true; #IfnDef NOSOUND; if (glk_gestalt(gestalt_Sound)) gs_music=true; if (gs_music && gs_timer && glk_gestalt(gestalt_SoundVolume)) gs_graphic=true; #Endif; ]; ! --- Graphics Global gxwin=0; Global gxwinside=0; Global gxwinmeth=0; Global gxwindim=0; Global imgx=0; Global imgy=0; Global picture=0; Global gx_location=0; Global picx; Global picy; Global winx; Global winy; !Global timer_event = 0; Global timer_time = 0; [ MakeScreen; if (~~gs_graphic) rfalse; glk_stylehint_set(wintype_textbuffer, 0, stylehint_backcolor, SCBACK); CloseAllWindows(); MakeBorder(); MakeFrame(true); MakeWindow(); MainWindow(); ]; [ MakeBorder; if (~~gs_graphic) rfalse; gg_leftbrd = glk_window_open(gg_mainwin, winmethod_Left+winmethod_Fixed, 4, wintype_Graphics, GG_LEFTBRD_ROCK); glk_window_set_background_color(gg_leftbrd, SLBACK); glk_window_clear(gg_leftbrd); gg_rightbrd = glk_window_open(gg_mainwin, winmethod_Right+winmethod_Fixed, 4, wintype_Graphics, GG_RIGHTBRD_ROCK); glk_window_set_background_color(gg_rightbrd, SLBACK); glk_window_clear(gg_rightbrd); gg_buttbrd = glk_window_open(gg_mainwin, winmethod_Below+winmethod_Fixed, 4, wintype_Graphics, GG_BUTTBRD_ROCK); glk_window_set_background_color(gg_buttbrd, SLBACK); glk_window_clear(gg_buttbrd); ]; ![ MakeSides redoall py gg_test; ! if (~~gs_graphic) rfalse; ! if (redoall) CloseFrameWindows(); ! gg_test = glk_window_open(gg_mainwin, winmethod_Above+winmethod_Fixed, 1, wintype_Graphics, 999); ! glk_window_get_size(gg_test, gg_arguments, gg_arguments+4); ! winx = gg_arguments-->0; ! glk_window_close(gg_test, 0); ! if (gg_leftwin) { ! glk_window_get_size(gg_leftwin, gg_arguments, gg_arguments+4); ! winx = winx + gg_arguments-->0; ! } ! if (gg_rightwin) { ! glk_window_get_size(gg_rightwin, gg_arguments, gg_arguments+4); ! winx = winx + gg_arguments-->0; ! } ! if (winx >= 560) { ! MakeFrame(false); ! if (gg_leftwin == 0) ! gg_leftwin = glk_window_open(gg_mainwin, winmethod_Left+winmethod_Fixed, 32, wintype_Graphics, GG_LEFTWIN_ROCK); ! if (gg_rightwin == 0) ! gg_rightwin = glk_window_open(gg_mainwin, winmethod_Right+winmethod_Fixed, 32, wintype_Graphics, GG_RIGHTWIN_ROCK); ! glk_window_get_size(gg_leftwin, gg_arguments, gg_arguments+4); ! winy = gg_arguments-->1; ! winx = winx - gg_arguments-->0; ! glk_window_get_size(gg_rightwin, gg_arguments, gg_arguments+4); ! winx = winx - gg_arguments-->0; ! glk_window_set_background_color(gg_leftwin, SCBACK); ! glk_window_set_background_color(gg_rightwin, SCBACK); ! glk_window_clear(gg_leftwin); ! glk_window_clear(gg_rightwin); ! !glk_image_draw_scaled(gg_leftwin, Column_img, 8, 16, 48, my-32); ! py = 0; ! while (py < winy) { ! glk_image_draw(gg_leftwin, ParchLeft_img, 0, py); ! glk_image_draw(gg_rightwin, ParchRight_img, 0, py); ! py = py + 640; ! } ! } else { ! MakeFrame(true); ! } ! CloseGrxWindows(); !!! Questo @`e ottimizzabile !]; [ MakeFrame allsides; if (~~gs_graphic) rfalse; if (gg_topwin == 0) gg_topwin = glk_window_open(gg_mainwin, winmethod_Above+winmethod_Fixed, 2, wintype_Graphics, GG_TOPWIN_ROCK); glk_window_set_background_color(gg_topwin, SLFRAM); glk_window_clear(gg_topwin); if (gg_buttwin == 0) gg_buttwin = glk_window_open(gg_mainwin, winmethod_Below+winmethod_Fixed, 2, wintype_Graphics, GG_BUTTWIN_ROCK); glk_window_set_background_color(gg_buttwin, SLFRAM); glk_window_clear(gg_buttwin); if (~~allsides) rtrue; if (gg_leftwin == 0) gg_leftwin = glk_window_open(gg_mainwin, winmethod_Left+winmethod_Fixed, 2, wintype_Graphics, GG_LEFTWIN_ROCK); glk_window_set_background_color(gg_leftwin, SLFRAM); glk_window_clear(gg_leftwin); if (gg_rightwin == 0) gg_rightwin = glk_window_open(gg_mainwin, winmethod_Right+winmethod_Fixed, 2, wintype_Graphics, GG_RIGHTWIN_ROCK); glk_window_set_background_color(gg_rightwin, SLFRAM); glk_window_clear(gg_rightwin); MeasureWindow(); ]; [ MakeMenu; if (~~gs_graphic) rfalse; !CloseFrameWindows(); CloseGrxWindows(); MakeFrame(true); MakeWindow(true); MainWindow(); ]; [ UnMakeMenu; MakeWindow(); MainWindow(); ]; [ ResizeWindows; MeasureWindow(); MakeWindow(); ]; [ MeasureWindow; winx = 0; winy = 0; if (~~gs_graphic) rfalse; if (gg_leftwin) { glk_window_get_size(gg_leftbrd, gg_arguments, gg_arguments+4); winy = gg_arguments-->1; } else if (gg_leftbrd) { glk_window_get_size(gg_leftbrd, gg_arguments, gg_arguments+4); winy = gg_arguments-->1; } if (gg_buttwin) { glk_window_get_size(gg_buttwin, gg_arguments, gg_arguments+4); winx = gg_arguments-->0; winy = winy - gg_arguments-->1; } else if (gg_buttbrd) { glk_window_get_size(gg_buttbrd, gg_arguments, gg_arguments+4); winx = gg_arguments-->0; winy = winy - gg_arguments-->1; } ]; ![ RemoveSides; ! CloseAllWindows(); ! MakeBorder(); ! MainWindow(); !]; [ CloseAllWindows; CloseBorderWindows(); CloseFrameWindows(); CloseGrxWindows(); ]; [ CloseBorderWindows; if (~~gs_graphic) rfalse; if (gg_leftbrd) glk_window_close(gg_leftbrd, 0); if (gg_rightbrd) glk_window_close(gg_rightbrd, 0); if (gg_buttbrd) glk_window_close(gg_buttbrd, 0); gg_leftbrd = 0; gg_rightbrd = 0; gg_buttbrd = 0; ]; [ CloseFrameWindows; if (~~gs_graphic) rfalse; if (gg_topwin) glk_window_close(gg_topwin, 0); if (gg_buttwin) glk_window_close(gg_buttwin, 0); if (gg_leftwin) glk_window_close(gg_leftwin, 0); if (gg_rightwin) glk_window_close(gg_rightwin, 0); gg_topwin=0; gg_buttwin=0; gg_leftwin=0; gg_rightwin=0; ]; [ CloseGrxWindows; if (gg_topsep) glk_window_close(gg_topsep, 0); if (gg_buttsep) glk_window_close(gg_buttsep, 0); if (gg_leftsep) glk_window_close(gg_leftsep, 0); if (gg_rightsep) glk_window_close(gg_rightsep, 0); gg_topsep = 0; gg_buttsep = 0; gg_leftsep = 0; gg_rightsep = 0; ]; ![ MakeWindow nopic dm; ! if (~~gs_graphic) rfalse; ! if (gg_topsep) glk_window_close(gg_topsep, 0); ! if (gg_buttsep) glk_window_close(gg_buttsep, 0); ! if (gg_leftsep) glk_window_close(gg_leftsep, 0); ! if (gg_rightsep) glk_window_close(gg_rightsep, 0); ! if (picture && (gxwinside == winmethod_Above) && (~~nopic)) dm = gxwindim; else dm = 6; ! gg_topsep = glk_window_open(gg_mainwin, winmethod_Above+winmethod_Fixed, dm, wintype_Graphics, GG_TOPSEP_ROCK); ! glk_window_set_background_color(gg_topsep, SCBACK); ! glk_window_clear(gg_topsep); ! gg_buttsep = glk_window_open(gg_mainwin, winmethod_Below+winmethod_Fixed, 6, wintype_Graphics, GG_BUTTSEP_ROCK); ! glk_window_set_background_color(gg_buttsep, SCBACK); ! glk_window_clear(gg_buttsep); ! if (picture && (gxwinside == winmethod_Left) && (~~nopic)) dm = gxwindim; else dm = 6; ! gg_leftsep = glk_window_open(gg_mainwin, winmethod_Left+winmethod_Fixed, dm, wintype_Graphics, GG_LEFTSEP_ROCK); ! glk_window_set_background_color(gg_leftsep, SCBACK); ! glk_window_clear(gg_leftsep); ! if (picture && (gxwinside == winmethod_Right) && (~~nopic)) dm = gxwindim; else dm = 6; ! gg_rightsep = glk_window_open(gg_mainwin, winmethod_Right+winmethod_Fixed, dm, wintype_Graphics, GG_RIGHTSEP_ROCK); ! glk_window_set_background_color(gg_rightsep, SCBACK); ! glk_window_clear(gg_rightsep); ! ! if (nopic) rtrue; ! switch(gxwinside) { ! winmethod_Above: gxwin = gg_topsep; ! winmethod_Left: gxwin = gg_leftsep; ! winmethod_Right: gxwin = gg_rightsep; ! default: gxwin = 0; ! } ! RedrawGraphicImage(); !]; [ MakeWindow nopic dm pwin; if (~~gs_graphic) rfalse; if ((gxwinside == winmethod_Above) && ((5*gxwindim) > (2*winy))) nopic = true; if ((gxwinside == winmethod_Above) && (imgx > winx)) nopic = true; if ((gxwinside == winmethod_Left or winmethod_Right) && ((3*gxwindim) > winx)) nopic = true; if ((gxwinside == winmethod_Left or winmethod_Right) && (imgy > winy)) nopic = true; if (picture && (gxwinside == winmethod_Above) && (~~nopic)) dm = gxwindim; else dm = 6; if (gg_topsep) { pwin=glk_window_get_parent(gg_topsep); glk_window_set_arrangement(pwin, winmethod_Above+winmethod_Fixed, dm, gg_topsep); } else gg_topsep = glk_window_open(gg_mainwin, winmethod_Above+winmethod_Fixed, dm, wintype_Graphics, GG_TOPSEP_ROCK); glk_window_set_background_color(gg_topsep, SCBACK); glk_window_clear(gg_topsep); if (gg_buttsep == 0) gg_buttsep= glk_window_open(gg_mainwin, winmethod_Below+winmethod_Fixed, 6, wintype_Graphics, GG_BUTTSEP_ROCK); glk_window_set_background_color(gg_buttsep, SCBACK); glk_window_clear(gg_buttsep); if (picture && (gxwinside == winmethod_Left) && (~~nopic)) dm = gxwindim; else dm = 6; if (gg_leftsep) { pwin = glk_window_get_parent(gg_leftsep); glk_window_set_arrangement(pwin, winmethod_Left+winmethod_Fixed, dm, gg_leftsep); } else gg_leftsep = glk_window_open(gg_mainwin, winmethod_Left+winmethod_Fixed, dm, wintype_Graphics, GG_LEFTSEP_ROCK); glk_window_set_background_color(gg_leftsep, SCBACK); glk_window_clear(gg_leftsep); if (picture && (gxwinside == winmethod_Right) && (~~nopic)) dm = gxwindim; else dm = 6; if (gg_rightsep) { pwin = glk_window_get_parent(gg_rightsep); glk_window_set_arrangement(pwin, winmethod_Right+winmethod_Fixed, dm, gg_rightsep); } else gg_rightsep = glk_window_open(gg_mainwin, winmethod_Right+winmethod_Fixed, dm, wintype_Graphics, GG_RIGHTSEP_ROCK); glk_window_set_background_color(gg_rightsep, SCBACK); glk_window_clear(gg_rightsep); if (nopic) rtrue; switch(gxwinside) { winmethod_Above: gxwin = gg_topsep; winmethod_Left: gxwin = gg_leftsep; winmethod_Right: gxwin = gg_rightsep; default: gxwin = 0; } RedrawGraphicImage(); ]; Constant MAXIMAGES 40; Array imgused->MAXIMAGES; [ DrawImage pic; !glk_set_style(style_User2); if (imgused->pic) rfalse; imgused->pic = true; glk_image_draw(gg_mainwin, pic, imagealign_MarginRight, 0); rtrue; !glk_set_style(style_Normal); ]; [ ImageBreak; glk_window_flow_break(gg_mainwin); ]; [ CheckImage pic; if (imgused->pic) rfalse; rtrue; ]; [ SetImage pic; if (imgused->pic) rfalse; imgused->pic = true; rtrue; ]; [ ResetImage pic; imgused->pic = false; rtrue; ]; ![ MakeWindow; ! if (gg_gxwin) glk_window_close(gg_gxwin, 0); ! gg_gxwin = 0; ! if (gxwindim>0 && gs_graphic) { ! gg_gxwin = glk_window_open(gg_mainwin, (gxwinside+gxwinmeth), gxwindim, wintype_Graphics, GG_GXWIN_ROCK); ! glk_window_set_background_color(gg_gxwin, SCBACK); ! glk_window_clear(gg_gxwin); ! } ! else { ! if (gg_gxwin) glk_window_close(gg_gxwin); ! gg_gxwin = 0; ! } ! MyRedrawGraphicsWindows(); ! !TalkWindowOpen(); ! MainWindow(); !]; ! ![ UnmakeWindow; ! if (gg_gxwin) glk_window_close(gg_gxwin, 0); ! gg_gxwin = 0; !]; ![ NewPicture id x y; ! if (gg_gxwin == 0) rfalse; ! glk_window_set_background_color(gg_gxwin, SCBACK); ! glk_window_clear(gg_gxwin); ! picture = id; ! picx = x; ! picy = y; ! MyRedrawGraphicsWindows(); !]; ![ CenterPicture id; ! if (gg_gxwin == 0 || (~~gs_graphic)) rfalse; ! glk_window_set_background_color(gg_gxwin, SCBACK); ! glk_window_clear(gg_gxwin); ! picture = id; ! gx_location = real_location; ! picx = -1; picy = -1; ! SetCenteredPosition(); !! glk_window_get_size(gg_gxwin, gg_arguments, gg_arguments+4); !! wx = gg_arguments-->0; wy = gg_arguments-->1; !! glk_image_get_info(picture, gg_arguments, gg_arguments+4); !! ix = gg_arguments-->0; iy = gg_arguments-->1; !! picx = (wx-ix)/2; !! picy = (wy-iy)/2; !! !print "***", id, ": ", wx, ",", wy, "; ", ix, ",", iy, "***^"; ! MyRedrawGraphicsWindows(); !]; ![ SetCenteredPosition wx wy ix iy; ! ! Calculate Center position if picx or picy < 0 ! if (gxwin == 0 || (~~gs_graphic)) rfalse; ! glk_window_get_size(gxwin, gg_arguments, gg_arguments+4); ! wx = gg_arguments-->0; wy = gg_arguments-->1; ! glk_image_get_info(picture, gg_arguments, gg_arguments+4); ! ix = gg_arguments-->0; iy = gg_arguments-->1; ! if (picx < 0) picx = (wx-ix)/2; ! if (picy < 0) picy = (wy-iy)/2; !]; [ RedrawGraphicImage wx wy ix iy px py; !SetCenteredPosition(); if ((~~gxwin) || (~~picture) || (~~gs_graphic)) rfalse; glk_window_get_size(gxwin, gg_arguments, gg_arguments+4); wx = gg_arguments-->0; wy = gg_arguments-->1; glk_image_get_info(picture, gg_arguments, gg_arguments+4); ix = gg_arguments-->0; iy = gg_arguments-->1; px = picx; py = picy; if (py < 0) { py = (wy-iy)/2; if (py < 0) py = 0; if ((gxwinside == winmethod_Left or winmethod_Right) && (py > 32)) py=32; } if (px < 0) px = (wx-ix)/2; if (px < 0) px = 0; if (gxwin && picture) glk_image_draw(gxwin, picture, px, py); ]; ![LeftPictureCheck pic x y; ! if (imgused->pic) rfalse; imgused->pic = true; ! LeftPicture(pic,x,y); !] ! ![RightPictureCheck pic x y; ! if (imgused->pic) rfalse; imgused->pic = true; ! RightPicture(pic,x,y); !] ! ![AbovePictureCheck pic x y; ! if (imgused->pic) rfalse; imgused->pic = true; ! AbovePicture(pic,x,y); !] [LeftPicture pic x y sz; if (imgused->pic) rfalse; imgused->pic = true; ! To remove later if (~~gs_graphic) rfalse; gxwinside = winmethod_Left; gxwinmeth = winmethod_Fixed; picture = pic; gx_location = real_location; glk_image_get_info(picture, gg_arguments, gg_arguments+4); imgx = gg_arguments-->0; imgy = gg_arguments-->1; if (sz <= 0) { sz = -sz; if ((sz == 0) || (imgx < sz)) sz = imgx; } gxwindim = sz; picx = x; picy = y; MakeWindow(); ]; [RightPicture pic x y sz; if (imgused->pic) rfalse; imgused->pic = true; ! To remove later if (~~gs_graphic) rfalse; gxwinside = winmethod_Right; gxwinmeth = winmethod_Fixed; picture = pic; gx_location = real_location; glk_image_get_info(picture, gg_arguments, gg_arguments+4); imgx = gg_arguments-->0; imgy = gg_arguments-->1; if (sz <= 0) { sz = -sz; if ((sz == 0) || (imgx < sz)) sz = imgx; } gxwindim = sz; picx = x; picy = y; MakeWindow(); ]; [AbovePicture pic x y sz; if (imgused->pic) rfalse; imgused->pic = true; ! To remove later if (~~gs_graphic) rfalse; gxwinside = winmethod_Above; gxwinmeth = winmethod_Fixed; picture = pic; gx_location = real_location; glk_image_get_info(picture, gg_arguments, gg_arguments+4); imgx = gg_arguments-->0; imgy = gg_arguments-->1; if (sz <= 0) { sz = -sz; if ((sz == 0) || (imgy < sz)) sz = imgy; } gxwindim = sz; picx = x; picy = y; MakeWindow(); ]; ![DarkenPicture n i wx wy ix iy; ! if ((~~gs_graphic) || (~~gs_imgfade)) rfalse; ! if (gg_gxwin == 0) rfalse; ! glk_window_get_size(gg_gxwin, gg_arguments, gg_arguments+4); ! wx = gg_arguments-->0; wy = gg_arguments-->1; ! glk_image_get_info(picture, gg_arguments, gg_arguments+4); ! ix = gg_arguments-->0; iy = gg_arguments-->1; ! wx = (wx-ix)/2; ! wy = (wy-iy)/2; ! if (n == 0) n = 1; ! for (i=0 : i0; iy = gg_arguments-->1; if ((ix > winx) || (iy > winy)) rfalse; px = (winx-ix)/2; py = (winy-iy)/2; px = px + (dx * px / 4); py = py + (dy * py / 4); if (gs_imgfade) { FadePic(pic, px, py); } else { glk_image_draw(gxwin, pic, px, py); KeyCharPrimitive(); } glk_window_clear(gxwin); ]; [ FadePic pic px py tp fadepic; timer_time = 0; tp = 0; while (true) { glk_request_char_event(gg_mainwin); glk_select(gg_event); if (gg_event-->0 ~= evtype_Timer or evtype_CharInput) { HandleGlkEvent(gg_event, 1, gg_arguments); continue; } if ((gg_event-->0 == evtype_CharInput) && (gg_event-->2 == keycode_Escape)) { movieon = false; break; } glk_cancel_char_event(gg_mainwin); !if (timer_time > 4000) break; !if (timer_time < tp*100) continue; tp++; !print tp, ", "; KeyCharPrimitive(); switch(tp) { 1, 39: fadepic = Fade9_img; 2, 38: fadepic = Fade8_img; 3, 37: fadepic = Fade7_img; 4, 36: fadepic = Fade6_img; 5, 35: fadepic = Fade5_img; 6, 34: fadepic = Fade4_img; 7, 33: fadepic = Fade3_img; 8, 32: fadepic = Fade2_img; 9, 31: fadepic = Fade1_img; 10: fadepic = 0; default: fadepic = -1; } if (fadepic >= 0) glk_image_draw(gxwin, pic, px, py); if (fadepic > 0) glk_image_draw(gxwin, fadepic, px, py); if (tp == 40) glk_window_clear(gxwin); if (tp > 40) break; } ]; [ OpenMovie; !if (gs_imgfade) TimerStart(); rtrue; movieon = true; if (~~gs_graphic) rfalse; CloseGrxWindows(); MeasureWindow(); gg_topsep = glk_window_open(gg_mainwin, winmethod_Above+winmethod_Proportional, 100, wintype_Graphics, GG_TOPSEP_ROCK); glk_window_set_background_color(gg_topsep, SCBACK); glk_window_clear(gg_topsep); gxwin = gg_topsep; if (gs_imgfade) TimerStart(); return gxwin; ]; [ CloseMovie; !rtrue; if (~~gs_graphic) rfalse; glk_window_close(gg_topsep); gg_topsep = 0; gxwin = 0; if (gs_imgfade) TimerStop(); MakeWindow(); MainWindow(); ]; [ TimerStart; if (~~gs_timer) rfalse; glk_request_timer_events(80); ]; [ TimerStop; if (~~gs_timer) rfalse; glk_request_timer_events(0); ]; #Ifndef NOSOUND; Constant MAXVOLUME $4000; Global musicflag = true; Global current_music = 0; Global next_music = 0; Global music_volume = MAXVOLUME; Global fade_music = false; [ MusicSub; if (~~gs_music) rfalse; if (musicflag) MusicOffSub(); else MusicOnSub(); ]; [ MusicOffSub; if (~~gs_music) rfalse; if (musicflag) { musicflag = false; FadeOutMusic(); } "[Sound is now Off]"; ]; [ MusicOnSub; if (~~gs_music) rfalse; musicflag = true; !MyRestartMusicChannel(); "[Sound is now On]"; ]; [ SoundInit; if (~~gs_music) rfalse; if (gg_musicchan == 0) { gg_musicchan = glk_schannel_create(GG_MUSICCHAN_ROCK); } ]; [ MyRestartMusicChannel; if (~~gs_music) rfalse; if (gg_musicchan) { if (current_music == 0) glk_schannel_stop(gg_musicchan); else glk_schannel_play_ext(gg_musicchan, current_music, 1, 1); glk_schannel_set_volume(gg_musicchan, music_volume); } ]; [ StopMusic; current_music = 0; MyRestartMusicChannel(); ]; [ FadeToMusic x; if (~~gs_music) rfalse; !print "Fade to music ", current_music, " -> ", x, ".^"; if (musicflag) { if (x == current_music) rtrue; if (current_music) { FadeOutMusic(); next_music = x; rtrue; } PlayMusic(x); } ]; [ PlayMusic x; if (~~gs_music) rfalse; !print "Play music ", x, ".^"; if (musicflag) { if (x == current_music) rtrue; StopMusic(); if (x == 0) rtrue; current_music = x; music_volume = MAXVOLUME; MyRestartMusicChannel(); } ]; [ DecreaseVolume; if (~~gs_music) rfalse; !print music_volume, "-", fade_music, "*"; music_volume = music_volume - MAXVOLUME / 40; if (music_volume < 0) music_volume = 0; if (gg_musicchan) glk_schannel_set_volume(gg_musicchan, music_volume); if (music_volume == 0) { fade_music = false; PlayMusic(next_music); next_music = 0; } ]; [ FadeOutMusic; fade_music = true; ]; #Endif; [ HandleGlkEvent ev context x; x = context; switch (ev-->0) { ! evtype_Timer: ! timer_time = timer_time + 80; ! if (timer_event) timer_event(); ! #Ifndef NOSOUND; ! if (fade_music) DecreaseVolume(); ! #Endif; evtype_Arrange, evtype_Redraw: ResizeWindows(); } ev=ev; ]; [ IdentifyGlkObject phase type ref rock res id; res = res; if (phase == 0) { ! Zero out references to our objects. #Ifndef NOSOUND; gg_musicchan = 0; #Endif; !gg_gxwin = 0; gg_leftbrd = 0; gg_rightbrd = 0; gg_buttbrd = 0; gg_topwin = 0; gg_buttwin = 0; gg_leftwin = 0; gg_rightwin = 0; gg_topsep = 0; gg_buttsep = 0; gg_leftsep = 0; gg_rightsep = 0; } if (phase == 1) { ! Reset our windows, streams and filerefs. switch (type) { 0: switch (rock) { !GG_GXWIN_ROCK: gg_gxwin = ref; GG_LEFTBRD_ROCK: gg_leftbrd = ref; GG_RIGHTBRD_ROCK: gg_rightbrd = ref; GG_BUTTBRD_ROCK: gg_buttbrd = ref; GG_TOPWIN_ROCK: gg_topwin = ref; GG_BUTTWIN_ROCK: gg_buttwin = ref; GG_LEFTWIN_ROCK: gg_leftwin = ref; GG_RIGHTWIN_ROCK: gg_rightwin = ref; GG_TOPSEP_ROCK: gg_topsep = ref; GG_BUTTSEP_ROCK: gg_buttsep = ref; GG_LEFTSEP_ROCK: gg_leftsep = ref; GG_RIGHTSEP_ROCK: gg_rightsep = ref; ! GG_TALKWIN_ROCK: gg_talkwin = ref; } 1: ! stream 2: ! fileref } } if (phase == 2) { ! Update our objects. !MakeSides(); MakeWindow(); #Ifndef NOSOUND; id = glk_schannel_iterate(0, gg_arguments); while (id) { switch (gg_arguments-->0) { GG_MUSICCHAN_ROCK: gg_musicchan = id; } id = glk_schannel_iterate(id, gg_arguments); } if (~~musicflag) current_music = 0; MyRestartMusicChannel(); #Endif; } id=id; return; ]; #Endif; Stub TestGlkCapabilities 0; !Stub MakeWindow 0; Stub MakeScreen 0; Stub MakeMenu 0; Stub UnMakeMenu 0; !Stub RemoveSides 0; !Stub UnmakeWindow 0; Stub LeftPicture 3; Stub RightPicture 3; Stub AbovePicture 3; Stub NoPicture 1; Stub MakeMovie 1; Stub DrawImage 2; Stub ResetImage 1; Stub SetImage 1; Stub CheckImage 1; Stub ImageBreak 0; #IfDef NOSOUND; !Stub TimerInit 0; !Stub SoundInit 0; !Stub StopMusic 0; !Stub PlayMusic 1; !Stub FadeToMusic 1; !Stub FadeOutMusic 0; #EndIf; [ __GlkWarningSquasher; TestGlkCapabilities(); Makescreen(); MakeMenu(); UnMakeMenu(); DrawImage(Dagger_img); CheckImage(Shub_img); ResetImage(IarinDagger_img); SetImage(Stars_img); LeftPicture(ParchLeft_img,0,0); RightPicture(ParchRight_img,0,0); AbovePicture(FRONTISPIECE_ib,0,0); NoPicture(); MakeMovie(Fade1_img); MakeMovie(Fade2_img); MakeMovie(Fade3_img); MakeMovie(Fade4_img); MakeMovie(Fade5_img); MakeMovie(Fade6_img); MakeMovie(Fade7_img); MakeMovie(Fade8_img); MakeMovie(Fade9_img); !TimerInit(); SoundInit(); FadeToMusic(0); FadeOutMusic(); __GlkWarningSquasher(); ]; ! --- Fake sounds