Jump to content

GeoCaching manager for the Nintendo DS!


Followers 0

Recommended Posts

This is one of my first NDS programs. If you have a NDS and a flashCart, try out this program. NOTE: since you put the caches in the sourcecode, you must be able to compile it too. You need devkitpro and PALib to compile it.

 

#include <PA9.h>

typedef struct Cache{
char * name;
char * id;
char * difficulty;
char * terrain;
char * location;
char * size;
char * description;
char * hint;
} Cache;

// SETUP BEGIN

#define numberOfCaches 2

Cache caches[numberOfCaches];

void inputCaches(){
caches[0].name="Holcomb Creek Trestle View";
caches[0].id="GCTDGK";
caches[0].difficulty="1.5";
caches[0].terrain="1.5";
caches[0].location="N 45° 35.998 W 122° 53.895";
caches[0].size="regular";
caches[0].description="Pretty easy cache, come see the Holcomb Creek Trestle.Some info/history on the Holcomb Creek Trestle: It's about 60' tall and 1100' long. Built around 1911 as part of a line intended to connect Portland (through Cornelius Pass) to Hillsboro, Banks, Vernonia, and Tillamook. The Cornelius Pass tunnel (4100' long) and several large trestles like this one took several years to complete. The United Branch (as it's known) was mostly used for lumber as it still is today. Feel free to add your own notes on the history if you have any, as I'm still new to the area and info on this was hard to come by. Side note: The pool of water nearby is called Mullerleile Pond and unfortunately it's on private property (signs everywhere). There are some kiddie goodies to start off the cache. Enjoy! Congratulations to Geo.Otter for FTF!";
caches[0].hint="not wet";

caches[1].name="Reminders of a Time Past  ";
caches[1].id="GCYHM5";
caches[1].difficulty="1.5";
caches[1].terrain="1.5";
caches[1].location="N 45° 33.856 W 122° 55.348";
caches[1].size="regular";
caches[1].description="This is a short, one stage, less than a mile long multi designed to be fun for kids and to remind us of some of the history of this area.This starts at the Five Oaks information kiosk, which some of you have visited before. It’s an interesting place to stop and learn about the history of this area, which has been used as a gathering spot for hundreds of years beginning with Native Americans, then mountain men, settlers, and contemporary businesses. But it’s a crummy place to hide a cache.So I hid a micro here with coordinates to the final cache. I need your help here though. I'm now on my fourth micro. I hid it in a way so that, should a car drive by (as they often do during work hours), you can pretend to be reading the fascinating information on the kiosk. Please be sneaky so passers-by won't wonder what else you may be looking so intently at or for. I don't want them to come back later and make me put a fifth micro out.To reward you for the bother of having to fuss with a micro, the final cache is a nice, big, 11” by 7” by 6” ammo can, disguised to blend in with its surroundings. It’s in a quiet spot that seems, to me, to be a step back in time from the surrounding area.There is an approach road west of the final cache, and one east. The west approach is closer to the Five Oaks pavillion, but if you go down (or leave on) the eastern road, you'll pass by a house that has peacocks that occasionally wander alongside the road. They too seem like something from an earlier time.A lot of people use this spot during weekday lunchtimes for a quiet break or nap. If you come by then, please use stealth-caching techniques. After work hours, the area is almost deserted.If you like the micro and want one of your own, send me a note and I'll tell you where I got it.";
caches[1].hint="Micro: Bug, front side, about knee level   Cache: Under";
}	

// SETUP END

char * emptyScreen = "																																																																																																																																																																																																";
void clearScreen(int screen){
PA_OutputSimpleText(screen,0,0,emptyScreen);
}

int stylusTileX(){
return(Stylus.X/8);
}

int stylusTileY(){
return(Stylus.Y/8);
}

int dirKeyStep=0;
int dirKey(){
int interval=5;
dirKeyStep++;
if(dirKeyStep<interval){
	return(0);
}
if(Pad.Held.Up){
	dirKeyStep=0;
	return(1);
}
if(Pad.Held.Right){
	dirKeyStep=0;
	return(2);
}
if(Pad.Held.Down){
	dirKeyStep=0;
	return(3);
}
if(Pad.Held.Left){
	dirKeyStep=0;
	return(4);
}
return(0);
}

void dispCache(int cacheNumb,bool showHint){
int desScroll=0;
bool hintShown=false;
int theDir;
Cache theCache=caches[cacheNumb];
PA_OutputText(1,0,0,"%s",theCache.name);
PA_OutputText(1,0,1,"ID:%s  Size:%s",theCache.id,theCache.size);
PA_OutputText(1,0,2,"Difficulty:%s  Terrain:%s",theCache.difficulty,theCache.terrain);
PA_OutputText(1,0,3,"Loc:%s",theCache.location);
PA_OutputText(1,0,4,"Press Y for hint");
PA_OutputText(1,0,22,"Scroll description below with\nup/down keys, press X to exit");
while(!Pad.Newpress.X){
	PA_WaitForVBL();
	if(Pad.Newpress.Y){
		if(!hintShown){
			PA_OutputText(1,0,4,"				   ");
			PA_OutputText(1,0,4,"Hint:\n%s",theCache.hint);
			hintShown=true;
		}
	}
	theDir=dirKey();
	if(theDir==1){
		if(desScroll>0){
			desScroll-=32;
		}
	}
	if(theDir==3){
		if(desScroll<strlen(theCache.description+32)){
			desScroll+=32;
		}
	}
	clearScreen(0);
	PA_OutputText(0,0,0,"%s",theCache.description+desScroll);
}
}

int whatCache(){
int i;
for(i=0;i<numberOfCaches;i++){
	PA_OutputText(0,0,i,"%s",caches[i].name);
}
int selection=-1;
while(!((selection>=0)&&(selection<numberOfCaches))){
	PA_WaitForVBL();
	if(Stylus.Held){
		selection=stylusTileY();
	}
}
return(selection);
}

void selectAndView(){
int cacheToView=whatCache();
clearScreen(0);
dispCache(cacheToView,false);
clearScreen(1);
clearScreen(0);
}	

int main(void) {
PA_Init();
PA_InitVBL();
PA_InitText(0,2);
PA_InitText(1,2);
inputCaches();
while(1){
	PA_WaitForVBL();
	selectAndView();
}
}

Link to comment

Heres a pearl script to convert from normal text to what you put on one line in the program (usefull for description and hint):

use warnings;
use strict;
sub shorten($$);
sub get($);
sub put($$);

# maximum line length
my $MAX = 32;

if (@ARGV != 2) {
die "Two argument required: $0 input-file output-file\n";
}
my($in, $out) = @ARGV;

my $s = get($in);
chomp($s);
$s =~ s/[ \t]+$//gm;  # remove trailing spaces

# shorten long lines:
1 while $s =~ s#^(.{$MAX})(.+)#shorten($1, $2)#em;

# convert newlines to \n
$s =~ s/\n/\\n/g;

put($out, $s);

exit;

# shorten one long line
sub shorten($$) {
my($pre, $post) = @_;
if($pre =~ /^\s*(\S.*)\s+(\S.*)$/) {
	return "$1\n$2$post";
} else {
	return "$pre\n$post"; # no spaces in pre -- just cut it off
}
}

sub get($) {
my($file) = @_;
local $/ = undef;
my $fh;
open($fh, '<', $file) or die "Can't read $file: $!\n";
return <$fh>;
}

sub put($$) {
my($file, $string) = @_;
my $fh;
open($fh, '>', $file) or die "Can't write $file: $!\n";
print $fh $string;
}

Link to comment

Hi dontpanic II! I have a Nintendo DS Lite. The only flash card I have is an old one I bought from Lik-Sang (*shakes fist at Sony*) that I used to play homebrew games on. I have not tried it with my DS (only the GBA SP). I have considered buying a M3 Simply.

 

Anyway, I would be willing to help with testing your software. If the compiler & libraries are open source/public domain, please post a link to them. Meanwhile I will dig out my old flash cart and see if it will work the DS.

 

Thanks! :surprise:

Link to comment

Woohoo finally a reply!!! anyway, gba card might work if you have a passme/2 or nopass, but i would suggest that you just get a m3 simply. I have one, and i LOVE it. The original passme prolly wont work on your firmware. Anyway, here are the links:

http://www.devkitpro.org/

http://www.palib.info/

Can you recommend a trustable vendor for teh M3 Simply? So far everywhere I have looked they have been 'backordered'. :surprise:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Followers 0
×
×
  • Create New...