#Nes Emulator

1 messages Β· Page 1 of 1 (latest)

ashen vapor
#

(Ignore the fact the picture was taken from my phone, im in class atm)

I got bored one day and was hyperfixating on making an nes emulator for something and, since i noticed people had trouble doing stuff like this in glua, I thought I'd give it a shot!

I only got enough opcode and work on the internal bits to JUST get to the title screen of super Mario bros, only super mario bros, and even then, it's lacking all object sprites.

My ONLY ISSUE I've been facing, other than controller input, is sprites, since idfk how the sprites on the nes ppu get rendered. All ik is that it's something to do with OEM, it could be the way I'm writing to them that's causing problems but idk.

Anyways, I doubt this will get finished anytime soon, but I thought it'd be neat to share here just in case anyone had any input on how I could continue this or even just small tidbits ig.

#

I'll try to get a better picture when I get home

#

Oh yeah also the palette is fucked, if you couldn't already tell 😭

#

I'm mainly impressed i even got THIS to work

ashen vapor
scenic kernel
#

okay i like this lol
also you could maybe take advantage of the luajit compiler by making a nes bytecode to lua transpiler

#

would also possibly make catching bugs a little easier

#

although uhh, if its RWX its not gonna work i guess

#

and identifying subroutines would not be very convenient either

#

well, too much work for something like that lol

ashen vapor
#

I probably do need to fix up the opcode table BTW, it's full of so many duplicates 😭

ashen vapor
#

Sorry for not showing much of this, I really got bored of working on it because of the sprite OEM not working at all.

If ANYONE knows anything about the sprite OEM and how it's read from and written to, I'd appreciate the assistance here.

ashen vapor
#

Ayyy something

ashen vapor
#

Okay so, input does work on the emulator, just not on super mario bros 1 😭

#

It works fine on an nes test rom

dim raptor
ashen vapor
#

If you wanted something just like that, i think the "easiest" way to do it would be porting the code over. I dont think the performance would be too good though, considering how many times I have to run the cpu in my emulator just to have it run at it's proper speed (albeit, awful fps on Garry's Mod)

dim raptor
#

indeed

ashen vapor
#

-- NESTEST.NES RESULTS --
Branch tests: OK
Flag tests: OK
Immediate tests: 21
Implied tests: OK
Stack tests: OK
Accumulation tests: OK
(Indirect,X) tests: 6A
Zeropage tests: AD
Absolute tests: E7
(Indirect),Y tests: FD
Absolute,Y tests: 4F
Zero Page,X tests: 33
Absolute,X tests: 76

NOP tests: OK
LAX tests: F6
SAX tests:
SBC test (opcode 0EBh): OK
DCP tests:
ISB tests:
SLO tests:
RLA tests:
SRE tests:
RRA tests:

ashen vapor
#

I got all the Access Opcodes (LDA, STA, LDX, STX, LDY, AND STY) rewritten and organized, along with all the jump instructions

#

I paused work on fixing the OAM so I could finish the CPU opcodes

#

And just in case you were, for some reason, wondering:
Yes, I did implement NOP opcode, and yes, it does absolutely nothing but waste space in your code.

ashen vapor
#

All the stack related opcodes should be done

ashen vapor
#

The only annoying part of translating functionality is needing to convert the bitwise operands with the bitwise functions

ashen vapor
#

Seperate from the emulator of course

#

That's the only reason I really came back to the emulator, I felt like I could optimize things since i had learned alot about lua since last time (not that i didn't know much, moreso that my code was god awful without any helpers)

#

Official 6502 Opcode Checklist:

Access: βœ…
Transfer βœ…
Arithmetic: βœ…
Shift: βœ…
Bitwise: βœ…
Compare: βœ…
Branch: βœ…
Jump: βœ…
Stack: βœ…
Flags: βœ…
Other: βœ…

#

Orange means not all modes are implemented but the atleast ONE of the modes is accounted for

ashen vapor
#

Might actually remove most of the old opcode implementations and start off of the current new implementations

ashen vapor
#

However, I have no clue how much will break if I remove alot of the old ones so let me test that first

ashen vapor
#

Just found out how palettes work now I think

ashen vapor
#

That um...sorta worked?

ashen vapor
#

Getting closer

ashen vapor
#

The last issue to deal with for background graphics is pretty much just this whole palette issue, I found out about attribute bytes so thats likely what I'll be doing tommorow, along with adding more opcode

ashen vapor
#

Ngl, I'm probably doing alot of things that could be minimized into a few if statements ngl

#

Like, after looking at smolnes for reference on how opcodes work, they have some fuckass calculation to allow them to not have to define every single one

#

Currently, I'm defining every single one by hand

ashen vapor
#

30-40 fps on the nestest rom may seem pretty bad but this is a hell of a alot better than what it used to be

ashen vapor
#

All Arithmetic opcodes are done

ashen vapor
#

All Shift opcodes are done

ashen vapor
#

Gonna take a little detour right now so i work on adding other mapper support, so, at the very least, more than smb1 can be loaded

ashen vapor
#

The CPU's opcode list is almost done

ashen vapor
#

Okay, every opcode has been implemented

#

Now it's time to test them, because the nes test rom is still saying some are incorrect, so now its time to fix all of them

ashen vapor
ashen vapor
#

Eventually, I might just post the code on github so I can get some help with figuring out the problems I'm having

#

So far, I can't figure out how the OAM is getting written to and read from

#

I was watching a video from portal runner on how they did it for vscript and like, it COULD be breaking due to not everything using my wrap functions (wrapping 8 bit and 16 bit values so they don't exceed that)

ashen vapor
#

DUCK HUNT OFFICIALLY RUNS ON THE EMULATOR

#

LITERALLY 5 FPS BUT I DON'T CARE, THIS TOOK SO LONG TO GET WORKING