I would've assumed this was something used a lot, but I couldn't find anything. Is there a way to copy sprite flipped horizontally?
I'm not sure if there is an inbuilt way to do this, but you could probably just manually flip the data, which is what the OS would do internally if there was a Syscall for this.
hmm.. It just turned out all black for me. Is this what you basically meant though?

Code:

#include <fxcg/display.h>
#include <fxcg/keyboard.h>
#include <stdlib.h>
#include <stddef.h>

color_t* flip_horizontal(color_t* b, size_t size) {
  color_t* flipped = malloc(size * sizeof(color_t));
  for (size_t i = 0; i < size; i++) {
      flipped[i] = b[size - i - 1];
  }
  return flipped;
}

int main() {
  Bdisp_EnableColor(1);
  EnableStatusArea(3);
  Bdisp_AllClr_VRAM();

  // Original
  VRAM_CopySprite(sprite, 167, 101, 25, 7);

  // Flipped Horizontally
  size_t size = sizeof(sprite) / sizeof(color_t);
  color_t* flipped = flip_horizontal(sprite, size);
  VRAM_CopySprite(flipped, 167, 131, 25, 7);

  Bdisp_PutDisp_DD();
 
  int key;
  while(1)
    GetKey(&key);
 
  return 0;
}
QuietRiot wrote:
hmm.. It just turned out all black for me. Is this what you basically meant though?

Code:

#include <fxcg/display.h>
#include <fxcg/keyboard.h>
#include <stdlib.h>
#include <stddef.h>

color_t* flip_horizontal(color_t* b, size_t size) {
  color_t* flipped = malloc(size * sizeof(color_t));
  for (size_t i = 0; i < size; i++) {
      flipped[i] = b[size - i - 1];
  }
  return flipped;
}

int main() {
  Bdisp_EnableColor(1);
  EnableStatusArea(3);
  Bdisp_AllClr_VRAM();

  // Original
  VRAM_CopySprite(sprite, 167, 101, 25, 7);

  // Flipped Horizontally
  size_t size = sizeof(sprite) / sizeof(color_t);
  color_t* flipped = flip_horizontal(sprite, size);
  VRAM_CopySprite(flipped, 167, 131, 25, 7);

  Bdisp_PutDisp_DD();
 
  int key;
  while(1)
    GetKey(&key);
 
  return 0;
}


Yeah, that's what I meant. I don't have a huge amount of experience with sprites but it seems like this should work. A few things (which probably won't help) which I would note:
- The malloc-ed flip_horizontal return was not freed.
- Make sure that you are defining the sprite variable. You probably are, it's just not in the code snippet.

You could also copy the VRAM_CopySprite routine (from here) and change it there.
Other than that, I am probably of no help whatsoever.
  
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