• What are you working on? May 2012
    2,222 replies, posted
I didn't have a thermometer in my room, so I made one using my Arduino and LED Matrix. [img]http://puu.sh/xlfx[/img] The addressing on these is fucked up, here's what my [i]drawPixel[/i] function looks like: [cpp]void ht1632_setpixel( byte x, byte y, bool on ) { byte addr; if ( x < 8 ) addr = (7-x)*4 + y/4; else if ( x < 16 ) addr = (15-x)*4 + y/4 + 32; else addr = (23-x)*4 + y/4 + 64; byte bit = 8>>(y%4); if ( on ) pixels[addr] |= bit; else if ( ( pixels[addr] & bit ) > 0 ) pixels[addr] ^= bit; ht1632_senddata( addr, pixels[addr] ); }[/cpp] Suggestions to shorten this code are welcome. The buffer is needed because 4 pixels share one address and it's not possible to read from the display (this would be unbearably slow anyway). I generated the bitmaps for the digits using a C# program, which outputted them as a font [i]byte[/i] array.
I think I just accidentally instancing, I wasn't trying to use it but looking at tutorials I think I just stumbled upon it.
[QUOTE=Overv;36111038]I didn't have a thermometer in my room, so I made one using my Arduino and LED Matrix. [img]http://puu.sh/xlfx[img] The addressing on these is fucked up, here's what my [i]drawPixel[/i] function looks like: [cpp]void ht1632_setpixel( byte x, byte y, bool on ) { byte addr; if ( x < 8 ) addr = (7-x)*4 + y/4; else if ( x < 16 ) addr = (15-x)*4 + y/4 + 32; else addr = (23-x)*4 + y/4 + 64; byte bit = 8>>(y%4); if ( on ) pixels[addr] |= bit; else if ( ( pixels[addr] & bit ) > 0 ) pixels[addr] ^= bit; ht1632_senddata( addr, pixels[addr] ); }[/cpp] Suggestions to shorten this code are welcome. The buffer is needed because 4 pixels share one address and it's not possible to read from the display (this would be unbearably slow anyway). I generated the bitmaps for the digits using a C# program, which outputted them as a font [i]byte[/i] array.[/QUOTE] Probably not faster but it does get rid of the ifs. [cpp]void ht1632_setpixel( byte x, byte y, bool on ) { byte addr; addr = (7 - (x % 8)) * 4; //Get X offset addr += y / 4; //Add Y offset addr += (x / 8) * 32; //Add boundary byte bit = 8>>(y%4); if ( on ) pixels[addr] |= bit; else if ( ( pixels[addr] & bit ) > 0 ) pixels[addr] ^= bit; ht1632_senddata( addr, pixels[addr] ); }[/cpp]
[QUOTE=high;36111327]Probably not faster but it does get rid of the ifs. [cpp]void ht1632_setpixel( byte x, byte y, bool on ) { byte addr; addr = (7 - (x % 8)) * 4; //Get X offset addr += y / 4; //Add Y offset addr += (x / 8) * 32; //Add boundary byte bit = 8>>(y%4); if ( on ) pixels[addr] |= bit; else if ( ( pixels[addr] & bit ) > 0 ) pixels[addr] ^= bit; ht1632_senddata( addr, pixels[addr] ); }[/cpp][/QUOTE] Less if's are good. fewer comparisons and branches. :v: I've not ever used the arduino compiler, so I don't know how optimizing it is, but here's my version of high's function [cpp] void ht1632_setpixel(byte x, byte y, bool on) { byte addr = ((7 - (x & 7)) << 2) + (y >> 2) + (x >> 3) << 5; // get x offset, add y offset, add boundary (last part could probably be an x << 2) byte bit = 8 >> (y & 3); if (on) { pixels[addr] |= bit; goto end; } // deal with it. if (pixels[addr] & bit) { pixels[addr] ^= bit; } end: ht1632_senddata(addr, pixels[addr]); } [/cpp] why yes, I [i]am[/i] a terrible person for using a goto, thanks for asking :v:
Calling an assembler function from C is really easy on AVRs: [img]http://i47.tinypic.com/2yjzltu.png[/img] [img]http://i45.tinypic.com/2pplvl4.png[/img]
[QUOTE=Maurice;36109549]At 5 fps you already have a frametime of 200 ms. A sleep of 1ms is not going to do very much.[/QUOTE] Except that it won't sleep for 1ms on most operating systems, it'll sleep for 15/16ms.
[QUOTE=Chandler;36112178]Less if's are good. fewer comparisons and branches. :v: I've not ever used the arduino compiler, so I don't know how optimizing it is, but here's my version of high's function [cpp] void ht1632_setpixel(byte x, byte y, bool on) { byte addr = ((7 - (x & 7)) << 2) + (y >> 2) + (x >> 3) << 5; // get x offset, add y offset, add boundary (last part could probably be an x << 2) byte bit = 8 >> (y & 3); if (on) { pixels[addr] |= bit; goto end; } // deal with it. if (pixels[addr] & bit) { pixels[addr] ^= bit; } end: ht1632_senddata(addr, pixels[addr]); } [/cpp] why yes, I [i]am[/i] a terrible person for using a goto, thanks for asking :v:[/QUOTE] Not necessarily - gotos here might translate directly to JMPs in the binary which gives you a bit more control over the final structure and thus a more (or less) optimised result.
[QUOTE=Dotmister;36112492]Except that it won't sleep for 1ms on most operating systems, it'll sleep for 15/16ms.[/QUOTE] [img]http://i.imgur.com/ZnOsp.png[/img] Whatever you say mate.
[QUOTE=Dotmister;36112492]Except that it won't sleep for 1ms on most operating systems, it'll sleep for 15/16ms.[/QUOTE] If the OS gives other programs 15ms instead of 1ms.
It's still longer than 0.001!
[QUOTE=geel9;36110275][img]http://puu.sh/xkxe[/img] Got the dedicated server working. It's made very simple by the fact that the actual game server is contained in a library, so anybody can create a dedicated server without needing to recode the server. It contains ways to handle console input/output and whatnot, so if you're hosting a listen server, the server will write to the in-game console.[/QUOTE] Very nice. I'm actually creating a dedicated server as we speak. If you don't mind, what networking library are you using?
You could always write your own sleep function for more accuracy if it did end up doing something funky.
[QUOTE=Maurice;36112799][img]http://i.imgur.com/ZnOsp.png[/img] Whatever you say mate.[/QUOTE] OK then, [I]Mate[/I].
Woah woah let's not get too friendly in here
I'm back with some more easy listening. This time I've got a basic menu in there, with smooth transitions using a frame-buffer. The buffer has a problem with transparent white pixels, though... [vid]http://mordi.ziphoid.com/data/stuff/Showing_First_OpenGL_App7.webm[/vid] The thing of note here isn't necessarily the menu itself, but rather how elements are added: [cpp]// Main Menu menuSystem->AddButton("Play", centerX - 100, 300, 200, 35, MENU_MAIN, [=]() { GameEngine::ChangeState(new IntroState(), true); }); menuSystem->AddButton("Settings", centerX - 100, 336, 200, 35, MENU_MAIN, [=]() { menuSystem->GoTo(MENU_SETTINGS); }); menuSystem->AddButton("Quit", centerX - 100, 372, 200, 35, MENU_MAIN, [=]() { GameEngine::StopGame(); }); // Settings menuSystem->AddBox("Settings", centerX - 150, 250, 300, 250, MENU_SETTINGS); menuSystem->AddButton("Back", centerX - 75, 515, 150, 35, MENU_SETTINGS, [=]() { menuSystem->GoTo(MENU_MAIN); });[/cpp]
Im trying to do this cube optimisation thing, and I think I have the chunk part done but in writing the whole thing my ccubes have ended up looking like this: [IMG]http://i.imgur.com/ct72E.png[/IMG]
[QUOTE=esalaka;36112575]Not necessarily - gotos here might translate directly to JMPs in the binary which gives you a bit more control over the final structure and thus a more (or less) optimised result.[/QUOTE] Oh I know, but I've come under fire for saying gotos are okay before :v: (also, a goto in C is almost always an unconditional jump unless the compiler does something crazy like link time optimization and then sees it can optimize the goto, which is probably unlikely, or if the underlying ISA doesn't support it. The more you know :v:)
I released my graphing calculator app as a beta test but I don't have I link because I'm too tired to find it. I'll post one tomorrow.
Optimisations FTW This is what it used to be like: 512 cubes at 0.641375ms AKA 1-2fps [quote][img]http://i.imgur.com/i83HR.png[/img][/quote] and now: 262144 cubes at 0.0158307ms AKA 60-65fps [QUOTE][IMG]http://i.imgur.com/RTmz9.png[/IMG][/QUOTE] [editline]29th May 2012[/editline] Also works for non square objects [IMG]http://i.imgur.com/kKM7i.png[/IMG]
wow synthiac why the dumbs that's pretty cool
Your "ms/frame" number appears to be in seconds rather than milliseconds.
[QUOTE=Mr_Razzums;36112913]Very nice. I'm actually creating a dedicated server as we speak. If you don't mind, what networking library are you using?[/QUOTE] It uses Lidgren.
[QUOTE=supersnail11;36114670]wow synthiac why the dumbs that's pretty cool[/QUOTE] Synthiac is WAYWO's official unofficial troll.
[QUOTE=false prophet;36115119]Synthiac is WAYWO's official unofficial troll.[/QUOTE] That's unofficially official.
[i][u][b]Bridging the Gap[/b][/u][/i] [img]http://farmpolice.com/content/images/bridgingthegap.png[/img] Engine compiles and runs flawlessly on both Windows and Linux without any loss of features on either. I even looked into coloring text output on windows even though I don't use it and it's not essential; I can't wait to actually start making the game now :u.
[QUOTE=Naelstrom;36115684][i][u][b]Bridging the Gap[/b][/u][/i] [img]http://farmpolice.com/content/images/bridgingthegap.png[/img] Engine compiles and runs flawlessly on both Windows and Linux without any loss of features on either. I even looked into coloring text output on windows even though I don't use it and it's not essential; I can't wait to actually start making the game now :u.[/QUOTE] windows fps > linux fps WINDOWS IS SUPREME
[QUOTE=geel9;36115810]windows fps > linux fps WINDOWS IS SUPREME[/QUOTE] shoulda run it on macs every1 knows they run faster
Thought this was neat. [media]http://www.youtube.com/watch?v=KppTmsNFneg[/media] Cryengine Y u so awesome?
Once they fix that clipping, that'll be completely amazing, instead of just 75% amazing
[img_thumb]http://i.imgur.com/HMpOL.png[/img_thumb] 13,324 zombies running around the map and zombie placement comes from the picture it loads. who needs map editors when you have paint.
Sorry, you need to Log In to post a reply to this thread.