Sunday, February 18, 2007

building the reel strip

building the reel strip.

some thing about video slot machine.
there are two things that would have to decided do you have game that can be resized on the fly?
that is operator can enter into configuration console and switch
from 640x480 to 800x600 or 1024x768?
that would be the ideal.

but for this demo probably not.
everything should be set to 800x600.

things to do start using sprites for everything.

move sprite classes into main prog.

start putting anything related to positions into positions.h



cache + vector (vertical/horizontal) = sprite/image

cache.cellsize(x,y)

check when adding the cells that these apre part of compile value

create build_strip
sprite.buildstrip(vector,horiztal/vetical,alpha)

build the strip. if the strip is has the same nature as before use
this dont recreate because this strip gets built over and over

fix spline code.



check to see if images have the correct depth and size properties
but make algorith simple that is if your system ask for 128 pixel
images do so but make this explicit


class wrapped around sdl_surface

Monday, February 12, 2007

xorg configuration for make-live cd

first startx looks like this :
#!/bin/sh

# $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $

userclientrc=$HOME/.xinitrc
sysclientrc=/etc/X11/xinit/xinitrc


userserverrc=$HOME/.xserverrc
sysserverrc=/etc/X11/xinit/xserverrc
defaultclient=xterm # this is what is launching xterm
defaultserver=/usr/bin/X
defaultclientargs=""
defaultserverargs=""
clientargs=""
serverargs=""

if [ -f $userclientrc ]; then
defaultclientargs=$userclientrc
elif [ -f $sysclientrc ]; then
defaultclientargs=$sysclientrc

fi
if [ -f $userserverrc ]; then
defaultserverargs=$userserverrc
elif [ -f $sysserverrc ]; then
defaultserverargs=$sysserverrc
fi

whoseargs="client"
while [ x"$1" != x ]; do
case "$1" in
# '' required to prevent cpp from treating "/*" as a C comment.
/''*|\./''*)
if [ "$whoseargs" = "client" ]; then
if [ x"$clientargs" = x ]; then
client="$1"
else
clientargs="$clientargs $1"
fi
else
if [ x"$serverargs" = x ]; then
server="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
--)
whoseargs="server"
;;
*)
if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
# display must be the FIRST server argument
if [ x"$serverargs" = x ] && \
expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
display="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
esac
shift
done

# process client arguments
if [ x"$client" = x ]; then
# if no client arguments either, use rc file instead
if [ x"$clientargs" = x ]; then
client="$defaultclientargs"
else
client=$defaultclient
fi
fi

# process server arguments
if [ x"$server" = x ]; then
# if no server arguments or display either, use rc file instead
if [ x"$serverargs" = x -a x"$display" = x ]; then
server="$defaultserverargs"
else
server=$defaultserver
fi
fi

if [ x"$XAUTHORITY" = x ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi

removelist=


# set up default Xauth info for this machine

# check for GNU hostname
if hostname --version > /dev/null 2>&1; then
if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
hostname=`hostname -f`
fi
fi

if [ -z "$hostname" ]; then
hostname=`hostname`
fi

authdisplay=${display:-:0}
mcookie=`/usr/bin/mcookie`
dummy=0

# create a file with auth information for the server. ':0' is a dummy.
xserverauthfile=$HOME/.serverauth.$$
xauth -q -f $xserverauthfile << EOF
add :$dummy . $mcookie
EOF
serverargs=${serverargs}" -auth "${xserverauthfile}

# now add the same credentials to the client authority file
# if '$displayname' already exists don't overwrite it as another
# server man need it. Add them to the '$xserverauthfile' instead.
for displayname in $authdisplay $hostname$authdisplay; do
authcookie=`xauth list "$displayname" \
| sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
if [ "z${authcookie}" = "z" ] ; then
xauth -q << EOF
add $displayname . $mcookie
EOF
removelist="$displayname $removelist"
else
dummy=$(($dummy+1));
xauth -q -f $xserverauthfile << EOF
add :$dummy . $authcookie
EOF
fi
done
xinit $client $clientargs -- $server $display $serverargs

if [ x"$removelist" != x ]; then
xauth remove $removelist
fi
if [ x"$xserverauthfile" != x ]; then
rm -f $xserverauthfile
fi

if command -v deallocvt > /dev/null 2>&1; then
deallocvt
fi

Thursday, February 08, 2007

make-live live cd project

the project is located at http://wiki.debian.org/DebianLive
first the project is the best of what is out there and produces
the smallest image all the other seem to want to into the direction
of knoppix. that is produce a application heavy cd. i dont need this.

First if you dont install apt-cacher your builds will take forever.
edit the file /etc/default/apt-cacher
change the entry AUTOSTART=0 to AUTOSTART=1
then start the server by
/etc/init.d/apt-cacher start
when that is done do the folllowin
edit the /etc/make-live.conf file:
LIVE_MIRROR="http://localhost:3142/ftp.debian.org"

things in the chroot that need to edit
/etc/apt/sources.list seems to have the settings for apt-cacher
this needs to be removed if you need to mod the chroot

making the bootsplash rle file
you will net the netpbm software package and ppmtolss16
and the gimp.
note, that ppmtolss16 is installed with the debian syslinux package.

1. create a new splash.png file using gimp 640x320 resolution and save it
as splash-isolinux.png

2. Click menu: image > mode > indexed > maximum number of colors > set to 16 > ok

3. Click menu: file > save as > file type > PNG image > save (splash-isolinux.png)

In a console:

4. convert it to "pnm" by using "pngtopnm"
   % pngtopnm splash.png > splash.pnm

5. convert it to "rle" by using "ppmtolss16"
% ppmtolss16 <>splash-isolinux.rle


see the document http://www.geexbox.org/wiki/index.php/How_to_create_a_theme
for decent explanation of this.




goals for this project:
1) brand the bootup screen for a specific splash rle file.
2) simplify the boot up options.
3) make sure that if xorg dies or the program crash xorg is restarted and will restart
the game application or game launcher application.
4) be able to add a deb package of the gaming software to the system, possible without
a complete rebuild of the underlying cdrom image.
5) slim down every thing.
6) the xorg resolution is way to high i needs to be set at 800x600
--------------------------------------------------------------------------------------
1) part of 1 is done with splash.rle file mentioned above.
2) this means altering the file isolinux.cfg this file is included in the --template
option of the make-live prog.
3) the file casper-login script does this:
USERNAME=casper
[ -f /etc/casper.conf ] && . /etc/casper.conf
exec su -l -c /usr/bin/startx $USERNAME
#exec /bin/login -f $USERNAME
4) this means know how to build deb packages. this is big one and i dont get know
how to do this. a possible way to start would be to take a small deb prog and modify
to my uses.
5) slimming means a couple of things. first running a script inside the chroot. this is
a good thing as you are going to be removing files and the worst that might happen is the
chroot will get trashed and not the outer system. the slimming script
will be included with directory designated with the --include-chroot and be run with --hook
option
6) xorg resolution is is probably last reall big task slimming down i will attack piecmeal

make-live has a nice option --

Friday, December 08, 2006

books of note about states

Pattern Hatching by John Vlisside discusses
the Mememento pattern on pages 102 to about 106+

How to Design Programs
An introduction to Programming and Computing
Matthias Felleisen (scheme language)

Tuesday, December 05, 2006

matt buckland : ai book excerpts

Buckland, Mat.
Programming game AI by example / by Mat Buckland.
p. cm.
Includes index.
ISBN 1-55622-078-2 (pbk.)
1. Computer games — Design. 2. Computer games — Programming. 3.Computer
graphics. I. Title.
QA76.76.C672B85 2004
794.8'1526 — dc22

class State
{
public:
virtual void Execute (Troll* troll) = 0;
};

Now imagine a Troll class that has member variables for attributes such as health, anger, stamina, etc., and an interface allowing a client to query and adjust those values. A Troll can be given the functionality of a finite state machine by adding a pointer to an instance of a derived object of the State class, and a method permitting a client to change the instance the pointer is pointing to.

class Troll
{
/* ATTRIBUTES OMITTED */

State* m_pCurrentState;

public:

/* INTERFACE TO ATTRIBUTES OMITTED */

void Update()
{
m_pCurrentState->Execute(this);
}

void ChangeState(const State* pNewState)
{
delete m_pCurrentState;
m_pCurrentState = pNewState;
}
};

Wednesday, November 22, 2006

how to build qt3 for win32

install the cvs client from http://www.wincvs.org/ its smaller than
the one from cygwin.

then do the following

http://qtwin.sourceforge.net/qt3-win32/compile-net.php

Requirements

* Windows 2000 or XP
* a cvs client (for example from http://www.cvsnt.org), when using the kde cvs server
* Visual Studio .NET or .NET 2003

Get the Q... sources

* by downloading a Q... source snapshot from the KDE-Cygwin snapshot area
* or from the cvs repository

first connect to the cvs server

c:\source> cvs -d :pserver:anonymous@qtwin.cvs.sourceforge.net:/cvsroot/qtwin login

enter empty password
then checkout the sources with

c:\source> cvs -z3 -d :pserver:anonymous@qtwin.cvs.sourceforge.net:/cvsroot/qtwin co -r QT_WIN32_3_3_BRANCH qt-3

Compiling Qt with command line tools

* Open a cmd shell
* Setup your compiler environment (please adjust the path to your needs)

c:\source> "c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\bin\vcvars32.bat"

* Setup Q.. environment

c:\source> set QTDIR=< qt3 source root>
c:\source> set PATH=%QTDIR%\bin;%PATH%
c:\source> set QMAKESPEC=win32-msvc.net

* Configure and build the source
The script first creates link_includes.exe and configure.exe which are needed for bootstrap the build process. link_includes copies all relevant Qt-headers into the include-directory. configure.exe is the replacement for the ./configure-script unter Unix/Linux. After that, qmake.exe is build and the compilation gets started.

c:\source> cd < qt3 source root >
c:\source\qt-3> configure.bat [-fast] [-verbose]

configure knows some of the parameters of the x11 release configure script like -fast or -verbose.
For a full list see bin\configure.exe -help.

This should build the whole Qt release. If it breaks you can restart compiling with

c:\source\qt-3> nmake [< target >]

for a list of all available targets see the toplevel Makefile
* Start Q.. applications

c:\source\qt-3> designer
c:\source\qt-3> assistant
c:\source\qt-3> linguist
c:\source\qt-3> cd tutorial\t1
c:\source\qt-3\tutorial\t1> t1

Monday, November 20, 2006

timegettime and unix gettimeofday

here is what i used to replace windows timegettime

from advance progamming in the unix environment page 173

the gettimeofday function provides greater resolution (up to
a microsecond) than the time function.

#include

int gettimeofday(struct timevale *restrcited tp, void *restrict tzp);

here is my one off.

Uint32 ticks;
struct timeval now;
gettimeofday(&now, NULL);
ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
return(ticks);

i also found some helpfull information by looking at SDL library
look at the source file src/timer/unix/SDL_systimer.c

#ifdef HAVE_CLOCK_GETTIME
static struct timespec start;
#else
static struct timeval start;
#error "i do have it"
#endif /* HAVE_CLOCK_GETTIME */


void SDL_StartTicks(void)
{
/* Set first ticks value */
#if HAVE_CLOCK_GETTIME
clock_gettime(CLOCK_MONOTONIC,&start);
error "clock_gettime"
#else
gettimeofday(&start, NULL);
#error "gettimeofday"
#endif
}

Uint32 SDL_GetTicks (void)
{
#if HAVE_CLOCK_GETTIME
Uint32 ticks;
struct timespec now;
clock_gettime(CLOCK_MONOTONIC,&now);
ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_nsec-start.tv_nsec)/1000000;
return(ticks);
#else
Uint32 ticks;
struct timeval now;
gettimeofday(&now, NULL);
ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
return(ticks);
#endif
}

Sunday, November 19, 2006

interesting but not useful

the following came from http://home.earthlink.net/~huston2/dp/AdapterDemosCpp
but its limited can only work on a void function.

// Purpose. Adapter design pattern (External Polymorphism demo)

// 1. Specify the new desired interface
// 2. Design a "wrapper" class that can "impedance match" the old to the new
// 3. The client uses (is coupled to) the new interface
// 4. The adapter/wrapper "maps" to the legacy implementation

#include

class ExecuteInterface { public: // 1. Specify the new i/f
virtual ~ExecuteInterface() { }
virtual void execute() = 0;
};

template // 2. Design a "wrapper" or
class ExecuteAdapter : public ExecuteInterface { // "adapter" class
public:
ExecuteAdapter( TYPE* o, void (TYPE::*m)() ) { object = o; method =m; }
~ExecuteAdapter() { delete object; }
// 4. The adapter/wrapper "maps" the new to the legacy implementation
void execute() /* the new */ { (object->*method)(); }
private:
TYPE* object; // ptr-to-object attribute
void (TYPE::*method)(); /* the old */ // ptr-to-member-function
}; // attribute

// The old: three totally incompatible classes // no common base class,
class Fea { public: // no hope of polymorphism
~Fea() { cout << "Fea::dtor" << endl; }
void doThis() { cout << "Fea::doThis()" << endl; }
};

class Feye { public:
~Feye() { cout << "Feye::dtor" << endl; }
void doThat() { cout << "Feye::doThat()" << endl; }
};

class Pheau { public:
~Pheau() { cout << "Pheau::dtor" << endl; }
void doTheOther() { cout << "Pheau::doTheOther()" << endl; }
};

/* the new is returned */ ExecuteInterface** initialize() {
ExecuteInterface** array = new ExecuteInterface*[3]; /* the old is below */
array[0] = new ExecuteAdapter( new Fea(), &Fea::doThis );
array[1] = new ExecuteAdapter( new Feye(), &Feye::doThat );
array[2] = new ExecuteAdapter( new Pheau(), &Pheau::doTheOther );
return array;
}

void main( void ) {
ExecuteInterface** objects = initialize();

for (int i=0; i < 3; i++) objects[i]->execute(); // 3. Client uses the new
// (polymporphism)
for (i=0; i < 3; i++) delete objects[i];
delete objects;
}

// Fea::doThis()
// Feye::doThat()
// Pheau::doTheOther()
// Fea::dtor
// Feye::dtor
// Pheau::dtor

Friday, November 17, 2006

java on debian

the following came from: http://www.crazysquirrel.com/computing/debian/java.jspx
Quick Guide

If you are fairly confident and don't want to read the whole document the following summary should probably be enought to get java working on your system. Lines 1 and 3 are preformed as root line 2 as a standard user.

apt-get install java-package
fakeroot make-jpkg .bin
dpkg -i .deb

Step 1 - Get the SunJVM

You could go with other JVM's like Blackdown or Kaffe if you want. I am not saying they aren't worth looking at but if you are serious about developing with Java you basically have no choice but to go with the Sun JVM. They provide it for free (as long as you sign you life away) so you might as well use the best.

You can get the latest Sun JVM from here http://java.sun.com/
Step 2 - Install the Required Builder Package

Installing Java on Debian is not the simplest thing in the world but fortunatly there is a package that will do most of the work for you (assuming it works). That heaven sent package is java-pacakge which can be installed with:

apt-get -u install java-package

Make sure that your repository is fully upto date before installing this package or you might run into problems installing the latest JVM. You also need fakeroot if you don't have it.
Step 3 - Create the .deb Package File

You have to perform this step as a non-root user so I suggest using your own account. Create a temporary directory and copy the java .bin installer file into it. then run the command:

fakeroot make-jpkg jdk-1_5_0-linux-i586.bin

changing the name of the java .bin package if you need to. You may see a few warnings while the package is being created (and it takes some time to actually create it - about 2 minutes). If you see a message at the end saying the package was created then the warnings are not a problem. The message will probably look something like this:

The Debian package has been created in the current
directory. You can install the package as root (e.g.
dpkg -i sun-j2sdk1.5_1.5.0+update00_i386.deb).

Step 4 - Install the Java .deb Package

You need to be root to perform this step so swtich now. Then execute the following command:

dpkg -i sun-j2sdk1.5_1.5.0+update00_i386.deb

Of course you need to specify the correct package name if yours doesn't match mine. You can find out what the package name is from looking at the success message.
Step 5 - Check it Works

This should be the simplest step. Just execute the command:

java -version

as both root and another user to make sure everything is installed correctly. You should see output not a million miles different to that shown below.

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

Tuesday, November 14, 2006

subversion.

/etc/rcS.d
lrwxrwxrwx 1 root root 20 2006-11-14 12:58 S80svnserve -> /etc/init.d/svnserve

chown all files in the repos to svnserve user
then chmod-ed the db files read/write

configured the file
[general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = write
auth-access = write

Monday, November 13, 2006

state machine fun!

BeginStateMachine

OnMsg(MSG_PrintError)
setState(STATE_Down);

State(STATE_Initialize)
OnEnter
if (paper_count <= 10)
setState(STATE_PaperLow);
else if (paper_count <= 0)
setState(STATE_PaperOut);
else
setState(STATE_Ready);

State(STATE_Ready)
OnEnter
// let device know
OnMsg(MSG_Print)
// print
setState(STATE_Print);

State(STATE_Print)
OnEnter
// let device know
// start printing
OnUpdate
// loop till printing is done
// maybe communicate with device to get progress

if (printing is done)
{
// decrement paper count
if (paper_count <= 10)
setState(STATE_PaperLow);
else if (paper_count <= 0)
setState(STATE_PaperOut);
}
OnExit
// do clean up for/with device

State(STATE_PaperLow)
OnEnter
// let device know
OnMsg(MSG_Print)
// print
setState(STATE_Print);

State(STATE_PaperOut)
OnEnter
// let device know
OnMsg(MSG_Print)
// return error message
setState(STATE_Down);

State(STATE_Down)
OnEnter
// let device know
OnMsg(MSG_Print)
// return error message

EndStateMachine

Thursday, November 09, 2006

ndiswrapper

ndiswrapper on Debian Sarge without having to compile anything
Written by MikeZila - 2005-06-13 20:40
Originally, I was trying to get the ndiswrapper source to compile with the stock Debian Sarge kernel. This didn't work because the kernel headers were absent. Even after installing them, compile failed with obscure errors. Getting the source didn't help either. Still no dice. I read around places and found that the kernel that comes with Debian Sarge has problems with ndiswrapper under certain situations. I made the safe assumption that I somehow had one of these "situations", and set out to get a new kernel.

You need a new kernel, but not to fear. The almighty apt-get has you covered from start to finish.

From this point on are instructions on how to get a new kernel and then get ndiswrapper playing ball with it. If you're unwilling to update your kernel, you can stop reading now. Please note that this kernel upgrade is very easy. There is no compile process and the whole deal takes about fifteen minutes; it isn't the usual kernel compile rigmarole. Also, it's totally safe to do the following. When the new kernel is installed, it makes an additional entry in your boot loader, it doesn't replace your current one. You're not stuck if it doesn't work.

Before we start, you should know that this guide assumes you're using a 686 CPU. Something like a P4, a P4 based Celeron, Pentium3, a PentiumPro, or similar. AMD Athlon people should be okay as well. Those with 64bit processors can try, but I have no idea if it will work. If your using a 586 or older, just replace every 686 in this guide with a 386. Everything will still work the same.

Ready? Let's do it.

First, you need to grab a new kernel. One is compiled and waiting for you in the apt repository. Do...

apt-get install kernel-image-2.6.8-2-686

It will download the deb containing the kernel and work it's magic. Before you know it a new kernel will be all setup and your boot loader will be configured with a new entry to boot it. Cool, huh? Your previous kernel and boot loader entry are preserved so you can boot it anytime you like.

Reboot and choose your new kernel at the bootmenu.

Now we'll grab the wireless-tools package. This will let us setup our card once it's working. You guessed it, apt-get has us covered.


apt-get install wireless-tools


The wireless tools will be downloaded and installed. You can check that they are by typing "iwconfig" and seeing if it gives you any output. It won't tell us anything good now, but it'll come in very handy later. Now we need to grab the ndiswrapper itself. Do...


apt-get install ndiswrapper-modules-2.6.8-2-686


If it suggests you install additional packages (it should suggest ndiswrapper-utils), type "Y" and hit enter to agree. It will download and install the packages. When it's done, try...

ndiswrapper -l

You should get a notice saying that no drivers are installed. This is normal, as we haven't yet given it the WindowsXP drivers to wrap. If you get a command not found error, then the ndiswrapper-utils package either wasn't suggested during the ndiswrapper-module install, or it failed for some reason. If it wasn't suggested (it was suggested to me), you can just get it yourself with...


apt-get install ndiswrapper-utils


Now try the "ndiswrapper -l" again. You should get the no drivers notice.

Now it's time to fix that no drivers notice. Get a hold of the WindowsXP drivers for your card. Don't use drivers included on the CD that came with your card, they won't work 99% of the time, and sometimes they cause kernel panics or other nasty things. Best to play it safe and grab the drivers known to work with your card. Go to the official ndiswrapper card list located here. Once you've got them, extract the driver files someplace (it doesn't matter where) and do the following in that directory. You'll need to run a...


ndiswrapper -i DRIVER.inf


..for a each .inf file required by your card. Usually you only need one. Your card's entry in the ndiswrapper card listing will tell you if you need more than one. I happen to need three. Once you have all the .inf files you need installed, you should do a...


ndiswrapper -l


...and check the output to make sure you see something like:


Installed ndis drivers:
lsbcmnds driver present
lsipnds driver present, hardware present
wmp11nds driver present


Your drivers will be have different names, and you may have more or less drivers installed. The important thing is that one of them says "hardware present". If you see a "hardware not present" you probably have bad drivers. If you see "cant see hardware", then you don't have wireless-tools. You should have downloaded them earlier in this guide, but if for some reason you didn't, just...


apt-get install wireless-tools


...and try "ndiswrapper -l" again. If all is well, move on.

It's time to load the module. Well, sorta. Remember installing the ndiswrapper-module package? It didn't actually install a module, but it did give us an ndiswrapper.ko, and that will work just as well.

You'll do this the old-school way...


insmod lib/modules/`uname -r`/misc/ndiswrapper.ko


The " ` " marks around "uname -r" aren't the " ' " next to your enter key, they're next to the " 1 " key, at the top left.

Doing this command probably won't give you any output, but it will give you the functionality of the ndiswrapper module. Now try...


iwconfig


You should now have an entry called "wlan0", and a bunch of information about it. If you see something like this...


wlan0 IEEE 802.11b ESSID:off/any
Mode:Managed Frequency:2.437 GHz Access Point: 00:40:05:C5:4E:03
Bit Rate:11 Mb/s Tx-Power:17 dBm
RTS thr:2347 B Fragment thr:2346 B
Encryption key:off
Power Management:off
Link Quality:100/100 Signal level:-69 dBm Noise level:-256 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:54 Invalid misc:512 Missed beacon:0


...then you're good to go. You may have additional entires without wireless extensions in the output, but this is normal.

Congratulations! Your card is up and running in Linux! Now to get it configured so you can be on your way. It's is simple enough.

At this point I recommend you turn off the ethernet connection. It can cause problems with the wlan0 interface if it's running when you try to configure the wireless card. Do...


ifdown eth0


If you've been using an ethernet connection to download the packages we've been installing, it will be lost. If for any reason you want it back, just...


ifup eth0
dhclient eth0


...and you'll be back to normal.

We'll get your new wireless running post haste. First we should make sure your AP (your wireless router or access point) is configured to have open access. Turn off WEP/WAP in your router or AP's configuration for the time being. Now let's set your SSID on the wireless card. It's simple. Do...


iwconfig wlan0 essid yourssidgoeshere


That will set the ssid. You won't get any feedback, but this is normal. Now run "iwconfig" again and check the ESSID in the top right of the block of information about your wireless card. It should no longer say "off/any", but the SSID you configured it to use. If it doesn't, try the command a few more times. Move your computer a little, do whatever you would normally do to get better signal. If "off/any" changed to your ssid, then you're good to go.

You don't have to bring up the wlan0 interface, but you do need to get an IP. Do...


dhclient wlan0


A bunch of stuff will go by, and at the end you'll either have errors, a long wait, or an IP on your network. If you get errors, then obviously something is wrong. Check the error and your system logs and hunt down the wrench in the works. If you get a long wait, your card is probably not talking to the router like it should, look in your logs and see if you can find out what's holding things up, it could just be that you aren't getting good signal. If you get no errors, and things finish in a reasonable time, you should be done. Open up a web browser and see if you can get to Google. If it works, then you're cooking with lasers, and everything is kosher. Congratulations!

If you want to make bringing up your wireless easy (this guide doesn't configure the ndiswrapper in a way that can be auto-loaded via normal means) dump the following in a text file and name it "loadwireless.sh". (really you can name it anything you want, just keep the .sh at the end) Make sure to put your ssid in place of "yourssidgoeshere"


#!/bin/sh
ifdown eth0
insmod /lib/modules/`uname -r`/misc/ndiswrapper.ko
sleep 2
iwconfig wlan0 essid yourssidgoeshere
sleep 2
iwconfig


chmod it executable and run it as root to bring your wireless up. If after several entries of "iwconfig" you still don't get your SSID set, try entering the config command again manually. Your card may not have started up in time to catch the command in the script. Just enter...


iwconfig wlan0 essid yourssidgoeshere


I'm sure there's a way to get this to be run automatically, but I'm done with my major accomplishments for the day. I'm cool just running this as root once the system is up and running. You don't have to be exclusively logged in as root for it to work, a root console in a normal user session will do fine.

That's all, folks. Post problems if you have them and I'll try to help you out. I'll do my very best, but keep in mind that I'm not a genius at this, I just happened to discover a correct way via experimentation and research. Like I said, ask and I'll try to help. I'm a nice guy, so don't be afraid to ask, no matter how small or large the question.

Thanks for reading my guide!
previous

up
Ndiswrapper in Fedora Core 5
Bookmark this post with:
delicious | digg | reddit | furl | google | yahoo
61 comments | Discuss Article | printer-friendly version
By martinj on Thu, 2005-06-16 11:58
This crashes my PC. I am running IPW2100



I do apt-get install ndiswrapper-modules-2.6.8-2-386



apt-get install ndiswrapper-utils

ndiswrapper -i w70n51.inf

ndiswrapper -l and it says the hardware is found

I do

apt-get install wireless-tools

ok

I do cd // and

insmod lib/modules/`uname -r`/misc/ndiswrapper.ko

and then it crashes
reply

belkin card

Configuring Belkin F5D6020 (Version 3.0) 802.11b wireless PCMCIA card on MandrakeLinux 10.1
Submitted by akkumar on Thu, 12/16/2004 - 05:15. General Interest | How-to | Quick Tips & Newbies | Distributions

I had bought a Belkin Wireless PCMCIA Card – F5D6020 (Version 3.0) recently and wanted to configure the same in my favourite Linux distribution.

I downloaded and installed the MandrakeLinux 10.1 distribution released recently to the public (on December 6 2004 ). To get the latest version of MandrakeLinux visit the home page of MandrakeLinux, here. If you have a DVD writer, go for the DVD image. It would be much easier to maintain instead of playing around with the 3 CDs .

The installation was a breeze with MandrakeLinux 10.1 identifying my PCMCIA card attached to my laptop while installing the system. It did not load the right module corresponding to the PCMCIA card, though. So I had to find the right module to get that done. I did not get the Linux device driver from the manufacturer, but I did have the Windows driver.

Thanks to the ndiswrapper project at sourceforge, I was able to use the Windows device driver (already installed on my dual-boot system) for my Linux distribution too. I downloaded the latest source code of ndiswrapper from its sourceforge project page . The version that I had downloaded was 0.12 released on November 24 2004. The project documentation available at the site was pretty much clear to get things done.
1. Compiling ndiswrapper:

To compile ndiswrapper, you would need the source code of the kernel. By default, the kernel source was not installed. I installed the kernel source corresponding to the 2.6 tree (kernel-source-2.6.8.1-12mdk, to be exact) .

[akkumar@localhost tmp]$ pwd
/home/akkumar/tmp
[akkumar@localhost tmp]$ tar xzvf ndiswrapper-0.12.tar.gz
[akkumar@localhost tmp]$ cd ndiswrapper-0.12
[akkumar@localhost ndiswrapper-0.12]$ make install

This would compile the ndiswrapper utility and compile the module to be loaded later to identify the device.
2. Copying the Windows device drivers:

By default, MandrakeLinux identifies the NTFS parititions on your hard disk used by Windows. I am running Windows XP, and I had already configured my wireless card for the operating system. The windows device driver corresponds to two files, namely an INF file and a SYS file. Search for the following files in your Windows directory. ( C:\Windows\System ) .

* Bel6020.inf
* Bel6020.sys

Copy the two files to a directory of your choice in linux, say /home/akkumar/tmp .

Now go ahead to configure this Windows device driver using ndiswrapper as follows.

[akkumar@localhost tmp]$ ndiswrapper-0.12/utils/ndiswrapper -i Bel6020.inf

This would install the device drivers. To check the status of your device drivers, invoke the following command.

[akkumar@localhost tmp]$ ndiswrapper-0.12/utils/ndiswrapper -l

You should see something like this:

Installed ndis drivers
bel6020 hardware present
3. Load Modules:

To load the module, invoke the following command.

[akkumar@localhost tmp]$ modprobe ndiswrapper

Use the 'dmesg' command to view the kernel log to see if everything works fine till now. Refer to this documentation on the site to double-check the same.
Assuming everything goes fine, all that needs to be done is to specify a wireless SSID to connect to.
4. Configuring the wireless interface:

If you know your wireless SSID correctly, invoke the following command.
[akkumar@localhost tmp]$ iwconfig wlan0 essid MYESSID

At this point, the LED on your wireless card should start glowing, if everything works fine till now.

Once this happens the network interface ought to be brought up.
[akkumar@localhost tmp]$ ifup wlan0

Wait for a couple of seconds and then, you should be connected to the network right now. So yes, we had indeed succcessfully configured our wireless card to work with MandrakeLinux 10.1 , thanks to the ndiswrapper utility.
» login or register to post comments
Great tutorial ;-)
Submitted by k4m3leon on Sun, 06/19/2005 - 18:59.

Great tutorial ;-)
» login or register to post comments

Wednesday, November 08, 2006

subversion inplace checkin

From the Subversion FAQ:
http://subversion.tigris.org/faq.html#in-place-import

Suppose, for example, that you wanted to put some of /etc under version control inside your repository:

# svn mkdir file:///root/svn-repository/etc -m "Make a directory in the repository to correspond to /etc"
# cd /etc
# svn checkout file:///root/svn-repository/etc .
# svn add apache samba alsa X11
# svn commit -m "Initial version of my config files"

This takes advantage of a not-immediately-obvious feature of svn checkout: you can check out a directory from the repository directly into an existing directory. Here, we first make a new empty directory in the repository, and then check it out into /etc, transforming /etc into a working copy. Once that is done, you can use normal svn add commands to select files and subtrees to add to the repository.

There is an issue filed for enhancing svn import to be able to convert the imported tree to a working copy automatically; see issue 1328.

note on using rapid svn i found that using file:/// is better than file:// !

Thursday, November 02, 2006

uic trick

want to make the implementation and header files
make a pro file with:

FORMS += form1.ui

this will cause

/usr/share/qt3/bin/uic form1.ui -o form1.h
/usr/share/qt3/bin/uic form1.ui -i form1.h -o form1.cpp

Monday, October 30, 2006

autoconf fun and games

i need to turn of optimization
discusses the following
http://wiki.inkscape.org/wiki/index.php/CompilingInkscape

Plain vanilla compilation is done as documented in INSTALL; ./autogen.sh (optionally); ./configure; make; su && make test; make install (optional). See INSTALL for more on that.

But if you're going to be doing a lot of development, there's some tricks and techniques you should know, to get best results.

1. Turn off optimization
2. Use ccache for faster compilation
3. Set up a separate build directory (nice for testing both gcc and g++, or cross compiling)
4. Use the -j N flag to optimize for the number of processors in your machine, with N = 1 + no. proc's

Example: Setting up both gcc and g++ build environments (in separate tree), and using ccache for faster compilations on a dual-processor machine, with no optimization, assuming /bin/bash:

mkdir build-gcc build-g++
cvs checkout inkscape
cd inkscape
libtoolize --copy --force
./autogen.sh
cd ../build-gcc
CFLAGS='-g -O0 -Wall' CC='ccache gcc' ../inkscape/configure
cd ../build-g++
CXXFLAGS='-g -O0 -Wall' CXX='ccache g++' ../inkscape/configure
cd ../build-gcc && make -j 3
cd ../build-g++ && make -j 3


Turning off just optimization (which can produce strange results in debuggers):

export CXXFLAGS='-g -O0 -Wall'
export CFLAGS='-g -O0 -Wall'
./configure

Retrieved from "http://wiki.inkscape.org/wiki/index.php/CompilingInkscape"

This page has been accessed 7,113 times. This page was last modified 21:45, 20 June 2006.

add to the file Makefile.am

bin_PROGRAMS = testxml
testxml_SOURCES = main.cpp
AM_CXXFLAGS = -g -O0 -Wall
CXXFLAGS=
SUBDIRS = tinyxml
LDADD = tinyxml/libtinyxml.a

getopts example

http://www.siit.tu.ac.th/mdailey/class/2003_s2/its225/assignments/testopts.c:

/*
* testopts.c: example usage for getopt command line parsing
* library.
*
* Matt Dailey, Feb 2004
*
* Compile with "gcc testopt.c" to get executable a.out.
*
* This example program takes arguments of the following form:
*
* a.out [-ac] [-b ] arg1 arg2 ...
*
* That is, a.out has three optional options -a, -b, and -c.
* -a and -c are standalone options, and -b is an option that
* takes a string argument.
*
* Valid invocations include:
*
* a.out
* a.out -a
* a.out -c
* a.out -b arg1
* a.out -ac
* a.out -b arg1 -ca
* a.out f1 f2 f3
* a.out -a f1 f2 f3
* a.out -ca f1 f2 f3
* a.out -ca f1 f2 -b arg1 f3
*
* and so on. What's nice is that the options and arguments
* can occur in any order.
*
* Also refer to "man 3 getopt"
*
*/

#include
#include
#include
#include

#define TRUE 1
#define FALSE 0

char *g_pCharProgramName = NULL;

int main( int argc, char *argv[] ) {

extern char *optarg;
extern int optind;
int this_opt;

int bOptA = FALSE;
int bOptB = FALSE;
int bOptC = FALSE;
char *pCharOptB = NULL;

g_pCharProgramName = argv[0];

/* Loop until all arguments are processed. On each pass, we
* call getopt() for the next option */

while ( 1 ) {

/* Get the next option. It is placed in this_opt. We pass
* the user-entered argc/argv and our option string. The
* option string "ab:c" says our program has options -a, -b,
* and -c. The -b option requires an argument (this is
* specified by the colon in 'b:'. */

this_opt = getopt( argc, argv, "ab:c" );

/* If there are no options left, getopt() returns -1. */

if ( this_opt == -1 ) break;

/* Now we have either a valid option or an invalid option.
* Check all possible cases. */

switch ( this_opt ) {
case 'a':

/* The user selected the -a option. Set a bool for later use. */

bOptA = TRUE;
break;

case 'b':

/* This is the -b option. Since we put b: in the getopt
* options string, option b has an argument. Let's save it */

bOptB = TRUE;
pCharOptB = strdup( optarg );
break;

case 'c':

/* -c is another simple option like -a. Just set a flag to
* not that the user selected it. */

bOptC = TRUE;
break;

default:

/* Error case.
*
* getopt() prints an invalid option message for you.
* Usually we now print a usage message. */

printf( "Usage: %s [-ac] [-b ] [arg1] [arg2] ...\n",
g_pCharProgramName );
exit( -1 );
break;
}

}

/* Print out the options selected and not selected */

if ( bOptA ) {
printf( "Option A selected\n" );
} else {
printf( "Option A not selected\n" );
}
if ( bOptB ) {
printf( "Option B selected with argument %s\n", pCharOptB );
} else {
printf( "Option B not selected\n" );
}
if ( bOptC ) {
printf( "Option C selected\n" );
} else {
printf( "Option C not selected\n" );
}

/* Print out the non-option arguments. optind now indexes
* the first non-option argument in argv[]. */

while( optind < argc ) {
printf( "Got non-option argument %s\n", argv[optind] );
optind++;
}

/* Clean up */

if ( pCharOptB != NULL ) free( pCharOptB );
}

Friday, October 27, 2006

Better XConfiguration script that uses the ouput of xvidtune

Section "ServerLayout"
Identifier "XFree86 Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
ModulePath "/usr/X11R6/lib/modules"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/CID/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
EndSection

Section "Module"
Load "dbe"
Load "dri"
Load "extmod"
Load "glx"
Load "record"
Load "xtrap"
Load "speedo"
Load "type1"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "keyboard"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
EndSection

Section "Monitor"
#DisplaySize 370 270 # mm
Identifier "Monitor0"
VendorName "VSC"
ModelName "A90-2"
Option "DPMS"
EndSection
#the following was derived from xvidtune
Section "Modes"
Identifier "Mode1"
Modeline "1280x1024" 157.50 1280 1344 1504 1728 1024 1025 1028 1072
Modeline "1280x960" 148.50 1280 1344 1504 1728 960 961 964 1011
Modeline "1024x768" 94.50 1024 1072 1168 1376 768 769 772 808
EndSection

Section "Device"
### Available Driver options are:-
### Values: : integer, : float, : "True"/"False",
### : "String", : " Hz/kHz/MHz"
### [arg]: arg optional
#Option "NoAccel" # []
#Option "SWcursor" # []
#Option "Dac6Bit" # []
#Option "Dac8Bit" # []
#Option "ForcePCIMode" # []
#Option "BusType" # []
#Option "CPPIOMode" # []
#Option "CPusecTimeout" #
#Option "AGPMode" #
#Option "AGPFastWrite" # []
#Option "AGPSize" #
#Option "GARTSize" #
#Option "RingSize" #
#Option "BufferSize" #
#Option "EnableDepthMoves" # []
#Option "EnablePageFlip" # []
#Option "NoBackBuffer" # []
#Option "PanelOff" # []
#Option "DDCMode" # []
#Option "MonitorLayout" # []
#Option "IgnoreEDID" # []
#Option "OverlayOnCRTC2" # []
#Option "CloneMode" # []
#Option "CloneHSync" # []
#Option "CloneVRefresh" # []
#Option "UseFBDev" # []
#Option "VideoKey" #
#Option "DisplayPriority" # []
#Option "PanelSize" # []
#Option "ForceMinDotClock" #
Identifier "Card0"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "Radeon R250 Lf [Radeon Mobility 9000 M9]"
BusID "PCI:1:0:0"
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"

DefaultColorDepth 16
# i added this section
SubSection "Display"
Depth 8
Modes "1280x1024" "1024x768" "800x600" "640x480" "640x400"
EndSubSection
SubSection "Display"
Depth 15
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480" "640x400" "512x384" "480x300" "400x300" "320x240" "320x200"
EndSubSection
SubSection "Display"
Depth 16
Modes "1280x1024" "1024x768" "800x600" "640x480" "640x400"
EndSubSection
SubSection "Display"
Depth 24
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480" "640x400" "512x384" "480x300" "400x300" "320x240" "320x200"
EndSubSection
SubSection "Display"
Depth 32
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480" "640x400" "512x384" "480x300" "400x300" "320x240" "320x200"
EndSubSection
EndSection

Thursday, October 26, 2006

setting up the kernel and the modules.

the kernel goes here
/boot/xxxkernel

you need to modify the /boot/grub/menu.lst
to have the following entry.
i just place this at the top of the previous
entries.

title sasKernel from xxxx
root (hd0,0)
kernel /boot/xxxkernel root=/dev/hdc1 ro single
savedefault
boot

notice that this is a 2.6 kernel and has kernel modules
the modules start-up is dependent on the file
/etc/modules:
------------------------------------------------------------------
# /etc/modules: kernel modules to load at boot time.
#
# This file should contain the names of kernel modules that are
# to be loaded at boot time, one per line. Comments begin with
# a "#", and everything on the line after them are ignored.

ide-cd
ide-detect
ide-disk
psmouse
sd_mod
sr_mod
## i added these.
radeon
sis
8250
serial_core
-----------------------------------------------------------------

these files are in /lib/modules/2.6.10-xxx/kernel

./drivers
./drivers/char
./drivers/char/drm
./drivers/char/drm/radeon.ko
./drivers/char/drm/sis.ko
./drivers/serial
./drivers/serial/8250.ko
./drivers/serial/serial_core.ko

bootlogd

i have added bootlogd start to my rc0 start up script
debian:/etc/rc0.d# ls -l S*boot*
lrwxr-xr-x 1 root root 18 2006-10-26 10:41 S00bootlogd -> ../init.d/bootlogd
lets see if this can log everything.

here is so more information i found out about bootlogd
the init script i set up in /etc/rcS.d no in the above /etc/rc0.d
and this guy at http://www.timhardy.net/wordpress/2005/12/11/enabling-bootlogd-on-debian-31/
had the following to say:

Enabling Bootlogd on Debian 3.1

Bootlogd does not work out of the box on Debian 3.1 with a 2.6.8 kernel. If you enable it by setting the option to yes in /etc/default/bootlogd you’ll see the error message bootlogd: ioctl (/dev/ttyzf, TIOCCONS): Bad file descriptor scroll by on boot and the log is not created.

The problem lies with the version of udev used in Debian stable.

One solution is to upgrade the udev package to one from testing or unstable but that is not acceptable to someone who wants a pure system.

The alternative is to move the order the scripts are executed in /etc/rcS.d/. Remember, execution order is determined by the number in the filename so by renaming the bootlogd launching script you can get it to run before the udev script S04udev

mv /etc/rcS.d/S05bootlogd /etc/rcS.d/S03bootlogd-was-S05

The next time you boot, the log will be enabled for reading in /var/log/boot.

(Solution by Frans Pop on the debian-laptop mailing list)

then you need to change the /etc/default/bootlogd file look like
-----------------------------------------------------------------
# Run bootlogd at startup ?
BOOTLOGD_ENABLE=YES