Jump to content
Sign in to follow this  
Fadest

RSETOBJ/RGETOBJ questions

Recommended Posts

I have some questions about those 2 functions.

 

First, my goal was to make a picture move on screen.

I modified _RAPINIT.S and _RAPAPP.S to declare list and load picture (not sure if there is another way of doing it with RBASIC ?)

With RSETLIST, I'm able to display the pic.

 

I did not notice RSETOBJ and RGETOBJ functionnality, so I started to look into basic68.s.

Please note that my asm knowlege is somewhere between 0 and nothing... In fact, I can understand if I try a bit (and because source code is really well commented).

 

For fun and in order to better understand how it works, I added a new token to add a setpos functionality (take an index, x & y new position). This was working quite well but I discovered RSETOBJ that was doing quite the same thing but in a more versatile way (can access to every single element of the list, whereas I was using sprite_x and sprite_y).

 

RGETOBJ is defined like this :

RGETOBJ(x,y)

This returns the RAPTOR Object field value for Object (x), offset (y) - For a list of offsets please consult the RAPTOR documentation

 

First, I thought that offset for sprite_x would be 2 and that I would get back a long with the 16.16 x value. This was not the case.

 

After some try, mistakes and retry (and using memory debug) the offset for sprite_x is 8, because the offset is a number of bytes to add to the starting point. No problem : as elements are defined in long, we have to multiply the position of the element by 4 in order to have the index.

 

Don't you think that it would be more easy to understand RGETOBJ, RSETOBJ for beginners if these functions multiply the index by 4 as they return/take a long and not a byte ?

 

 

 

 

OK..... patch welcome.

I guess that this could be something like this in both functions :

 

move.l r_offset,d0 ; FADEST++
mulu #4,d0 ; FADEST++
add.l d0,a0 ; FADEST++
; add.l r_offset,a0 ; FADEST--

But of course, this can be optimized with a bit decalage (don't know the token in ASM)...

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Ok, the reason they don't do a mult is because I intend to pre-load all the offsets as variables before starting RBASIC, so you will be able to RSETOBJ(obj,XPOS,value) or RGETOBJ(obj,hitpoint). I just haven't done that yet

 

Also, you should avoid MULU and DIVS whenever possible. For x4, just add it twice, or left shift twice ;)

 

I really need to work on some documentation for RBASIC, but right now I'm still expanding it's functions and commands and working on optimization.

 

The next version will probably not have the 68k.s file open, there will most likely just be an RBASIC.O file to link against.

Edited by CyranoJ

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...