Skip to content

Commit

Permalink
-QOL & print changes
Browse files Browse the repository at this point in the history
-debug & docu info/comments
-speed up spi to gb clock 4 mhz
-speed up uart baud to 19200
  • Loading branch information
wodowiesel committed Oct 22, 2024
1 parent 81d40dd commit 0d441df
Show file tree
Hide file tree
Showing 13 changed files with 1,140 additions and 1,115 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
Author: WodoWiesel
github: (https://github.com/wodowiesel/GB-Dumper)
Last Modified: 14 November 2023
Last Modified: 28 June 2024
Compativble with PCB v0.83!
*/

#ifndef PINDECLARATIONS_H_
#define PINDECLARATIONS_H_
#define HW3 // hardware revision v3.x
#define HW 3 // hardware revision v3.x nano
#define FW 4.4
#define OZ 28.800 //xtal oscilator 28,800 MHz
/*
// AVR definitions for Arduino nano! -> check your cocnnections again!
Expand Down Expand Up @@ -116,13 +119,13 @@
#define gb30Pin_high PORTB |= (1<<PB6); // /RES Pin3&29
#define gb30Pin_low PORTB &= ~(1<<PB6);

#define gb30cPin_high PORTD |= (1<<PD0); // /CS2(digital)on D0/PD0 Pin1
#define gb30cPin_high PORTD |= (1<<PD0); // /CS2(digital) on D0/PD0 Pin1
#define gb30cPin_low PORTD &= ~(1<<PD0);

#define gb31Pin_high PORTC |= (1<<PC1); // AUD_IN analog on A1 PC1 Pin21 (bits 7 & 3 of NR_50 register )
#define gb31Pin_low PORTC &= ~(1<<PC1);

#define gb31iPin_high PORTB |= (1<<PD2); // IRQ (digital) Pin5 INT0 D2 (on MISO Pin15 D12 old)
#define gb31iPin_high PORTB |= (1<<PD2); // IRQ (digital) Pin5 INT0 D2 (on MISO Pin15 D12 old)
#define gb31iPin_low PORTB &= ~(1<<PD2);

#endif /* PINDECLARATIONS_H_ */
48 changes: 25 additions & 23 deletions code-pc/c/GBCartRead_v1.8_Rev1.3_C_Interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Alex from insideGadgets (www.insidegadgets.com)
Created: 21/07/2013
Modified:26/05/2016
Optimized: 05/05/2024 by WodoWiesel
Optimized: 21/10/2024 by WodoWiesel
*/
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -17,7 +17,7 @@
#include <unistd.h>
#endif
int cport_nr = 2; // /dev/ttyS0 (COM1 on windows) , i use on com3
int bdrate = 9600; // 57600 baud (default)
int bdrate = 19200; // 9600 (slow), 57600 baud (default)
int firstStart = 1;
int headercounter = 0;
char gametitle[80];
Expand Down Expand Up @@ -136,12 +136,12 @@ void read_from_file(char* filename, char* cmd) {
}
int main() {
read_config();
printf("GBCartRead v1.8 Rev. 1.3 by wodowiessel\n");
printf("################################\n\n");
printf("Opening COM PORT %d at %d baud ...\n\n", cport_nr+1, bdrate);
printf("GB-Dumper v1.8 Rev. 1.3.2 by wodowiesel\n");
printf("################################\n");
printf("Opening COM PORT %d at %d baud ...\n", cport_nr+1, bdrate);
// Open COM port
if(RS232_OpenComport(cport_nr, bdrate)) {
printf("Can not open com port\n");
printf("Can not open COM port\n");
return(0);
}
#ifdef _WIN32
Expand All @@ -152,11 +152,11 @@ int main() {
char userInput = '0';
while (1) {
printf ("\nSelect an option below\n0. Read Header\n1. Dump ROM\n2. Save RAM\n3. Write RAM\n4. Exit\n");
printf (">");
printf ("> ");
userInput = read_one_letter();
if (userInput == '0') {
headercounter = 0;
RS232_cputs(cport_nr, "HEADER\n");
RS232_cputs(cport_nr, "HEADER");
unsigned char buffer[4096];
int n = 0;
int waitingforheader = 0;
Expand All @@ -181,7 +181,7 @@ int main() {
}
char* tokstr = strtok ((char *) buffer, "\r\n");
if (tokstr == NULL) {
printf ("tokstr: NULL error, no title found, using default: unknown\n");
printf ("\ntokstr: NULL error, no title found, using default: unknown\n");
tokstr = "unknown";
}
while (tokstr != NULL) {
Expand Down Expand Up @@ -255,15 +255,15 @@ int main() {
}
}
else if (headercounter == 3) {
printf ("RAM size: ");
printf ("\nRAM size: ");
ramSize = atoi(tokstr);
switch (ramSize) {
case 0:
if (cartridgeType == 6) {
printf ("512 bytes (nibbles)\n");
}
else {
printf ("None\n");
printf ("0 None\n");
}
break;
case 1: printf ("2 KBytes\n"); break;
Expand All @@ -277,44 +277,44 @@ int main() {
printf ("Logo check: ");
logoCheck = atoi(tokstr);
if (logoCheck == 1) {
printf ("OK\n");
printf ("1 OK\n");
}
else {
printf ("Failed\n");
printf ("0 Failed\n");
}
}
else {
printf ("\nselect loop error\n");
}
tokstr = strtok (NULL, "\r\n");
//tokstr = strtok (NULL, "\r\n");
printf ("tokstr: %s\n", tokstr);
headercounter++;
}
printf ("\nFlushed\n");
fflush(stdout);
}
else if (userInput == '1') {
printf ("\nDumping ROM to %s.gb ... ", gametitle);
printf ("\nDumping ROM to %s.gb ... \n", gametitle);
strncpy(filename, gametitle, 20);
strcat(filename, ".gb");
write_to_file(filename, "READROM\n", 32);
write_to_file(filename, "READROM", 32);
printf ("\nFinished\n");
}
else if (userInput == '2') {
printf ("\nDumping RAM to %s.sav ... ", gametitle);
printf ("\nDumping RAM to %s.sav ... \n", gametitle);
strncpy(filename, gametitle, 20); //why 20?
strcat(filename, ".sav");
write_to_file(filename, "READRAM\n", 1);
write_to_file(filename, "READRAM", 1);
printf ("\nFinished\n");
}
else if (userInput == '3') {
printf ("\nGoing to write to RAM from %s.sav ...", gametitle);
printf ("\n*** This will erase the save game from your Gameboy Cartridge ***");
printf ("\nPress y to continue or any other key to abort.");
printf ("\n>");
printf ("\nGoing to write to RAM from %s.sav ...\n", gametitle);
printf ("*** This will erase the save game from your Gameboy Cartridge ***\n");
printf ("Press y to continue or any other key to abort.\n");
printf ("> ");
char userInputConfirm = read_one_letter();
if (userInputConfirm == 'y') {
printf ("\nWriting to RAM from %s.sav ... ", gametitle);
printf ("\nWriting to RAM from %s.sav ... \n", gametitle);
strncpy(filename, gametitle, 30);
strcat(filename, ".sav");
read_from_file(filename, "WRITERAM\n");
Expand All @@ -326,6 +326,8 @@ int main() {
}
else if (userInput == '4') {
RS232_CloseComport(cport_nr);
printf("\nCLosing Com connection...\n");
printf("\nExiting..\n");
return(0);
}
else {
Expand Down
Binary file modified code-pc/c/GBCartRead_v1.8_Rev1.3_C_Interface.exe
Binary file not shown.
52 changes: 25 additions & 27 deletions code-pc/c/GBCartRead_v1.8_Rev1.3_C_Interface.i
Original file line number Diff line number Diff line change
Expand Up @@ -131114,7 +131114,7 @@ int unlinkat (int, const char *, int);

# 19 "GBCartRead_v1.8_Rev1.3_C_Interface.c"
int cport_nr = 2;
int bdrate = 9600;
int bdrate = 19200;
int firstStart = 1;
int headercounter = 0;
char gametitle[80];
Expand Down Expand Up @@ -131249,12 +131249,12 @@ void read_from_file(char* filename, char* cmd) {
}
int main() {
read_config();
printf("GBCartRead v1.8 Rev. 1.3 by wodowiessel\n");
printf("################################\n\n");
printf("Opening COM PORT %d at %d baud ...\n\n", cport_nr+1, bdrate);
printf("GB-Dumper v1.8 Rev. 1.3.2 by wodowiesel\n");
printf("################################\n");
printf("Opening COM PORT %d at %d baud ...\n", cport_nr+1, bdrate);

if(RS232_OpenComport(cport_nr, bdrate)) {
printf("Can not open com port\n");
printf("Can not open COM port\n");
return(0);
}

Expand All @@ -131265,11 +131265,11 @@ int main() {
char userInput = '0';
while (1) {
printf ("\nSelect an option below\n0. Read Header\n1. Dump ROM\n2. Save RAM\n3. Write RAM\n4. Exit\n");
printf (">");
printf ("> ");
userInput = read_one_letter();
if (userInput == '0') {
headercounter = 0;
RS232_cputs(cport_nr, "HEADER\n");
RS232_cputs(cport_nr, "HEADER");
unsigned char buffer[4096];
int n = 0;
int waitingforheader = 0;
Expand Down Expand Up @@ -131302,7 +131302,7 @@ int main() {
((void *)0)
# 183 "GBCartRead_v1.8_Rev1.3_C_Interface.c"
) {
printf ("tokstr: NULL error, no title found, using default: unknown\n");
printf ("\ntokstr: NULL error, no title found, using default: unknown\n");
tokstr = "unknown";
}
while (tokstr !=
Expand Down Expand Up @@ -131380,15 +131380,15 @@ int main() {
}
}
else if (headercounter == 3) {
printf ("RAM size: ");
printf ("\nRAM size: ");
ramSize = atoi(tokstr);
switch (ramSize) {
case 0:
if (cartridgeType == 6) {
printf ("512 bytes (nibbles)\n");
}
else {
printf ("None\n");
printf ("0 None\n");
}
break;
case 1: printf ("2 KBytes\n"); break;
Expand All @@ -131402,20 +131402,16 @@ int main() {
printf ("Logo check: ");
logoCheck = atoi(tokstr);
if (logoCheck == 1) {
printf ("OK\n");
printf ("1 OK\n");
}
else {
printf ("Failed\n");
printf ("0 Failed\n");
}
}
else {
printf ("\nselect loop error\n");
}
tokstr = strtok (
# 289 "GBCartRead_v1.8_Rev1.3_C_Interface.c" 3 4
((void *)0)
# 289 "GBCartRead_v1.8_Rev1.3_C_Interface.c"
, "\r\n");

printf ("tokstr: %s\n", tokstr);
headercounter++;
}
Expand All @@ -131427,28 +131423,28 @@ int main() {
);
}
else if (userInput == '1') {
printf ("\nDumping ROM to %s.gb ... ", gametitle);
printf ("\nDumping ROM to %s.gb ... \n", gametitle);
strncpy(filename, gametitle, 20);
strcat(filename, ".gb");
write_to_file(filename, "READROM\n", 32);
write_to_file(filename, "READROM", 32);
printf ("\nFinished\n");
}
else if (userInput == '2') {
printf ("\nDumping RAM to %s.sav ... ", gametitle);
printf ("\nDumping RAM to %s.sav ... \n", gametitle);
strncpy(filename, gametitle, 20);
strcat(filename, ".sav");
write_to_file(filename, "READRAM\n", 1);
write_to_file(filename, "READRAM", 1);
printf ("\nFinished\n");
}
else if (userInput == '3') {
printf ("\nGoing to write to RAM from %s.sav ...", gametitle);
printf ("\n*** This will erase the save game from your Gameboy Cartridge ***");
printf ("\nPress y to continue or any other key to abort.");
printf ("\n>");
printf ("\nGoing to write to RAM from %s.sav ...\n", gametitle);
printf ("*** This will erase the save game from your Gameboy Cartridge ***\n");
printf ("Press y to continue or any other key to abort.\n");
printf ("> ");
char userInputConfirm = read_one_letter();
if (userInputConfirm == 'y') {
printf ("\nWriting to RAM from %s.sav ... ", gametitle);
strncpy(filename, gametitle, 20);
printf ("\nWriting to RAM from %s.sav ... \n", gametitle);
strncpy(filename, gametitle, 30);
strcat(filename, ".sav");
read_from_file(filename, "WRITERAM\n");
printf ("\nFinished\n");
Expand All @@ -131459,6 +131455,8 @@ int main() {
}
else if (userInput == '4') {
RS232_CloseComport(cport_nr);
printf("\nCLosing Com connection...\n");
printf("\nExiting..\n");
return(0);
}
else {
Expand Down
Binary file modified code-pc/c/GBCartRead_v1.8_Rev1.3_C_Interface.o
Binary file not shown.
Loading

0 comments on commit 0d441df

Please sign in to comment.