Jump to content
Bones-69

RXB - Rich Extended Basic

Recommended Posts

Having an assembly search is useful, but don't get rid of the hardware check - you want the COINC(ALL) functionality sometimes.

Normally in a game, the programmer is less often asking the system "which two sprites collided?" and more often asking did sprite A (the player) hit any of a range of other sprites (enemies). The former could include things the software doesn't care about, like overlapping enemies.

 

So maybe something like COINC(player_sprite, first_enemy_sprite, last_enemy_sprite) - check by coordinates whether player collided with any of the enemies (in sequence), and return the first hit. That might be more useful?

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

As Lee pointed out, CALL COINC(ALL) detects when pixels on any pair of sprites overlap. Without using ALL you would have to use the sprite row and column to determine whether sprites are touching.  But you also must know something about the shape of the sprites. If you have two sprites are a single pixel then they only have to miss by one pixel. If they are 8 pixel squares then they have to miss by 8 pixels at least. If the sprites were 8 pixel diagonal lines and moving at 45 degrees, in one direction a 1 pixel offset would cause them to miss, but moving the other way they would have to miss by 8 pixels.

Not only that, but if all 28 sprites are touching, CALL COINC(ALL) will return -1 the same as if only 2 were touching.

So this is not a trivial task.

  • Like 2

Share this post


Link to post
Share on other sites
3 hours ago, Lee Stewart said:

 

Well—The thing about CALL COINC(ALL,numeric-variable) is that it relies on the VDP handling whether any two sprites have collided and only needs to read the VDP status register to find out. Any other hits involve reading the Sprite Attribute Table in VRAM for each sprite of interest and, then, making calculations, all of which take a lot more time. One use of checking the coincidence flag is to avoid checking for which sprites collided when the coincidence flag says none did. Of course, one problem with this is that a TRUE coincidence flag means two or more sprites overlap, but you do not know by how much until you check and, if your tolerance is large enough that a hit can happen without actual overlap, the hit could be missed. I suppose a programmer would be unlikely to compose such a scenario, so checking the flag first can still be the best procedure.

 

I am thinking, too, that a programmer is not interested so much in how many sprites have collided, but, rather, whether a particular pair have collided or a particular sprite has collided with a spot (wall?) on the screen.

 

Regarding CALL COLLIDE(ALL,numeric-variable,numeric-variable), it would probably be useful to read the entire Sprite Attribute Table (128 bytes) and deal with the sprite positions from that RAM table. I would think it best to check for the number of active sprites by looking for the lowest numbered sprite with y = >D0. This way, you would not be checking 28 sprites for coincidence when only 5 are in play.

 

I’ll stop rambling for now.

 

...lee

Yea thought of that as you check and look for the >D0 and stop there, as for checking the tolerance and collisions in Assembly it keeps them in RAM from VDP

so only has to read them once never ever has to write to VDP as the checking is in scratch pad. The 28 sprites row and columns are read into FAC and ARG and compared in assembly using 8 registers. 28 words at most need to be compared for overlap of tolerance. That should be pretty quick.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Tursi said:

Having an assembly search is useful, but don't get rid of the hardware check - you want the COINC(ALL) functionality sometimes.

Normally in a game, the programmer is less often asking the system "which two sprites collided?" and more often asking did sprite A (the player) hit any of a range of other sprites (enemies). The former could include things the software doesn't care about, like overlapping enemies.

 

So maybe something like COINC(player_sprite, first_enemy_sprite, last_enemy_sprite) - check by coordinates whether player collided with any of the enemies (in sequence), and return the first hit. That might be more useful?

 

CALL COINC is still there I just add an assembly version to speed it up, as currently it is written in GPL only.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, senior_falcon said:

As Lee pointed out, CALL COINC(ALL) detects when pixels on any pair of sprites overlap. Without using ALL you would have to use the sprite row and column to determine whether sprites are touching.  But you also must know something about the shape of the sprites. If you have two sprites are a single pixel then they only have to miss by one pixel. If they are 8 pixel squares then they have to miss by 8 pixels at least. If the sprites were 8 pixel diagonal lines and moving at 45 degrees, in one direction a 1 pixel offset would cause them to miss, but moving the other way they would have to miss by 8 pixels.

Not only that, but if all 28 sprites are touching, CALL COINC(ALL) will return -1 the same as if only 2 were touching.

So this is not a trivial task.

Thanks I was thinking of CALL COLLIDE(ALL,tolerance,numeric-variable,numberic-variable) only returns the first collision of sprites and which ones.

Another way is

CALL COLLIDE(#1,#5,tolerance,numeric-variable,numberic-variable,#4,#8,tolerance,numeric-variable,numberic-variable,#2,#6,tolerance,numeric-variable,numberic-variable,#3,#7,tolerance,numeric-variable,numberic-variable) ! this would be for 4 sprites used checking all 4 corners.

I would set the above tolerance to 6 to be safe.

These will be in Assembly as currently CALL COINC and other sprite commands are all in GPL currently.

Share this post


Link to post
Share on other sites

Just ran a test you can do yourself for RXB 2021 vs Extended Basic 110 vs XB 3:

XB             14 Minutes 14 Seconds

XB 3          12 Minutes   6 Seconds

RXB 2021    7 Minutes   0 Seconds

 

XB and XB 3 Program:

10 MNUM=99

100 CALL CLEAR
110 OPEN #1:"CLOCK"
120 INPUT #1:A$,B$,C$
130 FOR C=1 TO 10000
140 DISPLAY AT(23,14)SIZE(2):USING "##":MNUM
150 NEXT C
160 INPUT #1:D$,E$,F$
170 PRINT A$,D$:B$,E$,C$,F$
180 END

 

RXB 2021 changed line 140 to CALL HPUT(23,16,"  ",23,16,MNUM)

Thus even using two RXB 2021 HPUT in one single command is faster than USING image and DISPLAY AT(row,col)

Share this post


Link to post
Share on other sites

Hi,

 

for the use of TiCodEd with RXB 2021 store the attached package file in the LIB directory of TiCodEd. It declares all additional subroutines as "internal", as otherwise an "Subroutine not found" Error would occur.

 

Just select this package in the Project-Tab when using RXB 2021.

 

Steve

 

RXB 2021.xbpkg

  • Like 3

Share this post


Link to post
Share on other sites

 

Thanks Senior_Falcon, that did the trick.

 

FWIW - Windows 10, has a nice stop watch function built in.

 

image.thumb.png.60a4c3a81de2c8402af3e4299826e4d0.png

 

a dumb loop of:

image.png.50db517bf7f86be4b39d9a49145312bb.png

 

29.9 Sec with 'CALL HPUT'

 

vs print I

1:38.78

 

vs display at(10,10):I

59.35

 

Nice!

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Just install a new Character set in RXB 2022 that replaces the one used since 2015.

Notices the need for change as in some game there was no pixel between outside of one and the next if using a full block.

Share this post


Link to post
Share on other sites
On 12/29/2021 at 3:01 PM, dhe said:

I looked at the docs for hput, and I think this should be correct?

image.png.81f2cc730273322e7acf18e16f3c5c26.png

 

Per:

image.png.083018c44b55ea6147e1d001e201da81.png

Are you missing ROM 3 from the RXBC.bin?

Share this post


Link to post
Share on other sites
On 12/30/2021 at 1:41 PM, dhe said:

 

Thanks Senior_Falcon, that did the trick.

 

FWIW - Windows 10, has a nice stop watch function built in.

 

image.thumb.png.60a4c3a81de2c8402af3e4299826e4d0.png

 

a dumb loop of:

image.png.50db517bf7f86be4b39d9a49145312bb.png

 

29.9 Sec with 'CALL HPUT'

 

vs print I

1:38.78

 

vs display at(10,10):I

59.35

 

Nice!

 

 

 

On 12/30/2021 at 1:41 PM, dhe said:

 

Thanks Senior_Falcon, that did the trick.

 

FWIW - Windows 10, has a nice stop watch function built in.

 

image.thumb.png.60a4c3a81de2c8402af3e4299826e4d0.png

 

a dumb loop of:

image.png.50db517bf7f86be4b39d9a49145312bb.png

 

29.9 Sec with 'CALL HPUT'

 

vs print I

1:38.78

 

vs display at(10,10):I

59.35

 

Nice!

 

 

Just ran it again in Classic99 have no clue how yours could be so slow as RXB CALL HPUT is ASSEMBLY whereas DISPLAY AT(row,col) is GPL.

 

I use the clock built into Classic99 to time my loops:

  • River Patroller
  • pip_rank_joysticks_7.gif
  • 4,764 posts
  • Location:Vancouver, Washington, USA

Just ran a test you can do yourself for RXB 2021 vs Extended Basic 110 vs XB 3:

XB             14 Minutes 14 Seconds

XB 3          12 Minutes   6 Seconds

RXB 2021    7 Minutes   0 Seconds

 

XB and XB 3 Program:

10 MNUM=99

100 CALL CLEAR
110 OPEN #1:"CLOCK"
120 INPUT #1:A$,B$,C$
130 FOR C=1 TO 10000
140 DISPLAY AT(23,14)SIZE(2):USING "##":MNUM
150 NEXT C
160 INPUT #1:D$,E$,F$
170 PRINT A$,D$:B$,E$,C$,F$
180 END

 

RXB 2021 changed line 140 to CALL HPUT(23,16,"  ",23,16,MNUM)

Thus even using two RXB 2021 HPUT in one single command is faster than USING image and DISPLAY AT(row,col)

 

 

Share this post


Link to post
Share on other sites

RXB 2022 DEMO 9

Example: PRINT VAL(">2000) would print 8192

               CALL PEEK(VAL(">2000"),A,B) would peek at 8192 in RAM lower 8K

 

RXB 2022 DEMO 9 - YouTube

  • Like 2

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.
Note: Your post will require moderator approval before it will be visible.

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...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...