@@ -51,8 +51,36 @@ public partial class ChannelF : IVideoProvider, IRegionable
51
51
private double PixelClocksPerCpuClock ;
52
52
private double PixelClocksPerFrame ;
53
53
54
+ private int HDisplayable => HBlankOn - HBlankOff - TrimLeft - TrimRight ;
55
+ private int VDisplayable => VBlankOn - VBlankOff - TrimTop - TrimBottom ;
56
+
57
+ private int TrimLeft ;
58
+ private int TrimRight ;
59
+ private int TrimTop ;
60
+ private int TrimBottom ;
61
+
54
62
private void SetupVideo ( )
55
- => _videoBuffer = new int [ HTotal * VTotal ] ;
63
+ {
64
+ _videoBuffer = new int [ HTotal * VTotal ] ;
65
+
66
+ switch ( _syncSettings . Viewport )
67
+ {
68
+ case ViewPort . AllVisible :
69
+ TrimLeft = 0 ;
70
+ TrimRight = 0 ;
71
+ TrimTop = 0 ;
72
+ TrimBottom = 0 ;
73
+ break ;
74
+
75
+ case ViewPort . Trimmed :
76
+ // https://channelf.se/veswiki/index.php?title=VRAM
77
+ TrimLeft = 0 ;
78
+ TrimRight = HBlankOn - HBlankOff - ( 95 * PixelWidth ) ;
79
+ TrimTop = 0 ;
80
+ TrimBottom = 0 ;
81
+ break ;
82
+ }
83
+ }
56
84
57
85
/// <summary>
58
86
/// Called after every CPU clock
@@ -97,10 +125,7 @@ private void ClockVideo()
97
125
{
98
126
_pixelClockCounter -= PixelClocksPerFrame ;
99
127
}
100
- }
101
-
102
- private int HDisplayable => HBlankOn - HBlankOff ;
103
- private int VDisplayable => VBlankOn - VBlankOff ;
128
+ }
104
129
105
130
private static int [ ] ClampBuffer ( int [ ] buffer , int originalWidth , int originalHeight , int trimLeft , int trimTop , int trimRight , int trimBottom )
106
131
{
@@ -147,7 +172,7 @@ private static double GetVerticalModifier(int bufferWidth, int bufferHeight, dou
147
172
// VirtualWidth is being used to force the aspect ratio into 4:3
148
173
// On real hardware it looks like this (so we are close): https://www.youtube.com/watch?v=ZvQA9tiEIuQ
149
174
public int [ ] GetVideoBuffer ( )
150
- => ClampBuffer ( _videoBuffer , HTotal , VTotal , HBlankOff , VBlankOff , HTotal - HBlankOn , VTotal - VBlankOn ) ;
175
+ => ClampBuffer ( _videoBuffer , HTotal , VTotal , HBlankOff + TrimLeft , VBlankOff + TrimTop , HTotal - HBlankOn + TrimRight , VTotal - VBlankOn + TrimBottom ) ;
151
176
152
177
public DisplayType Region => _region == RegionType . NTSC ? DisplayType . NTSC : DisplayType . PAL ;
153
178
}
0 commit comments