Author Topic: Cobra 'mini'  (Read 3595 times)

0 Members and 1 Guest are viewing this topic.

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Cobra 'mini'
« on: March 13, 2007 »


A new little teaser for you, just to show I'm taking demo coders seriously  :||

I've started on a 'bare bones' engine, based around the ptc stuff I've seen in other parts of the forum.. It's pretty basic at the moment, but it runs shocky's raster code reasonably well so far, while still retaining a lot of cobra functionality (as in core functionality, rather than gfx engine functionality).

At present it provides the ability to create frambuffers and read/write to them on a pixel by pixel basis, that's about it at the moment (full keyboard support is in there though).

Here is an example of the raster code:
Code: [Select]
// RASTER EFFECT BY SHOCKWAVE.
// ---------------------------
// FEBRUARY 2007.
// LAME I KNOW, BUT FROM LITTLE ACORNS ETC....!!!!
// updated to test the use of 'cobramini', a new low level lib for cobra.
//----------------------------------------------------------------------------------------------------------------------------------
PROGRAM USES cobramini, KEYSET
//----------------------------------------------------------------------------------------------------------------------------------
CONST XRES = 640
CONST YRES = 480
VAR
GADD : REAL =0
GADD2: REAL =0
GADD3: REAL =0
v,r,j:integer
//----------------------------------------------------------------------------------------------------------------------------------
        PROCEDURE INITIALISE()
        BEGIN
            OPENSCREEN( XRES , YRES)
        END         
//----------------------------------------------------------------------------------------------------------------------------------                 
//----------------------------------------------------------------------------------------------------------------------------------       
// MAIN PROGRAM
//----------------------------------------------------------------------------------------------------------------------------------

VAR
  Y        : INTEGER   
  RD,GR,BL : REAL
  t1,t2,d:real 
  frames,fps:integer
  ImagePointer:integer
BEGIN
INITIALISE()
frames = 0
t1 = millisecs
WHILE NOT KEYDOWN (VK_ESCAPE)
      GADD=GADD+1
    GADD2=GADD2+2
    GADD3=GADD3+3
             
    if Millisecs-t1< 1000 then
        inc(frames)
    else
        fps = frames
        frames = 0
        t1 = millisecs
    endif
    ImagePointer = currentmembuffer                 
   
        FOR Y=0 TO YRES-1       
            RD = 125+((SIN(Y+GADD3)*50)+(COS(Y+GADD2)*50)-(SIN(Y+GADD)*24))
            GR = 125+((SIN(Y+GADD2)*50)+(COS(Y+GADD)*50)+(SIN(Y+GADD3)*24))
            BL = 125+((SIN(Y+GADD)*50)-(COS(Y+GADD3)*50)-(SIN(Y+GADD2)*24))
            r = ToRGB(rd,gr,bl)
            v = ImagePointer + (y*xres*4)
            j=xres     
           
            asm
                @mov eax,[!r]     
                @mov ecx,[!j]
                @mov edi,[!v]
                @rep stosd
            endasm

        NEXT

   
    FLIP
WEND
  MessageBox('FPS:'+fps)
END

Nice thing is, it also compiles down much smaller, ok not the 40k you can get with freebasic, 271k which is still a quarter of the usual exe size for cobra.

So, the question is... If I develop this further, what features would you, as demo coders, want in there ? (remembering that I would want to try and keep this as a low level library).

Things on the list so far (note excessive use of the word "simple")
1. Simple sound engine (probably just mod's, maybe wave files)
2. Simple drawing commands (including writing text to a buffer, as that can be a pain)
3. Simple image loader (probably restricted to bmp, or at a push include png)

I've attached the above code as an exe for you to have a look at.

« Last Edit: March 14, 2007 by GrahamK »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Cobra 'mini'
« Reply #1 on: March 13, 2007 »
That runs at around 540fps here, that's more than acceptable :D

As for what features, I don't just want to spout off a load of things here, I need to think about this, and post back later or tomorrow, but two things that spring to mind immediately are the ability to draw windows fonts and music playability with some way of monitoring the sound levels in the sound channels...

I could see it getting some fans :)

Btw, is this packed already? Upx says it is :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #2 on: March 13, 2007 »
Cobra includes it's own packer as part of it's build.

Working on getting hold of a 'mod' module, not sure on monitoring the sound levels (but I know what you are getting at ;) ) Fonts drawing "shouldn't" be an issue.
But have a good think, I'm not rushing at this, its been more of a diversion at the moment. But I'm willing to put some effort in if it's something people like.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7245
  • Karma: 71
    • View Profile
Re: Cobra 'mini'
« Reply #3 on: March 13, 2007 »
Thats way cool, grand job Graham dude.
btw, 413 Fps.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #4 on: March 14, 2007 »
Ok, I've included support for XM playback, thanks to the most excellent uFMOD :D
Also added limited text output (no control as yet, just basic text output to screen).

Updated download demo up on the first post....

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7245
  • Karma: 71
    • View Profile
Re: Cobra 'mini'
« Reply #5 on: March 14, 2007 »
Very cool addition dude, nice going :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Cobra 'mini'
« Reply #6 on: March 14, 2007 »
That's fantastic!

Nice that the sound and everything is resourced into the exe too :D

Tell me, what are the numbers next to the fps?

There are two in brackets and then a timer..

What are the two numbers in brackets? :)

Thanks!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #7 on: March 14, 2007 »
According to the uFmod docs..

The uFMOD_GetStats function returns the current RMS volume coefficients
 in L and R channels.
 --------------
 Return Values:
    low-order word : RMS volume in R channel
    hi-order  word : RMS volume in L channel


Not entirely sure what that means myself, going to have a play around tonight. Kinda looks like its some data that could be used for a vu-meter (or summat!)


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Cobra 'mini'
« Reply #8 on: March 14, 2007 »
RMS is sound level then, so ufmod is spitting out a longword with the sound values :D

Sweet. This will make sync very simple with cobra. Nice one Graham.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7245
  • Karma: 71
    • View Profile
Re: Cobra 'mini'
« Reply #9 on: March 14, 2007 »
Looks to me like stereo channels, left and right speakers.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Cobra 'mini'
« Reply #10 on: March 14, 2007 »
Yep, that's what Graham said ;)

L + R Channels = Left and Right :)

You'd like this Clyde, you love doing your synced demos, this would be a nice thing for you.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Steve Elliott

  • ZX 81
  • *
  • Posts: 23
  • Karma: 1
    • View Profile
Re: Cobra 'mini'
« Reply #11 on: March 14, 2007 »
Whoah!  Now that's faster!  :D

Cobra runs most programs very quickly indeed - Shockwave found something it didn't do quite so well.  Good idea to try and resolve it Graham - hope the talented guys here can come up with some cool demos and show off what Cobra is capable of - you have to include PNG support though.
« Last Edit: March 14, 2007 by Steve Elliott »
Intel Core2 Duo E7200 @ 2.53Ghz, 3Gb RAM Intel G45 Express, Windows Vista Home Premium
Samsung NC10 Intel Atom @ 1.60Ghz, 2Gb RAM, Intel 945 Express, Windows XP Home Edition
Scorpions's coming...

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #12 on: March 14, 2007 »
It should have jpg, png and bmp (fingers crossed), this will also be coming to the sunday cobra patch  (in fact, it IS the patch on sunday ;) )

here is another example, using the L-R values...


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Cobra 'mini'
« Reply #13 on: March 14, 2007 »
That's almost a cracktro :D

I just noticed that the music isn't resourced inside the exe.. Is it a pain in the arse to one file it?
Shockwave ^ Codigos
Challenge Trophies Won:

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #14 on: March 14, 2007 »
at the moment yeah :(
Saying that, I've been tinkering (again) and I may have an approach soon. Rather than have something 'just' for cobra mini, I want to try and get something more general, as it would be bloody useful for the rest of cobra too :D

I think for demo's it would be a real plus (I guess that is what you are getting at!) so I'll certianly be looking into it.

Offline rdc

  • Pentium
  • *****
  • Posts: 1480
  • Karma: 139
    • View Profile
    • Clark Productions
Re: Cobra 'mini'
« Reply #15 on: March 15, 2007 »
You might want to look at the bin2bas program. It converts a file to a binary representation. You should be able to do something like that in Cobra.


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17296
  • Karma: 489
  • evil/good
    • View Profile
    • My Homepage
Re: Cobra 'mini'
« Reply #16 on: March 15, 2007 »
I use a version of bin2bas at the moment indeed. It was coded by rbraz and converts a resource file into and array of unsigned bytes. I get along with it just fine, it confuses some people though.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #17 on: March 15, 2007 »
it's probably going to end up as

Code: [Select]
BINARY myfile "filename.something"

with a couple of supporting commands
Code: [Select]
        addr = binaryptr(myfile)
        ln = binarylength(myfile)

I'm also thinking about adding "dataptr" to allow access to raw data statements via assembler.


Offline Steve Elliott

  • ZX 81
  • *
  • Posts: 23
  • Karma: 1
    • View Profile
Re: Cobra 'mini'
« Reply #18 on: March 15, 2007 »
I love the sound of this low level stuff.  Perhaps Cobra could be 'promoted' to the main set of languages now?  ;)
Intel Core2 Duo E7200 @ 2.53Ghz, 3Gb RAM Intel G45 Express, Windows Vista Home Premium
Samsung NC10 Intel Atom @ 1.60Ghz, 2Gb RAM, Intel 945 Express, Windows XP Home Edition
Scorpions's coming...

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Cobra 'mini'
« Reply #19 on: March 15, 2007 »
I think a few more users are needed first ;)