Skip to content

Instantly share code, notes, and snippets.

@koron
Last active April 4, 2026 01:56
Show Gist options
  • Select an option

  • Save koron/e040383663dd860e91e061e4b50c43e1 to your computer and use it in GitHub Desktop.

Select an option

Save koron/e040383663dd860e91e061e4b50c43e1 to your computer and use it in GitHub Desktop.
This is an old code that was printed a long time ago, scanned, and then OCR'd and modified. The Japanese text in the code has been translated into English.
100 ' Super Family Computer
110 ' SRAM Back up program ver 2.00
120 ' (on MSA selected SRAM by SW)
130 ' `93/5/2(SAT)
140 ' programed by KoRoN
150 '
160 CLEAR200,&HB000:DEFINTA-Z:DIMS(13)
170 SCRENO,,1:COLOR14,0,0:KEYOFF
180 AD=&HD000:DEFUSR=AD:DEFUSR1=AD+2
190 FORI=0TO2:READA$,B$:A=LEN(A$):B=0
200 FORJ=1TOASTEP2:C=VAL("&H"+MID$(A$,J,2)):B=B+C:POKEAD,C:AD=AD+1:NEXT
210 IFHEX$(B)<>B$THENBEEP:PRINT"Data error in";220+I*10:ENDELSENEXT
220 DATA 18021821F3F5E5D5C52100601100B0010020D5C53E01CD0C0023C1D112130B78,B2C
230 DATA B120EF1820F3F5E5D5C52100601100B0010020D5C51A5F3E01CD140023C1D113,CBD
240 DATA 0B78B120EEC1D1E1F1FBC9,76A
250 FORI=0TO13:READS(I):NEXT:DATA120,0,240,1,224,0,184,16,16,16,0,16,14
260 GOSUB400:ONERORGOTO350:PRINT" Alert message: Put the game in PAUSE mode, then insert the SFC cartridge into the adapter. Then insert the data disk. When ready hit SPACE key."
270 FORI=0TO13:SOUNDI,S(I):NEXT:FORI=0TO1:COLORRND(1)*14+2:I=-STRIG(0):NEXT
280 BEEP:COLOR14:GOSUB400:FILES"*.DAT":PRINT:PRINT" Mode Select"
290 PRINT" 1 LOAD SRAM, WRITE IT TO DISK":PRINT" 2 LOAD DISK, WRITE IT TO SRAM":PRINT " 3 SWAP THE CARTRIDGE"
300 INPUT "What mode you need";M:IFM<1OR3<MTHEN280ELSEONMGOTO320,330,260
310 GOTO280
320 GOSUB380:IF=0THEN280ELSEA=USR(0):BSAVEF$,&HB000,&HCFFF:GOTO280
330 GOSUB380:IF=0THEN280ELSEBLOADF$:A=USR1(0):GOTO280
340 END
350 IFERR=53THENPRINT:PRINT"There is no files.":BEEP:RESUMENEXT
360 IFERR=70THENRESUME260
370 PRINT:PRINT:PRINT"ERROR no.";ERR;"in";ERL:BEEP:END
380 INPUT"File name (8 words)";F$:F=LEN(F$):IFO<FANDF<9THENF$=F$+".DAT"ELSEF=0
390 RETURN
400 CLS:PRINT"=== Super Family Computer =================== SRAM Back up program (onMSA) =====":RETURN
; Disassembled machine code embedded in the BASIC code.
0x0000: 0x18 jr 0x0004
0x0002: 0x18 jr 0x0025
; Copy 8KB bytes from address 0x6000 in the slot 1 to address 0xB000 in RAM.
0x0004: 0xf3 di
0x0005: 0xf5 push af ; Save registers.
0x0006: 0xe5 push hl
0x0007: 0xd5 push de
0x0008: 0xc5 push bc
0x0009: 0x21 ld hl,0x6000
0x000c: 0x11 ld de,0xb000
0x000f: 0x01 ld bc,0x2000
0x0012: 0xd5 push de
0x0013: 0xc5 push bc
0x0014: 0x3e ld a,0x01
0x0016: 0xcd call 0x000c ; Read a byte from the slot.
0x0019: 0x23 inc hl
0x001a: 0xc1 pop bc
0x001b: 0xd1 pop de
0x001c: 0x12 ld (de),a
0x001d: 0x13 inc de
0x001e: 0x0b dec bc
0x001f: 0x78 ld a,b
0x0020: 0xb1 or c
0x0021: 0x20 jr nz 0x0012
0x0023: 0x18 jr 0x0045 ; End of the subroutine.
; Copy 8KB bytes from address 0xB000 in RAM to address 0x6000 in the slot 1.
0x0025: 0xf3 di
0x0026: 0xf5 push af ; Save the register
0x0027: 0xe5 push hl
0x0028: 0xd5 push de
0x0029: 0xc5 push bc
0x002a: 0x21 ld hl,0x6000
0x002d: 0x11 ld de,0xb000
0x0030: 0x01 ld bc,0x2000
0x0033: 0xd5 push de
0x0034: 0xc5 push bc
0x0035: 0x1a ld a,(de)
0x0036: 0x5f ld e,a
0x0037: 0x3e ld a,0x01
0x0039: 0xcd call 0x0014 ; Write a byte to the slot.
0x003c: 0x23 inc hl
0x003d: 0xc1 pop bc
0x003e: 0xd1 pop de
0x003f: 0x13 inc de
0x0040: 0x0b dec bc
0x0041: 0x78 ld a,b
0x0042: 0xb1 or c
0x0043: 0x20 jr nz 0x33
; Recovery registers to end the subroutine.
0x0045: 0xc1 pop bc
0x0046: 0xd1 pop de
0x0047: 0xe1 pop hl
0x0048: 0xf1 pop af
0x0049: 0xfb ei
0x004a: 0xc9 ret
@koron
Copy link
Copy Markdown
Author

koron commented Apr 4, 2026

The original scanned image:
SFCSRAMBackup-19930502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment