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 - boogop

Pages: [1] 2 3
General chat / Re: Hello there!!
« on: January 02, 2018 »
Nice to see some new faces! I'm also a fan of amiga demos, pretty much all I do are in that style

Boogop's amazing summer demo! Loaded with ancient crusty effects you've seen a gorillion times before! Absolutely no new ground broken whatsoever!

Kludged up in Freebasic, Tinyptc_ext by RBZ, FMod for music (could have used Tinyptc_ext++ herp derp), FPS limiter by RBRAZ, FFNT_Lib by Deleter. Music is d3.mod by Necros. Is there anything in here by me?!

General chat / Re: Ideas for a new DBF compo
« on: April 28, 2017 »
TWO HOURS!! have mercy

General chat / Re: Ideas for a new DBF compo
« on: April 26, 2017 »
Ditto! Some summer theme sounds like a winnah

General chat / Re: Hello !
« on: April 19, 2017 »
Welcam Mon! What's yer language of choice?

Got a little more speed out of it. I love c# but eventually we run into the limitations of the language    :telloff:

Code: [Select]
        FastBitmap a = new FastBitmap(myTexture);
        FastBitmap b = new FastBitmap(myBitmap);
        for (int x = 0; x < bmp.Width; x++)
          fixed (int* pDistance = &distanceTable[x, 0])
            fixed (int* pAngle = &angleTable[x, 0])
              for (int y = 0; y < bmp.Height; y++)
                int xp = *(pDistance + y);
                int xx = (xp + shiftX) % 128;
                int ap = *(pAngle + y);
                int yy = (ap + shiftY) % 128;
                Color c = a.GetPixel(xx, yy);

                b.SetPixel(x, y, c);

Note: much discussion on bounds checking exists and unless you read the IL it's not easy to tell what the compiler is doing.

Glad to see some c#! All my contest entries so far have been in c#.

Two items jump out at me
1. Multi-dimension arrays. The compiler has to do bounds checks on those and it will tool your performance.
2. Getpixel. Even with fastbitmap these are bad. They make flame effects problematic in this language.

I can't tell what size your picturebox is but using gdi 640x480 is going to be about the limit. I find 350x350 or thereabouts works pretty good but above that starts really slowing down.

The game in c# is all about optimization. When I've done contest entries I sh1t you not the last couple months are spent optimizing.

Nice to see work in c#! I've gotten a lot of mileage out of it and have done all my DBF compo entries in it. I use the FastBitmap class which allows direct pixel-pushing to the graphics object, which in my thirst for punishment I enjoy.

Freebasic / Re: 13 * 13 Sin Scroll font in binary
« on: February 09, 2017 »
Sorry to necro this thread but this is way cool! I was looking at the unenviable task of writing my own when I found this. I think it will do just fine!

mad props!

General chat / Re: Merry Christmas 2016
« on: December 26, 2016 »
Merry Christmas dbfinteractive!

Freebasic / Re: Dot Tunnel
« on: November 23, 2016 »
This is a surprisingly low level language for all its VB trappings. I used to make my living in vb6 but this sure ain't that

Freebasic / Re: Dot Tunnel
« on: November 22, 2016 »
Liking this a lot! What's this all about?

Code: [Select]
dim as integer w=any,h=any

Freebasic / Re: Dot Tunnel
« on: November 22, 2016 »
Well,  tomorrow I can either fix a shop floor data collection app or mess around with this...wat do? lol the joys of 'padding the schedule'

Freebasic / Re: Dot Tunnel
« on: November 21, 2016 »
Yep, that works! Thanks!

But there's a basic design problem with the way I do tunnels. I've modified the algorithm from 3D stars, where each point in the circle is divided by Z in the processing loop, so each point moves towards the screen boundaries. Doing that I can never be outside the tunnel looking at it. See the attached screenshot below from Xography; treating each point on the circle like a 3D star, that view will never happen

Freebasic / Re: Dot Tunnel
« on: November 18, 2016 »
 lol thanks! Freebasic is a new experience but I'm liking it a lot

Freebasic / Dot Tunnel
« on: November 17, 2016 »
Dot tunnels gave me fits trying to figure out. So here's one for the lulz, maybe it will help (or hinder) someone else!

Code: [Select]
' by boogop
' The c# logic from my entry for the Amiga
' demo a year or so ago
' - now in glorious lo-res!
' For me, dot tunnels were the hardest effect
' to figure out. There didn't seem to be many
' examples (before I found dbfinteractive, on
' which there are several) and the ones I could
' find on the intarnets or hornet archive were
' frequently not very good. Some of them
' weren't tunnels at all, they were tubes with the
' rings fixed in place. The best one I ever saw
' was Crystal2 BBS addy by Xography but they never
' released the source, and I haven't been able to
' figure out how they were handling the movement path

#include ""

' screen dimensions & put_pixel routine
const screenWidth = 320
const screenHeight = 200
const SCR_SIZE as integer = screenWidth*screenHeight

dim shared buffer( 0 to SCR_SIZE-1 ) as integer
dim shared as uinteger ptr pntr
dim shared as integer ptr p

declare sub put_pixel(buffer() as integer, byval x as integer, byval y as integer, byval col as integer)

' this may be Shockwave's routine!
sub put_pixel(buffer() as integer, byval x as integer, byval y as integer, byval col as integer)

    if(y < screenHeight -1 and y > 1) then
        if( x < screenWidth-1 and x > 1 ) then
            PNTR = @buffer(y * screenWidth + x)   
                mov eax, dword ptr[col]
                mov edi, [pntr]               
            end asm           
        end if
    end if

end sub

' declare variables
type colors
    dim as integer r,g,b
end type

dim shared as colors colArray(256)

const _pointsPerCircle = 20
const _numCircles = 35
dim shared as double zDistance = 8

' named star because I lifted it from my 3d starfield code :)
type star
    dim as double xpos, ypos, speed, zpos
    dim as double origX, origY, origZ
    dim as integer oldx,oldy
end type

dim shared as star circles(_numCircles, _pointsPerCircle)

dim shared as double maxZ = 0
dim shared as double diam = 50
dim shared as double xp,yp,zp,increment, px, py, skew, skewCount
dim shared as integer angle = 0
dim shared as double zPos = 1
dim shared as integer angleAdder = int(360 / _pointsPerCircle)     
dim shared as double zPosAdder
dim shared as double midWidth = screenWidth / 2
dim shared as double midHeight = screenHeight / 2
dim as integer i,j, xpathcount
dim as double rad = 3.1416 / 180.0

' set initial values
skewCount = .0001
zPosAdder = zDistance / _numCircles

for  j = 0 to  _numCircles
    for  i = 0 to _pointsPerCircle
      dim as double Y =  diam * Sin(angle * rad)
      dim as double X = 2 * diam * Cos(angle * rad) ' make it oval shaped for the lulz
      circles(j, i).xpos = X
      circles(j, i).ypos = Y
      circles(j, i).speed = .0025
      circles(j, i).zpos = zPos
      circles(j, i).origX = X
      circles(j, i).origY = Y     
      circles(j, i).oldx = 0
      circles(j, i).oldy = 0
      angle += angleAdder
    next i
zPos += zPosAdder
next j

maxZ = 0

' figure out the largest z value
for  j = 0 to _numCircles
    for i = 0 to _pointsPerCircle     
        if circles(j, i).zpos > maxZ then
            maxZ = circles(j, i).zpos
        end if   
    next i
next j

increment = 0

' fill color array     
i = 0
while i < 256     
    dim as single red = 1 + Cos(i * 3.14 / 128)
    dim as single grn = 1 + Cos((i - 85) * 3.14 / 128)
    dim as single blu = 1 + Cos((i + 85) * 3.14 / 128)
    colArray(i).r = int(red * 127) mod 256
    colArray(i).g = int(grn * 127) mod 256
    colArray(i).b = int(blu * 127) mod 256
    i = i+1

' run the thing

if( ptc_open( "freeBASIC - tinyPTC Dot Tunnel", screenWidth, screenHeight ) = 0 ) then
    end -1
end if

while inkey() <> chr(27)   
    if skew <= 1 then
        skew = skew + skewcount
    end if
    for  i = 0 to _numCircles
        for  j = 0 to _pointsPerCircle
           ' erase the last point
            put_pixel Buffer(),circles(i, j).oldx,circles(i, j).oldy,0
            put_pixel Buffer(),circles(i, j).oldx+1,circles(i, j).oldy,0
            ' bring each circle towards the viewer
            circles(i, j).zpos -= circles(i, j).speed
            ' if a circle is close enough to the viewer, send it to the back
            ' using the maximum z value
            if circles(i, j).zpos < 2 then           
                circles(i, j).xpos = circles(i, j).origX
                circles(i, j).ypos = circles(i, j).origY
                circles(i, j).zpos = maxZ
            end if
            ' most compilers will perform some kind of bounds checks, and those
            ' will really bog an app down. Cast the array to vars so any bounds
            ' checking only has to happen once
            xp = circles(i, j).xpos
            yp = circles(i, j).ypos
            zp = circles(i, j).zpos
            ' kludgey color fader lol
            dim as double cc = 1 - Abs(zp / (maxZ * .8))
            if (cc < 0) then
                cc = 0
            end if
            if (cc > 1) then
                cc = 1
            end if
            dim as integer c = int(300 * cc)
            if c > 255 then
                c = 255
            end if
            dim as integer co = rgb(colArray(c).b,colArray(c).r,colArray(c).g)
            if zp > int(maxZ * .6) then
                co = rgb(colArray(c).b/2,c,c)
            end if       
           ' zpos isn't quite right and doesn't bring the circles as close
           ' as it should but I don't feel like fixing it!
            dim as double z = zp - 1.5
            ' path of the tunnel
            px = 50 * Sin(z * skew * sin(increment))
            py = 40 * Cos(z * skew * cos(increment))           
            ' calculate perspective, add path, align to center screen
            dim as double sx = (xp / z) + px + midWidth
            dim as double sy = (yp / z) - py + midHeight
            dim as integer ix = int(sx)
            dim as integer iy = int(sy)
            put_pixel Buffer(),ix,iy,co
            put_pixel Buffer(),ix+1,iy,co           
            ' save the current pos so we can erase it in the next iteration
            circles(i, j).oldx = ix
            circles(i, j).oldy = iy
        next j
    next i   
    increment +=.0005   
    ptc_update @buffer(0)


Freebasic / Fractal Zoomer
« on: November 09, 2016 »
Here's a version of the fractal zoomer from R.I.P. Boogop converted to freeBasic/ASM. I'd love to figure out a way around having to iterate over each pixel 300 times because that's where all your performance goes. It drives me nuts. This seems about as optimized as I know how to make it; if you focus optimizing anywhere else but the iteration loop it's a red herring, that loop is the killer. There are ideas around to split the screen in half and render each half in a separate thread, but that's still working around the central problem of the inability to determine if an equation is going to go to infinity without doing it 300 times.

On my work PC (LoMem Kludge-0-Matic 100) I get to the lose-resolution point in about 22 seconds. If you want to go deeper you'll need to tweak horizPosAdjust and vertPosAdjust to position yourself where you want to be

Code: [Select]
' by boogop
' this may be a little faster than the FB version
' but I'm sure I've done lots of stuff wrong or fb
' is just smarter than I am lol
' Where this loses resolution is about the limit
' of a single data type. Converting to double will
' zoom farther in but also take longer

#include ""

' 350 x 325 to size it the same as the c# effect
dim shared as integer screenWidth = 320
dim shared as integer screenHeight = 200
const SCR_SIZE as integer = 320*200

dim shared as integer ptr p

dim shared buffer( 0 to SCR_SIZE-1 ) as integer
dim shared as uinteger ptr pntr

dim shared as integer w, h, h2

' initial vals
dim shared as single a1 = -2.5
dim shared as single b1 = -1.5
dim shared as single ax1 = -2.5
dim shared as single ax2 = 1.5
dim shared as single bx1 = -1.5
dim shared as single bx2 = 1.6

dim shared as single bailnum = 2.0
dim shared as single bailGT1 = 1.3
dim shared as single bailLT1 = -1.3

dim shared as single z1, z2, z3, dx, dy, crx, yy, cr, ci', dydx
dim shared as integer k = 0   

dim shared as single ww
dim shared as single hh
dim shared as single a1w, b1h
dim shared as single aw
dim shared as single bh

dim shared as single zoom = 1

dim shared as uinteger colSingle(300)

declare sub init
declare sub DrawMandelbrot
declare sub CreateMandelbrot(a1 as single, a2 as single, b1 as single, b2 as single)
declare sub put_pixel(buffer() as integer, byval x as integer, byval y as integer, byval col as integer)

sub init   
    w = screenWidth
    h = screenHeight   
    h2 = h / 2     
    ' these coords put us in scepter valley
    a1 = 153.41801 
    b1 = h2 - 8.650006   
    ' if you change the size of the window you have to figure out where in the
    ' mandelbrot set you are - not easy! >:(
    dim as single horizPosAdjust = 13.24
    dim as single vertPosAdjust = 1.5
    a1 = a1 - horizPosAdjust
    b1 = b1 - vertPosAdjust
    ww = ax2 - ax1
    hh = bx2 - bx1
    a1w = a1 * ww
    b1h = b1 * hh
    aw = a1w / w
    bh = b1h / h
    dim i as integer = 0
    ' usually the array would be dimensioned to 256 but if we set it to the
    ' number of iterations we can skip a mod operation
    while i < 300     
        dim as single red = 1 + Cos(i * 3.14 / 128)
        dim as single grn = 1 + Cos((i - 85) * 3.14 / 128)
        dim as single blu = 1 + Cos((i + 85) * 3.14 / 128)       
        dim as integer r = int(red * 127) mod 256
        dim as integer g = int(grn * 127) mod 256
        dim as integer b = int(blu * 127) mod 256
        colSingle(i) = rgb(r,g,b)     
        i = i+1
end sub

sub DrawMandelbrot   
    zoom = zoom + (zoom * .05)
    dim as single d = zoom + zoom
    dim as single wax = ww / d
    dim as single wah = hh / d   
    dim as single newleft = aw + ax1 - wax
    dim as single newright = aw + ax1 + wax
    dim as single newtop = bh + bx1 - wah
    dim as single newbottom = bh + bx1 + wah
    CreateMandelbrot(newleft, newright, newtop, newbottom)
end sub

sub CreateMandelbrot(a1 as single, a2 as single, b1 as single, b2 as single)
    p = @buffer(0)
    dim as single dr = (a2 - a1) / w
    dim as single di = (b2 - b1) / h
    dim as integer j = 0
    dim as integer i = 0
    dim as single temp, q, a, b
    dim as single dx1, dy1
    dim as single ptr t
    'dim as string key
    for j = 1 to h
        ci = b1 + j * di 
        for i = 0 to w-1
            cr = a1 + i * dr
            dx1 = 0.0
            dy1 = 0.0         
            ' PERIOD CHECKING
            ' if we can tell we're inside the cardiod or period-2 bulb we can skip the iterations.
            ' period checks make the routine blaze until we're past them but the iteration loop is
            ' the big problem
            crx = cr + 1.0
            yy = ci * ci
            if ((crx * crx) + yy < .0625) then
                ' checks for a point inside the period-2 bulb
                ' but once you're past that it does nothing
                *p = 0
                goto bail
            end if
            ' check for cardiod bulb
            temp = cr - .25
            t = @temp
           ' q = temp * temp + yy
            q = (*t) * (*t) + yy
            a = q * (q + *t)
            b = .25 * yy
            if (a < b) then
                *p = 0
                goto bail
            end if
            ' SSE ITERATION LOOP
            k = 0   
            ' 32 bit singles are only taking up 1/4 of these registers
                mov cx, 0
                movss xmm2, [ci]
                movss xmm3, [cr]
                movss xmm0, [dx1]
                mulss xmm0, xmm0
                movss [z1], xmm0        'z1 =  dx1 * dx1
                movss xmm1, [dy1] 
                mulss xmm1, xmm1   
                movss [z2], xmm1        'z2 =  dy1 * dy1               
                addss xmm0, xmm1        ' z1 + z2     
                comiss xmm0,[bailnum]   ' if z1 + z2 > 2.0
                ja @asmdone                 
                inc cx                  ' handle the iterations counter
                cmp cx, 300
                je @asmdone
                movss xmm0, [dx1]
                movss xmm1, [dy1]
                mulss xmm0, xmm1        ' dy1 * dx1               
                addss xmm0, xmm0        ' (dy1 * dx1) + (dy1 * dx1)               
                addss xmm0, xmm2        ' + ci
                movss [dy1],xmm0        'dy1 = (dy1 * dx1) + (dy1 * dx1) + ci               
                movss xmm0, [z1]
                movss xmm1, [z2]
                subps xmm0, xmm1        ' z1 - z2               
                addss xmm0, xmm3        ' + cr
                movss [dx1],xmm0        'dx1 = z1 - z2 + cr   
                jmp @starter           
                mov [k],cx
            end asm
            if k = 300 then
                *p = 0
                *p = colSingle(k)
            end if
            ' print k, z3, dx1, dy1
            ' key = INKEY
            ' WHILE key = "": key = INKEY: WEND
            p = p + 1
        next i
    next j
end sub

ptc_open( "tinyPTC Mandelbrot test", screenWidth, screenHeight )

'dim as string key
'print "Press to start"
'WHILE key = "": key = INKEY: WEND


dim as single t1,t2

t2 = timer
while inkey() <> chr(27)
    t1 = timer
    ptc_update @buffer(0)
    print t1 - t2

R.I.P BOOGOP (getting some halloween correlation is really reaching!)

C#, .NET 4, VS2015, SharpMod for music, hopefully most folks will be able to run it without having to install a bunch of cruddy .NET which you probably wouldn't do anyway! No frameworks, only GDI with getpixel/putpixel [pointer] routines and bmp.drawstring. The drawback to doing things that 'oldskool' way is I have to limit the form size to get acceptable performance (particularly for the fractal zoomer), do my own sucky 3D, load my own textures [into int arrays] blahblah.

optimizing assumptions
- must have a doevents each time through the demo loop for the app to behave while rendering
- add is faster than mult (old assumption that may no longer be valid)
- bounds checking gets exponentially worse with 2-dim arrays so use multiples of 1 whenever possible
- switch is faster than if due to jumptable opcodes
- C# is optimized for doubles
- using pointers anywhere but the actual drawing would p-r-o-b-a-b-l-y be slower (much discussion on this exists)
- use bitwise ops whenever possible (&=, >>, <<)

Notes on some of the FX (I really need to get out of the early 90's, man)

- my two problems with fractal zooming is the thing wants to spend longer and longer in the escape-time loop to get resolution at depth, and eventually you run into the limits of a double variable type. After I'd gotten the thing working I dug around in the IL and optimized it based on what I saw the compiler emitting, though I'm guessing on some of the commands (just for kicks I rewrote this in freebasic with ASM for the inner loop, SSE instruction set, and it was slow as crap. But it may be my retarded asm too)
- these are lulzy and look really oldskool if you live in the past like I do
- there's a few of these in here for ball-0-ween lolz
- I'm really pleased with this, I worked the problems out of the one I used in my last demo and tweaked it until it looks close to 'fake demo' by Pelusa which I love
- The problem with these is whatever I do with them they usually end up looking like Tumblin's 94 demo unless you just bounce them around like Scoopex, but that was less interesting
- I liked Argon by Matrix (1997), however this ain't that. I draw three plasmas on top of each other and skip the black values in the color array. What I've done is probably not a true tri-plasma and Argon seems to be doing some blending that eludes me. But even if I translated it directly it wouldn't look the same. STOSW in c# --> lololol
- a modification of the effect I used last time which drew the plasma then rotated the palette. This one attempts to do it in realtime by using values in arrays to redraw the map instead of getPixel each time which is a killer. For some reason this wants to migrate to the bottom right. Meh, palette rotation actually looks better.

skull graphic, palm tree and a few others from some public domain clipart collection I can't remember, openclipart maybe
Music is starlitdeception.mod by Necros. Dude was one of the best trackers ever
Font is some free thing but I call bmp.SetResolution(320, 200) which doesn't affect the actual drawing but causes the font to be rendered in glorious lo-res lol

That's good stuff,  thanks! I've bookmarked the site and yeah,  he's got the do it yourself thing happening lol. I like that. There's something that makes me plotz about being able to open unity and lay out an entire landscape with vegetation that responds to wind in five freaking minutes.  :telloff:

I'm finding the freebasic section interesting. Though what exactly it's doing with the video/blitter seems to be disputed elsewhere.

Pages: [1] 2 3