@@ -19,6 +19,7 @@ class VGA3BitI : public VGA, public GraphicsR1G1B1A1
19
19
VGA3BitI () // 8 bit based modes only work with I2S1
20
20
: VGA(1 )
21
21
{
22
+ interruptStaticChild = &VGA3BitI::interrupt;
22
23
}
23
24
24
25
bool init (const Mode &mode, const int RPin, const int GPin, const int BPin, const int hsyncPin, const int vsyncPin, const int clockPin = -1 )
@@ -29,7 +30,7 @@ class VGA3BitI : public VGA, public GraphicsR1G1B1A1
29
30
BPin,
30
31
-1 , -1 , -1 ,
31
32
hsyncPin, vsyncPin
32
- };
33
+ };
33
34
return VGA::init (mode, pinMap, 8 , clockPin);
34
35
}
35
36
@@ -87,53 +88,61 @@ class VGA3BitI : public VGA, public GraphicsR1G1B1A1
87
88
return true ;
88
89
};
89
90
90
- void interrupt ()
91
+ static void interrupt (void *arg);
92
+
93
+ static void interruptPixelLine (int y, unsigned long *pixels, unsigned long syncBits, void *arg);
94
+ };
95
+
96
+
97
+ void IRAM_ATTR VGA3BitI::interrupt (void *arg)
98
+ {
99
+ VGA3BitI * staticthis = (VGA3BitI *)arg;
100
+
101
+ unsigned long *signal = (unsigned long *)staticthis->dmaBufferDescriptors [staticthis->dmaBufferDescriptorActive ].buffer ();
102
+ unsigned long *pixels = &((unsigned long *)staticthis->dmaBufferDescriptors [staticthis->dmaBufferDescriptorActive ].buffer ())[(staticthis->mode .hSync + staticthis->mode .hBack ) / 4 ];
103
+ unsigned long base, baseh;
104
+ if (staticthis->currentLine >= staticthis->mode .vFront && staticthis->currentLine < staticthis->mode .vFront + staticthis->mode .vSync )
91
105
{
92
- unsigned long *signal = (unsigned long *)dmaBufferDescriptors[dmaBufferDescriptorActive].buffer ();
93
- unsigned long *pixels = &((unsigned long *)dmaBufferDescriptors[dmaBufferDescriptorActive].buffer ())[(mode.hSync + mode.hBack ) / 4 ];
94
- unsigned long base, baseh;
95
- if (currentLine >= mode.vFront && currentLine < mode.vFront + mode.vSync )
96
- {
97
- baseh = syncBits (true , true );
98
- base = syncBits (false , true );
99
- }
100
- else
101
- {
102
- baseh = syncBits (true , false );
103
- base = syncBits (false , false );
104
- }
105
- for (int i = 0 ; i < mode.hSync / 4 ; i++)
106
- signal [i] = baseh;
107
- for (int i = mode.hSync / 4 ; i < (mode.hSync + mode.hBack ) / 4 ; i++)
108
- signal [i] = base;
109
-
110
- int y = (currentLine - mode.vFront - mode.vSync - mode.vBack ) / mode.vDiv ;
111
- if (y >= 0 && y < mode.vRes )
112
- interruptPixelLine (y, pixels, base);
113
- else
114
- for (int i = 0 ; i < mode.hRes / 4 ; i++)
115
- {
116
- pixels[i] = base;
117
- }
118
- for (int i = 0 ; i < mode.hFront / 4 ; i++)
119
- signal [i + (mode.hSync + mode.hBack + mode.hRes ) / 4 ] = base;
120
- currentLine = (currentLine + 1 ) % totalLines;
121
- dmaBufferDescriptorActive = (dmaBufferDescriptorActive + 1 ) % dmaBufferDescriptorCount;
122
- if (currentLine == 0 )
123
- vSync ();
106
+ baseh = (staticthis->hsyncBit | staticthis->vsyncBit ) * 0x1010101 ;
107
+ base = (staticthis->hsyncBitI | staticthis->vsyncBit ) * 0x1010101 ;
124
108
}
125
-
126
- void interruptPixelLine (int y, unsigned long *pixels, unsigned long syncBits)
109
+ else
127
110
{
128
- unsigned char *line = frontBuffer[y];
129
- int j = 0 ;
130
- for (int i = 0 ; i < mode.hRes / 4 ; i++)
111
+ baseh = (staticthis->hsyncBit | staticthis->vsyncBitI ) * 0x1010101 ;
112
+ base = (staticthis->hsyncBitI | staticthis->vsyncBitI ) * 0x1010101 ;
113
+ }
114
+ for (int i = 0 ; i < staticthis->mode .hSync / 4 ; i++)
115
+ signal [i] = baseh;
116
+ for (int i = staticthis->mode .hSync / 4 ; i < (staticthis->mode .hSync + staticthis->mode .hBack ) / 4 ; i++)
117
+ signal [i] = base;
118
+
119
+ int y = (staticthis->currentLine - staticthis->mode .vFront - staticthis->mode .vSync - staticthis->mode .vBack ) / staticthis->mode .vDiv ;
120
+ if (y >= 0 && y < staticthis->mode .vRes )
121
+ staticthis->interruptPixelLine (y, pixels, base, arg);
122
+ else
123
+ for (int i = 0 ; i < staticthis->mode .hRes / 4 ; i++)
131
124
{
132
- int p0 = (line[j] >> 0 ) & 7 ;
133
- int p1 = (line[j++] >> 4 ) & 7 ;
134
- int p2 = (line[j] >> 0 ) & 7 ;
135
- int p3 = (line[j++] >> 4 ) & 7 ;
136
- pixels[i] = syncBits | (p2 << 0 ) | (p3 << 8 ) | (p0 << 16 ) | (p1 << 24 );
125
+ pixels[i] = base;
137
126
}
127
+ for (int i = 0 ; i < staticthis->mode .hFront / 4 ; i++)
128
+ signal [i + (staticthis->mode .hSync + staticthis->mode .hBack + staticthis->mode .hRes ) / 4 ] = base;
129
+ staticthis->currentLine = (staticthis->currentLine + 1 ) % staticthis->totalLines ;
130
+ staticthis->dmaBufferDescriptorActive = (staticthis->dmaBufferDescriptorActive + 1 ) % staticthis->dmaBufferDescriptorCount ;
131
+ if (staticthis->currentLine == 0 )
132
+ staticthis->vSyncPassed = true ;
133
+ }
134
+
135
+ void IRAM_ATTR VGA3BitI::interruptPixelLine (int y, unsigned long *pixels, unsigned long syncBits, void *arg)
136
+ {
137
+ VGA3BitI * staticthis = (VGA3BitI *)arg;
138
+ unsigned char *line = staticthis->frontBuffer [y];
139
+ int j = 0 ;
140
+ for (int i = 0 ; i < staticthis->mode .hRes / 4 ; i++)
141
+ {
142
+ int p0 = (line[j] >> 0 ) & 7 ;
143
+ int p1 = (line[j++] >> 4 ) & 7 ;
144
+ int p2 = (line[j] >> 0 ) & 7 ;
145
+ int p3 = (line[j++] >> 4 ) & 7 ;
146
+ pixels[i] = syncBits | (p2 << 0 ) | (p3 << 8 ) | (p0 << 16 ) | (p1 << 24 );
138
147
}
139
- };
148
+ }
0 commit comments