8-bit BBG Famicom Clone is a powerful machine that can be connected to PC using DB25 Parallel (male to male) cable.
On PC, you will need to run pcsvr.exe which listens to the parallel port,
And on BBG Famiclone, you will need to run pclink.cmd on 8-bit BBGDOS (DOS-like OS),
The DB25 parallel cable will be connected to both BBG and PC (both sides are male), which will allow BBG to access the files on PC (the files can be on any storage devices for PC, e.g. harddrive, USB sticks, floppy drives and even read-only CD-ROMs.
The DOS prompt for BBG-1 after successfully connecting to PC is C:\ while on BBG-98, the C:\ is reserved for internal readonly 2M ROM and D:\ is the remote PC drive.
Now, as we all know, on BBG famiclone, there is no CMOS-like battery, thus, the date and time will not be saved after power off, everytime BBGDOS is booting, the time and date will be reset…
Because using pclink.cmd – pcsvr.exe we are allowed to access the files on PC from BBG, so we can run a batch file (located on PC), which sets the correct time and date on BBG.. Here are the steps to accomplish this.
First, the following C/C++ code will output the time and date (with some parameters) to console.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include <iostream> #include <ctime> #include <string.h> using namespace std; inline void pr(int x) { if (x < 10) { cout << '0'; } cout << x; } int main(int argc, char** argv) { if (argc == 1) { cout << "Create Batch File of Time and Date." << endl; cout << "By http://HelloACM.com" << endl; cout << "Usage: " << argv[0] << " [options] files.bat " << endl; cout << "-t Time; -d Date; -e @Echo off; -s No REM" << endl; return 1; } bool tt = false; bool date = false; bool echo = false; bool rem = true; for (int i = 1; i < argc; i ++) { int len = strlen(argv[i]); for (int j = 0; j < len; j ++) { if (argv[i][j] == 't') { tt = true; } else if (argv[i][j] == 'd') { date = true; } else if (argv[i][j] == 'e') { echo = true; } else if (argv[i][j] == 's') { rem = false; } } } if (echo) { cout << "@echo off" << endl; } if (rem) { cout << "echo TimeDate Batch File For BBG" << endl; cout << "echo Save the Output to File and Run it Remotely on BBG" << endl; cout << "echo BBG-pclink.cmd PC-pcsvr.exe" << endl; cout << "REM Visit http://HelloACM.com" << endl; } time_t now = time(0); tm *ltm = localtime(&now); if (date) { cout << "date "; pr(1 + ltm->tm_mon); cout << "-"; pr(ltm->tm_mday); cout << "-" << 1900 + ltm->tm_year << endl; } if (tt) { cout << "time "; pr(ltm->tm_hour % 12); cout << ":"; pr(ltm->tm_min); cout << ":"; pr(ltm->tm_sec); cout << endl; } return 0; } |
#include <iostream> #include <ctime> #include <string.h> using namespace std; inline void pr(int x) { if (x < 10) { cout << '0'; } cout << x; } int main(int argc, char** argv) { if (argc == 1) { cout << "Create Batch File of Time and Date." << endl; cout << "By http://HelloACM.com" << endl; cout << "Usage: " << argv[0] << " [options] files.bat " << endl; cout << "-t Time; -d Date; -e @Echo off; -s No REM" << endl; return 1; } bool tt = false; bool date = false; bool echo = false; bool rem = true; for (int i = 1; i < argc; i ++) { int len = strlen(argv[i]); for (int j = 0; j < len; j ++) { if (argv[i][j] == 't') { tt = true; } else if (argv[i][j] == 'd') { date = true; } else if (argv[i][j] == 'e') { echo = true; } else if (argv[i][j] == 's') { rem = false; } } } if (echo) { cout << "@echo off" << endl; } if (rem) { cout << "echo TimeDate Batch File For BBG" << endl; cout << "echo Save the Output to File and Run it Remotely on BBG" << endl; cout << "echo BBG-pclink.cmd PC-pcsvr.exe" << endl; cout << "REM Visit http://HelloACM.com" << endl; } time_t now = time(0); tm *ltm = localtime(&now); if (date) { cout << "date "; pr(1 + ltm->tm_mon); cout << "-"; pr(ltm->tm_mday); cout << "-" << 1900 + ltm->tm_year << endl; } if (tt) { cout << "time "; pr(ltm->tm_hour % 12); cout << ":"; pr(ltm->tm_min); cout << ":"; pr(ltm->tm_sec); cout << endl; } return 0; }
The date format accepted on BBGDOS is Month-Day-Year. The format is fixed width, so for Month and Day it is two digit and for Year it is four digit. The example is 03-13-2014.
The time format accepted on BBGDOS is Hour-Minute-Second. Each is two-digit width, for example, 00:23:44. The hour is from 00 to 11, so we have to do a modulation of hour on 12.
Also, we need to create a batch file to run on PC update.bat, which contains the following:
@echo off echo Press Ctrl-C to Exit... echo It will Update Time and Date to UpdateTD.bat every ten seconds. echo On BBG, Run e.g. C:\UpdateTD.bat to Synchronize Time and Date :Update echo Updating Time and Date to UpdateTD.bat ... echo @echo off > UpdateTD.bat echo echo TimeDate Batch File For BBG>> UpdateTD.bat echo echo Save the Output to File and Run it Remotely on BBG>> UpdateTD.bat echo echo BBG-pclink.cmd PC-pcsvr.exe>> UpdateTD.bat echo bbgcdos /z4 >> UpdateTD.bat TimeBat.exe -std >> UpdateTD.bat echo date >> UpdateTD.bat echo time >> UpdateTD.bat echo OK! echo Wait Ten Seconds ... sleep 10000 Goto :Update
The idea is to create a latest batch file with updated time and date command to run on BBG Famiclone. After BBG is connected to PC, then runs the UpdateTD.bat (updated by Update.bat on PC every ten seconds) to correctly set the time and date on BBG.
To sleep 10 seconds, we can use sleep.exe (google for it, there are tons of implementation) or you can use ping -n 10 127.0.0.1 > NUL in case that you don’t want to bother with it. ping.exe is available almost on every windows, which is a command line tool to check network connection problems given a host name (or IP address). parameter -n 10 will test the connection 10 times each time pause for 1 second, so that will give us 10 seconds time span. 127.0.0.1 is known as the local IP loop (which is valid and connective in all times) and > at the end will write all the output (redirection) to the file, which is NUL i.e. disregarded.
The UpdateTD.bat looks like this:
@echo off echo TimeDate Batch File For BBG echo Save the Output to File and Run it Remotely on BBG echo BBG-pclink.cmd PC-pcsvr.exe bbgcdos /z4 date 03-13-2014 time 09:31:12 date time
And it works! Simply put the following in the autoexec.bat on booting floppy on BBG Famiclone so on startup, BBG will execute the batch script.
@echo off pclink.cmd C:\UpdateTD.bat
You can adjust the file path on PC, so it doesn’t have to be C:\, it can have sub-folders such as C:\Test\UpdateTD.bat.
The entire batch code and program can be download in this zipped (170kb) file
Without Battery, you can always have a correct time and date on 8-bit BBG Famicom clone now!.
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Using Peek function to read from Memory on BBG Famicom Clone on Basic Programming Language
Next Post: Dumping Memory using BASIC on 8-bit Famicom Clone - BBG