LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Transfer Files from the 3DS to PC Using the Internet!

Root / Talk About Programs / [.]

amihartCreated:
This is my second attempt at a data transferring program. I wrote a program so that you can transfer files from the 3DS to the PC over the internet without the need of a webcam or an auxiliary cable. It's also significantly faster than those methods. Basically, it works by encoding your SmileBASIC program into an image that it draws to the screen, and then you take a screenshot of it using Miiverse (Home button->Miiverse icon). You then download the screenshot onto your PC by accessing your Miiverse page and then load the screenshot into the PC version of the program and it will convert it back into the SmileBASIC program. Each screenshot holds up to 3 kilobytes of data. If your program is bigger than 3 kilobytes, it will give you more screenshots. So if it's 9 kilobytes big, the program will give you 3 individual images to take screenshots of. On the PC end of the program, as long as your screenshots are in the correct order, you can open multiple screenshots at once and it will combine it back into a single file. (You'll know if you got them out of order because they'll appear to be gibberish.) The actual program on the 3DS is less than 3 kilobytes, so if I were to try and send that file it would give me this: That's an example of what the images look like. If you plug that into the PC end of the program you will get the code for the SmileBASIC end. This is the output:
Spoiler
ACLS
'SOME VARIABLES
BLK=RGB(0,0,0)
W=RGB(255,255,255)
R=RGB(255,0,0)
G=RGB(0,255,0)
B=RGB(0,0,255)
TX=0
TY=0

'READ TXT FILE LIST
DIM FILELIST$[100]
FILES "TXT:",FILELIST$

'LIST FILES REMOVING ASTERISKS
COLOR 15
PRINT "Pick a file to transfer:"
FOR I=0 TO LEN(FILELIST$)-1
  IF MID$(FILELIST$[I],0,1)=="*" THEN 
    FILELIST$[I]=MID$(FILELIST$[I],1,LEN(FILELIST$[I])-1)
  ENDIF
  
  PRINT "   "+FILELIST$[I]
NEXT

'UP/DOWN TO MOVE ARROW AND SELECT FILE W/ (A)
SEL=0
WHILE BUTTON()!=16
  IF SEL>0 THEN 
    LOCATE 1,1+SEL-1
    PRINT " "
  ENDIF
  LOCATE 1,1+SEL
  PRINT ">"
  LOCATE 1,1+SEL+1
  PRINT " "
  
  IF BUTTON()==1 THEN SEL=SEL-1
  IF BUTTON()==2 THEN SEL=SEL+1
  IF SEL<0 THEN SEL=0
  IF SEL>LEN(FILELIST$)-1 THEN 
    SEL=LEN(FILELIST$)-1
  ENDIF
  WAIT 5
WEND

CLS
IN$=FILELIST$[SEL]

'LOAD TEXT FILE AND CONVERT IT TO INT ARRAY
LOAD "TXT:"+IN$, FALSE OUT TEXT$
DIM OUT_ARRAY[LEN(TEXT$)]
FOR I=0 TO LEN(TEXT$)-1
  OUT_ARRAY[I]=ASC(MID$(TEXT$,I,1))
NEXT

PREV=W

'DISPLAY COLOR SEQUENCE
FOR II=0 TO LEN(OUT_ARRAY)-1
  IN=OUT_ARRAY[II]
  GOSUB @TOBIN
  IN$=OUT$
  GOSUB @COLOROUT
NEXT

WAIT 15
WHILE BUTTON()!=16:WEND

'FINISH/END PROGRAM
GCLS
CLS
COLOR 15

END

'INT TO BINARY STRING
'IN: IN
'OUT: OUT$
@TOBIN
  OUT$=""
  FOR I=0 TO 7
    OUT$=STR$(IN MOD 2)+OUT$
    IN=(IN-(IN MOD 2))/2
  NEXT
  
RETURN

'DISPLAY COLOR SEQUENCE FOR BINARY STRING
'IN: IN$
'OUT: <VOID>
@COLOROUT
  
  FOR I=0 TO LEN(IN$)-1
    BIT=VAL(MID$(IN$,I,1))
    
    'COLOR CODE TRANSFER PROTOCOL (CCTP1)
    COL=0
    IF BIT==0 THEN
      IF PREV==R THEN COL=G
      IF PREV==G THEN COL=R
      IF PREV==B THEN COL=R
      IF PREV==W THEN COL=G
    ENDIF
    IF BIT==1 THEN
      IF PREV==R THEN COL=B
      IF PREV==G THEN COL=B
      IF PREV==B THEN COL=G
      IF PREV==W THEN COL=B
    ENDIF
    
    GCOLOR COL
    GPSET TX+1,TY
    GPSET TX,TY+1
    GPSET TX+1,TY+1
    GPSET TX,TY
    TX=TX+2
    IF TX>400-2 THEN 
      TX=0
      TY=TY+2
    ENDIF
    
    IF TY>240-2 THEN 
      WHILE BUTTON()!=16
        IF BUTTON()==32 THEN 
          ACLS
          END
        ENDIF
      WEND
      GCLS
      TX=0
      TY=0
    ENDIF
        
    PREV=COL
  NEXT
RETURN
Why does each screenshot hold 3 kilobytes of information? Why not more? Mainly because Miiverse uses lossy compression, so I had to come up with a way to encode the images that wouldn't get lost when the image gets compressed. I basically reused the code I used for the webcam one, where it uses an R, G, B color sequence, each change representing 1 bit, and I made the colors 2x2 boxes so they wouldn't bleed together together too much when compressed. So, if each 2x2 box is a bit, and the 3DS screen is 400x240 res, then that's enough room for 24,000 boxes, meaning 24,000 bits, meaning 3 kilobytes. Here's the actual SmileBASIC program page. Here's the link for the PC end. I hope this hasn't already been done before. The 3DS end is coded in, obviously, SmileBASIC, and the PC end is coded in JavaScript and is compatible with Windows, Mac, and Linux (tested on Debian 8.2 and Windows 10).

Glennxserge discovered that there is no compression loss if you use black and white pixels, so I have updated the program so now it can hold 12 kilobytes an image instead of only 3. You need to redownload the program and get the new version of the PC end which is v0.5 for it to work.

This is cool!