Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: TinDragon on July 19, 2006

Title: TinyPTC project for DevCPP
Post by: TinDragon on July 19, 2006
Ok since people want to get started on some C coding I had a bash at getting TinyPTC to compile under DevCPP, after a few false starts I finaly got the demo file to compile. Had to change a few typedef's that were MS specific to standard C and remove the mmx optimizations, so it might not be as fast as under FB, not sure if that uses the mmx stuff ;)

I have set the files to use DirectDraw for the interface so you will need to have the DX devpak installed in DevCPP, you can get it from http://devpaks.org

The only code file you really need to mess with is test.c since the rest are part of TinyPTC, you can of course change some of the defines in Tinyptc.h but I dont know if they will all work ;)

The test.c file is as it was and I show it here just as the basic example, I included the compiled exe in the zip.
Code: [Select]
//
// TinyPTC by Gaffer
// www.gaffer.org/tinyptc
//

#include "tinyptc.h"

#define WIDTH 320
#define HEIGHT 200
#define SIZE WIDTH*HEIGHT
   
static int noise;
static int carry;
static int index;
static int seed = 0x12345;
static int pixel[SIZE];

int main()
{
    if (!ptc_open("test",WIDTH,HEIGHT)) return 1;
    while (1)
    {
        for (index=0; index<SIZE; index++)
        {
            noise = seed;
            noise >>= 3;
            noise ^= seed;
            carry = noise & 1;
            noise >>= 1;
            seed >>= 1;
            seed |= (carry << 30);
            noise &= 0xFF;
            pixel[index] = (noise<<16) | (noise<<8) | noise;
        }
        ptc_update(pixel);
    }
}

At present I have the setup to run in windowed mode, to change this you need to open tinyptc.h and comment out the line
Code: [Select]
#define __PTC_WINDOWED__
Hope this helps some people start on messing with C and doing a few pixel effects, it should be reasonably easy to convert some of the FB routines.

Anyway here's a zip with the directory and project, have fun and any questions I will attempt to anwser.

Cheers
Jon
Title: Re: TinyPTC project for DevCPP
Post by: Shockwave on July 19, 2006
That's excellent and really helpful.
Thanks TD :)
Title: Re: TinyPTC project for DevCPP
Post by: relsoft on July 19, 2006
Yeah all I had to do was add some typedefs

Code: [Select]
// integer types
typedef unsigned __int32 int32;
typedef unsigned __int16 short16;
typedef unsigned __int8 char8;

Then disable MMX.

PS. I've attached and example file I made when I was helping a dev from Bmax trying to make TPTC work with BMAX (Bmax uses GCC) :*)
Title: Re: TinyPTC project for DevCPP
Post by: TinDragon on July 19, 2006
Do you know if they got tinyPTC working in Bmax ? 

Would be very interested if they did, I have been thinking about looking into that myself being a bmax owner :)

[Edit]  Forgot to post this. Attach is a new zip with just the DDraw setup.  I made this before i noticed Relsofts post.

I have reduced the TinyPTC files to the bare minimum needed for DirectDraw minus the Directx files themselves, which I recommend getting the full package for from the site I posted earlier incase you decide to do more than use just TinyPTC ;)

Cheers jon
Title: Re: TinyPTC project for DevCPP
Post by: Jim on July 19, 2006
Good work!  That definitely lowers the barrier for entry!

Jim
Title: Re: TinyPTC project for DevCPP
Post by: Rbz on July 20, 2006
Nice work !  :cheers:
Title: Re: TinyPTC project for DevCPP
Post by: relsoft on July 20, 2006
TTD. Yep, according to him it worked with Bmax.
Title: Re: TinyPTC project for DevCPP
Post by: TinDragon on July 20, 2006
Thanks guys, I hope we can get a few people doing something in C/C++, it's much more fun when you can get a visual display rather than just some text saying "Hello World"  :D

@Relsoft, all my attempts have given me linker errors but I suspect I am missing something from the process, bmax documentation on this sort of thing isnt the best. If you have or can get any info on how it's done I would be most grateful.

Title: Re: TinyPTC project for DevCPP
Post by: DruggedBunny on July 20, 2006
Hi all, I'm the guy Relsoft was dealing with. (Thanks again Rel!) I did get it basically working in BlitzMax... I'll try dig it out.
Title: Re: TinyPTC project for DevCPP
Post by: TinDragon on July 20, 2006
@DruggedBunny,  first off,  Welcome to the board  :hi:

Thanks for posting and if your able to find what you did it would be very cool. Having tried a few times it would be nice to get it to work with a language I am more familiar with  :)
Title: Re: TinyPTC project for DevCPP
Post by: relsoft on July 20, 2006
Hi all, I'm the guy Relsoft was dealing with. (Thanks again Rel!) I did get it basically working in BlitzMax... I'll try dig it out.


Hello.  Nice to see you here. :*)

Title: Re: TinyPTC project for DevCPP
Post by: DruggedBunny on July 20, 2006
Hi all,

Thanks for the welcome, though I have been lurking on here and the old board (plus the old YaBasic Homebrew board) for quite a long time. I love seeing low-level pixel effects and software 3D renderers, clever optimisations, etc, but I'm completely useless at that sort of thing.

I've posted the BlitzMax TinyPTC library here for those interested:

http://dbfinteractive.com/index.php?topic=453.0
Title: Re: TinyPTC project for DevCPP
Post by: Shockwave on July 20, 2006
Nice one :)
 :hi: to the board and have some good karma for the Bmax ptc lib!
Title: Re: TinyPTC project for DevCPP
Post by: taj on August 29, 2006
Thanks for that, could be useful. Anyone got a GCC asm version (as in no PTC, just asm calls to do the same)?
Title: Re: TinyPTC project for DevCPP
Post by: Shockwave on August 29, 2006
Probably Rbraz, Jim or Stonemonkey will be able to help there I'd guess.
Title: Re: TinyPTC project for DevCPP
Post by: Rbz on August 30, 2006
Quote
Thanks for that, could be useful. Anyone got a GCC asm version (as in no PTC, just asm calls to do the same)?
Sorry, I have no ideaƂ  ???
Title: Re: TinyPTC project for DevCPP
Post by: ferris on November 20, 2006
If you want MMX back in there (trust me; it's SOOOOOOO worth it for this lib) you'll need nasmw, and write a .bat file for the compilation. I could be of some help, but not now - if anyone wants it done send me a PM or I'll forget :P