tuskenraider2k
Certified Guru
- Joined
- Nov 1, 2002
- Messages
- 117
Hello,
The "using-subprograms" testprogram seems to work. I've been playing around a bit and I am confused. In the first frame the data is available in the non cached area. But from that moment it disappears. I tried also in the our_shared_data.h 0x2000 instead of 0x1000. I disabled the second cpu, there it is the same situations.
#include "minimal.h"
#include "our_shared_data.h"
gp2x_dualcore_declare_subprogram(940t); //declare our first subprogram
void output_data(unsigned char *pData, int nCountCols, int nCountRows)
{
int i,j;
for (i = 0;i<nCountCols;i++)
{
gp2x_printf(NULL,10,-1,": ");
for (j = 0;j<nCountRows;j++)
{
gp2x_printf(NULL,-1,-1,"%03d ", *pData);
pData++;
}
gp2x_printf(NULL,-1,-1,"\n");
}
}
int main(int argc, char *argv[])
{
char szBuffer[260];
int szBufferLength;
int nLoopCounter=0;
gp2x_init(1000, 16, 11025,16,1,60, 1);
strcpy(szBuffer,"Hello World");
szBufferLength = strlen(szBuffer);
memcpy(((unsigned char*)&VARIABLE_STR),szBuffer,szBufferLength);
VARIABLE_STR_LENGTH = szBufferLength;
VARIABLE_A = 123;
//gp2x_dualcore_launch_subprogram(940t);
while (!(gp2x_joystick_read() & GP2X_A))
{
//memset(gp2x_video_RGB[0].screen8,3,320*240*2);
gp2x_printf(NULL,0,0,"Dual CPU test (compiled "__DATE__" " __TIME__")\n\n");
gp2x_printf(NULL,-1,-1,"Run %d\n",nLoopCounter++);
gp2x_printf(NULL,-1,-1,"cnt=%lu\n",VARIABLE_TESTS);
output_data( (unsigned char *)&gp2x_dualcore_data(0x1000),8,8);
gp2x_printf(NULL,-1,-1,"---\n");
gp2x_video_RGB_flip(0);
gp2x_timer_delay(1000);
}
}
void gp2x_sound_frame(void *blah, void *buff, int samples) {}
---
our_shared_data.h:
---
#define VARIABLE_A gp2x_dualcore_data(0x1000)
#define VARIABLE_B gp2x_dualcore_data(0x1004)
#define VARIABLE_TESTS gp2x_dualcore_data(0x1008)
#define VARIABLE_STR_LENGTH gp2x_dualcore_data(0x1010)
#define VARIABLE_STR gp2x_dualcore_data(0x1014)
/*
Let's define two messages for our communication system.
These numbers have no special meaning here, they're just for identification purposes.
*/
#define MESSAGE_INVERT 0
#define MESSAGE_SUBTRACT 1
#define MESSAGE_ADD_LOOP 2
#define MESSAGE_INC_STR 3
The "using-subprograms" testprogram seems to work. I've been playing around a bit and I am confused. In the first frame the data is available in the non cached area. But from that moment it disappears. I tried also in the our_shared_data.h 0x2000 instead of 0x1000. I disabled the second cpu, there it is the same situations.
#include "minimal.h"
#include "our_shared_data.h"
gp2x_dualcore_declare_subprogram(940t); //declare our first subprogram
void output_data(unsigned char *pData, int nCountCols, int nCountRows)
{
int i,j;
for (i = 0;i<nCountCols;i++)
{
gp2x_printf(NULL,10,-1,": ");
for (j = 0;j<nCountRows;j++)
{
gp2x_printf(NULL,-1,-1,"%03d ", *pData);
pData++;
}
gp2x_printf(NULL,-1,-1,"\n");
}
}
int main(int argc, char *argv[])
{
char szBuffer[260];
int szBufferLength;
int nLoopCounter=0;
gp2x_init(1000, 16, 11025,16,1,60, 1);
strcpy(szBuffer,"Hello World");
szBufferLength = strlen(szBuffer);
memcpy(((unsigned char*)&VARIABLE_STR),szBuffer,szBufferLength);
VARIABLE_STR_LENGTH = szBufferLength;
VARIABLE_A = 123;
//gp2x_dualcore_launch_subprogram(940t);
while (!(gp2x_joystick_read() & GP2X_A))
{
//memset(gp2x_video_RGB[0].screen8,3,320*240*2);
gp2x_printf(NULL,0,0,"Dual CPU test (compiled "__DATE__" " __TIME__")\n\n");
gp2x_printf(NULL,-1,-1,"Run %d\n",nLoopCounter++);
gp2x_printf(NULL,-1,-1,"cnt=%lu\n",VARIABLE_TESTS);
output_data( (unsigned char *)&gp2x_dualcore_data(0x1000),8,8);
gp2x_printf(NULL,-1,-1,"---\n");
gp2x_video_RGB_flip(0);
gp2x_timer_delay(1000);
}
}
void gp2x_sound_frame(void *blah, void *buff, int samples) {}
---
our_shared_data.h:
---
#define VARIABLE_A gp2x_dualcore_data(0x1000)
#define VARIABLE_B gp2x_dualcore_data(0x1004)
#define VARIABLE_TESTS gp2x_dualcore_data(0x1008)
#define VARIABLE_STR_LENGTH gp2x_dualcore_data(0x1010)
#define VARIABLE_STR gp2x_dualcore_data(0x1014)
/*
Let's define two messages for our communication system.
These numbers have no special meaning here, they're just for identification purposes.
*/
#define MESSAGE_INVERT 0
#define MESSAGE_SUBTRACT 1
#define MESSAGE_ADD_LOOP 2
#define MESSAGE_INC_STR 3