Author Topic: Please Help  (Read 8754 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Please Help
« on: May 17, 2011, 04:31:30 pm »
I've been coding so long and hard, I'm getting lazy. Can someone please help me with a few small routines:


AppVar Format, per entry

I1  I2  I3  I4  I5  U1  U2  U3  U4  U5  U6  U7  U8  C9  C1  C2  C3  C4  C5  C6  C7  C8  C9  C10  C11  C12
I = Calc ID (5-bytes)
U= Username
C= Coordinates

1: Routine to search an appvar pointed to by 'de' for an 8 byte username, pointed to by 'hl'. At the end, 'de' should point to I1

2: Routine to search an appvar pointed to by 'de' for the 12-byte coordinates pointed to by 'hl'. At the end, 'de' should point to I1

3: Routines to search an appvar pointed to by 'de' for the ID, pointed to by 'hl'. At the end, 'de' should point to (1) the associated user name (U1), and (2) the associated coordinates (C1).

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #1 on: May 17, 2011, 06:08:17 pm »
So are these all different appvars? If they are, why don't you throw them all into one big appvar?
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Please Help
« Reply #2 on: May 17, 2011, 06:26:36 pm »
No, it is one appvar, with one entry right after the next. Each player's info requires 25 bytes, 5 for the ID, 8 for the username, and 12 for the coordinates.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #3 on: May 17, 2011, 06:59:03 pm »
Ok, I'm glad it was all in one appvar because that makes it way easier.

Code: [Select]

;##########################################
;search for a user
;input: de = ptr to start of appvar data, (including size bytes)
; hl = ptr to username
;ouput: de = ptr to start of user section
; carry set if not found

searchForUser:
ld a, 8
ld bc, 5

jr realSearch




;##########################################
;search for a coordinate
;input: de = ptr to start of appvar data, (including size bytes)
; hl = ptr to coordinate
;output: de = ptr to start of user section
; carry set if not found

searchForCoordinate:
ld a, 12
ld bc, 13
jr realSearch


;##########################################
;search for an ID
;input: de = ptr to start of appvar data, (including size bytes)
; hl = ptr to coordinate
;ouput: de = ptr to start of user section
; carry set if not found

searchForAnId:
ld a, 5
ld bc, 0


; jr realSearch
; fall through

;#######
realSearch:
push bc
push hl
ex de, hl
ld e, (hl)
inc hl
ld d, (hl)
inc hl
add hl, bc
push hl
ex de, hl
push af
ld a, 25
bcall(_divHLbyA)
pop bc
ld c, l
pop hl
pop de


actualFindLoop:
push bc
push de
push hl
checkMatchLoop:
ld a, (de)
cp (hl)
jr nz, isntMatch

inc hl
inc de
djnz checkMatchLoop

pop hl
pop af
pop af
pop de
or a
sbc hl, de
ex de, hl
ret


isntMatch:
pop hl
ld de, 25
add hl, de
pop de
pop bc
dec c
jr nz, actualFindLoop
pop af
scf
ret

These routines are pretty simple. Just give it the DE that bcall(_chkFindSym) gives you and it will search the appvar for the data you give it. If it runs out of entries, it will return with carry set. Make sure that you don't have an appvar with more than 255 entries though, or else it won't look very far. I tried to make them as small as possible and a few times I was tempted to use the shadow registers, but I didn't.

I also have no idea what you wanted for your third routine. I just made one that searches for a specific ID, you can add whatever you want to the output it gives.

And if you need to search for other stuff, my realSearch: function should work quite nicely.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Please Help
« Reply #4 on: May 17, 2011, 07:13:50 pm »
Thanks thepenguin. As for the last option, the program needs to be able to accept a calc ID in hl and have de point to the start of that user's data section.

Suppose I wanted to use freeRAM instead. i know that won't change the program, i will just have to store $address into de, rather than ChkFindSym. But, I'm wondering what freeRAM areas are open to me. I use CALCnet, and the DCS7 GUI API, so the areas used by them are offlimits (not to mention Kerm recommends declaring RAM used as programs/appvars, to avoid corruption). Also, I use the first 60 bytes of saferam1, as defined by dcs7.inc

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #5 on: May 17, 2011, 09:37:03 pm »
I'm not sure what areas CALCnet uses, so I couldn't really tell you. There's nothing wrong moving it to static memory though. The only problem is that you might have to modify that routine a little because it relies on the two size bytes being out front.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Please Help
« Reply #6 on: May 18, 2011, 05:49:47 pm »
Code: [Select]
;##########################################
;search for a user
;input: de = ptr to start of appvar data, (including size bytes)
; hl = ptr to username
;ouput: de = ptr to start of user section
; carry set if not found

searchForUser:
ld a, 8
ld bc, 5

jr realSearch




;##########################################
;search for a coordinate
;input: de = ptr to start of appvar data, (including size bytes)
; hl = ptr to coordinate
;output: de = ptr to start of user section
; carry set if not found

searchForCoordinate:
ld a, 12
ld bc, 13
jr realSearch


;##########################################
;search for an ID
;input: de = ptr to start of appvar data, (including size bytes)
; hl = ptr to coordinate
;ouput: de = ptr to start of user section
; carry set if not found

searchForAnId:
ld a, 5
ld bc, 0

Shouldn't that last section have hl pointing to the ID to search for?


Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #7 on: May 18, 2011, 06:43:27 pm »
Oh, yes. I forgot to change it when I was retyping it. But at least you understand it enough to realize that it was wrong :D
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Please Help
« Reply #8 on: May 18, 2011, 06:59:09 pm »
Ok. So...

Each seperate section funnels into the realSearch section, which will return with de pointing to the start of that player's data section? Can I do a call on it? Where is the actual end, where de is output?
« Last Edit: May 18, 2011, 07:14:25 pm by ACagliano »

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #9 on: May 19, 2011, 05:59:30 pm »
The header for real search would be:
Code: [Select]
;############################################
;input: a = field length
; bc = field offset from start of data
; de = start of appvar
; hl = ptr to field to match

So you can call it if you want. There are two ret's out of realSearch, the first one is the good one, where DE = the start of the data section, and the second is just an error ret.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Please Help
« Reply #10 on: May 20, 2011, 05:36:42 pm »
Nice. Ok, another question. Is there a (_DeleteMem) command, like there is an (_InsertMem) command? Or if not, is there a work around?

Also, is there a two-byte subtract command?
« Last Edit: May 20, 2011, 06:47:47 pm by ACagliano »

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #11 on: May 20, 2011, 07:47:37 pm »
Yes, bcall(_delMem) exists. I believe you should download this. I pull it out about every 1 out of 4 programming sessions.

And two byte subtract? sbc hl, rr. Where rr is bc or de. Just remember though that since this is sbc and not sub, you will have to make sure the carry flag is not set. So typically, you will see it used like this.
Code: [Select]
or a
sbc hl, de
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Please Help
« Reply #12 on: May 20, 2011, 08:15:04 pm »
Nice. Ok, another question. Is there a (_DeleteMem) command, like there is an (_InsertMem) command? Or if not, is there a work around?

Also, is there a two-byte subtract command?

As I said earlier on IRC, yes there is.

You can find a list of all BCalls here.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Please Help
« Reply #13 on: May 20, 2011, 08:53:11 pm »
As I said earlier on IRC, yes there is.

You can find a list of all BCalls here.

That list doesn't include ones not officially listed in ti83plus.inc. Check out BrandonW's list it has every one listed, and most of them named. (Unnamed ones are unknown as of now, so they wouldn't be useful anyways.)

And between TI's list (linked above) and WikiTi you can figure out the inputs for most of the useful bcalls.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Please Help
« Reply #14 on: May 22, 2011, 03:49:09 pm »
This list on WikiTI is really useful to me. It's far from complete, but it links to pages that describe each routine pretty well. For everything else there's TI's System Routines guide, which thepenguin77 already linked to (twice) :)