This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 21 Dec 2008 08:29:30 pm    Post subject:

I'm trying to read the address of the start of data from the VAT entry for a picture, but I can't get the right value.

This is what I have:

Code:
   ld   HL, Pic1           ;Put VAT location in HL
     b_call(_Mov9ToOP1)
     b_call(_ChkFindSym)

;Get data location
     dec   HL    ;Data location starts at VAT location - 3
     dec   HL
     dec   HL    ;This givesthe correct address of the 'start of data', so the problem must be somewhere after here
     ld   A, (HL)          ;get the data location into HL
     dec   HL
     ld   H, (HL)
     ld   L, A

     push   HL            ;display data location
     b_call(_ClrLCDFull)
     b_call(_HomeUp)
     pop   HL
     b_call(_DispHL)
     ret

Pic1:
     .db   $07, tVarPict, tPic1, $00


Here are the data addresses and what this program gives me (P):
Pic1: Actual=A0C6, P=A110
Pic2: Actual=A3C5, P=A40F
Pic3: Actual=9DC7, P=9E11

The difference between them is the same, but that value isn't constant. It seems to hange after resetting the calc, so I can't just add/subtract the offset since it can change.


Any help would be appreciated.

ps: If it turns out to be a really stupid/simple mistake, don't worry about trying to phrase it nicely.
Back to top
benryves


Active Member


Joined: 23 Feb 2006
Posts: 564

Posted: 21 Dec 2008 09:02:25 pm    Post subject:

_ChkFindSym returns a pointer to the variable data in DE. Picture variables, like program variables and appvars, have a two-byte size prefix (always 63*12=756 for pictures) so you'll need to INC DE twice to point at the pixel data.

Last edited by Guest on 21 Dec 2008 09:02:49 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 21 Dec 2008 09:12:08 pm    Post subject:

The difference between them is probably because your program is loaded into the start of userMem before being run. Wink Then the pic moves forward a bit in memory. When the program exits, the copy gets deleted and the pic moves back.
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 21 Dec 2008 09:22:57 pm    Post subject:

benryves wrote:
_ChkFindSym returns a pointer to the variable data in DE. Picture variables, like program variables and appvars, have a two-byte size prefix (always 63*12=756 for pictures) so you'll need to INC DE twice to point at the pixel data.
[post="130573"]<{POST_SNAPBACK}>[/post]

I was using that, but it wasn't giving me the right answer either so I tried using the VAT entry. Using the DE pointer I get $A0E5 when it should be $A0C6.

Even though there's an easier way to do it, is the code I posted valid or is there a problem with it?

I'm using CalcSys to get the true location of the data and Wabbit with an 84+SE ROM if it matters.


[edit]
calc84maniac wrote:
The difference between them is probably because your program is loaded into the start of userMem before being run. Wink Then the pic moves forward a bit in memory. When the program exits, the copy gets deleted and the pic moves back.
[post="130574"]<{POST_SNAPBACK}>[/post]

So the location of the pic data is different when there's a program running?


Last edited by Guest on 21 Dec 2008 09:24:24 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 21 Dec 2008 09:29:24 pm    Post subject:

If you're using the pic data while your program is running, you won't have to worry about it. The problem was that Calcsys wouldn't give you an accurate account of where the pic was at runtime because of data shifting. Wink
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 21 Dec 2008 09:33:05 pm    Post subject:

calc84maniac wrote:
If you're using the pic data while your program is running, you won't have to worry about it. The problem was that Calcsys wouldn't give you an accurate account of where the pic was at runtime because of data shifting. Wink
[post="130577"]<{POST_SNAPBACK}>[/post]

Okay, thanks :biggrin:. I've been trying to figure out why I couldn't get the right address for a few hours Cool
I will be using the pic data from within the program so it should be fine.


Last edited by Guest on 21 Dec 2008 09:34:24 pm; edited 1 time in total
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 22 Dec 2008 12:13:25 am    Post subject:

I needed to find the address of pic data for a program to copy one Pic to another without modifying the graphscreen or buffer. Since this is my first actual program, could someone look it over and see if there are any potential issues with it. I've tested it and haven't found anything, but I want to be sure.

Code:
.nolist
     #include "ti83plus.inc"
.list
.org   $9D93
     .db   t2ByteTok, tAsmCmp

;Copy Pic# Ans(1) to Pic# Ans(2)

     b_call(_AnsName)
     b_call(_FindSym)            ;pointer to data in DE
     jp   C, _NoAns      ;if Ans isn't list, skip everything
     and   $1F
     cp   $01
     jr  NZ, _NoAns

     inc   DE          ;skip length bytes
     inc   DE
     ld    H, D          ;need pointer in HL
     ld   L, E

     push   HL            ;save pointer
     call   GetPicNum          ;First pic, modify name
     ld  (FirstPic + 2), A
     pop   HL          ;Second pic, modify name
     ld         BC, $09            ;Increment to second number
     add   HL, BC
     call   GetPicNum
     ld         (SecondPic + 2), A

     ld         HL, FirstPic        ;get pointer to FirstPic data
     b_call(_Mov9ToOP1)
     b_call(_ChkFindSym)
     jr         C, _NoAns        ;if no pic, skip to end
     inc   DE          ;skip length bytes
     inc   DE
     push   DE

     ld  HL, SecondPic            ;get pointer to SecondPic data
     b_call(_Mov9ToOP1)
     b_call(_ChkFindSym)
     jr         NC, _Okay
     b_call(_CreatePict)
_Okay:
     pop   HL
     ld  A, $F4;set length bytes
     ld         (DE), A
     inc   DE
     ld         A, $02
     ld  (DE), A
     inc   DE
     ld         BC, $02F4        ;copy source pic to other pic
     ldir
_NoAns:
     ret

GetPicNum:          ; in: HL=pointer to num,   out: A=number
     b_call(_Mov9ToOP1)
     b_call(_ConvOP1);integer in E (<256)
     ld  A, tPic1 - 1
     add   A, E
     ret


FirstPic:
     .db   $07, tVarPict, tPic1, $00;tPic1 == FirstPic + 2
SecondPic:
     .db   $07, tVarPict, tPic1, $00


.end
.end


The input is {A,B:Asm(prgmCOPYPIC to copy PicA to PicB.

Thanks

[edit] Fixed error in the code. I had and A instead of and $1F


Last edited by Guest on 12 Jul 2010 01:42:14 am; edited 1 time in total
Back to top
Mapar007


Advanced Member


Joined: 04 Oct 2008
Posts: 365

Posted: 22 Dec 2008 06:54:25 am    Post subject:

I think you should replace


Code:
b_call(_AnsName)
b_call(_FindSym)

with:

Code:
b_call(_RclAns)

Just for optimization Very Happy (I don't know whether it has any other advantage lol)
And why the and a?

to switch the pointers, use: ex de,hl

And instead of jp c, _NoAns and jp nz, _NoAns, use ret c and ret nz respectively.


And to find pics, you use _FindSym and not _ChkFindSym

I don't see any other issues, but I don't have that much experience after all Smile
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 22 Dec 2008 10:00:17 am    Post subject:

Mapar007 wrote:
I think you should replace


Code:
b_call(_AnsName)
b_call(_FindSym)

with:

Code:
b_call(_RclAns)

Just  for optimization Very Happy (I don't know whether it has any other advantage lol)
[post="130587"]<{POST_SNAPBACK}>[/post]

Actually, _RclAns is fairly useless unless you're wanting Ans to be a number. If Ans was a list, _RclAns would do the same thing as _AnsName.

(I think.)
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 22 Dec 2008 10:40:44 am    Post subject:

Mapar007 wrote:
And why the and a?

FindSym returns the object type in A, but bits 5-7 are garbage, so AND $1F takes care of that.

Quote:
to switch the pointers, use: ex de,hl

Good idea. I always forget about ex.

Quote:
And instead of jp c, _NoAns and jp nz, _NoAns, use ret c and ret nz respectively.

I'll try that. Thanks


Last edited by Guest on 12 Jul 2010 01:42:35 am; edited 1 time in total
Back to top
Mapar007


Advanced Member


Joined: 04 Oct 2008
Posts: 365

Posted: 22 Dec 2008 10:42:52 am    Post subject:

_RclAns sets up pointers to Ans if not real, _AnsName just sets OP1 to $00,$72 and seven other $00 bytes. (tAns, actually, $0072)
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 22 Dec 2008 11:41:26 am    Post subject:

I just tried using _RclAns. The good news is that it cut 3 bytes from the program size Smile , the bad news is the program doesn't work now :(

I also realized I didn't have to manually put in the length bytes, since both pics are the same size. This changed

Code:
_Okay:
    pop HL
    ld  A, $F4;set length bytes
    ld         (DE), A
    inc DE
    ld         A, $02
    ld  (DE), A
    inc DE
    ld         BC, $02F4      ;copy source pic to other pic
    ldir

to

Code:
_Okay:
     pop   HL
     ld  BC, $02F6;copy source pic to other pic
     ldir

and I was able to cut out the two pairs of inc DE when getting the pointers.

[edit][s]I have one more question. Is there a command/b_call that converts a one-byte integer to a floating point number? I can't find anything in the list of b_calls, but I might not be searching for the right keyword.[/s]

[another edit] [s]Better yet, is there something to turn a two-token string into a floating-point number (i.e. turn "FF" into $00, $82, $25, $50, $00, $00, $00, $00, $00). I have a routine to get the string into an integer, but it's a bit lengthy.[/s]

[another another edit] I figured it out (using _SetXXXOP1). I just need to compensate if the number is over 99.


Last edited by Guest on 12 Jul 2010 01:41:52 am; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 22 Dec 2008 12:39:22 pm    Post subject:

Mapar007 wrote:
_RclAns sets up pointers to Ans if not real, _AnsName just sets OP1 to $00,$72 and seven other $00 bytes. (tAns, actually, $0072)
[post="130591"]<{POST_SNAPBACK}>[/post]

No, this is not true. If it's not real, it puts a name you can _FindSym into OP1, otherwise it puts the number into OP1. I'm pretty sure here.

Oh, and _SetXXXXOp2 will put the value in HL into OP2 as long as 0<=HL<=9999 (which works for your purposes).

Edit: Also, you put and a instead of and $1f, which is why he asked. :)

Edit2: I found a demonstrated use of _RclAns on another site:

Code:
    b_call(_RclAns)
    ld a,(op1)
    cp 04h
    ret nz
    b_call(_ChkFindSym)

So it seems I am right. :D

Edit3: From other places in my Google search, it seems that we are both right. Hmm. It puts the name in OP1 and returns the pointers.


Last edited by Guest on 12 Jul 2010 01:38:37 am; edited 1 time in total
Back to top
Mapar007


Advanced Member


Joined: 04 Oct 2008
Posts: 365

Posted: 23 Dec 2008 03:13:15 am    Post subject:

Yes of course... should have seen it Very Happy (I used a similar piece of code myself lol)
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement