New Appvar utility

A forum where you can announce your awesome project(s).

Moderator: MaxCoderz Staff

King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

New Appvar utility

Post by King Harold »

I know there are milions of them out there, but because im quite disapointed about the "rflib" i got from ticalc.org (doesnt store chars yet and FP storing seems a bit like wasting space to me, asm libs should be much over 1k and you can store a FP number as 9 integers)
nor does it have the ability to enlarge/shrink appvars (which isnt all that hard)
and source code isnt even included (not that it really matters, but its nicer to other ppl if you include it)
So, there i go, im trying to make an appvar lib, but since im me and thus a programming noob it will probebly take a while (i will finish it though, i promise you that, but if it takes 1 year...)
i allready found something that isnt hard but i cant do anyway, which is making the name of the appvar a proper variable so that you can input a name/number for the name, any tips? (if i load hl with a value the names are like ^%#&^*#v is there something like sub(substring. number, length) for asm?)

update: I will probebly make 2 versions for the first release: 1 for speed (no error checking bcalls that take a lot of time) and 1 for safety loaded with error checking and data validating bcalls
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Well, after you input the user's name, be sure that you append a zero to the end of it. Also, I believe you'll have to store the name into OP1 and use some of the other ROM calls sto handle its creation.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

hmm that doesnt sound like thats the point of my code, have a look:

Code: Select all

.nolist
#include "ti83plus.inc"
#define    ProgStart    $9D95
.list
.org    ProgStart - 2
    .db    t2ByteTok, tAsmCmp
        bcall(_RclAns)		; recall Ans
        ld hl,1			; 1st element in Real List
        bcall(_GetLtoOp1)	; get element
        bcall(_ConvOp1)		; returns a as LSByte (and de as the total 16bit value)
	or a			
	JP Z,create_var		
	dec a			
	JP Z,del_var		
	dec a			
	JP Z,put_int		
	ret		

create_var:
	bcall(_RclAns)		;rcl ans because its lost
	ld hl, 2		;2nd list element (size)
	bcall(_GetLtoOp1)	;put it in op1
	bcall(_ConvOp1)		;make it a number and put it in de
	push de			;push de because it gets destructed
	ld hl,3			;3rd list element (name)
	bcall(_GetLtoOp1)	;put it in op1
	bcall(_ConvOp1)		;make it a number and put it in de (somehow this has to make a name)
				;name generation based on de (3rd element of list) (later)
	ld hl, var_name		;testingfase namegeneration
	bcall(_Mov9ToOP1)	;put the name in hl
	bcall(_ChkFindSym)	;see if it needs to be deleted
	JR C, create_var_2	;jump if it doesnt exist
	bcall(_DelVarArc)	;delete if so
create_var_2:
	pop hl			;pop size (was de) in hl, name is still in OP1
	bcall(_CreateAppVar)	;duhh..
	ret
del_var:
	bcall(_RclAns)
	ld hl, 2		;for deleting the name should be in the 2nd element
	bcall(_GetLtoOp1)	;2nd element to op1
	bcall(_ConvOp1)		;store the number in de
				;name generation based on de.. (need help on that)
	ld hl, var_name		;name in hl
	bcall(_Mov9ToOP1)	;name in op1
	bcall(_ChkFindSym)	;check if it exists, cant delete non-existant things
	JR C, not_found		;if not found, dont delete
	bcall(_DelVar)		;else delete
	ld a, 1			;1 in a
	bcall(_SetxxOP1)	;1 in op1
	bcall(_StoX)		;op1 in x (tell user that the appvar has (probebly) been deleted
	ret
put_int:
	ret			;not made yet
var_name:
	.db AppVarObj, "testvar "	;testname untill i make name generation
not_found:
	xor a			;if the appvar has not been found, 0 to a
	bcall(_SetxxOp1)	;a to op1
	bcall(_StoX)		;op1 to x (0 to x)
	ret

.end
END
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

alright my "err:dim" got ever stranger, it now happens when you try to make an appvar SMALLER then 256
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

I'll take a look at it. :)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Fixed a name bug (it generated insane names), i forgot a RclAns (omg)
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

So, does it work now? I've been trying to figure out exactly how the program works!

What is passed in through the Ans variable? Does it store the pointer to OP1? And how does GetLtoOP1 work? hl is the list's index, any other paramaters?
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

things like {0,size,name are passed through ans to tell the program what we want it to do
thats checked by the first few lines of code with the jumps
I dont axactly know what is stored in OP1 at RclAns but GetLtoOp1 works with it, and works just fine
hl is the list index and op1 is something with the list that came from ans - that all works fine
I still dont have a working way to create names like this:
"Var"+ 5 digits (integer value 0 - 65536)
in basic this would have been a piece of cake
just
Y being the number to convert
"_ ->Str1
for( X,1,5
Str1+sub("0123456789", iPart(10^(X-1)fPart(Y/(10^x))+1,1)->Str1
End
sub(Str1,2,5)->Str1 (remove space, space is there because of a zero-length bug)
but in assembly....??
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

A variable can have a space in assembly...

So wait, you're trying to create an appvar named VARXXXXX where XXXXX is a number?

Well, when you store something into a floating point variable, each nibble represents a digit.
They take the form:
Sign: $00=positive integer, $80 = negative
Decimal Point location: $80 = x10^0, $81 = x10^1, $7F=x10-1, etc
XX: first X is one digit, second X is another
Sign, DecLocation, XX,XX,XX,XX,XX,XX,XX

Ex: 15,540 would be
$00, $84, $15,$54,$0/\0,$00,$00,$00,$00
where the decimal would be.

I'm fairly certain that that is how the number would be stored in OP1/2/wherever it's stored, all you would need to do is skip the first two bytes of the OP1 register, load it into a, do AND $F0 to clear out the second digit, shift the bits over to the right, append that digit to your appvar name, reload that byte into a, AND $F to clear out the bits corresponding to the first digit, append that to your appvar name, and then go to the next byte and repeat.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

You must remember to convert the numbers to ASCII before appending to the name.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

True that, I think you have to add 32 to the number or something. Something around there.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

$30 really, but can i then just do this:

var_name:
.db AppVarObj, "Var", $20, $20, $20, $20, $20, 0

$20 is a space without ending the string
so do i store the value+$30 in var_name + offset and then pretend its a string?
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Yea, it will be a string. To the calculator it is a null-terminated string.

But yea, take the value from the OP register, convert it to an ascii string ($30?) then load it into the offset in the name (var_name+4 + offset in the OP register). But remember, the OP register stores the digits by nibble (4 bits), so for the leftmost nibble, you'll have to shift it to the right (srl should work, I believe). If you use a shift that loads the carry into the 7th bit, be sure to make sure it isn't set.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

yes $30 equals the large font 0 (zero)
that OP thing is a very good plan so i'll just mess around with the code untill it works, the newst problem however is unfortunately with the read/write functions..
edt: the routine works almost perfect, except that a number multiplied by 10^n will result in the same name, eg 4, 40, 400, 4000 and 40000 will be the same name, i think it can be solved by starting at the end, am i right?
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Probably not. It loads the zeros because that's what is in an OP register when it is null, so if we wanted to erase the zeros we'd have to write a routine that goes back through and overwrites it. What do you want it to be? Spaces? X's?
Post Reply