Skip to content

B side: Showing text and reading keys

A cassette tape with a handwritten label: "B Side. Fortran, the language that speaks maths."

B B side · Fortran · The language that speaks maths

How does the program talk to the person at the keyboard?

11 Fortran words in this segment
8 Assembly words for the same job

What Fortran says well here

  • PRINT and WRITE format numbers for you.
  • The same text works on Linux, macOS and Windows.
  • The format I4.4 keeps the leading zeros for a countdown, for example fuel 0042. The format I0 removes them for a score. The B side writes the number that the A side must show.

What is hard to say

  • Standard Fortran has no words for graphics, sound, or one key press without Enter.

One sentence in Fortran

print *, "Hello"

It says: Show the word Hello on the screen.

The words, by part of speech

Verbs (5) · A statement that does something, for example PRINT, CALL or ALLOCATE.

WordMeaningExample
PRINTShow values on the screen.print *, "Fuel:", fuel
WRITEWrite values to the screen or to a file.write(*, '(F8.2)') fuel
READRead values from the keyboard or from a file.read *, thrust
OPENConnect a file to a unit number.open(newunit=u, file='map.dat')
CLOSEDisconnect a file.close(u)

Idioms (1) · A built-in function or subroutine, for example SQRT or MATMUL.

WordMeaningExample
GET_COMMAND_ARGUMENTRead one word that the person typed after the program name. The checker gets the file name this way.call get_command_argument(1, in_file)

Grammar marks (5) · Maths signs (+ - * / **), the = sign, and (:) for part of an array.

WordMeaningExample
NEWUNIT=In OPEN: let the compiler choose a free unit number and put it in the name.open(newunit=u, file='sine.bin')
ACCESS='STREAM'In OPEN: read or write the raw bytes of a file, with no record marks. This is how the B side writes a table for the A side.open(newunit=u, file='sine.bin', access='stream', form='unformatted')
'(I4.4)' / '(I0)'Two formats for a whole number. I4.4 keeps the leading zeros (0042), for a countdown. I0 removes them (42), for a score.print '(i4.4)', fuel
*In PRINT and READ: let Fortran choose the layout.print *, x
'(F8.2)'A layout pattern. F8.2 is a number 8 characters wide with 2 decimals.write(*, '(F8.2)') x

Watch out: what the review found

These notes come from the review of the AI-written guides. They show traps that are easy to miss.

  • D02-M5 major This is too strong. Compilers from vendors of that time shipped graphics libraries that Fortran can call. An example is the graphics library of Microsoft FORTRAN 5.x. A call to a vendor or assembly library was normal practice. The Assembly path also depends on BIOS calls.
  • D02-M10 major The document does not discuss distribution. Modern players will run the game in DOSBox or in a browser build. Emulator input latency, frame latency and host-display refresh (60 Hz, not 70 Hz) weaken the "zero-latency, locked 70 fps" promises.
  • D13-M11 major The video gives the detail: the decimal flag does the carry (32:05), a 16-bit packed BCD counter holds "exactly the 10,000 I need", INC and DEC ignore the flag, so he uses ADC (32:05 to 32:26), and he suppresses leading zeros, except for the chicken counter (32:46 to 33:06). The claim is now checkable and correct.
  • D15-M7 major The code does bcdKillCounter + amount on a binary integer, then toString().padStart(4, '0'). It is a decimal string, not BCD. It clamps at 9999 (measured: 9990 + 25 gives 9999). A decimal-mode ADC wraps to 0000 and sets the carry. The nibble display is correct. In the video, the chicken counter counts down and keeps its leading zeros [33:06]. The level counter counts up and drops them [32:26]. The one real trap in the video, INC and DEC ignore the flag [32:05], is absent from the simulator.