├── .gitignore
├── history (raw2bmp).txt
├── history (nedcmake).txt
├── history (nevpk).txt
├── src
├── lib
│ ├── rawbin
│ │ ├── rs.h
│ │ ├── rs.cpp
│ │ └── binraw.cpp
│ ├── nes.cpp
│ ├── nedclib2.h
│ ├── rawbmp
│ │ ├── dcs.h
│ │ ├── rawbmp.cpp
│ │ ├── address.cpp
│ │ ├── dcs_encode.cpp
│ │ └── dcs_decode.cpp
│ ├── nedclib2.cpp
│ └── vpk
│ │ └── vpk.cpp
├── raw2bmp.cpp
├── nedcenc.cpp
├── nevpk.cpp
└── nedcmake.cpp
├── nedclib_dll.txt
├── make
├── ReadMe (nedcenc).txt
├── ereader card info.txt
├── README.md
└── LICENSE.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/history (raw2bmp).txt:
--------------------------------------------------------------------------------
1 | Version 1.0
2 | * Initial release
3 |
4 | Version 1.1
5 | * Added support for encoding short raw to bmp
6 |
7 | Version 1.2 (Name change from dcstool to raw2bmp)
8 | * Added support for decoding short bmp to raw
9 | * bug fixed decoding of bmps with swapped pallette
10 |
11 | Version 1.3
12 | * Ported to nedclib.dll
13 | * Now supports multistrip raw files. (Upcoming feature of no$gba)
14 |
15 | Version 1.4
16 | * Rewrote command line interface. Now can list multiple input/output files.
17 | * Added option to decode bmp to multistrip raw output.
18 | * Added DPI command line option. (300/600/1200 dpi)
--------------------------------------------------------------------------------
/history (nedcmake).txt:
--------------------------------------------------------------------------------
1 | V1.0
2 | - Initial release
3 |
4 | V1.1
5 | - Ported to use nedclib.dll
6 | - Added automatic vpk compression (lzwindow 16384, lzsize 2048, level 2, method 0)
7 | - Added automatic conversion to raw (-raw option).
8 | - Added automatic conversion to bmp (-bmp option).
9 | - Output of bin files optional (specify -bin for output).
10 | - Added support for loading Mapper 0 16K prg 8K chr nes roms.
11 |
12 | V1.2
13 | - Fixed a title processing bug that happens when -region
14 | is specified after -name/-title. (oops)
15 | - Removed the requirement to specify a filetype option. raw is
16 | default output format now.
17 | - Short titles on japanese e-reader used 8 bit characters rather
18 | than 16 bit shift-jis characters. (Thanks Martin Korth).
19 |
--------------------------------------------------------------------------------
/history (nevpk).txt:
--------------------------------------------------------------------------------
1 | Build 0
2 | * Initial release
3 |
4 | Build 1
5 | * Added preliminary level 2 compression
6 | * Added decompression
7 |
8 | Build 2
9 | * Improved level 2 compression.
10 | * Added lzsize option.
11 |
12 | Build 3
13 | * Added method 1 compression/decompression
14 |
15 | Build 4
16 | * Optimized LZ compressor
17 | * Optimized huffman tree builder
18 |
19 | Build 5
20 | * Broke decompressor while implementing verbose info. fixed.
21 |
22 | Build 6
23 | * Fixed bug that caused method 1 level 2 compressor to crash.
24 |
25 | Build 7
26 | * Fixed bug that caused level 0 compressed files to crash decompressor.
27 | * Added output logging of decompression.
28 |
29 | Build 8
30 | * Ported functions to nedclib.dll
31 | * added a brute force level 3 compressor. (Really slow)
32 | * Minimum lz77 run is 2 bytes (actually produces smaller files)
33 | (Thanks Martin Korth)
--------------------------------------------------------------------------------
/src/lib/rawbin/rs.h:
--------------------------------------------------------------------------------
1 | //unsigned char pp [mm+1] = { 1,1,0,0,0,0,1,1,1} ; /* specify irreducible polynomial coeffts */
2 | //unsigned char alpha_to [nn+1], index_of [nn+1], gg [nn-kk+1] ;
3 | //unsigned char recd [nn], data [kk], bb [nn-kk] ;
4 |
5 | void make_rev(unsigned char *data, int len);
6 | void make_pow(unsigned char *data, int len);
7 | void invert_error_bytes(unsigned char *data, int len);
8 | void reverse_byte_order(unsigned char *data, int len);
9 | void zerofill_error_bytes(unsigned char *data, int len);
10 | void generate_gf();
11 | void gen_poly();
12 | void append_error_info(unsigned char *data, int dtalen, int errlen);
13 | int verify_error_info(unsigned char *data, int dtalen, int errlen);
14 |
15 | int correct_errors(unsigned char *data, int dtalen, int errlen, unsigned char *erasure=NULL);
16 | int eras_dec_rs(int *eras_pos,int no_eras);
17 | void initialize_rs(int bits=8, int polynomial=0x187, int index=0x78, int errlen=16);
18 | void free_rs();
19 | int is_rs_initialized();
--------------------------------------------------------------------------------
/src/lib/nes.cpp:
--------------------------------------------------------------------------------
1 | #include "nedclib2.h"
2 |
3 | static char DMCA_data[0x19] = "\0\0DMCA NINTENDO E-READER";
4 |
5 | static uint16_t encode_nmi(uint16_t nmi) {
6 | for(int i=0; i<0x18; i++) {
7 | for(int j=0; j<8; j++) {
8 | if(nmi & 0x0001) {
9 | nmi >>= 1;
10 | nmi ^= 0x8646;
11 | } else {
12 | nmi >>= 1;
13 | }
14 | }
15 | nmi ^= (DMCA_data[0x17-i] << 8);
16 | }
17 |
18 | return nmi;
19 | }
20 |
21 | NEDCLIB_API int nedc_encode_nes(unsigned char *nesdata) {
22 | if(!is_nes(nesdata)) return 1;
23 | if(nesdata[4] != 1 || nesdata[5] != 1 || (nesdata[6] & 0xFE) != 0 || nesdata[7] != 0)
24 | return 2;
25 |
26 | uint16_t nmi = encode_nmi((nesdata[0x3FFB+16] << 8) + (nesdata[0x3FFA+16]));
27 | nesdata[0x3FFB+16] = (nmi >> 8) & 0xFF;
28 | nesdata[0x3FFA+16] = nmi & 0xFF;
29 |
30 | if(nesdata[6] & 1) nesdata[0x3FFD + 16] &= 0x7F;
31 | else nesdata[0x3FFD + 16] |= 0x80;
32 |
33 | return 0;
34 | }
35 |
--------------------------------------------------------------------------------
/nedclib_dll.txt:
--------------------------------------------------------------------------------
1 | This DLL, and its lib file, is for the development of other nintendo e-reader related tools. THe source code is availble, under gpl.
2 |
3 | History
4 | Version 1.0
5 | * Initial release
6 |
7 | Version 1.1
8 | * added is_nes(unsigned char *nesdata)
9 | * added is_vpk(unsigned char *bindata)
10 | * added make_nes(unsigned char *nesdata)
11 | * added nes_enc(unsigned short NMI_vector)
12 | * added nes_dec(unsigned short NMI_vector)
13 |
14 | Version 1.2
15 | * added is_bmp(char *bmpfile)
16 | * added MultiStrip flag;
17 | * made dpi_multiplier available externally;
18 | Version 1.3
19 | * Finally ditched the emulation core code for actual
20 | reed-solomon encoding/decoding functions.
21 | (Thanks Martin Korth for finding the code, and
22 | Simon Rockcliff, Robert Morelos-Zaragoza and Hari Thirumoorthy for
23 | writing that code.)
24 | * Added multistrip bin support.
25 | * Upgraded bin format to 0x840/0x540 byte format. (Still need to rebuild
26 | the rest of my tools for both multistrip bin and multistrip raw format.
27 | (The tools being nedcprint, and vba e-reader))
28 |
--------------------------------------------------------------------------------
/make:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | rm -rfv build
3 | mkdir build
4 |
5 | build_os() {
6 | case "$1" in
7 | win32)
8 | CC="gcc"
9 | CXX="g++"
10 | CC_PREFIX="i686-w64-mingw32-"
11 | SO_EXTENSION=".dll"
12 | EXE_EXTENSION=".exe"
13 | CFLAGS="-static-libgcc"
14 | ;;
15 | linux)
16 | CC="gcc"
17 | CXX="g++"
18 | ;;
19 | mac)
20 | CC="clang"
21 | CXX="clang++"
22 | CFLAGS="-L/opt/local/lib"
23 | ;;
24 | custom)
25 | ;;
26 | *)
27 | echo "invalid target platform"
28 | exit 1
29 | esac
30 |
31 | if [ "$SO_EXTENSION" = "" ]; then
32 | SO_EXTENSION=".so"
33 | fi
34 | if [ "$EXE_EXTENSION" = "" ]; then
35 | EXE_EXTENSION=""
36 | fi
37 |
38 | mkdir build/$1
39 | mkdir build/$1/obj
40 | for file in $(find src/lib | grep "\.cpp$"); do
41 | ${CC_PREFIX}${CXX} $CFLAGS -flto -DNEDCLIB2_EXPORTS -c -g -fPIC -o build/$1/obj/$(basename $file).o -Wall -O2 -std=c++0x -I src/lib -I src/lib/rawbmp $file
42 | done
43 | ar rcs build/$1/nedclib2.a build/$1/obj/*
44 | ${CC_PREFIX}${CXX} $LDFLAGS -flto -fPIC -o build/$1/nedclib2${SO_EXTENSION} -shared -Wall -O2 -std=c++0x build/$1/obj/*
45 |
46 | for prog in nedcenc raw2bmp nedcmake nevpk; do
47 | ${CC_PREFIX}${CXX} $CFLAGS -flto -O2 -Wall -o build/$1/${prog}${EXE_EXTENSION} -I src/lib src/$prog.cpp build/$1/nedclib2.a
48 | done
49 | }
50 |
51 | if [ ! "$1" = "" ]; then
52 | build_os $1
53 | else
54 | build_os linux
55 | build_os win32
56 | fi
57 |
--------------------------------------------------------------------------------
/ReadMe (nedcenc).txt:
--------------------------------------------------------------------------------
1 | Nintendo eReader Dotcode encoder/decoder
2 | Copyright (C) 2007 by CaitSith2
3 |
4 | This is a command line tool. As such, basic command line usage is assumed. if you don't
5 | know how to use the command line, then you should look up how.
6 |
7 | Usage is "nedcenc [options]"
8 |
9 | [options]
10 | -i (Required)
11 | -o