Author Topic: TinyPTC project for DevCPP  (Read 9715 times)

0 Members and 1 Guest are viewing this topic.

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
TinyPTC project for DevCPP
« 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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC project for DevCPP
« Reply #1 on: July 19, 2006 »
That's excellent and really helpful.
Thanks TD :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #2 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) :*)
« Last Edit: July 19, 2006 by relsoft »
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: TinyPTC project for DevCPP
« Reply #3 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
« Last Edit: July 19, 2006 by TinDragon »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #4 on: July 19, 2006 »
Good work!  That definitely lowers the barrier for entry!

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC project for DevCPP
« Reply #5 on: July 20, 2006 »
Nice work !  :cheers:
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #6 on: July 20, 2006 »
TTD. Yep, according to him it worked with Bmax.
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: TinyPTC project for DevCPP
« Reply #7 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.


Offline DruggedBunny

  • ZX 81
  • *
  • Posts: 8
  • Karma: 2
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #8 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.

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: TinyPTC project for DevCPP
« Reply #9 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  :)

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #10 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. :*)

Challenge Trophies Won:

Offline DruggedBunny

  • ZX 81
  • *
  • Posts: 8
  • Karma: 2
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #11 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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC project for DevCPP
« Reply #12 on: July 20, 2006 »
Nice one :)
 :hi: to the board and have some good karma for the Bmax ptc lib!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: TinyPTC project for DevCPP
« Reply #13 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)?
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC project for DevCPP
« Reply #14 on: August 29, 2006 »
Probably Rbraz, Jim or Stonemonkey will be able to help there I'd guess.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC project for DevCPP
« Reply #15 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Ƃ  ???
Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: TinyPTC project for DevCPP
« Reply #16 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
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won: