Need some help to use graylib functions.

TI-82, TI-83 (plus, silver..), TI-84, TI-85 and TI-86
Post Reply
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Need some help to use graylib functions.

Post by contra-sh »

Hi,

The z88dk devel kit works fine for my ti83 regular.
Thank you for this great software :)

It's not so easy to make it working because for ti83 regular without shell you need to squish code so your -create-app doesn't works.
I must use :


all:
zcc +ti83ansi -lm -startup=10 -o hello hello.c
bin2bin83 hello
bin2var output.bin OUTPUT.83p

clean:
rm *.83p


Here bin2bin83 is for squishing.
bin2var is to replace -create-app.
-startup=10 is for plain TIOS (no shell).

The generated code is a bit long but it works ;)
see http://www.yaronet.com/posts.php?s=138500


But when I try to use gray.h lib I got a compilation error (linker I think?!).

tib@cobra:~/Code/z80/C/gray$ make
zcc +ti83ansi -lm -startup=10 -o hello hello.c
cp /usr/share/z88dk/lib/ti83_crt0.opt /tmp/tmpXXWvhZpD.opt
cp /tmp/tmpXXWvhZpD.opt /tmp/tmpXXWvhZpD.asm
z88dk-zcpp -I. -DZ80 -DSMALL_C -DTI83 -D__TI83__ -DSCCZ80 -I/usr/share/z88dk/include hello.c /tmp/tmpXXkBTfBp.i
z88dk-sccz80 -// -startup=10 /tmp/tmpXXkBTfBp.i
z88dk-copt /usr/share/z88dk/lib/z80rules.2 < /tmp/tmpXXkBTfBp.asm > /tmp/tmpXXkBTfBp.op1
z88dk-copt /usr/share/z88dk/lib/z80rules.1 < /tmp/tmpXXkBTfBp.op1 > /tmp/tmpXXkBTfBp.opt
z88dk-z80asm -eopt -ns -Mo /tmp/tmpXXkBTfBp.opt
z88dk-z80asm -a -m -Mo -ohello -i/usr/share/z88dk/lib/clibs/gen_math -i/usr/share/z88dk/lib/clibs/ndos -i/usr/share/z88dk/lib/clibs/ti83ansi_clib -i/usr/share/z88dk/lib/clibs/z80_crt0 /tmp/tmpXXWvhZpD.opt /tmp/tmpXXkBTfBp.o
1 errors occurred during assembly
Key to filenames:
/tmp/tmpXXkBTfBp.o = hello.c
File '/tmp/tmpXXkBTfBp.asm', Module 'HELLO', Symbol not defined
Error in expression G_PLOT

make: *** [all] Error 1



Here is the code :

1 #include <stdio.h>
2 #include <gray.h>
3
4 main() {
5
6 printf("hello world\n\n\n\n");
7 while (1) {
8 // ne finit jamais
9 g_plot(4, 4, 0);
10 }
11
12
13 }



I got the same error while compiling startrek example code snippets (no error for tictactoe and ansi test example).

What is the problem?
Is there some path variable to define to say to linker where is gray.h (in my case it's /usr/share/z88dk/include/gray.h)

Could you help me please?

Best regards.


Thibault Duponchelle.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Ciao Thibault !
I will try to compile your code and try to find out what's wrong.

What happens if you try to compile the default example ?
http://z88dk.cvs.sourceforge.net/viewvc ... /graygfx.c
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Post by contra-sh »

Hi,

I just have found the reason...
In fact I have to add a -ltigray83 in the command line to specify to link explicitly the tigray lib like this :




all:
zcc +ti83ansi -ltigray83 -startup=10 -o hello hello.c
bin2bin83 hello
bin2var output.bin OUTPUT.83p

clean:
rm *.83p

It works fine on emulator ;)
That's cool !

Just one little question :
Why the generated code is so big ?


Thank you for the answer ;)

Regards

Thibault
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Couple of reasons usually:

1. Using full stdio pulls in a lot of library routines, printf/puts pull in a couple of k of libraries. puts_cons() is lot more lightweight
2. The ansi screen driver is quite large since it embeds a font.
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Post by contra-sh »

Re,

I suspected the answer was the stdio.h even if I have asked the question ;)
Does only the used function add some code defs?
I would mean : is the other function definition in the generated code or only if these one that were used really?

You should already know that TI z80 have two police (called by _vputs and _puts) included in the system (rom call).
One is used by classic home screen (one char is a sprite of 5 pixels by 7 pixels), the other is the graph (smaller police coordinates are in pixel).

Is it a reason to implement another police?
Is the code generated smaller if I use +83 instead +ti83ansi ?

(The file size is a major concern of TI z80 developer)

Thank you for your answer ;)

Regards

Thibault

edit : And the graygfx example code works fine too ;)
Last edited by contra-sh on Mon Feb 28, 2011 8:30 pm, edited 1 time in total.
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Post by contra-sh »

Small gif demonstrating how gfx works on an TI emulator :

Image

Really cool :p
Last edited by contra-sh on Mon Feb 28, 2011 8:45 pm, edited 1 time in total.
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Post by contra-sh »

Re,

Could you help me to compile this code please :


#include <graphics.h>
#include <malloc.h>
#include <gui.h>

main()
{
struct gui_win win;

win->x = 30; win->y = 15;
win->flags = WIN_BORDER|WIN_SHADOW;
win->height = 20; win->width = 40;
win_open (win);

}



I currently use :
zcc +ti83 -lmalloc -lx11 -startup=10 -o gfx gfx.c


But it give me an error :

cp /usr/share/z88dk/lib/ti83_crt0.opt /tmp/tmpXX2uoyMH.opt
cp /tmp/tmpXX2uoyMH.opt /tmp/tmpXX2uoyMH.asm
z88dk-zcpp -I. -DZ80 -DSMALL_C -DTI83 -D__TI83__ -DSCCZ80 -I/usr/share/z88dk/include gfx.c /tmp/tmpXXVxwD4W.i
z88dk-sccz80 -// -startup=10 /tmp/tmpXXVxwD4W.i
z88dk-copt /usr/share/z88dk/lib/z80rules.2 < /tmp/tmpXXVxwD4W.asm > /tmp/tmpXXVxwD4W.op1
z88dk-copt /usr/share/z88dk/lib/z80rules.1 < /tmp/tmpXXVxwD4W.op1 > /tmp/tmpXXVxwD4W.opt
z88dk-z80asm -eopt -ns -Mo /tmp/tmpXXVxwD4W.opt
z88dk-z80asm -a -m -Mo -ogfx -i/usr/share/z88dk/lib/clibs/x11 -i/usr/share/z88dk/lib/clibs/malloc -i/usr/share/z88dk/lib/clibs/ndos -i/usr/share/z88dk/lib/clibs/ti83_clib -i/usr/share/z88dk/lib/clibs/z80_crt0 /tmp/tmpXX2uoyMH.opt /tmp/tmpXXVxwD4W.o
2 errors occurred during assembly
Key to filenames:
/tmp/tmpXXVxwD4W.o = gfx.c
File '/usr/share/z88dk/lib/clibs/malloc.lib', Module 'FREE', Symbol not defined
Error in expression _HEAP

File '/usr/share/z88dk/lib/clibs/malloc.lib', Module 'MALLOC', Symbol not defined
Error in expression _HEAP

Why does it talk about free and heap (malloc is well defined and linked... it seems)?
(if I drop -lmalloc I get 10 or more malloc errors)

An idea?

Best regards.

Thibault
Last edited by contra-sh on Mon Feb 28, 2011 10:59 pm, edited 1 time in total.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

contra-sh wrote:You should already know that TI z80 have two police (called by _vputs and _puts) included in the system (rom call).
One is used by classic home screen (one char is a sprite of 5 pixels by 7 pixels), the other is the graph (smaller police coordinates are in pixel).
You could try using +ti83 rather than ti83ansi - that looks like it uses ROM routines rather than the ANSI terminal driver.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

contra-sh wrote:Re,

Could you help me to compile this code please :
Looking at the wiki, http://www.z88dk.org/wiki/doku.php?id=l ... allocation it looks like you need to specify where the heap is located - this obviously varies on a per target and program basis.
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Post by contra-sh »

dom wrote:Looking at the wiki, http://www.z88dk.org/wiki/doku.php?id=l ... allocation it looks like you need to specify where the heap is located - this obviously varies on a per target and program basis.
Thank you very very much :D
That's was exactly the problem.

Sorry to do not have found by myself and wasted a part of your time :(

Here a screenhsot wich demonstrates how it works on ti emulator :)

Image

Best regards.

And thank you ;)

Thibault.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

About the resulting code size when 'stdio0 is used.. are you using the old 1.9 versio ?
Have you tried a recent build ? ;)

http://nightly.z88dk.org/
contra-sh
Member
Posts: 13
Joined: Mon Feb 28, 2011 9:23 am

Post by contra-sh »

Not a recent build, I will try a recent version as soon as possible.
(Here is apt-get package on debian)

Thibault
Post Reply