Determining overall operation READ/WRITE.

This commit is contained in:
paul eeepc 2016-12-07 19:19:34 -06:00
parent 66635b15e7
commit d97c31db62
4 changed files with 70 additions and 9 deletions

View File

@ -117,6 +117,8 @@ int detect_console( cartridge *cart, USBtransfer *transfer )
return SUCCESS;
error:
//always end with resetting i/o
io_reset( transfer );
return -1;
}
@ -133,14 +135,54 @@ error:
int detect_mirroring( cartridge *cart, USBtransfer *transfer )
{
//always start with resetting i/o
io_reset( transfer );
if ( cart->console == NES_CART ) {
//For now just assume mirroring is fixed until start adding support for other mappers
cart->mirroring = MIR_FIXED;
}
//always end with resetting i/o
io_reset( transfer );
return SUCCESS;
//error:
//always end with resetting i/o
//io_reset( transfer );
// return -1;
}
//detecting mapper and memories ends up being one big operation
int detect_map_mem( cartridge *cart, USBtransfer *transfer )
{
//always start with resetting i/o
io_reset( transfer );
if ( cart->console == NES_CART && cart->mirroring = MIR_FIXED ) {
//if INL-ROM discrete board with EXP0->PRG-ROM /WE
//EXP0 pullup test should pass
if( exp0_pullup_test(transfer) == SUCCESS ){
} else {
//Potentially some other discrete board without EXP0->WE flash control
//Some ASIC mappers have fixed mirroring as well
}
//for NROM flashing first verify EXP0 pull up will clock /WE properly
}
//always end with resetting i/o
io_reset( transfer );
return SUCCESS;
//error:
//always end with resetting i/o
//io_reset( transfer );
// return -1;
}

View File

@ -19,5 +19,11 @@ enum mirroring {
MIR_MMC3
};
enum operations {
READ = 10,
WRITE,
CHECK
};
#endif

View File

@ -9,11 +9,7 @@ int erase_nes( USBtransfer *transfer )
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_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);

View File

@ -51,12 +51,12 @@ int main(int argc, char *argv[])
char *C_value = NULL; //program chr file
char *L_value = NULL; //LIBUSB debugging value
char *K_value = NULL; //connect to kazzo firmware version #
char *O_value = NULL; //start programming at offset base value
char *O_value = NULL; //start read/writing at offset base value
char *P_value = NULL; //program prg file
char *S_value = NULL; //program SNES binary file
char *W_value = NULL; //program WRAM/SRAM file
int operation = 0; //used to denote the overall operation being requested flash/dump/verify etc
int index = 0;
int rv = 0;
opterr = 0;
@ -139,15 +139,31 @@ int main(int argc, char *argv[])
//TODO display better help message
if (h_flag) {
printf("you've asked for help but the help message still needs created...\n");
printf("You've asked for help but the help message still needs created...\n");
return 0;
}
//Determine overall operation being performed based on user args
//Also don't want to continue if conflicting args are being used
//flags about input files only used for writes
if ( p_flag || i_value || C_value || P_value || S_value || W_value ) {
check( d_value == NULL, "input args conflict can't program and dump in same operation.");
operation = WRITE;
}
//flags about output files used for reads
if ( d_value ) {
check( e_flag == 0, "input args conflict can't erase and dump in same operation.");
operation = READ;
}
//context set to NULL since only acting as single user of libusb
libusb_context *context = NULL;
//create USBtransfer struct to hold all transfer info
USBtransfer *transfer = malloc( sizeof(USBtransfer));
//create usb device handle pointer to interact with retro-prog
//libusb_device_handle *rprog_handle = NULL;
transfer->handle = NULL;
@ -189,16 +205,16 @@ int main(int argc, char *argv[])
cartridge *cart = malloc( sizeof(cartridge));
check_mem(cart);
//set all cart elements to UNKNOWN
//set all cart elements to UNKNOWN and allocate memory object within
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
@ -206,6 +222,7 @@ int main(int argc, char *argv[])
//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
check(!detect_map_mem( cart, transfer ), "Problem detecting cart map & memory.");
//detect rom sizes as much as possible