Super Mario Bros. on the PC-Engine?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

cd_vision
Posts: 52
Joined: Thu Jul 27, 2006 8:05 pm

Super Mario Bros. on the PC-Engine?

Post by cd_vision »

I've got this rom for the PC-Engine that is a port of Super Mario Bros. Does anybody know the history on this? It seems to also be found in a 6-in-1 fami collection.

Did they use the original code from the famicom game, or is this programmed from the ground up? Because except for the colors and sound being a little off, it's indistinguishable from the original to me.
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

You could try comparing the ROMs and see if you find any chunks of code that are the same in both of them. Anything that accesses the APU, PPU or joypads would've had to be partially or completely rewritten, but the main game "engine" should've been possible to move from the NES to the PCE with few changes.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell »

NES games can be hacked (with considerable effort) to run on the PCE.

Those NES hacks are from Image, a Finnish cracking group. Since Image were Finnish, they used the PAL ROM of Super Mario Bros. for their PCE conversion, thus the colours are a bit off and the speed is wrong on NTSC systems such as the PCE/Turbo. Image also hid a few pictures at the end (?) of their PCE ROMs; go have a look for them in some tile editors.
doppelganger
Posts: 183
Joined: Tue Apr 05, 2005 7:30 pm

Post by doppelganger »

Very interesting. I had no idea such a port even existed.
Be whatever the situation demands.
LoneKiltedNinja
Posts: 63
Joined: Mon Jul 07, 2008 7:40 pm

Post by LoneKiltedNinja »

Out of curiosity, I've never thought seriously about PCE dev work. I'm sure I could pick up the basic ISA, but how different is the theory behind the sound and graphics systems? Iirc PCE uses mainly PCM sound, but is it strictly sampled or can you play arbitrary bitsrings? And how much more complex is it working with the greater range of sprite sizes? FractalEngine looks like it has some direct-draw. Is that for-real, or did you have to rig a clever raster hack?
Psych Software- failing to profit from retro/indie development since before it was cool
http://www.psychsoftware.org
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell »

The PC-Engine was clearly designed by Hudson to be as easy to program for as the Famicom, yet much more powerful, in order to lure FC developers to the system.

The graphics system on the PCE is tile-based like the FC, meaning that graphics are always composed of a tilemap of adjustable size, and then tile characters taking up the rest of VRAM. There is enough VRAM on the PCE for an uncomprssed/unoptimized 512x240 pixel image, which is what I set up in FractalEngine. My program sets up such a screen, then fills in the tile characters as it renders the fractal. It just so happens that each 8x1 horizontal line in a graphic tile takes up 4 bytes, so to get this "direct draw" thing going, I just had to have it change the VRAM addresses accordingly and write the fractal image to VRAM, 8 pixels at a time. There was no need to read previously-drawn tiles because of the tile bitplane layout.

Sprites are easy to use and set up for large sizes, the only headache being figuring out the VRAM offset for sprite tiles. Really stupidly, the sprite tile format on the PCE is different from the BG tile format, so sprites and BG can't use the same CHR graphics. I don't know why Hudson did it this way...

Sound on the PCE can be PCM, but it really is just a glorified PSG chip. It is a WSG: a PSG chip with a single user-definable waveform cycle for each sound channel Most games set up a waveform for each channel, using 4 or 5 channels as regular WSG, with perhaps the 6th channel set up with a CPU timer for PCM drum effects. Very few games use all the channels for PCM, because it is a bit tougher to do, and more CPU intensive. The PCE's sound chip is no SPC-700.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

ccovell wrote:Sound on the PCE can be PCM, but it really is just a glorified PSG chip. It is a WSG: a PSG chip with a single user-definable waveform cycle for each sound channel
Like the Game Boy's counterpart to the NES triangle channel, right?
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

Yeah, the samples are 4-bit on the GB and 5-bit on the PCE, but it's the same concept.
LoneKiltedNinja
Posts: 63
Joined: Mon Jul 07, 2008 7:40 pm

Post by LoneKiltedNinja »

ccovell wrote:My program sets up such a screen, then fills in the tile characters as it renders the fractal. It just so happens that each 8x1 horizontal line in a graphic tile takes up 4 bytes, so to get this "direct draw" thing going, I just had to have it change the VRAM addresses accordingly and write the fractal image to VRAM, 8 pixels at a time. There was no need to read previously-drawn tiles because of the tile bitplane layout.
So let me see if I'm parsing this correctly- you still compose the background of tiles, but you basically fill in the tiles at runtime via the CPU, as opposed to the NES architecture which (to my knowledge) makes it a pain for the CPU to get directly at the CHR data, and doesn't give you enough distinct tiles to fill more than a fraction of the screen anyway?
The best easy hack I could think of for the NES was a premade CHR bank with every possible combination of 4 quarter-tiles x 4 colors...
Psych Software- failing to profit from retro/indie development since before it was cool
http://www.psychsoftware.org
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

I'm sure the PC-Engine still has VBlank rules. You update the graphical hardware while it's between frames. I would guess the PC-Engine has a large amount of VRAM that the CPU loads tiles into through memory mapped registers similar to the NES. But I know the PC-Engine can remap its 64K of address space so maybe you can map VRAM into CPU space.

Honestly I don't see what you mean about the NES. The CPU can modify PPU memory well enough for some amazing games. Sure it's not fast enough to compare to how you do things on modern PCs with a frame buffer and tons of bitmaps. But it works pretty damn well when you consider how limited the hardware was back then.

What are you talking about a premade CHR bank with every possible combo of 4 quarter tiles x 4 colors? Hacking NES games to PC-Engine wouldn't require duplicating tiles for each palette. I don't really know that much about PC-Engine, but it's from the same era as the Genesis/MegaDrive and SNES.

But anyway, the NES may seem like a pain to work with, but if you take your time and think about what you are doing I really don't think it's as hard as you think it is.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell »

The PCE still has VBlank rules, but the VDC can still be written to during the active display. I'll quote Charles MacDonald:
During the active display period of a scanline, the VDC can do one 16-bit
access to VRAM on each cycle of the dot clock. Bits 1-0 of MWR tell the VDC
how to divide this amongst several sources:

1. CPU (reading or writing a word via register $02)
2. Background character pattern generator data (one read is for bitplanes
0 and 1, another is for bitplanes 2 and 3, either one or two are needed
per character)
3. BAT data (character name and palette, one fetch needed per character)

Code: Select all

 Bit   Dot   Dot cycles within an 8-dot unit
 1 0  Width   0   1   2   3   4   5   6   7
 -------------------------------------------
 0 0    1    CPU BAT CPU ??? CPU CG0 CPU CG1
 0 1    2    --BAT-- --CPU-- --CG0-- --CG1--
 1 0    2    --BAT-- --CPU-- --CG0-- --CG0--
 1 1    4    ------BAT------ ----CG0/CG1----
CPU - A read or write to register $02
BAT - The palette block and character name from the BAT
??? - Unknown, possibly an unused 'dummy' access
CG0 - Bitplanes 0, 1 from the character generator
CG1 - Bitplanes 2, 3 from the character generator

The default mode all games use is 0, as far as I can tell, modes 1, 2 are
identical, and mode 3 enables the CG mode bit as described later.
I never quite understood this exactly. VRAM can be written to at any time, but the access that the CPU is given is spread between VDC VRAM accesses. At any rate, I got small graphical corruption when I tried writing freely to the VDC in my Fractal Engine program, so I set up writes to occur during HBlank interrupts. I guess this slows down the program a little bit, but fractal computation stil takes longer than one scanline, I figured.

I might go back to my program someday and see if I can get it to write to VRAM at any time, speeding up writing.

On the NES, yes CHR-RAM writing is limited, but it can still be optimized -- look at what carts like Videomation do. I think for fractals, your 4x4 CHR bank is good enough, because who wants to watch a fractal on the NES render four times slower than it already is? :P
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

I'm not sure what a fractal engine is, but I don't see the point. These machines are meant for games. They are perfectly capable of performing rich and enjoyable games.

As for CHR-RAM and the NES in general, just look at Battletoads. :p You can do alot with the NES. You just can't be as wasteful as you can with newer platforms. But when you consider how simple most games are, and how much fun simple games can be, the NES can get the job done. And it does quite well if you pair the NES with a beefy memory mapper like the MMC5. Though even with a MMC3, you can accomplish alot in your games.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell »

MottZilla wrote:I'm not sure what a fractal engine is,
http://www.disgruntleddesigner.com/chri ... ngine.html
MottZilla wrote:but I don't see the point.These machines are meant for games.
:(
MottZilla wrote:They are perfectly capable of performing rich and enjoyable games.
True, but they are also capable of running various other kinds of software. You probably also don't see the point of demos, either.
MottZilla wrote:As for CHR-RAM and the NES in general, just look at Battletoads. :p You can do alot with the NES. You just can't be as wasteful as you can with newer platforms. But when you consider how simple most games are, and how much fun simple games can be, the NES can get the job done. And it does quite well if you pair the NES with a beefy memory mapper like the MMC5. Though even with a MMC3, you can accomplish alot in your games.
This, at least, is true.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

ccovell wrote:You probably also don't see the point of demos, either.
To me, the main point of demos is showing uncommon amazing effects, that couldn't be normally used in games because they require too much CPU time/ROM/RAM/whatever.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Demos vs. games

Post by tepples »

MottZilla wrote:I don't see the point. These machines are meant for games.
Are Nintendo platforms also meant just for games? If so, are these games?
  1. Videomation
  2. Mario Paint
  3. Workboy
  4. PictoChat
  5. Electroplankton
  6. Animal Crossing: Wild World
  7. Play-Yan
  8. MoonShell
  9. DSOrganize
All of these run on a Nintendo platform, but for each one, I can think of at least one objection to calling it a game.
tokumaru wrote:amazing effects, that couldn't be normally used in games because they require too much CPU time/ROM/RAM/whatever.
Have you played Recca? It's a shooter that looks like a demo with sprites on top.
Post Reply