Search Results (10 posts found):
After a few months of not looking at it, I've recently been working on making a few old-school improvements to Barkout, namely a continue code-style save game mechanism, and a new power up in the form of a multi-ball bonus, common in most other Arkanoid clones.
Above, the multi-ball powerup in action.
Below, using the Continue screen to enter a code.
The purpose of Barkout all along has simply been to get some practice in C programming. Initially, it was so I could help a family member who had started a C programming course at university, but it then evolved into doing it just because I enjoyed it. C is a great language to program in. It's also just a nostalgia trip for me; trying to program the sorts of games that I played on my first computer in the 80s: an Amstrad CPC6128.
Anyway, the fruit of my effort is that Barkout version 1.2.0 has now been released and can be found by following the "Free Games!" icon in the top menu.
Almost four years after its debut on the app store, Help Hannah's Horse has returned.
It was removed for repeatedly failing the Google ads policy, which was ludicrous as the app rating and ad content ratings are both determined by Google themselves.
Anyway, if anyone is interested, Help Hannah's Horse is now completely ad-free and can be found
HereI recently needed to implement RSA cryptography in Delphi, sticking to a few requirements of my own choosing:
1. The library used should be free
2. The library license should be permissive enough that I can use the library in a commercial application
3. The library should have as few extra files to include as possible
I looked initially at LockBox, but it came with a multitude of files to either copy to my source folder or include in my library path. I don't want other developers in my team to have to add yet more third party libraries, so I gave this a miss. Additionally, the documentation wasn't great and finding example online was quite tricky.
I then tried PGPCrypt, but could only find a version of that for Lazarus, the free Delphi compiler.
Next was the TMS Cryptography pack, but this isn't free, so again a non-starter.
Then I thought about OpenSSL. We already use OpenSSL as a DLL for a different, but related, purpose so the file is already present in our source and program folder. What we don't have are function headers as we're calling the DLL functions by importing them directly (we only use three at present), but RSA is more complicated and uses a particular structure that would need replicating in Delphi. I thought this might mean OpenSSL was also a non-starter, but after much searching online I came across the Delphi-OpenSSL project at https://github.com/UniGe/delphiopenssl/ which consists really of only three .pas files, only one of which is necessary for what I'm trying to implement: RSA encryption and decryption. For this purpose I need use only the LibEAY32.pas file coupled with the LibEAY32.dll file. We're using version 1.0.2 of this, and the Delphi-OpenSSL project is compatible with that. Great!
I needed to make a few minor changes, as despite the programmers' best efforts it seemed confused about the difference between Char and AnsiChar in Delphi 2009, but the changes were minimal and consisted, almost entirely, of me replacing references to PChar or PCharacter with PAnsiChar.
The next challenge was to see if I could use an existing key to encrypt a file.
I added my modulus, public exponent and private exponent (not needed for encryption) as Base64 encoded string constants and used:
_rsa = RSA_New();
to create a new RSA structure to populate with the key information. This actually returns a pointer to an RSA object, so it needs both dereferencing and casting when used. The properties we're interested in are the modulus, n; the public exponent, e; and the private exponent, d (when decrypting, later).
These properties take the form of BigNum objects as they can be sometimes thousands of bits long. The BigNums need to be created before being used:
RSA(_rsa^).n := BN_New();
RSA(_rsa^).e := BN_New();
The Base64 values were then decoded and altered, one byte at a time, to hex using IntToHex (which returns a string) and then BN_HexToBN was used to set the RSA record's properties accordingly:
BN_HexToBN(RSA(_rsa^).n, ansistring(public_modulus));
BN_HexToBN(RSA(_rsa^).e, ansistring(public_exponent));
The input string can then be encrypted by calling:
enc_in := SysUtils.TEncoding.ASCII.GetBytes(string(input_text));
to get the string character values as a byte array, followed by:
RSA_Public_Encrypt(length(enc_in),PAnsiChar(enc_in), PAnsiChar(@textout),_rsa,RSA_PKCS1_PADDING);
to do the actual encryption. The output cypher text is held in textout. This will look like garbage but can be converted to a Base64 string for convenient storage.
And that's it.
Two caveats:
I had to add an extra property to the RSA record to match the version of OpenSSL we're using. This was:
engine: pointer;
below the meth property.
And I had to initialise the SSL library by calling:
SSLEay_version(_SSLEAY_VERSION);
before making any calls to encryption or decryption routines. There's probably a better way to do this, but this did the trick.
I put this information here in the hope that it helps someone else who struggled as much as I did to implement this!
(This has nothing to do with Welsh)
About
Around 12 years ago I wrote and released a small PC game called "Help Hannah's Horse". It was essentially a variation on Pacman - collect the coins scattered about the maze while avoiding the ghosts and gathering the moving carrots and the powerups that appear from time to time. A few people played it and it got included in the Debian Linux repositories.
Recently I got thinking about that game again and thought it would be nice to give it a bit more polish and change the music. The music particularly has always niggled me; not because it's bad (it's great!) but because I found it online and just used it. I never credited the composer and never checked if it was free for non-commercial use. I have no idea where I found it, so unfortunately I can't correct this now. I don't even know the name of the piece as I renamed the file to just "bgm1.ogg". I needed to either find royalty-free music that fit the mood of the game, or write a piece myself. I took the latter approach.
Anyway, after a couple of weeks of tidying code, fixing bugs, composing music and redrawing some graphics, I have released version 1.2 of the game!
Screenshot
Here's Hannah merrily running around level 1 collecting the gold coins and moving carrots and avoiding the ghosts. The green potion makes Hannah invulnerable for a short time if she collects it.
Download
It's available on my Sourceforge page (
http://hannah.sourceforge.net) for Windows and in source code form for other platforms, if you're so inclined. There's a Makefile for Linux included.

I've realised that this blog has strayed somewhat from my original aim of it being about my journey of learning Welsh, and more just my opinion on various language-related things.
So, in a return to its true purpose, this post is a review of the book "Yn Ei Gwsg" (In His Sleep) by Bethan Gwanas.
Dafydd walks in his sleep. It's part of the reason, he suspects, for the breakup of his marriage and it gets him into all sorts of odd situations with his neighbours. One morning, however, it takes a more sinister turn when he wakes up covered in blood - not his own - and sets off with his faithful dog Wmffra to follow the bloody footprints to find out to whom the blood belongs.
The book is not nearly as dark as that synopsis makes it sound. It's actually very light-hearted, humorous and a touch sad in places. Bethan Gwanas writes novels for native Welsh speakers as well as learners, and I think that helps her keep this novel simple yet clearly aimed at adults. The language used has clearly been thought about so that the level remains suitable for the target audience, yet also shows a progression from start to finish and introduces new words and phrases.
I really enjoyed reading it. Unusually for me, I found I could hardly put it down. I think this was partly because it was genuinely an enjoyable story, and partly because the level was pretty much spot-on for my ability (this is set as Lefel Sylfaen) so I found I was able to read straight through most pages without having to resort to a dictionary (the glossary of new terms at the bottom of each page, as is common for Welsh-for-adults books, helps enormously). The language used is more northern in style, but I didn't find this a hindrance at all - in fact it helped to cement some knowledge of northern dialect that I'm bound to encounter in the wild anyway.
The last book I read before this was "Ffenestri" by Lois Arnold. If you've read up to the end of the Sylfaen level in that, you shouldn't have any problems with this and I'd recommend it as not only a good book for learners, but a good read in its own right.
If you're spending more time at home at the moment than perhaps you'd like, one of the ways to avoid going mad and to use the time productively is to learn a skill. Learn to paint, learn photography, learn an instrument, or... learn a language!
With so many resources for so many languages available online for free, now is a great time to start learning whatever language takes your fancy.
Obviously I would suggest Welsh, but learning any language is fun and often helps improve your understanding and appreciation of your own, native language.
So... if you're bored being at home and need something to do, that's my suggestion.
Last month, I completed the Welsh tree on DuoLingo. By "completed" I mean that I got all of the units up to at least level 2. That means I've covered material up to and including Canolradd level. I should be practically fluent by now, right?
Errr, no. I'm doing OK reading through my Welsh short stories book ("Ffenestri", by Lois Arnold - I highly recommend it) and I'm understanding more on Radio Cymru each time, but I just don't get enough chances to speak for my brain to engage quickly enough when I need to put a sentence together.
That said, DuoLingo has definitely helped broaden my vocabulary, and I'm often surprised by the sorts of sentences I can put together, but I don't think DuoLingo alone can get you fluency. For that, much more exposure to the spoken language and the way people speak it is needed.
This is something I've started feeling quite strongly about lately, although I admit I'm partial to a bit of bias given my current enthusiasm for Cymraeg, but...
...why don't we teach Welsh as a second language in England? I say England because in Scotland and Northern Ireland they already have native languages that should be taught, but England does not.
I know some people will think, "Are you mad?!" but hear me out; my reasoning is sound:
1. Many children are more likely to visit Wales than Germany. German is taught in many British schools, yet British tourists to Germany number around 2 million per year compared to 10 million in Wales (2015 figure). This means more chance to practice a language learnt in school.
2. Welsh is the language of these islands. English people may not appreciate this, but our ancestors spoke something similar to Welsh. Before the Romans, Saxons and then Normans invaded, the native languages of these islands were the Brythonic languages, of these Welsh is the one currently in the healthiest state. Learning Welsh is a link to our past, even as Englishmen.
3. Learning any language has benefits beyond just that language. Learning one language helps a child understand other languages and their own language much better. There is nothing to be lost by learning Welsh and much to be gained.
4. Welsh is different. Welsh is not like French, German or Spanish; the languages children usually learn in school. The structure is different and it borrows little from Romance or Germanic languages. Learning Welsh gives children a different perspective on language learning yet remains relevant as it's spoken as a living language by 700,000 people and is an official language of the UK, unlike Cantonese, Mandarin or Satsuma ;)
5. Welsh is easy. Well, sort of. As I've covered previously, simple Welsh sentences in the past, present and future tenses can involve very little conjugation beyond the verb "bod" (to be). This makes progress fast and enthuses children to learn. Why spend two years mastering present tense conjugations in French when you can learn the same sentences in Welsh in a fraction of the time?
Not everyone will agree with me. I know the counter argument will be "but more people speak language X than speak Welsh!" or the usual "Welsh is a dead language! What's the point?!". But Welsh is growing. By teaching it as a second language it will grow more and these questions will answer themselves.
If you're learning a language, one of the best ways to gain exposure to that language and increase fluency is to visit a country where that language is spoken.
Herein lies the problem with Welsh: not all Welsh people speak it. They all speak English, but only around 20% of the population speaks Welsh. This means that if I'm in Wales, I can't initiate a conversation in Welsh because I can't guarantee that the other person will be a Welsh speaker.
Such a situation, where a native does not speak the native language, would be inconceivable in most other countries.
The fact that there are no monoglot Welsh speakers remaining also doesn't help. Because everyone speaks English fluently there's less incentive to make the effort to learn and speak Welsh.
Then there's the problem with signage. In France, other than at some touristy areas, all signs are in French. Signs alerting me to the "dèrniere sortie avant péage" will do so only in French. Translating and understanding the signs becomes part of the learning experience. Unfortunately, in Wales most signs are bilingual. The order of the languages is left to the discretion of the local authority, but an English translation will be on the sign somewhere. On the one hand, this allows you to quickly confirm that your translation of the Welsh was correct. On the other, it takes a lot of the fun and the necessity out of translating in the first place. It's very hard not to notice the English accidentally before you've had chance to attempt the Welsh.
What I have discovered, to my surprise and delight, is that several of my colleagues speak varying levels of Welsh. Remember, this is Somerset, England, not the north of Wales, so it's not entirely expected. One even speaks fluent Welsh, having attended a Welsh medium school. And he's said he's always happy to help with my Welsh learning.
So things are looking up.
One of the more daunting things about Welsh which is common to all the Celtic languages is the concept of mutations: consonants that change to a different letter, or even group of letters, depending on context.
As an English speaker and someone who has learnt German and French in the past, this is a truly alien concept. German may have given us some pretty monstrous words, but at least they're always spelt the same way whenever you encounter them. The French may be sloppy when pronouncing the ends of their words, but at least the beginnings don't go changing.
In Welsh, however, certain initial consonants of words change to other consonants. This is a mutation, and exists in all the Celtic languages of the British Isles in various forms. Welsh has three types of mutation: soft, nasal and aspirate (which I won't go into here). The most common of these is the soft mutation. What this means, in practical terms, is that in certain circumstances the following letter changes occur at the start of a word:
c becomes g
p becomes b
t becomes d
d becomes dd
b and m become f
ll becomes l
rh becomes r
and g vanishes entirely!
One of the occasions these mutations occur is when a singular feminine noun follows the definite article "Y". So "cath" (a cat) becomes "y gath" (the cat). "Mam" (Mother) becomes "y fam" (the Mother). And so on. This change also occurs when we are going "from" or "to" somewhere. If we go "to Wales", for example, it's "i Gymru" with the usual C replaced by a G. I'm still getting accustomed to the various reasons for the soft mutation, and there are lots of them.
Then we have the nasal mutation. This is much less common, and comprises the following consonant changes, which I had to look up because they're not all yet very natural to me:
p -> mh
t -> nh
c -> ngh
b -> m
d -> n
g -> ng
I've principally encountered this mutation when saying I am "in" somewhere. As with the Cymru -> Gymru change above when we go to Wales, we change C to Ngh when we are in Wales. So one can like Cymru, go to Gymru, but be in Nghymru... argh! Still, all languages have their quirks, and the world would be a very boring place without these differences.
The purpose of mutations, so I've been led to believe, is to improve the flow of the language. I kind of buy that. Kind of. I can see that the words trip off the tongue a little better in the case of the nasal mutation ("my car" would be "fy car" ("vuh car") without the change but becomes "fy nghar" ("vunghar") with it), but I can't really see how abitrary changes to feminine singular nouns help the flow.
Still, it is what it is, and it's all part of language's rich tapestry!