So recently I've been trying to make a little effect on a Casio Prizm and have finally managed to draw sprites to the screen (thanks to that new pre-compiled SDK, may I add!) though I've ran into another wall. I'm trying to fill the white background of my program with a blue color, but the pre-made function suggested by the wiki isn't working. Here is my code:

Code:
#include <fxcg/display.h>
#include <fxcg/keyboard.h>
#include <math.h>

void CopySprite(const color_t* palette, int x, int y, int width, int height) {
   color_t *VRAM = (color_t*)GetVRAMAddress();
   VRAM += LCD_WIDTH_PX * y + x;
   for (int j = y; j < y + height; j++) {
      for (int i = x; i < x + height; i++) {
         *(VRAM++) = *(palette++);
      }
      VRAM += LCD_WIDTH_PX - width;
   }
}

void fillArea(unsigned x, unsigned y, unsigned w, unsigned h, unsigned short col) {
   unsigned short*s = (unsigned short*)0xA8000000;
   s += (y * 384) + x;
   while (h--) {
      unsigned w2 = w;
      while (w2--)
         *s++ = col;
      s += 384 - w;
   }
}

int main() {
   const color_t sprite[2048] = {
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0xff64,0xff64,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x042a,0x042a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x042a,0x042a,0x042a,0x042a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x042a,0x042a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x042a,0x042a,0x042a,0x042a,0xff64,0xff64,0xff64,0xff64,0xff64,0xff64,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,
      0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,
      0x0726,0x0726,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,
      0x0726,0x0726,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,
      0x0726,0x0726,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,
      0x0726,0x0726,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0xfbb5,0xfbb5,0xfbb5,0xfbb5,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,
      0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,
      0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x194a,0x194a,0x194a,0x194a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,
      0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,
      0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x042a,0x042a,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x0726,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x042a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,
      0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a,0x194a
   };

   fillArea(0, 0, LCD_WIDTH_PX, LCD_HEIGHT_PX, 0x194a);
   CopySprite(sprite, 64, 64, 32, 32);

   int key;
   while (1) GetKey(&key);

   return 0;
}

I've also tried using values that aren't LCD_WIDTH_/HEIGHT_PX and placing the line after using CopySprite but it still doesn't work. Any suggestions on what I'm doing wrong?
You haven't said what's wrong about it.

But it looks like you're trying to use 16-bit color which means you need to Bdisp_EnableColor(1).
I agree with Tari

Also in fillArea I would not hard code the
unsigned short*s = (unsigned short*)0xA8000000;
and use GetVRAMAddress() syscall as in CopySprite to keep the compatibilty with new FX-CG50 i.e:
unsigned short*s = (unsigned short*)GetVRAMAddress();
should work or maybe using color_t type for the above too

Also sprite[2048] declaration I think should be 1024 size not 2048 (if 32x32)

I suspect the image will show after you hit some key on the calculator but if you need your artwork to display straight away look into adding Bdisp_PutDisp_DD() syscall for example

I hope the above helps and let us know how it goes please
Bad habit to put your images on the stack.
Tari wrote:
You haven't said what's wrong about it.

But it looks like you're trying to use 16-bit color which means you need to Bdisp_EnableColor(1).

Oh, sorry, you're totally right. The issue is that I could see no noticeable difference, but this fixed it! Should've listened to you the first time you told me. Thank you so much!
amazonka wrote:
I agree with Tari

Also in fillArea I would not hard code the
unsigned short*s = (unsigned short*)0xA8000000;
and use GetVRAMAddress() syscall as in CopySprite to keep the compatibilty with new FX-CG50 i.e:
unsigned short*s = (unsigned short*)GetVRAMAddress();
should work or maybe using color_t type for the above too

Also sprite[2048] declaration I think should be 1024 size not 2048 (if 32x32)

I suspect the image will show after you hit some key on the calculator but if you need your artwork to display straight away look into adding Bdisp_PutDisp_DD() syscall for example

I hope the above helps and let us know how it goes please

It did help, the function works perfectly now! And about the sprite declaration, it would be 1024 size if I declared the palette separately, but when I choose the setting that produces only one array on Sourcecoder the size doubles. Should I change to the other method?
MateoConLechuga wrote:
Bad habit to put your images on the stack.

Not sure what you mean.
emibudd wrote:
MateoConLechuga wrote:
Bad habit to put your images on the stack.

Not sure what you mean.

Your sprite is inside the local stack for the main function.
May i recommend trying to see if the image can be exported with pallet color (CopySpriteNBit), as it can save much more space rather than using full 16bpp
MateoConLechuga wrote:
emibudd wrote:
MateoConLechuga wrote:
Bad habit to put your images on the stack.

Not sure what you mean.

Your sprite is inside the local stack for the main function.

Make the variable static. It is already const, so then it should be stored in flash.
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement