tag:blogger.com,1999:blog-5060551251465839575.post3619419264893462947..comments2023-12-25T23:28:04.785+08:00Comments on Dodgy Coder: Coding tricks of game developersDodgy_Coderhttp://www.blogger.com/profile/14418022725678218844noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-5060551251465839575.post-39068845334877148642016-07-06T15:13:57.035+08:002016-07-06T15:13:57.035+08:00Hi,
Thanks for sharing the coding tricks for game ...Hi,<br />Thanks for sharing the coding tricks for game development. Its useful for everyone.<br />Keep share:)KuwaitBrillMindzhttps://www.blogger.com/profile/15858423376512115387noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-87803010977625829262016-01-12T14:08:07.568+08:002016-01-12T14:08:07.568+08:00nICE POSTnICE POSTAnonymoushttps://www.blogger.com/profile/01818274872901330988noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-49179627365813825512012-08-04T12:34:40.772+08:002012-08-04T12:34:40.772+08:00My favorite trick has been from "Jak and Daxt...My favorite trick has been from "Jak and Daxter" - "trip and fall" - e.g. if the streaming falls behind, make the character trip and fall, thus giving time for the streamer to catch up.<br /><br />Heh, I wish we could've used that in Spiderman-2 :)<br /><br />Regards,<br />www.TechProceed.comSnehal Masnehttps://www.blogger.com/profile/10027968736163338678noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-25575235664203125392012-07-22T00:39:03.474+08:002012-07-22T00:39:03.474+08:00Great tips from game developers that apply to all ...Great tips from game developers that apply to all software development....Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-9000374723112575372012-07-17T03:49:40.570+08:002012-07-17T03:49:40.570+08:00To me this reminds me of the story of the man who ...To me this reminds me of the story of the man who liked to constantly hit his head with a hammer. People thought he was crazy and he was finally asked why he was hurting himself. He said, "Because it feels good when I stop."gin5enghttps://www.blogger.com/profile/01940617298230201174noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-4271725993854050012012-05-10T07:54:01.568+08:002012-05-10T07:54:01.568+08:00i don't think i've ever seen #1 in a memor...i don't think i've ever seen #1 in a memory context before--the more commonly heard version is the guy who hides "for(int i;i<1000000000;i++);" somewhere in the code, so that every now and then, he can knock a zero off and claim an order of magnitude speedup.Aaron Davieshttps://www.blogger.com/profile/05334056755840192313noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-80844279202836630552012-04-04T03:16:20.210+08:002012-04-04T03:16:20.210+08:00Death March != Crunch. Please don't confuse th...Death March != Crunch. Please don't confuse the twoSynopserhttps://www.blogger.com/profile/07135359317184463799noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-23254989028284996322012-03-08T23:27:04.509+08:002012-03-08T23:27:04.509+08:00I wrote a 68000 assembly to C conversion tool that...I wrote a 68000 assembly to C conversion tool that was used to convert code for Sonic 3D Blast from the Genesis to the Saturn. It worked really well, EXCEPT for one annoying bug, there was a secret door in one of the levels and it would crash if the player went through it. The reason was the data for the doors was stored using dc.w and ended when it encountered a negative value.<br /><br />doors:<br />dc.w 0x480,0x800 ;location of door<br />dc.w 0x200,0xa00 ;warp point<br /><br />move_player:<br />move.w playerX,d0<br /><br />But the move.w decoded as 0xa000, which is negative so it worked correctly on the Genesis. So I just added the dc.w -1 that was missing from the original code and reconverted.nhardinghttps://www.blogger.com/profile/10316489636559586522noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-76151410621291816502012-02-23T23:32:06.698+08:002012-02-23T23:32:06.698+08:00Sorry, I missed a "the" before terminolo...Sorry, I missed a "the" before terminology.tgwizardhttps://www.blogger.com/profile/14284208364902618278noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-63728011776511761112012-02-23T23:30:13.852+08:002012-02-23T23:30:13.852+08:00Perhaps the article is good, but terminology used ...Perhaps the article is good, but terminology used is very confusing. What about adding a note before the link that describes this issue?tgwizardhttps://www.blogger.com/profile/14284208364902618278noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-50925048660167033742012-02-14T08:53:52.839+08:002012-02-14T08:53:52.839+08:00You might be interested that incredibly it has bee...You might be interested that incredibly it has been written up as a formal pattern known as the <a href="http://www.charlesweir.com/papers/Mempres8AsHtml.html#Heading15" rel="nofollow">"Memory Overdraft Pattern"</a> -- <i>Ensure your memory budget has some slack. When a component needs more memory, and you can't reduce its size in any other way, you can grant it more memory from the overdraft. Either the remains of this overdraft, or a separate dynamic overdraft memory allocation in the budget, can supply extra memory in emergencies at runtime.</i>Dodgy_Coderhttps://www.blogger.com/profile/14418022725678218844noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-24358290008303037252012-02-14T01:46:08.292+08:002012-02-14T01:46:08.292+08:00Re: #17 a friend says:
"That explains why my...Re: #17 a friend says: <br />"That explains why my TSR's kept saying something about "Wing Commander" -- I always wondered. :)<br /><br />aGrumpy Gnomehttps://www.blogger.com/profile/08940403148286294798noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-64156383129528280232012-02-14T01:14:44.584+08:002012-02-14T01:14:44.584+08:00couldn't we just bitwise-and that integer?
inl...couldn't we just bitwise-and that integer?<br />inline int abs_no_branch(int n)<br />{<br />return (~(1<<(8*sizeof(int)-1)))&n;<br />}x4mhttps://www.blogger.com/profile/05795323474480716539noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-68841627732363923912012-02-14T00:17:02.328+08:002012-02-14T00:17:02.328+08:00this one i cannot attest to its accuracy but is ba...this one i cannot attest to its accuracy but is based on my personal experiments in the game "Dark souls"<br />the game employs a mechanism where it unloads higher poly/textured models when the player gets a certain distance away. however on one particular section there was a bridge with a dragon roosting on a building, the player was still inside this building just a bit below the dragon so that building was never unloaded, if you went to the top without exiting the building the dragon was never unloaded, you could then shoot it with an arrow and it would attempt to stomp on the bridge, but the bridge was unloaded and replace with a low poly, low texture model with no collision detection so the dragon just fell right through it and died.<br />the fix for this was simple:they unloaded the dragon as soon as he went out of sight.(you can even see his shadow disappear after walking through the lower door and can dance this line of him disappearing and reappearing)tushttps://www.blogger.com/profile/17521628310871763250noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-83771706281409756202012-02-13T21:22:17.165+08:002012-02-13T21:22:17.165+08:00It's actually a technique used a lot in projec...It's actually a technique used a lot in project management, called "contingency reserve". You reserve (i.e. hide from developers) part of the allocated resources (time and/or money) e.g. set their deadline a few weeks before the real deadline, to cope with unexpected risks.geerthttps://www.blogger.com/profile/05812867486690346819noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-12800454041856788482012-02-13T20:46:05.756+08:002012-02-13T20:46:05.756+08:00Thanks for the correction... as you rightly point ...Thanks for the correction... as you rightly point out its proper name is cache locality, however I think the linked to article (<a href="http://supercomputingblog.com/optimization/taking-advantage-of-cache-coherence-in-your-programs/" rel="nofollow">Taking advantage of cache coherence in your programs</a>) has a good introduction to the topic, even if the terminology is wrong. And here is the direct link for those interested to the paper you mention: <a href="http://www.akkadia.org/drepper/cpumemory.pdf" rel="nofollow">What Every Programmer Should Know About Memory [PDF] - by Ulrich Drepper (Red Hat)</a>Dodgy_Coderhttps://www.blogger.com/profile/14418022725678218844noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-90160202713873854762012-02-13T20:22:22.422+08:002012-02-13T20:22:22.422+08:00Re #2, cache coherence. That's in fact _local...Re #2, cache coherence. That's in fact _locality_ that you talk about. Coherence is feature whereby data is kept in sync across caches in multiprocessor machines. Those who care about the way caches and memories work might be interested in reading Ulrich Drepper's paper, linked here: https://lwn.net/Articles/259710/petrhttps://www.blogger.com/profile/02875187532253252695noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-59792897789717309092012-02-13T17:10:39.836+08:002012-02-13T17:10:39.836+08:00many thanks for this ... updating the article now....many thanks for this ... updating the article now.Dodgy_Coderhttps://www.blogger.com/profile/14418022725678218844noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-48394475898188339732012-02-13T15:58:02.968+08:002012-02-13T15:58:02.968+08:00Your right shift trick is incomplete. Here is a c...Your right shift trick is incomplete. Here is a complete version with demo:<br /><br /><br />inline int abs_no_branch(int n)<br />{<br /> int m = (n>>(8*sizeof(int)-1));<br /> return ((n^m) - m);<br />}<br />int main()<br />{<br /> int n = -5;<br /> cout << abs_no_branch(n);<br />}Brian Chttps://www.blogger.com/profile/10065346063023918827noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-91737509135142790222012-02-13T15:43:25.507+08:002012-02-13T15:43:25.507+08:00A coworker tried a variant of #1 once, although he...A coworker tried a variant of #1 once, although he was reserving memory for a feature he planned to add later rather than trying to be a hero. I had to teach him about modern compilers and linkers. Thanks to dead (unreferenced) data and code stripping, he'd set aside half a meg in debug builds only!Mailmanhttps://www.blogger.com/profile/03846961827808274592noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-17662728709764576612012-02-13T09:16:47.929+08:002012-02-13T09:16:47.929+08:00Thanks for the comment (fsel on GCC). Another note...Thanks for the comment (fsel on GCC). Another note is that I believe Visual Studio doesn't have the ability to do that sort of optimization, according to this post on StackOverflow ... http://stackoverflow.com/questions/1440570/likely-unlikely-equivalent-for-msvc.<br /><br />Regarding the CRC32 as a resource index, yeah I think it might have been simpler and better just to use a table of relative URIs/paths, each with a unique index.Dodgy_Coderhttps://www.blogger.com/profile/14418022725678218844noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-83169771776564859252012-02-13T09:00:02.534+08:002012-02-13T09:00:02.534+08:00That's a great story, thanks - a classic "...That's a great story, thanks - a classic "assumed its a bug but its actually not" case. No doubt there's often times when the artists' lack of knowledge about coding can cause issues, and vice versa.Dodgy_Coderhttps://www.blogger.com/profile/14418022725678218844noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-50663408470195273512012-02-13T08:53:45.947+08:002012-02-13T08:53:45.947+08:00@Tim yeah its certainly a bit extreme; I'm not...@Tim yeah its certainly a bit extreme; I'm not sure if that technique is used much anymore - that anecdote was from 12 years ago. I saw a comment over on hacker news that this technique would only work if only one person on the team did it - what if two people did it and ended up allocating too much (e.g. 4 mb). Also, someone else mentioned that he used to insert the equivalent for CPU cycles, e.g. he'd add in an empty spin loop and then when it came to the crunch he'd know that he still had a bit more processor power up his sleeve!Dodgy_Coderhttps://www.blogger.com/profile/14418022725678218844noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-49095224186094494962012-02-13T08:15:02.579+08:002012-02-13T08:15:02.579+08:00I'm horrified that you're "warming up...I'm horrified that you're "warming up" to item 1. I recall a guy who early in a project disabled the data cache in an embedded system to later look like a hero when it came time to measure performance. We would have worked like crazy solving unnecessary problems to make him look good. Luckily, I found and reported it early...M. Tim Joneshttps://www.blogger.com/profile/14405348062130473237noreply@blogger.comtag:blogger.com,1999:blog-5060551251465839575.post-76097740737644547502012-02-13T04:55:05.358+08:002012-02-13T04:55:05.358+08:00GCC optimizes for things like fsel, and Macs don&#...GCC optimizes for things like fsel, and Macs don't support PowerPC anymore. Try gcc -O2 instead; optimizations will be CPU-specific but your code will still be portable to other C compilers.<br /><br />Identity Crisis - Yeah, CRC32 has many collisions. Use a cryptographic hash sum, or better yet, don't use a silly resource indexing system at all.<br /><br />"It's not a bug, it's a feature!" - Yes, this describes the post as a whole.<br /><br />Patches - This anecdote counters most anecdotes in the post.<br /><br />Plan your Distractions - If you lack discipline and you're boring enough to spend hours on Facebook or Twitter, you shouldn't be making video games.<br /><br />I'm a programmer, not an artist - Absolutely.MCAndrehttps://www.blogger.com/profile/10025555896996100599noreply@blogger.com