Author Topic: trying to port tajs trinnity example  (Read 10293 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: trying to port tajs trinnity example
« Reply #20 on: July 10, 2007 »
I was in the middle of replying with something about having had a look to see if I could do the loops differently but couldn't find anything that made any difference when I noticed that.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: trying to port tajs trinnity example
« Reply #21 on: July 10, 2007 »
ive actually just got the size down to 1012 bytes by writing these bits out long hand.

Code: [Select]
Dim Shared As ZString * 15 glnameA => "glCreateShader"
Dim Shared As ZString * 15 glnameB => "glShaderSource"
Dim Shared As ZString * 16 glnameC => "glCompileShader"
Dim Shared As ZString * 16 glnameD => "glCreateProgram"
Dim Shared As ZString * 15 glnameE => "glAttachShader"
Dim Shared As ZString * 14 glnameF => "glLinkProgram"
Dim Shared As ZString * 13 glnameG => "glUseProgram"

Code: [Select]
glFP( 0 ) = Cast( GenFP , wglGetProcAddress( glnameA ) )
glFP( 1 ) = Cast( GenFP , wglGetProcAddress( glnameB ) )
glFP( 2 ) = Cast( GenFP , wglGetProcAddress( glnameC ) )
glFP( 3 ) = Cast( GenFP , wglGetProcAddress( glnameD ) )
glFP( 4 ) = Cast( GenFP , wglGetProcAddress( glnameE ) )
glFP( 5 ) = Cast( GenFP , wglGetProcAddress( glnameF ) )
glFP( 6 ) = Cast( GenFP , wglGetProcAddress( glnameG ) )
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: trying to port tajs trinnity example
« Reply #22 on: July 10, 2007 »
Utterly awesome work - karma++! I would never have believed it - a basic glsl program in <1k.

heres a wild idea that might save a few more bytes. Try changing:

Code: [Select]
gluSphere( gluNewQuadric() , 1.6 , 200 , 200 )
gluSphere( gluNewQuadric() , 1.04 , 200 , 200 )
gluSphere( gluNewQuadric() , 0.4 , 200 , 200 )

to
Code: [Select]
gluSphere( gluNewQuadric() , 1.6015625000f , 200 , 200 )
gluSphere( gluNewQuadric() , 1.0390625000f , 200 , 200 )
gluSphere( gluNewQuadric() , 0.4003906250f , 200 , 200 )

In theory this makes the code easier to compress, but it doesnt work for me. Then again, your trick of writing out the loop doesnt work for me so its all a bit black magic.
Chris
« Last Edit: July 10, 2007 by chris »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: trying to port tajs trinnity example
« Reply #23 on: July 10, 2007 »
wow that takes me down to 1003 bytes thanks chris! k+


Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: trying to port tajs trinnity example
« Reply #24 on: July 10, 2007 »
Can you try changing the loop to while/wend?
Code: [Select]
while GetAsyncKeyState(VK_ESCAPE) = 0
wend
And unfortunately, for Vista, you need to add
Code: [Select]
ExitProcess(0)
at the very end, otherwise it won't quite properly :(

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: trying to port tajs trinnity example
« Reply #25 on: July 10, 2007 »
yeah no probs jim here you go.

its went back up to 1012 bytes with that.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: trying to port tajs trinnity example
« Reply #26 on: July 10, 2007 »
I just wanted to see if do/while was smaller than while/wend.  Some compilers optimise one better than the other.

If you disassemble these .o files you can see there's a chunk of stuff that looks like this
Code: [Select]
jmp fb_static_initialisers
nop
nop
nop
...
nop
fb_static_initialisers:
jmp fb_RtInit
The fbc compiler always adds this to bring in the runtime libraries.
That's a real shame as it's quite probably wasting 10 or 20 bytes compared with the C version.  Maybe I could try to blank that out of the .o before sending it to crinkler.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: trying to port tajs trinnity example
« Reply #27 on: July 10, 2007 »
ahh i see if you can save between 10 to 20 bytes that would be really cool!

i cant belive benny got this down to 990 bytes with visual studio although i think we are beating dev c as the original trinity is 1024 bytes so we are in between the two.

-edit just tested the while/wend without exit process and it goes from 1003 to 1007 bytes so it is actually a little more expensive.
« Last Edit: July 10, 2007 by ninogenio »
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: trying to port tajs trinnity example
« Reply #28 on: July 10, 2007 »
Nino, Jim, I guess the NOPS are completely optimised out by the compressor.
Still 1012 is bloody brilliant. Is this the first 1k BASIC exe ever?

Chris
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: trying to port tajs trinnity example
« Reply #29 on: July 10, 2007 »
Quote
Is this the first 1k BASIC exe ever?
I would think so :)

Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: trying to port tajs trinnity example
« Reply #30 on: July 10, 2007 »
Mindblowing :D

Now a 1KB must be released with Freebasic. K+ Nino, great port!!!! (Yes it works here now )
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: trying to port tajs trinnity example
« Reply #31 on: July 10, 2007 »
cheers for your feedback guys, but really this is all down to jim its all his fb tiny hacking im using and without it this couldnt be done so thanks big guy  :cheers:

if jim finds a way to save any more bytes ill update this and in the mean time ill see if i can come up with an original fb 1k worthy of a release *gulp*.
« Last Edit: July 10, 2007 by ninogenio »
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: trying to port tajs trinnity example
« Reply #32 on: July 10, 2007 »
@jim how would i go about dissasembling the .o files id quite like to have a little mess around?
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: trying to port tajs trinnity example
« Reply #33 on: July 10, 2007 »
The compiler option -r should give you the asm output iirc.