Skip to content

Commit 07f2360

Browse files
add MEMFIND
1 parent 4e6df2d commit 07f2360

258 files changed

Lines changed: 1410 additions & 1032 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docpages/basic-language-reference/functions/integer/02_INDEX.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following functions operate on or return **integer values** in Retro Rocket
5353
* \subpage MAPHAS
5454
* \subpage MAX
5555
* \subpage MEMALLOC
56+
* \subpage MEMFIND
5657
* \subpage MEMFREE
5758
* \subpage MEMORY
5859
* \subpage MEMPEAK
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
\page MEMFIND MEMFIND Function
2+
3+
```basic
4+
MEMFIND(start, length, value)
5+
```
6+
7+
Searches a memory region for the first occurrence of a byte value.
8+
9+
Returns the address of the matching byte, or zero if the value is not found.
10+
11+
---
12+
13+
### Examples
14+
15+
```basic
16+
REM Find the first NUL byte in a buffer
17+
18+
P = MEMFIND(BUFFER, 100, 0)
19+
20+
IF P THEN
21+
PRINT "Found at "; P
22+
ENDIF
23+
```
24+
25+
```basic
26+
REM Extract a NUL-terminated tar filename
27+
28+
ENDPOS = MEMFIND(HEADER, 100, 0)
29+
30+
IF ENDPOS = 0 THEN
31+
ENDPOS = HEADER + 100
32+
ENDIF
33+
34+
NAME$ = BUFFERTOSTRING$(HEADER, ENDPOS - HEADER)
35+
36+
PRINT NAME$
37+
```
38+
39+
```basic
40+
REM Search for a marker byte
41+
42+
POS = MEMFIND(DATA, SIZE, &FF)
43+
44+
IF POS THEN
45+
PRINT "Escape byte found at "; POS
46+
ENDIF
47+
```
48+
49+
---
50+
51+
### Notes
52+
53+
* `start` is the starting memory address to search.
54+
* `length` is the number of bytes to scan.
55+
* `value` must be between 0 and 255.
56+
* Returns the address of the first matching byte.
57+
* Returns zero if the value is not found.
58+
* The search is performed using a forward linear scan.
59+
60+
---
61+
62+
### Errors
63+
64+
* MEMFIND: Invalid byte value
65+
* Bad Address
66+
67+
---
68+
69+
**See also:**
70+
\ref PEEK "PEEK" · \ref POKE "POKE" · \ref BUFFERTOSTRINGS "BUFFERTOSTRING$" · \ref STRINGTOBUFFER "STRINGTOBUFFER"
71+

docs/ACS.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<div class="textblock"><div class="fragment"><div class="line">ACS(real-expression)</div>
127127
</div><!-- fragment --><p>Returns the <b>arc cosine</b> (inverse cosine) of the given expression, in <b>radians</b>. The input must be between <span class="tt">-1</span> and <span class="tt">1</span>.</p>
128128
<hr />
129-
<h3 class="doxsection"><a class="anchor" id="examples-94"></a>
129+
<h3 class="doxsection"><a class="anchor" id="examples-95"></a>
130130
Examples</h3>
131131
<div class="fragment"><div class="line">PRINT ACS(1)</div>
132132
</div><!-- fragment --><p>Produces <span class="tt">0</span>.</p>
@@ -139,7 +139,7 @@ <h3 class="doxsection"><a class="anchor" id="examples-94"></a>
139139
<div class="line">PRINT ACS(COS(angle#))</div>
140140
</div><!-- fragment --><p>Produces the original angle (within floating point accuracy).</p>
141141
<hr />
142-
<h3 class="doxsection"><a class="anchor" id="notes-90"></a>
142+
<h3 class="doxsection"><a class="anchor" id="notes-91"></a>
143143
Notes</h3>
144144
<ul>
145145
<li>Argument range: <span class="tt">-1 ≤ x ≤ 1</span>. Values outside this range cause an error.</li>

docs/ADFSIMAGE.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@
126126
<div class="textblock"><div class="fragment"><div class="line">ADFSIMAGE$(path$)</div>
127127
</div><!-- fragment --><p>Creates a <b>RAM-backed block device from an ADFS disk image</b>. The parameter is the path to an ADFS S/M/L image file. Returns the device name on success.</p>
128128
<hr />
129-
<h3 class="doxsection"><a class="anchor" id="examples-115"></a>
129+
<h3 class="doxsection"><a class="anchor" id="examples-116"></a>
130130
Examples</h3>
131131
<div class="fragment"><div class="line">REM Load an ADFS disk image into RAM</div>
132132
<div class="line">RD$ = ADFSIMAGE$(&quot;chukie-egg.adl&quot;)</div>
133133
<div class="line">MOUNT &quot;/games&quot;, RD$, &quot;adfs&quot;</div>
134134
<div class="line">PRINT &quot;ADFS image mounted&quot;</div>
135135
</div><!-- fragment --><hr />
136-
<h3 class="doxsection"><a class="anchor" id="notes-111"></a>
136+
<h3 class="doxsection"><a class="anchor" id="notes-112"></a>
137137
Notes</h3>
138138
<ul>
139139
<li>The image must be a valid ADFS S/M/L disk image</li>

docs/ANIMATE.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ <h3 class="doxsection"><a class="anchor" id="example-7"></a>
159159
<div class="line">CLS</div>
160160
<div class="line">END</div>
161161
</div><!-- fragment --><hr />
162-
<h3 class="doxsection"><a class="anchor" id="notes-159"></a>
162+
<h3 class="doxsection"><a class="anchor" id="notes-160"></a>
163163
Notes</h3>
164164
<ul>
165165
<li>If the sprite is not animated (single-frame image), <span class="tt">ANIMATE</span> statements are silent no-ops.</li>

docs/ARRAYFIND.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
</li>
138138
</ul>
139139
<hr />
140-
<h5 class="doxsection"><a class="anchor" id="examples-161"></a>
140+
<h5 class="doxsection"><a class="anchor" id="examples-162"></a>
141141
Examples</h5>
142142
<p><b>Integer array</b></p>
143143
<div class="fragment"><div class="line">DIM N,5</div>
@@ -180,7 +180,7 @@ <h5 class="doxsection"><a class="anchor" id="examples-161"></a>
180180
<div class="fragment"><div class="line">0</div>
181181
<div class="line">-1</div>
182182
</div><!-- fragment --><hr />
183-
<h5 class="doxsection"><a class="anchor" id="notes-160"></a>
183+
<h5 class="doxsection"><a class="anchor" id="notes-161"></a>
184184
Notes</h5>
185185
<ul>
186186
<li><span class="tt">dest-array</span> is <b>automatically created or resized</b>:<ul>

docs/ARRSORT.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
</li>
137137
</ul>
138138
<hr />
139-
<h5 class="doxsection"><a class="anchor" id="examples-162"></a>
139+
<h5 class="doxsection"><a class="anchor" id="examples-163"></a>
140140
Examples</h5>
141141
<p><b>Integer array (ascending)</b></p>
142142
<div class="fragment"><div class="line">DIM N,5</div>
@@ -189,7 +189,7 @@ <h5 class="doxsection"><a class="anchor" id="examples-162"></a>
189189
<div class="line"> </div>
190190
<div class="line">ARRSORT D#</div>
191191
</div><!-- fragment --><hr />
192-
<h5 class="doxsection"><a class="anchor" id="notes-161"></a>
192+
<h5 class="doxsection"><a class="anchor" id="notes-162"></a>
193193
Notes</h5>
194194
<ul>
195195
<li>Sorting is <b>in place</b>; the original order is replaced</li>

docs/ARRSORTBY.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
</ul>
139139
<p>The values in <span class="tt">key-array</span> are <b>not modified</b>.</p>
140140
<hr />
141-
<h5 class="doxsection"><a class="anchor" id="examples-163"></a>
141+
<h5 class="doxsection"><a class="anchor" id="examples-164"></a>
142142
Examples</h5>
143143
<p><b>Sort indices by real key (depth sort)</b></p>
144144
<div class="fragment"><div class="line">DIM DEPTH#,6</div>
@@ -194,7 +194,7 @@ <h5 class="doxsection"><a class="anchor" id="examples-163"></a>
194194
<div class="line"> PRINT IDX(I), NAMES$(IDX(I))</div>
195195
<div class="line">NEXT</div>
196196
</div><!-- fragment --><hr />
197-
<h5 class="doxsection"><a class="anchor" id="notes-162"></a>
197+
<h5 class="doxsection"><a class="anchor" id="notes-163"></a>
198198
Notes</h5>
199199
<ul>
200200
<li>Only <span class="tt">index-array</span> is reordered; <span class="tt">key-array</span> remains unchanged</li>

docs/ASN.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<div class="textblock"><div class="fragment"><div class="line">ASN(real-expression)</div>
127127
</div><!-- fragment --><p>Returns the <b>arc sine</b> (inverse sine) of the given expression, in <b>radians</b>. The input must be between <span class="tt">-1</span> and <span class="tt">1</span>.</p>
128128
<hr />
129-
<h3 class="doxsection"><a class="anchor" id="examples-95"></a>
129+
<h3 class="doxsection"><a class="anchor" id="examples-96"></a>
130130
Examples</h3>
131131
<div class="fragment"><div class="line">PRINT ASN(0)</div>
132132
</div><!-- fragment --><p>Produces <span class="tt">0</span>.</p>
@@ -139,7 +139,7 @@ <h3 class="doxsection"><a class="anchor" id="examples-95"></a>
139139
<div class="line">PRINT ASN(SIN(angle#))</div>
140140
</div><!-- fragment --><p>Produces the original angle (within floating point accuracy).</p>
141141
<hr />
142-
<h3 class="doxsection"><a class="anchor" id="notes-91"></a>
142+
<h3 class="doxsection"><a class="anchor" id="notes-92"></a>
143143
Notes</h3>
144144
<ul>
145145
<li>Argument range: <span class="tt">-1 ≤ x ≤ 1</span>. Values outside this range cause an error.</li>

docs/ATAN.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
</div><!-- fragment --><p>Returns the <b>arc tangent</b> (inverse tangent) of the given expression, in <b>radians</b>.</p>
128128
<p>The result will always lie between <span class="tt">-PI#/2</span> and <span class="tt">PI#/2</span>.</p>
129129
<hr />
130-
<h3 class="doxsection"><a class="anchor" id="examples-96"></a>
130+
<h3 class="doxsection"><a class="anchor" id="examples-97"></a>
131131
Examples</h3>
132132
<div class="fragment"><div class="line">PRINT ATAN(0)</div>
133133
</div><!-- fragment --><p>Produces <span class="tt">0</span>.</p>
@@ -140,7 +140,7 @@ <h3 class="doxsection"><a class="anchor" id="examples-96"></a>
140140
<div class="line">PRINT ATAN(TAN(angle#))</div>
141141
</div><!-- fragment --><p>Produces the original angle (within floating point accuracy).</p>
142142
<hr />
143-
<h3 class="doxsection"><a class="anchor" id="notes-92"></a>
143+
<h3 class="doxsection"><a class="anchor" id="notes-93"></a>
144144
Notes</h3>
145145
<ul>
146146
<li>Input range: any real number is valid.</li>

0 commit comments

Comments
 (0)