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.

DS Misc > DS Option packs

#159017 - Mohammad - Tue Jun 24, 2008 11:00 am

Are "DS Option Packs" coded in the same way as one another? Well, I just got "Guitar Hero: On Tour" And was wandering if I could use the option pack on it. Imagine using google maps with that: the top two are zoom+ and zoom- while the next one is an options menu(which u could either touch or use the pack) and the last one will take you to your home location (or if you hit it while at your home location [ex: accidental hit so you hit it again] you could go back to where you were at)

#159031 - cheesethulhu - Tue Jun 24, 2008 2:48 pm

I'm not sure about any other DS Option Packs (I've looked at the libnds code for the rumble pack and I suspect it counts as one), but, as for the Guitar Grip (TM), I picked one up on Sunday and played around with it a bit.

First, you need to make sure you can use the GBA bus from the processor you're on. Call sysSetCartOwner() with either BUS_OWNER_ARM9 or BUS_OWNER_ARM7.

To detect the grip, you might want to look at the rumble code in libnds. Check GBA_HEADER.is96h to make sure there isn't a game in SLOT-2 (0x96 means there is a game). Then check if GBA_BUS[0] has bits 9 and 10 cleared. The guitar grip has pull down resistors on GBA pins 15 and 16, so it should always force bits 9 and 10 to zero. There may be more to detection than that, since other option packs might look similar.

To get the fret button statuses, just read any address from GBA SRAM, like SRAM[0], and bits 3-6 are blue through green. The buttons pull the lines down, so zero means pressed.

Sorry if this is incoherent or telling you things you already know. I only found this stuff out on Sunday and I'm a bit low on sleep.

#159041 - Mohammad - Tue Jun 24, 2008 8:10 pm

no I really have no clue when it comes down to raw inputs. You wouldn't happen to have a simple code with the stuff you were saying would you? (I learn better by looking a code) I might try to make a simple libary for it until a good one is out.[/img]

#159044 - cheesethulhu - Tue Jun 24, 2008 9:10 pm

This is based on the arm9 template from the libnds example code. I don't know how to mark the changes I made (is it possible with BBCode?), so if you can't pick them out by comparing it to the original template, please let me know.

Code:

/*---------------------------------------------------------------------------------

   $Id: main.c,v 1.5 2007/10/23 00:46:29 wntrmute Exp $

   Simple console print demo
   -- dovoto

---------------------------------------------------------------------------------*/
#include <nds.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

bool isGuitarGripInserted(void) {

   // Take ownership of the GBA bus (Cart, not Card)
   sysSetCartOwner(BUS_OWNER_ARM9);

   // Test for a GBA game being inserted
   if(GBA_HEADER.is96h == 0x96) {
      // Detected a GBA game, so no guitar grip
      return false;
   }

   // Check to see if data lines 15 and 16 are pulled down
   if(((~GBA_BUS[0]) & 0x0600) == 0x0600) {
      // Likely the guitar grip
      return true;
   }

   return false;
}

//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
   touchPosition touchXY;
   bool grip_detected;
   u8 grip_state;

   irqInit();
   irqEnable(IRQ_VBLANK);

   videoSetMode(0);   //not using the main screen
   videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);   //sub bg 0 will be used to print text
   vramSetBankC(VRAM_C_SUB_BG);

   SUB_BG0_CR = BG_MAP_BASE(31);

   BG_PALETTE_SUB[255] = RGB15(31,31,31);   //by default font will be rendered with color 255

   //consoleInit() is a lot more flexible but this gets you up and running quick
   consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);


   grip_detected = isGuitarGripInserted();

   iprintf("\n\n\tHello DS dev'rs\n");
   iprintf("\twww.drunkencoders.com");

   if(!grip_detected) {
      iprintf("\nGuitar Grip not detected.\n");
   }

   while(1) {

      touchXY=touchReadXY();
      iprintf("\x1b[10;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px);
      iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py);

      if(grip_detected) {
         grip_state = SRAM[0];

         iprintf("  Blue is %s\n", (grip_state & BIT(3)) ? "  up" : "down");
         iprintf("Yellow is %s\n", (grip_state & BIT(4)) ? "  up" : "down");
         iprintf("   Red is %s\n", (grip_state & BIT(5)) ? "  up" : "down");
         iprintf(" Green is %s\n", (grip_state & BIT(6)) ? "  up" : "down");
      }

      swiWaitForVBlank();
   }

   return 0;
}

#159074 - HyperHacker - Wed Jun 25, 2008 3:29 am

Hm, this device could be useful for media player controls.
_________________
I'm a PSP hacker now, but I still <3 DS.

#159079 - tepples - Wed Jun 25, 2008 3:51 am

But one would probably have to be a big fan of Guitar Hero in order to justify buying the Guitar Grip for $50, even if it does come with a game at no additional charge.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#159095 - Mohammad - Wed Jun 25, 2008 11:38 am

Already working on one lol, but it helps if I knew what I was doing :/ my plans

---- Griping_Music.txt ----
Top button -> Play/Pause
Mid-top -> Volume +/- (hit this then top for + and mid-top for -)
Mid-bottom -> Skip next
Bottom -> Skip prev
Top&Bottom -> Stop
------------------------------

But yeah I'm aways away, but hey you got to have a project you like other wise you will get no where :)

@tepples but soon people are bound to brake it meaning that will have to sell replacements for about $15 but that will make the game less in value, so they are probably going to wait awhile.

I'll post my code later there is something that's bothering the heck out of me (doesn't do what I say, but works)

#159389 - 11X_daemon_X11 - Mon Jun 30, 2008 2:24 am

I ahve a question... not to sound crazy or anything, but is there really a true point to this? The only thing I could see possibly coming from this is a single Guitar hero-esque homebrew with custom song input =\ lol
_________________
IRC (please join :D):

http://evilnetirc.ath.cx/