Jump to content



Photo
* * * * * 1 votes

9860 Sdk Image Display? Halp....


  • Please log in to reply
6 replies to this topic

#1 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 25 posts
  • Gender:Male

  • Calculators:
    Classpad CP-400
    Classpad CP-330
    fx-9860gii
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 19 April 2013 - 06:55 PM

I found a casio c image converter, it gave me the following code:


void drawImage(unsigned int pX, unsigned int pY, unsigned int pFlags){ // Flags: 1 - Draw To VRAM, 2 - Draw to Display

DISPGRAPH picture;
GRAPHDATA picture_info;
DISPBOX boxtoclear;

const unsigned char imagedata[] = {0x00,
0x00,0x00,0x00,0x7D,0xE0,0x00,0x00,0x7D,0x00,0x00,0x00,0x11,0xE0,0x00,0x00,0x11,0xE0,0x00,0x00,0x7D,0x00,0x00,0x00,0x7D,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x47,0x80,0x00,0x00,0x44,0x8E,0xF8,0x00,0x44,
0x88,0x20,0x00,0x44,0x88,0x20,0x00,0x77,0xB8,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00};

picture_info.width = 30;picture_info.height = 19;
picture_info.pBitmap = (unsigned char*)imagedata;

picture.x = pX;picture.y = pY;picture.GraphData = picture_info;
picture.WriteModify = IMB_WRITEMODIFY_NORMAL;picture.WriteKind = IMB_WRITEKIND_OR;

boxtoclear.left = pX;boxtoclear.top = pY;boxtoclear.right = (pX + 29);boxtoclear.bottom = (pY + 18);

if(pFlags & 1){Bdisp_AreaClr_VRAM(&boxtoclear);Bdisp_WriteGraph_VRAM(&picture);}
if(pFlags & 2){Bdisp_AreaClr_DD(&boxtoclear);Bdisp_WriteGraph_DD(&picture);}

}

How exactly do i use it though? I cant compile it without 20 something errors -_-

#2 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 25 posts
  • Gender:Male

  • Calculators:
    Classpad CP-400
    Classpad CP-330
    fx-9860gii
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 21 April 2013 - 12:50 AM

Anyone?

#3 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 21 April 2013 - 12:54 AM

What image converter did you use? It might be easier just to write your own routine.

@someone_with_more_experience_than_me: do we know the address of VRAM on the 9860? is it the same as the PRIZM? If so, writing a routine would be pretty straightforward... in fact a routine could possibly be made to support cemetech sourcecoder images.

#4 Casimo

Casimo

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 641 posts
  • Gender:Not Telling

Posted 21 April 2013 - 03:20 PM

Get the vram adress:
typedef char*(*sc_cpv)(void);
const unsigned int sc0135[] = { 0xD201D002, 0x422B0009, 0x80010070, 0x0135 };
#define Disp_GetVRAMPtr (*(sc_cpv)sc0135)
1 bit is one pixel. The address changes on the series, so you shouldn't use a predefined address.

The converter's name is "Casio c image converter".
Instead of this routine, you should better pick just the array imagedata (be careful with the other output mode, there are typos: remove all lines wirth \\ and change the name from imagegdata to imagedata or something different) and use this
void drawSprite(const unsigned char *bmp, int x, int y, int width, int height)
{
unsigned short line;
char shift, *screen, *p=(char*)&line;
int i, j, begin=0, end=height, real_width=(width-1>>3<<3)+8;
if(!bmp || x<0 || x>128-width || y<1-height || y>63 || width<1 || height<1) return;
if(y < 0) begin = -y;
if(y+height > 64) end = 64-y;
shift = 8-(x&7);
screen = Disp_GetVRAMPtr()+(y+begin<<4)+(x>>3);
for(i=begin ; i<end ; i++)
{
  for(j=0 ; j<width-1>>3 ; j++)
  {
   line = bmp[i*(real_width>>3)+j]<<shift;
   screen[j] |= *p;
   if(shift!=8) screen[j+1] |= *(p+1);
  }
  line = (bmp[i*(real_width>>3)+j] & -1<<(real_width-width))<<shift;
  screen[j] |= *p;
  if(shift!=8 && x+real_width<129) screen[j+1] |= *(p+1);
  screen += 16;
}
}
(taken from MonochromeLib by PierrotLL, modified)

Then just call drawSprite(imagedata, [x position], [y position], [height of picture], [width of picture]);

#5 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 25 posts
  • Gender:Male

  • Calculators:
    Classpad CP-400
    Classpad CP-330
    fx-9860gii
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 21 April 2013 - 06:27 PM

Mabye you could explain how to use it a bit more, i cant figure out how to compile it like this either, and have almost no c experience lol

#6 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 25 posts
  • Gender:Male

  • Calculators:
    Classpad CP-400
    Classpad CP-330
    fx-9860gii
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 21 April 2013 - 09:20 PM

Ok i got it a little further, heres my code:
#include "fxlib.h"
#include "stdlib.h"
#include "stdio.h"
#include "libg85.c"

int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;
    Bdisp_AllClr_DDVRAM();
    drawSprite(5,7,30,19);
    while(1){
	    GetKey(&key);
    }
    return 1;
}
typedef char*(*sc_cpv)(void);
const unsigned int sc0135[] = { 0xD201D002, 0x422B0009, 0x80010070, 0x0135 };
#define Disp_GetVRAMPtr (*(sc_cpv)sc0135)
void drawSprite(const unsigned char *bmp, int x, int y, int width, int height)
{
unsigned short line;
char shift, *screen, *p=(char*)&line;
int i, j, begin=0, end=height, real_width=(width-1>>3<<3)+8;
if(!bmp || x<0 || x>128-width || y<1-height || y>63 || width<1 || height<1) return;
if(y < 0) begin = -y;
if(y+height > 64) end = 64-y;
shift = 8-(x&7);
screen = Disp_GetVRAMPtr()+(y+begin<<4)+(x>>3);
for(i=begin ; i<end ; i++)
{
  for(j=0 ; j<width-1>>3 ; j++)
  {
   line = bmp[i*(real_width>>3)+j]<<shift;
   screen[j] |= *p;
   if(shift!=8) screen[j+1] |= *(p+1);
  }
  line = (bmp[i*(real_width>>3)+j] & -1<<(real_width-width))<<shift;
  screen[j] |= *p;
  if(shift!=8 && x+real_width<129) screen[j+1] |= *(p+1);
  screen += 16;
}
}
const unsigned char imagedata[] = {0x41,
0x38,0x00,0x00,0x41,0x44,0x00,0x00,0x63,0x40,0x00,0x00,0x63,0x40,0x00,0x00,0x55,0x38,0x00,0x00,0x55,0x04,0x00,0x00,0x49,
0x04,0x00,0x00,0x49,0x44,0x00,0x00,0x41,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x3E,0x00,0x00,0x44,0x41,0x1C,0x00,0x42,
0x80,0xA2,0x00,0x42,0x80,0xA0,0x00,0x42,0x80,0xA0,0x00,0x42,0x80,0x9C,0x00,0x42,0x80,0x82,0x00,0x44,0x80,0x82,0x00,0x78,
0x41,0x22,0x00};
//****************************************************************************
//**************											  ****************
//**************				 Notice!					  ****************
//**************											  ****************
//**************  Please do not change the following source.  ****************
//**************											  ****************
//****************************************************************************

#pragma section _BR_Size
unsigned long BR_Size;
#pragma section

#pragma section _TOP
//****************************************************************************
//  InitializeSystem
//
//  param   :   isAppli   : 1 = Application / 0 = eActivity
//			  OptionNum : Option Number (only eActivity)
//
//  retval  :   1 = No error / 0 = Error
//
//****************************************************************************
int InitializeSystem(int isAppli, unsigned short OptionNum)
{
    return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}
#pragma section


It seems to work better than the other code, but it still has 1 error when i attempt to compile. The output:
Executing Hitachi SH C/C++ Compiler/Assembler phase
set SHC_INC=C:\Program Files\CASIO\fx-9860G SDK\OS\SH\include
set PATH=C:\Program Files\CASIO\fx-9860G SDK\OS\SH\bin
set SHC_LIB=C:\Program Files\CASIO\fx-9860G SDK\OS\SH\bin
set SHC_TMP=C:\Users\Owner\Desktop\Calc Dev Projects\Image Real\Debug
"C:\Program Files\CASIO\fx-9860G SDK\OS\SH\bin\shc.exe" -subcommand=C:\Users\Owner\AppData\Local\Temp\hmk9904.tmp
C:\Users\Owner\Desktop\Calc Dev Projects\Image Real\realimag.c(23) : C2144 (E) Type mismatch
HMAKE MAKE UTILITY Ver. 1.1
Copyright (C) Hitachi Micro Systems Europe Ltd. 1998
Copyright (C) Hitachi Ltd. 1998

 ERROR: Process failed with return code: 1
Build was not successful.
Any ideas?

Edited by shinolife63, 21 April 2013 - 09:29 PM.


#7 shinolife63

shinolife63

    Newbie

  • Members
  • Pip
  • 25 posts
  • Gender:Male

  • Calculators:
    Classpad CP-400
    Classpad CP-330
    fx-9860gii
    Hacked fx-9750gii
    fx-300 ES plus
    fx-115 ES
    fx-300 MS

Posted 24 April 2013 - 09:24 PM

Got it to work, had to change the drawImage thing from a char to an int




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users