MSX DIAGNOSTICS - API Reference

Technical Documentation for Developers (Open Source)

prog/main.asm

FUNCTION_MAIN

Main entry point after boot. Initializes the engine, system, displays the welcome screen, and launches the main menu.

Input: None
Modifies: All

FUNCTION_EXIT

Emergency exit routine. Clears the screen, shows a reboot message, and executes a software reset (CHKRAM).

Input: None
Modifies: All (CPU Reset)
prog/system.asm

FUNCTION_SYSTEM_START

Boot orchestrator. Executes POST, detects memory configuration, VDP, initializes keyboard and state variables.

Input: None
Modifies: All

FUNCTION_SYSTEM_POST

Visual and audible Power On Self Test. Blinks the CAPS LED and beeps to confirm CPU activity.

Input: None
Modifies: AF, BC, DE

FUNCTION_SYSTEM_RESET_KEYBOARD_MATRIX

Clears the logical keyboard state variables (SYSKEY_*).

Input: None
Modifies: AF, B, HL

FUNCTION_SYSTEM_SET_KEY_NAMES_TABLE

Detects the MSX region (BIOS $002C) and selects the appropriate key name table.

Input: BIOS [$002C]
Modifies: AF, HL

FUNCTION_SYSTEM_HID_READ

Reads Keyboard and Joysticks, unifying the input into abstract logical variables.

Input: None
Modifies: AF, B

FUNCTION_SYSTEM_SCREEN0_CHARSET

Loads a custom character set for SCREEN 0 mode into VRAM.

Input: CUSTOM_CHARACTERS_SET
Modifies: AF, BC, DE, HL
prog/welcome.asm

FUNCTION_WELCOME

Displays the title/logo screen, waits for a timer or key press to continue.

Input: None
Modifies: All
prog/main_menu_*.asm

FUNCTION_MAIN_MENU_P1

Manages logic, rendering, and input for Main Menu Page 1 (Video Tests).

Input: Menu state vars
Modifies: All

FUNCTION_MAIN_MENU_P2

Manages logic, rendering, and input for Main Menu Page 2 (Input, Audio, System).

Input: Menu state vars
Modifies: All

FUNCTION_MAIN_MENU_HEADER_PRINT

Prints the common menu header (dashed lines and title).

Input: None
Modifies: AF, BC, DE, HL

FUNCTION_MAIN_MENU_PRINT_CURSOR

Clears the cursor from the old position and draws it at the new selected position.

Input: MAINMENU_ITEM_SELECTED, MAINMENU_ITEM_OLD
Modifies: AF, HL
prog/memory_routines.asm

FUNCTION_MEMORY_GET_CONFIG

Master function. Sequentially calls Slot detection and then RAM detection.

Input: None
Modifies: All

FUNCTION_MEMORY_GET_SLOT_LAYOUT

Iterates through the 4 primary slots to detect expansion (reading $FCC1).

Input: None
Modifies: AF, BC, DE, HL

FUNCTION_MEMORY_GET_MEMORY_LAYOUT

Iterates Slots (0-3) and Subslots (0-3) calling RAM detection for each combination.

Input: None
Modifies: All

FUNCION_MEMORY_GET_SLOT_RAM

Searches RAM in the current slot. Checks pages 0-2 (no mapper) and page 3. If 64KB found, looks for Mapper.

Input: MEMORY_SLOT_ID
Modifies: All

FUNCION_MEMORY_GET_RAM_IN_MAPPER

Detects Memory Mapper by writing to port $FC and verifying segment isolation.

Input: MEMORY_SLOT_ID
Modifies: All

FUNCTION_MEMORY_COUNTER_ADD_4KB

Adds 4KB to the global and local detected RAM counters.

Input: None
Modifies: AF, BC, DE, HL
prog/vdp_routines.asm

FUNCTION_VDP_INDENTIFY_VDP_TYPE

Identifies the VDP model (TMS9918, V9938, V9958) and frequency (50/60Hz) via register manipulation and cycle counting.

Input: None
Modifies: All
prog/sfx.asm

SFX_FUNCTION_PLAY_PING

Emits a high-pitched sound (Ping) by directly manipulating the PSG.

Input: None
Modifies: A (PSG Registers)

SFX_FUNCTION_PLAY_PONG

Emits a low-pitched sound (Pong) by directly manipulating the PSG.

Input: None
Modifies: A (PSG Registers)

SFX_FUNCTION_UPDATE

Controls the fade-out of the current sound on channel A.

Input: None
Modifies: A

SFX_FUNCTION_CLOSE

Immediately silences PSG channel A.

Input: None
Modifies: A
prog/memory_reports.asm

FUNCTION_MEMORY_REPORTS_PRINT_RAM_REPORT

Generates and displays the detailed detected RAM report on screen.

Input: RAM_* variables
Modifies: All

FUNCTION_MEMORY_REPORTS_PRINT_RAM_LAYOUT

Iterates over memory data structures to draw the Slot/Subslot grid on screen.

Input: HL (Pos), RAM_TEST_SHOW_ALL_INFO
Modifies: All
prog/screen_tests.asm

FUNCTION_SCREEN[0-3]_TEST_MENU

Shows the instruction menu before each video test.

Input: None
Modifies: All

FUNCTION_SCREEN[0-3]_TEST_RUN

Executes the corresponding visual test. Fills screen with chars/patterns and allows color/border changes.

Input: None
Modifies: All

FUNCTION_SCREEN2_TEST_LOAD_IMAGE

Loads one of the predefined RLE background images based on the provided index.

Input: B (Image index)
Modifies: AF, BC, DE, HL

FUNCTION_SCREEN3_TEST_CHANGE_PATTERN

Changes the tile pattern in the multicolor mode (Screen 3).

Input: B (Pattern index)
Modifies: All
prog/sprites_test.asm

FUNCTION_SPRITES_TEST_RUN

Main sprite test loop. Manages movement modes and bouncing.

Input: None
Modifies: All

FUNCTION_SPRITES_TEST_CREATE

Initializes 32 sprites in grid positions with incremental colors.

Input: None
Modifies: AF, BC, DE, HL

FUNCTION_SPRITES_TEST_MOVE

Calculates movement physics and bounce for all 32 sprites.

Input: Data in RAM BUFFER
Modifies: AF, BC, DE, HL
prog/keyboard/joystick.asm

FUNCTION_KEYBOARD_TEST_RUN

Displays the key matrix and highlights key presses in real-time.

Input: None
Modifies: All

FUNCTION_JOYSTICK_TEST_RUN

Displays the status of both joystick ports using sprites.

Input: None
Modifies: All
prog/psg_test.asm

FUNCTION_PSG_TEST_RUN

Interface to manually manipulate PSG channels, frequency, volume, and noise.

Input: None
Modifies: All
prog/mixed_mode_test.asm

FUNCTION_MIXED_MODE_TEST_RUN

Configures the VDP to show the undocumented "Mixed Mode", blending attributes from different graphics modes.

Input: None
Modifies: All
prog/monitor_color_test.asm

FUNCTION_MONITOR_COLOR_TEST_RUN

Displays solid colors (RGB/BW) and an automatic color cycle for monitor calibration.

Input: None
Modifies: All
prog/system_info.asm

FUNCTION_SYSTEM_INFO

System summary screen: MSX Model, VRAM, VDP, Slots, and RTC Clock (if present).

Input: None
Modifies: All
ngn/ngn_start.asm

NGN_START

Global initialization routine for the N'gine library.

Input: None
Modifies: AF, BC, DE, HL
ngn/ngn_system.asm

NGN_WAIT_FOR_START_UP_INTERRUPTS

Pauses execution for a few seconds at startup to allow hardware stabilization.

Input: None
Modifies: AF, B

NGN_SYSTEM_FD9A_PATCH_ON

Installs a hook at $FD9A to filter non-V-Blank interrupts.

Input: None
Modifies: AF, HL

NGN_SYSTEM_RANDOM_NUMBER

Simple pseudo-random number generator.

Input: NGN_RANDOM_SEED
Modifies: A, B
ngn/ngn_screen.asm

NGN_SCREEN_SET_MODE_[0-3]

Configures the VDP to the specified mode, clears VRAM, and sets colors.

Input: B (Fore), C (Back), D (Border)
Modifies: AF, BC, DE, HL

UPDATE_SCREEN_VDP

Applies base configurations to VDP registers 0 and 1.

Input: None
Modifies: AF, B, C
ngn/ngn_sprite.asm

NGN_SPRITE_MODE_[8x8/16x16]

Changes global sprite size and magnification in VDP register 1.

Input: None
Modifies: AF, BC

NGN_SPRITE_RESET

Clears all sprites from the screen and resets Shadow RAM.

Input: None
Modifies: AF, BC, DE, HL

NGN_SPRITE_CREATE

Defines a sprite in Shadow RAM.

Input: A (ID), B (Pattern), C (Color), DE (XY)
Modifies: AF, BC, DE, HL

NGN_SPRITE_UPDATE

Dumps sprite attributes from RAM (NGN_SPRITE_XX) to VRAM.

Input: Data in Global Variables
Modifies: AF, BC, DE, HL

NGN_SPRITE_POSITION

Moves an existing sprite.

Input: HL (Pointer), BC (XY)
Modifies: BC, HL

NGN_SPRITE_COLOR

Changes the color of an existing sprite.

Input: HL (Pointer), B (Color)
Modifies: DE, HL
ngn/ngn_background.asm

NGN_BACKGROUND_CREATE

Loads a full uncompressed image (Tiles+Color+Names) to VRAM.

Input: HL (Source data)
Modifies: AF, BC, DE, HL

NGN_BACKGROUND_CREATE_RLE

Loads a full image decompressing RLE on the fly.

Input: HL (Compressed source)
Modifies: AF, BC, DE, HL
ngn/ngn_text.asm

NGN_TEXT_PRINT

Prints a 0-terminated ASCII string.

Input: HL (String pointer)
Modifies: AF, BC, DE, HL

NGN_TEXT_PRINT_BCD

Prints a 3-byte BCD number (0-99999).

Input: BCD (Regs B,C,D)
Modifies: AF, BC, DE, HL

NGN_TEXT_PRINT_INTEGER

Prints a 16-bit integer (hex) as decimal.

Input: BC (Integer)
Modifies: AF, BC, DE, HL

NGN_TEXT_POSITION

Moves the text cursor (POSIT wrapper).

Input: H (Col), L (Row)
Modifies: AF, BC, DE, HL

NGN_TEXT_CLS

Clears the screen.

Input: None
Modifies: AF, BC, DE, HL

NGN_TEXT_COLOR

Sets text and background color.

Input: B (Text), C (Back)
Modifies: AF, BC, DE, HL
ngn/ngn_keyboard.asm

NGN_KEYBOARD_READ

Scans the full keyboard matrix via PPI. Updates the NGN_KEY_x array.

Input: None
Modifies: AF, BC, DE, HL
ngn/ngn_psg.asm

NGN_PSG_COMMAND

Writes a command to a specific PSG register.

Input: B (Register), C (Data)
Modifies: A

NGN_PSG_INIT

Resets the PSG to default values (Silence).

Input: None
Modifies: A

NGN_PSG_READ_JOY[1-2]

Reads the Joystick status connected to port 1 or 2.

Input: None
Modifies: AF, BC, HL
ngn/ngn_math.asm / ngn_rle.asm

NGN_BCD_ADD

Adds two 3-byte BCD numbers.

Input: DE (Dest), HL (Add)
Modifies: AF, BC, DE, HL

NGN_BCD_SUB

Subtracts two 3-byte BCD numbers.

Input: DE (Dest), HL (Sub)
Modifies: AF, BC, DE, HL

NGN_RLE_DECOMPRESS

Decompresses RLE data from a source address to a destination buffer.

Input: HL (Source), DE (Dest)
Modifies: AF, BC, DE, HL