⚠️ Clean-Room / Educational

This project is educational and Open Source. No code is copied from other emulators. Implementation based solely on technical documentation and permitted tests.

Selective Log Analysis

Date:2025-12-25 StepID:0288 State: VERIFIED

Summary

Selective analysis of the emulator diagnostic logs to identify the root cause of the green/white screen issue in Pokémon Red. The active monitors ([VRAM-VIBE], [VRAM-TOTAL], [DMA-TRIGGER], [BGP-CHANGE], [HANDLER-EXEC], [VBLANK-TRACE]) were analyzed and two critical issues were identified: VRAM is being written with only zeros (0x00) and BGP is temporarily set to 0x00 during the execution.

Hardware Concept

VRAM (Video RAM) and Graphics Loading:VRAM (0x8000-0x9FFF, 8KB) is the video memory of the Game Boy. It contains two main areas: Tile Data (0x8000-0x97FF, 384 tiles of 16 bytes each) and Tile Maps (0x9800-0x9FFF, 2 maps of 32x32 tiles). For the screen to display graphics, the game must load tile data into the Tile Data section and then configure the Tile Map to reference those tiles. If VRAM is empty (only zeros), the PPU will read empty tiles and render a blank or single-color screen.

BGP (Background Palette) and Color Mapping:BGP (0xFF47) is an 8-bit register that maps color indices (0-3) to other indices (0-3). Each pair of bits represents a mapping: bits 0-1 for index 0, bits 2-3 for index 1, etc. If BGP = 0x00 (00000000), all indexes are mapped to color 0 (white/green), causing a monochrome display. The standard value is 0xE4 (11100100), which is an identity mapping.

DMA (Direct Memory Access) and OAM:OAM (Object Attribute Memory, 0xFE00-0xFE9F) contains the attributes of the sprites (position, tile ID, palette, etc.). The game can copy data to OAM using DMA, which transfers 160 bytes from a source address to OAM in 160 cycles. If the sprites do not render, it may be because the OAM is empty or because the referenced tiles do not exist in VRAM.

Fountain:Pan Docs - "Video RAM (VRAM)", "LCD Control Register (LCDC)", "Background Palette (BGP)", "OAM DMA"

Implementation

Selective analysis of the diagnostic logs was performed using grep/Select-String to look for key patterns in the file `report3_updated.md` (over 200MB). The following monitors were analyzed:

Analyzed Monitors

  • [VRAM-VIBE]: VRAM writes with values ​​!= 0x00 and != 0x7F (real graphics data)
  • [VRAM-TOTAL]: All writes to VRAM without filters (up to 500 events)
  • [DMA-TRIGGER]: OAM DMA activation
  • [BGP-CHANGE]: Background palette registration changes
  • [HANDLER-EXEC]: V-Blank handler execution (up to 500 instructions)
  • [VBLANK-TRACE]: V-Blank Vector Trace (0x0040)

Critical Findings

1. VRAM Only Receives Zeros

Result:500 writes detected, all with value 0x00.

All writes come from the same PC: 0x36E3 (Bank:1) and occur in the range 0x8000-0x8030 (Tile Data Area). This suggests that the game iscleaning/erasing VRAMinstead of loading graphics.

Log example:

[VRAM-TOTAL] Write 8000=00 PC:36E3 (Bank:1)
[VRAM-TOTAL] Write 8001=00 PC:36E3 (Bank:1)
[VRAM-TOTAL] Write 8002=00 PC:36E3 (Bank:1)
...

2. BGP Temporarily to 0x00

Result:3 changes detected, one problematic.

BGP changes from 0xE4 to 0x00 at PC:0x1F6A and resets to 0xE4 at PC:0x1F85. If this occurs during rendering, it will cause green/white screen because all colors are mapped to index 0.

Sequence of changes:

[BGP-CHANGE] 0xFC -> 0xE4 at PC:0x0000 (Bank:1) // Initialization
[BGP-CHANGE] 0xE4 -> 0x00 on PC:0x1F6A (Bank:1) // PROBLEM
[BGP-CHANGE] 0x00 -> 0xE4 at PC:0x1F85 (Bank:1) // Restore

3. Positive Aspects

  • DMA:49 activations detected, working correctly
  • V-Blank Handler:49 executions detected, working correctly
  • LCDC:Constant value 0xE3, correct configuration
  • V-Blank Trace:49 traces detected, working correctly

Root Problem Identified

The main problem is thatVRAM is empty (only zeros). When the PPU renders, it reads empty tiles and applies the palette, resulting in a green/white screen. The secondary problem is that BGP is temporarily set to 0x00, which exacerbates the problem.

Affected Files

  • ANALYSIS_LOGS_STEP_0288.md- Executive analysis with detailed findings
  • report3_updated.md- Log file analyzed (more than 200MB)

Tests and Verification

The analysis was performed by searching for patterns in the logs using command line tools:

  • Command executed: grep -i "\[VRAM-VIBE\]" report3_updated.md
  • Result:0 matches (critical: no actual graph data writes)
  • Command executed: Select-String -Path "report3_updated.md" -Pattern "\[VRAM-TOTAL\]" | Measure-Object
  • Result:500 writes detected, all with value 0x00
  • Command executed: grep -i "\[BGP-CHANGE\]" updated_report3.md
  • Result:3 changes detected, one problematic (0xE4 -> 0x00)

Validation:The diagnostic monitors implemented in previous steps (0285-0287) function correctly and provide valuable information for diagnosis.

Sources consulted

Educational Integrity

What I Understand Now

  • VRAM and Rendering:For the screen to display graphics, VRAM must contain tile data. If VRAM is empty, the PPU will read empty tiles and render a blank or single-color screen.
  • BGP and Color Mapping:BGP maps color indexes to other indexes. If BGP = 0x00, all colors are mapped to index 0, causing a monochrome display.
  • Log Analysis:Diagnostic monitors are essential to understand the behavior of the emulator. Selective analysis of large logs requires command line tools (grep, Select-String) to look for specific patterns.

What remains to be confirmed

  • Why does VRAM only receive zeros?Is this an emulator bug or expected game behavior that requires additional conditions? We need to investigate the code in PC:0x36E3.
  • When does the change from BGP to 0x00 occur?Does it happen during rendering or before? We need to check the timing of the change in relation to the rendering.
  • What does the PPU read from VRAM?We need to implement a VRAM read monitor to see what addresses the PPU reads and what values ​​it gets.

Hypotheses and Assumptions

Hypothesis 1:The game is in an initialization phase that cleans VRAM before loading graphics. If the emulator does not meet any condition (e.g. timing, interruptions), the game never loads the graphics.

Hypothesis 2:There is a bug in the emulator that prevents the game from loading graphics (ex: access to VRAM blocked for a certain period, incorrect timing of interruptions).

Assumption:The change from BGP to 0x00 is intentional (ex: fade out/fade in), but if it occurs during rendering, it will cause visual problems.

Next Steps

  • [ ] Step 0289: Implement VRAM read monitor ([VRAM-READ]) to capture which addresses the PPU reads
  • [ ] Step 0289: Implement Tilemap inspector ([TILEMAP-INSPECT]) to check which tile IDs are being used
  • [ ] Step 0289: Implement Tile Data inspector ([TILEDATA-INSPECT]) to check if tiles contain data != 0x00
  • [ ] Step 0290: Implement LCDC change monitor ([LCDC-CHANGE]) to verify LCD configuration
  • [ ] Step 0290: Implement palette application monitor ([PALETTE-APPLY]) to check how BGP is applied during rendering
  • [ ] Step 0291: Apply corrections based on findings from previous steps