#135377 - yellowstar - Sun Jul 22, 2007 10:58 pm
I have some questions and problems.
These questions and problems
have to do with wireless, a bootloader, icon, and a Download Play Client.
NOTE:
I have moved the section about my Download Play Client's
Auth bug,
to a differen't topic.
This topic it was moved to is titled:
"Help! Wireless and Download Play Client"
I did that because the total length of
the starting post for the original post was
very long.
1.
I am trying to make a DS Download Play Client,
for Juglak's WMB Host.
All these problems are in this client.
My client is based on Juglak's WMB Host,
for local wireless.
Like Juglak's WMB Host,
my program's graphics is an console.
Here's my problems:
1a.
I don't have a bootloader for my client.
Which means my client can't boot the downloaded
programs.
In DS Download Play,
when it sends the NDS file,
it is not a normal NDS file.
It has some things removed.
See here for details.
On that web page,
click the DS Download Play protocol link
for details on the download format and the protocol.
I need some links to some bootloaders.(the download URL for them)
I can't use crishm's,
since most games(homebrew)
don't use FAT.
I know I would have to
convert the downloaded data to
a NDS struct for any bootloader to
work right.
My client dosen't get to the boot part yet,
as I haven't gotten that far.
Also,
it dosen't even make it past Authication.
It worked once, but after that it stopped working.
See the second section below this one
for details.
My client scans every channel,
so it can detect the official games.
But since homebrew local wireless is a lot
slower than the official games,
it can't communicate with them
in DS Download Play.(At least for the downloading part.)
1b.
My client isn't displaying the icon correctly.
I am using a sprite for displaying the icon.
The icon it displays looks nothing like
it would in the official client in the firmware.
Here's the code I am using:
This is the function that recieves the beacons.
It copies the important data into the ADC
struct pointed to by the ad parameter.
The ADC struct is an struct which contains important
stuff from the beacons.
That includes the ad,
the hostname, gamename,
total players, max players, and etc.
There is an global ADC var.
There is a timer(timer2)
which calls this function.(In the IRQ handler for it)
It passes the address of that global ADC var,
to that function.
This timer gets triggered every second.
Here's the function which
copies the ad icon into the sprite:
detect is wether or not an beacon was detected.
If so, it copies the icon into the sprite.
If not, it clears the sprite, making it invisible.
ad is the address of the ADC struct to use.
When called,
it is always the address of the global ADC struct.
scpy is an modified version of bytecpy.
It is the same,
except it copies 16 bits instead of bytes.
I tried using dmaCopy,
but that didn't do anything.
Here's the init code for video and etc.
Sprites:
initOAM sets every field in the spritesMain and spriteRotationsMain structs
to 0.
Video:
Since this client is based on Juglak's WMB Host,
it uses his libriyo for wireless and video.
When I try using videoSetModeSub with this program,
it won't work right with libriyo.
That is why I have to OR the SUB_DISPLAY_CR
register.
Last edited by yellowstar on Sun Jul 29, 2007 10:45 pm; edited 4 times in total
These questions and problems
have to do with wireless, a bootloader, icon, and a Download Play Client.
NOTE:
I have moved the section about my Download Play Client's
Auth bug,
to a differen't topic.
This topic it was moved to is titled:
"Help! Wireless and Download Play Client"
I did that because the total length of
the starting post for the original post was
very long.
1.
I am trying to make a DS Download Play Client,
for Juglak's WMB Host.
All these problems are in this client.
My client is based on Juglak's WMB Host,
for local wireless.
Like Juglak's WMB Host,
my program's graphics is an console.
Here's my problems:
1a.
I don't have a bootloader for my client.
Which means my client can't boot the downloaded
programs.
In DS Download Play,
when it sends the NDS file,
it is not a normal NDS file.
It has some things removed.
See here for details.
On that web page,
click the DS Download Play protocol link
for details on the download format and the protocol.
I need some links to some bootloaders.(the download URL for them)
I can't use crishm's,
since most games(homebrew)
don't use FAT.
I know I would have to
convert the downloaded data to
a NDS struct for any bootloader to
work right.
My client dosen't get to the boot part yet,
as I haven't gotten that far.
Also,
it dosen't even make it past Authication.
It worked once, but after that it stopped working.
See the second section below this one
for details.
My client scans every channel,
so it can detect the official games.
But since homebrew local wireless is a lot
slower than the official games,
it can't communicate with them
in DS Download Play.(At least for the downloading part.)
1b.
My client isn't displaying the icon correctly.
I am using a sprite for displaying the icon.
The icon it displays looks nothing like
it would in the official client in the firmware.
Here's the code I am using:
This is the function that recieves the beacons.
It copies the important data into the ADC
struct pointed to by the ad parameter.
The ADC struct is an struct which contains important
stuff from the beacons.
That includes the ad,
the hostname, gamename,
total players, max players, and etc.
There is an global ADC var.
There is a timer(timer2)
which calls this function.(In the IRQ handler for it)
It passes the address of that global ADC var,
to that function.
This timer gets triggered every second.
Code: |
bool RecieveBeacon(ADC *ad) { unsigned char *b,*d; struct beacon *bc; struct ds_element *ds; int i; if(!fire) fire=true; b=NULL; b = RXNextFrame(&sz); if(b==NULL) return 0; if(sz!=188) return 0; //b = (unsigned char *) Xmalloc(188); bc = (struct beacon *) (unsigned int) b; for(i=0;i<188;i++) { beacon[i] = b[i]; } ds = (struct ds_element *) (unsigned int) &beacon[52]; int seq = ds->sequence_number; //ds->sequence_number = seq; //ds->advert_sequence_number = seq; //b[42] = 13; // channel we're broadcasting on if (seq == 9) { //if(ds->non_advert!=2) //return 0; //ds->data_size = 1; ad->total_players = ds->advert_sequence_number; // Total players at this point. } else { if (seq == 8) { //ds->data_size = 72; } else { //ds->data_size = 98; } //if(ds->non_advert!=0) //return 0; } //ds->connected_clients = connected_clients; if (seq == 9) { //for(i=0;i<98;i++) ds->data[i] = 0; } else { // copy data from ad into beacon d = (unsigned char *) (unsigned int) &ad->AD; d += 98*seq; if (seq == 8) { for(i=0;i<72;i++) d[i] = ds->data[i]; for(i=72;i<98;i++) ds->data[i] = 0; } else { for(i=0;i<98;i++) d[i] = ds->data[i]; } } ad->max_players = ad->AD.max_players; ad->hostname_len = ad->AD.hostname_len; //strcpy(ad->hostname,""); int I = 0; for(int i = 0; i <= 10; i++) { ad->hostname[i] = ((char*)ad->AD.hostname)[I]; I+=2; } unsigned char len = 0; bool con = true; //strcpy(ad->hostname,""); I = 0; for(int i = 0; i <= 48; i++) { ad->game_name[i] = ((char*)ad->AD.game_name)[I]; I+=2; if(con) { if(ad->game_name[i]==0) { con=false; } else { len++; } } } ad->game_name_len = len; len = 0; con = true; //strcpy(ad->hostname,""); I = 0; for(int i = 0; i <= 96; i++) { ad->game_description[i] = ((char*)ad->AD.game_description)[I]; I+=2; if(con) { if(ad->game_description[i]==0) { con=false; } else { len++; } } } ad->game_description_len = len; //ds->checksum = computeBeaconChecksum((unsigned short *) (unsigned int)(((unsigned int)&ds->data[0])-4), (ds->data_size+4)/2); if(seq==0)//To optimize { IconDraw(&the_ad,1); } // think we're done... //bc->seq = bec_seq<<4; //bec_seq++; copy_mac(ad->host_mac,bc->srcmac); //copy_mac(bc->bssmac,mymac); //SendFrame(b,188); //Xfree(b); return 1; } |
Here's the function which
copies the ad icon into the sprite:
detect is wether or not an beacon was detected.
If so, it copies the icon into the sprite.
If not, it clears the sprite, making it invisible.
ad is the address of the ADC struct to use.
When called,
it is always the address of the global ADC struct.
scpy is an modified version of bytecpy.
It is the same,
except it copies 16 bits instead of bytes.
I tried using dmaCopy,
but that didn't do anything.
Code: |
__attribute__((section (".ewram"),long_call)) void scpy(void* in_dst, const void *in_src, unsigned int length) { //short copy(u16) u16 *src = (u16 *)in_src; u16 *dst = (u16 *)in_dst; for(; length > 0; length--) *dst++ = *src++; } void IconDraw(ADC *ad, bool detect) { if(detect) { position.x = SCREEN_WIDTH/2 - 64; position.y = SCREEN_HEIGHT/2 - 64; position.angle = 0; int GfxID = 64; spritesMain[0].attribute[0] = ATTR0_COLOR_256 | //Paletted //ATTR0_ROTSCALE_DOUBLE | //Enable rotscale (int)position.y; spritesMain[0].attribute[1] = //ATTR1_ROTDATA(0) | //Rot info is in first index of rot data. ATTR1_SIZE_32 | //32X32 (int)position.x; spritesMain[0].attribute[2] = GfxID; scpy( //source (uint16*)SPRITE_PALETTE_SUB+1,//target &ad->AD.icon_pallete[1], 15 ); scpy( //source &SPRITE_GFX_SUB[GfxID * 16], &ad->AD.icon,//target 512 ); updateOAM(spritesMain); } else { memset(&spritesMain[0],sizeof(SpriteEntry),0); } } |
Here's the init code for video and etc.
Sprites:
initOAM sets every field in the spritesMain and spriteRotationsMain structs
to 0.
Code: |
void initSprites() { initOAM(spritesMain,spriteRotationsMain); IconDraw(&the_ad,0); } |
Video:
Since this client is based on Juglak's WMB Host,
it uses his libriyo for wireless and video.
When I try using videoSetModeSub with this program,
it won't work right with libriyo.
That is why I have to OR the SUB_DISPLAY_CR
register.
Code: |
void initVideo() { //enable vram and map it to the right places /*vramSetMainBanks( VRAM_A_MAIN_BG_0x06000000, //map A and B to main background memory VRAM_B_MAIN_BG_0x06020000, //this gives us 256KB which is a healthy amount for 16-bit gfx VRAM_C_SUB_BG_0x06200000, //map C to sub background memory VRAM_D_LCD //map D to LCD free space //allows adjacent banks to overflow into D if a bug like that was ever to occur );*/ //map a bank for use with sprites vramSetBankI(VRAM_I_SUB_SPRITE); //mapping E to main sprites gives us 64k for sprites //(64k is the max space that 1024 tiles take up in 256 color mode) //set the video mode //videoSetModeSub( MODE_5_2D | SUB_DISPLAY_CR |= ( DISPLAY_SPR_ACTIVE | //turn on sprites //DISPLAY_BG3_ACTIVE | //turn on background 3 DISPLAY_SPR_1D); //this is used when in tile mode //); //videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE); } |
Last edited by yellowstar on Sun Jul 29, 2007 10:45 pm; edited 4 times in total