From 5acb3ba8bb1bed76eea5defde83bde1ac2225fb7 Mon Sep 17 00:00:00 2001 From: Tony Di Nucci Date: Wed, 24 Apr 2019 00:40:31 +0100 Subject: [PATCH] Start of graphics support --- sample/a.o65 | Bin 0 -> 78 bytes sample/draw.asm | 77 ++++++++++++++++-- src/machine/terminal.cpp | 24 +++--- src/machine/terminal.h | 11 +-- src/main.cpp | 2 +- .../maths-opcode-handler-container.cpp | 1 - src/utils.cpp | 1 - src/utils.h | 1 + 8 files changed, 88 insertions(+), 29 deletions(-) create mode 100644 sample/a.o65 diff --git a/sample/a.o65 b/sample/a.o65 new file mode 100644 index 0000000000000000000000000000000000000000..cc97692de9d69ecf7a70318b4f1d6ec10705739e GIT binary patch literal 78 zcmZ3)(8jRnK^x> 2) & 0x07; blue = colour & 0x03; - cout << "RED: " << (int)red << " GREEN: " << (int)green << " BLUE: " << (int)blue << endl; + //cout << "x: " << (int)x << " y: " << (int)y << " RED: " << (int)red << " GREEN: " << (int)green << " BLUE: " << (int)blue << endl; - SDL_SetRenderDrawColor(renderer, red * 36, green * 36, blue * 85, 0); - for (int i = 0; i < PIXEL_WEIGHT; i++) { - SDL_RenderDrawPoint(renderer, (x * PIXEL_WEIGHT) + i, (y * PIXEL_WEIGHT)); - - for (int j = 0; j < PIXEL_WEIGHT; j++) { - SDL_RenderDrawPoint(renderer, (x * PIXEL_WEIGHT) + i, (y * PIXEL_WEIGHT) + j); - } - } + SDL_SetRenderDrawColor(renderer, red * 36, green * 36, blue * 85, 255); + SDL_Rect rect{}; + rect.x = x * PIXEL_WEIGHT; + rect.y = y * PIXEL_WEIGHT; + rect.w = PIXEL_WEIGHT; + rect.h = PIXEL_WEIGHT; + SDL_RenderFillRect(renderer, &rect); } } \ No newline at end of file diff --git a/src/machine/terminal.h b/src/machine/terminal.h index d3f6e2a..cd901c2 100644 --- a/src/machine/terminal.h +++ b/src/machine/terminal.h @@ -2,6 +2,7 @@ #define INC_6502_EMULATOR_TERMINAL_H #include +#include #include #include "memory.h" @@ -10,11 +11,11 @@ using namespace std; namespace emu_6502 { class Terminal { private: - const uint16_t LOW_ADDR = 0xE000; - const uint16_t HIGH_ADDR = 0xF000; - const uint8_t WIDTH = 64; - const uint8_t HEIGHT = 64; - const uint8_t PIXEL_WEIGHT = 8; + static const uint16_t LOW_ADDR = 0xE000; + static const uint16_t HIGH_ADDR = 0xF000; + static const uint8_t WIDTH = 64; + static const uint8_t HEIGHT = 64; + static const uint8_t PIXEL_WEIGHT = 8; Memory& memory; diff --git a/src/main.cpp b/src/main.cpp index 07355ef..a928e6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,7 @@ int main() { (istreambuf_iterator())); auto machine = make_unique(); - machine->load(code, 0x600); + machine->load(code, 0x1000); machine->execute(); return 0; diff --git a/src/opcode/handler/maths-opcode-handler-container.cpp b/src/opcode/handler/maths-opcode-handler-container.cpp index a63f76a..eaaa394 100644 --- a/src/opcode/handler/maths-opcode-handler-container.cpp +++ b/src/opcode/handler/maths-opcode-handler-container.cpp @@ -154,7 +154,6 @@ namespace emu_6502 { void MathsOpcodeHandlerContainer::inc(Machine& machine, uint16_t address) { uint8_t value = machine.get_memory().get_at(address) + 1; machine.get_memory().set_at(address, value); - set_zero_and_neg_flags(machine.get_cpu().get_ps(), value); } diff --git a/src/utils.cpp b/src/utils.cpp index 3ab86e6..aa54e83 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -65,7 +65,6 @@ namespace emu_6502 { auto low = machine.get_memory().get_at(paddress); auto high = machine.get_memory().get_at(paddress + 1); uint16_t address = (high << 8) + low; - return address; } diff --git a/src/utils.h b/src/utils.h index 969ec0e..34a2336 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,6 +4,7 @@ #include "machine/machine.h" #include #include +#include using namespace std;