News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_SagaDS

How to check if program was launched from disk or tape?

Started by SagaDS, 13:12, 22 April 23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SagaDS

Hello,

I am planning to put in place some kind of HiScore saving capability in my MineSweeper clone. But I don't think it will be cool on a tape version of it.

So I was wondering how to differentiate if it was launched from disk or not. I didn't find any obvious answer for this question...
 

andycadley

The obvious solution is to have a slightly different version of the program for the disk version.

HAL6128

The way of software is stored on tape and disc is different (analysing of the file header after cas_in_open). Maybe add a some kind of flag after loading?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

SagaDS

Quote from: andycadley on 13:20, 22 April 23The obvious solution is to have a slightly different version of the program for the disk version.
Yes, but not as easy at it sounds...
There will be 2 builds with an env variable (or a specific C define) in CPCTelera and 2 separated DSK / CDT builds...
Need to dig on the build workflow process which I am not really good at.

So if anything can be done with code, it would be better... For example, there are ways to know if a disk was launched from A or B drive... 
Maybe some Disk init that could fail is enough to tell? Or a AMSDOS ROM check is enough?

HAL6128

...the first entry of a filename on a disc in its header is always its user number (0-15 or &E5). filename on cassette can have 16 characters (not 8.3) without user number. normally they start with an ascii character above 32. maybe a loader before could identify it?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Jean-Marie

You can simply check offset A701h, in the System variables. It is the current User number. On 464 with no disc drive,  it will always be 0.
The trick is to store your game files on disc in User 1. Thus, if [A701] is not 1, you can deduct it is run from tape.
Then, you can have your Loader.bas in User 0, like :
10 |user,1
20 run"game.bin"


McArti0

&BC77  *CAS IN OPEN

has sequence DF 8B A8 when |DISC

or

has sequence CF E5 A4 when |TAPE      (copy from &A864 ...)

     &A864 | &A864 | 14*3 | Tape Jumpblock is stored here by AMSDOS
           |       |      |   - is moved to &BC77 etc after |TAPE
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Jean-Marie

Or simply peek RAM @OffseT A70A : it should contain the filename of your program if loaded from Disc.
More info on system variables here.

McArti0

In Basic ...

100 ON ERROR GOTO 200
110 |DISC.OUT
120 PRINT "DISK - YOU can save"
130 END

200 PRINT "NOT DISK - You can not save"
210 RESUME 130
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

dragon

I have another idea, what is the diferencie between tape and disk?.

Time,load a Game from tape takes minutes ,loading from a disk takes seconds.

Just begin count time in the loader.at begining of load and count time when programs is loaded and begin execution. Made a rest and you know if has been loaded from tape or disk. Store the result and use It in save.



Axelay

Unless you are desperate to have a single shared loader for tape and disk, I'd suggest using the loader programs themselves as the way to identify the format.  Set up a 'disc access' variable that is visible to your main code and the loader.  Have the disc loader set it to 1 and the tape loader set it to 0.  Then whenever your main code wants to do a high score table save or load, it starts by checking the 'disc access' variable and aborts if it is 0.

McArti0

You need to connect the webcam interface with ChatGPT 4 plus which recognizes if a tape was used.
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

SagaDS

Thanks for all the answers. Some of them make my day :laugh:

I will try some of them starting with the (BC77) == DF or CF identification that might work easily for 464/6128...

Other variations might be good (BASIC loader before program), but I plan to have only one binary that is run directly.
Anyway, they are really good answers for a forum thread on the subject.

SagaDS

Hello,

here is an update on my tests.

Unfortunately, the test  (BC77) == DF or CF does not seem to work. It is true before launching the program, but it is reset after the launch of the file on disk. So I imagine that either AMSDOS rewrite it after its init or emulators use a specific hack on this address (tested on WinApe/RVM). I didn't test yet on real hardware, but as I want my game to be played on emulators, I stopped there.

So I have checked with the A70A check (from Jean-Marie). On my tests, disk reads set the filename after loading, but |tape doesn't... So it seems the good way to do it for me... Just need to make sure it runs on every machine.

Thanks to all.

Powered by SMFPacks Menu Editor Mod