Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4   Go Down

Author Topic: Issue with print #1 command  (Read 7676 times)

0 Members and 1 Guest are viewing this topic.

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Issue with print #1 command
« 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?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #1 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.
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #2 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!!
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #3 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.
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #4 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.
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #5 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 to view the AMCAF manual online.
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #6 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?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #7 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.
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #8 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
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #9 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.
« Last Edit: August 07, 2021, 04:56:48 PM by SamuraiCrow »
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #10 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.

« Last Edit: August 07, 2021, 06:05:52 PM by xboxisfinished »
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #11 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.
« Last Edit: August 07, 2021, 07:30:56 PM by SamuraiCrow »
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #12 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?
« Last Edit: August 07, 2021, 07:57:18 PM by xboxisfinished »
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Issue with print #1 command
« Reply #13 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
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Issue with print #1 command
« Reply #14 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.
« Last Edit: August 07, 2021, 11:07:48 PM by xboxisfinished »
Logged
Pages: [1] 2 3 4   Go Up
 

TinyPortal 2.2.2 © 2005-2022