Grok explains :hide:
But as it mentions checking monodetect twice, maybe its trying to debounce the signal.. Maybe stems from previous attempts at fixing the mono detect issue which was replaced by the F-series chip on later motherboard revisions.. But even so, a debounce would make sense as a fix.
But still , It doesn't make much sense why the registers seems to get cleaned and ignored with PAK ?!
All this needs someone with more than 2 functioning brain cells to figure out.. :lol:
Analysis of 68k Atari ST TOS Monochrome Detection Snippet and TP_666 Reset Issue
The provided 68k Atari ST TOS code snippet is a routine for detecting a monochrome monitor by checking the MFP (Multi-Function Peripheral) chip's General Purpose I/O Port (GPIP) and the sound matrix control register (
). The issue arises when the
flag is set to
, causing resets in a game or system. Below is an analysis of the code and why
may lead to resets.
Code: Select all
moncheck:
#if TP_666 /* PAK ?why? */
move.b #0,d0
#else
move.b ((sndmactl)+1).w,d0
#endif
move.b (MFP_GPIP).w,d1
btst #7,d1
sne d1
move.b (MFP_GPIP).w,d2
btst #7,d2
sne d2
cmp.b d1,d2
bne.s moncheck
#if TP_666 /* PAK ?why? */
move.b #0,d0
#else
cmp.b ((sndmactl)+1).w,d0
#endif
bne.s moncheck
move.w (a7)+,sr
btst #0,d0
beq.s nomoncheck
not.b d1
nomoncheck:
Code Breakdown
1.
Initial Check and Conditional Code:
Code: Select all
#if TP_666
move.b #0,d0
#else
move.b ((sndmactl)+1).w,d0
#endif
- When
,
is set to
.
- Otherwise, it reads the second byte of
into
, which may reflect monitor or sound chip settings.
2.
Monochrome Detection Loop:
Code: Select all
move.b (MFP_GPIP).w,d1
btst #7,d1
sne d1
move.b (MFP_GPIP).w,d2
btst #7,d2
sne d2
cmp.b d1,d2
bne.s moncheck
- Reads the MFP’s GPIP bit 7 (monochrome detect) into
and
. The
instruction sets
(monochrome) or
(color).
- Loops back to
if readings are inconsistent, ensuring a stable signal.
3.
Second Conditional Check:
Code: Select all
#if TP_666
move.b #0,d0
#else
cmp.b ((sndmactl)+1).w,d0
#endif
bne.s moncheck
- If
,
is set to
, skipping the
comparison.
- Otherwise, it checks if
matches
, looping back if not.
4.
Final Steps:
Code: Select all
move.w (a7)+,sr
btst #0,d0
beq.s nomoncheck
not.b d1
nomoncheck:
- Restores the status register (
), indicating an interrupt or privileged mode.
- If bit 0 of
is set, inverts
(monitor type). If
,
, so
is never inverted.
Why TP_666 = 1 Causes Resets
When
, the code forces
, bypassing
checks. This can cause issues:
1.
Bypassing Hardware Checks:
- Skipping
checks may allow incorrect monitor detection, leading to incompatible video mode settings (e.g., color mode on a monochrome monitor), which can crash or reset the system.
2.
Impact on d0 and Logic:
- With
, the
check always skips inverting
. If the game expects inversion for correct monitor detection, this could lead to wrong video mode initialization.
3.
Potential Infinite Loop:
- The
loop ensures stable GPIP readings. Bypassing
checks might allow premature exit with incorrect data, causing downstream issues.
4.
Game-Specific Assumptions:
- The
flag (noted as "PAK ?why?") seems like a debug hack. It may break game assumptions about monitor type, leading to crashes.
5.
System Reset Triggers:
- Incorrect video mode settings or invalid hardware accesses (e.g., to the Shifter or sound chip) can trigger resets on the Atari ST, especially in interrupt contexts.
Debugging Suggestions
-
Trace Video Initialization: Check how
is used to set video modes. Look for conflicts with the Shifter chip.
-
Monitor Hardware Accesses: Inspect code accessing video/sound registers post-routine.
-
Test Monitors: Try with monochrome and color monitors, toggling
.
-
Check sndmactl: Verify its role in your ST model for monitor or sound settings.
-
Patch TP_666: Set
to restore normal checks.
b]Emulator Debugging[/b]: Use Hatari to step through code, monitoring
,
,
, and video registers.
Conclusion
The
setting likely causes resets by bypassing
checks, leading to incorrect monitor detection and video mode mismatches. This can crash the game or system. Debugging with an emulator or testing monitor setups can help. If you have more code (e.g., video initialization), I can dig deeper!