Difference between revisions of "C SDK Tips and Tricks"

From Learn @ Cemetech
Jump to navigationJump to search
Line 77: Line 77:
  
 
Put that on a calculator or [https://github.com/CE-Programming/CEmu CEmu] with the [https://github.com/CE-Programming/libraries C libraries], and you are all set!
 
Put that on a calculator or [https://github.com/CE-Programming/CEmu CEmu] with the [https://github.com/CE-Programming/libraries C libraries], and you are all set!
 +
----
 +
 +
==Setting up the SDK on Windows==
 +
This section will help you set up the C SDK on '''windows'''. It is best to do it in this same order, but that is your choice.
 +
----
 +
----
 +
===Files===
 +
----
 +
Download the C toolchain [https://github.com/CE-Programming/toolchain/releases/tag/v5.2 here].
 +
 +
Extract it wherever you want, though putting it in the home directory is easiest.
 +
===Environment Variables===
 +
----
 +
<nowiki>- Open your ~/.bashrc file. (It is a hidden file in your home directory, [Ctl + H] to make it visible)
 +
</nowiki>
 +
<nowiki>- Add these lines to the end of the document:</nowiki>
 +
 +
export PATH=$PATH:~/CEdev/bin/
 +
export CEDEV=~/CEdev/
 +
<nowiki>- If you extracted CEdev to somewhere else other than your home, change the paths to that location. Keep in mind that CEDEV needs to point to the Cedev folder, and PATH needs to point to the CEdev/bin folder.</nowiki>
 +
----
 +
===Setting up the Template makefile===
 +
----
 +
Once you have the Environment Variables set up, create a New folder where you will put all of your projects. (I put mine in CEdev/Programs)
 +
 +
Once you have that folder, go into CEdev/examples and copy template.
 +
 +
Paste the template in your programs folder.
 +
 +
Open it up and edit the makefile.
 +
 +
It should look something like this: http://pastebin.com/N7K4ppBD
 +
 +
Edit '''TARGET ?= DEMOT''' and replace '''DEMOT''' with your program name.
 +
 +
Keep '''DEBUGMODE ?=''' as '''NDEBUG''' until you decide to use the Debug features in your program.
 +
 +
The others are pretty self explanatory, and the comments at the top of the file will help with explanation.
 +
 +
You will want to add '''graphx fileioc keypadc''' to '''L :=''' to be able to use the libraries.
 +
 +
That is just about everything you need to know about the makefile
 +
----
 +
===Tweaking the main.c file===
 +
----
 +
If you head into /src/ you will ''main.c''. Go ahead and open it. It will look something like this: http://pastebin.com/QqEgTBid
 +
 +
If you make that file, it will not do anything. To make it easier to set up a new project, we will edit it.
 +
 +
To make anything work, we will have to include the libraries, add the following text underneath '''#include <string.h>
 +
 +
#include <graphx.h>
 +
#include <keypadc.h>
 +
#include <fileioc.h>
 +
#include <debug.h>
 +
 +
Next, uncomment '''PrgmCleanUp();'''
 +
 +
Then, add '''gfx_Begin( gfx_8bpp );''' above that. This will make your program able to use the graphics libraries.
 +
 +
You may also want to add '''gfx_FillScreen(gfx_white);''' to color the screen white.
 +
 +
Remember, you can edit it more to tailor to your own needs, but this is what I do.
 +
----
 +
==="Making" the program===
 +
----
 +
Once you have edited and created your program, you will want to test it. To do so, you will have to "make" your program, and doing so will create a '''.8xp''' in '''/[program location/bin'''
 +
 +
'''Remember, this is on ''linux'', and it will not work on ''windows''.'''
 +
 +
Open a terminal and CD to your program's main directory. My command to cd is:
 +
cd /CEdev/Programs/[program folder name]/
 +
You can also right click in the folder and hit ''open in terminal''.
 +
 +
Now, once you are in the correct directory, run.
 +
wine /home/[username]/CEdev/bin/make.exe
 +
If CEdev is not in your home directory, just change the path to that location
 +
 +
It should run, and if you look in '''/bin/''' you should see a '''*.8xp'''.
 +
 +
Put that on a calculator or [https://github.com/CE-Programming/CEmu CEmu] with the [https://github.com/CE-Programming/libraries C libraries], and you are all set!
 +
----

Revision as of 19:40, 27 August 2016

Setting up the SDK on linux

This section will help you set up the C SDK on linux. It is best to do it in this same order, but that is your choice.


Files


Download the C toolchain here.

Extract it wherever you want, though putting it in the home directory is easiest.

Environment Variables


- Open your ~/.bashrc file. (It is a hidden file in your home directory, [Ctl + H] to make it visible)

- Add these lines to the end of the document:
export PATH=$PATH:~/CEdev/bin/
export CEDEV=~/CEdev/

- If you extracted CEdev to somewhere else other than your home, change the paths to that location. Keep in mind that CEDEV needs to point to the Cedev folder, and PATH needs to point to the CEdev/bin folder.


Setting up the Template makefile


Once you have the Environment Variables set up, create a New folder where you will put all of your projects. (I put mine in CEdev/Programs)

Once you have that folder, go into CEdev/examples and copy template.

Paste the template in your programs folder.

Open it up and edit the makefile.

It should look something like this: http://pastebin.com/N7K4ppBD

Edit TARGET ?= DEMOT and replace DEMOT with your program name.

Keep DEBUGMODE ?= as NDEBUG until you decide to use the Debug features in your program.

The others are pretty self explanatory, and the comments at the top of the file will help with explanation.

You will want to add graphx fileioc keypadc to L := to be able to use the libraries.

That is just about everything you need to know about the makefile


Tweaking the main.c file


If you head into /src/ you will main.c. Go ahead and open it. It will look something like this: http://pastebin.com/QqEgTBid

If you make that file, it will not do anything. To make it easier to set up a new project, we will edit it.

To make anything work, we will have to include the libraries, add the following text underneath #include <string.h>

#include <graphx.h>
#include <keypadc.h>
#include <fileioc.h>
#include <debug.h>

Next, uncomment PrgmCleanUp();

Then, add gfx_Begin( gfx_8bpp ); above that. This will make your program able to use the graphics libraries.

You may also want to add gfx_FillScreen(gfx_white); to color the screen white.

Remember, you can edit it more to tailor to your own needs, but this is what I do.


"Making" the program


Once you have edited and created your program, you will want to test it. To do so, you will have to "make" your program, and doing so will create a .8xp in /[program location/bin

Remember, this is on linux, and it will not work on windows.

Open a terminal and CD to your program's main directory. My command to cd is:

cd /CEdev/Programs/[program folder name]/

You can also right click in the folder and hit open in terminal.

Now, once you are in the correct directory, run.

wine /home/[username]/CEdev/bin/make.exe

If CEdev is not in your home directory, just change the path to that location

It should run, and if you look in /bin/ you should see a *.8xp.

Put that on a calculator or CEmu with the C libraries, and you are all set!


Setting up the SDK on Windows

This section will help you set up the C SDK on windows. It is best to do it in this same order, but that is your choice.



Files


Download the C toolchain here.

Extract it wherever you want, though putting it in the home directory is easiest.

Environment Variables


- Open your ~/.bashrc file. (It is a hidden file in your home directory, [Ctl + H] to make it visible)

- Add these lines to the end of the document:
export PATH=$PATH:~/CEdev/bin/
export CEDEV=~/CEdev/

- If you extracted CEdev to somewhere else other than your home, change the paths to that location. Keep in mind that CEDEV needs to point to the Cedev folder, and PATH needs to point to the CEdev/bin folder.


Setting up the Template makefile


Once you have the Environment Variables set up, create a New folder where you will put all of your projects. (I put mine in CEdev/Programs)

Once you have that folder, go into CEdev/examples and copy template.

Paste the template in your programs folder.

Open it up and edit the makefile.

It should look something like this: http://pastebin.com/N7K4ppBD

Edit TARGET ?= DEMOT and replace DEMOT with your program name.

Keep DEBUGMODE ?= as NDEBUG until you decide to use the Debug features in your program.

The others are pretty self explanatory, and the comments at the top of the file will help with explanation.

You will want to add graphx fileioc keypadc to L := to be able to use the libraries.

That is just about everything you need to know about the makefile


Tweaking the main.c file


If you head into /src/ you will main.c. Go ahead and open it. It will look something like this: http://pastebin.com/QqEgTBid

If you make that file, it will not do anything. To make it easier to set up a new project, we will edit it.

To make anything work, we will have to include the libraries, add the following text underneath #include <string.h>

#include <graphx.h>
#include <keypadc.h>
#include <fileioc.h>
#include <debug.h>

Next, uncomment PrgmCleanUp();

Then, add gfx_Begin( gfx_8bpp ); above that. This will make your program able to use the graphics libraries.

You may also want to add gfx_FillScreen(gfx_white); to color the screen white.

Remember, you can edit it more to tailor to your own needs, but this is what I do.


"Making" the program


Once you have edited and created your program, you will want to test it. To do so, you will have to "make" your program, and doing so will create a .8xp in /[program location/bin

Remember, this is on linux, and it will not work on windows.

Open a terminal and CD to your program's main directory. My command to cd is:

cd /CEdev/Programs/[program folder name]/

You can also right click in the folder and hit open in terminal.

Now, once you are in the correct directory, run.

wine /home/[username]/CEdev/bin/make.exe

If CEdev is not in your home directory, just change the path to that location

It should run, and if you look in /bin/ you should see a *.8xp.

Put that on a calculator or CEmu with the C libraries, and you are all set!