To demonstrate the improvements being made to KnightOS's C support, I've started to make a Real Project in C.
(http://a.pomf.se/pqvege.gif)
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!
NIce work! Now add hundreds of balls and epic GFX! :p
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
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.
Well thats just personal preference though. I'd write it like
typedef struct coordinates coordinates_t;
struct coordinates
{
uint8_t x, y;
};
Probably
I'm talking about the sturcture definition, not the formatting though.
Oh okay.
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.
Will the exact same source work for all KOS calcs? If not, what modifications would need to be made for cross-compatibility?
Good to know! I'm building the SDK as I type this. Hopefully I'll be able to make something soon!
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).
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.
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 >.<
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.
Quote from: DJ Omnimaga on 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.
Most KnightOS programs will work correctly on the CSE without any changes, in legacy mode. This simulates the older screen at 2x zoom. Then, if you choose, you can make your programs run in color mode, and take advantage of the full screen.
Quote from: Cumred_Snektron on April 25, 2015, 07:40:16 AM
Oh dear, building things... Someone will have to help me with this when i try this out >.<
It's very easy! I don't think you'll have trouble.
*Suddlenty, a wild Matref appears.*
Quote from: SirCmpwn on April 25, 2015, 04:28:39 PM
Quote from: Cumred_Snektron on April 25, 2015, 07:40:16 AM
Oh dear, building things... Someone will have to help me with this when i try this out >.<
It's very easy! I don't think you'll have trouble.
Maybe it's a good idea if someone writes a tutorial for this... and with support for win7 wo/ VS noobs... :3
Quote from: Cumred_Snektron on April 25, 2015, 04:46:32 PM
Maybe it's a good idea if someone writes a tutorial for this... and with support for win7 wo/ VS noobs... :3
Windows users write KnightOS software on Cygwin, which provides a Unix environment. No VS required. Here's the tutorial you're after: http://www.knightos.org/documentation/tutorials/getting-started/
Oh great! Though i use mingw... ah it'll be fine probably, though i heard there was a lot of hate towards mingw
Quote from: Cumred_Snektron on April 25, 2015, 04:50:31 PM
Oh great! Though i use mingw... ah it'll be fine probably, though i heard there was a lot of hate towards mingw
Mingw isn't supported and won't work, just use cygwin or you'll piss off everyone in #knightos when you come ask for help (it happens a lot).
Okay, will do :P
By the way, if it ever became clear that we will never be able to install third-party OSes on the 84+CE, will the CE version of KnightOS simply be downscaled to a shell like Mirage/DCS?
Quote from: DJ Omnimaga on April 26, 2015, 04:53:47 AM
By the way, if it ever became clear that we will never be able to install third-party OSes on the 84+CE, will the CE version of KnightOS simply be downscaled to a shell like Mirage/DCS?
I don't know enough about the CE yet to really say anything like that.
Quote from: DJ Omnimaga on April 26, 2015, 04:53:47 AM
By the way, if it ever became clear that we will never be able to install third-party OSes on the 84+CE, will the CE version of KnightOS simply be downscaled to a shell like Mirage/DCS?
There
is a way to install 3rd party OSes on the CE, but it requires hacks that have not been disclosed yet.
Oh OK, I thought it absolutely required the 2048 bit RSA key. That said I am betting that as soon as hacks or third-party OSes using them come out, then TI will patch them >.<
The 84+ CE is also so different from the other supported calcs that I'm not sure exactly how KnightOS support will take shape. A high quality port of KnightOS to the CE will take a lot of work, but will be really cool. And yeah, we need an exploit and there aren't any public ones yet. I don't have time myself to go hunting for exploits.
I realized that I never really gave an update - the mini-project is effectively done now. The game works great and I was able to fix a few problems with KnightOS's C support while making it. The code is a great reference now for anyone else hoping to build projects for KnightOS in C.
Good to hear. :) I will need to check it out. I wonder how does the executable size compare with a TI-OS Axe or pure ASM one?
Quote from: DJ Omnimaga on April 27, 2015, 04:25:06 AM
Good to hear. :) I will need to check it out. I wonder how does the executable size compare with a TI-OS Axe or pure ASM one?
It's 1719 bytes. You can get the package here: https://packages.knightos.org/community/pong
Quote from: DJ Omnimaga on April 26, 2015, 04:26:20 PM
Oh OK, I thought it absolutely required the 2048 bit RSA key. That said I am betting that as soon as hacks or third-party OSes using them come out, then TI will patch them >.<
Nope. Apparently TI messed up the ASIC, so the only way to fix them is with a very expensive hardware change.
Ah right, fail on their part then. I'm betting they would be ready to do anything at any cost to lock down their calcs, but since they seem to try less hard on Z80/ez80 calcs, then I bet it will take a few years before it happens (maybe only on their next calc?). I guess we have the path cleared to a certain extent for now.
QuoteThe game works great and I was able to fix a few problems with KnightOS's C support while making it.
Small projects, especially for new platforms / environments, usually have that effect. In 2011, advancing an old Lua port to the TI-68k/AMS series, and partially porting "p14p" python-on-a-chip to the same, yielded improvements in GCC4TI.
That's also why in 2010, I suggested the making of a demo (in the demoscene sense) for the Nspire platform.
Quote from: Lionel Debroux on April 27, 2015, 05:36:12 AM
QuoteThe game works great and I was able to fix a few problems with KnightOS's C support while making it.
Small projects, especially for new platforms / environments, usually have that effect. In 2011, advancing an old Lua port to the TI-68k/AMS series, and partially porting "p14p" python-on-a-chip to the same, yielded improvements in GCC4TI.
That's also why in 2010, I suggested the making of a demo (in the demoscene sense) for the Nspire platform.
Yep, that was the goal of this project in the first place. I'll be doing a few more projects with the same goal in mind.
Now that Lionel mentions the TI-Nspire, that makes me wish that Jacobly and Calc84maniac's respective attempts at creating TI-84+ emulators for the Nspire came to fruition. I don't remember if there is any other such project in the works, but it could be a way for people to use KnightOS on their Nspire if there are no plan to port KOS directly to that platform. But I guess that's for another topic.
Quote from: DJ Omnimaga on April 27, 2015, 05:43:33 AM
Now that Lionel mentions the TI-Nspire, that makes me wish that Jacobly and Calc84maniac's respective attempts at creating TI-84+ emulators for the Nspire came to fruition. I don't remember if there is any other such project in the works, but it could be a way for people to use KnightOS on their Nspire if there are no plan to port KOS directly to that platform. But I guess that's for another topic.
matref has ported z80e (the KnightOS project's emulator) to the Nspire, and I would love to see more contributors come in and help develop it.
Ah thanks for pointing out. Now that you mention matref, I think I remember hearing some tidbits about such project. I didn't know it went this far, though.
Quote from: DJ Omnimaga on April 27, 2015, 05:47:56 AM
Ah thanks for pointing out. Now that you mention matref, I think I remember hearing some tidbits about such project. I didn't know it went this far, though.
Unfortunately, no one is really working on z80e right now. It's the default emulator for the SDK, and it powers the live demo on knightos.org, but it can't emulate TIOS and it has poor performance.
Aah ok thanks for clarifying. As for performance I remember issues about lag and stuff. On my 2010 computer, when I had juju's topic open (which had the emulator embedded in) my browser would take 100% of the CPU and my mouse cursor moved at about 2 FPS when it was loading. And when it was done loading, typing posts was like 4 letters per second max. Hopefully if this project gets revived, you guys can find a way to get it run faster on older machines.
Quote from: DJ Omnimaga on April 28, 2015, 07:35:25 PM
Aah ok thanks for clarifying. As for performance I remember issues about lag and stuff. On my 2010 computer, when I had juju's topic open (which had the emulator embedded in) my browser would take 100% of the CPU and my mouse cursor moved at about 2 FPS when it was loading. And when it was done loading, typing posts was like 4 letters per second max. Hopefully if this project gets revived, you guys can find a way to get it run faster on older machines.
It runs at a much more reasonable speed natively. It's just in the browser that performance is abhorrent.