Announcing relaunch of Nezulator - now written in Javascript

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Grumskiz
Posts: 79
Joined: Sat Mar 26, 2011 1:06 pm
Location: Germany

Post by Grumskiz »

tokumaru wrote:
Bregalad wrote:(german keyboard)
Man, what a weird keyboard... Everything else (except for special characters, of course) is like a normal QWERTY keyboard, only Y and Z are swapped!
That's why I don't use it most of the time...(Yes, I'm from Germany btw)
My laptop has a QWERTY keyboard and I love it for the bigger shift-keys and it is also way better for programming since the special characters are somewhat "easier" to use...it's hard to explain but programming for me felt always more natural with a QWERTY keyboard than with the german QWERTZ one.

But there are more changes than you think: The "greater than" and "smaller than" are on a seperate key and the questionmark is where you would expect the hyphen to be.(They traded places as well)
Also the forward-slash is somewhat hard to reach (Shift + 7 key)
The weirdest thing is the Alt-Gr key which is used to put even more characters on one key. That's actually wouldn't be to bad, but you actually type EVEN more characters by using Shift+Alt-Gr+any key! It's like if they thought that we will need greek letters every day when we use our computer...

But yeah, it would be awesome if you could map the keys for yourself!
Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

Yeah, I can pretty easily put in keyboard maps. I'll do it as soon as I'm done implementing MMC2 for Punch out. (which is a PIA btw.. automatic mid-scanline nametable switching... )
User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz »

Zelex wrote:Yeah, I can pretty easily put in keyboard maps. I'll do it as soon as I'm done implementing MMC2 for Punch out. (which is a PIA btw.. automatic mid-scanline nametable switching... )
i've never been able to get the punch out mapper working quite right in my emulator, i didn't know about the auto nametable switching and i havent seen it in any docs. what exactly does it do?
Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

Basically, whenever the PPU or CPU reads/writes from some specific addresses, a bank change happens automatically at that point. This alleviates the CPU's need to do the bank switches manually.

So far I have the backgrounds behaving properly, but the sprites are not working 100% correctly. Unsure of the exact cause at the moment.
Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

Just got everything mostly working. Still a few glitches here and there that I'm working on, but otherwise very playable and enjoyable :)
Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

also just through in basic support for fire emblem, seeing as its nearly identical to MMC2. Still some graphical issues to work out however.
User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz »

looks pretty good. do you have a link to the doc you used to implement those automatic bank switches?

i would kill to get punch out going correctly in my emu! right now it runs the ROM, but there is graphical garbage everywhere. half the screens are barely recognizable, and then it locks up as you start the fight with glass joe.

here's what i get:

Image

Image

the second pic is the frame it locks up on. :(
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Waiting for a Sprite 0 hit I presume...
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

I primarilly referenced yoshi's doc and the nesdev wiki. The rest was just fiddling with things trying to figure out how the game actually uses the mapper.

One key point that the docs just brush upon, but don't really stress is that punch out *requires* that you to actually render the off-screen 33rd tile. It uses that tile to trigger the latch and switch VRAM banks.

Other than that. While your rendering the scan-line, every time it accesses < 0x2000 name tables, just do your latch calculations to possibly switch banks.

Example code:

Code: Select all


Nezulator.Mappers[9].prototype.reset = function() {
        Nezulator.Mappers[0].prototype.reset.apply(this);

        this.latch_a = 0xFE;
        this.latch_b = 0xFE;
        this.latchFD0 = 0;
        this.latchFE0 = 4;
        this.latchFD1 = 0;
        this.latchFE1 = 0;
        this.numTiles = 33;
};

Nezulator.Mappers[9].prototype.write = function(address, value) {
        // Writes to addresses other than MMC registers are handled by NoMapper.
        if (address < 0x8000) {
                Nezulator.Mappers[0].prototype.write.apply(this, arguments);
                return;
        }

        switch(address >> 12) {
        case 0xA:
                this.load8kRomBank(value, 0x8000);
                break;
        case 0xB:
                this.latchFD0 = value;
                if(this.latch_a == 0xFD) {
                        this.loadVromBank(this.latchFD0, 0x0000);
                }
                break;
        case 0xC:
                this.latchFE0 = value;
                if(this.latch_a == 0xFE) {
                        this.loadVromBank(this.latchFE0, 0x0000);
                }
                break;
        case 0xD:
                this.latchFD1 = value;
                if(this.latch_b == 0xFD) {
                        this.loadVromBank(this.latchFD1, 0x1000);
                }
                break;
        case 0xE:
                this.latchFE1 = value;
                if(this.latch_b == 0xFE) {
                        this.loadVromBank(this.latchFE1, 0x1000);
                }
                break;
        case 0xF:
                if(value & 0x1) {
                        this.nes.ppu.setMirroring(this.nes.rom.HORIZONTAL_MIRRORING);
                } else {
                        this.nes.ppu.setMirroring(this.nes.rom.VERTICAL_MIRRORING);
                }
                break;
        default:
                break;
        }
};

Nezulator.Mappers[9].prototype.loadROM = function(rom) {
    if (!this.nes.rom.valid) {
        alert("MMC2: Invalid ROM! Unable to load.");
        return;
    }

    // Load PRGUROM:
    // Swappable
    this.load8kRomBank(0, 0x8000);

    // Hard-wired
    this.load8kRomBank((this.nes.rom.romCount * 2) - 3, 0xA000);
    this.load8kRomBank((this.nes.rom.romCount * 2) - 2, 0xC000);
    this.load8kRomBank((this.nes.rom.romCount * 2) - 1, 0xE000);

    // Load CHR-ROM:
    this.loadVromBank(4, 0x0000);
    this.loadVromBank(0, 0x1000);

    // Do Reset-Interrupt:
    this.nes.cpu.requestIrq(this.nes.cpu.IRQ_RESET);
};

Nezulator.Mappers[9].prototype.latchAccess = function(address) {
        address &= 0x1FF0;
        if(address === 0x0FD0 && this.latch_a != 0xFD) {
                this.latch_a = 0xFD;
                this.loadVromBank(this.latchFD0, 0x0000);
        } else if(address == 0x0FE0 && this.latch_a != 0xFE) {
                this.latch_a = 0xFE;
                this.loadVromBank(this.latchFE0, 0x0000);
        } else if(address == 0x1FD0 && this.latch_b != 0xFD) {
                this.latch_b = 0xFD;
                this.loadVromBank(this.latchFD1, 0x1000);
        } else if(address == 0x1FE0 && this.latch_b != 0xFE) {
                this.latch_b = 0xFE;
                this.loadVromBank(this.latchFE1, 0x1000);
        }
};

Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

I should mention that Yoshi's doc is wrong. My code is right.

Fixed most of the graphical glitches early this morning. Still one left w/ scanlines and sprites. Probably a timing issue.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Sprite character fetches happen during "hblank time", not during background render time.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

I tried on rekonq and Firefox (both linux) too. On rekonq, like in Opera, the drag and drop doesn't even have any effect and the google search is not working so I don't know how it works.

In firefox, it runs even 1000 times slower than in Opera (where it was already slow), the whole computer slowed down completely and the mouse was barely moving anymore, I'm glad it didn't crash.
Useless, lumbering half-wits don't scare us.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Bregalad wrote:In firefox, it runs even 1000 times slower
Firefox 3 or Firefox 4? If the latter, please report it to bugzilla.mozilla.org.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

I just tested Nezulator on my Chu Chu Rocket game. The joypad reading code fails on that emulator.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Zelex
Posts: 268
Joined: Fri Apr 29, 2011 9:44 pm

Post by Zelex »

Dwedit wrote:I just tested Nezulator on my Chu Chu Rocket game. The joypad reading code fails on that emulator.
Just in case, make sure you click on the emulator first before trying the controls.

That being said, I did notice that one of the homebrew test roms didn't work with the emulator's joystick code. I'm really not sure why. Perhaps its using some kind of hacky trick to read the input? I haven't looked into it yet as every game I've ever tested has never had the issue. Email me the rom and I'll take a peak at it. jon.olick [at] gmail.com
Last edited by Zelex on Sun May 08, 2011 12:34 pm, edited 1 time in total.
Post Reply