Page 12 of 14

Posted: Tue 27 Dec, 2005 11:12 pm
by Timendus
Exactely. The entire API isn't very flag or register friendly, nor does it state what gets destroyed and what not. You could see that as a flaw, but it hasn't really bothered me yet when coding with the API. I think that the entire idea is that you're fiddling with blocks of data and with hardware rather than with registers...

Posted: Wed 04 Jan, 2006 11:37 am
by Timendus
To answer this question:
calcul831415 wrote:If this is all for the API, why not make API into it's own language? Like a better version of EZASM and Basic?
Does using libraries in C make it another programming language? Does including other packages in Java make it another programming language? Of course it doesn't. With the API included, you're still programming in z80, but you rely on other routines to do the really down to earth boring things, like you would in any other serious programming language.

That's why I wrote "why hasn't this been done yet?". On every other platform and language programmers have some form of libraries at their disposal, and all we have (had :)) are some stupid includes that define some memory areas and romcalls. Those can't DO anything for you, they just memorize some numbers. But you can actually let the API do some WORK for you :)

Posted: Wed 04 Jan, 2006 6:13 pm
by kalan_vod
But doesn't ions' routines give us some routines at our disposal? Of course yours is a lot easier to use, but I just wanted to make sure Ion isn't left out :P. Btw I can't wait till you have this completed as it is already amazing!

Posted: Wed 04 Jan, 2006 11:15 pm
by Timendus
Yes, you're right of course. The ION routines are the only exception. I'm sorry I forgot about them.

Anyway, "completed" is a pretty relative thing for this project :P I hope to see other people working on routines in the API long after I stop working on them myself :)

I'm still working on a few things to add at the moment, but at a very slow pace. Several other things currently have a higher priority.

Things I'm working on, in no particular order:
- Finally making that homescreen word wrap print routine
- Better/more key input (already have a few nice new routines to add on my PC, but need a few more)
- A graphical user interface (that DOESN'T resemble Windows in ANY way :mrgreen:) section (this has been my "secret" thing, because it's going to be really cool :P In fact, it already is, but a lot needs finishing)
- Link port routines with error handling shite (but I'm not sure how to do error handling with the TI-OS routines, could someone please tell me that?)

Posted: Mon 09 Jan, 2006 11:19 pm
by Timendus
I just added the load macro to the API (I had forgotten all about it), and edited 74 routines to make use of it :P I have confirmed that the old demo still runs properly, so I guess I didn't make too many mistakes, and I'm going to bed now :mrgreen:

If someone could confirm that the demo still works with the new api.inc when compiled with TASM that would be nice :)

Posted: Tue 10 Jan, 2006 12:05 pm
by benryves
Timendus wrote:- A graphical user interface (that DOESN'T resemble Windows in ANY way :mrgreen:) section (this has been my "secret" thing, because it's going to be really cool :P In fact, it already is, but a lot needs finishing)
Any screenshots, so we can, uh, verify this non-Windows look? ;) Sounds very cool!

Posted: Tue 10 Jan, 2006 4:50 pm
by Timendus
I'll try to make a nice one soon ;)
I'm not sure how the system should be used yet, so I'm still very much working on that (when I have the time :)).

Posted: Wed 11 Jan, 2006 8:44 pm
by Timendus
Image

Here's the full code of this little game:

Code: Select all

init_all:

	math.random(10)				; Random a number for the user to guess
	ld (savesscreen),a
game:
	graph.clear()					; Clean up the screen
	gui.drawPlane(256*1+1,256*43+53)		; Draw three Planes
	gui.drawPlane(256*46+1,256*93+9)
	gui.drawPlane(256*46+12,256*93+53)
	gui.print(256*2+48,str,50)			; Print two texts
	gui.print(256*13+48,str2,40)
	gui.resetChoices()				; Reset the choices pane
	gui.setChoiceKeyHandler(myhandler)		; Add a keyhandler to the pane...
	gui.addChoice(new,newgo)			; and three choices
	gui.addChoice(quit,quitgo)
	gui.addChoice(about,aboutgo)
	gui.goChoices()				; Give execution to the choices pane

; Gets called by the choices pane if F1 is pressed
newgo:
	jp init_all
	
; Gets called by the choices pane if F2 is pressed
quitgo:
	ret
	
; Gets called by the choices pane if F3 is pressed
aboutgo:
	gui.alert("Number Guess by Timendus as an API demo")
	jp game

; Gets called by the choices pane if another button than F1-F5 is pressed
; a = Button pressed (getcsc-style)
myhandler:
	cp $21
	ld c,0
	jr z,myhandler_checkvalue
	cp $22
	ld c,1
	jr z,myhandler_checkvalue
	cp $1A
	ld c,2
	jr z,myhandler_checkvalue
	cp $12
	ld c,3
	jr z,myhandler_checkvalue
	cp $23
	ld c,4
	jr z,myhandler_checkvalue
	cp $1B
	ld c,5
	jr z,myhandler_checkvalue
	cp $13
	ld c,6
	jr z,myhandler_checkvalue
	cp $24
	ld c,7
	jr z,myhandler_checkvalue
	cp $1C
	ld c,8
	jr z,myhandler_checkvalue
	cp $14
	ld c,9
	jr z,myhandler_checkvalue
	ret
	
myhandler_checkvalue:
	push bc
	int.decToString(savesscreen+1,c)
	gui.print(256*2+3,myhandler_string,50)
	graph.print(savesscreen+1)
	pop bc
	ld a,(savesscreen)
	ld hl,good
	cp c
	jr z,myhandler_disp
	ld hl,higher
	jr nc,myhandler_disp
	ld hl,lower
myhandler_disp:
	gui.print(256*10+3,hl,40)
	call ionFastCopy
	ret

; Data

myhandler_string:
	.db "You tried ",0
higher:
	.db "Too low!",0
lower:
	.db "Too high!",0
good:
	.db "You guessed it! Congrats! :)",0

new:
	.db "New",0
about:
	.db "About",0
quit:
	.db "Exit",0
	
str:
	.db "Number guess",0
str2:
	.db "Guess a number between 0 and 9!",0
This code alone compiles to 384 bytes, and the API routines about triple that.

I have not yet added those routines to the API, because they aren't 100% stable yet, and they can be improved/optimized/expanded. But what do you think? :)

Posted: Wed 11 Jan, 2006 9:47 pm
by kalan_vod
Nice.

Posted: Wed 11 Jan, 2006 10:07 pm
by Stickmanofdoom
Slick.

Posted: Thu 12 Jan, 2006 7:11 am
by CoBB
What about a coordinate macro? pt(x,y) -> x*256+y

Posted: Thu 12 Jan, 2006 8:34 am
by Timendus
Hey, good idea :) I'll add it some time soon!

Posted: Thu 12 Jan, 2006 12:04 pm
by benryves
Looking very nice!

Posted: Fri 13 Jan, 2006 3:22 am
by gangsta
add the gui stuff to the api!

Posted: Sat 14 Jan, 2006 11:04 pm
by Timendus
Thanks for the compliments y'all ;)
I'll add the gui stuff as soon as it's finished. That's probably in a few weeks time, because I have exams, projects, work, et cetera ahead in the coming weeks...