X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Fvideo.c;h=393d5bf43772de2cc9223a4c5c3417a4ee283f79;hb=d2e9501431148e85345cefe6315f0eace0dfd777;hp=8066a1baadb236a7d161a09659195b513da93fcb;hpb=f440462b381bb8bcfbe303e7c0c4b16ce4a97b6c;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/WM/video.c b/Usermode/Applications/axwin3_src/WM/video.c index 8066a1ba..393d5bf4 100644 --- a/Usermode/Applications/axwin3_src/WM/video.c +++ b/Usermode/Applications/axwin3_src/WM/video.c @@ -12,6 +12,7 @@ #include "resources/cursor.h" #include #include +#include // === PROTOTYPES === void Video_Setup(void); @@ -38,43 +39,24 @@ void Video_Setup(void) exit(-1); } - // Set width - tmpInt = giScreenWidth; - tmpInt = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, &tmpInt ); - if(tmpInt != giScreenWidth) - { - fprintf(stderr, "Warning: Selected width (%i) is invalid, clipped to %i\n", - giScreenWidth, tmpInt); - giScreenWidth = tmpInt; - } - - // Set height - tmpInt = giScreenHeight; - tmpInt = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, &tmpInt ); - if(tmpInt != giScreenHeight) - { - fprintf(stderr, "Warning: Selected height (%i) is invalid, clipped to %i\n", - giScreenHeight, tmpInt); - giScreenHeight = tmpInt; - } // Set mode to video tmpInt = TERM_MODE_FB; ioctl( giTerminalFD, TERM_IOCTL_MODETYPE, &tmpInt ); + // Get dimensions + giScreenWidth = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, NULL ); + giScreenHeight = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, NULL ); + // Force VT to be shown ioctl( giTerminalFD, TERM_IOCTL_FORCESHOW, NULL ); // Create local framebuffer (back buffer) gpScreenBuffer = malloc( giScreenWidth*giScreenHeight*4 ); -// memset(gpScreenBufferi -// Video_FillRect(0, 0, giScreenWidth, giScreenHeight, 0x8080FF); // Set cursor position and bitmap ioctl(giTerminalFD, TERM_IOCTL_SETCURSORBITMAP, &cCursorBitmap); Video_SetCursorPos( giScreenWidth/2, giScreenHeight/2 ); - - Video_Update(); } void Video_Update(void) @@ -129,3 +111,40 @@ void Video_Blit(uint32_t *Source, short DstX, short DstY, short W, short H) } } +tColour Video_AlphaBlend(tColour _orig, tColour _new, uint8_t _alpha) +{ + uint16_t ao,ro,go,bo; + uint16_t an,rn,gn,bn; + if( _alpha == 0 ) return _orig; + if( _alpha == 255 ) return _new; + + ao = (_orig >> 24) & 0xFF; + ro = (_orig >> 16) & 0xFF; + go = (_orig >> 8) & 0xFF; + bo = (_orig >> 0) & 0xFF; + + an = (_new >> 24) & 0xFF; + rn = (_new >> 16) & 0xFF; + gn = (_new >> 8) & 0xFF; + bn = (_new >> 0) & 0xFF; + + if( _alpha == 0x80 ) { + ao = (ao + an) / 2; + ro = (ro + rn) / 2; + go = (go + gn) / 2; + bo = (bo + bn) / 2; + } + else { + ao = ao*(255-_alpha) + an*_alpha; + ro = ro*(255-_alpha) + rn*_alpha; + go = go*(255-_alpha) + gn*_alpha; + bo = bo*(255-_alpha) + bn*_alpha; + ao /= 255*2; + ro /= 255*2; + go /= 255*2; + bo /= 255*2; + } + + return (ao << 24) | (ro << 16) | (go << 8) | bo; +} +