Ultimate Amiga

Please login or register.

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

Author Topic: Problem with AMOS compiler  (Read 11792 times)

0 Members and 2 Guests are viewing this topic.

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Problem with AMOS compiler
« Reply #15 on: May 29, 2015, 03:42:13 AM »

Attached here is the source code as request. When I attempted to compile it from within AMOS it gives me error with missing extension or some sort. When I attempt to set interpret it gives me error with configuration when I load configuration and it gives me error when I click in any of the set settings.
Thanks for the source code.  I'm currently trying to understand the details of the AMOS compiler sources.  So any examples of stuff that either won't compile or gives errors when run are most appreciated.  That way I stand some chance of nailing the problems in the debugger.

As a side note.  It's great to see how you've taken to AMOS.  Well done for getting involved.  ;)  And I can promise you a much improved version in the future.  It just takes time...

Thank you so much :D What do you think of my coding style and what I have done so far? Please the game use the arrow keys to move arrow then press P and see what happens. Right now make sure you don't step on the item yet, because if you step over the item in the array it will be deleted and replaced by empty space. I am working on fixing this in the future, but right now step beside an item and press P and try to pick an item beside you. Now try the same attempt with a different item and go further away from it and see what happens. Press S for status and try to pick the key and see what happens after you picked the key by pressing S. I am happy with my work...but all of this is alpha..more will be changed.

Using the Wind open it opens great opportunity but I have questions about it and I plan to ask them in a new topic. As this topic about compiler and I want to keep it that way...but THANKS for the compliment....:)

By the way, i am treating programming the same way as playing an RPG game and leveling. My level 0 experience now is in AMOS as AMOS is excellent and I emphasize with the term excellent for beginner programmer to make games. So my 1st game is going to be done in AMOS both engine and editor side of this game.  As a level 0 experience programmer my intention when the game is finished and replaced with better graphics I will release the engine, editor and their source code on aminet :) You guys can play the game i made with it's story and then make your own games using my editor (as my editor will also include having custom event and so on).

My level 1 experience when I am done with this will be in AmiBlitz as it is a more challenging programming language and i need to use a more challenging language to hun my skills better and learn better and improve better in programming and fix any bad habit and improve in my habit. As AmiBlitz is not true OO yet but helps more than the skill I have in current AMOS.

When I finish my second game completely, I will have that game closed source code and sell the executable in amigakit.

Finally, when I reach level 2 I will make my last Amiga game in my life and that will be done in C++. That too will be closed source and the executable will also be sold.

Then that is that :)
« Last Edit: May 29, 2015, 03:47:03 AM by xboxisfinished »
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Problem with AMOS compiler
« Reply #16 on: May 29, 2015, 06:00:51 PM »

It's good to see you have set yourself a good plan, but I hope you don't stop programming... you've set yourself some targets that will take alot of work.
I have been programming for years and love learning new algorithms and debugging both mine and other peoples code ;)

That leads nicely onto the fact that I have found the cause of the problem! :)

Code: [Select]
Dim MAPS(512,512) : Rem cause of "illegal function call" error.
That requires 512*512*4 bytes = 1048576 bytes (or ~1MB)
(each variable value in AMOS is always stored as a longword - 4 bytes - though I think AMCAF has a special version of Dim that uses 2 bytes per value?)

bruceuncle, I suspect it's some quirk of either the compiler code or (hopefully) something in the compiler config file? It seems weird to me that it works in the Editor and yet fails when compiled?
(FYI: my A600 setup in WinUAE has 8MB of chipRAM available)
« Last Edit: May 29, 2015, 06:03:37 PM by Lonewolf10 »
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Problem with AMOS compiler
« Reply #17 on: May 31, 2015, 12:59:42 AM »

It's good to see you have set yourself a good plan, but I hope you don't stop programming... you've set yourself some targets that will take alot of work.
I have been programming for years and love learning new algorithms and debugging both mine and other peoples code ;)

That leads nicely onto the fact that I have found the cause of the problem! :)

Code: [Select]
Dim MAPS(512,512) : Rem cause of "illegal function call" error.
That requires 512*512*4 bytes = 1048576 bytes (or ~1MB)
(each variable value in AMOS is always stored as a longword - 4 bytes - though I think AMCAF has a special version of Dim that uses 2 bytes per value?)

bruceuncle, I suspect it's some quirk of either the compiler code or (hopefully) something in the compiler config file? It seems weird to me that it works in the Editor and yet fails when compiled?
(FYI: my A600 setup in WinUAE has 8MB of chipRAM available)

Is there away I can put all the array on fast RAM directly and not on chip RAM? I will leave everything in chip RAM except for the array.

This way I can have:

Layer0(1000,1000) = floor, grass,which door locked and what key needed to open it, traps, etc
Layer1(1000,1000) = objects: wall, items, etc
Layer2(1000,1000) = events, quests, etc

I know that such array in itself will take 12 MB in memory right there. But I cannot use 12 MB on CHIP RAM and I cannot leave 1 byte chip ram and the rest on fast. I want that when the program runs...it instantly takes 12 MB from Fast RAM based on the three layer arrays. This way, the compiler does not care if I go this big in array and lots of people who use Amiga have at least 32 MB Fast RAM and 12 Mb Fast RAM is not too much.

So how do I put the array in fast ram directly?


The reason why I want the map size to be this big because I want to put everything in one array directly. I don't want to have to keep access files and loading new areas of the map and somehow try to save changes on old area and stuff like that on file when I come back to using that old area again. I want to do all the manipulation in memory directly.
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: Problem with AMOS compiler
« Reply #18 on: May 31, 2015, 08:59:16 AM »

I still think you need to re-think having such massive arrays. Especially if you have large sections of it of "zero" values

You could avoid using arrays all together and use PEEK/POKE Of memory addresses (to a bank stored in fast ram)
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Problem with AMOS compiler
« Reply #19 on: May 31, 2015, 03:59:35 PM »

You could avoid using arrays all together and use PEEK/POKE Of memory addresses (to a bank stored in fast ram)

I agree.

Having such huge arrays will waste alot of memory. Horace's suggestion above will reduce the memory usage a little.
Logged

Sidewinder

  • Forum Mod
  • A600
  • *****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • http://www.liquido2.com/
Re: Problem with AMOS compiler
« Reply #20 on: May 31, 2015, 04:39:26 PM »

So, if you do as Hungry Horace suggests you'll save memory also because your "array" elements can be less than 4 bytes.  You might have something that looks like:

Code: [Select]
Rem Calculate the array size
MAP_SIZE=MAP_WIDTH*MAP_HEIGHT

' Allocate Layer0 array
Reserve As Work 10,MAP_SIZE
LAYER0_BASE = Start(10)
' Allocate Layer1 array
Reserve As Work 11,MAP_SIZE
LAYER1_BASE = Start(11)
' Allocate Layer2 array
Reserve As Work 12,MAP_SIZE
LAYER2_BASE = Start(12)

These "arrays" are byte sized, so each element can store values between 0 and 255, so you can encode up to 256 different elements traps, keys, objects, quests, etc.) in each array.  If you need more values, you can make each two bytes in size, but here I show the one byte version.

You can write procedures or subroutines to get and set data in the memory bank much like you use an array:

Code: [Select]
Procedure GET_LAYER0[X,Y]
   Shared LAYER0_BASE,MAP_WIDTH,MAP_HEIGHT

   ' Check that we are within the array bounds
   If X<0 Or X>MAP_WIDTH Or Y<0 Or Y>MAP_HEIGHT
      RESULT=-1
      Pop Proc
   EndIf

   ' Compute the memory address of the X,Y location
   ADDRESS=LAYER0_BASE+Y*MAP_WIDTH+X
   RESULT=Peek(ADDRESS)
End Proc[RESULT]

Procedure SET_LAYER0[X,Y,VALUE]
   Shared LAYER0_BASE,MAP_WIDTH,MAP_HEIGHT

   ' Check that we are within the array bounds
   If X<0 Or X>MAP_WIDTH Or Y<0 Or Y>MAP_HEIGHT
      RESULT=-1
      Pop Proc
   Else
      RESULT=0
   EndIf

   ' Compute the memory address of the X,Y location
   ADDRESS=LAYER0_BASE+Y*MAP_WIDTH+X
   Poke(ADDRESS,VALUE)
End Proc[RESULT]

You can use these like:

Code: [Select]
' Set 10,20 to a value of 34
SET_LAYER0[10,20,34]
' Get the value of 10,20
GET_LAYER0[10,20]
' After the procedure, the value is stored in a system variable called Param.
VALUE=Param

If you do things this way, you'll save a huge amount of memory (3 MB vs 12 MB for your 3 layers) and you can also use the Save and Load commands to save your layer data to disk and reload it next time.  No is need for a secondary file for this purpose.
Logged
- Sidewinder

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Problem with AMOS compiler
« Reply #21 on: May 31, 2015, 06:23:26 PM »

Thank you so much! I love this suggestions a lot! I am going to try it right away. What if say I wanted more than 255 items?
Logged

Sidewinder

  • Forum Mod
  • A600
  • *****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • http://www.liquido2.com/
Re: Problem with AMOS compiler
« Reply #22 on: May 31, 2015, 09:52:49 PM »

Sure, if you need more than 255 items you can use 2 bytes per element which limits you to 65535 items.

The basic setup is the same, but you'll need to allocate double the space:

Code: [Select]
' Allocate Layer0 array
Reserve As Work 10,MAP_SIZE*2
LAYER0_BASE = Start(10)

Then, when you set and read elements in your procedure or subroutine you'll want to use Deek and Doke instead of Peek and Poke and multiply the address calculation by 2 before adding to the base address:

Code: [Select]
Procedure GET_LAYER0[X,Y]
   Shared LAYER0_BASE,MAP_WIDTH,MAP_HEIGHT

   ' Check that we are within the array bounds
   If X<0 Or X>=MAP_WIDTH Or Y<0 Or Y>=MAP_HEIGHT
      RESULT=-1
      Pop Proc
   EndIf

   ' Compute the memory address of the X,Y location
   ADDRESS=LAYER0_BASE+(Y*MAP_WIDTH+X)*2
   RESULT=Deek(ADDRESS)
End Proc[RESULT]

Procedure SET_LAYER0[X,Y,VALUE]
   Shared LAYER0_BASE,MAP_WIDTH,MAP_HEIGHT

   ' Check that we are within the array bounds
   If X<0 Or X>=MAP_WIDTH Or Y<0 Or Y>=MAP_HEIGHT
      RESULT=-1
      Pop Proc
   Else
      RESULT=0
   EndIf

   ' Compute the memory address of the X,Y location
   ADDRESS=LAYER0_BASE+(Y*MAP_WIDTH+X)*2
   Doke(ADDRESS,VALUE)
End Proc[RESULT]

So if you did this for all three layers they would take up 6 MB.  Still a substantial memory savings.  Also, you can mix and match sizes, for instance, if layer0 only needs 255 values and layer1 needs 65535 values, you can make layer0 one byte and layer1 two bytes.

There is a further enhancement that is possible that allows you to still use normal arrays, but store more than one value in each element location using bitmasks.  It's a bit more complicated, but it may be of interest.  Let me know if you'd like me to explain it.

And also note that the bounds checking test had an error in it in my first post.  It has been corrected in this one.  If you can ensure that you're not going to go out of bounds you could remove these tests for a bit of extra speed in a release version of your code.
Logged
- Sidewinder

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Problem with AMOS compiler
« Reply #23 on: June 01, 2015, 03:07:45 AM »

Thank you so much for your help :) Today I am going to make a copy of my original code and revise the new code with these changes. If everything works exactly the way I wanted it to work and it actually works :) I will post the new .exe here for people to play with it. I am hoping I will see the Fast RAM mostly affected and the chip RAM remains high in number when I quit the program :)

If storing map size and items in fast RAM it liberate me to make a decent size RPG game :D
Logged
Pages: 1 [2]   Go Up
 

TinyPortal 2.2.2 © 2005-2022