CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 117 users online: 8 members, 87 guests and 22 bots.
Members: juju2143, legodude, LuxenD, tiago94, Xeda112358.
Bots: Magpie Crawler (3), Googlebot (19).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 16 Jan 2012 01:00:35 pm    Post subject:

We need to get these all on the wiki one of these days. Smile Ashbad, speak to me at some point about this if you'd be willing to help me organize them onto it.
_________________


Back to top
Ashbad


... I think redheaded girls are kind of cool


Joined: 01 Dec 2010
Posts: 2417
Location: Stomp Stomp Stomp, The Idiot Convention

Posted: 16 Jan 2012 01:11:04 pm    Post subject:

KermMartian wrote:
We need to get these all on the wiki one of these days. Smile Ashbad, speak to me at some point about this if you'd be willing to help me organize them onto it.


Okay, sounds good Smile just PM some link to this wiki, and I can start adding my stuff to it.
_________________
-Ashbad
Back to top
Eiyeron


Member


Joined: 12 Dec 2011
Posts: 158

Posted: 16 Jan 2012 04:50:14 pm    Post subject:

I think I should publish my routines...
Where is my HDD?...
/me goes to sleep, then 'll think to publish him routines, there are a lot of useful graphics functions!
_________________
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 16 Jan 2012 05:34:46 pm    Post subject:

Eiyeron, that's great! Be sure to do so, and I'll have to give you a wiki link too. Ashbad, check your PMS.
_________________


Back to top
Ashbad


... I think redheaded girls are kind of cool


Joined: 01 Dec 2010
Posts: 2417
Location: Stomp Stomp Stomp, The Idiot Convention

Posted: 25 Jan 2012 07:34:14 am    Post subject:

CopySpriteMaskedAlpha: takes the same params as CopySpriteMasked, but with an alpha transparency channel between 0-31.


Code:
void CopySpriteMaskedAlpha(const void*datar, int x, int y, int width, int height, int maskcolor, int alpha) {
   color_t*data = (color_t*) datar;
   color_t* VRAM = (color_t*)0xA8000000;
   VRAM += LCD_WIDTH_PX*y + x;
   alpha %= 32;
   for(int j=y; j<y+height; j++) {
      for(int i=x; i<x+width;  i++) {
         if (*(data) != maskcolor) {
         *(VRAM) = (color_t)((((int)(*data & 0xf81f) * alpha + (int)(*VRAM & 0xf81f) * (32-alpha) + 0x8010) >> 5) & 0xf81f) |
                (color_t)((((int)(*data & 0x07e0) * alpha + (int)(*VRAM & 0x07e0) * (32-alpha) + 0x0400) >> 6) & 0x07e0);
           VRAM++; data++;
         } else { VRAM++; data++; }
      }
      VRAM += LCD_WIDTH_PX-width;
   }
}

_________________
-Ashbad
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 25 Jan 2012 12:15:08 pm    Post subject:

Awesome! Sounds like I need to get you to add the ability for SourceCoder to generate this format, or just do it myself.
_________________


Back to top
Ashbad


... I think redheaded girls are kind of cool


Joined: 01 Dec 2010
Posts: 2417
Location: Stomp Stomp Stomp, The Idiot Convention

Posted: 25 Jan 2012 12:38:47 pm    Post subject:

KermMartian wrote:
Awesome! Sounds like I need to get you to add the ability for SourceCoder to generate this format, or just do it myself.


Well, actually, this routine doesn't take a built-in channel Sad (edit: the whole image is taken as opaque and masked, and then the entire thing is alpha blended at the same level, which is given as a paramter) but because you prompted, I just whipped together a new format (RGBAX 56553, where X, for those few who don't know, is unused by the routine and can be used for something entirely else if wanted -- in this case, it's only 3 bits large per pixel) that uses a new type color_t_rgbax, which is 24 bits large instead of the original 565 color_t which is 16 bits. *Now* there's something to add to SC2.5 Smile


Code:
typedef struct {
   union {
      unsigned int : 24;
      struct {
         unsigned int r : 5;
         unsigned int g : 6;
         unsigned int b : 5;
         unsigned int a : 5;
         unsigned int x : 3;
      };
   };
} color_t_rgbax;

void CopySpriteMasked5655(const void*datar, int x, int y, int width, int height, int maskcolor) {
   color_t_rgbax*data = (color_t*) datar;
   color_t* VRAM = (color_t*)0xA8000000;
   VRAM += LCD_WIDTH_PX*y + x;
   for(int j=y; j<y+height; j++) {
      for(int i=x; i<x+width;  i++) {
         if ((color_t)*(data) != maskcolor) {
         int alpha = *data & 0x0000F8;
         *(VRAM) = (color_t)((((int)((*data>>8) & 0xf81f) * alpha + (int)(*VRAM & 0xf81f) * (32-alpha) + 0x8010) >> 5) & 0xf81f) |
                (color_t)((((int)((*data>>8) & 0x07e0) * alpha + (int)(*VRAM & 0x07e0) * (32-alpha) + 0x0400) >> 6) & 0x07e0);
           VRAM++; data++;
         } else { VRAM++; data++; }
      }
      VRAM += LCD_WIDTH_PX-width;
   }
}


Should work, untested, but only really minor additions made to my original routine.
_________________
-Ashbad
Back to top
AHelper


LONG LIVE COMICTECH


Joined: 30 Jan 2011
Posts: 1657
Location: Aufhelperstan, Utopian Republic

Posted: 25 Jan 2012 09:29:48 pm    Post subject:

So, I have looked at compression on GlassOS before, but SDCC just couldn't compile the library I was using. So, the prizm has more memory, so here it is:

Basic Compression Library

It impliments
  • RLE
  • Huffman
  • LZ77
  • SF - Shannon-Fano
  • rice8/8s/16/16s/32/32s

For example, I took a 40320 byte image and compressed and uncompressed on the prizm successfully using huffman compression. The compressed size is 15789 for this particular image, 39% of the actual size! So, how do you compress? Get that archive and build the compressor for your PC. Take your raw image data and save it to a file, such as fun.raw. use ./bfc.exe c huff fun.raw fun.huff to make a compressed image with header data. Remove the first 96 bits of that file as it was added by the bfc.exe and isn't part of the compression. Done! Add that data to your source file (you can use okteta from KDE to convert the binary file to a C array).

On the calculator, you need to malloc a buffer of the same size as the uncompressed data. Use Huffman_Uncompresss(compresseddata, outbuffer, compressedsize, uncompressedsize) to get the data from it, done!

Now, using this for a large background may be useful as you would only have 1 background malloc'd at a time, and you don't have the memory for multiple malloc'd at once. Decompressing isn't lightning fast as a PC as the prizm is under 60 Hz Razz For me, decompressing is about 0.5 sec. for the 40320 image.

I know that the LZ77 method allows for much better compression ratios, but compressing on-calc isn't reasonable as the method is a brute-force compressor and can be slow, but decompression should be fine.
_________________
°ᴥ° Get Lucky

<BrandonW> "You don't even want to know what TI Connect does when it's just detecting your calculator...It ACTUALLY ERASES THE SWAP SECTOR on every communication attempt...EVERY SINGLE ATTEMPT...Yes, TI Connect will kill your calculator..What do I have to do to get your attention?!....Such a bloated protocol."
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 26 Jan 2012 12:14:03 am    Post subject:

Is there anything that prevents you from using the VRAM or some offset thereof directly for the outbuffer? Can you (or me, of course) add an optional "step" argument to that command so that you can skip M pixels copying an SxT patch to outbuffer, allowing you to copy a patch of S<A, T<=B onto a screen buffer of AxB = (S+M)xB = 384x216 pixels to VRAM?
_________________


Back to top
AHelper


LONG LIVE COMICTECH


Joined: 30 Jan 2011
Posts: 1657
Location: Aufhelperstan, Utopian Republic

Posted: 26 Jan 2012 12:17:21 am    Post subject:

You can write directly to the VRAM, yes. Just have *out as the start of the VRAM and it will work. The buffer needs to be at max the size of the uncompressed data. However, if you want to do compression on files, such as if you make a game with levels, you can compress them to save on space as speed isn't an issue. Which goes back to the the VRAM. Once you decompress to the VRAM, you have to reserve it or else you must uncompress it again, taking up a lot of time.
_________________
°ᴥ° Get Lucky

<BrandonW> "You don't even want to know what TI Connect does when it's just detecting your calculator...It ACTUALLY ERASES THE SWAP SECTOR on every communication attempt...EVERY SINGLE ATTEMPT...Yes, TI Connect will kill your calculator..What do I have to do to get your attention?!....Such a bloated protocol."
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 26 Jan 2012 11:27:45 am    Post subject:

What about the step option? Also, did you happen to upload this to the archives anyway, or is it a simple build-from-source with no modifications needed?
_________________


Back to top
AHelper


LONG LIVE COMICTECH


Joined: 30 Jan 2011
Posts: 1657
Location: Aufhelperstan, Utopian Republic

Posted: 26 Jan 2012 11:44:39 am    Post subject:

Just modify the uncompressor. It simply is a for loop that writes to pointer and inc's it. I didn't upload it as I just gave the url to the source Wink
_________________
°ᴥ° Get Lucky

<BrandonW> "You don't even want to know what TI Connect does when it's just detecting your calculator...It ACTUALLY ERASES THE SWAP SECTOR on every communication attempt...EVERY SINGLE ATTEMPT...Yes, TI Connect will kill your calculator..What do I have to do to get your attention?!....Such a bloated protocol."
Back to top
merthsoft


File Archiver


Joined: 09 May 2010
Posts: 2735

Posted: 27 Jan 2012 07:08:04 pm    Post subject:

Here's a function that wraps around the sys calls and stuff for printing little text:

Code:
int PrintMiniFix( int x, int y, const char*Msg, const int flags, const short color, const short bcolor ){
int i = 0, dx;
unsigned short width;
void*p;

   while ( Msg[ i ] ){
      p = GetMiniGlyphPtr( Msg[ i ], &width );
      dx = ( 12 - width ) / 2;
      if ( dx > 0 ) {
         PrintMiniGlyph( x, y, (void*)empty, flags, dx, 0, 0, 0, 0, color, bcolor, 0 );
      }else dx = 0;
      PrintMiniGlyph( x+dx, y, p, flags, width, 0, 0, 0, 0, color, bcolor, 0 );
      if ( width+dx < 12 ){
         PrintMiniGlyph( x+width+dx, y, (void*)empty, flags, 12-width-dx, 0, 0, 0, 0, color, bcolor, 0 );
      }
      x += 12;
      i++;
   }
   return x;
}

Use it like:

Code:
PrintMiniFix(0, 175,
         "Oh look a string at the bottom of the screen.",
         0, COLOR_WHITE, COLOR_BLACK);

Empty is defined as:

Code:
const short empty[18] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

_________________
Shaun
Back to top
flyingfisch


Super-Expert


Joined: 02 Feb 2012
Posts: 893
Location: Akron, OH

Posted: 09 Feb 2012 01:02:13 pm    Post subject:

I don't know very much about C/ASM, but Kerm asked me to post this here:

http://www.top-progcasio.com/programme-216.html

It includes source code for the on-unload routine.

This is the same routine that eActivities uses for the Save dialog.
_________________



Back to top
gbl08ma


Power User


Joined: 26 Nov 2011
Posts: 475
Location: Portugal

Posted: 13 Feb 2012 01:29:13 pm    Post subject:

Oh well. The program fxLock flyingfisch posted includes source code, and I seem to understand how SetQuitHandler(void(*callback)(void)) works (it's described in the fx9860 SDK), the problem is that I'd like to use it on my screen locker (at least just as an experiment) but the PrizmSDK doesn't seem to have that function implemented. Any ideas?
_________________
My blog, where I write about random things... | tiny URL shortener
View JPEG images on your Prizm | Utilities for the Casio Prizm - clock, stopwatch, calendar/agenda, add-in manager and more!
Back to top
merthsoft


File Archiver


Joined: 09 May 2010
Posts: 2735

Posted: 13 Feb 2012 02:06:56 pm    Post subject:

Likely hasn't been exposed yet. You should bug Jonimus.
_________________
Shaun
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 10 Mar 2012 10:26:50 am    Post subject:

This is more of a generally-useful C routine or even general algorithm, but it takes a value z between z_min and z_max and converts it to a color. When z=z_max, the output color is dark blue; when z=z_min, it's maroon. The colors pass through bright red #F00) to yellow (#FF0) to bright green (#0F0) to aqua (#0FF) to bright blue (#00F) along the way. Enjoy, and I of course wouldn't mind a little attribution, but not necessary.

Code:

short unsigned int heightcolor(float z, float z_min, float z_max) {
         float frac = ((z-z_min)/(z_max-z_min));
         
         //color!
         float r = (0.25f)-frac;
         float g = (0.5f)-frac;
         float b = (0.75f)-frac;

         //calculate the R/G/B values
         r = (r>0.f)?r:-r; g = (g>0.f)?g:-g; b = (b>0.f)?b:-b;   //absolute value
         r = (0.25f)-r; g = (1.f/3.f)-g; b = (0.25f)-b;   //invert
         r = (r>0.f)?(6.f*r):0.f; g = (g>0.f)?(6.f*g):0.f; b = (b>0.f)?(6.f*b):0.f;   //scale the chromatic triangles
         r = (r>1.f)?1.f:r; g = (g>1.f)?1.f:g; b = (b>1.f)?1.f:b;   //clip the top of the chromatic triangles
         if (frac < 0.25f) r = (r+1.f)/2.f;   //adjust the bottom end of the scale so that z_min is red, not black
         if (frac > 0.75f) b = (b+1.f)/2.f;   //adjust the top end of the scale so that z_max is blue, not black
         return (short unsigned int)(0x0000ffff & (((int)(31.f*r) << 11) | ((int)(63.f*g) << 5) | ((int)(31.f*b))));   //put the bits together
}

_________________


Back to top
_player1537


Guru-in-Training


Joined: 25 Nov 2009
Posts: 2957

Posted: 10 Mar 2012 10:40:48 am    Post subject:

Thank you, Kerm! Very Happy It fit into my program really well and I barely had to change anything: http://img.removedfromgame.com/imgs/mandelbrot-Kerm-color.png
_________________
http://tanner.myserverathome.com
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 10 Mar 2012 10:49:23 am    Post subject:

Neat! It looks like you might need to be a little more specific with your maximum z value, though?
_________________


Back to top
_player1537


Guru-in-Training


Joined: 25 Nov 2009
Posts: 2957

Posted: 10 Mar 2012 10:55:52 am    Post subject:

Indeed, I changed it to a fixed amount, rather than the changing maxIteration value, and it looks a lot more vibrant: http://img.removedfromgame.com/imgs/mandelbrot-Kerm-color-max-changed.png FWIW, here is the only part of the code that I changed (Pretty much just styling and making it use a Java function header):
Code:
  /* Awesome color routine from Kerm!! */
  private Color getColor(float z, float z_min, float z_max) {
    float frac = ((z-z_min)/(z_max-z_min));
   
    //color!
    float r = (0.25f)-frac;
    float g = (0.5f)-frac;
    float b = (0.75f)-frac;
   
    //calculate the R/G/B values
    r = (r>0.f)?r:-r;            g = (g>0.f)?g:-g;          b = (b>0.f)?b:-b;              //absolute value
    r = (0.25f)-r;               g = (1.f/3.f)-g;           b = (0.25f)-b;                 //invert
    r = (r>0.f)?(6.f*r):0.f;     g = (g>0.f)?(6.f*g):0.f;   b = (b>0.f)?(6.f*b):0.f;       //scale the chromatic triangles
    r = (r>1.f)?1.f:r;           g = (g>1.f)?1.f:g;         b = (b>1.f)?1.f:b;             //clip the top of the chromatic triangles
    if (frac < 0.25f) r = (r+1.f)/2.f;   //adjust the bottom end of the scale so that z_min is red, not black
    if (frac > 0.75f) b = (b+1.f)/2.f;   //adjust the top end of the scale so that z_max is blue, not black
    return new Color(r, g, b);
    //return (short unsigned int)(0x0000ffff & (((int)(31.f*r) << 11) | ((int)(63.f*g) << 5) | ((int)(31.f*b))));   //put the bits together
  }
And here's the code that calls it (iteration is a variable for how many iterations it was able to do before it reached infinity):
Code:
return getColor((float)iteration, (float)0, 200.0f);

_________________
http://tanner.myserverathome.com
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    » Goto page Previous  1, 2, 3 ... 6, 7, 8, 9, 10, 11  Next
» View previous topic :: View next topic  
Page 7 of 11 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.051873 seconds.