OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Local Zaurus Compile Of An Ncurses Application, HELP!!!!!
andresgriego
post Feb 24 2006, 10:44 AM
Post #1





Group: Members
Posts: 48
Joined: 22-January 06
Member No.: 8,972



Greetings!

I am trying to compile a program written in C++, (no STL or Templates), that uses ncurses for the UI. The program was originally written in Windows under Bloodsheds Dev-C++.

Ncurses was supplied using a DEV Package for Bloodshed, called pdcurses2.6.

Well, my application doesn't compile and I think it is because I am not linking to the ncurses library, because most of the errors are undefined reference to ncurses calls :

IE. undefined reference to 'wattr_on'
undefined reference to 'waddch'
etc.

So, for starters, here is my ZGCC.SH file :

export GCC_EXEC_PREFIX=/mnt/cf/.zgcc/lib/gcc-lib/arm-linux/2.95.2/
export COMPILER_PATH=/mnt/cf/.zgcc/bin:/mnt/cf/.zgcc/lib/gcc-lib/arm-linux/2.95.2/
export CPATH=/mnt/cf/.zgcc/
export LIBRARY_PATH=/mnt/cf/.zgcc/lib/:/mnt/cf/.zgcc/lib/gcc-lib/arm-linux/2.95.2/:/lib/:/home/QtPalmtop/lib/
export CPLUS_INCLUDE_PATH=/mnt/cf/.zgcc/g++-3/
PATH=/mnt/cf/.zgcc/bin:$PATH
export PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/cf/.zgcc/lib
export LD_LIBRARY_PATH
TMAKEPATH="/mnt/cf/.zgcc/tmake/lib/sharp-onboard/"
export TMAKEPATH
ln -sf /lib/libc.so.6 /usr/lib/libc.so
ln -sf /lib/libm.so.6 /usr/lib/libm.so
ln -sf /mnt/cf/.zgcc/bin/libstdc++-3-libc6.1-2-2.10.0.so /home/QtPalmtop/lib/libstdc++-libc6.2-2.so.3




Anybody know what's going on?


Thanks,

Andres
Go to the top of the page
 
+Quote Post
andresgriego
post Feb 24 2006, 07:19 PM
Post #2





Group: Members
Posts: 48
Joined: 22-January 06
Member No.: 8,972



I searched google about linking ncurses and found a G++ example. All I needed to do was add '-lncurses' and now it works.

Case closed!
Go to the top of the page
 
+Quote Post
andresgriego
post Feb 27 2006, 12:01 AM
Post #3





Group: Members
Posts: 48
Joined: 22-January 06
Member No.: 8,972



I can't get ncurses in my program to work. I need some help. I don't even know what the problem is anymore. I've only been programming for 2 years too, so bare with me.

I am trying to get my roguelike game running on my Zaurus. It's simple C/C++ game that I wrote in school. Currently, it is using ncurses for the graphicsal user interface, but I was using windoes console before and switched. It will compile with 'g++ -lncurses *.c -o test', and will run with './test', but only my debugging text is printing, not the ncurses portions of the game. My debugging text is printed to the display using standard cout, not ncurses.

Well, maybe ncurses isn't installed on the Z? I found the following package, 'libncurses_5.0_arm.ipk' and installed it but even after a recompile ncurses still doesn't work.

So, I am starting to think maybe it has to do with how I am using ncurses in my code. I hope in posting it someone with ncurses experience can easily recognise anything that I might be doing in error. As a last resort, I might make my Z-port B&W only (couts only) or maybe find an ncurses program that runs on the Zaurus and mimic its method of ncurse programming. But, I'm not conviced entirely that ncurses is working properly on my Z. Hopefully, this can be resolved easily.

Here's my code in its primeval form.

/////////////////////////////////////////////
///// UI.CPP ////////////////////////////
/////////////////////////////////////////////
#include "ui.h"

UI::UI( Dungeon * inWorld )
{
world = inWorld;
initscr();
start_color();
cbreak();
noecho();
// nodelay(0, true);
intrflush(stdscr, false);
keypad(stdscr, true);
curs_set(0);

//if ( !has_colors() ) {
// endwin ();
// fputs ("No colours!", stderr);
// exit (1);
//}

init_pair(1, COLOR_BLACK, COLOR_BLACK);
init_pair(2, COLOR_WHITE, COLOR_BLACK);
init_pair(3, COLOR_RED, COLOR_BLACK);
init_pair(4, COLOR_GREEN, COLOR_BLACK);
init_pair(5, COLOR_BLUE, COLOR_BLACK);
init_pair(6, COLOR_CYAN, COLOR_BLACK);
init_pair(7, COLOR_MAGENTA, COLOR_BLACK);
init_pair(8, COLOR_YELLOW, COLOR_BLACK);
init_pair(9, COLOR_BLACK, COLOR_WHITE); // map colour in use

// Colour test
for(int i = 1;i<=9;i++)
{
attron( COLOR_PAIR(i) );
mvprintw (0, 60+i, "%d", i );
attroff( COLOR_PAIR(i) );
}
for(int i = 1;i<=9;i++)
{
attron( COLOR_PAIR(i)|A_BOLD );
mvprintw (0, 69+i, "%d", i );
attroff( COLOR_PAIR(i)|A_BOLD );
}

// Title test
mvprintw (1, 62, "%s", "Dungeon: Infernal" );

// display & frame initialization & centering of player to frame
display = newwin( DISP_HEIGHT, DISP_WIDTH, 0, 0 );
int pRow = ( world->getPlayer() )->getRow();
int pCol = ( world->getPlayer() )->getCol();
tRow = 0;
tCol = 0;
bRow = DISP_HEIGHT;
bCol = DISP_WIDTH;
centerFrame( UP_KEY );
centerFrame( DOWN_KEY );
centerFrame( LEFT_KEY );
centerFrame( RIGHT_KEY );
}
UI::~UI()
{
erase ();
refresh ();
endwin ();
}
void UI::bindFrame()
{
if( bCol > world->getLevelCols() )
{
bCol = world->getLevelCols();
tCol = world->getLevelCols() - DISP_WIDTH;
}
if( bRow > world->getLevelRows() )
{
bRow = world->getLevelRows();
tRow = world->getLevelRows() - DISP_HEIGHT;
}
if( tRow < 0 )
{
bRow = DISP_HEIGHT;
tRow = 0;
}
if( tCol < 0 )
{
bCol = DISP_WIDTH;
tCol = 0;
}
}
void UI::addMessage( int inNum )
{
// wattron( message, COLOR_PAIR(2) );
// mvwaddch( message, DISP_HEIGHT, 0, inNum );
mvprintw (22, 10, "%d", inNum );
// wattroff( message, COLOR_PAIR(2) );
// wrefresh( message );
}
void UI::refreshPlayWindow()
{
int x, y, frameRow, frameCol;
frameRow = tRow;
frameCol = tCol;
Tile * t;
for (x = 0; x < DISP_HEIGHT; x++)
{
for (y = 0; y < DISP_WIDTH; y++)
{
t = world->getTile( frameRow, frameCol++ );
if( (t->getFlags() & VISITED) == VISITED )
{
if( (t->getFlags() & DUNGEONWALL) == DUNGEONWALL )
{
if( (t->getFlags() & SEEN) == SEEN )
{
// Print 219 white
wattron( display, COLOR_PAIR(2) );
mvwaddch( display, x, y, 219 );
wattroff( display, COLOR_PAIR(2) );
// Later have a BLOODY flag for red
}
else
{
// Print 219 BOLD black
wattron( display, COLOR_PAIR(1)|A_BOLD );
mvwaddch( display, x, y, 219 );
wattroff( display, COLOR_PAIR(1)|A_BOLD );
}
}
else if( (t->getFlags() & PLAYER) == PLAYER )
{
// Print player as 64 for now
wattron( display, COLOR_PAIR(2)|A_BOLD );
mvwaddch( display, x, y, 64 );
wattroff( display, COLOR_PAIR(2)|A_BOLD );
}
else if( (t->getFlags() & OBJECT) == OBJECT )
{
if( (t->getFlags() & SEEN) == SEEN )
{
// Get the object and print icon and colour
wattron( display, COLOR_PAIR(2)|A_BOLD );
mvwaddch( display, x, y, 64 );
wattroff( display, COLOR_PAIR(2)|A_BOLD );
}
else
{
wattron( display, COLOR_PAIR(1)|A_BOLD );
mvwaddch( display, x, y, 64 );
wattroff( display, COLOR_PAIR(1)|A_BOLD );
}
}
else // Is an empty floor tile
{
// VISITED, SEEN, later BLOODY?
if( (t->getFlags() & SEEN) == SEEN )
{
if( (t->getFlags() & DIRTFLOOR) == DIRTFLOOR )
{
// Print 219 white
wattron( display, COLOR_PAIR(8) );
mvwaddch( display, x, y, 250 );
wattroff( display, COLOR_PAIR(8) );
}
else if( (t->getFlags() & STONEFLOOR) == STONEFLOOR )
{
// Print 219 white
wattron( display, COLOR_PAIR(2)|A_BOLD );
mvwaddch( display, x, y, 250 );
wattroff( display, COLOR_PAIR(2)|A_BOLD );
}
else
{
// Print 219 white
wattron( display, COLOR_PAIR(1)|A_BOLD );
mvwaddch( display, x, y, 250 );
wattroff( display, COLOR_PAIR(1)|A_BOLD );
}
// Later have a BLOODY flag for red
// Lighting effect
// * have a range check, player x y - tile x y,
// * if within 3, light up as white, else grey
//
}
else
{
// Print 219 jet black
wattron( display, COLOR_PAIR(1) );
mvwaddch( display, x, y, 32 );
wattroff( display, COLOR_PAIR(1) );
}
}
}
else
{
wattron( display, COLOR_PAIR(1) );
mvwaddch( display, x, y, 32 );
wattroff( display, COLOR_PAIR(1) );
}
//this erases what FOV does, so it can done again
t->setFlag(-SEEN);
}
frameRow++;
frameCol=tCol;
}
}
void UI::centerFrame( int key )
{
// decreasing far-enough will not move display with player
int farEnoughRow = ((DISP_HEIGHT) / 2);
int farEnoughCol = (DISP_WIDTH) / 2;
int pRow = ( world->getPlayer() )->getRow();
int pCol = ( world->getPlayer() )->getCol();
tCol = pCol - farEnoughCol;
bCol = pCol + farEnoughCol;
tRow = pRow - farEnoughRow;
bRow = pRow+2 + farEnoughRow;
bindFrame();
return;
}
void UI::getInput()
{
int c, r, a;
bool dirty;
while ( (a=getch()) != KEY_F(10) ) {
mvprintw (3, 62, "%s", " ");
mvprintw (4, 62, "%s", " ");
mvprintw (5, 62, "%s", " ");
mvprintw (6, 62, "%s", " ");
mvprintw (7, 62, "%s", " ");
mvprintw (8, 62, "%s", " ");

dirty = false;
switch( a )
{
case HOME_NUMPAD: //NW KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()-1,
( world->getPlayer() )->getCol()-1, 0 );
break;
}
case UP_NUMPAD: //N KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()-1,
( world->getPlayer() )->getCol(), 0 );
break;
}
case UP_KEY: //N KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()-1,
( world->getPlayer() )->getCol(), 0 );
break;
}
case PGUP_NUMPAD: //NE KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()-1,
( world->getPlayer() )->getCol()+1, 0 );
break;
}
case LEFT_NUMPAD: //W KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow(),
( world->getPlayer() )->getCol()-1, 0 );
break;
}
case LEFT_KEY: //W KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow(),
( world->getPlayer() )->getCol()-1, 0 );
break;
}
case RIGHT_NUMPAD: //E KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow(),
( world->getPlayer() )->getCol()+1, 0 );
break;
}
case RIGHT_KEY: //E KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow(),
( world->getPlayer() )->getCol()+1, 0 );
break;
}
case END_NUMPAD: //SW KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()+1,
( world->getPlayer() )->getCol()-1, 0 );
break;
}
case DOWN_NUMPAD: //S KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()+1,
( world->getPlayer() )->getCol(), 0 );
break;
}
case DOWN_KEY: //S KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()+1,
( world->getPlayer() )->getCol(), 0 );
break;
}
case PGDN_NUMPAD: //SE KEY_PAD
{
dirty = world->movePlayer( ( world->getPlayer() )->getRow()+1,
( world->getPlayer() )->getCol()+1, 0 );
break;
}
case CENTER_NUMPAD: //CENTER KEY_PAD
{
centerFrame( UP_KEY );
centerFrame( DOWN_KEY );
centerFrame( LEFT_KEY );
centerFrame( RIGHT_KEY );
dirty = true;
break;
}
case M_KEY: // tile averaged-centered map
{
int frameSize = 4;
generatePlayerMap( frameSize );
wrefresh( display );
while( getch() == M_KEY )
{
frameSize = frameSize * 2;
generatePlayerMap( frameSize );
wrefresh( display );
if( frameSize == 32 )
{
dirty = true;
world->movePlayer( ( world->getPlayer() )->getRow(),( world->getPlayer() )->getCol(), 0 );
break;
}
}
dirty = true;
world->movePlayer( ( world->getPlayer() )->getRow(),( world->getPlayer() )->getCol(), 0 );
break;
}
}// end switch
int pRow = (world->getPlayer())->getRow();
mvprintw (4, 62, "Calc bRow %d", ((pRow +2) +12) );
mvprintw (3, 62, "Calc tRow %d", ((pRow ) -12) );
mvprintw (5, 63, "tR %d", tRow );
mvprintw (7, 63, "tC %d", tCol );
mvprintw (6, 63, "bR %d", bRow );
mvprintw (8, 63, "bC %d", bCol );

if( dirty ) centerFrame( a );
if( dirty ) refreshPlayWindow();
if( dirty ) refreshDisplay();
} // end while
}

void UI::generatePlayerMap( int frSize )
{
int frRow = (world->getPlayer())->getRow();
int frCol = (world->getPlayer())->getCol();
while( frRow % frSize != 0 )
{
frRow = frRow - 1;
}
while( frCol % frSize != 0 )
{
frCol = frCol - 1;
}
int row = frRow - ((DISP_HEIGHT)/2)*frSize;
int col = frCol - ((DISP_WIDTH)/2)*frSize;
int walls;
bool seen;
Tile * t;
for (int x = 0; x < DISP_HEIGHT; x++)
{
for (int y = 0; y < DISP_WIDTH; y++)
{
walls = 0;
seen = false;
for (int r = 0; r < frSize; r++)
{
for (int c = 0; c < frSize; c++)
{
if( (world->getLevel(0))->inBounds( row+r, col+c ) )
{
t = world->getTile( row+r, col+c );
if( (t->getFlags()&IMPASSABLE) == IMPASSABLE )
walls++;
if( (t->getFlags()&PLAYER) == PLAYER )
walls+=10000;
if( (t->getFlags()&VISITED) == VISITED )
seen = true;
}
}
}
if( seen )
{
if( walls >= 10000 )
{
wattron( display, COLOR_PAIR(1)|A_REVERSE );
mvwaddch( display, x, y, 64 );
wattroff( display, COLOR_PAIR(1)|A_REVERSE );
}
else if( walls == (16) )
{
wattron( display, COLOR_PAIR(9) );
mvwaddch( display, x, y, 32 );
wattroff( display, COLOR_PAIR(9) );
}
else if(walls > (int)(((double)(16))*(.75)))
{
wattron( display, COLOR_PAIR(9) );
mvwaddch( display, x, y, 176 );
wattroff( display, COLOR_PAIR(9) );
}
else if(walls > (int)(((double)(16))*(.5)))
{
wattron( display, COLOR_PAIR(9) );
mvwaddch( display, x, y, 177 );
wattroff( display, COLOR_PAIR(9) );
}
else if(walls > (int)(((double)(16))*(.25)))
{
wattron( display, COLOR_PAIR(9) );
mvwaddch( display, x, y, 178 );
wattroff( display, COLOR_PAIR(9) );
}
else
{
wattron( display, COLOR_PAIR(0) );
mvwaddch( display, x, y, 219 );
wattroff( display, COLOR_PAIR(0) );
}
}
else // not seen by player
{
wattron( display, COLOR_PAIR(1) );
mvwaddch( display, x, y, 219 );
wattroff( display, COLOR_PAIR(1) );
}
col += frSize;
}
col = frCol - (DISP_WIDTH/2)*frSize;
row += frSize;
}
}

void UI::refreshDisplay()
{
wrefresh( display );
}
/////////////////////////////////////////////
///// END UI.CPP ///////////////////////
/////////////////////////////////////////////





Please, if you know ncurses and Zs, and you like helping people, help me at this dire hour.

Andres
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd October 2014 - 09:13 AM