Skip to content

Commit

Permalink
[General] Fixed description of buffer_poke, which was not wrong, but …
Browse files Browse the repository at this point in the history
…confusingly written

* Also improved buffer_seek, buffer_tell, and buffer_write pages with minor improvements
YoYoGames/GameMaker-Bugs#4650
  • Loading branch information
gurpreetsinghmatharoo committed Feb 13, 2024
1 parent aacb541 commit bd6dc13
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<body>
<!--<div class="body-scroll" style="top: 150px;">-->
<h1><span data-field="title" data-format="default">buffer_poke</span></h1>
<p>With the <span class="inline3_func"><a data-xref="{title}" href="buffer_write.htm">buffer_write</a></span> function, you can write data to the given buffer at the current &quot;seek&quot; position, with each piece of data advancing this position by the bytes being written or read. However, it may be necessary for you to change a given piece of data without wanting to change the current seek position, and that&#39;s when you would use this function. You supply the function with a buffer, and then the offset position from the buffer start (in bytes) within that buffer to write to, as well as the data type and the value to be written.</p>
<p>With this function you can write data into a buffer at the specified offset, without changing the <a href="buffer_seek.htm">seek position</a>. This is different from <span class="inline3_func"><a data-xref="{title}" href="buffer_write.htm">buffer_write</a></span>, which uses the <a href="buffer_tell.htm">current seek position</a> as the offset and advances that with the amount of bytes written.</p>
<p>You supply the function with a buffer, and then the offset position from the buffer start (in bytes) within that buffer to write to, as well as the data type and the value to be written.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default">buffer_poke</span>(buffer, offset, type, value);</p>
Expand All @@ -28,22 +29,22 @@ <h4>Syntax:</h4>
</tr>
<tr>
<td>buffer</td>
<td><span data-keyref="Type_ID_Buffer"><a href="../../../../GameMaker_Language/GML_Reference/Buffers/buffer_create.htm" target="_blank">Buffer</a></span></td>
<td><span data-keyref="Type_ID_Buffer"><a href="buffer_create.htm" target="_blank">Buffer</a></span></td>
<td>The buffer to use.</td>
</tr>
<tr>
<td>offset</td>
<td><span data-keyref="Type_Real"><a href="../../../../GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The offset position (in bytes) within the buffer to write the given data to.</td>
</tr>
<tr>
<td>type</td>
<td><span data-keyref="Type_Constant_Buffer_Data_Type"><a href="../../../../GameMaker_Language/GML_Reference/Buffers/buffer_write.htm" target="_blank">Buffer Data Type Constant</a></span></td>
<td><span data-keyref="Type_Constant_Buffer_Data_Type"><a href="buffer_write.htm" target="_blank">Buffer Data Type Constant</a></span></td>
<td>The type of data that is to be written to the buffer (see the list of constants <a href="buffer_write.htm">here</a>).</td>
</tr>
<tr>
<td>value</td>
<td><span data-keyref="Type_Any"><a href="../../../../GameMaker_Language/GML_Overview/Data_Types.htm#variable" target="_blank">Any</a></span></td>
<td><span data-keyref="Type_Any"><a href="../../GML_Overview/Data_Types.htm#variable" target="_blank">Any</a></span></td>
<td>The data to add to the buffer, in accordance with the type specified.</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!--<div class="body-scroll" style="top: 150px;">-->
<h1><span data-field="title" data-format="default">buffer_seek</span></h1>
<p>This function moves the seek position of a buffer, setting it relative to the start, end or current seek position (that which was last used when reading or writing data).</p>
<p>The seek position is the offset (in bytes) from the start of the buffer where new values are written, and from where values are read. It also moves automatically when you read from or write to a buffer.</p>
<p>The seek position is the offset (in bytes) from the start of the buffer where new values are <a href="buffer_write.htm">written</a>, and from where values are <a href="buffer_read.htm">read</a>. It also moves automatically when you read from or write to a buffer.</p>
<h3>Usage Notes</h3>
<ul class="Disc">
<li>The &quot;offset&quot; value is the offset (in bytes) to add to the given seek position, for example, if the base is relative and the offset is 4, then the buffer position will move along 4 bytes from its current position. Please note the following:
Expand All @@ -35,7 +35,7 @@ <h3>Usage Notes</h3>
</colgroup>
<tbody>
<tr>
<th colspan="2"><span data-keyref="Type_Constant_Buffer_Seek"><a href="../../../../GameMaker_Language/GML_Reference/Buffers/buffer_seek.htm" target="_blank">Buffer Seek Constant</a></span></th>
<th colspan="2"><span data-keyref="Type_Constant_Buffer_Seek"><a href="buffer_seek.htm" target="_blank">Buffer Seek Constant</a></span></th>
</tr>
<tr>
<th>Constant</th>
Expand Down Expand Up @@ -67,24 +67,24 @@ <h4>Syntax:</h4>
</tr>
<tr>
<td>buffer</td>
<td><span data-keyref="Type_ID_Buffer"><a href="../../../../GameMaker_Language/GML_Reference/Buffers/buffer_create.htm" target="_blank">Buffer</a></span></td>
<td><span data-keyref="Type_ID_Buffer"><a href="buffer_create.htm" target="_blank">Buffer</a></span></td>
<td>The buffer to use.</td>
</tr>
<tr>
<td>base</td>
<td><span data-keyref="Type_Real"><a href="../../../../GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The base position to seek.</td>
</tr>
<tr>
<td>offset</td>
<td><span data-keyref="Type_Real"><a href="../../../../GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td>
<td>The data offset value.</td>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Real"><a href="../../../../GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span> (the new seek position)</p>
<p class="code"><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span> (the new seek position)</p>
<p> </p>
<h4>Example:</h4>
<p class="code"><span data-field="title" data-format="default">buffer_seek</span>(buff, buffer_seek_start, 0);<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<h1><span data-field="title" data-format="default">buffer_tell</span></h1>
<p>This function gets the current &quot;seek&quot; position for use in other buffer functions.</p>
<p>When you read or write data to a buffer using the <span class="inline3_func"><a data-xref="{title}" href="buffer_read.htm">buffer_read</a></span> or <span class="inline3_func"><a data-xref="{title}" href="buffer_write.htm">buffer_write</a></span> functions, the current &quot;seek&quot; position is advanced by the bytes written or read. For example, if your buffer alignment is set to 4 bytes and you write a single piece of data which is 1 byte in size then do a <span class="inline3_func"><span data-field="title" data-format="default">buffer_tell</span></span>, you&#39;ll get a return value of 1. However, if you write another piece of data, also 1 byte in size, then do a <span class="inline3_func"><span data-field="title" data-format="default">buffer_tell</span></span>, you&#39;ll get a return value of 5 as the alignment has &quot;padded&quot; the data to that position.</p>
<p>To change the seek value of a buffer, use <span class="inline3_func"><a data-xref="{title}" href="buffer_seek.htm">buffer_seek</a></span>.</p>
<p> </p>
<h4>Syntax:</h4>
<p class="code"><span data-field="title" data-format="default">buffer_tell</span>(buffer);</p>
Expand All @@ -30,14 +31,14 @@ <h4>Syntax:</h4>
</tr>
<tr>
<td>buffer</td>
<td><span data-keyref="Type_ID_Buffer"><a href="../../../../GameMaker_Language/GML_Reference/Buffers/buffer_create.htm" target="_blank">Buffer</a></span></td>
<td><span data-keyref="Type_ID_Buffer"><a href="buffer_create.htm" target="_blank">Buffer</a></span></td>
<td>The buffer to use.</td>
</tr>
</tbody>
</table>
<p> </p>
<h4>Returns:</h4>
<p class="code"><span data-keyref="Type_Real"><a href="../../../../GameMaker_Language/GML_Overview/Data_Types.htm" target="_blank">Real</a></span></p>
<p class="code"><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></p>
<p> </p>
<h4>Example:</h4>
<p class="code">var _pos = <span data-field="title" data-format="default">buffer_tell</span>(buff); buffer_seek(buff, buffer_seek_start, 0);<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!--<div class="body-scroll" style="top: 150px;">-->
<h1><span data-field="title" data-format="default">buffer_write</span></h1>
<p>This function can be used to write data to a previously created buffer. The data you write must be in agreement with the &quot;type&quot; argument of this function, meaning that you can&#39;t try to write a string as an unsigned 16bit integer, for example.</p>
<p>The function will write your given value at the buffer&#39;s current <a href="buffer_seek.htm">seek position</a>.</p>
<p>The function will write your given value at the buffer&#39;s <a href="buffer_tell.htm">current seek position</a>.</p>
<p>The following constants can be used to define the data type:</p>
<div data-conref="../../../assets/snippets/buffer_data_type_constants.hts"> </div>
<p>The function will return 0 if it succeeds or -1 if it fails.</p>
Expand Down

0 comments on commit bd6dc13

Please sign in to comment.