Giter VIP home page Giter VIP logo

olcnes's People

Contributors

onelonecoder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

olcnes's Issues

I don't understand how SBC works

// A = A - M - (1 - C) -> A = A + -1 * (M - (1 - C)) -> A = A + (-M + 1 + C)

You wrote:
A = A - M - (1 - C) = A + -1 * (M - (1 - C)) = A + (-M + 1 + C)

Possibly two mistakes here - first is, A - M - (1 - C) factors to A + -1M + -1(1 - C) = A + -1(M + (1 - C)) IMHO?
Second, if I try the last part myself, I get A + -1 * (M + -1(1 - C)) = A + -1 * (M + -1 + C) = A - M + 1 - C

If I try from scratch, I get:
A = A - M - (1 - C) = A - M - 1 + C = A + C + -1 * (M + 1) = A + C - M - 1

Alternatively:
A = A - M - (1 - C) = A + -1M + -1(1 - C) = A + -1 (M + (1-C)) = A + -1 (M + 1 - C) = A - M - 1 + C

(both results equivalent to A+C-M-1)

Is there something I'm misunderstanding there?

I mean, I'm not doubting your code works fine (in fact, seeing Duck Tales run, I'm pretty sure it does...), but maybe the explanation of WHY it runs is slightly inaccurate?

disassembler: relative address calculation needs sign extension

In the dissasembler, the calculation for the relative address does not take into account negative values.

Sign extending the address should do the trick, something like this (I did not test this particular piece of code because my implementation is a bit different).

else if (lookup[opcode].addrmode == &olc6502::REL)
{
	value = bus->read(addr, true); addr++;
	uint32_t addr_rel = value;

	if (addr_rel & 0x80)
		addr_rel |= 0xFFFFFF00;

	sInst += "$" + hex(value, 2) + " [$" + hex(addr + addr_rel, 4) + "] {REL}";
}

else if (lookup[opcode].addrmode == &olc6502::REL)
{
value = bus->read(addr, true); addr++;
sInst += "$" + hex(value, 2) + " [$" + hex(addr + value, 4) + "] {REL}";
}

ExampleProgram in Part 3 open then shut immediately when ran

Situation

  • I tried to run 3rd tutorial: Bus, RAM,...
    g++ -o olcExampleProgram2 *.cpp -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17
    it compiles ok, then I run
    ./olcExampleProgram2
    it open, then close right away.
  • Part 2 runs fine, but from part 3 and on, it has the same behavior

Info

  • Im using Debian 11, with i3wm (dont know if it matters)
  • I followed this for compiling, installation instruction in Ubuntu.
  • Please tell me if you need more specs info.

Please help me out, thanks.

Incorrect ROL and ROR implementations

Edit: removed content due to an oversight on my part.

I did not catch that fetched was being set to a in the IMP mode, as this isn't in my code (I must have missed that in the video). Sorry.

B Flag doesn't actually exist (so don't save it in register)

Much like the U flag, the B flag in the status register doesn't actually exist in hardware. That means that reading the status register should always yield a 0 in the B flag place. The B register is only ever used when BRK or PHP are called to place a 1 in it's place on the stack.
This is implemented in code only by guarding the BRK and PHP and hardware interrupt routines.
But pulling a value with status flags from the stack and putting them into the status register (PLP) will set the Break flag, even though it should always be 0.

Sprite Zero bug.

in olc2C02.cpp

in clock function the following is specified :

				// If pixel is not transparent, we render it, and dont
				// bother checking the rest because the earlier sprites
				// in the list are higher priority
				if (fg_pixel != 0)
				{
					if (i == 0) // Is this sprite zero?
					{
						bSpriteZeroBeingRendered = true;
					}
					break;
				}				

it needs to be : -

`				// If pixel is not transparent, we render it, and dont
				// bother checking the rest because the earlier sprites
				// in the list are higher priority
				if (fg_pixel != 0)
				{
					if (bSpriteZeroHitPossible && i == 0) // Is this sprite zero?
					{
						bSpriteZeroBeingRendered = true;
					}
					break;
				}				

`

otherwise, as soon as any sprites are drawn on lines before sprite zero, they will count as being sprite zero.

So now you can get to the warp zones in SMB without blanking the screen :)

Cycle precision on addressing modes

Wouldn't be better to change cycles count directly on addressing modes functions as we do on branches, since it is called after the cycles initialization?

This way we can be more cycle precise for some games that depends on it

Fix: Cartridge.h error: 'shared_ptr' in namespace 'std' does not name a template type

E:\Code\PGE\olcNes_Sounds1\src\Cartridge.h|94|error: 'shared_ptr' in namespace 'std' does not name a template type|
E:\Code\PGE\olcNes_Sounds1\src\Cartridge.h|70|note: 'std::shared_ptr' is defined in header '<memory>'; did you forget to '#include <memory>'?|

I don't know if it is necessary or not in Visual Studio but in Code::Blocks using TDM64-GCC 9.2.0 #include is necessary in Cartridge.h file. ;)

The error is present starting Part 3 continues on all parts.

Edit: Compilation parameters are as follows.

g++.exe -Wall -std=c++17 -O2 -m64  -c E:\Code\PGE\olcNes_Sounds1\src\Cartridge.cpp -o obj\Release-Win64\src\Cartridge.cpp.o
g++.exe -Wall -std=c++17 -O2 -m64  -c E:\Code\PGE\olcNes_Sounds1\src\olc2C02.cpp -o obj\Release-Win64\src\olc2C02.cpp.o
g++.exe  -o bin\olcNes_Sounds1-Win64.exe obj\Release-Win64\src\Bus.cpp.o obj\Release-Win64\src\Cartridge.cpp.o obj\Release-Win64\src\Mapper.cpp.o obj\Release-Win64\src\Mapper_000.cpp.o obj\Release-Win64\src\Mapper_001.cpp.o obj\Release-Win64\src\Mapper_002.cpp.o obj\Release-Win64\src\Mapper_003.cpp.o obj\Release-Win64\src\Mapper_004.cpp.o obj\Release-Win64\src\Mapper_066.cpp.o obj\Release-Win64\src\olc2A03.cpp.o obj\Release-Win64\src\olc2C02.cpp.o obj\Release-Win64\src\olc6502.cpp.o obj\Release-Win64\src\olcNes_Sounds1.cpp.o  obj\Release-Win64\src\Version.rc.res -static-libstdc++ -static-libgcc -s -m64  -luser32 -lgdi32 -lopengl32 -lgdiplus -lshlwapi -ldwmapi -mwindows

Add link to 'nestest.nes'

In the latest video, you use a nes ROM to test some emulator functionality.

Could you provide a link to that ROM file?

BCD Support

@OneLoneCoder I'm not sure if you said this in the video, but are you planning to implement BCD?

Currently the instructions ADC and SBC are implemented only in binary mode; e.g. they ignore the D flag. It would be nice to have these also (correctly) implement decimal mode.

I'm not sure if there are any games using this mode, but I heard that some 6502 programs do.

Actually use revision control

This will be a polemic from a pompous arse, do forgive me. I do like your videos, however...
While I realize that I am perfectly capable of diffing two of the directories that you've made (kdiff3 being my tool of choice), GitHub includes tools that allow anyone to view the differences between two commits and see what has changed. I just feel that it would be more useful to teach people how to use (git and a site like GitHub) effectively than to have them diff things themselves. If you want to go back in time, you can checkout a specific revision.

Just my unwanted two cents.

PS. Did you know that this is a thing: https://jsnes.org/

CPU.cpp a little mistake in comment

There are some small mistakes in the comment, also in the video
old: A = A - M - (1 - C) -> A = A + -1 * (M - (1 - C)) -> A = A + (-M + 1 + C)
new: A = A - M - (1 - C) -> A = A + -1 * (M + (1 - C)) -> A = A + (-M - 1 + C)

code is right, because
-M = +value + 1 ( value = fetched & 0x00FF )
A = A + (value + 1) - 1 + C

thank for your sharing, then I can learn this interesting thing.

olc2C02.cpp error: use of deleted function 'olc::Sprite::Sprite(const olc::Sprite&)'

E:\Code\PGE\olcNes_Sounds1\src\olc2C02.cpp|59|error: use of deleted function 'olc::Sprite::Sprite(const olc::Sprite&)'|

I'm trying to build the source in Code::Blocks using TDM64-GCC 9.2.0 with no success. :(

The error is present starting Part 3 continues on all parts.

Edit: Compilation parameters are as follows.

g++.exe -Wall -std=c++17 -O2 -m64  -c E:\Code\PGE\olcNes_Sounds1\src\olc2C02.cpp -o obj\Release-Win64\src\olc2C02.cpp.o
g++.exe  -o bin\olcNes_Sounds1-Win64.exe obj\Release-Win64\src\Bus.cpp.o obj\Release-Win64\src\Cartridge.cpp.o obj\Release-Win64\src\Mapper.cpp.o obj\Release-Win64\src\Mapper_000.cpp.o obj\Release-Win64\src\Mapper_001.cpp.o obj\Release-Win64\src\Mapper_002.cpp.o obj\Release-Win64\src\Mapper_003.cpp.o obj\Release-Win64\src\Mapper_004.cpp.o obj\Release-Win64\src\Mapper_066.cpp.o obj\Release-Win64\src\olc2A03.cpp.o obj\Release-Win64\src\olc2C02.cpp.o obj\Release-Win64\src\olc6502.cpp.o obj\Release-Win64\src\olcNes_Sounds1.cpp.o  obj\Release-Win64\src\Version.rc.res -static-libstdc++ -static-libgcc -s -m64  -luser32 -lgdi32 -lopengl32 -lgdiplus -lshlwapi -ldwmapi -mwindows

Compile the game and load a room but don't have proper sound

Hello
First than all, awesome channel, and thank you for sharing your knowledge.
I compile the emulator and load a room but don't have proper sound,
in the sound plotter only appear horizontal dash, no vertical, and interrupted sounds on my speakers.
Also attach and print screen of the plotter bellow, Hope to find a solution for this issue.
thanks and best regards
Untitled

Cartridge.cpp ppuWrite calling pMapper.ppuMapRead?

I'm just in the process of porting this code, and this method has me a little confused. Is line 124 a typo? Should the ppuWrite method be obtaining the mapped address using the ppuMapRead logic?

if (pMapper->ppuMapRead(addr, mapped_addr))

Full method:

bool Cartridge::ppuWrite(uint16_t addr, uint8_t data)
{
	uint32_t mapped_addr = 0;
	if (pMapper->ppuMapRead(addr, mapped_addr))
	{
		vCHRMemory[mapped_addr] = data;
		return true;
	}
	else
		return false;
}

Possible incorrect bounds check in DrawCode()?

Hi,

while porting this to Pascal, I noticed that when you're drawing the code lines before the current line, you check against mapAsm.end(), when I think it should be mapAsm.begin(), right?

Not that it matters in this case, so thanks!

Initial value of stkp during initialization

Hi,

would it be safe (for consistency) to set stkp to 0xFD during initialization like it is done when reset() is called?

public:
...
 uint8_t y = 0x00;
 uint8_t stkp = 0xFD;
...

public:
// CPU Core registers, exposed as public here for ease of access from external
// examinors. This is all the 6502 has.
uint8_t a = 0x00; // Accumulator Register
uint8_t x = 0x00; // X Register
uint8_t y = 0x00; // Y Register
uint8_t stkp = 0x00; // Stack Pointer (points to location on bus)
uint16_t pc = 0x0000; // Program Counter
uint8_t status = 0x00; // Status Register

// Reset internal registers
a = 0;
x = 0;
y = 0;
stkp = 0xFD;
status = 0x00 | U;

Part #7 - Emulator no sound on Macos Ventura v13.6.6

Hello @OneLoneCoder, thank you for your videos. :)

I arrived at the last video in your series of videos on the development of the NES emulator, but when I run the emulator after it is compiled, the roms of several games the image appears, but the sound does not work and it does not show any error in the terminal, I think This would be because macos does not support the sound libraries that were added to the project.

image

Command to compile:

LIBRARIES = -framework OpenGL -framework GLUT -framework Carbon -lpng -framework OpenAL

EXE_DEBUG = ./bin/debug
EXE_TESTS = ./bin/tests
FILES_TO_LINKED = Mapper.cpp Bus.cpp Mapper_000.cpp Mapper_001.cpp Mapper_002.cpp Mapper_003.cpp Mapper_004.cpp Mapper_066.cpp olc6502.cpp olc2C02.cpp olc2A03.cpp Cartridge.cpp

clang++ -arch x86_64 -std=c++17 -mmacosx-version-min=10.15 -Wall $(LIBRARIES) olcNes_Sounds1.cpp ${FILES_TO_LINKED} -o $(EXE_DEBUG) -v

Note: Your Sound example from the SoundDemo.cpp files also does not work, without errors in the terminal, it just opens the program screen and the sound is muted.

Is there any alternative to make the sound work in the emulator on macos? Anybody know?

Tks

Disassemble logging "error" on REL addressing mode

I am using this project as a model to create a NES emulator using Java.

There's something happening here, when I run the code showed in the video value should be -6, but it's going as 250. Which causes inaccurate logging.
https://github.com/OneLoneCoder/olcNES/blob/master/Part%232%20-%20CPU/olc6502.cpp#L1580

To fix this in Java I did a explicit cast to byte, unfortunately I don't know how to do in C++...

For example, here in the video it should be BNE #$FA [$8010] {REL} instead of BNE #$FA [$8110] {REL}
image

Don't stay at home, and don't protect the UK's stupid & moron & donkey "national" clown "service".

@OneLoneCoder Shame on you David, you worthless loser slave. Shame on you cheap loser slave for openly promoting the stupidest places on earth ["univeristies"] and boasting about your daftness when you included that disgusting 3-letter word in your trashy account description. Death to you and death to every loser slave who uses the disgusting 2-letter word stupid "title" when mentioning first names. Death to every cheap loser slave who refers to that infinitely stupid and dumb 2-letter word. You showned nothing other that how stupid and cheap you mainstream propaganda clowns are. Death to "univeristies". Death to every low life lower clown who uses those stupid and childish and pathetic "prefixes" when mentioning first names. Death to open source. Hope you have a tragic life and painful death.

Death to the UK. Death to the stupid and trashy "national" [garbage] "service. Don't stay at home, and don't protect the stupid moron donkey "national" clown "service".

Shame on them, cheap slaves. Shame on them cheap loser slaves for promoting dumpsters in socities called "universities" [dumpsterversities]. Shame on David for boasting about his stupidity. How extremely dumb and childish you are for promoting those ultra racist clowns. Death to "univeristies" [dumpsterversities]. Death to every low life lower clown who uses those stupid and childish and pathetic "prefixes" when mentioning first name. Death to open source. Death to OneLoneCoder David. Hope you clown devs have a tragic life and painful death.
And another thing....

Stop making lies about real Engineering. Engineering has nothing to do with sitting behind a keyboard and writing code or games. Engineering is a real subject. Engineering means designing and building real mechanical systems, like vehicular engines and turbojets. Software devs are the biggest liars. Game/software devs have absolutely nothing to do with engineering, you are just being stupid wannabe liars. You will never be engineers, not even close. In fact, you don't even know what it takes to be an engineer. None of you are engineers, and you'll never even be close. So stop being disrespectful to real engineers (mechanical engineering is real engineering, and nothing else)
Mechanical Engineering is the ONLY ENGINEERING. Period.

A slight correction to ASL to more clearly represent the opcode definition

Per: http://www.obelisk.me.uk/6502/reference.html#TSX

C = the contents of the old bit 7

While the provided code does this, to someone newer at this kind of thing, it looks like it doesn't

I'd recommend changing the implementation to the following:

uint8_t olc6502::ASL()
{
	fetch();
	SetFlag(C, (fetched & 0x80)); //this will return either a 1 or a 0, so we don't need > 0 here

        fetched = (uint8_t)(fetched << 1); //could also be replaced with fetched *= 2.  the cast is to prevent the possibility of the compiler upgrading fetched to uint16_t)
	SetFlag(Z, (fetched & 0xFF) == 0x00);
	SetFlag(N, fetched & 0x80); //funnily enough, this is the same code we use to initially set the carry flag since bit 7 is the sign
	if (lookup[opcode].addrmode == &olc6502::IMP)
		a = fetched;
	else
		write(addr_abs, fetched);
	return 0;
}

This is pretty much my implementation of this opcode, and I was checking against the source code provided and initially thought I was doing something wrong (even though I'm not newer to this, I've written a full CHIP 8 emulator and done some other things using binary for a private server project). It took longer than I'd like to admit to realise that the code provided does the same thing, it just does some extra things that could be removed (yay optimization).

Part #3: segfault after compilation

Hi! thank you for really deep dive into NES internals :)
I wanted to play around with part 3's "cpu monitor" but i am unable to.

Looking around part 2's source i figured out possible g++ invocation
lis6502@e595:/var/tmp/auda/olcNES/Part #3 - Buses, Rams, Roms & Mappers$ g++ -o example Mapper.cpp Mapper_000.cpp Cartridge.cpp Bus.cpp olc2C02.cpp olc6502.cpp olcNes_Video2_2C02.cpp -lX11 -lGL -lpthread -lpng -lstdc++fs -std=c++17 -I ../../olcPixelGameEngine/
my g++ version
lis6502@e595:/var/tmp/auda/olcNES/Part #3 - Buses, Rams, Roms & Mappers$ g++ --version g++ (Debian 11.3.0-3) 11.3.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

with -Wall it threws some undefined pragma warnings, but other than that produces executable file.

lis6502@e595:/var/tmp/auda/olcNES/Part #3 - Buses, Rams, Roms & Mappers$ ./example Segmentation fault

I am not much into cpp, especially when i realized that order of arguments like sources, executable name and include paths are significant.
What am i doing wrong here?

ps.1 olcPGE example complies just fine.
ps.2 at Cartridge.h you've missed #include <memory> ;p

Peripherals sync with instantaneous operations of 6502

This is more a question than a real issue, albeit that could be an issue.

Hasn't the CPU a few cycles of advance to the peripherals of the NES? The olc6502 performs the whole instruction in the first clock of an instruction:

// Perform operation
uint8_t additional_cycle2 = (this->*lookup[opcode].operate)();

// Decrement the number of cycles remaining for this instruction
cycles--;

@OneLoneCoder mentioned this emulator emulates only the behaviour and is not cycle-accurate but doesn't this cause sync issues? In particular, I am thinking of the PPU since it performs operations at every clock cycle.

Interesting typo

// Pneumonic : A textual representation of the instruction (used for disassembly)

"Pneumonic" means it's somehow related to pneumonia. You probably meant "mnemonic" unless you intend to make your emulator ill.

BRK

BRK has to increment the PC by 2.
I flag should not be saved on the stack.

BTW: Nevertheless - This is a great and super understandable piece of software. Thank you!
Learned a lot...

MMC3 IRQ Issues

There is some issues with MMC3 on some games, might be related to different revisions of the chip.
For example, Kirby's adventure (MMC3C) does not render the status bar properly.

Looking at the implementation, it seems to be the correct "new/normal" behavior.
I tried fiddling with IRQs while nIRQReload == 0, but same result. My C# port has the exact same problem
It kind of displays if I force IRQ on some cycles, but it messes up other things.

Anyone has any idea what might be off ?

Thanks !

BRK instruction on [0,0] must be in 'implied' address mode, instead IMMediate

{ "BRK", &a::BRK, &a::IMM, 7 },{ "ORA", &a::ORA, &a::IZX, 6 },{ "???", &a::XXX, &a::IMP, 2 },{ "???", &a::XXX, &a::IMP, 8 },{ "???", &a::NOP, &a::IMP, 3 },{ "ORA", &a::ORA, &a::ZP0, 3 },{ "ASL", &a::ASL, &a::ZP0, 5 },{ "???", &a::XXX, &a::IMP, 5 },{ "PHP", &a::PHP, &a::IMP, 3 },{ "ORA", &a::ORA, &a::IMM, 2 },{ "ASL", &a::ASL, &a::IMP, 2 },{ "???", &a::XXX, &a::IMP, 2 },{ "???", &a::NOP, &a::IMP, 4 },{ "ORA", &a::ORA, &a::ABS, 4 },{ "ASL", &a::ASL, &a::ABS, 6 },{ "???", &a::XXX, &a::IMP, 6 },

NTSC | PAL

                If (GameFileHeader.tv_system1 And &H1) = &H1 Then 'check if bit 0 is set as 1
                    m_ntsc = True ' 1 = NTSC
                Else
                    m_ntsc = False ' 0 = PAL
                End If
                if ((GameFileHeader.tv_system1 & 0x1) == 0x1) { //check if bit 0 is set as 1
                    m_ntsc = true; // 1 = NTSC
                } else {
                    m_ntsc = false; // 0 = PAL
                }

since i didnt come across it in your code. edit: or was that ines2.0 only lol, my eyes a burning.

RTI

I guess RTI should not restore the Interrupt flag because when I unset it with CLI and then RTI from the Interrupt routine it is set again bacause it was saved when entering the IRQ.

OR the IRQ routine may simply set the I flag after the Status-Register is saved.
Same with NMI.

EDIT:
Found this in the datasheet :)
The Program Counter and Processor Status Register are stored in the stack.
The microprocessor will then set the interrupt mask flag high so that no further interrupts may occur.

Jump and coin sounds are distorted in Super Mario Bros.

What the title says. Other sounds are fine, but for some reason the jump sound lasts much longer than it should, and the coin grab sounds goes on until it crackles. I suspect there is something wrong with the sweep unit implementation, but I can't find anything wrong.

Possible bug at the indirect zeropage with x register offset

Shouldn't we check whether the offset has made the address jump to another page or not? just like the Y register indirect zeropage offset addressing mode?

std::uint8_t olc6502::IZX()
{
	std::uint16_t addr = this->read(this->PCReg);
	++this->pc;

	std::uint16_t lo = this->read(addr & 0x00FF);
	std::uint16_t hi = this->read((addr + 1) & 0x00FF);

	this->addr_abs = (hi << 8) | lo;
	this->addr_abs += this->x;

	if (this->addr_abs & 0xFF00 != hi << 8)
	{
		return 1;
	}
	return 0;
}

CPU program counter with 2KB ram

Hello,

In the first video, the ram was set to 16KB and in the reset function, program counter reads from an absolute address of 0xFFFC. With the changed Bus::cpuRead function, this will always give an address of 0x00. Is that the intended behavior?

I was trying make the disassembler demo work with the changes after adding PPU and was wondering if I need to set the PC to 0x00 in the assembly code instead of 0x8000?

Thanks

error C2280: 'olc::Sprite::Sprite(const olc::Sprite &)': attempting to reference a deleted function

I am on episode 2, and I just finished implementing everything. But when I build, I get this error:
error C2280: 'olc::Sprite::Sprite(const olc::Sprite &)': attempting to reference a deleted function

I don't know why its happening, but I do know it's coming from olc2C02.h (or in my case dvx2C02.h).
Here's my header:

#pragma once
#include <cstdint>
#include <memory>

#include "olcPixelGameEngine.h"

#include "Cartridge.h"

class dvx2C02
{
public:
	dvx2C02();
	~dvx2C02();

	olc::Sprite& GetScreen();
	olc::Sprite& GetNameTable(uint8_t i);
	olc::Sprite& GetPatternTable(uint8_t i);

	bool frame_complete = false;

	uint8_t cpuRead(uint16_t addr, bool rdonly = false);
	void cpuWrite(uint16_t addr, uint8_t data);
	uint8_t ppuRead(uint16_t addr, bool rdonly = false);
	void ppuWrite(uint16_t addr, uint8_t data);

	void ConnectCartridge(const std::shared_ptr<Cartridge>& cartridge);
	void clock();
private:
	uint8_t tblName[2][1024];
	uint8_t tblPattern[2][4096];
	uint8_t	tblPalette[32];

	olc::Pixel palScreen[0x40];
	olc::Sprite sprScreen = olc::Sprite(256, 240);     // <- The error is coming from this line.
	olc::Sprite sprNameTable[2] = { olc::Sprite(256, 240), olc::Sprite(256, 240) };
	olc::Sprite sprPatternTable[2] = { olc::Sprite(128, 128), olc::Sprite(128, 128) };

	int16_t scanline = 0;
	int16_t cycle = 0;

	std::shared_ptr<Cartridge> cart;
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.