System Monitors / Freezer

There are a lot of pure software freezers out there. The usage of such tools may be of great help during the development and debugging of Slaves and the installed programs. WHDLoad directly supports HRTmon and ThrillKill. Additionally there is a generic interface which every freezer may implement to get supported by WHDLoad automatically. During startup WHDLoad checks if one of the supported monitors are active. If one is found WHDLoad will do some special stuff. If the MMU is used by WHDLoad it will declare the memory used by the monitor as valid and cacheable using the appropriate cache mode. While the game/demo runs it will forward all NMI exceptions to the NMI vector saved from the monitors vector table. Additional, if the VBR is moved by WHDLoad (NoVBRMove/S is not set and the cpu is at least a 68010) it will compare the FreezeKey with the actual keyboard value at each interrupt. If the keys match WHDLoad will acknowledge the keyboard, transform the stackframe to a NMI stackframe and enter the monitor via his NMI handler. The monitor must return to the interrupted program using a RTE instruction.

Some further notes which are valid for all freezers:

Supported Freezers

TypeFreezerDetection
1ThrillKill 1.04d ... 1.05d code compare before the NMI vector
2ThrillKill 1.05d patched by stembbe@ala.net code compare before the NMI vector
3ThrillKill 17 patched by stembbe@ala.net signature "TKTK" before the NMI vector
4HRTmon 2.1d ... 2.19 signature "HRT!" relative to the VBR
5HRTmon 2.20 ... 2.24 signature "HRT!" before the NMI vector
6HRTmon 2.25 and newer signature "HRT!" and "NEWHRT"
7HRTmon 2.32 built into WinUAE signature "HRT!" at the fixed address $a10000
8ACA500plus and any other freezer implementing the generic interface signature "ACAF" before the NMI vector

The type is shown in the log file if the option Trace/S is used.

HRTmon

The detection in memory should be safe especially with newer versions of the monitor cause a new signature was added to the monitor. Be careful if the MMU is used by WHDLoad: don't access memory outside BaseMem/ExpMem from HRTmon. It will crash because HRTmon cannot handle the resulting Access Fault Exception.

In the HRTmonPrefs you must check the 'No VBR move' box, otherwise you will not be able to enter the monitor while WHDLoad is running.

After returning from an activated HRTmon to the program running under WHDLoad you may note a incorrect graphic display. This is because HRTmon overwrites some Custom register. You can work around this by telling HRTmon the correct value, e.g. use 'e $100 $5200' for a 32 color screen before return.

The HRTmon built into WinUAE can only be detected if HRTmon has been previousy activated at least one time (press key PgUp). This is the case because not until the first activation the NMI vector will be set which is required by WHDLoad to locate the monitor.

There are newer releases of HRTmon which add special commands when running under WHDLoad. So you can load/save files and use the resload_Protect#? functions from within HRTmon. These releases are downloadable from the WHDLoad page.

ThrillKill

There is no useable signature in the freezer, so some code compares are used. Therefore the detection only works with known releases.

Generic Freezer Interface

This interface was introduced with WHDLoad 18.6 for the freezer of the ACA500plus (which may contain ActionReplay or HRTmon code), but it is not limited to this hardware. Every freezer, software or hardware based, which implements this interface will be detected and supported by WHDLoad automatically, no changes in WHDLoad are required for it.

The interface consists of a signature and a list of the memory areas used by the freezer, both located immediately before the entry of the NMI handler. On startup WHDLoad reads the NMI vector (offset $7c) from the exception vector table (located at the VBR on a 68010 or better, otherwise at address 0) and checks for the signature.

	dc.l	memlist			;NMI-8  pointer to the memory list
	dc.l	"ACAF"			;NMI-4  signature
nmi	...				;NMI    entry of the NMI handler
	...
	rte

memlist	dc.l	$aa0000,$be0000,3	;freezer code and data, write through
	dc.l	$400000,$480000,3	;freezer buffer, write through
	dc.l	$bff000,$c00000,1	;hardware registers, non cachable
	dc.l	$d8c000,$d90000,1	;hardware registers, non cachable
	dc.l	0			;end of list

The memory list consists of entries of three long words each, terminated by a long word of zero. Each entry describes one memory area:
OffsetContents
0start address of the area
4end address of the area (exclusive)
8MMU page flags for the area, see below

The following values are supported as MMU page flags:
ValueMeaning
0invalid (any access creates an access fault)
1non cachable
2non cachable, serialized
3cachable, write through
4cachable, copy back
+8additionally write protected

Things to consider when implementing the interface: