├── .gitignore ├── Graphics ├── 3D │ ├── 3D_Both_Screens │ │ ├── Makefile │ │ └── source │ │ │ └── template.c │ ├── BoxTest │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── Display_List │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── Display_List_2 │ │ ├── Makefile │ │ ├── data │ │ │ └── teapot.bin │ │ └── source │ │ │ └── main.cpp │ ├── Env_Mapping │ │ ├── Makefile │ │ ├── data │ │ │ ├── cafe.bin │ │ │ └── teapot.bin │ │ └── source │ │ │ └── main.cpp │ ├── Makefile │ ├── Mixed_Text_3D │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── Ortho │ │ ├── Makefile │ │ ├── data │ │ │ └── drunkenlogo.pcx │ │ └── source │ │ │ └── main.cpp │ ├── Paletted_Cube │ │ ├── Makefile │ │ ├── data │ │ │ ├── texture10_COMP_pal.bin │ │ │ ├── texture10_COMP_tex.bin │ │ │ └── texture10_COMP_texExt.bin │ │ ├── graphics │ │ │ ├── 16bpp.grit │ │ │ ├── 16bpp.tga │ │ │ ├── a3i5.grit │ │ │ ├── a3i5.tga │ │ │ ├── a5i3.grit │ │ │ ├── a5i3.tga │ │ │ ├── i2.grit │ │ │ ├── i2.tga │ │ │ ├── i4.grit │ │ │ ├── i4.tga │ │ │ ├── i8.grit │ │ │ └── i8.tga │ │ └── source │ │ │ └── main.cpp │ ├── Picking │ │ ├── Makefile │ │ ├── data │ │ │ ├── cone.bin │ │ │ ├── cylinder.bin │ │ │ └── sphere.bin │ │ └── source │ │ │ └── main.cpp │ ├── Simple_Quad │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── Simple_Tri │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── Textured_Cube │ │ ├── Makefile │ │ ├── data │ │ │ └── texture.bin │ │ └── source │ │ │ └── main.cpp │ ├── Textured_Quad │ │ ├── Makefile │ │ ├── data │ │ │ └── texture.bin │ │ └── source │ │ │ └── main.cpp │ ├── Toon_Shading │ │ ├── Makefile │ │ ├── data │ │ │ └── statue.bin │ │ └── source │ │ │ └── main.cpp │ └── nehe │ │ ├── Makefile │ │ ├── lesson01 │ │ ├── Makefile │ │ └── source │ │ │ └── nehe1.cpp │ │ ├── lesson02 │ │ ├── Makefile │ │ └── source │ │ │ └── nehe2.cpp │ │ ├── lesson03 │ │ ├── Makefile │ │ └── source │ │ │ └── nehe3.cpp │ │ ├── lesson04 │ │ ├── Makefile │ │ └── source │ │ │ └── nehe4.cpp │ │ ├── lesson05 │ │ ├── Makefile │ │ └── source │ │ │ └── nehe5.cpp │ │ ├── lesson06 │ │ ├── Makefile │ │ ├── data │ │ │ └── drunkenlogo.pcx │ │ └── source │ │ │ └── nehe6.cpp │ │ ├── lesson07 │ │ ├── Makefile │ │ ├── data │ │ │ └── drunkenlogo.pcx │ │ └── source │ │ │ └── nehe7.cpp │ │ ├── lesson08 │ │ ├── Makefile │ │ ├── data │ │ │ └── drunkenlogo.pcx │ │ └── source │ │ │ └── nehe8.cpp │ │ ├── lesson09 │ │ ├── Makefile │ │ ├── data │ │ │ └── Star.pcx │ │ └── source │ │ │ └── nehe9.cpp │ │ ├── lesson10 │ │ ├── Makefile │ │ ├── data │ │ │ ├── Mud.pcx │ │ │ ├── World.txt │ │ │ └── drunkenlogo.pcx │ │ └── source │ │ │ └── nehe10.cpp │ │ ├── lesson10b │ │ ├── Makefile │ │ ├── data │ │ │ ├── Mud.pcx │ │ │ └── World.txt │ │ └── source │ │ │ └── nehe10b.cpp │ │ └── lesson11 │ │ ├── Makefile │ │ ├── data │ │ └── drunkenlogo.pcx │ │ └── source │ │ └── nehe11.cpp ├── Backgrounds │ ├── 16bit_color_bmp │ │ ├── Makefile │ │ ├── data │ │ │ ├── drunkenlogo.grit │ │ │ └── drunkenlogo.png │ │ └── source │ │ │ └── template.cpp │ ├── 256_color_bmp │ │ ├── Makefile │ │ ├── data │ │ │ ├── drunkenlogo.grit │ │ │ └── drunkenlogo.png │ │ └── source │ │ │ └── main.cpp │ ├── Double_Buffer │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── Makefile │ ├── all_in_one │ │ ├── Makefile │ │ ├── gfx │ │ │ ├── layers.pew │ │ │ ├── readme.txt │ │ │ └── tiles.png │ │ ├── include │ │ │ ├── Multilayer.h │ │ │ ├── RotBackgrounds.h │ │ │ └── TextBackgrounds.h │ │ └── source │ │ │ ├── Multilayer.s │ │ │ ├── RotBackgrounds.s │ │ │ ├── TextBackgrounds.s │ │ │ ├── advanced.cpp │ │ │ ├── basic.cpp │ │ │ ├── handmade.cpp │ │ │ ├── main.cpp │ │ │ └── scrolling.cpp │ └── rotation │ │ ├── Makefile │ │ ├── data │ │ ├── drunkenlogo.bin │ │ └── palette.bin │ │ └── source │ │ └── main.cpp ├── Effects │ └── windows │ │ ├── Makefile │ │ ├── gfx │ │ ├── drunkenlogo.grit │ │ └── drunkenlogo.png │ │ └── source │ │ └── template.c ├── Ext_Palettes │ └── backgrounds │ │ ├── Makefile │ │ ├── gfx │ │ ├── devkitlogo.grit │ │ ├── devkitlogo.png │ │ ├── drunkenlogo.grit │ │ └── drunkenlogo.png │ │ └── source │ │ └── main.c ├── Makefile ├── Printing │ ├── Makefile │ ├── ansi_console │ │ ├── Makefile │ │ └── source │ │ │ └── main.c │ ├── console_windows │ │ ├── Makefile │ │ └── source │ │ │ └── main.c │ ├── custom_font │ │ ├── Makefile │ │ ├── gfx │ │ │ ├── font.bmp │ │ │ └── font.grit │ │ └── source │ │ │ └── main.c │ ├── print_both_screens │ │ ├── Makefile │ │ └── source │ │ │ └── template.c │ └── rotscale_text │ │ ├── Makefile │ │ ├── gfx │ │ ├── font.bmp │ │ └── font.grit │ │ └── source │ │ └── main.c ├── Sprites │ ├── Makefile │ ├── allocation_test │ │ ├── Makefile │ │ └── source │ │ │ └── main.c │ ├── animate_simple │ │ ├── Makefile │ │ ├── source │ │ │ └── template.c │ │ └── sprites │ │ │ ├── man.png │ │ │ ├── sprite.grit │ │ │ └── woman.png │ ├── bitmap_sprites │ │ ├── Makefile │ │ └── source │ │ │ └── main.cpp │ ├── fire_and_sprites │ │ ├── Makefile │ │ ├── data │ │ │ └── ball.pcx │ │ └── source │ │ │ └── main.cpp │ ├── simple │ │ ├── Makefile │ │ └── source │ │ │ └── template.c │ ├── sprite_extended_palettes │ │ ├── Makefile │ │ └── source │ │ │ └── template.c │ └── sprite_rotate │ │ ├── Makefile │ │ └── source │ │ └── template.c ├── capture │ ├── Makefile │ └── ScreenShot │ │ ├── Makefile │ │ ├── include │ │ ├── bmp.h │ │ └── screenshot.h │ │ └── source │ │ ├── main.cpp │ │ └── screenshot.cpp ├── gl2d │ ├── 2Dplus3D │ │ ├── 2Dplus3D.pnps │ │ ├── Makefile │ │ ├── gfx │ │ │ ├── Thumbs.db │ │ │ ├── enemies.bmp │ │ │ ├── enemies.grit │ │ │ ├── flyer.grit │ │ │ ├── flyer.png │ │ │ ├── organ16.bmp │ │ │ ├── organ16.grit │ │ │ ├── shuttle.grit │ │ │ └── shuttle.png │ │ ├── readme_2Dplus2D.txt │ │ └── source │ │ │ ├── Cvertexbuffer.cpp │ │ │ ├── Cvertexbuffer.h │ │ │ ├── cearn_atan.cpp │ │ │ ├── cearn_atan.h │ │ │ ├── main.cpp │ │ │ └── uvcoord_enemies.h │ ├── Makefile │ ├── dual_screen │ │ ├── Makefile │ │ ├── dual_screen.pnps │ │ ├── readme_dual_screen.txt │ │ └── source │ │ │ └── main.c │ ├── fonts │ │ ├── Fonts.pnps │ │ ├── Makefile │ │ ├── gfx │ │ │ ├── Thumbs.db │ │ │ ├── font_16x16.bmp │ │ │ ├── font_16x16.grit │ │ │ ├── font_si.bmp │ │ │ └── font_si.grit │ │ ├── readme_fonts.txt │ │ └── source │ │ │ ├── main.cpp │ │ │ ├── uvcoord_font_16x16.h │ │ │ └── uvcoord_font_si.h │ ├── primitives │ │ ├── Makefile │ │ ├── primitives.pnps │ │ ├── readme_primitives.txt │ │ └── source │ │ │ └── main.c │ ├── scrolling │ │ ├── Makefile │ │ ├── gfx │ │ │ ├── Thumbs.db │ │ │ ├── crono.bmp │ │ │ ├── crono.grit │ │ │ ├── tiles.bmp │ │ │ └── tiles.grit │ │ ├── readme_scrolling.txt │ │ ├── scrolling.pnps │ │ └── source │ │ │ ├── main.c │ │ │ └── uvcoord_crono.h │ └── sprites │ │ ├── Makefile │ │ ├── gfx │ │ ├── Thumbs.db │ │ ├── anya.grit │ │ ├── anya.png │ │ ├── blob_sprite.bmp │ │ ├── blob_sprite.grit │ │ ├── enemies.bmp │ │ ├── enemies.grit │ │ ├── flyer.grit │ │ ├── flyer.png │ │ ├── font.bmp │ │ ├── font.grit │ │ ├── fontbubble.bmp │ │ ├── fontbubble.grit │ │ ├── shuttle.grit │ │ ├── shuttle.png │ │ ├── test_sprite.bmp │ │ ├── test_sprite.grit │ │ ├── tiles.bmp │ │ ├── tiles.grit │ │ ├── zero.bmp │ │ └── zero.grit │ │ ├── readme_sprites.txt │ │ ├── source │ │ ├── cearn_atan.cpp │ │ ├── cearn_atan.h │ │ ├── main.cpp │ │ ├── uvcoord_enemies.h │ │ └── uvcoord_zero.h │ │ └── sprites.pnps └── grit │ ├── 256colorTilemap │ ├── Makefile │ ├── gfx │ │ ├── tilemap.grit │ │ └── tilemap.png │ └── source │ │ └── main.c │ └── Makefile ├── Makefile ├── audio ├── Makefile ├── maxmod │ ├── Makefile │ ├── audio_modes │ │ ├── Makefile │ │ ├── audio │ │ │ ├── keyg-subtonal.xm │ │ │ ├── purple_motion-inspiration.s3m │ │ │ └── rez-monday.mod │ │ └── source │ │ │ └── main.c │ ├── basic_sound │ │ ├── Makefile │ │ ├── maxmod_data │ │ │ ├── Ambulance.wav │ │ │ ├── Boom.wav │ │ │ └── FlatOutLies.mod │ │ └── source │ │ │ └── MaxModExample.c │ ├── reverb │ │ ├── Makefile │ │ ├── audio │ │ │ └── tempest-zen_bowling.mod │ │ └── source │ │ │ └── main.c │ ├── song_events_example │ │ ├── Makefile │ │ ├── gfx │ │ │ ├── ball.grit │ │ │ └── ball.png │ │ ├── music │ │ │ └── example.it │ │ └── source │ │ │ └── template.c │ ├── song_events_example2 │ │ ├── Makefile │ │ ├── music │ │ │ └── example2.it │ │ └── source │ │ │ └── template.c │ └── streaming │ │ ├── Makefile │ │ └── source │ │ └── main.c └── micrecord │ ├── Makefile │ └── source │ └── micrecord.c ├── card ├── Makefile └── eeprom │ ├── Makefile │ └── source │ └── main.cpp ├── debugging ├── Makefile └── exceptionTest │ ├── Makefile │ └── source │ └── exceptionTest.c ├── dswifi ├── Makefile ├── ap_search │ ├── Makefile │ ├── gfx │ │ └── wifiicon.png │ └── source │ │ └── template.c ├── autoconnect │ ├── Makefile │ └── source │ │ └── autoconnect.c └── httpget │ ├── Makefile │ └── source │ └── httpget.c ├── filesystem ├── Makefile ├── libfat │ ├── Makefile │ └── libfatdir │ │ ├── Makefile │ │ └── source │ │ └── directory.c └── nitrofs │ ├── Makefile │ ├── nitrodir │ ├── Makefile │ ├── nitrofiles │ │ ├── dir1 │ │ │ └── test.txt │ │ ├── dir2 │ │ │ └── subdir1 │ │ │ │ ├── subsubdir1 │ │ │ │ └── file2.txt │ │ │ │ └── test2.txt │ │ └── file1.txt │ └── source │ │ └── directory.c │ └── overlays │ ├── Makefile │ ├── overlays.ld │ └── source │ ├── main.c │ ├── test0.c │ ├── test1.c │ └── test2.c ├── hello_world ├── Makefile └── source │ └── main.cpp ├── input ├── Makefile ├── Touch_Pad │ ├── Makefile │ ├── touch_look │ │ ├── Makefile │ │ ├── data │ │ │ ├── Mud.pcx │ │ │ └── World.txt │ │ └── source │ │ │ └── main.cpp │ └── touch_test │ │ ├── Makefile │ │ ├── graphics │ │ ├── ball.grit │ │ └── ball.png │ │ └── source │ │ └── main.c ├── addon │ ├── Makefile │ └── source │ │ └── addon.c └── keyboard │ ├── Makefile │ ├── keyboard_async │ ├── Makefile │ └── source │ │ └── template.c │ └── keyboard_stdin │ ├── Makefile │ └── source │ └── keymain.c ├── pxi ├── Makefile ├── arm7 │ ├── Makefile │ └── source │ │ └── template.c └── arm9 │ ├── Makefile │ └── source │ └── template.c ├── templates ├── Makefile ├── arm9 │ ├── Makefile │ └── source │ │ └── main.c ├── arm9lib │ ├── Makefile │ ├── include │ │ └── templatelib.h │ └── source │ │ └── templatelib.c ├── combined │ ├── Makefile │ ├── arm7 │ │ ├── Makefile │ │ └── source │ │ │ └── template.c │ └── arm9 │ │ ├── Makefile │ │ └── source │ │ └── template.c └── dldi │ ├── Makefile │ └── source │ ├── dldi_header.s │ └── iointerface.c └── time ├── Makefile ├── RealTimeClock ├── Makefile └── source │ └── main.c ├── stopwatch ├── Makefile └── source │ └── main.c └── timercallback ├── Makefile └── source └── main.c /.gitignore: -------------------------------------------------------------------------------- 1 | .*/ 2 | *.nds 3 | *.elf 4 | *build 5 | *.dldi 6 | templates/arm9lib/lib 7 | *.bz2 8 | *~ 9 | -------------------------------------------------------------------------------- /Graphics/3D/Display_List/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | //display list 5 | u32 triangle[] = 6 | { 7 | 12, 8 | FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR), 9 | GL_TRIANGLE, 10 | RGB15(31,0,0), 11 | VERTEX_PACK(inttov16(-1),inttov16(-1)), VERTEX_PACK(0,0), 12 | RGB15(0,31,0), 13 | FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_COLOR, FIFO_VERTEX16, FIFO_END), 14 | VERTEX_PACK(inttov16(1),inttov16(-1)), VERTEX_PACK(0,0), 15 | RGB15(0,0,31), 16 | VERTEX_PACK(inttov16(0),inttov16(1)), VERTEX_PACK(0,0), 17 | }; 18 | 19 | int main() 20 | { 21 | 22 | float rotateX = 0.0; 23 | float rotateY = 0.0; 24 | 25 | //set mode 0, enable BG0 and set it to 3D 26 | videoSetMode(MODE_0_3D); 27 | 28 | // initialize gl 29 | glInit(); 30 | 31 | // enable antialiasing 32 | glEnable(GL_ANTIALIAS); 33 | 34 | // setup the rear plane 35 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 36 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 37 | glClearDepth(0x7FFF); 38 | 39 | //this should work the same as the normal gl call 40 | glViewport(0,0,255,191); 41 | 42 | 43 | glMatrixMode(GL_PROJECTION); 44 | glLoadIdentity(); 45 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 46 | 47 | gluLookAt( 0.0, 0.0, 1.0, //camera possition 48 | 0.0, 0.0, 0.0, //look at 49 | 0.0, 1.0, 0.0); //up 50 | 51 | while(pmMainLoop()) 52 | { 53 | swiWaitForVBlank(); 54 | scanKeys(); 55 | 56 | u32 keys = keysHeld(); 57 | 58 | if(keys & KEY_START) break; 59 | 60 | if((keys & KEY_UP)) rotateX += 3; 61 | if((keys & KEY_DOWN)) rotateX -= 3; 62 | if((keys & KEY_LEFT)) rotateY += 3; 63 | if((keys & KEY_RIGHT)) rotateY -= 3; 64 | 65 | glPushMatrix(); 66 | 67 | //move it away from the camera 68 | glTranslatef32(0, 0, floattof32(-1)); 69 | 70 | glRotateX(rotateX); 71 | glRotateY(rotateY); 72 | 73 | glMatrixMode(GL_TEXTURE); 74 | glLoadIdentity(); 75 | 76 | glMatrixMode(GL_MODELVIEW); 77 | 78 | //not a real gl function and will likely change 79 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 80 | 81 | glCallList(triangle); 82 | 83 | glPopMatrix(1); 84 | 85 | glFlush(0); 86 | } 87 | 88 | return 0; 89 | }//end main 90 | -------------------------------------------------------------------------------- /Graphics/3D/Display_List_2/data/teapot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Display_List_2/data/teapot.bin -------------------------------------------------------------------------------- /Graphics/3D/Display_List_2/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //teapot display list provided by Mike260, as well as the display list gl code. 4 | #include "teapot_bin.h" 5 | 6 | 7 | int main() { 8 | 9 | float rotateX = 0.0; 10 | float rotateY = 0.0; 11 | 12 | //set mode 0, enable BG0 and set it to 3D 13 | videoSetMode(MODE_0_3D); 14 | 15 | // initialize gl 16 | glInit(); 17 | 18 | // enable antialiasing 19 | glEnable(GL_ANTIALIAS); 20 | 21 | // setup the rear plane 22 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 23 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 24 | glClearDepth(0x7FFF); 25 | 26 | //this should work the same as the normal gl call 27 | glViewport(0,0,255,191); 28 | 29 | //any floating point gl call is being converted to fixed prior to being implemented 30 | glMatrixMode(GL_PROJECTION); 31 | glLoadIdentity(); 32 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 33 | 34 | gluLookAt( 0.0, 0.0, 3.5, //camera possition 35 | 0.0, 0.0, 0.0, //look at 36 | 0.0, 1.0, 0.0); //up 37 | 38 | glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); 39 | glLight(1, RGB15(31,0,31), 0, floattov10(1) - 1, 0); 40 | glLight(2, RGB15(0,31,0) , floattov10(-1.0), 0, 0); 41 | glLight(3, RGB15(0,0,31) , floattov10(1.0) - 1, 0, 0); 42 | 43 | //not a real gl function and will likely change 44 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | 45 | POLY_FORMAT_LIGHT2 | POLY_FORMAT_LIGHT3 ) ; 46 | 47 | while(pmMainLoop()) 48 | { 49 | swiWaitForVBlank(); 50 | scanKeys(); 51 | u32 keys = keysHeld(); 52 | 53 | if(keys & KEY_START) break; 54 | if(!(keys & KEY_UP)) rotateX += 3; 55 | if(!(keys & KEY_DOWN)) rotateX -= 3; 56 | if(!(keys & KEY_LEFT)) rotateY += 3; 57 | if(!(keys & KEY_RIGHT)) rotateY -= 3; 58 | 59 | glPushMatrix(); 60 | 61 | glRotateX(rotateX); 62 | glRotateY(rotateY); 63 | 64 | glCallList((u32*)teapot_bin); 65 | 66 | glPopMatrix(1); 67 | 68 | glFlush(0); 69 | } 70 | 71 | return 0; 72 | }//end main 73 | -------------------------------------------------------------------------------- /Graphics/3D/Env_Mapping/data/cafe.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Env_Mapping/data/cafe.bin -------------------------------------------------------------------------------- /Graphics/3D/Env_Mapping/data/teapot.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Env_Mapping/data/teapot.bin -------------------------------------------------------------------------------- /Graphics/3D/Env_Mapping/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | #include "teapot_bin.h" 5 | #include "cafe_bin.h" 6 | 7 | 8 | static void get_pen_delta( int *dx, int *dy ) { 9 | 10 | static int prev_pen[2] = { 0x7FFFFFFF, 0x7FFFFFFF }; 11 | touchPosition touchXY; 12 | 13 | if( touchRead(&touchXY) ) { 14 | 15 | if( prev_pen[0] != 0x7FFFFFFF ) { 16 | *dx = (prev_pen[0] - touchXY.rawx); 17 | *dy = (prev_pen[1] - touchXY.rawy); 18 | } else { 19 | *dx = *dy = 0; 20 | } 21 | 22 | prev_pen[0] = touchXY.rawx; 23 | prev_pen[1] = touchXY.rawy; 24 | } else { 25 | prev_pen[0] = prev_pen[1] = 0x7FFFFFFF; 26 | *dx = *dy = 0; 27 | } 28 | } 29 | 30 | 31 | int main() { 32 | 33 | int rotateX = 0; 34 | int rotateY = 0; 35 | 36 | //set mode 0, enable BG0 and set it to 3D 37 | videoSetMode(MODE_0_3D); 38 | 39 | // intialize gl 40 | glInit(); 41 | 42 | // enable antialiasing 43 | glEnable(GL_ANTIALIAS); 44 | 45 | // setup the rear plane 46 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 47 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 48 | glClearDepth(0x7FFF); 49 | 50 | //this should work the same as the normal gl call 51 | glViewport(0,0,255,191); 52 | 53 | vramSetBankA(VRAM_A_TEXTURE); 54 | glEnable(GL_TEXTURE_2D); 55 | 56 | int cafe_texid; 57 | glGenTextures( 1, &cafe_texid ); 58 | glBindTexture( 0, cafe_texid ); 59 | glTexImage2D( 0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, GL_TEXTURE_WRAP_S|GL_TEXTURE_WRAP_T|TEXGEN_NORMAL, (u8*)cafe_bin ); 60 | 61 | 62 | //any floating point gl call is being converted to fixed prior to being implemented 63 | glMatrixMode(GL_PROJECTION); 64 | glLoadIdentity(); 65 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 66 | 67 | while(pmMainLoop()) { 68 | 69 | swiWaitForVBlank(); 70 | scanKeys(); 71 | u32 keys = keysHeld(); 72 | 73 | if(keys & KEY_START) break; 74 | if( keys & KEY_UP ) rotateX += 1<<7; 75 | if( keys & KEY_DOWN ) rotateX -= 1<<7; 76 | if( keys & KEY_LEFT ) rotateY += 1<<7; 77 | if( keys & KEY_RIGHT ) rotateY -= 1<<7; 78 | 79 | //TEXGEN_NORMAL helpfully pops our normals into this matrix and uses the result as texcoords 80 | glMatrixMode(GL_TEXTURE); 81 | glLoadIdentity(); 82 | GLvector tex_scale = { 64<<16, -64<<16, 1<<16 }; 83 | glScalev( &tex_scale ); //scale normals up from (-1,1) range into texcoords 84 | glRotateXi(rotateX); //rotate texture-matrix to match the camera 85 | glRotateYi(rotateY); 86 | 87 | 88 | glMatrixMode(GL_POSITION); 89 | glLoadIdentity(); 90 | glTranslatef32(0, 0, floattof32(-3)); 91 | glRotateXi(rotateX); 92 | glRotateYi(rotateY); 93 | 94 | glMaterialf(GL_EMISSION, RGB15(31,31,31)); 95 | 96 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK ); 97 | 98 | int pen_delta[2]; 99 | get_pen_delta( &pen_delta[0], &pen_delta[1] ); 100 | rotateY -= pen_delta[0]<<2; 101 | rotateX -= pen_delta[1]<<2; 102 | 103 | glBindTexture( 0, cafe_texid ); 104 | glCallList((u32*)teapot_bin); 105 | 106 | glFlush(0); 107 | 108 | } 109 | 110 | return 0; 111 | }//end main 112 | -------------------------------------------------------------------------------- /Graphics/3D/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/3D/Mixed_Text_3D/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | void DrawGLScene(); 7 | 8 | float rtri; // Angle For The Triangle ( NEW ) 9 | float rquad; // Angle For The Quad ( NEW ) 10 | 11 | int main() { 12 | 13 | // initialize the geometry engine 14 | glInit(); 15 | 16 | // Setup the Main screen for 3D 17 | videoSetMode(MODE_0_3D); 18 | 19 | //map some vram to background for printing 20 | vramSetBankC(VRAM_C_MAIN_BG_0x06000000); 21 | 22 | consoleInit(0,1, BgType_Text4bpp, BgSize_T_256x256, 31,0, true, true); 23 | 24 | //put bg 0 at a lower priority than the text background 25 | bgSetPriority(0, 1); 26 | 27 | 28 | 29 | // enable antialiasing 30 | glEnable(GL_ANTIALIAS); 31 | 32 | // setup the rear plane 33 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 34 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 35 | glClearDepth(0x7FFF); 36 | 37 | // Set our viewport to be the same size as the screen 38 | glViewport(0,0,255,191); 39 | 40 | glMatrixMode(GL_PROJECTION); 41 | glLoadIdentity(); 42 | gluPerspective(70, 256.0 / 192.0, 0.1, 100); 43 | 44 | //ds specific, several attributes can be set here 45 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 46 | 47 | // Set the current matrix to be the model matrix 48 | glMatrixMode(GL_MODELVIEW); 49 | 50 | iprintf(" Hello DS World\n"); 51 | iprintf(" www.devkitpro.org\n"); 52 | iprintf(" www.drunkencoders.com\n"); 53 | 54 | while (pmMainLoop()) { 55 | 56 | DrawGLScene(); 57 | 58 | // flush to screen 59 | glFlush(0); 60 | 61 | // wait for the screen to refresh 62 | swiWaitForVBlank(); 63 | 64 | scanKeys(); 65 | 66 | int keys = keysDown(); 67 | 68 | if(keys & KEY_START) break; 69 | 70 | printf("\x1b[15;5H rtri = %f \n", rtri); 71 | printf("\x1b[16;5H rquad = %f \n", rquad); 72 | rtri+=0.9f; // Increase The Rotation Variable For The Triangle ( NEW ) 73 | rquad-=0.75f; // Decrease The Rotation Variable For The Quad ( NEW ) 74 | 75 | rtri = fmodf( rtri , 360 ); 76 | rquad = fmodf( rquad, 360 ); 77 | 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | // Here's Where We Do All The Drawing 84 | void DrawGLScene() { 85 | 86 | //ds does this automagically*open>///glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer 87 | 88 | glLoadIdentity(); // Reset The Current Modelview Matrix 89 | glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 90 | glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW ) 91 | glColor3f(1, 1, 1); // set the vertex color 92 | glBegin(GL_TRIANGLES); // Start Drawing A Triangle 93 | glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To Red 94 | glVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The Triangle 95 | glColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To Green 96 | glVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The Triangle 97 | glColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To Blue 98 | glVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle 99 | glEnd(); // Done Drawing The Triangle 100 | glLoadIdentity(); // Reset The Current Modelview Matrix 101 | 102 | 103 | glTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0 104 | glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW ) 105 | glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time Only 106 | glBegin(GL_QUADS); // Draw A Quad 107 | glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left 108 | glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right 109 | glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right 110 | glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left 111 | glEnd(); // Done Drawing The Quad 112 | 113 | } 114 | 115 | -------------------------------------------------------------------------------- /Graphics/3D/Ortho/data/drunkenlogo.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Ortho/data/drunkenlogo.pcx -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/data/texture10_COMP_pal.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/data/texture10_COMP_pal.bin -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/data/texture10_COMP_tex.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/data/texture10_COMP_tex.bin -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/data/texture10_COMP_texExt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/data/texture10_COMP_texExt.bin -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/16bpp.grit: -------------------------------------------------------------------------------- 1 | #enable texture mode 2 | -gx 3 | 4 | #enable bitmap mode 5 | -gb 6 | 7 | #required texture format 8 | -gB16 9 | 10 | #generate binary file and no header 11 | -ftb 12 | -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/16bpp.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/graphics/16bpp.tga -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/a3i5.grit: -------------------------------------------------------------------------------- 1 | #enable texture mode 2 | -gx 3 | 4 | #enable bitmap mode 5 | -gb 6 | 7 | #required texture format 8 | -gBa3i5 9 | 10 | #generate binary file and no header 11 | -ftb 12 | -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/a3i5.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/graphics/a3i5.tga -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/a5i3.grit: -------------------------------------------------------------------------------- 1 | #enable texture mode 2 | -gx 3 | 4 | #enable bitmap mode 5 | -gb 6 | 7 | #required texture format 8 | -gBa5i3 9 | 10 | -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/a5i3.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/graphics/a5i3.tga -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/i2.grit: -------------------------------------------------------------------------------- 1 | #enable texture mode 2 | -gx 3 | 4 | #enable bitmap mode 5 | -gb 6 | 7 | #required texture format 8 | -gB2 9 | 10 | #generate binary file and no header 11 | -ftb 12 | -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/i2.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/graphics/i2.tga -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/i4.grit: -------------------------------------------------------------------------------- 1 | #enable texture mode 2 | -gx 3 | 4 | #enable bitmap mode 5 | -gb 6 | 7 | #required texture format 8 | -gB4 9 | 10 | #generate binary file and no header 11 | -ftb 12 | -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/i4.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/graphics/i4.tga -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/i8.grit: -------------------------------------------------------------------------------- 1 | #enable texture mode 2 | -gx 3 | 4 | #enable bitmap mode 5 | -gb 6 | 7 | #required texture format 8 | -gB8 9 | 10 | #generate binary file and no header 11 | -ftb 12 | -------------------------------------------------------------------------------- /Graphics/3D/Paletted_Cube/graphics/i8.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Paletted_Cube/graphics/i8.tga -------------------------------------------------------------------------------- /Graphics/3D/Picking/data/cone.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Picking/data/cone.bin -------------------------------------------------------------------------------- /Graphics/3D/Picking/data/cylinder.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Picking/data/cylinder.bin -------------------------------------------------------------------------------- /Graphics/3D/Picking/data/sphere.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Picking/data/sphere.bin -------------------------------------------------------------------------------- /Graphics/3D/Simple_Quad/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | 7 | float rotateX = 0.0; 8 | float rotateY = 0.0; 9 | 10 | //set mode 0, enable BG0 and set it to 3D 11 | videoSetMode(MODE_0_3D); 12 | 13 | // initialize gl 14 | glInit(); 15 | 16 | // enable antialiasing 17 | glEnable(GL_ANTIALIAS); 18 | 19 | // setup the rear plane 20 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 21 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 22 | glClearDepth(0x7FFF); 23 | 24 | //this should work the same as the normal gl call 25 | glViewport(0,0,255,191); 26 | 27 | //any floating point gl call is being converted to fixed prior to being implemented 28 | glMatrixMode(GL_PROJECTION); 29 | glLoadIdentity(); 30 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 31 | 32 | gluLookAt( 0.0, 0.0, 1.0, //camera possition 33 | 0.0, 0.0, 0.0, //look at 34 | 0.0, 1.0, 0.0); //up 35 | 36 | while(pmMainLoop()) 37 | { 38 | glPushMatrix(); 39 | 40 | //move it away from the camera 41 | glTranslatef32(0, 0, floattof32(-1)); 42 | 43 | glRotateX(rotateX); 44 | glRotateY(rotateY); 45 | 46 | 47 | glMatrixMode(GL_MODELVIEW); 48 | 49 | 50 | 51 | //not a real gl function and will likely change 52 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 53 | 54 | scanKeys(); 55 | 56 | u16 keys = keysHeld(); 57 | 58 | if((keys & KEY_UP)) rotateX += 3; 59 | if((keys & KEY_DOWN)) rotateX -= 3; 60 | if((keys & KEY_LEFT)) rotateY += 3; 61 | if((keys & KEY_RIGHT)) rotateY -= 3; 62 | 63 | //draw the obj 64 | glBegin(GL_QUAD); 65 | 66 | glColor3b(255,0,0); 67 | glVertex3v16(inttov16(-1),inttov16(-1),0); 68 | 69 | glColor3b(0,255,0); 70 | glVertex3v16(inttov16(1), inttov16(-1), 0); 71 | 72 | glColor3b(0,0,255); 73 | glVertex3v16(inttov16(1), inttov16(1), 0); 74 | 75 | glColor3b(255,0,255); 76 | glVertex3v16(inttov16(-1), inttov16(1), 0); 77 | 78 | glEnd(); 79 | 80 | glPopMatrix(1); 81 | 82 | glFlush(0); 83 | 84 | swiWaitForVBlank(); 85 | 86 | if(keys & KEY_START) break; 87 | } 88 | 89 | return 0; 90 | }//end main 91 | -------------------------------------------------------------------------------- /Graphics/3D/Simple_Tri/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() { 5 | 6 | float rotateX = 0.0; 7 | float rotateY = 0.0; 8 | 9 | //set mode 0, enable BG0 and set it to 3D 10 | videoSetMode(MODE_0_3D); 11 | 12 | // initialize gl 13 | glInit(); 14 | 15 | // enable antialiasing 16 | glEnable(GL_ANTIALIAS); 17 | 18 | // setup the rear plane 19 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 20 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 21 | glClearDepth(0x7FFF); 22 | 23 | //this should work the same as the normal gl call 24 | glViewport(0,0,255,191); 25 | 26 | //any floating point gl call is being converted to fixed prior to being implemented 27 | glMatrixMode(GL_PROJECTION); 28 | glLoadIdentity(); 29 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 30 | 31 | gluLookAt( 0.0, 0.0, 1.0, //camera possition 32 | 0.0, 0.0, 0.0, //look at 33 | 0.0, 1.0, 0.0); //up 34 | 35 | while(pmMainLoop()) { 36 | glPushMatrix(); 37 | 38 | //move it away from the camera 39 | glTranslatef32(0, 0, floattof32(-1)); 40 | 41 | glRotateX(rotateX); 42 | glRotateY(rotateY); 43 | 44 | 45 | glMatrixMode(GL_MODELVIEW); 46 | 47 | 48 | 49 | //not a real gl function and will likely change 50 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 51 | 52 | scanKeys(); 53 | 54 | u16 keys = keysHeld(); 55 | 56 | if((keys & KEY_UP)) rotateX += 3; 57 | if((keys & KEY_DOWN)) rotateX -= 3; 58 | if((keys & KEY_LEFT)) rotateY += 3; 59 | if((keys & KEY_RIGHT)) rotateY -= 3; 60 | 61 | 62 | //draw the obj 63 | glBegin(GL_TRIANGLE); 64 | 65 | glColor3b(255,0,0); 66 | glVertex3v16(inttov16(-1),inttov16(-1),0); 67 | 68 | glColor3b(0,255,0); 69 | glVertex3v16(inttov16(1), inttov16(-1), 0); 70 | 71 | glColor3b(0,0,255); 72 | glVertex3v16(inttov16(0), inttov16(1), 0); 73 | 74 | glEnd(); 75 | 76 | glPopMatrix(1); 77 | 78 | glFlush(0); 79 | 80 | swiWaitForVBlank(); 81 | 82 | if(keys & KEY_START) break; 83 | } 84 | 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /Graphics/3D/Textured_Cube/data/texture.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Textured_Cube/data/texture.bin -------------------------------------------------------------------------------- /Graphics/3D/Textured_Quad/data/texture.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Textured_Quad/data/texture.bin -------------------------------------------------------------------------------- /Graphics/3D/Textured_Quad/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //texture_bin.h is created automagicaly from the texture.bin placed in arm9/resources 5 | //texture.bin is a raw 128x128 16 bit image. I will release a tool for texture conversion 6 | //later 7 | #include "texture_bin.h" 8 | 9 | int main() { 10 | 11 | int textureID; 12 | 13 | float rotateX = 0.0; 14 | float rotateY = 0.0; 15 | 16 | //set mode 0, enable BG0 and set it to 3D 17 | videoSetMode(MODE_0_3D); 18 | 19 | // initialize gl 20 | glInit(); 21 | 22 | //enable textures 23 | glEnable(GL_TEXTURE_2D); 24 | 25 | // enable antialiasing 26 | glEnable(GL_ANTIALIAS); 27 | 28 | // setup the rear plane 29 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 30 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 31 | glClearDepth(0x7FFF); 32 | 33 | //this should work the same as the normal gl call 34 | glViewport(0,0,255,191); 35 | 36 | vramSetBankA(VRAM_A_TEXTURE); 37 | 38 | glGenTextures(1, &textureID); 39 | glBindTexture(0, textureID); 40 | glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)texture_bin); 41 | 42 | 43 | //any floating point gl call is being converted to fixed prior to being implemented 44 | glMatrixMode(GL_PROJECTION); 45 | glLoadIdentity(); 46 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 47 | 48 | gluLookAt( 0.0, 0.0, 1.0, //camera possition 49 | 0.0, 0.0, 0.0, //look at 50 | 0.0, 1.0, 0.0); //up 51 | 52 | while(pmMainLoop()) { 53 | glMatrixMode(GL_MODELVIEW); 54 | glPushMatrix(); 55 | 56 | //move it away from the camera 57 | glTranslatef32(0, 0, floattof32(-1)); 58 | 59 | glRotateX(rotateX); 60 | glRotateY(rotateY); 61 | 62 | 63 | 64 | glMaterialf(GL_AMBIENT, RGB15(16,16,16)); 65 | glMaterialf(GL_DIFFUSE, RGB15(16,16,16)); 66 | glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8)); 67 | glMaterialf(GL_EMISSION, RGB15(16,16,16)); 68 | 69 | //ds uses a table for shinyness..this generates a half-ass one 70 | glMaterialShinyness(); 71 | 72 | //not a real gl function and will likely change 73 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK); 74 | 75 | scanKeys(); 76 | 77 | u16 keys = keysHeld(); 78 | 79 | if((keys & KEY_UP)) rotateX += 3; 80 | if((keys & KEY_DOWN)) rotateX -= 3; 81 | if((keys & KEY_LEFT)) rotateY += 3; 82 | if((keys & KEY_RIGHT)) rotateY -= 3; 83 | 84 | glBindTexture(0, textureID); 85 | 86 | //draw the obj 87 | glBegin(GL_QUAD); 88 | glNormal(NORMAL_PACK(0,inttov10(-1),0)); 89 | 90 | GFX_TEX_COORD = (TEXTURE_PACK(0, inttot16(128))); 91 | glVertex3v16(floattov16(-0.5), floattov16(-0.5), 0 ); 92 | 93 | GFX_TEX_COORD = (TEXTURE_PACK(inttot16(128),inttot16(128))); 94 | glVertex3v16(floattov16(0.5), floattov16(-0.5), 0 ); 95 | 96 | GFX_TEX_COORD = (TEXTURE_PACK(inttot16(128), 0)); 97 | glVertex3v16(floattov16(0.5), floattov16(0.5), 0 ); 98 | 99 | GFX_TEX_COORD = (TEXTURE_PACK(0,0)); 100 | glVertex3v16(floattov16(-0.5), floattov16(0.5), 0 ); 101 | 102 | glEnd(); 103 | 104 | glPopMatrix(1); 105 | 106 | glFlush(0); 107 | 108 | swiWaitForVBlank(); 109 | 110 | if(keys & KEY_START) break; 111 | } 112 | 113 | return 0; 114 | }//end main 115 | -------------------------------------------------------------------------------- /Graphics/3D/Toon_Shading/data/statue.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/Toon_Shading/data/statue.bin -------------------------------------------------------------------------------- /Graphics/3D/Toon_Shading/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | //NB: This would look better if the object had a bit of texturing too (eyes, nose etc) 5 | 6 | 7 | #include "statue_bin.h" 8 | 9 | 10 | static void get_pen_delta( int *dx, int *dy ) { 11 | static int prev_pen[2] = { 0x7FFFFFFF, 0x7FFFFFFF }; 12 | 13 | u32 keys = keysHeld(); 14 | 15 | touchPosition touchXY; 16 | 17 | if( keys & KEY_TOUCH ) { 18 | 19 | touchRead(&touchXY); 20 | if( prev_pen[0] != 0x7FFFFFFF ) { 21 | *dx = (prev_pen[0] - touchXY.rawx); 22 | *dy = (prev_pen[1] - touchXY.rawy); 23 | } else { 24 | *dx = *dy = 0; 25 | } 26 | 27 | prev_pen[0] = touchXY.rawx; 28 | prev_pen[1] = touchXY.rawy; 29 | } else { 30 | prev_pen[0] = prev_pen[1] = 0x7FFFFFFF; 31 | *dx = *dy = 0; 32 | } 33 | } 34 | 35 | 36 | 37 | int main() { 38 | 39 | int rotateX = 0; 40 | int rotateY = 0; 41 | 42 | //set mode 0, enable BG0 and set it to 3D 43 | videoSetMode(MODE_0_3D); 44 | 45 | // initialize gl 46 | glInit(); 47 | 48 | // enable antialiasing 49 | glEnable(GL_ANTIALIAS); 50 | 51 | // setup the rear plane 52 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 53 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 54 | glClearDepth(0x7FFF); 55 | 56 | //this should work the same as the normal gl call 57 | glViewport(0,0,255,191); 58 | 59 | //toon-table entry 0 is for completely unlit pixels, going up to entry 31 for completely lit 60 | //We block-fill it in two halves, we get cartoony 2-tone lighting 61 | glSetToonTableRange( 0, 15, RGB15(8,8,8) ); 62 | glSetToonTableRange( 16, 31, RGB15(24,24,24) ); 63 | 64 | //any floating point gl call is being converted to fixed prior to being implemented 65 | glMatrixMode(GL_PROJECTION); 66 | glLoadIdentity(); 67 | gluPerspective(70, 256.0 / 192.0, 0.1, 40); 68 | 69 | //NB: When toon-shading, the hw ignores lights 2 and 3 70 | //Also note that the hw uses the RED component of the lit vertex to index the toon-table 71 | glLight(0, RGB15(16,16,16) , 0, floattov10(-1.0), 0); 72 | glLight(1, RGB15(16,16,16), floattov10(-1.0), 0, 0); 73 | 74 | gluLookAt( 0.0, 0.0, -3.0, //camera possition 75 | 0.0, 0.0, 0.0, //look at 76 | 0.0, 1.0, 0.0); //up 77 | 78 | while(pmMainLoop()) { 79 | 80 | glMatrixMode(GL_MODELVIEW); 81 | glPushMatrix(); 82 | glRotateXi(rotateX); 83 | glRotateYi(rotateY); 84 | 85 | 86 | glMaterialf(GL_AMBIENT, RGB15(8,8,8)); 87 | glMaterialf(GL_DIFFUSE, RGB15(24,24,24)); 88 | glMaterialf(GL_SPECULAR, RGB15(0,0,0)); 89 | glMaterialf(GL_EMISSION, RGB15(0,0,0)); 90 | 91 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_TOON_HIGHLIGHT); 92 | 93 | 94 | scanKeys(); 95 | u32 keys = keysHeld(); 96 | 97 | if( keys & KEY_UP ) rotateX += 1; 98 | if( keys & KEY_DOWN ) rotateX -= 1; 99 | if( keys & KEY_LEFT ) rotateY += 1; 100 | if( keys & KEY_RIGHT ) rotateY -= 1; 101 | 102 | int pen_delta[2]; 103 | get_pen_delta( &pen_delta[0], &pen_delta[1] ); 104 | rotateY -= pen_delta[0]; 105 | rotateX -= pen_delta[1]; 106 | 107 | glCallList((u32*)statue_bin); 108 | glPopMatrix(1); 109 | 110 | glFlush(0); 111 | 112 | swiWaitForVBlank(); 113 | 114 | if(keys & KEY_START) break; 115 | } 116 | 117 | return 0; 118 | } 119 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson01/source/nehe1.cpp: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * NDS NeHe Lesson 01 * 3 | * Author: Dovoto * 4 | ****************************************/ 5 | 6 | // include your ndslib 7 | #include 8 | 9 | 10 | int DrawGLScene(); 11 | 12 | int main() { 13 | 14 | // Setup the Main screen for 3D 15 | videoSetMode(MODE_0_3D); 16 | 17 | // initialize the geometry engine 18 | glInit(); 19 | 20 | // enable antialiasing 21 | glEnable(GL_ANTIALIAS); 22 | 23 | // setup the rear plane 24 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 25 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 26 | glClearDepth(0x7FFF); 27 | 28 | // Set our viewport to be the same size as the screen 29 | glViewport(0,0,255,191); 30 | 31 | // setup the view 32 | glMatrixMode(GL_PROJECTION); 33 | glLoadIdentity(); 34 | gluPerspective(70, 256.0 / 192.0, 0.1, 100); 35 | 36 | 37 | //ds specific, several attributes can be set here 38 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 39 | 40 | while (pmMainLoop()) 41 | { 42 | // Set the current matrix to be the model matrix 43 | glMatrixMode(GL_MODELVIEW); 44 | 45 | glColor3f(1, 1, 1); // Set the color..not in nehe source...ds gl default will be black 46 | 47 | //Push our original Matrix onto the stack (save state) 48 | glPushMatrix(); 49 | 50 | DrawGLScene(); 51 | 52 | // Pop our Matrix from the stack (restore state) 53 | glPopMatrix(1); 54 | 55 | //a handy little built in function to wait for a screen refresh 56 | swiWaitForVBlank(); 57 | 58 | // flush to screen 59 | glFlush(0); 60 | 61 | scanKeys(); 62 | 63 | int pressed = keysDown(); 64 | 65 | if(pressed & KEY_START) break; 66 | } 67 | 68 | return 0; 69 | } 70 | 71 | int DrawGLScene(void) 72 | { 73 | //we are going to use floating point for the tutorial...keep in mind the DS has no 74 | //floating point hardware. For real life use the built in fixed point types. 75 | //this is where the magic happens 76 | glLoadIdentity(); 77 | return TRUE; 78 | } 79 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson02/source/nehe2.cpp: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * NDS NeHe Lesson 02 * 3 | * Author: Dovoto * 4 | ****************************************/ 5 | 6 | // include your ndslib 7 | #include 8 | 9 | 10 | int DrawGLScene(); 11 | 12 | 13 | int main() { 14 | // Setup the Main screen for 3D 15 | videoSetMode(MODE_0_3D); 16 | 17 | // initialize the geometry engine 18 | glInit(); 19 | 20 | // enable antialiasing 21 | glEnable(GL_ANTIALIAS); 22 | 23 | // setup the rear plane 24 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 25 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 26 | glClearDepth(0x7FFF); 27 | 28 | // Set our viewport to be the same size as the screen 29 | glViewport(0,0,255,191); 30 | 31 | glMatrixMode(GL_PROJECTION); 32 | glLoadIdentity(); 33 | gluPerspective(70, 256.0 / 192.0, 0.1, 100); 34 | 35 | // Set the color of the vertices 36 | glColor3f(1, 1, 1); 37 | 38 | while (pmMainLoop()) { 39 | 40 | //ds specific, several attributes can be set here 41 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 42 | 43 | // Set the current matrix to be the model matrix 44 | glMatrixMode(GL_MODELVIEW); 45 | 46 | //Push our original Matrix onto the stack (save state) 47 | glPushMatrix(); 48 | 49 | DrawGLScene(); 50 | 51 | // Pop our Matrix from the stack (restore state) 52 | glPopMatrix(1); 53 | 54 | //a handy little built in function to wait for a screen refresh 55 | swiWaitForVBlank(); 56 | 57 | // flush to screen 58 | glFlush(0); 59 | 60 | scanKeys(); 61 | 62 | int pressed = keysDown(); 63 | 64 | if(pressed & KEY_START) break; 65 | 66 | } 67 | 68 | return 0; 69 | } 70 | 71 | int DrawGLScene() { 72 | 73 | glLoadIdentity(); // Reset The Current Modelview Matrix 74 | glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 75 | glBegin(GL_TRIANGLES); // Drawing Using Triangles 76 | glVertex3f( 0.0f, 1.0f, 0.0f); // Top 77 | glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left 78 | glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right 79 | glEnd(); // Finished Drawing The Triangle 80 | glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units 81 | glBegin(GL_QUADS); // Draw A Quad 82 | glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left 83 | glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right 84 | glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right 85 | glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left 86 | glEnd(); // Done Drawing The Quad 87 | return TRUE; // Keep Going 88 | } 89 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson03/source/nehe3.cpp: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * NDS NeHe Lesson 03 * 3 | * Author: Dovoto * 4 | ****************************************/ 5 | 6 | // include your ndslib 7 | #include 8 | 9 | 10 | int DrawGLScene(); 11 | 12 | 13 | int main() { 14 | 15 | // Setup the Main screen for 3D 16 | videoSetMode(MODE_0_3D); 17 | 18 | // initialize the geometry engine 19 | glInit(); 20 | 21 | // enable antialiasing 22 | glEnable(GL_ANTIALIAS); 23 | 24 | // setup the rear plane 25 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 26 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 27 | glClearDepth(0x7FFF); 28 | 29 | // Set our viewport to be the same size as the screen 30 | glViewport(0,0,255,191); 31 | 32 | glMatrixMode(GL_PROJECTION); 33 | glLoadIdentity(); 34 | gluPerspective(70, 256.0 / 192.0, 0.1, 100); 35 | 36 | //ds specific, several attributes can be set here 37 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 38 | 39 | // Set the current matrix to be the model matrix 40 | glMatrixMode(GL_MODELVIEW); 41 | 42 | while (pmMainLoop()) 43 | { 44 | // draw the scene 45 | DrawGLScene(); 46 | 47 | // flush to screen 48 | glFlush(0); 49 | swiWaitForVBlank(); 50 | scanKeys(); 51 | 52 | int pressed = keysDown(); 53 | 54 | if(pressed & KEY_START) break; 55 | } 56 | 57 | return 0; 58 | } 59 | 60 | int DrawGLScene() // Here's Where We Do All The Drawing 61 | { 62 | glLoadIdentity(); // Reset The Current Modelview Matrix 63 | glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 64 | glBegin(GL_TRIANGLES); // Drawing Using Triangles 65 | glColor3f(1.0f,0.0f,0.0f); // Set The Color To Red 66 | glVertex3f( 0.0f, 1.0f, 0.0f); // Top 67 | glColor3f(0.0f,1.0f,0.0f); // Set The Color To Green 68 | glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left 69 | glColor3f(0.0f,0.0f,1.0f); // Set The Color To Blue 70 | glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right 71 | glEnd(); // Finished Drawing The Triangle 72 | glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units 73 | glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time Only 74 | glBegin(GL_QUADS); // Draw A Quad 75 | glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left 76 | glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right 77 | glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right 78 | glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left 79 | glEnd(); // Done Drawing The Quad 80 | return TRUE; 81 | } 82 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson04/source/nehe4.cpp: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * NDS NeHe Lesson 04 * 3 | * Author: Dovoto * 4 | ****************************************/ 5 | 6 | // include your ndslib 7 | #include 8 | 9 | 10 | int DrawGLScene(); 11 | 12 | float rtri; // Angle For The Triangle ( NEW ) 13 | float rquad; // Angle For The Quad ( NEW ) 14 | 15 | int main() { 16 | 17 | // Setup the Main screen for 3D 18 | videoSetMode(MODE_0_3D); 19 | 20 | // initialize the geometry engine 21 | glInit(); 22 | 23 | // enable antialiasing 24 | glEnable(GL_ANTIALIAS); 25 | 26 | // setup the rear plane 27 | glClearColor(0,0,0,31); // BG must be opaque for AA to work 28 | glClearPolyID(63); // BG must have a unique polygon ID for AA to work 29 | glClearDepth(0x7FFF); 30 | 31 | // Set our viewport to be the same size as the screen 32 | glViewport(0,0,255,191); 33 | 34 | glMatrixMode(GL_PROJECTION); 35 | glLoadIdentity(); 36 | gluPerspective(70, 256.0 / 192.0, 0.1, 100); 37 | 38 | //ds specific, several attributes can be set here 39 | glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); 40 | 41 | // Set the current matrix to be the model matrix 42 | glMatrixMode(GL_MODELVIEW); 43 | 44 | while (pmMainLoop()) 45 | { 46 | // draw the scene 47 | DrawGLScene(); 48 | 49 | // flush to screen 50 | glFlush(0); 51 | 52 | // wait for the screen to refresh 53 | swiWaitForVBlank(); 54 | scanKeys(); 55 | 56 | int pressed = keysDown(); 57 | 58 | if(pressed & KEY_START) break; 59 | } 60 | 61 | return 0; 62 | } 63 | 64 | int DrawGLScene() // Here's Where We Do All The Drawing 65 | { 66 | /*ds does this automagicaly*///glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer 67 | glLoadIdentity(); // Reset The Current Modelview Matrix 68 | glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 69 | glRotatef(rtri,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis ( NEW ) 70 | glColor3f(1, 1, 1); // set the vertex color 71 | glBegin(GL_TRIANGLES); // Start Drawing A Triangle 72 | glColor3f(1.0f,0.0f,0.0f); // Set Top Point Of Triangle To Red 73 | glVertex3f( 0.0f, 1.0f, 0.0f); // First Point Of The Triangle 74 | glColor3f(0.0f,1.0f,0.0f); // Set Left Point Of Triangle To Green 75 | glVertex3f(-1.0f,-1.0f, 0.0f); // Second Point Of The Triangle 76 | glColor3f(0.0f,0.0f,1.0f); // Set Right Point Of Triangle To Blue 77 | glVertex3f( 1.0f,-1.0f, 0.0f); // Third Point Of The Triangle 78 | glEnd(); // Done Drawing The Triangle 79 | glLoadIdentity(); // Reset The Current Modelview Matrix 80 | glTranslatef(1.5f,0.0f,-6.0f); // Move Right 1.5 Units And Into The Screen 6.0 81 | glRotatef(rquad,1.0f,0.0f,0.0f); // Rotate The Quad On The X axis ( NEW ) 82 | glColor3f(0.5f,0.5f,1.0f); // Set The Color To Blue One Time Only 83 | glBegin(GL_QUADS); // Draw A Quad 84 | glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left 85 | glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right 86 | glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right 87 | glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left 88 | glEnd(); // Done Drawing The Quad 89 | rtri+=0.9f; // Increase The Rotation Variable For The Triangle ( NEW ) 90 | rquad-=0.75f; // Decrease The Rotation Variable For The Quad ( NEW ) 91 | return TRUE; // Keep Going 92 | } 93 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson06/data/drunkenlogo.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson06/data/drunkenlogo.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson07/data/drunkenlogo.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson07/data/drunkenlogo.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson08/data/drunkenlogo.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson08/data/drunkenlogo.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson09/data/Star.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson09/data/Star.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson10/data/Mud.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson10/data/Mud.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson10/data/World.txt: -------------------------------------------------------------------------------- 1 | 2 | NUMPOLLIES 36 3 | 4 | // Floor 1 5 | -3.0 0.0 -3.0 0.0 6.0 6 | -3.0 0.0 3.0 0.0 0.0 7 | 3.0 0.0 3.0 6.0 0.0 8 | 9 | -3.0 0.0 -3.0 0.0 6.0 10 | 3.0 0.0 -3.0 6.0 6.0 11 | 3.0 0.0 3.0 6.0 0.0 12 | 13 | // Ceiling 1 14 | -3.0 1.0 -3.0 0.0 6.0 15 | -3.0 1.0 3.0 0.0 0.0 16 | 3.0 1.0 3.0 6.0 0.0 17 | -3.0 1.0 -3.0 0.0 6.0 18 | 3.0 1.0 -3.0 6.0 6.0 19 | 3.0 1.0 3.0 6.0 0.0 20 | 21 | // A1 22 | 23 | -2.0 1.0 -2.0 0.0 1.0 24 | -2.0 0.0 -2.0 0.0 0.0 25 | -0.5 0.0 -2.0 1.5 0.0 26 | -2.0 1.0 -2.0 0.0 1.0 27 | -0.5 1.0 -2.0 1.5 1.0 28 | -0.5 0.0 -2.0 1.5 0.0 29 | 30 | // A2 31 | 32 | 2.0 1.0 -2.0 2.0 1.0 33 | 2.0 0.0 -2.0 2.0 0.0 34 | 0.5 0.0 -2.0 0.5 0.0 35 | 2.0 1.0 -2.0 2.0 1.0 36 | 0.5 1.0 -2.0 0.5 1.0 37 | 0.5 0.0 -2.0 0.5 0.0 38 | 39 | // B1 40 | 41 | -2.0 1.0 2.0 2.0 1.0 42 | -2.0 0.0 2.0 2.0 0.0 43 | -0.5 0.0 2.0 0.5 0.0 44 | -2.0 1.0 2.0 2.0 1.0 45 | -0.5 1.0 2.0 0.5 1.0 46 | -0.5 0.0 2.0 0.5 0.0 47 | 48 | // B2 49 | 50 | 2.0 1.0 2.0 2.0 1.0 51 | 2.0 0.0 2.0 2.0 0.0 52 | 0.5 0.0 2.0 0.5 0.0 53 | 2.0 1.0 2.0 2.0 1.0 54 | 0.5 1.0 2.0 0.5 1.0 55 | 0.5 0.0 2.0 0.5 0.0 56 | 57 | // C1 58 | 59 | -2.0 1.0 -2.0 0.0 1.0 60 | -2.0 0.0 -2.0 0.0 0.0 61 | -2.0 0.0 -0.5 1.5 0.0 62 | -2.0 1.0 -2.0 0.0 1.0 63 | -2.0 1.0 -0.5 1.5 1.0 64 | -2.0 0.0 -0.5 1.5 0.0 65 | 66 | // C2 67 | 68 | -2.0 1.0 2.0 2.0 1.0 69 | -2.0 0.0 2.0 2.0 0.0 70 | -2.0 0.0 0.5 0.5 0.0 71 | -2.0 1.0 2.0 2.0 1.0 72 | -2.0 1.0 0.5 0.5 1.0 73 | -2.0 0.0 0.5 0.5 0.0 74 | 75 | // D1 76 | 77 | 2.0 1.0 -2.0 0.0 1.0 78 | 2.0 0.0 -2.0 0.0 0.0 79 | 2.0 0.0 -0.5 1.5 0.0 80 | 2.0 1.0 -2.0 0.0 1.0 81 | 2.0 1.0 -0.5 1.5 1.0 82 | 2.0 0.0 -0.5 1.5 0.0 83 | 84 | // D2 85 | 86 | 2.0 1.0 2.0 2.0 1.0 87 | 2.0 0.0 2.0 2.0 0.0 88 | 2.0 0.0 0.5 0.5 0.0 89 | 2.0 1.0 2.0 2.0 1.0 90 | 2.0 1.0 0.5 0.5 1.0 91 | 2.0 0.0 0.5 0.5 0.0 92 | 93 | // Upper hallway - L 94 | -0.5 1.0 -3.0 0.0 1.0 95 | -0.5 0.0 -3.0 0.0 0.0 96 | -0.5 0.0 -2.0 1.0 0.0 97 | -0.5 1.0 -3.0 0.0 1.0 98 | -0.5 1.0 -2.0 1.0 1.0 99 | -0.5 0.0 -2.0 1.0 0.0 100 | 101 | // Upper hallway - R 102 | 0.5 1.0 -3.0 0.0 1.0 103 | 0.5 0.0 -3.0 0.0 0.0 104 | 0.5 0.0 -2.0 1.0 0.0 105 | 0.5 1.0 -3.0 0.0 1.0 106 | 0.5 1.0 -2.0 1.0 1.0 107 | 0.5 0.0 -2.0 1.0 0.0 108 | 109 | // Lower hallway - L 110 | -0.5 1.0 3.0 0.0 1.0 111 | -0.5 0.0 3.0 0.0 0.0 112 | -0.5 0.0 2.0 1.0 0.0 113 | -0.5 1.0 3.0 0.0 1.0 114 | -0.5 1.0 2.0 1.0 1.0 115 | -0.5 0.0 2.0 1.0 0.0 116 | 117 | // Lower hallway - R 118 | 0.5 1.0 3.0 0.0 1.0 119 | 0.5 0.0 3.0 0.0 0.0 120 | 0.5 0.0 2.0 1.0 0.0 121 | 0.5 1.0 3.0 0.0 1.0 122 | 0.5 1.0 2.0 1.0 1.0 123 | 0.5 0.0 2.0 1.0 0.0 124 | 125 | 126 | // Left hallway - Lw 127 | 128 | -3.0 1.0 0.5 1.0 1.0 129 | -3.0 0.0 0.5 1.0 0.0 130 | -2.0 0.0 0.5 0.0 0.0 131 | -3.0 1.0 0.5 1.0 1.0 132 | -2.0 1.0 0.5 0.0 1.0 133 | -2.0 0.0 0.5 0.0 0.0 134 | 135 | // Left hallway - Hi 136 | 137 | -3.0 1.0 -0.5 1.0 1.0 138 | -3.0 0.0 -0.5 1.0 0.0 139 | -2.0 0.0 -0.5 0.0 0.0 140 | -3.0 1.0 -0.5 1.0 1.0 141 | -2.0 1.0 -0.5 0.0 1.0 142 | -2.0 0.0 -0.5 0.0 0.0 143 | 144 | // Right hallway - Lw 145 | 146 | 3.0 1.0 0.5 1.0 1.0 147 | 3.0 0.0 0.5 1.0 0.0 148 | 2.0 0.0 0.5 0.0 0.0 149 | 3.0 1.0 0.5 1.0 1.0 150 | 2.0 1.0 0.5 0.0 1.0 151 | 2.0 0.0 0.5 0.0 0.0 152 | 153 | // Right hallway - Hi 154 | 155 | 3.0 1.0 -0.5 1.0 1.0 156 | 3.0 0.0 -0.5 1.0 0.0 157 | 2.0 0.0 -0.5 0.0 0.0 158 | 3.0 1.0 -0.5 1.0 1.0 159 | 2.0 1.0 -0.5 0.0 1.0 160 | 2.0 0.0 -0.5 0.0 0.0 161 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson10/data/drunkenlogo.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson10/data/drunkenlogo.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson10b/data/Mud.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson10b/data/Mud.pcx -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson10b/data/World.txt: -------------------------------------------------------------------------------- 1 | 2 | NUMPOLLIES 36 3 | 4 | // Floor 1 5 | -3.0 0.0 -3.0 0.0 6.0 6 | -3.0 0.0 3.0 0.0 0.0 7 | 3.0 0.0 3.0 6.0 0.0 8 | 9 | -3.0 0.0 -3.0 0.0 6.0 10 | 3.0 0.0 -3.0 6.0 6.0 11 | 3.0 0.0 3.0 6.0 0.0 12 | 13 | // Ceiling 1 14 | -3.0 1.0 -3.0 0.0 6.0 15 | -3.0 1.0 3.0 0.0 0.0 16 | 3.0 1.0 3.0 6.0 0.0 17 | -3.0 1.0 -3.0 0.0 6.0 18 | 3.0 1.0 -3.0 6.0 6.0 19 | 3.0 1.0 3.0 6.0 0.0 20 | 21 | // A1 22 | 23 | -2.0 1.0 -2.0 0.0 1.0 24 | -2.0 0.0 -2.0 0.0 0.0 25 | -0.5 0.0 -2.0 1.5 0.0 26 | -2.0 1.0 -2.0 0.0 1.0 27 | -0.5 1.0 -2.0 1.5 1.0 28 | -0.5 0.0 -2.0 1.5 0.0 29 | 30 | // A2 31 | 32 | 2.0 1.0 -2.0 2.0 1.0 33 | 2.0 0.0 -2.0 2.0 0.0 34 | 0.5 0.0 -2.0 0.5 0.0 35 | 2.0 1.0 -2.0 2.0 1.0 36 | 0.5 1.0 -2.0 0.5 1.0 37 | 0.5 0.0 -2.0 0.5 0.0 38 | 39 | // B1 40 | 41 | -2.0 1.0 2.0 2.0 1.0 42 | -2.0 0.0 2.0 2.0 0.0 43 | -0.5 0.0 2.0 0.5 0.0 44 | -2.0 1.0 2.0 2.0 1.0 45 | -0.5 1.0 2.0 0.5 1.0 46 | -0.5 0.0 2.0 0.5 0.0 47 | 48 | // B2 49 | 50 | 2.0 1.0 2.0 2.0 1.0 51 | 2.0 0.0 2.0 2.0 0.0 52 | 0.5 0.0 2.0 0.5 0.0 53 | 2.0 1.0 2.0 2.0 1.0 54 | 0.5 1.0 2.0 0.5 1.0 55 | 0.5 0.0 2.0 0.5 0.0 56 | 57 | // C1 58 | 59 | -2.0 1.0 -2.0 0.0 1.0 60 | -2.0 0.0 -2.0 0.0 0.0 61 | -2.0 0.0 -0.5 1.5 0.0 62 | -2.0 1.0 -2.0 0.0 1.0 63 | -2.0 1.0 -0.5 1.5 1.0 64 | -2.0 0.0 -0.5 1.5 0.0 65 | 66 | // C2 67 | 68 | -2.0 1.0 2.0 2.0 1.0 69 | -2.0 0.0 2.0 2.0 0.0 70 | -2.0 0.0 0.5 0.5 0.0 71 | -2.0 1.0 2.0 2.0 1.0 72 | -2.0 1.0 0.5 0.5 1.0 73 | -2.0 0.0 0.5 0.5 0.0 74 | 75 | // D1 76 | 77 | 2.0 1.0 -2.0 0.0 1.0 78 | 2.0 0.0 -2.0 0.0 0.0 79 | 2.0 0.0 -0.5 1.5 0.0 80 | 2.0 1.0 -2.0 0.0 1.0 81 | 2.0 1.0 -0.5 1.5 1.0 82 | 2.0 0.0 -0.5 1.5 0.0 83 | 84 | // D2 85 | 86 | 2.0 1.0 2.0 2.0 1.0 87 | 2.0 0.0 2.0 2.0 0.0 88 | 2.0 0.0 0.5 0.5 0.0 89 | 2.0 1.0 2.0 2.0 1.0 90 | 2.0 1.0 0.5 0.5 1.0 91 | 2.0 0.0 0.5 0.5 0.0 92 | 93 | // Upper hallway - L 94 | -0.5 1.0 -3.0 0.0 1.0 95 | -0.5 0.0 -3.0 0.0 0.0 96 | -0.5 0.0 -2.0 1.0 0.0 97 | -0.5 1.0 -3.0 0.0 1.0 98 | -0.5 1.0 -2.0 1.0 1.0 99 | -0.5 0.0 -2.0 1.0 0.0 100 | 101 | // Upper hallway - R 102 | 0.5 1.0 -3.0 0.0 1.0 103 | 0.5 0.0 -3.0 0.0 0.0 104 | 0.5 0.0 -2.0 1.0 0.0 105 | 0.5 1.0 -3.0 0.0 1.0 106 | 0.5 1.0 -2.0 1.0 1.0 107 | 0.5 0.0 -2.0 1.0 0.0 108 | 109 | // Lower hallway - L 110 | -0.5 1.0 3.0 0.0 1.0 111 | -0.5 0.0 3.0 0.0 0.0 112 | -0.5 0.0 2.0 1.0 0.0 113 | -0.5 1.0 3.0 0.0 1.0 114 | -0.5 1.0 2.0 1.0 1.0 115 | -0.5 0.0 2.0 1.0 0.0 116 | 117 | // Lower hallway - R 118 | 0.5 1.0 3.0 0.0 1.0 119 | 0.5 0.0 3.0 0.0 0.0 120 | 0.5 0.0 2.0 1.0 0.0 121 | 0.5 1.0 3.0 0.0 1.0 122 | 0.5 1.0 2.0 1.0 1.0 123 | 0.5 0.0 2.0 1.0 0.0 124 | 125 | 126 | // Left hallway - Lw 127 | 128 | -3.0 1.0 0.5 1.0 1.0 129 | -3.0 0.0 0.5 1.0 0.0 130 | -2.0 0.0 0.5 0.0 0.0 131 | -3.0 1.0 0.5 1.0 1.0 132 | -2.0 1.0 0.5 0.0 1.0 133 | -2.0 0.0 0.5 0.0 0.0 134 | 135 | // Left hallway - Hi 136 | 137 | -3.0 1.0 -0.5 1.0 1.0 138 | -3.0 0.0 -0.5 1.0 0.0 139 | -2.0 0.0 -0.5 0.0 0.0 140 | -3.0 1.0 -0.5 1.0 1.0 141 | -2.0 1.0 -0.5 0.0 1.0 142 | -2.0 0.0 -0.5 0.0 0.0 143 | 144 | // Right hallway - Lw 145 | 146 | 3.0 1.0 0.5 1.0 1.0 147 | 3.0 0.0 0.5 1.0 0.0 148 | 2.0 0.0 0.5 0.0 0.0 149 | 3.0 1.0 0.5 1.0 1.0 150 | 2.0 1.0 0.5 0.0 1.0 151 | 2.0 0.0 0.5 0.0 0.0 152 | 153 | // Right hallway - Hi 154 | 155 | 3.0 1.0 -0.5 1.0 1.0 156 | 3.0 0.0 -0.5 1.0 0.0 157 | 2.0 0.0 -0.5 0.0 0.0 158 | 3.0 1.0 -0.5 1.0 1.0 159 | 2.0 1.0 -0.5 0.0 1.0 160 | 2.0 0.0 -0.5 0.0 0.0 161 | -------------------------------------------------------------------------------- /Graphics/3D/nehe/lesson11/data/drunkenlogo.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/3D/nehe/lesson11/data/drunkenlogo.pcx -------------------------------------------------------------------------------- /Graphics/Backgrounds/16bit_color_bmp/data/drunkenlogo.grit: -------------------------------------------------------------------------------- 1 | -W3 2 | # disable alpha and set opaque bit for all pixels 3 | -gT! 4 | 5 | # use lz77 compression 6 | -gzl 7 | 8 | # 16 bit bitmap 9 | -gB16 10 | 11 | -gb 12 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/16bit_color_bmp/data/drunkenlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Backgrounds/16bit_color_bmp/data/drunkenlogo.png -------------------------------------------------------------------------------- /Graphics/Backgrounds/16bit_color_bmp/source/template.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | // git outputs a nice header to reference data 6 | #include "drunkenlogo.h" 7 | 8 | int main(void) { 9 | 10 | // set the mode for 2 text layers and two extended background layers 11 | videoSetMode(MODE_5_2D); 12 | 13 | // set the sub background up for text display (we could just print to one 14 | // of the main display text backgrounds just as easily 15 | videoSetModeSub(MODE_0_2D); //sub bg 0 will be used to print text 16 | 17 | vramSetBankA(VRAM_A_MAIN_BG); 18 | 19 | consoleDemoInit(); 20 | 21 | iprintf("\n\n\tHello DS devers\n"); 22 | iprintf("\twww.drunkencoders.com\n"); 23 | iprintf("\t16 bit bitmap demo"); 24 | 25 | // set up our bitmap background 26 | bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0); 27 | 28 | decompress(drunkenlogoBitmap, BG_GFX, LZ77Vram); 29 | 30 | while(pmMainLoop()) { 31 | swiWaitForVBlank(); 32 | scanKeys(); 33 | if (keysDown()&KEY_START) break; 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/256_color_bmp/data/drunkenlogo.grit: -------------------------------------------------------------------------------- 1 | # 8 bit bitmap 2 | -gB8 3 | 4 | # bitmap format 5 | -gb 6 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/256_color_bmp/data/drunkenlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Backgrounds/256_color_bmp/data/drunkenlogo.png -------------------------------------------------------------------------------- /Graphics/Backgrounds/256_color_bmp/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // git adds a nice header we can include to access the data 6 | // this has the same name as the image 7 | #include "drunkenlogo.h" 8 | 9 | int main(void) 10 | { 11 | // set the mode for 2 text layers and two extended background layers 12 | videoSetMode(MODE_5_2D); 13 | vramSetBankA(VRAM_A_MAIN_BG_0x06000000); 14 | 15 | consoleDemoInit(); 16 | 17 | iprintf("\n\n\tHello DS devers\n"); 18 | iprintf("\twww.drunkencoders.com\n"); 19 | iprintf("\t256 color bitmap demo"); 20 | 21 | int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0); 22 | 23 | dmaCopy(drunkenlogoBitmap, bgGetGfxPtr(bg3), 256*256); 24 | dmaCopy(drunkenlogoPal, BG_PALETTE, 256*2); 25 | 26 | while(pmMainLoop()) { 27 | swiWaitForVBlank(); 28 | scanKeys(); 29 | if (keysDown()&KEY_START) break; 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/Double_Buffer/source/main.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | // Simple double buffering demo 3 | // -- dovoto 4 | //--------------------------------------------------------------------------------- 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | 12 | //--------------------------------------------------------------------------------- 13 | int main(void) { 14 | //--------------------------------------------------------------------------------- 15 | //set the mode for 2 text layers and two extended background layers 16 | videoSetMode(MODE_5_2D); 17 | 18 | //set the first two banks as background memory and the third as sub background memory 19 | //D is not used..if you need a bigger background then you will need to map 20 | //more vram banks consecutivly (VRAM A-D are all 0x20000 bytes in size) 21 | vramSetPrimaryBanks( VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, 22 | VRAM_C_SUB_BG , VRAM_D_LCD); 23 | 24 | consoleDemoInit(); 25 | 26 | iprintf("\n\n\tHello DS devers\n"); 27 | iprintf("\twww.drunkencoders.com\n"); 28 | iprintf("\tdouble buffer demo"); 29 | 30 | 31 | int bg = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0); 32 | 33 | u16 colorMask = 0x1F; 34 | 35 | u16* backBuffer = (u16*)bgGetGfxPtr(bg) + 256*256; 36 | 37 | while(pmMainLoop()) 38 | { 39 | //draw a box (60,60,196,136) 40 | for(int iy = 60; iy < 196 - 60; iy++) 41 | for(int ix = 60; ix < 256 - 60; ix++) 42 | backBuffer[iy * 256 + ix] = (rand() & colorMask) | BIT(15); 43 | 44 | swiWaitForVBlank(); 45 | scanKeys(); 46 | if (keysDown()&KEY_START) break; 47 | 48 | //swap the back buffer to the current buffer 49 | backBuffer = (u16*)bgGetGfxPtr(bg); 50 | 51 | //swap the current buffer by changing the base. Each base 52 | //represents 16KB of offset and each screen is 256x256x2 (128KB) 53 | //this requires a map base seperation of 8 (could get away with smaller 54 | //as the screen is really only showing 256x192 (96KB or map base 6) 55 | if(bgGetMapBase(bg) == 8) 56 | { 57 | bgSetMapBase(bg, 0); 58 | } 59 | else 60 | { 61 | bgSetMapBase(bg, 8); 62 | } 63 | 64 | colorMask ^= 0x3FF; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/all_in_one/gfx/layers.pew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Backgrounds/all_in_one/gfx/layers.pew -------------------------------------------------------------------------------- /Graphics/Backgrounds/all_in_one/gfx/readme.txt: -------------------------------------------------------------------------------- 1 | Maps were created using the tileset provided via the Pern Editor map software by dovoto 2 | 3 | Maps were exported individually using the grit export option. 4 | Rotation backgrounds were exported with 8 bit tile indexes checked. 5 | 6 | www.pernedit.com 7 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/all_in_one/gfx/tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Backgrounds/all_in_one/gfx/tiles.png -------------------------------------------------------------------------------- /Graphics/Backgrounds/all_in_one/include/Multilayer.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(Layer_1) 3 | 4 | //====================================================================== 5 | // 6 | // Layer_1, 256x256@8, 7 | // + regular map (flat), not compressed, 32x32 8 | // Total size: 2048 = 2048 9 | // 10 | // Time-stamp: 2007-12-07, 18:17:34 11 | // Exported by Cearn's GBA Image Transmogrifier 12 | // ( http://www.coranac.com ) 13 | // 14 | //====================================================================== 15 | 16 | #ifndef __LAYER_1__ 17 | #define __LAYER_1__ 18 | 19 | #define Layer_1MapLen 2048 20 | extern const unsigned short Layer_1Map[1024]; 21 | 22 | #endif // __LAYER_1__ 23 | 24 | //}}BLOCK(Layer_1) 25 | 26 | //{{BLOCK(Layer_2) 27 | 28 | //====================================================================== 29 | // 30 | // Layer_2, 256x256@8, 31 | // + regular map (flat), not compressed, 32x32 32 | // Total size: 2048 = 2048 33 | // 34 | // Time-stamp: 2007-12-07, 18:17:34 35 | // Exported by Cearn's GBA Image Transmogrifier 36 | // ( http://www.coranac.com ) 37 | // 38 | //====================================================================== 39 | 40 | #ifndef __LAYER_2__ 41 | #define __LAYER_2__ 42 | 43 | #define Layer_2MapLen 2048 44 | extern const unsigned short Layer_2Map[1024]; 45 | 46 | #endif // __LAYER_2__ 47 | 48 | //}}BLOCK(Layer_2) 49 | 50 | //{{BLOCK(Layer_3) 51 | 52 | //====================================================================== 53 | // 54 | // Layer_3, 256x256@8, 55 | // + regular map (flat), not compressed, 32x32 56 | // Total size: 2048 = 2048 57 | // 58 | // Time-stamp: 2007-12-07, 18:17:34 59 | // Exported by Cearn's GBA Image Transmogrifier 60 | // ( http://www.coranac.com ) 61 | // 62 | //====================================================================== 63 | 64 | #ifndef __LAYER_3__ 65 | #define __LAYER_3__ 66 | 67 | #define Layer_3MapLen 2048 68 | extern const unsigned short Layer_3Map[1024]; 69 | 70 | #endif // __LAYER_3__ 71 | 72 | //}}BLOCK(Layer_3) 73 | 74 | //{{BLOCK(Multilayer) 75 | 76 | //====================================================================== 77 | // 78 | // Multilayer, 8x2504@8, 79 | // + palette 256 entries, not compressed 80 | // + 313 tiles not compressed 81 | // Total size: 512 + 20032 = 20544 82 | // 83 | // Time-stamp: 2007-12-07, 18:17:35 84 | // Exported by Cearn's GBA Image Transmogrifier 85 | // ( http://www.coranac.com ) 86 | // 87 | //====================================================================== 88 | 89 | #ifndef __MULTILAYER__ 90 | #define __MULTILAYER__ 91 | 92 | #define MultilayerPalLen 512 93 | extern const unsigned short MultilayerPal[256]; 94 | 95 | #define MultilayerTilesLen 20032 96 | extern const unsigned int MultilayerTiles[5008]; 97 | 98 | #endif // __MULTILAYER__ 99 | 100 | //}}BLOCK(Multilayer) 101 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/all_in_one/include/RotBackgrounds.h: -------------------------------------------------------------------------------- 1 | 2 | //{{BLOCK(Layer128x128r) 3 | 4 | //====================================================================== 5 | // 6 | // Layer128x128r, 128x128@8, 7 | // + affine map, not compressed, 16x16 8 | // External tile file: (null). 9 | // Total size: 256 = 256 10 | // 11 | // Time-stamp: 2008-12-03, 18:15:41 12 | // Exported by Cearn's GBA Image Transmogrifier 13 | // ( http://www.coranac.com/projects/#grit ) 14 | // 15 | //====================================================================== 16 | 17 | #ifndef GRIT_LAYER128X128R_H 18 | #define GRIT_LAYER128X128R_H 19 | 20 | #define Layer128x128rMapLen 256 21 | extern const unsigned char Layer128x128rMap[256]; 22 | 23 | #endif // GRIT_LAYER128X128R_H 24 | 25 | //}}BLOCK(Layer128x128r) 26 | 27 | //{{BLOCK(Layer256x256r) 28 | 29 | //====================================================================== 30 | // 31 | // Layer256x256r, 256x256@8, 32 | // + affine map, not compressed, 32x32 33 | // External tile file: (null). 34 | // Total size: 1024 = 1024 35 | // 36 | // Time-stamp: 2008-12-03, 18:15:41 37 | // Exported by Cearn's GBA Image Transmogrifier 38 | // ( http://www.coranac.com/projects/#grit ) 39 | // 40 | //====================================================================== 41 | 42 | #ifndef GRIT_LAYER256X256R_H 43 | #define GRIT_LAYER256X256R_H 44 | 45 | #define Layer256x256rMapLen 1024 46 | extern const unsigned char Layer256x256rMap[1024]; 47 | 48 | #endif // GRIT_LAYER256X256R_H 49 | 50 | //}}BLOCK(Layer256x256r) 51 | 52 | //{{BLOCK(Layer512x512r) 53 | 54 | //====================================================================== 55 | // 56 | // Layer512x512r, 512x512@8, 57 | // + affine map, not compressed, 64x64 58 | // External tile file: (null). 59 | // Total size: 4096 = 4096 60 | // 61 | // Time-stamp: 2008-12-03, 18:15:41 62 | // Exported by Cearn's GBA Image Transmogrifier 63 | // ( http://www.coranac.com/projects/#grit ) 64 | // 65 | //====================================================================== 66 | 67 | #ifndef GRIT_LAYER512X512R_H 68 | #define GRIT_LAYER512X512R_H 69 | 70 | #define Layer512x512rMapLen 4096 71 | extern const unsigned char Layer512x512rMap[4096]; 72 | 73 | #endif // GRIT_LAYER512X512R_H 74 | 75 | //}}BLOCK(Layer512x512r) 76 | 77 | //{{BLOCK(Layer1024x1024r) 78 | 79 | //====================================================================== 80 | // 81 | // Layer1024x1024r, 1024x1024@8, 82 | // + affine map, not compressed, 128x128 83 | // External tile file: (null). 84 | // Total size: 16384 = 16384 85 | // 86 | // Time-stamp: 2008-12-03, 18:15:42 87 | // Exported by Cearn's GBA Image Transmogrifier 88 | // ( http://www.coranac.com/projects/#grit ) 89 | // 90 | //====================================================================== 91 | 92 | #ifndef GRIT_LAYER1024X1024R_H 93 | #define GRIT_LAYER1024X1024R_H 94 | 95 | #define Layer1024x1024rMapLen 16384 96 | extern const unsigned char Layer1024x1024rMap[16384]; 97 | 98 | #endif // GRIT_LAYER1024X1024R_H 99 | 100 | //}}BLOCK(Layer1024x1024r) 101 | 102 | //{{BLOCK(RotBackgrounds) 103 | 104 | //====================================================================== 105 | // 106 | // RotBackgrounds, 8x872@8, 107 | // + palette 256 entries, not compressed 108 | // + 109 tiles not compressed 109 | // Total size: 512 + 6976 = 7488 110 | // 111 | // Time-stamp: 2008-12-03, 18:15:42 112 | // Exported by Cearn's GBA Image Transmogrifier 113 | // ( http://www.coranac.com/projects/#grit ) 114 | // 115 | //====================================================================== 116 | 117 | #ifndef GRIT_ROTBACKGROUNDS_H 118 | #define GRIT_ROTBACKGROUNDS_H 119 | 120 | #define RotBackgroundsTilesLen 6976 121 | extern const unsigned int RotBackgroundsTiles[1744]; 122 | 123 | #define RotBackgroundsPalLen 512 124 | extern const unsigned short RotBackgroundsPal[256]; 125 | 126 | #endif // GRIT_ROTBACKGROUNDS_H 127 | 128 | //}}BLOCK(RotBackgrounds) 129 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/all_in_one/source/handmade.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | void scroll(int id, int width, int height); 7 | 8 | u8 tiles[] = 9 | { 10 | //Tile 0: transparent tile 11 | 0,0,0,0,0,0,0,0, 12 | 0,0,0,0,0,0,0,0, 13 | 0,0,0,0,0,0,0,0, 14 | 0,0,0,0,0,0,0,0, 15 | 0,0,0,0,0,0,0,0, 16 | 0,0,0,0,0,0,0,0, 17 | 0,0,0,0,0,0,0,0, 18 | 0,0,0,0,0,0,0,0, 19 | //Tile 1: solid tile using color index 1 20 | 1,1,1,1,1,1,1,1, 21 | 1,1,1,1,1,1,1,1, 22 | 1,1,1,1,1,1,1,1, 23 | 1,1,1,1,1,1,1,1, 24 | 1,1,1,1,1,1,1,1, 25 | 1,1,1,1,1,1,1,1, 26 | 1,1,1,1,1,1,1,1, 27 | 1,1,1,1,1,1,1,1, 28 | //Tile 2: solid tile using color index 2 29 | 2,2,2,2,2,2,2,2, 30 | 2,2,2,2,2,2,2,2, 31 | 2,2,2,2,2,2,2,2, 32 | 2,2,2,2,2,2,2,2, 33 | 2,2,2,2,2,2,2,2, 34 | 2,2,2,2,2,2,2,2, 35 | 2,2,2,2,2,2,2,2, 36 | 2,2,2,2,2,2,2,2, 37 | //Tile 3: smily face tile 38 | 0,0,1,1,1,1,0,0, 39 | 0,1,1,1,1,1,1,0, 40 | 1,1,2,1,1,2,1,1, 41 | 1,1,1,1,1,1,1,1, 42 | 1,1,1,1,1,1,1,1, 43 | 1,2,1,1,1,1,2,1, 44 | 0,1,2,2,2,2,1,0, 45 | 0,0,1,1,1,1,0,0, 46 | 47 | 48 | }; 49 | 50 | 51 | u16 map32x32[] = 52 | { 53 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 54 | 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 55 | 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1, 56 | 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1, 57 | 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1, 58 | 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 59 | 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 60 | 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 61 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 62 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 63 | 1,1,1,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,1,1, 64 | 1,1,1,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,1,1, 65 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 66 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 67 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 68 | 1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1, 69 | 1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1, 70 | 1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1, 71 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 72 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 73 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 74 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 75 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 76 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 77 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 78 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 79 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 80 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 81 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 82 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 83 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 84 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 85 | 86 | }; 87 | 88 | u16 palette[] = 89 | { 90 | RGB15(0,0,0), 91 | RGB15(31,31,0), 92 | RGB15(0,31,0) 93 | }; 94 | 95 | 96 | 97 | void HandMadeTiles(void) 98 | { 99 | videoSetMode(MODE_0_2D); 100 | vramSetBankA(VRAM_A_MAIN_BG); 101 | 102 | int bg = bgInit(0, BgType_Text8bpp, BgSize_T_256x256, 0,1); 103 | 104 | dmaCopy(tiles, bgGetGfxPtr(bg), sizeof(tiles)); 105 | dmaCopy(map32x32, bgGetMapPtr(bg), sizeof(map32x32)); 106 | dmaCopy(palette, BG_PALETTE, sizeof(palette)); 107 | 108 | scroll(bg, 256, 256); 109 | } 110 | -------------------------------------------------------------------------------- /Graphics/Backgrounds/rotation/data/drunkenlogo.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Backgrounds/rotation/data/drunkenlogo.bin -------------------------------------------------------------------------------- /Graphics/Backgrounds/rotation/data/palette.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Backgrounds/rotation/data/palette.bin -------------------------------------------------------------------------------- /Graphics/Backgrounds/rotation/source/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include //basic print funcionality 5 | #include 6 | #include 7 | 8 | 9 | // make file automaticaly makes a header file for access 10 | // to the binary data in any file ending in .bin that is in 11 | // the data folder. It also links in that data to your project 12 | 13 | #include "drunkenlogo_bin.h" 14 | #include "palette_bin.h" 15 | 16 | 17 | int main(void) { 18 | 19 | videoSetMode(MODE_5_2D ); 20 | 21 | vramSetBankA(VRAM_A_MAIN_BG); 22 | 23 | consoleDemoInit(); 24 | 25 | 26 | int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0); 27 | 28 | 29 | dmaCopy(drunkenlogo_bin, bgGetGfxPtr(bg3), 256*256); 30 | dmaCopy(palette_bin, BG_PALETTE, 256*2); 31 | 32 | s16 angle = 0; 33 | 34 | // the screen origin is at the rotation center...so scroll to the rotation 35 | // center + a small 32 pixle offset so our image is centered 36 | s16 scrollX = 128; 37 | s16 scrollY = 128 ; 38 | 39 | //scale is fixed point 40 | s16 scaleX = 1 << 8; 41 | s16 scaleY = 1 << 8; 42 | 43 | //this is the screen pixel that the image will rotate about 44 | s16 rcX = 128; 45 | s16 rcY = 96; 46 | 47 | while(pmMainLoop()) { 48 | // Print status 49 | 50 | iprintf("\n\n\tHello DS devers\n"); 51 | iprintf("\twww.drunkencoders.com\n"); 52 | iprintf("\tBG Rotation demo\n"); 53 | 54 | iprintf("Angle %3d(actual) %3d(degrees)\n", angle, (angle * 360) / (1<<15)); 55 | iprintf("Scroll X: %4d Y: %4d\n", scrollX, scrollY); 56 | iprintf("Rot center X: %4d Y: %4d\n", rcX, rcY); 57 | iprintf("Scale X: %4d Y: %4d\n", scaleX, scaleY); 58 | 59 | scanKeys(); 60 | u32 keys = keysHeld(); 61 | 62 | if( keys & KEY_L ) angle+=20; 63 | if( keys & KEY_R ) angle-=20; 64 | if( keys & KEY_LEFT ) scrollX++; 65 | if( keys & KEY_RIGHT ) scrollX--; 66 | if( keys & KEY_UP ) scrollY++; 67 | if( keys & KEY_DOWN ) scrollY--; 68 | if( keys & KEY_A ) scaleX++; 69 | if( keys & KEY_B ) scaleX--; 70 | if( keys & KEY_START ) rcX ++; 71 | if( keys & KEY_SELECT ) rcY++; 72 | if( keys & KEY_X ) scaleY++; 73 | if( keys & KEY_Y ) scaleY--; 74 | 75 | 76 | swiWaitForVBlank(); 77 | scanKeys(); 78 | if (keysDown()&KEY_START) break; 79 | 80 | bgSetCenter(bg3, rcX, rcY); 81 | bgSetRotateScale(bg3, angle, scaleX, scaleY); 82 | bgSetScroll(bg3, scrollX, scrollY); 83 | bgUpdate(); 84 | 85 | // clear the console screen (ansi escape sequence) 86 | iprintf("\x1b[2J"); 87 | 88 | } 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /Graphics/Effects/windows/gfx/drunkenlogo.grit: -------------------------------------------------------------------------------- 1 | # 8 bit bitmap 2 | -gB8 3 | 4 | # bitmap format 5 | -gb 6 | -------------------------------------------------------------------------------- /Graphics/Effects/windows/gfx/drunkenlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Effects/windows/gfx/drunkenlogo.png -------------------------------------------------------------------------------- /Graphics/Effects/windows/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | A very simple window demo which displays a square window 4 | 5 | ---------------------------------------------------------------------------------*/ 6 | #include 7 | #include "drunkenlogo.h" 8 | 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | 14 | videoSetMode(MODE_5_2D); 15 | vramSetBankA(VRAM_A_MAIN_BG); 16 | 17 | //enable a background 18 | int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0); 19 | 20 | //use the standard drunken logo 21 | dmaCopy(drunkenlogoBitmap, bgGetGfxPtr(bg3), drunkenlogoBitmapLen); 22 | dmaCopy(drunkenlogoPal, BG_PALETTE, drunkenlogoPalLen); 23 | 24 | //enable window 0 25 | windowEnable(WINDOW_0); 26 | 27 | //enable window 0 on our new background 28 | bgWindowEnable(bg3, WINDOW_0); 29 | 30 | int x = 60; 31 | int y = 60; 32 | int size = 100; 33 | 34 | while(pmMainLoop()) 35 | { 36 | 37 | scanKeys(); 38 | if(keysHeld() & KEY_START) break; 39 | //the code below just moves the window around 40 | if(keysHeld() & KEY_UP) y--; 41 | if(keysHeld() & KEY_DOWN) y++; 42 | if(keysHeld() & KEY_LEFT) x--; 43 | if(keysHeld() & KEY_RIGHT) x++; 44 | 45 | if(keysHeld() & KEY_A) size--; 46 | if(keysHeld() & KEY_B) size++; 47 | 48 | if(keysHeld() & KEY_X) 49 | { 50 | bgWindowDisable(bg3, WINDOW_OUT); 51 | bgWindowEnable(bg3, WINDOW_0); 52 | } 53 | if(keysHeld() & KEY_Y) 54 | { 55 | bgWindowDisable(bg3, WINDOW_0); 56 | bgWindowEnable(bg3, WINDOW_OUT); 57 | } 58 | 59 | if(x < 0) x = 0; 60 | if(x > SCREEN_WIDTH - 1) x = SCREEN_WIDTH - 1; 61 | if(y < 0) y = 0; 62 | if(y > SCREEN_HEIGHT - 1) y = SCREEN_HEIGHT - 1; 63 | 64 | swiWaitForVBlank(); 65 | 66 | //set up the boundaries on our window 67 | windowSetBounds(WINDOW_0, x, y, x + size, y + size); 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /Graphics/Ext_Palettes/backgrounds/gfx/devkitlogo.grit: -------------------------------------------------------------------------------- 1 | # extended palettes only work on 8bpp tiled bg with 16-bit map entries 2 | # this means you can only use BgType_Text8bpp or BgType_ExRotation 3 | -g -gt -gB8 4 | -m -mR8 5 | -p 6 | -------------------------------------------------------------------------------- /Graphics/Ext_Palettes/backgrounds/gfx/devkitlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Ext_Palettes/backgrounds/gfx/devkitlogo.png -------------------------------------------------------------------------------- /Graphics/Ext_Palettes/backgrounds/gfx/drunkenlogo.grit: -------------------------------------------------------------------------------- 1 | # extended palettes only work on 8bpp tiled bg with 16-bit map entries 2 | # this means you can only use BgType_Text8bpp or BgType_ExRotation 3 | -g -gt -gB8 4 | -m -mR8 5 | -p 6 | 7 | # let's use palette slot 12 for demonstrative purposes 8 | -mp 12 9 | -------------------------------------------------------------------------------- /Graphics/Ext_Palettes/backgrounds/gfx/drunkenlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Ext_Palettes/backgrounds/gfx/drunkenlogo.png -------------------------------------------------------------------------------- /Graphics/Ext_Palettes/backgrounds/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "devkitlogo.h" 3 | #include "drunkenlogo.h" 4 | 5 | int main(int argc, char *argv[]) { 6 | int bg[4], i, frames = 0; 7 | 8 | // initialize video 9 | videoSetMode(MODE_0_2D); 10 | videoSetModeSub(MODE_0_2D); 11 | vramSetBankA(VRAM_A_MAIN_BG); 12 | vramSetBankC(VRAM_C_SUB_BG); 13 | 14 | // enable extended palettes 15 | bgExtPaletteEnable(); 16 | bgExtPaletteEnableSub(); 17 | 18 | // initialize backgrounds 19 | // extended palettes only work on 8bpp tiled bg's with 16-bit map entries 20 | // this means you can only use BgType_Text8bpp or BgType_ExRotation 21 | // http://mtheall.com/vram.html#T0=1&NT0=192&MB0=6&TB0=0&S0=0&T1=1&NT1=576&MB1=7&TB1=1&S1=0 22 | bg[0] = bgInit (0, BgType_Text8bpp, BgSize_T_256x256, 6, 0); 23 | bg[1] = bgInit (1, BgType_Text8bpp, BgSize_T_256x256, 7, 1); 24 | // we're using identical settings on the sub screen 25 | bg[2] = bgInitSub(0, BgType_Text8bpp, BgSize_T_256x256, 6, 0); 26 | bg[3] = bgInitSub(1, BgType_Text8bpp, BgSize_T_256x256, 7, 1); 27 | 28 | // copy graphics to vram 29 | dmaCopy(devkitlogoTiles, bgGetGfxPtr(bg[0]), devkitlogoTilesLen); 30 | dmaCopy(drunkenlogoTiles, bgGetGfxPtr(bg[1]), drunkenlogoTilesLen); 31 | // same for sub engine 32 | dmaCopy(devkitlogoTiles, bgGetGfxPtr(bg[2]), devkitlogoTilesLen); 33 | dmaCopy(drunkenlogoTiles, bgGetGfxPtr(bg[3]), drunkenlogoTilesLen); 34 | 35 | // copy maps to vram 36 | dmaCopy(devkitlogoMap, bgGetMapPtr(bg[0]), devkitlogoMapLen); 37 | dmaCopy(drunkenlogoMap, bgGetMapPtr(bg[1]), drunkenlogoMapLen); 38 | // same for sub engine 39 | dmaCopy(devkitlogoMap, bgGetMapPtr(bg[2]), devkitlogoMapLen); 40 | dmaCopy(drunkenlogoMap, bgGetMapPtr(bg[3]), drunkenlogoMapLen); 41 | 42 | // you can only access extended palettes in LCD mode 43 | vramSetBankE(VRAM_E_LCD); // for main engine 44 | vramSetBankH(VRAM_H_LCD); // for sub engine 45 | 46 | // copy palettes to extended palette area 47 | // there are 16 256-color palettes per bg 48 | // use '-mp #' to make grit use # for the slot number 49 | // we used '-mp 12' for drunkenlogo for demonstrative purposes 50 | dmaCopy(devkitlogoPal, &VRAM_E_EXT_PALETTE[0][0], devkitlogoPalLen); // bg 0, slot 0 51 | dmaCopy(drunkenlogoPal, &VRAM_E_EXT_PALETTE[1][12], drunkenlogoPalLen); // bg 1, slot 12 52 | // same for sub engine 53 | dmaCopy(devkitlogoPal, &VRAM_H_EXT_PALETTE[0][0], devkitlogoPalLen); // bg 0, slot 0 54 | dmaCopy(drunkenlogoPal, &VRAM_H_EXT_PALETTE[1][12], drunkenlogoPalLen); // bg 1, slot 12 55 | 56 | // map vram banks to extended palettes 57 | // http://mtheall.com/banks.html#A=MBG0&C=MBG2&E=BGEPAL&H=SBGEPAL 58 | vramSetBankE(VRAM_E_BG_EXT_PALETTE); // for main engine 59 | vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE); // for sub engine 60 | 61 | while (pmMainLoop()) { 62 | swiWaitForVBlank(); 63 | frames++; 64 | bgUpdate(); 65 | scanKeys(); 66 | if(keysDown()&KEY_START)break; 67 | 68 | // let's make it obvious there are multiple backgrounds 69 | for(i = 0; i < 8; i++) 70 | bgSetScroll(i, frames/((i&3)+1), frames/((i&3)+1)); 71 | } 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /Graphics/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/Printing/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/Printing/ansi_console/source/main.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | demo of ansi escape sequences 4 | 5 | ---------------------------------------------------------------------------------*/ 6 | #include 7 | #include 8 | 9 | //--------------------------------------------------------------------------------- 10 | int main(void) { 11 | //--------------------------------------------------------------------------------- 12 | 13 | consoleDemoInit(); 14 | 15 | // ansi escape sequence to clear screen and home cursor 16 | // /x1b[line;columnH 17 | iprintf("\x1b[2J"); 18 | 19 | // ansi escape sequence to set print co-ordinates 20 | // /x1b[line;columnH 21 | iprintf("\x1b[10;10HHello World!"); 22 | 23 | // ansi escape sequence to move cursor up 24 | // /x1b[linesA 25 | iprintf("\x1b[10ALine 0"); 26 | 27 | // ansi escape sequence to move cursor left 28 | // /x1b[columnsD 29 | iprintf("\x1b[28DColumn 0"); 30 | 31 | // ansi escape sequence to move cursor down 32 | // /x1b[linesB 33 | iprintf("\x1b[19BLine 19"); 34 | 35 | // ansi escape sequence to move cursor right 36 | // /x1b[columnsC 37 | iprintf("\x1b[5CColumn 20"); 38 | 39 | while(pmMainLoop()) { 40 | 41 | swiWaitForVBlank(); 42 | scanKeys(); 43 | 44 | int keys = keysDown(); 45 | 46 | if(keys & KEY_START) break; 47 | 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Graphics/Printing/console_windows/source/main.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple console print demo using two consols with different windows 4 | -- dovoto 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | 10 | char *border = 11 | "------------" 12 | "| |" 13 | "| |" 14 | "| |" 15 | "| |" 16 | "| |" 17 | "| |" 18 | "| |" 19 | "| |" 20 | "| |" 21 | "| |" 22 | "| |" 23 | "| |" 24 | "| |" 25 | "| |" 26 | "------------"; 27 | 28 | //--------------------------------------------------------------------------------- 29 | int main(void) { 30 | //--------------------------------------------------------------------------------- 31 | touchPosition touch; 32 | 33 | PrintConsole *left = consoleDemoInit(); 34 | PrintConsole right = *left; 35 | 36 | consoleSetWindow(left, 15,1,12,16); 37 | consoleSetWindow(&right, 1,1,12,16); 38 | 39 | consoleSelect(left); 40 | iprintf(border); 41 | consoleSelect(&right); 42 | iprintf(border); 43 | 44 | consoleSetWindow(left, 2,2,10,14); 45 | consoleSetWindow(&right,16,2,10,14); 46 | 47 | while(pmMainLoop()) 48 | { 49 | int keys; 50 | 51 | scanKeys(); 52 | 53 | keys = keysHeld(); 54 | 55 | if(keys & KEY_START) break; 56 | 57 | if(touchRead(&touch)) 58 | { 59 | if(touch.px < 128) 60 | consoleSelect(left); 61 | else 62 | consoleSelect(&right); 63 | 64 | iprintf("\nT: %i", touch.px); 65 | } 66 | 67 | swiWaitForVBlank(); 68 | } 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /Graphics/Printing/custom_font/gfx/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Printing/custom_font/gfx/font.bmp -------------------------------------------------------------------------------- /Graphics/Printing/custom_font/gfx/font.grit: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------- 2 | # graphics in tile format 3 | #------------------------------------------------------- 4 | -gt 5 | 6 | #------------------------------------------------------- 7 | # output first 16 colors of the palette 8 | #------------------------------------------------------- 9 | -pw16 10 | 11 | #------------------------------------------------------- 12 | # no tile reduction 13 | #------------------------------------------------------- 14 | -mR! 15 | 16 | #------------------------------------------------------- 17 | # no map output 18 | #------------------------------------------------------- 19 | -m! 20 | 21 | #------------------------------------------------------- 22 | # graphics bit depth is 4 (16 color) 23 | #------------------------------------------------------- 24 | -gB4 25 | 26 | -------------------------------------------------------------------------------- /Graphics/Printing/custom_font/source/main.c: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | #include 3 | 4 | #include 5 | 6 | 7 | //Include the font header generated by grit 8 | #include "font.h" 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | 14 | const int tile_base = 0; 15 | const int map_base = 20; 16 | 17 | videoSetModeSub(MODE_0_2D); 18 | vramSetBankC(VRAM_C_SUB_BG); 19 | 20 | PrintConsole *console = consoleInit(0,0, BgType_Text4bpp, BgSize_T_256x256, map_base, tile_base, false, false); 21 | 22 | ConsoleFont font; 23 | 24 | font.gfx = (u16*)fontTiles; 25 | font.pal = (u16*)fontPal; 26 | font.numChars = 95; 27 | font.numColors = fontPalLen / 2; 28 | font.bpp = 4; 29 | font.asciiOffset = 32; 30 | font.convertSingleColor = false; 31 | 32 | consoleSetFont(console, &font); 33 | 34 | iprintf("Custom Font Demo\n"); 35 | iprintf(" by Poffy\n"); 36 | iprintf("modified by WinterMute\n"); 37 | iprintf("for libnds examples\n"); 38 | 39 | while(pmMainLoop()) { 40 | 41 | swiWaitForVBlank(); 42 | scanKeys(); 43 | 44 | int keys = keysDown(); 45 | 46 | if(keys & KEY_START) break; 47 | 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /Graphics/Printing/print_both_screens/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple console print demo which prints to both screens 4 | -- dovoto 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | touchPosition touch; 14 | 15 | PrintConsole topScreen; 16 | PrintConsole bottomScreen; 17 | 18 | videoSetMode(MODE_0_2D); 19 | videoSetModeSub(MODE_0_2D); 20 | 21 | vramSetBankA(VRAM_A_MAIN_BG); 22 | vramSetBankC(VRAM_C_SUB_BG); 23 | 24 | consoleInit(&topScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, true, true); 25 | consoleInit(&bottomScreen, 3,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true); 26 | 27 | 28 | consoleSelect(&topScreen); 29 | iprintf("\n\n\tHello DS dev'rs\n"); 30 | iprintf("\twww.drunkencoders.com\n"); 31 | iprintf("\twww.devkitpro.org"); 32 | 33 | consoleSelect(&bottomScreen); 34 | 35 | while(pmMainLoop()) { 36 | 37 | touchRead(&touch); 38 | 39 | iprintf("\x1b[10;0HTouch x = %04i, %04i\n", touch.rawx, touch.px); 40 | iprintf("Touch y = %04i, %04i\n", touch.rawy, touch.py); 41 | 42 | swiWaitForVBlank(); 43 | scanKeys(); 44 | 45 | int keys = keysDown(); 46 | 47 | if(keys & KEY_START) break; 48 | 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /Graphics/Printing/rotscale_text/gfx/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Printing/rotscale_text/gfx/font.bmp -------------------------------------------------------------------------------- /Graphics/Printing/rotscale_text/gfx/font.grit: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------- 2 | # graphics in tile format 3 | #------------------------------------------------------- 4 | -gt 5 | 6 | #------------------------------------------------------- 7 | # no tile reduction 8 | #------------------------------------------------------- 9 | -mR! 10 | 11 | #------------------------------------------------------- 12 | # no map output 13 | #------------------------------------------------------- 14 | -m! 15 | 16 | #------------------------------------------------------- 17 | # graphics bit depth is 8 (256 color) 18 | #------------------------------------------------------- 19 | -gB8 20 | 21 | -------------------------------------------------------------------------------- /Graphics/Printing/rotscale_text/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | //Include the font header generated by grit 6 | #include "font.h" 7 | 8 | //--------------------------------------------------------------------------------- 9 | int main(void) { 10 | //--------------------------------------------------------------------------------- 11 | 12 | const int tile_base = 0; 13 | const int map_base = 20; 14 | 15 | 16 | videoSetMode(0); 17 | 18 | videoSetModeSub(MODE_5_2D); 19 | vramSetBankC(VRAM_C_SUB_BG); 20 | 21 | PrintConsole *console = consoleInit(0, 3, BgType_ExRotation, BgSize_ER_256x256, map_base, tile_base, false, false); 22 | 23 | ConsoleFont font; 24 | 25 | font.gfx = (u16*)fontTiles; 26 | font.pal = (u16*)fontPal; 27 | font.numChars = 95; 28 | font.numColors = fontPalLen / 2; 29 | font.bpp = 8; 30 | font.asciiOffset = 32; 31 | font.convertSingleColor = false; 32 | 33 | consoleSetFont(console, &font); 34 | 35 | int bg3 = console->bgId; 36 | 37 | iprintf("Custom Font Demo\n"); 38 | iprintf(" by Poffy\n"); 39 | iprintf("modified by WinterMute and dovoto\n"); 40 | iprintf("for libnds examples\n"); 41 | 42 | 43 | unsigned int angle = 0; 44 | int scrollX = 0; 45 | int scrollY = 0; 46 | int scaleX = intToFixed(1,8); 47 | int scaleY = intToFixed(1,8); 48 | 49 | while(pmMainLoop()) { 50 | scanKeys(); 51 | u32 keys = keysHeld(); 52 | 53 | if ( keys & KEY_START ) break; 54 | 55 | if ( keys & KEY_L ) angle+=64; 56 | if ( keys & KEY_R ) angle-=64; 57 | 58 | if ( keys & KEY_LEFT ) scrollX++; 59 | if ( keys & KEY_RIGHT ) scrollX--; 60 | if ( keys & KEY_UP ) scrollY++; 61 | if ( keys & KEY_DOWN ) scrollY--; 62 | 63 | if ( keys & KEY_A ) scaleX++; 64 | if ( keys & KEY_B ) scaleX--; 65 | 66 | if( keys & KEY_X ) scaleY++; 67 | if( keys & KEY_Y ) scaleY--; 68 | 69 | swiWaitForVBlank(); 70 | 71 | 72 | bgSetRotateScale(bg3, angle, scaleX, scaleY); 73 | bgSetScroll(bg3, scrollX, scrollY); 74 | bgUpdate(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /Graphics/Sprites/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/Sprites/animate_simple/sprites/man.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Sprites/animate_simple/sprites/man.png -------------------------------------------------------------------------------- /Graphics/Sprites/animate_simple/sprites/sprite.grit: -------------------------------------------------------------------------------- 1 | -m! 2 | -gB8 3 | #metatile 4 | -Mh4 5 | -Mw4 6 | -------------------------------------------------------------------------------- /Graphics/Sprites/animate_simple/sprites/woman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Sprites/animate_simple/sprites/woman.png -------------------------------------------------------------------------------- /Graphics/Sprites/bitmap_sprites/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | //a simple sprite structure 6 | //it is generally preferred to separate your game object 7 | //from OAM 8 | typedef struct 9 | { 10 | u16* gfx; 11 | SpriteSize size; 12 | SpriteColorFormat format; 13 | int rotationIndex; 14 | int paletteAlpha; 15 | int x; 16 | int y; 17 | }MySprite; 18 | 19 | int main(int argc, char** argv) { 20 | 21 | //three sprites of differing color format 22 | MySprite sprites[] = { 23 | {0, SpriteSize_32x32, SpriteColorFormat_Bmp, 0, 15, 20, 15}, 24 | {0, SpriteSize_32x32, SpriteColorFormat_256Color, 0, 0, 20, 80}, 25 | {0, SpriteSize_32x32, SpriteColorFormat_16Color, 0, 1, 20, 136} 26 | }; 27 | 28 | videoSetModeSub(MODE_0_2D); 29 | 30 | consoleDemoInit(); 31 | 32 | //initialize the sub sprite engine with 1D mapping 128 byte boundary 33 | //and no external palette support 34 | oamInit(&oamSub, SpriteMapping_Bmp_1D_128, false); 35 | 36 | 37 | vramSetBankD(VRAM_D_SUB_SPRITE); 38 | 39 | //allocate some space for the sprite graphics 40 | for(int i = 0; i < 3; i++) 41 | sprites[i].gfx = oamAllocateGfx(&oamSub, sprites[i].size, sprites[i].format); 42 | 43 | //ugly positional printf 44 | iprintf("\x1b[1;1HDirect Bitmap:"); 45 | iprintf("\x1b[9;1H256 color:"); 46 | iprintf("\x1b[16;1H16 color:"); 47 | 48 | //fill bmp sprite with the color red 49 | dmaFillHalfWords(ARGB16(1,31,0,0), sprites[0].gfx, 32*32*2); 50 | //fill the 256 color sprite with index 1 (2 pixels at a time) 51 | dmaFillHalfWords((1<<8)|1, sprites[1].gfx, 32*32); 52 | //fill the 16 color sprite with index 1 (4 pixels at a time) 53 | dmaFillHalfWords((1<<12)|(1<<8)|(1<<4)|1, sprites[2].gfx, 32*32 / 2); 54 | 55 | //set index 1 to blue...this will be the 256 color sprite 56 | SPRITE_PALETTE_SUB[1] = RGB15(0,31,0); 57 | //set index 17 to green...this will be the 16 color sprite 58 | SPRITE_PALETTE_SUB[16 + 1] = RGB15(0,0,31); 59 | 60 | int angle = 0; 61 | 62 | while(pmMainLoop()) { 63 | for(int i = 0; i < 3; i++) { 64 | oamSet( 65 | &oamSub, //sub display 66 | i, //oam entry to set 67 | sprites[i].x, sprites[i].y, //position 68 | 0, //priority 69 | sprites[i].paletteAlpha, //palette for 16 color sprite or alpha for bmp sprite 70 | sprites[i].size, 71 | sprites[i].format, 72 | sprites[i].gfx, 73 | sprites[i].rotationIndex, 74 | true, //double the size of rotated sprites 75 | false, //don't hide the sprite 76 | false, false, //vflip, hflip 77 | false //apply mosaic 78 | ); 79 | } 80 | 81 | oamRotateScale(&oamSub, 0, angle, (1 << 8), (1<<8)); 82 | 83 | angle += 64; 84 | 85 | swiWaitForVBlank(); 86 | 87 | 88 | scanKeys(); 89 | 90 | int keys = keysDown(); 91 | 92 | if(keys & KEY_START) break; 93 | 94 | //send the updates to the hardware 95 | oamUpdate(&oamSub); 96 | } 97 | return 0; 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /Graphics/Sprites/fire_and_sprites/data/ball.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/Sprites/fire_and_sprites/data/ball.pcx -------------------------------------------------------------------------------- /Graphics/Sprites/simple/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple sprite demo 4 | -- dovoto 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | //--------------------------------------------------------------------------------- 13 | int main(void) { 14 | //--------------------------------------------------------------------------------- 15 | int i = 0; 16 | touchPosition touch; 17 | 18 | videoSetMode(MODE_0_2D); 19 | videoSetModeSub(MODE_0_2D); 20 | 21 | vramSetBankA(VRAM_A_MAIN_SPRITE); 22 | vramSetBankD(VRAM_D_SUB_SPRITE); 23 | 24 | oamInit(&oamMain, SpriteMapping_1D_32, false); 25 | oamInit(&oamSub, SpriteMapping_1D_32, false); 26 | 27 | u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color); 28 | u16* gfxSub = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color); 29 | 30 | for(i = 0; i < 16 * 16 / 2; i++) 31 | { 32 | gfx[i] = 1 | (1 << 8); 33 | gfxSub[i] = 1 | (1 << 8); 34 | } 35 | 36 | SPRITE_PALETTE[1] = RGB15(31,0,0); 37 | SPRITE_PALETTE_SUB[1] = RGB15(0,31,0); 38 | 39 | while(pmMainLoop()) { 40 | 41 | scanKeys(); 42 | 43 | int held = keysHeld(); 44 | 45 | if(held & KEY_TOUCH) 46 | touchRead(&touch); 47 | 48 | if(held & KEY_START) break; 49 | 50 | oamSet(&oamMain, //main graphics engine context 51 | 0, //oam index (0 to 127) 52 | touch.px, touch.py, //x and y pixle location of the sprite 53 | 0, //priority, lower renders last (on top) 54 | 0, //this is the palette index if multiple palettes or the alpha value if bmp sprite 55 | SpriteSize_16x16, 56 | SpriteColorFormat_256Color, 57 | gfx, //pointer to the loaded graphics 58 | -1, //sprite rotation data 59 | false, //double the size when rotating? 60 | false, //hide the sprite? 61 | false, false, //vflip, hflip 62 | false //apply mosaic 63 | ); 64 | 65 | 66 | oamSet(&oamSub, 67 | 0, 68 | touch.px, 69 | touch.py, 70 | 0, 71 | 0, 72 | SpriteSize_16x16, 73 | SpriteColorFormat_256Color, 74 | gfxSub, 75 | -1, 76 | false, 77 | false, 78 | false, false, 79 | false 80 | ); 81 | 82 | swiWaitForVBlank(); 83 | 84 | 85 | oamUpdate(&oamMain); 86 | oamUpdate(&oamSub); 87 | } 88 | 89 | return 0; 90 | } 91 | -------------------------------------------------------------------------------- /Graphics/Sprites/sprite_extended_palettes/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple extended palette demo. Creates two sprites on the main display 4 | using palette 0 and palette 1. 5 | 6 | -- dovoto 7 | 8 | ---------------------------------------------------------------------------------*/ 9 | #include 10 | 11 | //--------------------------------------------------------------------------------- 12 | int main(void) { 13 | //--------------------------------------------------------------------------------- 14 | 15 | int i = 0; 16 | 17 | touchPosition touch; 18 | 19 | videoSetMode(MODE_0_2D); 20 | 21 | vramSetBankA(VRAM_A_MAIN_SPRITE); 22 | 23 | oamInit(&oamMain, SpriteMapping_1D_32, true); 24 | 25 | u16* gfx1 = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color); 26 | u16* gfx2 = oamAllocateGfx(&oamMain, SpriteSize_16x16, SpriteColorFormat_256Color); 27 | 28 | //------------------------------------------------------------------ 29 | // notice both sprites are filled with color 1 30 | //------------------------------------------------------------------ 31 | for(i = 0; i < 16 * 16 / 2; i++) 32 | { 33 | gfx1[i] = 1 | (1 << 8); 34 | gfx2[i] = 1 | (1 << 8); 35 | } 36 | 37 | //------------------------------------------------------------------ 38 | // unlock vram (cannot write to vram while mapped as palette memory) 39 | //------------------------------------------------------------------ 40 | vramSetBankF(VRAM_F_LCD); 41 | 42 | VRAM_F_EXT_SPR_PALETTE[0][1] = RGB15(31,0,0); 43 | VRAM_F_EXT_SPR_PALETTE[1][1] = RGB15(0,31,0); 44 | 45 | // set vram to ex palette 46 | vramSetBankF(VRAM_F_SPRITE_EXT_PALETTE); 47 | 48 | while(pmMainLoop()) { 49 | 50 | scanKeys(); 51 | 52 | int held = keysHeld(); 53 | 54 | if(held & KEY_TOUCH) 55 | touchRead(&touch); 56 | 57 | if(held & KEY_START) break; 58 | 59 | oamSet(&oamMain, //main graphics engine context 60 | 0, //oam index (0 to 127) 61 | touch.px, touch.py, //x and y pixle location of the sprite 62 | 0, //priority, lower renders last (on top) 63 | 0, //this is the palette index if multiple palettes or the alpha value if bmp sprite 64 | SpriteSize_16x16, 65 | SpriteColorFormat_256Color, 66 | gfx1, //pointer to the loaded graphics 67 | -1, //sprite rotation data 68 | false, //double the size when rotating? 69 | false, //hide the sprite? 70 | false, false, //vflip, hflip 71 | false //apply mosaic 72 | ); 73 | 74 | 75 | oamSet(&oamMain, 76 | 1, 77 | SCREEN_WIDTH - touch.px, 78 | SCREEN_HEIGHT - touch.py, 79 | 0, 80 | 1, //use second palette 81 | SpriteSize_16x16, 82 | SpriteColorFormat_256Color, 83 | gfx2, 84 | -1, 85 | false, 86 | false, 87 | false, false, 88 | false 89 | ); 90 | 91 | swiWaitForVBlank(); 92 | 93 | oamUpdate(&oamMain); 94 | } 95 | 96 | return 0; 97 | } -------------------------------------------------------------------------------- /Graphics/Sprites/sprite_rotate/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple sprite demo 4 | -- dovoto 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | int i = 0; 14 | int angle = 0; 15 | 16 | videoSetMode(MODE_0_2D); 17 | 18 | vramSetBankA(VRAM_A_MAIN_SPRITE); 19 | 20 | oamInit(&oamMain, SpriteMapping_1D_32, false); 21 | 22 | u16* gfx = oamAllocateGfx(&oamMain, SpriteSize_32x32, SpriteColorFormat_256Color); 23 | 24 | for(i = 0; i < 32 * 32 / 2; i++) 25 | { 26 | gfx[i] = 1 | (1 << 8); 27 | } 28 | 29 | SPRITE_PALETTE[1] = RGB15(31,0,0); 30 | 31 | while(pmMainLoop()) { 32 | 33 | scanKeys(); 34 | 35 | int held = keysHeld(); 36 | 37 | if(held & KEY_START) 38 | break; 39 | if(held & KEY_LEFT) 40 | angle += degreesToAngle(2); 41 | if(held & KEY_RIGHT) 42 | angle -= degreesToAngle(2); 43 | 44 | //------------------------------------------------------------------------- 45 | // Set the first rotation/scale matrix 46 | // 47 | // There are 32 rotation/scale matricies that can store sprite rotations 48 | // Any number of sprites can share a sprite rotation matrix or each sprite 49 | // (up to 32) can utilize a seperate rotation. Because this sprite is doubled 50 | // in size we have to adjust its position by subtracting half of its height and 51 | // width (20 - 16, 20 - 16, ) 52 | //------------------------------------------------------------------------- 53 | oamRotateScale(&oamMain, 0, angle, intToFixed(1, 8), intToFixed(1, 8)); 54 | 55 | oamSet(&oamMain, //main graphics engine context 56 | 0, //oam index (0 to 127) 57 | 20 - 16, 20 - 16, //x and y pixle location of the sprite 58 | 0, //priority, lower renders last (on top) 59 | 0, //this is the palette index if multiple palettes or the alpha value if bmp sprite 60 | SpriteSize_32x32, 61 | SpriteColorFormat_256Color, 62 | gfx, //pointer to the loaded graphics 63 | 0, //sprite rotation/scale matrix index 64 | true, //double the size when rotating? 65 | false, //hide the sprite? 66 | false, false, //vflip, hflip 67 | false //apply mosaic 68 | ); 69 | 70 | //------------------------------------------------------------------------- 71 | // Because the sprite below has size double set to false it can never be larger than 72 | // 32x32 causing it to clip as it rotates. 73 | //------------------------------------------------------------------------- 74 | oamSet(&oamMain, //main graphics engine context 75 | 1, //oam index (0 to 127) 76 | 204, 20, //x and y pixle location of the sprite 77 | 0, //priority, lower renders last (on top) 78 | 0, //this is the palette index if multiple palettes or the alpha value if bmp sprite 79 | SpriteSize_32x32, 80 | SpriteColorFormat_256Color, 81 | gfx, //pointer to the loaded graphics 82 | 0, //sprite rotation/scale matrix index 83 | false, //double the size when rotating? 84 | false, //hide the sprite? 85 | false, false, //vflip, hflip 86 | false //apply mosaic 87 | ); 88 | swiWaitForVBlank(); 89 | 90 | 91 | oamUpdate(&oamMain); 92 | } 93 | 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /Graphics/capture/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i; fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean; fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install; fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/capture/ScreenShot/include/bmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _bmp_h_ 2 | #define _bmp_h_ 3 | 4 | typedef struct PACKED { 5 | u16 type; /* Magic identifier */ 6 | u8 size[4]; /* File size in bytes */ 7 | u16 reserved1, reserved2; 8 | u32 offset; /* Offset to image data, bytes */ 9 | } HEADER; 10 | 11 | static_assert(sizeof(HEADER)==14,"HEADER wrong size"); 12 | 13 | typedef struct { 14 | u32 size; /* Header size in bytes */ 15 | u32 width,height; /* Width and height of image */ 16 | u16 planes; /* Number of colour planes */ 17 | u16 bits; /* Bits per pixel */ 18 | u32 compression; /* Compression type */ 19 | u32 imagesize; /* Image size in bytes */ 20 | u32 xresolution,yresolution; /* Pixels per meter */ 21 | u32 ncolours; /* Number of colours */ 22 | u32 importantcolours; /* Important colours */ 23 | } INFOHEADER; 24 | 25 | static_assert(sizeof(INFOHEADER)==40,"INFOHEADER wrong size"); 26 | 27 | #endif //_bmp_h_ 28 | -------------------------------------------------------------------------------- /Graphics/capture/ScreenShot/include/screenshot.h: -------------------------------------------------------------------------------- 1 | void screenshot(const char* filename); 2 | void screenshotbmp(const char* filename); 3 | -------------------------------------------------------------------------------- /Graphics/capture/ScreenShot/source/screenshot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include "screenshot.h" 8 | #include "bmp.h" 9 | 10 | void wait(); 11 | 12 | void screenshot(u8* buffer) { 13 | 14 | u8 vram_cr_temp=VRAM_A_CR; 15 | VRAM_A_CR=VRAM_A_LCD; 16 | 17 | u8* vram_temp=(u8*)malloc(128*1024); 18 | dmaCopy(VRAM_A, vram_temp, 128*1024); 19 | 20 | REG_DISPCAPCNT=DCAP_BANK(0)|DCAP_ENABLE|DCAP_SIZE(3); 21 | while(REG_DISPCAPCNT & DCAP_ENABLE); 22 | 23 | dmaCopy(VRAM_A, buffer, 256*192*2); 24 | dmaCopy(vram_temp, VRAM_A, 128*1024); 25 | 26 | VRAM_A_CR=vram_cr_temp; 27 | 28 | free(vram_temp); 29 | 30 | } 31 | 32 | void screenshot(char* filename) { 33 | 34 | FILE* file=fopen(filename, "w"); 35 | if (!file) { 36 | return; 37 | } 38 | 39 | u8* temp=(u8*)malloc(256*192*2); 40 | dmaCopy(VRAM_B, temp, 256*192*2); 41 | fwrite(temp, 1, 256*192*2, file); 42 | fclose(file); 43 | free(temp); 44 | } 45 | 46 | void write16(void* address, u16 value) { 47 | 48 | u8* array=(u8*)address; 49 | 50 | array[0]=value&0xff; 51 | array[1]=value>>8; 52 | } 53 | 54 | void write32(void* address, u32 value) { 55 | 56 | u8* array=(u8*)address; 57 | 58 | array[0]=value&0xff; 59 | array[1]=(value>>8)&0xff; 60 | array[2]=(value>>16)&0xff; 61 | array[3]=(value>>24)&0xff; 62 | } 63 | 64 | void screenshotbmp(const char* filename) { 65 | 66 | FILE* file=fopen(filename, "wb"); 67 | if (!file) { 68 | return; 69 | } 70 | 71 | REG_DISPCAPCNT=DCAP_BANK(3)|DCAP_ENABLE|DCAP_SIZE(3); 72 | while(REG_DISPCAPCNT & DCAP_ENABLE); 73 | 74 | u8* temp=(u8*)malloc(256*192*3+sizeof(INFOHEADER)+sizeof(HEADER)); 75 | 76 | HEADER* header=(HEADER*)temp; 77 | INFOHEADER* infoheader=(INFOHEADER*)(temp+sizeof(HEADER)); 78 | 79 | write16(&header->type, 0x4D42); 80 | write32(&header->size, 256*192*3+sizeof(INFOHEADER)+sizeof(HEADER)); 81 | write32(&header->offset, sizeof(INFOHEADER)+sizeof(HEADER)); 82 | write16(&header->reserved1, 0); 83 | write16(&header->reserved2, 0); 84 | 85 | write16(&infoheader->bits, 24); 86 | write32(&infoheader->size, sizeof(INFOHEADER)); 87 | write32(&infoheader->compression, 0); 88 | write32(&infoheader->width, 256); 89 | write32(&infoheader->height, 192); 90 | write16(&infoheader->planes, 1); 91 | write32(&infoheader->imagesize, 256*192*3); 92 | write32(&infoheader->xresolution, 0); 93 | write32(&infoheader->yresolution, 0); 94 | write32(&infoheader->importantcolours, 0); 95 | write32(&infoheader->ncolours, 0); 96 | 97 | for(int y=0;y<192;y++) 98 | { 99 | for(int x=0;x<256;x++) 100 | { 101 | u16 color=VRAM_D[256*192-y*256+x]; 102 | 103 | u8 b=(color&31)<<3; 104 | u8 g=((color>>5)&31)<<3; 105 | u8 r=((color>>10)&31)<<3; 106 | 107 | temp[((y*256)+x)*3+sizeof(INFOHEADER)+sizeof(HEADER)]=r; 108 | temp[((y*256)+x)*3+1+sizeof(INFOHEADER)+sizeof(HEADER)]=g; 109 | temp[((y*256)+x)*3+2+sizeof(INFOHEADER)+sizeof(HEADER)]=b; 110 | } 111 | } 112 | 113 | DC_FlushAll(); 114 | fwrite(temp, 1, 256*192*3+sizeof(INFOHEADER)+sizeof(HEADER), file); 115 | fclose(file); 116 | free(temp); 117 | } 118 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/2Dplus3D.pnps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/2Dplus3D/gfx/Thumbs.db -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/enemies.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/2Dplus3D/gfx/enemies.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/enemies.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 8 (256 colors) 8 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/flyer.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 4 (16 colors) 8 | -gB4 9 | 10 | #include pal 11 | -p 12 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/flyer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/2Dplus3D/gfx/flyer.png -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/organ16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/2Dplus3D/gfx/organ16.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/organ16.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 16 8 | -gB16 -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/shuttle.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 4 (16 colors) 8 | -gB4 9 | 10 | #include pal 11 | -p 12 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/gfx/shuttle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/2Dplus3D/gfx/shuttle.png -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/readme_2Dplus2D.txt: -------------------------------------------------------------------------------- 1 | This example shows how to combine a 3D renderer with Easy GL2D DS 2 | 3 | Also shows how to use: 4 | Diferent texture formats 5 | Multiple palettes 6 | Some animation schemes. 7 | 8 | 9 | Thanks to: 10 | 11 | Adigun A. Polack for the enemies sprites and 3d Texture 12 | Cearn (Jasper Vijn) for the atan2 implementation 13 | 14 | Patater (Jaeden Amero) for the shuttle and flyer sprites 15 | 16 | 17 | Relminator (Richard Eric M. Lope) 18 | Http://Rel.Phatcode.Net 19 | November 2010 20 | 21 | 22 | Note: 23 | 24 | This demo works perfectly on a Real DS. 25 | 26 | However, if you are running this on an emulator... 27 | No$GBA - works perfectly. 28 | deSmuMe - use the soft rasterizer instead of OpenGL 29 | 30 | 31 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/source/Cvertexbuffer.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ******************************************************************************* 3 | 4 | Space Impakto DS 5 | relminator 6 | http://rel.betterwebber.com 7 | 8 | 9 | Cvertexbuffer class 10 | 11 | 12 | ******************************************************************************* 13 | ******************************************************************************/ 14 | #include 15 | #include 16 | 17 | 18 | #ifndef Cvertexbuffer__H 19 | #define Cvertexbuffer__H 20 | 21 | static const float PI = 3.141593f; 22 | static const float TWOPI = PI * 2; 23 | 24 | 25 | // .12 FP vector 26 | class Cvector3f32 27 | { 28 | public: 29 | s32 x; 30 | s32 y; 31 | s32 z; 32 | }; 33 | 34 | class Crgbf32 35 | { 36 | public: 37 | s32 r; 38 | s32 g; 39 | s32 b; 40 | }; 41 | 42 | 43 | 44 | class Ctexcoordf32 45 | { 46 | public: 47 | s32 u; 48 | s32 v; 49 | }; 50 | 51 | class Cpolygon 52 | { 53 | public: 54 | u32 v1; 55 | u32 v2; 56 | u32 v3; 57 | 58 | }; 59 | 60 | // vertex buffer object. LOL 61 | class Cvertexbuffer 62 | { 63 | public: 64 | Cvertexbuffer(); 65 | ~Cvertexbuffer(); 66 | void render(s32 text_off_u,s32 text_off_v, bool colorize); 67 | void render_lines(u8 r, u8 g, u8 b); 68 | int load_texture(u8 *texture_gfx); 69 | int i_max_poly; 70 | int i_max_vertex; 71 | int i_primitive_type; 72 | int i_texture_ID; 73 | Cvector3f32 *ips_vertex; 74 | Ctexcoordf32 *ips_texture; 75 | Crgbf32 *ips_color; 76 | Cpolygon *ps_poly; 77 | }; 78 | 79 | Cvertexbuffer *init_grid ( int rings, 80 | int bands, 81 | float width, 82 | float height, 83 | int uscale, 84 | int vscale); 85 | 86 | 87 | 88 | Cvertexbuffer *init_super_shape ( int rings, // rings 89 | int bands, // bands 90 | float radius, // radius 91 | int uscale, 92 | int vscale, 93 | float a, 94 | float b, 95 | float m, 96 | float n1, 97 | float n2, 98 | float n3); 99 | 100 | 101 | 102 | Cvertexbuffer *init_ascaris ( int rings, // rings 103 | int bands, // bands 104 | float radius, // radius of each ring from center 105 | float center_offset, // swirl offset 106 | int uscale, 107 | int vscale); 108 | 109 | 110 | #endif 111 | 112 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/source/cearn_atan.h: -------------------------------------------------------------------------------- 1 | /* 2 | coranac.com's awesome atan2 implementation 3 | very fast and very small. 4 | Kudos! 5 | 6 | */ 7 | 8 | #include 9 | 10 | 11 | #ifndef cearn_atan__H 12 | #define cearn_atan__H 13 | 14 | 15 | static int __qran_seed= 42; 16 | 17 | 18 | u32 atan2Lookup(int x, int y); 19 | u32 atan2Lerp(int x, int y); 20 | 21 | int sqran(int seed); 22 | 23 | //! Quick (and very dirty) pseudo-random number generator 24 | /*! \return random in range [0,8000h> 25 | */ 26 | inline int qran() 27 | { 28 | __qran_seed= 1664525*__qran_seed+1013904223; 29 | return (__qran_seed>>16) & 0x7FFF; 30 | } 31 | 32 | //! Ranged random number 33 | /*! \return random in range [\a min, \a max> 34 | * \note (max-min) must be lower than 8000h 35 | */ 36 | inline int qran_range(int min, int max) 37 | { 38 | return (qran()*(max-min)>>15)+min; 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /Graphics/gl2d/2Dplus3D/source/uvcoord_enemies.h: -------------------------------------------------------------------------------- 1 | /*====================================================================== 2 | 3 | enemies texture coordinates 4 | Generated by Rel Texture Packer 5 | relminator 2010 6 | 7 | ======================================================================*/ 8 | 9 | 10 | #ifndef ENEMIES__H 11 | #define ENEMIES__H 12 | 13 | 14 | #define ENEMIES_BITMAP_WIDTH 256 15 | #define ENEMIES_BITMAP_HEIGHT 256 16 | #define ENEMIES_NUM_IMAGES 100 17 | 18 | 19 | // Format: 20 | // U,V,Width,Height 21 | 22 | 23 | 24 | const unsigned int enemies_texcoords[] = { 25 | 144, 136, 20, 20, // 0 26 | 164, 136, 20, 20, // 1 27 | 184, 136, 20, 20, // 2 28 | 204, 136, 20, 20, // 3 29 | 124, 216, 20, 20, // 4 30 | 124, 236, 20, 20, // 5 31 | 64, 40, 60, 20, // 6 32 | 64, 64, 60, 20, // 7 33 | 124, 64, 60, 20, // 8 34 | 184, 64, 60, 20, // 9 35 | 228, 84, 20, 20, // 10 36 | 104, 116, 20, 20, // 11 37 | 104, 136, 20, 20, // 12 38 | 124, 156, 20, 20, // 13 39 | 124, 176, 20, 20, // 14 40 | 124, 196, 20, 20, // 15 41 | 64, 84, 40, 30, // 16 42 | 64, 114, 40, 30, // 17 43 | 64, 144, 40, 30, // 18 44 | 64, 174, 40, 30, // 19 45 | 64, 204, 40, 30, // 20 46 | 0, 224, 40, 30, // 21 47 | 124, 40, 20, 20, // 22 48 | 228, 0, 20, 20, // 23 49 | 228, 20, 20, 20, // 24 50 | 228, 40, 20, 20, // 25 51 | 40, 224, 20, 20, // 26 52 | 168, 84, 20, 20, // 27 53 | 188, 84, 20, 20, // 28 54 | 208, 84, 20, 20, // 29 55 | 154, 0, 44, 56, // 30 56 | 198, 0, 30, 56, // 31 57 | 64, 0, 90, 40, // 32 58 | 104, 156, 20, 20, // 33 59 | 104, 176, 20, 20, // 34 60 | 104, 196, 20, 20, // 35 61 | 104, 216, 20, 20, // 36 62 | 104, 236, 20, 20, // 37 63 | 124, 116, 20, 20, // 38 64 | 144, 116, 20, 20, // 39 65 | 164, 116, 20, 20, // 40 66 | 184, 116, 20, 20, // 41 67 | 204, 116, 20, 20, // 42 68 | 224, 116, 20, 20, // 43 69 | 124, 136, 20, 20, // 44 70 | 208, 172, 16, 16, // 45 71 | 224, 172, 16, 16, // 46 72 | 240, 172, 16, 16, // 47 73 | 176, 188, 16, 16, // 48 74 | 176, 204, 16, 16, // 49 75 | 176, 220, 16, 16, // 50 76 | 176, 236, 16, 16, // 51 77 | 192, 188, 16, 16, // 52 78 | 208, 188, 16, 16, // 53 79 | 48, 128, 16, 16, // 54 80 | 48, 144, 16, 16, // 55 81 | 48, 160, 16, 16, // 56 82 | 48, 176, 16, 16, // 57 83 | 48, 192, 16, 16, // 58 84 | 48, 208, 16, 16, // 59 85 | 224, 136, 16, 16, // 60 86 | 240, 136, 16, 16, // 61 87 | 144, 156, 16, 16, // 62 88 | 144, 172, 16, 16, // 63 89 | 144, 188, 16, 16, // 64 90 | 144, 204, 16, 16, // 65 91 | 144, 220, 16, 16, // 66 92 | 144, 236, 16, 16, // 67 93 | 160, 156, 16, 16, // 68 94 | 176, 156, 16, 16, // 69 95 | 192, 156, 16, 16, // 70 96 | 208, 156, 16, 16, // 71 97 | 224, 156, 16, 16, // 72 98 | 240, 156, 16, 16, // 73 99 | 160, 172, 16, 16, // 74 100 | 160, 188, 16, 16, // 75 101 | 160, 204, 16, 16, // 76 102 | 160, 220, 16, 16, // 77 103 | 160, 236, 16, 16, // 78 104 | 176, 172, 16, 16, // 79 105 | 192, 172, 16, 16, // 80 106 | 0, 0, 64, 64, // 81 107 | 0, 64, 64, 32, // 82 108 | 0, 96, 64, 32, // 83 109 | 104, 84, 32, 32, // 84 110 | 136, 84, 32, 24, // 85 111 | 64, 234, 32, 22, // 86 112 | 0, 128, 48, 32, // 87 113 | 0, 160, 48, 32, // 88 114 | 0, 192, 48, 32, // 89 115 | 224, 188, 16, 16, // 90 116 | 240, 188, 16, 16, // 91 117 | 192, 204, 16, 16, // 92 118 | 192, 220, 16, 16, // 93 119 | 192, 236, 16, 16, // 94 120 | 208, 204, 16, 16, // 95 121 | 224, 204, 16, 16, // 96 122 | 240, 204, 16, 16, // 97 123 | 208, 220, 16, 16, // 98 124 | 208, 236, 16, 16, // 99 125 | }; 126 | 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /Graphics/gl2d/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Graphics/gl2d/dual_screen/dual_screen.pnps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphics/gl2d/dual_screen/readme_dual_screen.txt: -------------------------------------------------------------------------------- 1 | This example shows how to render on both screens with Easy GL2D DS 2 | 3 | 4 | 5 | Relminator (Richard Eric M. Lope) 6 | Http://Rel.Phatcode.Net 7 | November 2010 8 | 9 | 10 | Note: 11 | 12 | This demo works perfectly on a Real DS. 13 | 14 | However, if you are running this on an emulator... 15 | No$GBA - works perfectly. 16 | deSmuMe - Lines and Pixels do not show 17 | 18 | -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/Fonts.pnps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/gfx/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/fonts/gfx/Thumbs.db -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/gfx/font_16x16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/fonts/gfx/font_16x16.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/gfx/font_16x16.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # exclude palette 8 | -p! 9 | 10 | # Set the bit depth to 8 (256 colors) 11 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/gfx/font_si.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/fonts/gfx/font_si.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/gfx/font_si.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | 8 | # Set the bit depth to 8 (256 colors) 9 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/readme_fonts.txt: -------------------------------------------------------------------------------- 1 | This example shows how to make a simple font class in Easy GL2D DS 2 | 3 | Fonts by Adigun A. Polack 4 | 5 | 6 | Relminator (Richard Eric M. Lope) 7 | Http://Rel.Phatcode.Net 8 | November 2010 9 | 10 | 11 | Note: 12 | 13 | This demo works perfectly on a Real DS. 14 | 15 | However, if you are running this on an emulator... 16 | No$GBA - works perfectly. 17 | deSmuMe - use the soft rasterizer instead of OpenGL 18 | 19 | -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/source/uvcoord_font_16x16.h: -------------------------------------------------------------------------------- 1 | /*====================================================================== 2 | 3 | font_16x16 texture coordinates 4 | Generated by Rel Texture Packer 5 | relminator 2010 6 | 7 | ======================================================================*/ 8 | 9 | 10 | #ifndef FONT_16X16__H 11 | #define FONT_16X16__H 12 | 13 | 14 | #define FONT_16X16_BITMAP_WIDTH 64 15 | #define FONT_16X16_BITMAP_HEIGHT 512 16 | #define FONT_16X16_NUM_IMAGES 96 17 | 18 | 19 | // Format: 20 | // U,V,Width,Height 21 | 22 | 23 | 24 | extern const unsigned int font_16x16_texcoords[] = { 25 | 0, 0, 16, 16, // 0 26 | 16, 0, 16, 16, // 1 27 | 32, 0, 16, 16, // 2 28 | 48, 0, 16, 16, // 3 29 | 0, 16, 16, 16, // 4 30 | 16, 16, 16, 16, // 5 31 | 32, 16, 16, 16, // 6 32 | 48, 16, 16, 16, // 7 33 | 0, 32, 16, 16, // 8 34 | 16, 32, 16, 16, // 9 35 | 32, 32, 16, 16, // 10 36 | 48, 32, 16, 16, // 11 37 | 0, 48, 16, 16, // 12 38 | 16, 48, 16, 16, // 13 39 | 32, 48, 16, 16, // 14 40 | 48, 48, 16, 16, // 15 41 | 0, 64, 16, 16, // 16 42 | 16, 64, 16, 16, // 17 43 | 32, 64, 16, 16, // 18 44 | 48, 64, 16, 16, // 19 45 | 0, 80, 16, 16, // 20 46 | 16, 80, 16, 16, // 21 47 | 32, 80, 16, 16, // 22 48 | 48, 80, 16, 16, // 23 49 | 0, 96, 16, 16, // 24 50 | 16, 96, 16, 16, // 25 51 | 32, 96, 16, 16, // 26 52 | 48, 96, 16, 16, // 27 53 | 0, 112, 16, 16, // 28 54 | 16, 112, 16, 16, // 29 55 | 32, 112, 16, 16, // 30 56 | 48, 112, 16, 16, // 31 57 | 0, 128, 16, 16, // 32 58 | 16, 128, 16, 16, // 33 59 | 32, 128, 16, 16, // 34 60 | 48, 128, 16, 16, // 35 61 | 0, 144, 16, 16, // 36 62 | 16, 144, 16, 16, // 37 63 | 32, 144, 16, 16, // 38 64 | 48, 144, 16, 16, // 39 65 | 0, 160, 16, 16, // 40 66 | 16, 160, 16, 16, // 41 67 | 32, 160, 16, 16, // 42 68 | 48, 160, 16, 16, // 43 69 | 0, 176, 16, 16, // 44 70 | 16, 176, 16, 16, // 45 71 | 32, 176, 16, 16, // 46 72 | 48, 176, 16, 16, // 47 73 | 0, 192, 16, 16, // 48 74 | 16, 192, 16, 16, // 49 75 | 32, 192, 16, 16, // 50 76 | 48, 192, 16, 16, // 51 77 | 0, 208, 16, 16, // 52 78 | 16, 208, 16, 16, // 53 79 | 32, 208, 16, 16, // 54 80 | 48, 208, 16, 16, // 55 81 | 0, 224, 16, 16, // 56 82 | 16, 224, 16, 16, // 57 83 | 32, 224, 16, 16, // 58 84 | 48, 224, 16, 16, // 59 85 | 0, 240, 16, 16, // 60 86 | 16, 240, 16, 16, // 61 87 | 32, 240, 16, 16, // 62 88 | 48, 240, 16, 16, // 63 89 | 0, 256, 16, 16, // 64 90 | 16, 256, 16, 16, // 65 91 | 32, 256, 16, 16, // 66 92 | 48, 256, 16, 16, // 67 93 | 0, 272, 16, 16, // 68 94 | 16, 272, 16, 16, // 69 95 | 32, 272, 16, 16, // 70 96 | 48, 272, 16, 16, // 71 97 | 0, 288, 16, 16, // 72 98 | 16, 288, 16, 16, // 73 99 | 32, 288, 16, 16, // 74 100 | 48, 288, 16, 16, // 75 101 | 0, 304, 16, 16, // 76 102 | 16, 304, 16, 16, // 77 103 | 32, 304, 16, 16, // 78 104 | 48, 304, 16, 16, // 79 105 | 0, 320, 16, 16, // 80 106 | 16, 320, 16, 16, // 81 107 | 32, 320, 16, 16, // 82 108 | 48, 320, 16, 16, // 83 109 | 0, 336, 16, 16, // 84 110 | 16, 336, 16, 16, // 85 111 | 32, 336, 16, 16, // 86 112 | 48, 336, 16, 16, // 87 113 | 0, 352, 16, 16, // 88 114 | 16, 352, 16, 16, // 89 115 | 32, 352, 16, 16, // 90 116 | 48, 352, 16, 16, // 91 117 | 0, 368, 16, 16, // 92 118 | 16, 368, 16, 16, // 93 119 | 32, 368, 16, 16, // 94 120 | 48, 368, 16, 16, // 95 121 | }; 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /Graphics/gl2d/fonts/source/uvcoord_font_si.h: -------------------------------------------------------------------------------- 1 | /*====================================================================== 2 | 3 | font_si texture coordinates 4 | Generated by Rel Texture Packer 5 | relminator 2010 6 | 7 | ======================================================================*/ 8 | 9 | 10 | #ifndef FONT_SI__H 11 | #define FONT_SI__H 12 | 13 | 14 | #define FONT_SI_BITMAP_WIDTH 64 15 | #define FONT_SI_BITMAP_HEIGHT 128 16 | #define FONT_SI_NUM_IMAGES 96 17 | 18 | 19 | // Format: 20 | // U,V,Width,Height 21 | 22 | 23 | 24 | extern const unsigned int font_si_texcoords[] = { 25 | 0, 0, 8, 9, // 0 26 | 8, 0, 8, 9, // 1 27 | 16, 0, 8, 9, // 2 28 | 24, 0, 8, 9, // 3 29 | 32, 0, 8, 9, // 4 30 | 40, 0, 8, 9, // 5 31 | 48, 0, 8, 9, // 6 32 | 56, 0, 8, 9, // 7 33 | 0, 9, 8, 9, // 8 34 | 8, 9, 8, 9, // 9 35 | 16, 9, 8, 9, // 10 36 | 24, 9, 8, 9, // 11 37 | 24, 117, 4, 9, // 12 38 | 32, 9, 8, 9, // 13 39 | 40, 9, 8, 9, // 14 40 | 48, 9, 8, 9, // 15 41 | 56, 9, 8, 9, // 16 42 | 0, 18, 8, 9, // 17 43 | 8, 18, 8, 9, // 18 44 | 16, 18, 8, 9, // 19 45 | 24, 18, 8, 9, // 20 46 | 32, 18, 8, 9, // 21 47 | 40, 18, 8, 9, // 22 48 | 48, 18, 8, 9, // 23 49 | 56, 18, 8, 9, // 24 50 | 0, 27, 8, 9, // 25 51 | 8, 27, 8, 9, // 26 52 | 16, 27, 8, 9, // 27 53 | 24, 27, 8, 9, // 28 54 | 32, 27, 8, 9, // 29 55 | 40, 27, 8, 9, // 30 56 | 48, 27, 8, 9, // 31 57 | 56, 27, 8, 9, // 32 58 | 0, 36, 8, 9, // 33 59 | 8, 36, 8, 9, // 34 60 | 16, 36, 8, 9, // 35 61 | 24, 36, 8, 9, // 36 62 | 32, 36, 8, 9, // 37 63 | 40, 36, 8, 9, // 38 64 | 48, 36, 8, 9, // 39 65 | 56, 36, 8, 9, // 40 66 | 0, 45, 8, 9, // 41 67 | 8, 45, 8, 9, // 42 68 | 16, 45, 8, 9, // 43 69 | 24, 45, 8, 9, // 44 70 | 32, 45, 8, 9, // 45 71 | 40, 45, 8, 9, // 46 72 | 48, 45, 8, 9, // 47 73 | 56, 45, 8, 9, // 48 74 | 0, 54, 8, 9, // 49 75 | 8, 54, 8, 9, // 50 76 | 16, 54, 8, 9, // 51 77 | 24, 54, 8, 9, // 52 78 | 32, 54, 8, 9, // 53 79 | 40, 54, 8, 9, // 54 80 | 48, 54, 8, 9, // 55 81 | 56, 54, 8, 9, // 56 82 | 0, 63, 8, 9, // 57 83 | 8, 63, 8, 9, // 58 84 | 16, 63, 8, 9, // 59 85 | 24, 63, 8, 9, // 60 86 | 32, 63, 8, 9, // 61 87 | 40, 63, 8, 9, // 62 88 | 48, 63, 8, 9, // 63 89 | 56, 63, 8, 9, // 64 90 | 0, 72, 8, 9, // 65 91 | 0, 81, 8, 9, // 66 92 | 0, 90, 8, 9, // 67 93 | 0, 99, 8, 9, // 68 94 | 0, 108, 8, 9, // 69 95 | 0, 117, 8, 9, // 70 96 | 8, 72, 8, 9, // 71 97 | 8, 81, 8, 9, // 72 98 | 8, 90, 8, 9, // 73 99 | 8, 99, 8, 9, // 74 100 | 8, 108, 8, 9, // 75 101 | 8, 117, 8, 9, // 76 102 | 16, 72, 8, 9, // 77 103 | 24, 72, 8, 9, // 78 104 | 32, 72, 8, 9, // 79 105 | 40, 72, 8, 9, // 80 106 | 48, 72, 8, 9, // 81 107 | 56, 72, 8, 9, // 82 108 | 16, 81, 8, 9, // 83 109 | 16, 90, 8, 9, // 84 110 | 16, 99, 8, 9, // 85 111 | 16, 108, 8, 9, // 86 112 | 16, 117, 8, 9, // 87 113 | 24, 81, 8, 9, // 88 114 | 32, 81, 8, 9, // 89 115 | 40, 81, 8, 9, // 90 116 | 48, 81, 8, 9, // 91 117 | 56, 81, 8, 9, // 92 118 | 24, 90, 8, 9, // 93 119 | 24, 99, 8, 9, // 94 120 | 24, 108, 8, 9, // 95 121 | }; 122 | 123 | 124 | #endif 125 | -------------------------------------------------------------------------------- /Graphics/gl2d/primitives/primitives.pnps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphics/gl2d/primitives/readme_primitives.txt: -------------------------------------------------------------------------------- 1 | This example shows that simple primitives can be nice to look at using Easy GL2D DS 2 | 3 | 4 | Relminator (Richard Eric M. Lope) 5 | Http://Rel.Phatcode.Net 6 | November 2010 7 | 8 | 9 | Note: 10 | 11 | This demo works perfectly on a Real DS. 12 | 13 | However, if you are running this on an emulator... 14 | No$GBA - works perfectly. 15 | deSmuMe - pixels and lines are not rendered. 16 | 17 | 18 | -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/gfx/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/scrolling/gfx/Thumbs.db -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/gfx/crono.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/scrolling/gfx/crono.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/gfx/crono.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 8 (256 colors) 8 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/gfx/tiles.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/scrolling/gfx/tiles.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/gfx/tiles.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | 8 | # Set the bit depth to 8 (256 colors) 9 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/readme_scrolling.txt: -------------------------------------------------------------------------------- 1 | This example shows how to do a scrolling engine with Easy GL2D DS 2 | 3 | Also shows how to manage character animation. 4 | 5 | Tiles by Unknown 6 | 7 | Crono sprite by Square Enix 8 | 9 | 10 | 11 | 12 | Relminator (Richard Eric M. Lope) 13 | Http://Rel.Phatcode.Net 14 | November 2010 15 | 16 | 17 | Note: 18 | 19 | This demo works perfectly on a Real DS. 20 | 21 | However, if you are running this on an emulator... 22 | No$GBA - works perfectly. 23 | deSmuMe - use the soft rasterizer instead of OpenGL 24 | 25 | -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/scrolling.pnps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphics/gl2d/scrolling/source/uvcoord_crono.h: -------------------------------------------------------------------------------- 1 | /*====================================================================== 2 | 3 | crono coordinates 4 | Generated by Rel Texture Packer 5 | relminator 2010 6 | 7 | ======================================================================*/ 8 | 9 | 10 | #ifndef CRONO__H 11 | #define CRONO__H 12 | 13 | 14 | #define CRONO_BITMAP_WIDTH 256 15 | #define CRONO_BITMAP_HEIGHT 128 16 | #define CRONO_NUM_IMAGES 28 17 | 18 | 19 | // Format: 20 | // U,V,Width,Height 21 | 22 | 23 | 24 | const unsigned int crono_texcoords[] = { 25 | 152, 40, 24, 40, // 0 26 | 152, 80, 24, 40, // 1 27 | 0, 80, 24, 40, // 2 28 | 32, 0, 24, 40, // 3 29 | 32, 40, 24, 40, // 4 30 | 32, 80, 24, 40, // 5 31 | 56, 0, 24, 40, // 6 32 | 56, 40, 24, 40, // 7 33 | 56, 80, 24, 40, // 8 34 | 80, 0, 24, 40, // 9 35 | 80, 40, 24, 40, // 10 36 | 80, 80, 24, 40, // 11 37 | 104, 0, 24, 40, // 12 38 | 104, 40, 24, 40, // 13 39 | 104, 80, 24, 40, // 14 40 | 128, 0, 24, 40, // 15 41 | 128, 40, 24, 40, // 16 42 | 128, 80, 24, 40, // 17 43 | 152, 0, 24, 40, // 18 44 | 176, 0, 24, 40, // 19 45 | 200, 0, 24, 40, // 20 46 | 224, 0, 24, 40, // 21 47 | 0, 0, 32, 40, // 22 48 | 0, 40, 32, 40, // 23 49 | 176, 40, 24, 40, // 24 50 | 176, 80, 24, 40, // 25 51 | 200, 40, 24, 40, // 26 52 | 224, 40, 24, 40, // 27 53 | }; 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/Thumbs.db -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/anya.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | 5 | #bitmap mode 6 | -gb 7 | 8 | 9 | # Set the bit depth to 16bit 10 | -gB16 -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/anya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/anya.png -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/blob_sprite.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/blob_sprite.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/blob_sprite.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 4 (16 colors) 8 | -gB4 9 | 10 | #include pal 11 | -p 12 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/enemies.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/enemies.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/enemies.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 8 (256 colors) 8 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/flyer.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 4 (16 colors) 8 | -gB4 9 | 10 | #include pal 11 | -p 12 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/flyer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/flyer.png -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/font.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/font.grit: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------- 2 | # graphics in tile format 3 | #------------------------------------------------------- 4 | -gt 5 | 6 | #------------------------------------------------------- 7 | # no tile reduction 8 | #------------------------------------------------------- 9 | -mR! 10 | 11 | #------------------------------------------------------- 12 | # no map output 13 | #------------------------------------------------------- 14 | -m! 15 | 16 | #------------------------------------------------------- 17 | # graphics bit depth is 8 (256 color) 18 | #------------------------------------------------------- 19 | -gB4 20 | 21 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/fontbubble.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/fontbubble.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/fontbubble.grit: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------- 2 | # graphics in tile format 3 | #------------------------------------------------------- 4 | -gt 5 | 6 | #------------------------------------------------------- 7 | # no tile reduction 8 | #------------------------------------------------------- 9 | -mR! 10 | 11 | #------------------------------------------------------- 12 | # no map output 13 | #------------------------------------------------------- 14 | -m! 15 | 16 | #------------------------------------------------------- 17 | # graphics bit depth is 8 (256 color) 18 | #------------------------------------------------------- 19 | -gB4 20 | 21 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/shuttle.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 4 (16 colors) 8 | -gB4 9 | 10 | #include pal 11 | -p 12 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/shuttle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/shuttle.png -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/test_sprite.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/test_sprite.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/test_sprite.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | # Set the bit depth to 8 (256 colors) 8 | -gB8 9 | 10 | #include pal 11 | #-p 12 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/tiles.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/tiles.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/tiles.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | 8 | # Set the bit depth to 8 (256 colors) 9 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/zero.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/gl2d/sprites/gfx/zero.bmp -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/gfx/zero.grit: -------------------------------------------------------------------------------- 1 | # Set the warning/log level to 3 2 | -W3 3 | 4 | #bitmap mode 5 | -gb 6 | 7 | #exclude palette (no need since enemies.bmp and zero.bmp share the same palette) 8 | -p! 9 | 10 | # Set the bit depth to 8 (256 colors) 11 | -gB8 -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/readme_sprites.txt: -------------------------------------------------------------------------------- 1 | This example shows some sprite capabilities of Easy GL2D DS 2 | 3 | Also shows how to manage character animation. 4 | 5 | Enemies sprites by Adigun A. Polack 6 | Tiles by Unknown 7 | 8 | Zero sprite by Capcom 9 | Shuttle 10 | sprite by Patater 11 | Anya Image by Anya Therese B. Lope 12 | Fonts my Marc Russel and Libnds 13 | 14 | 15 | Relminator (Richard Eric M. Lope) 16 | Http://Rel.Phatcode.Net 17 | November 2010 18 | 19 | 20 | Note: 21 | 22 | This demo works perfectly on a Real DS. 23 | 24 | However, if you are running this on an emulator... 25 | No$GBA - works perfectly. 26 | deSmuMe - use the soft rasterizer instead of OpenGL 27 | 28 | 29 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/source/cearn_atan.h: -------------------------------------------------------------------------------- 1 | /* 2 | coranac.com's awesome atan2 implementation 3 | very fast and very small. 4 | Kudos! 5 | 6 | */ 7 | 8 | #include 9 | 10 | 11 | #ifndef cearn_atan__H 12 | #define cearn_atan__H 13 | 14 | 15 | static int __qran_seed= 42; 16 | 17 | 18 | u32 atan2Lookup(int x, int y); 19 | u32 atan2Lerp(int x, int y); 20 | 21 | int sqran(int seed); 22 | 23 | //! Quick (and very dirty) pseudo-random number generator 24 | /*! \return random in range [0,8000h> 25 | */ 26 | inline int qran() 27 | { 28 | __qran_seed= 1664525*__qran_seed+1013904223; 29 | return (__qran_seed>>16) & 0x7FFF; 30 | } 31 | 32 | //! Ranged random number 33 | /*! \return random in range [\a min, \a max> 34 | * \note (max-min) must be lower than 8000h 35 | */ 36 | inline int qran_range(int min, int max) 37 | { 38 | return (qran()*(max-min)>>15)+min; 39 | } 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/source/uvcoord_zero.h: -------------------------------------------------------------------------------- 1 | /*====================================================================== 2 | 3 | zero coordinates 4 | Generated by Rel Texture Packer 5 | relminator 2010 6 | 7 | ======================================================================*/ 8 | 9 | 10 | #ifndef ZERO__H 11 | #define ZERO__H 12 | 13 | 14 | #define ZERO_BITMAP_WIDTH 128 15 | #define ZERO_BITMAP_HEIGHT 256 16 | #define ZERO_NUM_IMAGES 10 17 | 18 | 19 | // Format: 20 | // U,V,Width,Height 21 | 22 | 23 | 24 | const unsigned int zero_texcoords[] = { 25 | 0, 0, 52, 46, // 0 26 | 52, 0, 52, 46, // 1 27 | 0, 46, 52, 46, // 2 28 | 52, 46, 52, 46, // 3 29 | 0, 92, 52, 46, // 4 30 | 52, 92, 52, 46, // 5 31 | 0, 138, 52, 46, // 6 32 | 0, 184, 52, 46, // 7 33 | 52, 138, 52, 46, // 8 34 | 52, 184, 52, 46, // 9 35 | }; 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Graphics/gl2d/sprites/sprites.pnps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphics/grit/256colorTilemap/gfx/tilemap.grit: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------- 2 | # graphics in tile format 3 | #------------------------------------------------------- 4 | -gt 5 | 6 | #------------------------------------------------------- 7 | # tile reduction by tiles, palette and hflip/vflip 8 | #------------------------------------------------------- 9 | -mRtf 10 | 11 | #------------------------------------------------------- 12 | # graphics bit depth is 8 (256 color) 13 | #------------------------------------------------------- 14 | -gB8 15 | 16 | -p 17 | 18 | #------------------------------------------------------- 19 | # map layout standard bg format 20 | #------------------------------------------------------- 21 | -mLs -------------------------------------------------------------------------------- /Graphics/grit/256colorTilemap/gfx/tilemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/Graphics/grit/256colorTilemap/gfx/tilemap.png -------------------------------------------------------------------------------- /Graphics/grit/256colorTilemap/source/main.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple tilemap demo 4 | -- WinterMute 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | 9 | #include "tilemap.h" 10 | 11 | //--------------------------------------------------------------------------------- 12 | int main(void) { 13 | //--------------------------------------------------------------------------------- 14 | 15 | // enable the main screen with background 0 active 16 | videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE); 17 | 18 | // map bank A for use with the background 19 | vramSetBankA(VRAM_A_MAIN_BG); 20 | 21 | // enable background 0 in 256 color mode with a 256x256 map 22 | // BG_TILE_BASE changes the offset where tile data is stored 23 | // BG_MAP_BASE gives the offset to the map data 24 | BGCTRL[0] = BG_TILE_BASE(1) | BG_MAP_BASE(0) | BG_COLOR_256 | BG_32x32; 25 | 26 | // use dma to copy the tile, map and palette data to VRAM 27 | // CHAR_BASE_BLOCK gives us the actual address of the tile data 28 | // SCREEN_BASE_BLOCK does the same thing for maps 29 | // these should match the BG_TILE_BASE and BG_MAP base numbers above 30 | dmaCopy(tilemapTiles,(void *)CHAR_BASE_BLOCK(1),tilemapTilesLen); 31 | dmaCopy(tilemapMap,(void *)SCREEN_BASE_BLOCK(0),tilemapMapLen); 32 | dmaCopy(tilemapPal,BG_PALETTE,tilemapPalLen); 33 | // finally, hang around in an infinite loop 34 | // using swiWaitForVBlank here puts the DS into a low power loop 35 | while(pmMainLoop()) { 36 | swiWaitForVBlank(); 37 | scanKeys(); 38 | int pressed = keysDown(); 39 | if(pressed & KEY_START) break; 40 | } 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /Graphics/grit/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= $(shell ls | egrep -v '^(CVS)$$') 2 | 3 | DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d) 4 | 5 | #--------------------------------------------------------------------------------- 6 | all: examples 7 | #--------------------------------------------------------------------------------- 8 | @rm -fr bin 9 | @mkdir -p bin 10 | @find . -path ./bin -prune -o -name "*.nds" -exec cp -fv {} bin \; 11 | 12 | examples: 13 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 14 | 15 | #--------------------------------------------------------------------------------- 16 | clean: 17 | #--------------------------------------------------------------------------------- 18 | @rm -fr bin 19 | @rm -f *.bz2 20 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 21 | 22 | #--------------------------------------------------------------------------------- 23 | dist: clean 24 | #--------------------------------------------------------------------------------- 25 | @rm -fr bin 26 | @tar --exclude=.svn --exclude=*CVS* -cvjf nds-examples-$(DATESTRING).tar.bz2 * 27 | -------------------------------------------------------------------------------- /audio/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /audio/maxmod/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /audio/maxmod/audio_modes/audio/keyg-subtonal.xm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/audio_modes/audio/keyg-subtonal.xm -------------------------------------------------------------------------------- /audio/maxmod/audio_modes/audio/purple_motion-inspiration.s3m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/audio_modes/audio/purple_motion-inspiration.s3m -------------------------------------------------------------------------------- /audio/maxmod/audio_modes/audio/rez-monday.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/audio_modes/audio/rez-monday.mod -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/maxmod_data/Ambulance.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/basic_sound/maxmod_data/Ambulance.wav -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/maxmod_data/Boom.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/basic_sound/maxmod_data/Boom.wav -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/maxmod_data/FlatOutLies.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/basic_sound/maxmod_data/FlatOutLies.mod -------------------------------------------------------------------------------- /audio/maxmod/basic_sound/source/MaxModExample.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "soundbank.h" 6 | #include "soundbank_bin.h" 7 | 8 | int main() { 9 | 10 | consoleDemoInit(); 11 | 12 | mmInitDefaultMem((mm_addr)soundbank_bin); 13 | 14 | // load the module 15 | mmLoad( MOD_FLATOUTLIES ); 16 | 17 | // load sound effects 18 | mmLoadEffect( SFX_AMBULANCE ); 19 | mmLoadEffect( SFX_BOOM ); 20 | 21 | // Start playing module 22 | mmStart( MOD_FLATOUTLIES, MM_PLAY_LOOP ); 23 | 24 | mm_sound_effect ambulance = { 25 | { SFX_AMBULANCE } , // id 26 | (int)(1.0f * (1<<10)), // rate 27 | 0, // handle 28 | 255, // volume 29 | 0, // panning 30 | }; 31 | 32 | mm_sound_effect boom = { 33 | { SFX_BOOM } , // id 34 | (int)(1.0f * (1<<10)), // rate 35 | 0, // handle 36 | 255, // volume 37 | 255, // panning 38 | }; 39 | 40 | // ansi escape sequence to clear screen and home cursor 41 | // /x1b[line;columnH 42 | iprintf("\x1b[2J"); 43 | 44 | // ansi escape sequence to set print co-ordinates 45 | // /x1b[line;columnH 46 | iprintf("\x1b[0;8HMaxMod Audio demo"); 47 | iprintf("\x1b[3;0HHold A for ambulance sound"); 48 | iprintf("\x1b[4;0HPress B for boom sound"); 49 | 50 | // sound effect handle (for cancelling it later) 51 | mm_sfxhand amb = 0; 52 | 53 | while (pmMainLoop()) { 54 | 55 | int keys_pressed, keys_released; 56 | 57 | swiWaitForVBlank(); 58 | scanKeys(); 59 | 60 | keys_pressed = keysDown(); 61 | keys_released = keysUp(); 62 | 63 | // Play looping ambulance sound effect out of left speaker if A button is pressed 64 | if ( keys_pressed & KEY_A ) { 65 | amb = mmEffectEx(&ambulance); 66 | } 67 | 68 | // stop ambulance sound when A button is released 69 | if ( keys_released & KEY_A ) { 70 | mmEffectCancel(amb); 71 | } 72 | 73 | // Play explosion sound effect out of right speaker if B button is pressed 74 | if ( keys_pressed & KEY_B ) { 75 | mmEffectEx(&boom); 76 | } 77 | if( keys_pressed & KEY_START) break; 78 | 79 | } 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /audio/maxmod/reverb/audio/tempest-zen_bowling.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/reverb/audio/tempest-zen_bowling.mod -------------------------------------------------------------------------------- /audio/maxmod/song_events_example/gfx/ball.grit: -------------------------------------------------------------------------------- 1 | #default options work for sprites -------------------------------------------------------------------------------- /audio/maxmod/song_events_example/gfx/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/song_events_example/gfx/ball.png -------------------------------------------------------------------------------- /audio/maxmod/song_events_example/music/example.it: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/song_events_example/music/example.it -------------------------------------------------------------------------------- /audio/maxmod/song_events_example2/music/example2.it: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/audio/maxmod/song_events_example2/music/example2.it -------------------------------------------------------------------------------- /audio/micrecord/source/micrecord.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //the record sample rate 5 | #define sample_rate 8000 6 | 7 | //buffer to hold sound data for playback 8 | u16* sound_buffer = 0; 9 | 10 | //buffer which is written to by the arm7 11 | u16* mic_buffer = 0; 12 | 13 | //the length of the current data 14 | u32 data_length = 0; 15 | 16 | //enough hold 5 seconds of 16bit audio 17 | u32 sound_buffer_size = sample_rate * 2 * 5; 18 | 19 | //the mic buffer sent to the arm7 is a double buffer 20 | //every time it is half full the arm7 signals us so we can read the 21 | //data. I want the buffer to swap about once per frame so i chose a 22 | //buffer size large enough to hold two frames of 16bit mic data 23 | u32 mic_buffer_size = sample_rate * 2 / 30; 24 | 25 | 26 | //mic stream handler 27 | void micHandler(void* data, int length) 28 | { 29 | if(!sound_buffer || data_length > sound_buffer_size) return; 30 | 31 | 32 | DC_InvalidateRange(data, length); 33 | 34 | dmaCopy(data, ((u8*)sound_buffer) + data_length, length); 35 | 36 | data_length += length; 37 | 38 | iprintf("."); 39 | 40 | } 41 | 42 | void record(void) 43 | { 44 | data_length = 0; 45 | soundMicRecord(mic_buffer, mic_buffer_size, MicFormat_12Bit, sample_rate, micHandler); 46 | } 47 | 48 | void play(void) 49 | { 50 | soundMicOff(); 51 | soundEnable(); 52 | iprintf("data length: %li\n", data_length); 53 | soundPlaySample(sound_buffer, SoundFormat_16Bit, data_length, sample_rate, 127, 64, false, 0); 54 | } 55 | 56 | int main(void) 57 | { 58 | int key; 59 | bool recording = false; 60 | 61 | sound_buffer = (u16*)malloc(sound_buffer_size); 62 | mic_buffer = (u16*)malloc(mic_buffer_size); 63 | 64 | consoleDemoInit(); 65 | 66 | iprintf("Press A to record / play\n"); 67 | 68 | while(pmMainLoop()) 69 | { 70 | 71 | scanKeys(); 72 | key = keysDown(); 73 | 74 | if(key & KEY_A) 75 | { 76 | recording ? play() : record(); 77 | recording = !recording; 78 | iprintf("%s\n", recording ? "recording" : "playing"); 79 | } 80 | 81 | if(key & KEY_START) break; 82 | 83 | swiWaitForVBlank(); 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /card/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /card/eeprom/source/main.cpp: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple eeprom example 4 | -- davr 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | //--------------------------------------------------------------------------------- 13 | void ButtonWait() { 14 | //--------------------------------------------------------------------------------- 15 | iprintf("Press a key, start to exit...\n"); 16 | while(1) { 17 | scanKeys(); 18 | int buttons = keysDown(); 19 | if (!pmMainLoop() || (buttons & KEY_START)) { 20 | ntrcardClose(); 21 | exit(0); 22 | } 23 | if(buttons) break; 24 | swiWaitForVBlank(); 25 | } 26 | 27 | scanKeys(); 28 | } 29 | 30 | //--------------------------------------------------------------------------------- 31 | int main(void) { 32 | //--------------------------------------------------------------------------------- 33 | 34 | consoleDemoInit(); 35 | 36 | static u8 header1[512]; 37 | static u8 header2[512]; 38 | 39 | // Try to obtain ARM9 access to the cart 40 | if (!ntrcardOpen()) { 41 | iprintf("Cannot open Slot-1\n"); 42 | ButtonWait(); 43 | return 0; 44 | } 45 | 46 | iprintf("Reading cart info...\n"); 47 | 48 | while(1) { 49 | // Read the header twice to verify. 50 | // If the card is being encrypted, we will get random junk 51 | cardReadHeader(header1); 52 | cardReadHeader(header2); 53 | 54 | // Make sure we got the same data twice 55 | while(memcmp(header1, header2, 32) != 0) { 56 | // If not, the card needs ejected and reinserted into the DS 57 | iprintf("Please eject & reinsert DS card.\n"); 58 | ButtonWait(); 59 | cardReadHeader(header1); 60 | cardReadHeader(header2); 61 | } 62 | 63 | // Add a null char right after the game title, so we can print it 64 | header1[32] = '\0'; 65 | 66 | // Read some various info about the EEPROM 67 | int type = cardEepromGetType(); 68 | int size = cardEepromGetSize(); 69 | 70 | iprintf("Game ID: %s\n", header1); 71 | iprintf("EEPROM:\n"); 72 | iprintf(" Type: %d\n", type); 73 | iprintf(" Size: %d\n", size); 74 | ButtonWait(); 75 | 76 | // Read the first 512 bytes of EEPROM 77 | static u8 data[512]; 78 | cardReadEeprom(0, data, 512, type); 79 | 80 | iprintf("First 160 bytes of EEPROM: \n"); 81 | 82 | // Print 20 rows of 8 bytes each 83 | for(int y=0; y<20; y++) { 84 | 85 | // print 8 bytes as hex 86 | for(int x=0; x<8; x++) { 87 | iprintf("%02x ", data[y*8 + x]); 88 | } 89 | 90 | // print 8 bytes as characters 91 | for(int x=0; x<8; x++) { 92 | u8 c = data[y*8 + x]; 93 | if(isprint(c)) // only display if it's a printable character 94 | iprintf("%c", c); 95 | else 96 | iprintf("."); 97 | } 98 | } 99 | 100 | iprintf("Insert a new card to read again\n"); 101 | ButtonWait(); 102 | } 103 | 104 | return 0; 105 | } 106 | -------------------------------------------------------------------------------- /debugging/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /debugging/exceptionTest/source/exceptionTest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /*--------------------------------------------------------------------------------- 4 | 5 | The default exception handler displays the exception type - data abort or undefined 6 | instruction you can relate the exception to your code using 7 | 8 | arm-none-eabi-addr2line -e
9 | 10 | assuming you built with debug info this will display a source file and a line number 11 | The address of the instruction is shown as pc, beside the address which faulted 12 | the rest of the screen is a dump of the registers. 13 | 14 | ---------------------------------------------------------------------------------*/ 15 | 16 | //--------------------------------------------------------------------------------- 17 | int main(void) { 18 | //--------------------------------------------------------------------------------- 19 | 20 | // install the default exception handler 21 | defaultExceptionHandler(); 22 | 23 | // generate an exception 24 | *(u32*)8192 = 100; 25 | 26 | while(pmMainLoop()) swiWaitForVBlank(); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /dswifi/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /dswifi/ap_search/gfx/wifiicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/dswifi/ap_search/gfx/wifiicon.png -------------------------------------------------------------------------------- /dswifi/autoconnect/source/autoconnect.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | ---------------------------------------------------------------------------------*/ 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | 14 | struct in_addr ip, gateway, mask, dns1, dns2; 15 | 16 | consoleDemoInit(); //setup the sub screen for printing 17 | 18 | iprintf("\n\n\tSimple Wifi Connection Demo\n\n"); 19 | iprintf("Connecting via WFC data ...\n"); 20 | 21 | if(!Wifi_InitDefault(WFC_CONNECT)) { 22 | iprintf("Failed to connect!"); 23 | } else { 24 | 25 | iprintf("Connected\n\n"); 26 | 27 | ip = Wifi_GetIPInfo(&gateway, &mask, &dns1, &dns2); 28 | 29 | iprintf("ip : %s\n", inet_ntoa(ip) ); 30 | iprintf("gateway: %s\n", inet_ntoa(gateway) ); 31 | iprintf("mask : %s\n", inet_ntoa(mask) ); 32 | iprintf("dns1 : %s\n", inet_ntoa(dns1) ); 33 | iprintf("dns2 : %s\n", inet_ntoa(dns2) ); 34 | 35 | 36 | } 37 | 38 | 39 | while(pmMainLoop()) { 40 | swiWaitForVBlank(); 41 | scanKeys(); 42 | int keys = keysDown(); 43 | if(keys & KEY_START) break; 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /dswifi/httpget/source/httpget.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | ---------------------------------------------------------------------------------*/ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | void getHttp(char* url); 14 | 15 | //--------------------------------------------------------------------------------- 16 | int main(void) { 17 | //--------------------------------------------------------------------------------- 18 | 19 | consoleDemoInit(); //setup the sub screen for printing 20 | 21 | iprintf("\n\n\tSimple Wifi Connection Demo\n\n"); 22 | iprintf("Connecting via WFC data ...\n"); 23 | 24 | if(!Wifi_InitDefault(WFC_CONNECT)) { 25 | iprintf("Failed to connect!"); 26 | } else { 27 | 28 | iprintf("Connected\n\n"); 29 | 30 | getHttp("www.akkit.org"); } 31 | 32 | 33 | while(pmMainLoop()) { 34 | swiWaitForVBlank(); 35 | int keys = keysDown(); 36 | if(keys & KEY_START) break; 37 | } 38 | 39 | return 0; 40 | } 41 | 42 | //--------------------------------------------------------------------------------- 43 | void getHttp(char* url) { 44 | //--------------------------------------------------------------------------------- 45 | // Let's send a simple HTTP request to a server and print the results! 46 | 47 | // store the HTTP request for later 48 | const char * request_text = 49 | "GET /dswifi/example1.php HTTP/1.1\r\n" 50 | "Host: www.akkit.org\r\n" 51 | "User-Agent: Nintendo DS\r\n\r\n"; 52 | 53 | // Find the IP address of the server, with gethostbyname 54 | struct hostent * myhost = gethostbyname( url ); 55 | iprintf("Found IP Address!\n"); 56 | 57 | // Create a TCP socket 58 | int my_socket; 59 | my_socket = socket( AF_INET, SOCK_STREAM, 0 ); 60 | iprintf("Created Socket!\n"); 61 | 62 | // Tell the socket to connect to the IP address we found, on port 80 (HTTP) 63 | struct sockaddr_in sain; 64 | sain.sin_family = AF_INET; 65 | sain.sin_port = htons(80); 66 | sain.sin_addr.s_addr= *( (unsigned long *)(myhost->h_addr_list[0]) ); 67 | connect( my_socket,(struct sockaddr *)&sain, sizeof(sain) ); 68 | iprintf("Connected to server!\n"); 69 | 70 | // send our request 71 | send( my_socket, request_text, strlen(request_text), 0 ); 72 | iprintf("Sent our request!\n"); 73 | 74 | // Print incoming data 75 | iprintf("Printing incoming data:\n"); 76 | 77 | int recvd_len; 78 | char incoming_buffer[256]; 79 | 80 | while( ( recvd_len = recv( my_socket, incoming_buffer, 255, 0 ) ) != 0 ) { // if recv returns 0, the socket has been closed. 81 | if(recvd_len>0) { // data was received! 82 | incoming_buffer[recvd_len] = 0; // null-terminate 83 | iprintf("%s", incoming_buffer); 84 | } 85 | } 86 | 87 | iprintf("Other side closed connection!"); 88 | 89 | shutdown(my_socket,0); // good practice to shutdown the socket. 90 | 91 | closesocket(my_socket); // remove the socket. 92 | } 93 | 94 | -------------------------------------------------------------------------------- /filesystem/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /filesystem/libfat/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /filesystem/libfat/libfatdir/source/directory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(int argc, char **argv) { 12 | //--------------------------------------------------------------------------------- 13 | 14 | // Initialise the console, required for printf 15 | consoleDemoInit(); 16 | 17 | if (fatInitDefault()) { 18 | 19 | 20 | DIR *pdir; 21 | struct dirent *pent; 22 | 23 | pdir=opendir("/"); 24 | 25 | if (pdir){ 26 | 27 | while ((pent=readdir(pdir))!=NULL) { 28 | if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0) 29 | continue; 30 | if(pent->d_type == DT_DIR) 31 | iprintf("[%s]\n", pent->d_name); 32 | else 33 | iprintf("%s\n", pent->d_name); 34 | } 35 | closedir(pdir); 36 | } else { 37 | iprintf ("opendir() failure; terminating\n"); 38 | } 39 | 40 | } else { 41 | iprintf("fatInitDefault failure: terminating\n"); 42 | } 43 | 44 | while(pmMainLoop()) { 45 | swiWaitForVBlank(); 46 | scanKeys(); 47 | if(keysDown()&KEY_START) break; 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /filesystem/nitrofs/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /filesystem/nitrofs/nitrodir/nitrofiles/dir1/test.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/filesystem/nitrofs/nitrodir/nitrofiles/dir1/test.txt -------------------------------------------------------------------------------- /filesystem/nitrofs/nitrodir/nitrofiles/dir2/subdir1/subsubdir1/file2.txt: -------------------------------------------------------------------------------- 1 | Hello from file2.txt 2 | 3 | -------------------------------------------------------------------------------- /filesystem/nitrofs/nitrodir/nitrofiles/dir2/subdir1/test2.txt: -------------------------------------------------------------------------------- 1 | hello world. 2 | -------------------------------------------------------------------------------- /filesystem/nitrofs/nitrodir/nitrofiles/file1.txt: -------------------------------------------------------------------------------- 1 | this file has some content 2 | it is small. 3 | but we should make it 512 bytes at least to make sure that some stuff works. 4 | so let us pad it out. 5 | pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad 6 | pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad 7 | pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad 8 | pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad 9 | pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad pad 10 | and now it is 631 bytes. 11 | wait, make that 678 -------------------------------------------------------------------------------- /filesystem/nitrofs/nitrodir/source/directory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | //--------------------------------------------------------------------------------- 11 | void dirlist(const char* path) { 12 | //--------------------------------------------------------------------------------- 13 | 14 | DIR* pdir = opendir(path); 15 | 16 | if (pdir != NULL) { 17 | 18 | while(true) { 19 | struct dirent* pent = readdir(pdir); 20 | if(pent == NULL) break; 21 | 22 | if(strcmp(".", pent->d_name) != 0 && strcmp("..", pent->d_name) != 0) { 23 | if(pent->d_type == DT_DIR) { 24 | printf("%s/%s \n", (strcmp("/",path) == 0)?"":path, pent->d_name); 25 | char *dnbuf = (char *)malloc(strlen(pent->d_name)+strlen(path)+2); 26 | sprintf(dnbuf, "%s/%s", (strcmp("/",path) == 0)?"":path, pent->d_name); 27 | dirlist(dnbuf); 28 | free(dnbuf); 29 | } else { 30 | printf("%s/%s\n",(strcmp("/",path) == 0)?"":path, pent->d_name); 31 | } 32 | } 33 | } 34 | 35 | closedir(pdir); 36 | } else { 37 | printf("opendir() failure.\n"); 38 | } 39 | } 40 | 41 | 42 | //--------------------------------------------------------------------------------- 43 | int main(int argc, char **argv) { 44 | //--------------------------------------------------------------------------------- 45 | 46 | // Initialise the console, required for printf 47 | consoleDemoInit(); 48 | 49 | if (nitroFSInit(NULL)) { 50 | 51 | dirlist("nitro:/"); 52 | 53 | { 54 | // now, try reading a file to make sure things are working OK. 55 | FILE* inf = fopen("nitro:/file1.txt","rb"); 56 | if(inf) 57 | { 58 | int len; 59 | 60 | fseek(inf,0,SEEK_END); 61 | len = ftell(inf); 62 | fseek(inf,0,SEEK_SET); 63 | 64 | iprintf("\nthe following %d bytes message\nfrom file1.txt is\nbrought to you by fread:\n",len); 65 | { 66 | char *entireFile = (char*)malloc(len+1); 67 | entireFile[len] = 0; 68 | if(fread(entireFile,1,len,inf) != len) 69 | iprintf("savage error reading the bytes from the file!\n"); 70 | else 71 | iprintf("%s\n-done-\n",entireFile); 72 | free(entireFile); 73 | } 74 | 75 | fclose(inf); 76 | } 77 | } 78 | 79 | iprintf("here is the dirlist once more:\n"); 80 | dirlist("nitro:/"); 81 | 82 | } else { 83 | iprintf("nitroFSInit failure: terminating\n"); 84 | } 85 | 86 | while(pmMainLoop()) { 87 | swiWaitForVBlank(); 88 | scanKeys(); 89 | if(keysDown()&KEY_START) break; 90 | } 91 | 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /filesystem/nitrofs/overlays/source/main.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Basic template code for starting a DS app 4 | 5 | ---------------------------------------------------------------------------------*/ 6 | #include 7 | #include 8 | #include 9 | 10 | const char* test0Func(void); 11 | void test1FuncInItcm(void); 12 | void test2Func(void); 13 | 14 | //--------------------------------------------------------------------------------- 15 | int main(int argc, char* argv[]) { 16 | //--------------------------------------------------------------------------------- 17 | 18 | consoleDemoInit(); 19 | 20 | iprintf("DS ROM overlay demo\n"); 21 | 22 | if (!fatInitDefault()) { 23 | iprintf("[WARN] fatInitDefault failed\n"); 24 | } 25 | 26 | if (!ovlInit()) { 27 | iprintf("[ERROR] ovlInit failed\n"); 28 | } else for (unsigned i = 0; i < 2; i ++) { 29 | if (!ovlLoadAndActivate(0)) { 30 | iprintf("[ERROR] test0 load fail\n"); 31 | } else { 32 | iprintf("Message: %s\n", test0Func()); 33 | ovlDeactivate(0); 34 | } 35 | 36 | if (!ovlLoadAndActivate(1)) { 37 | iprintf("[ERROR] test1 load fail\n"); 38 | } else { 39 | test1FuncInItcm(); 40 | ovlDeactivate(1); 41 | } 42 | 43 | if (!ovlLoadAndActivate(2)) { 44 | iprintf("[ERROR] test2 load fail\n"); 45 | } else { 46 | test2Func(); 47 | test2Func(); 48 | test2Func(); 49 | ovlDeactivate(2); 50 | } 51 | } 52 | 53 | while (pmMainLoop()) { 54 | threadWaitForVBlank(); 55 | scanKeys(); 56 | 57 | unsigned pressed = keysDown(); 58 | if (pressed & KEY_START) { 59 | break; 60 | } 61 | } 62 | 63 | return 0; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /filesystem/nitrofs/overlays/source/test0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static const char* testvar; 5 | 6 | __attribute__((constructor)) static void test0ctor(void) 7 | { 8 | iprintf("[test0] Loaded\n"); 9 | testvar = "This string is stored in the overlay"; 10 | } 11 | 12 | __attribute__((destructor)) static void test0dtor(void) 13 | { 14 | iprintf("[test0] Unloaded\n"); 15 | } 16 | 17 | const char* test0Func(void) 18 | { 19 | return testvar; 20 | } 21 | -------------------------------------------------------------------------------- /filesystem/nitrofs/overlays/source/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int var; 5 | 6 | void test1FuncInItcm(void) 7 | { 8 | iprintf("[test1] Hello ITCM %p\n", &var); 9 | } 10 | -------------------------------------------------------------------------------- /filesystem/nitrofs/overlays/source/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static int numcalls; 5 | 6 | __attribute__((constructor)) static void test2ctor(void) 7 | { 8 | iprintf("[test2] Loaded\n"); 9 | } 10 | 11 | __attribute__((destructor)) static void test2dtor(void) 12 | { 13 | iprintf("[test2] Unloaded\n"); 14 | } 15 | 16 | void test2Func(void) 17 | { 18 | iprintf("[test2] Called %d times\n", ++numcalls); 19 | } 20 | -------------------------------------------------------------------------------- /hello_world/source/main.cpp: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | $Id: main.cpp,v 1.13 2008-12-02 20:21:20 dovoto Exp $ 4 | 5 | Simple console print demo 6 | -- dovoto 7 | 8 | 9 | ---------------------------------------------------------------------------------*/ 10 | #include 11 | 12 | #include 13 | 14 | static volatile int frame = 0; 15 | 16 | //--------------------------------------------------------------------------------- 17 | // VBlank interrupt handler. This function is executed in IRQ mode - be careful! 18 | //--------------------------------------------------------------------------------- 19 | static void Vblank() { 20 | //--------------------------------------------------------------------------------- 21 | frame++; 22 | } 23 | 24 | //--------------------------------------------------------------------------------- 25 | int main(void) { 26 | //--------------------------------------------------------------------------------- 27 | touchPosition touchXY; 28 | 29 | irqSet(IRQ_VBLANK, Vblank); 30 | 31 | consoleDemoInit(); 32 | 33 | iprintf(" Hello DS dev'rs\n"); 34 | iprintf(" \x1b[32mwww.devkitpro.org\n"); 35 | iprintf(" \x1b[32;1mwww.drunkencoders.com\x1b[39m"); 36 | 37 | while(pmMainLoop()) { 38 | 39 | swiWaitForVBlank(); 40 | scanKeys(); 41 | int keys = keysDown(); 42 | if (keys & KEY_START) break; 43 | 44 | touchRead(&touchXY); 45 | 46 | // print at using ansi escape sequence \x1b[line;columnH 47 | iprintf("\x1b[10;0HFrame = %d",frame); 48 | iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px); 49 | iprintf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py); 50 | 51 | } 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /input/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /input/Touch_Pad/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /input/Touch_Pad/touch_look/data/Mud.pcx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/input/Touch_Pad/touch_look/data/Mud.pcx -------------------------------------------------------------------------------- /input/Touch_Pad/touch_look/data/World.txt: -------------------------------------------------------------------------------- 1 | 2 | NUMPOLLIES 36 3 | 4 | // Floor 1 5 | -3.0 0.0 -3.0 0.0 6.0 6 | -3.0 0.0 3.0 0.0 0.0 7 | 3.0 0.0 3.0 6.0 0.0 8 | 9 | -3.0 0.0 -3.0 0.0 6.0 10 | 3.0 0.0 -3.0 6.0 6.0 11 | 3.0 0.0 3.0 6.0 0.0 12 | 13 | // Ceiling 1 14 | -3.0 1.0 -3.0 0.0 6.0 15 | -3.0 1.0 3.0 0.0 0.0 16 | 3.0 1.0 3.0 6.0 0.0 17 | -3.0 1.0 -3.0 0.0 6.0 18 | 3.0 1.0 -3.0 6.0 6.0 19 | 3.0 1.0 3.0 6.0 0.0 20 | 21 | // A1 22 | 23 | -2.0 1.0 -2.0 0.0 1.0 24 | -2.0 0.0 -2.0 0.0 0.0 25 | -0.5 0.0 -2.0 1.5 0.0 26 | -2.0 1.0 -2.0 0.0 1.0 27 | -0.5 1.0 -2.0 1.5 1.0 28 | -0.5 0.0 -2.0 1.5 0.0 29 | 30 | // A2 31 | 32 | 2.0 1.0 -2.0 2.0 1.0 33 | 2.0 0.0 -2.0 2.0 0.0 34 | 0.5 0.0 -2.0 0.5 0.0 35 | 2.0 1.0 -2.0 2.0 1.0 36 | 0.5 1.0 -2.0 0.5 1.0 37 | 0.5 0.0 -2.0 0.5 0.0 38 | 39 | // B1 40 | 41 | -2.0 1.0 2.0 2.0 1.0 42 | -2.0 0.0 2.0 2.0 0.0 43 | -0.5 0.0 2.0 0.5 0.0 44 | -2.0 1.0 2.0 2.0 1.0 45 | -0.5 1.0 2.0 0.5 1.0 46 | -0.5 0.0 2.0 0.5 0.0 47 | 48 | // B2 49 | 50 | 2.0 1.0 2.0 2.0 1.0 51 | 2.0 0.0 2.0 2.0 0.0 52 | 0.5 0.0 2.0 0.5 0.0 53 | 2.0 1.0 2.0 2.0 1.0 54 | 0.5 1.0 2.0 0.5 1.0 55 | 0.5 0.0 2.0 0.5 0.0 56 | 57 | // C1 58 | 59 | -2.0 1.0 -2.0 0.0 1.0 60 | -2.0 0.0 -2.0 0.0 0.0 61 | -2.0 0.0 -0.5 1.5 0.0 62 | -2.0 1.0 -2.0 0.0 1.0 63 | -2.0 1.0 -0.5 1.5 1.0 64 | -2.0 0.0 -0.5 1.5 0.0 65 | 66 | // C2 67 | 68 | -2.0 1.0 2.0 2.0 1.0 69 | -2.0 0.0 2.0 2.0 0.0 70 | -2.0 0.0 0.5 0.5 0.0 71 | -2.0 1.0 2.0 2.0 1.0 72 | -2.0 1.0 0.5 0.5 1.0 73 | -2.0 0.0 0.5 0.5 0.0 74 | 75 | // D1 76 | 77 | 2.0 1.0 -2.0 0.0 1.0 78 | 2.0 0.0 -2.0 0.0 0.0 79 | 2.0 0.0 -0.5 1.5 0.0 80 | 2.0 1.0 -2.0 0.0 1.0 81 | 2.0 1.0 -0.5 1.5 1.0 82 | 2.0 0.0 -0.5 1.5 0.0 83 | 84 | // D2 85 | 86 | 2.0 1.0 2.0 2.0 1.0 87 | 2.0 0.0 2.0 2.0 0.0 88 | 2.0 0.0 0.5 0.5 0.0 89 | 2.0 1.0 2.0 2.0 1.0 90 | 2.0 1.0 0.5 0.5 1.0 91 | 2.0 0.0 0.5 0.5 0.0 92 | 93 | // Upper hallway - L 94 | -0.5 1.0 -3.0 0.0 1.0 95 | -0.5 0.0 -3.0 0.0 0.0 96 | -0.5 0.0 -2.0 1.0 0.0 97 | -0.5 1.0 -3.0 0.0 1.0 98 | -0.5 1.0 -2.0 1.0 1.0 99 | -0.5 0.0 -2.0 1.0 0.0 100 | 101 | // Upper hallway - R 102 | 0.5 1.0 -3.0 0.0 1.0 103 | 0.5 0.0 -3.0 0.0 0.0 104 | 0.5 0.0 -2.0 1.0 0.0 105 | 0.5 1.0 -3.0 0.0 1.0 106 | 0.5 1.0 -2.0 1.0 1.0 107 | 0.5 0.0 -2.0 1.0 0.0 108 | 109 | // Lower hallway - L 110 | -0.5 1.0 3.0 0.0 1.0 111 | -0.5 0.0 3.0 0.0 0.0 112 | -0.5 0.0 2.0 1.0 0.0 113 | -0.5 1.0 3.0 0.0 1.0 114 | -0.5 1.0 2.0 1.0 1.0 115 | -0.5 0.0 2.0 1.0 0.0 116 | 117 | // Lower hallway - R 118 | 0.5 1.0 3.0 0.0 1.0 119 | 0.5 0.0 3.0 0.0 0.0 120 | 0.5 0.0 2.0 1.0 0.0 121 | 0.5 1.0 3.0 0.0 1.0 122 | 0.5 1.0 2.0 1.0 1.0 123 | 0.5 0.0 2.0 1.0 0.0 124 | 125 | 126 | // Left hallway - Lw 127 | 128 | -3.0 1.0 0.5 1.0 1.0 129 | -3.0 0.0 0.5 1.0 0.0 130 | -2.0 0.0 0.5 0.0 0.0 131 | -3.0 1.0 0.5 1.0 1.0 132 | -2.0 1.0 0.5 0.0 1.0 133 | -2.0 0.0 0.5 0.0 0.0 134 | 135 | // Left hallway - Hi 136 | 137 | -3.0 1.0 -0.5 1.0 1.0 138 | -3.0 0.0 -0.5 1.0 0.0 139 | -2.0 0.0 -0.5 0.0 0.0 140 | -3.0 1.0 -0.5 1.0 1.0 141 | -2.0 1.0 -0.5 0.0 1.0 142 | -2.0 0.0 -0.5 0.0 0.0 143 | 144 | // Right hallway - Lw 145 | 146 | 3.0 1.0 0.5 1.0 1.0 147 | 3.0 0.0 0.5 1.0 0.0 148 | 2.0 0.0 0.5 0.0 0.0 149 | 3.0 1.0 0.5 1.0 1.0 150 | 2.0 1.0 0.5 0.0 1.0 151 | 2.0 0.0 0.5 0.0 0.0 152 | 153 | // Right hallway - Hi 154 | 155 | 3.0 1.0 -0.5 1.0 1.0 156 | 3.0 0.0 -0.5 1.0 0.0 157 | 2.0 0.0 -0.5 0.0 0.0 158 | 3.0 1.0 -0.5 1.0 1.0 159 | 2.0 1.0 -0.5 0.0 1.0 160 | 2.0 0.0 -0.5 0.0 0.0 161 | -------------------------------------------------------------------------------- /input/Touch_Pad/touch_test/graphics/ball.grit: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------- 2 | # graphics in tile format 3 | #------------------------------------------------------- 4 | -gt 5 | 6 | #------------------------------------------------------- 7 | # no tile reduction 8 | #------------------------------------------------------- 9 | -mR! 10 | 11 | #------------------------------------------------------- 12 | # no map output 13 | #------------------------------------------------------- 14 | -m! 15 | 16 | #------------------------------------------------------- 17 | # metatile width 4 tiles 18 | #------------------------------------------------------- 19 | -Mw4 20 | 21 | #------------------------------------------------------- 22 | # metatile height 4 tiles 23 | #------------------------------------------------------- 24 | -Mh4 25 | 26 | #------------------------------------------------------- 27 | # graphics bit depth is 8 (256 color) 28 | #------------------------------------------------------- 29 | -gB8 30 | 31 | 32 | -------------------------------------------------------------------------------- /input/Touch_Pad/touch_test/graphics/ball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devkitPro/nds-examples/f1ba715a451c6407f8b0f805999d0153062ff552/input/Touch_Pad/touch_test/graphics/ball.png -------------------------------------------------------------------------------- /input/Touch_Pad/touch_test/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "ball.h" 6 | 7 | static enum { CONTINUOUS, SINGLE } TouchType = CONTINUOUS; 8 | 9 | //--------------------------------------------------------------------------------- 10 | int main(void) { 11 | //--------------------------------------------------------------------------------- 12 | int min_x = 4096 , min_y = 4096, max_x = 0, max_y = 0; 13 | int min_px = 4096 , min_py = 4096, max_px = 0 , max_py = 0; 14 | touchPosition touch; 15 | 16 | // put the main screen on the bottom lcd 17 | lcdMainOnBottom(); 18 | 19 | // set the video mode 20 | videoSetMode(MODE_0_2D); 21 | 22 | // Sprite initialisation 23 | oamInit(&oamMain, SpriteMapping_1D_32, false); 24 | 25 | // enable vram and map it to the right places 26 | vramSetPrimaryBanks( 27 | VRAM_A_MAIN_BG, //map A to background memory 28 | VRAM_B_MAIN_SPRITE, //map B to sprite memory 29 | VRAM_C_LCD, //not using C 30 | VRAM_D_LCD //not using D 31 | ); 32 | 33 | // load sprite palette 34 | for(unsigned i = 0; i < 256; i++) 35 | SPRITE_PALETTE[i] = ((u16*)ballPal)[i]; 36 | 37 | // load sprite graphics 38 | for(unsigned i = 0; i< 32*16; i++) 39 | SPRITE_GFX[i] = ((u16*)ballTiles)[i]; 40 | 41 | // initialise console background 42 | consoleInit(0, 0,BgType_Text4bpp, BgSize_T_256x256, 31,0, true, true); 43 | 44 | iprintf("\x1b[4;8HTouch Screen Test"); 45 | iprintf("\x1b[15;4HRight Shoulder toggles"); 46 | 47 | while(pmMainLoop()) { 48 | 49 | swiWaitForVBlank(); 50 | oamUpdate(&oamMain); 51 | 52 | // read the button states 53 | scanKeys(); 54 | 55 | // read the touchscreen coordinates 56 | touchRead(&touch); 57 | 58 | int pressed = keysDown(); // buttons pressed this loop 59 | int held = keysHeld(); // buttons currently held 60 | 61 | // Right Shoulder button toggles the mode 62 | if ( pressed & KEY_R) TouchType ^= SINGLE; 63 | 64 | // Start button exits the app 65 | if ( pressed & KEY_START) break; 66 | 67 | iprintf("\x1b[14;4HTouch mode: %s",TouchType==CONTINUOUS?"CONTINUOUS ":"SINGLE SHOT"); 68 | 69 | iprintf("\x1b[6;5HTouch x = %04X, %04X\n", touch.rawx, touch.px); 70 | iprintf("\x1b[7;5HTouch y = %04X, %04X\n", touch.rawy, touch.py); 71 | 72 | iprintf("\x1b[0;18Hkeys: %08lX\n", keysHeld()); 73 | 74 | if ( TouchType == SINGLE && !(pressed & KEY_TOUCH) ) continue; 75 | 76 | if ( !(held & KEY_TOUCH) || touch.rawx == 0 || touch.rawy == 0) continue; 77 | 78 | iprintf("\x1b[12;12H(%d,%d) ",touch.px,touch.py); 79 | 80 | if ( touch.rawx > max_x) max_x = touch.rawx; 81 | if ( touch.rawy > max_y) max_y = touch.rawy; 82 | if ( touch.px > max_px) max_px = touch.px; 83 | if ( touch.py > max_py) max_py = touch.py; 84 | 85 | if ( touch.rawx < min_x) min_x = touch.rawx; 86 | if ( touch.rawy < min_y) min_y = touch.rawy; 87 | if ( touch.px < min_px) min_px = touch.px; 88 | if ( touch.py < min_py) min_py = touch.py; 89 | 90 | iprintf("\x1b[0;0H(%d,%d) ",min_px,min_py); 91 | iprintf("\x1b[1;0H(%d,%d) ",min_x,min_y); 92 | iprintf("\x1b[22;21H(%d,%d)",max_x,max_y); 93 | iprintf("\x1b[23;23H(%d,%d)",max_px,max_py); 94 | 95 | // Move and display sprite 96 | oamSet(&oamMain, 0, 97 | ((touch.px - 16) & 0x01FF), // X position 98 | ((touch.py - 16) & 0x00FF), // Y position 99 | 0, 100 | 0, 101 | SpriteSize_32x32, SpriteColorFormat_256Color, 102 | SPRITE_GFX, 103 | -1, 104 | false, false, false, false, false); 105 | } 106 | 107 | return 0; 108 | } 109 | -------------------------------------------------------------------------------- /input/addon/source/addon.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any 5 | damages arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any 8 | purpose, including commercial applications, and to alter it and 9 | redistribute it freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you 12 | must not claim that you wrote the original software. If you use 13 | this software in a product, an acknowledgment in the product 14 | documentation would be appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and 16 | must not be misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source 18 | distribution. 19 | 20 | ---------------------------------------------------------------------------------*/ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | typedef struct { 29 | union { 30 | struct { 31 | u16 c:1; 32 | u16 c_sharp:1; //rules! 33 | u16 d:1; 34 | u16 d_sharp:1; 35 | u16 e:1; 36 | u16 f:1; 37 | u16 f_sharp:1; 38 | u16 g:1; 39 | u16 g_sharp:1; 40 | u16 a:1; 41 | u16 a_sharp:1; 42 | u16 _unknown1:1; 43 | u16 _unknown2:1; 44 | u16 b:1; 45 | u16 high_c:1; //is yummy 46 | u16 _unknown3:1; 47 | }; 48 | u16 VAL; 49 | }; 50 | } PianoKeys; 51 | 52 | int main(void) { 53 | consoleDemoInit(); 54 | 55 | consoleClear(); 56 | 57 | bool gbaOk = gbacartOpen(); 58 | 59 | if (!gbaOk) { 60 | iprintf("GBA slot not available\n"); 61 | } else { 62 | iprintf("Insert gamepak addon."); 63 | } 64 | 65 | while(pmMainLoop()) { 66 | swiWaitForVBlank(); 67 | 68 | scanKeys(); 69 | 70 | if(keysDown() & KEY_START) break; 71 | 72 | 73 | if (!gbaOk) continue; 74 | 75 | 76 | iprintf("\x1b[5;0Hgba header 96h: %02X\n",GBA_HEADER.is96h); 77 | iprintf("0x08000000: %04X\n",*(vu16*)0x08000000); 78 | 79 | if(guitarGripIsInserted()) 80 | { 81 | guitarGripScanKeys(); 82 | u8 keys = guitarGripKeysHeld(); 83 | iprintf("\x1b[8;0HguitarGrip: %02X\n",keys); 84 | iprintf(" [%s] [%s] [%s] [%s]",(keys&GUITARGRIP_BLUE)?"BLU":" ",(keys&GUITARGRIP_YELLOW)?"YEL":" ",(keys&GUITARGRIP_RED)?"RED":" ",(keys&GUITARGRIP_GREEN)?"GRN":" "); 85 | } 86 | 87 | if(pianoIsInserted()) 88 | { 89 | pianoScanKeys(); 90 | PianoKeys keys; 91 | keys.VAL = pianoKeysHeld(); 92 | iprintf("\x1b[8;0Hpiano: %04X\n",pianoKeysHeld()); 93 | iprintf(" %s %s %s %s %s \n",keys.c_sharp?"C#":" ",keys.d_sharp?"D#":" ",keys.f_sharp?"F#":" ",keys.g_sharp?"G#":" ",keys.a_sharp?"A#":" "); 94 | iprintf("%s %s %s %s %s %s %s %s\n",keys.c?"C ":" ",keys.d?"D ":" ",keys.e?"E ":" ",keys.f?"F ":" ",keys.g?"G ":" ",keys.a?"A ":" ",keys.b?"B ":" ",keys.high_c?"C ":" "); 95 | } 96 | 97 | if(paddleIsInserted()) 98 | { 99 | iprintf("\x1b[8;0Hpaddle: %04X\n",paddleRead()); 100 | } 101 | 102 | 103 | } 104 | 105 | if (gbaOk) { 106 | gbacartClose(); 107 | } 108 | 109 | return 0; 110 | } 111 | -------------------------------------------------------------------------------- /input/keyboard/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /input/keyboard/keyboard_async/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple console print demo 4 | -- dovoto 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | consoleDemoInit(); //setup the sub screen for printing 14 | 15 | keyboardDemoInit(); 16 | 17 | keyboardShow(); 18 | 19 | while(pmMainLoop()) { 20 | 21 | int key = keyboardUpdate(); 22 | 23 | if(key > 0) 24 | iprintf("%c", key); 25 | 26 | swiWaitForVBlank(); 27 | scanKeys(); 28 | 29 | int pressed = keysDown(); 30 | 31 | if(pressed & KEY_START) break; 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /input/keyboard/keyboard_stdin/source/keymain.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | 6 | void OnKeyPressed(int key) { 7 | if(key > 0) 8 | iprintf("%c", key); 9 | } 10 | 11 | int main(void) { 12 | 13 | consoleDemoInit(); 14 | 15 | Keyboard *kbd = keyboardDemoInit(); 16 | 17 | kbd->OnKeyPressed = OnKeyPressed; 18 | 19 | bool askname = true; 20 | 21 | while(pmMainLoop()) { 22 | swiWaitForVBlank(); 23 | scanKeys(); 24 | 25 | u32 keys = keysDown(); 26 | if (keys & KEY_START) { 27 | break; 28 | } else if (keys != 0) { 29 | askname = true; 30 | } 31 | 32 | if (askname) { 33 | char myName[256]; 34 | 35 | consoleClear(); 36 | iprintf("What is your name?\n"); 37 | iscanf("%s", myName); 38 | iprintf("\nHello %s", myName); 39 | askname = false; 40 | } 41 | } 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /pxi/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | export TARGET := $(shell basename $(CURDIR)) 9 | export TOPDIR := $(CURDIR) 10 | 11 | # GMAE_ICON is the image used to create the game icon, leave blank to use default rule 12 | GAME_ICON := 13 | 14 | # specify a directory which contains the nitro filesystem 15 | # this is relative to the Makefile 16 | NITRO_FILES := 17 | 18 | # These set the information text in the nds file 19 | #GAME_TITLE := My Wonderful Homebrew 20 | #GAME_SUBTITLE1 := built with devkitARM 21 | #GAME_SUBTITLE2 := http://devitpro.org 22 | 23 | include $(DEVKITARM)/ds_rules 24 | 25 | .PHONY: checkarm7 checkarm9 clean 26 | 27 | #--------------------------------------------------------------------------------- 28 | # main targets 29 | #--------------------------------------------------------------------------------- 30 | all: checkarm7 checkarm9 $(TARGET).nds 31 | 32 | #--------------------------------------------------------------------------------- 33 | checkarm7: 34 | $(MAKE) -C arm7 35 | 36 | #--------------------------------------------------------------------------------- 37 | checkarm9: 38 | $(MAKE) -C arm9 39 | 40 | #--------------------------------------------------------------------------------- 41 | $(TARGET).nds : $(NITRO_FILES) arm7/$(TARGET).elf arm9/$(TARGET).elf 42 | ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ 43 | -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ 44 | $(_ADDFILES) 45 | 46 | #--------------------------------------------------------------------------------- 47 | arm7/$(TARGET).elf: 48 | $(MAKE) -C arm7 49 | 50 | #--------------------------------------------------------------------------------- 51 | arm9/$(TARGET).elf: 52 | $(MAKE) -C arm9 53 | 54 | #--------------------------------------------------------------------------------- 55 | clean: 56 | $(MAKE) -C arm9 clean 57 | $(MAKE) -C arm7 clean 58 | rm -f $(TARGET).nds 59 | -------------------------------------------------------------------------------- /pxi/arm7/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | ARM7 code for PXI example 4 | -- fincs 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | 9 | // Management structure and stack space for PXI server thread 10 | static Thread s_myServerThread; 11 | alignas(8) static u8 s_myServerThreadStack[1024]; 12 | 13 | //--------------------------------------------------------------------------------- 14 | static int myServerThreadMain(void* arg) { 15 | //--------------------------------------------------------------------------------- 16 | // Set up PXI mailbox, used to receive PXI command words 17 | Mailbox mb; 18 | u32 mb_slots[4]; 19 | mailboxPrepare(&mb, mb_slots, sizeof(mb_slots)/4); 20 | pxiSetMailbox(PxiChannel_User0, &mb); 21 | 22 | // Main PXI message loop 23 | for (;;) { 24 | // Receive a message 25 | u32 msg = mailboxRecv(&mb); 26 | u32 retval = 0; 27 | 28 | switch (msg) { 29 | default: break; 30 | 31 | // Command 0: Read the firmware chip's JEDEC identifier 32 | case 0: { 33 | spiLock(); 34 | nvramReadJedec(&retval); 35 | spiUnlock(); 36 | 37 | break; 38 | } 39 | 40 | // Command 1: Read touch pressure values (only works on DS Phat/DS Lite) 41 | case 1: { 42 | unsigned z1 = 0, z2 = 0; 43 | 44 | if (!cdcIsTwlMode()) { 45 | spiLock(); 46 | z1 = tscReadChannel12(TscChannel_Z1); 47 | z2 = tscReadChannel12(TscChannel_Z2); 48 | spiUnlock(); 49 | } 50 | 51 | // Pack the two 12-bit values into the reply value 52 | retval = z1 | (z2 << 12); 53 | break; 54 | } 55 | } 56 | 57 | // Send a reply back to the ARM9 58 | pxiReply(PxiChannel_User0, retval); 59 | } 60 | 61 | return 0; 62 | } 63 | 64 | //--------------------------------------------------------------------------------- 65 | int main(int argc, char* argv[]) { 66 | //--------------------------------------------------------------------------------- 67 | // Read settings from NVRAM 68 | envReadNvramSettings(); 69 | 70 | // Set up extended keypad server (X/Y/hinge) 71 | keypadStartExtServer(); 72 | 73 | // Configure and enable VBlank interrupt 74 | lcdSetIrqMask(DISPSTAT_IE_ALL, DISPSTAT_IE_VBLANK); 75 | irqEnable(IRQ_VBLANK); 76 | 77 | // Set up RTC 78 | rtcInit(); 79 | rtcSyncTime(); 80 | 81 | // Initialize power management 82 | pmInit(); 83 | 84 | // Set up touch screen driver 85 | touchInit(); 86 | touchStartServer(80, MAIN_THREAD_PRIO); 87 | 88 | // Set up server thread 89 | threadPrepare(&s_myServerThread, myServerThreadMain, NULL, &s_myServerThreadStack[sizeof(s_myServerThreadStack)], MAIN_THREAD_PRIO); 90 | threadStart(&s_myServerThread); 91 | 92 | // Keep the ARM7 mostly idle 93 | while (pmMainLoop()) { 94 | threadWaitForVBlank(); 95 | } 96 | 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /pxi/arm9/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | ARM9 code for PXI example 4 | -- fincs 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | 10 | //--------------------------------------------------------------------------------- 11 | static s32 calcTouchPressure(unsigned px, unsigned z1, unsigned z2) { 12 | //--------------------------------------------------------------------------------- 13 | // Given px, z1, z2 (all 20.12 fixed point numbers), 14 | // pressure = 1/resistance = 1 / (x * (z2/z1 - 1)) = z1 / (x * (z2 - z1)) 15 | // With some mathematical cleverness we can avoid divisions by zero, 16 | // as well as 0/0 indetermination (such as when z1 == z2) 17 | 18 | s32 num = divf32(z1, px); 19 | s32 den = z2 - z1; 20 | 21 | if (num == den) { 22 | return inttof32(1); 23 | } else { 24 | return divf32(num, den); 25 | } 26 | } 27 | 28 | //--------------------------------------------------------------------------------- 29 | int main(void) { 30 | //--------------------------------------------------------------------------------- 31 | touchPosition touch; 32 | 33 | consoleDemoInit(); //setup the sub screen for printing 34 | 35 | pxiWaitRemote(PxiChannel_User0); 36 | 37 | iprintf("\n\n\tHello DS dev'rs\n"); 38 | iprintf("\thttps://devkitpro.org\n\n"); 39 | 40 | u32 jedec = pxiSendAndReceive(PxiChannel_User0, 0); 41 | printf("Firmware JEDEC ID: 0x%06lX\n", jedec); 42 | 43 | while(pmMainLoop()) { 44 | 45 | swiWaitForVBlank(); 46 | scanKeys(); 47 | if (keysDown()&KEY_START) break; 48 | 49 | if (keysHeld()&KEY_TOUCH) { 50 | touchRead(&touch); 51 | 52 | u32 reply = pxiSendAndReceive(PxiChannel_User0, 1); 53 | s32 pressure = calcTouchPressure(touch.rawx, reply & 0xfff, reply >> 12); 54 | 55 | iprintf("\x1b[10;0HTouch x = %04i, %04i\n", touch.rawx, touch.px); 56 | iprintf("Touch y = %04i, %04i\n", touch.rawy, touch.py); 57 | 58 | printf("Touch pressure: %.6f\n", f32tofloat(pressure)); 59 | } 60 | 61 | } 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /templates/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /templates/arm9/source/main.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Basic template code for starting a DS app 4 | 5 | ---------------------------------------------------------------------------------*/ 6 | #include 7 | #include 8 | 9 | //--------------------------------------------------------------------------------- 10 | int main(int argc, char* argv[]) { 11 | //--------------------------------------------------------------------------------- 12 | 13 | consoleDemoInit(); 14 | iprintf("Hello World!"); 15 | 16 | while(pmMainLoop()) { 17 | swiWaitForVBlank(); 18 | scanKeys(); 19 | int pressed = keysDown(); 20 | if(pressed & KEY_START) break; 21 | } 22 | 23 | return 0; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /templates/arm9lib/include/templatelib.h: -------------------------------------------------------------------------------- 1 | #ifndef _templatelib_h_ 2 | #define _templatelib_h_ 3 | 4 | int myLibFunction(); 5 | 6 | #endif // _templatelib_h_ 7 | -------------------------------------------------------------------------------- /templates/arm9lib/source/templatelib.c: -------------------------------------------------------------------------------- 1 | int myLibFunction() { 2 | 3 | 4 | return 42; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /templates/combined/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | ifeq ($(strip $(DEVKITARM)),) 5 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 6 | endif 7 | 8 | export TARGET := $(shell basename $(CURDIR)) 9 | export TOPDIR := $(CURDIR) 10 | 11 | # GMAE_ICON is the image used to create the game icon, leave blank to use default rule 12 | GAME_ICON := 13 | 14 | # specify a directory which contains the nitro filesystem 15 | # this is relative to the Makefile 16 | NITRO_FILES := 17 | 18 | # These set the information text in the nds file 19 | #GAME_TITLE := My Wonderful Homebrew 20 | #GAME_SUBTITLE1 := built with devkitARM 21 | #GAME_SUBTITLE2 := http://devitpro.org 22 | 23 | include $(DEVKITARM)/ds_rules 24 | 25 | .PHONY: checkarm7 checkarm9 clean 26 | 27 | #--------------------------------------------------------------------------------- 28 | # main targets 29 | #--------------------------------------------------------------------------------- 30 | all: checkarm7 checkarm9 $(TARGET).nds 31 | 32 | #--------------------------------------------------------------------------------- 33 | checkarm7: 34 | $(MAKE) -C arm7 35 | 36 | #--------------------------------------------------------------------------------- 37 | checkarm9: 38 | $(MAKE) -C arm9 39 | 40 | #--------------------------------------------------------------------------------- 41 | $(TARGET).nds : $(NITRO_FILES) arm7/$(TARGET).elf arm9/$(TARGET).elf 42 | ndstool -c $(TARGET).nds -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf \ 43 | -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" \ 44 | $(_ADDFILES) 45 | 46 | #--------------------------------------------------------------------------------- 47 | arm7/$(TARGET).elf: 48 | $(MAKE) -C arm7 49 | 50 | #--------------------------------------------------------------------------------- 51 | arm9/$(TARGET).elf: 52 | $(MAKE) -C arm9 53 | 54 | #--------------------------------------------------------------------------------- 55 | clean: 56 | $(MAKE) -C arm9 clean 57 | $(MAKE) -C arm7 clean 58 | rm -f $(TARGET).nds 59 | -------------------------------------------------------------------------------- /templates/combined/arm7/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | default ARM7 core 4 | 5 | Copyright (C) 2005 - 2010 6 | Michael Noland (joat) 7 | Jason Rogers (dovoto) 8 | Dave Murphy (WinterMute) 9 | 10 | This software is provided 'as-is', without any express or implied 11 | warranty. In no event will the authors be held liable for any 12 | damages arising from the use of this software. 13 | 14 | Permission is granted to anyone to use this software for any 15 | purpose, including commercial applications, and to alter it and 16 | redistribute it freely, subject to the following restrictions: 17 | 18 | 1. The origin of this software must not be misrepresented; you 19 | must not claim that you wrote the original software. If you use 20 | this software in a product, an acknowledgment in the product 21 | documentation would be appreciated but is not required. 22 | 23 | 2. Altered source versions must be plainly marked as such, and 24 | must not be misrepresented as being the original software. 25 | 26 | 3. This notice may not be removed or altered from any source 27 | distribution. 28 | 29 | ---------------------------------------------------------------------------------*/ 30 | #include 31 | #include 32 | #include 33 | 34 | //--------------------------------------------------------------------------------- 35 | int main() { 36 | //--------------------------------------------------------------------------------- 37 | 38 | // Read settings from NVRAM 39 | envReadNvramSettings(); 40 | 41 | // Set up extended keypad server (X/Y/hinge) 42 | keypadStartExtServer(); 43 | 44 | // Configure and enable VBlank interrupt 45 | lcdSetIrqMask(DISPSTAT_IE_ALL, DISPSTAT_IE_VBLANK); 46 | irqEnable(IRQ_VBLANK); 47 | 48 | // Set up RTC 49 | rtcInit(); 50 | rtcSyncTime(); 51 | 52 | // Initialize power management 53 | pmInit(); 54 | 55 | // Set up block device peripherals 56 | blkInit(); 57 | 58 | // Set up touch screen driver 59 | touchInit(); 60 | touchStartServer(80, MAIN_THREAD_PRIO); 61 | 62 | // Set up sound and mic driver 63 | soundStartServer(MAIN_THREAD_PRIO-0x10); 64 | micStartServer(MAIN_THREAD_PRIO-0x18); 65 | 66 | // Set up wireless manager 67 | wlmgrStartServer(MAIN_THREAD_PRIO-8); 68 | 69 | // Set up Maxmod 70 | mmInstall(MAIN_THREAD_PRIO+1); 71 | 72 | // Keep the ARM7 mostly idle 73 | while (pmMainLoop()) { 74 | threadWaitForVBlank(); 75 | } 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /templates/combined/arm9/source/template.c: -------------------------------------------------------------------------------- 1 | /*--------------------------------------------------------------------------------- 2 | 3 | Simple console print demo 4 | -- dovoto 5 | 6 | ---------------------------------------------------------------------------------*/ 7 | #include 8 | #include 9 | 10 | //--------------------------------------------------------------------------------- 11 | int main(void) { 12 | //--------------------------------------------------------------------------------- 13 | touchPosition touch; 14 | 15 | consoleDemoInit(); //setup the sub screen for printing 16 | 17 | iprintf("\n\n\tHello DS dev'rs\n"); 18 | iprintf("\twww.drunkencoders.com\n"); 19 | iprintf("\twww.devkitpro.org"); 20 | 21 | while(pmMainLoop()) { 22 | 23 | swiWaitForVBlank(); 24 | scanKeys(); 25 | if (keysDown()&KEY_START) break; 26 | 27 | if (keysHeld()&KEY_TOUCH) { 28 | touchRead(&touch); 29 | iprintf("\x1b[10;0HTouch x = %04i, %04i\n", touch.rawx, touch.px); 30 | iprintf("Touch y = %04i, %04i\n", touch.rawy, touch.py); 31 | } 32 | 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /templates/dldi/source/dldi_header.s: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | @--------------------------------------------------------------------------------- 4 | .section ".crt0","ax" 5 | @--------------------------------------------------------------------------------- 6 | .global _start 7 | .align 4 8 | .arm 9 | 10 | @--------------------------------------------------------------------------------- 11 | @ Driver patch file standard header -- 16 bytes 12 | .word 0xBF8DA5ED @ Magic number to identify this region 13 | .asciz " Chishm" @ Identifying Magic string (8 bytes with null terminator) 14 | .byte 0x01 @ Version number 15 | .byte DLDI_SIZE_16KB 16 | .byte FIX_GOT | FIX_BSS | FIX_GLUE @ Sections to fix 17 | .byte 0x00 @ Space allocated in the application, not important here. 18 | 19 | @--------------------------------------------------------------------------------- 20 | @ Text identifier - can be anything up to 47 chars + terminating null -- 48 bytes 21 | .align 4 22 | .asciz "Name of driver goes here" 23 | 24 | @--------------------------------------------------------------------------------- 25 | @ Offsets to important sections within the data -- 32 bytes 26 | .align 6 27 | .word __text_start @ data start 28 | .word __data_end @ data end 29 | .word __glue_start @ Interworking glue start -- Needs address fixing 30 | .word __glue_end @ Interworking glue end 31 | .word __got_start @ GOT start -- Needs address fixing 32 | .word __got_end @ GOT end 33 | .word __bss_start @ bss start -- Needs setting to zero 34 | .word __bss_end @ bss end 35 | 36 | @--------------------------------------------------------------------------------- 37 | @ IO_INTERFACE data -- 32 bytes 38 | .ascii "XXXX" @ ioType 39 | .word FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_SLOT_NDS 40 | .word startup @ 41 | .word isInserted @ 42 | .word readSectors @ Function pointers to standard device driver functions 43 | .word writeSectors @ 44 | .word clearStatus @ 45 | .word shutdown @ 46 | 47 | @--------------------------------------------------------------------------------- 48 | _start: 49 | @--------------------------------------------------------------------------------- 50 | .align 51 | .pool 52 | .end 53 | @--------------------------------------------------------------------------------- 54 | -------------------------------------------------------------------------------- /time/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS:= `ls | egrep -v '^(CVS)$$'` 2 | all: 3 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done; 4 | clean: 5 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done; 6 | install: 7 | @for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done; 8 | -------------------------------------------------------------------------------- /time/stopwatch/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | //the speed of the timer when using ClockDivider_1024 7 | #define TIMER_SPEED (BUS_CLOCK/1024) 8 | 9 | typedef enum 10 | { 11 | timerState_Stop, 12 | timerState_Pause, 13 | timerState_Running 14 | }TimerStates; 15 | 16 | 17 | int main() 18 | { 19 | consoleDemoInit(); 20 | 21 | unsigned ticks = 0; 22 | TimerStates state = timerState_Stop; 23 | 24 | while(pmMainLoop()) 25 | { 26 | swiWaitForVBlank(); 27 | consoleClear(); 28 | scanKeys(); 29 | u32 down = keysDown(); 30 | 31 | if(down & KEY_START) break; 32 | 33 | if(state == timerState_Running) 34 | { 35 | ticks += timerElapsed(0); 36 | } 37 | 38 | if(down & KEY_A) 39 | { 40 | if(state == timerState_Stop) 41 | { 42 | timerStart(0, ClockDivider_1024, 0, NULL); 43 | state = timerState_Running; 44 | } 45 | else if(state == timerState_Pause) 46 | { 47 | timerUnpause(0); 48 | state = timerState_Running; 49 | } 50 | else if(state == timerState_Running) 51 | { 52 | ticks += timerPause(0); 53 | state = timerState_Pause; 54 | } 55 | } 56 | else if(down & KEY_B) 57 | { 58 | timerStop(0); 59 | ticks = 0; 60 | state = timerState_Stop; 61 | } 62 | 63 | iprintf("Press A to start and pause the \ntimer, B to clear the timer \nand start to quit the program.\n\n"); 64 | iprintf("ticks: %u\n", ticks); 65 | iprintf("second: %u.%03u\n", ticks/TIMER_SPEED, ((ticks%TIMER_SPEED)*1000) /TIMER_SPEED); 66 | } 67 | 68 | if(state != timerState_Stop) 69 | { 70 | timerStop(0); 71 | } 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /time/timercallback/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | static bool play = true; 6 | static volatile bool trigger = false; 7 | 8 | // Timer callback. This function is executed in IRQ mode - be careful! 9 | void timerCallBack() 10 | { 11 | play = !play; 12 | trigger = true; 13 | } 14 | 15 | int main() 16 | { 17 | consoleDemoInit(); 18 | iprintf("Timer callback demo\n"); 19 | 20 | soundEnable(); 21 | int channel = soundPlayPSG(DutyCycle_50, 10000, 127, 64); 22 | 23 | //calls the timerCallBack function 5 times per second. 24 | timerStart(0, ClockDivider_1024, TIMER_FREQ_1024(5), timerCallBack); 25 | 26 | while (pmMainLoop()) { 27 | swiWaitForVBlank(); 28 | scanKeys(); 29 | 30 | if (keysDown() & KEY_START) { 31 | break; 32 | } 33 | 34 | if (trigger) { 35 | trigger = false; 36 | if (play) { 37 | soundResume(channel); 38 | } else { 39 | soundPause(channel); 40 | } 41 | } 42 | } 43 | 44 | return 0; 45 | } 46 | --------------------------------------------------------------------------------