Skip to content

Refactor bitmap viewer with proper DI and multi-mode support#1463

Merged
maximilien-noal merged 4 commits intofeat/memory_as_bitmap_vgafrom
copilot/sub-pr-1414
Nov 1, 2025
Merged

Refactor bitmap viewer with proper DI and multi-mode support#1463
maximilien-noal merged 4 commits intofeat/memory_as_bitmap_vgafrom
copilot/sub-pr-1414

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

Addresses code review feedback and feature requests for the memory bitmap viewer: improper dependency injection pattern, missing display mode options, and incorrect exception constructors.

Dependency Injection Refactoring

Replaced messenger-based factory pattern with proper constructor injection:

// Before: side-stepping DI with messenger
messenger.Register<CreateMemoryBitmapViewModelMessage>(this, (_, m) => {
    var vm = new MemoryBitmapViewModel(videoState, hostStorageProvider);
    m.SetInstance(vm);
});

// After: proper factory pattern
public interface IMemoryBitmapViewModelFactory {
    MemoryBitmapViewModel CreateNew();
}

public class MemoryBitmapViewModelFactory : IMemoryBitmapViewModelFactory {
    private readonly IVideoState _videoState;
    private readonly IHostStorageProvider _storage;
    // ... constructor injection
}
  • Created IMemoryBitmapViewModelFactory with concrete implementation
  • Updated all MemoryViewModel variants to accept factory via constructor
  • Removed CreateMemoryBitmapViewModelMessage message class

Display Mode Support

Added MemoryBitmapDisplayMode enum with 5 rendering modes:

  • VGA 8BPP: 256-color indexed (existing implementation)
  • CGA 4-color: 2 bits per pixel with 4-color palette
  • EGA 16-color: 4 bits per pixel with 16-color palette
  • Text Mode: Character/attribute pairs with IBM PC fonts (placeholder pattern currently)
  • Hercules Monochrome: 1 bit per pixel for 720×348 graphics

UI updated with ComboBox for mode selection and CheckBox for optional overlay grid (stub for future implementation).

Exception Constructor Fixes

Corrected 4 instances of ArgumentOutOfRangeException using single-parameter constructor:

// Before
throw new ArgumentOutOfRangeException($"Invalid bitmap size: {width}x{height}");

// After
throw new ArgumentOutOfRangeException(nameof(BitmapViewWidth), $"Invalid bitmap size: {width}x{height}");

Remaining Work

  • Text mode needs actual IBM font glyph rendering from video memory plane 2
  • Overlay grid implementation for memory address/value visualization
  • AvaloniaHex integration for switching between hex and bitmap views

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 1, 2025 12:59
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.1/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/11.3.1/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add display for VGA 8BPP over memory region Refactor bitmap viewer with proper DI and multi-mode support Nov 1, 2025
Copilot AI requested a review from maximilien-noal November 1, 2025 13:12
@maximilien-noal maximilien-noal marked this pull request as ready for review November 1, 2025 13:49
@maximilien-noal maximilien-noal merged commit a8154ea into feat/memory_as_bitmap_vga Nov 1, 2025
9 checks passed
@maximilien-noal maximilien-noal deleted the copilot/sub-pr-1414 branch November 1, 2025 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants