Transfer SmileBASIC 4 Programs from your Switch to your Smartphone over WiFi
Transferring a SmileBASIC program from your Switch to your smartphone is a relatively simple task.
This method also has the benefit of (1) it works offline, and (2) it will continue to work even after SmileBoom shuts down their servers.
It works offline because the transfer happens over WiFi, not over the internet. Even without internet, it will work.
First, you have to load the program data and break it up into individual bits.
var filedata$ = loadv("txt:myfile")
var i%, j%
for i% = 0 to len(filedata$) - 1
for j% = 7 to 0 step -1
push bindata%, (asc(filedata$[i%]) >> j%) and 1
In our outer loop, we are just looping through all characters in the file. The "asc" turns the character into its numerical ASCII equivalent. This is an 8-bit value, so we do another loop from 7 to 0 where the break that bit-value into its individual bits. The "and 1" simply removes all data from the byte except for the final, least-significant bit. If we use ">>" beforehand, a right-shift, then we can combine the two to select particular bits from the byte, and thus break the byte up into its individual bits.
Once we have done this, we want to draw an image to the screen. This image will simply contain all of our bits as either black or white pixels. In order to fit the maximum amount of data into the screen, we will want to use "xscreen" to resize the screen to 1280 by 720. This will allow us to fit 1 bit per pixel, and thus 1280x720 bits, and thus (1280x720)/8 bytes in the screen, or = 115,200 bytes of data. Once we've setup the screen and loaded our bit-data, we will need to plot it. Simply loop through all the bit-data and keep track of your X and Y coordinates. Every time you plot a pixel, increment the X coordinate. If the X coordinate goes off the right-side of the screen, then reset it to 0 and increment the Y coordinate.
xscreen 1280, 720
var x% = 0
var y% = 0
for i% = 0 to len(bindata%) - 1
if bindata%[i%] then
gcolor rgb(255, 255, 255)
gcolor rgb(0, 0, 0)
gpset x%, y%
if x% >= 1280 then
x% = 0
If the program ends, then it will say "OK" on the screen and show the flashing cursor which will conflict with the data we just created, so you will want to have the program pause after this. I just use these lines below to have it pause until you press enter/return on the keyboard.
We converted our program to an image, but how does that help get it to your smartphone? Very simple: take a screenshot. Press the screenshot button then the home button and go to your Album and click the screenshot you just took, press A again and there should be an option "Send to Smartphone". This allows you to transfer the image or a bunch of images over your Wifi from your Switch to your smartphone. Once you've sent your screenshot to the smartphone, go to this URL in your phone's browser:
There is a file upload button. Just click upload and select your image and it will convert it back into the program text!
Since you can transfer 115 kilobytes in a single image, you can probably transfer your entire program in one image. If your program is somehow larger than this, you may need to break it apart into multiple images.
To transfer back to the Switch, the easiest way I know of is to use PetitModem on the 3DS and then upload it with a public key, and then you can download it to the Switch using the public key. So the transfer uses the 3DS as a middle-man.