<div dir="ltr">Hi Tty,<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 22, 2014 at 5:23 AM, gettimothy <span dir="ltr">&lt;<a href="mailto:gettimothy@zoho.com" target="_blank">gettimothy@zoho.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> <br><u></u><div><div style="font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif">
I have some questions on how to proceed at the bottom of this post.<br><br>In the host simulation environment, one cannot interact with the running simulation using the standard Morphic &quot;event chain&quot;.<br><br>One cannot do so because from the host environment, there is no World in the simulation; there is only a painted picture of a World.<br>
The key to seeing this  is to grok  what a running simulation actually is. <br><br><blockquote style="border:1px solid rgb(204,204,204);padding:7px;background-color:rgb(245,245,245)"><div><br>StackInterpreterSimulator &gt;&gt; run<br>
<br>    &quot;..simulation setup code..&quot;<br><br>    [true] whileTrue:<br>        [self assertValidExecutionPointers.<br>         atEachStepBlock value. &quot;N.B. may be nil&quot;<br>         self dispatchOn: currentBytecode in: BytecodeTable.<br>
         self incrementByteCount].<br><br>    &quot;..we never get here...&quot;</div></blockquote> <br><br><br>There is no &#39;hook&#39; for me to chain the Morphic event&#39;s down into, there  are only bytecodes being fetched and executed .    (which is totally cool and awesome, btw).<br>
<br>Those bytecodes paint a pretty picture on an ImageMorph placed on a Frame placed within a SystemWindow as seen here in <br><br><blockquote style="border:1px solid rgb(204,204,204);padding:7px;background-color:rgb(245,245,245)">
<div>StackInterpreterSimulater &gt;&gt; openAsMorph<br>      <br>      &quot;....&quot;<br><br>        window addMorph: (displayView := ImageMorph new image: displayForm)<br>        frame: (0@0 corner: 1@0.8).<br><br><br>
      &quot;....&quot;<br></div></blockquote> <br><br>That image is not a PasteUpMorph named TheWorld that can respond to events--it is just a pretty picture.<br></div></div></blockquote><div><br></div><div>Let me expand on this, because what you say is not the whole picture ;-)</div>
<div><br></div><div>The Morphic event you cannot (yet) pass to the simulation came from somewhere.  It actually bubbled up from within the real VM you&#39;re running.  It started off as an OS event coming in through EventSensor&gt;&gt;primGetNextEvent: which is sent from fetchMoreEvents.  From there EventSensor&gt;&gt;processEvent: created the Morphic event that you&#39;re having problems with.</div>
<div><br></div><div>Inside the real VM that OS event was responded to by the VM first calling ioProcessEvents from its event polling routine StackInterpreter&gt;&gt;ioProcessEvents, and then fetching the OS event via InterpreterPrimitives&gt;&gt;primitiveGetNextEvent, which implements EventSensor&gt;&gt;primGetNextEvent:.  Inside primitiveGetNextEvent there&#39;s a call to ioGetNextEvent: which will answer the OS event that primitiveGetNextEvent answers as an Array.</div>
<div><br></div><div>Addressing the simulation, what is painting the picture is the VM simulator that sits behind the window.  Within this VM there is a simulation of both ioProcessEvents and ioGetNextEvent:, but they do nothing:</div>
<div><br></div><div>StackInterpreterSimulator&gt;&gt;ioProcessEvents<br></div><div><span style="white-space:pre">        </span>&quot;do nothing...&quot;</div><div><br></div><div>StackInterpreterSimulator&gt;&gt;ioGetNextEvent: evtBuf</div>
<div><br></div><div><span class="" style="white-space:pre">        </span>self primitiveFail.</div><div><br></div><div>So your challenge is to take the Morphic event, queue it inside StackInterpreterSimulator (e.g. in a new inst var eventQueue), and convert it to an OS event (an Array), so that it can for example implement ioGetNextEvent: as something like</div>
<div><br></div><div><div>StackInterpreterSimulator&gt;&gt;ioGetNextEvent: evtBuf</div><div><br></div><div><span class="" style="white-space:pre">        eventQueue isEmpty ifTrue:</span></div></div><div><span class="" style="white-space:pre"><div style="white-space:normal">
<span style="white-space:pre">        </span><span style="white-space:pre">        [^</span>self primitiveFail].</div><div style="white-space:normal"><br></div></span></div><div><span style="white-space:pre">        self convertMorphicEvent: eventQueue removeFirst into: evtBuf</span><br>
</div><div><span style="white-space:pre"><br></span></div><div><span style="white-space:pre">HTH</span></div><div><span style="white-space:pre"><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><div style="font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif">That ladies and gentleman is the point where us fat and coddled coder Hobbit&#39;s have to enter the dragon&#39;s cave, leaving the<br>comfortable environment of the Squeak API for whatever strange and dangerous world lies below; Me? I decided to post here instead<br>
before venturing in (:<br><br>So, having learned this the hard way, there are a couple of strategies I could take--RFB, or maybe Nebraska-- to get events over to<br>the target image but before doing that I have to ask is it really necessary? <br>
<br>My goal is to port the StackInterpeter to native 64 (and after that 64x64). Presumably Eliot managed to do the original work without the<br>use of direct interaction with morphic on the running world, so shouldn&#39;t my task now be to emulate whatever techiques Eliot uses?<br>
<br>If so, that raises the final point. What exactly are those techniques? Specifically, given a running simulation, how does one produce<br>a new VM? Do we boot up the target image on which we have developed and run VMMaker the standard way?<br>
<br><br>Finally, direct interaction with the runnig simulation world is desirable, I will be happy to implement it. Just please inform me of what strategy you would prefer and I<br>will try to get it done.<br><br>Thank you for your time.<br>
<br></div></div><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>