V30B: Add option to always start in a submenu

For example you can change "#define startMenu mainMenu" to "#define startMenu n64Menu" if you only need the N64 stuff.
This commit is contained in:
sanni 2017-11-17 20:53:00 +01:00 committed by GitHub
parent 8e5f90c68a
commit 0ab9f7f120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 173 additions and 163 deletions

View File

@ -2,15 +2,15 @@
Cartridge Reader for Arduino Mega2560
Author: sanni
Date: 2017-10-22
Version: V30
Date: 2017-11-17
Version: V30B
SD lib: https://github.com/greiman/SdFat
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
Clockgen: https://github.com/etherkit/Si5351Arduino
RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools
Compiled with Arduino 1.8.3
Compiled with Arduino 1.8.5
Thanks to:
MichlK - ROM-Reader for Super Nintendo
@ -35,7 +35,13 @@
infinest - help with GB Memory cart
**********************************************************************************/
char ver[5] = "V30";
char ver[5] = "V30B";
/******************************************
Define Starting Point
******************************************/
// mainMenu, n64Menu, snsMenu, npMenu, gbxMenu, segaMenu, flashMenu
#define startMenu mainMenu
/******************************************
Define Output
@ -57,11 +63,6 @@ char ver[5] = "V30";
#define sdSpeed SPI_FULL_SPEED
//#define sdSpeed SPI_HALF_SPEED
/******************************************
Pinout
******************************************/
// Please see included pinout.xls
/******************************************
Libraries
*****************************************/
@ -91,7 +92,7 @@ Si5351 clockgen;
// RGB LED
#include <RGBTools.h>
// set pins of red, green and blue
// Set pins of red, green and blue
RGBTools rgb(12, 11, 10);
typedef enum COLOR_T {
@ -212,7 +213,6 @@ byte sdBuffer[512];
//******************************************
// Bitmaps
//******************************************
// Logo
static const unsigned char PROGMEM icon [] = {
0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF,
@ -322,7 +322,6 @@ static const unsigned char PROGMEM sig [] = {
/******************************************
Menu
*****************************************/
// All menus and menu entries are stored in progmem to save on sram
// Main menu
static const char modeItem1[] PROGMEM = "Nintendo 64";
static const char modeItem2[] PROGMEM = "Super Nintendo";
@ -333,142 +332,6 @@ static const char modeItem6[] PROGMEM = "Flashrom Programmer";
static const char modeItem7[] PROGMEM = "About";
static const char* const modeOptions[] PROGMEM = {modeItem1, modeItem2, modeItem3, modeItem4, modeItem5, modeItem6, modeItem7};
// N64 Submenu
static const char n64MenuItem1[] PROGMEM = "Cart Slot";
static const char n64MenuItem2[] PROGMEM = "Controller";
static const char n64MenuItem3[] PROGMEM = "Flash Repro";
static const char* const menuOptionsN64[] PROGMEM = {n64MenuItem1, n64MenuItem2, n64MenuItem3};
// Nintendo Power Submenu
static const char npMenuItem1[] PROGMEM = "SF Memory";
static const char npMenuItem2[] PROGMEM = "GB Memory";
static const char* const menuOptionsNP[] PROGMEM = {npMenuItem1, npMenuItem2};
// Flash Submenu
static const char flashMenuItem1[] PROGMEM = "8bit slot";
static const char flashMenuItem2[] PROGMEM = "16bit slot";
static const char* const menuOptionsFlash[] PROGMEM = {flashMenuItem1, flashMenuItem2};
// GBx Submenu
static const char gbxMenuItem1[] PROGMEM = "Game Boy (Color)";
static const char gbxMenuItem2[] PROGMEM = "Game Boy Advance";
static const char* const menuOptionsGBx[] PROGMEM = {gbxMenuItem1, gbxMenuItem2};
void n64Menu() {
// create menu with title and 3 options to choose from
unsigned char n64Dev;
// Copy menuOptions out of progmem
convertPgm(menuOptionsN64, 3);
n64Dev = question_box("Select N64 device", menuOptions, 3, 0);
// wait for user choice to come back from the question box menu
switch (n64Dev)
{
case 0:
display_Clear();
display_Update();
setup_N64_Cart();
printCartInfo_N64();
mode = mode_N64_Cart;
break;
case 1:
display_Clear();
display_Update();
setup_N64_Controller();
mode = mode_N64_Controller;
break;
case 2:
display_Clear();
display_Update();
setup_N64_Cart();
flashRepro_N64();
printCartInfo_N64();
mode = mode_N64_Cart;
break;
}
}
void npMenu() {
// create menu with title and 2 options to choose from
unsigned char npCart;
// Copy menuOptions out of progmem
convertPgm(menuOptionsNP, 2);
npCart = question_box("Select NP Cart", menuOptions, 2, 0);
// wait for user choice to come back from the question box menu
switch (npCart)
{
case 0:
display_Clear();
display_Update();
setup_SFM();
mode = mode_SFM;
break;
case 1:
display_Clear();
display_Update();
setup_GBM();
mode = mode_GBM;
break;
}
}
void gbxMenu() {
// create menu with title and 2 options to choose from
unsigned char gbType;
// Copy menuOptions out of progmem
convertPgm(menuOptionsGBx, 2);
gbType = question_box("Select Game Boy", menuOptions, 2, 0);
// wait for user choice to come back from the question box menu
switch (gbType)
{
case 0:
display_Clear();
display_Update();
setup_GB();
mode = mode_GB;
break;
case 1:
display_Clear();
display_Update();
setup_GBA();
mode = mode_GBA;
break;
}
}
void flashMenu() {
// create menu with title and 2 options to choose from
unsigned char flashSlot;
// Copy menuOptions out of progmem
convertPgm(menuOptionsFlash, 2);
flashSlot = question_box("Select flashrom slot", menuOptions, 2, 0);
// wait for user choice to come back from the question box menu
switch (flashSlot)
{
case 0:
display_Clear();
display_Update();
setup_Flash8();
mode = mode_FLASH8;
break;
case 1:
display_Clear();
display_Update();
setup_Flash16();
mode = mode_FLASH16;
break;
}
}
void aboutScreen() {
display_Clear();
// Draw the Logo
@ -534,10 +397,7 @@ void mainMenu() {
break;
case 1:
display_Clear();
display_Update();
setup_Snes();
mode = mode_SNES;
snsMenu();
break;
case 2:
@ -549,10 +409,7 @@ void mainMenu() {
break;
case 4:
display_Clear();
display_Update();
setup_MD();
mode = mode_MD;
segaMenu();
break;
case 5:
@ -564,6 +421,7 @@ void mainMenu() {
break;
}
}
/******************************************
Setup
*****************************************/
@ -619,7 +477,7 @@ void setup() {
Serial.print(F("GB FAT"));
Serial.println(int(sd.vol()->fatType()));
}
mainMenu();
startMenu();
}
/******************************************

View File

@ -15,6 +15,11 @@ unsigned long blank;
/******************************************
Menu
*****************************************/
// Flash start menu
static const char flashMenuItem1[] PROGMEM = "8bit slot";
static const char flashMenuItem2[] PROGMEM = "16bit slot";
static const char* const menuOptionsFlash[] PROGMEM = {flashMenuItem1, flashMenuItem2};
// 8bit Flash menu items
static const char flash8MenuItem1[] PROGMEM = "Blankcheck";
static const char flash8MenuItem2[] PROGMEM = "Erase";
@ -35,6 +40,32 @@ static const char flash16MenuItem6[] PROGMEM = "Print";
static const char flash16MenuItem7[] PROGMEM = "Reset";
static const char* const menuOptionsFLASH16[] PROGMEM = {flash16MenuItem1, flash16MenuItem2, flash16MenuItem3, flash16MenuItem4, flash16MenuItem5, flash16MenuItem6, flash16MenuItem7};
void flashMenu() {
// create menu with title and 2 options to choose from
unsigned char flashSlot;
// Copy menuOptions out of progmem
convertPgm(menuOptionsFlash, 2);
flashSlot = question_box("Select flashrom slot", menuOptions, 2, 0);
// wait for user choice to come back from the question box menu
switch (flashSlot)
{
case 0:
display_Clear();
display_Update();
setup_Flash8();
mode = mode_FLASH8;
break;
case 1:
display_Clear();
display_Update();
setup_Flash16();
mode = mode_FLASH16;
break;
}
}
void flashromMenu8() {
// create menu with title and 7 options to choose from
unsigned char mainMenu;

View File

@ -13,6 +13,11 @@ uint16_t sramEndAddress = 0;
/******************************************
Menu
*****************************************/
// GBx start menu
static const char gbxMenuItem1[] PROGMEM = "Game Boy (Color)";
static const char gbxMenuItem2[] PROGMEM = "Game Boy Advance";
static const char* const menuOptionsGBx[] PROGMEM = {gbxMenuItem1, gbxMenuItem2};
// GB menu items
static const char GBMenuItem1[] PROGMEM = "Read Rom";
static const char GBMenuItem2[] PROGMEM = "Read Save";
@ -21,6 +26,33 @@ static const char GBMenuItem4[] PROGMEM = "Write Flashcart";
static const char GBMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsGB[] PROGMEM = {GBMenuItem1, GBMenuItem2, GBMenuItem3, GBMenuItem4, GBMenuItem5};
// Start menu for both GB and GBA
void gbxMenu() {
// create menu with title and 2 options to choose from
unsigned char gbType;
// Copy menuOptions out of progmem
convertPgm(menuOptionsGBx, 2);
gbType = question_box("Select Game Boy", menuOptions, 2, 0);
// wait for user choice to come back from the question box menu
switch (gbType)
{
case 0:
display_Clear();
display_Update();
setup_GB();
mode = mode_GB;
break;
case 1:
display_Clear();
display_Update();
setup_GBA();
mode = mode_GBA;
break;
}
}
void gbMenu() {
// create menu with title and 5 options to choose from
unsigned char mainMenu;

View File

@ -18,6 +18,14 @@ static const char MDMenuItem4[] PROGMEM = "Write Flashcart";
static const char MDMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsMD[] PROGMEM = {MDMenuItem1, MDMenuItem2, MDMenuItem3, MDMenuItem4, MDMenuItem5};
// Sega start menu
void segaMenu() {
display_Clear();
display_Update();
setup_MD();
mode = mode_MD;
}
void mdMenu() {
// create menu with title and 5 options to choose from
unsigned char mainMenu;

View File

@ -45,6 +45,12 @@ boolean MN63F81MPN = false;
/******************************************
Menu
*****************************************/
// N64 start menu
static const char n64MenuItem1[] PROGMEM = "Cart Slot";
static const char n64MenuItem2[] PROGMEM = "Controller";
static const char n64MenuItem3[] PROGMEM = "Flash Repro";
static const char* const menuOptionsN64[] PROGMEM = {n64MenuItem1, n64MenuItem2, n64MenuItem3};
// N64 controller menu items
static const char N64ContMenuItem1[] PROGMEM = "Test Controller";
static const char N64ContMenuItem2[] PROGMEM = "Read ControllerPak";
@ -66,6 +72,44 @@ static const char N64CRCMenuItem3[] PROGMEM = "Ignore";
static const char N64CRCMenuItem4[] PROGMEM = "Reset";
static const char* const menuOptionsN64CRC[] PROGMEM = {N64CRCMenuItem1, N64CRCMenuItem2, N64CRCMenuItem3, N64CRCMenuItem4};
// N64 start menu
void n64Menu() {
// create menu with title and 3 options to choose from
unsigned char n64Dev;
// Copy menuOptions out of progmem
convertPgm(menuOptionsN64, 3);
n64Dev = question_box("Select N64 device", menuOptions, 3, 0);
// wait for user choice to come back from the question box menu
switch (n64Dev)
{
case 0:
display_Clear();
display_Update();
setup_N64_Cart();
printCartInfo_N64();
mode = mode_N64_Cart;
break;
case 1:
display_Clear();
display_Update();
setup_N64_Controller();
mode = mode_N64_Controller;
break;
case 2:
display_Clear();
display_Update();
setup_N64_Cart();
flashRepro_N64();
printCartInfo_N64();
mode = mode_N64_Cart;
break;
}
}
// N64 Controller Menu
void n64ControllerMenu() {
// create menu with title and 4 options to choose from

View File

@ -12,9 +12,7 @@
******************************************/
// The clock signal for the SF Memory cassette
// is generated with the Adafruit Clock Generator
// If you don't have one just plug a wire into CLK0
// (Snes Pin 1) and let the 50/60Hz noise of your
// mains do the rest, works in ~80% of all cases ;)
// or a similar external clock source
/******************************************
Variables
@ -37,6 +35,11 @@ boolean hirom[8];
/******************************************
Menu
*****************************************/
// Nintendo Power start menu
static const char npMenuItem1[] PROGMEM = "SF Memory";
static const char npMenuItem2[] PROGMEM = "GB Memory";
static const char* const menuOptionsNP[] PROGMEM = {npMenuItem1, npMenuItem2};
// SFM menu items
static const char sfmMenuItem1[] PROGMEM = "Game Menu";
static const char sfmMenuItem2[] PROGMEM = "Flash Menu";
@ -60,6 +63,32 @@ static const char sfmGameMenuItem4[] PROGMEM = "Switch Game";
static const char sfmGameMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsSFMGame[] PROGMEM = {sfmGameMenuItem1, sfmGameMenuItem2, sfmGameMenuItem3, sfmGameMenuItem4, sfmGameMenuItem5};
void npMenu() {
// create menu with title and 2 options to choose from
unsigned char npCart;
// Copy menuOptions out of progmem
convertPgm(menuOptionsNP, 2);
npCart = question_box("Select NP Cart", menuOptions, 2, 0);
// wait for user choice to come back from the question box menu
switch (npCart)
{
case 0:
display_Clear();
display_Update();
setup_SFM();
mode = mode_SFM;
break;
case 1:
display_Clear();
display_Update();
setup_GBM();
mode = mode_GBM;
break;
}
}
void sfmMenu() {
// create menu with title and 3 options to choose from
unsigned char mainMenu;

View File

@ -42,6 +42,14 @@ static const char confMenuItem4[] PROGMEM = "6MB ExRom 256K Sram";
static const char confMenuItem5[] PROGMEM = "Reset";
static const char* const menuOptionsConf[] PROGMEM = {confMenuItem1, confMenuItem2, confMenuItem3, confMenuItem4, confMenuItem5};
// SNES start menu
void snsMenu() {
display_Clear();
display_Update();
setup_Snes();
mode = mode_SNES;
}
// SNES Menu
void snesMenu() {
// create menu with title and 7 options to choose from
@ -907,11 +915,11 @@ void readROM_SNES() {
//Dump Low-type ROM
else if (romType == LO) {
if(romSize > 24) {
if (romSize > 24) {
// ROM > 96 banks (up to 128 banks)
readLoRomBanks( 0x80, numBanks + 0x80, &myFile );
} else {
// Read up to 96 banks starting at bank 0×00.
// Read up to 96 banks starting at bank 0×00.
readLoRomBanks( 0, numBanks, &myFile );
}
}
@ -1838,4 +1846,4 @@ boolean eraseSRAM (byte b) {
//******************************************
// End of File
//******************************************
//******************************************