Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MrP

Pages: [1] 2 3 4 5 6
1
Freebasic / Re: Fireworks (particle-test-demo)
« on: March 25, 2007 »
Vey nice.... Could be the start of a very nice particle engine... Good Work

2
Freebasic / Re: Using ASM to Plot Pixels.
« on: March 25, 2007 »
if you want to plot out the whole screen the fastest way I know of is to use asm and blit from the start of the screen to the end, much like you do with the for loop... also if your just plotting something that isn't full screen, asm again is way faster than nesting two for loops, don't know why but this was the case in the tests i did.....

Heres a routine i used to clear the screen to any colour when i first started messing around with asm.... Theres still some things you could do to make this a tad faster but its fast enough.....

Code: [Select]
sub pgl_cls(byval col as integer = rgb(0, 0, 0))
    asm
        mov ebx, [pgl_screen_ptr]
        mov edx, [pgl_screen_length]
        mov ecx, [col]
        lea eax, [ebx + edx]
        rep:
            mov [ebx], ecx
            add ebx, 4
            cmp ebx, eax
        jbe rep
    end asm
end sub

and to blit a full screen image with an alpha value using mmx..... again this was written a while ago so theres probably some optimisations that could be done, also it relies on some variables that are pre-determined at the start of the graphics lib I put together, so its pretty useless as usable code to copy and paste but you get the idea..... Jim helped out a lot with this when I was putting it together.... Cheers again Jim... Also dont be surprised if the comments dont make any sense, its been chopped and changed a bit while i was doing it.....

Code: [Select]
sub pgl_blit_screen(byval src_buffer as integer ptr, byval alpha as ubyte)
    dim p_alpha as integer = alpha shl 16 or alpha shl 8 or alpha
    asm
        mov eax, [src_buffer]     
        mov ebx, [pgl_screen_ptr]   
        mov ecx, [pgl_screen_length] 
        lea ecx, [ebx + ecx]
        add eax, 12
       
        pxor mm6, mm6
        movd mm2, [p_alpha]         'mm2 has alpha value
        punpcklbw mm2, mm6          'unpack it for processing
 
        dloop:
            movd mm0, [eax]         'image pixel col in mm0
            movd mm1, [ebx]         'screen pixel col in mm2
           
            punpcklbw mm0, mm6      'unpack mm0 using blank mm6 register as interleave
            punpcklbw mm1, mm6      'same for screen color
   
            psubw mm0, mm1          'subtract image color from screen color
            pmullw mm0, mm2         'multiply resulting color by alpha
            psrlw mm0, 8            'divide that by 255
            add eax, 4              'increment image position
            paddb mm0, mm1          'and then add screen color back in

            packuswb mm0, mm0       'repack image pixel back to lower 32 bits of mm0
            movd [ebx], mm0         'move result back to screen
       
            add ebx, 4              'increment screen position
       
            cmp ebx, ecx            'check for end of screen
        jbe dloop                   'if were not there wrap!!!!
       
        emms                        'restore floating point stuff, fuck this is expensive..
    end asm
end sub

3
Freebasic / Re: Pentagram.
« on: March 25, 2007 »
Cool..... looks pretty fast to.... nice job

4
Freebasic / Re: Using ASM to Plot Pixels.
« on: March 24, 2007 »
This may be a bit late in the day for this post, but i'll add something anyway....

Quote
ScreenBuffer(PosX+PosY*ScreenWidth)=Colour

I've found that if your plotting lots of individual pixels using this code the most expensive thing is that multiply by the screenwidth.

For example if your plotting a 100x100 pixel box thats 10,000 multiplies, and 10,000 additions to get them all into the screenbuffer, I wrote some inline assembly to replace the above code and while it was faster than the freebasic commands you can still get it faster by removing all those nasty multiplies...

because the value you get from multiplying posy by the screenwidth will always be the same regardles of which line your on you can precalculate this beforehand, eg if your plotting a pixel at 100, 10 and your screen resolution is 800x600 the (posy*screenwidth) bit will be 10*600 which equals 6000, if your plotting at 100, 5 it will be 3000 so we can store these calculations in an array, then just reference that to avoid doing a multiply every time you want to plot a pixel......

create an array of 600 uinteger values (the height of your screen) then calculate the offset for each line of the screen as in the following code

Code: [Select]
dim y_offset(screen_y) as uinteger
for i = 0 to 599
    y_offset(i) = i * screen_x
next i

once this is done you can then replace your original drawing command with the following

Code: [Select]
scr_buffer(100 + y_offset(100)) = rgb(255, 255, 255)
as you can see you have now eliminated the expensive multiply and you should find that this is even faster than using inline asm to calculate the offset for your pixel... Of course if your trying to write small code the array of 600 integers wont help, but if speed is what your after then I don't think theres a much faster way of plotting single pixels in freebasic than this..

I'll put the complete code listing at the end, but please be aware this uses the standard ptc lib that comes with freebasic. I myself use the gfxlib and  I dont have the fantastic extended lib by Jim and Rbraz (I think thats who did it, if not my apologies for the incorrect credit) Hope this helps in some way.....

Code: [Select]
#include "tinyptc.bi"

const screen_x = 800
const screen_y = 600
const screen_size = screen_x * screen_y

dim shared scr_buffer(0 to screen_size - 1) as integer

ptc_open("test", screen_x, screen_y)

dim y_offset(screen_y) as uinteger
for i = 0 to screen_y - 1
    y_offset(i) = i * screen_x
next i

while inkey$ = ""
    scr_buffer(100 + y_offset(100)) = rgb(255, 255, 255)
    ptc_update @scr_buffer(0)
wend

ptc_close()
end

5
Freebasic / Re: Double Buffer?
« on: March 24, 2007 »
Depends what your using to output your screen, tinyptc, gfxlib etc... If your using the tinyptc lib theres loads of articles on here about it and double buffering. If your using gfxlib I'm in the process of writing a tutorial on how to set it up and use it so you get silky smooth frame updates with no flickering.... Just started a new job 2 weeks or so ago and I aint had much time at the pc at all. The tutorial is about 75% complete and I intend to get more done today (possibly even finish it).... If its gfxlib your using I can definately help out.....

6
Freebasic / Re: Really cute typer.
« on: March 04, 2007 »
Sweet typer Shocky, nice work.....

7
Cool example shocky... Didn't know that unsigned integers were faster to work with than their signed counterparts.... Nice tip..... I acces memory in much the same way in my graphics lib, Since I dont use the tinyptc framebuffer library, i started out with using the gfxlib that comes as standard in freebasic... I just get a pointer to the start of current screen memory and use pointers to write directly to the memory.....

8
General chat / Re: Visual Basic
« on: March 01, 2007 »
Its definately got to be a picture of the hoff.... Good call shocky.... good luck with your app, and you should post it....

9
Cheers Shocky, just reading the other post, about dbf being dead, and I'd like to say that although that saddens me, the fact that you wish to devote your time to this board has also shaken me to get rid of my closet lurkerness.... Thanks for supporting this board the way you do.... Lets move up a gear

10
Although I don't think I fit into the lurker group, I may very well be a closet lurker. I suppose I dont post here anywhere near as much as I ought to. I do spend a lot of time looking over the board, and I reckon I've probably seen everything that everybodys produced since I joined, however I dont seem to post back with a response some times. It seems that if I don't check the board for a few days, I don't want to add anything on the end of a post that may well have gone out of day so to speak.... Well anyways, I start a new job as I.T. Manager next week, rather than doing field service stuff, so hopefully I'll have more time in the office. And I even get an hour for dinner, which is much better than stuffing my face at macdonalds at 3.30 in the afternoon coz thats the first chance I've had to eat.... Anyways this is getting to the point of rambling way off topic, so if you find that water torture thing shocky i'd be willing to subject myself as punishment, and I promise to try and be more pro-active on this great board....

11
General chat / Re: Leaving scene
« on: March 01, 2007 »
Although I don't post much on here at the moment, I still check the forum more or less every day, and to hear that you are leaving to do other things saddens me a little..... I have seen a lot of your work that you have posted here, and can only look on it with admiration and respect...... So with that I say good luck with all your future endeavours, and like others have said do what makes you happy and sod the rest, coz at the end of the day were not here long enough to be unhappy...... Good luck Taj, hope to see you post again when you feel it is right to do so.....

12
Freebasic / Re: Dutch Colourz Source
« on: January 18, 2007 »
very nice gesture..... karma++

13
Blitz / Re: Jims 3D Engine Source
« on: January 18, 2007 »
Im not going to say anything about that......... I'll just add some karma............ (for someone that is crap at maths and this 3d stuff, just be assured that respect has been issued where it needs to be)

14
Since i've not coded anything with the graphics functions i've been working on in freebasic i suppose i should release something.... so you can count me in.... (remembers how many times i've said that before and not come up with anything, we live in hope)

15
General chat / Re: New Years Frolicks & Resolutions.
« on: January 11, 2007 »
Mines not really a resolution but more of a get your lazy ass in gear.... I'm really shit at getting up in the morning, so since we got back to work after the holidays i've forced myself out of bed early and got my sorry carcass in a reasonable shape to present to society, rather than getting up 10 mins before i'm supposed to leave the house and getting ready very quickly, and then leaving in a rather unpresentable state... I've also got myself an interview for a new job on friday..... So, so far things are looking good.... Please don't ask me how i'm doing in a month or so, i'll probably be getting up 5 mins before i'm supposed to leave, and it'll start all over again.....

16
General chat / Re: What makes a good cracktro great?
« on: January 11, 2007 »
This is a great topic.... I remember sitting in front of my old ST (yes i know thats swearing to some on here) watching various cracktros from people like automation, and the medway boys. Jeez brings back some good memories. You've all pretty much covered the definition of a good cracktro so i'll just ask, what is it thats in some people and not others to make them appreciate whats going on???? Have you ever showed someone whos not really into the scene a cracktro, intro or demo, and then tried to explain to them whats going on and why the thing they are watching has been produced only for them to look blankly at you and not get it at all..... Well I dont get it, but then i suppose these things are art and as such they will only appeal to a certain audience... I mean i cant picture myself going to an art gallery and having a good time, yet lots of people do.... Anyway rambling now so ill leave it there.....

17
Projects / Re: Specs/Readings please!
« on: January 01, 2007 »
Looking forward to the finished prod....

18
Projects / Re: Laconism
« on: January 01, 2007 »
Sweet little prod..... Enjoyed watching it...

19
General chat / Re: Happy New Years
« on: January 01, 2007 »
Happy new year to all of you.... Hope you all had a good one...... All the best for 2007

20
Projects / Re: Specs/Readings please!
« on: January 01, 2007 »
floats between 98 and 101, but on average about 100... P4 3.2G Dual Core (one of the early ones), G-Force FX 7800GTX

Pages: [1] 2 3 4 5 6