Pages

Sunday, March 1, 2020

dreamcast.local VII - Uploads and Downloads

Uploading files from your Dreamcast the Dreamcast server sounds easy, but it is not. Downloading files from the Dreamcast server also sounds easy, but it is also not. With this article I will explain the major pitfalls and how to avoid them.

Part I - Uploading files

For uploading files from your Dreamcast to the Dreamcast server, you can not use any generic file uploader (no matter if written in PHP or Perl). One reason is, that Dream Key is using a modified Netscape/Mozilla 3.0 version, which does not use the default 'input type="file"' element. Instead it uses 'input type="vmfile"'. Another reason is the structure of downloads for the Dreamcast. Downloads for the Dreamcast are splitted into two different files:
  • The first file is the VMI file, which is only some sort of descriptor file.
  • The second files is them VMS file, which contains the actual content to download.
See the (unofficial) VMU FAQ for more details about this topic.

Since I am really not a developer, I searched for an alternative to develop an VMU uploader. I found an excellent alternative with NeoDC. NeoDC has the entire code that is needed to upload content from your VMU's and it also creates the VMI and VMS structure. So here is what I did:
  • Download NeoDC
  • Extract the required code from the NeoDC project into a single neodc.php file
  • Create a very simple upload front end, that would use the neodc.php upload functions
To get these files, navigate to https://drive.google.com/open?id=13-bYNo7srDDny-jcxFUHxESc3SHJoi5Y and download dc_up_down.tar.gz. Copy it on the Dramcast server to /var/www/html. Then go into the same directory and extract it:

# cd /var/www/html
# tar xf dc_up_down.tar.gz


You should have at least the following structure now:

# tree
.
├── dc_up_down.tar.gz
├── download.php
├── neodc.php
├── upload
│   ├── _SILVE_0.VMI
│   ├── _SILVE_0.VMS
│   ├── _SILVE_1.VMI
│   └── _SILVE_1.VMS
└── upload.php


download.php will just list all VMI files inside the upload folder
neodc.php contains the functions to upload content from your VMU
upload.php will offer you to upload a file and then utilize neodc.php to actually upload a file
The files under upload are my save states from the game 'Silver' as an example.

Now you can navigate to your Dreamcast server, load the upload.php and save some game states.

Part II - Downloading files

As I said before, downloading files is also not too easy. Fortunately, way easier than uploading files. If you try to download any VMI file from the Dreamcast server, Dream Key will only display an error meassge with: "This page can not be displayed.". To be able to download files, you have to manipulate the mime.types file for Nginx and add the following two lines:

# vi /etc/nginx/mime.types
...
    application/x-dreamcast-vms-info      vmi;
    application/x-dreamcast-vms           vms;
...


And don't forget to restart Nginx again:

# systemctl restart nginx

After that you will be able to download files via the download.php script from above. The (unofficial) VMU FAQ also describes a method by using the .htaccess file, but I haven't tested it.

Links:

The (unofficial) VMU FAQ: https://vmudev.dcemulation.org/faq.html
NeoDC: https://github.com/mrneo240/NeoDC-Icondata-Tool
dc_up_down.tar.gz: https://drive.google.com/open?id=13-bYNo7srDDny-jcxFUHxESc3SHJoi5Y

No comments:

Post a Comment