Search found 726 matches

by grindstone
Apr 22, 2016 9:25
Forum: General
Topic: What distance formula to know if point is in rectangular area?
Replies: 26
Views: 1197

Re: What distance formula to know if point is in rectangular area?

@Tourist Trap:
Could you please specify: Do you mean a rectangle (with four right angles) or a quadrangle (with an angle sum of 360 degrees)?
by grindstone
Apr 21, 2016 19:52
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

Yes, I see. The simplest way to fix it is to let the text string surely end with a delimiter. I amended the code above.
by grindstone
Apr 21, 2016 9:53
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

Just for amusement, I played a little with assembly code. Not quite the improvement I'd expected, but still... Sub splitOver2(txts As String, delim As String, outArr() As String) Dim As String txt = txts + delim Dim As Integer x, p3 = Len(txt) - 1, dm = Len(delim) - 1, count = Int(Len(txt)/8)+1 Dim ...
by grindstone
Apr 20, 2016 10:16
Forum: General
Topic: How to 'shade' a pixel FAST?
Replies: 29
Views: 1767

Re: How to 'shade' a pixel FAST?

This code works twice as fast as the former one. Call me silly, but I don't understand how the alpha preserving works. As far as I understand the code, the variable shade_fix contains the value &b000000010000000000000000ssssssss. But -as far as I understand the Intel reference- pshufw mm1,mm1,&a...
by grindstone
Apr 19, 2016 0:23
Forum: General
Topic: How to 'shade' a pixel FAST?
Replies: 29
Views: 1767

Re: How to 'shade' a pixel FAST?

You're right. With a pre-calculated loop count it works about 60% faster than with the For..Next - loop: Sub fade3(shade As UByte) Dim As Integer scrWidth, scrHeight, scrPitch, count Dim As Byte Ptr argb ScreenInfo scrWidth, scrHeight,,,scrPitch count = scrHeight * scrPitch / 4 argb = ScreenPtr Asm ...
by grindstone
Apr 18, 2016 7:57
Forum: General
Topic: How to 'shade' a pixel FAST?
Replies: 29
Views: 1767

Re: How to 'shade' a pixel FAST?

The addressing doesn't work this way. To dereference the pixel pointer you have to load it into a register first: Sub fade2(shade As UByte) Dim As Integer scrWidth, scrHeight, scrPitch Dim As Byte Ptr argb ScreenInfo scrWidth, scrHeight,,,scrPitch For argb = ScreenPtr To ScreenPtr + scrHeight * scrP...
by grindstone
Apr 17, 2016 12:20
Forum: General
Topic: How to 'shade' a pixel FAST?
Replies: 29
Views: 1767

Re: How to 'shade' a pixel FAST?

Maybe try some assembly code (only works with 32bit colour depth): Sub fade(factor As Single = 1.0) Dim As Integer scrWidth, scrHeight, scrPitch Dim As Byte Ptr ptr1 Dim As Single fac(3) = {factor,factor,factor,factor} Dim As Single Ptr fp = @fac(0) ScreenInfo scrWidth, scrHeight,,,scrPitch For ptr1...
by grindstone
Apr 12, 2016 6:01
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

Maybe the various execution times do arise from different hardware and/or OSs. My equipment is rather old, my CPU (Pentium IV) has only one core (although hyperthreading). This could explain the different behaviour.
by grindstone
Apr 11, 2016 9:46
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

Great! That's about 10 per cent faster than the string method. In the meantime I've made the algo foolproof (at least I hope so): Type tStrDescr txtPtr As UByte Ptr txtLen As UInteger txtMem As UInteger End Type Sub splitOver2(ByRef txt As String, delim As String, outArr() As String) Dim As Integer ...
by grindstone
Apr 11, 2016 8:34
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

@fxm: (mis)using strings for pointer storage seems to work slightly (abt. 1.5 per cent) faster than using integer buffers. - I prefer the syntax ' p[n] ' instead of ' *(p+n) '. I agree. @dodicat: I can't confirm that. With "abcdefghijklmnopqrstuvwxy" as delim I get a number of 'z's, and wi...
by grindstone
Apr 10, 2016 10:10
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

I've combined dodicat's tally string method with my pointer tagging. And although it's seductive I avoided to use the swapping, for I noticed that after calling the sub every change of the txt string causes the programme to crash. Type tStrDescr txtPtr As UByte Ptr txtLen As UInteger txtMem As UInte...
by grindstone
Apr 10, 2016 8:51
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

@fxm:
Yes, you're right. With passing the string ByVal the programme crashes.

The german reference says that since FB v0.17 all variables are passed ByVal as default, that's obviously wrong. I'll report that.
by grindstone
Apr 09, 2016 12:20
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

I thougt it was clear that the array only returns references to the original string. That's the reason why it works so fast. Oops! I see, somehow the ByRef had disappeared from the parameter list. My fault. The txt string absolutely has to be submitted ByRef! Otherwise the references are void at lea...
by grindstone
Apr 09, 2016 10:58
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

I remember some time ago there was a discussion here about a bug of FB 1.xx: If there is a SLEEP as the last line of the code the programme crashes at shutdown. To solve this problem you have to insert an END at the end of the code. In my case it works. I thought this bug had already been fixed, but...
by grindstone
Apr 09, 2016 9:28
Forum: General
Topic: I need someone to defeat my string splitting algo
Replies: 113
Views: 6422

Re: I need someone to defeat my string splitting algo

Yes, maybe it's only a littleness that's going wrong. Or it's a bug of FB 1.05.0. Perhaps you should try to compile the code with a former version of FB.

Go to advanced search