Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 54 additions & 13 deletions Cart_Reader/7800.ino
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ byte a7800size;
// 07 MAPPER
// 08 ROM SIZE

bool enable_clockgen = false;
bool clockgen_selected = false;

//******************************************
// Menu
//******************************************
// Base Menu
static const char* const menuOptions7800[] PROGMEM = { FSTRING_SELECT_CART, FSTRING_READ_ROM, FSTRING_SET_SIZE, FSTRING_RESET };
// Clock Gen Menu
static const char* const menuClockGen7800[] PROGMEM = { FSTRING_CLKGEN_OFF, FSTRING_CLKGEN_ON };

void setup_7800() {
void setup_7800(bool display_status) {
// Request 5V
setVoltage(VOLTS_SET_5V);

Expand Down Expand Up @@ -131,34 +136,68 @@ void setup_7800() {
// Set Eeprom clock to 1Mhz
clockgen.set_freq(200000000ULL, SI5351_CLK1);

// Start outputting Eeprom clock
clockgen.output_enable(SI5351_CLK1, 1); // Eeprom clock
if (enable_clockgen) {
// Start outputting Eeprom clock
clockgen.output_enable(SI5351_CLK1, 1); // Eeprom clock
} else {
clockgen.output_enable(SI5351_CLK1, 0); // SI5351_CLK_DISABLE = 0
clockgen.set_clock_disable(SI5351_CLK1, 2); // SI5351_CLK_DISABLE_HI_Z = 2
}

// Wait for clock generator
clockgen.update_status();

#else
// Set CLK(PH1) to Output
DDRH |= (1 << 1);
// Output a high signal CLK(PH1)
PORTH |= (1 << 1);
#endif

checkStatus_7800();
if (!enable_clockgen) {
// Set CLK(PH1) to Output
DDRH |= (1 << 1);
// Output a high signal CLK(PH1)
PORTH |= (1 << 1);
}

if (display_status) {
checkStatus_7800();
}

strcpy(romName, "ATARI");

mode = CORE_7800;
}

void a7800Menu() {
uint8_t mainMenu;

#ifdef ENABLE_CLOCKGEN
if (!clockgen_selected) {
convertPgm(menuClockGen7800, 2);
mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 2, 0);

switch (mainMenu) {
case 0:
// Disable Clock Gen
enable_clockgen = false;
break;

case 1:
// Enable Clock Gen
enable_clockgen = true;
break;
}

setup_7800(true);

clockgen_selected = true;
}
#endif

convertPgm(menuOptions7800, 4);
uint8_t mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 4, 0);
mainMenu = question_box(F("ATARI 7800 MENU"), menuOptions, 4, 0);

switch (mainMenu) {
case 0:
// Select Cart
setCart_7800();
setup_7800();
setup_7800(true);
break;

case 1:
Expand Down Expand Up @@ -579,6 +618,7 @@ void checkStatus_7800() {
print_Msg(FS(FSTRING_ROM_SIZE));
print_Msg(a7800[a7800size]);
println_Msg(F("K"));
println_Msg(enable_clockgen ? FS(FSTRING_CLKGEN_ON) : FS(FSTRING_CLKGEN_OFF));
display_Update();
wait();
#else
Expand All @@ -605,7 +645,8 @@ void checkStatus_7800() {
Serial.print(FS(FSTRING_ROM_SIZE));
Serial.print(A7800[a7800size]);
Serial.println(F("K"));
Serial.println(FS(FSTRING_EMPTY));
Serial.println(F("K"));
Serial.println(enable_clockgen ? FS(FSTRING_CLKGEN_ON) : FS(FSTRING_CLKGEN_OFF));
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Cart_Reader/Cart_Reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ void mainMenu() {

#ifdef ENABLE_7800
case SYSTEM_MENU_7800:
setup_7800();
setup_7800(false);
return a7800Menu();
break;
#endif
Expand Down
2 changes: 2 additions & 0 deletions Cart_Reader/OSCR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ constexpr char PROGMEM FSTRING_CHECKSUM[] = "Checksum: ";
constexpr char PROGMEM FSTRING_ROM_SIZE[] = "ROM Size: ";
constexpr char PROGMEM FSTRING_REVISION[] = "Revision: ";
constexpr char PROGMEM FSTRING_SERIAL[] = "Serial: ";
constexpr char PROGMEM FSTRING_CLKGEN_ON[] = "Enable Clock Gen";
constexpr char PROGMEM FSTRING_CLKGEN_OFF[] = "Disable Clock Gen";

/*==== /CONSTANTS =================================================*/

Expand Down
2 changes: 2 additions & 0 deletions Cart_Reader/OSCR.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ extern const char PROGMEM FSTRING_NAME[];
extern const char PROGMEM FSTRING_CHECKSUM[];
extern const char PROGMEM FSTRING_REVISION[];
extern const char PROGMEM FSTRING_SERIAL[];
extern const char PROGMEM FSTRING_CLKGEN_ON[];
extern const char PROGMEM FSTRING_CLKGEN_OFF[];

#define FS(pmem_string) (reinterpret_cast<const __FlashStringHelper *>(pmem_string))

Expand Down