quarta-feira, 18 de junho de 2014

Making a LaTeX table out of matrix data on a text file


Ah, UNIX! I love you!

So after generating some data as a matrix with MATLAB, I ran with the problem of formatting it again but now for LaTeX. So I made this little bash script to solve my problem:

#!/bin/bash

FILE=$1

EXT=`echo $FILE | grep -o "\..*" | tail -n 1`
BASENAME=`basename $FILE $EXT`

cat $FILE | awk 'BEGIN{ ORS=""; OFS=""; } { for (i=1;i<=NF;i++) if (i<NF) print $i," & "; else print $i," \\\\ \n";;  }' > $BASENAME.tex

Hope it helps anyone out there

quinta-feira, 25 de julho de 2013

Problema do framebuffer

Ok, então eu tenho um Framebuffer que pode ser mapeado em espaço de usuário, entrega as informações via "fbset -i" corretamente, porém é utilizado erroneamente pela API DFB.

Utilizando o hexdump /dev/fb0 -n 4, posso averiguar o que exatamente é escrito no framebuffer.

Pintando um retângulo de teste com a cor:
R: 0x01
G: 0x02
B: 0x03
A: 0x04

Deveria aparecer pelo hexdump
0x0102 0x0304

Porém, obtenho
0xFF01 0x0203

Isso dá a entender que 1) o DFB não entende o formato RGBA, apenas o ARGB 2) o canal A não está sendo corretamente utilizado

Averiguando rapidamente os fontes do DFB, parece que realmente uma solução possível é "ensinar" a API esta difícil tarefa. Mas ela é invasiva demais... será que consigo achar outra melhor?

terça-feira, 23 de julho de 2013

Linux-Fusion fundido

Depois de um bom tempo tentando resolver questões relativas ao funcionamento do DirectFB em sistemas mais atuais, hoje consegui chegar a uma configuração funcional.

O grande problema de instalar o DirectFB 1.4.5 é que seu modo multi-processo requer um módulo Linux chamado linux-fusion. As versões mais antigas desse módulo, durante o processo de instalação, verificam qual a versão do Kernel utilizada e setam um Makefile especial de acordo - o que gera problemas quando é utilizada as versão "comemorativas" do Linux 3.x.y pois esses Makefiles funcionam apenas com os 2.x.y.

A solução foi, a força bruta, achar uma versão desse módulo que não só funcionasse com o Kernel 3.x.y como também com a versão 1.4.5 do DirectFB . Testando uma-a-uma, encontrei a versão 8.8.1, e agora posso testar aplicações DFB em uma máquina Linux qualquer.

O próximo passo agora é criar a aplicação de test_bars para encontrar qual a configuração adequada do Framebuffer do Linux para o SoC. Ela imprimirá na tela 8 barras de cores, a fim de ver quais canais estão sendo invertidos, e um degrade de cinza para ver se não estou invertendo o endianness na leitura das cores.

quinta-feira, 18 de julho de 2013

Framebufer continua inserindo mas não remove.

Mais um dia se passa, e mais um dia com bugs terei amanhã.

Contextualizando: tenho que escrever um driver de vídeo usando a API de framebuffer do Linux. Esta tarefa já havia sido iniciada anteriormente, porém, esse driver utilizava um identificador de hardware para se "encaixar" dentro do sistema maluco de platform_device do Linux, declarando uma tabela de identificadores que possuía apenas o ID do controlador de memória.

Porém, o projeto mudou, o identificador sumiu, e o driver então parou de funcionar. A solução? Utilizar um sistema "alternativo" (e obviamente não recomendado) que consiste em alocar dinamicamente o dispositivo e então registrar o seu driver, ao invés de utilizar apenas os identificadores como referência para a inserção e inicialização do driver do dispositivo. Esse método foi descoberto olhando os fontes do Framebuffer arkfb, ou algo assim, corrigirei depois.

Essa solução havia resolvido o problema de inicialização. Mas, como não dá para se ter tudo na vida, a remoção grotescamente gerava um Kernel Taint por um dereferência a um ponteiro nulo - e não poder remover um driver significa que não poderei compilá-lo como módulo a fim de teste, me obrigando a carregar a imagem do linux via porta serial toda hora que fizesse uma modificação.

Entonces, hoje foi mais um dia tentando resolver esse empecilho. Como não posso perder mais muito tempo nisso, vou ter que utilizar o método brucutu de carregar as imagens toda hora que modificar apenas uma linha de código. Sigh.

Ok, próximos passos então:

  • Criar a aplicação DirectFB TestCard, de teste de cores
  • Rodar ela na placa e ver como as cores estão sendo interpretadas pela API
  • Corrigir o Framebuffer

Update: depois de verificar os sources de novo, decidi ignorar o problema da remoção, uma vez que o método que estou utilizando é descrito como "desencorajado" pelos mainteners do Linux e um comentário propício em um deles salienta que o módulo não é removível



Monk da Luz

Vamos ver: 20 Lightmonk

STR 14
DEX 15
CON 14
INT 10
WIS 16
CHA 8

Helf, Dilletante de Rogue

Feats legais, ainda não final

Power Attack
Cleave
Great Cleave
Dodge
Mobility
Combat Expertise
Whirlwind Attack
Two Weapon FIghting (x3)
Stunning Fist
Stunning Blow
Toughness

13... acho q n rola, mimimi. Vamos ver: 7 de lvl ups (1,3,6,9,12,15,18)
1,3,6 marciais ... 10 feats no total.

não sou monge de força - logo no Cleaves, 11, só tenho 10, Humano?



quarta-feira, 17 de julho de 2013

segunda-feira, 28 de janeiro de 2013

The Light of Cera Sumat

This is the part 2 of the tale of the Holy Avenger Cera Sumat, extracted from the game Icewind Dale II. This part tells of the time in which the legend was constructed, and is best digested after reading the first part 1 of the story, told bellow.

The light of Cera Sumat 

The holy avenger is the paladin's ultimate weapon against the forces of evil. There are few creatures on the Lower Planes that would not hesitate to confront a holy warrior wielding such a weapon... and this one, perhaps more so than others. Once, it was nothing more than a simple iron sword, but through the courage and faith of one man, it became something more.

The blade of this holy avenger glows with a soft golden light. Inscribed upon the hilt in flowing gold letters is "Cera Sumat," which translates into "Six, now Silenced." Cera Sumat earned its name through the labors of elderly duke Kholsa Ehld, a man cresting nearly eighty years of age, who vowed to complete a task that the greatest warriors of three kingdoms feared to do... all because of the weeping of a child.

The times in which Old Duke Ehld lived were ones of great upheaval, and the servitors of Bane were strong, crushing all that stood in their way. Entire kingdoms feared their wrath, and to speak out against them meant death, so many remained silent and turned their eyes from the evils of Bane and his servants.

During these dark times, the most terrible of Bane's minions were six who called themselves the Lost Followers. Their souls were storms of avarice and hate, and mighty were the powers at their command. They reveled in strife and tyranny... and for all the blood they shed, it was never enough.

Together, the Lost Followers brought about the downfall of the Silver Court, slaying its king upon his throne and renaming his once-beautiful nation the Barbed Kingdom. After animating his decapitated corpse and having it march through the streets slaying anyone it could find, they brought a rain of fire down upon the city and the lands around, leaving it a barren wasteland. It is said that they dined in the capital's great hall that night as the land burned, and they raised their wine glasses as the screams of the dying reached their peak.

There was only one survivor. In their last act of malice, the Lost Followers left the king's only daughter, barely five years old, alive to reign as "Queen" over the burned kingdom. They called her the Weeping Queen and cast wards about her so that she might never leave the empty capital, and then left her to starve. Their appetite momentarily slaked, the Lost Followers parted ways and went upon their separate roads of damnation, sowing strife in the Bane's Name.

Old Duke Ehld was the first one to cross the wards of the Barbed Kingdom and seek out the Weeping Queen upon her father's throne. When he found the small girl, he approached, kneeled before her, and told her he had come to pledge his life in her service. In stiff, formal words, he said he had brought food and water and apologized for his lateness, but his bones were old and it had taken him some time to reach this place. The near-starving child stared at him as he pledged his worn blade and his honor to seeing that the ones who had done this terrible crime answered for their actions, if his Queen wished it. After a long, stunned silence, the Weeping Queen found the words to thank him.

From the moment Ehld left the throne room in search of the Lost Followers, the weeping of the queen ended, and she never cried again.

Over six years, Ehld traveled the lands of Faerun and across the planes themselves, seeking the Six, and asking them to answer for their crimes. Each scoffed at the old man and his worn-looking blade, only to find him a dangerous opponent... and in the end, the victor. He recorded the events of their death upon a stone set into the pommel of his blade, and there was even regret in his writings that he had not been able to enlighten the Lost Followers to turn from their path before it came to its end.

When the last of the Six had answered for their crimes upon the edge of the Cera Sumat blade, Ehld returned to the Weeping Queen and laid the blade at her feet. Where once it had been a tarnished blade, it shone as brightly as the sun, and the stone in the pommel was covered with the writing of his journeys. He detached the stone, and set into a chain, and he gave the Weeping Queen. Ehld told her to keep the chain to wear as a reminder of the many wrongs of the world and that they are never far from one's heart... but if one's heart is true and one's path is righteous, one may triumph against any number of evils.

Duke Ehld outlived his queen, living to the age of 107, at which point Ehld took his Cera Sumat and left the Barbed Kingdom... and is said to have traveled north. In time, the Barbed Kingdom rose to its former glory and its name was changed, and with it, the fate of Cera Sumat and the Medallion of the Lost Followers was forgotten... until your arrival in Kuldahar and the medallion and the Holy Avenger were united once again to meet the Lost Followers in battle one final time.

But the story of Ehld and Cera Sumat was a story of another time, and of the adventures of another hero. This is now your time, and your epic. If your band counts a paladin among its number, then this ancient blade is yours to wield against the forces of evil...

And perhaps, if your heart is true, save a land from destruction once again.

The Medallion of the Lost Followers

Extracted from the Game Icewind Dale II, this is the part 1 of the tale of the Holy Avenger Cera Sumat. It's also one of the reasons that make a game epic for me.

The medallion of the lost 

Perhaps the yuan-ti did not know what they held in depths of Dragon's Eye, but simply holding this item reveals its long history to you, and its saga is an extended and bloody tale indeed. One only needs to bring the medallion close to them, close their eyes and concentrate upon it's cool metallic surface, and the chronicle of the keepsake scrolls through your mind.

This notched stone was once set into the pommel of the ancient blade Cera Sumat, a Holy Avenger wielded by the old paladin, Duke Kholsa Ehld as he walked upon the path of the Lost Followers, challenging them to answer for their crimes in the Barbed Kingdom. Inscribed upon the stone is the chronicle of his search for the six Lost Followers, and the circumstances surrounding their deaths. The medallion tells of the them:

Ehld met Inhein-Who-Was-Taken as she slept beneath the earth on the Battle of Bones and asked her to follow him to the Barbed Kingdom to be judged. Her laughter was a storm of bladed whispers, and she cursed the old man, hurling spells of death and flame upon him... she surrounded herself with mighty magics and swirling blades, daring the old man to come close, but he simply bowed his head and took shelter within the spiritual shield of his holy blade. In fury, she risked much and began to raise the dead from the Battle of Bones to destroy the Duke, but the shield around him prevented them from getting close. The undead, furious at their summoner for putting them to an impossible task, turned upon their mistress and tore her apart. Ehld took what was left in a small metal cask and brought it to the highest hill at daybreak, and let the sun shine down upon Inhein's remains until they were dust.

Broken Khree, one of the only monks to fight the Black Raven in combat and survive with only his legs shattered and his jaw splintered, was the next of the six, and he was not hard to find. He had gathered together a band of slaves captured from a number of small farming hamlets and had them build a temple in Bane's name. Khree was a master of unarmed combat, with eyes and reflexes so quick that he could dodge most missiles and spells before they stood a chance of touching him - and he had sent many archers and mages to their graves. In hand to hand combat, he was a terror, for his bones and body were one with the elements, ignoring fire, cold, lightning, and weather's other displeasures, and while his skin could be stabbed or cut, his bones had the strength of the earth about them, preventing them from being broken or crushed by all but the most powerful of attacks. Ehld knew this, and when he found the bloody monk, the two traded no words, but attacked each other immediately. It was all Ehld could do to dodge Khree's attacks, but in a dangerous stratagem, Ehld tricked Khree into collapsing the newly-erected temple of Bane around them, causing Khree's arms to become pinned by the falling masonry. The monk died as the falling crossbeams of the temple pierced his chest, and in the last minute of his life, he spat his defiance against Ehld and told him he would fight his way back from death to destroy him.

Kaervas Death's Head was the lord of an empire deep within the earth, and he sat upon his lava-red throne of rock and magma, his skin so thick with calluses and black enchantments that no mortal weapon could pierce or cut it. Ehld traveled many leagues beneath the surface of Faerun and demanded an audience with the black rock king. Kaervas, amused by the old human's challenge, agreed to fight him, but found Ehld's strength and holy avenger an equal match for his strength and skill. Finding it almost impossible to strike a mortal blow against Kaervas with even his keen blade, Ehld parried one of Kaervas' strikes and turned the momentum of Kaervas' own axe back on its owner, causing the blunt end of his mighty axe to sink into the dwarf's skull, splintering the bone beneath the skin into fragments. The Duergar allowed the human who had slain their king to leave unmolested, and they sealed Kaervas' body in the throne room where he died.

Atalaclys the Lost traveled upon the great sands of Anarouch, hoping to unearth some of the ancient magics buried within the desert to stave off the rotting disease which had claimed him. Ehld tracked him down through the shifting desert, meeting him in the sandy square of a dead town. With no living creature as their witness, the two of them fought for days, spell against blade for days, until at the height of the fourth day, Atalaclys's rotting throat cracked in the desert heat. Unable to utter a spell to carry him away, Ehld left him in the desert, where his corpse lay, fed upon the flies and beetles of Anarouch.

Jaiger of the Fanged Season had once been one of four Uthgart brothers whose father had blessed each of them with a binding of the elements. Jaiger had been bound to the Elemental Plane of Air, and such was his power that he could harness the wind to pull his bowstring - and cause the missiles and spells of his enemies to go astray. Jaiger was serving as a mercenary in one of the many southern kingdoms, his bow firing out a stream of arrows so fast and sure that he was said to bring a Rain of Death wherever he traveled. Ehld found the toothless barbarian within the brothels of a southern port, half-drunk and belligerent. When confronted, Jaiger was too deep in his cups to realize who Ehld was, and once it suddenly sunk in the old man had come to capture him, Jaiger tried to fight back with his bow - only to find it much more difficult to fire with his opponent standing almost on top of him than it was when the opponent was a horizon's distance away. Although Jaiger sunk many arrows into his opponent, Ehld was able to best him with a whirling strike that severed Jaiger's bow... and the barbarian's head from his body.

Veddion Kairne, the Hunched Lord, was the last and most difficult of Ehld's challenges. Kairne was said to be the spawn of a storm giant and a demon, combining the great strength of his father with the cunning and bloodthirstiness of his mother. No fork of lightning could touch him, no fire could burn him, and it was said that he bathed in acid and frost as if it were water. The two bloods coursing through him had given him a tremendous resistance to magic, but it prevented him from using magic himself, forcing him to walk the face of Faerun whenever he wished to travel the land. Instead of awaiting his death, however, he sought out Ehld as he was traveling upon the Spine of the World Mountains and tasked the old paladin with proving him guilty of the slaughter in the Barbed Kingdom. The two of them dueled with words for many hours atop the Spine of the World Mountains until Ehld finally tricked Kairne into admitting his guilt... and the Hunched Lord laughed and their battle began. Hurling jagged boulders at the elderly warrior, Kairne buried Ehld under an ever-growing mountain of rubble, then lifted up his hammer to drive the tombstone into the makeshift cairn around the old warrior... only to have the cairn collapse beneath him, causing an avalanche and crushing him beneath its great weight. Ehld, who had been crouching within the cairn and using his sword as a brace against the precarious balance of rocks, had slipped free and let weight and gravity take their course. With Kairne, the last of the six had been silenced, and Ehld returned home to his Queen.

When he arrived in the court of the Barbed Kingdom, Ehld detached the medallion from the pommel of his Holy Avenger and gave it to his Queen to wear as a reminder of the many evils of the world... but if one's heart is true and one's path is righteous, one may triumph against any number of evils.

If this medallion could somehow be brought to the resting place of Ehld's Holy Avenger, the blade will rise from the ground, ready to be taken up against the forces of evil once again.

sexta-feira, 14 de dezembro de 2012

Torchlight 2

I've played Diablo 2 for a long time. I would even still be playing it, if it hadn't such an old engine and mechanics intended to make the player linger on playing just for the items - a kind of a BS system for me now that I got older and started questioning things - but at any rate that game was a special one among so many other games I've played.

It's not surprising then that I liked the idea of a sequel as it was announced by Blizzard a good while ago. At that time, though, I had not yet played their gold mine called WoW, so I had no idea they were going to go backwards and undo what the excellent patch 1.10 of Diablo II did to that game.

Thing is, Diablo III has no customization. None. Zero. Nich. The only things that you can customize are the armor and sex. Boo, look how good Demon Hunter I am on black lycra and heels!

Luckily, this post is not about Diablo III's mistakes - it's about another game who stayed true to D2 virtues - and it was no surprise for me when I discovered that many developers of D2 were responsible into this.

To sum what I loved in Torchlight 2, it is a game that makes you think. Makes you plan. It is almost Diablo 2 with a few minor but needed tweaks: where in Diablo 2 you would need some skills as prerequisites for the higher level ones, on Torchlight 2 you get them as autogranted at specific levels. While on Diablo 2 the skill point system was irreversible, ie a point spent is lost forever, here you have the option to undo the last 3 ones used. It's still restrictive, but I think that was meant for the player to "feel" the skill into their playstyle. Increasing it to 5 wouldn't be bad, though.

The same 5 points for any attribute you wish is used, but then again an interesting change was made: almost all points are useful for all classes. Strength, for example, increases all critical damage bonus - inclusing spells - and dexterity all critical chance, again, including spells. So, even as the Embermage, the game's flavored mage class, you would still need to consider these 2 factors before dumping all points into focus, which increases all elemental damage, and vitality, which would be a classical choice made by players on their Sorceress on Diablo 2.

The battles are fun. Really. The game is action-full, fast paced, and you have to analyse carefully what you're doing and facing on the same level as you click.  Even playing as an Embermage on Veteran that killed stuff fast, I found myself dying over casual mistakes like getting hit by a slow but strong Troll - my favorite part was reading at status that the biggest damage I had taken was 2.6k when I had 2.3k hp.

To sum it up, this is a game that delivered everything that I was expecting. Granted, as I had read on a game reviewer, the story doesn't inspire much emotion. Maybe it was the fact that there wasn't no voiceover.

But, again, T2>>>D3.

quinta-feira, 1 de novembro de 2012

... and it shone as bright as the sky ...

Browsing a little through the web, I remember on of my favorites parts of The Silmarillion, from the Master JRR Tolkien:


As an exercise to those who read the book, try to remember where it came from.