Permalink
Browse files

Cleaned up (got rid of) outdated files

  • Loading branch information...
1 parent b2afac9 commit 4a2e7db94ffa54e29352209c32768754b02d8b86 @Blaizer committed Oct 6, 2011
View
34 base
@@ -1,34 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-
-use SDL;
-use SDLx::Surface;
-use SDL::Video;
-use SDL::Image;
-
-my $bas = "img/$ARGV[0]";
-$bas =~ s/\/(?!.*\/).*/\//;
-die "no base" unless -f "${bas}base.bmp";
-my $img = SDLx::Surface->new(surface => SDL::Image::load("${bas}base.bmp"));
-my $base = SDLx::Surface->new(w => $img->w, h => $img->h, d => 24);
-$img->blit($base);
-$base = [ map \@{$base->[$_]}, 0..$base->w-1 ];
-
-while(glob "img/$ARGV[0]*.bmp") {
- next if /(?:^|\/)base\.bmp$/ or /\/B(?!.*\/)/ or /^B(?!.*\/)/;
- my $img = SDLx::Surface->new(surface => SDL::Image::load($_));
- my $surf = SDLx::Surface->new(w => $img->w, h => $img->h, d => 24);
- $img->blit($surf);
-
- for my $x (0..$surf->w-1) {
- for my $y (0..$surf->h-1) {
- if($surf->[$x][$y] == ($base->[$x][$y])) {
- $surf->[$x][$y] = 0x2df07aff; #random non-8-bit colour
- }
- }
- }
-
- s/\/(?!.*\/)/\/B/ or s/^/B/;
- SDL::Video::save_BMP($surf, $_) and die "Could not save bmp: " . SDL::get_error;
-}
View
18 crop
@@ -1,18 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-
-use SDL;
-use SDLx::Surface;
-use SDL::Video;
-use SDL::Image;
-
-for(grep { !/\/C(?!.*\/)/ and !/^C(?!.*\/)/ } glob "img/$ARGV[0]*.bmp") {
- my $surf = SDLx::Surface->new(surface => SDL::Image::load($_));
- my $crop = SDLx::Surface->new(w => $ARGV[3], h => $ARGV[4], d => $surf->format->BitsPerPixel);
-
- $surf->blit($crop, [ @ARGV[1..4] ], undef);
-
- s/\/(?!.*\/)/\/C/ or s/^/C/;
- SDL::Video::save_BMP($crop, $_) and die "Could not save bmp: " . SDL::get_error;
-}
View
65 dup
@@ -1,65 +0,0 @@
-#!/usr/bin/env perl
-use strict;
-use warnings;
-
-use SDL;
-use SDLx::Surface;
-use SDL::Image;
-
-my @name = sort glob "img/$ARGV[0]*.bmp";
-for(@name) {
- my $old = $_;
- if(s/\/D(?!.*\/)/\// or s/^D(?!.*\/)//) {
- rename $old, $_;
- }
-}
-my @file = map SDLx::Surface->new(surface => SDL::Image::load($_)), @name;
-my @sequence;
-for my $first (0..$#file-1) {
- my $s1 = $file[$first];
- if(ref $s1) {
- push @sequence, $first;
- for my $second (grep ref $file[$_], $first+1..$#file) {
- my $s2 = $file[$second];
- if($s1->w == $s2->w and $s1->h == $s2->h) {
- DUP: {
- for my $x (0..$s1->w-1) {
- for my $y (0..$s1->h-1) {
- last DUP if $s1->[$x][$y] != $s2->[$x][$y];
- }
- }
- $file[$second] = $first;
- local $_ = $name[$second];
- s/\/(?!.*\/)/\/D/ or s/^/D/;
- rename $name[$second], $_;
- }
- }
- }
- }
- else {
- push @sequence, $file[$first];
- }
-}
-push @sequence, ref $file[$#file] ? $#file : $file[$#file];
-
-my @new;
-$#new = $#sequence;
-
-my ($look, $actually) = (0, 0);
-while(grep !defined, @new) {
- my $found;
- for(0..$#sequence) {
- if($sequence[$_] == $look) {
- $new[$_] = $actually;
- $found = 1;
- }
- }
- if($found) {
- $actually++;
- }
- $look++;
-}
-
-open SEQUENCE, ">img/$ARGV[0]sequence.txt" or die join ", ", @new;
-print SEQUENCE join ", ", @new;
-close SEQUENCE;
@@ -35,7 +35,7 @@ int NHC_BS_seek(NHC_BS* bs, int bytes) {
int NHC_BS_offset(NHC_BS* bs, int bytes) {
bs->byte_offset = bytes;
-
+ bs->bit_offset = 0;
}
int NHC_BS_tell(NHC_BS* bs) {
@@ -70,8 +70,8 @@ Uint16 NHC_BS_get_16(NHC_BS* bs) {
;
}
return
- (Uint16)bs->buffer[bs->byte_offset++] |
- (Uint16)bs->buffer[++bs->byte_offset] << 8
+ bs->buffer[bs->byte_offset++] |
+ bs->buffer[++bs->byte_offset] << 8
;
}
@@ -287,6 +287,12 @@ NHC_VID* NHC_VID_new(const char* filename) {
vid->bs = NHC_BS_new(file);
NHC_BS_read(vid->bs, vid->header->trees_size);
+ printf("%d\n", vid->header->trees_size);
+ printf("%d\n", vid->header->mmap_size);
+ printf("%d\n", vid->header->mclr_size);
+ printf("%d\n", vid->header->full_size);
+ printf("%d\n", vid->header->type_size);
+
// vid->mmap_tree = NHC_VID_Tree_New(vid->bs);
// vid->mclr_tree = NHC_VID_Tree_New(vid->bs);
// vid->full_tree = NHC_VID_Tree_New(vid->bs);
@@ -1,108 +0,0 @@
-use 5.01;
-use strict;
-use warnings;
-package Games::Neverhood::Video::BitStream;
-
-use constant CHUNK_SIZE => 512;
-
-sub new {
- my ($class, $fh) = @_;
- bless {
- fh => $fh,
- byte_off => CHUNK_SIZE,
- bit_off => 8,
- }, ref $class || $class;
-}
-
-sub read_1 {
- my ($self) = @_;
- if($self->{bit_off} >= 8) {
- $self->{bit_off} = 0;
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- $self->{cur} = ord substr $self->{buf}, $self->{byte_off}, 1;
- }
- return $self->{cur} >> $self->{bit_off}++ & 1;
-}
-
-sub read_8 {
- my ($self) = @_;
- if($self->{bit_off} >= 8) {
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- return ord substr $self->{buf}, $self->{byte_off}, 1;
- }
- my $ret = $self->{cur} >> $self->{bit_off};
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- $self->{cur} = ord substr $self->{buf}, $self->{byte_off}, 1;
- return $ret | $self->{cur} << 8 - $self->{bit_off} & 0xFF;
-}
-
-sub read_16 {
- my ($self) = @_;
- my $ret;
- if($self->{bit_off} >= 8) {
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- $ret = ord substr $self->{buf}, $self->{byte_off}, 1;
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- return $ret | ord(substr $self->{buf}, $self->{byte_off}, 1) << 8;
- }
- $ret = $self->{cur} >> $self->{bit_off};
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- $ret |= ord(substr $self->{buf}, $self->{byte_off}) << 8 - $self->{bit_off};
- if(++$self->{byte_off} >= CHUNK_SIZE) {
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{byte_off} = 0;
- }
- $self->{cur} = ord substr $self->{buf}, $self->{byte_off}, 1;
- $ret | $self->{cur} << 16 - $self->{bit_off} & 0xFFFF;
-}
-
-sub reset {
- my ($self) = @_;
- $self->{byte_off} = -1;
- $self->{bit_off} = 8;
-}
-
-sub tell {
- my ($self) = @_;
- tell($self->{fh})*8 + $self->{bit_off};
-}
-
-sub seek {
- my ($self, $pos) = @_;
-
- if($pos % 8) {
- $self->{bit_off} = $pos % 8;
- $self->{byte_off} = 0;
-
- seek $self->{fh}, int($pos / 8), 0;
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- $self->{cur} = ord $self->{buf};
- }
- else {
- $self->{byte_off} = -1;
- $self->{bit_off} = 8;
-
- seek $self->{fh}, int($pos / 8), 0;
- read $self->{fh}, $self->{buf}, CHUNK_SIZE;
- }
-}
-
-1;
@@ -1,93 +0,0 @@
-use 5.01;
-use strict;
-use warnings;
-package Games::Neverhood::Video::Huffman::BigTree;
-
-use Games::Neverhood::Video::BitStream;
-use Games::Neverhood::Video::Huffman::Tree;
-
-sub new {
- my ($class, $bit) = @_;
- my $self = bless {}, ref $class || $class;
-
- return $self unless $bit->read_1;
-
- $self->{low_byte_tree} = Games::Neverhood::Video::Huffman::Tree->new($bit);
- $self->{high_byte_tree} = Games::Neverhood::Video::Huffman::Tree->new($bit);
-
- $self->{marker_1} = $bit->read_16;
- $self->{marker_2} = $bit->read_16;
- $self->{marker_3} = $bit->read_16;
-
- $self->{marker_1_node} = [];
- $self->{marker_2_node} = [];
- $self->{marker_3_node} = [];
-
- $self->build_tree_recurse($bit, $self->{tree} = []);
-
- $bit->read_1;
-
- $self;
-}
-
-sub build_tree_recurse {
- my ($self, $bit, $node) = @_;
- if($bit->read_1) {
- $self->build_tree_recurse($bit, $node->[0] = []);
- }
- else {
- warn 'what going on' if @$node;
- my $leaf = $self->{low_byte_tree}->decode($bit) | $self->{high_byte_tree}->decode($bit) << 8;
- if($leaf == $self->{marker_1}) {
- $self->{marker_1_node} = $node;
- $leaf = 0;
- }
- if($leaf == $self->{marker_2}) {
- $self->{marker_2_node} = $node;
- $leaf = 0;
- }
- if($leaf == $self->{marker_3}) {
- $self->{marker_3_node} = $node;
- $leaf = 0;
- }
- $node->[0] = $leaf;
- return;
- }
- $self->build_tree_recurse($bit, $node->[1] = []);
-}
-
-sub decode {
- my ($self, $bit) = @_;
- my $node = $self->{tree};
- unless($node) {
- # warn 'trying to read from nonononono bigtree';
- return 0;
- }
- while(@$node > 1) {
- $node = $node->[$bit->read_1];
- }
- my $val = $node->[0];
- if($val != $self->{marker_1}) {
- $self->{marker_3} = $self->{marker_2};
- $self->{marker_2} = $self->{marker_1};
- $self->{marker_1} = $val;
-
- $self->{marker_3_node}[0] = $self->{marker_2_node}->[0];
- $self->{marker_2_node}[0] = $self->{marker_1_node}->[0];
- $self->{marker_1_node}[0] = $val;
- }
- return $val;
-}
-
-sub reset {
- my ($self) = @_;
- $self->{marker_1} = 0;
- $self->{marker_2} = 0;
- $self->{marker_3} = 0;
-
- $self->{marker_1_node}[0] = 0;
- $self->{marker_1_node}[1] = 0;
- $self->{marker_1_node}[2] = 0;
-}
-
-1;
Oops, something went wrong.

0 comments on commit 4a2e7db

Please sign in to comment.