From 7e0512902385ea23d1131add150d58008a570320 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 7 Nov 2012 15:26:02 +0100 Subject: [PATCH] Seek to 0 before writing to /dev/vga. --- games/conway.cpp | 4 +++- games/pong.cpp | 4 +++- games/snake.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/games/conway.cpp b/games/conway.cpp index 3870cc69..43ab03cc 100644 --- a/games/conway.cpp +++ b/games/conway.cpp @@ -57,7 +57,9 @@ void Clear() bool FlushVGA() { - return writeall(vgafd, frame, sizeof(frame)) < sizeof(frame); + if ( lseek(vgafd, 0, SEEK_SET) < 0) + return false; + return writeall(vgafd, frame, sizeof(frame)) == sizeof(frame); } int Init() diff --git a/games/pong.cpp b/games/pong.cpp index 51f66865..6674e804 100644 --- a/games/pong.cpp +++ b/games/pong.cpp @@ -70,7 +70,9 @@ unsigned soundleft; bool FlushVGA() { - return writeall(vgafd, frame, sizeof(frame)) < sizeof(frame); + if ( lseek(vgafd, 0, SEEK_SET) < 0) + return false; + return writeall(vgafd, frame, sizeof(frame)) == sizeof(frame); } int Init() diff --git a/games/snake.cpp b/games/snake.cpp index b3078c8b..5cd6e2cd 100644 --- a/games/snake.cpp +++ b/games/snake.cpp @@ -95,7 +95,9 @@ void Reset() bool FlushVGA() { - return writeall(vgafd, frame, sizeof(frame)) < sizeof(frame); + if ( lseek(vgafd, 0, SEEK_SET) < 0) + return false; + return writeall(vgafd, frame, sizeof(frame)) == sizeof(frame); } int Init()