The Matrix v1.41 [Windows only]

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

The Matrix v1.41 [Windows only]

Post by UEZ »

Can you read the Matrix?

Image

Code: Select all

'Matrix Code Rain coded by UEZ v1.41 build 2018-10-18
'Windows only!

#Include "fbgfx.bi" 
#Include "string.bi" 
#Include "windows.bi"

#Ifdef __Fb_64bit__
    #Inclib "gdiplus"
    #Include Once "win/gdiplus-c.bi"
#Else
    #Include Once "win/gdiplus.bi"
    Using gdiplus
#Endif


Declare Function RandomRange(fStart as Single, fEnd as Single) as Single
Declare Function RestoreMemImage() As Any Ptr
Declare Function Base91Decode(sString As String, Byref iBase91Len As Ulong) As Ubyte Ptr
Declare Function _GDIPlus_BitmapCreateFromMemory2(aBinImage As Ubyte Ptr, iLen As Ulong, bBitmap_GDI As Bool = False) As Any Ptr
Declare Function Regulate(Byval MyFps As Long, Byref fps As UShort) As Long

Using FB 
#Define unicode


Dim As Integer iRet = MessageBox(Null, "Run in fullscreen mode?", "Question", MB_YESNO Or MB_ICONQUESTION Or MB_TOPMOST)

Dim As Integer dw, dh, iScreenParam = 0
ScreenInfo dw, dh

Dim As Boolean bFullscreen = False
Dim As UShort iW, iH
If iRet = IDYES Then
	iW = dw \ 2
	iH = dh \ 2
	bFullscreen = False
	iScreenParam = GFX_FULLSCREEN Or GFX_NO_FRAME
Else
	dw = 800
	iW = 800
	dh = 500
	iH = 500
Endif

Dim Shared gdipToken As ULONG_PTR
Dim Shared GDIp As GdiplusStartupInput 
GDIp.GdiplusVersion = 1
If GdiplusStartup(@gdipToken, @GDIp, NULL) <> 0 Then End

SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)

Dim As String sTitle = "The MATRIX v1.41 by UEZ"
Dim As Single fFontSize = 7.5, fPosX
Dim As UShort iFPS = 0, iW_Char = Cushort(fFontSize * 1.6666), iH_Char = Cushort(fFontSize * 1.6666), iAmountChars = 256, iMaxSpeed = 6, iMinSpeed = 2, i

Screencontrol FB.SET_DRIVER_NAME, "GDI"
Screenres dw, dh, 32, 1, GFX_HIGH_PRIORITY Or GFX_NO_SWITCH Or iScreenParam
Windowtitle sTitle 

Dim As HWND hHWND
Screencontrol(FB.GET_WINDOW_HANDLE, Cast(Integer, hHWND))

Dim as GpRectF  tLayout1, tLayout2
tLayout1.x = 0
tLayout1.y = 0
tLayout1.width = iW_Char
tLayout1.height = iH_Char
tLayout2.x = 0
tLayout2.y = 0
tLayout2.width = iW_Char
tLayout2.height = iH_Char

Dim As BITMAPINFO tBITMAP
With tBITMAP.bmiheader
            .biSize = Sizeof(BITMAPINFOHEADER)
            .biWidth = iW
            .biHeight = -iH
            .biPlanes = 1
            .biBitCount = 32
            .biCompression = BI_RGB
End With

Dim As ULong Ptr aBitmap, aBitmap2, aBitmap3

Dim As Any Ptr 	hDC = GetDC(hHWND), _
				hHBitmap = CreateDIBSection(hDC, @tBITMAP, DIB_RGB_COLORS, @aBitmap, NULL, NULL), _
				hDC_backbuffer = CreateCompatibleDC(hDC), _
				hHBitmap2 = CreateDIBSection(hDC, @tBITMAP, DIB_RGB_COLORS, @aBitmap2, NULL, NULL), _
				hDC_backbuffer2 = CreateCompatibleDC(hDC), _
				hCanvas, hCanvas2, hBrush_Clr, hBrush_Char, hBrush_CharGlow, hBrush_CharGlow2, hBrush_Bg, hFamily, hFont, hFont_Glow, hStringFormat, hGfx

Var hDC_obj = SelectObject(hDC_backbuffer, hHBitmap), hDC_obj2 = SelectObject(hDC_backbuffer2, hHBitmap2)
GdipCreateFromHDC(hDC_backbuffer, @hCanvas)
GdipCreateFromHDC(hDC_backbuffer2, @hCanvas2)
GdipSetSmoothingMode(hCanvas, SmoothingModeAntiAlias)
GdipSetPixelOffsetMode(hCanvas, PixelOffsetModeHalf)
GdipSetTextRenderingHint(hCanvas, TextRenderingHintAntiAlias)
GdipSetSmoothingMode(hCanvas2, SmoothingModeAntiAlias)
GdipSetPixelOffsetMode(hCanvas2, PixelOffsetModeHalf)
GdipSetTextRenderingHint(hCanvas2, TextRenderingHintAntiAlias)
GdipCreateStringFormat(0, 0, @hStringFormat)
GdipCreateFontFamilyFromName("Times New Roman", Null, @hFamily)
GdipCreateFont(hFamily, fFontSize, 1, 3, @hFont)
GdipCreateFont(hFamily, iW_Char, 1, 3, @hFont_Glow)
GdipSetStringFormatAlign(hStringFormat, StringAlignmentCenter)
GdipSetStringFormatLineAlign(hStringFormat, StringAlignmentCenter)
GdipCreateSolidFill(&h0D000000, @hBrush_Clr)
GdipCreateSolidFill(&hE8E8FFE8, @hBrush_Char)
GdipCreateLineBrushFromRectWithAngle(@tLayout2, &h1000FF00, &hE0A0FFA0, 0, False, 1, @hBrush_CharGlow)
GdipSetLineSigmaBlend(hBrush_CharGlow, 0.5, 1)
GdipSetLineGammaCorrection(hBrush_CharGlow, True)
GdipCreateHatchBrush(9, &hF0003800, &hFF000000, @hBrush_Bg)

GdipCreateSolidFill(&hF0FFD0D0, @hBrush_CharGlow2)

Dim As String sFPS
Dim hFont_FPS As HFONT = CreateFont(12, 0, 0, 0, 0, 0, 0, 0,_
								        DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,_
								        DEFAULT_PITCH, "Times New Roman")
Var hObjOld_FPS = SelectObject(hDC_backbuffer2, hFont_FPS)
SetTextColor(hDC_backbuffer2, &hF8F8F8)
SetBkMode(hDC_backbuffer2, TRANSPARENT)

Dim tRect As RECT
tRect.Left = 2
tRect.Top = 2
tRect.Right = 30
tRect.Bottom = 15

Dim As Any Ptr hIA, hCanvas3, hHBitmap3Mem, hDC_backbuffer3, hBitmap3Mem = RestoreMemImage()

Dim tMatrix as ColorMatrix
tMatrix.m(0, 0) = 1
tMatrix.m(1, 1) = 1
tMatrix.m(2, 2) = 1
tMatrix.m(3, 3) = 0.0125
tMatrix.m(4, 4) = 1

GdipCreateImageAttributes(@hIA)
GdipSetImageAttributesColorMatrix(hIA, 0, 1, @tMatrix, 0, 0)

hHBitmap3Mem = CreateDIBSection(hDC, @tBITMAP, DIB_RGB_COLORS, @aBitmap3, NULL, NULL)
hDC_backbuffer3 = CreateCompatibleDC(hDC)
Var hDC_obj3 = SelectObject(hDC_backbuffer3, hHBitmap3Mem)

Dim as Single iW2, iH2, iPosY
GdipGetImageDimension(hBitmap3Mem, @iW2, @iH2)
iPosY = iH2 - iH
iPosY = Iif(iPosY >= 0, 0, iPosY)

GdipCreateFromHDC(hDC_backbuffer3, @hCanvas3)
GdipDrawImageRectRect(hCanvas3, hBitmap3Mem, 0, 0, iW, iH, 0, iPosY, iW, iH, 2, hIA, 0, 0)

GdipDeleteGraphics(hCanvas3)
GdipDisposeImage(hBitmap3Mem)
GdipDisposeImageAttributes(hIA)

Type tTable
	x As Single
	y As Single
	vy As Single
	c As integer
End Type

Dim As tTable aTable(0 To iAmountChars)

For i = 0 To iAmountChars - 1
	fPosX = Rnd() * (iW - iW_Char)
	aTable(i).x = fPosX
	aTable(i).y = -fFontSize - RandomRange(10, 200)
	aTable(i).vy = RandomRange(iMinSpeed, iMaxSpeed)
	aTable(i).c = aTable(i).y - iH_Char - 1
Next

GdipGraphicsClear(hCanvas, &hFF000000)

Dim As Ushort iLen = 55, iChar = 0
Dim As Wstring * 2 aChars(iLen) 
For i = 0 To iLen
	aChars(i) = WChr(i + 65382)
Next
Dim As WString * 2 sChar = aChars(0)

Type tPrePaintedChars
	hBitmap As Any Ptr
End Type

Dim As tPrePaintedChars aChars_pre(iLen, 3)
For i = 0 To iLen
	GdipCreateBitmapFromScan0(iW_Char, iH_Char, 0, PixelFormat32bppARGB, 0, @aChars_pre(i, 0).hBitmap)
	GdipGetImageGraphicsContext(aChars_pre(i, 0).hBitmap, @hGfx)
	GdipSetPixelOffsetMode(hGfx, PixelOffsetModeHalf)
	GdipSetTextRenderingHint(hGfx, TextRenderingHintAntiAlias)
	GdipSetSmoothingMode(hGfx, SmoothingModeAntiAlias)
	GdipDrawString(hGfx, aChars(i), -1, hFont_Glow, @tLayout1, hStringFormat, hBrush_CharGlow)
	GdipDeleteGraphics(hGfx)
	GdipCreateBitmapFromScan0(iW_Char, iH_Char, 0, PixelFormat32bppARGB, 0, @aChars_pre(i, 1).hBitmap)
	GdipGetImageGraphicsContext(aChars_pre(i, 1).hBitmap, @hGfx)
	GdipSetPixelOffsetMode(hGfx, PixelOffsetModeHalf)
	GdipSetTextRenderingHint(hGfx, TextRenderingHintAntiAlias)
	GdipSetSmoothingMode(hGfx, SmoothingModeAntiAlias)
	GdipDrawString(hGfx, aChars(i), -1, hFont, @tLayout1, hStringFormat, hBrush_Char)
	GdipDeleteGraphics(hGfx)
	GdipCreateBitmapFromScan0(iW_Char, iH_Char, 0, PixelFormat32bppARGB, 0, @aChars_pre(i, 2).hBitmap)
	GdipGetImageGraphicsContext(aChars_pre(i, 2).hBitmap, @hGfx)
	GdipSetPixelOffsetMode(hGfx, PixelOffsetModeHalf)
	GdipSetTextRenderingHint(hGfx, TextRenderingHintAntiAlias)
	GdipSetSmoothingMode(hGfx, SmoothingModeAntiAlias)
	GdipDrawString(hGfx, aChars(i), -1, hFont, @tLayout1, hStringFormat, hBrush_CharGlow2)
	GdipDeleteGraphics(hGfx)
Next

Dim As Long c = 250, bDisplay = -1

If iRet = IDYES Then Setmouse(-1, -1, 0)

Dim As Double fTimer = Timer 

Do 
	GdipFillRectangle(hCanvas2, hBrush_Bg, 0, 0, iW, iH)
	GdipFillRectangle(hCanvas, hBrush_Clr, 0, 0, iW, iH)
	
	For i = 0 To iAmountChars - 1
		If aTable(i).y - aTable(i).c > iH_Char Then
			If aTable(i).x > 0 And aTable(i).y > 0 And aTable(i).x < (iW - fFontSize) And aTable(i).y < (iH - fFontSize) And c > 750 Then
				If aBitmap3[CUlng(aTable(i).x) + CUlng(aTable(i).y) * iW] > 0 then
					GdipDrawImageRect(hCanvas, aChars_pre(iChar, 2).hBitmap, aTable(i).x, aTable(i).y, iW_Char, iH_Char)
				Else
					GdipDrawImageRect(hCanvas, aChars_pre(iChar, 0).hBitmap, aTable(i).x, aTable(i).y, iW_Char, iH_Char)
				End If
			Else
				GdipDrawImageRect(hCanvas, aChars_pre(iChar, 0).hBitmap, aTable(i).x, aTable(i).y, iW_Char, iH_Char)
			End If
			aTable(i).c = aTable(i).y
		Endif
		iChar = Cushort(Rnd() * iLen)
		GdipDrawImageRect(hCanvas2, aChars_pre(iChar, 0).hBitmap, aTable(i).x, aTable(i).y, iW_Char, iH_Char)
		GdipDrawImageRect(hCanvas2, aChars_pre(iChar, 1).hBitmap, aTable(i).x, aTable(i).y, iW_Char, iH_Char)
		aTable(i).y += aTable(i).vy
		If aTable(i).y > iH Then
			aTable(i).x = Rnd() * (iW - iW_Char)
			aTable(i).y = -fFontSize - 1
			aTable(i).vy = RandomRange(iMinSpeed, iMaxSpeed)
			aTable(i).c = aTable(i).y - iH_Char - 1
		EndIf
	Next
	
	c += 1
	If c Mod 1000 = 0 Then bDisplay *= -1
	If bDisplay = 1 Then BitBlt(hDC_backbuffer, 0, 0, iW, iH, hDC_backbuffer3, 0, 0, SRCPAINT)
	
	BitBlt(hDC_backbuffer2, 0, 0, iW, iH, hDC_backbuffer, 0, 0, SRCPAINT)
	DrawText(hDC_backbuffer2, StrPtr(sFPS), -1, @tRect, DT_SINGLELINE)
	StretchBlt(hDC, 0, 0, dw, dh, hDC_backbuffer2, 0, 0, iW, iH, SRCCOPY)
	
	If(Timer - fTimer > 0.99) Then 
		sFPS = Str(Format(iFPS, "0#")) & " fps"
		fTimer = Timer 
	Endif 
	
	Sleep Regulate(30, iFPS), 1
Loop Until Len(Inkey())

'GDI
SelectObject(hDC_backbuffer, hDC_obj)
DeleteDC(hDC_backbuffer)
DeleteObject(hHBitmap)
SelectObject(hDC_backbuffer2, hDC_obj2)
DeleteDC(hDC_backbuffer2)
DeleteObject(hHBitmap2)
SelectObject(hDC_backbuffer3, hDC_obj3)
DeleteObject(hDC_backbuffer3)
DeleteObject(hHBitmap3Mem)
SelectObject(hDC_backbuffer2, hObjOld_FPS)
DeleteObject(hFont_FPS)
ReleaseDC(hHWND, hDC)

'GDIPlus
For i = 0 To iLen
	GdipDisposeImage(aChars_pre(i, 0).hBitmap)
	GdipDisposeImage(aChars_pre(i, 1).hBitmap)
Next
GdipDeleteBrush(hBrush_Clr)
GdipDeleteBrush(hBrush_Char)
GdipDeleteBrush(hBrush_CharGlow)				
GdipDeleteBrush(hBrush_CharGlow2)				
GdipDeleteBrush(hBrush_Bg)				
GdipDeleteFont(hFont)
GdipDeleteFont(hFont_Glow)
GdipDeleteFontFamily(hFamily)
GdipDeleteStringFormat(hStringFormat)
GdipDeleteGraphics(hCanvas)
GdipDeleteGraphics(hCanvas2)
GdiplusShutdown(gdipToken)
Setmouse(-1, -1, 1)

Function RandomRange(fStart as Single, fEnd as Single) as Single
   Return Rnd() * (fEnd - fStart) + fStart
End Function

Function Regulate(Byval MyFps As Long, Byref fps As uShort) As Long    'code by dodicat
    Static As Double timervalue, _lastsleeptime, t3, frames
    Var t = Timer
    frames+=1
    If (t-t3) >= 1 Then t3 = t : fps = frames : frames = 0
    Var sleeptime = _lastsleeptime + ((1 / myfps) - T + timervalue) * 1000
    If sleeptime < 1 Then sleeptime = 1
    _lastsleeptime=sleeptime
    timervalue=T
    Return sleeptime
End Function

Function RestoreMemImage() As Any Ptr
	'decompress base91 encoded image
	Dim As Ulong iLines, bCompressed, iFileSize, iCompressedSize
	Dim As String sBaseType, sBase91, aB91(1)

	Restore __Neo:
	Read iLines
	Read bCompressed
	Read iFileSize
	Read iCompressedSize
	Read sBaseType
	For i As Ushort = 0 To iLines - 1
	   Read aB91(0)
	   sBase91 &= aB91(0)
	Next

	Dim As Ulong iLenB91
	Static As Ubyte Ptr aBinary
	aBinary = Base91Decode(sBase91, iLenB91)
   Return _GDIPlus_BitmapCreateFromMemory2(@aBinary[0], iLenB91)
End Function

Function Base91Decode(sString As String, Byref iBase91Len As Ulong) As Ubyte Ptr
   Dim As String sB91, sDecoded 
   sB91 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{|}~´" '´ instead of "
   Dim As Long i, n = 0, c, b = 0, v = -1

   Dim aChr(0 To Len(sString) - 1) As String
   For i = 0 To Ubound(aChr)             
      aChr(i) = Mid(sString, i + 1, 1)
   Next
   
   For i = 0 To Ubound(aChr)
      c = Instr(sB91, aChr(i)) - 1
      If v < 0 Then
         v = c
      Else
         v += c * 91
         b = b Or (v Shl n)
         n += 13 + (((v And 8191) <= 88) * -1)
         Do Until  (n > 7)=0
            sDecoded &= Chr(b And 255)
            b = b Shr 8
            n -= 8
         Loop
         v = -1
      Endif
   Next
   If (v + 1) Then 
      sDecoded &= Chr((b Or (v Shl n)) And 255) 
   End If
   iBase91Len = Len(sDecoded)

   Static As Ubyte aReturn(0 To Len(sDecoded))
   For i = 0 To Len(sDecoded) - 1 'convert result String To ascii code values
      aReturn(i) = Asc(sDecoded, i + 1)
   Next
   Return @aReturn(0) 'Return Pointer To the array
End Function

Function _GDIPlus_BitmapCreateFromMemory2(aBinImage As Ubyte Ptr, iLen As Ulong, bBitmap_GDI As Bool = False) As Any Ptr
	Dim As HGLOBAL hGlobal
	Dim As LPSTREAM hStream
	Dim As Any Ptr hBitmap_Stream
	Dim As Any Ptr hMemory = GlobalAlloc(GMEM_MOVEABLE, iLen)
	Dim As Any Ptr lpMemory = GlobalLock(hMemory)
	RtlCopyMemory(lpMemory, @aBinImage[0], iLen)
	GlobalUnlock(hMemory)
	CreateStreamOnHGlobal(hMemory, 0, @hStream)
	GdipCreateBitmapFromStream(hStream, @hBitmap_Stream)
	IUnknown_Release(hStream)

	If bBitmap_GDI = TRUE Then
		Dim hBitmap_GDI As Any Ptr
		GdipCreateHBITMAPFromBitmap(hBitmap_Stream, @hBitmap_GDI, &hFF000000)
		GdipDisposeImage(hBitmap_Stream)
		Return hBitmap_GDI
	Endif

	Return hBitmap_Stream
End Function


'Generated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5/|:4f1BASESg%KZs8x`Z#PD+GO^w}JkmLAk´y3yJ>~%qS8vOL@CAih[P4k+´_F=WW3I:uY;#}5,;KBNFn|}1rgl>QuO6TUR@q,2u$Hf%{vg@CFTi<4f^c_9FQmFer;fs<uboBJg5{T]U^*if.J{DXr18?1ouL*hj8hKjh^+~^.xk&3`&V*hHrgpTycwI>8&*FHj:(Pu!Kr|CS{^RV^ix}JkPAli93Z~.ebBy>yyVCpQej3{qKux,zB@htL{uKc,><7>TUH,d,3N2~4v=!CXt_=)htz22$NwwScrYyBx[%JyoBqR*`,XJRypezHomP7$ie#>{I:uml(VLZlJ,8BKl+@w0$2R{kX*+^"
Data "dzbtdB1;VC3W]r33(.U!:hc=3LJ2F=dC[I(jY&W6@!xazU~H3p^maz^9#V|FEzf:S+fG)*MK[CETD.buVJzV.Fb}e>zMLP_JSGzlA{´rvqLHx8qpU0AH;q8Rp|V%,yXRx$Fq9*v1!b7k0wJ@$~SB{~>~8/~^b;r$A/X!.q$K3X|<9CaFY>[C+vBokE(@l}B@VRSqKp5h>_3|W+r$dS]QKW;,?,By´|dYsV.F:UX%.FI@hy´|~).{ZhG^,4a!({w:sciVwFeML(TwZ<ZsnLI~3^1xE)Fr2L1X4V+F22<J&#(h8Me43Og#LC2AAAXLhYKMe8#(>C"


Download The MATRIX with sound (much cooler ^^)



Edit1: found a way to add unicode characters. :-)
Edit2: small code update
Edit3: increased FPS by calling timeBeginPeriod / timeEndPeriod WinAPI function -> thanks to dodicat / deltarho[1859]
Edit4: some internal tuning to increase FPS a little more
Edit5: small code update
Edit6: last update
Last edited by UEZ on Oct 19, 2018 13:54, edited 14 times in total.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: The Matrix [Windows only]

Post by jj2007 »

I expected some boring matrix transformations but ... wow! Very nice work! GdiPlus is underrated IMO.
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: The Matrix [Windows only]

Post by UEZ »

jj2007 wrote:I expected some boring matrix transformations but ... wow! Very nice work! GdiPlus is underrated IMO.
Glad to hear that your expectations has been exceeded. ;-)

The KO criteria for GDI+ is unfortunately speed for animated graphical stuff. To add here real glow and blurring will kill the fps rate which is currently anyway not the best... :-(

Btw, I've updated the code -> now with unicode characters which looks more encrypted.
deltarho[1859]
Posts: 4313
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: The Matrix v1.2 [Windows only]

Post by deltarho[1859] »

UEZ wrote:To add here real glow and blurring will kill the fps rate which is currently anyway not the best... :-(
Sleep(10) will sleep for 15.625ms (1000/64Hz); as will any Sleep(n) where n<16

If you insert the following at the head of your code

Code: Select all

Declare Function SetTimerInterval Lib "winmm" Alias "timeBeginPeriod"(As Ulong=1) As Long ' dodicat snippet
SetTimerInterval
and change Sleep(10) to Sleep(1), about 2ms with a resolution of 1ms, you should a decent increase in FPS.

I go from FPS 19-20 to FPS 29-30. Not earth shattering but it is noticeable.
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: The Matrix v1.3 [Windows only]

Post by UEZ »

@deltarho[1859]: thanks for the hint. Indeed the FPS increases a few FPS on my 'old' notebook, better than nothing. :-)

Running in x64 mode is even a little bit faster.
UEZ
Posts: 988
Joined: May 05, 2017 19:59
Location: Germany

Re: The Matrix v1.40 [Windows only]

Post by UEZ »

If you are interested then have a look to the small update in post#1.
Post Reply