 
       i += 1;
     }
+
+    // Free temp OAM
+    // free(oam_c);
   } else {
     // Sprites not enabled
     // FIXME: Should we do anything special here?

    //    Bit3   Tile VRAM-Bank  **CGB Mode Only**     (0=Bank 0, 1=Bank 1)
    //    Bit2-0 Palette number  **CGB Mode Only**     (OBP0-7)

    let i = 0;
    let total = 0;
    while i < 40 {
      let offset = (i * 4);

      let sprite_y = int16(*(oam + offset + 0)) - 16;
      let sprite_x = int16(*(oam + offset + 1)) - 8;
      let sprite_tile = int16(*(oam + offset + 2));
      let sprite_flags = *(oam + offset + 3);

      // Remember, we are rendering on a line-by-line basis
      // Does this sprite intersect our current scanline?

      if sprite_y <= int16(gpu_line) and (sprite_y + 8) > int16(gpu_line) {

        total += 1;
        if total > 10 {
          // No more sprites
          break;
        }

        let tile_y: int16 = int16(gpu_line) - sprite_y;
        if testb(sprite_flags, 6) {
          tile_y = 7 - tile_y;
        }

        let td_address: int16 = sprite_tile * 16 + int16(tile_y) * 2;

  gpu_line = 0;
}

def gpu_sprite_compare(a: *uint8, b: *uint8): c_int {
  let a_x = *(a + 1);
  let b_x = *(b + 1);

  if a_x < b_x {
    return -1;
  }

  if b_x > a_x {
    return 1;
  }

  if a_x == b_x {
    let aptr = a as uint64;
    let bptr = b as uint64;

    if aptr < bptr {
      return -1;
    }

    if bptr > aptr {
      return 1;
    }
  }

  return 0;
}

def gpu_render_scanline() {
  // TODO: Combine Window & Background rendering .. code is super duplicated

  // Set whole line to 0x0 (clear)
  let i = 0;
  while i < 160 {
    *(gpu_framebuffer + (int64(gpu_line) * 160) + i) = 0;

    i += 1;
  }

  // Background
  if gpu_bg_enable {
