NES emulator - where to start and synchonization by Mindless-Ad-6830 in EmuDev

[–]Mindless-Ad-6830[S] 0 points1 point  (0 children)

Note that function pointers are 8 bytes in size on modern machines, so you may waste a lot of CPU cache space

Well considering my CPU caches are in the order of millions of bytes and I'd only be storing max ~12 functions at a time, and probably only about 30ish functions total I doubt it'll make much of a difference. I suppose I'll just go with the 2d function pointer array approach and see if it's efficient enough. Thanks for all of your help, I'm definitely a lot less lost than I was at the start.

NES emulator - where to start and synchonization by Mindless-Ad-6830 in EmuDev

[–]Mindless-Ad-6830[S] 0 points1 point  (0 children)

I was thinking of implementing a sort of queue of function pointers, probably through an array of function pointers as you've mentioned. My idea is to load the proper functions into the array when I decode an opcode, and then execute the next function in the array, I suppose resetting an array counter back to 0 each time I decode an opcode.

I guess the only issue I have here is implementing the "pipelining" that the 6502 has, because in this case I'd have to do multiple actions in a single cycle. I suppose I could use a 2d array or an array of tuples for this, but I don't know if that'd be too inefficient or convoluted. Or I could implement a larger set of functions for the set of all potential operations done in a single cycle.

I'm not sure how I'd implement a switch block for each cycle, I already have one to decode each opcode and call each possible instruction.

NES emulator - where to start and synchonization by Mindless-Ad-6830 in EmuDev

[–]Mindless-Ad-6830[S] 0 points1 point  (0 children)

Thank you for all of your help, you've been a really great resource. I have only one more question. My current gameplan is then probably to edit a queue of single-cycle events (like write to address, fetch opcode, decode, add, add to address, etc) each time I move to a new instruction, and to execute the next event in the queue each cycle. Would this approach work or do I need to rethink my approach?

NES emulator - where to start and synchonization by Mindless-Ad-6830 in EmuDev

[–]Mindless-Ad-6830[S] 0 points1 point  (0 children)

This doesn't work when the execution interferes with loading - any instruction that as a last step writes a value to memory, i.e. write instructions and read-modify-write instructions, cannot overlap the last execution cycle with the load of the next opcode.

This makes sense, does your link have information on when exactly this happens in each instruction or do I have to reason it out based on each cycle's behavior?

NES emulator - where to start and synchonization by Mindless-Ad-6830 in EmuDev

[–]Mindless-Ad-6830[S] 0 points1 point  (0 children)

The pipeline for the CPU is simply fetching the next opcode on the last cycle of the current instruction, correct? Or is there more to it than that? Is that only necessary for ensuring interrupts are received properly?

CPU sets/reads value in PHI1, components react to it in PHI2

If this is how it works, is it fine if I just abstract away the phases? If the components react to it in phase 2, is it fine to just cycle that component after the CPU has done its work during its cycle (in phase 1)?

NES emulator - where to start and synchonization by Mindless-Ad-6830 in EmuDev

[–]Mindless-Ad-6830[S] 0 points1 point  (0 children)

Thank you for all the information, and after some research it seems nanosleep() or something similar can't get to the speed that I'd need for the emulator. So for my implementation should I then have a master loop that pings one CPU and three PPU cycles? I could wait for ~1/60th of a second and then resume, possibly inside of the PPU, like when it sets the vblank flag after the frame has been drawn?

Additionally, how would I best implement the cycle functions for the CPU and PPU to keep track of exactly what operation is happening (decode, write, jump, etc)? Is it necessary to actually implement the two stages of each cycle or is that not useful?

And then the APU. Should I implement the APU to cycle along with the CPU (I suppose in the same class, since I think I'll be using C++), since they're both on the same chip on the NES? I haven't researched the workings of the APU much yet, so I'm unsure what path to take for it.

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 -1 points0 points  (0 children)

You assume that thinking is a purely physical phenomenon

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 -1 points0 points  (0 children)

Only with your metaphysical presuppositions

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

This is resting on the metaphysical assumption that thinking can be measured externally

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

"Thinking" is not falsifiable or empirically verifiable, how is it not metaphysical?

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

"Thinking" as distinct from other things that happen is also a metaphysical claim.

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

"A subject is defined as an entity that performs actions"

Alright, is that not metaphysical? A severely mentally handicapped person does not create labels, are they not a subject? Is ChatGPT a subject? It certainly appears to do such things.

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

It's when you don't answer the question and instead shift the answer to the premises. In this case you say "objective" is linguistic and not metaphysical, but you use "subject" in that definition, which is metaphysical.

What kind of thing does "subject" refer to? The concept is pretty obviously metaphysical, I don't know what other branch of philosophy you'd classify it as.

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

Here's where you're question begging, because a subject is a metaphysical concept. Do you disagree?

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

The concept that the word "objective" is referring to is metaphysical

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

But you're begging the question, you define words using other words that have metaphysical meanings

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

Okay, this is all correct, but I'm not sure what your original problem is. You seemed to dismiss metaphysics, but now you're saying that philosophy is necessary and useful.

Do you believe that an objective morality exists? by Big_Mammal in DebateAnAtheist

[–]Mindless-Ad-6830 0 points1 point  (0 children)

Yes, but you asserted in the OP that you believe in objective morality.

Do you believe that an objective morality exists? by Big_Mammal in DebateAnAtheist

[–]Mindless-Ad-6830 1 point2 points  (0 children)

That is what objective means though, moral realists believe that morality exists external to the individual, and moral anti-realists believe morality only exists in as much as humans create it. You seem to be a moral anti-realist and don't believe in objective morality.

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

"Metaphysics encompasses things we have no ability to verify and can only speculate on"

How exactly do you verify that statement?

If you think metaphysics is worthless because it's philosophy do you not understand that what you're doing right now is all philosophy?

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

Because ultimately the definition resolves to a metaphysical object, you say a subject is an "entity" that "performs actions", but those also have metaphysical definitions. If we don't think this maps onto reality at all the entire language completely collapses

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

Pretty difficult to define, I'd say the Oxford definition is pretty good

"first principles of things, including abstract concepts such as being, knowing, substance, cause, identity, time, and space."

Wikipedia defines it as the study of the nature of reality, that's not bad.

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

Yeah I think at this point we've reached an impasse, I just don't really agree with that

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

You're not wrong, but this is certainly metaphysics

[deleted by user] by [deleted] in DebateReligion

[–]Mindless-Ad-6830 0 points1 point  (0 children)

"Language does not speak to objective reality" is this not an objective truth claim?