VDP-Read as collision detection (Development MSX Fora)MSX Resource Center PassionMSX MSX2 contest           
            
English Nederlands Español Português Russian         
 Nieuws
   Voorpagina
  Nieuws archief
  Nieuws onderwerpen

 Informatie
   MSX Fora
  Artikelen
  Recensies
  Beursverslagen
  Fotoreportages
  Beurzen en meetings
  Enquêtes
  Links
  Zoek

 Software
   Downloads
  Webshop

 MRC
   Wie we zijn
  Kom bij ons team
  Doneren
  Policies
  Contact met het MRC
  Link naar Ons
  Statistieken

 Zoek
 
  

  

 Login
 

Gebruikersnaam

Wachtwoord




Ben je nog niet lid? Klik hier en word MSX vriend!


 Statistieken
 

Er zijn 98 gasten en 5 MSX vrienden online

Je bent een anonieme bezoeker.
 

MSX Fora


MSX Fora

Development - VDP-Read as collision detection

Schrijver

VDP-Read as collision detection

norakomi
msx professional
Berichten: 861
Geplaatst: 25 Februari 2006, 22:43   
Hi there !!
I'm using a routine to check if the ship and the bullets hit a wall.
However, this routine is not 100% accurate (sometimes you die when you fly very close to a wall)
Maybe this is because r#18 (horizontal screen offset) and r#23 (vertical screen offset) are used on VBLANK and at the linesplit (y=20) this routine.
Also the page is switched every 16 steps.
The sprites are 16x16 and I want the collision detection to occur exactly in the middle of the sprite.

This is my routine, I would love some help to perfect it, or speed it up !!! THANX !!
CollisionCheck:                ;collision with foreground check

;set X-coordinate
        LD      A,(vdp_8+10) ;horizontal screen offset
        ADD   7 
        AND   15
        RRA                           ;devide by 2
        LD     B,A                   

        LD     A,(X_coord)      ;x coordinate of whatever needs collision detection
        RRA                           ;devide by 2 (screen 5 is used, and 2 pixels are defined in 
        ADD   B                      ;1 byte, so devide by 2)
        LD     L,A                   ;store X

;set y-coordinate
        LD      A,($F3E1)        ;current page
        AND   %00100000    ;check which page is displayed (0 or 1?)
        RLCA                         ;page 1? then a=128, page 0? then a=0 
        RLCA                         ;add 128 bytes to y-coordinate when page 1 is used 
        LD      C,A

        LD    A,(vdp_8+15)    ;vertical screen offset
        LD    B,A

        LD     A,(Y_coord)      ;y coordinate of whatever needs collision detection
        ADD   B                      ;add vertical screen offset
        RRA                           ;devide by 2 (screen 5 is used, and 2 pixels=1 byte)
        ADD   4                      ;chech the middle of this sprites Y
        ADD   C
        LD     H,A                   ;store Y
        CALL  VDPREA           ;now check the color value at these coordinates
        IN    A,($98)
        AND   15                    ;color from 0-15

        SUB   4                      ;color=>4 ?
        RET   C
 	YOU  DIE !!
 


ARTRAG
msx master
Berichten: 1592
Geplaatst: 26 Februari 2006, 02:25   
Actually ising colors is a very bad limitation !!!

This implies that you have to reserve teh first colors to the background and that you
cannot reuse background colors in the main layer!

Probably the best thinh should to use a direct access to teh "map" of tiles you have
in ram tarher that reading vram.

It is less accurate (as each collision happens lokking at the tile as a single object)
but you can use all the colors everywhere you like on the screen


norakomi
msx professional
Berichten: 861
Geplaatst: 26 Februari 2006, 09:39   
Quote:

Actually using colors is a very bad limitation !!!

This implies that you have to reserve teh first colors to the background and that you
cannot reuse background colors in the main layer!

true, but thats no problem for me.
I'm always using different color in the background/foreground.
Quote:

Probably the best thing should to use a direct access to the "map" of tiles you have in ram rather that reading vram.

Ok, but I have no "map" nor "tiles".
I'm just using screen 5 copies. 16 big copies in 16 steps. No tile copies used. No "map" used.
Quote:

It is less accurate (as each collision happens lokking at the tile as a single object)

And thats the problem.
Vertically speaking the collision detection is perfect, looking at exactly the middle of the sprite.
Horizontally speaking I want the collision detection to be pixel accurate, but it's not.
Sometimes the right edge of the sprite detects the collision, sometimes the left edge. And I want the exact middle of the sprite to detect collision.

I presume it has to do with page switching and r#18 (jumping whole screen 16 pixels to the right).
How should I take the fact that r#18 and the current page is set at lineint in account???
The collision detection is outside of the interrupt.....
 
 







(c) 1994 - 2008 Stichting MSX Resource Center. MSX is een trademark van MSX Licensing Corporation.