Sandbox

From ProjectWiki
Revision as of 04:07, 23 June 2008 by Wikisysop (Talk | contribs)
Jump to: navigation, search

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

~_~</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);
}
Personal tools
irssi scripts
eggdrop scripts