Tip of the Year: Save your work after MSX crash! (Development MSX Fora)MSX Resource Center            
            
English Nederlands Espa�ol Portugu�s Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 77 gasten en 2 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - Tip of the Year: Save your work after MSX crash!

Ga naar pagina ( 1 | 2 Volgende pagina )
Schrijver

Tip of the Year: Save your work after MSX crash!

NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 14 April 2005, 16:51   

Ok, I think, that most of you, who have been playing with BASIC (and expetially X-BASIC) have already had this situation:

Program hanged, your MSX does not respond to keyboard and everything to do is to push that reset button... You can usually prevent this by enabling soft reset (POKE &HFBB0,1) but always even that does not work.

At this point people usually remember program named OLD, that is made to save your ass in this kind of situations. Only problem is, that you usually really can't find it when you most need it!!!

I anyway managed to find general solution to this problem that is even easy to remember!

- If there is disk in drive, remove it
- Press that reset button
- Wait BASIC to start
- Put formatted disk into drive.
- Type:

POKE &H8002,128
SAVE"TEMP"
LOAD"TEMP"
SAVE"TEMP",A
LOAD"TEMP"
SAVE"DEARPROG.BAS"
KILL"TEMP"

- Send greetings to NYYRIKKI as he has just saved your work.



Sonic_aka_T

msx guru
Berichten: 2269
Geplaatst: 14 April 2005, 19:37   
you forgot KILL "DEARPROG.BAS" as the last line
manuel
msx guru
Berichten: 3531
Geplaatst: 16 April 2005, 17:01   
NYYRIKKI, I just needed this trick and therefore I can conclude: it works!!

Can you explain it?
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 17 April 2005, 04:53   
Quote:

Can you explain it?



Sure...

To clear things out, let's take an example program:

10 REM Example program
20 PRINT"Hello world!"

In memory this program is tokenized this way:

#8000 =#00 This byte is always zero. If it is not, program can not run.
#8001-8002 =#8017 This is pointer to start of next line (20)
#8003-8004 =#000A = 10 this is line number
#8005 = #8F This is a token that represents REM command
#8006-8015 = " Example program"
#8016 =#00 This indicates end of line.
#8017-8018 =#802B This is pointer to start of next line
#8019-801A =#0014 = 20 this is line number
#801B = #91 This is a token that represents PRINT command
#801C-8029 = "Hello world!"
#802A =#00 This indicates end of line.
#802B-#802C =#0000 This is pointer to start of next line. Now it is 0 because there is no next line.

When your MSX is rebooted or NEW command is executed, pointer to start of next line in #8001 will be reseted to 0. If we want to restore the program, our problem is, that now we don't know what the next address for start of next line is!

When I was thinking about the tokenized program I was wondering, that how this can work when BASIC is not in default #8000 address? When loading of the data is done, these addresses must be calculated again and I was right. (This has been propably implemented to get BASIC files exchangeable with 16KB RAM machines as well.)

So here is actually what happens, when you execute those commands.

When you save empty program #FF will be put in start of the file to indicate start of tokenized program and BASIC program (this case #8001-8002) will be saved after it. Now we how ever change this address in #8001 to #8000. This number can be actually anything else but 0, but I used #8000 as in #8000 there is word #0000 so, if you use list command, you will not get crap to your screen or in worst case hang your MSX.

Now when this is saved, we will get file with following bytes: #FF,#00,#80
Now when this file is loaded, BASIC does not understand, that the file is so short and address in #8001 will be calculated again using data already in memory as information.

Now when you execute list, you can see the whole program. There is anyway still few problems... BASIC still thinks, that our program is 2 bytes long, so if you execute it, start of the program will be overwritten by variables of the program. Also if you try to save the program as tokenized BASIC program, only 3 bytes will be saved (This time they are anyway correct ). Solution is to save the program as ASCII file as then it is converted to text same way as when you use LIST command.

Rest of the steps are used to convert the ASCII file back to tokenized format in order to save disk space and loading time.

NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 18 April 2005, 19:38   

Ok, here comes a version for people, who don't have a disk drive. This is not as easy to remember, but it is still faster to type, than load OLD program from tape...

Note: Type this in in direct command mode, else you are going to overwrite the program, you are trying to save!!! Please do not add spaces, but this listing is not case sensitive.

POKE&H8002,128:DEFUSR=&HF434:IFUSR(0)THENMAXSB#""""PSETANDBASE


NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 19 April 2005, 00:58   
Ok, I was a bit too quick with the cassette version... It seems, that it has still some problems with GOTO, GOSUB and variable arrays... I think I still need to learn some more BASIC when I have more time

NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 19 April 2005, 11:26   
Hmm... I think, CLEAR will init rest of the variable stuff... You can try this one, but I still recommend you to save your work right after running this:
POKE&H8002,128:DEFUSR=&HF434:IFUSR(0)THENMAXSB#""""PSETANDBASEELSECLEAR



marison
msx lover
Berichten: 98
Geplaatst: 19 April 2005, 13:37   
NYYRIKKI,

This tip works in Windows? It's much more necessarily in that enviroment...

I have needed this some times. In a brazillian book or magazine I've saw this tip 15 years ago, I guess.
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 19 April 2005, 14:50   
Quote:

This tip works in Windows?.



Quote:

In a brazillian book or magazine I've saw this tip 15 years ago, I guess.



Which one?

AuroraMSX

msx master
Berichten: 1260
Geplaatst: 19 April 2005, 15:14   
Quote:

Now when you execute list, you can see the whole program. There is anyway still few problems... BASIC still thinks, that our program is 2 bytes long, so if you execute it, start of the program will be overwritten by variables of the program.


The system variable (VARTAB? I don't have the docs at hand ) that tells BASIC where the start of the variable area is, will point to #8003 directly following the BASIC code. And therefor, the program gets overwritten.
Quote:

Also if you try to save the program as tokenized BASIC program, only 3 bytes will be saved (This time they are anyway correct ).


That surprises me, actually. That means that the SAVE routine just writes out the block of memoty between TXTTAB (start of BASIC program) and (VARTAB). I woudl have thought that the save routine writes BASIC lines until it reaches the end of the program (3x #00)...
Quote:

Solution is to save the program as ASCII file as then it is converted to text same way as when you use LIST command.


... whereas the SAVE,A routine seems to LIST the program to file.
Interesting...

Quote:

POKE&H8002,128:DEFUSR=&HF434:IFUSR(0)THENMAXSB#""""PSETANDBASE




That MAXSB#""""PSETANDBASE: is that plain old obfuscation or functional code, somehow?
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 19 April 2005, 17:04   
Quote:

That MAXSB#""""PSETANDBASE: is that plain old obfuscation or functional code, somehow?



It's ML. Purpose is to calculate lenght of first line and update VARTAB to end of program.

wolf_

msx legend
Berichten: 4777
Geplaatst: 19 April 2005, 17:11   
I remember some apps that stopped because of an error .. when doing 'list', I got a huge shitload of basic mess .. is that the same principle?
marison
msx lover
Berichten: 98
Geplaatst: 19 April 2005, 21:39   
About the brazillian book or magazine with this tip, I don't ever could say if it's a book or a magazine!

But I remember the pokes in the first bytes in the page 2, and the objective of them. I can'nt say if the form is identical to that you have presented to us, however.
NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 19 April 2005, 22:23   
Quote:

I remember some apps that stopped because of an error .. when doing 'list', I got a huge shitload of basic mess .. is that the same principle?



This is typical situation, when you try to load some memory mapped program (game) and you don't have enough memory. This is caused by the fact that BASIC area is overwritten by machine language (ML) program, graphic, music or some other data.

Because BASIC is tokenized in memory, ML data converted back to BASIC listing causes "a huge shitload of basic mess". Here the situation is turned around... This basic mess will cause predefined bytes to be written in to memory and those bytes are used to make a working program that we call from the "BASIC part of the program".


NYYRIKKI
msx master
Berichten: 1525
Geplaatst: 19 April 2005, 22:27   
Quote:

But I remember the pokes in the first bytes in the page 2, and the objective of them. I can'nt say if the form is identical to that you have presented to us, however.

Yeah, I know that I'm not first person that has been working on this problem and all these solutions are based to same prinsiple I think, but I just try to find shortest/easyest possible solution for it.

 
Ga naar pagina ( 1 | 2 Volgende pagina )
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.