cdoty Posted August 21, 2020 Share Posted August 21, 2020 Has their been any clever code you've amazed yourself with lately? For me, it's a joystick handling routine. Handling joystick input, in any assembly language, is always messy. I got the idea to wrap the joystick handling into a macro that accepts "callback" routines for each of the movements, buttons, and an idle "callback". This is closer to the model used in many higher level languages. This separates the joystick handling logic from the bit processing to identify the inputs, and it allows the code to be used in different sections of the game, I just have to write routines to handle the specific inputs. I also customize the macro based on the inputs expected. My current one only looks for left, right, and fire. But, in a high score screen, I might need all four directions. A potential downside would be the handling of diagonal movements near an edge. The macro could be expanded to check for diagonal movements first, and call the appropriate callback. 1 Quote Link to comment https://forums.atariage.com/topic/310403-clever-code/ Share on other sites More sharing options...
JamesD Posted September 13, 2020 Share Posted September 13, 2020 Lately? Not really, it's usually just hard work, and experience. One time does really stand out. When I was in my 20s, there was a piece of code I wrote for a project that nobody on the team had the slightest idea how to do. We had to get some software (network switch simulators) to work together that was exhibiting what everyone thought was random behavior. After putting off this piece of code as long as I could (2 a.m. a few nights before it was due), I wrote some code based on a complex mathematical relationship that worked. When I showed it to the team they were like... how... the... hell... did you get that from this random data? There's no way I can describe it other than I just saw it. Divine inspiration maybe? 1 Quote Link to comment https://forums.atariage.com/topic/310403-clever-code/#findComment-4631554 Share on other sites More sharing options...
Mr SQL Posted December 17, 2020 Share Posted December 17, 2020 On 9/13/2020 at 6:52 PM, JamesD said: Lately? Not really, it's usually just hard work, and experience. One time does really stand out. When I was in my 20s, there was a piece of code I wrote for a project that nobody on the team had the slightest idea how to do. We had to get some software (network switch simulators) to work together that was exhibiting what everyone thought was random behavior. After putting off this piece of code as long as I could (2 a.m. a few nights before it was due), I wrote some code based on a complex mathematical relationship that worked. When I showed it to the team they were like... how... the... hell... did you get that from this random data? There's no way I can describe it other than I just saw it. Divine inspiration maybe? Very cool! Erlang's algorithm may have been similarly inspired by what other engineers thought was random behavior at the switch - Erlang was a Danish mathematician who came up with a complex algorithm to optimize throughput in Telephone switches. Quote Link to comment https://forums.atariage.com/topic/310403-clever-code/#findComment-4701297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.