Monday, May 5, 2014

NES Dual Port RAM Interface

UPDATE : Thanks for the great response - I'll be posting more videos throughout the week @batslyadams - I'd love to hear your ideas for ways to enhance games! Looking to livestream some development / testing this Thursday, 5/6/14.


I've been writing a game recently and was looking for a way to live debug on real hardware. The original solution was to fire variable information out the second controller port to serial every NMI but I decided to to take a shot at a new PCB for the console I've been dreaming about for a while.


The board routes the left port of the dual port RAM (Cypress CY7C136) to the DIP footprint on the NES and the right port to an AVR (ATMEGA164), this allows me to read and write any location at runtime without bus conflicts. Control is provided through the UART and two additional pins are soldered directly to the 2A03 to control /NMI and /RESET. I took a console and desoldered the 2KB RAM and replaced it with a socket. I'd like to permanently solder this in now that they work but having them removable for debugging was a huge help. AVR control code was written mainly in C with some assembly sprinkled across for the memory control portions.

The AVR sits and wait for serial commands and can perform several functions including :
* Read / write of any memory location
* Quick dump of an entire 256-byte page
* Freezing of memory addresses (rewriting a single value constantly in the busy loop)
* Single frame stepping by controlling the NMI
* Remote reset of console
* Applying auto increment to tables to a single variable (fun for sine waves on x/y positions!)

I had pretty great results with using 250000 baud with the Genesis flasher project which is plenty fast for what I'm trying to do here. Cautionary tale about using this dual port RAM part, be sure to operate the other side normally even though it appears to be decoupled. As far as I can tell from the datasheet leaving CE low shouldn't have an effect on the opposite port but it most certainly does. Next revision could definitely use a few pullups on the AVR side, other than that I'm pretty happy with the layout.

Before wiring up the additional control lines :



Pretty excited to finally use this guy - your usual USB FTDI cable except with a 3.5mm jack. Routed the UART to a standard panel mount TRS on the back of the console.

It has been a blast playing with this thing - stuff I've done so far :

Debug Information
The original intention of this was be able to manipulate values in real time on a console for a game I've been developing, FCEUX is pretty incredible for emulation but I try to do a lot of testing on real hardware.





Scoreboards
Blades of Steel used to be my favorite, but I'm starting to come around on Ice Hockey. Heavily using the read function to pull any relevant data from a game then deciding what to do with it.
Would probably be great for automatic splits for speedruns.



Relay Control
Contra has a particular way of allocating shots, there are five slots for one player that a bullet can accommodate. I didn't want to cheap out and just trigger on a button press so all five values are pulled and checked for a new rising edge.



Hex editor
Wrote a live hex editor inspired by FCEUX, lots of fun goofing with variables on the fly. Great fun to have a "co-pilot" looking for ways to help you cheat, like a manual game genie.




Single Frame Step
The /NMI pin is the 60hz interrupt generated from the PPU, this is one of the trickiest parts of the NES since this is the only safe window in which to make writes to VRAM. Due to the limited video bandwidth, the game is typically laid out the following way :

Busy loop / Wait for NMI
Falling edge of NMI / Perform VRAM updates then set flag that NMI has occured
Return from NMI / Perform logic updates / queue VRAM updates
(repeat)

On a "step" command sent from the host the AVR waits until the natural falling edge /NMI then asserts low until it receives the command for another step. This safely inhibits the interrupt and keeps everything in sync. Could also set up a frame level breakpoint here!


 


Enhanced Rules / Displays
Every game needs a place to store the controller reads after a $4016/$4017 fetch. Typically these routines will still run in a pause menu (so you'll know when to exit). The idea is that the host can read that we are in a pause state AND the controller data you can control a menu offscreen.

Remote Reset
I provided two pins for the NMI and RESET on the console, these are jumpered from the 2A03 directly to GPIO on the AVR. Both of these inputs to the CPU are open drain.

The /RESET pin allows you to command a console reset the host so you wouldn't have to fuss with the console. You can provide an argument for a short reset (10ms) to jump to reset vector within the game and a long reset (~1s) which will bring you back to the powerpak menu.



Glitch Roulette
This was a lot of fun. The idea that every time the player jumps (memory location / method of determining jumping will vary from game to game) the host will write a random value to a random location. The sound engine is usually the first to go since they typically require a good amount of RAM and are overwriting is fairly harmless. A hit on an indirect memory address/stack is usually catastrophic.

Biggest ups to Todd Bailey for the help with assembling these things and Adam Stankiewicz and Nick Gargiulo for tirelessly testing blades of steel.

280 comments:

  1. It's amazing, you can now write a kinect based game for nes ;)

    ReplyDelete
  2. I've been wanting to do this for a pinball scoreboard, using the same dual port ram chip. Do you happen to have a schematic/KiCAD files online anywhere? If not it's great to see that the idea is at least sound.

    Thanks

    ReplyDelete
    Replies
    1. if my mother board 1 or 2 pin have damaged yet it will repair. 1 Dollar Hosting and thank ;you for these informative post.

      Delete
  3. This is incredible! We've been looking for something like this. We play a TON of Blades at our office, and have even built a scorekeeper app:

    http://blades-app.herokuapp.com/

    It relies on hand-fed data though, and doesn't have any of the more advanced stats direct data would provide.

    ReplyDelete
  4. Awesome! I've been wanting to do something like this for the last 6 months or so. I was borrowing an fpga from a friend, that I was going to program to emulate the memory chip, but this is so much easier. Any chance you'll open source the AVR code?

    ReplyDelete
  5. This is awesome. Exactly what I was looking to do -- grab values during runtime. I wanted to get them, then post to an online leaderboard.

    ReplyDelete
  6. the big bang broderie Replica Watches Anglais, Bischoff, home to see the acquisition of major cooperative Mimi handbag replica ace, and 11 and Diamond Bezel contains a pattern of straps soft.Raffaelli before Ambassador, Kobe Bryant, Jay · Z, Replica handbags her footprints, including the bolt and Wade, to follow, she will attend today to the latest (maximum) Hublot flagship Replica watches UK store at 743 Fifth Avenue Surprise. (This NYFW is your schedule to add another NBA events.) Rolex Daytona .

    ReplyDelete
  7. Great to see that someone still understand how to create an awesome blog. The blog is genuinely impressive in all aspects.
    judi poker

    ReplyDelete
  8. The price of excellence is discipline; the cost of mediocrity is disappointment - William Arthur Ward

    Judi Casino
    Judi Casino Online
    Agen Casino
    Dragon Tiger
    Jadwal Bola

    ReplyDelete
  9. very nice and interesting
    http://www.sanadomino.com/

    ReplyDelete
  10. Information That Is Very Helpful and very complete, thanks for the news Greetings Dwi ^^

    Togel Online
    Agen Casino Online
    Prediksi Togel Singapura

    ReplyDelete

  11. Ayo Bergabung Bersama kami di
    http://www.Pokersemi.com
    Proses Deposit / Withdraw Super Cepat Dan,
    Didukung Oleh Costumer Service Kami Yang Ramah.
    Kami Juga menyediakan berbagai macam game dalam 1 ID :
    - Poker
    - Capsa
    - Ceme
    - Q- Kick
    - Ceme Keliling Dan
    - Live Poker
    Banyak Bonus Dan Jackpot yang akan menanti anda
    kami Juga memberikan bonus Seperti
    - Bonus New member 10%
    - Bonus Turnover 0.5% Dan
    - Bonus Refferal 20%
    Tunggu apa lagi Gan.. !!
    Buruan Daftar diri anda di
    http://www.pokersemi.com/register.php
    Anda juga bisa Hubungi CS kami :
    - Skype : Pokersemi
    - Yahoo : Pokersemi
    - Twitter : Pokersemi
    - Facebook : Pokersemi

    Poker Terpercaya
    Agen Domino
    Agen Domino Terpercaya
    Judi Poker
    Judi Poker Online
    Poker99

    ReplyDelete
  12. Thanks for sharing your information, its great and i appreciated about it!
    Judi Bola Online

    ReplyDelete
  13. presentation of the article in this blog is very nice, I like it

    Nonton Film Online
    Bioskop Online
    Nonton Online
    Bioskop

    ReplyDelete
  14. Thank You Sir, Very Good and Helpful Articles .. Update continues and always success sir

    BandarQ
    Bandar QQ
    BandarQ Online
    Poker Online
    Domino QQ
    AduQ

    ReplyDelete
  15. Your article is very useful and has real knowledge. It’s very helpful information. I will be waiting for your Agen Bola Terpercaya

    ReplyDelete
  16. Some problems are difficult to solve, but I will try. I have a part time job to cover life. Learning by doing is very tired, but it's my life.
    www.facebookbaixargratis.com.br

    ReplyDelete
  17. Good Articel and so Important topic in this page.
    Good Well.. and thanks.
    BandarQ Terpercaya

    ReplyDelete
  18. Artikelnya bagus ....kunjungi situs resmi kami juga ya http://jagobet.online/

    ReplyDelete
  19. Situs Judi Online Poker terpercaya we from the online gambling site poker reliably thank you for the information you provide

    ReplyDelete
  20. Nice writing , thankyou for sharing this article !

    agen sbobet

    ReplyDelete
  21. Very nice post.really I apperciate your blog.
    Thanks for sharing, keep sharing more blogs.

    Sbobet Casino

    ReplyDelete
  22. This is very educating post, thanks for sharing with us.
    Tips Menang AduQ
    Tips Bermain AduQ

    ReplyDelete
  23. https://situs-ikutqq.blogspot.com/
    https://ikutqqblog.wordpress.com/
    https://ikutqq.wixsite.com/agenbandarq
    https://ikutqq.wixsite.com/bandarq
    https://ikutqq.yolasite.com/
    http://ikutqq.weebly.com/
    http://agenbandarq.zohosites.com/
    http://agenbandarqonline.webs.com/
    http://agenbandarq.bravesites.com/
    http://ikutqq-blog.logdown.com/

    ReplyDelete
  24. https://daftarbandarqterbaik.blogspot.com/
    https://bandarq99.wordpress.com/
    https://bandarqq.wixsite.com/boyaqq
    https://bandarqq.wixsite.com/bandarq
    http://daftarbandarq.weebly.com/
    http://daftarbandarq.slidi.net/
    http://bandar-qq.ml/
    http://bandar-qq.ga/
    http://bandar-qq.cf/
    http://bandar-qq.gq/

    ReplyDelete
  25. Wah kami Sangat Senang Bisa Menemukan Artikel Sebagus Ini Dan Sangat Bermanfaat Sekali, Kami Menunggu Artikel Berikutnya Yah Gan.

    Poker
    Agen Poker
    Agen Poker Online
    Agen Poker Terpercaya
    Poker Online
    Poker Online Terpercaya
    Poker Terpercaya
    Poker Online Aman dan Terpercaya

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. Online Betting Games Get special privileges.

    Royal1688 Online Gambling Games Gives you the pleasure of online gambling all day. Make Money Forward with joy to us. Join the fun. Of Online Gambling At Home All the routes of enjoyment are always good services all the way through the fun as you like. This is an online casino. It is a game that has been very popular. With the opportunity to progress to good service. The bets are over. For online entertainment The fun of online gambling every day, every time, the choice of fun to take to the best opportunity. Current Online Casino Site It is a game that meets the needs of many gamers. Make fun with people who are interested in online betting all day. Online games that give a good return. Get the most out of online gambling. Get the privilege to play casino games in the entertainment you want. Enjoy the full range of gambling options available today through the website Goldclub Slo

    ReplyDelete
  29. Cuma di http://www.OTWPOKER.com
    KAMI BERI BUKTI,BUKAN JANJI.ANDA PUAS KAMI BANGGA !!!
    Segera Gabung Bersama kami di http://www.OTWPOKER.com AGEN POKER TERPERCAYA,TERBESAR dan TERBAIK DI INDONESIA dengan memberikan pelayanan 24jam nonstop dan proses deposit withdraw yang sangat cepat serta Memberikan Respon Langsung Ramah dan Sopan kenyamanan para member adalah perioritas kami yaitu keunggulan dari Kami, Segera Lakukan Pendaftaran di http://www.OTWPOKER.com dan nikmati hadiah yang didapat
    ayooo...... tunggu apa lagi, Join Sekarang bersama POKER ONLINE TERPERCAYA
    Poker Online
    Poker Online Terpercaya
    Poker Terpercaya
    Poker Online Aman dan Terpercaya
    Situs Poker Online Terpercaya
    Situs Poker Online Yang Banyak Bonus

    ReplyDelete
  30. Famous Casino Club That makes ordinary people rich.

    Gclub Slot Is a g club website Casinos are another new opportunity to play very much for people who love and fall in love playing online casino games because of the fun and opportunities for players from all over the world. Online casino games can be played at the same time, because the current online casino games can play the game, which is not the only player who is a player. Thousands loves to play the lottery online is a risk I was able to play the lottery every online form on page G Club. Our casino.

    Nowadays, online casino games can also be played on mobile phones and on the computer, the fluidity is constantly being developed, making it even more exciting to play online casino games. Play more. Players can also play online games. You can join the fun and play online gambling games all day, all night and all the time as well.

    So if you are thinking about playing the online gambling games, do not forget to choose the service with our casino gambling club only. By playing online gambling games, you can make money by playing online casino games easily. When the player is thinking about the fun of playing online gambling games, do not forget to play online gambling games with the web Holiday Palace


    ReplyDelete
  31. togel online



    I love this post it very nice and integrating post.I really enjoy to reading this article thanks for sharing this article.

    ReplyDelete
  32. yes..I like the basic concepts behind Second Life but it seems incredibly outdated and when I played it was intensely non-intuitive / user friendly to an extent that made EVE look like a game for toddlers. thanks from
    togelpelangi





    ReplyDelete
  33. Really nice post in this site..
    Domino99



    Amazing posting. I like it and keep doing goods.
    Agen Domino99



    So impresive posting like this.. Thanks sharing.
    Agen Poker

    ReplyDelete

  34. Silahkan di kunjungi ya kawan-kawan 100% Memuaskan
    > Hoki anda ada di sini <
    Bandar Q Online Terpercaya dan Teraman di GUNUNGPOKER
    Link daftar : http://bandaraduq.com/Register.aspx?lang=id
    BBM : 56978317

    SEMUA GAME HANYA PAKAI 1 USER ID : Poker, Domino QQ, Capsa Susun, Adu Q, Bandar Poker,

    Segera daftarkan userid anda di GUNUNGPOKER
    Promo Terbaru dari GUNUNGPOKER
    - Minimal DEPOSIT & WITHDRAW Rp 20.000,-
    - Tersedia 7 game dalam 1 USER ID
    - BONUS Turnover 0.5%
    - BONUS Referral 20%

    UNTUK INFORMASI SELANJUTNYA BISA HUB KAMI DI :
    LIVECHAT GUNUNGPOKER 24 JAM ONLINE
    Fanspage FB : @agengunungpoker
    Pin BB : 56978317
    WA : +62812-7287-4416
    LINE : gunungpokercsr1
    WECHAT : gunungpokercsr1
    YM : gunungpokercsr1@yahoo.com
    Agen domino
    BandarQ
    Domino 99
    Domino QQ
    Agen Poker
    Bandar Poker
    Agen Judi QQ
    Judi Online
    Forum Judi Online

    hubungi kami di :
    Line : gunungpokercsr1
    Bbm : 56978317
    Wa : +6281272874416

    ReplyDelete
  35. Thank you information that you have brought, very interesting, please visit our website
    Agen BandarQ
    BandarQQ Online
    Agen Sakong Online

    ReplyDelete
  36. This comment has been removed by the author.

    ReplyDelete
  37. Very nice and always successful.
    This is a very good article.
    I’m waiting for you the other article.
    Prediksi Togel

    ReplyDelete
  38. Very nice and always successful.
    This is a very good article.
    I’m waiting for you the other article.

    Tentang Dunia

    interesting articles and this is my first first reading a very interesting article thanks for this article that fits with the theme news.

    Prediksi Togel

    ReplyDelete

  39. Ayuk Buruan Daftar Diri Anda Di Armanitogel Dan Sekarang Sudah Ada Promo Bonus Deposit Di Armanitogel 10%, Tunggu Apalagi.
    Ayo Gabung Bersama kami Agen Togel Terpercaya

    Agen Togel Terpercaya
    Bandar Togel Online
    Daftar Togel
    Bandar Togel Terpercaya

    ReplyDelete
  40. Ayuk Buruan Daftar Diri Anda Di Armanitogel Dan Sekarang Sudah Ada Promo Bonus Deposit Di Armanitogel 10%, Tunggu Apalagi.
    Ayo Gabung Bersama kami Agen Togel Terpercaya

    Agen Togel Terpercaya
    Bandar Togel Online
    Daftar Togel
    Bandar Togel Terpercaya

    ReplyDelete
  41. Prediksi Togel Sydney Jumat 19 Januari 2018

    Prediksi Jitu Togel Sydney
    Ai : 2645
    Sydney Colok Bebas : 5
    Angka Top : 6 dan 4
    Racik dan racik : 2645 vs 7931
    Kepala : 2645
    Ekor : 7931
    Untuk Pola 2D : (2x, 6x, 4x, 5x)

    Prediksi Togel

    ReplyDelete
  42. Interesting post in this site.. Has interesting ideas and is very usefull.
    Bandar Ceme

    Ceme Online

    Ceme Terpercaya

    ReplyDelete
  43. Thank you for this helpful information, keep on providing the best information
    Agen Poker

    DewaPoker

    PokerDewa

    Bandar Ceme

    ReplyDelete
  44. Prediksi Togel Sydney Minggu 21 Januari 2018

    Prediksi Jitu Togel Sydney
    Ai : 6981
    Sydney Colok Bebas : 1
    Angka Top : 6 dan 8
    Racik dan racik : 6981 vs 2473
    Kepala : 6981
    Ekor : 2473
    Untuk Pola 2D : (6x, 9x, 8x, 1x)

    Prediksi Togel Sydney



    Prediksi Togel Singapura Minggu 21 Januari 2018

    Prediksi Jitu Togel Singapura
    Ai : 3967
    Singapura Colok Bebas : 6
    Angka Top : 7 dan 9
    Racik dan racik : 3967 vs 8241
    Kepala : 3967
    Ekor : 8241
    Untuk Pola 2D : (3x, 9x, 6x, 7x)

    Prediksi Togel Singapura


    Prediksi Togel Hongkong Minggu 21 Januari 2018

    Prediksi Jitu Togel Hongkong
    Ai : 9731
    Hongkong Colok Bebas : 1
    Angka Top : 9 dan 7
    Racik dan racik : 9731 vs 2584
    Kepala : 9731
    Ekor : 2584
    Untuk Pola 2D : (9x, 7x, 3x, 1x)

    Prediksi Togel Hongkong

    ReplyDelete
  45. Prediksi Togel Sydney Senin 22 Januari 2018

    Prediksi Jitu Togel Sydney
    Ai : 6549
    Sydney Colok Bebas : 4
    Angka Top : 6 dan 9
    Racik dan racik : 6549 vs 1327
    Kepala : 6549
    Ekor : 1327
    Untuk Pola 2D : (6x, 5x, 4x, 9x)

    Prediksi Togel Sydney


    Prediksi Togel Singapura Senin 22 Januari 2018

    Prediksi Jitu Togel Singapura
    Ai : 2376
    Singapura Colok Bebas : 2
    Angka Top : 6 dan 7
    Racik dan racik : 2376 vs 4521
    Kepala : 2376
    Ekor : 4521
    Untuk Pola 2D : (2x, 3x, 7x, 6x)

    Prediksi Togel Singapura


    Prediksi Togel Hongkong Senin 22 Januari 2018

    Prediksi Jitu Togel Hongkong
    Ai : 2397
    Hongkong Colok Bebas : 3
    Angka Top : 7 dan 9
    Racik dan racik : 2397 vs 1584
    Kepala : 2397
    Ekor : 1584
    Untuk Pola 2D : (2x, 3x, 9x, 7x)

    Prediksi Togel Hongkong

    ReplyDelete
  46. Prediksi Togel Sydney Selasa 23 Januari 2018

    Prediksi Jitu Togel Sydney
    Ai : 3128
    Sydney Colok Bebas : 2
    Angka Top : 3 dan 8
    Racik dan racik : 3128 vs 7549
    Kepala : 3128
    Ekor : 7549
    Untuk Pola 2D : (3x, 1x, 2x, 8x)

    Prediksi Togel


    Prediksi Togel Hongkong Selasa 23 Januari 2018

    Prediksi Jitu Togel Hongkong
    Ai : 5493
    Hongkong Colok Bebas : 4
    Angka Top : 5 dan 9
    Racik dan racik : 5493 vs 7218
    Kepala : 5493
    Ekor : 7218
    Untuk Pola 2D : (5x, 4x, 9x, 3x)

    Prediksi Togel

    ReplyDelete
  47. The articles you create are always interesting to watch and read is very useful. Always passion and success continues.
    Situs Togel Resmi
    daftar bandar togel resmi
    situs resmi 4d

    ReplyDelete
  48. Ayuk Buruan Daftar Diri Anda Di Armanitogel Dan Sekarang Sudah Ada Promo Bonus Deposit Di Armanitogel 10%, Tunggu Apalagi.
    Ayo Gabung Bersama kami Agen Togel Terpercaya

    Bandar Togel
    Agen Togel
    Daftar Togel
    Bandar Togel Terpercaya

    ReplyDelete
  49. This is really very nice blog and so informative, It give us lots of interest and pleasure.
    Domino99
    DominoBet
    Agen Poker

    ReplyDelete
  50. Nice post, Thanks a lot of for share the informative and useful blog.
    Daftar BandarQ
    Domino99
    DominoQQ

    ReplyDelete
  51. It was really a great information thanks for sharing.
    Daftar BandarQ
    Domino99
    DominoQQ

    Thanks for sharing this great article
    BandarQ
    AduQ
    Daftar BandarQ

    ReplyDelete
  52. This is very educating post, thanks for sharing with us.
    Tips Menang AduQ
    Tips Bermain AduQ

    ReplyDelete
  53. This is really very nice blog and so informative, It give us lots of interest and pleasure.
    DominoBet
    Agen Poker
    Domino99

    Nice post, Thanks a lot of for share the informative and useful blog.
    DominoQQ
    Domino99
    Daftar BandarQ

    ReplyDelete
  54. Numpang Promo ya Gan ^_^


    Mari Bergabung Bersama (DGPOKER) Agen Poker Online Uang Asli Terpercaya Indonesia
    Bonus Rolingan 0,5%
    Bonus Referal 10%
    Proses Cepat Cukup 1 Menit
    Online 24 Jam

    Hanya dengan Mengunakan 1 ID permainan saja, sudah bisa memainkan 6 game sekaligus..
    - Live Poker
    - Texas Hold'en Poker
    - Ceme
    - Ceme Keliling
    - Domino Qiu
    - Capsa Susun

    PIN : D88D5AAC
    Skype : dgpoker88
    Watshap : +6281368738167
    No. Tlp : +6281368738167

    DGPOKER - Agen Poker Online Uang Asli Terpercaya Indonesia

    Capsa Susun Online
    Cara Menang Poker
    Trick Menang Domino
    Bonus Rollingan Poker
    Bonus Mingguan
    Member Baru 100% WD
    Menang Kalah Dapat Bonus
    Cara Menang Poker
    Jackpot Puluhan Juta Rupiah
    Situs Poker Ternama
    Situs Poker Terbaik
    Member Baru Pasti Menang

    https://goo.gl/uOaqpn

    ReplyDelete