| 1 | #!/usr/bin/env perl | ||
| 2 | use 5.008003; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | BEGIN { eval { require blib; blib->import } } # use ./blib in-tree if present | ||
| 6 | use Same::Boy::Terminal; | ||
| 7 | |||
| 8 | # --------------------------------------------------------------------------- | ||
| 9 | # termboy.pl - a playable terminal frontend for Same::Boy. | ||
| 10 | # | ||
| 11 | # termboy.pl ROM.gbc [--scale N] [--model cgb|dmg|sgb|sgb2|mgb] | ||
| 12 | # | ||
| 13 | # See Same::Boy::Terminal for the emulator loop, controls, and rendering. | ||
| 14 | # --------------------------------------------------------------------------- | ||
| 15 | |||
| 16 | my ($rom_path, $scale, $model) = (undef, 1, 'cgb'); | ||
| 17 | while (@ARGV) { | ||
| 18 | my $a = shift @ARGV; | ||
| 19 | if ($a eq '--scale') { $scale = shift @ARGV || 1 } | ||
| 20 | elsif ($a eq '--model') { $model = shift @ARGV || 'cgb' } | ||
| 21 | elsif ($a =~ /^--/) { die "unknown option $a\n" } | ||
| 22 | else { $rom_path = $a } | ||
| 23 | } | ||
| 24 | die "usage: $0 ROM.gbc [--scale N] [--model cgb|dmg|sgb|sgb2|mgb]\n" | ||
| 25 | unless defined $rom_path && -f $rom_path; | ||
| 26 | |||
| 27 | my $term = Same::Boy::Terminal->new( | ||
| 28 | rom_path => $rom_path, | ||
| 29 | scale => $scale, | ||
| 30 | model => $model, | ||
| 31 | ); | ||
| 32 | |||
| 33 | my $had_battery = $term->run; | ||
| 34 | print "saved battery to ${\ $term->sav_path}\n" if $had_battery; |