Friday, 22 April 2016
Avoid C++ Typo-bugs with this One Cool Trick!
Recently I found an online quiz created by a company which develops some static code analysis tool. You were presented with buggy C++ code which the tool had detected and you had to click on where the bug in the code was.
The large majority of the bugs in the questions were down to typos. These normally occurred when someone had written the same line of code 3 or 4 times, but with different attributes (e.g. .x, .y and .z for a vec3)
Well, here's a neat trick that will allow you to avoid such typos. In the following example I recalculate the min/max values of a bounding box given a vector (pos):
/* Iterate the X, Y and Z attributes and assign them if necessary */
auto attrs = { &Vec3::x, &Vec3::y, &Vec3::z };
for(auto& attr: attrs) {
if(pos.*attr < bounding_box.min.*attr) bounding_box.min.*attr = pos.*attr;
if(pos.*attr > bounding_box.max.*attr) bounding_box.max.*attr = pos.*attr;
}
By using C++11 initializer lists, and auto, you can elegantly create a list of pointers to member attributes. C++11 range-for loops allow you to iterate them easily without a bunch of type definitions, and then you can just apply the pointers to the two vectors. This ensures that you never accidentally check the value of .y against .x or something like that. It's also fewer lines of code than repeating the if checks (4 vs 6). You could also tidy it up more if you create some extra reference variables in the loop. Win.
Saturday, 16 April 2016
DreamPi 1.3 Released!
This is a minor release which simply updates the Raspberry Pi firmware on the image. This should mean that the Pi 3 is supported, but I don't have one to test that!
You can download the new release here!
You can download the new release here!
Being Spread Too Thin
It's come to my attention that I have way too many projects on the go. This post is going to summarize what needs to be done to each of them in a kind of semi-apology for why things you are waiting for might take a while...
It's also worth remembering I can only work on some of these projects in certain locations. DreamPi stuff must happen at home where I have a Dreamcast and a DreamPi set up. Electronics stuff needs to happen near electronics kit, SDL 2 needs a PC with a Dreamcast emulator, access to a Dreamcast and KallisitiOS which I only have at home. Most of my computer time happens on the train, so... yeah.
The DreamPi software image has been a huge success. pcwzrd13 of Dreamcast Live recently reported the most active online Dreamcast game session ever as a result of more people getting their Dreamcast connected. Even though the software works, here's a list of things that are still left to do:
Connected, but separate, Dreamcast Now has become a useful tool, here are the things I'd like to fix:
I'd like to design and manufacture these, but this is on hold until I have some line voltage inducers made. The whole process for making a PCB is pretty time consuming so don't expect this stuff soon!
I have 3 prototype PCBs. I need to manually hot-plate solder the components, and then 3D print cases for them. At that point I can decide whether I have the time to sell them and whether it's worth it. This can only be done when I'm at my work's electronics club which unfortunately I can only make occasionally. Don't expect these any time soon either :(
Also, I need to fix some bugs in Fritzing (the PCB software) to make these PCBs export correctly without me manually fixing up the Gerber export files.
This is about 70% done. It needs testing and fixing. I'll get around to this when I start porting my game engine to the Dreamcast....
This is the main project I really want to focus on. Here's what I intend to do:
As you can see, I have a lot going on, and that's ignoring all the support requests / questions I get about the Dreampi and all the other things I'm helping individuals with. It also ignores the non-Dreamcast related stuff that I already have out there.
So, if you are waiting for something, I apologise, but all of my code is open source, I'd appreciate the help if you can contribute!
It's also worth remembering I can only work on some of these projects in certain locations. DreamPi stuff must happen at home where I have a Dreamcast and a DreamPi set up. Electronics stuff needs to happen near electronics kit, SDL 2 needs a PC with a Dreamcast emulator, access to a Dreamcast and KallisitiOS which I only have at home. Most of my computer time happens on the train, so... yeah.
DreamPi
The DreamPi software image has been a huge success. pcwzrd13 of Dreamcast Live recently reported the most active online Dreamcast game session ever as a result of more people getting their Dreamcast connected. Even though the software works, here's a list of things that are still left to do:
- Better IP address allocation, what is there now is incredibly buggy
- Cutting down the image, and swapping the init system for systemd then writing a proper systemd service file
- Detecting modem hotplugging and handling it gracefully
- Hanging up and reconnecting every 5 minutes or so when generating the dial-tone to workaround the modem apparently going to sleep
- Speeding up the connection process by removing excess AT commands
- Upgrading the image to support the Pi 3
- Coming up with a way to easily configure Wifi dongles
Dreamcast Now
Connected, but separate, Dreamcast Now has become a useful tool, here are the things I'd like to fix:
- Add more game domain hashes (e.g. Toy Racer)
- Add Dreamcast Live and Dreamcast-talk versions of the listing so that those sites can iframe them in
DC-Pheonix (DreamArena)
This is working amazingly well considering I hammered it out in a few hours. Still left to do though:
- Add Quake 3 PAL support
- Add a clone of the DreamArena registration site so users can register with DreamKey 1.0
- Database-backed user registration so that the entire process works as it did back in the day
Serial Connector / Link Cable
I'd like to design and manufacture these, but this is on hold until I have some line voltage inducers made. The whole process for making a PCB is pretty time consuming so don't expect this stuff soon!
Line Voltage Adapters
I have 3 prototype PCBs. I need to manually hot-plate solder the components, and then 3D print cases for them. At that point I can decide whether I have the time to sell them and whether it's worth it. This can only be done when I'm at my work's electronics club which unfortunately I can only make occasionally. Don't expect these any time soon either :(
Also, I need to fix some bugs in Fritzing (the PCB software) to make these PCBs export correctly without me manually fixing up the Gerber export files.
Dreamcast SDL 2 Port
This is about 70% done. It needs testing and fixing. I'll get around to this when I start porting my game engine to the Dreamcast....
My Game Engine (KGLT)
This is the main project I really want to focus on. Here's what I intend to do:
- Improve rendering performance
- Fix Quake 2 BSP lightmap loading
- Add an OpenGL 1.x renderer for Dreamcast support
- Port to the Dreamcast
- Write a game for the Dreamcast
As you can see, I have a lot going on, and that's ignoring all the support requests / questions I get about the Dreampi and all the other things I'm helping individuals with. It also ignores the non-Dreamcast related stuff that I already have out there.
So, if you are waiting for something, I apologise, but all of my code is open source, I'd appreciate the help if you can contribute!
Thursday, 7 April 2016
Toy Racer Back Online for Everyone!
I'm excited to announce that an experimental replacement server for Dreamarena is now online and as a result, Toy Racer is back online for everyone, even if you don't have a BBA!
DreamPi users have this support right now, just try it! Anyone else on dial-up will need to point their DNS at 46.101.91.123 to use the new server.
As I said, this server is HIGHLY EXPERIMENTAL. It will likely crash, not work, behave weirdly etc. the server will keep improving as I gain more understanding of the authentication protocol.
Quake 3 PAL doesn't work at the moment, but that support is coming soon too!
Special thanks go to Jonas Karlsson who did the hard job of deciphering the protocol!
Subscribe to:
Posts (Atom)