bin2cas.pl updated

A place to discuss everything Dragon related that doesn't fall into the other categories.
sixxie
Posts: 1344
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: bin2cas.pl updated

Post by sixxie »

I'm not sure of Perl's ability to use a pipe under Windows - that message seems to imply it's not going to work!

Can you upload an example of the WAV output? Might be possible to see what's going wrong from what ends up in it.

The script rewrites bytes in the wav header once it knows the total length by seeking and rewriting - maybe that's being messed up. I guess, "does it load in XRoar?" might be a useful question, too!
sorchard
Posts: 529
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: bin2cas.pl updated

Post by sorchard »

sixxie wrote:Something like that! It compresses well...
I'm simultaneously impressed by the compression ratio you've achieved and apalled by the redundancy in my code! Which algorithm are you using? It has the not unpleasant whiff of LZ77 about it.

I'll take the secret of the cheat mode to the grave with me then ;)

I suck at my own game. If I make it past the unfortunate dog and into the salad then I'm doing well. The spinning things that move across the middle of the screen are my nemesis, and I can report exactly the same problem with the keyboard controls. It seemed perfect to me when I was a teenager but now it just feels wrong.

I know of one person who completed the game... It was Simon Harrison aka "Dudley the Incredible Games Playing Goldfish" who went to the same school & sixth form as me :)
Stew
sorchard
Posts: 529
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: bin2cas.pl updated

Post by sorchard »

sixxie wrote:Can you upload an example of the WAV output? Might be possible to see what's going wrong from what ends up in it.
Please see attached working cas & non-working wav. I couldn't get the wav to load into xroar.
Attachments
test.zip
(25.74 KiB) Downloaded 141 times
Stew
sixxie
Posts: 1344
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: bin2cas.pl updated

Post by sixxie »

So yes, looks like it's not rewriting the chunk sizes at the beginning of the file. I suspect that's because of the dubious "reopen stdout" approach I was taking (and then effectively seeking within stdout - works under Linux!), so I've uploaded a new version that opens an explicit filehandle - hopefully Windows Perl will be happier with that.
sorchard wrote: I'm simultaneously impressed by the compression ratio you've achieved and apalled by the redundancy in my code!
Nothing to be ashamed of! Loop unrolling to make stuff fast would naturally introduce a lot of redundancy... Just one of the trade-offs.
Which algorithm are you using? It has the not unpleasant whiff of LZ77 about it.
Yeah exactly that, plus the ability to flag a run of literals. Here's the "spec", such as it is:

Code: Select all

; 1iiiiiii 0nnnnnnn - repeat 128-n (1-128) bytes from current + 1i (-ve 2s cmpl)
; 1iiiiiii 1jjjjjjj nnnnnnnn - repeat 128-n (1-256) bytes from current + 1ij
; 0nnnnnnn - directly copy next 128-n (1-128) bytes
That "128-" stuff is purely to make the dunzip 6809 code tighter ;)
I'll take the secret of the cheat mode to the grave with me then ;)
Sounds like a challenge ;)
sorchard
Posts: 529
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: bin2cas.pl updated

Post by sorchard »

It worked! The output file is now full of wavy goodness :-)

Ooh that unzip code is just so smart. Plus it's so tiny it can be used to unpack during runtime. Excellent stuff.

Rather than wine about it I thought I would have a look at the bin2cas script to see if I could figure out why calling dzip isn't working under windows. Sadly it would appear that a certain level of knowledge of perl is required to even read it so it may take me some time to get to grips with it. After that I'll tackle malbolge ;)
Stew
sixxie
Posts: 1344
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: bin2cas.pl updated

Post by sixxie »

Heh, Perl's not that bad! It's very C-like, with some awk and sed thrown in to make it more directly powerful...

It does occur to me that this particular project would have been an ideal vector for learning more python, but in reality it does need to become C, so I can build dzip directly into it.

Probably a kludge solution to this would be to have it write out to a temp file, then read the results from a pipe to "dzip -c tmpfile". IIRC there's a builtin global variable you can consult to see what platform it's running on, so I'll look into making it do that only under Windows.
sixxie
Posts: 1344
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: bin2cas.pl updated

Post by sixxie »

Ok, kludge built! Can you test the version of bin2cas.pl under http://www.6809.org.uk/tmp/xroar/? The code works under Linux. I should get a Windows version of Perl pulled down to test under Wine - what are you using? Strawberry?
sorchard
Posts: 529
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: bin2cas.pl updated

Post by sorchard »

I certainly appreciate the customer support but it looks like it's not going to play fair:

"List form of pipe open not implemented at C:\devtools\bin2cas.pl line 865"

I chose ActiveState purely because it was at the top of a list of suggestions. Happy to ditch it and use Strawberry if you think this would be better.
Stew
sixxie
Posts: 1344
Joined: Fri Jul 18, 2008 8:36 am
Location: Hertfordshire
Contact:

Re: bin2cas.pl updated

Post by sixxie »

I've just pulled down strawberry and it has the exact same issue. Rasserfrassen!

Ok, I've avoided all pipes completely now and just make system calls then read in the results. And it works under Wine with strawberry!
sorchard
Posts: 529
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: bin2cas.pl updated

Post by sorchard »

:) Now working with ActiveState! Thanks sixxie, I'll buy you a drink if I catch up with you.

The windows command shell does have pipes in the sense that it's possible to send the output of one command 'through' another command, (trivial example "dir | more" to pause directory listing) but I have zero knowledge of perl and can't offer any further insight. I'm tempted to learn though.
Stew
Post Reply