@@ -188,13 +188,13 @@ static const char s_fragmentShaderTileGen[] = R"glsl(
188188 }
189189
190190 // register data
191- bool LineScrollMode (int layerNum ) { return (regs [0x60 /4 + layerNum ] & 0x8000 ) != 0 ; }
192- int GetHorizontalScroll (int layerNum ) { return int (regs [0x60 / 4 + layerNum ] & 0x3FFu ); }
193- int GetVerticalScroll (int layerNum ) { return int ((regs [0x60 /4 + layerNum ] >> 16 ) & 0x1FFu ); }
194- int LayerPriority () { return int ((regs [0x20 /4 ] >> 8 ) & 0xFu ); }
195- bool LayerIs4Bit (int layerNum ) { return (regs [0x20 /4 ] & (1 << (12 + layerNum ))) != 0 ; }
196- bool LayerEnabled (int layerNum ) { return (regs [0x60 /4 + layerNum ] & 0x80000000 ) != 0 ; }
197- bool LayerSelected (int layerNum ) { return (LayerPriority () & (1 << layerNum )) == 0 ; }
191+ bool LineScrollMode (int layerNum ) { return (regs [0x60 /4 + layerNum ] & 0x8000u ) != 0 ; }
192+ int GetHorizontalScroll (int layerNum ) { return int (regs [0x60 / 4 + layerNum ] & 0x3FFu ); }
193+ int GetVerticalScroll (int layerNum ) { return int ((regs [0x60 /4 + layerNum ] >> 16 ) & 0x1FFu ); }
194+ int LayerPriority () { return int ((regs [0x20 /4 ] >> 8 ) & 0xFu ); }
195+ bool LayerIs4Bit (int layerNum ) { return (regs [0x20 /4 ] & uint (1 << (12 + layerNum ))) != 0 ; }
196+ bool LayerEnabled (int layerNum ) { return (regs [0x60 /4 + layerNum ] & 0x80000000u ) != 0 ; }
197+ bool LayerSelected (int layerNum ) { return (LayerPriority () & (1 << layerNum )) == 0 ; }
198198
199199 float Int8ToFloat (uint c )
200200 {
@@ -225,11 +225,12 @@ static const char s_fragmentShaderTileGen[] = R"glsl(
225225 uint alpha = (colour >>15 ); // top bit is alpha. 1 means clear, 0 opaque
226226 alpha = ~alpha ; // invert
227227 alpha = alpha & 0x1u ; // mask bit
228+ const uint mask = 0x1F ;
228229
229230 vec4 c ;
230- c .r = float ((colour >> 0 ) & 0x1F ) / 31.0 ;
231- c .g = float ((colour >> 5 ) & 0x1F ) / 31.0 ;
232- c .b = float ((colour >> 10 ) & 0x1F ) / 31.0 ;
231+ c .r = float ((colour >> 0 ) & mask ) / 31.0 ;
232+ c .g = float ((colour >> 5 ) & mask ) / 31.0 ;
233+ c .b = float ((colour >> 10 ) & mask ) / 31.0 ;
233234 c .a = float (alpha ) / 1.0 ;
234235
235236 c .rgb *= c .a ; // multiply by alpha value, this will push transparent to black, no branch needed
0 commit comments