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 - Porting NES games to SMS

Reply to topic
Author Message
  • Joined: 25 Feb 2023
  • Posts: 99
Reply with quote
Porting NES games to SMS
Post Posted: Mon Feb 27, 2023 1:21 pm
I'm currently attempting to port a couple games that were originally NES exclusive over the Master System, and I was wondering if anybody with experience in doing such a thing had some tips or pointers. So far I've just been using emulator debuggers to try and analyze code, but a lot of emulator debuggers don't pick up everything. It's been a little frustrating, and I'm running out of music and graphics to recreate.

Just in case anyone was curious, my first project is Final Fantasy I.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14687
  • Location: London
Reply with quote
Post Posted: Mon Feb 27, 2023 1:43 pm
It sounds like a very difficult job. You effectively have to recreate the game from scratch; making the logic absolutely identical to the original would require a very detailed disassembly and analysis.
  View user's profile Send private message Visit poster's website
  • Joined: 25 Feb 2023
  • Posts: 99
Reply with quote
Post Posted: Mon Feb 27, 2023 1:50 pm
Maxim wrote
It sounds like a very difficult job. You effectively have to recreate the game from scratch; making the logic absolutely identical to the original would require a very detailed disassembly and analysis.


It has been pretty difficult! I'm still pretty new to assembly in general but I'm learning tons and tons really quickly about both 6502 and Z80. Your tutorial has been pretty helpful too :)

Thankfully, Final Fantasy I has a pretty big ROM hacking community, with plenty of custom tools and even a decent disassembly to look through. In the meantime, I've been recreating a lot of the assets and I think they look pretty good (which is to be expected, since the Master System has great colors!)
SmallEnemiesFFSMSPROJECT_Cereza64.png (25.15 KB)
Final Fantasy I's various small enemies
SmallEnemiesFFSMSPROJECT_Cereza64.png

  View user's profile Send private message
  • Joined: 16 May 2002
  • Posts: 1355
  • Location: italy
Reply with quote
Post Posted: Mon Feb 27, 2023 3:00 pm
NES to SMS conversion is a topic which pops up from time to time, if you play with the search engine on the forums you might find some insights from the older discussions, here is one, but there is much more.
  View user's profile Send private message Visit poster's website
  • Joined: 14 Oct 2008
  • Posts: 508
Reply with quote
Post Posted: Mon Feb 27, 2023 4:47 pm
Final Fantasy 1 did get a MSX2 port which used 16-color enemies.
I don't remember how great it was. (I wouldn't expect it to have great use of the extra colors, it did seem to be a kind of careless port.)
I only remember playing a bit into it and stopping because the loading time was kind of annoying. (it was a floppy disk game, and perhaps even more annoying is that it wanted a whole 720KB disk to save, and it could STILL only save one file. I guess it was excusable on the NES since that only had 8KB RAM and a lot of that space went to general RAM expansion, but when you have 720k to work with...)
  View user's profile Send private message
  • Joined: 25 Feb 2023
  • Posts: 99
Reply with quote
Post Posted: Mon Feb 27, 2023 6:05 pm
KingMike wrote
Final Fantasy 1 did get a MSX2 port which used 16-color enemies.
I don't remember how great it was. (I wouldn't expect it to have great use of the extra colors, it did seem to be a kind of careless port.)
I only remember playing a bit into it and stopping because the loading time was kind of annoying. (it was a floppy disk game, and perhaps even more annoying is that it wanted a whole 720KB disk to save, and it could STILL only save one file. I guess it was excusable on the NES since that only had 8KB RAM and a lot of that space went to general RAM expansion, but when you have 720k to work with...)


The MSX port is definitely a pretty mixed bag in terms of quality. On the one hand, FM synth music; on the other hand, everything else lol. Even though it's also on a Z80 system, I'm not looking at it for code at all. The sprites and other various graphical differences are too extreme for my goal in making a relatively similar version to the original. I'm trying to hit a sweet spot where the graphics take advantage of the Master System's better hardware, but it still feels like the NES version.
  View user's profile Send private message
  • Joined: 01 Aug 2012
  • Posts: 322
  • Location: Porto, Portugal
Reply with quote
Post Posted: Sat Mar 04, 2023 4:31 pm
i think some people at atariage forum were trying to port zx-spectrum games to atari800, but it required (at least) converting z80 code to 6502 - seems a quite deep disassembling/reassembling analytic process that might be very interesting, but it is nothing like an automatic conversion at all
  View user's profile Send private message Visit poster's website
  • Joined: 07 Apr 2021
  • Posts: 20
Reply with quote
Post Posted: Mon Mar 06, 2023 12:43 am
Definitely a huge undertaking. If you wanted to create a typical port, it would involve just playing the game, knowing it, creating a decent facsimile of it, and going with that. Since we have modern emulators and debug tools, we can extract some graphics and sound, and even disassemble the ROM. But in order to know what the code does, that's on you to do, unless you find someone else who has done the work for you in terms of figuring out what bits of code originally did what. In short, there is no easy automatic way to convert 6502 code to optimized Z80 code (at least that I've ever heard of).

If you enjoy it, though, keep at it!
  View user's profile Send private message
  • Joined: 17 Sep 2013
  • Posts: 128
  • Location: Gravataí, RS, Brazil
Reply with quote
Post Posted: Wed Mar 08, 2023 3:32 pm
In my experience, looking to the original source/disassembly, is only useful to analyse general aspects of the game. Like the position of colision points, or speed of the caracteres, or getting details that are not obvious for the player. For exemple, in Megaman 2, when you jump from a slipery floor, megaman still slides half a pixel in the first frame in the air. This wolud be all but impossible to perceive while playing, or even notice when watching the memory values changing.

Other than that, since the CPUs are too diferent, you probrably better of just writing your own code, thatn trying to translate the original.
  View user's profile Send private message
  • Joined: 30 Nov 2017
  • Posts: 74
Reply with quote
Post Posted: Wed Mar 08, 2023 5:55 pm
I've always wondered if porting Super Mario Bros to the SMS could be done as smoothly as it was for the Genesis. I think the person that did that mostly automated it since SMB was a rather simplistic game. I would be curious to know if a similar program could be developed to convert the SMB NES code to SMS compatible code. The actual source code for SMB has been floating around for a few years.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 544
  • Location: Málaga, Spain
Reply with quote
Post Posted: Thu Mar 09, 2023 6:11 pm
I am almost sure the main trouble you Will find is, the Sprite system in the nes IS different that the máster system one... In nes you have pointers to sprites and changing them IS quick. In máster system you have to load all the being used sprites in vram... Or load them dynamically (which IS a time consumming task)... By example, Sun soft Batman uses a big bunch of sprites for the player animations.... In máster you could not maintain these nunber of sprites at once.

Although the máster system have other goodies like the 8kb of RAM or the far superior palette system, of course.

If we are talking of simpler games... Like smb1 ... Almost sure you would not have a big trouble, other than the inner complexity of a video Game, for the port.
  View user's profile Send private message
  • Joined: 23 Jan 2010
  • Posts: 414
Reply with quote
Post Posted: Thu Mar 09, 2023 6:36 pm
Last edited by segarule on Fri Mar 10, 2023 12:20 am; edited 1 time in total
Quote
By example, Sun soft Batman uses a big bunch of sprites for the player animations.... In máster you could not maintain these nunber of sprites at once.

Based that Sunsoft developed 2 batman, what Batman ? Return of the Joker?
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 544
  • Location: Málaga, Spain
Reply with quote
Post Posted: Thu Mar 09, 2023 7:37 pm
I'd suppose both... But i was talking about the first one, the good one (for me)!!!

I do not say it cannot be done... by example... if you load with unsafe functions..... let's say... 9-10 sprites per frame (or each two frames... we don't need so many updates).... you won't have trouble, even if you need to load other animations (tile background animations by example...) it is a trouble of timing and testing, nothing more.
  View user's profile Send private message
  • Joined: 23 Jan 2010
  • Posts: 414
Reply with quote
Post Posted: Fri Mar 10, 2023 12:28 am
eruiz00 wrote
I'd suppose both... But i was talking about the first one, the good one (for me)!!!

I do not say it cannot be done... by example... if you load with unsafe functions..... let's say... 9-10 sprites per frame (or each two frames... we don't need so many updates).... you won't have trouble, even if you need to load other animations (tile background animations by example...) it is a trouble of timing and testing, nothing more.

Interesting! I imagined that 1 is totally doable to SMS and it would be finished better. The first is good (although i think that the 2nd (Return of the joker) is top). But if we have a dev very very capable and expert in SMS hardware is you. Mainly because you is familiarized with NES port. So you convinced me.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 544
  • Location: Málaga, Spain
Reply with quote
Post Posted: Fri Mar 10, 2023 6:40 am
Welll.... thanks, guy...

I was interested in this topic due to the last project, in which I am loading the player sprites at real time (like in ninja gaiden, by example, doing this I am using only about 40 sprites at once for the player, the player weapons, the power capsules, the explosions...) which is a good thing , as you get more free sprite slots for the enemies.

The trouble, like I said, is timing... although, if you have many tiles/sprites to update each frame, a) you can alternate the updates, b) you can use unsafe updates in vblank time for some updates and safe for others, it is a timing question. Have to be careful if you have scrolling and have to update columns or rows of tiles due to the scrolling, as It can be visible to the player. A timing trouble.
  View user's profile Send private message
  • Joined: 25 Feb 2023
  • Posts: 99
Reply with quote
Post Posted: Fri Mar 10, 2023 6:51 am
eruiz00 wrote
Welll.... thanks, guy...

I was interested in this topic due to the last project, in which I am loading the player sprites at real time (like in ninja gaiden, by example, doing this I am using only about 40 sprites at once for the player, the player weapons, the power capsules, the explosions...) which is a good thing , as you get more free sprite slots for the enemies.

The trouble, like I said, is timing... although, if you have many tiles/sprites to update each frame, a) you can alternate the updates, b) you can use unsafe updates in vblank time for some updates and safe for others, it is a timing question. Have to be careful if you have scrolling and have to update columns or rows of tiles due to the scrolling, as It can be visible to the player. A timing trouble.


When you mention, "sprites" are you refering to the 8x8 tiles making up the player, or the frames of animation for the player?

Also, there's plenty of examples of Master System games with very smooth animations and lots of sprites on screen without flickering or looking ugly. The skill of the programmer plays a role for sure but it's not impossible to do. Putting NES games on the MSX is a different (off-topic) story lol.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14687
  • Location: London
Reply with quote
Post Posted: Fri Mar 10, 2023 9:29 am
The fact is that the NES CHR ROM design combined with mapping chips allows instantaneous changes of all of the loaded tiles (backgrounds and sprites) for nearly zero CPU time. The SMS VRAM approach can’t match that - changing tiles costs CPU and time - but it does mean you don’t need that extra hardware and ROM.
  View user's profile Send private message Visit poster's website
  • Joined: 07 Apr 2021
  • Posts: 20
Reply with quote
Post Posted: Thu Mar 16, 2023 4:39 pm
NewHorizon wrote
I've always wondered if porting Super Mario Bros to the SMS could be done as smoothly as it was for the Genesis. I think the person that did that mostly automated it since SMB was a rather simplistic game. I would be curious to know if a similar program could be developed to convert the SMB NES code to SMS compatible code. The actual source code for SMB has been floating around for a few years.


Yeah. I've read about that Genesis port, and apparently a lot of it was automated. But keep in mind that a Motorola 68000 running at 7.6mHz as the Genesis does is going to be considerably faster than the 6502 running at 1.79mHz in the NES. Not quite 4.2 times as fast as the clock speeds suggest, since the 6502 is apparently more efficient per clock cycle, but let's say 2-3 times easily, if not more. If the automated process resulted in some inefficient code, it doesn't really matter unless it's REALLY bad, because the speed difference is more than enough to make up for any inefficiencies and keep the game running at full speed.

If there was a way to do it on the SMS automatically, there would likely be inefficiencies in the same way, except the processors are pretty similar in speed at the clock rates the 2 consoles run at. Any inefficiencies would result in some significant slowdown.
  View user's profile Send private message
  • Joined: 30 Nov 2017
  • Posts: 74
Reply with quote
Post Posted: Fri Mar 17, 2023 11:15 am
Jabberwocky wrote
NewHorizon wrote
I've always wondered if porting Super Mario Bros to the SMS could be done as smoothly as it was for the Genesis. I think the person that did that mostly automated it since SMB was a rather simplistic game. I would be curious to know if a similar program could be developed to convert the SMB NES code to SMS compatible code. The actual source code for SMB has been floating around for a few years.


Yeah. I've read about that Genesis port, and apparently a lot of it was automated. But keep in mind that a Motorola 68000 running at 7.6mHz as the Genesis does is going to be considerably faster than the 6502 running at 1.79mHz in the NES. Not quite 4.2 times as fast as the clock speeds suggest, since the 6502 is apparently more efficient per clock cycle, but let's say 2-3 times easily, if not more. If the automated process resulted in some inefficient code, it doesn't really matter unless it's REALLY bad, because the speed difference is more than enough to make up for any inefficiencies and keep the game running at full speed.

If there was a way to do it on the SMS automatically, there would likely be inefficiencies in the same way, except the processors are pretty similar in speed at the clock rates the 2 consoles run at. Any inefficiencies would result in some significant slowdown.


The automation could get it most of the way there though with optimizations afterward.
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 844
Reply with quote
Post Posted: Fri Mar 17, 2023 12:37 pm
NewHorizon wrote
The automation could get it most of the way there though with optimizations afterward.

Optimizing the code like that would probably be as time-consuming as translating it manually from scratch. The only thing you could re-use would be the general game logic anyway. All input and output routines would have to be coded anew specifically to match the SMS's requirements, as the kind of on-the-fly pseudo emulation the Mega Drive port uses would take more cpu time than the SMS could realistically handle.
  View user's profile Send private message
  • Joined: 30 Nov 2017
  • Posts: 74
Reply with quote
Post Posted: Fri Mar 17, 2023 3:39 pm
Kagesan wrote
NewHorizon wrote
The automation could get it most of the way there though with optimizations afterward.

Optimizing the code like that would probably be as time-consuming as translating it manually from scratch. The only thing you could re-use would be the general game logic anyway. All input and output routines would have to be coded anew specifically to match the SMS's requirements, as the kind of on-the-fly pseudo emulation the Mega Drive port uses would take more cpu time than the SMS could realistically handle.


Oh, so the Megadrive version is actually running in some type of emulation? I thought it the code had been fully converted. Would be awesome to have Super Mario Bros on the SMS someday though. The SMS colour palette would make it look really nice.
  View user's profile Send private message
  • Joined: 07 Apr 2021
  • Posts: 20
Reply with quote
Post Posted: Sun Mar 19, 2023 8:15 pm
Kagesan wrote
NewHorizon wrote
The automation could get it most of the way there though with optimizations afterward.

Optimizing the code like that would probably be as time-consuming as translating it manually from scratch. The only thing you could re-use would be the general game logic anyway. All input and output routines would have to be coded anew specifically to match the SMS's requirements, as the kind of on-the-fly pseudo emulation the Mega Drive port uses would take more cpu time than the SMS could realistically handle.


Yeah, agreed. If you brute-force translate 6502 code line by line to Z80, it's really dirty, especially with regards to memory offsets. Being able to get an offset in an index register (x and y) on the 6502, then being able to use any base memory address in the memory map is something the Z80 can't do. So to make a good working quick optimized version would result in code that looks quite different than the original.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!