Page 1 of 14

[Featured][Beta] API - Why hasn't this been done yet?!

Posted: Thu 17 Nov, 2005 11:55 pm
by Timendus
[edit]

For anyone who's new to this:

The Ti calculator API is a set of macro's and routines that is assembled to make calculator programming in z80 more simple. Normally, you have to deal with all those pesky registers and Ti-OS routines, even if you just want to display a simple string. With the Ti API you just tell the API to output the string for you, and it'll do all the boring work!

More information: http://api.timendus.com

Original first post follows:

[/edit]


I've started working on an include file today, that will allow you to write something like this:

Code: Select all

	graph.clear()
	graph.println(welcome)
	graph.println(type)
	graph.readln(buffer, 128)
	graph.print(think)
	graph.print(buffer)
	graph.println(think2)
	graph.readln(buffer, 128)
	string.compare(buffer,yes)
	jp	z,goyes
	string.compare(buffer,no)
	jp	z,gono
	graph.println(exit)
	graph.waitkey()
	ret

welcome:
	.db "Welcome!",0
type:
	.db "Type something useless:",0
think:
	.db "So you think ",0
think2:
	.db " is useless?",0
yes:
	.db "YES",0
no:
	.db "NO",0
exit:
	.db "Not playing along, are we? Leave then!",0
buffer:
	.fill 128,0

goyes:
	graph.clear()
	graph.println(well)
	...
	ret

well:
	.db "You really think a lot of yourself, don't you?",0

gono:
	...
	ret
And convert it to working code. This will ask you a few questions in the graph screen, and respond depending on whatever you type in.

I'm not sure if this is worth the name API, but I guess it's as close as it gets to one on a calculator :) And I must say it's a hell of a lot more fun to code simple things like in- and output in this way than in pure asm.

How it works
Nope, it's not object based, nope it doesn't add redundant code and nope you don't need a new compiler. The include file that I'm working on defines a few macros for TASM if you include this at the beginning of your file:

Code: Select all

#define api_defines
#include "api.inc"
The ones that are more complex than a few lines call one of the routines that you include at the bottom of your file (or wherever you like) like this:

Code: Select all

#define api_routines
#include "api.inc"
TASM will "know" which routines need to be included and which need to be left out based on the ones that you actually use, so it shouldn't clutter up your memory with useless code.

Commands that are currently understood by this "API":

Code: Select all

Homescreen:
disp.clear()
disp.print(str)
disp.println(str)
disp.readln(buffer,maxsize)
disp.waitkey()
disp.newline()

Graphscreen:
graph.clear()
graph.print(str)
graph.println(str)
graph.readln(buffer,maxsize)
graph.waitkey()
graph.newline()

String:
string.compare(str1,str2)
I'm currently working on link.println(str) and link.readln(buffer,maxsize) to enable writing a string over the link port, but the Ti-OS routines don't seem to be willing... And I NEED to go get some sleep because I have to get on a bus to Germany in seven hours :(

The input routines are pretty crude at the moment. You can type in caps when you turn Alpha on, and space works, but that's about it. I hope to be able to use Ben's routines once he's done with his keyboard project, so that you can use just the Ti keyboard or also an external one by adding another define. Either way, it would be abstract to the programmer where the input comes from, as long as he gets some input from the API.

Anyway, my list of ideas (so far):

Code: Select all

- Add word wrapping (it wraps already, also in the graphscreen, but not at words)
- More String routines (append,copy,etc)
- Better linking (get it working :)/faster/running in background/more than 2 calcs)
- file.read(filename) / file.write(filename,data) for programs
- var.read(varletter) / var.write(varletter,value) for A-Z vars
- str.read(strnumber) / str.write(strnumber,data) for str0-str9
- menu.choice(str1,str2) to give a choice between two things (return in z and a)
- menu.alert(str) to give an alert that goes away after a keypress
- menu.question(str) to ask "str? Yes/No" (return in z and a)
- menu.options(menu) to give a proper menu (.db 1,"Option one" \ .db 2,"Option two" \ ... \ .db $FF) (return in a)
I don't really plan on making all that myself, but since this is all just a collection of routines anyone can optimize it and add to the API once I release the source. I plan on making a simple website where you can download the latest version, and submit ideas/improvements et cetera.

Please let me know what you think, but don't expect any response from me untill after the weekend. (Convention in Germany, see my girlfriend, party in Groningen on saterday night, calc convention on sunday in Amsterdam... so much to do :)) Good night!

Posted: Fri 18 Nov, 2005 1:11 am
by necro
Sounds cool...except I don't understand it much...well, API like code is always a good thing to see I guess

Posted: Fri 18 Nov, 2005 2:38 am
by crzyrbl
awsome idea :D too bad i dont prgm asm

Posted: Fri 18 Nov, 2005 2:57 am
by kalan_vod
I didn't understand too much :D, but sounds like it will be usefull.

Posted: Fri 18 Nov, 2005 3:02 am
by necro
so, do you think you could explain this a little better for us with little to no asm understanding?

Posted: Fri 18 Nov, 2005 3:34 am
by Jim e
well basically rather than having to write the several lines of code for certain functions you simply have to remember macros. The benefits is it would be quicker to code simple interfaces that would normally take couple hours for inexperienced coder. Interface can be a time consuming part of coding, I can imagine this might speed things up a bit.


I hope you plan on include graphic routines.(Sprite, mapping)

How do you plan on handling a variable or constant? like say something like this:

Code: Select all

   graph.println(pointer)

pointer:
 .dw somestring 
Somestring:
 .db "Hello",0

Posted: Fri 18 Nov, 2005 4:37 am
by Liazon
wow, it cut's the esotericity out of ASM.

me likes, and me no likes

Posted: Fri 18 Nov, 2005 6:09 am
by L4E_WakaMol-King
Wow! I'm impressed. You're right... why had this never been done before?

Posted: Fri 18 Nov, 2005 6:44 am
by Timendus
Thanks :P

I've slept for the amazing amount of three hours because I couldn't stop thinking about this :x But anyway, here's some short answers before I go get my bus:
Jim e wrote:I hope you plan on include graphic routines.(Sprite, mapping)

How do you plan on handling a variable or constant?
Well, the big idea is that everyone will be able to add and improve routines, it's like a replacement for that codebank idea that kv and I were working on a while ago, so yes I do expect sprite and mapping routines to be included in the near future :)
And at the moment you just give it a pointer to a string, and it displays it. To make a string with changing content, you could point it to a buffer and use the string routines (that haven't been made yet :)) to copy/paste some text in it. Or you could call the println routine "by hand".
necro wrote:so, do you think you could explain this a little better for us with little to no asm understanding?
Well, think of it like this: in the final state where I hope to get, this include file would contain the combined knowlegde of half the community. So when writing a program you could rely on other people's routines, without having to copy them in and understand what it does. You only have to deal with the interface. In other words: ASM will become almost as simple to code in as Basic (except for if-statements and for-loops).
crzyrbl wrote:awsome idea :D too bad i dont prgm asm
Maybe you will with this ;)

Posted: Fri 18 Nov, 2005 10:26 am
by benryves
I've done something similar in the past, but it didn't get too far. ;)

TASM's macro system is pretty primitive... http://users.tkk.fi/~vhelin/wla.html might allow you more flexibility. (I've never tried building a TI-8? file in it though).

EDIT: I was writing a simple Z80 OS a while ago which has a bunch of string manipulation routines (reverse string, string->number, number->string, convert to hex, that sort of thing) - any use to you?

Posted: Fri 18 Nov, 2005 3:49 pm
by MissingIntellect
I was working on a project similar to this, of doing an GUI API, but it's kind of on the back burner now...

Posted: Fri 18 Nov, 2005 5:00 pm
by Kozak
What does it add besides looking good and structured.?

Posted: Fri 18 Nov, 2005 6:04 pm
by tr1p1ea
Isnt EZAsm supposed to be like this? (A set of macros).

Posted: Fri 18 Nov, 2005 8:51 pm
by dysfunction
EZAsm was pretty limited in its macros however.

Posted: Sat 19 Nov, 2005 2:41 am
by threefingeredguy
Kozak wrote:What does it add besides looking good and structured.?
No offense, but all it will add is size and slowness. It may be a good way to start learning, but the code will be unoptimized.