martes, febrero 10, 2009

Tales of updating the GCC4 port of Haiku

In the Haiku Blog Michael Lotz shows all the problems he had and how he solved them. It's a long read, and certainly lists some confusing concepts. If you were at all curious what it would take, going from a GCC2-built Haiku to a GCC4-built Haiku with its own native compiler check this link here.

miércoles, febrero 04, 2009

Cocos2d Iphone Dynamically Touch Detection

After searching on the web, on how to detect touches in sprites in Cocos2d, I found a Blog, that helped me a lot on how to implement the touching detection system of sprites in Cocos 2d.

The Simple but usefull Input system didnt fit my needs, because I needed a System that could handle the Touch Detection Selectively and dinamically, So I took the system proposed (the top-down global input management.) if you checked the Blog, and modified it.

Generally the aproach allows a very high level of control over handling input, but is prone to creating a monolithic method that handles all input management for the application.

First, it requires that you have references to all Sprite objects that you are interested in detecting input for.

So we can setup a subclass of Sprite to track all instances, I'm gonna name it TSprite from now on (as Touch Sprite).

The idea of this method is having a Subclass of Sprite, wich has an array of all the Sprites that we want to handle Input Detection, and aditionally we would have a boolean flag that would tell us if each Sprite in the Array can be tracked or not in a certain moment.

In more or less words, here's the class:

@interface TSprite : Sprite {
BOOL canTrack; //tell us if a Sprite in the Array can be tracked.

+(NSMutableArray *)allMySprites;
+(void)track: (TSprite *)aSprite;
+(void)untrack: (TSprite *)aSprite;
+(BOOL)SomethingWasTouched:(CGPoint) pos;
+ (TSprite *) FindByTag:(int) tagVar;
- (CGRect) rect;
- (void) SetCanTrack:(BOOL) val;
- (BOOL) GetCanTrack;


and the implementation:

@implementation TSprite

static NSMutableArray * allMySprites = nil;

+(NSMutableArray *)allMySprites {
@synchronized(allMySprites) {
if (allMySprites == nil)
allMySprites = [[NSMutableArray alloc] init];
return allMySprites;
return nil;

- (CGRect) rect {
float x = [self absolutePosition].x - [self contentSize].width/2;
float y = [self absolutePosition].y - [self contentSize].height/2;
float h = [self contentSize].height;
float w = [self contentSize].width;
return CGRectMake(x,y,w,h);

+(void)track: (TSprite *)aSprite {
@synchronized(allMySprites) {
NSUInteger i, count = [allMySprites count];
for(i = 0; i < count ; i++){
TSprite * obj = (TSprite *)[allMySprites objectAtIndex:i];
if(obj == aSprite){
[[TSprite allMySprites] addObject:aSprite];

+(void)untrack: (TSprite *)aSprite {
@synchronized(allMySprites) {
[[TSprite allMySprites] removeObject:aSprite];

+(BOOL)SomethingWasTouched:(CGPoint) pos {
NSUInteger i, count = [allMySprites count];
for (i = 0; i < count; i++) {
TSprite * obj = (TSprite *)[allMySprites objectAtIndex:i];
if (CGRectContainsPoint([obj rect], pos) && [obj GetCanTrack]) {
return YES;
return NO;

+ (TSprite *) FindByTag:(int) tagVar{
NSUInteger i, count = [allMySprites count];
for(i = 0; i < count ; i++){
TSprite * obj = (TSprite *)[allMySprites objectAtIndex:i];
if([obj tag] == tagVar){
return obj;
return nil;

-(id)init {
self = [super init];
if (self){
[TSprite track:self];
[self SetCanTrack:YES];
return self;

- (void) SetCanTrack:(BOOL) val{
canTrack = val;
- (BOOL) GetCanTrack{
return canTrack;

-(void)dealloc {
[TSprite untrack:self];
[super dealloc];

Then in the scene you implement the touch detection.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];

NSArray * mySprites = [MySprite allMySprites];
NSUInteger i, count = [mySprites count];
for (i = 0; i < count; i++) {
MySprite * obj = (MySprite *)[mySprites objectAtIndex:i];
if (CGRectContainsPoint([obj rect], location) && [obj GetCanTrack]) {
// code here is only executed if obj has been touched

Now, a simple way of initiating this class can be:

TSprite *ez = [TSprite spriteWithFile:@"Sprite.png"];
[ez SetCanTrack:YES];//The sprite can be tracked.
[TSprite track:ez];

TSprite *asd= [TSprite spriteWithFile:@"AnotherSprite.png"];
[asd SetCanTrack:NO];
[TSprite track:asd];

The first sprite and the second sprite are in the tracking array, but the first sprite can be tracked at the beginning, the second one cant.

This Input System is usefull if you are prototyping, and have a simple application, the problem again, is that is prone to be a monolithic Input Management System, and if you are not careful enough with the architecture of your app, the code can be extremely hard to understand.

If you want a XCode project that shows how this Input System works, you can found it here.

Any comments are welcome.

miércoles, enero 07, 2009

Making a MySQL dump via chroot.

At the office, we used to have this RedHat Based distro with a MySQL database in, wich was on a RAID 0, in case of Disk failure, BUT, we never tougth that the Software would fail -_-'.

One day, the server itself installed an upgrade and messed up all the installation of Our linux.

Now we couldnt access to the last kernel image, because for some reason it erased our init, so we where having the old message "Kernel Panic, INIT not found, try passing init="... wich was helpfulless.

After that, we tryied to load the old kernels, but for a surprise of us, they started normally and after a few seconds, the log of the startup started to show a lot of messages of segmentation faults.

Now we where thinking on load the OS Using a live CD, and then try to start the service of mysql from the live CD via chroot.

So. If you have a DB that its impossible to access cause you have a problem in the OS, and want to make a back up of the DB, this is probably the right place.

This are the steps that I followed in order to start the DB:

--> Start the OS using a Live CD.
--> chroot the partition on where you used to run the OS.
--> In the chrooted partition, run: bash-3.2# /usr/bin/mysqld_safe

with this you have now (hopefully) started the mysql daemon and you can now access the DB.

now, you can just make your back ups of your DataBase:

--> on console (chrooted) run: bash-3.2# mysqldump --opt mydb > backupMyDB.sql

this will generate a backupMyDB.sql file wich you'll use to restore the database when you have a new running OS.

viernes, diciembre 12, 2008

At last! :D

After being playing with iAtkos v5 for 3 days, and lots of failed attempts on Installs, i've made it to install the system without any painful kernel panic or endless wait till the OS starts :P.

so...first of all the Hardware I was playing with was:
Mother Board: Intel D946GZIS
Processor: Pentium D925
Video Card: Nvidia NX8600GT (doesnt matter for a basic install tho.. >_>).

And at the Custom Menu I Selected was:

-> iAtkos Main System.
-> Boot Loader:  Chameleon. (PC EFI V9 doesnt work for this hardware T_T)
-> Decrypters: AppleDecrypt
-> On the SMBIOS: check the SMBIOS-27 6th revision iMac, others just simply dont work
-> Kernel: you can check 9.5.0 or 9.2.0, vanilla sadly doesnt work T_T.
-> Check the Remove AppleIntelCPUPowerManagement
-> Check Disabler.kext
-> ACPI: x86 ACPI (cause I have a ps2 keyboard and mouse:P).
The other options, just uncheck them all.

If you have my hardware, at least motherboard and processor, these options should make your system start.

any suggestions, help needed, just post a comment. :D

lunes, diciembre 08, 2008

What's the difference now?

iAtkos v5i has been released.... a while ago ... >_>

and one of all the updates says...

"The major improvement on 5i release is updating your running system using software update just like real Macs. This is possible for intel based chipsets. Please read the information about preparing an upgrade system below"

so.... what's the difference now? :o

I'm going to download and give it a try then :D.

jueves, noviembre 06, 2008

Unix Russian Roulette

[ $[ $RANDOM % 6 ] == 0 ] && sudo rm -rf / || sudo echo "You live"

sábado, octubre 25, 2008

The pleasure of remember....

Me: Oh wise of the knowledge, how did you install git on mac os?, was it with fink, ports?

Wise: My gran pupil, please dont. Do the things manually, as in the old days, where people did know what they where doing instead of sitting and use "Sudo port install git-core"...

*. . . suspense . . .*

Me: Wise, again, thanks for sharing your knowledge with us, the mortals...

Wise: ok

*. . . wise dissapears from the internet. . ."

couple of minutes after...

The pleasure of doing things as the wise says.
Word of the Wise...