Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Xeda112358 on November 29, 2010, 08:19:26 pm

Title: Battery Level
Post by: Xeda112358 on November 29, 2010, 08:19:26 pm
Does anybody know of a way to check the battery level without using a B_Call? If you have code, hex or mnemonics are fine. Thanks
Title: Re: Battery Level
Post by: calcdude84se on November 29, 2010, 08:22:25 pm
I have assembly ;D You want bit 0 of port 2. It's set if batteries are good, reset if they are low. So:
Code: [Select]
in a,($02)
rra
jr c,batt_good
batt_bad:
I think you get the general idea :)
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 08:24:28 pm
Oh, that is helpful, thanks. Is there a way to do a multi-level test? Like that B_Call that returns a value from 0 to 4?
Title: Re: Battery Level
Post by: calcdude84se on November 29, 2010, 08:27:40 pm
It involves weird not-completely-understood interrupt stuff. (Hardware timer 2 is involved. Read more at http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:5221 (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:5221))
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 08:30:42 pm
Uh-oh... I've never learned how to work with interrupts... I could never understand how to make them or set them up. I've read some tutorials, but it isn't working for me...
Title: Re: Battery Level
Post by: Yeong on November 29, 2010, 08:34:27 pm
I believe it already exists:
http://www.ticalc.org/archives/files/fileinfo/415/41559.html (http://www.ticalc.org/archives/files/fileinfo/415/41559.html)
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 08:36:54 pm
I believe it already exists:
http://www.ticalc.org/archives/files/fileinfo/415/41559.html (http://www.ticalc.org/archives/files/fileinfo/415/41559.html)
That one uses the B_Call which is what I am trying to avoid...
Title: Re: Battery Level
Post by: calcdude84se on November 29, 2010, 08:37:26 pm
Something tells me that that program uses the OS bcall. If it did otherwise its author would most likely have stated.
Xeda wants an OS-independent one for some unknown reason ;)
Edit: ninja'd
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 08:41:32 pm
Oh, I am working on that app and the program itself with all the calls (even the unused ones) is only about 2000 bytes of code. I figured I could add some more padding to the code and make it get a little closer to using the full 16384 bytes :D. I have been trying to make it independent of OS calls to make it a little faster and so that I can make the calls fit my needs.
Title: Re: Battery Level
Post by: calcdude84se on November 29, 2010, 08:43:19 pm
Ah, okay, that makes sense. Have you duplicated the font routines yet? ;D
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 08:44:09 pm
Nope :D I will be working on that one sometime, but examples would be cool.
Title: Re: Battery Level
Post by: SirCmpwn on November 29, 2010, 09:57:21 pm
You can have the KnightOS font code, if you want.  Look at font.asm and text.asm in http://knightos.sourceforge.net (http://knightos.sourceforge.net)
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 10:01:58 pm
Sweet, thanks!. I will look at that for sure!
Title: Re: Battery Level
Post by: thepenguin77 on November 29, 2010, 11:06:01 pm
Xeda, your best bet is to just go disassemble the bcall yourself because I don't think there is anyone who actually understands how it works.

Go into calcsys>Hex editor. Then switch to page 7b, 3b, or 1b respective to calcs. Goto 5221. Goto the address you are now looking at (address followed by page number). And have fun. You basically just did a manual bcall. :D
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 11:07:18 pm
How do I switch the flash page in CalcSys? I never knew I could do that...
Title: Re: Battery Level
Post by: thepenguin77 on November 29, 2010, 11:07:43 pm
[Alpha] R
Title: Re: Battery Level
Post by: calc84maniac on November 29, 2010, 11:08:42 pm
Xeda, your best bet is to just go disassemble the bcall yourself because I don't think there is anyone who actually understands how it works.

Go into calcsys>Hex editor. Then switch to page 7b, 3b, or 1b respective to calcs. Goto 5221. Goto the address you are now looking at (address followed by page number). And have fun. You basically just did a manual bcall. :D
Even easier, go to the Calcsys console and enter DISROM 5221 (or DR 5221 for short) :)
Title: Re: Battery Level
Post by: Xeda112358 on November 29, 2010, 11:09:56 pm
Oh, wow. Thanks, I didn't know CalcSys could do any of that. Thanks!
Title: Re: Battery Level
Post by: AngelFish on November 29, 2010, 11:58:49 pm
I've always wondered how to disassemble the b_calls. Thanks.
Title: Re: Battery Level
Post by: jnesselr on November 30, 2010, 07:02:54 am
Very nice. I didn't know calcsys could do that.  I'll try it to day and report back.

EDIT: Okay, wait, when I do the 5221 bcall, is it page 7B address 72E8 or address E872? Endianness confuses me.

EDIT2: nvm, 72E8.  The DR function was helpful, too.