<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 15, 2014 at 1:24 PM, David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.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"><div class=""><br>
On Fri, Mar 14, 2014 at 06:44:59PM -0700, tim Rowledge wrote:<br>
&gt;<br>
&gt;<br>
&gt; On 14-03-2014, at 6:16 PM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; Hi Tim,<br>
&gt; &gt;<br>
&gt; &gt;     I&#39;m simulating bitblt code and have a situation where<br>
&gt; &gt;<br>
&gt; &gt; (cmShiftTable at: 0) = 4294967280<br>
&gt; &gt; (cmShiftTable at: 0) hex &#39;16rFFFFFFF0&#39;<br>
&gt; &gt;<br>
&gt; &gt; Clearly this should be -4.<br>
&gt; &gt;<br>
&gt; &gt; This breaks simulation because<br>
&gt; &gt;         (sourcePixel bitAnd: (cmMaskTable at: 0)) bitShift: (cmShiftTable at: 0)<br>
&gt; &gt; is trying to make a 4Gb LargePositiveInteger ;-).<br>
&gt; &gt;<br>
&gt; &gt; How can we make it so?<br>
&gt;<br>
</div>&gt; Hmm, well if you need to make a 4Gb LPI I guess you?d best have plenty of memory?<br>
<div class="">&gt;<br>
&gt; Dunno; looks like cmShiftTable is supposed to use int32_t thingies in the C code.<br>
&gt; BitBltSimulation&gt;loadColorMapShiftOrMaskFrom: looks like the culprit to me though -  (simulated)firstIndexableField: might be not doing the right thing?<br>
&gt;<br>
<br>
</div>firstIndexableField is ok, this looks like a problem elsewhere.<br>
<br>
Probably not helpful, but maybe it will point someone to a clue: The shifts array<br>
in a color map is an IntegerArray, so must be signed 32 bit int. Somewhere along<br>
the line, a perfectly valid entry in shift array with value -16 must have gotten<br>
converted or cast to unsigned int, such that it was now being interpreted as an<br>
integer with value 16rFFFFFFF0. I&#39;m not very familiar with BitBlt, but this looks<br>
to me like in inappropriated conversion from int to unsigned, or possibly something<br>
related to the way an integer value is being extracted from an IntegerArray.<br></blockquote><div><br></div><div>There are two different initializations.  One in setupColorMasksFrom:to: uses an explicit IntegerArray (and this will work).  The other in loadColorMap uses loadColorMapShiftOrMaskFrom: which just answers a vanilla CArray, and this won&#39;t work without appropriate access through the CArray.  To add that I added this at the end of loadColorMap, immediately before the ^true:</div>
<div><br></div><div><div><span class="" style="white-space:pre">        </span>self cCode: [] inSmalltalk:</div><div><span class="" style="white-space:pre">                </span>[cmShiftTable ifNotNil:</div><div><span class="" style="white-space:pre">                        </span>[cmShiftTable := CPluggableAccessor new</div>
<div><span class="" style="white-space:pre">                                                                </span>setObject: cmShiftTable;</div><div><span class="" style="white-space:pre">                                                                </span>atBlock: [:obj :idx| obj intAt: idx - 1]</div><div><span class="" style="white-space:pre">                                                                </span>atPutBlock: [:obj :idx :val| obj intAt: idx - 1 put: val];</div>
<div><span class="" style="white-space:pre">                                                                </span>yourself]].</div></div><div><span style="white-space:pre">        ^true</span><br></div></div>-- <br>best,<div>Eliot</div>
</div></div>