diff options
Diffstat (limited to 'jindroush/chkrom')
-rw-r--r-- | jindroush/chkrom/Makefile | 56 | ||||
-rw-r--r-- | jindroush/chkrom/chkrom.cpp | 119 | ||||
-rw-r--r-- | jindroush/chkrom/pub.def | 31 | ||||
-rw-r--r-- | jindroush/chkrom/readme.txt | 56 | ||||
-rw-r--r-- | jindroush/chkrom/switches.def | 5 |
5 files changed, 267 insertions, 0 deletions
diff --git a/jindroush/chkrom/Makefile b/jindroush/chkrom/Makefile new file mode 100644 index 0000000..19bf6f4 --- /dev/null +++ b/jindroush/chkrom/Makefile @@ -0,0 +1,56 @@ +#===================================================================== +PRGNAME = chkrom + +all: $(PRGNAME) + +release: + @$(MAKE) $(PRGNAME) CFLAGS="-c -O2 -Wall" LDFLAGS="" + @echo RELEASE: Compiled. + +rel_strip: + @strip $(PRGNAME).exe + +rel_inst: + @copy $(PRGNAME).exe $(ATAROOT)\\bin + @echo RELEASE: Installed. + +debug: + @$(MAKE) $(PRGNAME) CFLAGS="-c -g -Wall -D_DEBUG" LDFLAGS="-g" + @echo DEBUG: Compiled. + +clean: + rm -f *.o + rm -f $(PRGNAME) + rm -f $(PRGNAME).exe + rm -f switches.cpp + rm -rf rel + @echo DEBUG: Cleaned. + +#===================================================================== +INCLUDES = makefile \ + pub.def \ + switches.def + + +OBJECTS = chkrom.o + +#===================================================================== +CC = g++ +LD = g++ +LDLIBS = -lm -L../lib -ljindroush +CPPFLAGS=-I../include $(COPT) +COPT=-O2 + +#===================================================================== + +$(PRGNAME) : $(OBJECTS) + $(LD) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $(PRGNAME) + +chkrom.o: chkrom.cpp switches.cpp + +%.o : %.cpp $(INCLUDES) + $(CC) $(CPPFLAGS) -c $< -o $@ + +switches.cpp : switches.def ../switches.pl + perl ../switches.pl $< $@ + diff --git a/jindroush/chkrom/chkrom.cpp b/jindroush/chkrom/chkrom.cpp new file mode 100644 index 0000000..32c8979 --- /dev/null +++ b/jindroush/chkrom/chkrom.cpp @@ -0,0 +1,119 @@ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +//#include <unistd.h> +#include "pub.def" +#include "jintypes.h" +#include "at_dis.h" + +BOOL g_bDisassemble = FALSE; + +int hIn = -1; + +char* g_szInfile = NULL; + +#define SHEADER PRG_NAME " v" PRG_VERSION " (c) " PRG_COPYRIGHT " " PRG_AUTHOR "\n" + +#define HEADER SHEADER \ + PRG_DESC "\n" \ + " Latest version can be found at " PRG_URL "\n" \ + " Published under GPL. See GPL.TXT.\n\n" + +#define USAGE HEADER "Usage: " PRG_NAME " " PRG_USAGE + +#include "switches.cpp" + +int main (int argc,char *argv[]) +{ + setbuf( stdout, NULL ); + setbuf( stderr, NULL ); + + if ( !SWITCHES_Init( &argc, argv ) ) + return 1; + + if ( argc < 2 ) + { + SWFN_HELP( USAGE ); + return 1; + } + + fprintf( stderr, SHEADER ); + + g_szInfile = argv[ 1 ]; + + hIn = open( g_szInfile, O_RDONLY | O_BINARY ); + + if ( hIn == -1 ) + { + fprintf(stderr, "Unable to open file\n\n%s", g_szInfile ); + exit( 1 ); + } + + LONG lFileLen = lseek( hIn, 0, SEEK_END ); + + lseek( hIn, 0, SEEK_SET ); + + if ( ( lFileLen != 0x2000 ) && ( lFileLen != 0x4000 ) ) + { + printf( "%s: Unknown ROM size\n", g_szInfile ); + close( hIn ); + exit( 1 ); + } + + printf( "ROM file: %s\n", g_szInfile ); + + BYTE pbtMem[ 0x4000 ]; + + read( hIn, pbtMem, lFileLen ); + + WORD wInit = pbtMem[ lFileLen - 2 ] + ( pbtMem[ lFileLen - 1 ] << 8 ); + WORD wFlags = pbtMem[ lFileLen - 4 ] + ( pbtMem[ lFileLen - 3 ] << 8 ); + WORD wRun = pbtMem[ lFileLen - 6 ] + ( pbtMem[ lFileLen - 5 ] << 8 ); + + WORD wStart = ( lFileLen == 0x2000 ) ? 0xA000 : 0x8000; + + printf( "Init Addr :%04X\n", wInit ); + printf( "Run Addr :%04X\n", wRun ); + printf( "Flags :%04X ( ", wFlags ); + + if ( wFlags & 0x0400 ) + { + printf( "INIT&RUN " ); + } + else + printf( "INIT " ); + + if ( wFlags & 0x0100 ) + printf( "BOOT " ); + + if ( wFlags & 0x8000 ) + printf( "TESTMOD " ); + + printf( ")\n" ); + + if ( g_bDisassemble ) + { + printf( "\n" ); + OutputBlockDiss( pbtMem, wStart, wStart + lFileLen - 1 - 6 ); + printf( "\n" ); + } + + printf( "Ok!\n" ); + + close( hIn ); + + return 0; +} + diff --git a/jindroush/chkrom/pub.def b/jindroush/chkrom/pub.def new file mode 100644 index 0000000..f888d12 --- /dev/null +++ b/jindroush/chkrom/pub.def @@ -0,0 +1,31 @@ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// + +#define PRG_NAME "chkrom" +#define PRG_VERSION "1.00" +#define PRG_COPYRIGHT "1998-1999" +#define PRG_UNDERGPL "1" +#define PRG_AUTHOR "Jindrich Kubec <kubecj@asw.cz>" + +#define PRG_URL "http://www.asw.cz/~kubecj" + +#define PRG_DESC "Atari cartridge ROM 8/16 decompiler." +#define PRG_USAGE "[options] sourcefile" + +#define PRG_ARCH "PC" +#define PRG_TOOLS "PERL" + +#define PRG_SRCS "!GENERATED!" +#define PRG_BINS "rel/chkrom.exe" diff --git a/jindroush/chkrom/readme.txt b/jindroush/chkrom/readme.txt new file mode 100644 index 0000000..7f3c12b --- /dev/null +++ b/jindroush/chkrom/readme.txt @@ -0,0 +1,56 @@ +ChkRom v1.00 (c) 1998-1999 Jindrich Kubec <kubecj@asw.cz> +Latest version can be found at http://www.asw.cz/~kubecj + +This program is provided 'as is', no warranty will be taken +for any damage caused by it or by any use of it. + +The whole package is placed under the GNU Public License, for further +information on redistribution see the included file "GPL.TXT". + + +Description: +------------ +Atari cartridge ROM 8/16 decompiler. + + + +Usage: +------ +ChkRom [options] sourcefile + +sourcefile is Atari ROM image. + + +History: +-------- +Date, Author, Version +4/5/1999, kubecj, 0.95 +First version + +10/10/1999, kubecj, 1.00 +Changed switches processing. +First release. + + +To Do: +------ +Maybe better disassembler. + + +Known Bugs: +----------- +None. + + +Compiling Tools: +---------------- +For scripts: Perl. +URL: http://www.perl.com + +For PC executables: DJGPP. +Sources were written/tested on GCC/Intel only. There should be only +slight problems to port it to different architectures/environments. +Makefile should need only slight changes. +URL: http://www.delorie.com + + diff --git a/jindroush/chkrom/switches.def b/jindroush/chkrom/switches.def new file mode 100644 index 0000000..827d5b4 --- /dev/null +++ b/jindroush/chkrom/switches.def @@ -0,0 +1,5 @@ +d, dis, disassemble +disassemble +=g_bDisassemble = TRUE; += + |