Sandbox

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<big>This page can be used to experiment with the waki wiki ways</big>
 
<big>This page can be used to experiment with the waki wiki ways</big>
 +
 +
note to self: make a page on writing device drivers for libnds...
 +
 +
asdfgh!
 +
 +
some of meh programming values:
 +
* simplicity
 +
things should be intuitive, easy to use. variable and function names should be self explanitory as much as possible.
 +
* consistency
 +
variable and function names, methods, etc should follow patterns
 +
* modularity
 +
individual components that can be used alone or in tandem
 +
* compatibility
 +
components should work with each other as well as other '3rd party components'
 +
* familiarity
 +
components should be based when appropriate on well known common concepts.
 +
* eat lots of leet onion
 +
Huh @_@? How about: no one is perfect :p
  
 
{{refimprove|date=February 2008}}
 
{{refimprove|date=February 2008}}
Line 29: Line 47:
 
</source>
 
</source>
  
==WAG54GV3 Firmware==
 
first downloads teh TI-toolchains-2_1_0-cy07.PROPER.tar.bz2 and WAG54GV3-AU_v1.00.22.PROPER.tar.bz2.
 
* extract TI-toolchains-2_1_0-cy07.PROPER.tar.bz2 and copy opt/ to / (there is probably already a /opt hopefully it wont copy over anything impotant :p).
 
* extract WAG54GV3-AU_v1.00.22.PROPER.tar.bz2 to your home dir. it will create the WAG54GV3-AU_v1.00.22 dir.
 
cd /WAG54GV3-AU_v1.00.22/src
 
export PATH=$PATH:/opt/TI-toolchains-2_1_0-cy07/mipsfple/bin/:/opt/TI-toolchains-2_1_0-cy07/mipsfple-uclibc/bin/
 
(if you plan to work with the code alot, make mods, etc, might wanna add this to .bashrc or .login or such :)
 
./make.sh
 
This will make everything, hopefully. If not see the troubleshooting section:
 
==onoes! teh fail :/==
 
if you gets:
 
/home/isabella/ForL3x/WAG54GV3-AU_v1.00.22/src/linux/linux-2.4.17_mvl21/tools/7zip: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory
 
trys:
 
sudo apt-get install something with libstdc++-libc6.2-2.so.3? (sry i forget u_u)
 
  
What no bison?! if you gets:
 
make[2]: bison: Command not found
 
trys:
 
sudo apt-get install bison
 
  
if you gets: (btw this is only necessary if your re-building after a previous build, but rly that it generates error messages and fuglys up your terminal should be reason enough to fix this...)
+
==bgfunct==
/bin/sh: rcsclean: not found
+
<source lang="c">
trys:
+
#ifndef THBG_H
sudo apt-get install rcs
+
#define THBG_H
  
It may be useful to make each step seperately, helps finding error messages as it'll prolly halt abruptly. To do that first type this once:
+
typedef void(*_pBgStartFunc)(void); //Background Setup Function (called first)
cd router
+
typedef void(*_pBgUpdateFunc)(int); //Background update function
 +
typedef void(*_pBgFinishFunc)(void); //Background destroy function
  
and then type (one line at a time newbs):
+
typedef struct {
make linux-clean
+
_pBgStartFunc start;
make linux-dep
+
_pBgUpdateFunc update;
make linux
+
_pBgFinishFunc finish;
make clean
+
void *bgdat; //background set specific data
make
+
} thbg_t;
make linux-modules
+
make install
+
make rom
+
make upgrade
+
make lang
+
  
If your done you should have a file called ???? in the image dir.. (may be 1 directory up if you cd router'ed)
+
void thBgInit(void); //get everything ready
 +
void thBgUpdate(int frame); //call this every vblank
 +
void thBgStart(thbg_t *thbg); //call this to start a bg (will first stop any already running)
 +
void thBgFinish(void); //stops bg, erases bg mem, etc
  
==What did j00 do to this?!?!==
+
void thUpdateBgPalette(uint16 *pal, int dstpal, int size);
Tbh, i cannot remember exactly, firstly finding the right toolchains and where to put it was a plus, then finding a few syntax errors in the main Makefile, and umm ummm, oh yah, finding that library file was pita mostly because i didn't get that it was looking for file to run 7zip and not link it or somethign and missing libstdc++blahblah, also installing bison and such...
+
void thUpdateBgSubPalette(uint16 *pal, int dstpal, int size);
  
sounds easy, but took 4 days :P
+
#endif
 +
 
 +
</source>
 +
<source lang="c">
 +
#include <nds.h>
 +
#include "thbg.h"
 +
#include <stdio.h>
 +
 
 +
thbg_t *currentbg;
 +
 
 +
void thBgInit(void) {
 +
currentbg=NULL;
 +
vramSetBankC(VRAM_C_SUB_BG);
 +
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
 +
vramSetBankB(VRAM_B_MAIN_BG);
 +
vramSetBankE(VRAM_E_MAIN_BG);
 +
vramSetBankF(VRAM_F_BG_EXT_PALETTE);
 +
}
 +
 
 +
//hmmz should i have pBgStartFunc return a pointer to its data, then pass that as arg to update and finish?
 +
void thBgStart(thbg_t *thbg) {
 +
thBgFinish(); //just in case
 +
currentbg=thbg;
 +
if(currentbg->start)
 +
((_pBgStartFunc)currentbg->start)();
 +
}
 +
 
 +
void thBgUpdate(int frame) {
 +
if(currentbg) {
 +
((_pBgUpdateFunc)currentbg->update)(frame);
 +
}
 +
}
 +
 
 +
void thBgFinish(void) {
 +
if(currentbg) {
 +
if(currentbg->finish)
 +
((_pBgFinishFunc)currentbg->finish)();
 +
currentbg=NULL;
 +
}
 +
}
 +
 
 +
void thUpdateBgPalette(uint16 *pal, int dstpal, int size) {
 +
vramSetBankF(VRAM_F_LCD);
 +
        DC_FlushRange(pal,size);
 +
dmaCopyWords(3,pal, VRAM_F_EXT_PALETTE[dstpal], size);
 +
vramSetBankF(VRAM_F_BG_EXT_PALETTE);
 +
}
 +
 
 +
void thUpdateBgSubPalette(uint16 *pal, int dstpal, int size) {
 +
vramSetBankH(VRAM_H_LCD);
 +
        DC_FlushRange(pal,size);
 +
dmaCopyWords(3,pal, VRAM_H_EXT_PALETTE[dstpal], size);
 +
vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
 +
}
 +
 
 +
 
 +
</source>
 +
<source lang="c">
 +
//Whatever you need to initalize the bg
 +
void mybg0start(void) {
 +
BG1_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(12) | BG_TILE_BASE(1) | BG_PRIORITY(BG_PRIORITY_1);
 +
SUB_BG1_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(12) | BG_TILE_BASE(1) | BG_PRIORITY(BG_PRIORITY_1);
 +
dmaCopyWords(3,BG1_Map, BG_MAP_RAM(12), sizeof(BG1_Map));
 +
dmaCopyWords(3,BG1_Tiles, BG_TILE_RAM(1), sizeof(BG1_Tiles));
 +
dmaCopyWords(3,BG1_Map, BG_MAP_RAM_SUB(12), sizeof(BG1_Map));
 +
dmaCopyWords(3,BG1_Tiles, BG_TILE_RAM_SUB(1), sizeof(BG1_Tiles));
 +
thUpdateBgPalette(BG1_Pal, 1, sizeof(BG1_Pal));
 +
thUpdateBgSubPalette(BG1_Pal, 1, sizeof(BG1_Pal));
 +
thSpriteSetHblankFunc((void*)&myhblnkfunc);
 +
}
 +
 
 +
//whatever you need to update the bg each frame
 +
void mybg0update(int frame) {
 +
BG1_Y0=(u16)-frame;
 +
SUB_BG1_Y0=(u16)-frame;
 +
}
 +
 
 +
//when your finished...
 +
void mybg0finish(void) {
 +
thSpriteSetHblankFunc((void*)NULL);
 +
}
 +
 
 +
//defines the background
 +
thbg_t mybg0={
 +
(void*)&mybg0start,
 +
(void*)&mybg0update,
 +
(void*)&mybg0finish
 +
};
 +
 
 +
</source>
 +
<source lang="c">
 +
//someplace in ur code start the desired bg...
 +
thBgStart(&mybg0);
 +
</source>

Latest revision as of 16:19, 22 November 2009

This page can be used to experiment with the waki wiki ways

note to self: make a page on writing device drivers for libnds...

asdfgh!

some of meh programming values:

  • simplicity

things should be intuitive, easy to use. variable and function names should be self explanitory as much as possible.

  • consistency

variable and function names, methods, etc should follow patterns

  • modularity

individual components that can be used alone or in tandem

  • compatibility

components should work with each other as well as other '3rd party components'

  • familiarity

components should be based when appropriate on well known common concepts.

  • eat lots of leet onion

Huh @_@? How about: no one is perfect :p

~_~</div>{{#if:February 2008||}}

Blah Blah Blah

Black and pink DSLite displayed here play with wiki image links

Lupis Leeestum blah da teestium.

Sowarikko?!! nandeyo?! ¬_¬

Math boxes do not work?

<math>(x2-x1)^2</math>

<math>{n^n \over 3^n} < n! < {n^n \over 2^n}\mbox{ for }n\ge 6.</math>

(a*px+b*py+c)/sqrt(a^2+b^2) <--- shortest distance from p(oint) to line (abc) ab = slope, c = distance


void reverse(char *str) {
 char *epos=strlen(str);
 char c;
 do {
   c=*--epos;
   *str=*epos;
   *epos++=c;
 } while(str>epos);
}


bgfunct

#ifndef THBG_H
#define THBG_H
 
typedef void(*_pBgStartFunc)(void);	//Background Setup Function (called first)
typedef void(*_pBgUpdateFunc)(int);	//Background update function
typedef void(*_pBgFinishFunc)(void);	//Background destroy function 
 
typedef struct {
	_pBgStartFunc 	start;
	_pBgUpdateFunc	update;
	_pBgFinishFunc	finish;
	void 		*bgdat;		//background set specific data
} thbg_t;
 
void thBgInit(void);		//get everything ready
void thBgUpdate(int frame);	//call this every vblank
void thBgStart(thbg_t *thbg);	//call this to start a bg (will first stop any already running)
void thBgFinish(void);		//stops bg, erases bg mem, etc
 
void thUpdateBgPalette(uint16 *pal, int dstpal, int size);
void thUpdateBgSubPalette(uint16 *pal, int dstpal, int size);
 
#endif
#include <nds.h>
#include "thbg.h"
#include <stdio.h>
 
thbg_t *currentbg;
 
void thBgInit(void) {
	currentbg=NULL;
	vramSetBankC(VRAM_C_SUB_BG);
	vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
	vramSetBankB(VRAM_B_MAIN_BG);
	vramSetBankE(VRAM_E_MAIN_BG);
	vramSetBankF(VRAM_F_BG_EXT_PALETTE);
}
 
//hmmz should i have pBgStartFunc return a pointer to its data, then pass that as arg to update and finish?
void thBgStart(thbg_t *thbg) {
	thBgFinish();	//just in case
	currentbg=thbg;	
	if(currentbg->start) 
		((_pBgStartFunc)currentbg->start)();
}
 
void thBgUpdate(int frame) {
	if(currentbg) {
		((_pBgUpdateFunc)currentbg->update)(frame);
	}
}
 
void thBgFinish(void) {
	if(currentbg) {
		if(currentbg->finish) 
			((_pBgFinishFunc)currentbg->finish)();
		currentbg=NULL;
	}
}
 
void thUpdateBgPalette(uint16 *pal, int dstpal, int size) {
	vramSetBankF(VRAM_F_LCD);
        DC_FlushRange(pal,size);
	dmaCopyWords(3,pal, VRAM_F_EXT_PALETTE[dstpal], size);
	vramSetBankF(VRAM_F_BG_EXT_PALETTE);
}
 
void thUpdateBgSubPalette(uint16 *pal, int dstpal, int size) {
	vramSetBankH(VRAM_H_LCD);
        DC_FlushRange(pal,size);
	dmaCopyWords(3,pal, VRAM_H_EXT_PALETTE[dstpal], size);
	vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
}
//Whatever you need to initalize the bg
void mybg0start(void) {
	BG1_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(12) | BG_TILE_BASE(1) | BG_PRIORITY(BG_PRIORITY_1);
	SUB_BG1_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(12) | BG_TILE_BASE(1) | BG_PRIORITY(BG_PRIORITY_1);
	dmaCopyWords(3,BG1_Map, BG_MAP_RAM(12), sizeof(BG1_Map));
	dmaCopyWords(3,BG1_Tiles, BG_TILE_RAM(1), sizeof(BG1_Tiles));
	dmaCopyWords(3,BG1_Map, BG_MAP_RAM_SUB(12), sizeof(BG1_Map));
	dmaCopyWords(3,BG1_Tiles, BG_TILE_RAM_SUB(1), sizeof(BG1_Tiles));
	thUpdateBgPalette(BG1_Pal, 1, sizeof(BG1_Pal));
	thUpdateBgSubPalette(BG1_Pal, 1, sizeof(BG1_Pal));
	thSpriteSetHblankFunc((void*)&myhblnkfunc);	
}
 
//whatever you need to update the bg each frame
void mybg0update(int frame) {
	BG1_Y0=(u16)-frame;
	SUB_BG1_Y0=(u16)-frame;	
}
 
//when your finished...
void mybg0finish(void) {
	thSpriteSetHblankFunc((void*)NULL);
}
 
//defines the background
thbg_t mybg0={
	(void*)&mybg0start,
	(void*)&mybg0update,
	(void*)&mybg0finish
};
//someplace in ur code start the desired bg...
	thBgStart(&mybg0);
Personal tools
irssi scripts
eggdrop scripts