Results 1 to 9 of 9

Thread: Nintendo Entertainment System emulator in VB6 [EXE + source]

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    32

    Nintendo Entertainment System emulator in VB6 [EXE + source]

    EDIT: Updated to version 0.1.1, added 1x, 2x, 3x scaling selection. Fixed bug where it crashed if you click cancel on the load state dialog.

    EDIT 2: Updated to version 0.1.3, MMC3 fixed enough so that Super Mario Bros 3 basically runs perfectly. Added battery-backed SRAM emulation. Added netplay support. Not tested over internet, works great on LAN.

    I've been working on a NES emu from scratch (other than some small snippets for DirectX audio and fast image blitting) in VB6 the last couple of weeks, thought I'd share what I have. It's still a work in progress, but a lot of games play fine. It's got auto frame-skipping, save states, and AUTHENTIC Game Genie support! Source and EXE included in attachment. Check the readme.txt if you have any problems or ask in here!

    (The GG ROM is legal to include, Galoob made it public domain years ago)

    The bad:
    - A lot of games have graphics glitches or don't run.
    - APU has a few issues, most noticeably that I haven't been able to get sweeps to work right so they're disabled for now.
    - It's slow. You'll want an Intel Core-i3/i5/i7 or AMD equivalent to play at full a 60 FPS. High end Pentium 4 or Core 2 Duo will work, but it will skip frames to compensate.

    I'll be fixing things over the next few weeks and updating with major improvements here! If it doesn't start or has no audio, start cmd.exe AS ADMINISTRATOR, then run resreg.bat.

    Download: (too large to attach to post)

    Source and EXE in ZIP: http://rubbermallet.org/vbNES-0.1.3.zip
    MSI installer, no source: http://rubbermallet.org/vbNES-0.1.3.msi

    MSI doesn't require messing with registering any files.

    And some screenshots:











    Last edited by miker00lz; Feb 10th, 2016 at 12:32 PM.

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    Just FYI if anybody cares, the latest update v0.1.3 above now plays Super Mario Bros 3 pretty much perfectly...
    Last edited by miker00lz; Feb 10th, 2016 at 12:32 PM.

  3. #3
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    Well I must say your sound is extremely off which I'll get into a bit later since its 3am o.o

    But another thing thats easier to solve for ya is that your palette is a way off. Basically for many NES emulators out there, their palette is off too. The NES palette that's been mentioned all over the internet is also extremely off, and more like colors captured after taking photos of a TV using a professional camera, which actually darkens a lot of the colors. And I'm pretty damn picky when it comes to emulating something, especially colors. I understand there is no way to get the exact colors but I have a method that's pretty freaking close, if not exact. When I use my laptop, I have it hooked into my 40 inch HDTV. When I use my real NES, I also have it hooked into the same HDTV. No matter what, the brightness and contrast are the same for both the laptop and NES. So when I make my emulator and run it, I can go back and forth between Video and HD mode (my laptop) to compare colors. Although my so called guessing game in values wasn't precise, it got it pretty close. However, I wasn't satisfied enough. So I recently got an El Gato composite video capture cable. Funny thing is, it was the same exact colors as if I had it on Video mode, only now I can see it off my laptop. Although it was composite and still had a blend of particular colors, I took snapshots and blended the average color of the blurred composite color in photoshop, which then gave me the actual color that matched the captured video! I didn't tell too many people this, but I have been redesigning the emulator on C++ using DirectX, so use this new palette. Play Super Mario Bros and you'll see a difference:

    cpp Code:
    1. void Create_Real_NES_Pallete_NTSC()
    2. {
    3.     int Current_Color;
    4.  
    5.     //Row 1
    6.     Pallete[0] = D3DCOLOR_XRGB(104, 104, 104);
    7.     Pallete[1] = D3DCOLOR_XRGB(0, 42, 136);
    8.     Pallete[2] = D3DCOLOR_XRGB(20, 18, 167);
    9.     Pallete[3] = D3DCOLOR_XRGB(59, 0, 164);
    10.     Pallete[4] = D3DCOLOR_XRGB(92, 0, 126);
    11.     Pallete[5] = D3DCOLOR_XRGB(110, 0, 64);
    12.     Pallete[6] = D3DCOLOR_XRGB(108, 6, 0);
    13.     Pallete[7] = D3DCOLOR_XRGB(86, 29, 0); //One of the coin block animations in Super Mario Bros
    14.     Pallete[8] = D3DCOLOR_XRGB(51, 53, 0);
    15.     Pallete[9] = D3DCOLOR_XRGB(11, 72, 0);
    16.     Pallete[10] = D3DCOLOR_XRGB(0, 82, 0);
    17.     Pallete[11] = D3DCOLOR_XRGB(0, 79, 8);
    18.     Pallete[12] = D3DCOLOR_XRGB(0, 64, 77);
    19.     Pallete[13] = D3DCOLOR_XRGB(0, 0, 0);
    20.     Pallete[14] = D3DCOLOR_XRGB(0, 0, 0);
    21.     Pallete[15] = D3DCOLOR_XRGB(0, 0, 0);
    22.  
    23.     //Row 2
    24.     Pallete[16] = D3DCOLOR_XRGB(173, 173, 173);
    25.     Pallete[17] = D3DCOLOR_XRGB(4, 62, 210);    // CORRECT 'Blue: Punch Out Ring Floor
    26.     Pallete[18] = D3DCOLOR_XRGB(66, 64, 255);
    27.     Pallete[19] = D3DCOLOR_XRGB(117, 39, 254);
    28.     Pallete[20] = D3DCOLOR_XRGB(160, 26, 204);
    29.     Pallete[21] = D3DCOLOR_XRGB(183, 30, 123);
    30.     Pallete[22] = D3DCOLOR_XRGB(145, 39, 1);    // CORRECT 'Dark Red: Marios suspenders in Super Mario Bros, Marios hair, mustache, and boots as fire mario.
    31.     Pallete[23] = D3DCOLOR_XRGB(113, 61, 0);    // CORRECT 'Brown: Ground Bricks and regular bricks of outdoor worlds in Super Mario Bros. Background of Super Mario Bros Title.
    32.     Pallete[24] = D3DCOLOR_XRGB(87, 89, 1);     // CORRECT 'Dark Greenish Yellow 'Marios Shirt
    33.     Pallete[25] = D3DCOLOR_XRGB(56, 135, 0);
    34.     Pallete[26] = D3DCOLOR_XRGB(0, 121, 0);     // CORRECT 'Dark Green: Hills, turtle shells, pipe, top of flag pole in Super Mario Bros. Green spots on 1-Up.
    35.     Pallete[27] = D3DCOLOR_XRGB(0, 143, 50);
    36.     Pallete[28] = D3DCOLOR_XRGB(0, 99, 133);    // CORRECT 'Dark Turquoise: Ground and ceiling bricks in dark worlds such as 1-2 of Super Mario Bros 'D3DCOLOR_XRGB(0, 104, 101) '
    37.     Pallete[29] = D3DCOLOR_XRGB(0, 0, 0);
    38.     Pallete[30] = D3DCOLOR_XRGB(0, 0, 0);
    39.     Pallete[31] = D3DCOLOR_XRGB(0, 0, 0);
    40.  
    41.     //Row 3
    42.     Pallete[32] = D3DCOLOR_XRGB(255, 254, 255);
    43.     Pallete[33] = D3DCOLOR_XRGB(100, 176, 255);
    44.     Pallete[34] = D3DCOLOR_XRGB(134, 129, 255); // CORRECT 'Sky Blue: Sky of outdoor worlds in Super Mario Bros
    45.     Pallete[35] = D3DCOLOR_XRGB(198, 118, 255);
    46.     Pallete[36] = D3DCOLOR_XRGB(243, 106, 255);
    47.     Pallete[37] = D3DCOLOR_XRGB(254, 110, 204);
    48.     Pallete[38] = D3DCOLOR_XRGB(254, 129, 112);
    49.     Pallete[39] = D3DCOLOR_XRGB(221, 141, 23);  // CORRECT 'Peach/Light Yello: Marios skin, Bright color coins, bright color ? blocks in Super Mario Bros. Mushroom main color.
    50.     Pallete[40] = D3DCOLOR_XRGB(188, 190, 0);
    51.     Pallete[41] = D3DCOLOR_XRGB(127, 200, 0);   // CORRECT 'Green: Pipes in Super Mario Bros. Bright Green Bushes
    52.     Pallete[42] = D3DCOLOR_XRGB(92, 228, 48);
    53.     Pallete[43] = D3DCOLOR_XRGB(69, 224, 130);
    54.     Pallete[44] = D3DCOLOR_XRGB(72, 205, 222);
    55.     Pallete[45] = D3DCOLOR_XRGB(79, 79, 79);
    56.     Pallete[46] = D3DCOLOR_XRGB(0, 0, 0);
    57.     Pallete[47] = D3DCOLOR_XRGB(0, 0, 0);
    58.  
    59.     //Row 4
    60.     Pallete[48] = D3DCOLOR_XRGB(255, 255, 255); // CORRECT 'White: Super Mario Bros Text. Clouds
    61.     Pallete[49] = D3DCOLOR_XRGB(192, 223, 255);
    62.     Pallete[50] = D3DCOLOR_XRGB(211, 210, 255);
    63.     Pallete[51] = D3DCOLOR_XRGB(232, 200, 255);
    64.     Pallete[52] = D3DCOLOR_XRGB(251, 194, 255);
    65.     Pallete[53] = D3DCOLOR_XRGB(254, 196, 234);
    66.     Pallete[54] = D3DCOLOR_XRGB(252, 204, 197); // CORRECT 'Pinkish White: Super Mario Bros Title Logo, White in bricks
    67.     Pallete[55] = D3DCOLOR_XRGB(253, 219, 175); // CORRECT 'Pinkish White 2: Marios Shirt with Fireflower in Super Mario Bros
    68.     Pallete[56] = D3DCOLOR_XRGB(228, 229, 148);
    69.     Pallete[57] = D3DCOLOR_XRGB(207, 239, 150);
    70.     Pallete[58] = D3DCOLOR_XRGB(189, 244, 171);
    71.     Pallete[59] = D3DCOLOR_XRGB(179, 243, 204);
    72.     Pallete[60] = D3DCOLOR_XRGB(181, 235, 242);
    73.     Pallete[61] = D3DCOLOR_XRGB(184, 184, 184);
    74.     Pallete[62] = D3DCOLOR_XRGB(0, 0, 0);
    75.     Pallete[63] = D3DCOLOR_XRGB(0, 0, 0);
    76.    
    77.     for (Current_Color = 0; Current_Color <= 63; Current_Color++)
    78.     {
    79.         Pallete[Current_Color + 64] = Pallete[Current_Color];
    80.         Pallete[Current_Color + 128] = Pallete[Current_Color];
    81.         Pallete[Current_Color + 192] = Pallete[Current_Color];
    82.     }
    83. }

    And this is how the colors should look. I put both the real NES captured through my El Gato and my emulator side by side along with yours to show you what I mean:

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    Good work on the capture. Yeah, my palette choice was a personal preference but I was thinking about making it selectable with the proper palette as the default. The ability to load in a PAL file would be nice too, and easy to add. For the audio, yes it needs some work. Sweeps don't work, never was able to get that right. The tone is also lower than it should be. This is an easy fix, I deliberately sped up sample generation slightly to ensure the buffer is always full when the sound card is ready for more data. Kind of a band-aid hack that I've been meaning to get back to. There's also a clicking issue with some games (for example, play SMB3 then pause it and wait a few seconds). I didn't have that in an older version of the emulator, I need to restore the audio module to an older version. Other than these known issues, I think it's fairly close.

    This emulator is largely a port from a C emulator I wrote a few years ago. There are a few bugs that got introduced during the port that I need to work out as well. Micro Machines doesn't play in the VB version, for one. I think it's a sprite zero hit problem.
    Last edited by miker00lz; Feb 10th, 2016 at 10:42 AM.

  5. #5
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    Well you could take a look at my NES emulator in my signature. The sweeps work there at least

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    I'll take a look at your sweeps, thanks. IIRC, there were some issues in your sound too like the SMB bricks smashing. The NES APU is just a tough beast to get right!
    Last edited by miker00lz; Feb 10th, 2016 at 12:32 PM.

  7. #7
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    Yea I'm not hearing bricks smash, but at least I get some nice beats / punch sounds in Double Dragon. And I literally matched my values with the documentation. Must have missed something.

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    32

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    EDIT: deleted
    Last edited by miker00lz; Mar 1st, 2016 at 08:40 AM.

  9. #9
    College Grad!!! Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,339

    Re: Nintendo Entertainment System emulator in VB6 [EXE + source]

    Hmmm missed it. If ya have any more NES questions let me know :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width