Pascal II: Disable Slot 3 Terminal Initialization

This program modifies the file SYSTEM.APPLE on the boot diskette so that Pascal won't initialize an 80-column card in slot 3, thereby allowing graphics programs to be run without interference from the 80-column card.
PROGRAM PATCH_40_COL;

TYPE BYTE = 0..255;

VAR F : FILE;
BUFFER : PACKED ARRAY [0..511] OF BYTE;
BLOCK, BLOCK_XFER : INTEGER;

BEGIN
WRITELN (CHR (12));
WRITELN ('Put disk with "SYSTEM.APPLE" in drive 1');
WRITELN;
WRITELN ('Press RETURN when ready');
READLN;
RESET (F, '#4:SYSTEM.APPLE');
BLOCK_XFER := BLOCKREAD (F, BUFFER, 1, 3);

BUFFER[327] := 76; (* PATCH #1 *)
BUFFER[328] := 245;
BUFFER[329] := 254;

BUFFER[384] := 24; (* PATCH #2 *)
BUFFER[385] := 144;
BUFFER[386] := 12;

BLOCK_XFER := BLOCKWRITE (F, BUFFER, 1, 3);
BLOCK_XFER := BLOCKREAD (F, BUFFER, 1, 4);

BUFFER[201] := 24; (* PATCH #3 *)
BUFFER[202] := 144;
BUFFER[203] := 12;

BUFFER[345] := 24; (* PATCH #4 *)
BUFFER[346] := 144;
BUFFER[347] := 14;

BLOCK_XFER := BLOCKWRITE (F, BUFFER, 1, 4);
CLOSE (F, LOCK);
WRITELN ('Done')
END.
Published Date: Feb 20, 2012