pico: build type handler list
diff --git a/32blit-pico/blit_launch.cpp b/32blit-pico/blit_launch.cpp
index dbe50ef..d922b14 100644
--- a/32blit-pico/blit_launch.cpp
+++ b/32blit-pico/blit_launch.cpp
@@ -1,4 +1,5 @@
 #include <cstring>
+#include <forward_list>
 
 #include "pico/stdlib.h"
 #include "hardware/flash.h"
@@ -34,6 +35,13 @@
 static const uint32_t flash_end = FLASH_STORAGE_OFFSET;
 #endif
 
+struct TypeHandlerInfo {
+  char type[4]; // should have a null terminator, but the low byte of the offset will always be zero
+  uint32_t offset;
+};
+
+std::forward_list<TypeHandlerInfo> handlers;
+
 extern int (*do_tick)(uint32_t time);
 
 void disable_user_code();
@@ -223,6 +231,36 @@
   return nullptr;
 }
 
+void create_type_handler_list() {
+  handlers.clear();
+
+  blit::api.list_installed_games([](const uint8_t *ptr, uint32_t block, uint32_t size) {
+    auto header = (const BlitGameHeader *)ptr;
+    auto metadata_ptr = ptr + header->end;
+
+    if(memcmp(metadata_ptr, "BLITMETA", 8) != 0)
+      return;
+
+    // skip straight to the type block
+    metadata_ptr += 10 + sizeof(RawMetadata);
+
+    if(memcmp(metadata_ptr, "BLITTYPE", 8) != 0)
+      return;
+
+    // get the type block
+    auto type_meta = (const RawTypeMetadata *)(metadata_ptr + 8);
+
+    // loop through filetypes
+    for(unsigned i = 0; i < type_meta->num_filetypes; i++) {
+      TypeHandlerInfo info;
+      memcpy(info.type, type_meta->filetypes[i], 4);
+      info.offset = block * game_block_size;
+
+      handlers.emplace_front(info);
+    }
+  });
+}
+
 bool launch_file(const char *path) {
   uint32_t flash_offset = ~0u;
 
diff --git a/32blit-pico/blit_launch.hpp b/32blit-pico/blit_launch.hpp
index 69c203f..abb7dce 100644
--- a/32blit-pico/blit_launch.hpp
+++ b/32blit-pico/blit_launch.hpp
@@ -10,6 +10,8 @@
 
 RawMetadata *get_running_game_metadata();
 
+void create_type_handler_list();
+
 bool launch_file(const char *path);
 blit::CanLaunchResult can_launch(const char *path);
 void launch_pre_init();
diff --git a/32blit-pico/main.cpp b/32blit-pico/main.cpp
index aee9111..4dba8e2 100644
--- a/32blit-pico/main.cpp
+++ b/32blit-pico/main.cpp
@@ -317,7 +317,9 @@
 #endif
 #endif
 
-#ifndef BUILD_LOADER
+#ifdef BUILD_LOADER
+  create_type_handler_list();
+#else
   blit::set_screen_mode(ScreenMode::lores);
 #endif