Ultimate Amiga

Please login or register.

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

Author Topic: Bug in the code....  (Read 2958 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
Bug in the code....
« on: October 06, 2013, 05:14:13 AM »

I have a major bug in the code and I cannot for the like of me know how to solve the problem. When I put the two dots to each other they suppose to form dots in a square form but when two dots are close to each other I can go diagonal and thus resulting in a line forming diagonal instead of a straight line either left to right, right to left, up to down or down to up...I do not know what to do with this problem. I tried so hard to solve the problem but AMOS does not have NewType method that Blitz Basic 2 have which make things way easier for me...anyone can shed light on this matter? I have attached the source code here.

Thanks in advance.

Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 946
  • Compile-time wierdo
Re: Bug in the code....
« Reply #1 on: October 07, 2013, 03:44:09 PM »

The equivalent of the NewType setup in Amos is the Bank system.  Using a work bank for each board will allow you to do a tilemap more quickly than an array will do on a 16-bit Amiga.  The trick is that you have to use Deek and Doke to access the memory addresses in the bank instead of array lookups.  The advantage is that Deek and Doke store numbers as 16-bit integers instead of 32-bits.

--edit--
I forgot to tell you the formula to do an array lookup:  offset=x+y*width will do the offset of a 2d array in a linear address space such as a bank.  Then, depending on the maximum number of tiles, you can do a tilenum=Peek(offset+boardstart) where boardstart is the start address of the bank, or if you do 16-bit tiles, the formula will be tilenum=Deek(offset+offset+boardstart) since each element will have a width of 2 bytes.  (Adding offset to itself is much faster than multiplying by 2 even though AmosPro does bit-shift optimization in its compiler.)
« Last Edit: October 07, 2013, 03:52:57 PM by SamuraiCrow »
Logged

xboxisfinished

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 205
  • Generic Amiga User
    • gamemakermagazine.com
Re: Bug in the code....
« Reply #2 on: October 07, 2013, 04:37:39 PM »

Thank you so much for the help! I like it when my code is all complex and commodore like...even though no one is going to see it :D It is fun coding in AMOS and Blitz Basic heheh....

Anyways I decided to go even in a more funner approach instead of doing mouse click I decided to do keyboard interaction. Instead of using the mouse to click on a plot you move the cursor using the keyboard arrows then pressing space bar to plot the dot...of course it is in a very early stage....it still needs more work done on it...but I have attached here the program for you to try it out...check it out :D

Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Bug in the code....
« Reply #3 on: October 07, 2013, 11:33:44 PM »

Quote from: SamuraiCrow
The equivalent of the NewType setup in Amos is the Bank system.  Using a work bank for each board will allow you to do a tilemap more quickly than an array will do on a 16-bit Amiga.  The trick is that you have to use Deek and Doke to access the memory addresses in the bank instead of array lookups.  The advantage is that Deek and Doke store numbers as 16-bit integers instead of 32-bits.
A few traps for new players with AMOS Banks and memory access:
Peek and Poke   No problems
Deek and Doke   The address MUST be aligned to a word boundary.  That is, you can't use them on odd addresses, only on even ones.
Leek and Loke   Same as for Deek and Doke - must be word-aligned

So if you're using a mixture of bytes, words and longwords in each element of your memory bank 'array', you may need to use one or more padding bytes to ensure word-alignment.  Just the same as when you're declaring memory storage in assembler except the Assembler usually does that for you without telling you!  Easy to forget.  ;)

Also note:
When you allocate a Memory Bank, it is guaranteed to start on a word boundary and AMOS clears the allocated memory to zeroes.  So there's no need to check for word alignment or clear the memory yourself.  Of course, if you need to clear the whole or part of a Bank later, use the Fill start To finish, pattern instruction (but beware, all addresses MUST be even again!).

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: Bug in the code....
« Reply #4 on: October 08, 2013, 12:45:29 AM »

Hey guys what do you think of this new fixes and changes? These are the new changes and fixes:

- Fixed when the select cursor goes on top of the selected dot, it causes the selected dot to disappear and become unselected visually in all directions.
- Changed the missed message to a scrollable text on the bottom of the screen.

These are what I want to do before releasing another alpha version here:
-Add the ability to have turns between player 1 and player 2
-Change color of selected dot based on player 1 (red) and player 2 (blue)
-Fix the bug so that player 1 and player 2 cannot select diagonally and if the player selects diagonally the game warns the player and the player have to try again with a valid move
-Add a feature where ones the player selects a dot on the grid he or she must select the next dot adjacent either right, left, down or up to the first selected dot
-Ones two points of dots have being selected the program instantly forms a line between the two dots
-Change color of turn and the player 2 also forms a line when two dots are met
-Execute the scrollable text

That is all for right now in terms of features...ones I do that and do bug fixes I will release another alpha version here as well for you guys to try it out. What I want though from you guys is your input, opinion and advice as I move on with a new release. I want your opinion for making the program better, opinion in interface and ideas in the game and so on :)
« Last Edit: October 08, 2013, 12:48:27 AM by xboxisfinished »
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022