Sandbox

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
Line 27: Line 27:
 
  } while(str>epos);
 
  } while(str>epos);
 
}
 
}
 +
</source>
 +
 +
 +
 +
==bgfunct==
 +
<source lang="c>
 +
#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);
 +
}
 +
 +
 
</source>
 
</source>

Revision as of 04:07, 23 June 2008

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

Invalid language.

You need to specify a language like this: <source lang="html">...</source>

Supported languages for syntax highlighting:

abap, actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, dot, eiffel, fortran, freebasic, genero, gml, groovy, haskell, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, m68k, matlab, mirc, mpasm, mysql, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, per, perl, php, php-brief, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80

Personal tools
irssi scripts
eggdrop scripts