Ultimate Amiga

Please login or register.

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

Author Topic: Specify memory location  (Read 4363 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
Specify memory location
« on: May 02, 2015, 01:14:05 AM »

   Hello,

I want to write a game where I want to put all the resources into specific memory location (Fast RAM) and then stream them as I need them to the CHIP RAM. Ones I used or needed that information into CHIP RAM, I wish to remove them from the CHIP RAM then put them back into the Fast RAM. I have purchased ACA500 and I wish to put files into memory location in the ACA500 and I do not know how to do that. I would like to be able to specify the location in memory in Fast RAM where I can store everything I need and from that location in Fast RAM as I go by during game play stream it to CHIP RAM and back and forth between Fast RAM and CHIP RAM. How do I go about doing that?

According to the ACA500 manual "Address range 0x80.0000 to 0x9f.ffff contains the 2M fastmem of the ACA500.". I wish to use this memory range to store information into. Is there some examples I could use to store in this memory range and obtain data from within that memory range?

Thanks in advance.
Logged

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 307
  • Offline Offline
  • Gender: Male
  • Posts: 3,364
  • Don't forget... Ameboid's need love too!
    • AUW
Re: Specify memory location
« Reply #1 on: May 02, 2015, 11:47:36 AM »

you should use AMOS's bank commands rather than peeking / poking directly to specific memory addresses.

http://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMOSProManual/5/577.html

I've mad ethe assumption you dont need 'permanent' banks of memory, so have a look at some of the following commands:

Quote
RESERVE AS WORK
instruction: reserve a new work bank
Reserve as Work bank number,length
This allocates a temporary workspace of the requested length from fast memory, if it is available.

RESERVE AS CHIP WORK
instruction: reserve a new chip work bank
Reserve As Chip Work bank number,length
This command allocates the selected block of temporary memory using Chip Ram, and it is often used with the DOUBLE BUFFERED sampling system, to play samples directly from hard disc.


AMCAF extension alsp has some commands that should help you force a bank to reside in chip or fast ram.

http://www.ultimateamiga.co.uk/HostedProjects/AMOSFactory/AMCAFguide/manual/bank.html

Quote
BANK TO FAST
instruction: move a memory bank to fast ram
Bank To Fast won't work with Icon and sprite bank.
Warning: Do not try to replay music or sound that exist in fast ram.


BANK TO CHIP
instruction: move a memory bank to chip ram


this way you can create 2 banks of whatever size you need, and force each on into fast/chip ram.

You can then access their starting address using the address START(X)  (where X is the bank number) and add an offset for how far into the memory space you want to read/write, using PEEK/POKE, DEEK/DOKE, LEEK/LOKE.


Hope this helps
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Specify memory location
« Reply #2 on: May 02, 2015, 12:38:49 PM »

So if I wanted to put for example the music files into this bank number  0x80.000 for example, I will say:

RESERVE AS WORK 0x80.000, "Df0:Music.mod"

Is that how it works? How do I increment 0x80.000 up to  0x9f.ffff? Do I go:

 0x80.000 ,  0x81.000,  0x82.000,....  0x89.000,.. 0x90.000, 0x91.000 and so on.   

Couple of more questions in my mind...I reserved some work using Reserve as Work which is I assume the fast ram..how does it work with bank to fast? Do I start with Bank to Fast first before I do the command reserve as work?

I read this under Bank To Fast
Bank To Fast won't work with Icon and sprite bank.
Warning: Do not try to replay music or sound that exist in fast ram

Does that mean I still can load icons, sprite banks, .abk, music, sound into the Bank To Fast but when it comes to displaying them or playing audio I move them first using Bank to Chip under the engine while loop and then do what i need then again bank to fast?

Can I specify certain item in bank to fast to move to bank to chip and then back again bank to fast? Can I specify a certain address I stored in above where it holds the item to display it on screen and then put it back again in bank to fast?

I just need couple of clarifications before i understand how this works. Is there an example that shows how reserver as work, reserver as chip work, bank to fast and bank to chip works?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Specify memory location
« Reply #3 on: May 02, 2015, 02:31:53 PM »

The maximum number of banks are 65535 and that is also the biggest bank number.  Some other commands that will help is bank swap, load, and save.

If you use bank to chip on music modules they can be played using pt play from the AMCAF extension.  Icon banks and sprite/bob banks are not stored in continuous chunks of RAM, however they can be saved to the ramdisk for future reference.
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Specify memory location
« Reply #4 on: May 02, 2015, 08:22:37 PM »

So my understanding is this. Let me put it in a context to the way I understood this and tell me if I understood correct or not.

Reserve As Work is really setting up a specific set of bytes I wish to reserve in a bank number. Say Bank #1 I wish to reserve aside 2 MB of RAM. Which is located in the Fast RAM. From my understanding it have NOTHING to do with actual location of bank registry, it simply put aside 2 MB of Fast RAM whenever such amount is available. However, if I wish to put a certain data in a certain location in a registry of the RAM then I need to specify that using the Poking. If I wish to retrieve such data I use it under Peeking from that specified location in registry.

Am I correct so far? For example, say I want to store information in RAM registry at this specified location range  0x80.0000 to 0x9f.ffff. This is where poking and peeking comes in this regard. So if by default I have saved 2 MB and I only used 1 MB and in this location range  0x80.0000 to 0x9f.ffff I can only use 2 MB, I poke data in that location range  0x80.0000 to 0x9f.ffff of 1 MB that data now is stored exactly in that location range  0x80.0000 to 0x9f.ffff. I will be left with 1 MB free from that location range  0x80.0000 to 0x9f.ffff, am I correct?

Now comes the question how do I poke within this location 0x80.0000 to 0x9f.ffff range? How does the incrementation goes so that in poking I use it between  0x80.0000 and 0x9f.ffff? When it comes to peeking, is the same information I used for poking just change it from poking to peeking? Finally, how do I store the main program engine not so much the graphics for example within that range of RAM? Or in fact, how do I store graphics or media in that range of RAM?

Ones I have that information stored using reserve work and taking that 2 MB from reserve work and poking it in that certain specified location range...the chip RAM have different location range all together than the one I specified here. How do I go about now, taking audio and sprite from reserve work to reserve chip withing that chip ram location range of memory registry?
« Last Edit: May 02, 2015, 08:26:36 PM by xboxisfinished »
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Specify memory location
« Reply #5 on: May 03, 2015, 12:34:40 AM »

Bank numbers have no correlation with addresses.  You use the "start" function to find the address starting the range contained in the bank and the "length" command to determine its length if you forget.  AMCAF extension lets you shrink a bank or grow it using the respective commands but they work by allocating the new memory bank and copying to the new addresses before deallocation of the original.

Work banks are not stored in the program but the other kinds are.  Peeking and poking are not unheard of but the "bload" command is handy from direct mode also.  If you want to store banks outside of the program, loading a work bank does the trick.
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Specify memory location
« Reply #6 on: May 03, 2015, 03:21:22 AM »

Bank numbers have no correlation with addresses.  You use the "start" function to find the address starting the range contained in the bank and the "length" command to determine its length if you forget.  AMCAF extension lets you shrink a bank or grow it using the respective commands but they work by allocating the new memory bank and copying to the new addresses before deallocation of the original.

Work banks are not stored in the program but the other kinds are.  Peeking and poking are not unheard of but the "bload" command is handy from direct mode also.  If you want to store banks outside of the program, loading a work bank does the trick.

All I want from you is one example of which you speak about the start function and getting the length using this registry 0x80.0000 to 0x9f.ffff  range. Say I want to store Dim level (512, 512) and wish to store this memory consuming RAM between this range 0x80.0000 to 0x9f.ffff using the start function you speak and poking an peeking.

You give me one example and I am set, I promise I will not ask about this topic anymore. I take it we are incrementing by hexadecimal right?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Specify memory location
« Reply #7 on: May 03, 2015, 03:27:46 AM »

The reason I have been avoiding any particular address range is because banks are dynamic allocations.  If you are doing level data, there's a thread about that already.  I will find it and post a link.
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Specify memory location
« Reply #8 on: May 03, 2015, 03:36:16 AM »

http://www.ultimateamiga.co.uk/index.php?topic=9074.0 has an example but isn't the one I was looking for.
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Specify memory location
« Reply #9 on: May 03, 2015, 04:27:59 AM »

All I want from you is one example of which you speak about the start function and getting the length using this registry 0x80.0000 to 0x9f.ffff  range. Say I want to store Dim level (512, 512) and wish to store this memory consuming RAM between this range 0x80.0000 to 0x9f.ffff using the start function you speak and poking an peeking.

You give me one example and I am set, I promise I will not ask about this topic anymore. I take it we are incrementing by hexadecimal right?
It might be best to go back to Amiga basics.  The Amiga has an operating system.  So whether you boot up into Workbench or a simple CLI window, that operating system is already using up some of the RAM in your machine.  It will use a bit of Chip RAM for what's being displayed on screen (Workbench or CLI) and a bit of Fast RAM (if available) for managing the system and the RAM: disk.  The Amiga operating system allocates whatever memory it needs for this and keeps track of it for you.  So when you run something like AMOS, it is also taking up some of the system's memory.  Again, Chip RAM for any graphics or sound and Fast RAM for the program itself and its memory requirements.

The point being that only the Amiga's operating system "knows" where all that allocated memory is.  And it could be anywhere!  That's why you can't just Peek and Poke around in the Amiga's memory without first politely asking the operating system for a chunk to play with.  If you ignore that, you will inevitably end up either Poke-ing into a memory address that's already being used, or you will have whatever you've Poke-ed into memory stomped on when the operating system allocates some memory it requires.  Either way it's a disaster!

So the Amiga high-level programming languages, like AMOS, all have instructions to politely request memory.  In AMOS, these chunks of memory are known as "banks".  They are identified by a Bank Number.  All you need to do is specify:
  • A free Bank Number
  • How many bytes you want
  • Whether you want Chip or Fast RAM
AMOS then has instructions to tell you the memory address where your bank starts and how long it is.  Having got that information, you can then Peek and Poke to your heart's content within that chunk of memory.  It also has Deek and Doke (two bytes) and Leek and Loke (four bytes) instructions plus an instruction to copy blocks of memory.  I won't go into the details here as the manual explains it very well (download links below).

It is very important to realise that some memory is already being used by both the operating system and AMOS.  And both will prefer to use your Fast RAM for anything that doesn't require Chip RAM.  So just because you've got a 2Mb Fast RAM does not mean that you can allocate a 2Mb Bank!  AMOS also has instructions to find out how much is available in Chip and Fast RAM.  Check before you go allocating any very large Banks.

What version of AMOS are you using?  AMOS The Creator or AMOS Pro?  If it's AMOS The Creator, I would strongly recommend upgrading to AMOS Pro using this and this from the Downloads section.  The PDF version of the AMOS Pro manual is really useful too as its bookmarks and index make it very easy to chase up what you need to find.  It's also in the Downloads section here.  Read the section from page 157 onwards for info on Banks and page 557 onwards for info on manipulating memory.  The online version is also very good (the link Hungry Horace provided above).

AMOS The Creator is limited to only 16 banks.  AMOS Pro allows over 65,000.  We'll assume you're using AMOS Pro.  ;)

A last couple of things to beware of:

Sprite, Bob and Icon objects can also be stored in Banks.  BUT, they're not just Banks that contain a nice chunk of linear memory to play with!  Each object is loaded into its own chunk of memory and AMOS keeps track of what's where in a list.  In other words, they're scattered all over the place.  Any other banks are okay - nice linear chunks of memory.

Bank numbers 1 through 16 are a bit special in that each one is "usually" allocated to a specific purpose.  For example, most of the AMOS accessory programs use Bank 16 for their Interface data, Bank 1 for Sprites, etc. (I can never remember the exact list, look it up in the manual).  So it's always best to check whether a Bank Number is in use before using it.  Simply ask for its Length.  If it's zero, the Bank Number's free.

Final words:  Have a read of those sections in the manual.  And use the built-in help system, there's some example programs there that can help show you how to use the instructions.  Best of all, play with it - the best way to learn.   :)
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Specify memory location
« Reply #10 on: May 03, 2015, 11:37:12 PM »

i want to thank you guys for all your help and I diffinatly want to thank you guys for the quick replies you give me. You are better than AmiBlitz3 forum or AmiBlitz2 forum. Very fast replier, thank you!

Today I am going to start my first attempt in writing a game in AMOS. Here goes nothing!!
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022