altoslib: Finish AltosState changes. Update version number.
[fw/altos] / altoslib / AltosHexfile.java
index 68f42f14b4ade98f023bff8da197213f0c9dd3fe..90352927433f219e1a79c359554c84b2e40009d7 100644 (file)
@@ -15,7 +15,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_1;
+package org.altusmetrum.altoslib_2;
 
 import java.io.*;
 import java.util.LinkedList;
@@ -230,17 +230,19 @@ public class AltosHexfile {
                }
 
                long    extended_addr = 0;
-               long    base = 0xffffffff;
-               long    bound = 0x00000000;
+               long    base = 0;
+               long    bound = 0;
+               boolean set = false;
                for (HexRecord record : record_list) {
                        switch (record.type) {
                        case 0:
                                long addr = extended_addr + record.address;
                                long r_bound = addr + record.data.length;
-                               if (addr < base)
+                               if (!set || addr < base)
                                        base = addr;
-                               if (r_bound > bound)
+                               if (!set || r_bound > bound)
                                        bound = r_bound;
+                               set = true;
                                break;
                        case 1:
                                break;
@@ -259,7 +261,7 @@ public class AltosHexfile {
                        }
                }
 
-               if (base >= bound)
+               if (!set || base >= bound)
                        throw new IOException("invalid hex file");
 
                if (bound - base > 4 * 1024 * 1024)