I'm wondering if there's any way to "set" the flash page to read from, so you can do
Code:
ld a,(5437h)

and other commands like that.
Nope, you have to use some calls I wrote or the equivalent. For simplicity's sake, here they are. Note that all of them use CurROMPage to indicate which ROM page to use (feel free to use any byte location you want to equate CurROMPage), and ALL work for RAM reads if CurROMPage = 0.

ldirRomRam: Copy from location HL on CurROMPage to DE in RAM.
GetArcProgByte: Like ld a,(hl) for any CurROMPage incl. RAM (0).
GetArcProgByteDE: Same, but for ld a,(de).
GetArcProgWord: A bcall(_ldhlind) equivalent for any CurROMPage.
SetUpROM: Given the location and CurROMPage indicated in a VAT entry [only for ROM, this one's not for RAM!!] this will return the pointer to the RAM-formatted part of the data (size & program data)


Code:
ldirROMRAM:
   ld a,(CurROMPage)
   or a
   jr z,ldirRAM
ldirROM:
   call GetArcProgByte
   ld (de),a
   inc hl
   inc de
   dec bc
   ld a,b
   or c
   jr nz,ldirROM
   ret
ldirRAM:
   ldir
   ret
GetArcProgByte:
   push bc
   push hl
   ld a,(CurROMPage)
   or a
   jr z,GetArcProgByteReg
   ld b,a
   call AutoArcPtrUpdate
   bcall(_LoadCIndPaged)
   ld a,c
   pop hl
   pop bc
   ret
GetArcProgByteReg:
   pop hl
   pop bc
   ld a,(hl)
   ret
GetArcProgByteDE:
   push bc
   push hl
   push de
   ld a,(CurROMPage)
   or a
   jr z,GetArcProgByteRegDE
   ld b,a
   ex de,hl
   call AutoArcPtrUpdate
   bcall(_LoadCIndPaged)
   ld a,c
   pop de
   pop hl
   pop bc
   ret
GetArcProgByteRegDE:
   pop de
   pop hl
   pop bc
   ld a,(de)
   ret
GetArcProgWord:
   push de
   push bc
   ld a,(CurROMPage)
   or a
   jr z,GetArcProgWordReg
   ld b,a
   call AutoArcPtrUpdate
   bcall(_LoadDEIndPaged)
   ex de,hl
   pop bc
   pop de
   ret
GetArcProgWordReg:
   pop bc
   pop de
   bcall(_ldhlind)
   ret
AutoArcPtrUpdate:
   bit 7,h
   ret z
   inc b
   res 7,h
   set 6,h
   ret
SetUpROM:
   ld a,(CurROMPage)
   or a
   ret z
   push de
   ld de,9
   add hl,de
   call GetArcProgByte
   ld d,0
   inc a
   ld e,a
   add hl,de
   pop de
   ret
Or you can use the system routine _FlashtoRAM
That's exceptionally slow and relatively destructive of registers.
I was looking at the source of Calcsys, and for the search function, it did something like:
Code:
push af
in a,(6)
push af
ld a,(9874h) ;the current page to browse
out (6),a
ld a,d
ld bc,0
cpir ;find first occurence of d
dec hl
pop af
in (6),a
pop af
ret
That wasn't the exact code, but you get the picture. Port 6 is the current page to read from. Wink
...or you could just use my code, which makes it supereasy. Wink
There's actually a much better way to setup an arched program, if you realize that if you add the length of the prog's name plus 10 to the datapointer, you skip right over the extra VAT entry! Very Happy

Code:
bcall _chkfindsym  ;find the program
jr c,notfound
ex de,hl   ;put data pointer into hl
xor a
cp  b   ;see if b is 0
jr z,unarched   ;if so, jump to unarched
push bc   ;save page
ld b,0   ;after chkfindsym, c=length of name
add hl,bc   ;so add that to hl
ld c,10   ;bc=10
add hl,bc   ;add 10 to hl
pop bc   ;restore page
You mean like this?? Oh, c holds name length. Well, this will deal with any pointer, including one not returned from chkfindsym, which I need in DCS. Smile

Code:
SetUpROM:
   ld a,(CurROMPage)
   or a
   ret z
   push de
   ld de,9
   add hl,de
   call GetArcProgByte
   ld d,0
   inc a
   ld e,a
   add hl,de
   pop de
   ret
Wink
I still may use the port 6 method occasionally, combined with cpir (to find stuff) or maybe even _puts might work if hl points to the place in archive...
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement