You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

Pong for KnightOS - An example C project

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/[Inactive] KnightOS (TI-73/83+/84+/CSE) publicado por u/SirCmpwn April 23, 2015, 12:43:25 AM
To demonstrate the improvements being made to KnightOS's C support, I've started to make a Real Project in C.



The source code is here, it's worth browsing (especially if you know C): https://github.com/SirCmpwn/pong

Pong is a pretty simple project, but since this is meant to be an example I've been keeping it carefully organized so that it's a clear example of how you might structure a large C project for KnightOS. Some important things going on here include:


  • Images are kept as PNG files, and then magically converted to object files and linked into your application through kimg and scwrap. English: the sprites are PNG files, not hex written into the code
  • This separates everything into separate C files for the sake of organization and they're all linked together correctly
  • Globals work now! And libc is working well, and some bugs were fixed in unused function optimization and in kcc. Not really a feature of this project, but it wouldn't work without.

I haven't put it in place yet, but dynamic linking with KnightOS libraries (i.e. corelib, configlib, etc) works and I'll be putting that into this game somehow.

Other than that, this is your usual project updates thread. Pong! Currently the ball logic is implemented (for bouncing around and scoring points), and you can move paddles around. Collision between paddle and ball isn't in place yet, nor is any sort of main menu or any other UI. More on that to come!
Inicia sesión o crea una cuenta para dejar un comentario
u/Duke "Tape" Eiyeron April 23, 2015, 07:13:59 AM
NIce work! Now add hundreds of balls and epic GFX! :p
u/Snektron April 23, 2015, 07:33:42 AM
Awesome! also i saw the source before, very clean :). I hope more C projects are going to pop up now, especially if kcc also has tios support :D
u/Duke "Tape" Eiyeron April 23, 2015, 08:07:32 AM
It's a pong, you can't really mess up such game code unless you really want to.

typedef struct {
uint8_t x, y;
} coordinates_t;


I prefer using

typedef struct coordinates coordinates_t;
struct coordinates {
uint8_t x, y;
};


But in this case this change nothing, this form only allow a structure to include a variable member of the same type.
u/Snektron April 23, 2015, 08:29:30 AM
Well thats just personal preference though. I'd write it like
typedef struct coordinates coordinates_t;
struct coordinates
{
uint8_t x, y;
};

Probably
u/Duke "Tape" Eiyeron April 23, 2015, 08:36:50 AM
I'm talking about the sturcture definition, not the formatting though.
u/Snektron April 23, 2015, 08:38:09 AM
Oh okay.
u/SirCmpwn April 23, 2015, 02:06:35 PM
Quote from: Duke "Tape" Eiyeron on April 23, 2015, 07:13:59 AM
NIce work! Now add hundreds of balls and epic GFX! :p

The first goal of this project is to be a rock solid example of a C project done right on KnightOS, for others to reference. So adding complexity isn't something I'm really up for. However, it is open source, so feel free to fork it and make your own version with hundreds of balls and epic GFX.
u/pimathbrainiac April 24, 2015, 05:44:44 PM
Will the exact same source work for all KOS calcs? If not, what modifications would need to be made for cross-compatibility?
u/SirCmpwn April 24, 2015, 06:15:23 PM
Quote from: pimathbrainiac on April 24, 2015, 05:44:44 PM
Will the exact same source work for all KOS calcs?

Yes.
u/pimathbrainiac April 24, 2015, 06:15:56 PM
Good to know! I'm building the SDK as I type this. Hopefully I'll be able to make something soon!
u/SirCmpwn April 24, 2015, 06:22:47 PM
Quote from: pimathbrainiac on April 24, 2015, 06:15:56 PM
Good to know! I'm building the SDK as I type this. Hopefully I'll be able to make something soon!

Awesome! Have fun, and let me know if you need any help. Remember that C support is still very experimental (and also undocumented).
u/Dream of Omnimaga April 25, 2015, 06:51:07 AM
Does that include the CSE? I forgot if KOS automatically scaled program graphics up if they were ran on a color calc instead of monochrome.
u/Snektron April 25, 2015, 07:40:16 AM
Quote from: pimathbrainiac on April 24, 2015, 06:15:56 PM
Good to know! I'm building the SDK as I type this. Hopefully I'll be able to make something soon!
Oh dear, building things... Someone will have to help me with this when i try this out >.<
u/matrefeytontias April 25, 2015, 09:29:02 AM
KnightOS for the CSE lets programs decide themselves whether or not to use the color screen or the legacy mode, which emulates the monochrome display. Legacy mode is the default mode, so programs will also work on the CSE.
Start a Discussion

b/[Inactive] KnightOS (TI-73/83+/84+/CSE)

A third-party operating system intended to be compatible with every Z80 TI calculator that can be upgraded from the TI-73 to the TI-84 Plus series. It is still under development.

6
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal