It is currently Mon Dec 11, 2017 12:09 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Sun Jan 29, 2017 6:39 am 
Offline

Joined: Sun Jan 29, 2017 6:30 am
Posts: 5
Hi all,

I am working on a nes emulator from scratch (mainly for learning purposes) in javascript. I have build the cpu allready (it's seems to be Ok and have passed a few test for llegal opcodes); i have build the ppu too (almost 80%), and some games are fully playable right now (like Donkey Kong). But I have found some extrange behaviour in some games like 'Mario Bros' (not 'Super Mario Bros') or 'Pac-Man'. All seems to work properly, but the sprites (Mario and turtles), falls without collides with the background. I have check the sprite 0 hit collision on PPUSTATUS register and it's set to 0x40 (six bit) when a collision is detected between sprite and background (I have force the collision bit on this register all the time for test purposes, but nothing changes)... I wonder if there is another collision system / register that I am not implementing or if my sprite 0 hit collision is not implemented correctly.

I am stuck on that right now, any help will be appreciated.

Thanks in advance,

Regards,


Top
 Profile  
 
PostPosted: Sun Jan 29, 2017 7:36 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Besides the sprite 0 hit, which is used exclusively for synchronizing the CPU and the PPU for raster effects, having nothing to do with in-game object collisions, the NES doesn't have any collision-related features.

AFAIK, all games handle collision entirely in software, meaning that there must be something wrong with your CPU emulation. I suggest logging all executed instructions and comparing the log to that of an emulator where the game works, so you can identify when things go wrong.


Top
 Profile  
 
PostPosted: Sun Jan 29, 2017 7:43 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
Make sure that you have correctly implemented nametable reads (via $2006/$2007).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sun Jan 29, 2017 8:02 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
Yes, it's possible that a game uses the name table data previously written to VRAM for collisions against the background, instead of a map in CPU RAM or ROM. Don't forget that reads from $2007 are buffered, so the CPU doesn't immediately get the byte from VRAM, it gets the buffered byte and the actual data from VRAM is buffered for the NEXT read. This is true for all of VRAM/ROM except for the palette RAM, which returns values without any delay (on PPUs that support pallets read back, early revisions didn't).

EDIT: I might have confused palette readback and OAM readback. I'm not sure if palette readback was broken on early PPUs (I'm pretty sure that OAM readback was though), so I'm crossing that part out. It'd be nice if someone could confirm this readback deal.


Last edited by tokumaru on Sun Jan 29, 2017 12:37 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Jan 29, 2017 9:11 am 
Offline

Joined: Sun Jan 29, 2017 6:30 am
Posts: 5
Hi,

Thanks for help to solve the problem; the issue was effectively on the VRAM read (I was reading cpu memory not ppu memory which is where the background tiles are). Now all it's seems to work properly (and mario doesn't fall continously).

Thanks so much for the help!

Regards,


Top
 Profile  
 
PostPosted: Sun Jan 29, 2017 11:37 am 
Offline

Joined: Sun Jan 29, 2017 6:30 am
Posts: 5
By the way.

The trick was the buffered byte as mentioned by tokumaru; that it's seems a few more games works properly (like Pac-Man).

Thanks again,

Regards,


Top
 Profile  
 
PostPosted: Sat Feb 18, 2017 5:29 am 
Offline

Joined: Sun Jan 29, 2017 6:30 am
Posts: 5
Hi all,

I have another issue with the background collision. All seems to work great in games tested so far, but I found issues on 'Ice Climber' game; the player is falling on all the left edges of the level, as you can see in the attached picture (i add red circles on the places where player falls).

I have just implemented scroll y, but seems to work properly in the rest of the game but in the left edges.

Anyone can help?

Thanks in advance,

Regards,


Attachments:
ice_climber.png
ice_climber.png [ 49.03 KiB | Viewed 885 times ]
Top
 Profile  
 
PostPosted: Sat Feb 18, 2017 5:37 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3076
Location: Brazil
Did you test your CPU with a test ROM?


Top
 Profile  
 
PostPosted: Sat Feb 18, 2017 6:46 am 
Offline

Joined: Sun Jan 29, 2017 6:30 am
Posts: 5
Yep, I tested and It's seem all OK.

All other games (collision), tested seems to work properly (like Mario Bros).

Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group