]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-02-14 Samuel Thibault <samuel.thibault@ens-lyon.org>
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 14 Feb 2010 16:25:52 +0000 (17:25 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 14 Feb 2010 16:25:52 +0000 (17:25 +0100)
* commands/i386/pc/play.c (T_REST, T_FINE, struct note, beep_on): Use
grub_uint16_t instead of short.
(grub_cmd_play): Use grub_uint32_t instead of int, convert data from
disk from little endian to cpu endianness.

ChangeLog
commands/i386/pc/play.c

index 03388c7f39dd799dbad6e21b90ae17135bc397e2..950a26f3d95147071736ea27690190799963217e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-02-14  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+       * commands/i386/pc/play.c (T_REST, T_FINE, struct note, beep_on): Use
+       grub_uint16_t instead of short.
+       (grub_cmd_play): Use grub_uint32_t instead of int, convert data from
+       disk from little endian to cpu endianness.
+
 2010-02-07  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
        * commands/i386/pc/play.c (BASE_TEMPO): Set to 60 *
index 04bf8625d2189160fbfbafb9f1b948081da46927..84819b5519eef19e09f0d1b56ecf82b740a484a1 100644 (file)
 #define PIT_CTRL_COUNT_BINARY  0x00    /* 16-bit binary counter.  */
 #define PIT_CTRL_COUNT_BCD     0x01    /* 4-decade BCD counter.  */
 
-#define T_REST                 ((short) 0)
-#define T_FINE                 ((short) -1)
+#define T_REST                 ((grub_uint16_t) 0)
+#define T_FINE                 ((grub_uint16_t) -1)
 
 struct note
 {
-  short pitch;
-  short duration;
+  grub_uint16_t pitch;
+  grub_uint16_t duration;
 };
 
 static void
@@ -120,7 +120,7 @@ beep_off (void)
 }
 
 static void
-beep_on (short pitch)
+beep_on (grub_uint16_t pitch)
 {
   unsigned char status;
   unsigned int counter;
@@ -149,7 +149,7 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
 {
   grub_file_t file;
   struct note buf;
-  int tempo;
+  grub_uint32_t tempo;
   unsigned int to;
 
   if (argc != 1)
@@ -166,12 +166,18 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
                          "file doesn't even contains a full tempo record");
     }
 
+  tempo = grub_le_to_cpu32(tempo);
+
   grub_dprintf ("play","tempo = %d\n", tempo);
 
   while (grub_file_read (file, &buf,
-                         sizeof (struct note)) == sizeof (struct note)
-         && buf.pitch != T_FINE && grub_checkkey () < 0)
+                         sizeof (struct note)) == sizeof (struct note))
     {
+      buf.pitch = grub_le_to_cpu16(buf.pitch);
+      buf.duration = grub_le_to_cpu16(buf.duration);
+
+      if (buf.pitch == T_FINE || grub_checkkey () >= 0)
+        break;
 
       grub_dprintf ("play", "pitch = %d, duration = %d\n", buf.pitch,
                     buf.duration);