Post by andrian on Oct 19, 2008 16:18:56 GMT -5
I have a Basic4GL function that runs slow on my computer. Could someone port this to a DLL and then give me a step-by-step explanation of what you did please? I would prefer that the plugin be made in C++ - still more preferably in Dev C++ (www.bloodshed.net/devcpp.html), because I don't have freebasic or MS Visual Studio. Please help!
Here is the function. The text parser is the part that is probably causing the slowing.
Here is the function. The text parser is the part that is probably causing the slowing.
sub printtext(s$, xcoord, ycoord, width, height, &spr)
dim textmap(len(s$) - 1, 0)
dim x
for x = 0 to len(s$) - 1
if mid$(s$, x+1, 1) = " " then
textmap(x, 0) = 0
elseif mid$(s$, x+1, 1) = "!" then
textmap(x, 0) = 1
elseif mid$(s$, x+1, 1) = "#" then
textmap(x, 0) = 3
elseif mid$(s$, x+1, 1) = "$" then
textmap(x, 0) = 4
elseif mid$(s$, x+1, 1) = "%" then
textmap(x, 0) = 5
elseif mid$(s$, x+1, 1) = "&" then
textmap(x, 0) = 6
elseif mid$(s$, x+1, 1) = "(" then
textmap(x, 0) = 8
elseif mid$(s$, x+1, 1) = ")" then
textmap(x, 0) = 9
elseif mid$(s$, x+1, 1) = "*" then
textmap(x, 0) = 10
elseif mid$(s$, x+1, 1) = "+" then
textmap(x, 0) = 11
elseif mid$(s$, x+1, 1) = "," then
textmap(x, 0) = 12
elseif mid$(s$, x+1, 1) = "-" then
textmap(x, 0) = 13
elseif mid$(s$, x+1, 1) = "." then
textmap(x, 0) = 14
elseif mid$(s$, x+1, 1) = "/" then
textmap(x, 0) = 15
elseif mid$(s$, x+1, 1) = "0" then
textmap(x, 0) = 16
elseif mid$(s$, x+1, 1) = "1" then
textmap(x, 0) = 17
elseif mid$(s$, x+1, 1) = "2" then
textmap(x, 0) = 18
elseif mid$(s$, x+1, 1) = "3" then
textmap(x, 0) = 19
elseif mid$(s$, x+1, 1) = "4" then
textmap(x, 0) = 20
elseif mid$(s$, x+1, 1) = "5" then
textmap(x, 0) = 21
elseif mid$(s$, x+1, 1) = "6" then
textmap(x, 0) = 22
elseif mid$(s$, x+1, 1) = "7" then
textmap(x, 0) = 23
elseif mid$(s$, x+1, 1) = "8" then
textmap(x, 0) = 24
elseif mid$(s$, x+1, 1) = "9" then
textmap(x, 0) = 25
elseif mid$(s$, x+1, 1) = ":" then
textmap(x, 0) = 26
elseif mid$(s$, x+1, 1) = ";" then
textmap(x, 0) = 27
elseif mid$(s$, x+1, 1) = "<" then
textmap(x, 0) = 28
elseif mid$(s$, x+1, 1) = "=" then
textmap(x, 0) = 29
elseif mid$(s$, x+1, 1) = ">" then
textmap(x, 0) = 30
elseif mid$(s$, x+1, 1) = "?" then
textmap(x, 0) = 31
elseif mid$(s$, x+1, 1) = "@" then
textmap(x, 0) = 32
elseif mid$(s$, x+1, 1) = "A" then
textmap(x, 0) = 33
elseif mid$(s$, x+1, 1) = "B" then
textmap(x, 0) = 34
elseif mid$(s$, x+1, 1) = "C" then
textmap(x, 0) = 35
elseif mid$(s$, x+1, 1) = "D" then
textmap(x, 0) = 36
elseif mid$(s$, x+1, 1) = "E" then
textmap(x, 0) = 37
elseif mid$(s$, x+1, 1) = "F" then
textmap(x, 0) = 38
elseif mid$(s$, x+1, 1) = "G" then
textmap(x, 0) = 39
elseif mid$(s$, x+1, 1) = "H" then
textmap(x, 0) = 40
elseif mid$(s$, x+1, 1) = "I" then
textmap(x, 0) = 41
elseif mid$(s$, x+1, 1) = "J" then
textmap(x, 0) = 42
elseif mid$(s$, x+1, 1) = "K" then
textmap(x, 0) = 43
elseif mid$(s$, x+1, 1) = "L" then
textmap(x, 0) = 44
elseif mid$(s$, x+1, 1) = "M" then
textmap(x, 0) = 45
elseif mid$(s$, x+1, 1) = "N" then
textmap(x, 0) = 46
elseif mid$(s$, x+1, 1) = "O" then
textmap(x, 0) = 47
elseif mid$(s$, x+1, 1) = "P" then
textmap(x, 0) = 48
elseif mid$(s$, x+1, 1) = "Q" then
textmap(x, 0) = 49
elseif mid$(s$, x+1, 1) = "R" then
textmap(x, 0) = 50
elseif mid$(s$, x+1, 1) = "S" then
textmap(x, 0) = 51
elseif mid$(s$, x+1, 1) = "T" then
textmap(x, 0) = 52
elseif mid$(s$, x+1, 1) = "U" then
textmap(x, 0) = 53
elseif mid$(s$, x+1, 1) = "V" then
textmap(x, 0) = 54
elseif mid$(s$, x+1, 1) = "W" then
textmap(x, 0) = 55
elseif mid$(s$, x+1, 1) = "X" then
textmap(x, 0) = 56
elseif mid$(s$, x+1, 1) = "Y" then
textmap(x, 0) = 57
elseif mid$(s$, x+1, 1) = "Z" then
textmap(x, 0) = 58
elseif mid$(s$, x+1, 1) = "[" then
textmap(x, 0) = 59
elseif mid$(s$, x+1, 1) = "\" then
textmap(x, 0) = 60
elseif mid$(s$, x+1, 1) = "]" then
textmap(x, 0) = 61
elseif mid$(s$, x+1, 1) = "^" then
textmap(x, 0) = 62
elseif mid$(s$, x+1, 1) = "_" then
textmap(x, 0) = 63
elseif mid$(s$, x+1, 1) = "`" then
textmap(x, 0) = 64
elseif mid$(s$, x+1, 1) = "a" then
textmap(x, 0) = 65
elseif mid$(s$, x+1, 1) = "b" then
textmap(x, 0) = 66
elseif mid$(s$, x+1, 1) = "c" then
textmap(x, 0) = 67
elseif mid$(s$, x+1, 1) = "d" then
textmap(x, 0) = 68
elseif mid$(s$, x+1, 1) = "e" then
textmap(x, 0) = 69
elseif mid$(s$, x+1, 1) = "f" then
textmap(x, 0) = 70
elseif mid$(s$, x+1, 1) = "g" then
textmap(x, 0) = 71
elseif mid$(s$, x+1, 1) = "h" then
textmap(x, 0) = 72
elseif mid$(s$, x+1, 1) = "i" then
textmap(x, 0) = 73
elseif mid$(s$, x+1, 1) = "j" then
textmap(x, 0) = 74
elseif mid$(s$, x+1, 1) = "k" then
textmap(x, 0) = 75
elseif mid$(s$, x+1, 1) = "l" then
textmap(x, 0) = 76
elseif mid$(s$, x+1, 1) = "m" then
textmap(x, 0) = 77
elseif mid$(s$, x+1, 1) = "n" then
textmap(x, 0) = 78
elseif mid$(s$, x+1, 1) = "o" then
textmap(x, 0) = 79
elseif mid$(s$, x+1, 1) = "p" then
textmap(x, 0) = 80
elseif mid$(s$, x+1, 1) = "q" then
textmap(x, 0) = 81
elseif mid$(s$, x+1, 1) = "r" then
textmap(x, 0) = 82
elseif mid$(s$, x+1, 1) = "s" then
textmap(x, 0) = 83
elseif mid$(s$, x+1, 1) = "t" then
textmap(x, 0) = 84
elseif mid$(s$, x+1, 1) = "u" then
textmap(x, 0) = 85
elseif mid$(s$, x+1, 1) = "v" then
textmap(x, 0) = 86
elseif mid$(s$, x+1, 1) = "w" then
textmap(x, 0) = 87
elseif mid$(s$, x+1, 1) = "x" then
textmap(x, 0) = 88
elseif mid$(s$, x+1, 1) = "y" then
textmap(x, 0) = 89
elseif mid$(s$, x+1, 1) = "z" then
textmap(x, 0) = 90
elseif mid$(s$, x+1, 1) = "{" then
textmap(x, 0) = 91
elseif mid$(s$, x+1, 1) = "|" then
textmap(x, 0) = 92
elseif mid$(s$, x+1, 1) = "}" then
textmap(x, 0) = 93
elseif mid$(s$, x+1, 1) = "~" then
textmap(x, 0) = 94
endif
next
spr = NewTileMap (loadtexstrip("Images/font.bmp", 16, 16))
sprsettiles(textmap)
sprsetpos(xcoord, ycoord)
sprsetsolid(false)
sprsetsize(width, height)
sprsetxrepeat(false)
sprsetyrepeat(false)
SetTexTransparentCol(0,0,0)
end sub