eyeball This site is a proud member of the geekring!
Check some other geeky websites here!

Previous site -- Random site -- Next site

This will be a web page with just things that interests me which is mostly programming.
Code is hosted at notabug.org/orbb
Feel free to contact me at orbb at cock.li

Projects
Tutorials
Ramblings
Religion

Blog:

2021-07-04 I've been feeling tired lately and so haven't got much work done. One thing I've been fiddling around with is a stripped down version of C. It's not completely finished so I'll keep experimenting with it while doing other projects.
Other than that I just want to complain a bit about the state of the world: At an apartment complex where I work there had been a group of around 6-10 kids running around with their faces covered that were harassing people, particularly a 65 year old man from whom they wanted $50 or they said they were gonna kill him. He was slightly offended by their low evaluation on his life. Me and another guy went into the stairwell while they were at this man's door again and they ran away but I'd called the police prior and they managed to pick up some of them this time and it turns out they were 14 year olds from a nearby school.
We'd figured they were probably school kids as they kept fairly regular schedules of around either 10 or 12 o'clock but thought they'd at least be in late high school. We did some stupid things at 14 but threatening to murder complete strangers over 50 bucks on our lunch breaks wasn't one of them. Modern times I guess.

2021-05-09 Did a review of the book The Sacred Mushroom and the Cross and had some thoughts about switch statements.

2021-04-11 So I've found another little side project that's turned into a bit of a rabbit hole. This one involves parsing a C source file which turned out to be a none trivial undertaking but I think I've got it worked out and hope I can publish something about it soon.
Other than that I've written a short review about a recent keyboard purchase.

2021-03-09 Wrote a page for rendering floors and ceilings in the raycaster engine and some musings on control schemes. Also had to do a slight update to the raycaster tutorial because irritatingly enough I was off by one when calculating "yScreenBottom".
Moved all the blog posts from 2020 to their own page.

2021-02-20 Finally got done with the raycaster tutorial. Mostly anyways, floors and ceilings are implemented but not explained yet. It's been sitting half finished for some time so I somewhat rushed it just to get it out of the way but hopefully it's still comprehensible. I'll add floors and ceilings later or as a separate page.
One problem that cropped up was compiling the example code for WASM. Because the code leans heavily on recursion it becomes a necessity to have tail call elimination but this just recently got added as a proposed feature for WASM. Chrome has an experimental implementation of it though and the only way of seeing the little game at the top of the page is with Chrome at the moment.
WASM has probably inherited this lack of proper tail calls from java script where it's a feature in the language that no one but Safari implements. It was surprising to see that this wasn't in JS considering all the other features it got. The most popular programming language with millions of users and no one uses recursion enough to need it? It certainly throws some doubt on the story that JS is inspired by Scheme...
After rereading Moses and Monotheism recently I wrote a short summary.
Also I found a broken laptop with a stick of 4GB PC3 memory in the trash! Found another 4GB stick a year ago so now I'm up from 4 to 8GB in the laptop which is nice.

2021-01-03 A new year. But will I piddle it away like all the others? Most likely. I added something about the origin of the name of the Demiurge in Gnosticism, Ialdabaoth.
When writing Orbz 3D I got stuck on how to rotate objects in 3D. At first I was going to use an algebraic solution. Stated simply the problem was finding three variables, the x, y and z coordinates for the new 3D position after doing the rotation. As we know from basic algebra three unknowns requires us to have three equations in which the variables are used in order to find what their values are. The three things known about the rotated position was the dot product, cross product and the equation for the 2D plane in which it had to exist. Cross product being a vector and not a scalar value you also had to use it with a second vector to get another dot product.
Solving something like this is not terribly complicated. You can break it down into a couple of steps when doing it on paper. When doing it in a program however those steps had to be compressed into a single one and I thought it looked kind of ugly and it wasn't easy to explain what was happening. Instead I found a way to do it using geometry that was a lot more intuitive. I tend to favor geometrical solutions since when you have something visual it is much easier to reason about the solution and therefor remember how it works. It's one of the best areas of mathematics.

Other than that I've been implementing some more small changes to how I program. I found myself often using negative numbers to signal the absence of something. For example each orb in the program can have a parent associated with it, which is another orb who's actions like movement and rotation it can be made to mimic. A parent is then defined as just an integer that represents an array index at which that parent is located. So e.g. the orb at array index 5 might have a parent of 7. So these parent values for all orbs where stored in an int array and since they represented array indices they were only supposed to be positive - negative array indices are of course valid in C as an array is just a pointer but I've never seen this used and can't imagine it to be a good idea ever - so then the array can be of type unsigned int. However some orbs might not have a parent and what I usually do in these cases is use -1 to signal none. If the parent array then had -1 in one place you knew that that orb didn't have a parent.
This though if you think about it is a bit wasteful. You're giving up half the possible values that the array can hold. If an unsigned int can be between 0 and 65,535 then a signed int can only contain the numbers -32,767 and 32,767, and on the negative side you'll only ever use -1, all the others go unused. This might not matter in practice since the program won't ever approach 32 thousand orbs let alone 65 thousand but it still irked me that the parent[] array was now being used for two different purposes: Indicating whether an orb had a parent or not and also storing the value for that parent if it had one.
To make things more explicit and to me clearer I made a bool array called hasParent that is for indicating if an orb has a parent in the first place. The parent[] array can then be made of type unsigned int and each array now only does a single job.
Similarly there was also a function called find_orb() that took an "orb id" and returned an index to an array where that orb could be found. If it didn't find any orb with that id it returned -1. Again I thought this caused confusion since the return value of the function now essentially was variable. The nature of the return value is either a bool representing false if no orb is found and it returns -1 or if one is found it will return a positive integer representing both true and therefor being a bool while simultaneously also being an integer representing an array index. Sure, you can use a define or constant to label the value -1 to something like NONE but I felt this did not get rid of the inherent ugliness in having one number represent multiple things. Modifying the function to only return a bool to indicate found/not found and having it place the array index in a passed in pointer I thought was a neater solution.