Close

Saved Game Editor (GFA Source)

The code block below is the full code from my most recent cheat for Legend Of The Sword which, whilst over 2 years old, has not been released as of yet.

The code below was written in GFA v3.6TT and uses a few .INL files (grab the .ZIP file underneath for the whole package) which cover a few small added extras:

  • SNDH Replay routine by Gwem
  • SNDH version of a piece of music
  • The new 8×8 replacement font

The source code is fairly self-explanatory in that it displays some intro text in a simple message box.

  • Sets up the location variables
  • Starts the music and changes the font
  • Displays some intro text in a simple message box
  • Shows a file-selector for you to point to the saved game (filename = GAME.LOS) you want to inspect/alter.
  • Checks that the file size is correct and if so, loads it into a buffer.
  • Reads in the single byte which stores the player’s current location in the game and then displays the appropriate location text on screen.
  • Allows you to change the location to any one of the others (including the ones which will cause you instant death – maybe for a screenshot or walkthrough, perhaps?)
  • Saves the new location to the memory buffer and then overwrites the existing saved game with the altered one.
  • Closes down the music, resets the font back to the normal GEM one and exits.
  • All done!

Full source code

'
' Legend Of The Sword Location Hack by MUG U.K(tm)
' ------------------------------------------------
'
' (c) MUG U.K¿ - 26th September 2016
'
' Based on my Caesar cheat routine from November 1992!
' It's been 24 years since my last saved game routine!
'
$m100000
'
start:
CLS
DEFMOUSE 0
DIM r%(16)
DIM locations$(16)
locations$(0)="Dead"
locations$(1)="On board the Lady Juville"
locations$(2)="On a sandy beach at the foot of a sheer rockface"
locations$(3)="In a small cave, 30' above the beach"
locations$(4)="A prisoner"
locations$(5)="At the end of a darkened passage which runs south"
locations$(6)="Dead"
locations$(7)="At the base of a jagged rockface which towers almost 50' above you"
locations$(8)="Along this point of the beach, the water line is much nearer to the rockface"
locations$(9)="The boat is sinking"
locations$(10)="At the top of a rockface which looks down nearly 50' to a sandy beach below"
locations$(11)="In the keep's courtyard"
locations$(12)="At the tower's entrance"
locations$(13)="At the foot of the path"
locations$(14)="At the bottom of a circular stone stairway"
locations$(15)="The two paths at this turning lead west and southeast"
locations$(16)="At the western edge of the Anar forest"
'
' Check resolution isn't monochrome
IF XBIOS(4)=2
  ALERT 0,"Monochrome not supported",1," Oh ..",d|
  EDIT
ENDIF
'
font_set
music
ALERT 0," Legend Of The Sword | Location Hack | | ½ MUG U.K¿ - Sept. 2017",1," OK ",d|
buffer%=MALLOC(2048)
'
IF buffer%=0
  ALERT 0,"Not enough memory ??",1," Oh .. ",d|
  kwit
ENDIF
'
redo_file:
CLS
FILESELECT CHR$(65+GEMDOS(25))+":\GAME.LOS","",in$
'
IF in$=""
  ALERT 0,"Cancel Selected ?",1," Retry | Quit ",d|
  IF d|=1
    GOTO redo_file
  ELSE
    kwit
  ENDIF
ENDIF
' Open the selected file
OPEN "U",#1,in$
' Check that the file is the correct length?
IF LOF(#1)<>2048
  ALERT 0,"Save file is wrong length! It should be 2048 bytes long.",1," Oh .. ",d|
  ~MFREE(buffer%)
  CLOSE #1
  GOTO start
ENDIF
BGET #1,buffer%,2048
CLOSE #1
'
' Print current values
'
CLS
PRINT "Legend Of The Sword Location Hack by MUG U.K¿"
PRINT "---------------------------------------------"
PRINT
IF PEEK(buffer%+&H35)<16 THEN
  PRINT "Your current location is: ";locations$(PEEK(buffer%+&H35))
ELSE
  PRINT "You current location is unrecognised!"
ENDIF
'
redo_hack:
'
' Now change the location for the saved game
'
PRINT
PRINT "Select the location where you want to move to in the game (or 0 to exit)."
PRINT
FOR f=1 TO 16
  PRINT f;" ";locations$(f)
NEXT f
'
redo_location:
INPUT "Move to: ";location|
'
IF location|=0
  GOTO no_more_changes
ELSE
  IF location|>16
    ALERT 0,"Enter a location value that's displayed above",1," Oh ..",d|
    GOTO redo_location
  ENDIF
  POKE buffer%+&H35,location|
ENDIF
'
no_more_changes:
PRINT
PRINT "Any key to save game."
~INP(2)
'
OPEN "U",#1,in$
BPUT #1,buffer%,2048
CLOSE #1
'
ALERT 0,"All Done !!",1," Bye Bye ",d|
kwit
'
' ************
' * Music On *
' ************
'
PROCEDURE music
  INLINE sndhreplay%,186
  INLINE sndhmusic%,18906
  super%=GEMDOS(&H20,L:0)
  ' Tune number
  '   r%(0)=1
  ' SNDH music file
  r%(14)=sndhmusic%
  ' SNDH Frequency
  r%(7)=50
  RCALL sndhreplay%+28,r%()
  ~GEMDOS(&H20,L:super%)
  SPOKE &H484,BCLR(PEEK(&H484),0)
RETURN
'
' ********************
' * Music Off & Quit *
' ********************
'
PROCEDURE kwit
  super%=GEMDOS(&H20,L:0)
  RCALL sndhreplay%+28+4,r%()
  ~GEMDOS(32,L:super%)
  LPOKE tos_addr%,old_tos%
  LPOKE gem_addr%,old_gem%
  SPOKE &H484,BSET(PEEK(&H484),0)
  EDIT
RETURN
'
' ***************
' * Crappy Wait *
' ***************
'
> PROCEDURE wait
  REPEAT
  UNTIL INKEY$<>""
RETURN
'
' **********************************************
' * Centre Text On Screen with various options *
' **********************************************
'
> PROCEDURE centre(mode|,lf|,text$)
  '
  IF XBIOS(4)=0
    tab|=20
  ELSE
    tab|=40
  ENDIF
  '
  IF mode|=0
    PRINT TAB(tab|-LEN(text$)/2);text$     ! 0 = Normal
  ENDIF
  '
  IF mode|=1
    PRINT TAB(tab|-LEN(text$)/2);text$     ! 1 = Underline
    PRINT TAB(tab|-LEN(text$)/2);STRING$(LEN(text$),"~")
  ENDIF
  '
  IF mode|=2
    PRINT TAB(tab|-LEN(text$)/2);"<ESC>p";text$;"<ESC>q"  ! 2 = Inverted
  ENDIF
  '
  IF lf|          ! Is a linefeed required - if so how many?
    FOR f|=1 TO lf|
      PRINT
    NEXT f|
  ENDIF
  CLR f|
RETURN
'
' ****************
' * Set New Font *
' ****************
'
PROCEDURE font_set
  INLINE new_font%,2066
  a$=MKI$(&HA000)+MKI$(&H4E75)            ! dc.w A000   rts
  a%=V:a$
  a0=C:a%() ! call machine code and return result in a0
  '
  tos_addr%=a0-&H16            ! TOS font pointer
  old_tos%=LPEEK(tos_addr%)  ! Original medium font
  '
  gem_addr%=&H4C+LPEEK(a0-&H1C4)  ! 8 * 8 font
  old_gem%=LPEEK(gem_addr%)      ! store old pointer
  '
  LPOKE tos_addr%,new_font%    ! New TOS font
  LPOKE gem_addr%,new_font%    ! New GEM font
RETURN
'
' Legend of the Sword (GAME.LOS, 2048 bytes)-
'
' OFFSETS into save file
' ----------------------
'
' $00:      $FF
' $01..$2E: "Hi hackers! Another boring 48byte file header!"
' $2F:      $00
' $35:      Your location:

Some of the text had to be changed so that it would display on a web page, e.g. the <ESC> in the text display routine for inverse characters. In the GFA code, these will display the original Atari ST characters.

Download

You can download the whole source code, plus the .INL files from the link below.

Legend Of The Sword Saved Game Editor (GFA source code)