Ultimate Amiga

Please login or register.

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

Author Topic: Keep getting an illegal function call  (Read 4159 times)

0 Members and 2 Guests are viewing this topic.

Brick Nash

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 83
  • Generic Amiga User
Keep getting an illegal function call
« on: October 02, 2017, 10:26:48 AM »

I've been trying to write my own sprite image grabber. Hungry Horace very kindly let me see some code of one that he did and it was most helpful, but in the interest of learning I decided to try a more basic one myself using a FOR loop and a Get Sprite command rather than just copy, paste and hope for the best.

I have an iff of a sprite sheet which has frames exactly 80 x 80. There are 8 columns and 12 rows adding up to 96 frames, but actually 93 as the last 3 frames are blank.

I wrote a piece of code which would loop 93 times (one for each frame), and each loop the two X coordinates would move right by 80 pixels from their last position. When it reached column 8 in each row, the X coordinates would reset and the two Y coordinates would move down 80 pixels. This would repeat until the last frame was reached.

I think I have everything ok but I keep getting an illegal function call at the "Get Sprite" command, so I'd be grateful if someone could tell me what I'm doing wrong.

PS, even though I didn't get it working, this is quite good fun! :)

Thanks.

Code: [Select]
Screen Open 3,640,960,64,Lowres
Auto View Off
Screen Hide 3

I=1
'P=0
ROWCOUNT=0

Load Iff "DH1:double dragon/sprite sheets/billy/billy 80 x 80.iff"

For C=1 To 93

  ' Starting point

  If C=1
     LX=0 : TY=0 : RX=LX+80 : BY=TY+80
  End If

  ' Shift right every loop

  If C>1 and C<94
     ROWCOUNT=ROWCOUNT+1
     I=I+1
     LX=LX+80 : TY=TY : RX=LX+80 : BY=BY
  End If

  'Step down one row every 8th loop (8th frame)

  If ROWCOUNT>8
     LX=0 : TY=TY+80 : RX=LX+80 : BY=TY+80
     ROWCOUNT=0
  End If

Get Sprite 3,I,LX,TY To RX,BY

Next C
Logged

KevG

  • A600
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 87
Re: Keep getting an illegal function call
« Reply #1 on: October 02, 2017, 04:19:45 PM »

Hi there.

Does your AMOS config file allow for 93 images? You may have to adjust it as I think the default is a little lower.

Hope that helps. Kev G
Logged

Brick Nash

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 83
  • Generic Amiga User
Re: Keep getting an illegal function call
« Reply #2 on: October 02, 2017, 06:02:44 PM »

Thanks for the reply KevG.

I got it working as I had to reduce the frames due to a miscalculation so it's 91 now, although I'll probably need to look at what you mentioned anyway.

In the meantime I have a new issue now. The frames are being chopped and grabbed but they are all slightly off from each other.

They are positioned perfectly within the grid on the .iff image as I did it manually (and it took ages to do) but they seem to be grabbed just few pixels off here and there and the weird thing is that it appears to be at random. As far as I can see it's not the grabbing calculations which seem to be off, otherwise it would be one pixel off in one direction sequentially. Rather it's one pixel down then two pixels back or one up and so forth.

I'm not great at even basic maths but I can't see what's causing this. The hot spot is manually set to be at the bottom of the image when being grabbed but I can't see how it would throw it off a few pixels in all directions so randomly.

I checked the .iff image 4 times and all the frames are positioned perfectly, plus all the grabbing variables are set set to values of 80 so I'm stumped as to why it's so randomly jittery by just a couple of pixels.
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: Keep getting an illegal function call
« Reply #3 on: October 02, 2017, 06:27:56 PM »

Are you using widths that are a multiple of 4/8/16 etc? (i forget which one it needs to be)

Any chance of sharing the code and iff file?
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

Brick Nash

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 83
  • Generic Amiga User
Re: Keep getting an illegal function call
« Reply #4 on: October 02, 2017, 07:19:57 PM »

It's ok I found the problem. The iff file wasn't saving correctly out of PPaint and the program was using an old image where the frames weren't positioned correctly. Not sure why it wasn't saving but it's appears to be ok now.

The frames seem to work at 80x80 too. I know that multiples of 16 are preferred (for sprites I think) but it seems to be all good.

Thanks for the help folks! :)
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022