Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Part #3 - Buses, Rams, Roms & Mappers/olc6502.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019
David Barr, aka javidx9, �OneLoneCoder 2019
*/

#include "olc6502.h"
Expand Down Expand Up @@ -208,10 +208,13 @@ void olc6502::irq()
// Then Push the status register to the stack
SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

// Read new program counter location from fixed address
addr_abs = 0xFFFE;
uint16_t lo = read(addr_abs + 0);
Expand All @@ -236,10 +239,13 @@ void olc6502::nmi()

SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

addr_abs = 0xFFFA;
uint16_t lo = read(addr_abs + 0);
uint16_t hi = read(addr_abs + 1);
Expand Down Expand Up @@ -894,7 +900,6 @@ uint8_t olc6502::BRK()
{
pc++;

SetFlag(I, 1);
write(0x0100 + stkp, (pc >> 8) & 0x00FF);
stkp--;
write(0x0100 + stkp, pc & 0x00FF);
Expand All @@ -905,6 +910,10 @@ uint8_t olc6502::BRK()
stkp--;
SetFlag(B, 0);

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

pc = (uint16_t)read(0xFFFE) | ((uint16_t)read(0xFFFF) << 8);
return 0;
}
Expand Down
17 changes: 13 additions & 4 deletions Part #4 - PPU Backgrounds/olc6502.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019
David Barr, aka javidx9, �OneLoneCoder 2019
*/

#include "olc6502.h"
Expand Down Expand Up @@ -208,10 +208,13 @@ void olc6502::irq()
// Then Push the status register to the stack
SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

// Read new program counter location from fixed address
addr_abs = 0xFFFE;
uint16_t lo = read(addr_abs + 0);
Expand All @@ -236,10 +239,13 @@ void olc6502::nmi()

SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

addr_abs = 0xFFFA;
uint16_t lo = read(addr_abs + 0);
uint16_t hi = read(addr_abs + 1);
Expand Down Expand Up @@ -894,7 +900,6 @@ uint8_t olc6502::BRK()
{
pc++;

SetFlag(I, 1);
write(0x0100 + stkp, (pc >> 8) & 0x00FF);
stkp--;
write(0x0100 + stkp, pc & 0x00FF);
Expand All @@ -905,6 +910,10 @@ uint8_t olc6502::BRK()
stkp--;
SetFlag(B, 0);

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

pc = (uint16_t)read(0xFFFE) | ((uint16_t)read(0xFFFF) << 8);
return 0;
}
Expand Down
17 changes: 13 additions & 4 deletions Part #5 - PPU Foregrounds/olc6502.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019
David Barr, aka javidx9, �OneLoneCoder 2019
*/

#include "olc6502.h"
Expand Down Expand Up @@ -208,10 +208,13 @@ void olc6502::irq()
// Then Push the status register to the stack
SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

// Read new program counter location from fixed address
addr_abs = 0xFFFE;
uint16_t lo = read(addr_abs + 0);
Expand All @@ -236,10 +239,13 @@ void olc6502::nmi()

SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

addr_abs = 0xFFFA;
uint16_t lo = read(addr_abs + 0);
uint16_t hi = read(addr_abs + 1);
Expand Down Expand Up @@ -894,7 +900,6 @@ uint8_t olc6502::BRK()
{
pc++;

SetFlag(I, 1);
write(0x0100 + stkp, (pc >> 8) & 0x00FF);
stkp--;
write(0x0100 + stkp, pc & 0x00FF);
Expand All @@ -905,6 +910,10 @@ uint8_t olc6502::BRK()
stkp--;
SetFlag(B, 0);

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

pc = (uint16_t)read(0xFFFE) | ((uint16_t)read(0xFFFF) << 8);
return 0;
}
Expand Down
17 changes: 13 additions & 4 deletions Part #7 - Mappers & Basic Sounds/olc6502.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

Author
~~~~~~
David Barr, aka javidx9, �OneLoneCoder 2019
David Barr, aka javidx9, �OneLoneCoder 2019
*/

#include "olc6502.h"
Expand Down Expand Up @@ -208,10 +208,13 @@ void olc6502::irq()
// Then Push the status register to the stack
SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

// Read new program counter location from fixed address
addr_abs = 0xFFFE;
uint16_t lo = read(addr_abs + 0);
Expand All @@ -236,10 +239,13 @@ void olc6502::nmi()

SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

addr_abs = 0xFFFA;
uint16_t lo = read(addr_abs + 0);
uint16_t hi = read(addr_abs + 1);
Expand Down Expand Up @@ -894,7 +900,6 @@ uint8_t olc6502::BRK()
{
pc++;

SetFlag(I, 1);
write(0x0100 + stkp, (pc >> 8) & 0x00FF);
stkp--;
write(0x0100 + stkp, pc & 0x00FF);
Expand All @@ -905,6 +910,10 @@ uint8_t olc6502::BRK()
stkp--;
SetFlag(B, 0);

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

pc = (uint16_t)read(0xFFFE) | ((uint16_t)read(0xFFFF) << 8);
return 0;
}
Expand Down
15 changes: 12 additions & 3 deletions Part#2 - CPU/olc6502.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,13 @@ void olc6502::irq()
// Then Push the status register to the stack
SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

// Read new program counter location from fixed address
addr_abs = 0xFFFE;
uint16_t lo = read(addr_abs + 0);
Expand All @@ -236,10 +239,13 @@ void olc6502::nmi()

SetFlag(B, 0);
SetFlag(U, 1);
SetFlag(I, 1);
write(0x0100 + stkp, status);
stkp--;

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

addr_abs = 0xFFFA;
uint16_t lo = read(addr_abs + 0);
uint16_t hi = read(addr_abs + 1);
Expand Down Expand Up @@ -894,7 +900,6 @@ uint8_t olc6502::BRK()
{
pc++;

SetFlag(I, 1);
write(0x0100 + stkp, (pc >> 8) & 0x00FF);
stkp--;
write(0x0100 + stkp, pc & 0x00FF);
Expand All @@ -905,6 +910,10 @@ uint8_t olc6502::BRK()
stkp--;
SetFlag(B, 0);

// After writing to the stack, set the Interupt flag to 1
// to prevent other interrupts
SetFlag(I, 1);

pc = (uint16_t)read(0xFFFE) | ((uint16_t)read(0xFFFF) << 8);
return 0;
}
Expand Down