English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 06 November 2023, 19:41   #1
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
Emulating the Nintendo Entertainment System

Since 1997 (every now and then) a friend and I coded on our NES emulator, A/NES, for Amiga. It has been fun (most of the time) but of course the biggest bottleneck is the graphics emulation which in many parts isn't really suitable for Amiga hardware.
Some days I think about how to improve the graphicsemulation (and speed) but it's quite complex but I'm after some ideas, perhaps someone here can think of something clever (assuming you understand my massive post..)

Imagine this scenario (slightly simplied):
* NES has 4 screens based of tiles (like the C64), 4*256x240 pixels in size but only two of them are unique, the other ones are mirrors of existing ones. The screens consists of of 4 bitplanes.
* They are positioned like this:
2 3
0 1
Screens can be mirrored so 0-1/2-3 are duplicates (horizontal mirroring) or 2-0 and 3-1 (vertical mirroring).
* The visible area could be any one of those 4 (+ scrolling information). Imagine horizontal mirroring is active and screen 1 is active and keeps scrolling horizontally (SMB for example), the visible area will wrap around to screen 0 again.

I keep thinking of emulating this in the most efficient/simple way. In theory I only needs to be updating 2 screens but the difficult question remains, how to "glue" those screens together during scrolling in a fast way. Generating the final image, copying data using the blitter/CPU would greatly decrease performance (target computer is A1200/~68030+/FastRAM).
Currently we are using "simple" Amiga hardware scrolling for this purpose but it introduces other problems aswell.
To further add complexity, the graphics related to the tiles could be switched easily, so tile nr 1 could be a cloud or a tree depending on the current graphics-bank. Adding sprites then adds another layer of complexity, they can appear behind the background aswell..

Congratulations if you've read it all all the way down here. I'd appreciate some ideas concerning this.

Last edited by oRBIT; 06 November 2023 at 21:07.
oRBIT is offline  
Old 06 November 2023, 22:31   #2
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,809
No idea maybe try contacting doble07 directly or maybe NES emulator for Atari ST holds some answers.
Retro1234 is offline  
Old 06 November 2023, 22:33   #3
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,360
when you draw/blit a tile, draw it twice in both mirrors. Then you can use hardware scrolling

I did that with Xevious port. It was vertical scrolling, but the wrap around was done like that.

But I agree designing an emulator using amiga hardware features is a challenge. You want to handle the general case.

If you want to make it AGA, you can also use AGA dual playfield and get 2 independant 16-color layers.

Hardware sprites won't help a lot because of the size (but AGA can fix that) and mostly lack of colors I suppose. With AGA you have more possibilities: 8 sprites with 8 independent palettes and 64 bit wide. And blit the rest.

I combined 4 sprites to create a 7 color huge space ship (Xevious Andor Genesis), and still had 4 sprites left, with any palette I'd choose.

Just ideas...
jotd is online now  
Old 07 November 2023, 00:52   #4
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,652
NES hardware is very simple, backwards, and alien. It ended up this way because of economic decisions.

The small thinking and small tiles makes it a half as good fit for the Blitter, but the visuals can be reproduced faithfully at full frame rate on an Amiga 500.

The problem is that you're emulating, not reproducing the game. Because of this your emulator becomes an interpreter of how the software had to be written to even produce the standard we saw. I.e. the software looks up pre-mirrored tiles, you can pre-mirror the entire ROM in chip RAM and map the banks, render loop to fill a screen with tiles. And dual playfield solves all the sprites, and scrolling is not a problem. (I feel like I'm parroting jotd.)

So it's more of a strategy how to do it (e.g. mirror the entire cart 4x and flip tiles while loading the cart). The tiles are flippable not because of performance but because of small ROM space.

And it didn't update tiles anywhere near full frame rate or full screen, so neither do you. Just track the changes and make the updates needed.

But you know all these things, it's just ideas. You must also be able to produce performant code to determine if any platform can do a specific thing or not.
Photon is offline  
Old 07 November 2023, 02:29   #5
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,809
Last time I tried A/NES iirc it was pretty complete?

Speed? Maybe on a PiStorm it might be fast?
Retro1234 is offline  
Old 07 November 2023, 06:52   #6
DanyPPC
Registered User
 
Join Date: Dec 2016
Location: Italy
Posts: 769
The best NES emulator I tested on Amiga is CoolNES and it works on a simple 68030.
It is far from perfect, but some games are playable, where the A/NES lacks...

On Aminet A/NES 1.2 has been released, but it doesn't emulate even Super Mario Bros...

Certainly a new emulator written specifically to make better use of the Amiga hardware is welcome.

Last edited by DanyPPC; 07 November 2023 at 07:37.
DanyPPC is offline  
Old 07 November 2023, 09:53   #7
AestheticDebris
Registered User
 
Join Date: May 2023
Location: Norwich
Posts: 426
Quote:
Originally Posted by Photon View Post
And it didn't update tiles anywhere near full frame rate or full screen, so neither do you. Just track the changes and make the updates needed.
Well, kind of. There are mapper chips that can swap the entire set of tiles the VDP "sees" instantly, which would result in a change across the whole screen in a frame. Usually that was done on line interrupts to create extra effects (parallax scrolling for one but sometimes just to get more tiles on screen) - I imagine that could make tracking "dirty" rectangles a little bit trickier.
AestheticDebris is offline  
Old 07 November 2023, 10:04   #8
derSammler
Senior Member
 
Join Date: Jun 2001
Location: Germany
Posts: 1,666
Quote:
Originally Posted by DanyPPC View Post
On Aminet A/NES 1.2 has been released, but it doesn't emulate even Super Mario Bros...
Then you do something wrong. Just tested - works and is playable with sound.
Attached Thumbnails
Click image for larger version

Name:	001.png
Views:	66
Size:	8.7 KB
ID:	80666  
derSammler is offline  
Old 07 November 2023, 10:16   #9
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,360
If you need an emulator just to run Super Mario Bros, transcode the game to 68000, implement the game requirements in terms of sprites / scrolling / etc as it's a single game, not the whole console, and you have Super Mario Bros for Amiga (like I would convert any arcade game)

Not sure how many other NES games are worth playing on Amiga nowadays... Also not sure if an emulator is needed for Amiga today. Wouldn't most people run it through WinUAE anyway? That and the performance issue on real hardware. I know. It's hard to emulate consoles in a generic way. Even the NES.
jotd is online now  
Old 07 November 2023, 11:12   #10
DanyPPC
Registered User
 
Join Date: Dec 2016
Location: Italy
Posts: 769
Quote:
Originally Posted by derSammler View Post
Then you do something wrong. Just tested - works and is playable with sound.
You were right.

Yesterday when I tested the new 1.21 release something gone wrong, and sprites on screen weren't shown.
Today I test again and surprisingly all is ok.

Thanks for the advice.
DanyPPC is offline  
Old 07 November 2023, 11:22   #11
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,809
Looks like 1.19 is oRBIT's latest version of A/NES

"A/NES PRO v1.19 AmigaOS NES-emulator for classic Amigas (AGA and 68060+ highly recommended)."

Quote:
Originally Posted by oRBIT View Post

Download here: http://nes.goondocks.se
Maybe someone could try it on PiStorm?
Retro1234 is offline  
Old 07 November 2023, 11:29   #12
derSammler
Senior Member
 
Join Date: Jun 2001
Location: Germany
Posts: 1,666
A/NES Pro seems to have RTG support, A/NES does not. But A/NES is newer, he updated it just five days ago.
derSammler is offline  
Old 07 November 2023, 11:30   #13
Retro1234
Phone Homer
 
Retro1234's Avatar
 
Join Date: Jun 2006
Location: 5150
Posts: 5,809
Ok, maybe he can clarify.
PiStorm supports RTG ?
Retro1234 is offline  
Old 07 November 2023, 11:36   #14
derSammler
Senior Member
 
Join Date: Jun 2001
Location: Germany
Posts: 1,666
Yes, PiStorm does support RTG. But there's no reason not to use the normal, newer version instead of the older Pro.

This should run at full speed on any 060. Doubt a PiStorm is even needed.
derSammler is offline  
Old 07 November 2023, 15:24   #15
oRBIT
Zone Friend
 
Join Date: Apr 2006
Location: Gothenburg/Sweden
Age: 48
Posts: 344
The original A/NES is the one that I'm currently working on (well, more or less, mostly less). Yes, A/NES PRO does a better job with the graphics but obviously requires a pretty powerful machine.
oRBIT is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Vs. Nintendo System Homebrew DamienD Retrogaming General Discussion 0 25 December 2020 02:17
Christmas entertainment for the family jimbob Retrogaming General Discussion 5 23 December 2011 01:43
Hyperion Entertainment Announces The Amiga X1000 Mangar News 1 07 January 2010 08:06
Workbench-Style GUI System for the Nintendo DS ant512 Retrogaming General Discussion 5 21 April 2008 20:19

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:28.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09356 seconds with 14 queries