Casio Kingdom - The Casio calculator resource site            
Home Downloads Forums Unread Posts Hall of Fame
Your Account Search Tutorials Wiki
Staff
 
Resources

Downloads

[ Newest | Hottest ]

1: Rock Paper Scissors
    [Hits: 24]
2: Pokemon NEC
    [Hits: 247]
3: Classic Game Invincible MAZE v2.1
    [Hits: 433]
4: DELTA<->ESTRELLA
    [Hits: 106]
5: FOBONACCI
    [Hits: 142]
6: Chess v2.0
    [Hits: 282]
7: Snake Revolution
    [Hits: 502]
8: INFIX POSTFIX
    [Hits: 239]
9: UNTPOST
    [Hits: 217]
10: Organic Chemistry notes
    [Hits: 411]

[ Add new | Rank all ]
Search

Advanced Search

Casio Kingdom - The Casio calculator resource site: Forums

Casio Kingdom :: View topic - Revolution FX problem

Forum FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in

View next topic
View previous topic
Post new topic Reply to topic  Casio Kingdom Forum Index » SDK
Author Message
kelli
Marquess
Marquess


Joined: Apr 25, 2007
Posts: 41
Location: Finland

PostPosted: Sun Mar 30, 2008 6:58 am Reply with quote

Hi, I'm currently working with some projects and I'm using Revolution FX for super fast graphics. The problem is that I would like to print some text, variables, etc. to screen, but I can't because CopyVRAM(); function gives me error. It does compile, but when I try to run the program it gives me system error.

Have any of you really used CopyVRAM(); function succesfully? If so, can you give me an example how to do it? Or is there an alternative way to print text to screen than SDK's print funktions?

Thanks for your help.
View user's profile Send private message
neur0n
Team Kingdom
Team Kingdom


Joined: Mar 07, 2007
Posts: 101

PostPosted: Sun Mar 30, 2008 8:47 am Reply with quote

You don't describe the problem well enough for us to give you a proper answer.

The problem is likely that revolution-fx does not take into account the different addresses for the VRAM in newer OSes.
View user's profile Send private message
SimonLothar
Team Kingdom
Team Kingdom


Joined: Jan 19, 2008
Posts: 426
Location: Germany

PostPosted: Sun Mar 30, 2008 1:29 pm Reply with quote

@neurON! Of course you are right. It's safer to fetch the VRAM_base with SysCall 0x0135, before using it. Even the original CASIO SDK-emulator uses another VRAM_base as V1.03 on a FX-9860G calc. After reading your post I just downloaded revolution-FX 0.3.2 to have a look.
revolution_asm.src contains following code for CopyVRAM:

_CopyVRAM:
mov.l r12, @-r15
mov.l r11, @-r15
mov.l r10, @-r15
mov.l r9, @-r15
mov.l r8, @-r15

mov.l #h'8800498D, r10

mov.l #h'400, r6
mov #h'0, r1

CopyByte:
dt r6
mov.b @r10+, r3
mov.b r3, @r4
add #h'1, r4
bf/s CopyByte

mov.l @r15+, r8
mov.l @r15+, r9
mov.l @r15+, r10
mov.l @r15+, r11
mov.l @r15+, r12
rts
nop
...
But

bf/s CopyByte

is a branch instruction with delay slot. Wouldn't it execute

mov.l @r15+, r8

every time it branches?
Wouldn't that lead to a crash due to stack corruption?
(The above code actually leads to a crash in a little test program I tried.)
I cannot imagine this source to be used with the current version of revolution-FX binary (perhaps kucalc only has forgotten to update the source in 0.3.2).

_________________
IŽll be back!
View user's profile Send private message
neur0n
Team Kingdom
Team Kingdom


Joined: Mar 07, 2007
Posts: 101

PostPosted: Sun Mar 30, 2008 10:20 pm Reply with quote

Yup, SimonLothar, looks like a bug.

kelli: The CopyVRAM()-function is no more than a memcpy(), with the vram address and size predefined.
To get you going, you could use the system call SimonLothar mentioned to get the address;

syscall.src:
Code:
.section P, code
.export _syscall
_syscall:
  mov.l  #h'80010070, r2
  mov.l  @r15, r0
  jmp    @r2
  nop

.end


Your C-code:
Code:
  ...
char your_buffer[1024];
char *vram_address;
vram_address = syscall(0,0,0,0,0x135); // use syscall() to get vram address
memcpy(your_buffer, vram_address, 1024);
  ...
View user's profile Send private message
SimonLothar
Team Kingdom
Team Kingdom


Joined: Jan 19, 2008
Posts: 426
Location: Germany

PostPosted: Sun Mar 30, 2008 10:37 pm Reply with quote

Yeah! And if you don't like to do assembler, you can do it all inside C.

Code:
// definition of the syscall-port (usable for nearly every syscall)
int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070};
int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode;

// use
vram_address = (*SysCall)( 0, 0, 0, 0, 0x0135 );

_________________
IŽll be back!
View user's profile Send private message
kelli
Marquess
Marquess


Joined: Apr 25, 2007
Posts: 41
Location: Finland

PostPosted: Mon Mar 31, 2008 1:49 am Reply with quote

It doesn't work. I guess I'm doing something wrong.

This is my test program, tell me what's wrong with it. Compiler gives me " Type not compatible for "=" ". I tried to mess with those pointers and got it compiled, but then the program itself gave me an error.

Code:

int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070};
int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode;

char buffer[1024];
char *vram_address;

int AddIn_main(int isAppli, unsigned short OptionNum)
{
    memset(&buffer, 0, 1024);
    Bdisp_AllClr_DDVRAM();
    while(1)
   {
      if(IsKeyDown(KEY_CTRL_SHIFT)==1)
      {
         Bdisp_DrawLineVRAM(0,0,127,0);
         vram_address = (*SysCall)( 0, 0, 0, 0, 0x0135 ); //<---
         memcpy(buffer, vram_address, 1024);
      }
      DrawLine(0,1,127,1,&buffer, BLACK);
      DrawAll(&buffer);
    }
    return 1;
}
View user's profile Send private message
neur0n
Team Kingdom
Team Kingdom


Joined: Mar 07, 2007
Posts: 101

PostPosted: Mon Mar 31, 2008 2:19 am Reply with quote

Before we get too complicated, you could just use Bdisp_GetDisp_VRAM (see SDK documentation). It should be faster than the Revolution-fx variant.
View user's profile Send private message
kelli
Marquess
Marquess


Joined: Apr 25, 2007
Posts: 41
Location: Finland

PostPosted: Mon Mar 31, 2008 2:29 am Reply with quote

Thanks! Using Bdisp_GetDisp_VRAM I got it working. Very Happy
View user's profile Send private message
SimonLothar
Team Kingdom
Team Kingdom


Joined: Jan 19, 2008
Posts: 426
Location: Germany

PostPosted: Tue Apr 01, 2008 12:17 am Reply with quote

Sorry! My fault not to mention it. We have to use a type cast.

vram_address = (char*)(*SysCall)( 0, 0, 0, 0, 0x0135 );

_________________
IŽll be back!
View user's profile Send private message
Jimboom
Peasant
Peasant


Joined: Jan 30, 2010
Posts: 1
Location: Germany

PostPosted: Fri Feb 05, 2010 8:58 pm Reply with quote

I solved the problem on my own way:
I deleted in Revolution Fx 1.0 the line
Code:
#define VRAM (unsigned char*)0x8800498D

and put this in:
Code:
int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070};
int (*SysCall)( int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode;
#define VRAM (unsigned char*)(*SysCall)( 0, 0, 0, 0, 0x0135 )


It works great! Now you can draw sprites, CoolText, etc. and use the normal Bdisp functions.
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic

View next topic
View previous topic
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
You cannot attach files in this forum
You can download files in this forum
Forums ©

Data Recovery
Computer problems are so stressful! Find help with data recovery here.

Data Recovery Specialist
Don't look any further. You've come across the data recovery specialists. Click above.





Casio Kingdom 2003-2009 Sean Tan
casiokingdom.org | admin@casiokingdom.org