Save Routine Modification

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
English Invader
Posts: 64
Joined: Tue Aug 18, 2020 9:10 pm
Contact:

Save Routine Modification

Post by English Invader » Sun Sep 13, 2020 3:33 pm

Following on from my thread in the software section about saving and loading game progress in Football Manager on an MMC, I thought it best to post here as my software enquiry changed into a programming one:
viewtopic.php?f=2&t=20481

My knowledge of Basic is the equivalent of someone who knows a few pieces of conversational French. The aim is to amend the code so it will save game data to a virtual disk image in drive 1 on my MMC. This is the code someone found for me on the BBC archive site:

Code: Select all

13710DEFPROCSG:CLS:PROCB("SAVING GAME",3,8,0,2):PROCB("ENTER NAME OF FILE",1,1,4,0):PROCi("",5,22,4,10):IFV%=2ENDPROCELSEF$=E$
 13740PROCB("READY DISC THEN PRESS RETURN",4,2,8,0):*FX15,0
 13760REPEATUNTILGET=13:PRINTTAB(9);:K=OPENOUTF$:PRINT#K,M,L,e,i,k,h,D,A(2),U,t,c,S,g,F,C,H,V,a,G,W,X,y,w,T,Y,G%,z,u,F%,Z%:FORI=1TO48:PRINT#K,T(I),T$(I),T%(I),B%(I),C%(I),Z(I):NEXT:FORI=1TO24:PRINT#K,P$(I),P(I),R%(I),Y%(I),V%(I):NEXT:FORI=1TO12:FORb=0TO1:PRINT#K,W%(I,b):NEXT,:CLOSE#K:ENDPROC
 
My understanding of the code is that the PROC command is the equivalent of GOSUB on the Beeb and that it executes pre-defined sub routines that pertain to game saves (is that correct?). What would I need to change in this code to ensure that the game looks for a disk image in drive 1 instead of drive 0? This is essential because the MMC has no means to change disk files on the fly so the save disk needs to be in another drive.

Thank you for the time you've taken to read this and for any help you are able to provide.

User avatar
dv8
Posts: 333
Joined: Mon Jun 22, 2009 10:07 pm
Contact:

Re: Save Routine Modification

Post by dv8 » Sun Sep 13, 2020 4:14 pm

English Invader wrote:
Sun Sep 13, 2020 3:33 pm
What would I need to change in this code to ensure that the game looks for a disk image in drive 1 instead of drive 0?
Basically, a drive specifier needs to be added to the start of the filename.
i.e. change the end of line 13710 to read F$=":1."+E$

Code: Select all

13710DEFPROCSG:CLS:PROCB("SAVING GAME",3,8,0,2):PROCB("ENTER NAME OF FILE",1,1,4,0):PROCi("",5,22,4,10):IFV%=2ENDPROCELSEF$=":1."+E$
And the equivalent line in the load routine...

Code: Select all

13080DEFPROC5:PROCB("ENTER NAME OF FILE",5,8,20,0):PROCi("",0,12,23,10):IFV%=2ENDPROCELSEF$=":1."+E$

User avatar
helpful
Posts: 634
Joined: Tue Sep 22, 2009 1:18 pm
Location: London
Contact:

Re: Save Routine Modification

Post by helpful » Sun Sep 13, 2020 5:26 pm

Although if the program is asking you to enter the filename, then can you simply enter ":1.file" when prompted and not need to edit the program at all?
RISC OS User Group Of London - http://www.rougol.jellybaby.net/
RISC OS London Show - http://www.riscoslondonshow.co.uk/

julie_m
Posts: 235
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: Save Routine Modification

Post by julie_m » Mon Sep 14, 2020 12:31 am

That and all .....

This is why, when you ask a user to supply a filename, you should never, ever presume to know what is or is not a valid filename.

English Invader
Posts: 64
Joined: Tue Aug 18, 2020 9:10 pm
Contact:

Re: Save Routine Modification

Post by English Invader » Wed Sep 16, 2020 3:10 pm

Thank you for your responses. I tried saving the file as helpful suggested and it's done something as when I do a CAT on the boot-up screen it lists the file on the disk. The problem is getting the game to load it up. When the program loader asks me if I want to load a previous game, I put in my filename and it just takes me back to the same prompt a few seconds later.

It looks like I need to access the source code and make the changes that dv8 outlined. What do I have to do to get the Micro to list the source code?

English Invader
Posts: 64
Joined: Tue Aug 18, 2020 9:10 pm
Contact:

Re: Save Routine Modification

Post by English Invader » Thu Sep 17, 2020 7:59 pm

The penny finally dropped that I was able to copy and paste the source code from the BBC archive site into BeebEm and I've made the instructed changes. How do I turn this from two save state files in an emulator into a bootable SSD that I can run on my MMC?

User avatar
jgharston
Posts: 4121
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Save Routine Modification

Post by jgharston » Thu Sep 17, 2020 8:13 pm

English Invader wrote:
Thu Sep 17, 2020 7:59 pm
The penny finally dropped that I was able to copy and paste the source code from the BBC archive site into BeebEm and I've made the instructed changes. How do I turn this from two save state files in an emulator into a bootable SSD that I can run on my MMC?
I was about to post:
MkImg destfile file1
MkImg destfile -add file2

but on checking the code, am reminded I've still not got around to adding the -add switch. #-o
I was sure I had, as the main code is the same as BINto(spectrum files). So...
create a text file containing:
file1
file2
then:
MkImg destfile -i@textfile
;)

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

Post Reply

Return to “programming”