Please try my NES emulator HDNes

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

LittleMike
Posts: 10
Joined: Mon May 12, 2014 6:43 pm

Re: Please try my NES emulator HDNes

Post by LittleMike »

这次的更新很好!
之前的版本在我的笔记本上运行拖慢的现象,现在已经没有了,运行非常流畅。
mkwong98
Posts: 282
Joined: Mon May 30, 2011 9:01 pm

Re: Please try my NES emulator HDNes

Post by mkwong98 »

I'm working on Astyanax and it is annoying that the same tile is reused at different location in the single large image in cut scenes. So I'm thinking about the script feature. The primary use of the script is to allow the emulator to identify a tile and palette being use in different situations and apply a different HD tile to it. So there are several steps to this:

1. Find out if a specific tile and palette is being used by searching the name table, attribute table and OAM.
2. Find out how the tile is used: e.g. location on screen, values in RAM or variables used by the script.
3. Tag a number to that entry in the name table or OAM. A specific HD tile is previously added to the graphics pack for that particular tile, palette and tag combination.
4. When the emulator renders that tile, it will use the specific HD tile instead of the default one.

For example many tiles are repeated in the title screen of Super Mario Bros. For a particular tile on the screen, the script can find the location of the tile to identify it. However the screen will scroll as the demo starts and so we need to subtract the horizontal scroll value of the map to find out the real location of the tile. Then we tag a number to that tile. Better still, if we know we are in the title screen and the horizontal scroll value, we can immediately identify each entry in the name table and tag them in a loop.

Let's use the standing of Mario as another example. If we can find out whether Mario is standing still, we can start a frame counter and tag the OAM according to the counter to show Mario breathing like in some fighting games. We can also find out the direction that Mario is facing to have more detailed rendering as suggested in an earlier post.

So the emulator needs to provide the following functions:
1. Read from name table, attribute table and OAM.
2. Tag a number to name table and OAM.
3. Read from RAM.
4. Some memory for the script to read and write and the values written persist across frames.
5. A search function to find the existence of a tile.
6. The script will run once per frame

Is that enough to make it work?
Tygerbug
Posts: 61
Joined: Sun Jan 19, 2014 5:15 pm

Re: Please try my NES emulator HDNes

Post by Tygerbug »

Could be good -- could make it easier to do better art for Super Mario Bros and other games where there are a lot of "cheats." I know that the artist who did (some) 2x art for Super Mario got very frustrated at all the cheats present in the original coding.

I am concerned about how it would affect the speed of the emulator. Alex Douglas who did some tests on SMB2 reports that the new version of HDNES runs faster and smoother, allowing for real gameplay (if not recording) at 4x on his computer.
evgeny
Posts: 10
Joined: Sat Dec 27, 2014 7:40 am

Re: Please try my NES emulator HDNes

Post by evgeny »

mkwong98, maybe you need to enable replacing tiles and sprites with bigger picture?
For example: 8x8 tile replaced by 8x64, which can owerlap the neighboring repeating tiles.

And sprite limit option needed too.
User avatar
GGuy
Posts: 24
Joined: Fri Jul 18, 2014 4:52 pm
Contact:

Re: Please try my NES emulator HDNes

Post by GGuy »

An alternate idea is to have it possible to mark tiles that are next to each other as a whole. Mario standing is 8 tiles total (2x4) but instead of replacing each tile by itself it replaces it as a whole 64x128 sprite (@ 4x). And then multiple tiles that are used twice can be replaced as well because it's seen as it's own separate object.

Using HEX values from the pattern table in this example.
----------------
| $00 | $01 |
----------------
| $4C | $4D |
----------------
| $4A | $4A |
----------------
| $4B | $4B |
----------------
That's Mario standing.

Mario's second(?) walk frame is this.
----------------
| $00 | $01 |
----------------
| $02 | $03 |
----------------
| $04 | $05 |
----------------
| $06 | $07 |
----------------

As you can see the top 2 tiles are the same while everything else is different. Now if we made it one whole object that is replaced you could edit the top of Mario's head as well and not worry about the tile being used somewhere else unexpectedly. Selecting the tiles to group together could be as simple as clicking and dragging on the captured frame in the editor and pressing a button saying "mark as object"! :D

I've noticed people prefer/expect to use composite sprite sheets for sprite editing and doing it this way would make those edits usable.

Example with graphics.
combined.png
combined.png (1.99 KiB) Viewed 13172 times
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Please try my NES emulator HDNes

Post by tokumaru »

Detecting meta-sprites automatically isn't such a trivial task though. But I like the idea of having tiles look different depending on the tiles that surround them.
mkwong98
Posts: 282
Joined: Mon May 30, 2011 9:01 pm

Re: Please try my NES emulator HDNes

Post by mkwong98 »

Yes, both evgeny's and GGuy's ideas are good ideas that I haven't thought of. But I think there is a limitation that the whole object must be in the name table or OAM in order to get recognized. That means it won't work for objects in scrolling background or sprites that can more out of the screen. And for sprites, all the tiles must be placed in consecutive entries OAM, otherwise it will be hard to tell when there are several instances of the same meta sprite flying all over the screen.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Please try my NES emulator HDNes

Post by tepples »

You could hook each game's sprite engine and have it write out the display list in some other format.
User avatar
GGuy
Posts: 24
Joined: Fri Jul 18, 2014 4:52 pm
Contact:

Re: Please try my NES emulator HDNes

Post by GGuy »

My idea is similar to a lua script for FCEUX. Hitbox drawing
But instead of hitboxes it would be metasprites. I don't know how it works exactly because I'm not a programmer but it might be possible with your scripting system mkwong.
Good luck with this however you decide to implement your alternate tile replacement script. It's a much needed feature.

edit: typo
Last edited by GGuy on Sat Mar 14, 2015 9:34 pm, edited 1 time in total.
evgeny
Posts: 10
Joined: Sat Dec 27, 2014 7:40 am

Re: Please try my NES emulator HDNes

Post by evgeny »

Another idea: add custom parameter. (RAM adress and value)
for example: if RAM $0010=1 then draw tile variant 2, else default.
Maybe use optional RAM, ROM, VRAM, CHROM adresses for check, then anybody can select use pallete or NameTable or game level or anything else as indicator for individual tiles. Also selection custom for byte, word, or double word as value for this.
leosouza85
Posts: 2
Joined: Sat Mar 14, 2015 4:25 pm

Re: Please try my NES emulator HDNes

Post by leosouza85 »

@mkwong To title screens and fixed images you could do the following:

we have to dump a tile that doesn't repeat.

If the image that we want to replace is a 8 x 8 tile screen we could use the following name patern in the edited tile:

"thenormalnameofthetiledumped-08x08-02-07.bmp"

The 08x08 is the column vs lines the 02 means that the dumped tile was in the second column and the 07 means the dumped tile was in the seventh line.

The file "thenormalnameofthetiledumped-08x08-02-07.bmp" is the whole 08x08 tile image that uses my reference the unic dumped tile in the name file.

Edit: Thinking more this method could be used for everything! It will make the work of dumpers and editors very very easy!

Sorry about my english!
mkwong98
Posts: 282
Joined: Mon May 30, 2011 9:01 pm

Re: Please try my NES emulator HDNes

Post by mkwong98 »

Now that I think about it, the meta-sprite idea may actually work well enough in most cases if I add a restriction to it. The restriction is that the the meta-sprite must be a strip of tiles, so that a big object will be composed of a few vertical or horizontal strips of tiles. If an object only move into the screen from left or right edge, then we can break the object down into vertical strips. This way, we still have the whole meta-sprite to work with even when only part of the object is on the screen. This will also simplify the detection algorithm as it is much simpler to match a strip of tiles to a known pattern.
leosouza85
Posts: 2
Joined: Sat Mar 14, 2015 4:25 pm

Re: Please try my NES emulator HDNes

Post by leosouza85 »

mkwong98 wrote:Now that I think about it, the meta-sprite idea may actually work well enough in most cases if I add a restriction to it. The restriction is that the the meta-sprite must be a strip of tiles, so that a big object will be composed of a few vertical or horizontal strips of tiles. If an object only move into the screen from left or right edge, then we can break the object down into vertical strips. This way, we still have the whole meta-sprite to work with even when only part of the object is on the screen. This will also simplify the detection algorithm as it is much simpler to match a strip of tiles to a known pattern.
Great news Mkwong! It will expand the possibilities and will be very easy to edit the graphics!
8bitMicroGuy
Posts: 314
Joined: Sun Mar 08, 2015 12:23 pm
Location: Croatia

Re: Please try my NES emulator HDNes

Post by 8bitMicroGuy »

Awesome! So original and new! I've never seen an emulator like this. It's great! Now, when the cartridge bankswitches, how do you manage to keep track of which sprite goes where?
I think you should do the following
Name every HD sprite as the hex sequence of the sprite's data and 3 colors from the palette. For example: 01020408102040800103070F1F3F7FFF2C2E31
That way every sprite, wherever it comes from, will have its HD sprite.
mkwong98
Posts: 282
Joined: Mon May 30, 2011 9:01 pm

Re: Please try my NES emulator HDNes

Post by mkwong98 »

8bitMicroGuy wrote:Awesome! So original and new! I've never seen an emulator like this. It's great! Now, when the cartridge bankswitches, how do you manage to keep track of which sprite goes where?
I think you should do the following
Name every HD sprite as the hex sequence of the sprite's data and 3 colors from the palette. For example: 01020408102040800103070F1F3F7FFF2C2E31
That way every sprite, wherever it comes from, will have its HD sprite.
In HDNes, the mappers return the real address of the read so bankswitching is not a problem.
Post Reply