Author Topic: Prizm Useful Routines -- post here!  (Read 30972 times)

0 Members and 1 Guest are viewing this topic.

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #60 on: November 28, 2011, 02:23:04 am »
Not much optimization I can see there other than changing the flags in the makefile. The only thing I might do is include some type casts because your arguments are unsigned chars which don't have the necessary width for your bit shifts. My own personal preference is to use 24 bit color and then convert it to 16 bits using a simple routine because it's much easier to write out in code but your method does have a speed advantage.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline PierrotLL

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 19
  • Rating: +2/-0
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #61 on: November 28, 2011, 07:36:04 am »
IsKeyDown equivalent
Code: [Select]
int keydown(int basic_keycode)
{
const unsigned short* keyboard_register = (unsigned short*)0xA44B0000;
int row, col, word, bit;
row = basic_keycode%10;
col = basic_keycode/10-1;
word = row>>1;
bit = col + 8*(row&1);
return (0 != (keyboard_register[word] & 1<<bit));
}
Expect a Basic keycode (27=right, 38=left) or 10 to test the AC/ON key.
It allow to detect multiple pressed keys simultaneous.
« Last Edit: November 28, 2011, 08:02:10 pm by PierrotLL »

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Prizm Useful Routines -- post here!
« Reply #62 on: December 15, 2011, 05:05:47 pm »
The size of float based routines is really quite negligible and they don't use any extra ram because the entire executable is stored in flash. You could use a fixed point float in this situation but I would advise against them in this situation as the best way to write them out would be to use pre-defined macros such as TWO_POINT_FIVE which would be 0x00028000 in a 32 bit fixed point notation. The other alternative here is to specify when calling the function what size you would like to scale it to instead of providing a scale factor. Perhaps in this situation 2 different functions ought to be developed. One for rather straightforward scales that can be easily implemented such as x.5, x2, x4 and so on. This would be called as 2 raised to the x power. For example passing 0 as the scale will result in a sprite with no change in size while 1 will be x2, 2 as x4, 3 as x8, and so on. That would also mean that -1 would be .5, -2 as .25 and so on. The second routine would require much more overhead and be called with either a float factor or specify the new image size. If this sounds good I can start work on the first routine and have that out in not too long.
Bump-bi-di-bump the topic for asking someone to realize zoo-msacled sprite drawing function. That could be very useful to some animations..
I think always that 2^factors would be easier and faster to use...

moderator edit: fixed
« Last Edit: December 22, 2011, 01:11:39 am by z80man »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Prizm Useful Routines -- post here!
« Reply #63 on: December 22, 2011, 12:42:03 am »
I think you put your answer inside the quote Eiyeron ???

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #64 on: December 22, 2011, 01:16:02 am »
The size of float based routines is really quite negligible and they don't use any extra ram because the entire executable is stored in flash. You could use a fixed point float in this situation but I would advise against them in this situation as the best way to write them out would be to use pre-defined macros such as TWO_POINT_FIVE which would be 0x00028000 in a 32 bit fixed point notation. The other alternative here is to specify when calling the function what size you would like to scale it to instead of providing a scale factor. Perhaps in this situation 2 different functions ought to be developed. One for rather straightforward scales that can be easily implemented such as x.5, x2, x4 and so on. This would be called as 2 raised to the x power. For example passing 0 as the scale will result in a sprite with no change in size while 1 will be x2, 2 as x4, 3 as x8, and so on. That would also mean that -1 would be .5, -2 as .25 and so on. The second routine would require much more overhead and be called with either a float factor or specify the new image size. If this sounds good I can start work on the first routine and have that out in not too long.
Bump-bi-di-bump the topic for asking someone to realize zoo-msacled sprite drawing function. That could be very useful to some animations..
I think always that 2^factors would be easier and faster to use...

moderator edit: fixed
For shrinking sprites factors of 2 would be much faster while for enlarging there wouldn't be a difference. What could be done is that the routine checks if a factor of 2 is used and then resizes using the proper routine. It isn't too hard to check whether an integer is a factor of 2 or not especially if you limit the the scale size to something like x16

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Prizm Useful Routines -- post here!
« Reply #65 on: December 23, 2011, 03:53:45 pm »
I think you put your answer inside the quote Eiyeron ???
I think I should miswrite somewhere: I request the help from someone to make this function...

Anyway, my function for my project

Two pixels are concatened like this:
0bAAAABBBB
or
0xAB

Code: [Select]
void CopySprite_Palette_Alpha_Nibbles(unsigned char* data, unsigned short* palette, int x, int y, int width, int height) {
   unsigned short* VRAM = (unsigned short*)0xA8000000;
   unsigned short* ptr = VRAM + y*LCD_WIDTH_PX + x;
   int i,j;
   unsigned char nibble;  //Get the color's index to use.
   for(j=0; j<height; j++) {
                for(i = 0; i < width; i+=2)
                {
                nibble = (*data)>>4; We get the first pixel
                        if(nibble)  //First index is alpha.
                                *ptr = palette[nibble];  //COpy from the palette
                nibble = (*data) %16; We get the second pixel
                        if(nibble)  //On the road again
                                *(ptr+1) = palette[nibble];
/*                      else
                                *(ptr+1) = palette[0];*/ // FOr tests
                        ptr+=2; //We go furtherer on the VRAM
                        data++; //Idem
                }
                ptr += LCD_WIDTH_PX-width; // Go one line lower.
   }
}

Max 16 colours, enough for Pokémons, in example... :-°
First index is alpha
(Could you please too adapt this function to add a zoom factor, please? I would be erternally grateful)
« Last Edit: December 29, 2011, 12:53:58 pm by Eiyeron »

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #66 on: December 23, 2011, 05:05:01 pm »
Could I get some comments on that routine. Always a good practice cause it can often be difficult for some people to understand others code. I'm out of town right now but I'll write something up when I get back tomorrow

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Prizm Useful Routines -- post here!
« Reply #67 on: December 29, 2011, 12:50:25 pm »
Okay... I'll do that!

EDIT: DONE!
« Last Edit: December 29, 2011, 12:54:10 pm by Eiyeron »

Offline [email protected]

  • LV2 Member (Next: 40)
  • **
  • Posts: 33
  • Rating: +0/-0
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #68 on: September 12, 2012, 07:04:58 pm »
Sorry to go off topic, but z80man, PLEASE could you tell me how you got a gb emulator on your casio, and is there a way to run ti games on a casio?

Edit: oh wait, I was on topic, lol, but is there something like ti-boy for casio prizm that converts file to calc format rather than running it as an emulator, or maybe even an emulator (I want Pokemon but emulators are usually too slow but I'm sure GBC will be fine with Prizm if can't use that method)
« Last Edit: September 12, 2012, 07:09:27 pm by [email protected] »

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #69 on: September 14, 2012, 04:12:38 pm »
Sorry to go off topic, but z80man, PLEASE could you tell me how you got a gb emulator on your casio, and is there a way to run ti games on a casio?

Edit: oh wait, I was on topic, lol, but is there something like ti-boy for casio prizm that converts file to calc format rather than running it as an emulator, or maybe even an emulator (I want Pokemon but emulators are usually too slow but I'm sure GBC will be fine with Prizm if can't use that method)
TI-Boy is actually an emulator. There aren't any emulators for the Prizm right now, and I don't know of any current projects to make one.

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Prizm Useful Routines -- post here!
« Reply #70 on: September 19, 2012, 04:38:18 pm »
CopySrpite alpha palette with clipping :
Code: [Select]
void CopySprite_Palette_Alpha_clipping(const unsigned char* data, const unsigned short* palette, int x, int y, int width, int height)
{
   unsigned short* VRAM = (unsigned short*)VRAM_ADRESS;
   unsigned short* ptr = VRAM + y*LCD_WIDTH_PX + x;
   int i,j;
   int real_width = x+width > LCD_WIDTH_PX ? LCD_WIDTH_PX - x : width;
   int decal = x < 0? -x : 0;
   if(real_width <= 0 || decal >= width) return;
   for(j=0; j<height; j++) {
ptr += decal;
data += decal;
for(i = decal; i < real_width; i++)
{
if(*data)
*ptr = palette[*(data)];
ptr++;
data++;
}
data += width - real_width;
ptr += LCD_WIDTH_PX-real_width;
   }
}

Offline sry9681

  • LV0 Newcomer (Next: 5)
  • Posts: 1
  • Rating: +0/-0
    • View Profile
Re: Prizm Useful Routines -- post here!
« Reply #71 on: September 28, 2012, 12:02:00 am »
hey z80man. I was just wondering, is it possible to have an emulator on the casio prizm? any type of emulator because i see your avatar picture with pokemon on the screen and i was wondering if that was real or photoshopped?

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Prizm Useful Routines -- post here!
« Reply #72 on: September 28, 2012, 12:10:22 am »
Emulators are certainly possible, but nobody's written any. Don't look at me... Also I'm pretty sure that's photoshopped from a common TI-Boy blog screenshot :P
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman