summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-08-17 19:51:43 +0930
committerDaniel Jones <admin@danieljon.es>2020-08-17 19:51:51 +0930
commit78af003371b6b651e1d9b005702e3d22cee951c7 (patch)
tree53c9b61139c4de10184a00397af20ddcce817b69 /main.c
parent7d60741c1393ebc0c572891cfeb19a25c4579ed6 (diff)
downloadchip8-78af003371b6b651e1d9b005702e3d22cee951c7.tar.gz
chip8-78af003371b6b651e1d9b005702e3d22cee951c7.zip
implement pixel XORing and wrapping
sprites are properly XOR'd to the display, setting the 0xF register as appropriate. sprites also wrap on the bottom and irght side of the screen. because you can't access negative video memory, wrpaping top to bottom and left to right isn't implemented
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/main.c b/main.c
index d549b25..ce86053 100644
--- a/main.c
+++ b/main.c
@@ -12,7 +12,7 @@
* http://www.emulator101.com/chip-8-sprites.html
*/
-#define VIDEO_SCALE 10
+#define VIDEO_SCALE 5
SDL_Window *window;
SDL_Renderer *renderer;
@@ -109,6 +109,7 @@ int main(int argc, char *argv[])
uint32_t frame_time;
int do_quit = 0;
+
chip8_draw_sprite(0, 0, 0xD*5, 0x5);
chip8_draw_sprite(5, 0, 0xE*5, 0x5);
chip8_draw_sprite(10, 0, 0xA*5, 0x5);
@@ -127,13 +128,21 @@ int main(int argc, char *argv[])
chip8_draw_sprite(30, 9, 0xE*5, 0x5);
chip8_draw_sprite(35, 9, 0xf*5, 0x5);
+ chip8_draw_sprite(0, 20, 0x200, 0x6);
+ chip8_draw_sprite(8, 20, 0x200, 0x6);
+ chip8_draw_sprite(16, 20, 0x200, 0x6);
+ chip8_draw_sprite(18, 20, 0x200, 0x6);
+
+ chip8_draw_sprite(61, 25, 0x200, 0x6);
+ chip8_draw_sprite(50, 30, 0x200, 0x6);
while(!do_quit)
{
frame_start = SDL_GetTicks();
// logic
- update_video();
+ if (draw_flag)
+ update_video();
frame_time = SDL_GetTicks() - frame_start;
if (frame_delay > frame_time)