Making progress on main program flow with detection in preparation for dumping/writing operations.

Prepended DICT_ to dictionary names to prevent using those defines for something else accidentally
"NES/SNES" etc could be used in a lot of places, don't want to use wrong enum/define in wrong place.

created enums.h to list out all enums/defines for cartridge and memory elements in one location.

separate file.c/h file for getting data in/out of a files, and opening/closing them.

adding test roms to roms folder so they can be used for various testing.
This commit is contained in:
paul eeepc 2016-12-07 18:08:31 -06:00
parent 8654a8f4bf
commit 66635b15e7
38 changed files with 404 additions and 220 deletions

View File

@ -1,5 +1,12 @@
#include "buffer.h"
//used to communicate to usbFunctionWrite which buffer object
//it should be filling
buffer *cur_usb_load_buff;
//used to determine number of bytes left to finish current
//OUT transfer utilized by usbFunctionWrite
//uint16_t incoming_bytes_remain;
uint8_t incoming_bytes_remain;
//min define of two buffers
static buffer buff0;

View File

@ -31,12 +31,5 @@ uint8_t * buffer_payload( setup_packet *spacket, buffer *buff, uint8_t hostsetbu
void update_buffers();
//used to communicate to usbFunctionWrite which buffer object
//it should be filling
buffer *cur_usb_load_buff;
//used to determine number of bytes left to finish current
//OUT transfer utilized by usbFunctionWrite
//uint16_t incoming_bytes_remain;
uint8_t incoming_bytes_remain;
#endif

View File

@ -1,17 +1,6 @@
#ifndef _logic_h
#define _logic_h
#define LO 0x00
#define HI 0xFF
//DDR values
#define IP 0x00
#define OP 0xFF
#define FALSE 0x00
//TRUE is any value besides zero
//used to indicate when intentionally passing zero because option not used
#define NILL 0x00
#endif

View File

@ -177,6 +177,14 @@ void software_AXL_CLK();
// used for a very short delay
#define NOP() do { __asm__ __volatile__ ("nop"); } while (0)
//PORT wide set/clear
#define LO 0x00
#define HI 0xFF
//DDR values
#define IP 0x00
#define OP 0xFF
//============================
//ADDR[7:0] PORTA
//============================

View File

@ -44,6 +44,9 @@ static uint8_t usbWrite_status;
USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
//defined and controled by buffer.c
extern buffer *cur_usb_load_buff;
//cast incoming data into the the usb setup packet it is
setup_packet *spacket = (void *)data;
@ -93,7 +96,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
switch(spacket->bRequest) {
case PINPORT:
case DICT_PINPORT:
switch (spacket->opcode) {
case PP_OPCODE_ONLY_MIN ... PP_OPCODE_ONLY_MAX:
rv[RV_ERR_IDX] = pinport_opcode_only( spacket->opcode );
@ -119,7 +122,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
}
break; //end of PINPORT
case IO:
case DICT_IO:
switch (spacket->opcode) {
case IO_OPCODE_ONLY_MIN ... IO_OPCODE_ONLY_MAX:
rv[RV_ERR_IDX] = io_opcode_only( spacket->opcode );
@ -134,7 +137,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
}
break; //end of IO
case NES:
case DICT_NES:
switch (spacket->opcode) {
case NES_OPCODE_24BOP_MIN ... NES_OPCODE_24BOP_MAX:
rv[RV_ERR_IDX] = nes_opcode_24b_operand( spacket->opcode,
@ -150,7 +153,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
}
break; //end of NES
case SNES:
case DICT_SNES:
switch (spacket->opcode) {
case SNES_OPCODE_24BOP_MIN ... SNES_OPCODE_24BOP_MAX:
rv[RV_ERR_IDX] = snes_opcode_24b_operand( spacket->opcode,
@ -166,12 +169,12 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
}
break; //end of SNES
case BUFFER:
case DICT_BUFFER:
//just give buffer.c the setup packet and let it figure things out for itself
usbMsgPtr = (usbMsgPtr_t)buffer_usb_call( spacket, rv, &rlen );
break; //end of BUFFER
case USB:
case DICT_USB:
//currently just a simple way to read back usbFunctionWrite status SUCCESS/ERROR
//if there are future status' to read back may have to create some functions
rv[RV_ERR_IDX] = SUCCESS;
@ -266,6 +269,10 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
//#define MAKECHECKS 0
USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) {
//defined and controled by buffer.c
extern buffer *cur_usb_load_buff;
extern uint8_t incoming_bytes_remain;
uint8_t data_cur = 0; //current incoming byte to copy
uint8_t buf_cur = cur_usb_load_buff->cur_byte; //current buffer byte

View File

@ -1,5 +1,43 @@
#include "cartridge.h"
//init all cart elements to UNKNOWN
//allocate memory for memory elements
int init_cart_elements( cartridge *cart )
{
cart->console = UNKNOWN;
cart->mapper = UNKNOWN;
cart->submap = UNKNOWN;
cart->mapvariant = UNKNOWN;
cart->manf = UNKNOWN;
cart->product = UNKNOWN;
cart->mirroring = UNKNOWN;
cart->sound = UNKNOWN;
cart->pri_rom = malloc( sizeof(memory));
check_mem(cart->pri_rom);
init_memory_elements(cart->pri_rom);
cart->sec_rom = malloc( sizeof(memory));
check_mem(cart->sec_rom);
init_memory_elements(cart->sec_rom);
cart->save_mem = malloc( sizeof(memory));
check_mem(cart->save_mem);
init_memory_elements(cart->save_mem);
cart->aux_mem = malloc( sizeof(memory));
check_mem(cart->aux_mem);
init_memory_elements(cart->aux_mem);
cart->logic_mem = malloc( sizeof(memory));
check_mem(cart->logic_mem);
init_memory_elements(cart->logic_mem);
return SUCCESS;
error:
return ~SUCCESS;
}
int detect_console( cartridge *cart, USBtransfer *transfer )
{
printf("attempting to detect cartridge...\n");
@ -92,3 +130,17 @@ error:
//INL SNES boards memory mapping is controlled by /RESET pin
//roms are still visible when /RESET low, but SRAM isn't
int detect_mirroring( cartridge *cart, USBtransfer *transfer )
{
if ( cart->console == NES_CART ) {
//For now just assume mirroring is fixed until start adding support for other mappers
cart->mirroring = MIR_FIXED;
}
return SUCCESS;
//error:
// return -1;
}

View File

@ -6,7 +6,6 @@
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <libusb.h>
//include prior to other file includes
//that way DEBUG can be turned on/off for this file alone
@ -19,11 +18,12 @@
#include "shared_errors.h"
#include "shared_dictionaries.h"
#include "dictionary.h"
#include "types.h"
#include "enums.h"
#include "io.h"
#include "nes.h"
#include "snes.h"
#include "memory.h"
//cartridge object/struct
typedef struct cartridge{
@ -39,17 +39,13 @@ typedef struct cartridge{
memory *sec_rom; //secondary rom if used (CHR-ROM for NES)
memory *save_mem; //save data memory
memory *aux_mem; //additional memory
memory *logic; //programmable logic
memory *logic_mem; //programmable logic
} cartridge;
//console options
#define UNKNOWN 0
#define NES_CART 'N'
#define FC_CART 'F'
#define SNES_CART 'S'
#define BKWD_CART 'B'
int init_cart_elements( cartridge *cart );
int detect_console( cartridge *cart, USBtransfer *transfer );
int detect_mirroring( cartridge *cart, USBtransfer *transfer );
#endif

View File

@ -68,7 +68,7 @@ int dictionary_call_print_option( int print_debug, USBtransfer *transfer, uint8_
dictionary, opcode, opcode, addr, miscdata);
}
switch (dictionary) {
case PINPORT: debug("dict: PINPORT");
case DICT_PINPORT: debug("dict: PINPORT");
//transfer->wLength = 1;
switch (opcode) {
case PP_OPCODE_ONLY_MIN ... PP_OPCODE_ONLY_MAX:
@ -92,7 +92,7 @@ int dictionary_call_print_option( int print_debug, USBtransfer *transfer, uint8_
}
break; //end of PINPORT
case IO: debug("dict: IO");
case DICT_IO: debug("dict: IO");
// transfer->wLength = 1;
switch (opcode) {
case IO_OPCODE_ONLY_MIN ... IO_OPCODE_ONLY_MAX:
@ -107,7 +107,7 @@ int dictionary_call_print_option( int print_debug, USBtransfer *transfer, uint8_
}
break; //end of IO
case NES: debug("dict: NES");
case DICT_NES: debug("dict: NES");
// transfer->wLength = 1;
switch (opcode) {
case NES_OPCODE_24BOP_MIN ... NES_OPCODE_24BOP_MAX:
@ -122,7 +122,7 @@ int dictionary_call_print_option( int print_debug, USBtransfer *transfer, uint8_
}
break; //end of NES
case SNES: debug("dict: SNES");
case DICT_SNES: debug("dict: SNES");
// transfer->wLength = 1;
switch (opcode) {
case SNES_OPCODE_24BOP_MIN ... SNES_OPCODE_24BOP_MAX:
@ -137,14 +137,14 @@ int dictionary_call_print_option( int print_debug, USBtransfer *transfer, uint8_
}
break; //end of SNES
case BUFFER: debug("dict: BUFFER");
case DICT_BUFFER: debug("dict: BUFFER");
// transfer->wLength = length;
if (buffer != NULL) {
transfer->data = (unsigned char *)buffer;
}
break; //end of BUFF
case USB: debug("dict: USB");
case DICT_USB: debug("dict: USB");
// transfer->wLength = length;
break;

23
host/source/enums.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef _enums_h
#define _enums_h
//One concise place to list all enums used for setting cartridge and memory elements
//used to denote when any cartridge element is not known
#define UNKNOWN -1
//console options
#define NES_CART 'N'
#define FC_CART 'F'
#define SNES_CART 'S'
#define BKWD_CART 'B'
enum mirroring {
MIR_FIXED = 10,
MIR_ANROM,
MIR_MMC1,
MIR_MMC3
};
#endif

View File

@ -2,39 +2,45 @@
int erase_nes( USBtransfer *transfer )
{
//uint8_t rv[8];
//int i = 0;
debug("erasing");
debug("erasing_nrom");
io_reset(transfer);
//for NROM flashing first verify EXP0 pull up will clock /WE properly
check( !exp0_pullup_test(transfer), "EXP0 pullup test failed can't erase PRG-ROM" );
nes_init(transfer);
dictionary_call( transfer, IO, IO_RESET, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, IO, NES_INIT, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, IO, EXP0_PULLUP_TEST,0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0xAA, USB_IN, NULL, 1);
dictionary_call( transfer, NES, DISCRETE_EXP0_PRGROM_WR, 0x2AAA, 0x55, USB_IN, NULL, 1);
dictionary_call( transfer, NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0x80, USB_IN, NULL, 1);
dictionary_call( transfer, NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0xAA, USB_IN, NULL, 1);
dictionary_call( transfer, NES, DISCRETE_EXP0_PRGROM_WR, 0x2AAA, 0x55, USB_IN, NULL, 1);
dictionary_call( transfer, NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0x10, USB_IN, NULL, 1);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call( transfer, NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0xAA, USB_IN, NULL, 1);
dictionary_call_debug( transfer, DICT_NES, DISCRETE_EXP0_PRGROM_WR, 0x2AAA, 0x55, USB_IN, NULL, 1);
dictionary_call_debug( transfer, DICT_NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0x80, USB_IN, NULL, 1);
dictionary_call_debug( transfer, DICT_NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0xAA, USB_IN, NULL, 1);
dictionary_call_debug( transfer, DICT_NES, DISCRETE_EXP0_PRGROM_WR, 0x2AAA, 0x55, USB_IN, NULL, 1);
dictionary_call_debug( transfer, DICT_NES, DISCRETE_EXP0_PRGROM_WR, 0x5555, 0x10, USB_IN, NULL, 1);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
dictionary_call_debug( transfer, DICT_NES, NES_CPU_RD, 0x8000, 0, USB_IN, NULL, 2);
//dictionary_call( transfer, IO, IO_RESET, 0, 0);
//dictionary_call( transfer, IO, NES_INIT, 0, 0);
@ -90,5 +96,6 @@ int erase_nes( USBtransfer *transfer )
return 0;
error:
return -1;
}

View File

@ -19,6 +19,7 @@
#include "shared_errors.h"
#include "shared_dictionaries.h"
#include "dictionary.h"
#include "io.h"
int erase_nes( USBtransfer *transfer );

View File

@ -4,44 +4,47 @@
#define SIZE_PRG_BANK 16384
#define SIZE_CHR_BANK 8192
int detect_file( rom_image *rom_info, char *filename )
//Need to pass in pointer to a filepointer to properly pass by reference
//the OS/stdio creates a FILE struct and returns the address of that struct
//so when this function opens a file it's setting the value of a pointer
//for the calling function. To set a pointer we must have a pointer to that pointer..
int open_file( FILE **fptr, char *filename )
{
//first open file
*fptr = fopen( filename, "rb");
//returns file ptr on success, NULL on fail
check( *fptr, "Unable to open file: %s in read binary mode", filename);
return SUCCESS;
error:
return -1;
}
int detect_file( rom_image *rom )
{
int rv = 0;
// int index = 0;
FILE *fileptr = NULL;
//warn uint8_t data[128];
//first open file
fileptr = fopen( filename, "rb");
//returns file ptr on success, NULL on fail
check( fileptr, "Unable to open file: %s in read binary mode", filename);
//then determine file type
uint8_t header[SIZE_NES_HEADER];
//size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
rv = fread( header, sizeof(header[0]), (sizeof(header)/sizeof(header[0])), fileptr);
check( rv = sizeof(header), "Unable to read NES header");
//for ( index = 0; index < SIZE_NES_HEADER; index++ ) {
// debug("header byte #%d = h%x c%c", index, header[index], header[index]);
//}
//size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
rv = fread( header, sizeof(header[0]), (sizeof(header)/sizeof(header[0])), rom->fileptr);
check( rv = sizeof(header), "Unable to read NES header");
//0-3: Constant $4E $45 $53 $1A ("NES" followed by MS-DOS end-of-file)
if ( (header[0]=='N') && (header[1]=='E') && (header[2]=='S') && (header[3]==0x1A) ) {
debug("detected ines header");
rom_info->console = NES_CART;
rom->console = NES_CART;
} else {
debug("only ines files currently accepted as input");
goto error;
}
//4: Size of PRG ROM in 16 KB units
rom_info->prg_size = header[4] * SIZE_PRG_BANK;
debug("PRG ROM size= %d", rom_info->prg_size);
rom->prg_size = header[4] * SIZE_PRG_BANK;
debug("PRG ROM size= %d", rom->prg_size);
//5: Size of CHR ROM in 8 KB units (Value 0 means the board uses CHR RAM)
rom_info->chr_size = header[5] * SIZE_CHR_BANK;
debug("CHR ROM size= %d", rom_info->chr_size);
rom->chr_size = header[5] * SIZE_CHR_BANK;
debug("CHR ROM size= %d", rom->chr_size);
//6: Flags 6
// 76543210
@ -52,11 +55,12 @@ int detect_file( rom_image *rom_info, char *filename )
// |||| |+-- 1: Cartridge contains battery-backed PRG RAM ($6000-7FFF) or other persistent memory
// |||| +--- 1: 512-byte trainer at $7000-$71FF (stored before PRG data)
// ++++----- Lower nybble of mapper number
rom_info->mapper = (header[6]>>4);
rom_info->mapper |= (header[7] & 0xF0);
debug("mapper #%d", rom_info->mapper);
rom_info->mirroring = header[6] & 0x09; //0b0000 1001
debug("mirroring:%x", rom_info->mirroring);
rom->mapper = (header[6]>>4);
rom->mapper |= (header[7] & 0xF0);
debug("mapper #%d", rom->mapper);
rom->mirroring = header[6] & 0x09; //0b0000 1001
debug("mirroring:%x", rom->mirroring);
//7: Flags 7
// 76543210
// ||||||||
@ -70,18 +74,7 @@ int detect_file( rom_image *rom_info, char *filename )
//10: Flags 10 (unofficial)
//11-15: Zero filled
//close file
check( fclose(fileptr) == SUCCESS, "Unable to close file");
fileptr = NULL;
return 0;
return SUCCESS;
error:
if (fileptr) {
fclose(fileptr);
}
return -1;
}

View File

@ -27,8 +27,10 @@ typedef struct rom_image{
int ram_size;
int battery;
int mirroring;
FILE *fileptr;
} rom_image;
int detect_file( rom_image *rom_info, char *filename );
int open_file( FILE **fptr, char *filename );
int detect_file( rom_image *rom );
#endif

View File

@ -19,6 +19,7 @@
#include "test.h"
#include "cartridge.h"
#include "file.h"
#include "enums.h"
int main(int argc, char *argv[])
@ -147,12 +148,18 @@ int main(int argc, char *argv[])
//create USBtransfer struct to hold all transfer info
USBtransfer *transfer = malloc( sizeof(USBtransfer));
check_mem(transfer);
//create usb device handle pointer to interact with retro-prog
//libusb_device_handle *rprog_handle = NULL;
transfer->handle = NULL;
//create file object/struct
rom_image *rom = malloc( sizeof(rom_image));
rom->fileptr = NULL;
check_mem(transfer);
check_mem(rom);
//command line arg L_value to set different LIBUSB debugging options
//any value > 0 also prints debug statements in open_usb_device function
int libusb_log = LIBUSB_LOG_LEVEL_NONE; // 0: default no msgs ever printed
@ -182,29 +189,37 @@ int main(int argc, char *argv[])
cartridge *cart = malloc( sizeof(cartridge));
check_mem(cart);
//attempt to detect board inserted in device
cart->console = UNKNOWN;
//set all cart elements to UNKNOWN
init_cart_elements(cart);
// -x flag turns off all autodection
if (!x_flag) {
//attempt to detect board inserted in device
check(!detect_console( cart, transfer ), "Problem detecting cartridge.");
//detect mapper as much as possible
//TODO first step is mirroring for NES boards
check(!detect_mirroring( cart, transfer ), "Problem detecting cart mirroring.");
//TODO first step for SNES is mapping mode
//By this point we know a lot about the cartridge but for things like NES discrete
//mappers we'll have to play around with the memory to determine exact mapper
//detect board manufacturer/flash memories as much as possible
//detect rom sizes as much as possible
} else {
printf("auto-detection turned off\n");
}
//detect mapper as much as possible
//detect board manufacturer/flash memories as much as possible
//detect rom sizes as much as possible
//read in user files/args that glean info about expected board
//create file object/struct
rom_image *rom_info = malloc( sizeof(rom_image));
check_mem(rom_info);
//for now just assume user file/args are correct
if ( p_value != NULL ) {
//program file provided at commandline
detect_file( rom_info, p_value );
check( !open_file( &rom->fileptr, p_value ), "Problem opening file %s", p_value);
detect_file( rom );
}
//compare detections to user args and get permission to continue if there are discrepencies
@ -214,7 +229,7 @@ int main(int argc, char *argv[])
//erase required sectors of flash
//forced to erase board regardless of current status
if (e_flag) {
if (e_flag || p_value) {
erase_nes( transfer );
}
@ -248,7 +263,7 @@ int main(int argc, char *argv[])
}
printf("\n");
transfer->endpoint = USB_IN;
transfer->request = PINPORT;
transfer->request = DICT_PINPORT;
if (o_flag) transfer->wValueLSB = LED_ON;
if (n_flag) transfer->wValueLSB = LED_OFF;
transfer->data = rbuf;
@ -268,11 +283,21 @@ int main(int argc, char *argv[])
close:
close_usb( context, transfer->handle);
if(rom->fileptr != NULL){
//close file
fclose(rom->fileptr);
}
return 0;
error:
printf("main program went to error\n");
// printf("main program went to error\n");
//
// close_usb( context, transfer->handle);
// if(rom->fileptr != NULL){
// fclose(rom->fileptr);
// }
return 1;

View File

@ -7,7 +7,7 @@
*/
void io_reset( USBtransfer *transfer )
{
dictionary_call( transfer, IO, IO_RESET, 0, 0,
dictionary_call( transfer, DICT_IO, IO_RESET, 0, 0,
USB_IN, NULL, 1);
}
@ -18,7 +18,7 @@ void io_reset( USBtransfer *transfer )
*/
void nes_init( USBtransfer *transfer )
{
dictionary_call( transfer, IO, NES_INIT, 0, 0,
dictionary_call( transfer, DICT_IO, NES_INIT, 0, 0,
USB_IN, NULL, 1);
}
@ -30,8 +30,52 @@ void nes_init( USBtransfer *transfer )
*/
void snes_init( USBtransfer *transfer )
{
dictionary_call( transfer, IO, SNES_INIT, 0, 0,
dictionary_call( transfer, DICT_IO, SNES_INIT, 0, 0,
USB_IN, NULL, 1);
}
/* Desc:test EXP0 pullup and determine now many avr cpu cycles it takes to go high
* Pre: io_reset
* Post:EXP0 left as pullup
* Rtn: number of extra AVR cpu cycles it took to pullup EXP0
* SUCCESS = 0 which means pullup was immediate
* returns negative number on error
*/
int exp0_pullup_test( USBtransfer *transfer )
{
uint8_t rv[RETURN_BUFF_SIZE];
int i = 0;
//call EXP0 test command
dictionary_call( transfer, DICT_IO, EXP0_PULLUP_TEST, NILL, NILL, USB_IN,
rv, RETURN_BUFF_SIZE);
//return value first gives error/succes of opcode call
//data first gives mask for EXP0 pin
//then gives result of successive byte wide reads to be masked
check( (rv[RV_ERR_IDX] == SUCCESS), "Device error calling EXP0 pullup test opcode" )
if ( rv[RV_DATA0_IDX] & rv[RV_DATA0_IDX+1] ) {
//mask out EXP0 bit, and EXP0 was set on first read after pullup
return SUCCESS;
} else if ( (rv[RV_DATA0_IDX] & rv[RV_DATA_MAX_IDX]) == 0 ) {
//last read didn't have EXP0 high fail
return GEN_FAIL;
}else {
//determine how many cycles it took for EXP0 to go high
for( i=RV_DATA0_IDX+2; i<=RV_DATA_MAX_IDX; i++) {
//debug("index %d", i);
if ( rv[RV_DATA0_IDX] & rv[RV_DATA0_IDX+i] ) {
return i-1;
}
}
}
//shouldn't be here..
sentinel("EXP0 test failed to check results proplerly");
error:
return -1;
}

View File

@ -22,5 +22,6 @@
void io_reset( USBtransfer *transfer );
void nes_init( USBtransfer *transfer );
void snes_init( USBtransfer *transfer );
int exp0_pullup_test( USBtransfer *transfer );
#endif

14
host/source/memory.c Normal file
View File

@ -0,0 +1,14 @@
#include "memory.h"
void init_memory_elements( memory *mem )
{
mem->manf = UNKNOWN;
mem->part = UNKNOWN;
mem->volatility = UNKNOWN;
mem->size = UNKNOWN;
mem->addr_size = UNKNOWN;
mem->width = UNKNOWN;
mem->protocol = UNKNOWN;
mem->sector_size = UNKNOWN;
}

39
host/source/memory.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef _memory_h
#define _memory_h
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
//include prior to other file includes
//that way DEBUG can be turned on/off for this file alone
//uncomment to DEBUG this file alone
#define DEBUG
//"make debug" to get DEBUG msgs on entire program
#include "dbg.h"
#include "usb_operations.h"
#include "shared_errors.h"
#include "shared_dictionaries.h"
#include "dictionary.h"
#include "enums.h"
//memory object/struct
typedef struct memory{
int manf;
int part;
int volatility; //sram no batt vs batt, mask rom, erasability, etc
int size; //size of the actual memory excluding grounded address pins etc
int addr_size; //addressable size of the memory including grounded address pins etc
int width; //width of data bus as configured
int protocol; //parallel, SPI, I2C, JTAG, custom etc.
int sector_size; //minimum eraseable size in bytes
} memory;
void init_memory_elements( memory *mem );
#endif

View File

@ -11,10 +11,10 @@ int jumper_ciramce_ppuA13n( USBtransfer *transfer )
uint8_t rv[RV_DATA0_IDX+1];
//check that we can clear CIRAM /CE with PPU /A13
dictionary_call( transfer, PINPORT, ADDRH_SET, 0, 0,
dictionary_call( transfer, DICT_PINPORT, ADDRH_SET, 0, 0,
USB_IN, NULL, 1);
//read CIRAM /CE pin
dictionary_call( transfer, PINPORT, CICE_RD, 0, 0,
dictionary_call( transfer, DICT_PINPORT, CICE_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
//CIRAM /CE's port PIN register contents are now in rv[RV_DATA_IDX]
@ -26,10 +26,10 @@ int jumper_ciramce_ppuA13n( USBtransfer *transfer )
}
//set PPU /A13 high
dictionary_call( transfer, PINPORT, ADDRH_SET, PPU_A13N_MSK, 0,
dictionary_call( transfer, DICT_PINPORT, ADDRH_SET, PPU_A13N_MSK, 0,
USB_IN, NULL, 1);
//read CIRAM /CE pin
dictionary_call( transfer, PINPORT, CICE_RD, 0, 0,
dictionary_call( transfer, DICT_PINPORT, CICE_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
//CIRAM /CE's port PIN register contents are now in rv[RV_DATA_IDX]
@ -58,10 +58,10 @@ int ciramce_inv_ppuA13( USBtransfer *transfer )
uint8_t rv[RV_DATA0_IDX+1];
//set PPU /A13 low
dictionary_call( transfer, PINPORT, ADDRH_SET, 0, 0,
dictionary_call( transfer, DICT_PINPORT, ADDRH_SET, 0, 0,
USB_IN, NULL, 1);
//read CIRAM /CE pin
dictionary_call( transfer, PINPORT, CICE_RD, 0, 0,
dictionary_call( transfer, DICT_PINPORT, CICE_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
// CIRAM /CE should be high if inverted A13 is what drives it
@ -72,10 +72,10 @@ int ciramce_inv_ppuA13( USBtransfer *transfer )
}
//check that we can clear CIRAM /CE with PPU /A13 high
dictionary_call( transfer, PINPORT, ADDRH_SET, PPU_A13_MSK, 0,
dictionary_call( transfer, DICT_PINPORT, ADDRH_SET, PPU_A13_MSK, 0,
USB_IN, NULL, 1);
//read CIRAM /CE pin
dictionary_call( transfer, PINPORT, CICE_RD, 0, 0,
dictionary_call( transfer, DICT_PINPORT, CICE_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
// CIRAM /CE should be low if inverted A13 is what drives it
@ -120,41 +120,41 @@ int famicom_sound( USBtransfer *transfer )
//but don't leave it enabled before exiting function
//set AXLOE to output
dictionary_call( transfer, PINPORT, AXLOE_OP, 0, 0,
dictionary_call( transfer, DICT_PINPORT, AXLOE_OP, 0, 0,
USB_IN, NULL, 1);
//enable EXP FF
dictionary_call( transfer, PINPORT, EXPFF_OP, 0, 0,
dictionary_call( transfer, DICT_PINPORT, EXPFF_OP, 0, 0,
USB_IN, NULL, 1);
//Latch low first
dictionary_call( transfer, PINPORT, ADDRX_SET, 0, 0,
dictionary_call( transfer, DICT_PINPORT, ADDRX_SET, 0, 0,
USB_IN, NULL, 1);
//read EXP0 Famicom APU audio pin
dictionary_call( transfer, PINPORT, FC_APU_RD, 0, 0,
dictionary_call( transfer, DICT_PINPORT, FC_APU_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
//need to mask out the pin
if ( rv[RV_DATA0_IDX] & FC_APU_MSK ) {
debug("RF audio out (EXP6) didn't drive APU audio in (EXP0) low");
//disable EXP FF
dictionary_call( transfer, PINPORT, EXPFF_FLT, 0, 0,
dictionary_call( transfer, DICT_PINPORT, EXPFF_FLT, 0, 0,
USB_IN, NULL, 1);
//retun AXLOE to input
dictionary_call( transfer, PINPORT, AXLOE_IP, 0, 0,
dictionary_call( transfer, DICT_PINPORT, AXLOE_IP, 0, 0,
USB_IN, NULL, 1);
return FALSE;
}
//Latch pin high
dictionary_call( transfer, PINPORT, ADDRX_SET, FC_RF_MSK, 0,
dictionary_call( transfer, DICT_PINPORT, ADDRX_SET, FC_RF_MSK, 0,
USB_IN, NULL, 1);
//read EXP0 Famicom APU audio pin
dictionary_call( transfer, PINPORT, FC_APU_RD, 0, 0,
dictionary_call( transfer, DICT_PINPORT, FC_APU_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
//disable EXP FF
dictionary_call( transfer, PINPORT, EXPFF_FLT, 0, 0,
dictionary_call( transfer, DICT_PINPORT, EXPFF_FLT, 0, 0,
USB_IN, NULL, 1);
//retun AXLOE to input
dictionary_call( transfer, PINPORT, AXLOE_IP, 0, 0,
dictionary_call( transfer, DICT_PINPORT, AXLOE_IP, 0, 0,
USB_IN, NULL, 1);
//mask pin from byte

View File

@ -10,13 +10,13 @@ int snes_mem_visible( USBtransfer *transfer, uint8_t bank, uint16_t addr )
uint8_t rv[RV_DATA0_IDX+1];
//place address on bus
dictionary_call( transfer, PINPORT, ADDR24_SET, addr, bank,
dictionary_call( transfer, DICT_PINPORT, ADDR24_SET, addr, bank,
USB_IN, NULL, 1);
//ensure data bus is pulled up
dictionary_call( transfer, PINPORT, DATA_HI, 0, 0,
dictionary_call( transfer, DICT_PINPORT, DATA_HI, 0, 0,
USB_IN, NULL, 1);
//read data bus
dictionary_call_debug( transfer, PINPORT, DATA_RD, 0, 0,
dictionary_call_debug( transfer, DICT_PINPORT, DATA_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
if ( rv[RV_DATA0_IDX] != 0xFF ) {
debug("Can't pull up data bus in attempt to detect SNES cart");
@ -24,21 +24,21 @@ int snes_mem_visible( USBtransfer *transfer, uint8_t bank, uint16_t addr )
}
//enable rom control signals
dictionary_call( transfer, PINPORT, SRST_HI, 0, 0,
dictionary_call( transfer, DICT_PINPORT, SRST_HI, 0, 0,
USB_IN, NULL, 1);
dictionary_call( transfer, PINPORT, CSRD_LO, 0, 0,
dictionary_call( transfer, DICT_PINPORT, CSRD_LO, 0, 0,
USB_IN, NULL, 1);
dictionary_call( transfer, PINPORT, ROMSEL_LO, 0, 0,
dictionary_call( transfer, DICT_PINPORT, ROMSEL_LO, 0, 0,
USB_IN, NULL, 1);
//read data bus
dictionary_call_debug( transfer, PINPORT, DATA_RD, 0, 0,
dictionary_call_debug( transfer, DICT_PINPORT, DATA_RD, 0, 0,
USB_IN, rv, RV_DATA0_IDX+1);
//clear data bus
dictionary_call( transfer, PINPORT, SRST_LO, 0, 0,
dictionary_call( transfer, DICT_PINPORT, SRST_LO, 0, 0,
USB_IN, NULL, 1);
dictionary_call( transfer, PINPORT, CSRD_HI, 0, 0,
dictionary_call( transfer, DICT_PINPORT, CSRD_HI, 0, 0,
USB_IN, NULL, 1);
dictionary_call( transfer, PINPORT, ROMSEL_HI, 0, 0,
dictionary_call( transfer, DICT_PINPORT, ROMSEL_HI, 0, 0,
USB_IN, NULL, 1);
if ( rv[RV_DATA0_IDX] != 0xFF ) {
debug("Found memory with SNES control signals");

View File

@ -4,36 +4,36 @@ int test_function( USBtransfer *transfer )
{
debug("testing");
dictionary_call( transfer, IO, IO_RESET, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, IO, NES_INIT, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, IO, EXP0_PULLUP_TEST, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_IO, IO_RESET, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_IO, NES_INIT, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_IO, EXP0_PULLUP_TEST, 0, 0, USB_IN, NULL, 8);
//dict opcode addr/index miscdata endpoint *buffer length
debug("reset butters");
dictionary_call( transfer, BUFFER, RAW_BUFFER_RESET, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, BUFFER, RAW_BANK_STATUS, 0, 0, USB_IN, NULL, 2);
dictionary_call( transfer, DICT_BUFFER, RAW_BUFFER_RESET, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, RAW_BANK_STATUS, 0, 0, USB_IN, NULL, 2);
debug("get pri"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, GET_PRI_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, BUFFER, GET_PRI_ELEMENTS, 0, 1, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_PRI_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_PRI_ELEMENTS, 0, 1, USB_IN, NULL, 8);
// debug("get nonexistent 7"); //id:basebank num32B banks
// dictionary_call( transfer, BUFFER, GET_PRI_ELEMENTS, 0, 7, USB_IN, NULL, 8);
// dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER7, 0x7008, 8, USB_IN, NULL, 1);
// debug("get nonexistent 8"); //id:basebank num32B banks
// dictionary_call( transfer, BUFFER, GET_PRI_ELEMENTS, 0, 8, USB_IN, NULL, 8);
debug("allocate buff0 256B"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER0, 0x1000, 8, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, ALLOCATE_BUFFER0, 0x1000, 8, USB_IN, NULL, 1);
debug("allocate buff2 0B"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER1, 0x2008, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, ALLOCATE_BUFFER1, 0x2008, 0, USB_IN, NULL, 1);
debug("allocate buff1 256B"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER1, 0x2008, 8, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, ALLOCATE_BUFFER1, 0x2008, 8, USB_IN, NULL, 1);
debug("status"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, RAW_BANK_STATUS, 0, 0, USB_IN, NULL, 2);
dictionary_call( transfer, BUFFER, RAW_BANK_STATUS, 8, 0, USB_IN, NULL, 2);
dictionary_call( transfer, DICT_BUFFER, RAW_BANK_STATUS, 0, 0, USB_IN, NULL, 2);
dictionary_call( transfer, DICT_BUFFER, RAW_BANK_STATUS, 8, 0, USB_IN, NULL, 2);
debug("get pri"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, GET_PRI_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, BUFFER, GET_PRI_ELEMENTS, 0, 1, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_PRI_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_PRI_ELEMENTS, 0, 1, USB_IN, NULL, 8);
debug("get sec"); //id:basebank num32B banks
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
uint8_t load_in[256];
uint8_t load_out[256];
@ -48,7 +48,7 @@ int test_function( USBtransfer *transfer )
printf("\n");
debug("read payload0 uninitialized");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
//print load
printf("load_in data:");
@ -70,10 +70,10 @@ int test_function( USBtransfer *transfer )
printf("\n");
debug("send payload0");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_OUT, load_out, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_OUT, load_out, 254);
debug("read payload0");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
//print load
printf("load_in data:");
@ -82,13 +82,13 @@ int test_function( USBtransfer *transfer )
}
printf("\n");
dictionary_call( transfer, USB, 0, 0, 0, USB_IN, NULL, 3);
dictionary_call( transfer, DICT_USB, 0, 0, 0, USB_IN, NULL, 3);
debug("send payload0");
dictionary_call( transfer, BUFFER, BUFF_OUT_PAYLOAD_2B_INSP, 0xa5c3, 0, USB_OUT, &load_out[2], 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_OUT_PAYLOAD_2B_INSP, 0xa5c3, 0, USB_OUT, &load_out[2], 254);
debug("read payload0");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
printf("load_in data:");
for (i=0; i<254; i++) {
@ -118,15 +118,15 @@ int test_function( USBtransfer *transfer )
//dict opcode addr/index miscdata endpoint *buffer length
debug("set func");
dictionary_call( transfer, BUFFER, SET_FUNCTION, DUMPING, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, SET_FUNCTION, DUMPING, 0, USB_IN, NULL, 1);
debug("get sec");
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
debug("read payload0");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, BUFFER, SET_FUNCTION, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, SET_FUNCTION, 0, 0, USB_IN, NULL, 1);
printf("load_in data:");
for (i=0; i<254; i++) {
printf(" %x",load_in[i]);
@ -140,17 +140,17 @@ int test_function( USBtransfer *transfer )
printf("\n");
debug("send payload0");
dictionary_call( transfer, BUFFER, BUFF_OUT_PAYLOAD_2B_INSP, 0xa5c3, 0, USB_OUT, &load_out[2], 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_OUT_PAYLOAD_2B_INSP, 0xa5c3, 0, USB_OUT, &load_out[2], 254);
debug("set func");
dictionary_call( transfer, BUFFER, SET_FUNCTION, FLASHING, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, SET_FUNCTION, FLASHING, 0, USB_IN, NULL, 1);
debug("get sec");
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
debug("read payload0");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
printf("load_in data:");
for (i=0; i<254; i++) {
@ -158,13 +158,13 @@ int test_function( USBtransfer *transfer )
}
printf("\n");
debug("set func");
dictionary_call( transfer, BUFFER, SET_FUNCTION, DUMPING, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_BUFFER, SET_FUNCTION, DUMPING, 0, USB_IN, NULL, 1);
debug("get sec");
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 0, USB_IN, NULL, 8);
dictionary_call( transfer, DICT_BUFFER, GET_SEC_ELEMENTS, 0, 1, USB_IN, NULL, 8);
debug("read payload0");
dictionary_call( transfer, BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
dictionary_call( transfer, DICT_BUFFER, BUFF_PAYLOAD0, 0, 0, USB_IN, load_in, 254);
printf("load_in data:");
for (i=0; i<254; i++) {
@ -172,7 +172,7 @@ int test_function( USBtransfer *transfer )
}
printf("\n");
dictionary_call( transfer, IO, IO_RESET, 0, 0, USB_IN, NULL, 1);
dictionary_call( transfer, DICT_IO, IO_RESET, 0, 0, USB_IN, NULL, 1);
// dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER2, 0x3508, 4);
// dictionary_call( transfer, BUFFER, ALLOCATE_BUFFER3, 0x4A0C, 4);

View File

@ -1,19 +0,0 @@
#ifndef _types_h
#define _types_h
//memory object/struct
typedef struct memory{
int manf;
int partnum;
int volatility; //sram no batt vs batt, mask rom, erasability, etc
int size; //size of the actual memory excluding grounded address pins etc
int addressable; //addressable size of the memory including grounded address pins etc
int width; //width of data bus as configured
int protocol; //parallel, SPI, I2C, JTAG, custom etc.
int sector_size; //minimum eraseable size in bytes
} memory;
#endif

BIN
roms/M10_P128K_C64K_W8K.nes Normal file

Binary file not shown.

BIN
roms/M118_P128K_C64K.nes Normal file

Binary file not shown.

BIN
roms/M180_P128K_H.nes Normal file

Binary file not shown.

BIN
roms/M1_P128K_C128K_W8K.nes Normal file

Binary file not shown.

BIN
roms/M28_P512K.nes Normal file

Binary file not shown.

BIN
roms/M2_P128K_V.nes Normal file

Binary file not shown.

BIN
roms/M34_P128K_H.nes Normal file

Binary file not shown.

BIN
roms/M3_P32K_C32K_H.nes Normal file

Binary file not shown.

BIN
roms/M4_P256K_C256K.nes Normal file

Binary file not shown.

BIN
roms/M66_P64K_C16K_V.nes Normal file

Binary file not shown.

BIN
roms/M69_P128K_C64K_W8K.nes Normal file

Binary file not shown.

BIN
roms/M78.3_P128K_C64K.nes Normal file

Binary file not shown.

BIN
roms/M7_P128K.nes Normal file

Binary file not shown.

BIN
roms/M9_P128K_C64K.nes Normal file

Binary file not shown.

View File

@ -27,7 +27,7 @@
//=============================================================================================
//=============================================================================================
#define PINPORT 1
#define DICT_PINPORT 1
#include "shared_dict_pinport.h"
//pinport dictionary has various commands giving low and mid level access to retro prog's i/o pins.
//It also contains internal avr registers associated with the avr's io.
@ -72,7 +72,7 @@
//=============================================================================================
//=============================================================================================
#define IO 2
#define DICT_IO 2
#include "shared_dict_io.h"
//io dictionary contains commands
//Scope of functions contained is intended to be general and generic not specific
@ -88,7 +88,7 @@
//=============================================================================================
//=============================================================================================
#define NES 3
#define DICT_NES 3
#include "shared_dict_nes.h"
//nes dictionary contains commands
//These commands rely on io initialization from io dictionary prior to calling
@ -99,7 +99,7 @@
//=============================================================================================
//=============================================================================================
#define SNES 4
#define DICT_SNES 4
#include "shared_dict_snes.h"
//snes dictionary contains commands
//These commands rely on io initialization from io dictionary prior to calling
@ -110,7 +110,7 @@
//=============================================================================================
//=============================================================================================
#define BUFFER 5
#define DICT_BUFFER 5
#include "shared_dict_buffer.h"
//mcu buffer dictionary commands
//This library is intended to contain all buffer related opcodes/commands
@ -121,7 +121,7 @@
//=============================================================================================
//=============================================================================================
#define USB 6
#define DICT_USB 6
#include "shared_dict_usb.h"
//currently no actual dictionary as there are no opcodes.
//just used to return status of usbfunctions in event of a transfer error.

View File

@ -2,7 +2,9 @@
#define _error_codes_h
#define SUCCESS 0
#define GEN_FAIL 0xFF
#define FALSE 0
#define NILL 0
//greater than 128 are possible avr return codes
#define ERR_UNKN_DICTIONARY 128