Created
March 11, 2012 21:40
-
-
Save BlockoS/2018306 to your computer and use it in GitHub Desktop.
Search for the 2 bytes preceding the jsr 7d98 instruction in a PC Engine rom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use File::stat; | |
die "You must specify a rom name!" unless ($#ARGV == 0); | |
my $rom = 0; | |
my $fileSize = stat($ARGV[0])->size; | |
open(FILE, "<$ARGV[0]") or die $!; | |
my $nRead = read(FILE, $rom, $fileSize); | |
close(FILE); | |
die "Unexpected error!" unless ($nRead == $fileSize); | |
my $max = 0; | |
# Find 'byte' in : | |
# lda byte | |
# jsr $7d98 | |
while($rom =~ m/(\C)(\C)\x20\x98\x7d/gs) | |
{ | |
my ($opcode, $value) = ($1, $2); | |
print pos($rom) . " : " . unpack("H*", $value); | |
my $tmp = unpack("C", $value); | |
$max = $tmp if($tmp > $max); | |
print " !LDA" unless (unpack("C", $opcode) == 0xa9); | |
print "\n"; | |
} | |
printf("Max: %x", $max); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment