implemented draw function in interpreter
This commit is contained in:
39
main.cpp
39
main.cpp
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "BuzzerSDL.hpp"
|
||||
#include "DisplaySDL.hpp"
|
||||
#include "Interpreter.hpp"
|
||||
#include "Peripherals.hpp"
|
||||
|
||||
int main(int argc, char* args[]) {
|
||||
@@ -11,18 +12,38 @@ int main(int argc, char* args[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
class DisplayTest : public DisplaySDL {
|
||||
public:
|
||||
DisplayTest() : DisplaySDL(1280, 640, 0xff0000, 0x00ff00) {
|
||||
for(int i = 0; i < chocochip8::gcHeight; i+=2) {
|
||||
mpFramebuffer->at(i).set();
|
||||
}
|
||||
}
|
||||
class TestKeypad : public chocochip8::Keypad {
|
||||
bool isKeyPressed(chocochip8::Key) override { return false; }
|
||||
};
|
||||
|
||||
BuzzerSDL buzzer(440);
|
||||
//buzzer.on();
|
||||
DisplayTest display;
|
||||
DisplaySDL display(1280, 640);
|
||||
TestKeypad keypad;
|
||||
chocochip8::Interpreter chip8(90, display, buzzer, keypad);
|
||||
|
||||
uint8_t prog[] = {
|
||||
0xA0, 0x00, // LD I,0
|
||||
0x60, 0x00, // LD $0,0
|
||||
0x61, 0x00, // LD $1,0
|
||||
0xD0, 0x15, // DRW $0, $1, 5
|
||||
0xA0, 0x05, // LD I,5
|
||||
0x60, 0x3C, // LD $0,60
|
||||
0x61, 0x00, // LD $1,0
|
||||
0xD0, 0x15, // DRW $0, $1, 5
|
||||
0xA0, 0x0A, // LD I,10
|
||||
0x60, 0x00, // LD $0,0
|
||||
0x61, 0x1B, // LD $1,27
|
||||
0xD0, 0x15, // DRW $0, $1, 5
|
||||
0xA0, 0x0F, // LD I,15
|
||||
0x60, 0x3C, // LD $0,60
|
||||
0x61, 0x1B, // LD $1,27
|
||||
0xD0, 0x15, // DRW $0, $1, 5
|
||||
};
|
||||
|
||||
chip8.loadProgram((char*)prog, sizeof(prog));
|
||||
for(int i = 0; i < sizeof(prog) / 2; i++) {
|
||||
chip8.tick();
|
||||
}
|
||||
|
||||
SDL_Event event;
|
||||
while(SDL_WaitEvent(&event) && event.type != SDL_QUIT) {
|
||||
|
||||
Reference in New Issue
Block a user