<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Comments for page &quot;External Levels/Files&quot;</title>
		<link>http://z80-heaven.wikidot.com/forum/t-159366/external-levels-files</link>
		<description>Posts in the discussion thread &quot;External Levels/Files&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Fri, 13 Mar 2026 08:53:40 +0000</lastBuildDate>
		
					<item>
				<guid>http://z80-heaven.wikidot.com/forum/t-159366#post-1729216</guid>
				<title>External Levels/Files</title>
				<link>http://z80-heaven.wikidot.com/forum/t-159366/external-levels-files#post-1729216</link>
				<description></description>
				<pubDate>Tue, 12 Mar 2013 04:29:37 +0000</pubDate>
				<wikidot:authorName>Xeda Elnara</wikidot:authorName>				<wikidot:authorUserId>595803</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>For your code accessing the files, here is some code that might be useful:</p> <div class="code"> <pre><code> ld hl,Name rst rMov9ToOP1 bcall(_ChkFindSym) jr c,FileNotFound ld a,b ld b,0 or a jr z,SizeBytes add hl,bc ld c,10 add hl,bc jp m,SizeBytes inc a ld h,40h SizeBytes: ;at this point, A is the flash page the data is on (or 0 if in RAM) ;HL points to the size bytes</code></pre></div> <br /> Now from here, you have two options. If you are working from an App, you will probably either want to copy archive reading code to RAM, or use a bcall like _FlashToRAM or _FlashToRAM2. If it is a program in RAM, I would combine it all like this: <div class="code"> <pre><code> ld hl,Name rst rMov9ToOP1 bcall(_ChkFindSym) jr c,FileNotFound in a,(6) push af ;save the current flash page ld a,b ld b,0 or a jr z,SizeBytes add hl,bc ld c,10 add hl,bc jp m,SizeBytes inc a ld h,40h SizeBytes: out (6),a ld c,(hl) inc l call z,AdjustAHL ld b,(hl) inc l call z,AdjustAHL ex (sp),hl ld l,a ld a,h out (6),a ld a,l pop hl ;now AHL points to the variable data, BC is the size of the data ;You can either copy the rest of the data to a temp variable or to saferam, or whatever, but the original variable can remain archived or unarchived &lt;&lt;rest of code&gt;&gt;</code></pre></div> <br /> And the call AdjustAHL would be this: <div class="code"> <pre><code> inc h ret m inc a out (6),a ld hl,40h ret</code></pre></div> <br /> And you could similarly create your own archive reading routine: <div class="code"> <pre><code>ReadArc: ;Inputs: ; A is the flash page on which to read (or 0 if in RAM) ; HL points to the data to read ; DE points to where to copy the data ; BC is the number of bytes to copy ;Outputs: ; BC is 0 or a jr nz,FlashPageRead ld a,b or c ret z ldir ret FlashPageRead: push hl ld l,a ld a,b or c jr z,Pop1Exit in a,(6) ld h,a ld a,l ex (sp),hl out (6),a ArcReadLoop: ldi jp po,ExitArcRead bit 7,h jr nz,ArcReadLoop ld h,40h inc a out (6),a jp ArcReadLoop ;JP is one byte larger than JR, but 2 t-states faster ExitArcRead: pop af out (6),a ret Pop1Exit: pop hl ret</code></pre></div> <p>Also, sorry if that code is broken, I am really tired at the moment.</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>