Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
PT_ wrote:
Another question: how can I display a string in Ans on the screen? I think it should be something with _RclAns, and _CreateTempString, but I've no idea. Or in pseudo-code:

Code:
gc_PrintStringXY(Ans, 10, 10)


Ans is a part of the TIOS, not a part of C itself. You can't read Ans unless you write your own inline assembly for it. I was going to make an addition to the file io library to let you directly interact with TI variables with version 2.0. Also, PT_, would you mind redownloading the libraries and using those ones instead? I added the custom font routine. Smile

EDIT: For the custom font, this editor is really good: (Has a ton of preinstalled fonts, and allows you to export as a C header file)
https://www.min.at/prinz/o/software/pixelfont/#download

EDIT2:
Hello again! I added some debugging stuff to CEmu and the toolchain today, so that way C programs can take advantage of some commands. Smile

As always, the latest release is available here: https://github.com/CE-Programming/toolchain/releases

Here are the commands:


Code:
void abort(void)
- Opens the CEmu debugger, prints "Program Aborted." to the console, and then exits your C program


Code:
void debugger(void)
- Opens the CEmu debugger, prints "Program Entered Debugger." to the console. Pretty much the same as abort(), just no program exit.


Code:
int dbg_printf(char *buf, const char *format, ...);
- Print to the CEmu console without opening the debugger, use the defined dbgout to write to the console. For example, to see the value of int data:


Code:
dbg_printf(dbgout, "data=%d\n", data);


In order to use these, you need #include <debug.h> at the start of your program. Good luck! Smile
This is a great start - I've opened a couple issues on the github tracker regarding specific implementation details.
elfprince13 wrote:
This is a great start - I've opened a couple issues on the github tracker regarding specific implementation details.


Cool, I took care of them. I did not change the implementation of dbg_printf, as this allows you to print to other buffers, not just CEmu's, and it would add a couple hundred bytes of needless code to the binary.

Anywho, I updated the release to also support:


Code:
assert(condition)


And then the assertion, file, and line info are printed to dbgout. This is very, very handy now. Smile

Here it is:
https://github.com/CE-Programming/toolchain/releases/tag/v1.6
Can anyone tell me what each exe in bin does? I couldn't find documentation. Just asking.
The bin folder contains all the compiler and assembler items. You just type 'make' at the command line to build programs as long as the environment variables are set up correctly.
I can't seem to get it to work for me... I set up my environment variables. Now what?
KingInfinity wrote:
I can't seem to get it to work for me... I set up my environment variables. Now what?

Open a command shell, navigate to the examples->template directory, and type 'make'.
Can you give exact documentation how to compile? I did make CEDEV variable in the top listview in windows environment variables window and added C:\CEdev\bin to Path variable after ; character.

All files are in C:\CEdev and I made a batch file in C:\CEdev\examples\template folder with this code:

@echo off&make&pause>nul

it recognizes 'make' file and runs it, but it gives following error: "filename or directory name or volume label syntax is incorrect[CR+LF]make: *** [main.obj] Error 1" although I didn't modify anything and variables are set correctly.

Files in the C:\CEdev\examples\template folder are main.c, Makefile, Linkcmd and my mak.bat.

I also copied include and lib folders to the template folder and copied them to bin also, but it still gave the same error. What did I do wrong?

EDIT: I added the line in the post below to makefile and used PATH instead of Path and doesn't work.
A fix for windows users:
Before compiling, add the following line to the top of makefile

Code:
SHELL=C:/Windows/System32/cmd.exe


The template should now compile without errors.
KingInfinity wrote:
A fix for windows users:
Before compiling, add the following line to the top of makefile

Code:
SHELL=C:/Windows/System32/cmd.exe


The template should now compile without errors.



Code:
SHELL ?= C:/Windows/System32/cmd.exe

This is a bit safer. SHELL should have already been defined in your environment variables though; I'm surprised it isn't Razz
Great job getting this going, Mateo! Now all that is needed is a completed C tutorial... poke poke Razz
The gc_SetTransparentColor doesn't work for me. I displayed sprites while changing the transparent color - no result.

Code:

Code:
gc_FillScrn(0xEE);
   
    /* Set only the palette we need of mushroomsprite */
    gc_SetPalette(mushroomsprite_pal, sizeof mushroomsprite_pal);
   
    /* Mushroom sprite uses that pink color as its transparent color. That is set to
       index 0 in the color table */
    gc_SetTransparentColor(0x00);
   
   gc_NoClipDrawTransparentSprite(mushroomsprite,0,0,32,32);
   
   gc_SetTransparentColor(0x01);
   
   gc_NoClipDrawTransparentSprite(mushroomsprite,0,32,32,32);
   
   gc_SetTransparentColor(0x02);
   
   gc_NoClipDrawTransparentSprite(mushroomsprite,0,64,32,32);


Also, may I ask you what pop de \ pop hl \ push hl \ push de is useful for?
Cool; thanks for letting me know Smile There's a few other bugs I am aware of; I'll have a fix on GitHub for everything by tomorrow. Thanks again; and good luck!
Important notice The graphics library has been updated! Smile Please reinstall the latest version, and if there are any bugs; don't forget to post here! Thanks everyone.

Click on [Download ZIP]: https://github.com/CE-Programming/libraries
So now that the first program to use v1.0 of the libraries is out, it's time to make some even cooler routines! I'm thinking windowed screen scrolling and clipping of sprites and everything else. Should be fun.

Also, for those who are unaware, srand() can be seeded as follows in in your programs (As time.h has yet to be completed Smile )


Code:
srand(*(unsigned long*)0xF30044);
May I point you to the DoorsCS libraries? There are some nice routines as well, and not very hard to create Very Happy

Massive and important update! Version 1.0 has been repaired; the problem was that arguments were not zero extended when they were popped off the stack. Anyway, here's what to do:

Version 1.7 of the toolchain is out. Please reinstall it Smile This includes a new makefile which you can find in the demos/demo0 folder. In addition, it allows you to easily create icons compatible with Cesium in your C programs (described below)
https://github.com/CE-Programming/toolchain/releases/

Libraries have also been updated; but still at version 1.0, which is a repaired version of 1.0. You can find them here:
Developemnt:
https://github.com/CE-Programming/libraries
Binaries:
https://github.com/CE-Programming/libraries/releases

I apologize for all the confusion; these should be pretty much bug-free now Smile Which means v2 stuff! Razz

How to make icons
In the demos/demo0 folder you will find a file called 'iconc.png'. This is the icon that you can edit. You can find the available palette of colors in 'CEdev\include\ce\pal', or just save the below image. You must use the colors from this image in your icon. Once that is complete, open your Makefile: (You should have these lines at the top)


Code:
#Change 'template' to the name of your program
TARGET ?= template

#Change ICONC to "ICON" to include a custom icon, and "NICON" to not use an icon
ICONC ?= ICON
DESCRIPTION ?= "Template C Program"


Change 'template' to whatever you want the name of your program to be, and NICON to ICON to use the iconc.png image as your icon, and then change the description to explain what your program does. Icon and description are displayed within Cesium. Once that is done, just type 'make' and it should compile just fine.

Anywho, I would like to personally thank jacobly for pointing out my big goof and helping remedy it. And to everyone else who uses the C libraries, happy coding and good luck!

There is an error in the compiler. It doesn't let me have any methods (procedures and functions) in sturctures. It strangely points the error at the CR+LF character at the end of the line where the only character is "{" after definition of procedure with arguments. When I remove the method from the struct, it works completely fine along with attributes inside it. Here's the code:

main.c:

Code:

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <ti84pce.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "hdr.h"

void main()
{
    Foo bar;
}


hdr.h:

Code:

#ifndef HDR_H
#define HDR_H

typedef struct /* Foo */
{
    bool is_something;

    uint16_t x;
    uint16_t y;
    uint16_t z;
    uint16_t i;

    void createSomething(uint16_t a, uint16_t b, uint16_t abcxyz, uint16_t rofl)
    { // it strangely points the error at this exact line when there is nothing else than tabulator,
       // { character and EOL character.
    }

} Foo;

#endif // HDR_H


If I'm doing something wrong point it out, else please fix the problem because what I did seems correct syntax-wise, but not for the compiler.

Thank you!
KKZiomek wrote:
There is an error in the compiler. It doesn't let me have any methods (procedures and functions) in sturctures.

No, it's the normal behaviour, you can't do that in C, only C++ (let alone ZDS' C89/Ansi).

You can achieve that with function pointers, though. See http://stackoverflow.com/questions/17052443/c-function-inside-struct etc.
@up Adriweb
Thank you! It works now, but the code looks messier and I wish you could do it like in C++. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 17
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement