Patch 717260


The 717260 patch consist of three parts:

  • A ROM Extension (REx) patch as an embedded installer package
  • A ROM patch as an embedded installer package
  • A patch installer

The parts are combined into one Newton installer package. The patch installer is triggering the installation of the first two embedded packages.


The files in the package can be split into four groups. The patch packages are constructed out of NSOF stream objects, which in turn are either extracted from the original patch verbatim, or generated by the Newton C++ tools by linking compiled code together.

Generic and common files

  • include/Bytecode.a: Assember macros to generate NewtonScript bytecode
  • include/package.a: Macros to control package attributes
  • include/page.a: Macros for MMU page mapping
  • include/project.a: Definitions for the patch areas
  • include/sound.a: Not used
  • include/stream.a: Macros to generate NSOF streams
  • Makefile: The MPW makefile which controls compilation of the patche code
  • common.txt: Common definition for the NTK projects
  • NSOF stream containing the original binary code for the RegisterPatch function. This stream is included in the REx and ROM patch packages verbatim.

REx Patch

The REx patch part patches the ROM extension found at address 0x01e00000.

  • RExStrmHead.s: Preamble for the REx patch
  • RExMMU.s: MMU remapping
  • RExPatch.s: Actual patch data
  • RExPatch.txt: Text file with the install script and other scripts for the REx patch NTK project
  • RExPatch: NTK project file used to generate the REx patch package

ROM Patch

The ROM patch part patches the jump tables starting at 0x01a00000.

  • ROMStrmHead.s: Preable for the ROM patch NSOF stream
  • ROMMMU.s: MMU page mappings for the ROM patch
  • Patch1.s to Patch6.s: Actual patch data
  • ROMPatch.txt: Install script and other scripts for the ROM patch NTK package
  • ROMPatch: NTK project file used to generate the ROM patch package

Patch Installer

  • Original NSOF stream containing the binary code for installing patch packages
  • TestPatch.txt: Install and other scripts for the overall patch package
  • TestPatch: NTK project file for the overall patch package

Memory Layout

The ROM and REx patches are combined into sequential areas. This is the layout of the ROM patch:

% Physical Address % Virtual Address % Source File % Section %
% 0x00000000         %                   % ROMMMU.s      % MMU patch table, 8192 bytes of patch entries to patch 2048 MMU pages %
% 0x00002000         % 0x01d80000        % Patch1.s      %           %
% 0x00003000         % 0x01ae0000        % Patch2.s      %           %
% 0x00004000         % 0x01b40000        % Patch3.s      %           %
% 0x00005000         % 0x01a8c000        % Patch4.s      %           %
% 0x00006000         % 0x01bac000        % Patch5.s      %           %
% 0x00007000         % 0x01c11000        % Patch6.s      %           %

Patch Example

Below is an example of how the TClassOneModem::PrepareCommand is patched. The function implementation is located at address 0x0006399c in the MP2x00 US ROM, and the jumptable entry is at address 0x01a16b3c. Patching the function is achieved by letting the jump table entry point to the patched function.

The ROMMMU.s file contains the first step for this, it maps the page starting at 0x01A16000 to RAM:

; patches of 0x2000
	DontLoadPages 22	; 0x01A00000 - 0x01A15000
	LoadPage 2		; 0x01A16000 needs to be patched
	DontLoadPages 9		; 0x01A17000 - 0x01A1F000

The next step is in Patch1.s, it contains the new page for address 0x01A16000:

reORG	SETA	{PC} - 0x1A16B00
	B	0x001B9AA8 + reORG
	B	0x01B40C5C + reORG ; patch from 0x0006399C, address of the original function
	B	0x001E0F68 + reORG

And the final part is in Patch6.s, where the new code for the TClassOneModem::PrepareCommand function is located at address 0x01B40C5C:

	STMFD	sp!,{R0,LR}
	STMFD	sp!,{R0,R1,LR}
	BL	0x0006399C ; call to the original function, new code follows
	LDMFD	sp!,{R1,R2,LR}
	TEQ	R2,#15
	LDR	R2,[R1,#1932]
	ADD	R2,R2,#0x000007D0
	STR	R2,[R1,#1932]

Compiling the Patch

Prerequisites are MPW, the Newton C++ tools and NTK. The steps to recreate the package are:

  • Download and extract the patch
  • Start MPW and set the current directory to the location of the patch
  • Use the make command to compile the ROMPatch and RExPatch targets:
    • Make ROMPatch
    • Make RExPatch
  • Launch NTK
  • Open the RExPatch project and create the RExPatch package
  • Open the ROMPatch project and create the ROMPatch package
  • Open the TestPatch project and create the TestPatch package