gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Writing PogoShell plugin with Devkit Advance

#5462 - Quirky - Mon Apr 28, 2003 8:51 pm

I've written a plugin for PogoShell (nothing useful, pcx image files) but I'm having problems getting it to actually work. The actual pcx "decoding" works, I've tested it with .all.rodata.o pcx files, then appended data files (copy /b pcx.bin+pic.pcx pcx.gba) then the final step, as a plugin. Which is where it goes wrong.

According to the docs, when you select a file in pogoshell, a "magic value" is stored at 0x0203FC00, i.e. near the end of EWRAM. However, this value is always 0. The code I have is:

Code:
unsigned int *p = (unsigned int *)0x0203FC00;
   if(p[0] == 0xFAB0BABE) {
   
      load_pcx((u8 *)p[-1]);
  } else {... debug stuff to find out why it went wrong


I have my theory as to why it fails - I think that Devkit adds code at the start of the rom that sets EWRAM to 0. Can anyone confirm this and suggest a work around? Oh and should the plugin be written as a multiboot image or doesn't that matter?

#5469 - tepples - Mon Apr 28, 2003 11:17 pm

Quirky wrote:
According to the docs, when you select a file in pogoshell, a "magic value" is stored at 0x0203FC00, i.e. near the end of EWRAM. However, this value is always 0. [...]I have my theory as to why it fails - I think that Devkit adds code at the start of the rom that sets EWRAM to 0.

It might. If it does, you can work around it by getting Devkit Advance R5 when it comes out.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#5473 - Quirky - Tue Apr 29, 2003 9:37 am

Well, I've found the problem. I need to edit crt0.s, as I kind of suspected it clears EWRAM on start up. I should have looked here first really.

Code:

DoEWRAMClear:
@ Clear External WRAM to 0x00

        mov     r1,#0x40
        lsl     r1,#12          @ r1 = 0x40000
        lsl     r0,r1,#7        @ r0 = 0x2000000
        bl      ClearMem
       


Changing the first line to mov r1,#0x3f will do the trick as that will not clear the ERAM that PogoShell sets.

#5478 - niltsair - Tue Apr 29, 2003 2:07 pm

That's usefull to know. I wanted to eventually developp a plugging myself.

Thanks for the feedback.

#5512 - gb_feedback - Wed Apr 30, 2003 12:41 pm

Quote:
Well, I've found the problem. I need to edit crt0.s, as I kind of suspected it clears EWRAM on start up.

I guess you fixed it before I replied to your email! One other thought - It is good practice to set the fabobabe value to 0 after you've recognised it, so that other plug-ins don't think the reference is for them. I'm not sure of the exact circumstances where this might matter but I seem to remember the Pogoshell author recommending it.
_________________
http://www.bookreader.co.uk/

#5515 - Quirky - Wed Apr 30, 2003 1:30 pm

I hit "send" then about 5 minutes later I had that brainwave. Typical! Anyway, cheers for reading at least :)

Have I understood correctly that, regardless of the actual size of the plugin, they use up a multiple of 32kb of space?

#5517 - gb_feedback - Wed Apr 30, 2003 1:43 pm

Quote:
Have I understood correctly that, regardless of the actual size of the plugin, they use up a multiple of 32kb of space?

That's basically it. I think the usual cart is designed to map any whole number of 32kb blocks to a block which starts at 0x08000000 (for obvious reasons).
_________________
http://www.bookreader.co.uk/