1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. eukalyptus

Beiträge von eukalyptus

  • Foto jpg-Dateien mit Audio mp3-Dateien verknüpfen

    • eukalyptus
    • 14. Februar 2014 um 20:09

    Du kannst beide Dateien in eine Datei verschmelzen und später die Mp3 wieder extrahieren:

    Spoiler anzeigen
    [autoit][/autoit] [autoit][/autoit] [autoit]

    _CombineJpgMp3(@ScriptDir & "\Out.jpg", @ScriptDir & "\Test.jpg", @ScriptDir & "\Test.mp3")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $bMp3 = _ExtractMp3(@ScriptDir & "\Out.jpg")
    $hFile = FileOpen(@TempDir & "\JpgMp3.mp3", 18)
    FileWrite($hFile, $bMp3)
    FileClose($hFile)

    [/autoit] [autoit][/autoit] [autoit]

    SoundPlay(@TempDir & "\JpgMp3.mp3")
    ShellExecuteWait(@ScriptDir & "\Out.jpg")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ExtractMp3($sFile)
    If Not FileExists($sFile) Then
    MsgBox(16, "ERROR", $sFile & " not found")
    Return
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $iJpgSize = _JpgGetSize($sFile)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hFile = FileOpen($sFile, 16)
    Local $bMp3 = FileRead($hFile)
    FileClose($hFile)

    [/autoit] [autoit][/autoit] [autoit]

    $bMp3 = BinaryMid($bMp3, $iJpgSize, BinaryLen($bMp3))

    [/autoit] [autoit][/autoit] [autoit]

    Return $bMp3
    EndFunc ;==>_ExtractMp3

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CombineJpgMp3($sFile, $sFile_Jpg, $sFile_Mp3)
    If Not FileExists($sFile_Jpg) Then
    MsgBox(16, "ERROR", $sFile_Jpg & " not found")
    Return
    EndIf
    If Not FileExists($sFile_Mp3) Then
    MsgBox(16, "ERROR", $sFile_Mp3 & " not found")
    Return
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $hFile = FileOpen($sFile_Jpg, 16)
    Local $bJpg = FileRead($hFile)
    FileClose($hFile)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iJpgSize = _JpgGetSize($sFile_Jpg)
    If @extended Or $iJpgSize <> BinaryLen($bJpg) Then
    MsgBox(16, "ERROR", "error calculating jpg size")
    Return
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hFile = FileOpen($sFile_Mp3, 16)
    Local $bMp3 = FileRead($hFile)
    FileClose($hFile)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hFile = FileOpen($sFile, 18)
    FileWrite($hFile, $bJpg)
    FileWrite($hFile, $bMp3)
    FileClose($hFile)
    EndFunc ;==>_CombineJpgMp3

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _JpgGetSize($sFile)
    Local $hFile = FileOpen($sFile, 16)
    Local $bJpg = FileRead($hFile)
    FileClose($hFile)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iLen = BinaryLen($bJpg)
    Local $iSize = 0

    [/autoit] [autoit][/autoit] [autoit]

    Local $tJpg = DllStructCreate("byte Data[" & $iLen + 1 & "];")
    $tJpg.Data = $bJpg

    [/autoit] [autoit][/autoit] [autoit]

    Local $iIdx = 1, $iOffset
    While $iIdx < $iLen ;looking for Start Of Scan (SOS)
    $iOffset = 1

    [/autoit] [autoit][/autoit] [autoit]

    If $tJpg.Data(($iIdx)) = 0xFF Then
    Switch $tJpg.Data(($iIdx + 1))
    Case 0x00, 0xFF ;not a marker
    Case 0xD8 ;SOI
    Case 0x01 ;TEM
    Case 0xD0 To 0xD7 ;RST
    Case 0xD9 ;EOI
    $iSize = $iIdx + 2
    ExitLoop
    Case 0xDA ;SOS
    ExitLoop
    Case Else
    $iOffset = ($tJpg.Data(($iIdx + 2)) * (2 ^ 8) + $tJpg.Data(($iIdx + 3))) + 2
    EndSwitch
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $iIdx += $iOffset
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    If $tJpg.Data(($iIdx)) = 0xFF And $tJpg.Data(($iIdx + 1)) = 0xDA Then
    $bJpg = BinaryMid($bJpg, $iIdx, $iLen)
    $iSize = $iIdx + (StringInStr($bJpg, "FFD9") - 1) / 2
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $iSize <> $iLen Then Return SetExtended(1, $iSize)
    Return $iSize
    EndFunc ;==>_JpgGetSize

    [/autoit]

    Speichere niemals über deine Originalbilder!!!

    Das erzeugte Jpg-Bild sollte von jedem Bildbetrachter (auch mit AutoIt via GDI+) angezeigt werden können, obwohl eine Mp3 dranhängt.
    Um die Mp3 abzuspielen, muss man vorher den Jpg-Teil wegschneiden.

    Die Mp3 kann auch direkt (ohne im Tempordner zu speichern) vom Speicher abgespielt werden: http://www.autoitscript.com/forum/topic/12…e/#entry1004262

    E

  • _WinAPI_BitBlt und Ausgabe in Bild-Datei

    • eukalyptus
    • 9. Februar 2014 um 17:04

    Ich nehme an, die Labels werden erst sichtbar, wenn du im Child_GUI ganz nach unten scrollst!?
    Wenn du von $hDC auf $hMemDC blitten willst, hast du folgendes Problem:
    Der Bildspeicher von $hDC ist nur so groß, wie der sichtbrae Bereich selber; Deshalb wird diese Methode nicht funktionieren!

    Es fallen mir nun 3 Möglichkeiten ein:

    1) Blitte auf mehrere Bitmaps, jeweils einen anderen Scrollbereich und setzte die Bilder danach zusammen (würd ich nicht empfehlen)

    2) Erstelle ein Child-GUI im Scroll-GUI. Dieses Fenster muss bereits die richtige Größe haben.
    Also Graph + Labels auf Child-GUI -> dieses wird teilweise angezeigt im Scroll-GUI -> dieses liegt auf Main_GUI.
    Dann sollte das Blitten funktionieren.

    3) verzichte auf Labels und beschrifte gleich mit GDIPlus! (das wäre meiner Ansicht nach die einfachste und "schönste" Variante)

    E

  • Pixeln aus 1bit BMP auslesen - vertikal (Scanlines emulieren)

    • eukalyptus
    • 6. Februar 2014 um 15:58

    Man muss nicht gezwungenermaßen ASM verwenden, möglicherweise reicht GDI+

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hImage = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\template.bmp")
    Global $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Global $iImgH = _GDIPlus_ImageGetHeight($hImage)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBmpW = $iImgH
    Global $iBmpH = $iImgW
    Global $iBmpStride = Int($iBmpW / 8)
    If Mod($iBmpStride, 4) Then $iBmpStride += 4 - Mod($iBmpStride, 4) ;BMP format requires that each row begins on a four-byte boundary

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $tPixel = DllStructCreate("byte[" & $iBmpStride * $iBmpH & "];")
    Global $hBitmap = _GDIPlus_BitmapCreateFromScan0($iBmpW, $iBmpH, $GDIP_PXF01INDEXED, $iBmpStride, DllStructGetPtr($tPixel))
    Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsRotateTransform($hContext, 90)
    _GDIPlus_GraphicsTranslateTransform($hContext, $iBmpW, 0, True)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hIA = _GDIPlus_ImageAttributesCreate()
    Global $tCM = _GDIPlus_ColorMatrixCreateNegative()
    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tCM)
    _GDIPlus_GraphicsDrawImageRectRect($hContext, $hImage, 0, 0, $iImgW, $iImgH, 0, $iBmpW, $iBmpH, -$iBmpW, $hIA)
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hContext)

    [/autoit] [autoit][/autoit] [autoit]

    Global $bPixel = StringTrimLeft(DllStructGetData($tPixel, 1), 2)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    Global $iByteChars = $iBmpW / 4
    Global $iByteCharStride = $iBmpStride * 2 - $iByteChars

    [/autoit] [autoit][/autoit] [autoit]

    If $iByteCharStride <> 0 Then $bPixel = StringRegExpReplace($bPixel, "(.{" & $iByteChars & "}).{" & $iByteCharStride & "}", "$1")

    [/autoit] [autoit][/autoit] [autoit]

    Global $hFile = FileOpen(@ScriptDir & "\Out.log", 18)
    FileWrite($hFile, "0x" & $bPixel)
    FileClose($hFile)

    [/autoit]

    Ich hab aber auch noch nicht ganz verstanden, was eigentlich der Sinn und Zweck dieses Scriptes sein soll...

    E

  • Suche (schnelle) Funktion zum Umrechnen ins Dual- oder Hexadezimalsystem

    • eukalyptus
    • 2. Februar 2014 um 16:45

    Ich verwende mit pmulld mindestens einen Befehl von SSEv4.1
    Ältere Prozessoren werden das noch nicht unterstützen!


    Ich könnte auch eine SSEv3.3 oder im extremfall eine SSEv2 basteln; wenn gewünscht...

    Edit: Eine alternative Version benutzt nur SSEv2 Befehle und sollte auf älteren Prozessoren laufen... Siehe Post 38

    E

  • Audiofiles zusammenführen

    • eukalyptus
    • 2. Februar 2014 um 15:36

    Hmm.

    Ich denke, dass das dann eher zu noch mehr Problemen führt!

    Eigentlich sollte MP3Gain solche Spitzen "übersehen" und die hörbare Lautstärke ermitteln.
    Warum das bei manchen Beiträgen nicht klappt, kann ich auch nicht sagen!

    E

  • Suche (schnelle) Funktion zum Umrechnen ins Dual- oder Hexadezimalsystem

    • eukalyptus
    • 2. Februar 2014 um 15:28

    Halleluja!
    Der 64Bit Modus gibt ordentlich Gas!

    Eine Dezimalzahl mit 327680 benötigt auf meinem Rechner mit der X86 Variante über 1 Sekunde für die Umwandlung.
    Der X64-Code ist bereits nach guten 200ms fertig!

    Und ich denke, es gibt noch etwas Optimierungspotenzial


    Zitat von Andy

    ...der (wie sehr schön von eukalyptus gezeigt) das vermeidbare DIV benutzt...


    Das ist passiert und war eigentlich keine Absicht ^^
    Ich wollte schon durch 2^24 dividieren, da ich vorerst nicht wusste, wie ich durch 2^32 dividieren soll - bis es mir plötzlich wie Schuppen von den Augen fiel... 8o

    E

    Dateien

    ASM_DecToHex.au3 10,79 kB – 274 Downloads ASM_DecToHex_SSE2.au3 10,93 kB – 273 Downloads
  • Suche (schnelle) Funktion zum Umrechnen ins Dual- oder Hexadezimalsystem

    • eukalyptus
    • 29. Januar 2014 um 09:12

    Ich hab jetzt meine BigNum Version in ASM umgesetzt

    Für eine etwa 40.000 stellige Dezimalzahl braucht es ca 25ms:
    Edit: Durch kleines Speedupdate nu ca 20ms

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n

    [/autoit] [autoit][/autoit] [autoit]

    ;#include "FASM.au3"

    [/autoit] [autoit][/autoit] [autoit]

    ;Global $bOPCode = _FASM_Compile("_ASM_DecToHex32")
    Global $_pASM_DecToHex = _FASM_StructCreateBCA16("0x5589E583EC048B75088B4D0C8B551089F7F30F6F3AF30F6F7210F30F6F6A20660FEFE4F30F6F5A3031DB909090909090F30F6F06660FFAC7660F6FC8660F60C4660FF5C5660F3840C3660F3802C0660F3802C0660FDBCE660F73D908660FFEC1660F7E0783C30183C60983C70483E9097FBE8B750889F789D9890C24BB00CA9A3B9090909090909090909090909090908B0C2489FE31C090909090909090909031D2F7E3030683D200891683C60483E9017FED890783C704832C24017FD283C4045DC20C00")
    ;$bOPCode = _FASM_Compile("_ASM_HexToStr32")
    Global $_pASM_HexToStr = _FASM_StructCreateBCA16("0x8B7424048B4C24088B7C240C01CE66BBF00F83EE018A0688C46621D8C0E8043C0A7C020407043080FC0A7C0380C40780C43066890783C70283E9017FD5C20C00")
    ;$bOPCode = _FASM_Compile("_ASM_HexToBinStr32")
    Global $_pASM_HexToBinStr = _FASM_StructCreateBCA16("0x8B7424048B4C24088B7C240C01CE66BBF00F83EE018A0688C46621D8C0E804BA30303030A801740681CA00000001A802740681CA00000100A804740681CA00010000A808740383CA01891783C704BA30303030F6C401740681CA00000001F6C402740681CA00000100F6C404740681CA00010000F6C408740383CA01891783C70483E9017F8CC20C00")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $sDec = "1234567890"

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To 12
    $sDec &= $sDec
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("! Dec Len: " & StringLen($sDec) & @CRLF & "> " & $sDec & @CRLF & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iTimer = TimerInit()
    $sHex = _BigDecToHex($sDec)
    ConsoleWrite("! Time: " & TimerDiff($iTimer) & @CRLF & @CRLF)
    ConsoleWrite("> " & $sHex & @CRLF & @CRLF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BigDecToHex(ByRef $sDec, $iMode = 2)
    Local $iLen = StringLen($sDec)
    If Mod($iLen, 9) Then
    $iLen += 9 - Mod($iLen, 9)
    $sDec = StringRight("000000000" & $sDec, $iLen)
    EndIf
    Local $tDec = DllStructCreate("char[" & $iLen & "]; byte[16];")
    DllStructSetData($tDec, 1, $sDec)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tVal = DllStructCreate("byte[64];")
    DllStructSetData($tVal, 1, "0x303030303030303030303030303030300000000000000000FF000000000000001027E80364000A001027E80364000A0010270000102700000100000001000000")

    [/autoit] [autoit][/autoit] [autoit]

    DllCallAddress("none", $_pASM_DecToHex, "struct*", $tDec, "uint", $iLen, "struct*", $tVal)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $iMode
    Case 1 ;Hex String
    Local $tHex = DllStructCreate("char[" & $iLen & "];")
    DllCallAddress("none", $_pASM_HexToStr, "struct*", $tDec, "uint", $iLen / 18 * 8, "struct*", $tHex)
    Return StringRegExpReplace(DllStructGetData($tHex, 1), "^0+([^0]|0$)", "\1", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 2 ;Bin String
    Local $tBin = DllStructCreate("char[" & $iLen * 4 & "];")
    DllCallAddress("none", $_pASM_HexToBinStr, "struct*", $tDec, "uint", $iLen / 18 * 8, "struct*", $tBin)
    Return StringRegExpReplace(DllStructGetData($tBin, 1), "^0+([^0]|0$)", "\1", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case Else ;Hex
    Local $tHex = DllStructCreate("byte[" & Ceiling($iLen / 18 * 8) & "];", DllStructGetPtr($tDec))
    Return DllStructGetData($tHex, 1)

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    EndFunc ;==>_BigDecToHex

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_DecToHex32
    # use32

    [/autoit] [autoit][/autoit] [autoit]

    # push ebp
    # mov ebp, esp
    # sub esp, 4

    [/autoit] [autoit][/autoit] [autoit]

    ;#######################################################
    ;# Char to NumberArray
    ;#######################################################

    [/autoit] [autoit][/autoit] [autoit]

    # mov esi, [ebp+8]
    # mov ecx, [ebp+12]
    # mov edx, [ebp+16]

    [/autoit] [autoit][/autoit] [autoit]

    # mov edi, esi

    [/autoit] [autoit][/autoit] [autoit]

    # movdqu xmm7, [edx]
    # movdqu xmm6, [edx+16]
    # movdqu xmm5, [edx+32]
    # pxor xmm4, xmm4
    # movdqu xmm3, [edx+48]

    [/autoit] [autoit][/autoit] [autoit]

    ;xmm7 = 0x30303030303030303030303030303030
    ;xmm6 = 0x0000000000000000FF00000000000000
    ;xmm5 = 10000, 1000, 100, 10, 10000, 1000, 100, 10
    ;xmm4 = 0, 0, 0, 0
    ;xmm3 = 10000, 10000, 1, 1

    [/autoit] [autoit][/autoit] [autoit]

    # xor ebx, ebx
    # align 16
    # _LoopChar:
    # movdqu xmm0, [esi]
    # psubd xmm0, xmm7
    # movdqa xmm1, xmm0

    [/autoit] [autoit][/autoit] [autoit]

    # punpcklbw xmm0, xmm4 ;Char 1-8
    # pmaddwd xmm0, xmm5
    # pmulld xmm0, xmm3
    # phaddd xmm0, xmm0
    # phaddd xmm0, xmm0 ;12345678.

    [/autoit] [autoit][/autoit] [autoit]

    # pand xmm1, xmm6
    # psrldq xmm1, 8
    # paddd xmm0, xmm1 ;123456789

    [/autoit] [autoit][/autoit] [autoit]

    # movd [edi], xmm0

    [/autoit] [autoit][/autoit] [autoit]

    # add ebx, 1
    # add esi, 9
    # add edi, 4
    # sub ecx, 9
    # jg _LoopChar

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;#######################################################
    ;# BigDiv
    ;#######################################################

    [/autoit] [autoit][/autoit] [autoit]

    # mov esi, [ebp+8]
    # mov edi, esi
    # mov ecx, ebx

    [/autoit] [autoit][/autoit] [autoit]

    # mov [esp], ecx
    # mov ebx, 1000000000

    [/autoit] [autoit][/autoit] [autoit]

    ;eax = Number/Result
    ;ebx = MulFactor
    ;ecx = Count
    ;edx = Result

    [/autoit] [autoit][/autoit] [autoit]

    # align 16
    # _LoopDiv:
    # mov ecx, [esp]
    # mov esi, edi

    [/autoit] [autoit][/autoit] [autoit]

    # xor eax, eax ;Tmp = 0

    [/autoit] [autoit][/autoit] [autoit]

    # align 16
    # _LoopBigDiv:
    # xor edx, edx ;???
    # mul ebx ;carry * 100000000

    [/autoit] [autoit][/autoit] [autoit]

    # add eax, [esi]
    # adc edx, 0

    [/autoit] [autoit][/autoit] [autoit]

    # mov [esi], edx

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, 4
    # sub ecx, 1
    # jg _LoopBigDiv

    [/autoit] [autoit][/autoit] [autoit]

    # mov [edi], eax ;write carry

    [/autoit] [autoit][/autoit] [autoit]

    # add edi, 4 ;next ArrayIndex
    # sub dword[esp], 1
    # jg _LoopDiv

    [/autoit] [autoit][/autoit] [autoit]

    # add esp, 4
    # pop ebp

    [/autoit] [autoit][/autoit] [autoit]

    # ret 12
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_HexToBinStr32
    # use32

    [/autoit] [autoit][/autoit] [autoit]

    # mov esi, [esp+4]
    # mov ecx, [esp+8]
    # mov edi, [esp+12]

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, ecx
    # mov bx, 0x0FF0

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # sub esi, 1
    # mov al, [esi]

    [/autoit] [autoit][/autoit] [autoit]

    # mov ah, al
    # and ax, bx
    # shr al, 4

    [/autoit] [autoit][/autoit] [autoit]

    # mov edx, 0x30303030
    # test al, 1
    # jz _L2
    # or edx, 0x01000000
    # _L2:
    # test al, 2
    # jz _L4
    # or edx, 0x00010000
    # _L4:
    # test al, 4
    # jz _L8
    # or edx, 0x00000100
    # _L8:
    # test al, 8
    # jz _H1
    # or edx, 0x00000001
    # _H1:

    [/autoit] [autoit][/autoit] [autoit]

    # mov [edi], edx
    # add edi, 4

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    # mov edx, 0x30303030
    # test ah, 1
    # jz _H2
    # or edx, 0x01000000
    # _H2:
    # test ah, 2
    # jz _H4
    # or edx, 0x00010000
    # _H4:
    # test ah, 4
    # jz _H8
    # or edx, 0x00000100
    # _H8:
    # test ah, 8
    # jz _HN
    # or edx, 0x00000001
    # _HN:

    [/autoit] [autoit][/autoit] [autoit]

    # mov [edi], edx
    # add edi, 4

    [/autoit] [autoit][/autoit] [autoit]

    # sub ecx, 1
    # jg _Loop

    [/autoit] [autoit][/autoit] [autoit]

    # ret 12
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_HexToStr32
    # use32

    [/autoit] [autoit][/autoit] [autoit]

    # mov esi, [esp+4]
    # mov ecx, [esp+8]
    # mov edi, [esp+12]

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, ecx
    # mov bx, 0x0FF0

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # sub esi, 1
    # mov al, [esi]

    [/autoit] [autoit][/autoit] [autoit]

    # mov ah, al
    # and ax, bx
    # shr al, 4

    [/autoit] [autoit][/autoit] [autoit]

    # cmp al, 0xA
    # jl _Dec
    # add al, 7
    # _Dec:
    # add al, 0x30

    [/autoit] [autoit][/autoit] [autoit]

    # cmp ah, 0xA
    # jl _Dec2
    # add ah, 7
    # _Dec2:
    # add ah, 0x30

    [/autoit] [autoit][/autoit] [autoit]

    # mov [edi], ax
    # add edi, 2

    [/autoit] [autoit][/autoit] [autoit]

    # sub ecx, 1
    # jg _Loop

    [/autoit] [autoit][/autoit] [autoit]

    # ret 12
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;#cs
    Func _FASM_StructCreateBCA16($bBinaryCode)
    Local $iSize = BinaryLen($bBinaryCode)
    Local $aResult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", $iSize + 16, "dword", 0x00001000, "dword", 0x00000040)
    If @error Or Not $aResult[0] Then Return SetError(1, 0, False)
    Local $pStruct = Number($aResult[0])
    $pStruct = $pStruct + 16 - Mod($pStruct, 16)
    Local $tStruct = DllStructCreate("byte[" & $iSize & "];", $pStruct)
    DllStructSetData($tStruct, 1, $bBinaryCode)
    Return $pStruct
    EndFunc ;==>_FASM_StructCreateBCA16
    ;#ce

    [/autoit]


    Um die Ergebnisse zu überprüfen, verwende ich übrigens: http://www.mobilefish.com/services/big_number/big_number.php

    E

  • Audiofiles zusammenführen

    • eukalyptus
    • 29. Januar 2014 um 07:12

    Hi

    ist das auch bei meiner vorigen Version so, wo noch nicht MP3Gain.exe verwendet wird?

    Falls das Problem ist, dass der Beitrag zB leise beginnt und dann immer lauter wird, dann gäbe es 2 Möglichkeiten:

    1) In Bass_FX gibt es "Dynamic Amplification" $BASS_BFX_DAMP. Das ist jedoch mit Vorsicht zu genießen.

    2) Man analysiert nur die ersten bzw. letzten Sekunden der Datei - dann sollten zumindest die Übergänge passen.

  • FreeBASIC DLL Rückgabe String

    • eukalyptus
    • 29. Januar 2014 um 06:55

    Die Variable wird beim Beenden der Funktion gelöscht.

    Entweder du deklarierst die Variable außerhalb der Funktion:

    Code
    Extern "Windows-MS"
    
    
    Dim Shared As String s
    
    
    Function back As ZString Ptr Export
    	s = "ABC"
    	Return StrPtr(s)
    End Function
    
    
    End Extern
    Alles anzeigen

    Oder zu reservierst den Speicher zuvor in AutoIt - das wäre dann die ByRef-Methode

    E

  • Suche (schnelle) Funktion zum Umrechnen ins Dual- oder Hexadezimalsystem

    • eukalyptus
    • 24. Januar 2014 um 15:02

    Hi

    Ich hab hier noch eine ganz flotte BigNum-Version:

    Spoiler anzeigen
    [autoit]


    $sDec = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #cs
    $sDec = ""
    For $i = 1 To 10000
    $sDec &= Random(0, 9, 1)
    Next
    #ce

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $iTimer = TimerInit()
    $sBin = _BigNum_DecToBin($sDec)
    ConsoleWrite("! Time Decimal To Binary: " & StringFormat("%.2f", TimerDiff($iTimer)) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    $iTimer = TimerInit()
    $sDec2 = _BigNum_BinToDec($sBin)
    ConsoleWrite("! Time Binary To Decimal: " & StringFormat("%.2f", TimerDiff($iTimer)) & @CRLF & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    If $sDec2 = $sDec Then
    ConsoleWrite("+ Richtig:" & @CRLF & "+ " & $sDec & @CRLF & "+ " & $sDec2 & @CRLF & "+ " & $sBin & @CRLF & @CRLF)
    Else
    ConsoleWrite("! Falsch:" & @CRLF & "! " & $sDec & @CRLF & "! " & $sDec2 & @CRLF & "! " & $sBin & @CRLF & @CRLF)
    _Compare($sDec, $sDec2)
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Compare($sX, $sY)
    Local $aX = StringSplit($sX, "")
    Local $aY = StringSplit($sY, "")

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("! ")
    For $i = 1 To $aX[0]
    If $aX[$i] = $aY[$i] Then
    ConsoleWrite("_")
    Else
    ConsoleWrite("|")
    ExitLoop
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite(@CRLF)
    EndFunc ;==>_Compare

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BigNum_DecToBin($sDec)
    Local $tChr = DllStructCreate("char[65];")
    Local $sRet = ""
    While Not ($sDec = "0")
    DllCall("msvcrt.dll", "ptr:cdecl", "_i64toa", "int64", __BigNum_DecToBinDiv($sDec), "struct*", $tChr, "int", 2)
    $sRet = StringRight("0000000000000000000000000000000000000000000" & DllStructGetData($tChr, 1), 43) & $sRet
    WEnd
    Return StringRegExpReplace($sRet, "^0+([^0]|0$)", "\1", 1)
    EndFunc ;==>_BigNum_DecToBin

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BigNum_BinToDec($sBin)
    Local Const $cPOT = 32
    Local Const $cDVS = Int(2 ^ $cPOT)
    Local $aBin = StringRegExp($sBin, '\A.{' & $cPOT - (Ceiling(StringLen($sBin) / $cPOT) * $cPOT - StringLen($sBin)) & '}|.{' & $cPOT & '}+', 3)
    Local $aResult, $sTmp, $sPot = "1", $sDec = "0"
    For $i = UBound($aBin) - 1 To 0 Step -1
    $sTmp = $sPot
    $aResult = DllCall("msvcrt.dll", "uint64:cdecl", "_strtoui64", "str", $aBin[$i], "ptr", 0, "int", 2)
    __BigNum_BinToDecMul($sTmp, $aResult[0])
    __BigNum_BinToDecAdd($sDec, $sTmp)
    __BigNum_BinToDecMul($sPot, $cDVS)
    Next
    Return StringRegExpReplace($sDec, "^0+([^0]|0$)", "\1", 1)
    EndFunc ;==>_BigNum_BinToDec

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __BigNum_BinToDecAdd(ByRef $sX, $sY)
    Local $iTmp = StringLen($sX), $iLen = StringLen($sY), $iCar = 0, $sRet = ""
    If $iLen < $iTmp Then $iLen = $iTmp
    For $i = 1 To $iLen Step 18
    $iTmp = Int(StringRight($sX, 18)) + Int(StringRight($sY, 18)) + $iCar
    $sX = StringTrimRight($sX, 18)
    $sY = StringTrimRight($sY, 18)
    If ($iTmp > 999999999999999999) Then
    $iTmp = StringRight($iTmp, 18)
    $sRet = $iTmp & $sRet
    $iCar = 1
    Else
    $iTmp = StringRight("000000000000000000" & $iTmp, 18)
    $sRet = $iTmp & $sRet
    $iCar = 0
    EndIf
    Next
    $sX = StringRegExpReplace($iCar & $sRet, "^0+([^0]|0$)", "\1", 1)
    EndFunc ;==>__BigNum_BinToDecAdd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __BigNum_BinToDecMul(ByRef $sX, $iY)
    Local $aX = StringRegExp($sX, '\A.{' & 6 - (Ceiling(StringLen($sX) / 6) * 6 - StringLen($sX)) & '}|.{6}+', 3)
    For $i = 0 To UBound($aX) - 1
    $aX[$i] = Int($aX[$i]) * $iY
    Next
    Local $iCar = 0, $iTmp
    $sX = ""
    For $i = UBound($aX) - 1 To 0 Step -1
    $aX[$i] += $iCar
    $iCar = Floor($aX[$i] / 1000000)
    $iTmp = Mod($aX[$i], 1000000)
    If $iTmp <= 1000000 Then $iTmp = StringRight("000000" & $iTmp, 6)
    $sX = $iTmp & $sX
    Next
    If $iCar > 0 Then $sX = $iCar & $sX
    $sX = StringRegExpReplace($sX, "^0+([^0]|0$)", "\1", 1)
    EndFunc ;==>__BigNum_BinToDecMul

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __BigNum_DecToBinDiv(ByRef $sX)
    Local Const $cDVS = 8796093022208
    Local $sRet = "", $iRem = StringLeft($sX, 15), $iTmp = 0, $iTrm = 6, $iLen
    $sX = StringTrimLeft($sX, 15)
    $iTmp = Floor($iRem / $cDVS)
    $sRet &= $iTmp
    $iRem -= $iTmp * $cDVS
    While StringLen($sX) > 0
    $iTrm = 15 - StringLen($iRem)
    $iTmp = StringLeft($sX, $iTrm)
    $iLen = StringLen($iTmp)
    $iRem &= $iTmp
    $sX = StringTrimLeft($sX, $iTrm)
    $iTmp = Floor($iRem / $cDVS)
    $iTmp = StringRight("000000000000000" & $iTmp, $iLen)
    $sRet &= $iTmp
    $iRem -= $iTmp * $cDVS
    WEnd
    $sX = StringRegExpReplace($sRet, "^0+([^0]|0$)", "\1", 1)
    Return $iRem
    EndFunc ;==>__BigNum_DecToBinDiv

    [/autoit]

    lgE

  • GDI+ How to Path

    • eukalyptus
    • 25. Dezember 2013 um 00:21

    HoHoHo!

    Es weihnachtet sehr und das Christkind hat uns wieder eine neue Stable unter den Baum gelegt!
    Mit dabei sind zahlreiche neue GDI+ Funktionen, ua Path-Funktionen...

    Aber was ist eigentlich ein Path und was kann man damit machen!?

    Hier ein kleines Tut, welches die Pfade etwas beleuchten soll: Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.
    Ganz viel Dank an UEZ für die Unterstützung!


    Ich hoffe, das Tut ist nicht allzu (p)fad ;)

    Dateien

    Path_Tut.7z 1,56 MB – 534 Downloads
  • Neuer Syntax in Version 3.3.10.0

    • eukalyptus
    • 25. Dezember 2013 um 00:06
    Zitat von Mars

    Das Problem mit dem Index in Structs kann auch ohne Eval sehr einfach gelöst werden.

    [autoit]

    For $i = 1 To 4
    ;~ $tStruct.x($i) = $i; Das funktioniert nicht, fehler vom Compiler, wird wohl noch ausgebessert. Stattdessen z.B. die untere Zeile verwenden
    $tStruct.x(($i)) = $i; Mit Klammern funktioniert es
    Next

    [/autoit]

    Durch die Klammern wird $i in einen Ausdruck dessen Ergebnis $i ist umgewandelt. Und mit Ausdrücken hat der Index kein Problem ;)

    lg
    M


    Yeah! :rock::party::thumbup:

  • Eigener GDIPlus Button Style

    • eukalyptus
    • 20. Dezember 2013 um 20:51

    Vielleicht gefällt dir ja sowas: Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Hier der Code (benötigt die aktuelle Beta)

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 610
    Global $iHeight = 200
    Global $hGui = GUICreate("GDI+ Path Tutorial", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
    _GDIPlus_GraphicsClear($hContext, 0xFFFFFFFF)
    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _DrawButton("Button", 10, 30, 160, 100, 0xFFDD3030)
    _DrawButton("Text", 210, 30, 160, 100, 0xFF30AA30)
    _DrawButton("Abcdefg", 410, 30, 190, 100, 0xFF3040DD)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DrawButton($sText, $fX, $fY, $fW, $fH, $iColor, $fRadius = 40)
    Local $hPath = _GDIPlus_PathCreate()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathAddArc($hPath, $fX, $fY, $fRadius, $fRadius, 180, 90)
    _GDIPlus_PathAddArc($hPath, $fX + $fW - $fRadius, $fY, $fRadius, $fRadius, 270, 90)
    _GDIPlus_PathAddArc($hPath, $fX + $fW - $fRadius, $fY + $fH - $fRadius, $fRadius, $fRadius, 0, 90)
    _GDIPlus_PathAddArc($hPath, $fX, $fY + $fH - $fRadius, $fRadius, $fRadius, 90, 90)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 0, $fH * 0.1)
    _GDIPlus_PathTransform($hPath, $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, $fX + $fW * 0.5, $fY)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF000000)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0x00000000)
    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 1, 1)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.85, 0.85)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillPath($hContext, $hPath, $hBrush)
    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixTranslate($hMatrix, 0, -$fH * 0.2)
    _GDIPlus_PathTransform($hPath, $hMatrix)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, $fX + $fW * 0.5, $fY)
    _GDIPlus_PathBrushSetCenterColor($hBrush, $iColor)
    Local $iR = Int(BitAND(BitShift($iColor, 16), 0xFF) * 0.3)
    Local $iG = Int(BitAND(BitShift($iColor, 8), 0xFF) * 0.3)
    Local $iB = Int(BitAND($iColor, 0xFF) * 0.3)
    Local $iColor2 = BitOR(BitShift($iR, -16), BitShift($iG, -8), $iB)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, BitOR(0xFF000000, $iColor2))

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 1, 1)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.97, 0.3)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillPath($hContext, $hPath, $hBrush)
    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $fRadius *= 0.6
    _GDIPlus_PathReset($hPath)
    _GDIPlus_PathAddArc($hPath, $fX + $fRadius * 0.2, $fY, $fRadius, $fRadius, 90, 180)
    _GDIPlus_PathAddArc($hPath, $fX + $fW - $fRadius * 1.2, $fY, $fRadius, $fRadius, 270, 180)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, $fX + $fW * 0.5, $fY + $fRadius * 0.2)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xDDFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0x00000000)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.8, 0.2)
    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 1, 0.9)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillPath($hContext, $hPath, $hBrush)
    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathReset($hPath)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    DllCall($ghGDIPDll, "int", "GdipSetStringFormatLineAlign", "handle", $hFormat, "int", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tLayout = _GDIPlus_RectFCreate($fX, $fY, $fW, $fH)
    _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, 32, $hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix)
    _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2) + $fX + $fW / 2, -($aBounds[1] + $aBounds[3] / 2) + $fY + $fH * 0.48)
    ;_GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    $hBrush = _GDIPlus_LineBrushCreate(0, $aBounds[1] - 4, 0, $aBounds[1] + $aBounds[3] + 4, BitOR(0x40000000, $iColor2), 0x40FFFFFF)
    Local $hPen = _GDIPlus_PenCreate2($hBrush, 4)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDrawPath($hContext, $hPath, $hPen)
    _GDIPlus_PenDispose($hPen)

    [/autoit] [autoit][/autoit] [autoit]

    $hPen = _GDIPlus_PenCreate(BitOR(0x70000000, $iColor2), 2)
    _GDIPlus_GraphicsDrawPath($hContext, $hPath, $hPen)
    _GDIPlus_PenDispose($hPen)

    [/autoit] [autoit][/autoit] [autoit]

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    _GDIPlus_GraphicsFillPath($hContext, $hPath, $hBrush)
    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathDispose($hPath)
    EndFunc ;==>_DrawButton

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Bilder

    • Buttons.jpg
      • 21,36 kB
      • 602 × 117
  • FASM UDF (X86 u X64)

    • eukalyptus
    • 5. Dezember 2013 um 22:20

    UEZ: Probier nun Rot-Weiß mit SIMD und verarbeite 4 Pixel gleichzeitig. :D
    Edit: im "Game of Life" findest du eine Random-Funktion


    Andy: welche Fehlermeldungen? Bei mir läuft es ohne Probleme unter WinXP32 und Win764

    Zitat von Andy

    Wieso du dir die Mühe machst mit dem #ASM und #ASMEND und dann noch das völlig überflüssige # vor die Assemblerbefehle reinbastelst, verstehe ich allerdings nicht.
    Dann lieber in LUA den Teil von #cs und #ce suchen und mit #ASM und #ASMEND ergänzen, so dass der Code dazwischen nicht von AutoIt geparsed wird.

    Wenn alles zwischen #cs und #ce steht, dann geht total der Überblick verloren
    hier mal ein Vergleich:
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist. Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.
    im zweiten Bild sieht man auf den ersten Blick, welche Teile nun tatsächlich zum Code gehören und welche nicht.

    Des weiteren zerstört Tidy.exe die Formatierung innerhalb eines CommentBlocks:
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.


    Optimal wäre ja, wenn LASM auch 64Bit könnte!
    Minx, ist das geplant?

    Dateien

    ASM-1.jpg 114,73 kB – 0 Downloads ASM-2.jpg 120,12 kB – 0 Downloads ASM-3.jpg 111,46 kB – 0 Downloads
  • FASM UDF (X86 u X64)

    • eukalyptus
    • 5. Dezember 2013 um 20:24
    Zitat von minx

    Höhö :D


    Das hab ich mir, ganz ehrlich, nicht von dir abgeguckt!


    Zitat von UEZ

    Ich glaube, dass ich doch endlich ASM lernen sollte...


    Starte doch mal mit diesem Script:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n

    [/autoit] [autoit][/autoit] [autoit]

    #include "FASM.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $bOPCode, $_pASM_StringCopy
    $bOPCode = _FASM_Compile("_ASM_StringCopy")
    $_pASM_StringCopy = _FASM_StructCreateBCA16($bOPCode)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tStringSrc = DllStructCreate("char[1024];")
    Global $tStringDst = DllStructCreate("char[1024];")
    DllStructSetData($tStringSrc, 1, "AutoIt rulez!")

    [/autoit] [autoit][/autoit] [autoit]

    DllCallAddress("none", $_pASM_StringCopy, "struct*", $tStringSrc, "struct*", $tStringDst, "int", StringLen(DllStructGetData($tStringSrc, 1)))

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> Fertig: " & DllStructGetData($tStringDst, 1) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_StringCopy
    # use32
    # mov esi, [esp+4] ;Parameter 1 in ESI laden (Pointer $tStringSrc)
    # mov edi, [esp+8] ;Parameter 2 in EDI laden (Pointer $tStringDst)
    # mov ecx, [esp+12] ;Parameter 3 in ECX laden (StringLen)

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # mov al, [esi] ;1 Byte von tStringSrc in AL laden
    # mov [edi], al ;Inhalt von AL nach tStringDst schreiben

    [/autoit] [autoit][/autoit] [autoit]

    # _FASM_DBG("_Debug")

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, 1 ;Src Pointer + 1
    # add edi, 1 ;Dst Pointer + 1

    [/autoit] [autoit][/autoit] [autoit]

    # sub ecx, 1 ;LoopCount - 1
    # jg _Loop ;if ecx > 0 then "springe zu _Loop:"

    [/autoit] [autoit][/autoit] [autoit]

    # ret 12 ;Anzahl der Parameter * 4
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Debug($tData)
    Local $tTmp = DllStructCreate($tagFASM_DBG_32, DllStructGetPtr($tData))
    Local $tEAX = DllStructCreate("char[4];", DllStructGetPtr($tTmp, "EAX"))
    ;EAX ist 32Bit = 4Byte lang und hat folgenden Aufbau:
    ;32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
    ;|--------------------------------------------- EAX -------------------------------------------|
    ; |--------------------- AX --------------------|
    ; |--------- AH ---------|
    ; |--------- AL ---------|

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> Byte in AL: " & DllStructGetData($tEAX, 1, 1) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("+ LoopCnt ECX: " & DllStructGetData($tTmp, "ECX") & @CRLF)
    ConsoleWrite("! Pointer Src ESI: " & DllStructGetData($tTmp, "ESI") & " / Offset: " & DllStructGetData($tTmp, "ESI") - Number(DllStructGetPtr($tStringSrc)) & @CRLF)
    ConsoleWrite("! Pointer Dst EDI: " & DllStructGetData($tTmp, "EDI") & " / Offset: " & DllStructGetData($tTmp, "EDI") - Number(DllStructGetPtr($tStringDst)) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite(@CRLF)
    EndFunc ;==>_Debug

    [/autoit]

    Sollte relativ einfach nachzuvollziehen sein.

    Versuch mal jedes Char um 1 zu erhöhen (Aus "A" wird "B" usw...)
    Oder den String in umgedrehter Reihenfolge (StringReverse) zu kopieren (Tip: StringLen / 2 = "shr ecx, 1")


    Und dann experimentier mal mit DEINER Materie - GdiPlus ;)

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\Beta
    #AutoIt3Wrapper_UseX64=n
    #include <GDIPlus.au3>
    #include "FASM.au3"

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $tPixels = DllStructCreate("uint[" & 9 * 9 & "];")
    Global $hBitmap = _GDIPlus_BitmapCreateFromScan0(9, 9, $GDIP_PXF32ARGB, 9 * 4, DllStructGetPtr($tPixels))
    Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hContext, 0xFFFF00FF)
    Global $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    _GDIPlus_GraphicsFillRect($hContext, 1, 1, 3, 3, $hBrush)
    _GDIPlus_BrushSetSolidColor($hBrush, 0xFF00FF00)
    _GDIPlus_GraphicsFillRect($hContext, 5, 1, 3, 3, $hBrush)
    _GDIPlus_BrushSetSolidColor($hBrush, 0xFF0000FF)
    _GDIPlus_GraphicsFillRect($hContext, 1, 5, 3, 3, $hBrush)
    _GDIPlus_BrushSetSolidColor($hBrush, 0xFFFFFF00)
    _GDIPlus_GraphicsFillRect($hContext, 5, 5, 3, 3, $hBrush)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hContext)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Src.bmp")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $bOPCode, $_pASM_StringCopy
    $bOPCode = _FASM_Compile("_ASM_Red2White")
    $_pASM_Red2White = _FASM_StructCreateBCA16($bOPCode)

    [/autoit] [autoit][/autoit] [autoit]

    DllCallAddress("none", $_pASM_Red2White, "struct*", $tPixels, "int", 9 * 9)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Dst.bmp")
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_Red2White
    # use32
    # mov esi, [esp+4]
    # mov ecx, [esp+8]

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # mov eax, [esi]
    # _FASM_DBG("_Debug_1")

    [/autoit] [autoit][/autoit] [autoit]

    # cmp eax, 0xFFFF0000
    # jne _NotEqual
    # mov dword[esi], 0xFFFFFFFF
    # _FASM_DBG("_Debug_2")

    [/autoit] [autoit][/autoit] [autoit]

    # _NotEqual:

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, 4
    # sub ecx, 1
    # jg _Loop

    [/autoit] [autoit][/autoit] [autoit]

    # ret 8
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Debug_2($tData)
    Local $tTmp = DllStructCreate($tagFASM_DBG_32, DllStructGetPtr($tData))
    ConsoleWrite("! EAX: " & Hex($tTmp.EAX, 8) & " = 0xFFFF0000 => Farbe Weiß wird geschrieben" & @CRLF)
    EndFunc ;==>_Debug_2

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Debug_1($tData)
    Local $tTmp = DllStructCreate($tagFASM_DBG_32, DllStructGetPtr($tData))
    ConsoleWrite("+ EAX: " & Hex($tTmp.EAX, 8) & @CRLF)
    EndFunc ;==>_Debug_1

    [/autoit]

    Nun probier, dass auch eine weitere Farbe weiß wird...

    lgE

  • FASM UDF (X86 u X64)

    • eukalyptus
    • 5. Dezember 2013 um 13:04

    Ich habe mir nun meine eigene FASM UDF geschrieben um mir die Arbeit zu erleichtern.

    Die UDF kann direkt aus einem X64 Script heraus einen X64 Assemblercode erzeugen.
    D.h.: mann muss nicht ständig zwischen X64 u X86 wechseln, was die Arbeit erheblich erleichtert.

    Direkt aus dem ASM-Code kann man benutzerdefinierte Debug-Funktionen aufrufen.
    Die Register lassen sich in einer normalen AutoIt-Funktion im gewünschten Format ausgeben.
    So kann man sich für jede Situation die richtige Debug-Funktion basteln (z.B. wenn bei den xmm Registern float und int gemischt vorkommen)

    Der ASM-Abschnitt im Script ist mit den Keywords #ASM, #ASMEND und # definiert:
    Dadurch ist der ASM-Code sehr übersichtlich.
    Beim Aufruf von Tidy.exe verliert man nicht die Formatierung.
    Man kann größere Codeteile wie gewohnt mit #cs und #ce auskommentieren
    Durch geringe Anpassungen in SciTE (beschrieben in FASM.au3) kann man die Übersicht/Schreibgeschwindigkeit noch erhöhen


    Die wichtigsten Funktionen sind:
    _FASM_Compile: kompiliert den ASM-Code
    _FASM_StructCreateBCA16: schreibt den ByteCode in den Speicher
    _FASM_DBG: ruft eine AutoIt-Debugfunktion auf


    Hier ein Beispiel, wie man die Debugfunktion nutzen kann:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n

    [/autoit] [autoit][/autoit] [autoit]

    #include "FASM.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $bOPCode, $_pASM_Test
    Switch @AutoItX64
    Case 1
    $bOPCode = _FASM_Compile("_ASM_Test64")
    Case Else
    $bOPCode = _FASM_Compile("_ASM_Test32")
    EndSwitch
    $_pASM_Test = _FASM_StructCreateBCA16($bOPCode)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $tStruct = DllStructCreate("byte xmm0[16]; word xmm1[8]; dword xmm2[4]; float xmm3[4]; byte xmm4[16]; word xmm5[8]; dword xmm6[4]; float xmm7[4];")
    DllStructSetData($tStruct, "xmm0", "0x11111111222222223333333344444444")
    DllStructSetData($tStruct, "xmm4", "0x11111111111111111111111111111111")
    For $i = 1 To 8
    DllStructSetData($tStruct, "xmm1", 2 ^ $i * 100, $i)
    DllStructSetData($tStruct, "xmm5", 1, $i)
    Next
    For $i = 1 To 4
    DllStructSetData($tStruct, "xmm2", 2 ^ $i * 1000000, $i)
    DllStructSetData($tStruct, "xmm6", 1, $i)
    DllStructSetData($tStruct, "xmm3", 2 ^ $i + 0.5, $i)
    DllStructSetData($tStruct, "xmm7", 10, $i)
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCallAddress("none", $_pASM_Test, "int", 4, "struct*", $tStruct)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_Test32
    # use32
    # mov ecx, [esp+4] ;LoopCount
    # mov esi, [esp+8] ;StructPointer

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# X86
    ;###########################################################

    [/autoit] [autoit][/autoit] [autoit]

    # movdqu xmm0, [esi]
    # movdqu xmm1, [esi+16]
    # movdqu xmm2, [esi+32]
    # movdqu xmm3, [esi+48]
    # movdqu xmm4, [esi+64]
    # movdqu xmm5, [esi+80]
    # movdqu xmm6, [esi+96]
    # movdqu xmm7, [esi+112]

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # _FASM_DBG("_DebugREG_32")
    # _FASM_DBG("_DebugXMM_32")

    [/autoit] [autoit][/autoit] [autoit]

    # paddb xmm0, xmm4
    # paddw xmm1, xmm5
    # paddd xmm2, xmm6
    # addps xmm3, xmm7

    [/autoit] [autoit][/autoit] [autoit]

    # sub ecx, 1
    # jnz _Loop

    [/autoit] [autoit][/autoit] [autoit]

    #cs
    X86
    #ce

    [/autoit] [autoit][/autoit] [autoit]

    # ret 8
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DebugREG_32($tData)
    ConsoleWrite("-= Debug X86 ==========================================" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tTmp = DllStructCreate($tagFASM_DBG_32, DllStructGetPtr($tData))
    ConsoleWrite("+ StructPointer ESI: " & DllStructGetData($tTmp, "ESI") & @CRLF)
    ConsoleWrite("! LoopCount ECX: " & DllStructGetData($tTmp, "ECX") & @CRLF)
    EndFunc ;==>_DebugREG_32

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DebugXMM_32($tData)
    Local $tTmp = DllStructCreate($tagFASM_DBG_32, DllStructGetPtr($tData))
    Local $tXMM = DllStructCreate("byte xmm0[16]; word xmm1[8]; dword xmm2[4]; float xmm3[4];", DllStructGetPtr($tTmp, "xmm0"))

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> Byte Xmm0: " & DllStructGetData($tXMM, "xmm0") & @CRLF)
    ConsoleWrite("> Word Xmm1:")
    For $i = 1 To 8
    ConsoleWrite(" " & DllStructGetData($tXMM, "xmm1", $i))
    Next
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> DWord Xmm2:")
    For $i = 1 To 4
    ConsoleWrite(" " & DllStructGetData($tXMM, "xmm2", $i))
    Next
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> Float Xmm3:")
    For $i = 1 To 4
    ConsoleWrite(" " & DllStructGetData($tXMM, "xmm3", $i))
    Next
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite(@CRLF)
    EndFunc ;==>_DebugXMM_32

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_Test64
    # use64

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# X64
    ;###########################################################

    [/autoit] [autoit][/autoit] [autoit]

    # movdqu xmm0, [rdx]
    # movdqu xmm1, [rdx+16]
    # movdqu xmm2, [rdx+32]
    # movdqu xmm3, [rdx+48]
    # movdqu xmm4, [rdx+64]
    # movdqu xmm5, [rdx+80]
    # movdqu xmm6, [rdx+96]
    # movdqu xmm7, [rdx+112]

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # _FASM_DBG("_DebugREG_64")
    # _FASM_DBG("_DebugXMM_64")

    [/autoit] [autoit][/autoit] [autoit]

    # paddb xmm0, xmm4
    # paddw xmm1, xmm5
    # paddd xmm2, xmm6
    # addps xmm3, xmm7

    [/autoit] [autoit][/autoit] [autoit]

    # sub rcx, 1
    # jnz _Loop

    [/autoit] [autoit][/autoit] [autoit]

    #cs
    X64
    #ce

    [/autoit] [autoit][/autoit] [autoit]

    # ret
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DebugREG_64($tData)
    ConsoleWrite("-= Debug X64 ==========================================" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tTmp = DllStructCreate($tagFASM_DBG_64, DllStructGetPtr($tData))
    ConsoleWrite("+ StructPointer RDX: " & DllStructGetData($tTmp, "RDX") & @CRLF)
    ConsoleWrite("! LoopCount RCX: " & DllStructGetData($tTmp, "RCX") & @CRLF)
    EndFunc ;==>_DebugREG_64

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _DebugXMM_64($tData)
    Local $tTmp = DllStructCreate($tagFASM_DBG_64, DllStructGetPtr($tData))
    Local $tXMM = DllStructCreate("byte xmm0[16]; word xmm1[8]; dword xmm2[4]; float xmm3[4];", DllStructGetPtr($tTmp, "xmm0"))

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> Byte Xmm0: " & DllStructGetData($tXMM, "xmm0") & @CRLF)
    ConsoleWrite("> Word Xmm1:")
    For $i = 1 To 8
    ConsoleWrite(" " & DllStructGetData($tXMM, "xmm1", $i))
    Next
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> DWord Xmm2:")
    For $i = 1 To 4
    ConsoleWrite(" " & DllStructGetData($tXMM, "xmm2", $i))
    Next
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite("> Float Xmm3:")
    For $i = 1 To 4
    ConsoleWrite(" " & DllStructGetData($tXMM, "xmm3", $i))
    Next
    ConsoleWrite(@CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite(@CRLF)
    EndFunc ;==>_DebugXMM_64

    [/autoit]


    Hier noch eine (vorkompilierte) Version von "Conway's Game of Life" (benötigt aktuelle Beta)

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\Beta
    #AutoIt3Wrapper_UseX64=n

    [/autoit] [autoit][/autoit] [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;#include "FASM.au3"

    [/autoit] [autoit][/autoit] [autoit]

    ;Global $bOPCode = _FASM_Compile("_ASM_Calc")
    Global $_pASM_Calc = _FASM_StructCreateBCA16("0x8B54240C8B5A088B7C24048B74240889D90FAF4A0489D86BC00201C601C7660F6F06660F7F0783C71083C61083E91075ED8B7C240489FE01DF8B420483C0010FAFC301C689D9660F6F06660F6F0C1F660F7F07F30F7F0C1E83C71083C61083E91075E38B7C240401DF01DF89FE03328B4A048A068A6701880788660101DF01DE83E90175ED8B7C240401DF8B42040FAFC389FE01C68B028A4E018A2C06882F884C070101DE01DF8A4F018A2C07882E884C06018B74240889D90FAF4A0C660FEFC0660F7F0683C61083E91075F48B7424048B7C24088B420483C00201DE83C701660F6F0689D983C610660F6FC8660F6FD0660F6FD8660F6F06660F6FE0660F73DA01660F73DB02660F73FC0E660FEBDC660F73FC01660FEBD4660FFCCB660FFCD1F30F6F1FF30F6F241FF30F6F2C5F660FFCDA660FFCE1660FFCEAF30F7F1FF30F7F241FF30F7F2C5F83C71083E910759583E801758A8B7424048B7C2408B8020000000FAFC301C601C789D90FAF4A04B803030303660F6EF8660F70FF00B802020202660F6EF0660F70F600B801010101660F6EE8660F70ED00660F6F07660F6F0E660F6FD0660F6FD8660F74D6660F74DF660FDBCA660F6FE5660FDBE3660FEBCC660F7F0F83C71083C61083E91075C9C20C00")
    ;$bOPCode = _FASM_Compile("_ASM_SetBitmap")
    Global $_pASM_SetBitmap = _FASM_StructCreateBCA16("0x8B54240C8B7C24048B7424088B5A0889D96BDB0201DE83C6010FAF4A04B801000000660F6EF0660F70F600660F6E6A14660F70ED00660FEFFFF30F6F06660F6FD0660F60C7660F68D7660F6FC8660F6FDA660F60C7660F60D7660F68CF660F68DF660F76C6660F76CE660F76D6660F76DE660FDBC5660FDBCD660FDBD5660FDBDD660F7F0783C710660F7F0F83C710660F7F1783C710660F7F1F83C71083C61083E9107594C20C00")
    ;$bOPCode = _FASM_Compile("_ASM_Random")
    Global $_pASM_Random = _FASM_StructCreateBCA16("0x8B7C24048B4C24088B44240C69C0FD43030005C39E260083F8007C05C60701EB03C6070083C70183E90175E0C20C00")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)
    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $iLife_X = 600 * 4
    Global $iLife_Y = 600 * 4

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $iLife_PatX = $iLife_X + 2 + 16
    $iLife_PatX = $iLife_PatX + 16 - Mod($iLife_PatX, 16)
    Global $iLife_PatY = $iLife_Y + 4

    [/autoit] [autoit][/autoit] [autoit]

    Global $tLife_Pat = DllStructCreate("byte[" & $iLife_PatX * $iLife_PatY & "]; byte[32];")
    Global $pLife_Pat = Number(DllStructGetPtr($tLife_Pat))
    If Mod($pLife_Pat, 16) Then $pLife_Pat += 16 - Mod($pLife_Pat, 16)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tLife_PatNG = DllStructCreate("byte[" & $iLife_PatX * $iLife_PatY & "]; byte[32];")
    Global $pLife_PatNG = Number(DllStructGetPtr($tLife_PatNG))
    If Mod($pLife_PatNG, 16) Then $pLife_PatNG += 16 - Mod($pLife_PatNG, 16)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tLife_BMP = DllStructCreate("uint[" & $iLife_PatX * $iLife_Y & "]; byte[32];")
    Global $pLife_BMP = Number(DllStructGetPtr($tLife_BMP))
    If Mod($pLife_BMP, 16) Then $pLife_BMP += 16 - Mod($pLife_BMP, 16)
    Global $hBmp_Life = _GDIPlus_BitmapCreateFromScan0($iLife_X, $iLife_Y, $GDIP_PXF32ARGB, $iLife_PatX * 4, $pLife_BMP)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tValues = DllStructCreate("int X; int Y; int PatX; int PatY; uint BGColor; uint Color;")
    DllStructSetData($tValues, "X", $iLife_X)
    DllStructSetData($tValues, "Y", $iLife_Y)
    DllStructSetData($tValues, "PatX", $iLife_PatX)
    DllStructSetData($tValues, "PatY", $iLife_PatY)
    DllStructSetData($tValues, "BGColor", 0xFF000000)
    DllStructSetData($tValues, "Color", 0xFF00FF00)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $iGui_W = 600
    Global $iGui_H = 600

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Conway's Game of Life", $iGui_W, $iGui_H)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hBmp = _WinAPI_CreateBitmap($iGui_W, $iGui_H)
    Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
    _WinAPI_DeleteObject($hBmp)
    $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Global $hDC = _WinAPI_GetDC($hGui)
    Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
    Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBmp)
    Global $hGfx_Buffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
    _GDIPlus_GraphicsSetInterpolationMode($hGfx_Buffer, 5)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx_Buffer, 2)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _Random()

    [/autoit] [autoit][/autoit] [autoit]

    Global $iTimer = TimerInit(), $iSteps = 0
    While 1
    _Calc()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
    _GDIPlus_GraphicsDrawImageRect($hGfx_Buffer, $hBmp_Life, 0, 0, $iGui_W, $iGui_H)
    _WinAPI_BitBlt($hDC, 0, 0, $iGui_W, $iGui_H, $hCDC, 0, 0, 0x00CC0020)

    [/autoit] [autoit][/autoit] [autoit]

    $iSteps += 1
    WinSetTitle($hGui, "", "Conway's Game of Life " & $iLife_X & "x" & $iLife_Y & " / " & StringFormat("%.1f", 1000 / (TimerDiff($iTimer) / $iSteps), 1) & " fps")
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Calc()
    DllCallAddress("none", $_pASM_Calc, "ptr", $pLife_Pat, "ptr", $pLife_PatNG, "struct*", $tValues)
    DllCallAddress("none", $_pASM_SetBitmap, "ptr", $pLife_BMP, "ptr", $pLife_PatNG, "struct*", $tValues)
    EndFunc ;==>_Calc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_Calc
    # use32

    [/autoit] [autoit][/autoit] [autoit]

    # mov edx, [esp+12]
    # mov ebx, [edx+8] ;PatX

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# Copy NextGeneration Pattern to LifePattern incl. Borders
    ;###########################################################
    # mov edi, [esp+4]
    # mov esi, [esp+8]
    # mov ecx, ebx;PatX
    # imul ecx, [edx+4];PatX*Y
    # mov eax, ebx
    # imul eax, 2
    # add esi, eax ;skip first/last 2 rows
    # add edi, eax
    # _LoopCopy:
    # movdqa xmm0, [esi]
    # movdqa [edi], xmm0
    # add edi, 16
    # add esi, 16
    # sub ecx, 16
    # jnz _LoopCopy

    [/autoit] [autoit][/autoit] [autoit]

    ; Mirror Bottom-Top
    # mov edi, [esp+4]
    # mov esi, edi
    # add edi, ebx;2 row
    # mov eax, [edx+4]
    # add eax, 1
    # imul eax, ebx
    # add esi, eax;Y+2 row
    # mov ecx, ebx
    # _LoopCopyX:
    # movdqa xmm0, [esi]
    # movdqa xmm1, [edi+ebx]
    # movdqa [edi], xmm0
    # movdqu [esi+ebx], xmm1
    # add edi, 16
    # add esi, 16
    # sub ecx, 16
    # jnz _LoopCopyX

    [/autoit] [autoit][/autoit] [autoit]

    ; Mirror Left-Right
    # mov edi, [esp+4]
    # add edi, ebx
    # add edi, ebx
    # mov esi, edi
    # add esi, [edx]
    # mov ecx, [edx+4]
    # _LoopCopyY:
    # mov al, [esi]
    # mov ah, [edi+1]
    # mov [edi], al
    # mov [esi+1], ah
    # add edi, ebx
    # add esi, ebx
    # sub ecx, 1
    # jnz _LoopCopyY

    [/autoit] [autoit][/autoit] [autoit]

    ; Corners
    # mov edi, [esp+4]
    # add edi, ebx
    # mov eax, [edx+4]
    # imul eax, ebx
    # mov esi, edi
    # add esi, eax
    # mov eax, [edx]
    # mov cl, [esi+1]
    # mov ch, [esi+eax]
    # mov [edi], ch
    # mov [edi+eax+1], cl

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, ebx
    # add edi, ebx
    # mov cl, [edi+1]
    # mov ch, [edi+eax]
    # mov [esi], ch
    # mov [esi+eax+1], cl

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# Clear NextGeneration Pattern
    ;###########################################################
    # mov esi, [esp+8]
    # mov ecx, ebx;PatX
    # imul ecx, [edx+12];PatX*PatY
    # pxor xmm0, xmm0
    # _LoopClear:
    # movdqa [esi], xmm0
    # add esi, 16
    # sub ecx, 16
    # jnz _LoopClear

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# Count Neighbors
    ;###########################################################
    # mov esi, [esp+4]
    # mov edi, [esp+8]
    # mov eax, [edx+4] ;Y
    # add eax, 2 ;+2 rows
    # add esi, ebx
    # add edi, 1 ;center field
    # _LoopY:
    # movdqa xmm0, [esi]
    # mov ecx, ebx;PatX
    # _LoopX:
    # add esi, 16
    ;xmm0 = 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01 00
    # movdqa xmm1, xmm0
    # movdqa xmm2, xmm0
    # movdqa xmm3, xmm0
    # movdqa xmm0, [esi]
    # movdqa xmm4, xmm0
    # psrldq xmm2, 1
    # psrldq xmm3, 2
    # pslldq xmm4, 14
    ;xmm0 = 1F 1E 1D 1C 1B 1A 19 18 17 16 15 14 13 12 11 10
    ;xmm1 = 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01 00
    ;xmm2 = __ 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01
    ;xmm3 = __ __ 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02
    ;xmm4 = 11 10 __ __ __ __ __ __ __ __ __ __ __ __ __ __
    # por xmm3, xmm4
    # pslldq xmm4, 1
    # por xmm2, xmm4
    # paddb xmm1, xmm3 ;=>aktuelle Zeile => 00+02 | 01+03...
    # paddb xmm2, xmm1 ;=>vorherige u nächste Zeile => 00+01+02 | 01+02+03...

    [/autoit] [autoit][/autoit] [autoit]

    # movdqu xmm3, [edi]
    # movdqu xmm4, [edi+ebx]
    # movdqu xmm5, [edi+ebx+ebx]
    # paddb xmm3, xmm2
    # paddb xmm4, xmm1
    # paddb xmm5, xmm2
    # movdqu [edi], xmm3
    # movdqu [edi+ebx], xmm4
    # movdqu [edi+ebx+ebx], xmm5

    [/autoit] [autoit][/autoit] [autoit]

    # add edi, 16
    # sub ecx, 16
    # jnz _LoopX

    [/autoit] [autoit][/autoit] [autoit]

    # sub eax, 1
    # jnz _LoopY

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# Calc NextGeneration
    ;###########################################################
    # mov esi, [esp+4]
    # mov edi, [esp+8]
    # mov eax, 2
    # imul eax, ebx
    # add esi, eax
    # add edi, eax
    # mov ecx, ebx;PatX
    # imul ecx, [edx+4];PatX*Y

    [/autoit] [autoit][/autoit] [autoit]

    # mov eax, 0x03030303
    # movd xmm7, eax
    # pshufd xmm7, xmm7, 0
    # mov eax, 0x02020202
    # movd xmm6, eax
    # pshufd xmm6, xmm6, 0
    # mov eax, 0x01010101
    # movd xmm5, eax
    # pshufd xmm5, xmm5, 0

    [/autoit] [autoit][/autoit] [autoit]

    ;xmm7 = 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
    ;xmm6 = 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
    ;xmm5 = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    # _LoopCalc:
    # movdqa xmm0, [edi]
    # movdqa xmm1, [esi]
    # movdqa xmm2, xmm0
    # movdqa xmm3, xmm0
    ;2=NoChange 3=1 Else=0
    # pcmpeqb xmm2, xmm6
    # pcmpeqb xmm3, xmm7
    # pand xmm1, xmm2
    # movdqa xmm4, xmm5
    # pand xmm4, xmm3
    # por xmm1, xmm4
    # movdqa [edi], xmm1
    # add edi, 16
    # add esi, 16
    # sub ecx, 16
    # jnz _LoopCalc

    [/autoit] [autoit][/autoit] [autoit]

    # ret 12
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_SetBitmap
    # use32

    [/autoit] [autoit][/autoit] [autoit]

    ;###########################################################
    ;# Set Pixel
    ;###########################################################
    # mov edx, [esp+12]
    # mov edi, [esp+4]
    # mov esi, [esp+8]
    # mov ebx, [edx+8]
    # mov ecx, ebx
    # imul ebx, 2
    # add esi, ebx
    # add esi, 1
    # imul ecx, [edx+4]

    [/autoit] [autoit][/autoit] [autoit]

    # mov eax, 1
    # movd xmm6, eax
    # pshufd xmm6, xmm6, 0

    [/autoit] [autoit][/autoit] [autoit]

    # movd xmm5, [edx+20]
    # pshufd xmm5, xmm5, 0

    [/autoit] [autoit][/autoit] [autoit]

    # pxor xmm7, xmm7

    [/autoit] [autoit][/autoit] [autoit]

    # _Loop:
    # movdqu xmm0, [esi]
    # movdqa xmm2, xmm0

    [/autoit] [autoit][/autoit] [autoit]

    # punpcklbw xmm0, xmm7
    # punpckhbw xmm2, xmm7
    # movdqa xmm1, xmm0
    # movdqa xmm3, xmm2
    # punpcklbw xmm0, xmm7
    # punpcklbw xmm2, xmm7
    # punpckhbw xmm1, xmm7
    # punpckhbw xmm3, xmm7

    [/autoit] [autoit][/autoit] [autoit]

    # pcmpeqd xmm0, xmm6
    # pcmpeqd xmm1, xmm6
    # pcmpeqd xmm2, xmm6
    # pcmpeqd xmm3, xmm6

    [/autoit] [autoit][/autoit] [autoit]

    # pand xmm0, xmm5
    # pand xmm1, xmm5
    # pand xmm2, xmm5
    # pand xmm3, xmm5
    #
    # movdqa [edi], xmm0
    # add edi, 16
    # movdqa [edi], xmm1
    # add edi, 16
    # movdqa [edi], xmm2
    # add edi, 16
    # movdqa [edi], xmm3
    # add edi, 16

    [/autoit] [autoit][/autoit] [autoit]

    # add esi, 16
    # sub ecx, 16
    # jnz _Loop

    [/autoit] [autoit][/autoit] [autoit]

    # ret 12
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Random()
    Local Static $iSeed = Random(0, 2 ^ 16, 1)
    Local $aResult = DllCallAddress("int", $_pASM_Random, "ptr", $pLife_PatNG, "uint", $iLife_PatX * $iLife_PatY, "int", $iSeed)
    $iSeed = $aResult[0]
    EndFunc ;==>_Random

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #ASM _ASM_Random
    # use32
    # mov edi, [esp+4]
    # mov ecx, [esp+8] ;Count
    # mov eax, [esp+12] ;Seed
    # _Loop:
    # imul eax, 214013
    # add eax, 2531011
    # cmp eax, 0
    # jl _Zero
    # mov byte[edi], 1
    # jmp _Cont
    # _Zero:
    # mov byte[edi], 0
    # _Cont:
    # add edi, 1
    # sub ecx, 1
    # jnz _Loop
    # ret 12
    #ASMEND

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _FASM_StructCreateBCA16($bBinaryCode)
    Local $iSize = BinaryLen($bBinaryCode)
    Local $aResult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", $iSize + 16, "dword", 0x00001000, "dword", 0x00000040)
    If @error Or Not $aResult[0] Then Return SetError(1, 0, False)
    Local $pStruct = Number($aResult[0])
    $pStruct = $pStruct + 16 - Mod($pStruct, 16)
    Local $tStruct = DllStructCreate("byte[" & $iSize & "];", $pStruct)
    DllStructSetData($tStruct, 1, $bBinaryCode)
    Return $pStruct
    EndFunc ;==>_StructCreateBCA16

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_BitmapDispose($hBmp_Life)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _WinAPI_SelectObject($hCDC, $hOBJ)
    _WinAPI_DeleteObject($hBmp)
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]


    Die UDF ist kein Inline-Assembler! Sondern ein Werkzeug zum Entwickeln von fertigem Bytecode.
    Damit FASM auch unter X64 kompilieren kann, wird die FASM.exe auf die Festplatte geschrieben und gestartet.

    Vielen Dank an UEZ und vor allem Andy! :thumbup:
    (Ich hab mir einige Sachen ganz dreist abgeguckt :whistling: )

    lgE

    Dateien

    FASM.au3 110,09 kB – 517 Downloads
  • Zeigerbeschleunigung verbessern

    • eukalyptus
    • 1. Dezember 2013 um 18:49

    Auf msdn.com steht bei SPI_SETMOUSE folgende Beschreibung:
    Sets the two mouse threshold values and the mouse acceleration. The pvParam parameter must point to an array of three integers that specifies these values

    Mit SPI_SETMOUSE setzt man also gleichzeitig 3 Parameter.

    Zunächst reservieren wir den Speicherplatz für diese 3 Parameter vom Typ Integer:

    [autoit]

    Global $tVal = DllStructCreate("int[3];")

    [/autoit]


    Mit folgender Funktion erhalten wir die Position im Speicher. (die wir nacher an _WinAPI_SystemParametersInfo übergeben müssen):

    [autoit]

    DllStructGetPtr($tVal)

    [/autoit]


    Wir haben keine Ahnung, was die ersten 2 Parameter (two mouse threshold values) genau machen, geschweigen denn welchen Wert wir diesen zuweisen sollen.
    Darum lesen wir zuerst die aktuellen Werte aus:

    [autoit]

    _WinAPI_SystemParametersInfo($SPI_GETMOUSE, 0, DllStructGetPtr($tVal))

    [/autoit]

    Die aktuellen Werte wurden nun in den Speicher geschrieben.


    Der Wert für die Zeigerbeschleunigung liegt an dritter Position im Speicher und kann die Werte 0 oder 1 annehmen.

    Wir lesen den Wert nun aus und schreiben den gegenteiliegen Wert wieder zurück:

    [autoit]

    DllStructSetData($tVal, 1, Not DllStructGetData($tVal, 1, 3), 3)

    [/autoit]

    Mit Not wird in diesem Fall aus 0=1 bzw. 1=0


    Nun setzen wir die veränderten Parameter:

    [autoit]

    _WinAPI_SystemParametersInfo($SPI_SETMOUSE, 0, DllStructGetPtr($tVal))

    [/autoit]

    Alles klar? ^^

  • Zeigerbeschleunigung verbessern

    • eukalyptus
    • 30. November 2013 um 12:02
    [autoit]

    #include <WinAPI.au3>

    [/autoit][autoit][/autoit][autoit]

    Global Const $SPI_GETMOUSE = 0x0003
    Global Const $SPI_SETMOUSE = 0x0004

    [/autoit][autoit][/autoit][autoit]

    Global $tVal = DllStructCreate("int[3];")

    [/autoit][autoit][/autoit][autoit]

    _WinAPI_SystemParametersInfo($SPI_GETMOUSE, 0, DllStructGetPtr($tVal))

    [/autoit][autoit][/autoit][autoit]

    DllStructSetData($tVal, 1, Not DllStructGetData($tVal, 1, 3), 3)
    _WinAPI_SystemParametersInfo($SPI_SETMOUSE, 0, DllStructGetPtr($tVal))

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Switch DllStructGetData($tVal, 1, 3)
    Case 1
    MsgBox(0, "", "Zeigerbeschleunigung Ein")
    Case Else
    MsgBox(0, "", "Zeigerbeschleunigung Aus")
    EndSwitch

    [/autoit]

    lgE

  • [RegEx] Suche RegEx für Whitespace + Parameter (alles gelöst)

    • eukalyptus
    • 3. Oktober 2013 um 07:03

    So?

    StringRegExpReplace($sSrc, '(\s)|(["][^"]*["]|' & "['][^']*['])", "$2")

    E

  • Kleines GDI+ Beispiel: XOR Textur

    • eukalyptus
    • 23. September 2013 um 21:28

    Ich fürchte, das haben wir übersehen!

    Sollten wir unbedingt noch mitnehmen.

    Könnte man aber auch statt TextureCreate2 nehmen und mit optionalem ImgAttributes-Parameter versehen...
    Falls dies keine Performanceverschlechterung bedeutet!

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™