Ultimate Amiga

Network Boards => AMOS Language Discussion => AMOS Factory => AMOS Professional Forum => Topic started by: xboxisfinished on August 07, 2021, 02:20:38 AM

Title: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 02:20:38 AM
 I am using print#1, _getstr$ but it keeps putting invisible enter key (code 13) at the end of each line. How do I prevent this from happening?

It is screwing everything up when it does that. Any help on this would be greatly appreciate it.

Another issue I have is the print #1,"0000"
                                       print #1,"fals"
                                       print #1,"fals"
                                       print #1,"0000"
                                       print #1,"0002"
and read them back it reads fals, but the next line it reads it as fal and the 0000 have some square code inside the 000 instead of reading full zeros. As if char(13) or some other char inside of it and each line have char(13) it screws up everything. Any help on this would be greatly appreciate it.


How do I install AMCAF extension?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 04:34:07 AM
The AMCAF extension installs in slot 5.  Yes it matters.

When writing to disk and reading back, the most reliable way to keep it working predictably is to buffer it in a work bank in binary and save it using your own custom bank format.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 04:36:35 AM
I want it in binary..encrypted. PLEASE TEACH ME DO THIS. Also I cannot find the expansion and how do I install it in hard drive and put it in five? Please help me!! Please!!
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 04:59:20 AM
AMCAF includes simple bank encryption techniques.  If you still have 1.5b from the Aminet it's no longer crippleware but the documentation for it is from an old version.  It's been years since I did a fresh AmosPro install but the main file is AMCAF_Install/AMOSPro_AMCAF.Lib .  First, you copy this file to the AmosPro extensions directory, second you back up your interpreter configuration file from its original location in S: to somewhere else (at least I think it's in s: ), finally you go into your interpreter configuration and type AMOSPro_AMCAF.Lib exactly as it appears, and put it on the slot 5 row.  Save your interpreter configuration and restart AmosPro.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 05:05:39 AM
AMCAF includes simple bank encryption techniques.  If you still have 1.5b from the Aminet it's no longer crippleware but the documentation for it is from an old version.  It's been years since I did a fresh AmosPro install but the main file is AMCAF_Install/AMOSPro_AMCAF.Lib .  First, you copy this file to the AmosPro extensions directory, second you back up your interpreter configuration file from its original location in S: to somewhere else (at least I think it's in s: ), finally you go into your interpreter configuration and type AMOSPro_AMCAF.Lib exactly as it appears, and put it on the slot 5 row.  Save your interpreter configuration and restart AmosPro.

Thank you so much!!! Now concerning saving/loading binary my files by first storing them in reserve as work. Please teach me!! - goes down to my knees - Please teach me!! If here is anything you need from me to provide you first, please tell me.
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 05:24:02 AM
A work bank is just a continuous slab of memory that can be loaded and saved to disk.  You access it using Peek, Poke, Deek, Doke, Leek, Loke, Peek$ and Poke$, listed from smallest to biggest.  Strings may be tricky because they are different lengths in memory.  Also, items don't load into the same addresses at any given time from the same file so don't put memory addresses into your file format.  Once you've figured out the layout of your file, you follow the directions in the AMCAF manual to encrypt the file and save it.  Go to https://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMCAFguide/index.html (https://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMCAFguide/index.html) to view the AMCAF manual online.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 05:36:27 AM
But I don't know how to use the pokes and peeks and deeks and feeks and seeks. This is beyond my ability. Is there no other suggestion you can give me, or at least show me how to do it?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 05:57:24 AM
Variables are 32 bits long so mostly you'll be using Loke to put it into the bank buffer.  Keep track of where in the file you put things.  Each Loke takes 4 bytes of storage.

The icon, bob and sprite banks take only 2 bytes per image number.  Likewise, the x and y coordinates are 2 bytes for x and 2 bytes for y.  You write 2 byte numbers using Doke.

Strings take different lengths so one way to store them is to know how many strings there are and Loke the file offsets for the start of each string with the end of each string being 2 bytes less than the next.  Allow 1 extra Loke for the end of the string storage and store the strings at the end of the bank.

Finally there are other considerations with bank handling.  Keep the total length of the bank even numbered because if it's an odd number of bytes, it will crash the compiler or the code it generates.  Likewise, Lokes are quickest if stored on multiples of 4 bytes and Dokes are best on 2 byte increments.

It's almost 1am here so I can't help any more until morning.  Good-night.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 06:14:11 AM
I will wait for the morning then. Because all I end up with a foaming mouth, drooling, going uuuuuuuuuuuuuuuuuh....and understood absolutely nothing, except now felt now that my IQ is only one digit number.

Thanks for that feeling!!  ??? ??? :o :o
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 03:04:55 PM
Ok, what information are you trying to store?

The link to the AMCAF manual above doesn't work in the Tapatalk app so use the web view feature to open that post in a browser window.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 06:00:08 PM
I have two arrays. Each of them are 49,49. The first array stores only integer values ranging from 0 to 9. The second array stores only strings, ranging from A-Z. The level is 49 x 49. However, I will make a demo here of 8 x 8 to give you an idea of the level design in a larger scale.

2 = wall
0 = nothing
S = the x,y where the player starts in the map
F = Fish card
F = FIsh card
G = Gem card
G = Gem card

22222222
2000G002
20F00002
200S0002
20000F02
20000002
20G00002
20000002
22222222

That level on screen are stored in two arrays: one integer, and one string. At the top corner of the level is X=0, Y=0. When you move one right, it becomes X=16, Y=0. When you move one down, it becomes X=16, Y=16, and so forth.  The character based on that sample starts at: _CurrentX=64, and _CurrentY=64. In my code when I want to determine where in the array is 64 and 64, I take _CurrentX and _CurrentY and divide them by 16 to give me the index points. In this example, the starting point is located at LEVEL(4,4). The first fish is located LEVELGETCARD$(5,1) and so forth. That is how the game engine handles this in memory.

I have two arrays labeled: LEVEL(49,49) and LEVELGETCARD$(49,49). I want to be able to take that information and store them as binary correctly where invisible characters like CR or Enter (Char$(13)) and other jibberish is not added to the file that causes corruption during loading the level. I am ok to reworking the entire save/load engine part of the game, if you can help me make it work correctly.

Honestly, I want the files to be encyrpted and can't be viewed by a simple application like notepad. I don't want players to modify the original level designs of the main game, and then be able to cheat. If they want to do their own levels then this is where the editor comes in play. Please help me.

If you want snapshot of the code that loads and saves to file please tell me and I will provide it by request.

Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 07:28:37 PM
Since your tiles go from 0-9, I would use a byte each in the bank so 49×49=2401 bytes.  The same number of strings is 9604 bytes of offsets using the string encoding I described above.  This will make the level 12001 bytes plus the total combined length of the strings.

I'd store the file offsets first for the strings first so that you don't have to worry about alignment of the bytes and strings.  Then the tile array next.  By this point you have filled the header but the strings will sit at the end.  This will take time to read into the 2d arrays but if you like you can use the data in place without needing to copy it.

To read x, y coordinates from the bank, the start address of the string will be at:

Code: [Select]
Offset=Leek((y*49+x)*4+Start(bank num))
To read the string using those offsets, it will be at:

Code: [Select]
Peek$(12001+Start(bank num) + Offset)
To read the tile value will be as follows:

Code: [Select]
Peek(Start(bank num)+9604+(49*y+x))
To write the bytes for the tiles, just use the following code:

Code: [Select]
Poke Start(bank num)+9604+(49*y+x), tile
To make the strings work with Peek$ and Poke$ you need to add Chr$(0) to the end of each.  Use the Len function to figure out the total length of all the strings.

Code: [Select]
Reserve As Work bank num, (12001+total string length+3)and not 3
I'm a little shady about this command so be sure to look it up in the Amos Bank chapter in the manual.  The "+3 and not 3" at the end rounds it up to the next multiple of 4 bytes to be safe.

To write the strings to the work bank, you start at 12001 and
Code: [Select]
Poke$(start(bank num)+offset),s$(x,y), store offset at
Code: [Select]
Loke Start(bank num)+(49*y+x)*4,offset and add
Code: [Select]
offset=offset+Len(s$(x,y)) then move on to the next value for x and y.  This assumes that s$ is your original string array and that each string has Chr$(0) at the end as mentioned above.

Finally, to encrypt the bank using AMCAF, use:
Code: [Select]
Bank Code Mix.w bank num, key where key is the value used to decrypt also.  Don't lose the key value without backing up your unencrypted file, there are 65535 wrong keys to use.  It might take a minute or 2 to brute force it even if you use the same command. By the way, the same command decrypts it, I think.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 07:40:22 PM
And how do you store all that in a file and read it back from a file?

In my game I already placed all the data in these two arrays. How do I take these from the arrays and put them in the bank and offset and poke or doke or whatever? IN additional to that, do I place it in a loop? I am using open in and open out to read and save...do I still use this to make new files, load files or save files after level been modified? How do I generate the key for encyrption?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 09:13:19 PM
To generate the levels, you do 2 loops.  First, you loop through all the strings, adding a Chr$(0) to the end of them, then add the length to the total length of the strings using the Len(s$(x,y)) function.  Once you have the total length of all the strings, you can allocate the level bank and loop through all the coordinates, poking all the array values for the tiles and strings into the level bank using the commands above.

Once the level bank is populated, you encrypt it using the Bank Code instruction above and save the whole bank to disk with the command called "save".  To generate the number as key, just pick a number between 0 and 65535 and stick with it.

I'd recommend replacing all the array accesses with functions that correspond to the Peek and Peek$ commands above.  See the Def Fn command and use it to replace all the array accesses with a global search/replace from the editor.  Each access will just need the Fn command added in front.

I just noticed a mistake in the Poke$ command above.  Poke$ requires the first address in the string instead of the string itself.  To get that, just use VarPtr(s$(x,y))+2 instead of just s$(x,y) .

Now this leads me to the discussion of whether you want a save game bank format independent of the level bank format.  If so, do the tiles get modified during the game?  Also, do the strings change or remain constant?  Are there other variables besides x and y?

Finally, test the decryption before you go any farther.  If it doesn't work, I have a backup plan.  The command for that should be:

Code: [Select]
Load"filename", bank num
Bank Code Mix.w bank num, key
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 10:55:58 PM
In the runtime game engine there is no saving to level after gameplay modification. Simply put, when you die, it clears all arrays: Level(width,height) and levelgetcard$(width,height) to zero and then reload that level again:

Level 0.dat

and refill them again as if you just started from the beginning. The whole concept of loading/saving and modifying level is for the editor itself. I just want to make a complete editor and save those levels, so it is easy for me to make more levels for the main game itself.

I am not saving sprites or images or audios in the file. I am just saving single character and 1 digit variable ranging from 0 to 9 to represent walls, items, monsters, etc.

That is all.

To go back to your statement to generate levels...I need to do two loops.

This is my 1st loop for reading from file (assuming the file is already encrypted and cannot be modified by outside the engine and it is saved using the write method you showed me):

Reserve As Work bank num, (12001+total string length+3)

Reading method:
-------------------
Load "filename", bank num
For Height=0 to 49
  For Width=0 to 49
      offset=Leak((Height*49+Width)*4+Start(bank num))
      LEVELGETCARD$(Width, Height)=Peek$(12001+Start(bank num) + Offset)
      LEVEL(Width, Height)=Peek(Start(bank num)+9604+(49*Height+Width))
  Next Width
Next Height

and if I print out Level(0,0) it will spit out 2, where 2 represents yellow wall?
and if I print out LevelGetCard$(5,5) it will spout out F, where F represent the Fish card?


Am I 100% correct on this?
--------------------------------------------------------------------------------------------
When it comes to saving I do this?

For Height=0 to 49
   for Width=0 to 49
        Poke$(start(bank num)+offset),VarPtr(LevelGetCard$(Width,Height))+2=LEVELGETCARD$(Width,Height)+Chr$(0)
        Loke Start(bank num)+(49*Height+Width)*4,offset=LEVEL(Width,Height)
        offset=offset+Len(s$(Width,Height))
   Next Width
Next Height

Bank Code Mix.w bank num, key <-- to save in the hard drive with a filename called level 0.dat at DH1:AMOS/Code/test/

Please tell me if I made a mistake in the code and where I made a mistake? Thanks in advance.
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 07, 2021, 11:45:51 PM
Reading method:
-------------------
Code: [Select]
Load "dh1:amos/code/test/level0.dat", 16
Bank Code ROR.w 16, 5
Bank Code xor.w 16, $a55a
For Height=0 to 49
  For Width=0 to 49
      offset=Leek((Height*49+Width)*4+Start(16))
      LEVELGETCARD$(Width, Height)=Peek$(12001+Start(16) + Offset)
      LEVEL(Width, Height)=Peek(Start(16)+9604+(49*Height+Width))
  Next Width
Next Height
Erase Bank 16
Save:
Code: [Select]
StringLength=0
For Height=0 to 49
   For Width=0 to 49
      LevelGetCard$(width, height)=LevelGetCard$(width,height)+Chr$(0)
      StringLength=StringLength+Len(LevelGetCard$(width,height))
    Next width
Next Height
Reserve as work bank 16, (StringLength+12001+3) And Not 3
Offset=12001
For Height=0 to 49
   for Width=0 to 49
        Poke$(start(16)+offset),VarPtr(LevelGetCard$(Width,Height))+2
        Loke Start(16)+(49*Height+Width)*4,offset
        offset=offset+Len(LevelGetCard$(Width,Height))
        Poke start(16)+(49*height+width)+9604, level(width,height)
   Next Width
Next Height

Bank Code xor.w 16, $a55a
Bank Code ROL.w 16, 5
save"dh1:amos/code/test/level0.dat",16
Erase bank 16

I changed the encryption commands to something that should fully reverse itself.  It seems odd that the "Bank code mix.w" command doesn't have an inverse.  I also chose bank 16 for you and encryption keys.  Hopefully this should work.

Please credit me for my work if you release your game publicly.  My name is Samuel D. Crow.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 07, 2021, 11:48:34 PM
IT IS A DEAL!! DEAL!! DEAL!! DEAL!! DEAL!!!
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 12:03:15 AM
I fixed a typo in the save loop.  It wasn't writing the level bytes correctly.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 01:15:43 AM
Thank you sooo much!!!
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 01:25:18 AM
:-)
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 02:42:41 AM
I do not know if it is too late for you to read this, since we closed it by saying thank you. I will try again though, in hopes you can still reply here or else I may need to make an entire new post. The extension AMCAF is not working. I am having a hard time installing it. I keep getting the same error message even after placing it in slot 5 and typing the name exactly. What advice do you have?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 02:47:11 AM
Is the file in the right directory?
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 02:52:25 AM
APUSystem.
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 02:53:44 AM
What error is it giving?
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 03:01:29 AM
That!!

(https://www.ultimateamiga.com/index.php?action=dlattach;topic=10245.0;attach=1413;image)


Problem with that is...that once this happens...replacing the config file again with a backup before changes doesn't do anything. I need to delete everything, restart the system, THEN AND ONLY then, extra lha again back for it to work. It is a dramatic reinstall.


It doesn't matter if this is the original AMOS or AMOS Unity with added features that is in current development. This happens regardless. It doesn't matter if it is in WinUAE or on my Amiga 500 or Vampire 4. This happens again and again and again.
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 03:03:22 AM
Are there any directories inside APSystem?
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 03:04:49 AM
No. By the way, I am going to post this publicly for download with donation button. Any money coming in donation, even if it is a 1 dollar you are getting 50% royalty for helping in additional to getting full credit.

I will be putting under credit screen:

Programming By:
XboxOwn
<YOUR NAME> not SamuraiCrow as you told me to put it

This will give people the idea you have 50% if not more input in it's development, in additional you get 50% royalty for any money generated as donation.

Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 03:11:21 AM
I only copied AMCAF to APSysem...should I also copy amos.library, explore.library and powerpacker.library to the libs directory too?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 03:13:22 AM
Put powerpacker.library and explode.library in Libs: and see if it helps.  The custom Amos.lib shouldn't be required.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 03:21:15 AM
Failed!!
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 03:22:42 AM
What other extensions are in APSystem?  The AmosMusic extension should be in there too.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 03:33:02 AM
K. You know what? I have this AMOS Unity they are making which adds new features to AGA and such for the new hardware Vampire 4 they released to the public. Maybe this (being in alpha stage) is the reason. Do you have a complete lha I can unextract that contains AMOS already installed with all it's extensions configured (including AMCAF)? I will simply migrate my game to that and remove any code I used that works with AMOS Unity only and recode it to work with normal AMOS.

I just want to release this game and I am not going to wait patiently until the author deals with his political issues in French to resume work and help me solve it from his end.

To answer your question this is what I have in APUSystem folder:

AmosProUnity.Lib
AmosProUnityAGA.library
AmosProUnityECS.library
AmosProUnity_Compact.lib
AmosProUnity_Compiler.lib
AmosProUnity_IOPorts.Lib
AmosProUnity_Music.Lib
AmosProUnity_Request.Lib
AmosProUnity_Support.Lib
AmosPro_AMCAF.Lib
AmosPro_AMCAFUpdate.Lib
Compiler.Lib
Header_Backstart.Lib
Header_CLI.Lib
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 03:36:28 AM
That may be the problem!  Yes!  Frèdèric may not have tested it with old extensions.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 03:52:22 AM
Do you know where I can find that lha that have the entire amos installed? thanks
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 03:58:42 AM
Mequa's old build might be modifyable but it booted straight to Amos via Aros on Windows.  It had trouble with file transfers because it had such an ancient Aros version.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 04:00:13 AM
Nothing for Amiga? :(
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 04:02:33 AM
@Hungry Horace

Didn't Hungry Horace have a full Amos install on HDF that could be unpacked on Amiga?
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 06:01:26 AM
Do you think he will hear you?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 08, 2021, 12:57:18 PM
He's got the tapatalk app and I asked on our Discord server too.  If all you need is xor encryption, I can rewrite the save routine without AMCAF.  Just not right now.
Title: Re: Issue with print #1 command
Post by: Hungry Horace on August 08, 2021, 01:20:00 PM
https://cdn.discordapp.com/attachments/392453604348526595/873914531632513024/AmosProBoot.zip

Not sue if this will work without a Discord login!


Make sure to speak to Frederic about plans for AMCAF support - either recompiling the ReSourced code or adding the same commands into his own compatibility extension. I know he had plans to do this.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 08, 2021, 06:31:17 PM
Frédéric CORDIER <cordierfr@wanadoo.fr>
9:03 AM (2 hours ago)
to me

Hello.
Quick reply from my holidays week.
Amos Pro Unity is not compatible with amos professional existing plugins.
I have the AMCAF source code, but did not yet ported it to amos pro unity.
It will maybe be done later in the years, once saga graphics will be completed.

Regards.
Frédéric Cordier

Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 09, 2021, 10:30:58 PM
As a non-AMCAF implementation of the encryption, substitute the following for the Bank Code lines:
Code: [Select]
For C=Start(16) To Start(16)+Length(16)-2 Step 2
    Doke C, Rol.w(Xor(Deek(C),$A55A),5)
Next C

To decode the prevous encryption:
Code: [Select]
For C=Start(16) To Start(16)+Length(16)-2 Step 2
   Doke C, Xor(Ror.w(Deek(C),5),$A55A)
Next C

If it's not fast enough, assign the end expression of the for loops (everything between the To keyword to the Step keyword) to a variable and test against that inside the loop.  Also, be sure the file is loaded before you assign the expression to the value.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 10, 2021, 12:24:28 AM

Hey SamuraiCrow I have issue with the code you gave me....
« on: August 09, 2021, 05:01:27 AM »
ReplyQuoteModifyModify
   First, I would like to thank you in advance for all the help you are giving me. So in this regard, thank you. Sorry to disturb you or further waste your time, I typed the code and I am facing issues with it. Please, bare with me.

For this code:

Load "dh1:amos/code/test/level0.dat", 16
Bank Code ROR.w 16, 5
Bank Code xor.w 16, $a55a
For Height=0 to 49
  For Width=0 to 49
      offset=Leek((Height*49+Width)*4+Start(16))
      LEVELGETCARD$(Width, Height)=Peek$(12001+Start(16) + Offset)==> this line always spit out syntax error for some reason. No matter what I do, it spits out syntax error. The error is on peek$. For some reason, it is happy to return to value if it is typed like this:

_retVal=Peek(12001+Start(16)+Offset) instead of Peek$. Which is why the line below this sentence works great. I am not sure what to do here.

      LEVEL(Width, Height)=Peek(Start(16)+9604+(49*Height+Width))
  Next Width


---------------------------

For this line of code:

Reserve as work bank 16, (StringLength+12001+3) And Not 3

There is no such thing as bank 16. if I type Reserve As Work BANK 16, (StringLength+12001+3) And Not 3 as you can see, I have capitlized it. Meaning BANK is invalid and will give me syntax error. If I removed bank after Reserve As Work then it compiles.

This line of code:

        Poke$(start(16)+offset),VarPtr(LevelGetCard$(Width,Height))+2

gives me type mismatch. It doesn't like VarPtr with string LevelGetCard$ and nor does it like +2 after it. How do I go about resolving this issue.

There is no such thing as Bank after Erase. It have to be Erase 16. Is this correct? Once I ran the code...it produces horribles gibberish graphics effects in the screen and resulted in full fledge crash. What advice do you have. I cannot save or load because it results in destructive jibberish in the screen followed by crashing.

Here are the codes again below:

reading
Load "dh1:amos/code/test/level0.dat", 16
Bank Code ROR.w 16, 5
Bank Code xor.w 16, $a55a
For Height=0 to 49
  For Width=0 to 49
      offset=Leek((Height*49+Width)*4+Start(16))
      LEVELGETCARD$(Width, Height)=Peek$(12001+Start(16) + Offset)
      LEVEL(Width, Height)=Peek(Start(16)+9604+(49*Height+Width))
  Next Width
Next Height
Erase Bank 16


writing
StringLength=0
For Height=0 to 49
   For Width=0 to 49
      LevelGetCard$(width, height)=LevelGetCard$(width,height)+Chr$(0)
      StringLength=StringLength+Len(LevelGetCard$(width,height))
    Next width
Next Height
Reserve as work bank 16, (StringLength+12001+3) And Not 3
Offset=12001
For Height=0 to 49
   for Width=0 to 49
        Poke$(start(16)+offset),VarPtr(LevelGetCard$(Width,Height))+2
        Loke Start(16)+(49*Height+Width)*4,offset
        offset=offset+Len(LevelGetCard$(Width,Height))
        Poke start(16)+(49*height+width)+9604, level(width,height)
   Next Width
Next Height

Bank Code xor.w 16, $a55a
Bank Code ROL.w 16, 5
save"dh1:amos/code/test/level0.dat",16
Erase bank 16
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 10, 2021, 12:53:56 AM
I just looked up the correct syntax at https://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMOSProManual/14/1405.html and it needs a few more parameters.

Peek$(address, length, chr$(0))

The length is the maximum length possible for the string so give it a sensible number like 32768 or smaller.  The address is what I previously gave you as a parameter for the start of the string.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 10, 2021, 01:01:46 AM
I just looked up the correct syntax at https://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMOSProManual/14/1405.html and it needs a few more parameters.

Peek$(address, length, chr$(0))

The length is the maximum length possible for the string so give it a sensible number like 32768 or smaller.  The address is what I previously gave you as a parameter for the start of the string.


So I should type it like this:

Peek$(12001+Start(16) + Offset, stringlength, chr$(0)) instead of Peek$(12001+Start(16) + Offset)? What about reserve as work bank 16 where the word bank doesn't exist after work and what about type mismatch error and about jibbering graphics and crashing the entire system?
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 10, 2021, 01:24:27 AM
The word "bank" should be deleted because it thinks it is a function or variable.  https://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMOSProManual/5/578.html

I assumed you had the manual.  I haven't programmed in AmosPro for a long time and was typing from memory on my phone.

Also, you have the right idea about the Peek$ function.  Just give StringLength a big number bigger than your biggest string.  As long as it finds the Chr$(0) at the end it will stop.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 10, 2021, 01:32:37 AM
As a non-AMCAF implementation of the encryption, substitute the following for the Bank Code lines:
Code: [Select]
For C=Start(16) To Start(16)+Length(16)-2 Step 2
    Doke C, Rol.w(Xor(Deek(C),$A55A),5)
Next C

To decode the prevous encryption:
Code: [Select]
For C=Start(16) To Start(16)+Length(16)-2 Step 2
   Doke C, Xor(Ror.w(Deek(C),5),$A55A)
Next C

If it's not fast enough, assign the end expression of the for loops (everything between the To keyword to the Step keyword) to a variable and test against that inside the loop.  Also, be sure the file is loaded before you assign the expression to the value.

This code resulted in a syntax error.

By the way the loop is fine..it crashes the second the first line of bank code xor.w 16,$a55a is executed.
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 10, 2021, 02:21:01 AM
Bank code Xor.w, Bank Code ROL.w and Bank Code ROR.w requires the AMCAF extension.  Use the loop instead.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 10, 2021, 02:55:08 AM
Bank code Xor.w, Bank Code ROL.w and Bank Code ROR.w requires the AMCAF extension.  Use the loop instead.

I have the extension. Even if I use the loop it returns syntax error. It would not allow me to compile.
Title: Re: Issue with print #1 command
Post by: SamuraiCrow on August 10, 2021, 03:07:02 AM
https://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMOSProManual/14/1409.html

According to the manual, the 5 should come first and doesn't return a value.  The loop that had the rotate inside should be
Code: [Select]
ROL.W 5, C
Doke C, Deek(c) Xor $A55A

And the other loop should be:
Code: [Select]
Doke C, Deek(c) Xor $A55A
Ror.w 5, C
inside the loop.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 10, 2021, 04:54:13 AM
saving worked. It made a 1.7 MB encrypted file. Loading failed. It kept my hard drive activity endless working, then screen turn blue while loading and then went into software failure. Maybe because I am still using bank code. Let me try with your new code change.
Title: Re: Issue with print #1 command
Post by: xboxisfinished on August 10, 2021, 05:05:35 PM
The decoding is not working. It is still reading jibberish. It have failed to decode. Can you help me?