|
From: <at...@us...> - 2007-11-06 15:55:00
|
Revision: 532
http://cadcdev.svn.sourceforge.net/cadcdev/?rev=532&view=rev
Author: atani
Date: 2007-11-06 07:54:58 -0800 (Tue, 06 Nov 2007)
Log Message:
-----------
NDS optimized console for lower screen.
Modified Paths:
--------------
tiki/include/Tiki/drawables/console.h
tiki/nds/Makefile
tiki/nds/Makefile.rules
tiki/nds/src/init_shutdown.cpp
tiki/src/gl/drawables/console.cpp
Added Paths:
-----------
tiki/nds/ascii_font.bin
Property Changed:
----------------
tiki/nds/
Modified: tiki/include/Tiki/drawables/console.h
===================================================================
--- tiki/include/Tiki/drawables/console.h 2007-11-06 02:14:10 UTC (rev 531)
+++ tiki/include/Tiki/drawables/console.h 2007-11-06 15:54:58 UTC (rev 532)
@@ -122,36 +122,52 @@
return *this;
}
virtual void draw(ObjType t);
- void renderCharacter(float x, float y, float w, float h, unsigned char c, int color);
- void renderBackground(float x, float y, float w, float h, int color);
+
protected:
- RefPtr<Texture> m_texture;
int m_rows, m_cols;
std::vector<unsigned char> m_charData;
std::vector<unsigned short> m_colorData;
-
- Color m_palette[8];
+ float m_w, m_h;
+ virtual void refresh() {
+ Frame::begin();
+ draw(Drawable::Opaque);
+ Frame::transEnable();
+ draw(Drawable::Trans);
+ Frame::finish();
+ }
+
private:
- void processAnsiString();
+ RefPtr<Texture> m_texture;
+ Color m_palette[8];
bool m_autoScroll, m_autoWrap, m_autoRefresh;
bool m_ansi;
int m_cursor_x, m_cursor_y;
int m_save_x, m_save_y;
int m_attr;
- float m_w, m_h;
unsigned char ansistr[51];
unsigned char ansiptr;
-
- void refresh() {
- Frame::begin();
- draw(Drawable::Opaque);
- Frame::transEnable();
- draw(Drawable::Trans);
- Frame::finish();
- }
+
+ void processAnsiString();
+ void renderCharacter(float x, float y, float w, float h, unsigned char c, int color);
+ void renderBackground(float x, float y, float w, float h, int color);
};
+
+#if TIKI_PLAT == TIKI_NDS
+ // NDS optimized console for the lower screen
+ class NDSSubScreenConsole : public Console
+ {
+ public:
+ NDSSubScreenConsole(int cols, int rows);
+ virtual void draw(ObjType list);
+
+ protected:
+ virtual void refresh() {
+ draw(Drawable::Opaque);
+ }
+ };
+#endif
};
};
Property changes on: tiki/nds
___________________________________________________________________
Name: svn:ignore
- libtiki.a
tiki.depend
tiki.layout
.objs
+ libtiki.a
tiki.depend
tiki.layout
.objs
ascii_font_bin.h
Modified: tiki/nds/Makefile
===================================================================
--- tiki/nds/Makefile 2007-11-06 02:14:10 UTC (rev 531)
+++ tiki/nds/Makefile 2007-11-06 15:54:58 UTC (rev 532)
@@ -6,6 +6,7 @@
BASE_GL_OBJ+=$(patsubst %.cpp,%.o,$(wildcard ../src/gl/anims/*.cpp))
BASE_GL_OBJ+=$(patsubst %.cpp,%.o,$(wildcard ../src/gl/drawables/*.cpp))
BASE_GL_OBJ+=$(patsubst %.cpp,%.o,$(wildcard ../src/gl/triggers/*.cpp))
+BASE_GL_OBJ+=ascii_font.bin.o
BASE_HID_OBJ=$(patsubst %.cpp,%.o,$(wildcard ../src/hid/*.cpp))
BASE_IMAGE_OBJ=$(patsubst %.cpp,%.o,$(wildcard ../src/image/*.cpp))
BASE_MATH_OBJ=$(patsubst %.cpp,%.o,$(wildcard ../src/math/*.cpp))
Modified: tiki/nds/Makefile.rules
===================================================================
--- tiki/nds/Makefile.rules 2007-11-06 02:14:10 UTC (rev 531)
+++ tiki/nds/Makefile.rules 2007-11-06 15:54:58 UTC (rev 532)
@@ -55,3 +55,11 @@
@rm -f tikiarm7.arm7
@rm -f $@.arm9.elf
endef
+
+#-----------------
+# extra rules not provided by devkitpro
+
+%.bin.o : %.bin
+ @echo $(notdir $<)
+ @$(bin2o)
+#-----------------
Added: tiki/nds/ascii_font.bin
===================================================================
(Binary files differ)
Property changes on: tiki/nds/ascii_font.bin
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: tiki/nds/src/init_shutdown.cpp
===================================================================
--- tiki/nds/src/init_shutdown.cpp 2007-11-06 02:14:10 UTC (rev 531)
+++ tiki/nds/src/init_shutdown.cpp 2007-11-06 15:54:58 UTC (rev 532)
@@ -22,6 +22,10 @@
SendCommandToArm7( 0x87654321 );
}
+Tiki::GL::NDSSubScreenConsole *console = NULL;
+extern const u8 ascii_font_bin[];
+extern const u32 ascii_font_bin_size;
+
namespace Tiki {
bool init( int argc, char **argv ) {
@@ -32,13 +36,21 @@
if(g_tiki_init_flags & TIKI_INIT_DEBUG_CONSOLE) {
consoleDemoInit();
+ /*
+ videoSetModeSub( MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE );
+ SUB_BG0_CR = BG_64x32 | BG_COLOR_16 | BG_MAP_BASE( 0 ) | BG_TILE_BASE( 1 );
+ SUB_BG1_CR = BG_64x32 | BG_COLOR_16 | BG_MAP_BASE( 2 ) | BG_TILE_BASE( 1 );
+ vramSetBankC( VRAM_C_SUB_BG );
+ memcpy( ( void * )BG_TILE_RAM_SUB( 1 ), ascii_font_bin, ascii_font_bin_size );
+ console = new Tiki::GL::NDSSubScreenConsole( 64, 24 );
+ */
}
- // Setup the Main screen for 3D
+ // Setup the Main screen for 3D
videoSetMode( MODE_0_3D );
vramSetBankA( VRAM_A_TEXTURE );
- Tiki::Debug::printf("Enabling IRQs\n");
+ Tiki::Debug::printf("Enabling IRQs\n");
// IRQ basic setup
irqInit();
@@ -47,39 +59,39 @@
glInit();
glEnable(GL_TEXTURE_2D);
- // enable antialiasing
- glEnable(GL_ANTIALIAS);
- glClearColor(0,0,0,31); // BG must be opaque for AA to work
- glClearPolyID(63); // BG must have a unique polygon ID for AA to work
- glClearDepth( 0x7FFF );
+ // enable antialiasing
+ glEnable(GL_ANTIALIAS);
+ glClearColor(0,0,0,31); // BG must be opaque for AA to work
+ glClearPolyID(63); // BG must have a unique polygon ID for AA to work
+ glClearDepth( 0x7FFF );
// Set our viewport to be the same size as the screen
- glViewport(0,0,255,191);
+ glViewport(0,0,255,191);
glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(70, 256.0 / 192.0, 0.1, 100);
+ glLoadIdentity();
+ gluPerspective(70, 256.0 / 192.0, 0.1, 100);
glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0),0);
glLight(1, RGB15(31,31,31) , 0,0,floattov10(-1.0));
glLight(2, RGB15(31,31,31) , 0,0,floattov10(1.0));
//need to set up some material properties since DS does not have them set by default
- glMaterialf(GL_AMBIENT, RGB15(16,16,16));
- glMaterialf(GL_DIFFUSE, RGB15(16,16,16));
- glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));
- glMaterialf(GL_EMISSION, RGB15(16,16,16));
+ glMaterialf(GL_AMBIENT, RGB15(16,16,16));
+ glMaterialf(GL_DIFFUSE, RGB15(16,16,16));
+ glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));
+ glMaterialf(GL_EMISSION, RGB15(16,16,16));
- //ds uses a table for shinyness..this generates a half-ass one
- glMaterialShinyness();
+ //ds uses a table for shinyness..this generates a half-ass one
+ glMaterialShinyness();
- glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_FORMAT_LIGHT0| POLY_FORMAT_LIGHT1| POLY_FORMAT_LIGHT2 );
+ glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_FORMAT_LIGHT0| POLY_FORMAT_LIGHT1| POLY_FORMAT_LIGHT2 );
- glMatrixMode(GL_MODELVIEW);
+ glMatrixMode(GL_MODELVIEW);
- // set a default color.
- glColor3f(1, 1, 1);
+ // set a default color.
+ glColor3f(1, 1, 1);
- Tiki::Debug::printf("Enabling libFAT\n");
+ Tiki::Debug::printf("Enabling libFAT\n");
fatInitDefault();
if(g_tiki_init_flags & TIKI_INIT_AUDIO_MASK) {
@@ -123,6 +135,9 @@
if(g_tiki_init_flags & TIKI_INIT_HID_MASK ) {
Audio::Stream::shutdownGlobal();
}
+ if(g_tiki_init_flags & TIKI_INIT_DEBUG_CONSOLE && console != NULL) {
+ delete console;
+ }
}
void setName( const char *windowName, const char *iconName ) {}
Modified: tiki/src/gl/drawables/console.cpp
===================================================================
--- tiki/src/gl/drawables/console.cpp 2007-11-06 02:14:10 UTC (rev 531)
+++ tiki/src/gl/drawables/console.cpp 2007-11-06 15:54:58 UTC (rev 532)
@@ -519,3 +519,61 @@
}
ansiptr = 0;
}
+
+
+#if TIKI_PLAT == TIKI_NDS
+NDSSubScreenConsole::NDSSubScreenConsole(int cols, int rows) : Console(cols, rows, NULL) {
+ BG_PALETTE_SUB[ ( 16 * 0 ) + 1 ] = RGB15( 0, 0, 0 );
+ BG_PALETTE_SUB[ ( 16 * 1 ) + 1 ] = RGB15( 0, 0, 15 );
+ BG_PALETTE_SUB[ ( 16 * 2 ) + 1 ] = RGB15( 0, 15, 0 );
+ BG_PALETTE_SUB[ ( 16 * 3 ) + 1 ] = RGB15( 0, 15, 15 );
+ BG_PALETTE_SUB[ ( 16 * 4 ) + 1 ] = RGB15( 15, 0, 0 );
+ BG_PALETTE_SUB[ ( 16 * 5 ) + 1 ] = RGB15( 15, 0, 15 );
+ BG_PALETTE_SUB[ ( 16 * 6 ) + 1 ] = RGB15( 15, 15, 0 );
+ BG_PALETTE_SUB[ ( 16 * 7 ) + 1 ] = RGB15( 15, 15, 15 );
+ BG_PALETTE_SUB[ ( 16 * 8 ) + 1 ] = RGB15( 6, 6, 6 );
+ BG_PALETTE_SUB[ ( 16 * 9 ) + 1 ] = RGB15( 0, 0, 31 );
+ BG_PALETTE_SUB[ ( 16 * 10 ) + 1 ] = RGB15( 0, 31, 0 );
+ BG_PALETTE_SUB[ ( 16 * 11 ) + 1 ] = RGB15( 0, 31, 31 );
+ BG_PALETTE_SUB[ ( 16 * 12 ) + 1 ] = RGB15( 31, 0, 0 );
+ BG_PALETTE_SUB[ ( 16 * 13 ) + 1 ] = RGB15( 31, 0, 31 );
+ BG_PALETTE_SUB[ ( 16 * 14 ) + 1 ] = RGB15( 31, 31, 0 );
+ BG_PALETTE_SUB[ ( 16 * 15 ) + 1 ] = RGB15( 31, 31, 31 );
+
+ setANSI(true);
+ setAutoRefresh(true);
+}
+
+// use the following value to ensure the background is visible when rendered
+#define SOLID_FILL 219
+
+// Macro for palette selecting
+#define TILE_PALETTE(n) ((n)<<12)
+
+void NDSSubScreenConsole::draw(ObjType list) {
+ if(list == Trans) {
+ return;
+ }
+ u16 * bg0Map = ( u16 * )SCREEN_BASE_BLOCK_SUB( 0 );
+ u16 * bg1Map = ( u16 * )SCREEN_BASE_BLOCK_SUB( 2 );
+
+ for( u16 y = 0; y < m_rows; y++ ) {
+ for( u16 x = 0; x < m_cols; x++ ) {
+ char fg = m_colorData[ ( y * m_cols ) + x ] & 0x07;
+ if( m_colorData[ ( y * m_cols ) + x ] & HIGH_INTENSITY ) {
+ fg += 8;
+ }
+ char bg = ( m_colorData[ ( y * m_cols ) + x ] >> 8 ) & 0x07;
+
+ if(x < 32) {
+ bg1Map[ ( y * 32 ) + x ] = SOLID_FILL | TILE_PALETTE(bg);
+ bg0Map[ ( y * 32 ) + x ] = m_charData[ ( y * m_cols ) + x ] | TILE_PALETTE(fg);
+ }
+ else {
+ bg1Map[ ( y * 32 ) + ( x - 32 ) + 1024 ] = SOLID_FILL | TILE_PALETTE(bg);
+ bg0Map[ ( y * 32 ) + ( x - 32 ) + 1024 ] = m_charData[ ( y * m_cols ) + x ] | TILE_PALETTE(fg);
+ }
+ }
+ }
+}
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|