--- VRac.pm 2007/08/05 13:27:27 145 +++ VRac.pm 2007/08/05 17:59:29 158 @@ -3,7 +3,7 @@ use warnings; use strict; -use Carp qw/confess croak/; +use Carp qw/confess croak cluck carp/; use File::Slurp; use Data::Dump qw/dump/; @@ -29,6 +29,14 @@ This project is homage to 8-bit computers in Croatia and former Yugoslavia from 1980-1990. Word B means also I in Croatian. +This project should enable anyone with limited knowledge of perl and 8-bit +arhitecture of some machine to write emulator in an afternoon. To achieve this, +code is written is as cleanly as possible. + +Porting existing emulators should be especially easy: you need passive +understaning of language in which emulator is written and you can be on your +way C<:-)> + =cut =head1 FUNCTIONS @@ -193,9 +201,21 @@ my $path = shift || confess "no path?"; my $bytes = join('', @_); + my $size = -s $path || 0; + my $len = length($bytes); + open(my $fh, '>>', $path) || confess "can't open $path: $!"; + print($fh $bytes); + my $pos = tell($fh); + + my $expected = $size + $len; + if ( $pos != $expected ) { + cluck "BUG: file grows too big got $pos, expected $expected !"; + truncate $fh, $expected; + } + + close($fh); - print $fh $bytes; warn sprintf("## append_to_file('%s',%s)\n", $path, dump($bytes)); } @@ -346,7 +366,7 @@ =head1 SEE ALSO -Components: L, L, L, L +Components: L, L, L, L, L Emulators: L, L @@ -354,10 +374,13 @@ Dobrica Pavlinusic, C<< >> -=head1 BUGS - =head1 ACKNOWLEDGEMENTS +Structure and Interpretation of Computer Programs by Abelson, Sussman, and +Sussman L is a great book. It gave me idea +that you should have wizard powers over your computer, even if it's 8 bit +one. + =head1 COPYRIGHT & LICENSE Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.