From 3a7260b784a3c4f96bf9bb7782d9d19472f406ef Mon Sep 17 00:00:00 2001 From: Michael Fabian Dirks Date: Sun, 17 May 2015 11:54:23 +0200 Subject: [PATCH] Initial Commit --- Blitz/BlitzPointer.decls | 383 +++++++++++++++++++++++++++++++++++ Blitz/BlitzPointer.ipf | 21 ++ Blitz/Example01.bb | 56 +++++ Blitz/Example02.bb | 42 ++++ Blitz/Example03.bb | 73 +++++++ Blitz/Example04.bb | 112 ++++++++++ Blitz/Example05.bb | 58 ++++++ Blitz/Example06.bb | 103 ++++++++++ Blitz/Example07.bb | 299 +++++++++++++++++++++++++++ Blitz/Example_Shared.bb | 67 ++++++ BlitzHybrid.cpp | 134 ++++++++++++ BlitzNative.cpp | 75 +++++++ BlitzPointer.cpp | 47 +++++ BlitzPointer.h | 18 ++ BlitzPointer.vcxproj | 193 ++++++++++++++++++ BlitzPointer.vcxproj.filters | 70 +++++++ BlitzPointer.vcxproj.user | 4 + MemoryHelpers.cpp | 74 +++++++ dllmain.cpp | 16 ++ dllmain.h | 12 ++ 20 files changed, 1857 insertions(+) create mode 100644 Blitz/BlitzPointer.decls create mode 100644 Blitz/BlitzPointer.ipf create mode 100644 Blitz/Example01.bb create mode 100644 Blitz/Example02.bb create mode 100644 Blitz/Example03.bb create mode 100644 Blitz/Example04.bb create mode 100644 Blitz/Example05.bb create mode 100644 Blitz/Example06.bb create mode 100644 Blitz/Example07.bb create mode 100644 Blitz/Example_Shared.bb create mode 100644 BlitzHybrid.cpp create mode 100644 BlitzNative.cpp create mode 100644 BlitzPointer.cpp create mode 100644 BlitzPointer.h create mode 100644 BlitzPointer.vcxproj create mode 100644 BlitzPointer.vcxproj.filters create mode 100644 BlitzPointer.vcxproj.user create mode 100644 MemoryHelpers.cpp create mode 100644 dllmain.cpp create mode 100644 dllmain.h diff --git a/Blitz/BlitzPointer.decls b/Blitz/BlitzPointer.decls new file mode 100644 index 0000000..fe08a06 --- /dev/null +++ b/Blitz/BlitzPointer.decls @@ -0,0 +1,383 @@ +.lib "BlitzPointer.dll" + +; Memory Modification +PeekMemoryByte%(lpMemoryPointer%) +PeekMemoryShort%(lpMemoryPointer%) +PeekMemoryInt%(lpMemoryPointer%) +PeekMemoryFloat#(lpMemoryPointer%) +PeekMemory(lpMemoryPointer%, iLength%, lpBank*) +PokeMemoryByte(lpMemoryPointer%, value%) +PokeMemoryShort(lpMemoryPointer%, value%) +PokeMemoryInt(lpMemoryPointer%, value%) +PokeMemoryFloat(lpMemoryPointer%, value#) +PokeMemory(lpMemoryPointer%, iLength%, lpBank*) + +; BlitzPointer +BlitzPointer_GetReturnAddress%() +BlitzPointer_GetFunctionPointer%() + +; Function Calling +BlitzPointer_CallFunctionV(lpFunctionPointer%) : "BlitzPointer_CallFunction0" +BlitzPointer_CallFunctionVI(lpFunctionPointer%, P1%) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionVII(lpFunctionPointer%, p1%, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVIII(lpFunctionPointer%, p1%, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIIII(lpFunctionPointer%, p1%, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIIF(lpFunctionPointer%, p1%, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIIP(lpFunctionPointer%, p1%, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIF(lpFunctionPointer%, p1%, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIIFI(lpFunctionPointer%, p1%, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIFF(lpFunctionPointer%, p1%, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIFP(lpFunctionPointer%, p1%, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIP(lpFunctionPointer%, p1%, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIIPI(lpFunctionPointer%, p1%, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIPF(lpFunctionPointer%, p1%, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIIPP(lpFunctionPointer%, p1%, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIF(lpFunctionPointer%, p1%, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVIFI(lpFunctionPointer%, p1%, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIFII(lpFunctionPointer%, p1%, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFIF(lpFunctionPointer%, p1%, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFIP(lpFunctionPointer%, p1%, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFF(lpFunctionPointer%, p1%, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIFFI(lpFunctionPointer%, p1%, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFFF(lpFunctionPointer%, p1%, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFFP(lpFunctionPointer%, p1%, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFP(lpFunctionPointer%, p1%, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIFPI(lpFunctionPointer%, p1%, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFPF(lpFunctionPointer%, p1%, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIFPP(lpFunctionPointer%, p1%, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIP(lpFunctionPointer%, p1%, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVIPI(lpFunctionPointer%, p1%, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIPII(lpFunctionPointer%, p1%, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPIF(lpFunctionPointer%, p1%, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPIP(lpFunctionPointer%, p1%, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPF(lpFunctionPointer%, p1%, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIPFI(lpFunctionPointer%, p1%, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPFF(lpFunctionPointer%, p1%, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPFP(lpFunctionPointer%, p1%, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPP(lpFunctionPointer%, p1%, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVIPPI(lpFunctionPointer%, p1%, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPPF(lpFunctionPointer%, p1%, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVIPPP(lpFunctionPointer%, p1%, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVF(lpFunctionPointer%, P1#) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionVFI(lpFunctionPointer%, p1#, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVFII(lpFunctionPointer%, p1#, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFIII(lpFunctionPointer%, p1#, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIIF(lpFunctionPointer%, p1#, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIIP(lpFunctionPointer%, p1#, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIF(lpFunctionPointer%, p1#, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFIFI(lpFunctionPointer%, p1#, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIFF(lpFunctionPointer%, p1#, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIFP(lpFunctionPointer%, p1#, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIP(lpFunctionPointer%, p1#, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFIPI(lpFunctionPointer%, p1#, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIPF(lpFunctionPointer%, p1#, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFIPP(lpFunctionPointer%, p1#, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFF(lpFunctionPointer%, p1#, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVFFI(lpFunctionPointer%, p1#, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFFII(lpFunctionPointer%, p1#, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFIF(lpFunctionPointer%, p1#, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFIP(lpFunctionPointer%, p1#, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFF(lpFunctionPointer%, p1#, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFFFI(lpFunctionPointer%, p1#, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFFF(lpFunctionPointer%, p1#, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFFP(lpFunctionPointer%, p1#, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFP(lpFunctionPointer%, p1#, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFFPI(lpFunctionPointer%, p1#, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFPF(lpFunctionPointer%, p1#, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFFPP(lpFunctionPointer%, p1#, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFP(lpFunctionPointer%, p1#, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVFPI(lpFunctionPointer%, p1#, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFPII(lpFunctionPointer%, p1#, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPIF(lpFunctionPointer%, p1#, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPIP(lpFunctionPointer%, p1#, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPF(lpFunctionPointer%, p1#, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFPFI(lpFunctionPointer%, p1#, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPFF(lpFunctionPointer%, p1#, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPFP(lpFunctionPointer%, p1#, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPP(lpFunctionPointer%, p1#, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVFPPI(lpFunctionPointer%, p1#, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPPF(lpFunctionPointer%, p1#, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVFPPP(lpFunctionPointer%, p1#, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVP(lpFunctionPointer%, P1*) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionVPI(lpFunctionPointer%, p1*, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVPII(lpFunctionPointer%, p1*, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPIII(lpFunctionPointer%, p1*, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIIF(lpFunctionPointer%, p1*, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIIP(lpFunctionPointer%, p1*, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIF(lpFunctionPointer%, p1*, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPIFI(lpFunctionPointer%, p1*, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIFF(lpFunctionPointer%, p1*, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIFP(lpFunctionPointer%, p1*, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIP(lpFunctionPointer%, p1*, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPIPI(lpFunctionPointer%, p1*, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIPF(lpFunctionPointer%, p1*, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPIPP(lpFunctionPointer%, p1*, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPF(lpFunctionPointer%, p1*, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVPFI(lpFunctionPointer%, p1*, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPFII(lpFunctionPointer%, p1*, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFIF(lpFunctionPointer%, p1*, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFIP(lpFunctionPointer%, p1*, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFF(lpFunctionPointer%, p1*, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPFFI(lpFunctionPointer%, p1*, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFFF(lpFunctionPointer%, p1*, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFFP(lpFunctionPointer%, p1*, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFP(lpFunctionPointer%, p1*, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPFPI(lpFunctionPointer%, p1*, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFPF(lpFunctionPointer%, p1*, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPFPP(lpFunctionPointer%, p1*, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPP(lpFunctionPointer%, p1*, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionVPPI(lpFunctionPointer%, p1*, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPPII(lpFunctionPointer%, p1*, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPIF(lpFunctionPointer%, p1*, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPIP(lpFunctionPointer%, p1*, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPF(lpFunctionPointer%, p1*, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPPFI(lpFunctionPointer%, p1*, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPFF(lpFunctionPointer%, p1*, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPFP(lpFunctionPointer%, p1*, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPP(lpFunctionPointer%, p1*, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionVPPPI(lpFunctionPointer%, p1*, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPPF(lpFunctionPointer%, p1*, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionVPPPP(lpFunctionPointer%, p1*, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionI%(lpFunctionPointer%) : "BlitzPointer_CallFunction0" +BlitzPointer_CallFunctionII%(lpFunctionPointer%, P1%) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionIII%(lpFunctionPointer%, p1%, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIIII%(lpFunctionPointer%, p1%, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIIII%(lpFunctionPointer%, p1%, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIIF%(lpFunctionPointer%, p1%, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIIP%(lpFunctionPointer%, p1%, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIF%(lpFunctionPointer%, p1%, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIIFI%(lpFunctionPointer%, p1%, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIFF%(lpFunctionPointer%, p1%, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIFP%(lpFunctionPointer%, p1%, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIP%(lpFunctionPointer%, p1%, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIIPI%(lpFunctionPointer%, p1%, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIPF%(lpFunctionPointer%, p1%, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIIPP%(lpFunctionPointer%, p1%, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIF%(lpFunctionPointer%, p1%, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIIFI%(lpFunctionPointer%, p1%, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIFII%(lpFunctionPointer%, p1%, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFIF%(lpFunctionPointer%, p1%, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFIP%(lpFunctionPointer%, p1%, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFF%(lpFunctionPointer%, p1%, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIFFI%(lpFunctionPointer%, p1%, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFFF%(lpFunctionPointer%, p1%, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFFP%(lpFunctionPointer%, p1%, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFP%(lpFunctionPointer%, p1%, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIFPI%(lpFunctionPointer%, p1%, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFPF%(lpFunctionPointer%, p1%, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIFPP%(lpFunctionPointer%, p1%, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIP%(lpFunctionPointer%, p1%, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIIPI%(lpFunctionPointer%, p1%, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIPII%(lpFunctionPointer%, p1%, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPIF%(lpFunctionPointer%, p1%, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPIP%(lpFunctionPointer%, p1%, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPF%(lpFunctionPointer%, p1%, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIPFI%(lpFunctionPointer%, p1%, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPFF%(lpFunctionPointer%, p1%, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPFP%(lpFunctionPointer%, p1%, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPP%(lpFunctionPointer%, p1%, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIIPPI%(lpFunctionPointer%, p1%, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPPF%(lpFunctionPointer%, p1%, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIIPPP%(lpFunctionPointer%, p1%, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIF%(lpFunctionPointer%, P1#) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionIFI%(lpFunctionPointer%, p1#, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIFII%(lpFunctionPointer%, p1#, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFIII%(lpFunctionPointer%, p1#, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIIF%(lpFunctionPointer%, p1#, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIIP%(lpFunctionPointer%, p1#, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIF%(lpFunctionPointer%, p1#, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFIFI%(lpFunctionPointer%, p1#, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIFF%(lpFunctionPointer%, p1#, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIFP%(lpFunctionPointer%, p1#, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIP%(lpFunctionPointer%, p1#, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFIPI%(lpFunctionPointer%, p1#, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIPF%(lpFunctionPointer%, p1#, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFIPP%(lpFunctionPointer%, p1#, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFF%(lpFunctionPointer%, p1#, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIFFI%(lpFunctionPointer%, p1#, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFFII%(lpFunctionPointer%, p1#, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFIF%(lpFunctionPointer%, p1#, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFIP%(lpFunctionPointer%, p1#, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFF%(lpFunctionPointer%, p1#, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFFFI%(lpFunctionPointer%, p1#, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFFF%(lpFunctionPointer%, p1#, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFFP%(lpFunctionPointer%, p1#, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFP%(lpFunctionPointer%, p1#, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFFPI%(lpFunctionPointer%, p1#, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFPF%(lpFunctionPointer%, p1#, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFFPP%(lpFunctionPointer%, p1#, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFP%(lpFunctionPointer%, p1#, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIFPI%(lpFunctionPointer%, p1#, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFPII%(lpFunctionPointer%, p1#, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPIF%(lpFunctionPointer%, p1#, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPIP%(lpFunctionPointer%, p1#, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPF%(lpFunctionPointer%, p1#, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFPFI%(lpFunctionPointer%, p1#, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPFF%(lpFunctionPointer%, p1#, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPFP%(lpFunctionPointer%, p1#, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPP%(lpFunctionPointer%, p1#, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIFPPI%(lpFunctionPointer%, p1#, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPPF%(lpFunctionPointer%, p1#, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIFPPP%(lpFunctionPointer%, p1#, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIP%(lpFunctionPointer%, P1*) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionIPI%(lpFunctionPointer%, p1*, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIPII%(lpFunctionPointer%, p1*, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPIII%(lpFunctionPointer%, p1*, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIIF%(lpFunctionPointer%, p1*, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIIP%(lpFunctionPointer%, p1*, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIF%(lpFunctionPointer%, p1*, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPIFI%(lpFunctionPointer%, p1*, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIFF%(lpFunctionPointer%, p1*, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIFP%(lpFunctionPointer%, p1*, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIP%(lpFunctionPointer%, p1*, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPIPI%(lpFunctionPointer%, p1*, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIPF%(lpFunctionPointer%, p1*, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPIPP%(lpFunctionPointer%, p1*, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPF%(lpFunctionPointer%, p1*, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIPFI%(lpFunctionPointer%, p1*, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPFII%(lpFunctionPointer%, p1*, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFIF%(lpFunctionPointer%, p1*, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFIP%(lpFunctionPointer%, p1*, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFF%(lpFunctionPointer%, p1*, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPFFI%(lpFunctionPointer%, p1*, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFFF%(lpFunctionPointer%, p1*, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFFP%(lpFunctionPointer%, p1*, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFP%(lpFunctionPointer%, p1*, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPFPI%(lpFunctionPointer%, p1*, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFPF%(lpFunctionPointer%, p1*, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPFPP%(lpFunctionPointer%, p1*, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPP%(lpFunctionPointer%, p1*, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionIPPI%(lpFunctionPointer%, p1*, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPPII%(lpFunctionPointer%, p1*, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPIF%(lpFunctionPointer%, p1*, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPIP%(lpFunctionPointer%, p1*, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPF%(lpFunctionPointer%, p1*, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPPFI%(lpFunctionPointer%, p1*, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPFF%(lpFunctionPointer%, p1*, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPFP%(lpFunctionPointer%, p1*, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPP%(lpFunctionPointer%, p1*, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionIPPPI%(lpFunctionPointer%, p1*, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPPF%(lpFunctionPointer%, p1*, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionIPPPP%(lpFunctionPointer%, p1*, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionF#(lpFunctionPointer%) : "BlitzPointer_CallFunction0" +BlitzPointer_CallFunctionFI#(lpFunctionPointer%, P1%) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionFII#(lpFunctionPointer%, p1%, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFIII#(lpFunctionPointer%, p1%, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIIII#(lpFunctionPointer%, p1%, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIIF#(lpFunctionPointer%, p1%, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIIP#(lpFunctionPointer%, p1%, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIF#(lpFunctionPointer%, p1%, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIIFI#(lpFunctionPointer%, p1%, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIFF#(lpFunctionPointer%, p1%, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIFP#(lpFunctionPointer%, p1%, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIP#(lpFunctionPointer%, p1%, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIIPI#(lpFunctionPointer%, p1%, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIPF#(lpFunctionPointer%, p1%, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIIPP#(lpFunctionPointer%, p1%, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIF#(lpFunctionPointer%, p1%, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFIFI#(lpFunctionPointer%, p1%, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIFII#(lpFunctionPointer%, p1%, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFIF#(lpFunctionPointer%, p1%, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFIP#(lpFunctionPointer%, p1%, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFF#(lpFunctionPointer%, p1%, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIFFI#(lpFunctionPointer%, p1%, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFFF#(lpFunctionPointer%, p1%, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFFP#(lpFunctionPointer%, p1%, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFP#(lpFunctionPointer%, p1%, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIFPI#(lpFunctionPointer%, p1%, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFPF#(lpFunctionPointer%, p1%, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIFPP#(lpFunctionPointer%, p1%, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIP#(lpFunctionPointer%, p1%, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFIPI#(lpFunctionPointer%, p1%, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIPII#(lpFunctionPointer%, p1%, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPIF#(lpFunctionPointer%, p1%, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPIP#(lpFunctionPointer%, p1%, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPF#(lpFunctionPointer%, p1%, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIPFI#(lpFunctionPointer%, p1%, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPFF#(lpFunctionPointer%, p1%, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPFP#(lpFunctionPointer%, p1%, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPP#(lpFunctionPointer%, p1%, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFIPPI#(lpFunctionPointer%, p1%, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPPF#(lpFunctionPointer%, p1%, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFIPPP#(lpFunctionPointer%, p1%, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFF#(lpFunctionPointer%, P1#) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionFFI#(lpFunctionPointer%, p1#, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFFII#(lpFunctionPointer%, p1#, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFIII#(lpFunctionPointer%, p1#, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIIF#(lpFunctionPointer%, p1#, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIIP#(lpFunctionPointer%, p1#, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIF#(lpFunctionPointer%, p1#, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFIFI#(lpFunctionPointer%, p1#, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIFF#(lpFunctionPointer%, p1#, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIFP#(lpFunctionPointer%, p1#, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIP#(lpFunctionPointer%, p1#, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFIPI#(lpFunctionPointer%, p1#, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIPF#(lpFunctionPointer%, p1#, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFIPP#(lpFunctionPointer%, p1#, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFF#(lpFunctionPointer%, p1#, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFFFI#(lpFunctionPointer%, p1#, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFFII#(lpFunctionPointer%, p1#, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFIF#(lpFunctionPointer%, p1#, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFIP#(lpFunctionPointer%, p1#, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFF#(lpFunctionPointer%, p1#, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFFFI#(lpFunctionPointer%, p1#, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFFF#(lpFunctionPointer%, p1#, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFFP#(lpFunctionPointer%, p1#, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFP#(lpFunctionPointer%, p1#, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFFPI#(lpFunctionPointer%, p1#, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFPF#(lpFunctionPointer%, p1#, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFFPP#(lpFunctionPointer%, p1#, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFP#(lpFunctionPointer%, p1#, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFFPI#(lpFunctionPointer%, p1#, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFPII#(lpFunctionPointer%, p1#, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPIF#(lpFunctionPointer%, p1#, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPIP#(lpFunctionPointer%, p1#, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPF#(lpFunctionPointer%, p1#, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFPFI#(lpFunctionPointer%, p1#, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPFF#(lpFunctionPointer%, p1#, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPFP#(lpFunctionPointer%, p1#, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPP#(lpFunctionPointer%, p1#, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFFPPI#(lpFunctionPointer%, p1#, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPPF#(lpFunctionPointer%, p1#, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFFPPP#(lpFunctionPointer%, p1#, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFP#(lpFunctionPointer%, P1*) : "BlitzPointer_CallFunction1" +BlitzPointer_CallFunctionFPI#(lpFunctionPointer%, p1*, p2%) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFPII#(lpFunctionPointer%, p1*, p2%, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPIII#(lpFunctionPointer%, p1*, p2%, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIIF#(lpFunctionPointer%, p1*, p2%, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIIP#(lpFunctionPointer%, p1*, p2%, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIF#(lpFunctionPointer%, p1*, p2%, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPIFI#(lpFunctionPointer%, p1*, p2%, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIFF#(lpFunctionPointer%, p1*, p2%, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIFP#(lpFunctionPointer%, p1*, p2%, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIP#(lpFunctionPointer%, p1*, p2%, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPIPI#(lpFunctionPointer%, p1*, p2%, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIPF#(lpFunctionPointer%, p1*, p2%, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPIPP#(lpFunctionPointer%, p1*, p2%, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPF#(lpFunctionPointer%, p1*, p2#) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFPFI#(lpFunctionPointer%, p1*, p2#, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPFII#(lpFunctionPointer%, p1*, p2#, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFIF#(lpFunctionPointer%, p1*, p2#, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFIP#(lpFunctionPointer%, p1*, p2#, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFF#(lpFunctionPointer%, p1*, p2#, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPFFI#(lpFunctionPointer%, p1*, p2#, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFFF#(lpFunctionPointer%, p1*, p2#, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFFP#(lpFunctionPointer%, p1*, p2#, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFP#(lpFunctionPointer%, p1*, p2#, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPFPI#(lpFunctionPointer%, p1*, p2#, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFPF#(lpFunctionPointer%, p1*, p2#, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPFPP#(lpFunctionPointer%, p1*, p2#, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPP#(lpFunctionPointer%, p1*, p2*) : "BlitzPointer_CallFunction2" +BlitzPointer_CallFunctionFPPI#(lpFunctionPointer%, p1*, p2*, p3%) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPPII#(lpFunctionPointer%, p1*, p2*, p3%, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPIF#(lpFunctionPointer%, p1*, p2*, p3%, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPIP#(lpFunctionPointer%, p1*, p2*, p3%, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPF#(lpFunctionPointer%, p1*, p2*, p3#) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPPFI#(lpFunctionPointer%, p1*, p2*, p3#, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPFF#(lpFunctionPointer%, p1*, p2*, p3#, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPFP#(lpFunctionPointer%, p1*, p2*, p3#, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPP#(lpFunctionPointer%, p1*, p2*, p3*) : "BlitzPointer_CallFunction3" +BlitzPointer_CallFunctionFPPPI#(lpFunctionPointer%, p1*, p2*, p3*, p4%) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPPF#(lpFunctionPointer%, p1*, p2*, p3*, p4#) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionFPPPP#(lpFunctionPointer%, p1*, p2*, p3*, p4*) : "BlitzPointer_CallFunction4" +BlitzPointer_CallFunctionS$(lpFunctionPointer%) : "BlitzPointer_CallFunctionT0" diff --git a/Blitz/BlitzPointer.ipf b/Blitz/BlitzPointer.ipf new file mode 100644 index 0000000..124c479 --- /dev/null +++ b/Blitz/BlitzPointer.ipf @@ -0,0 +1,21 @@ +[IDEal Project file] + + Version="1" + Expanded="True" + Icon="" + MainFile="Example07.bb" + Compiler="Blitz3D" + CommandLine="" + + + + + AbsPath="\Example01.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example02.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example03.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example04.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example05.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example06.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example07.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + AbsPath="\Example_Shared.bb" PrjFolder="" Line="0" Column="0" Tip="0" Visible="False" + diff --git a/Blitz/Example01.bb b/Blitz/Example01.bb new file mode 100644 index 0000000..a629252 --- /dev/null +++ b/Blitz/Example01.bb @@ -0,0 +1,56 @@ +; ---------------------------------------------------------------------------- ; +; Example 1 - Retrieving Function Pointers +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks + +; If you don't know what a pointer is, I recommend googling it. + +; Blitz doesn't offer native ways of getting function pointers, nor would they +; work with anything but tailored ASM calls. So what can they be useful for? +; Here are some examples on what you can do: +; * Footprint-only Callbacks (no longer need to override functions) +; * Creating APIs that support multiple versions. + + +Include "Example_Shared.bb" +ExampleInit() + +; We begin by initalizing a variable to hold our pointer. Globals work best for +; this task as we don't have to use a function parameter. +Global fpOurFunction = 0 + +; Our function can be anything we want, however we must be able to call it once +; without effect before we can actually retrieve the function pointer. Why? +; Simple! The BlitzPointer_GetFunctionPointer traces the return address for the +; Blitz function signature - and thus can't work outside a function. +Function OurFunction() +; Let's begin by checking if we already have the pointer. Not required, but +; we do it anyway to save some scanning time on every call. + If fpOurFunction = 0 Then +; Now let us call the above mentioned function to retrieve the pointer. + fpOurFunction = BlitzPointer_GetFunctionPointer() +; Weether you use a Return or an Else is up to you. Return is technically +; faster in Blitz, as using Else causes a complex ASM construction. + Return + EndIf + +; For proof reasons, we show the pointer on the screen. + Text 0, 0, "Function Pointer" + Text 0,15, " 0x" + Replace(RSet(Hex(fpOurFunction),8)," ","0") +End Function +; Now we call our function once. Since there is no function pointer assigned +; it will return almost immediately. +OurFunction() + +While Not KeyHit(1) + ExampleUpdate() + + OurFunction() + + ExampleLoop() +Wend + +End +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example02.bb b/Blitz/Example02.bb new file mode 100644 index 0000000..1ec8537 --- /dev/null +++ b/Blitz/Example02.bb @@ -0,0 +1,42 @@ +; ---------------------------------------------------------------------------- ; +; Example 2 - Calling Functions (Beginner) +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks +; Prerequisite: Example 1 + +; Since we now know how to retrieve a function pointer, how about we call it? + +Include "Example_Shared.bb" +ExampleInit() + +Global fpOurFunction = 0 +Function OurFunction() + If fpOurFunction = 0 Then + fpOurFunction = BlitzPointer_GetFunctionPointer() + Return + EndIf + + Text 0, 0, "Function Pointer" + Text 0,15, " 0x" + Replace(RSet(Hex(fpOurFunction),8)," ","0") +End Function +OurFunction() + +While Not KeyHit(1) + ExampleUpdate() + +; BlitzPointer offers many ways of calling our function pointer. Each one +; describes different return types, parameter count and parameter types. +; Let's use the one that doesn't return a value for now. + BlitzPointer_CallFunctionV fpOurFunction +; Now if we run the program, instead of a fixed native call, we're calling a +; function pointer instead. Pretty useful in my opinion, especially for UI, +; networking, fake classes, etc. +; We'll talk about the other ways of calling a function in Example 3. + + ExampleLoop() +Wend + +End +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example03.bb b/Blitz/Example03.bb new file mode 100644 index 0000000..040369c --- /dev/null +++ b/Blitz/Example03.bb @@ -0,0 +1,73 @@ +; ---------------------------------------------------------------------------- ; +; Example 3 - Calling Functions (Intermediate) +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks +; Prerequisite: Example 2 + +; BlitzPointer offers a lot of ways to call our function pointer. Each one +; describes return type, parameter count and parameter types. +; So, what magic can we do with those? + +; BlitzPointer supports three return types: +; ---------------------------------------------------------------------------- ; +; Type Id Description Calling Function +; ---------------------------------------------------------------------------- ; +; void V Nothing BlitzPointer_CallFunctionV +; int I 32-bit Integer BlitzPointer_CallFunctionI +; float F Floating Point BlitzPointer_CallFunctionF + +; Now that we know what we can and can't do (without memory leaks at least), +; let's try out the return types ourselves. + +Include "Example_Shared.bb" +ExampleInit() + +; 'void' function +Global fpVoidFunction = 0 +Function VoidFunction() + If fpVoidFunction = 0 Then + fpVoidFunction = BlitzPointer_GetFunctionPointer() + Return + EndIf + Text 0, 0, "Void Return Type" +End Function +VoidFunction() + +; 'int' function +Global fpIntFunction = 0 +Function IntFunction%() + If fpIntFunction = 0 Then + fpIntFunction = BlitzPointer_GetFunctionPointer() + Return + EndIf + Text 0, 15, "Int Return Type" + Return MilliSecs() +End Function +IntFunction() + +; 'float' function +Global fpFloatFunction = 0 +Function FloatFunction#() + If fpFloatFunction = 0 Then + fpFloatFunction = BlitzPointer_GetFunctionPointer() + Return + EndIf + Text 0, 30, "Float Return Type" + Return MilliSecs() / 1000.0 +End Function +FloatFunction() + +While Not KeyHit(1) + ExampleUpdate() + +; Calling the function and using the return value is really easy to do now: + BlitzPointer_CallFunctionV(fpVoidFunction) ; void returns nothing. + Text 200, 15, BlitzPointer_CallFunctionI(fpIntFunction) + Text 200, 30, BlitzPointer_CallFunctionF(fpFloatFunction) + + ExampleLoop() +Wend +End +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example04.bb b/Blitz/Example04.bb new file mode 100644 index 0000000..b21e325 --- /dev/null +++ b/Blitz/Example04.bb @@ -0,0 +1,112 @@ +; ---------------------------------------------------------------------------- ; +; Example 4 - Calling Functions (Advanced) +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks +; Prerequisite: Example 3 + +; Returned values aren't everything, don't you agree? That is why BlitzPointer +; offers you the ability to pass parameters too, even allowing you to pass Type +; Objects without having to use Handle() and Object() (both slow functions). +; At the time of writing this example, BlitzPointer supports four parameters at +; most - plenty of space to pass type objects and variables on. + +; There are three parameter types in Blitz that we can use: +; ---------------------------------------------------------------------------- ; +; Type Id Description Calling Function +; ---------------------------------------------------------------------------- ; +; int I 32-bit Integer BlitzPointer_CallFunction*I +; float F Floating Point BlitzPointer_CallFunction*F +; pointer P Memory Pointer BlitzPointer_CallFunction*P + +; Watch out: +; Calling a function that has parameters without giving enough parameters will +; fill those parameters with values that have been on the stack (and possibly +; corrupt the stack too - you never know). + +Include "Example_Shared.bb" +ExampleInit() + +; Example Function: Divide p1 by 60 and return the result. +Global fpCurInGameSecond = 0 +Function CurInGameSecond%(p1%=0) + If fpCurInGameSecond = 0 Then + fpCurInGameSecond = BlitzPointer_GetFunctionPointer() + Return + EndIf + Text 5, 15, "IIFunction" + Text 125, 15, p1 + + Return (p1 Shr 2) / 15 ; Division by 60 +End Function +CurInGameSecond() + +; Example Function: Multiply p1 by p2 and return the result. +Global fpCurInGameSecondEx = 0 +Function CurInGameSecondEx#(p1%=0, p2#=0) + If fpCurInGameSecondEx = 0 Then + fpCurInGameSecondEx = BlitzPointer_GetFunctionPointer() + Return + EndIf + + Text 5, 30, "FIFFunction" + Text 125, 30, p1 + Text 245, 30, p2 + + Return p1 * p2 +End Function +CurInGameSecondEx() + +; Example Function: Convert between Float and Int easily +; For this to work we must take and return a float. +Global fpConvertIntFloat +Function ConvertIntFloat#(p1#=0) + If fpConvertIntFloat = 0 Then + fpConvertIntFloat = BlitzPointer_GetFunctionPointer() + Print Hex(fpConvertIntFloat) + WaitKey() + Return + EndIf + + Return p1 +End Function +ConvertIntFloat() + +; Pointer-parameters are a bit trickier and require memory access, see UserLibs.txt. + +Local Frame% = 0 +While Not KeyHit(1) + ExampleUpdate() + + Text 0, 0, "Functions" + Text 120, 0, "Parameter 1" + Text 240, 0, "Parameter 2" + Text 360, 0, "Parameter 3" + Text 480, 0, "Parameter 4" + Text 600, 0, "Result" + + Text 605, 15, BlitzPointer_CallFunctionII(fpCurInGameSecond, Frame) + Text 605, 30, BlitzPointer_CallFunctionFIF(fpCurInGameSecondEx, Frame, 0.016666666) + + Local TempFlt# = Frame / 60.0 + Local TempInt% = BlitzPointer_CallFunctionIF(fpConvertIntFloat, TempFlt) + Text 5, 60, "Float -> Int" + Text 125, 60, TempFlt + Text 605, 60, Hex(TempInt) + + Text 5, 75, "Int -> Float" + Text 125, 75, Hex(TempInt) + Text 605, 75, BlitzPointer_CallFunctionFI(fpConvertIntFloat, TempInt) + + ExampleLoop() + + ; Allow us to pause execution + While KeyDown(57) + WaitTimer(Example_Timer) + Wend + + Frame=Frame+1 +Wend +End +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example05.bb b/Blitz/Example05.bb new file mode 100644 index 0000000..db24d55 --- /dev/null +++ b/Blitz/Example05.bb @@ -0,0 +1,58 @@ +; ---------------------------------------------------------------------------- ; +; Example 5 - Calling Functions (Advanced) +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks +; Prerequisite: Example 4 + +; In Blitz, there are only three real types: Int, Float and String - anything +; else is a pointer that can be represented using Int. That is why almost all +; Blitz functions return an Int. +; Using this knowledge we can try (and succeed) passing a Type Object into a +; function - using nothing more than the Int() function. + +Include "Example_Shared.bb" +ExampleInit() + +; We'll have to define a Type that can be passed to our function, any Type will +; do fine. +Type MyType + Field Test + Field Name$ +End Type + +; The function can be defined like any other Blitz function. +Global fpMyTypeFunc = 0 +Function MyTypeFunc(This.MyType) + If fpMyTypeFunc = 0 Then + fpMyTypeFunc = BlitzPointer_GetFunctionPointer() + Return + EndIf + If This = Null Then Return + + ; Display the content of the Type Object. + Text 0, Handle(This) * 15, This\Test + This\Name +End Function +MyTypeFunc(Null) + +; And create two testing objects. +Local MT1.MyType = New MyType +MT1\Test = 1 +MT1\Name = "First Object" + +Local MT2.MyType = New MyType +MT2\Name = "Second Object" + +While Not KeyHit(1) + ExampleUpdate() + +; Now in order to pass a Type Object to a function, we have to get a pointer +; from it. Thankfully, Blitz has this already built in: Int(). + If KeyDown(2) Then BlitzPointer_CallFunctionVI fpMyTypeFunc, Int(MT1) + If KeyDown(3) Then BlitzPointer_CallFunctionVI fpMyTypeFunc, Int(MT2) + + ExampleLoop() +Wend +End +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example06.bb b/Blitz/Example06.bb new file mode 100644 index 0000000..b63cadc --- /dev/null +++ b/Blitz/Example06.bb @@ -0,0 +1,103 @@ +; ---------------------------------------------------------------------------- ; +; Example 6 - Direct Memory Access +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks +; Prerequisite: Example 5 + +; --!-!!!-!-- +; This Example is aimed at Experts. You will most likely never need this. +; --!-!!!-!-- + +; BlitzPointer ships with functions for direct memory access, allowing you to +; modify things that were previously out of reach. The functions follow the +; typical style of Bank access, Peek and Poke: +; PeekMemoryByte%(MemoryAddress%) / PokeMemoryByte(MemoryAddress%, Value%) +; PeekMemoryShort%(MemoryAddress%) / PokeMemoryShort(MemoryAddress%, Value%) +; PeekMemoryInt%(MemoryAddress%) / PokeMemoryInt(MemoryAddress%, Value%) +; PeekMemoryFloat#(MemoryAddress%) / PokeMemoryFloat(MemoryAddress%, Value#) +; PeekMemory%(MemoryAddress%, Length%, Bank%) / PokeMemory%(MemoryAddress%, Length%, Bank%) +; This function allows you to directly read and write from memory into a Bank +; or from a Bank, saving you a few instructions per access. It will only read +; or write as many bytes as your Bank holds and returns the amount of read or +; written bytes. + +; These allow us to do simple direct memory modification, allowing us to do some +; things that were previously only possible using MemMove and MemCopy from +; the Windows libraries. + +; For example, Types in Blitz follow this structure: +; ---------------------------------------------------------------------------- ; +; Offset Type Description +; ---------------------------------------------------------------------------- ; +; 0 Pointer Pointer to Field Data +; 4 Pointer Next Type Object or Type Structure (Last Element Signal) +; 8 Pointer Prev Type Object or Type Structure (First Element Signal) +; 12 Pointer Type Structure +; 16 Integer Reference Count +; 20+ ... Your Field Data usually follows here. +; +; We can do some fun stuff with this information. + +; If you want to know more about the internal structure of Blitz, there are some +; resources that people have compiled in addition to the official source: +; Structures: http://www.blitzforum.de/forum/viewtopic.php?t=4320 +; Source Code: http://github.com/blitz-research/ + +Include "Example_Shared.bb" +ExampleInit() + +; Our Type will hold one of every Element. +Type EverythingType + Field MyInt% + Field MyFloat# + Field MyString$ + Field MyObject.EverythingType +; It is important to note that Blitz doesn't consider Arrays as pointers, but +; as solid blocks in memory instead. This is why we can't make them dynamic, +; and have to use Dim or Banks. + Field MyIntArray%[5] + Field MyFloatArray#[5] + Field MyStringArray$[5] + Field MyObjectArray.EverythingType[5] +End Type + +; And create a function that modifies only using pointers. +Global fpMyPointerFunction% = 0 +Function MyPointerFunction(Pointer%) + If fpMyPointerFunction = 0 Then + fpMyPointerFunction = BlitzPointer_GetFunctionPointer() + Return + EndIf + + ; Simple Memory modification + PokeMemoryInt Pointer + 20, PeekMemoryInt(Pointer + 20) + 1 + PokeMemoryFloat Pointer + 24, PeekMemoryFloat(Pointer + 24) + 1 + + ; Sick of reference counting? Do Circular References without incrementing that! + PokeMemoryInt Pointer + 32, Pointer +End Function +MyPointerFunction(0) + +Local Instance.EverythingType = New EverythingType + +While Not KeyHit(1) + ExampleUpdate() + + MyPointerFunction(Int(Instance)) + + Text 0, 0, "\MyInt" + Text 200, 0, Instance\MyInt + Text 0,15, "\MyFloat" + Text 200,15, Instance\MyFloat + ; Circular Reference + Text 0,45, "\MyObject\MyInt" + Text 200,45, Instance\MyObject\MyInt + Text 0,60, "\MyObject\MyObject\MyInt" + Text 200,60, Instance\MyObject\MyObject\MyInt + + ExampleLoop() +Wend +End +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example07.bb b/Blitz/Example07.bb new file mode 100644 index 0000000..01f1b10 --- /dev/null +++ b/Blitz/Example07.bb @@ -0,0 +1,299 @@ +; ---------------------------------------------------------------------------- ; +; Example 6 - Callbacks +; ---------------------------------------------------------------------------- ; +; License: Creative Commons Attribution 2.0 +; Author: Michael Fabian Dirks +; Prerequisite: Example 5 + +; In my opinion, Callbacks are one of the best things that people have figured +; out is useful. We can completely combine all our update logic into one single +; function call without ever having to worry about how to handle a new object. +; Well, unless you are a terrible planner anyways. + +Include "Example_Shared.bb" +ExampleInit() +SeedRnd MilliSecs() + +; We'll begin by creating a basic Type that holds our generic object. By itself +; this generic object does nothing, but we define custom callbacks later on. +; For optimization reasons (saves some memory) we can use a manually defined +; index for our callbacks. + +; Using an Index to store our Callbacks is more efficient that storing it for +; each entry. By doing this we can also have multiple functions that use the +; same structure (Update, PhysicsUpdate, Render, ...). It is wise to reserve +; the first index to check for incorrectly created objects. +Dim CallbackIndex(10) + +; Here we define our Type. Since each object has an Index, we +Type TGeneric +; For optimization reasons and saving memory, we just store a callback index. + Field Index + +; We only need to store the pointer to our Type object, nothing else. + Field Pointer +End Type + +Function TGenericUpdate() + Local This.TGeneric + For This = Each TGeneric + If This\Pointer <> 0 Then + If BlitzPointer_CallFunctionII(CallbackIndex(This\Index), This\Pointer) Then + Delete This + EndIf + EndIf + Next +End Function + +; TGeneric will call a function pointer with the following footprint: +; int FUNCTION(pointer) +; We will need to implement this function footprint in every callback. + +; Our first Type will hold Cubes that moves up and down. +Type TCube + ; Our TCube is represented by an actual Cube in the world, so let's store it. + Field Entity + ; This is the original position of the Cube. Y is dynamically modified in code. + Field PosX#, PosY#, PosZ# + ; And finally, the time it was created. + Field Time +End Type +; Assign an index to our new Type (starting at 1) +Const CALLBACK_INDEX_TCUBE% = 1 + +Function TCubeCreate.TCube(X#, Y#, Z#) + ; Create our Object + Local This.TCube = New TCube + This\Entity = CreateCube(Example_SceneRoot) + This\PosX = X + This\PosY = Y + This\PosZ = Z + This\Time = MilliSecs() + + ; And now store it withing TGeneric + Local TG.TGeneric = New TGeneric + TG\Index = CALLBACK_INDEX_TCUBE + ; To get the pointer we need (and can store), we just use Int() on the object. + TG\Pointer = Int(This) + + ; That's all we had to do. + Return This +End Function + +Function TCubeCallback%(This.TCube) + If CallbackIndex(CALLBACK_INDEX_TCUBE) = 0 Then + CallbackIndex(CALLBACK_INDEX_TCUBE) = BlitzPointer_GetFunctionPointer() + Return + EndIf + ; Safeguard against stupidity (it affect everyone). + If This = Null Then Return True + + Local TimeDiff = (MilliSecs() - This\Time) + + Local YOffset# = Cos((Cos(This\PosX) * 180) + (Sin(This\PosZ) * 180) + (TimeDiff / 10.0)) * 5 + 5 + PositionEntity This\Entity, This\PosX, This\PosY + YOffset, This\PosZ + EntityAlpha This\Entity, 1.0 - (TimeDiff / 5000.0) + + ; We will allow the object to exist for at most 5 seconds. + If TimeDiff > 5000 Then + TCubeDestroy(This) + Return True + EndIf + Return False +End Function + +Function TCubeDestroy(This.TCube) + ; Safeguard against stupidity (it affect everyone). + If This = Null Then Return + + FreeEntity This\Entity + Delete This +End Function + +; And call the function once to automagically register it as a callback. +TCubeCallback(Null) + +; Next up is our second Type. It will hold a simple sphere that grows over time. +Type TSphere + ; Again, represented by an actual Sphere in the world. + Field Entity + ; And the time it was created. + Field Time +End Type +; And we will assign the second index to it. +Const CALLBACK_INDEX_TSPHERE% = 2 + +Function TSphereCreate.TSphere(X#, Y#, Z#) + ; Initialize our TSphere instance. + Local This.TSphere = New TSphere + This\Entity = CreateSphere(32, Example_SceneRoot) + PositionEntity This\Entity, X, Y, Z + This\Time = MilliSecs() + + ; And now store it withing TGeneric + Local TG.TGeneric = New TGeneric + TG\Index = CALLBACK_INDEX_TSPHERE + TG\Pointer = Int(This) + + Return This +End Function + +Function TSphereUpdate%(This.TSphere) + If CallbackIndex(CALLBACK_INDEX_TSPHERE) = 0 Then + CallbackIndex(CALLBACK_INDEX_TSPHERE) = BlitzPointer_GetFunctionPointer() + Return + EndIf + ; Safeguard against stupidity (it affect everyone). + If This = Null Then Return True + + Local TimeDiff = (MilliSecs() - This\Time) + Local TimePrc# = TimeDiff / 2500.0 + + Local Stp#, StpSize# + Local R#, G#, B#, A#, Scale# + ;Step + StpSize# = 0.05:Stp# = 1.0 / (1.0 - StpSize) + R = Interp(1, 1, TimePrc * Stp) + G = Interp(1, 1, TimePrc * Stp) + B = Interp(1, 0, TimePrc * Stp) + ;Step + StpSize# = 0.20:Stp# = 1.0 / (1.0 - StpSize) + R = Interp(R, 1, (TimePrc - 0.05) * Stp) + G = Interp(G, 0.75, (TimePrc - 0.05) * Stp) + B = Interp(B, 0, (TimePrc - 0.05) * Stp) + ;Step + StpSize# = 0.25:Stp# = 1.0 / (1.0 - StpSize) + R = Interp(R, 1, (TimePrc - 0.25) * Stp) + G = Interp(G, 0, (TimePrc - 0.25) * Stp) + B = Interp(B, 0, (TimePrc - 0.25) * Stp) + ;Step + StpSize# = 0.50:Stp# = 1.0 / (1.0 - StpSize) + R = Interp(R, 0, (TimePrc - 0.50) * Stp) + G = Interp(G, 0, (TimePrc - 0.50) * Stp) + B = Interp(B, 0, (TimePrc - 0.50) * Stp) + + ;AlphaStop 1 at (0.8 of 1.0) + A = Interp(1, 0, (TimePrc - 0.8) * 5) + + Scale = Interp(1, 20, Sin(TimePrc * 90)) + ScaleEntity This\Entity, Scale,Scale,Scale + EntityColor This\Entity, R * 255, G * 255, B * 255 + EntityAlpha This\Entity, A + + ; We will allow the object to exist for at most 2.5 seconds. + If TimeDiff > 2500 Then + TSphereDestroy(This) + Return True + EndIf + Return False +End Function +TSphereUpdate(Null) + +Function TSphereDestroy(This.TSphere) + ; Safeguard against stupidity (it affect everyone). + If This = Null Then Return + + FreeEntity This\Entity + Delete This +End Function + +; And finally, a terrain that we can pick a spawning position from. +Local Terrain = CreateTerrain(256, Example_SceneRoot) +ScaleEntity Terrain, 1 / 256.0, 64, 1 / 256.0 +MoveEntity Terrain, -100, 0, -100 +ScaleEntity Terrain, 1 / 256.0 * 201, 64, 1 / 256.0 * 201 +EntityColor Terrain, 25, 92, 25 +TerrainShading Terrain, True +TerrainDetail Terrain, 32767, False +EntityPickMode Terrain, 2, True + +RandomTerrain(Terrain, 256, 8, 8) + +MoveEntity Example_Camera, 0, 0, -125 +;HideEntity Example_Floor + +While Not KeyHit(1) + TGenericUpdate() + + ; Space to randomize Terrain + If KeyHit(57) Then + RandomTerrain(Terrain, 256, Rand(1,8), Rand(1,8)) + EndIf + + Local ZDelta = MouseZSpeed() + If KeyHit(2) Or ZDelta > 0 Then + CameraPick(Example_Camera, MouseX(), MouseY()) + TCubeCreate(PickedX(), PickedY(), PickedZ()) + EndIf + + If KeyHit(3) Or ZDelta < 0 Then + CameraPick(Example_Camera, MouseX(), MouseY()) + TSphereCreate(PickedX(), PickedY(), PickedZ()) + EndIf + + ExampleUpdate() + ExampleLoop() + UpdateWorld() +Wend + +Function RandomTerrain(Terrain, GridSize, CellsX = 1, CellsZ = 1) + Local CellW, CellH, CellX, CellZ, TerX, TerZ, CellPrcX#, CellPrcZ# + Local HTL#, HTR#, HBL#, HBR#, HCC# + + CellW = Floor(GridSize / Float(CellsX)) + CellH = Floor(GridSize / Float(CellsZ)) + + Local RowSize = CellsZ + 1 + Local TempBankSize = (CellsX + 1) * RowSize * 4 + Local TempBank = CreateBank(TempBankSize) + For CellX = 0 To CellsX + For CellZ = 0 To CellsZ + PokeFloat TempBank, 4 * (CellX * RowSize + CellZ), Rnd(0, 1) + Next + Next + + Local OCellX, OCellZ:OCellX = -1: OCellZ = -1 + For TerX = 1 To (GridSize - 1) + CellX = Floor(TerX / Float(CellW)) + CellPrcX = (TerX Mod CellW) / Float(CellW - 1) + For TerZ = 1 To (GridSize - 1) + CellZ = Floor(TerZ / Float(CellH)) + CellPrcZ = (TerZ Mod CellH) / Float(CellH - 1) + ;DebugLog CellPrcZ + + If CellX <> OCellX Or CellZ <> OCellZ Then + HTL = PeekFloat(TempBank, 4 * (((CellX + 0) * RowSize + (CellZ + 0)))) + HTR = PeekFloat(TempBank, 4 * (((CellX + 1) * RowSize + (CellZ + 0)))) + HBL = PeekFloat(TempBank, 4 * (((CellX + 0) * RowSize + (CellZ + 1)))) + HBR = PeekFloat(TempBank, 4 * (((CellX + 1) * RowSize + (CellZ + 1)))) + OCellX = CellX:OCellZ = CellZ + EndIf + + Local PrcX#, PrcZ# + ; Normally, you'd use a bezier curve for this. + PrcX = (Sin(-90 + CellPrcX*180) * 0.5 + 0.5) + PrcZ = (Sin(-90 + CellPrcZ*180) * 0.5 + 0.5) + Local Height# = Interp(Interp(HTL, HTR, PrcX), Interp(HBL, HBR, PrcX), PrcZ) + + ModifyTerrain Terrain, TerX, TerZ, Height + Next + Next + FreeBank TempBank +End Function + +Function Min#(A#, B#) + If B < A Then Return B + Return A +End Function + +Function Max#(A#, B#) + If B > A Then Return B + Return A +End Function + +Function Interp#(L#, R#, Lerp#) + Lerp = Min(Max(Lerp, 0.0), 1.0) + Return L * (1.0 - Lerp) + R * Lerp +End Function +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/Blitz/Example_Shared.bb b/Blitz/Example_Shared.bb new file mode 100644 index 0000000..7487f90 --- /dev/null +++ b/Blitz/Example_Shared.bb @@ -0,0 +1,67 @@ +Global Example_Timer +; Camera +Global Example_Camera_YawPivot +Global Example_Camera_PitchPivot +Global Example_Camera +; Scene +Global Example_SceneRoot +Global Example_SceneLight +Global Example_Floor +Global Example_Block + +Function ExampleInit() + Example_Timer = CreateTimer(60) + + Graphics3D 1024, 768, 32, 2 + SetBuffer BackBuffer() + + Example_Camera_YawPivot = CreatePivot() + Example_Camera_PitchPivot = CreatePivot(Example_Camera_YawPivot) + Example_Camera = CreateCamera(Example_Camera_PitchPivot) + MoveEntity Example_Camera, 0, 0, -20 + TurnEntity Example_Camera_PitchPivot, 30, 0, 0 + + Example_SceneRoot = CreatePivot() + + AmbientLight 51, 51, 51 + Example_SceneLight = CreateLight(1, Example_SceneRoot) + RotateEntity Example_SceneLight, 70, 30, 0 + + Example_Floor = CreateCube(Example_SceneRoot) + EntityColor Example_Floor, 153, 255, 153 + EntityShininess Example_Floor, 1.0 + ScaleEntity Example_Floor, 100, 0.001, 100 + + ;Example_Block = CreateCube(Example_SceneRoot) + ;MoveEntity Example_Block, 0, 1, 0 +End Function + +Function ExampleUpdate() + Local MX#, MY# + + MX = (MouseX() - 512) / 512.0 + MY = (MouseY() - 384) / 384.0 + + If MouseHit(1) Then + MoveMouse 512, 384 + ElseIf MouseDown(1) Then + TurnEntity Example_Camera_YawPivot, 0, -MX, 0 + TurnEntity Example_Camera_PitchPivot, MY, 0, 0 + ;MoveMouse 512, 384 + EndIf + + If MouseHit(2) Then + MoveMouse 512, 384 + ElseIf MouseDown(2) Then + MoveEntity Example_Camera, 0, 0, MY + ;MoveMouse 512, 384 + EndIf + + RenderWorld +End Function + +Function ExampleLoop() + Flip 0:Cls:WaitTimer(Example_Timer) +End Function +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/BlitzHybrid.cpp b/BlitzHybrid.cpp new file mode 100644 index 0000000..588c549 --- /dev/null +++ b/BlitzHybrid.cpp @@ -0,0 +1,134 @@ +#include "BlitzPointer.h" + +// Hybrid specific defines. +#define CALLFUNCTION_DECL_BEGIN_64(NAME) DLL_EXPORT int64_t BlitzPointer_CallFunction##NAME(intptr_t lpFunctionPointer +#define CALLFUNCTION_IMPL_PARAMETER_64(INDEX, NAME) __asm MOV RAX, [NAME] __asm mov [esp + INDEX * 4], RAX +#define CALLFUNCTION_IMPL_CALL_64() __asm CALL QWORD ptr[lpFunctionPointer] +#define CALLFUNCTION_IMPL_RESULT_64() int64_t result; __asm MOV [result], RAX + +/* +// No Parameters +CALLFUNCTION_DECL_BEGIN_64(Q0) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_CALL_64() + CALLFUNCTION_IMPL_RESULT_64() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +// One Parameter +CALLFUNCTION_DECL_BEGIN_64(Q1D) + CALLFUNCTION_DECL_PARAMETER(int32_t, p1) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_PREPARE(1) + CALLFUNCTION_IMPL_PARAMETER(0, p1) + CALLFUNCTION_IMPL_CALL_64() + CALLFUNCTION_IMPL_RESULT_64() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN_64(Q1Q) + CALLFUNCTION_DECL_PARAMETER(int64_t, p1) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_PREPARE(1) + CALLFUNCTION_IMPL_PARAMETER_64(0, p1) + CALLFUNCTION_IMPL_CALL_64() + CALLFUNCTION_IMPL_RESULT_64() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +// Two Parameters +CALLFUNCTION_DECL_BEGIN(D2DQ) +CALLFUNCTION_DECL_PARAMETER(int32_t, p1) +CALLFUNCTION_DECL_PARAMETER(int64_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER_64(1, p2) +CALLFUNCTION_IMPL_PARAMETER(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN(D2QD) +CALLFUNCTION_DECL_PARAMETER(int64_t, p1) +CALLFUNCTION_DECL_PARAMETER(int32_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER(1, p2) +CALLFUNCTION_IMPL_PARAMETER_64(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN(D2QQ) +CALLFUNCTION_DECL_PARAMETER(int64_t, p1) +CALLFUNCTION_DECL_PARAMETER(int64_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER_64(1, p2) +CALLFUNCTION_IMPL_PARAMETER_64(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN_64(Q2DD) +CALLFUNCTION_DECL_PARAMETER(int32_t, p1) +CALLFUNCTION_DECL_PARAMETER(int64_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER_64(1, p2) +CALLFUNCTION_IMPL_PARAMETER(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT_64() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN_64(Q2DQ) +CALLFUNCTION_DECL_PARAMETER(int32_t, p1) +CALLFUNCTION_DECL_PARAMETER(int64_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER_64(1, p2) +CALLFUNCTION_IMPL_PARAMETER(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT_64() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN_64(Q2QD) +CALLFUNCTION_DECL_PARAMETER(int64_t, p1) +CALLFUNCTION_DECL_PARAMETER(int32_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER(1, p2) +CALLFUNCTION_IMPL_PARAMETER_64(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT_64() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +CALLFUNCTION_DECL_BEGIN_64(Q2QQ) +CALLFUNCTION_DECL_PARAMETER(int64_t, p1) +CALLFUNCTION_DECL_PARAMETER(int64_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() +CALLFUNCTION_IMPL_SAFEGUARD() +CALLFUNCTION_IMPL_PREPARE(2) +CALLFUNCTION_IMPL_PARAMETER_64(1, p2) +CALLFUNCTION_IMPL_PARAMETER_64(0, p1) +CALLFUNCTION_IMPL_CALL() +CALLFUNCTION_IMPL_RESULT_64() +CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() + +*/ \ No newline at end of file diff --git a/BlitzNative.cpp b/BlitzNative.cpp new file mode 100644 index 0000000..cb2c1ae --- /dev/null +++ b/BlitzNative.cpp @@ -0,0 +1,75 @@ +#include "BlitzPointer.h" + +// No Parameters +CALLFUNCTION_DECL_BEGIN(0) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_CALL() + CALLFUNCTION_IMPL_RESULT() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() +#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction0=_BlitzPointer_CallFunction0@4") + +// One Parameter +CALLFUNCTION_DECL_BEGIN(1) + CALLFUNCTION_DECL_PARAMETER(int32_t, p1) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_PREPARE(1) + CALLFUNCTION_IMPL_PARAMETER(0, p1) + CALLFUNCTION_IMPL_CALL() + CALLFUNCTION_IMPL_RESULT() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() +#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction1=_BlitzPointer_CallFunction1@8") + +// Two Parameters +CALLFUNCTION_DECL_BEGIN(2) + CALLFUNCTION_DECL_PARAMETER(int32_t, p1) + CALLFUNCTION_DECL_PARAMETER(int32_t, p2) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_PREPARE(2) + CALLFUNCTION_IMPL_PARAMETER(1, p2) + CALLFUNCTION_IMPL_PARAMETER(0, p1) + CALLFUNCTION_IMPL_CALL() + CALLFUNCTION_IMPL_RESULT() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() +#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction2=_BlitzPointer_CallFunction2@12") + +// Three Parameters +CALLFUNCTION_DECL_BEGIN(3) + CALLFUNCTION_DECL_PARAMETER(int32_t, p1) + CALLFUNCTION_DECL_PARAMETER(int32_t, p2) + CALLFUNCTION_DECL_PARAMETER(int32_t, p3) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_PREPARE(3) + CALLFUNCTION_IMPL_PARAMETER(2, p3) + CALLFUNCTION_IMPL_PARAMETER(1, p2) + CALLFUNCTION_IMPL_PARAMETER(0, p1) + CALLFUNCTION_IMPL_CALL() + CALLFUNCTION_IMPL_RESULT() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() +#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction3=_BlitzPointer_CallFunction3@16") + +// Four Parameters +CALLFUNCTION_DECL_BEGIN(4) + CALLFUNCTION_DECL_PARAMETER(int32_t, p1) + CALLFUNCTION_DECL_PARAMETER(int32_t, p2) + CALLFUNCTION_DECL_PARAMETER(int32_t, p3) + CALLFUNCTION_DECL_PARAMETER(int32_t, p4) +CALLFUNCTION_DECL_END() CALLFUNCTION_IMPL_BEGIN() + CALLFUNCTION_IMPL_SAFEGUARD() + CALLFUNCTION_IMPL_PREPARE(4) + CALLFUNCTION_IMPL_PARAMETER(3, p4) + CALLFUNCTION_IMPL_PARAMETER(2, p3) + CALLFUNCTION_IMPL_PARAMETER(1, p2) + CALLFUNCTION_IMPL_PARAMETER(0, p1) + CALLFUNCTION_IMPL_CALL() + CALLFUNCTION_IMPL_RESULT() + CALLFUNCTION_IMPL_RETURN() +CALLFUNCTION_IMPL_END() +#pragma comment(linker, "/EXPORT:BlitzPointer_CallFunction4=_BlitzPointer_CallFunction4@20") diff --git a/BlitzPointer.cpp b/BlitzPointer.cpp new file mode 100644 index 0000000..f9c5987 --- /dev/null +++ b/BlitzPointer.cpp @@ -0,0 +1,47 @@ +// Original Code by Noodoby +// Modified Code by Xaymar + +#include "BlitzPointer.h" + +DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress() { + intptr_t StackPointer, ReturnAddress; + + __asm { //ASM. Do touch if suicidal. + mov StackPointer, esp; // Store current Stack Pointer + mov esp, ebp; // On X86, EBP[0] is our own function and EBP[1] is the return address. + add esp, 4; // Which means that we can just take it from there into our own variable. + pop ReturnAddress; // Just like this. + mov esp, [StackPointer]; // And then reset the Stack Pointer. + } + + return ReturnAddress; +} +#pragma comment(linker, "/EXPORT:BlitzPointer_GetReturnAddress=_BlitzPointer_GetReturnAddress@0") + +DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer() +{ + intptr_t StackPointer, ReturnAddress; + + __asm { //ASM. Do touch if suicidal. + mov StackPointer, esp; // Store current Stack Pointer + mov esp, ebp; // On X86, EBP[0] is our own function and EBP[1] is the return address. + add esp, 4; // Which means that we can just take it from there into our own variable. + pop ReturnAddress; // Just like this. + mov esp, [StackPointer]; // And then reset the Stack Pointer. + } + + // Let's look backwards in memory for the function signature (0x53 0x56 0x57 0x55 0x89 0xE5) for at most one megabyte. + uint8_t* startPtr = (uint8_t*)ReturnAddress; + uint8_t* endPtr = (uint8_t*)(ReturnAddress - 1048576); + for (uint8_t* curPtr = startPtr; curPtr != endPtr; curPtr--) { + if (*(curPtr) == 0x53) // push ebx + if (*(curPtr + 1) == 0x56) // push esi + if (*(curPtr + 2) == 0x57) // push edi + if (*(curPtr + 3) == 0x55) // push ebp + if (*(curPtr + 4) == 0x89 && *(curPtr + 5) == 0xE5) // mov ebp,esp + return (intptr_t)curPtr; + } + + return 0; +} +#pragma comment(linker, "/EXPORT:BlitzPointer_GetFunctionPointer=_BlitzPointer_GetFunctionPointer@0") diff --git a/BlitzPointer.h b/BlitzPointer.h new file mode 100644 index 0000000..9539bb0 --- /dev/null +++ b/BlitzPointer.h @@ -0,0 +1,18 @@ +#include "dllmain.h" +#include + +DLL_EXPORT intptr_t BlitzPointer_GetReturnAddress(); +DLL_EXPORT intptr_t BlitzPointer_GetFunctionPointer(); + +// Defines for easier function generation. +#define CALLFUNCTION_DECL_BEGIN(NAME) DLL_EXPORT int32_t BlitzPointer_CallFunction##NAME(intptr_t lpFunctionPointer +#define CALLFUNCTION_DECL_PARAMETER(TYPE, NAME) , TYPE NAME +#define CALLFUNCTION_DECL_END() ) +#define CALLFUNCTION_IMPL_BEGIN() { +#define CALLFUNCTION_IMPL_SAFEGUARD() if (!lpFunctionPointer) return NULL; +#define CALLFUNCTION_IMPL_PREPARE(COUNT) __asm SUB ESP, COUNT * 4 +#define CALLFUNCTION_IMPL_PARAMETER(INDEX, NAME) __asm MOV EAX, [NAME] __asm MOV [ESP + INDEX * 4], EAX +#define CALLFUNCTION_IMPL_CALL() __asm CALL DWORD ptr[lpFunctionPointer] +#define CALLFUNCTION_IMPL_RESULT() int32_t result; __asm MOV [result], EAX +#define CALLFUNCTION_IMPL_RETURN() return result; +#define CALLFUNCTION_IMPL_END() } diff --git a/BlitzPointer.vcxproj b/BlitzPointer.vcxproj new file mode 100644 index 0000000..14beac7 --- /dev/null +++ b/BlitzPointer.vcxproj @@ -0,0 +1,193 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {AC8F52F4-9FE6-4CEF-B549-8180757020C8} + BlitzPointer + + + + DynamicLibrary + true + v120 + Unicode + + + DynamicLibrary + false + v120 + false + Unicode + + + + + + + + + + + + + $(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\ + $(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\ + .dll + true + $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); + + + $(SolutionDir)\#Build\$(ProjectName)\$(Configuration)\ + $(SolutionDir)\#Intermediate\$(ProjectName)\$(Configuration)\ + .dll + true + $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); + + + + Level3 + Disabled + + + $(SolutionDir);$(ProjectDir) + false + Default + MultiThreaded + false + false + false + false + 4Bytes + true + false + false + false + + + false + false + Disabled + false + StdCall + + + true + 1.0 + + + + + + + Level3 + Full + false + true + + + $(SolutionDir);$(ProjectDir) + false + Speed + MultiThreaded + false + false + false + 4Bytes + true + false + false + false + + + Default + false + AnySuitable + false + StdCall + + + false + + + + + 1.0 + + + + + + + false + false + + + + + + + + + + + + + BlitzPointer.decls + PreserveNewest + true + + + Examples\BlitzPointer.ipf + PreserveNewest + true + + + true + + + true + + + Examples\Example_Shared.bb + PreserveNewest + true + + + Examples\Example01.bb + PreserveNewest + true + + + Examples\Example02.bb + PreserveNewest + true + + + Examples\Example03.bb + PreserveNewest + true + + + Examples\Example04.bb + PreserveNewest + true + + + Examples\Example05.bb + PreserveNewest + true + + + + + + \ No newline at end of file diff --git a/BlitzPointer.vcxproj.filters b/BlitzPointer.vcxproj.filters new file mode 100644 index 0000000..7c9d04e --- /dev/null +++ b/BlitzPointer.vcxproj.filters @@ -0,0 +1,70 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {53eae672-7e3f-4de4-af1f-79e46e407a39} + false + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + Blitz Files + + + \ No newline at end of file diff --git a/BlitzPointer.vcxproj.user b/BlitzPointer.vcxproj.user new file mode 100644 index 0000000..ef5ff2a --- /dev/null +++ b/BlitzPointer.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/MemoryHelpers.cpp b/MemoryHelpers.cpp new file mode 100644 index 0000000..bccccfd --- /dev/null +++ b/MemoryHelpers.cpp @@ -0,0 +1,74 @@ +#include "dllmain.h" + +DLL_EXPORT uint32_t PeekMemory(intptr_t* address, uint32_t length, intptr_t bank) { + uint32_t bankAddress, bankSize; + bankAddress = *(uint32_t*)(bank + 4); + bankSize = *(uint32_t*)(bank + 8); + + // Limit reading to bank size. + length = (length > bankSize ? bankSize : length); + + for (uint32_t offset = 0; offset < length; offset++) { + *(int32_t*)(bankAddress + offset) = *(address + offset); + } + + return length; +} +#pragma comment(linker, "/EXPORT:PeekMemory=_PeekMemory@12") + +DLL_EXPORT uint32_t PokeMemory(intptr_t address, uint32_t length, intptr_t bank) { + uint32_t bankAddress, bankSize; + bankAddress = *(uint32_t*)(bank + 4); + bankSize = *(uint32_t*)(bank + 8); + + // Limit reading to bank size. + length = (length > bankSize ? bankSize : length); + + for (uint32_t offset = 0; offset < length; offset++) { + *(int32_t*)(address + offset) = *(int32_t*)(bankAddress + offset); + } + + return length; +} +#pragma comment(linker, "/EXPORT:PokeMemory=_PokeMemory@12") + +DLL_EXPORT int8_t PeekMemoryByte(intptr_t* address) { + return *(int8_t*)address; +} +#pragma comment(linker, "/EXPORT:PeekMemoryByte=_PeekMemoryByte@4") + +DLL_EXPORT void PokeMemoryByte(intptr_t* address, int8_t value) { + *(int8_t*)address = value; +} +#pragma comment(linker, "/EXPORT:PokeMemoryByte=_PokeMemoryByte@8") + +DLL_EXPORT int16_t PeekMemoryShort(intptr_t* address) { + return *(int16_t*)address; +} +#pragma comment(linker, "/EXPORT:PeekMemoryShort=_PeekMemoryShort@4") + +DLL_EXPORT void PokeMemoryShort(intptr_t* address, int16_t value) { + *(int16_t*)address = value; +} +#pragma comment(linker, "/EXPORT:PokeMemoryShort=_PokeMemoryShort@8") + +DLL_EXPORT int32_t PeekMemoryInt(intptr_t* address) { + return *(int32_t*)address; +} +#pragma comment(linker, "/EXPORT:PeekMemoryInt=_PeekMemoryInt@4") + +DLL_EXPORT void PokeMemoryInt(intptr_t* address, int32_t value) { + *(int32_t*)address = value; +} +#pragma comment(linker, "/EXPORT:PokeMemoryInt=_PokeMemoryInt@8") + +DLL_EXPORT float_t PeekMemoryFloat(intptr_t* address) { + return *(float_t*)address; +} +#pragma comment(linker, "/EXPORT:PeekMemoryFloat=_PeekMemoryFloat@4") + +DLL_EXPORT void PokeMemoryFloat(intptr_t* address, float_t value) { + *(float_t*)address = value; +} +#pragma comment(linker, "/EXPORT:PokeMemoryFloat=_PokeMemoryFloat@8") + diff --git a/dllmain.cpp b/dllmain.cpp new file mode 100644 index 0000000..dc1eed2 --- /dev/null +++ b/dllmain.cpp @@ -0,0 +1,16 @@ +#pragma once +#include "dllmain.h" + +bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + break; + case DLL_PROCESS_DETACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + } + return true; +} \ No newline at end of file diff --git a/dllmain.h b/dllmain.h new file mode 100644 index 0000000..9c5dadf --- /dev/null +++ b/dllmain.h @@ -0,0 +1,12 @@ +// STL Exceptions +#include +#include + +// Memory Management +#include + +// Platform specific: Windows +#include + +// Macros +#define DLL_EXPORT extern "C" //__declspec(dllexport) \ No newline at end of file