Tagged C
Atari XE Multicart
Posted on by Idorobots
Cranking out another post took me way longer than I had anticipated when I rebooted this blog, but I got sidetracked by another quick hardware project that turned out to be way more involved and equally more fun than I originally thought...
I've designed an Atari 400/800/XL/XE standard cartridge compatible board that can hold up to 127 different standard 8KB and 16KB game ROMs at the same time. It's memory chip agnostic and features software game selection & a few neat hacks.
Continue readingHere's a little something I was actively developing arround this time last year and recently ported to Linux. It's a little game me and a couple of guys made while in SKN Shader.
Here's a video, make sure to watch it in HD!
ASM heatmap
Posted on by Idorobots
I had very little time for this blog lately, but this is about to end soon enough. Here's a quick post showing ASM' keyboard distribution.
Continue readingThis post shows the Particle System and its editor me and Raver wrote for the LRRH project.
Here's some demo-steam: I have since deleted my YouTube channel.
Properties in the D programming language
Posted on by Idorobots
Just to evangelize D a little and increase my code/crap ratio, let's pretend we develop a library in C++ that contains this class:
class SomeMetaVariables {
public:
std::string foo;
bool bar;
};
// ... Somewhere in the client code:
SomeMetaVariables baz;
baz.foo = "foo";
baz.bar = true;
Our library is quite successful and many people are using SomeMetaVariables
despite its obvious flaws. Now, say we get many requests for additional functionality, for example: "Make bar
true
only when foo
is set to "foo" and other way arround." "Well, ok." - we say and commit this new version of SomeMetaVariables
:
class SomeMetaVariables {
std::string foo;
bool bar;
public:
std::string getFoo() {
return foo;
}
std::string setFoo(std::string newFoo) {
foo = newFoo;
bar = (foo == "foo");
return foo;
}
bool getBar() {
return bar;
}
bool setBar(bool newBar) {
bar = newBar;
foo = bar ? "foo" : "";
return bar;
}
};
We implemented the requested feature, but SomeMetaVariables
' interface has changed... "But why are you mad clients? You asked for it!" - cries the C++ developer.
Accessing private class members in C++
Posted on by Idorobots
I've been called Kajtek "MOTHERFU*KINGWALLOFTEXT" Rzepecki lately, so let's make this post short.
We've got this code:
#include <iostream>
class A {
private:
int bar;
void foo() {
std::cout << "In A::foo() " << bar << "\n";
}
public:
//...
};
int main() {
A* a = new A();
//...
delete a;
return 0;
}
And we feel a sudden urge to call foo()
or access bar
. How do we do that?
Mixins make sense
Posted on by Idorobots
Let's suppose we have this class hierarchy:
It's a fairly specialized class hierarchy providing some functionality, let's say for the sake of this example that SomeClass
provides a kind of player-game interaction interface and HierarchyWith
defines it as a trigger based interaction (as in "a player does something - it triggers a response"). Our ExampleClass
represents an entity that can be triggered by the player and that generates some response and in addition to that is further specialised to have some concrete functionality - let's say it's a lever that a player determined enough can pull to flood something with delicious magma. As we clearly can see ExampleClass
is well-defined in terms of OOP, it's highly specialised and modular, but as an in-game entity it lacks a rather crucial functionality - it can't even be displayed on the screen. What do we do now?
Testing in programming is pretty important, no doubts about it, too bad that some languages make it difficult to test the code easly. For instance C++ is pretty limited in terms of DbC and unit testing. All it ever supplied to programmers was a little =assert()= macro that stopped the program providing minimal info about the error and the place it was "caught" in. I mean there are exceptions in C++ and they are pretty usefull, but still it's not enough and requires lots of effort in lerning and implementing correctly. One can still say there are libraries such as CppUnit for those purposes, but we all know how it goes - the more I need to do to get some minor advantage the less I'm interrested in it, and unit testing is so underestimated it's not considered an advantage to have a working piece of code anymore, how about that? And speaking of DbC in C++... It is possible... bam (A sound of a thousand readers going "whaaa" this instant.)
Continue reading