today, i started to read linux 0.01 code. but to understand boot/ directory under it, i have to learn gnu assembly.
So, while i m learning GAS, enjoy your stay here.
if u like reading kernel code too, download it from here
Wednesday, September 16, 2009
Monday, September 14, 2009
How-To: Compile and Install Code::Blocks from Source in Debian Lenny
Code::Blocks is a complete, cross-platform integrated development environment for C and C++, built using the wxWidgets toolkit. Code::Blocks is available on Linux, Windows and OS X, so you may find it useful on Linux if you switched and are already used to it or an IDE like Dev-C++, for example.

The last stable version is 8.02, and was released almost an year ago. Since Code::Blocks is not included in the Debian repositories, I will show in this tutorial how to compile and install it from source in Lenny, the upcoming stable Debian release. Just follow the steps below:
1. Download the source and uncompress it
Download the source code from the official website, here, then make sure to switch the current directory to the one where you saved the source and uncompress it using the following command:
tar -xjf codeblocks-8.02-src.tar.bz2
2. Install the needed dependencies
This should be easy since only a few dependencies are needed. First, make sure you have the build-essential meta-package installed, which contains tools like make or g++, needed for compilation:
su
apt-get install build-essential
Next, install the development packages needed by Code::Blocks:
su
apt-get install wx-common libwxgtk2.8-dev libgtk2.0-dev
You will also need package zip to build it:
apt-get install zip
3. Update wx-config to point to wxWidgets 2.8
Issue the following command as root:
update-alternatives --config wx-config
What appears should look something like this:
# update-alternatives --config wx-config
There are 4 alternatives which provide `wx-config'.
Selection Alternative -----------------------------------------------
1 /usr/lib/wx/config/base-unicode-release-2.6 +
2 /usr/lib/wx/config/gtk2-unicode-release-2.6
3 /usr/lib/wx/config/base-unicode-release-2.8
* 4 /usr/lib/wx/config/gtk2-unicode-release-2.8
Press enter to keep the default[*], or type selection number:
4 Using '/usr/lib/wx/config/gtk2-unicode-release-2.8' to provide 'wx-config'.
Select option 4 from the list, that is /usr/lib/wx/config/gtk2-unicode-release-2.8
4. Compile from source and install
Make sure the working directory is the uncompressed source of Code::Blocks (codeblocks-8.02) and issue the usual commands:
./configure
make
make install
The last one as root.
5. Run ldconfig as root
Finally, run the ldconfig utility as root to update the links to shared libraries:
su
ldconfig
Code::Blocks should be now properly installed in /usr/local/bin/ and you can run it using codeblocks from a terminal or from a run dialogue (ALT+F2 and type codeblocks in KDE and GNOME).


The last stable version is 8.02, and was released almost an year ago. Since Code::Blocks is not included in the Debian repositories, I will show in this tutorial how to compile and install it from source in Lenny, the upcoming stable Debian release. Just follow the steps below:
1. Download the source and uncompress it
Download the source code from the official website, here, then make sure to switch the current directory to the one where you saved the source and uncompress it using the following command:
tar -xjf codeblocks-8.02-src.tar.bz2
2. Install the needed dependencies
This should be easy since only a few dependencies are needed. First, make sure you have the build-essential meta-package installed, which contains tools like make or g++, needed for compilation:
su
apt-get install build-essential
Next, install the development packages needed by Code::Blocks:
su
apt-get install wx-common libwxgtk2.8-dev libgtk2.0-dev
You will also need package zip to build it:
apt-get install zip
3. Update wx-config to point to wxWidgets 2.8
Issue the following command as root:
update-alternatives --config wx-config
What appears should look something like this:
# update-alternatives --config wx-config
There are 4 alternatives which provide `wx-config'.
Selection Alternative -----------------------------------------------
1 /usr/lib/wx/config/base-unicode-release-2.6 +
2 /usr/lib/wx/config/gtk2-unicode-release-2.6
3 /usr/lib/wx/config/base-unicode-release-2.8
* 4 /usr/lib/wx/config/gtk2-unicode-release-2.8
Press enter to keep the default[*], or type selection number:
4 Using '/usr/lib/wx/config/gtk2-unicode-release-2.8' to provide 'wx-config'.
Select option 4 from the list, that is /usr/lib/wx/config/gtk2-unicode-release-2.8
4. Compile from source and install
Make sure the working directory is the uncompressed source of Code::Blocks (codeblocks-8.02) and issue the usual commands:
./configure
make
make install
The last one as root.
5. Run ldconfig as root
Finally, run the ldconfig utility as root to update the links to shared libraries:
su
ldconfig
Code::Blocks should be now properly installed in /usr/local/bin/ and you can run it using codeblocks from a terminal or from a run dialogue (ALT+F2 and type codeblocks in KDE and GNOME).

Tuesday, September 8, 2009
Midpoint Ellipse Algorithm

/*************************************************
* Midpoint Ellipse Algorithm *
*************************************************
* Usage :- Optimized and general method for rasterizing ellipses
* Author :- Rooparam Choudhary
* Date :- September 1, 2009 [3:15 PM IST]
* Place :- Shri Mata Vaishno Devi University
* EntryNo :- 2006ECS20
*/
#include <graphics.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <time.h>
inline void setpixel(int, int);
void unionJack(void);
void randomUnionJack(int);
void ellipseMidpoint(int, int, int, int);
inline void draw(int, int, int, int);
void wait(void);
int MYCOLOR = WHITE;
clock_t DELAY = 0;
void wait(void) {
clock_t init = clock();
while( (clock() - init) < DELAY)
;
}
/* Ellipse drawing algorithm */
void ellipseMidpoint(int xc, int yc, int rx, int ry) {
long long int rx_2 = rx*rx, ry_2 = ry*ry;
long long int p = ry_2 - rx_2*ry + (ry_2>>2);
int x = 0, y = ry;
long long int two_ry_2_x = 0, two_rx_2_y = (rx_2<<1)*y;
draw(xc, yc, x, y);
while(two_rx_2_y >= two_ry_2_x){
++x;
two_ry_2_x += (ry_2<<1);
p += two_ry_2_x + ry_2;
if(p >= 0){
--y;
two_rx_2_y -= (rx_2<<1);
p -= two_rx_2_y ;
}
wait();
draw(xc, yc, x, y);
}
p = (long long int)(ry_2*(x+1/2.0)*(x+1/2.0) + rx_2*(y-1)*(y-1) - rx_2*ry_2);
while (y>=0) {
p += rx_2;
--y;
two_rx_2_y -= (rx_2<<1);
p -= two_rx_2_y;
if(p <= 0) {
++x;
two_ry_2_x += (ry_2<<1);
p += two_ry_2_x;
}
wait();
draw(xc, yc, x, y);
}
}
/* Using the symmetry of Ellipse to draw points in other octants */
inline void draw(int xc, int yc, int x, int y) {
setpixel(xc+x, yc+y); // Ist Quadrant
setpixel(xc-x, yc+y); // IInd Quadrant
setpixel(xc-x, yc-y); // IIIrd Quadrant
setpixel(xc+x, yc-y); // IVth Quadrant
}
inline void setpixel(int x, int y){
putpixel(320+x, 240-y, MYCOLOR);
}
void randomUnionJack(int count){
void DJ(int, int, int);
int xr, yr, clr=0;
srand(time(NULL));
while(count-- > 0){
xr = -320 + rand()%641;
yr = -240 + rand()%481;
clr = 0;
if(yr > -xr){
if(xr < 0) clr = 3;
else if(yr < 0) clr = 2;
else if(yr > xr) clr = 4;
else if(yr < xr) clr = 1;
}else if(yr < -xr) {
if(xr > 0) clr = 3;
else if(yr > 0) clr = 2;
else if(yr < xr) clr = 4;
else if(yr > xr) clr = 1;
}
DJ(xr, yr, clr);
}
}
void DJ(int x, int y, int clr){
int shade = 0;
switch(clr){
case 1: shade = RED; break;
case 2: shade = BLUE; break;
case 3: shade = CYAN; break;
case 4: shade = MAGENTA; break;
default: return; break;
}
putpixel(320+x, 240-y, shade);
}
void unionJack(){
for(int y = 240; y>0; --y) {
int x = -321;
MYCOLOR = BLUE;
while(++x < -y)
{ putpixel(320+x, 240-y, MYCOLOR); }
MYCOLOR = CYAN;
while(++x < 0)
{ putpixel(320+x, 240-y, MYCOLOR); }
MYCOLOR = MAGENTA;
while(++x < y)
{ putpixel(320+x, 240-y, MYCOLOR); }
MYCOLOR = RED;
while(++x < 321)
{ putpixel(320+x, 240-y, MYCOLOR); }
}
for(int y = -1; y>-241; --y) {
int x = -321;
MYCOLOR = RED;
while(++x < y)
{ putpixel(320+x, 240-y, MYCOLOR); }
MYCOLOR = MAGENTA;
while(++x < 0)
{ putpixel(320+x, 240-y, MYCOLOR); }
MYCOLOR = CYAN;
while(++x < -y)
{ putpixel(320+x, 240-y, MYCOLOR); }
MYCOLOR = BLUE;
while(++x < 321)
{ putpixel(320+x, 240-y, MYCOLOR); }
}
}
int main(void) {
int gd = DETECT, gm;
char *author = "Coder:- Rooparam Choudhary";
char *algo = "Midpoint Ellipse Algorithm";
char point[30];
//std::cout << algo << std::endl;
//std::cout << author << std::endl;
initgraph(&gd, &gm, "C:\\");
setcolor(WHITE);
setbkcolor(GREEN);
outtextxy(320 - textwidth(algo)/2, 5, algo);
outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);
setcolor(GREEN);
setbkcolor(BLACK);
setcolor(YELLOW);
// X-axis
line(0, 239, 640, 239);
line(0, 240, 640, 240);
line(0, 241, 640, 241);
// Y-axis
line(319, 0, 319, 480);
line(320, 0, 320, 480);
line(321, 0, 321, 480);
// Y + X = 0
line(80, 0, 560, 480);
// Y - X = 0
line(80, 480, 560, 0);
std::cout << "Enter samples for union jack\n(SHOULD BE GEATER THAN 100K): ";
int samp;
std::cin >> samp;
//unionJack();
randomUnionJack(samp);
setcolor(WHITE);
setbkcolor(GREEN);
outtextxy(320 - textwidth(algo)/2, 5, algo);
outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);
setcolor(GREEN);
setbkcolor(BLACK);
int xc, yc, rx, ry;
MYCOLOR = WHITE;
std::cout << "\nDelay Interval [0 - 100]\t Recommended: 20\n\n";
std::cout << "Enter the coordinates of ellipse center and it's two axes and delay\n[xc yc rx ry delay] (\'-400\' to exit) : ";
std::cin >> xc;
while(xc != -400) {
std::cin >> yc >> rx >> ry >> DELAY;
sprintf(point, "(%3d, %3d) %3d %3d", xc, yc, rx, ry);
setpixel(xc, yc);
line(320+xc, 240-yc, 320+xc+rx, 240-yc);
line(320+xc, 240-yc, 320+xc, 240-yc-ry);
outtextxy(320+xc-textwidth(point)/2, 240-yc+2, point);
ellipseMidpoint(xc, yc, rx, ry);
setcolor(WHITE);
setbkcolor(GREEN);
outtextxy(320 - textwidth(algo)/2, 5, algo);
outtextxy(getmaxx()-4 -textwidth(author), getmaxy()-20, author);
setcolor(GREEN);
setbkcolor(BLACK);
std::cout << "[xc yc rx ry delay] (\'-400\' to exit) : ";
std::cin >> xc;
}
closegraph();
return 0;
}
Subscribe to:
Posts (Atom)
