Author Topic: Getting Total and Current Archive  (Read 3559 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Getting Total and Current Archive
« on: June 01, 2011, 02:58:35 am »
I'd like to know something for my first ASM program.

How to get MAX and Current Archive in ASM Code?

Is there a pointer to it, or a B_CALL that returns it?

Thanks

SirCmpwn

  • Guest
Re: Getting Total and Current Archive
« Reply #1 on: June 01, 2011, 10:46:11 am »
Getting the amount of free flash is complicated.  Available flash is a different story.  You can just use the model.  An 83+ has 32 pages, an 83+ SE has 64, an 84+ has 128, and an 84+ SE has 256.  I may be wrong on the later models, and I didn't account for the space the OS takes up.

Offline Camdenmil

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 121
  • Rating: +4/-0
    • View Profile
Re: Getting Total and Current Archive
« Reply #2 on: June 01, 2011, 11:22:07 am »
I think the 83+ has 32 pages, 84+ has 64, and both the 83+SE and 84+SE have 128. The garbage collector assumes a page is empty when it starts with $FF but I don't know how to get the amount of free flash down to the byte.
« Last Edit: June 01, 2011, 11:50:36 am by Camdenmil »
It is bad luck to be superstitious.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Getting Total and Current Archive
« Reply #3 on: June 01, 2011, 12:57:40 pm »
Available flash is a different story.

So?

Also, do I have to get Model in ASM and then for each model have a MAX Archive?

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Getting Total and Current Archive
« Reply #4 on: June 01, 2011, 02:28:12 pm »
After a little bit of research and coding, this is what I have come up with! Calling GetTotalArc will return a pointer to a string containing the total amount of user archive. Calling GetFreeArc will return a pointer to a string containing the amount of free archive.

All the routines put together are 76 bytes, which isn't too bad I guess. If anyone knows of any super top secret OS calls that can make this smaller/easier, feel free to suggest them. And before you suggest it, I purposely avoided Disp32 because it doesn't work on all OS versions. Also if I used any calls that don't work on every OS version, feel free to point that out as well.


Code: [Select]
GetTotalArc:
;——————————————————————————————————————————————;
;—> Returns the total amount of user archive as a 7-character decimal string
;INPUTS:    none
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
B_CALL($80BA) ;GetHWVer
add a,a
add a,a
ld d,0
ld e,a
ld hl,GetTotalArc_HWValues
add hl,de
jr ConvArc
GetTotalArc_HWValues:
.db (10*$4000)>>24&$FF,(10*$4000)>>16&$FF,(10*$4000)>>8&$FF,(10*$4000)&$FF
.db (94*$4000)>>24&$FF,(94*$4000)>>16&$FF,(94*$4000)>>8&$FF,(94*$4000)&$FF
.db (30*$4000)>>24&$FF,(30*$4000)>>16&$FF,(30*$4000)>>8&$FF,(30*$4000)&$FF
.db (94*$4000)>>24&$FF,(94*$4000)>>16&$FF,(94*$4000)>>8&$FF,(94*$4000)&$FF


GetFreeArc:
;——————————————————————————————————————————————;
;—> Returns the amount of free archive as a 7-character decimal string
;INPUTS:    none
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
B_CALL($5014) ;ArcChk
ex de,hl
inc hl


ConvArc:
;——————————————————————————————————————————————;
;—> Converts a 32-bit integer into a 7-character decimal string
;INPUTS:    hl=pointer to 32-bit integer (big-endian)
;OUTPUTS:   hl=pointer to string (OP3)
;DESTROYS:  af  bc  de  ix
;——————————————————————————————————————————————;
rst 20h
ld hl,OP3+7
ld de,10
ld (hl),d
ld b,7
ConvArc_Loop1:
push bc
push hl
B_CALL($80B1) ;Div32By16
pop hl
pop bc
ld a,(OP2+3)
add a,'0'
dec hl
ld (hl),a
djnz ConvArc_Loop1
ld d,h
ld e,l
ld bc,6<<8+'0'
ConvArc_Loop2:
ld a,(de)
cp c
ret nz
ld a,' '
ld (de),a
inc de
djnz ConvArc_Loop2
ret
« Last Edit: June 01, 2011, 02:56:24 pm by Runer112 »

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Getting Total and Current Archive
« Reply #5 on: June 05, 2011, 09:30:33 am »
Runer112, that was really helpful, thanks.

SirCmpwn told me about a BCall that returns Free Archive, _ChkFreeArc.

However, yours is more precise as it returns the same free archive listed in MEMORY, and the BCall is not so accurate.

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: Getting Total and Current Archive
« Reply #6 on: June 05, 2011, 11:50:39 am »
Runer112, that was really helpful, thanks.

SirCmpwn told me about a BCall that returns Free Archive, _ChkFreeArc.

However, yours is more precise as it returns the same free archive listed in MEMORY, and the BCall is not so accurate.

Well, runer actually uses a bcall too.
Code: [Select]
B_CALL($5014) ;ArcChk

And since this bcall isn't officially or unofficially named, and doesn't even appear in wikiTi or TI's routines, there's a good chance that SirCmpwn and Runer are actually talking about the same bcall ;)
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