2025-01-11 - 2024 Retrospective
Once again I feel like I have made progress. It’s not entirely clear how much progress but I think I am moving forward in more ways that just temporally.
Personal stuff first
Cats
The cats continue to slowly get better with each other. I still have to referee a lot but I think the total number of incidents is still going down. The main challenges there is finding ways for them to have positive interactions. Refereeing is also a challenge because I want to keep Robin safe but not upset Lupo in the process.
Robin’s poops continue to be a problem. In September I switched her to half-and-half urinary tract and senior food which seemed like it was helping but then at the end of December she stopped eating and got constipated. I started giving her restoraLax (A stool softener) which seems to be helping but now the trick is making sure it doesn’t cause urinary issues.
Lupo got his teeth cleaned this year without any complications. I started brushing his teeth but I’m not sure if I’m doing a good job or not. It’s difficult to tell how much I am actually brushing and keeping him still for the brushing. He also decided not to eat at the end of December and I’m not sure why. He started eating normally again a couple days later and seems fine.
Health
I have continued to have spats of feeling sick without really getting sick this year although it might be to a lesser degree. I went to a new doctor to get a check-up and they referred me to an allergist. I had an allergy test and nothing significant came up (I am allergic to some kind of weed but that seems to be it). Both doctors had me do a bunch of blood and urine tests with no significant results.
I got properly sick just before Christmas and still have a cough. I’m hoping it will clear out my throat and I will feel better.
I would like to get a camera shoved down my throat just to see if anything’s up but I’m not sure how to properly ask for that.
It’s possible that it’s stress related or sleep related which is related to stress.
House
I bought a new bookshelf for the office/second bedroom and did some re-arranging in there. I also drilled a hole in the wall and ran an ethernet connection to the main floor so that my work laptop could be wired. I also bought a bookshelf for the kitchen.
I probably need to get a new furnace and an AC or at least a duct cleaning but I don’t have the energy to arrange that
Volunteering
At the beginning of this year we got a new staff member who was at most of the volunteering sessions this year. She’s great and helped to make volunteering a positive experience. She was really involved and trying to make things happen. She was also more proactive about getting people to come in.
I also started taking paper folding patterns to volunteering this year. That’s helped to make sure I have something to do without being unapproachable (at least I hope that’s how it comes off).
I think my two complaints are the lack of feedback, I don’t know how well I am doing or if I should be doing things differently, and the time investment. I sometimes feel like losing that Sunday afternoon limits what I cam accomplish. It’s much nicer during the summer when I can take every other Friday afternoon off so I have a bit of extra time to get stuff done on weeks that I volunteer.
Collecting
I think I have managed to buy most of the software that I really want. There’s always more stuff but I have found most of the tentpole software releases that I’m interested in. I have also pretty much ran out of space.
I think the next steps for me are getting more user manuals for retro computers and maybe buying some actual retro machines to play with. The challenge there remains space.
Computers
I have built two computers this year. The first is a high-mid gaming machine and the second is a 486 based retro machine.
The gaming machine seems to be working well. I had some issues with game crashes at the beginning but managed to resolve those by disabling the BIOS setting which makes RAM run at the speed it says it does. Now it’s running all the games I play without issue. I have it slightly underclocked to keep temperatures manageable but I haven’t noticed any issues because of that. It was a fun experience because it was my first driveless build. There are no optical drives and it’s using M.2 SSDs which plug directly into the motherboard. That means that the whole front of the case can just be fans and there’s a lot less wires.
Building the new gaming machine also means that I can use my old gaming machine as a dev machine which is nice. My previous dev machine was starting to show it’s age and have some stutters when doing a lot of work. I have reinstalled Windows Vista on it and now it can be a retro machine. I also found out that the telephone activation for Windows and Office still works, so that’s interesting.
The 486 machine has been a fun and educational exercise. Learning about all the complications with older hardware and figuring out how to make things work. I had to re-wire the PS/2 mouse connector because the one I bought didn’t match the motherboard. I have also learned a lot about serial RS-232 connections because of this machine. Apparently there are two ways that the motherboard can be wired and this machine uses the less common one. I’m actually really proud of how I figured that out. I bought a serial tester (A box with lights that indicate what each signal is doing) and then I compared the results from the 486 machine to my other machines. From that I had a pretty good guess as to how things were miss-wired and was able to look up the issue and have my guess validated.
Penguin Cooker and Website
At the beginning of this year I finished up the management of pictures and picture sets. This includes the functionality for picSet parents, using a UUID to sync data between local and remote instances as well as cleaning up functionality.
The ability to sync pics and picSets was also added which required refactoring the creation and updating logic into separate classes so that it could be used by the edit pages and the sync pages.
Website
I’ve made some minor changes to the website, mostly cleaning up issues from the changes made for pictures such as cleaning up some URL issues and how thumbnail images are used.
The display scripts were updated to handle changes to how pictures are organized. Some files were moved so that the the content files were stored separately from the page scripts, this was done so that the content could be removed from source control.
The pic page was updated to add name and description. This makes it easier to understand the images when navigating. The pictures page and picSet pages were updated to have the link boxes wrap correctly. Also added parent links to picSet pages.
Floppy Image Rectifier
My big project for this year has been the Floppy Image Rectifier. This is a project to unify some tools that I started building last year. My goal is to have a single program I can run on an SCP floppy image to generate HFE and IMG files with feedback and options that I feel are important. I have made a lot of progress and have most of the application implemented.
Mainly what I still have to do is verify that I am doing things correctly. My process for this has been to read through the code of a couple other tools that do similar things and compare how they work to how my application works. The challenge there is understanding other people’s code and having the motivation to look at it.
I stopped working on other projects, book exercises and writing blog posts in order to focus on this project. I don’t think that has been super successfully as typically it just meant I didn’t do any programming but I’m hoping I can get more done this year.
I was hoping to get more done over Christmas but I got sick before going to visit my parents and then the cats had problems after I got home.
I would like to get this project done as it would allow me to archive all my disks which is the first step to going through them and making progress on other retro projects.
Videos
I have not made any videos this year. The challenge I have is that I think I need to dedicate more time to them and that requires taking time away from other things that I want to do. I was thinking about trying to make some one-off videos to practice but that just means I have more videos to make.
Part of the problems is that I don’t really want to make videos. That’s not something that I am really interested in. What I want to do is show people how weird the story changes in Mafia: Definitive Edition are, but video is the best way to do that which means I have to make videos.
Stats
- Blog posts – 3
- Writing pages added – 1
- Writing pages updated - 8
- Videos made – 0
- Books read – 10 (0 Programming Textbooks)
- Programming textbook chapters completed – 22
- Programming project commits – 134 (58 SVN, 76 GitHub)
2024-05-25 - In IL: Field Declarations
Last time we looked at the options for declaring fields in IL, today we are going to look at some examples.
This C# program has a variety of fields defined.
Let's start by looking at the accessibility attributes.
As expected we have the .field directive, the accessibility attribute, the type and the name of the field. The accessibility attributes line up the same as they did for the nested classes that we looked at previously.
Next we have some examples of the contract attributes.
Again this is as we expect. All the fields are private because we omitted the accessibility marker. The const field became static literal to indicate that it is stored with the class and it can only have the value specified. Note that the literal assigned to the field is wrapped in a type specifier. readonly became initonly with both meaning that the field can only be set in a constructor. The static field is also marked as static in IL.
Now let's look at some different type identifiers.
First we have the FileMode field, in IL this is marked valuetype to indicate it's a value type (it's an enum) and then we get the fully qualified name of the type [mscorlib]System.IO.FileMode. The [mscorlib] part indicates the assembly that contains the type. The FileInfo field is marked class to indicate that it's a reference type. The Complex field is also marked as valuetype because it's a struct and we can see it's from a different assembly ([System.Numerics]) than the others. Finally we have the built in types which just replace the C# name for the type with the IL name for the time.
To finish off, let's look at some array fields.
Arrays are indicated by the [] at the end of the type name the same way they are in C#.
Well this was all very straight forward. Next time we will look at the instructions used to work with fields
2024-03-16 - DataTypes: Negative Numbers
In the last two posts we've been looking at positive binary numbers but what about negative binary numbers? How do we represent those? The simple answer is that you put a negative sign in front of the number, so –101 would be –5, but that just changes the question to how do we record a negative sign with bits?
Well, we have a few options.
Sign and magnitude
The simplest way is to use one of the bits to indicate the sign. This is typically the most significant bit. So if you were using an 8-bit byte to store a number, bit 7 would encode the sign and bits 0-6 would encode the value. This means you can encode the values –127 to +127. The sign bit is usually 0 to indicate positive and 1 for negative but it's only really important that the machines using these numbers are consistent about the meaning.
The main problem with this approach is that it requires computers to analyze the bits before performing operations.
5 + –7?
We are adding a negative value so that can be converted to subtraction.
5 – 7
The right number is bigger than the left number so we know the value will be negative and the value will be the same as if the subtraction was done the other way around.
-(7 – 5) = –2 = 5 + – 7
5 + – 3?
We are still adding a negative value so that can be converted to subtraction.
5 – 3
This time the right number is smaller than the left so we know the value will be positive and we can just do the subtraction.
5 – 3 = 2
Another oddity with sign and magnitude is that you have both –0 and +0 as we can have a zero magnitude with either sign.
This isn't terribly complicated and, as we will see later, this is how standard floating-point numbers are encoded. It would be nice to speed up the process if we can, especially when computers are going to be doing these kinds of calculations billions of times a second.
Ones' complement
Another option is Ones' complement which defines negative numbers as being the binary complement of the positive number with the same value. Binary complement means to flip all of the bits, 0 –> 1 and 1 –> 0. So for –56 we take 0011 1000 (56 in binary) and flip all the bits to get 1100 0111. The most significant bit still acts as a sign bit as it will only be set for negative numbers but now it's also a part of the value. The range of values is still –127 to +127 and we still have two zeros (0000 0000 and 1111 1111) but we have to do less special work to handle negative numbers in calculations. We add and subtract numbers as normal but if we get a carry or a borrow left over then we have to apply that back to the result.
For example if we were using 4-bit numbers we could do 5 + -7 which would be 0101 + 1000 (The complement of 0111 which is 7).
We know the result is negative because the most significant bit is set and if we take the complement we get 0010 which is 2. So 5 + –7 = –2 as we expect.
What if we try 5 + –3? That would be 0101 + 1100.
Our current result is 0001 which is 1. 5 + –3 = 1? That doesn't seem right. We have a carry left over though, so with ones' complement we need to add that back to the result.
Which gives us 0010 or 2. 5 + –3 = 2 makes a lot more sense.
So Ones' complement simplifies performing math with negative numbers at the cost of making negative numbers a little harder to decode. Can we do better?
Two's complement
The answer is yes. Two's complement defines negative numbers as being the complement of the positive number plus one. This is sort of like pre-including that extra addition step. The easiest way to determine the Two's complement of a value is to switch every value after the first 1. So for –56 we start with 0011 1000, keep all of the bits up to the one in the fourth spot the same and then flip all the bits after that to get 1100 1000.
You can also think of this as simply making the most significant bit negative. So you can determine the decimal equivalent of 1100 1000 by calculating –27 + 26 + 23 = –128 + 64 + 8 = –56. Like Ones' complement we don't have to handle the sign separately but now we also don't need to perform a second calculation.
For 5 + –7 we do 0101 + 1001
Again the most significant bit is 1 indicating a negative number. If we take the two's complement of 1110 we get 0010 which is 2, so the result of 5 + –7 is –2.
And for 5 + –3 we do 0101 + 1101
We ignore the carry out in this case and get 0010 which is the correct result of 2.
We can also think of negative numbers in two's complement as being the positive value subtracted from 0. To determine –9 we can calculate 0 – 9 or 0000 – 1001.
Which gives us our expected result of 0111. To do this calculation we had to borrow from some kind of nether space but that's okay because we got the result that we wanted.
With an 8-bit Two's complement number the range of values – 128 – 127. So we have an extra value now. Another benefit of Two's complement is we only have one zero because the two's complement of 0000 0000 is 0000 0000. So that's nice.
Two's complement is by far the most common way to represent negative numbers because we don't need to do any extra steps to get the correct result.
Next time we will start to look at fractional numbers
2024-01-14 - Adventures in Text Interfaces
For a while now I've been curious about how full screen MS-DOS applications were made. The kind of programs that have menus, scroll bars and pop-up prompts. Stuff like Edit or the various DOS IDEs. They seemed pretty common so I assumed that there would be a lot written about them, I was wrong and that just made me more curious.
My first problem was coming up with the right terms to search for. Searching for "Text Interface" leads to a bunch of pages taking about it in an abstract sense but nothing specific. Adding "DOS" helps a little but but you still end up with a lot of general discussion. Adding "Programming" would just flood the results with discussion of DOS programming in general.
Eventually I found a page talking about programming with DOS conio and this seemed promising but it was also very confusing. For example, the page talked about the conio library but none of the functions mentioned on the page appeared in any examples of the conio library I could find. This article was talking about FreeDOS, so I assumed this was a modern implementation that did things differently.
Later I figured out that the confusion was coming from differences between different compilers. The Microsoft compiler implemented a lot of its drawing functions in graph.h, you can see it being included in all of the examples on that page. Borland had those kinds of functions in conio.h but with different names. So conio + function name didn't give any results because the conio with those functions didn't use those names and the functions with those names weren't in conio. I imagine the writer of that article used Borland back in the day which is why they associated that kind of programming with conio. Microsoft used conio for functions more related to command line programming (Where text is printed to the screen one line at a time).
This did lead me to the header files and functions that I was interested in but I still couldn't find any good examples. The compiler documentation I had did give examples of how to use the functions but nothing about how to combine them together.
Unrelated to my text mode interface searches, I've also been looking for old software and documentation on eBay. One of my saved searches was for "Programmer's guide" in an attempt to find books talking about how to program for various systems. From this search I found a book titled "C Programmer's guide to Graphics" by James W. McCord. This book is geared towards programming in graphics modes and not text mode but it did get me thinking. The book is titled "C Programmer's guide" and not "DOS programmer's guide", maybe that's my problem.
So I did some searches for "C programming text interfaces" and eventually found "User Interfaces in C" by Mark Goodwin. This book was exactly what I wanted and gave a bunch of examples of how to write text mode user interfaces for MS-DOS applications. Of course the words "text-mode" and "MS-DOS" don't appear in the title of the book.
I'm not sure why the book was titled this way. Putting "C" in the name to indicate what language it was using makes sense but why not mention what operating system it was for? It was published by Microsoft Press, did they assume that only MS-DOS users would be looking at their books? Was it just that MS-DOS was ubiquitous at this point and no one would have thought you were talking about something else?
It just goes to show that one of the problems with searching for things is that you don't know what to search for until you've found it.
At least I have some DOS text mode programming examples now.