Scott Adams - Save to Disk?
Moderator: Moderators
-
- Vic 20 Afficionado
- Posts: 355
- Joined: Thu Oct 13, 2016 11:35 am
- Location: Toronto
- Occupation: Programmer
Scott Adams - Save to Disk?
I believe the Scott Adams adventures can only save to / restore from tape? I don't have a datasette these days and I was wondering if anyone had ever patched the ROM images to support save / restore to / from disc? (I am guessing this may not be trivially easy to change as disc needs filenames and I expect the existing code saves to tape with zero-length filename.)
- orion70
- VICtalian
- Posts: 4343
- Joined: Thu Feb 02, 2006 4:45 am
- Location: Piacenza, Italy
- Occupation: Biologist
Re: Scott Adams - Save to Disk?
No save to disk patch I know of. But someone here is skilled enough to do this mod
- mrr19121970
- Vic 20 Nerd
- Posts: 873
- Joined: Tue Jan 19, 2016 9:22 am
- Location: Germany
- Occupation: IT service manager
Re: Scott Adams - Save to Disk?
I am thinking the IRQ can trap tape commands and reroute them?
http://sleepingelephant.com/ipw-web/bul ... ott#p88051
http://sleepingelephant.com/ipw-web/bul ... ott#p88051
- eslapion
- ultimate expander
- Posts: 5458
- Joined: Fri Jun 23, 2006 7:50 pm
- Location: Canada
- Occupation: 8bit addict
Re: Scott Adams - Save to Disk?
I was about to jump on this one and tell you it must be possible to simply change the device number.Bobbi wrote:I believe the Scott Adams adventures can only save to / restore from tape? I don't have a datasette these days and I was wondering if anyone had ever patched the ROM images to support save / restore to / from disc? (I am guessing this may not be trivially easy to change as disc needs filenames and I expect the existing code saves to tape with zero-length filename.)
However, if the file name is blank then definitely there will be more to it than that!
Be normal.
-
- Vic 20 Afficionado
- Posts: 355
- Joined: Thu Oct 13, 2016 11:35 am
- Location: Toronto
- Occupation: Programmer
Re: Scott Adams - Save to Disk?
I wonder where in memory the current state is. I know it is tiny (location, inventory, score) and saves to tape in a couple of seconds! Perhaps we could write an interrupt service routine to just dump and/or restore those ~512bytes to disk
- eslapion
- ultimate expander
- Posts: 5458
- Joined: Fri Jun 23, 2006 7:50 pm
- Location: Canada
- Occupation: 8bit addict
Re: Scott Adams - Save to Disk?
Here's my suggestion:Bobbi wrote:I wonder where in memory the current state is. I know it is tiny (location, inventory, score) and saves to tape in a couple of seconds! Perhaps we could write an interrupt service routine to just dump and/or restore those ~512bytes to disk
Start a game, save it to tape then use WAV2PRG to get the details of the saved data to examine on a PC.
Then you can start the game again in WinVICE, do exactly the same moves and use WinVICE's built-in monitor to inspect the emulated VIC's RAM.
Since Scott Adams games are designed for an unexpanded VIC and occupy BLK2-3, the information you look for should either be in the 1st 1k ($0000-$03FF) or in the normal 4k RAM ($1000-$1FFF). The last ~512 bytes are used by the screen codes.
Be normal.
-
- Vic 20 Afficionado
- Posts: 355
- Joined: Thu Oct 13, 2016 11:35 am
- Location: Toronto
- Occupation: Programmer
Re: Scott Adams - Save to Disk?
A project for a rainy day. (I have too many projects right now!)
- Mike
- Herr VC
- Posts: 4871
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Scott Adams - Save to Disk?
Here are the two relevant parts for Voodoo Castle. I'd simply replace those in full with patches located in $2000..$3FFF (assuming a soft-loaded cartridge and full RAM expansion):
...
For the other adventures, the commands "H 4000 7FFF 20 D5 FF" and "H 4000 7FFF 20 D8 FF" should point to the routines that do the save/load there.
I leave doing the actual patches as exercise for the reader.
Code: Select all
.7588 A2 01 LDX #$01
.758A 20 BA FF JSR $FFBA
.758D A9 00 LDA #$00
.758F 85 4E STA $4E
.7591 A9 10 LDA #$10
.7593 85 4F STA $4F
.7595 A9 4E LDA #$4E
.7597 A2 3E LDX #$3E
.7599 A0 12 LDY #$12
.759B 20 D8 FF JSR $FFD8
[...]
.7BA3 A2 01 LDX #$01
.7BA5 A0 00 LDY #$00
.7BA7 20 BA FF JSR $FFBA
.7BAA A9 00 LDA #$00
.7BAC 8D 3C 12 STA $123C
.7BAF 20 D5 FF JSR $FFD5
Erm, no? How should it be able to do that? Just for you to know: the KERNAL tape routines temporarily replace the current IRQ vector with an own one. Simply put: that colour selection wedge you refer to is put out of service during tape operations. A rather uncomfortable situation for a routine you want to take over the load/save process.mrr19121970 wrote:I am thinking the IRQ can trap tape commands and reroute them?
...
For the other adventures, the commands "H 4000 7FFF 20 D5 FF" and "H 4000 7FFF 20 D8 FF" should point to the routines that do the save/load there.
I leave doing the actual patches as exercise for the reader.
-
- Vic 20 Afficionado
- Posts: 355
- Joined: Thu Oct 13, 2016 11:35 am
- Location: Toronto
- Occupation: Programmer
Re: Scott Adams - Save to Disk?
I didn't know the KERNAL tape routines fiddled with the vector. Good to know!
- eslapion
- ultimate expander
- Posts: 5458
- Joined: Fri Jun 23, 2006 7:50 pm
- Location: Canada
- Occupation: 8bit addict
Re: Scott Adams - Save to Disk?
JSR $FFBA sets the device number. Since the LDX #$01 precedes it then that's the tape device number.
JSR $FFD8 is a jump to the save, JSR $FFD5 is a jump to the load.
There is no JSR $FFBD to set the file name but if you want to save to a disk drive, you'll have to make sure you either save under an unused filename or use the overwrite option.
The saved region is from $1000 to $123E, starts at 4096, ends at 4670. Saved data is 574 bytes in length.
JSR $FFD8 is a jump to the save, JSR $FFD5 is a jump to the load.
There is no JSR $FFBD to set the file name but if you want to save to a disk drive, you'll have to make sure you either save under an unused filename or use the overwrite option.
The saved region is from $1000 to $123E, starts at 4096, ends at 4670. Saved data is 574 bytes in length.
Be normal.
- eslapion
- ultimate expander
- Posts: 5458
- Joined: Fri Jun 23, 2006 7:50 pm
- Location: Canada
- Occupation: 8bit addict
Re: Scott Adams - Save to Disk?
AFAIK, there will be a problem with that.Mike wrote:Here are the two relevant parts for Voodoo Castle. I'd simply replace those in full with patches located in $2000..$3FFF (assuming a soft-loaded cartridge and full RAM expansion):
The area which contains the game status saved is $1000-$123e and most of this areas becomes used by the screen codes if you install 8k+ RAM expansion which starts at BLK1 ($2000-$3FFF).
If you have full RAM expansion and do the patching as you suggest, you have to make sure BASIC doesn't detect it.
An alternative is to have RAM in BLK5 ($A000-$BFFF) or in the 3k RAM expansion area ($0400-$0FFF).
Be normal.
- Mike
- Herr VC
- Posts: 4871
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Scott Adams - Save to Disk?
Well spotted. However, the patch can simply relocate the screen to the position where it is with unexpanded (or +3K) RAM.eslapion wrote:AFAIK, there will be a problem with that.
The area which contains the game status saved is $1000-$123e and most of this areas becomes used by the screen codes if you install 8k+ RAM expansion which starts at BLK1 ($2000-$3FFF).
If you have full RAM expansion and do the patching as you suggest, you have to make sure BASIC doesn't detect it.
Three instructions in machine code: LDA #$1E:STA $0288:JSR $E518 (or POKE648,30:SYS58648 in BASIC) are all that is needed *) - ...
... instead of resorting to rather uncommon RAM configurations (BLK2+BLK3+BLK5 or RAMx+BLK2+BLK3, both *excluding* BLK1).An alternative is to have RAM in BLK5 ($A000-$BFFF) or in the 3k RAM expansion area ($0400-$0FFF).
The aforementioned wedge for the screen colour change resides in the internal RAM, implying the Scott Adams adventures don't use all of it. Possibly the load/save patch could be put there too, and then the screen relocation "issue" also doesn't crop up.
*) in a related matter, temporarily "unexpanding" the VIC-20 from any kind of RAM expansion until the next power cycle or hard reset also needs the BASIC start and end to be adjusted correspondingly. That is done with POKE642,16:POKE644,30:POKE648,30:SYS64818. POKE642,16 sets the start of BASIC, POKE644,30 the end of BASIC, POKE648,30 the screen base address and SYS64818 performs a soft reset (which excludes the RAM check but includes SYS58648). However, for these cartridge games, that adjustment of the BASIC pointers is not necessary.
P.S.
You know the "@" drive command for save-with-replace is bugged on CBM disk drives and can lead to loss of data? Not because of the issue when not enough room is there for the new file, but because the remove procedure for the old file sometimes frees the wrong blocks.eslapion wrote:if you want to save to a disk drive, you'll have to make sure you either save under an unused filename or use the overwrite option.
If you do it on your own disks, with your own drives, that's your own problem.
It will annoy a lot of people if it's put in a released program. Really no good idea to even suggest its use.
The Right Thing to do is: either first scratch the old savegame (with the "S" DOS command) and then save; or - for the more paranoid - with a savegame and a backup of it: (step 1) first scratch a possible remnant of the backup, then (step 2) rename SAVEGAME.DAT to SAVEGAME.BAK, and finally (step 3) save a new SAVEGAME.DAT.
Last edited by Mike on Fri Nov 11, 2016 2:57 am, edited 1 time in total.
- eslapion
- ultimate expander
- Posts: 5458
- Joined: Fri Jun 23, 2006 7:50 pm
- Location: Canada
- Occupation: 8bit addict
Re: Scott Adams - Save to Disk?
I have a preference for "automated" solutions. Instead of leaving the VIC with RAM in BLK1 and then using tricks to relocate the screen, leave it with only BLK2-3 used by the SA game and then we know the RAM from $1300 to $1DFF is most likely completely unused.Mike wrote:Well spotted. However, the patch can simply relocate the screen to the position where it is with unexpanded (or +3K) RAM.
... instead of resorting to rather uncommon RAM configurations (BLK2+BLK3+BLK5 or RAMx+BLK2+BLK3, both *excluding* BLK1).
The aforementioned wedge for the screen colour change resides in the internal RAM, implying the Scott Adams adventures don't use all of it. Possibly the load/save patch could be put there too, and then the screen relocation "issue" also doesn't crop up.
Just in case we can always resort to do exactly what you did a few months ago with another massive save routine and use $02A1 - $02FF which is always available no matter what RAM configuration you use.
Be normal.
- Mike
- Herr VC
- Posts: 4871
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Scott Adams - Save to Disk?
If anything, you're proposing a hardware solution.eslapion wrote:I have a preference for "automated" solutions.
"TRICKS?"Instead of leaving the VIC with RAM in BLK1 and then using tricks
What, please, is "tricky" about a *known* *working* software solution you just didn't have on the radar?
Go ahead, write the patch. In whatever way you deem working. You know there'll be at least two users.Just in case we can always resort to do exactly what you did a few months ago with another massive save routine and use $02A1 - $02FF which is always available no matter what RAM configuration you use.