Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Help Creating collision/boundary system

Reply to topic
Author Message
  • Joined: 08 Sep 2018
  • Posts: 270
Reply with quote
Help Creating collision/boundary system
Post Posted: Wed Sep 12, 2018 6:20 pm
I'm making a game for the sms using GSL for scrolling. I'm wondering if anyone has any helpful tips on creating boundaries. I'm programming it all in asm and I'm pretty slow at it so any help would be greatly appreciated.
currently with the player, I keep track of which direction she's facing in as well as her x and y position on the map.[/img]
output-04.png (9.13 KB)
output-04.png

  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Post Posted: Wed Sep 12, 2018 7:23 pm
You need to decide if the tile the player is moving into is a barrier or not, and if it is, decrease their movement until the target tile is passable. Ideally you'd store the barrier information within the map data itself, but I'm not sure how much GSL helps with that.
  View user's profile Send private message Visit poster's website
  • Joined: 08 Sep 2018
  • Posts: 270
Reply with quote
Post Posted: Fri Sep 14, 2018 1:25 am
Thanks for the reply, i had nearly forgotten about the 3 unused most significant bits for meta tiles. Ive set that up, however Im currently trying to set up a routine to read that information from tiles. Psidum has done an amazing job on the library but some things are still a bit obscure or just plain not explained very well in the provided asm demo and documentation. He has a tile lookup function built into GSL but its not clear on if the X and Y parameters are relative to pixels on the entire map or pixels on screen.

At this point im at experimentation and debugging but was hoping someone who is also experimenting with the library has any input, or if someone had a different method all together with handling boundaries.
  View user's profile Send private message
  • Joined: 04 Jul 2010
  • Posts: 542
  • Location: Angers, France
Reply with quote
Post Posted: Fri Sep 14, 2018 3:26 am
I'm using the 3 unused bits on my Rick Dangerous Port.
(but not using Psidum's lib)

unsigned int map_address;
unsigned char map_value;

void col_map(){
__asm
ld hl, (#_map_address)
inc hl //msb only
ld c, #0xBF
out (c), l
out (c), h
in a, (#0xBE)
and #0xF0 // keep only 3 unused bits
ld (#_map_value),a
__endasm;
}

to test a tile :
map_address = 0x3800 + your_offset //set your vram address
col_map(); //value will be stored in map_value variable

Also, i've made an "alternate" spritesheet to see/adjust the (real) sprite limits.
Map is made in Tiled, with a specific collision layer

  View user's profile Send private message
  • Joined: 08 Sep 2018
  • Posts: 270
Reply with quote
Post Posted: Sat Sep 15, 2018 4:09 am
Interesting, i applied your code into mine and though its very similar yours does some things that are far more optimized than mine.
It works but GSL doesnt interface to it well. I sent a message to Psidum to see if he could clearify on how GSLs metatile address lookup function works, and if i can figure that out ill be able to set up the rest just fine.
so far from what i know, the Metatile Lookup Function returns an address of a metatile entry in the scroll table.(a bit complex but basically i think it gives me an indirect reference to a metatile from the scroll table or "game map")
If i can use this to obtain a metatile's raw data then i can tell if an individual tile from there has any extra information within its 3 most significant bits.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14744
  • Location: London
Reply with quote
Post Posted: Sat Sep 15, 2018 5:12 am
You could just take the metatile index itself and use that as an index into your own table of metadata, to get more than 3 bits.
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 273
Reply with quote
Post Posted: Sat Sep 15, 2018 5:17 pm
Hello
Does the example code work as intended, considering the buffering when reading from vram? And you are masking with $F0, 3 bits would be $E0. Reading from vram for collision tests has the disadvantage that interrupts have to be disabled for them, which could get in the way if you want to do graphics effects using line interrupts for example.
  View user's profile Send private message Visit poster's website
  • Joined: 08 Sep 2018
  • Posts: 270
Reply with quote
Post Posted: Sat Sep 15, 2018 7:13 pm
Hey Martin, i havnt tested the current code again yet even with maxims added advice. As far as $F0 for that logical AND goes, i use $E0 instead but some devs may just never use the priority bit so technically in that case $F0 will still work.
Im not nor do i plan on doing any graphical effects that use line interrupts so ive not been disabling interrupts during vram access, however it probably would not hurt or may even provide more stable results to disable it for the access period. If it does, that might be something other devs should take note on in the future.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!