1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-28 08:41:30 +00:00
8bitworkshop/gen/zmachine-QT2YTAFV.js

3 lines
10 KiB
JavaScript

import{a as f,b as m}from"./chunk-3XE5YOCV.js";import{x as h}from"./chunk-6UU4KLMR.js";import{D as l,H as _,Q as d}from"./chunk-7LTJUW24.js";import"./chunk-RQFURXHW.js";var x=[{id:"hello.inf",name:"Hello World"},{id:"house01.inf",name:"House Tutorial #1"},{id:"house02.inf",name:"House Tutorial #2"},{id:"house03.inf",name:"House Tutorial #3"},{id:"house04.inf",name:"House Tutorial #4"},{id:"house05.inf",name:"House Tutorial #5"},{id:"house06.inf",name:"House Tutorial #6"},{id:"house07.inf",name:"House Tutorial #7"},{id:"alice.inf",name:"Through the Looking-Glass"},{id:"aloneice.inf",name:"Alone on the Ice"},{id:"adventureland.inf",name:"Adventureland"},{id:"toyshop.inf",name:"Toyshop"},{id:"ruins1.inf",name:"Ruins #1"},{id:"ruins2.inf",name:"Ruins #2"},{id:"ruins3.inf",name:"Ruins #3"},{id:"balances.inf",name:"Balances"},{id:"museum.inf",name:"Museum of Inform"},{id:"advent.inf",name:"Colossal Cave Adventure"},{id:"ztrek.inf",name:"Super Z Trek"}];function i(...u){}var c=class{constructor(e,t,n){this.exited=!1;this.DidNotReturn={dummy:"Glk call has not yet returned"};this.RefBox=g;this.RefStruct=p;this.mainwnd=new m(e,!1,t),this.mainwnd.keepinput=!1,this.mainwnd.splitInput=!1,this.mainwnd.uppercaseOnly=!0,this.mainwnd.hideinput(),this.windows={1:this.mainwnd,2:new f(n,!0),3:new f(null,!0)},this.input=t,this.mainwnd.resolveInput=r=>{var s=r.line;if(this.vm.read_data.buffer){for(var o=0;o<s.length;o++)this.vm.read_data.buffer[o]=s.charCodeAt(o)&255;this.vm.handle_line_input(s.length)}else this.vm.handle_char_input(s.charCodeAt(0));this.vm.run()},this.reset()}reset(){this.windowcount=0,this.exited=!1,this.windows[1].clear(),this.windows[2].clear(),this.curwnd=this.windows[1]}init(e){this.vm=e.vm,this.vm.start()}fatal_error(e){throw new d(e)}update(){}focusinput(){this.mainwnd.focusinput()}flushline(){this.curwnd.flushline()}glk_exit(){this.exited=!0,this.flushline(),this.windows[1].addtext("** Game exited **",1)}glk_window_clear(e){i("glk_window_clear",arguments),this.windows[e].clear()}glk_request_line_event_uni(e,t,n){this.mainwnd.waitingfor="line",this.focusinput(),this.startinputtimer()}glk_request_char_event_uni(e,t,n){this.mainwnd.waitingfor="char",this.focusinput(),this.startinputtimer()}startinputtimer(){}glk_put_jstring(e,t){this.curwnd.print(e)}glk_put_jstring_stream(e,t){this.windows[e].print(t)}glk_put_char_stream_uni(e,t){this.windows[e].print(String.fromCharCode(t))}glk_set_style(e){this.curwnd.curstyle=e}glk_char_to_lower(e){return e>=65&&e<=90||e>=192&&e<=222&&e!=215?e+32:e}glk_char_to_upper(e){return e>=97&&e<=122||e>=224&&e<=254&&e!=247?e-32:e}glk_stylehint_set(e,t,n,r){}glk_stylehint_clear(e,t,n){}glk_style_distinguish(e,t,n){return 0}glk_style_measure(e,t,n,r){return r&&r.set_value(0),0}glk_select(e){i("glk_select",arguments)}glk_window_open(e,t,n,r,s){return i("glk_window_open",arguments),e?t!=18||r!=4?0:n?($(this.windows[2].page).show(),2):3:1}glk_window_close(e){i("glk_window_close",arguments),e==2&&(this.windows[e].clear(),$(this.windows[e].page).hide())}glk_window_get_parent(e){return i("glk_window_get_parent",arguments),e==1?0:1}glk_window_move_cursor(e,t,n){i("glk_window_move_cursor",arguments),this.windows[e].move_cursor(t,n)}glk_window_set_arrangement(e,t,n,r){i("glk_window_set_arrangement",arguments),e==1&&this.windows[2].setrows(n)}glk_window_get_stream(e){return i("glk_window_get_stream",arguments),e}glk_set_window(e){i("glk_set_window",arguments),this.curwnd=this.windows[e],this.curwnd==null&&this.fatal_error("no window "+e)}glk_window_get_size(e,t,n){i("glk_window_get_size",arguments),t&&t.set_value(y),n&&n.set_value(e==1?25:1)}garglk_set_reversevideo(e){i("garglk_set_reversevideo",arguments),this.curwnd.reverse=!!e}garglk_set_reversevideo_stream(e,t){i("garglk_set_reversevideo_stream",arguments),this.windows[e].reverse=!!t}glk_fileref_create_by_prompt(e,t,n){i("glk_fileref_create_by_prompt",arguments),this.vm.handle_create_fileref(0),this.vm.run()}glk_gestalt(e,t){return this.glk_gestalt_ext(e,t,null)}glk_gestalt_ext(e,t,n){switch(e){case 0:return 257;case 1:return t<=a.keycode_Left&&t>=a.keycode_End?1:t>=4294967296-a.keycode_MAXVAL||t>1114111||t>=0&&t<32||t>=127&&t<160?0:1;case 2:return t>1114111||t>=0&&t<32||t>=127&&t<160?0:1;case 3:return t>1114111||t>=0&&t<32||t>=127&&t<160?(n&&(n[0]=1),0):(n&&(n[0]=1),2);case 4:return t==a.wintype_TextBuffer||t==a.wintype_Graphics&&w,0;case 5:return 0;case 6:return 0;case 7:return t==a.wintype_TextBuffer||t==a.wintype_Graphics&&w,0;case 8:return 0;case 9:return 0;case 10:return 0;case 11:return 0;case 12:return t==3||t==4,0;case 13:return 0;case 14:return 0;case 15:return 1;case 16:return 1;case 17:return 1;case 18:return 1;case 19:return t==a.keycode_Escape||t>=a.keycode_Func12&&t<=a.keycode_Func1,0;case 20:return 0;case 21:return 0;case 22:return 0;case 23:return 0;case 4352:return 0}return 0}},g=class{set_value(e){this.value=e}get_value(){return this.value}},p=class{constructor(e){this.fields=[]}push_field(e){this.fields.push(e)}set_field(e,t){this.fields[e]=t}get_field(e){return this.fields[e]}get_fields(){return this.fields}},w=typeof window=="object",a={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_ResourceStream:22,gestalt_GraphicsCharInput:23,keycode_Unknown:4294967295,keycode_Left:4294967294,keycode_Right:4294967293,keycode_Up:4294967292,keycode_Down:4294967291,keycode_Return:4294967290,keycode_Delete:4294967289,keycode_Escape:4294967288,keycode_Tab:4294967287,keycode_PageUp:4294967286,keycode_PageDown:4294967285,keycode_Home:4294967284,keycode_End:4294967283,keycode_Func1:4294967279,keycode_Func2:4294967278,keycode_Func3:4294967277,keycode_Func4:4294967276,keycode_Func5:4294967275,keycode_Func6:4294967274,keycode_Func7:4294967273,keycode_Func8:4294967272,keycode_Func9:4294967271,keycode_Func10:4294967270,keycode_Func11:4294967269,keycode_Func12:4294967268,keycode_MAXVAL:28,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,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,wintype_AllTypes:0,wintype_Pair:1,wintype_Blank:2,wintype_TextBuffer:3,wintype_TextGrid:4,wintype_Graphics:5,winmethod_Left:0,winmethod_Right:1,winmethod_Above:2,winmethod_Below:3,winmethod_DirMask:15,winmethod_Fixed:16,winmethod_Proportional:32,winmethod_DivisionMask:240,winmethod_Border:0,winmethod_NoBorder:256,winmethod_BorderMask:256,fileusage_Data:0,fileusage_SavedGame:1,fileusage_Transcript:2,fileusage_InputRecord:3,fileusage_TypeMask:15,fileusage_TextMode:256,fileusage_BinaryMode:0,filemode_Write:1,filemode_Read:2,filemode_ReadWrite:3,filemode_WriteAppend:5,seekmode_Start:0,seekmode_Current:1,seekmode_End:2,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,imagealign_InlineUp:1,imagealign_InlineDown:2,imagealign_InlineCenter:3,imagealign_MarginLeft:4,imagealign_MarginRight:5},y=80,k=class{constructor(e){this.focused=!1;this.mainElement=e,$(e).css("overflowY","auto")}async start(){await l("./lib/zvm/ifvms.min.js");var e=this.mainElement,t=$('<div id="gameport"/>').appendTo(e),n=$('<div id="upperport" class="transcript transcript-split transcript-style-2"/>').insertBefore(e).hide(),r=$('<div id="windowport" class="transcript"/>').appendTo(t),s=$('<input class="transcript-input" type="text"/>').appendTo(t).hide();this.glk=new c(r[0],s[0],n[0]),this.resize=()=>{var o=$(t).width()*1.6/y;$(n).css("font-size",o+"px")},this.resize()}loadROM(e,t){this.zfile=t,this.reset()}getROMExtension(){return".z"+(this.zvm.version||5)}reset(){this.zfile!=null&&(this.zvm=new ZVM,this.zvm.prepare(this.zfile.slice(0),{Glk:this.glk}),this.glk.reset(),this.glk.init({vm:this.zvm}),console.log(this.zvm))}pause(){}resume(){}readAddress(e){return this.zvm&&e<this.zvm.ram.byteLength?this.zvm.ram.getUint8(e):this.zfile[e]}getPC(){return this.zvm.pc}isRunning(){return this.zvm!=null&&!this.glk.exited}advance(e){return 0}getToolForFilename(e){return"inform6"}getDefaultExtension(){return".inf"}showHelp(){return"https://www.inform-fiction.org/manual/html/contents.html"}getPresets(){return x}inspect(e){return h(this,e)}getDebugTree(){var e={};return this.zvm!=null&&(e.Objects={$$:()=>this.getRootObjects()},e.Globals={$$:()=>this.getGlobalVariables()}),e}getObjectName(e){var t=this.getDebugLookup("object"),n=t[e]||"";return n+=" (#"+e+")",n}addObjectToTree(e,t){let n=this.getObjectName(t);e[n]=this.getObjectTree(t)}getRootObjects(){var e={};try{for(let t=0;t<65536;t++)this.zvm.get_parent(t)==0&&this.addObjectToTree(e,t)}catch(t){if(!(t instanceof RangeError))throw t}return e}getObjectTree(e){for(var t=this.zvm.get_child(e),n={};t;)this.addObjectToTree(n,t),t=this.zvm.get_sibling(t);var r=this.getFlagList(e);return r.length&&(n["[attributes]"]=r.join(" ")),n}getFlagList(e){for(var t=this.getDebugLookup("attribute"),n=[],r=0;r<32;r++)this.zvm.test_attr(e,r)&&n.push(t[r]||"#"+r);return n}getPropList(e){for(var t=this.getDebugLookup("property"),n=[],r=0,s=0;s<50&&(r=this.zvm.find_prop(e,0,r),r!=0);s++)n.push(t[r]||"%"+r);return n}getDebugLookup(e){var t=this.debugSymbols;return t&&t.debuginfo&&t.debuginfo[e]||{}}getGlobalVariables(){var e=this.getDebugLookup("global-variable"),t={};return Object.entries(e).forEach(n=>{var r=parseInt(n[0]),s=n[1];t[s]=this.zvm.m.getUint16(r)}),t}};_.zmachine=k;
//# sourceMappingURL=zmachine-QT2YTAFV.js.map