MSX DIAGNOSTICS v1.2.0 - Technical Docs

Author: Cesar Rincon "NightFox"
Platform: MSX (Z80)
Compiler: asMSX 0.19+

Table of Contents

1. Executive Summary

MSX Diagnostics is a hardware validation tool designed under the "Bare Metal" paradigm. Unlike standard MSX software, this program minimizes reliance on the system BIOS.

2. Memory Map

The system enforces a specific memory layout to avoid conflicts with areas reserved by the host system or the stack.

2.1 RAM Memory Map

Address Label Type Description
$0000 - $3FFF BIOS ROM Page 0 (Slot 0).
$4000 - $BFFF PROGRAM ROM Cartridge code and static data (Pages 1 and 2).
$C000 - $E37F STACK / FREE RAM Free area and System Stack.
$E380 - $EB7F NGN_RAM_BUFFER RAM 2KB Buffer. Used for RLE decompression, text buffer, and volatile variables.
$EB80 - $F380 VARIABLES RAM Static Variables. Defined in vars.asm. Forced location for security.

2.2 Video Memory Map (VRAM - SCREEN 2)

Address Label Content
$0000 NGN_CHRTBL Pattern Table: Tile definitions (Characters).
$1800 NGN_NAMTBL Name Table: Screen map.
$1B00 NGN_SPRATR Sprite Attributes: Sprite attribute table.
$2000 NGN_CLRTBL Color Table: Color table for tiles.
$3800 NGN_SPRTBL Sprite Patterns: Graphic definitions for sprites.

3. Software Architecture

3.1 Boot Flow & POST

  1. Initialization (NGN_START): Waits for interrupt stabilization, applies patch to hook $FD9A (Watchdog), clears variables, and silences the PSG.
  2. POST (Power On Self Test): Executes FUNCTION_SYSTEM_POST. Emits 3 beeps and blinks the CAPS LOCK LED. Goal: Life feedback (CPU OK) even if the video chip fails.
  3. Hardware Detection: Scans Slots, RAM, and identifies the VDP.
  4. Launch: Transfers control to FUNCTION_MAIN.

3.2 Menu State Machine

The program does not have a single loop. Each screen acts as an independent state:

4. Engine Analysis (N'gine)

4.1 Hardware Abstraction (HAL)

The engine isolates logic via low-level drivers:

4.2 Synchronization Watchdog

In ngn_system.asm, the hook $FD9A intercepts the interrupt. If it's not from the VDP (Bit 7 of S0), it returns. This guarantees that the HALT in the main loop is a perfect vertical synchronizer (50/60Hz).

5. Diagnostic Modules

5.1 RAM and Mapper Detection (Core)

Location: memory_routines.asm. Non-destructive algorithm:

  1. Topological Scan: Iterates through Slots and Sub-slots detecting expansion.
  2. RAM Verification: Read byte -> Invert bits (CPL) -> Write -> Read -> Compare -> Restore original.
  3. Mapper Detection: If 64KB is detected in a slot, performs a pagination test by writing markers to port $FC and verifying if memory segments change.

5.2 VDP Detection

Identifies the chip by hardware behavior, not BIOS:

6. Compilation & Build

Different formats are generated via conditional directives in msxdiag.asm: