// post · 744

Does SimCity 2000 actually use your FPU?

·

A question that's nagged me for years: if you dropped a 387 maths coprocessor into a 386DX-40, would SimCity 2000 run any faster? Plenty of DOS games never touched the FPU, so the coprocessor was often dead weight. So I pulled apart the shipped binary to check.

There's no source, so this is static analysis — disassembling SC2000.EXE from the 1994 CD-ROM Collection. Claude did most of the legwork counting opcodes, same as the recent site redesign.

What it is

SC2000.EXE is a 32-bit protected-mode program behind a DOS/4GW extender, compiled with Watcom C/C++ as a Linear Executable. It was built with Watcom's -fpi floating-point model, which matters below.

Does it use floating point?

Yes — around 543 x87 instructions spread across the 644 KB code segment. A typical routine:

fild   word ptr [ebp-4]     ; int -> float
fmul   dword ptr [ebp-0xc]
fadd   dword ptr [ebp-8]
fdiv   dword ptr [0x543b]   ; divide by a float constant
fld1                        ; load 1.0
fcomp  dword ptr [ebp-8]
fnstsw ax / sahf / jbe      ; FP compare -> branch

The fnstsw ax; sahf; jbe sequence is the 387-era way of branching on a float compare; a Pentium Pro would use fcomi, which never appears, so this was written for the 386. There's also a lot of fild/fistp — int to float and back — which is what you'd expect from a sim that keeps its state as integers.

Hardware or emulator?

The -fpi model emits real x87 instructions and links a software emulator as a fallback. With a coprocessor they run on it; without, they fault and the emulator handles them. There's the usual detection routine (fninit, read the control word, cmp ah, 3) and support for the NO87 environment variable to force the emulator. So an FPU is used when present but not required.

How much faster?

Per operation, a 387 op is about 25–90 cycles; emulated in software it's roughly 1,000–5,000, so the coprocessor is about 20–80× faster, worst for divides and transcendentals. But only about 2.5% of the game's functions touch the FPU. The constant work — the 128×128 tile sim (power, water, traffic, pollution, land value, crime) and the isometric blitter — is all integer.

Workload Effect of a 387
Normal play — scrolling, drawing, the sim tick, UI A few percent at most.
Periodic recalcs — budget, graphs, terrain generation, loading a city Noticeable; a 1–2 s pause can become near-instant.

Bottom line

A 386DX-40 with no coprocessor runs SimCity 2000 fine — that's what the -fpi/NO87 design is for. A 387 won't help the scrolling, but it takes the edge off the periodic pauses (when processing e.g the budget).

// post · 743

Claude Code

·

AI is finally here to take our jobs :)

Got Claude Code do to a bit of design work to the site. Still running the same old backend PHP but some newer HTML/CSS. It makes updating old code so much more accessible, hopefully I will still be running the same old crusty backend in 2050.

I used this markdown file https://getdesign.md/ibm/design-md to ask Claude to rewrite the theme.

It's not really a massive improvement at this stage, but I didn't have to write any code, so that is a plus...

I should ask it to start writing my blog posts, might be more interesting.

EDIT: I ran out of tokens now too :(

// post · 742

It works on PHP 8.2!

·

Upgrading the OS this site (and a few others including https://www.vogonswiki.com) runs on was one of my goals for the Christmas break this year.

Unfortunately there is a lot of old scripts running on it; making it difficult to move past PHP 7.0.

I've finally fixed a lot, most were pretty easy (including this site), mediawiki was the worst so far.

  • Bluetrait Blog now works on PHP 8.2!
  • Media Wiki upgraded (ish, still a super old version, extension hell there)
  • The Board (old recipe tracking system)

I've been able to switch over to PHP 7.3 now which is great. Hopefully I can get to 7.4 this year?

Also had to rebuild the raspberry pi zero running our gate recently. That was a pain. The SD card died so I replaced that and upgraded to Raspbian/Debian 12, that broke all the GPIO libraries I was using :/

Isn't upgrading fun? Actually I'm pretty happy how well things are working considering I ignore them for years at a time.

Next I'm actually thinking of upgrading this blog to replace the theme with something new, although not sure yet.

// post · 722

Password Manager

·

I've never found a password manager that I like (the story of my life)!

I've never been a fan of hosting my personal data with other companies.

So I spent two days writing my own.

Mr Password is awesome. It does almost everything a Password Manager should do. I'm selling it cheap on codecanyon and once purchased you get free upgrades and access to the code.

Features include:

  • Unlimited number of custom fields per password.
  • Active Directory Authentication Support
  • Multiple Users (with 2 permission levels, User and Administrator)
  • Security Logging
  • Account lock down after 5 failed logins
  • MySQL Database
  • Hashed (with SHA ) Account Passwords
  • Password Generator
  • Password Categories
  • Sharing Categories
  • HTTPs/SSL Supported

Go get it, only $US8-10 (depending on the way you purchase it).

Link: http://codecanyon.net/item/password-manager/2145518

Demo

URL : http://www.onlinecompanyportal.com/mrp/

Username: admin

Password: 1234

// post · 720

IPManager Invoicing

·

Invoicing is just about complete! There are two more things that are not finished yet, PDF invoices and emailing the invoicing. Both will be pretty easy.

There were a few complex SQL queries to handle the tax calculations (and to have the total on the view all invoices page).

Here is what it looks like (click to see full size).

Invoicing IPM3.0

// post · 719

Fun with JQuery

·

I am in the process of writing in invoicing support for IPManager (need to change the name of this app!). I've looked at Xero and Saasu but I'd still need to work out their API, and I don't like the idea of companies having access to my data, so I'm doing it myself :)

To do it nicely I need to use a bunch of JQuery so that you can easily add new line items on the fly (and calculate tax etc).

I've got it working just the way I want it, using a very long JQuery command! 

$('.invoice_item').clone().addClass('new_invoice_item').removeClass('invoice_item').find('input')

.val('').end().find('p').append('<a id="delete_item" class="button"

href="#">Delete</a>').end().appendTo('.invoice_item_extra');

Here are a couple of screen shots:

Invoice Line Items

And here is the basic design that the clients will see:

Client Invoice View

I am pretty happy with it so far, lots of work to go though.