Ver código fonte

Refactored and added many syscalls. Removed 8.3 names for userbdos files as not needed with brfs anymore. Added mkdir program and removed some old stuff.

bart 7 meses atrás
pai
commit
c2114c8eae

+ 93 - 24
BCC/BDOS/BDOS.c

@@ -42,12 +42,26 @@
 #define INTID_UART2 0x8
 
 // System call IDs
-#define SYSCALL_FIFO_AVAILABLE 1
-#define SYSCALL_FIFO_READ 2
-#define SYSCALL_PRINT_C_CONSOLE 3
-#define SYSCALL_GET_ARGS 4       // Get arguments for executed program
-#define SYSCALL_GET_PATH 5       // Get OS path
-#define SYSCALL_GET_USB_KB_BUF 6 // Get the 8 bytes of the USB keyboard buffer
+#define SYS_HID_CHECKFIFO 1
+#define SYS_HID_READFIFO 2
+#define SYS_BDOS_PRINTC 3
+#define SYS_BDOS_PRINT 4
+#define SYS_FS_OPEN 5
+#define SYS_FS_CLOSE 6
+#define SYS_FS_READ 7
+#define SYS_FS_WRITE 8
+#define SYS_FS_SETCURSOR 9
+#define SYS_FS_GETCURSOR 10
+#define SYS_FS_DELETE 11
+#define SYS_FS_MKDIR 12
+#define SYS_FS_MKFILE 13
+#define SYS_FS_STAT 14
+#define SYS_FS_READDIR 15
+#define SYS_FS_GETCWD 16
+// Syscalls 17-19 are reserved for future use
+#define SYS_SHELL_ARGC 20
+#define SYS_SHELL_ARGV 21
+#define SYS_USB_KB_BUF 99
 
 /*
  * Global vars (also might be used by included libraries below)
@@ -192,36 +206,91 @@ int main()
   return 1;
 }
 
+/**
+ * System calls
+*/
+
+
+
 // System call handler
 // Returns at the same address it reads the command from
 void syscall()
 {
-  word *p = (word *)SYSCALL_RETVAL_ADDR;
-  word ID = p[0];
+  word *syscall_data = (word *)SYSCALL_RETVAL_ADDR;
+  word id = syscall_data[0];
+
+  // Special case for mkdir and mkfile
+  if (id == SYS_FS_MKDIR)
+  {
+    char dirname_output[MAX_PATH_LENGTH];
+    char* file_path_basename = basename((char *)syscall_data[1]);
+    char* file_path_dirname = dirname(dirname_output, (char *)syscall_data[1]);
+    syscall_data[0] = brfs_create_directory(file_path_dirname, file_path_basename);
+  }
+  else if (id == SYS_FS_MKFILE)
+  {
+    char dirname_output[MAX_PATH_LENGTH];
+    char* file_path_basename = basename((char *)syscall_data[1]);
+    char* file_path_dirname = dirname(dirname_output, (char *)syscall_data[1]);
+    syscall_data[0] = brfs_create_file(file_path_dirname, file_path_basename);
+  }
 
-  switch (ID)
+  switch (id)
   {
-  case SYSCALL_FIFO_AVAILABLE:
-    p[0] = HID_FifoAvailable();
+  case SYS_HID_CHECKFIFO:
+    syscall_data[0] = HID_FifoAvailable();
+    break;
+  case SYS_HID_READFIFO:
+    syscall_data[0] = HID_FifoRead();
+    break;
+  case SYS_BDOS_PRINTC:
+    GFX_PrintcConsole(syscall_data[1]);
+    syscall_data[0] = 0;
+    break;
+  case SYS_BDOS_PRINT:
+    GFX_PrintConsole(syscall_data[1]);
+    syscall_data[0] = 0;
+    break;
+  case SYS_FS_OPEN:
+    syscall_data[0] = brfs_open_file((char *)syscall_data[1]);
+    break;
+  case SYS_FS_CLOSE:
+    syscall_data[0] = brfs_close_file(syscall_data[1]);
+    break;
+  case SYS_FS_READ:
+    syscall_data[0] = brfs_read(syscall_data[1], (char *)syscall_data[2], syscall_data[3]);
+    break;
+  case SYS_FS_WRITE:
+    syscall_data[0] = brfs_write(syscall_data[1], (char *)syscall_data[2], syscall_data[3]);
+    break;
+  case SYS_FS_SETCURSOR:
+    syscall_data[0] = brfs_set_cursor(syscall_data[1], syscall_data[2]);
+    break;
+  case SYS_FS_GETCURSOR:
+    syscall_data[0] = brfs_get_cursor(syscall_data[1]);
+    break;
+  case SYS_FS_DELETE:
+    syscall_data[0] = brfs_delete_file((char *)syscall_data[1]);
     break;
-  case SYSCALL_FIFO_READ:
-    p[0] = HID_FifoRead();
+  case SYS_FS_STAT:
+    syscall_data[0] = brfs_stat((char *)syscall_data[1]);
     break;
-  case SYSCALL_PRINT_C_CONSOLE:
-    GFX_PrintcConsole(p[1]);
-    p[0] = 0;
+  case SYS_FS_READDIR:
+    brfs_list_directory((char *)syscall_data[1]);
+    syscall_data[0] = 0; // TODO: implement
     break;
-  case SYSCALL_GET_ARGS:
-    p[0] = 0; // TODO: implement
+  case SYS_FS_GETCWD:
+    strcpy(syscall_data[0], shell_path);
     break;
-  case SYSCALL_GET_PATH:
-    p[0] = 0; // TODO: implement
+  case SYS_SHELL_ARGC:
+    syscall_data[0] = shell_num_tokens;
     break;
-  case SYSCALL_GET_USB_KB_BUF:
-    p[0] = USBkeyboard_buffer_parsed;
+  case SYS_SHELL_ARGV:
+    // Not so fancy as we return by reference instead of making a copy
+    syscall_data[0] = shell_tokens;
     break;
-  default:
-    p[0] = 0;
+  case SYS_USB_KB_BUF:
+    syscall_data[0] = USBkeyboard_buffer_parsed;
     break;
   }
 }

+ 0 - 1593
BCC/userBDOS/BRFS.C

@@ -1,1593 +0,0 @@
-// Test implementation of Bart's RAM File System (BRFS)
-
-/*
-General Idea:
-- HDD for the average home user was <100MB until after 1990
-- SPI NOR Flash provides around the same amount of storage, with very little wear
-    - Very fast reads in QSPI mode
-    - However, writes are extremely slow and need to be performed in pages of 256 bytes (64 words)
-- FPGC has 64MiB RAM, which is a lot even for 32 bit addressable words
-    - 32MiB is already more than enough for the FPGC in its current form
-- Use the other 32MiB as a fully in RAM filesystem
-    - That initializes from SPI flash and writes back to Flash at a chosen time
-*/
-
-/*
-Implementation Idea:
-- Use superblock for info/addresses, no hard-coded sizes!
-  - Allows for different storage media, easier testing on tiny size, and more future proof
-*/
-
-/*
-Implementation Details:
---------------------------------------------------
-| superblock | FAT | Data+Dir blocks (same size) |
---------------------------------------------------
-
-16 word superblock:
-  - (1)  total blocks
-  - (1)  bytes per block
-  - (10) label [1 char per word]
-  - (1)  brfs version
-  - (3)  reserved
-
-8 word Dir entries:
-  - (4) filename.ext [4 chars per word -> 16 chars total]
-  - (1) modify date [to be implemented when RTC]
-  - (1) flags [max 32 flags, from right to left: directory, hidden]
-  - (1) 1st FAT idx
-  - (1) file size [in words, not bytes]
-*/
-
-/*
-Implementation Notes:
-- Current directory is managed by the application/OS, not the FS. Directory (or file) can be checked to exist using stat()
-- Updating a file: might be better to delete and create a new one, but this is better be done by the application instead of the FS
-- Write should start writing at the cursor and jump to the next block (also create in FAT) if the end is reached
-- No delete/backspace, only delete entire file or overwrite data
-*/
-
-/*
-Required operations:
-- [x] Format
-- [x] Create directory
-- [x] Create file
-- [x] Open file (not a dir!) (allow multiple files open at once)
-- [x] Close file
-- [x] Stat (returns dir entry)
-- [x] Set cursor
-- [x] Get cursor
-- [x] Read file
-- [x] Write file
-- [x] Delete entire file (deleting part of file is not a thing)
-- [x] List directory
-*/
-
-/*
-Implementing in BDOS on PCB v3:
-- BDOS only uses ~340 pages of 256 bytes -> 90000 bytes
-- SPI flash has 65536 pages of 256 bytes -> 16777216 bytes
-- With current verilog implementation, only 32MiB of RAM is addressable, so BRFS should be used somewhere in the first 32MiB
-- With current BDOS memory map, BRFS should be placed in the first 8MiB available as BDOS Program Code
-- Lets use the last 4MiB of this space for BRFS (0x100000 - 0x200000)
-*/
-
-/*
-Integrate with SPI Flash:
-- [x] Function to read from SPI Flash (to be used on startup of BDOS)
-  - [x] Check for valid BRFS superblock
-  - [x] Load BRFS into RAM (read total blocks and words per block from superblock)
-- [x] Function to write BRFS to SPI Flash (to be used by applications/OS via System Call)
-  - [x] Check which blocks/FAT entries have changed using a bitmap
-  - [x] Erase changed blocks/FAT entries (by sector) in SPI Flash
-  - [x] Write changed blocks/FAT entries to SPI Flash (by page)
-*/
-
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/SYS.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SPIFLASH.C"
-
-#define BRFS_SUPPORTED_VERSION 1
-
-#define BRFS_RAM_STORAGE_ADDR 0x100000 // From 4th MiB
-
-// Addresses in SPI Flash
-// Note that each section should be in a different 4KiB sector in SPI Flash
-#define BRFS_SPIFLASH_SUPERBLOCK_ADDR 0xDF000 // One sector before FAT
-#define BRFS_SPIFLASH_FAT_ADDR 0xE0000 // Can be 32768 words (128KiB) for 32MiB of 256word blocks
-#define BRFS_SPIFLASH_BLOCK_ADDR 0x100000 // From first MiB
-
-#define MAX_PATH_LENGTH 127
-#define MAX_OPEN_FILES 16 // Can be set higher, but 4 is good for testing
-
-// Length of structs, should not be changed
-#define SUPERBLOCK_SIZE 16
-#define DIR_ENTRY_SIZE 8
-
-#define BRFS_MAX_BLOCKS 65536 // 64KiB
-word brfs_changed_blocks[BRFS_MAX_BLOCKS >> 5]; // Bitmap of changed blocks, each block has 1 bit
-
-// 16 words long
-struct brfs_superblock
-{
-  word total_blocks;
-  word words_per_block;
-  word label[10];       // 1 char per word
-  word brfs_version;
-  word reserved[3];
-};
-
-// 8 words long
-struct brfs_dir_entry
-{
-  word filename[4];       // 4 chars per word
-  word modify_date;       // TBD when RTC added to FPGC
-  word flags;             // 32 flags, from right to left: directory, hidden 
-  word fat_idx;           // idx of first FAT block
-  word filesize;          // file size in words, not bytes
-};
-
-word *brfs_ram_storage = (word*) BRFS_RAM_STORAGE_ADDR; // RAM storage of file system
-
-// Variables for open files
-word brfs_cursors[MAX_OPEN_FILES]; // Cursor position offset from start of file
-word brfs_file_pointers[MAX_OPEN_FILES]; // FAT idx of open file
-struct brfs_dir_entry* brfs_dir_entry_pointers[MAX_OPEN_FILES]; // Pointer to dir entry of open file
-
-/**
- * Create a hexdump like dump of a section of memory
- * addr: address of the section
- * len: length of the section in words
- * linesize: number of words per line to print
-*/
-void brfs_dump_section(word* addr, word len, word linesize)
-{
-  char buf[16];
-  word i;
-  for (i = 0; i < len; i++)
-  {
-    itoah(addr[i], buf);
-    if (strlen(buf+2) == 1)
-      uprintc('0');
-    uprint(buf+2);
-
-    uprintc(' ');
-
-    // newline every linesize words
-    // also print last linesize words as chars if alphanum
-    if (i != 0 && MATH_modU(i+1, linesize) == 0)
-    {
-      uprint("  ");
-      word j;
-      for (j = i - (linesize-1); j < i+1; j++)
-      {
-        if (isalnum(addr[j]) || addr[j] == ' ')
-          uprintc(addr[j]);
-        else
-          uprintc('.');
-      }
-      uprintc('\n');
-    }
-  }
-}
-
-
-/**
- * Create a raw filesystem dump over UART
- * fatsize: size of the FAT table in words
- * datasize: size of the data section in words
-*/
-void brfs_dump(word fatsize, word datasize)
-{
-  // Superblock dump
-  uprintln("Superblock:");
-  brfs_dump_section(brfs_ram_storage, SUPERBLOCK_SIZE, 16);
-
-  // FAT dump
-  uprintln("\nFAT:");
-  brfs_dump_section(brfs_ram_storage+SUPERBLOCK_SIZE, fatsize, 16);
-
-  // Datablock dump
-  uprintln("\nData:");
-  brfs_dump_section(brfs_ram_storage+SUPERBLOCK_SIZE+fatsize, datasize, 32);
-
-  uprintln("\nOpen files:");
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    uprint("FP");
-    uprintDec(i+1);
-    uprint(":");
-    uprint(" FAT idx: ");
-    uprintDec(brfs_file_pointers[i]);
-    uprint(" Cursor: ");
-    uprintDec(brfs_cursors[i]);
-    uprint(" Size: ");
-    uprintDec(brfs_dir_entry_pointers[i] ? brfs_dir_entry_pointers[i]->filesize : 0);
-    uprintc('\n');
-  }
-}
-
-
-/**
- * Return the FAT index of a directory, or -1 if not found
- * dir_path: full path of the directory
-*/
-word brfs_get_fat_idx_of_dir(char* dir_path)
-{
-  // Check length of path
-  if (strlen(dir_path) > MAX_PATH_LENGTH)
-  {
-    uprintln("Path too long!");
-    return -1;
-  }
-
-  // Start with root directory
-  word current_dir_fat_idx = 0;
-
-  // Check if root directory is requested
-  if (strcmp(dir_path, "/") == 0)
-  {
-    return current_dir_fat_idx;
-  }
-
-  // Copy dir_path, size + 1 for null terminator
-  // Since strtok modifies the string
-  char dir_path_copy[MAX_PATH_LENGTH+1];
-  strcpy(dir_path_copy, dir_path);
-
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* brfs_data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-
-  // Split path by '/' and traverse directories
-  char* token = strtok(dir_path_copy, "/");
-  while (token != (word*)-1)
-  {
-    // Find token in current directory
-    word* dir_addr = brfs_data_block_addr + (current_dir_fat_idx * superblock->words_per_block);
-    word found_dir = 0; // Keep track if token is found in current directory
-    word i;
-    for (i = 0; i < dir_entries_max; i++)
-    {
-      struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (dir_addr + (i * sizeof(struct brfs_dir_entry)));
-      if (dir_entry->filename[0] != 0)
-      {
-        char decompressed_filename[16];
-        strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-        // Also check for directory flag
-        if (strcmp(decompressed_filename, token) == 0 && dir_entry->flags == 1)
-        {
-          // Found token in current directory
-          // Set current directory to token's FAT index
-          current_dir_fat_idx = dir_entry->fat_idx;
-          found_dir = 1;
-          break;
-        }
-      }
-    }
-
-    // If token not found in current directory, return -1
-    if (!found_dir)
-    {
-      uprint("Directory ");
-      uprint(dir_path);
-      uprintln(" not found!");
-      return -1;
-    }
-
-    token = strtok((word*)-1, "/");
-  }
-  return current_dir_fat_idx;
-}
-
-/**
- * Given the address of the FAT table and the number of blocks, find the next free block
- * Returns -1 if no free block is found
- * fat_addr: address of the FAT table
- * blocks: number of blocks in the FAT table
-*/
-word brfs_find_next_free_block(word* fat_addr, word blocks)
-{
-  word i = 0;
-  word* fat_ptr = fat_addr;
-
-  while (i < blocks)
-  {
-    if (*fat_ptr == 0)
-    {
-      return i;
-    }
-
-    fat_ptr++;
-    i++;
-  }
-
-  return -1;
-}
-
-/**
- * Given the address of a directory data block and the maximum number of entries, find the next free directory entry
- * Returns -1 if no free entry is found
- * dir_addr: address of the directory data block (not the FAT idx)
- * dir_entries_max: maximum number of entries in the directory
-*/
-word brfs_find_next_free_dir_entry(word* dir_addr, word dir_entries_max)
-{
-  word i = 0;
-  word* dir_ptr = dir_addr;
-
-  while (i < dir_entries_max)
-  {
-    if (*dir_ptr == 0)
-    {
-      return i;
-    }
-
-    dir_ptr += sizeof(struct brfs_dir_entry);
-    i++;
-  }
-
-  return -1;
-}
-
-/**
- * Create a single directory entry
- * dir_entry: pointer to the directory entry to be created
- * filename: name of the file, max 16 chars and uncompressed
- * fat_idx: index of the first FAT block of the file/directory
- * filesize: size of the file in words
- * flags: flags of the file/directory
-*/
-void brfs_create_single_dir_entry(struct brfs_dir_entry* dir_entry, char* filename, word fat_idx, word filesize, word flags)
-{
-  // Initialize to 0
-  memset((char*)dir_entry, 0, sizeof(*dir_entry));
-
-  // Set filename
-  char compressed_filename[4] = {0,0,0,0};
-  strcompress(compressed_filename, filename);
-  memcpy((char*)&(dir_entry->filename), compressed_filename, sizeof(compressed_filename));
-
-  // Set other fields
-  dir_entry->fat_idx = fat_idx;
-  dir_entry->flags = flags;
-  dir_entry->filesize = filesize;
-}
-
-/**
- * Initialize a directory with . and .. entries
- * dir_addr: address of the directory data block
- * dir_entries_max: maximum number of entries in the directory
- * dir_fat_idx: index of the FAT block of the directory
- * parent_fat_idx: index of the FAT block of the parent directory
-*/
-void brfs_init_directory(word* dir_addr, word dir_entries_max, word dir_fat_idx, word parent_fat_idx)
-{
-  // Create . entry
-  struct brfs_dir_entry dir_entry;
-  brfs_create_single_dir_entry(&dir_entry, ".", dir_fat_idx, dir_entries_max*sizeof(struct brfs_dir_entry), 1);
-  // Copy to first data entry
-  memcpy(dir_addr, (char*)&dir_entry, sizeof(dir_entry));
-
-  // Create .. entry
-  brfs_create_single_dir_entry(&dir_entry, "..", parent_fat_idx, dir_entries_max*sizeof(struct brfs_dir_entry), 1);
-  // Copy to second data entry
-  memcpy(dir_addr+sizeof(dir_entry), (char*)&dir_entry, sizeof(dir_entry));
-
-  // Set FAT table
-  brfs_ram_storage[SUPERBLOCK_SIZE + dir_fat_idx] = -1;
-
-  // Set changed block
-  brfs_changed_blocks[dir_fat_idx >> 5] |= (1 << (dir_fat_idx & 31));
-}
-
-/**
- * Format the ram storage as a BRFS filesystem
- * Also writes the superblock to SPI Flash
- * blocks: number of blocks in the filesystem
- * words_per_block: number of bytes per block
- * label: label of the filesystem
- * full_format: if 1, initialize data section to 0
-*/
-void brfs_format(word blocks, word words_per_block, char* label, word full_format)
-{
-  // Create a superblock
-  struct brfs_superblock superblock;
-
-  // Initialize to 0
-  memset((char*)&superblock, 0, sizeof(superblock));
-
-  // Set values of superblock
-  superblock.total_blocks = blocks;
-  superblock.words_per_block = words_per_block;
-  strcpy((char*)&superblock.label, label);
-  superblock.brfs_version = BRFS_SUPPORTED_VERSION;
-
-  // Copy superblock to head of ram addr
-  memcpy(brfs_ram_storage, (char*)&superblock, sizeof(superblock));
-
-
-  // Create FAT
-  memset(brfs_ram_storage + SUPERBLOCK_SIZE, 0, blocks);
-
-  // Create Data section
-  if (full_format)
-  {
-    memset(brfs_ram_storage + SUPERBLOCK_SIZE + blocks, 0, blocks * words_per_block);
-  }
-  
-  // Initialize root dir
-  word dir_entries_max = words_per_block / sizeof(struct brfs_dir_entry);
-  brfs_init_directory(brfs_ram_storage + SUPERBLOCK_SIZE + blocks, dir_entries_max, 0, 0);
-
-  // Clear open files and cursors
-  memset(brfs_file_pointers, 0, sizeof(brfs_file_pointers));
-  memset(brfs_cursors, 0, sizeof(brfs_cursors));
-  // Set all dir entry pointers to 0
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    brfs_dir_entry_pointers[i] = 0;
-  }
-
-  // For all blocks that have just been formatted, set changed block
-  word j;
-  for (j = 0; j < blocks; j++)
-  {
-    brfs_changed_blocks[j >> 5] |= (1 << (j & 31));
-  }
-
-  // Write superblock to SPI Flash
-  spiflash_sector_erase(BRFS_SPIFLASH_SUPERBLOCK_ADDR);
-  spiflash_write_page_in_words((char*)&superblock, BRFS_SPIFLASH_SUPERBLOCK_ADDR, sizeof(superblock));
-}
-
-/**
- * Create a new directory in the directory of parent_dir_path
- * Returns 1 on success, 0 on error
- * parent_dir_path: full path of the parent directory
- * dirname: name of the new directory
-*/
-word brfs_create_directory(char* parent_dir_path, char* dirname)
-{
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-
-  word* brfs_data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // Find first free FAT block
-  word next_free_block = brfs_find_next_free_block(brfs_ram_storage + SUPERBLOCK_SIZE, superblock->total_blocks);
-  if (next_free_block == -1)
-  {
-    uprintln("No free blocks left!");
-    return 0;
-  }
-
-  // Find data block address of parent directory path
-  word parent_dir_fat_idx = brfs_get_fat_idx_of_dir(parent_dir_path);
-  if (parent_dir_fat_idx == -1)
-  {
-    uprint("Parent directory ");
-    uprint(parent_dir_path);
-    uprintln(" not found!");
-    return 0;
-  }
-
-  // Check if file or folder already exists
-  word* parent_dir_addr = brfs_data_block_addr + (parent_dir_fat_idx * superblock->words_per_block);
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-  word i;
-  for (i = 0; i < dir_entries_max; i++)
-  {
-    struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (parent_dir_addr + (i * sizeof(struct brfs_dir_entry)));
-    if (dir_entry->filename[0] != 0)
-    {
-      char decompressed_filename[16];
-      strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-      if (strcmp(decompressed_filename, dirname) == 0)
-      {
-        uprint(dirname);
-        uprintln(" already exists!");
-        return 0;
-      }
-    }
-  }
-
-  // Find first free dir entry
-  word next_free_dir_entry = brfs_find_next_free_dir_entry(
-    brfs_data_block_addr + (parent_dir_fat_idx * superblock->words_per_block), 
-    superblock->words_per_block / sizeof(struct brfs_dir_entry)
-  );
-  if (next_free_dir_entry == -1)
-  {
-    uprintln("No free dir entries left!");
-    return 0;
-  }
-
-  // Create dir entry
-  struct brfs_dir_entry new_entry;
-  brfs_create_single_dir_entry(&new_entry, dirname, next_free_block, 0, 1);
-
-  // Copy dir entry to first free dir entry
-  memcpy(
-    brfs_data_block_addr + (parent_dir_fat_idx * superblock->words_per_block) + (next_free_dir_entry * sizeof(struct brfs_dir_entry)),
-    (char*)&new_entry,
-    sizeof(new_entry)
-  );
-
-  // Initialize directory
-  brfs_init_directory(
-    brfs_data_block_addr + (next_free_block * superblock->words_per_block),
-    dir_entries_max,
-    next_free_block,
-    parent_dir_fat_idx
-  );
-
-  // Update changed block
-  brfs_changed_blocks[next_free_block >> 5] |= (1 << (next_free_block & 31));
-
-  return 1;
-}
-
-/**
- * Create a new file in the directory of parent_dir_path
- * Returns 1 on success, 0 on error
- * parent_dir_path: full path of the parent directory
- * filename: name of the new file
-*/
-word brfs_create_file(char* parent_dir_path, char* filename)
-{
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-
-  word* brfs_data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // Find first free FAT block
-  word next_free_block = brfs_find_next_free_block(brfs_ram_storage + SUPERBLOCK_SIZE, superblock->total_blocks);
-  if (next_free_block == -1)
-  {
-    uprintln("No free blocks left!");
-    return 0;
-  }
-
-  // Find data block address of parent directory path
-  word parent_dir_fat_idx = brfs_get_fat_idx_of_dir(parent_dir_path);
-  if (parent_dir_fat_idx == -1)
-  {
-    uprint("Parent directory ");
-    uprint(parent_dir_path);
-    uprintln(" not found!");
-    return 0;
-  }
-
-  // Check if file or folder already exists
-  word* parent_dir_addr = brfs_data_block_addr + (parent_dir_fat_idx * superblock->words_per_block);
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-  word i;
-  for (i = 0; i < dir_entries_max; i++)
-  {
-    struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (parent_dir_addr + (i * sizeof(struct brfs_dir_entry)));
-    if (dir_entry->filename[0] != 0)
-    {
-      char decompressed_filename[16];
-      strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-      if (strcmp(decompressed_filename, filename) == 0)
-      {
-        uprint(filename);
-        uprintln(" already exists!");
-        return 0;
-      }
-    }
-  }
-
-  // Find first free dir entry
-  word next_free_dir_entry = brfs_find_next_free_dir_entry(
-    brfs_data_block_addr + (parent_dir_fat_idx * superblock->words_per_block), 
-    superblock->words_per_block / sizeof(struct brfs_dir_entry)
-  );
-  if (next_free_dir_entry == -1)
-  {
-    uprintln("No free dir entries left!");
-    return 0;
-  }
-
-  // Create file entry
-  struct brfs_dir_entry new_entry;
-  brfs_create_single_dir_entry(&new_entry, filename, next_free_block, 0, 0);
-
-  // Copy dir entry to first free dir entry
-  memcpy(
-    brfs_data_block_addr + (parent_dir_fat_idx * superblock->words_per_block) + (next_free_dir_entry * sizeof(struct brfs_dir_entry)),
-    (char*)&new_entry,
-    sizeof(new_entry)
-  );
-
-  // Initialize file by setting data to 0
-  memset(
-    brfs_data_block_addr + (next_free_block * superblock->words_per_block),
-    0,
-    superblock->words_per_block
-  );
-
-  // Update FAT
-  brfs_ram_storage[SUPERBLOCK_SIZE + next_free_block] = -1;
-
-  // Update changed block
-  brfs_changed_blocks[next_free_block >> 5] |= (1 << (next_free_block & 31));
-
-  return 1;
-}
-
-/**
- * List the contents of a directory over UART
- * dir_path: full path of the directory
-*/
-void brfs_list_directory(char* dir_path)
-{
-  uprint("Listing directory ");
-  uprintln(dir_path);
-  uprintln("-------------------");
-
-  // Find data block address of parent directory path
-  word dir_fat_idx = brfs_get_fat_idx_of_dir(dir_path);
-  if (dir_fat_idx == -1)
-  {
-    uprint("Parent directory ");
-    uprint(dir_path);
-    uprintln(" not found!");
-    return;
-  }
-
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* dir_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks + (dir_fat_idx * superblock->words_per_block);
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-
-  word i;
-  for (i = 0; i < dir_entries_max; i++)
-  {
-    struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (dir_addr + (i * sizeof(struct brfs_dir_entry)));
-    if (dir_entry->filename[0] != 0)
-    {
-      uprint("Filename: ");
-      char decompressed_filename[16];
-      strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-      uprint(decompressed_filename);
-      uprint(" FAT idx: ");
-      uprintDec((dir_entry->fat_idx));
-      uprint(" Flags: ");
-      uprintDec((dir_entry->flags));
-      uprint(" Filesize: ");
-      uprintDec((dir_entry->filesize));
-      uprintc('\n');
-    }
-  }
-  uprintln("");
-}
-
-/**
- * Open a file for reading and writing
- * Returns the file pointer (FAT idx of file), or -1 on error
- * file_path: full path of the file
-*/
-word brfs_open_file(char* file_path)
-{
-
-  // Split filename from path using basename and dirname
-  char dirname_output[MAX_PATH_LENGTH];
-  char* file_path_basename = basename(file_path);
-  char* file_path_dirname = dirname(dirname_output, file_path);
-
-  // Find data block address of parent directory path
-  word dir_fat_idx = brfs_get_fat_idx_of_dir(file_path_dirname);
-  if (dir_fat_idx == -1)
-  {
-    uprint("Parent directory ");
-    uprint(file_path_dirname);
-    uprintln(" not found!");
-    return -1;
-  }
-
-  // Find file in directory
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* dir_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks + (dir_fat_idx * superblock->words_per_block);
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-
-  word i;
-  for (i = 0; i < dir_entries_max; i++)
-  {
-    struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (dir_addr + (i * sizeof(struct brfs_dir_entry)));
-    if (dir_entry->filename[0] != 0)
-    {
-      char decompressed_filename[16];
-      strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-      // Also check for directory flag to be 0
-      if (strcmp(decompressed_filename, file_path_basename) == 0 && dir_entry->flags == 0)
-      {
-        // Found file
-        // Check if file is already open
-        word j;
-        for (j = 0; j < MAX_OPEN_FILES; j++)
-        {
-          if (brfs_file_pointers[j] == dir_entry->fat_idx)
-          {
-            uprint("File ");
-            uprint(file_path_basename);
-            uprintln(" already open!");
-            return -1;
-          }
-        }
-
-        // Find first free file pointer
-        word next_free_file_pointer = -1;
-        for (j = 0; j < MAX_OPEN_FILES; j++)
-        {
-          if (brfs_file_pointers[j] == 0)
-          {
-            next_free_file_pointer = j;
-            break;
-          }
-        }
-
-        if (next_free_file_pointer == -1)
-        {
-          uprintln("All files already opened!");
-          return -1;
-        }
-
-        // Open file
-        brfs_file_pointers[next_free_file_pointer] = dir_entry->fat_idx;
-        brfs_cursors[next_free_file_pointer] = 0;
-        brfs_dir_entry_pointers[next_free_file_pointer] = dir_entry;
-        return brfs_file_pointers[next_free_file_pointer];
-      }
-    }
-  }
-  uprint("File ");
-  uprint(file_path_basename);
-  uprintln(" not found!");
-  return -1;
-}
-
-/**
- * Close an opened file
- * Returns 1 on success, 0 on error
- * file_pointer: file pointer returned by brfs_open_file
-*/
-word brfs_close_file(word file_pointer)
-{
-  // Find file pointer
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    if (brfs_file_pointers[i] == file_pointer)
-    {
-      // Close file
-      brfs_file_pointers[i] = 0;
-      brfs_cursors[i] = 0;
-      brfs_dir_entry_pointers[i] = 0;
-      return 1;
-    }
-  }
-  uprintln("File not found!");
-  return 0;
-}
-
-
-/**
- * Delete a file by removing all FAT blocks and the directory entry
- * Returns 1 on success, 0 on error
- * file_path: full path of the file
-*/
-word brfs_delete_file(char* file_path)
-{
-  // Split filename from path using basename and dirname
-  char dirname_output[MAX_PATH_LENGTH];
-  char* file_path_basename = basename(file_path);
-  char* file_path_dirname = dirname(dirname_output, file_path);
-
-  // Find data block address of parent directory path
-  word dir_fat_idx = brfs_get_fat_idx_of_dir(file_path_dirname);
-  if (dir_fat_idx == -1)
-  {
-    uprint("Parent directory ");
-    uprint(file_path_dirname);
-    uprintln(" not found!");
-    return 0;
-  }
-
-  // Find file in directory
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* dir_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks + (dir_fat_idx * superblock->words_per_block);
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-
-  word i;
-  for (i = 0; i < dir_entries_max; i++)
-  {
-    struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (dir_addr + (i * sizeof(struct brfs_dir_entry)));
-    if (dir_entry->filename[0] != 0)
-    {
-      char decompressed_filename[16];
-      strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-      // Also check for directory flag to be 0
-      if (strcmp(decompressed_filename, file_path_basename) == 0 && dir_entry->flags == 0)
-      {
-        // Found file
-        // Check if file is already open
-        word j;
-        for (j = 0; j < MAX_OPEN_FILES; j++)
-        {
-          if (brfs_file_pointers[j] == dir_entry->fat_idx)
-          {
-            uprint("File ");
-            uprint(file_path_basename);
-            uprintln(" is open!");
-            return 0;
-          }
-        }
-
-        // Delete fat blocks
-        word current_fat_idx = dir_entry->fat_idx;
-        word next_fat_idx;
-        while (current_fat_idx != -1)
-        {
-          next_fat_idx = brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx];
-          brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx] = 0;
-          brfs_changed_blocks[current_fat_idx >> 5] |= (1 << (current_fat_idx & 31));
-          current_fat_idx = next_fat_idx;
-        }
-
-        // Delete file
-        memset((char*)dir_entry, 0, sizeof(struct brfs_dir_entry));
-
-        // Update changed block
-        brfs_changed_blocks[dir_fat_idx >> 5] |= (1 << (dir_fat_idx & 31));
-        return 1;
-      }
-    }
-  }
-  uprint("File ");
-  uprint(file_path_basename);
-  uprintln(" not found!");
-  return 0;
-}
-
-/**
- * Set the cursor of an opened file
- * Returns 1 on success, 0 on error
- * file_pointer: file pointer returned by brfs_open_file
- * cursor: new cursor position in words
-*/
-word brfs_set_cursor(word file_pointer, word cursor)
-{
-  if (file_pointer == 0)
-  {
-    uprintln("File not open!");
-    return 0;
-  }
-
-  // Find file pointer
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    if (brfs_file_pointers[i] == file_pointer)
-    {
-      // Set cursor
-      if (cursor < 0 || cursor > brfs_dir_entry_pointers[i]->filesize)
-      {
-        cursor = brfs_dir_entry_pointers[i]->filesize;
-      }
-
-      brfs_cursors[i] = cursor;
-      return 1;
-    }
-  }
-  uprintln("File not found!");
-  return 0;
-}
-
-/**
- * Get the cursor of an opened file
- * Returns the cursor position in words, or -1 on error
- * file_pointer: file pointer returned by brfs_open_file
-*/
-word brfs_get_cursor(word file_pointer)
-{
-  if (file_pointer == 0)
-  {
-    uprintln("File not open!");
-    return -1;
-  }
-
-  // Find file pointer
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    if (brfs_file_pointers[i] == file_pointer)
-    {
-      // Get cursor
-      return brfs_cursors[i];
-    }
-  }
-  uprintln("File not found!");
-  return -1;
-}
-
-/**
- * Get the FAT index of a file at the cursor
- * Returns the FAT index, or 0 on error
- * file_pointer: file pointer returned by brfs_open_file
- * cursor: cursor position of opened file
-*/
-word brfs_get_fat_idx_at_cursor(word file_pointer, word cursor)
-{
-  if (file_pointer == 0)
-  {
-    uprintln("File not open!");
-    return 0;
-  }
-  // Get FAT index of file at cursor
-  word current_fat_idx = file_pointer;
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-
-  // Loop through FAT until cursor is reached
-  while (cursor > superblock->words_per_block)
-  {
-    current_fat_idx = brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx];
-    if (current_fat_idx == -1)
-    {
-      uprintln("Cursor is out of bounds!");
-      return 0;
-    }
-    cursor -= superblock->words_per_block;
-  }
-
-  return current_fat_idx;
-}
-
-/**
- * Read a file from the cursor position
- * Returns 1 on success, or 0 on error
- * file_pointer: file pointer returned by brfs_open_file
- * buffer: buffer to read the file into
- * length: number of words to read
-*/
-word brfs_read(word file_pointer, word* buffer, word length)
-{
-  if (file_pointer == 0)
-  {
-    uprintln("File not open!");
-    return 0;
-  }
-
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // Find file pointer
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    if (brfs_file_pointers[i] == file_pointer)
-    {
-      if (length < 0)
-      {
-        uprintln("Length cannot be negative!");
-        return 0;
-      }
-      // Trunctate length to file size - cursor
-      if (length > brfs_dir_entry_pointers[i]->filesize - brfs_cursors[i])
-      {
-        length = brfs_dir_entry_pointers[i]->filesize - brfs_cursors[i];
-      }
-
-      // Get FAT index of file at cursor
-      word current_fat_idx = brfs_get_fat_idx_at_cursor(file_pointer, brfs_cursors[i]);
-      if (current_fat_idx == 0)
-      {
-        uprintln("Error getting FAT index at cursor!");
-        return 0;
-      }
-
-      // Loop:
-      // - calculate words until end of block (or up to length)
-      // - read words until end of block (or up to length)
-      // - decrease length by words read
-      // - get next block from FAT
-      // - repeat until length is 0
-      while (length > 0)
-      {
-        word words_until_end_of_block = superblock->words_per_block - (MATH_modU(brfs_cursors[i], superblock->words_per_block));
-        word words_to_read = words_until_end_of_block > length ? length : words_until_end_of_block;
-
-        // Copy words to buffer
-        memcpy(buffer, data_block_addr + (current_fat_idx * superblock->words_per_block) + brfs_cursors[i], words_to_read);
-
-        // Update cursor and length
-        brfs_cursors[i] += words_to_read;
-        length -= words_to_read;
-        buffer += words_to_read;
-
-        // Get next block from FAT
-        current_fat_idx = brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx];
-        if (current_fat_idx == -1 && length > 0)
-        {
-          uprintln("There is no next block in the file!");
-          return 0;
-        }
-      }
-
-      return 1;
-    }
-  }
-  uprintln("File not found!");
-  return 0;
-}
-
-/**
- * Write a file from the cursor position
- * Returns 1 on success, or 0 on error
- * file_pointer: file pointer returned by brfs_open_file
- * buffer: buffer to write to the file
- * length: number of words to write
-*/
-word brfs_write(word file_pointer, word* buffer, word length)
-{
-  if (file_pointer == 0)
-  {
-    uprintln("File not open!");
-    return 0;
-  }
-
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // Find file pointer
-  word i;
-  for (i = 0; i < MAX_OPEN_FILES; i++)
-  {
-    if (brfs_file_pointers[i] == file_pointer)
-    {
-      if (length < 0)
-      {
-        uprintln("Length cannot be negative!");
-        return 0;
-      }
-
-      // Get FAT index of file at cursor
-      word current_fat_idx = brfs_get_fat_idx_at_cursor(file_pointer, brfs_cursors[i]);
-      if (current_fat_idx == 0)
-      {
-        uprintln("Error getting FAT index at cursor!");
-        return 0;
-      }
-
-      // Loop:
-      // - calculate words until end of block (or up to length)
-      // - write words until end of block (or up to length)
-      // - decrease length by words written
-      // - get next block from FAT, or find next free block if end of block
-      // - if next block is needed, update FAT
-      // - repeat until length is 0
-      while (length > 0)
-      {
-        word cursor_in_block = MATH_modU(brfs_cursors[i], superblock->words_per_block);
-        word words_until_end_of_block = superblock->words_per_block - cursor_in_block;
-        word words_to_write = words_until_end_of_block > length ? length : words_until_end_of_block;
-
-        // Copy words to buffer
-        memcpy(data_block_addr + (current_fat_idx * superblock->words_per_block) + cursor_in_block, buffer, words_to_write);
-
-        // Update changed block
-        brfs_changed_blocks[current_fat_idx >> 5] |= (1 << (current_fat_idx & 31));
-
-        // Update cursor and length
-        brfs_cursors[i] += words_to_write;
-        length -= words_to_write;
-        buffer += words_to_write;
-
-        // Get next block from FAT, or find next free block if end of block
-        if (words_until_end_of_block == words_to_write && length > 0)
-        {
-          
-          word next_fat_idx = brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx];
-          // Check if next block is already allocated
-          if (next_fat_idx != -1)
-          {
-            current_fat_idx = next_fat_idx;
-          }
-          else
-          {
-            // Find next free block
-            word next_free_block = brfs_find_next_free_block(brfs_ram_storage + SUPERBLOCK_SIZE, superblock->total_blocks);
-            if (next_free_block == -1)
-            {
-              uprintln("No free blocks left!");
-              return 0;
-            }
-            // Update FAT
-            brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx] = next_free_block;
-            // Go to next block
-            current_fat_idx = next_free_block;
-            // Set next block to -1 to indicate end of file
-            brfs_ram_storage[SUPERBLOCK_SIZE + current_fat_idx] = -1;
-            // Update changed block
-            brfs_changed_blocks[current_fat_idx >> 5] |= (1 << (current_fat_idx & 31));
-          }
-        }
-      }
-
-      // Update file size in dir entry if we wrote past the current size
-      if (brfs_cursors[i] > brfs_dir_entry_pointers[i]->filesize)
-      {
-        brfs_dir_entry_pointers[i]->filesize = brfs_cursors[i];
-      }
-
-      return 1;
-    }
-  }
-  uprintln("File not found!");
-  return 0;
-}
-
-/**
- * Stat a file or directory
- * Returns the directory entry, or -1 on error
-*/
-struct brfs_dir_entry* brfs_stat(char* file_path)
-{
-  // Split filename from path using basename and dirname
-  char dirname_output[MAX_PATH_LENGTH];
-  char* file_path_basename = basename(file_path);
-  char* file_path_dirname = dirname(dirname_output, file_path);
-
-  // Find data block address of parent directory path
-  word dir_fat_idx = brfs_get_fat_idx_of_dir(file_path_dirname);
-  if (dir_fat_idx == -1)
-  {
-    uprint("Parent directory ");
-    uprint(file_path_dirname);
-    uprintln(" not found!");
-    return (struct brfs_dir_entry*)-1;
-  }
-
-  // Find file in directory
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* dir_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks + (dir_fat_idx * superblock->words_per_block);
-  word dir_entries_max = superblock->words_per_block / sizeof(struct brfs_dir_entry);
-
-  word i;
-  for (i = 0; i < dir_entries_max; i++)
-  {
-    struct brfs_dir_entry* dir_entry = (struct brfs_dir_entry*) (dir_addr + (i * sizeof(struct brfs_dir_entry)));
-    if (dir_entry->filename[0] != 0)
-    {
-      char decompressed_filename[16];
-      strdecompress(decompressed_filename, (char*)&(dir_entry->filename));
-      // Also check for directory flag to be 0
-      if (strcmp(decompressed_filename, file_path_basename) == 0)
-      {
-        return dir_entry;
-      }
-    }
-  }
-  uprint("File or directory ");
-  uprint(file_path_basename);
-  uprintln(" not found!");
-  return (struct brfs_dir_entry*)-1;
-}
-
-/**
- * Check if a block has changed by comparing it to the flash, returns 1 if changed and 0 if not
- * Note: this is slow and should eventually be replaced by a list of changed blocks
- * block_idx: index of the block
-*/
-word brfs_check_block_changed(word block_idx)
-{
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  word spi_data_buffer[256];
-
-  if (superblock->words_per_block > 256)
-  {
-    uprintln("Error: words_per_block should be <= 256 for this function!");
-    return 0;
-  }
-
-  // Read block from flash, and enable bytes to word
-  spiflash_read_from_address(spi_data_buffer, BRFS_SPIFLASH_BLOCK_ADDR + block_idx * superblock->words_per_block, superblock->words_per_block, 1);
-
-  // Compare block to flash
-  return memcmp(data_block_addr + (block_idx * superblock->words_per_block), spi_data_buffer, superblock->words_per_block);
-}
-
-/**
- * Write the FAT table to SPI flash by performing three steps:
- * 1. Check which FAT entries have changed
- * 2. Erase the 4KiB sectors that contain these FAT entries
- * 3. Write each changed FAT entry to flash by using 16 page writes per sector
-*/
-void brfs_write_fat_to_flash()
-{
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // 1 sector = 4KiB = 1024 words = 1024 FAT entries
-  // 1 word contains 32 flags for changed blocks/FAT entries
-  // 1024/32 = 32 words in the changed_blocks array per sector
-
-  uprintln("---Writing FAT to SPI Flash---");
-
-  // Loop over brfs_changed_blocks in 32 word parts
-  // Assumes length of brfs_changed_blocks is a multiple of 32
-  word i;
-  for (i = 0; i < sizeof(brfs_changed_blocks); i+=32)
-  {
-    // Check if any value within brfs_changed_blocks[i:i+32] is not 0
-    word j;
-    word changed = 0;
-    for (j = 0; j < 32; j++)
-    {
-      if (brfs_changed_blocks[i+j] != 0)
-      {
-        changed = 1;
-        break;
-      }
-    }
-
-    if (changed)
-    {
-      // Erase sector
-      word addr = BRFS_SPIFLASH_FAT_ADDR; // Workaround because of large static number
-      addr += (i >> 5) * 4096; // Sector idx * bytes per sector
-      spiflash_sector_erase(addr);
-      uprint("Erased sector ");
-      uprintDec(i >> 5);
-      uprint(" at address ");
-      uprintHex(addr);
-      uprintln("");
-
-
-      // Write sector by writing 16 pages k of 64 words
-      // Does not check for boundaries of actual FAT table size,
-      //  so it can write garbage if block size is not a multiple of 1024
-      word k;
-      for (k = 0; k < 1024; k+=64)
-      {
-        addr = BRFS_SPIFLASH_FAT_ADDR; // Workaround because of large static number
-        addr += (i >> 5) * 4096; // Sector idx * bytes per sector
-        addr += k << 2; // 64 words * 4 bytes per word
-
-        word* fat_addr_ram = brfs_ram_storage + SUPERBLOCK_SIZE + (i << 5) + k;
-        spiflash_write_page_in_words(fat_addr_ram, addr, 64);
-
-        uprint("Wrote FAT entries ");
-        uprintDec((i << 5) + k);
-        uprint(":");
-        uprintDec((i << 5) + k + 63);
-        uprint(" from RAM addr ");
-        uprintHex((word)fat_addr_ram);
-        uprint(" to SPI Flash addr ");
-        uprintHex(addr);
-        uprintln("");
-      }
-    }
-  }
-
-  uprintln("---Finished writing FAT to SPI Flash---");
-}
-
-/**
- * Write the data blocks to SPI flash by performing three steps:
- * 1. Check which blocks have changed
- * 2. Erase the 4KiB sectors that contain these blocks
- * 3. Write each erased sector with the new block data by using 16 page writes per sector
-*/
-void brfs_write_blocks_to_flash()
-{
-  // Loop over all blocks
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  word* data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // Check if block size is <= 4KiB
-  if (superblock->words_per_block > 1024)
-  {
-    uprintln("Error: block size should be <= 4KiB");
-    return;
-  }
-
-  // Check if block size is a multiple of 64
-  if (superblock->words_per_block & 63)
-  {
-    uprintln("Error: block size should be a multiple of 64");
-    return;
-  }
-
-  uprintln("---Writing blocks to SPI Flash---");
-
-  word blocks_per_sector = MATH_divU(4096, superblock->words_per_block * 4);
-  uprint("Blocks per sector: ");
-  uprintDec(blocks_per_sector);
-  uprintln("");
-
-  // Erase 4KiB sectors that contain changed blocks
-  // This code is written such that it only erases each sector once, even if multiple blocks in the sector have changed
-  word i;
-  word sector_to_erase = -1;
-  for (i = 0; i < superblock->total_blocks; i++)
-  {
-    if (brfs_changed_blocks[i >> 5] & (1 << (i & 31)))
-    {
-      if (sector_to_erase == -1)
-      {
-        sector_to_erase = MATH_divU(i, blocks_per_sector);
-      }
-      else if (sector_to_erase != MATH_divU(i, blocks_per_sector))
-      {
-        word addr = BRFS_SPIFLASH_BLOCK_ADDR; // Workaround because of large static number
-        addr += sector_to_erase * 4096;
-        spiflash_sector_erase(addr);
-        uprint("Erased sector ");
-        uprintDec(sector_to_erase);
-        uprint(" at address ");
-        uprintHex(addr);
-        uprintln("");
-
-        sector_to_erase = MATH_divU(i, blocks_per_sector);
-      }
-    }
-  }
-  if (sector_to_erase != -1)
-  {
-    word addr = BRFS_SPIFLASH_BLOCK_ADDR; // Workaround because of large static number
-    addr += sector_to_erase * 4096;
-    spiflash_sector_erase(addr);
-    uprint("Erased sector ");
-    uprintDec(sector_to_erase);
-    uprint(" at address ");
-    uprintHex(addr);
-    uprintln("");
-  }
-
-  // Write each block to flash in parts of 64 words
-  for (i = 0; i < superblock->total_blocks; i++)
-  {
-    if (brfs_changed_blocks[i >> 5] & (1 << (i & 31)))
-    {
-      word j;
-      for (j = 0; j < superblock->words_per_block; j+=64)
-      {
-        word spiflash_addr = BRFS_SPIFLASH_BLOCK_ADDR; // Workaround because of large static number
-        spiflash_addr += i * (superblock->words_per_block * 4) + (j * 4);
-
-        word* data_addr = data_block_addr + (i * superblock->words_per_block) + j;
-        spiflash_write_page_in_words(data_addr, spiflash_addr, 64);
-
-        uprint("Wrote block ");
-        uprintDec(i);
-        uprint(" from RAM addr ");
-        uprintHex((word)data_addr);
-        uprint(" to SPI Flash addr ");
-        uprintHex(spiflash_addr);
-        uprintln("");
-      }
-    }
-  }
-
-  uprintln("---Finished writing blocks to SPI Flash---");
-}
-
-/**
- * Write the FAT and data blocks to SPI flash
- * Superblock should already be written to flash during format
-*/
-void brfs_write_to_flash()
-{
-  brfs_write_fat_to_flash();
-  brfs_write_blocks_to_flash();
-}
-
-/**
- * Checks if given superblock is valid
- * Returns 1 if valid, 0 if invalid
-*/
-word brfs_superblock_is_valid(struct brfs_superblock* superblock)
-{
-  // Check if brfs version is correct
-  if (superblock->brfs_version != BRFS_SUPPORTED_VERSION)
-  {
-    uprint("BRFS version ");
-    uprintDec(superblock->brfs_version);
-    uprint(" is not supported by this implementation (");
-    uprintDec(BRFS_SUPPORTED_VERSION);
-    uprintln(")!");
-    return 0;
-  }
-  // Check if total blocks is > 0 and a multiple of 64
-  if (superblock->total_blocks == 0 || superblock->total_blocks & 63)
-  {
-    uprintln("Error: total blocks should be > 0 and a multiple of 64");
-    return 0;
-  }
-  // Check if block size is > 0
-  if (superblock->words_per_block == 0)
-  {
-    uprintln("Error: block size should be > 0");
-    return 0;
-  }
-  // Check if words per block is > 0 and <= 2048
-  if (superblock->words_per_block == 0 || superblock->words_per_block > 2048)
-  {
-    uprintln("Error: words per block should be > 0 and <= 2048");
-    return 0;
-  }
-
-  return 1;
-}
-
-/**
- * Read the superblock, FAT and data blocks from SPI flash
- * Returns 1 on success, or 0 on error
-*/
-word brfs_read_from_flash()
-{
-  // Read superblock from flash
-  spiflash_read_from_address(brfs_ram_storage, BRFS_SPIFLASH_SUPERBLOCK_ADDR, SUPERBLOCK_SIZE, 1);
-
-  // Perform validity checks on superblock
-  struct brfs_superblock* superblock = (struct brfs_superblock*) brfs_ram_storage;
-  if (!brfs_superblock_is_valid(superblock))
-  {
-    uprintln("Error: superblock is not valid!");
-    return 0;
-  }
-  
-  word* data_block_addr = brfs_ram_storage + SUPERBLOCK_SIZE + superblock->total_blocks;
-
-  // Read FAT from flash
-  spiflash_read_from_address(brfs_ram_storage + SUPERBLOCK_SIZE, BRFS_SPIFLASH_FAT_ADDR, superblock->total_blocks, 1);
-
-  // Read data blocks from flash
-  spiflash_read_from_address(data_block_addr, BRFS_SPIFLASH_BLOCK_ADDR, superblock->total_blocks * superblock->words_per_block, 1);
-
-  return 1;
-}
-
-
-int main() 
-{
-  // Clear UART screen:
-  uprintc(0x1B);
-  uprintc(0x5B);
-  uprintc(0x32);
-  uprintc(0x4A);
-  uprintln("------------------------");
-  uprintln("BRFS test implementation");
-  uprintln("------------------------");
-
-  spiflash_init();
-
-  // Flag to switch between write and read test
-  word write_test = 1;
-  
-  // Small scale test values
-  //word blocks = 16;
-  //word words_per_block = 64; // 256 bytes per block
-  //word full_format = 1;
-
-  // Large scale test
-  word blocks = 64; // 1KiB per block * 64 = 64KiB
-  word words_per_block = 128; // 1KiB per block
-  word full_format = 1;
-
-  if (write_test)
-  {
-    uprintln("Formatting BRFS filesystem...");
-    brfs_format(blocks, words_per_block, "SystemBRFS", full_format);
-    uprintln("BRFS filesystem formatted!");
-
-      // Create directories
-    if (!brfs_create_directory("/", "dir1"))
-    {
-      uprintln("Error creating dir1!");
-    }
-    if (!brfs_create_directory("/", "dir2"))
-    {
-      uprintln("Error creating dir2!");
-    }
-
-    // Create files
-    if (!brfs_create_file("/dir1", "file1.txt"))
-    {
-      uprintln("Error creating file1!");
-    }
-    if (!brfs_create_file("/dir1", "file2.txt"))
-    {
-      uprintln("Error creating file2!");
-    }
-
-    // Open file and write
-    word file_pointer = brfs_open_file("/dir1/file1.txt");
-    if (file_pointer == -1)
-    {
-      uprintln("Error opening file1!");
-    }
-    else
-    {
-      char* write_string = "This message should exceed the length of a single block, it even should exceed the length of two blocks! I am adding this part here to keep increasing the number of blocks used. This is the end of the message.";
-      if (!brfs_write(file_pointer, write_string, strlen(write_string)))
-      {
-        uprintln("Error writing to file1!");
-      }
-
-      // Update two blocks in the middle of the file
-      brfs_set_cursor(file_pointer, 57);
-      char* write_string2 = "THIS PART IS WRITTEN IN THE MIDDLE OF THE FILE!";
-      if (!brfs_write(file_pointer, write_string2, strlen(write_string2)))
-      {
-        uprintln("Error writing to file1!");
-      }
-
-      brfs_close_file(file_pointer);
-    }
-
-    // Open second file and write
-    word file_pointer2 = brfs_open_file("/dir1/file2.txt");
-    if (file_pointer2 == -1)
-    {
-      uprintln("Error opening file2!");
-    }
-    else
-    {
-      char* write_string = "Small message in file2!";
-      if (!brfs_write(file_pointer2, write_string, strlen(write_string)))
-      {
-        uprintln("Error writing to file2!");
-      }
-
-      // Update within the first block
-      brfs_set_cursor(file_pointer2, 6);
-      char* write_string2 = "UPDATES";
-      if (!brfs_write(file_pointer2, write_string2, strlen(write_string2)))
-      {
-        uprintln("Error writing to file2!");
-      }
-
-      // Skip closing the file to see data in dump
-      //brfs_close_file(file_pointer2);
-
-      brfs_list_directory("/");
-      brfs_list_directory("/dir1");
-      brfs_dump(blocks, blocks*words_per_block);
-
-      brfs_write_to_flash();
-    }
-  }
-  else
-  {
-    brfs_read_from_flash();
-
-    brfs_dump(blocks, blocks*words_per_block);
-
-    brfs_list_directory("/");
-    brfs_list_directory("/dir1");
-  }
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    default:
-      break;
-  }
-}

+ 0 - 78
BCC/userBDOS/COLORS.C

@@ -1,78 +0,0 @@
-// Prints some rgb colors for testing purposes
-
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
-#include "DATA/COLOR.C"
-
-#define DATA_OFFSET 3
-
-void testTiles()
-{
-  asm(".dw 0 1 2 3\n");
-}
-
-int main() 
-{
-  GFX_initVram(); // clear all VRAM
-  GFX_copyPaletteTable((word)DATA_PALETTE_COLOR);
-  GFX_copyPatternTable((word)DATA_PATTERN_COLOR);
-
-  word y = 0;
-  word c = 1;
-
-  word x;
-  for (x = 0; x < 5; x++)
-  {
-    GFX_printWindowColored(((word)testTiles) + DATA_OFFSET, 4, GFX_WindowPosFromXY(x*4, y), x + 1);
-    GFX_printBGColored(((word)testTiles) + DATA_OFFSET, 4, GFX_BackgroundPosFromXY(x*4, y+2), x + 1);
-  }
-
-  // Any key to quit
-  while (1)
-  {
-    if (HID_FifoAvailable())
-    {
-      word c = HID_FifoRead();
-      return 'q';
-    }
-  }
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
-  }
-}

+ 0 - 1073
BCC/userBDOS/DATA/ASCII_BW.C

@@ -1,1073 +0,0 @@
-/*
-* Contains default ASCII table with default palette table.
-* Assembly is used as workaround to store them.
-* Because of the default stack code at the start of each code,
-* an offset is required to access the data
-*/
-
-
-void DATA_PALETTE_DEFAULT(){
-asm(
-".dw 0b00000000000000001111111111111111 ; green, black,  white,  white\n"
-".dw 0b00000000000000000000000000011100\n"
-".dw 0b00000000000000000000000010100011\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-);
-}
-
-void DATA_ASCII_DEFAULT(){
-asm(
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111001100000000000011\n"
-".dw 0b11001100001100111100000000000011\n"
-".dw 0b11001111111100111100001111000011\n"
-".dw 0b11000000000000110011111111111100\n"
-".dw 0b00111111111111001111111111111111\n"
-".dw 0b11110011110011111111111111111111\n"
-".dw 0b11110000000011111111110000111111\n"
-".dw 0b11111111111111110011111111111100\n"
-".dw 0b00111100111100001111111111111100\n"
-".dw 0b11111111111111001111111111111100\n"
-".dw 0b00111111111100000000111111000000\n"
-".dw 0b00000011000000000000000000000000\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00111111111100001111111111111100\n"
-".dw 0b00111111111100000000111111000000\n"
-".dw 0b00000011000000000000000000000000\n"
-".dw 0b00001111110000000011111111110000\n"
-".dw 0b00001111110000001111111111111100\n"
-".dw 0b11111111111111001111001100111100\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00000011000000000000001100000000\n"
-".dw 0b00001111110000000011111111110000\n"
-".dw 0b11111111111111000011111111110000\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111100001111111111000000001111\n"
-".dw 0b11110000000011111111110000111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000111111110000\n"
-".dw 0b00111100001111000011000000001100\n"
-".dw 0b00110000000011000011110000111100\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11111111111111111111000000001111\n"
-".dw 0b11000011110000111100111111110011\n"
-".dw 0b11001111111100111100001111000011\n"
-".dw 0b11110000000011111111111111111111\n"
-".dw 0b00000000111111110000000000111111\n"
-".dw 0b00000000111111110011111111110011\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00001111111111110000111100001111\n"
-".dw 0b00001111111111110000111100000000\n"
-".dw 0b00001111000000000011111100000000\n"
-".dw 0b11111111000000001111110000000000\n"
-".dw 0b00111111111111110011110000001111\n"
-".dw 0b00111111111111110011110000001111\n"
-".dw 0b00111100000011110011110000111111\n"
-".dw 0b11111100001111001111000000000000\n"
-".dw 0b00000011110000001111001111001111\n"
-".dw 0b00001111111100001111110000111111\n"
-".dw 0b11111100001111110000111111110000\n"
-".dw 0b11110011110011110000001111000000\n"
-".dw 0b11000000000000001111110000000000\n"
-".dw 0b11111111110000001111111111111100\n"
-".dw 0b11111111110000001111110000000000\n"
-".dw 0b11000000000000000000000000000000\n"
-".dw 0b00000000000011000000000011111100\n"
-".dw 0b00001111111111001111111111111100\n"
-".dw 0b00001111111111000000000011111100\n"
-".dw 0b00000000000011000000000000000000\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00000011110000000011111111111100\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000000000000000000\n"
-".dw 0b00111100001111000000000000000000\n"
-".dw 0b00111111111111111111001111001111\n"
-".dw 0b11110011110011110011111111001111\n"
-".dw 0b00000011110011110000001111001111\n"
-".dw 0b00000011110011110000000000000000\n"
-".dw 0b00001111111111000011110000001111\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111000011111111111100\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00111111111111000000111111110000\n"
-".dw 0b00000011110000001111111111111111\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00111111111111000000111111110000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00000000111100001111111111111100\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00111100000000001111111111111100\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000000000001111111111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000110000110000\n"
-".dw 0b00111100001111001111111111111111\n"
-".dw 0b00111100001111000000110000110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00001111111100000011111111111100\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111111111\n"
-".dw 0b11111111111111110011111111111100\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111000000000011111111000000\n"
-".dw 0b00111111110000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b11111111111111000011110011110000\n"
-".dw 0b11111111111111000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00001111000000000011111111110000\n"
-".dw 0b11110000000000000011111111000000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000001111000000111100\n"
-".dw 0b11110000111100000000001111000000\n"
-".dw 0b00001111000000000011110000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00001111110000000011111100111100\n"
-".dw 0b11110011111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b11110000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000000000000000\n"
-".dw 0b00000000000000000011110000111100\n"
-".dw 0b00001111111100001111111111111111\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000001111111111110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000001111000000000011110000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b11000000000000000000000000000000\n"
-".dw 0b00111111111100001111000000111100\n"
-".dw 0b11110000111111001111001111111100\n"
-".dw 0b11111111001111001111110000111100\n"
-".dw 0b00111111111100000000000000000000\n"
-".dw 0b00001111000000000011111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000111100000000111111000000\n"
-".dw 0b00111100000000001111000011110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000111100000000111111000000\n"
-".dw 0b00000000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011111100000000111111110000\n"
-".dw 0b00111100111100001111000011110000\n"
-".dw 0b11111111111111000000000011110000\n"
-".dw 0b00000011111111000000000000000000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b11111111110000000000000011110000\n"
-".dw 0b00000000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00001111110000000011110000000000\n"
-".dw 0b11110000000000001111111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111111111100001111000011110000\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00111111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000011110000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111111111100001111000000111100\n"
-".dw 0b11110011111111001111001111111100\n"
-".dw 0b11110011111111001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00001111000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11111111111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b11111111111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000000000000011110000111100\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11111111110000000011110011110000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000011110011110000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b11111111111111000011110000001100\n"
-".dw 0b00111100110000000011111111000000\n"
-".dw 0b00111100110000000011110000001100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b11111111111111000011110000001100\n"
-".dw 0b00111100110000000011111111000000\n"
-".dw 0b00111100110000000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000111111000011110000111100\n"
-".dw 0b00001111111111000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111111111110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111110000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011111111000000000011110000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111100001111000011110000111100\n"
-".dw 0b00111100111100000011111111000000\n"
-".dw 0b00111100111100000011110000111100\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b11111111000000000011110000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111100000011000011110000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b11110000001111001111110011111100\n"
-".dw 0b11111111111111001111111111111100\n"
-".dw 0b11110011001111001111000000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b11110000001111001111110000111100\n"
-".dw 0b11111111001111001111001111111100\n"
-".dw 0b11110000111111001111000000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b11110000001111000011110011110000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b11111111111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110011111100000011111111000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b11111111111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100111100000011110000111100\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111111111100001100111100110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b11110000001111001111001100111100\n"
-".dw 0b11111111111111001111110011111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111111111111001111000000111100\n"
-".dw 0b11000000111100000000001111000000\n"
-".dw 0b00001111000011000011110000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00111111110000000011110000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000000000000011110000000000\n"
-".dw 0b00001111000000000000001111000000\n"
-".dw 0b00000000111100000000000000111100\n"
-".dw 0b00000000000011000000000000000000\n"
-".dw 0b00111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00111100111100001111000000111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111111111\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b11111100000000000011110000000000\n"
-".dw 0b00111100000000000011111111110000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b11110011111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000000000001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011111100000000000011110000\n"
-".dw 0b00000000111100000011111111110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100000000001111111100000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111001111001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b11111100000000000011110000000000\n"
-".dw 0b00111100111100000011111100111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000111100000000000000000000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b00000000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b11111100000000000011110000000000\n"
-".dw 0b00111100001111000011110011110000\n"
-".dw 0b00111111110000000011110011110000\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111111111111100\n"
-".dw 0b11111111111111001111001100111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110011111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100000000001111111100000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111001111001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100000000001111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110011111100000011111100111100\n"
-".dw 0b00111100001111000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111100001111000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b00000011000000000000111100000000\n"
-".dw 0b00111111111100000000111100000000\n"
-".dw 0b00001111000000000000111100110000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000001111001111001100111100\n"
-".dw 0b11111111111111001111111111111100\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000001111000011110011110000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111100001100001111000000\n"
-".dw 0b00001111000000000011110000110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000011111100000000111100000000\n"
-".dw 0b00001111000000001111110000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11111100000000000000111100000000\n"
-".dw 0b00001111000000000000001111110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111001111001111001111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000001100000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000000000001111000011110000\n"
-".dw 0b00111111110000000000001111000000\n"
-".dw 0b00000000111100000011111111000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111111111001111000000001111\n"
-".dw 0b00001111111100000000000000111100\n"
-".dw 0b00001111111111000011110000111100\n"
-".dw 0b00001111111111110000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000000000000\n"
-".dw 0b11110000000000000011111111000000\n"
-".dw 0b00000000111100000000111111000000\n"
-".dw 0b00111111111111001111000000001111\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00111111111111000011110000000000\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111111100001111000000111100\n"
-".dw 0b00001111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000001111000000111111000000\n"
-".dw 0b00111100111100001111000000111100\n"
-".dw 0b11111111111111001111000000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111111111110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b11111111111100000011110000000000\n"
-".dw 0b00111111110000000011110000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111110000000011110000\n"
-".dw 0b00111111111111111111000011110000\n"
-".dw 0b00111111111111110000000000000000\n"
-".dw 0b00001111111111000011110011110000\n"
-".dw 0b11110000111100001111111111111100\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111111000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000001111110000000000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000001111110000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b11110000000011110000001111000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00111100001111000000111111110000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00111111111111001111000000000000\n"
-".dw 0b11110000000000000011111111111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100001100001111111100000000\n"
-".dw 0b00111100000000001111110000111100\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000001111111111110000\n"
-".dw 0b00001111000000001111111111110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111111110000001111000011110000\n"
-".dw 0b11110000111100001111111111001100\n"
-".dw 0b11110000001111001111000011111111\n"
-".dw 0b11110000001111001111000000111111\n"
-".dw 0b00000000111111000000001111001111\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11110011110000000011111100000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000001111110000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000001111110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000001111111111000000\n"
-".dw 0b00000000000000001111111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b11110000111100001111110011110000\n"
-".dw 0b11111111111100001111001111110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00001111111100000011110011110000\n"
-".dw 0b00111100111100000000111111111100\n"
-".dw 0b00000000000000000011111111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b00000000000000000011111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b11110000000000001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000000011111111000000111100\n"
-".dw 0b11110000111100001111001111111100\n"
-".dw 0b00001111000011110011110000111100\n"
-".dw 0b11110000111100000000000011111111\n"
-".dw 0b11110000000011111111000000111100\n"
-".dw 0b11110000111100001111001111001111\n"
-".dw 0b00001111001111110011110011111111\n"
-".dw 0b11110000111111110000000000001111\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000111100001111\n"
-".dw 0b00111100001111001111000011110000\n"
-".dw 0b00111100001111000000111100001111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00111100001111000000111100001111\n"
-".dw 0b00111100001111001111000011110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b11110011110011110011111100111111\n"
-".dw 0b11110011110011111111110011111100\n"
-".dw 0b11110011110011110011111100111111\n"
-".dw 0b11110011110011111111110011111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111000000000000111100\n"
-".dw 0b11111111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111000000000000111100\n"
-".dw 0b11111111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111000000000000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111110000111100000000\n"
-".dw 0b00001111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111111111110000111100000000\n"
-".dw 0b00001111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111110000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111110000111100000000\n"
-".dw 0b00001111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111110000000000000000\n"
-".dw 0b11111111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111111111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111111111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111001111001111001111110000\n"
-".dw 0b11110000110000001111001111110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111111111000000\n"
-".dw 0b11110000111100001111111111000000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b11110000111100001111000000000000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000000000000000000000000000\n"
-".dw 0b00000000000000001111111111111100\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b11111111111100001111000011110000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00111100000000001111000011110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111001111001111000000\n"
-".dw 0b11110011110000001111001111000000\n"
-".dw 0b00111111000000000000000000000000\n"
-".dw 0b00000000000000000011110000111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b00000000000000000011111100111100\n"
-".dw 0b11110011111100000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11111111111100000000111100000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000001111111111110000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111111111111100\n"
-".dw 0b11110000001111000011110011110000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b11111100111111000000000000000000\n"
-".dw 0b00000011111100000000111100000000\n"
-".dw 0b00000011110000000011111111110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111001111001111001111\n"
-".dw 0b11110011110011110011111111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000001111000000000011110000\n"
-".dw 0b00111111111111001111001111001111\n"
-".dw 0b11110011110011110011111111111100\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b00001111110000000011110000000000\n"
-".dw 0b11110000000000001111111111000000\n"
-".dw 0b11110000000000000011110000000000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111111111100000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000111111000000001111001111\n"
-".dw 0b00000011110011110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000001111001111000000\n"
-".dw 0b11110011110000000011111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000011111100111100\n"
-".dw 0b11110011111100000000000000000000\n"
-".dw 0b00111111001111001111001111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000111111110000000011110000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b11111100111100000011110011110000\n"
-".dw 0b00001111111100000000001111110000\n"
-".dw 0b00111111110000000011110011110000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111000000000000001111000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111111100000000111111110000\n"
-".dw 0b00001111111100000000111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-);
-}

+ 0 - 65
BCC/userBDOS/DATA/COLOR.C

@@ -1,65 +0,0 @@
-/*
-* Contains default ASCII table with default palette table.
-* Assembly is used as workaround to store them.
-* Because of the default stack code at the start of each code,
-* an offset is required to access the data
-*/
-
-
-void DATA_PALETTE_COLOR(){
-asm(
-".dw 0b00000000000000001111111111111111 ; green, black,  white,  white\n"
-".dw 0b00000000001000000100000001100000\n"
-".dw 0b10000000101000001100000011100000\n"
-".dw 0b00000000000001000000100000001100\n"
-".dw 0b00010000000101000001100000011100\n"
-".dw 0b00000000000000010000001000000011\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-);
-}
-
-void DATA_PATTERN_COLOR(){
-asm(
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-);
-}

+ 0 - 1234
BCC/userBDOS/DATA/TESTIMGD.C

@@ -1,1234 +0,0 @@
-/*
-* Contains default ASCII table with default palette table.
-* Assembly is used as workaround to store them.
-* Because of the default stack code at the start of each code,
-* an offset is required to access the data
-*/
-
-// 32 lines max
-void DATA_PALETTE_COLOR(){
-asm(
-".dw 0b00000000000000000000000011111111 ; black, black,  black,  white\n"
-".dw 0b11111111111111000001111100011100 ; white, yellow, cyan, green\n"
-".dw 0b11100011111000000000001100000000 ; magenta, red, blue, black\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-);
-}
-
-// 1024 lines max
-void DATA_PATTERN_COLOR(){
-asm(
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-);
-}
-
-
-void tileColor0(){
-asm(
-".dw 0 0 0 0 0\n"
-);
-}
-
-void tileColor1(){
-asm(
-".dw 1 1 1 1 1\n"
-);
-}
-
-void tileColor2(){
-asm(
-".dw 2 2 2 2 2\n"
-);
-}
-
-void tileColor3(){
-asm(
-".dw 3 3 3 3 3\n"
-);
-}
-
-
-void TEST_COLOR_PALETTETABLE_1(){
-asm(
-".dw 0b00000000000000010000001000000011\n"
-".dw 0b00000100000001010000011000000111\n"
-".dw 0b00001000000010010000101000001011\n"
-".dw 0b00001100000011010000111000001111\n"
-".dw 0b00100000001000010010001000100011\n"
-".dw 0b00100100001001010010011000100111\n"
-".dw 0b00101000001010010010101000101011\n"
-".dw 0b00101100001011010010111000101111\n"
-".dw 0b01000000010000010100001001000011\n"
-".dw 0b01000100010001010100011001000111\n"
-".dw 0b01001000010010010100101001001011\n"
-".dw 0b01001100010011010100111001001111\n"
-".dw 0b01100000011000010110001001100011\n"
-".dw 0b01100100011001010110011001100111\n"
-".dw 0b01101000011010010110101001101011\n"
-".dw 0b01101100011011010110111001101111\n"
-".dw 0b10000000100000011000001010000011\n"
-".dw 0b10000100100001011000011010000111\n"
-".dw 0b10001000100010011000101010001011\n"
-".dw 0b10001100100011011000111010001111\n"
-".dw 0b10100000101000011010001010100011\n"
-".dw 0b10100100101001011010011010100111\n"
-".dw 0b10101000101010011010101010101011\n"
-".dw 0b10101100101011011010111010101111\n"
-".dw 0b11000000110000011100001011000011\n"
-".dw 0b11000100110001011100011011000111\n"
-".dw 0b11001000110010011100101011001011\n"
-".dw 0b11001100110011011100111011001111\n"
-".dw 0b11100000111000011110001011100011\n"
-".dw 0b11100100111001011110011011100111\n"
-".dw 0b11101000111010011110101011101011\n"
-".dw 0b11101100111011011110111011101111\n"
-);
-}
-
-void TEST_COLOR_PALETTETABLE_2(){
-asm(
-".dw 0b00000000000100010001001000010011\n"
-".dw 0b00010100000101010001011000010111\n"
-".dw 0b00011000000110010001101000011011\n"
-".dw 0b00011100000111010001111000011111\n"
-".dw 0b00110000001100010011001000110011\n"
-".dw 0b00110100001101010011011000110111\n"
-".dw 0b00111000001110010011101000111011\n"
-".dw 0b00111100001111010011111000111111\n"
-".dw 0b01010000010100010101001001010011\n"
-".dw 0b01010100010101010101011001010111\n"
-".dw 0b01011000010110010101101001011011\n"
-".dw 0b01011100010111010101111001011111\n"
-".dw 0b01110000011100010111001001110011\n"
-".dw 0b01110100011101010111011001110111\n"
-".dw 0b01111000011110010111101001111011\n"
-".dw 0b01111100011111010111111001111111\n"
-".dw 0b10010000100100011001001010010011\n"
-".dw 0b10010100100101011001011010010111\n"
-".dw 0b10011000100110011001101010011011\n"
-".dw 0b10011100100111011001111010011111\n"
-".dw 0b10110000101100011011001010110011\n"
-".dw 0b10110100101101011011011010110111\n"
-".dw 0b10111000101110011011101010111011\n"
-".dw 0b10111100101111011011111010111111\n"
-".dw 0b11010000110100011101001011010011\n"
-".dw 0b11010100110101011101011011010111\n"
-".dw 0b11011000110110011101101011011011\n"
-".dw 0b11011100110111011101111011011111\n"
-".dw 0b11110000111100011111001011110011\n"
-".dw 0b11110100111101011111011011110111\n"
-".dw 0b11111000111110011111101011111011\n"
-".dw 0b11111100111111011111111011111111\n"
-);
-}
-
-
-void DATA_PALETTE_DEFAULT(){
-asm(
-".dw 0b00000000000000001111111111111111 ; black, black,  white,  white\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-);
-}
-
-
-void DATA_ASCII_DEFAULT(){
-asm(
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111001100000000000011\n"
-".dw 0b11001100001100111100000000000011\n"
-".dw 0b11001111111100111100001111000011\n"
-".dw 0b11000000000000110011111111111100\n"
-".dw 0b00111111111111001111111111111111\n"
-".dw 0b11110011110011111111111111111111\n"
-".dw 0b11110000000011111111110000111111\n"
-".dw 0b11111111111111110011111111111100\n"
-".dw 0b00111100111100001111111111111100\n"
-".dw 0b11111111111111001111111111111100\n"
-".dw 0b00111111111100000000111111000000\n"
-".dw 0b00000011000000000000000000000000\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00111111111100001111111111111100\n"
-".dw 0b00111111111100000000111111000000\n"
-".dw 0b00000011000000000000000000000000\n"
-".dw 0b00001111110000000011111111110000\n"
-".dw 0b00001111110000001111111111111100\n"
-".dw 0b11111111111111001111001100111100\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00000011000000000000001100000000\n"
-".dw 0b00001111110000000011111111110000\n"
-".dw 0b11111111111111000011111111110000\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111100001111111111000000001111\n"
-".dw 0b11110000000011111111110000111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000111111110000\n"
-".dw 0b00111100001111000011000000001100\n"
-".dw 0b00110000000011000011110000111100\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11111111111111111111000000001111\n"
-".dw 0b11000011110000111100111111110011\n"
-".dw 0b11001111111100111100001111000011\n"
-".dw 0b11110000000011111111111111111111\n"
-".dw 0b00000000111111110000000000111111\n"
-".dw 0b00000000111111110011111111110011\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00001111111111110000111100001111\n"
-".dw 0b00001111111111110000111100000000\n"
-".dw 0b00001111000000000011111100000000\n"
-".dw 0b11111111000000001111110000000000\n"
-".dw 0b00111111111111110011110000001111\n"
-".dw 0b00111111111111110011110000001111\n"
-".dw 0b00111100000011110011110000111111\n"
-".dw 0b11111100001111001111000000000000\n"
-".dw 0b00000011110000001111001111001111\n"
-".dw 0b00001111111100001111110000111111\n"
-".dw 0b11111100001111110000111111110000\n"
-".dw 0b11110011110011110000001111000000\n"
-".dw 0b11000000000000001111110000000000\n"
-".dw 0b11111111110000001111111111111100\n"
-".dw 0b11111111110000001111110000000000\n"
-".dw 0b11000000000000000000000000000000\n"
-".dw 0b00000000000011000000000011111100\n"
-".dw 0b00001111111111001111111111111100\n"
-".dw 0b00001111111111000000000011111100\n"
-".dw 0b00000000000011000000000000000000\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00000011110000000011111111111100\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000000000000000000\n"
-".dw 0b00111100001111000000000000000000\n"
-".dw 0b00111111111111111111001111001111\n"
-".dw 0b11110011110011110011111111001111\n"
-".dw 0b00000011110011110000001111001111\n"
-".dw 0b00000011110011110000000000000000\n"
-".dw 0b00001111111111000011110000001111\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111000011111111111100\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00111111111111000000111111110000\n"
-".dw 0b00000011110000001111111111111111\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00111111111111000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00111111111111000000111111110000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00000000111100001111111111111100\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00111100000000001111111111111100\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000000000001111111111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000110000110000\n"
-".dw 0b00111100001111001111111111111111\n"
-".dw 0b00111100001111000000110000110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00001111111100000011111111111100\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111111111\n"
-".dw 0b11111111111111110011111111111100\n"
-".dw 0b00001111111100000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111000000000011111111000000\n"
-".dw 0b00111111110000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b11111111111111000011110011110000\n"
-".dw 0b11111111111111000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00001111000000000011111111110000\n"
-".dw 0b11110000000000000011111111000000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000001111000000111100\n"
-".dw 0b11110000111100000000001111000000\n"
-".dw 0b00001111000000000011110000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00001111110000000011111100111100\n"
-".dw 0b11110011111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b11110000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000000000000000\n"
-".dw 0b00000000000000000011110000111100\n"
-".dw 0b00001111111100001111111111111111\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000001111111111110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000001111000000000011110000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b11000000000000000000000000000000\n"
-".dw 0b00111111111100001111000000111100\n"
-".dw 0b11110000111111001111001111111100\n"
-".dw 0b11111111001111001111110000111100\n"
-".dw 0b00111111111100000000000000000000\n"
-".dw 0b00001111000000000011111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000111100000000111111000000\n"
-".dw 0b00111100000000001111000011110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000111100000000111111000000\n"
-".dw 0b00000000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011111100000000111111110000\n"
-".dw 0b00111100111100001111000011110000\n"
-".dw 0b11111111111111000000000011110000\n"
-".dw 0b00000011111111000000000000000000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b11111111110000000000000011110000\n"
-".dw 0b00000000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00001111110000000011110000000000\n"
-".dw 0b11110000000000001111111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111111111100001111000011110000\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00111111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000011110000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000111100000000001111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111111111100001111000000111100\n"
-".dw 0b11110011111111001111001111111100\n"
-".dw 0b11110011111111001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00001111000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11111111111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b11111111111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000000000000011110000111100\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11111111110000000011110011110000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000011110011110000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b11111111111111000011110000001100\n"
-".dw 0b00111100110000000011111111000000\n"
-".dw 0b00111100110000000011110000001100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b11111111111111000011110000001100\n"
-".dw 0b00111100110000000011111111000000\n"
-".dw 0b00111100110000000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000111111000011110000111100\n"
-".dw 0b00001111111111000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111111111110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111110000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011111111000000000011110000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111100001111000011110000111100\n"
-".dw 0b00111100111100000011111111000000\n"
-".dw 0b00111100111100000011110000111100\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b11111111000000000011110000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111100000011000011110000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b11110000001111001111110011111100\n"
-".dw 0b11111111111111001111111111111100\n"
-".dw 0b11110011001111001111000000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b11110000001111001111110000111100\n"
-".dw 0b11111111001111001111001111111100\n"
-".dw 0b11110000111111001111000000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b11110000001111000011110011110000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b11111111111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110011111100000011111111000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b11111111111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100111100000011110000111100\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111111111100001100111100110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b11110000001111001111001100111100\n"
-".dw 0b11111111111111001111110011111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111111111111001111000000111100\n"
-".dw 0b11000000111100000000001111000000\n"
-".dw 0b00001111000011000011110000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00111111110000000011110000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000000000000011110000000000\n"
-".dw 0b00001111000000000000001111000000\n"
-".dw 0b00000000111100000000000000111100\n"
-".dw 0b00000000000011000000000000000000\n"
-".dw 0b00111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011000000000000111111000000\n"
-".dw 0b00111100111100001111000000111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111111111\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b11111100000000000011110000000000\n"
-".dw 0b00111100000000000011111111110000\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b11110011111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000000000001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011111100000000000011110000\n"
-".dw 0b00000000111100000011111111110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100000000001111111100000000\n"
-".dw 0b00111100000000000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111001111001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b11111100000000000011110000000000\n"
-".dw 0b00111100111100000011111100111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000111100000000000000000000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b00000000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b11111100000000000011110000000000\n"
-".dw 0b00111100001111000011110011110000\n"
-".dw 0b00111111110000000011110011110000\n"
-".dw 0b11111100001111000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111111111111100\n"
-".dw 0b11111111111111001111001100111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110011111100000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100000000001111111100000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111001111001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100000000001111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110011111100000011111100111100\n"
-".dw 0b00111100001111000011110000000000\n"
-".dw 0b11111111000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111100001111000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b00000011000000000000111100000000\n"
-".dw 0b00111111111100000000111100000000\n"
-".dw 0b00001111000000000000111100110000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000001111001111001100111100\n"
-".dw 0b11111111111111001111111111111100\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000001111000011110011110000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111100001100001111000000\n"
-".dw 0b00001111000000000011110000110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000011111100000000111100000000\n"
-".dw 0b00001111000000001111110000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11111100000000000000111100000000\n"
-".dw 0b00001111000000000000001111110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111001111001111001111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000001100000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000000000001111000011110000\n"
-".dw 0b00111111110000000000001111000000\n"
-".dw 0b00000000111100000011111111000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111111111001111000000001111\n"
-".dw 0b00001111111100000000000000111100\n"
-".dw 0b00001111111111000011110000111100\n"
-".dw 0b00001111111111110000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111110000001111000000000000\n"
-".dw 0b11110000000000000011111111000000\n"
-".dw 0b00000000111100000000111111000000\n"
-".dw 0b00111111111111001111000000001111\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00111111111111000011110000000000\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11111111111100001111000000000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111111100001111000000111100\n"
-".dw 0b00001111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111111100000000000000000000\n"
-".dw 0b11111100000000000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b11110000001111000000111111000000\n"
-".dw 0b00111100111100001111000000111100\n"
-".dw 0b11111111111111001111000000111100\n"
-".dw 0b11110000001111000000000000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111111111110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b11111111111100000011110000000000\n"
-".dw 0b00111111110000000011110000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111110000000011110000\n"
-".dw 0b00111111111111111111000011110000\n"
-".dw 0b00111111111111110000000000000000\n"
-".dw 0b00001111111111000011110011110000\n"
-".dw 0b11110000111100001111111111111100\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111111000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000001111110000000000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000001111110000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100000011111111110000\n"
-".dw 0b00000000111100001111111111000000\n"
-".dw 0b11110000000011110000001111000000\n"
-".dw 0b00001111111100000011110000111100\n"
-".dw 0b00111100001111000000111111110000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00111111111111001111000000000000\n"
-".dw 0b11110000000000000011111111111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100001100001111111100000000\n"
-".dw 0b00111100000000001111110000111100\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000001111111111110000\n"
-".dw 0b00001111000000001111111111110000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111111110000001111000011110000\n"
-".dw 0b11110000111100001111111111001100\n"
-".dw 0b11110000001111001111000011111111\n"
-".dw 0b11110000001111001111000000111111\n"
-".dw 0b00000000111111000000001111001111\n"
-".dw 0b00000011110000000000111111110000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11110011110000000011111100000000\n"
-".dw 0b00000011111100000000000000000000\n"
-".dw 0b00111111110000000000000011110000\n"
-".dw 0b00111111111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b00111111000000000000111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000001111110000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000001111110000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111111111000000000000000000\n"
-".dw 0b00000000000000001111111111000000\n"
-".dw 0b00000000000000001111111111000000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b11110000111100001111110011110000\n"
-".dw 0b11111111111100001111001111110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00001111111100000011110011110000\n"
-".dw 0b00111100111100000000111111111100\n"
-".dw 0b00000000000000000011111111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b00000000000000000011111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00001111000000000011110000000000\n"
-".dw 0b11110000000000001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11110000000011111111000000111100\n"
-".dw 0b11110000111100001111001111111100\n"
-".dw 0b00001111000011110011110000111100\n"
-".dw 0b11110000111100000000000011111111\n"
-".dw 0b11110000000011111111000000111100\n"
-".dw 0b11110000111100001111001111001111\n"
-".dw 0b00001111001111110011110011111111\n"
-".dw 0b11110000111111110000000000001111\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000111100001111\n"
-".dw 0b00111100001111001111000011110000\n"
-".dw 0b00111100001111000000111100001111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000001111000011110000\n"
-".dw 0b00111100001111000000111100001111\n"
-".dw 0b00111100001111001111000011110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00001100000011001100000011000000\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b00110011001100111100110011001100\n"
-".dw 0b11110011110011110011111100111111\n"
-".dw 0b11110011110011111111110011111100\n"
-".dw 0b11110011110011110011111100111111\n"
-".dw 0b11110011110011111111110011111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111000000000000111100\n"
-".dw 0b11111111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111000000000000111100\n"
-".dw 0b11111111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111000000000000111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111111111000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111110000111100000000\n"
-".dw 0b00001111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111111111110000111100000000\n"
-".dw 0b00001111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111110000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111110000111100000000\n"
-".dw 0b00001111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111001111110000000000000000\n"
-".dw 0b11111111001111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000000000000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011111111110000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111111111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b11111111111111110000111100111100\n"
-".dw 0b00001111001111000000111100111100\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b11111111111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011111111110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b11111111000000001111111100000000\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b00000000111111110000000011111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111001111001111001111110000\n"
-".dw 0b11110000110000001111001111110000\n"
-".dw 0b00111111001111000000000000000000\n"
-".dw 0b00000000000000000011111111000000\n"
-".dw 0b11110000111100001111111111000000\n"
-".dw 0b11110000111100001111111111000000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b11110000111100001111000000000000\n"
-".dw 0b11110000000000001111000000000000\n"
-".dw 0b11110000000000000000000000000000\n"
-".dw 0b00000000000000001111111111111100\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b00111100111100000000000000000000\n"
-".dw 0b11111111111100001111000011110000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00111100000000001111000011110000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111001111001111000000\n"
-".dw 0b11110011110000001111001111000000\n"
-".dw 0b00111111000000000000000000000000\n"
-".dw 0b00000000000000000011110000111100\n"
-".dw 0b00111100001111000011110000111100\n"
-".dw 0b00111100001111000011111111110000\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b00000000000000000011111100111100\n"
-".dw 0b11110011111100000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11111111111100000000111100000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100000011111111000000\n"
-".dw 0b00001111000000001111111111110000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111111111111100\n"
-".dw 0b11110000001111000011110011110000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b11110000001111001111000000111100\n"
-".dw 0b00111100111100000011110011110000\n"
-".dw 0b11111100111111000000000000000000\n"
-".dw 0b00000011111100000000111100000000\n"
-".dw 0b00000011110000000011111111110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b00111111110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00111111111111001111001111001111\n"
-".dw 0b11110011110011110011111111111100\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000001111000000000011110000\n"
-".dw 0b00111111111111001111001111001111\n"
-".dw 0b11110011110011110011111111111100\n"
-".dw 0b00111100000000001111000000000000\n"
-".dw 0b00001111110000000011110000000000\n"
-".dw 0b11110000000000001111111111000000\n"
-".dw 0b11110000000000000011110000000000\n"
-".dw 0b00001111110000000000000000000000\n"
-".dw 0b00111111110000001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100001111000011110000\n"
-".dw 0b11110000111100000000000000000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b11111111111100000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000011110000000000111100000000\n"
-".dw 0b00111100000000000000111100000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b11111111111100000000000000000000\n"
-".dw 0b00000000111111000000001111001111\n"
-".dw 0b00000011110011110000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000000000001111000000\n"
-".dw 0b00000011110000001111001111000000\n"
-".dw 0b11110011110000000011111100000000\n"
-".dw 0b00001111000000000000111100000000\n"
-".dw 0b00000000000000001111111111110000\n"
-".dw 0b00000000000000000000111100000000\n"
-".dw 0b00001111000000000000000000000000\n"
-".dw 0b00000000000000000011111100111100\n"
-".dw 0b11110011111100000000000000000000\n"
-".dw 0b00111111001111001111001111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00001111110000000011110011110000\n"
-".dw 0b00111100111100000000111111000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000001111000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000011110000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000111111110000000011110000\n"
-".dw 0b00000000111100000000000011110000\n"
-".dw 0b11111100111100000011110011110000\n"
-".dw 0b00001111111100000000001111110000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b00000000000000000000000000000000\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b01010101010101010101010101010101\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b10101010101010101010101010101010\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-".dw 0b11111111111111111111111111111111\n"
-);
-}

+ 0 - 896
BCC/userBDOS/LIB/FS.C

@@ -1,896 +0,0 @@
-/*
-* Filesystem library
-* Handles all filesystem related work for userBDOS programs using CH376.
-* Uses only bottom USB port (SPI1 CH376), 
-*  allowing top USB top to be used for other USB devices (like HID).
-* Uses blocking delays for now.
-*/
-
-// uses stdlib.c
-
-#define FS_INTERRUPT_ADDR 0xC0272D
-
-//CH376 Codes
-#define FS_CMD_GET_IC_VER       0x01
-#define FS_CMD_SET_BAUDRATE     0x02
-#define FS_CMD_ENTER_SLEEP      0x03
-#define FS_CMD_SET_USB_SPEED    0x04
-#define FS_CMD_RESET_ALL      0x05
-#define FS_CMD_CHECK_EXIST      0x06
-#define FS_CMD_SET_SD0_INT      0x0b
-#define FS_CMD_SET_RETRY      0x0b
-#define FS_CMD_GET_FILE_SIZE    0x0c
-#define FS_CMD_SET_FILE_SIZE    0x0d
-#define FS_CMD_SET_USB_ADDRESS    0x13
-#define FS_CMD_SET_USB_MODE     0x15
-#define FS_MODE_HOST_0        0x05
-#define FS_MODE_HOST_1        0x07
-#define FS_MODE_HOST_2        0x06
-#define FS_CMD_GET_STATUS       0x22
-#define FS_CMD_RD_USB_DATA0     0x27
-#define FS_CMD_WR_USB_DATA      0x2c
-#define FS_CMD_WR_REQ_DATA      0x2d
-#define FS_CMD_WR_OFS_DATA      0x2e
-#define FS_CMD_SET_FILE_NAME    0x2f
-#define FS_CMD_DISK_CONNECT     0x30
-#define FS_CMD_DISK_MOUNT       0x31
-#define FS_CMD_FILE_OPEN      0x32
-#define FS_CMD_FILE_ENUM_GO     0x33
-#define FS_CMD_FILE_CREATE      0x34
-#define FS_CMD_FILE_ERASE       0x35
-#define FS_CMD_FILE_CLOSE       0x36
-#define FS_CMD_DIR_INFO_READ    0x37
-#define FS_CMD_DIR_INFO_SAVE    0x38
-#define FS_CMD_BYTE_LOCATE      0x39
-#define FS_CMD_BYTE_READ      0x3a
-#define FS_CMD_BYTE_RD_GO       0x3b
-#define FS_CMD_BYTE_WRITE       0x3c
-#define FS_CMD_BYTE_WR_GO       0x3d
-#define FS_CMD_DISK_CAPACITY    0x3e
-#define FS_CMD_DISK_QUERY       0x3f
-#define FS_CMD_DIR_CREATE       0x40
-#define FS_CMD_SET_ADDRESS      0x45
-#define FS_CMD_GET_DESCR      0x46
-#define FS_CMD_SET_CONFIG       0x49
-#define FS_CMD_AUTO_CONFIG      0x4D
-#define FS_CMD_ISSUE_TKN_X      0x4E
-
-#define FS_ANSW_RET_SUCCESS     0x51
-#define FS_ANSW_USB_INT_SUCCESS   0x14
-#define FS_ANSW_USB_INT_CONNECT   0x15
-#define FS_ANSW_USB_INT_DISCONNECT  0x16
-#define FS_ANSW_USB_INT_USB_READY   0x18
-#define FS_ANSW_USB_INT_DISK_READ   0x1d
-#define FS_ANSW_USB_INT_DISK_WRITE  0x1e
-#define FS_ANSW_RET_ABORT       0x5F
-#define FS_ANSW_USB_INT_DISK_ERR  0x1f
-#define FS_ANSW_USB_INT_BUF_OVER  0x17
-#define FS_ANSW_ERR_OPEN_DIR    0x41
-#define FS_ANSW_ERR_MISS_FILE     0x42
-#define FS_ANSW_ERR_FOUND_NAME    0x43
-#define FS_ANSW_ERR_DISK_DISCON   0x82
-#define FS_ANSW_ERR_LARGE_SECTOR  0x84
-#define FS_ANSW_ERR_TYPE_ERROR    0x92
-#define FS_ANSW_ERR_BPB_ERROR     0xa1
-#define FS_ANSW_ERR_DISK_FULL     0xb1
-#define FS_ANSW_ERR_FDT_OVER    0xb2
-#define FS_ANSW_ERR_FILE_CLOSE    0xb4
-#define FS_ERR_LONGFILENAME     0x01
-#define FS_ATTR_READ_ONLY       0x01
-#define FS_ATTR_HIDDEN        0x02
-#define FS_ATTR_SYSTEM        0x04
-#define FS_ATTR_VOLUME_ID       0x08
-#define FS_ATTR_DIRECTORY       0x10 
-#define FS_ATTR_ARCHIVE       0x20
-
-// Sets SPI1_CS low
-void FS_spiBeginTransfer()
-{
-  asm(
-    "; backup regs\n"
-    "push r1\n"
-    "push r2\n"
-
-    "load32 0xC0272C r2      ; r2 = 0xC0272C\n"
-
-    "load 0 r1              ; r1 = 0 (enable)\n"
-    "write 0 r2 r1            ; write to SPI1_CS\n"
-
-    "; restore regs\n"
-    "pop r2\n"
-    "pop r1\n"
-    );
-}
-
-// Sets SPI1_CS high
-void FS_spiEndTransfer()
-{
-  asm(
-    "; backup regs\n"
-    "push r1\n"
-    "push r2\n"
-
-    "load32 0xC0272C r2      ; r2 = 0xC0272C\n"
-
-    "load 1 r1              ; r1 = 1 (disable)\n"
-    "write 0 r2 r1            ; write to SPI1_CS\n"
-
-    "; restore regs\n"
-    "pop r2\n"
-    "pop r1\n"
-    );
-}
-
-// write dataByte and return read value
-// write 0x00 for a read
-// Writes byte over SPI1 to CH376
-word FS_spiTransfer(word dataByte)
-{
-  word retval = 0;
-  asm(
-    "load32 0xC0272B r2       ; r2 = 0xC0272B\n"
-    "write 0 r2 r4            ; write r4 over SPI1\n"
-    "read 0 r2 r2             ; read return value\n"
-    "write -4 r14 r2          ; write to stack to return\n"
-    );
-
-  return retval;
-}
-
-
-
-
-// Get status after waiting for an interrupt
-word FS_WaitGetStatus()
-{
-  word intValue = 1;
-  while(intValue)
-  {
-    word *i = (word *) FS_INTERRUPT_ADDR;
-    intValue = *i;
-  }
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_GET_STATUS);
-  FS_spiEndTransfer(); 
-  //delay(1);
-
-  FS_spiBeginTransfer();
-  word retval = FS_spiTransfer(0x00);
-  FS_spiEndTransfer(); 
-
-  return retval;
-}
-
-
-// Get status without using interrupts
-word FS_noWaitGetStatus()
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_GET_STATUS);
-  word retval = FS_spiTransfer(0x00);
-  FS_spiEndTransfer(); 
-
-  return retval;
-}
-
-
-// Function to send a string (without terminating 0)
-void FS_sendString(char* str)
-{
-  char chr = *str;      // first character of str
-
-  while (chr != 0)      // continue until null value
-  {
-    FS_spiTransfer(chr);
-    str++;          // go to next character address
-    chr = *str;       // get character from address
-  }
-}
-
-
-// Function to send data d of size s
-void FS_sendData(char* d, word s)
-{
-  char chr = *d;      // first byte of data
-
-  word i;
-  for(i = 0; (unsigned int) i < (unsigned int)s; i++)  // write s bytes
-  {
-    FS_spiTransfer(chr);
-    d++;          // go to next data address
-    chr = *d;       // get data from address
-  }
-}
-
-
-// Returns IC version of CH376 chip
-// Good test to know if the communication with chip works
-word FS_getICver()
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_GET_IC_VER);
-  delay(1);
-
-  word icVer = FS_spiTransfer(0x00);
-  FS_spiEndTransfer();
-
-  return icVer;
-}
-
-// Sets USB mode to mode, returns status code
-// Which should be FS_ANSW_RET_SUCCESS when successful
-word FS_setUSBmode(word mode)
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_SET_USB_MODE);
-  FS_spiEndTransfer();
-  delay(1);
-
-  FS_spiBeginTransfer();
-  FS_spiTransfer(mode);
-  FS_spiEndTransfer();
-  delay(1);
-
-  FS_spiBeginTransfer();
-  word status = FS_spiTransfer(0x00);
-  FS_spiEndTransfer();
-  delay(1);
-
-  return status;
-}
-
-
-// resets and intitializes CH376
-// returns FS_ANSW_RET_SUCCESS on success
-word FS_init()
-{
-  FS_spiEndTransfer(); // start with cs high
-  delay(10);
-
-  // Reset
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_RESET_ALL);
-  FS_spiEndTransfer();
-  delay(100); // wait after reset
-
-  // USB mode 0
-  return FS_setUSBmode(FS_MODE_HOST_0);
-}
-
-
-// waits for drive connection,
-// sets usb host mode
-// waits for drive to be ready
-// mounts drive
-// also initializes current path to /
-// returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_connectDrive() 
-{
-  // Wait forever until an USB device is connected
-  while(FS_WaitGetStatus() != FS_ANSW_USB_INT_CONNECT);
-
-  // USB mode 1
-  word retval = FS_setUSBmode(FS_MODE_HOST_1);
-  // Return on error
-  if (retval != FS_ANSW_RET_SUCCESS)
-    return retval;
-
-  // USB mode 2
-  retval = FS_setUSBmode(FS_MODE_HOST_2);
-  // Return on error
-  if (retval != FS_ANSW_RET_SUCCESS)
-    return retval;
-
-  // Need to check again for device connection after changing USB mode
-  while(FS_WaitGetStatus() != FS_ANSW_USB_INT_CONNECT);
-
-  // Connect to drive
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_DISK_CONNECT);
-  FS_spiEndTransfer();
-
-  retval = FS_WaitGetStatus();
-  // Return on error
-  if (retval != FS_ANSW_USB_INT_SUCCESS)
-    return retval;
-
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_DISK_MOUNT);
-  FS_spiEndTransfer();
-
-  return FS_WaitGetStatus();
-}
-
-
-// Returns file size of currently opened file (32 bits)
-word FS_getFileSize()
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_GET_FILE_SIZE);
-  FS_spiTransfer(0x68);
-  word retval = FS_spiTransfer(0);
-  retval = retval + (FS_spiTransfer(0) << 8);
-  retval = retval + (FS_spiTransfer(0) << 16);
-  retval = retval + (FS_spiTransfer(0) << 24);
-  FS_spiEndTransfer();
-
-  return retval;
-}
-
-
-// Sets cursor to position s
-// Returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_setCursor(word s) 
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_BYTE_LOCATE);
-  FS_spiTransfer(s);
-  FS_spiTransfer((unsigned) s >> 8);
-  FS_spiTransfer((unsigned) s >> 16);
-  FS_spiTransfer((unsigned) s >> 24);
-  FS_spiEndTransfer();
-
-  return FS_WaitGetStatus();
-}
-
-
-// Reads s bytes into buf
-// If bytesToWord is true, four bytes will be stored in one address/word
-// Can read 65536 bytes per call
-// Returns FS_ANSW_USB_INT_SUCCESS on success
-// TODO: this surely can be optimized for speed in some way!
-word FS_readFile(char* buf, word s, word bytesToWord) 
-{
-  if (s == 0)
-    return FS_ANSW_USB_INT_SUCCESS;
-
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_BYTE_READ);
-  FS_spiTransfer(s);
-  FS_spiTransfer((unsigned) s >> 8);
-  FS_spiEndTransfer();
-
-  word retval = FS_WaitGetStatus();
-  // Return on error or EOF
-  if (retval == FS_ANSW_USB_INT_SUCCESS) // eof
-    return 0;
-  if (retval != FS_ANSW_USB_INT_DISK_READ)
-    return retval;
-
-
-  word bytesRead = 0; 
-  word wordsRead = 0;
-  word doneReading = 0;
-
-  // clear first address
-  buf[wordsRead] = 0;
-
-  // used for shifting bytes to word
-  word currentByteShift = 24;
-
-  while (doneReading == 0)
-  {
-    // Read set of bytes (max 255)
-    FS_spiBeginTransfer();
-    FS_spiTransfer(FS_CMD_RD_USB_DATA0);
-    word readLen = FS_spiTransfer(0x00);
-
-    word readByte;
-
-    word i;
-    for (i = 0; i < readLen; i++) 
-    {
-      readByte = FS_spiTransfer(0x00);
-
-      // Read 4 bytes into one word, from left to right
-      if (bytesToWord)
-      {
-        readByte = readByte << currentByteShift;
-        buf[wordsRead] = buf[wordsRead] + readByte;
-
-
-        if (currentByteShift == 0)
-        {
-          currentByteShift = 24;
-          wordsRead++;
-          buf[wordsRead] = 0;
-        }
-        else
-        {
-          currentByteShift -= 8;
-        }
-
-      }
-      else
-      {
-        buf[bytesRead] = (char)readByte;
-        bytesRead = bytesRead + 1;
-      }
-    }
-    FS_spiEndTransfer();
-
-    // requesting another set of data
-    FS_spiBeginTransfer();
-    FS_spiTransfer(FS_CMD_BYTE_RD_GO);
-    FS_spiEndTransfer();
-
-    retval = FS_WaitGetStatus();
-    if (retval == FS_ANSW_USB_INT_SUCCESS)
-      doneReading = 1;
-    else if (retval == FS_ANSW_USB_INT_DISK_READ)
-    {
-      // read another block
-    }
-    else
-    {
-      uprintln("E: Error while reading data");
-      return retval;
-    }
-  }
-
-  return retval;
-}
-
-
-// Writes data d of size s
-// Can only write 65536 bytes at a time
-// returns FS_ANSW_USB_INT_SUCCESS on success
-// TODO: optimize for speed
-word FS_writeFile(char* d, word s) 
-{
-  if (s == 0)
-    return FS_ANSW_USB_INT_SUCCESS;
-
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_BYTE_WRITE);
-  FS_spiTransfer(s);
-  FS_spiTransfer((unsigned) s >> 8);
-  FS_spiEndTransfer();
-
-  word retval = FS_WaitGetStatus();
-  // Return on error
-  if (retval != FS_ANSW_USB_INT_DISK_WRITE)
-    return retval;
-
-
-  word bytesWritten = 0;
-  word doneWriting = 0;
-
-  while (doneWriting == 0)
-  {
-    // Write set of bytes (max 255)
-    FS_spiBeginTransfer();
-    FS_spiTransfer(FS_CMD_WR_REQ_DATA);
-    word wrLen = FS_spiTransfer(0x00);
-
-    FS_sendData(d + bytesWritten, wrLen);
-    bytesWritten = bytesWritten + wrLen;
-    FS_spiEndTransfer();
-
-    // update file size
-    FS_spiBeginTransfer();
-    FS_spiTransfer(FS_CMD_BYTE_WR_GO);
-    FS_spiEndTransfer();
-
-
-    retval = FS_WaitGetStatus();
-    if (retval == FS_ANSW_USB_INT_SUCCESS)
-      doneWriting = 1;
-    else if (retval == FS_ANSW_USB_INT_DISK_WRITE)
-    {
-      // write another block
-    }
-    else
-    {
-      uprintln("E: Error while writing data");
-      return retval;
-    }
-
-  }
-  
-  return retval;
-}
-
-
-// returns status of opening a file/directory
-// Usually the successful status codes are:
-//  FS_ANSW_USB_INT_SUCCESS || FS_ANSW_ERR_OPEN_DIR || FS_ANSW_USB_INT_DISK_READ
-word FS_open() 
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_FILE_OPEN);
-  FS_spiEndTransfer();
-
-  return FS_WaitGetStatus();
-}
-
-
-// returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_delete() 
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_FILE_ERASE);
-  FS_spiEndTransfer();
-
-  return FS_WaitGetStatus();
-}
-
-
-// returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_close() 
-{  
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_FILE_CLOSE);
-  FS_spiTransfer(0x01); //0x01 if update filesize, else 0x00
-  FS_spiEndTransfer();
-
-  return FS_WaitGetStatus();
-}
-
-
-// returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_createDir() 
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_DIR_CREATE);
-  FS_spiEndTransfer();
-
-  return FS_WaitGetStatus();
-}
-
-
-// Creates file (recreates if exists)
-// New files are 1 byte long
-// Have not found a way to set it to 0 bytes, 
-// since FS_CMD_SET_FILE_SIZE does not work
-// Automatically closes file
-// returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_createFile() 
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_FILE_CREATE);
-  FS_spiEndTransfer();
-
-  word retval = FS_WaitGetStatus();
-  // Return on error
-  if (retval != FS_ANSW_USB_INT_SUCCESS)
-    return retval;
-
-  // open and close file
-  FS_open();
-  FS_close();
-
-  return FS_ANSW_USB_INT_SUCCESS;
-}
-
-
-// Sends single path f
-// No processing of f is done, it is directly sent
-// This means no error checking on file length!
-void FS_sendSinglePath(char* f) 
-{
-
-  // send buf
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_SET_FILE_NAME);
-  FS_sendString(f);    // send file name
-  FS_spiTransfer(0);     // close with null
-  FS_spiEndTransfer();
-}
-
-
-// Sends path f
-// Can be relative or absolute file or directory
-// REQUIRES CAPITAL LETTERS and must conform the 8.3 filename standard
-// Function can handle folders with forward slashes
-// returns FS_ANSW_USB_INT_SUCCESS on success
-word FS_sendFullPath(char* f) 
-{
-  // path to uppercase and replace backslash by slash
-  word i = 0;
-  while (f[i] != 0)
-  {
-    f[i] = toUpper(f[i]);
-    if (f[i] == '\\')
-      f[i] = '/';
-    i++;
-  }
-
-  word removedSlash = 0; // to restore removed slash
-  // remove (single) trailing slash if exists
-  // we reuse i here since it points to the end of the path
-  if (i > 1) // ignore the root path
-  {
-    if (f[i-1] == '/')
-    {
-      f[i-1] = 0;
-      removedSlash = 1;
-    }
-  }
-
-  // if first char is a /, then we go back to root
-  if (f[0] == '/')
-  {
-    FS_sendSinglePath("/");
-    FS_open();
-  }
-
-  i = 0;
-  char buf[16]; // buffer for single folder/file name
-  word bufi = 0;
-
-  while (f[i] != 0)
-  {
-    // handle all directories
-    if (f[i] == 47) // forward slash
-    {
-      // return error on opening folders containing a single or double dot
-      if ((bufi == 1 && buf[0] == '.') || (bufi == 2 && buf[0] == '.' && buf[1] == '.'))
-        return FS_ANSW_ERR_OPEN_DIR;
-
-      // add null to end of buf
-      buf[bufi] = 0;
-      // send buf
-      FS_spiBeginTransfer();
-      FS_spiTransfer(FS_CMD_SET_FILE_NAME);
-      FS_sendString(buf);    // send folder name
-      FS_spiTransfer(0);     // close with null
-      FS_spiEndTransfer();
-      // reset bufi
-      bufi = 0;
-      // open folder
-      word retval = FS_open();
-      // Return on if failure / folder not found
-      if (retval != FS_ANSW_USB_INT_SUCCESS && retval != FS_ANSW_ERR_OPEN_DIR)
-        return retval;
-    }
-    else
-    {
-      buf[bufi] = f[i];
-      bufi++;
-      if (bufi > 13)
-        return FS_ERR_LONGFILENAME; // exit if folder/file name is too long
-    }
-    i++;
-  }
-  if (removedSlash) // restore removed slash if there
-  {
-    f[i] = '/';
-    f[i+1] = 0;
-  }
-
-  // handle filename itself (if any)
-  // add null to end of buf
-  buf[bufi] = 0;
-  if (bufi == 0)
-    return FS_ANSW_USB_INT_SUCCESS; // exit if there is no filename after the folder
-
-  // return error on opening folders containing a single or double dot
-  if ((bufi == 1 && buf[0] == '.') || (bufi == 2 && buf[0] == '.' && buf[1] == '.'))
-    return FS_ANSW_ERR_OPEN_DIR;
-
-  // send buf (last part of string)
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_SET_FILE_NAME);
-  FS_sendString(buf);    // send file name
-  FS_spiTransfer(0);     // close with null
-  FS_spiEndTransfer();
-
-  return FS_ANSW_USB_INT_SUCCESS;
-}
-
-
-// Parses and prints a string (useful for name and extension) after removing trailing spaces
-// Len should be <= 8 chars
-// Does not add a new line at the end.
-// Returns length of written string
-word FS_parseFATstring(char* fatBuffer, word len, char* b, word* bufLen)
-{
-  //uprintlnDec(bufLen);
-  //uprintlnDec(*bufLen);
-  if (len > 8)
-  {
-    uprintln("FATstring: Len argument > 8");
-    return 0;
-  }
-
-  word retval = 0;
-
-  // buffer of parsed string
-  char nameBuf[9];
-  nameBuf[len] = 0;
-
-  // loop backwards until a non-space character is found
-  // then, write string to nameBuf from there, keeping spaces in filename if any
-  word foundChar = 0;
-  word i;
-  for (i = 0; i < len; i++)
-  {
-    if (!foundChar)
-    {
-      if (fatBuffer[len-1-i] == ' ')
-        nameBuf[len-1-i] = 0; // set null until a non-space char is found
-      else
-      {
-        foundChar = 1;
-        retval = len-i;
-        nameBuf[len-1-i] = fatBuffer[len-1-i]; // write the non-space char
-      }
-    }
-    else
-      nameBuf[len-1-i] = fatBuffer[len-1-i]; // copy char
-  }
-
-  // write to buffer
-  i = 0;
-  while (nameBuf[i] != 0)
-  {
-    b[*bufLen] = nameBuf[i];
-    (*bufLen)++;
-    i++;
-  }
-  
-  return retval;
-}
-
-
-// Parses and writes name.extension and filesize on one line
-void FS_parseFATdata(word datalen, char* fatBuffer, char* b, word* bufLen)
-{
-  if (datalen != 32)
-  {
-    uprintln("Unexpected FAT table length");
-    return;
-  }
-
-  /* // Ignore lines with '.' and ".." as filename
-  // ignore '.'
-  if (memcmp(fatBuffer, ".      ", 11))
-    return;
-
-  // ignore ".."
-  if (memcmp(fatBuffer, "..     ", 11))
-    return;
-  */
-
-  // parse filename
-  word printLen = FS_parseFATstring(fatBuffer, 8, b, bufLen);
-
-  // add '.' and parse extension
-  if (fatBuffer[8] != ' ' || fatBuffer[9] != ' ' || fatBuffer[10] != ' ')
-  {
-    b[*bufLen] = '.';
-    (*bufLen)++;
-    printLen += FS_parseFATstring(fatBuffer+8, 3, b, bufLen) + 1;
-  }
-  
-  // append with spaces until 16th char
-  while (printLen < 16)
-  {
-    b[*bufLen] = ' ';
-    (*bufLen)++;
-    printLen++;
-  }
-
-  // filesize
-  word fileSize = 0;
-  fileSize += fatBuffer[28];
-  fileSize += (fatBuffer[29] << 8);
-  fileSize += (fatBuffer[30] << 16);
-  fileSize += (fatBuffer[31] << 24);
-
-  // filesize to integer string
-  char buffer[10];
-  itoa(fileSize, buffer);
-
-  // write to buffer
-  word i = 0;
-  while (buffer[i] != 0)
-  {
-    b[*bufLen] = buffer[i];
-    (*bufLen)++;
-    i++;
-  }
-  b[*bufLen] = '\n';
-  (*bufLen)++;
-
-  //uprintlnDec(*bufLen);
-}
-
-
-// Reads FAT data for single entry
-// FAT data is parsed by FS_parseFatData()
-void FS_readFATdata(char* b, word* bufLen)
-{
-  FS_spiBeginTransfer();
-  FS_spiTransfer(FS_CMD_RD_USB_DATA0);
-  word datalen = FS_spiTransfer(0x0);
-  char fatbuf[32];
-  word i;
-  for (i = 0; i < datalen; i++)
-  {
-    fatbuf[i] = FS_spiTransfer(0x00);
-  }
-  FS_parseFATdata(datalen, fatbuf, b, bufLen);
-  FS_spiEndTransfer();
-}
-
-// Lists directory of full path f
-// f needs to start with / and not end with /
-// Returns FS_ANSW_USB_INT_SUCCESS if successful
-// Writes parsed result to address b
-// Result is terminated with a \0
-word FS_listDir(char* f, char* b)
-{
-  word bufLen = 0;
-
-  word retval = FS_sendFullPath(f);
-  // Return on failure
-  if (retval != FS_ANSW_USB_INT_SUCCESS)
-    return retval;
-
-  retval = FS_open();
-  // Return on failure
-  if (retval != FS_ANSW_USB_INT_SUCCESS && retval != FS_ANSW_ERR_OPEN_DIR)
-    return retval;
-
-  FS_sendSinglePath("*");
-
-  retval = FS_open();
-  // Return on failure
-  if (retval != FS_ANSW_USB_INT_DISK_READ)
-    return retval;
-
-  // Init length of output buffer
-  bufLen = 0;
-
-  while (retval == FS_ANSW_USB_INT_DISK_READ)
-  {
-    FS_readFATdata(b, &bufLen);
-    FS_spiBeginTransfer();
-    FS_spiTransfer(FS_CMD_FILE_ENUM_GO);
-    FS_spiEndTransfer();
-    retval = FS_WaitGetStatus();
-  }
-
-  // Terminate buffer
-  b[bufLen] = 0;
-  bufLen++;
-
-  return FS_ANSW_USB_INT_SUCCESS;
-}
-
-
-// Returns FS_ANSW_USB_INT_SUCCESS on successful change of dir
-// Will return error FS_ANSW_ERR_FILE_CLOSE if dir is a file
-word FS_changeDir(char* f)
-{
-  // Special case for root, since FS_open() returns as if it opened a file
-  if (f[0] == '/' && f[1] == 0)
-  {
-    FS_sendSinglePath("/");
-    FS_open();
-    return FS_ANSW_USB_INT_SUCCESS;
-  }
-
-  word retval = FS_sendFullPath(f);
-  // Return on failure
-  if (retval != FS_ANSW_USB_INT_SUCCESS)
-    return retval;
-
-  retval = FS_open();
-  
-  // Return sucess on open dir
-  if (retval == FS_ANSW_ERR_OPEN_DIR)
-    return FS_ANSW_USB_INT_SUCCESS;
-
-  // Close and return on opening file
-  if (retval == FS_ANSW_USB_INT_SUCCESS)
-  {
-    FS_close();
-    return FS_ANSW_ERR_FILE_CLOSE;
-  }
-  else // otherwise return error code
-    return retval;
-
-}

+ 0 - 208
BCC/userBDOS/LIB/SYS.C

@@ -1,208 +0,0 @@
-/*
-Contains System Call functions
-*/
-
-#define SYSCALL_RETVAL_ADDR 0x200000
-
-// Interrupt IDs for interrupt handler
-#define INTID_TIMER1  0x1
-#define INTID_TIMER2  0x2
-#define INTID_UART0   0x3
-#define INTID_GPU     0x4
-#define INTID_TIMER3  0x5
-#define INTID_PS2     0x6
-#define INTID_UART1   0x7
-#define INTID_UART2   0x8
-
-
-// executes system call to BDOS
-// ID is written to the same location as the output of the system call
-//  at address SYSCALL_RETVAL_ADDR
-// This address is also returned
-word* syscall(word ID)
-{
-  word* p = (word*) SYSCALL_RETVAL_ADDR;
-  *p = ID;
-
-  asm("push r1\n"
-    "push r2\n"
-    "push r3\n"
-    "push r4\n"
-    "push r5\n"
-    "push r6\n"
-    "push r7\n"
-    "push r8\n"
-    "push r9\n"
-    "push r10\n"
-    "push r11\n"
-    "push r12\n"
-    "push r13\n"
-    "push r14\n"
-    "push r15\n"
-    "savpc r1\n"
-    "push r1\n"
-    "jump 4\n"
-    "pop r15\n"
-    "pop r14\n"
-    "pop r13\n"
-    "pop r12\n"
-    "pop r11\n"
-    "pop r10\n"
-    "pop r9\n"
-    "pop r8\n"
-    "pop r7\n"
-    "pop r6\n"
-    "pop r5\n"
-    "pop r4\n"
-    "pop r3\n"
-    "pop r2\n"
-    "pop r1\n");
-
-  return p;
-}
-
-// quit the user program and return to BDOS in a somewhat controlled way
-void exit()
-{
-  asm("ccache\n");
-  asm("jump Return_BDOS\n");
-}
-
-word HID_FifoAvailable()
-{
-  char* p = syscall(1);
-  return p[0];
-}
-
-
-word HID_FifoRead()
-{
-  char* p = syscall(2);
-  return p[0];
-}
-
-
-void BDOS_PrintcConsole(char c)
-{
-  char* p = (char*) SYSCALL_RETVAL_ADDR;
-  p[1] = c;
-  syscall(3);
-}
-
-// Prints string on BDOS console untill terminator
-// Does not add newline at end
-void BDOS_PrintConsole(char* str)
-{
-  char chr = *str;      // first character of str
-
-  while (chr != 0)      // continue until null value
-  {
-    BDOS_PrintcConsole(chr);
-    str++;          // go to next character address
-    chr = *str;       // get character from address
-  }
-}
-
-void BDOS_PrintlnConsole(char* str)
-{
-  BDOS_PrintConsole(str);
-  BDOS_PrintcConsole('\n');
-}
-
-void BDOS_PrintDecConsole(word i)
-{
-  char buffer[12];
-
-  if (i < 0)
-  {
-    buffer[0] = '-';
-    itoa(MATH_abs(i), &buffer[1]);
-  }
-  else
-  {
-    itoa(i, buffer);
-  }
-  BDOS_PrintConsole(buffer);
-}
-
-void BDOS_PrintlnDecConsole(word i)
-{
-  BDOS_PrintDecConsole(i);
-  BDOS_PrintcConsole('\n');
-}
-
-void BDOS_PrintHexConsole(word i)
-{
-  char buffer[11];
-  itoah(i, buffer);
-  BDOS_PrintConsole(buffer);
-}
-
-
-// Returns command line args
-char* BDOS_GetArgs()
-{
-  char* p = syscall(4);
-  return (char*) p[0];
-}
-
-
-// Writes command line argument n into buf
-// Arg 0 is the command itself
-void BDOS_GetArgN(word n, char* buf)
-{
-  char* args = BDOS_GetArgs();
-
-  word i = 0;
-  word bufi = 0;
-  word currentArg = 0;
-  char prevChar = 0;
-  buf[0] = 0;
-  while (args[i] != 0)
-  {
-    // new argument
-    if (args[i] == ' ' && prevChar != ' ')
-    {
-      currentArg++;
-    }
-
-    if (args[i] != ' ')
-    {
-      if (currentArg == n)
-      {
-        buf[bufi] = args[i];
-        bufi++;
-      }
-    }
-
-    prevChar = args[i];
-    i++;
-  }
-
-  buf[bufi] = 0; // terminate
-}
-
-
-// Returns BDOS current path
-char* BDOS_GetPath()
-{
-  word* p = syscall(5);
-  return (char*) p[0];
-}
-
-// Returns 1 if key is being held on USB keyboard
-word BDOS_USBkeyHeld(word c)
-{
-  word* p = syscall(6);
-  word* usbKeyBuffer = (char*) p[0];
-  
-  word i;
-  for (i = 0; i < 8; i++)
-  {
-    if (usbKeyBuffer[i] == c)
-    {
-      return 1;
-    }
-  }
-  return 0;
-}

+ 0 - 122
BCC/userBDOS/PXTEST.C

@@ -1,122 +0,0 @@
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-
-#define SCREEN_WIDTH 320
-#define SCREEN_HEIGHT 240
-#define FB_ADDR 0xD00000
-
-// Framebuffer. fb[Y][X] (bottom right is [239][319])
-char (*fb)[SCREEN_WIDTH] = (char (*)[SCREEN_WIDTH]) FB_ADDR;
-
-int main() 
-{
-
-  word pxcount = 0;
-  word x, y;
-  
-
-
-  while (1)
-  {
-    if (HID_FifoAvailable())
-    {
-      word c = HID_FifoRead();
-
-      if (c == 'a')
-      {
-        for (x = 0; x < SCREEN_WIDTH; x++)
-        {
-          for (y = 0; y < SCREEN_HEIGHT; y++)
-          {
-            fb[y][x] = 0;
-          }
-        }
-      }
-
-      if (c == 'b')
-      {
-        for (x = 0; x < SCREEN_WIDTH; x++)
-        {
-          for (y = 0; y < SCREEN_HEIGHT; y++)
-          {
-            fb[y][x] = x;
-          }
-        }
-      }
-
-      if (c == 'c')
-      {
-        for (x = 0; x < SCREEN_WIDTH; x++)
-        {
-          for (y = 0; y < SCREEN_HEIGHT; y++)
-          {
-            fb[y][x] = y;
-          }
-        }
-      }
-
-      if (c == 'd')
-      {
-        pxcount = 0;
-        for (x = 0; x < SCREEN_WIDTH; x++)
-        {
-          for (y = 0; y < SCREEN_HEIGHT; y++)
-          {
-            fb[y][x] = pxcount;
-            pxcount++;
-          }
-        }
-      }
-
-      if (c == 27) // escape
-      {
-        for (x = 0; x < SCREEN_WIDTH; x++)
-        {
-          for (y = 0; y < SCREEN_HEIGHT; y++)
-          {
-            fb[y][x] = 0;
-          }
-        }
-        return 'q';
-      }
-    }
-  }
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
-  }
-}

+ 0 - 266
BCC/userBDOS/SPIFLASH.C

@@ -1,266 +0,0 @@
-/*
-Test program for SPI flash memory
-*/
-
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-
-// Sets SPI0_CS low
-void SpiBeginTransfer()
-{
-  asm(
-      "; Backup regs\n"
-      "push r1\n"
-      "push r2\n"
-
-      "load32 0xC02729 r2                 ; r2 = 0xC02729\n"
-
-      "load 0 r1                          ; r1 = 0 (enable)\n"
-      "write 0 r2 r1                      ; write to SPI0_CS\n"
-
-      "; Restore regs\n"
-      "pop r2\n"
-      "pop r1\n"
-      );
-}
-
-// Sets SPI0_CS high
-void SpiEndTransfer()
-{
-  asm(
-      "; Backup regs\n"
-      "push r1\n"
-      "push r2\n"
-
-      "load32 0xC02729 r2                 ; r2 = 0xC02729\n"
-
-      "load 1 r1                          ; r1 = 1 (disable)\n"
-      "write 0 r2 r1                      ; write to SPI0_CS\n"
-
-      "; Restore regs\n"
-      "pop r2\n"
-      "pop r1\n"
-      );
-}
-
-// Write dataByte and return read value
-// Write 0x00 for a read
-// Writes byte over SPI0
-word SpiTransfer(word dataByte)
-{
-  word retval = 0;
-  asm(
-      "load32 0xC02728 r2                 ; r2 = 0xC02728\n"
-      "write 0 r2 r4                      ; write r4 over SPI0\n"
-      "read 0 r2 r2                       ; read return value\n"
-      "write -4 r14 r2                    ; write to stack to return\n"
-      );
-
-  return retval;
-}
-
-// Inits SPI by enabling SPI0 and resetting the chip
-void initSPI()
-{
-    // Already set CS high before enabling SPI0
-    SpiEndTransfer();
-
-    // Enable SPI0
-    word *p = (word *) 0xC0272A; // Set address (SPI0 enable)
-    *p = 1; // Write value
-    delay(10);
-
-    // Reset to get out of continuous read mode
-    SpiBeginTransfer();
-    SpiTransfer(0x66);
-    SpiEndTransfer();
-    delay(1);
-    SpiBeginTransfer();
-    SpiTransfer(0x99);
-    SpiEndTransfer();
-    delay(1);
-    SpiBeginTransfer();
-    SpiTransfer(0x66);
-    SpiEndTransfer();
-    delay(1);
-    SpiBeginTransfer();
-    SpiTransfer(0x99);
-    SpiEndTransfer();
-    delay(1);
-}
-
-// Should print 239 as Winbond manufacturer, and 23 for W25Q128 device ID
-void readDeviceID()
-{
-    SpiBeginTransfer();
-    SpiTransfer(0x90);
-    SpiTransfer(0);
-    SpiTransfer(0);
-    SpiTransfer(0);
-    word manufacturer = SpiTransfer(0);
-    word deviceID = SpiTransfer(0);
-    SpiEndTransfer();
-
-    BDOS_PrintConsole("Manufacturer ID: ");
-    BDOS_PrintDecConsole(manufacturer);
-    BDOS_PrintConsole("\n");
-
-    BDOS_PrintConsole("Device ID: ");
-    BDOS_PrintDecConsole(deviceID);
-    BDOS_PrintConsole("\n");
-}
-
-void enableWrite()
-{
-    SpiBeginTransfer();
-    SpiTransfer(0x06);
-    SpiEndTransfer();
-}
-
-
-void read_from_address(word addr, word len)
-{
-    SpiBeginTransfer();
-    SpiTransfer(0x03);
-    SpiTransfer(addr >> 16);
-    SpiTransfer(addr >> 8);
-    SpiTransfer(addr);
-
-
-    word i;
-    for (i = 0; i < len; i++)
-    {
-        word x = SpiTransfer(0x00);
-        // delay a bit here
-        uprintDec(x);
-        uprint(" ");
-    }
-    uprint("\n");
-
-    SpiEndTransfer();
-}
-
-word readStatusRegister(word reg)
-{
-    SpiBeginTransfer();
-
-    if (reg == 2)
-        SpiTransfer(0x35);
-    else if (reg == 3)
-        SpiTransfer(0x15);
-    else
-        SpiTransfer(0x05);
-
-    word status = SpiTransfer(0);
-    SpiEndTransfer();
-
-    return status;
-}
-
-// Executes chip erase operation
-// TAKES AT LEAST 20 SECONDS!
-// Returns 1 on success
-word chipErase()
-{
-    enableWrite();
-
-    word status = readStatusRegister(1);
-
-    // Check if write is enabled
-    if ((status & 0x2) == 0)
-    {
-      BDOS_PrintlnConsole("WE disabled!");
-        return 0;
-    }
-
-    // Send command
-    SpiBeginTransfer();
-    SpiTransfer(0xC7);
-    SpiEndTransfer();
-
-
-    // Wait for busy bit to be 0
-    status = 1;
-
-    while((status & 0x1) == 1) 
-    {
-      delay(100);
-        status = readStatusRegister(1);
-    }
-
-    BDOS_PrintlnConsole("Chip erase complete!");
-
-    return 1;
-}
-
-void dump_memory()
-{
-  word page_max = 9000;//65536;
-  word page;
-  for (page = 0; page < page_max; page++)
-  {
-    uprintDec(page);
-    uprint(": ");
-    word addr = page * 256;
-    SpiBeginTransfer();
-    SpiTransfer(0x03);
-    SpiTransfer(addr >> 16);
-    SpiTransfer(addr >> 8);
-    SpiTransfer(addr);
-
-    word i;
-    for (i = 0; i < 16; i++)
-    {
-        word x = SpiTransfer(0x00);
-        
-        uprintDec(x);
-        uprint(" ");
-    }
-    uprint("\n");
-
-    SpiEndTransfer();
-  }
-
-}
-
-int main() 
-{
-  // Clear UART screen:
-  uprintc(0x1B);
-  uprintc(0x5B);
-  uprintc(0x32);
-  uprintc(0x4A);
-
-  BDOS_PrintConsole("SPI Flash test\n");
-
-  initSPI();
-  readDeviceID();
-
-  //chipErase();
-
-  word addr = 2000000;
-
-  read_from_address(addr, 512);
-
-  //dump_memory();
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // Handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // Notify ending of timer1
-      break;
-
-    default:
-      break;
-  }
-}

+ 0 - 63
BCC/userBDOS/TEST.C

@@ -1,63 +0,0 @@
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-
-int main() 
-{
-
-  BDOS_PrintConsole("Running user program\n");
-
-  while (1)
-  {
-    if (HID_FifoAvailable())
-    {
-      word c = HID_FifoRead();
-      if (c == 27) // escape
-      {
-        return 'q';
-      }
-      if (c < 255)
-      {
-        BDOS_PrintcConsole(c);
-      }
-    }
-
-  }
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
-  }
-}

+ 0 - 175
BCC/userBDOS/TESTCH3.C

@@ -1,175 +0,0 @@
-// Test CH376
-
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/SYS.C"
-#include "LIB/STDLIB.C"
-
-#define FS_CMD_GET_IC_VER       0x01
-
-void BOTTOM_spiBeginTransfer()
-{
-  asm(
-    "; backup regs\n"
-    "push r1\n"
-    "push r2\n"
-
-    "load32 0xC0272C r2      ; r2 = 0xC0272C\n"
-
-    "load 0 r1              ; r1 = 0 (enable)\n"
-    "write 0 r2 r1            ; write to SPI1_CS\n"
-
-    "; restore regs\n"
-    "pop r2\n"
-    "pop r1\n"
-    );
-}
-
-void BOTTOM_spiEndTransfer()
-{
-  asm(
-    "; backup regs\n"
-    "push r1\n"
-    "push r2\n"
-
-    "load32 0xC0272C r2      ; r2 = 0xC0272C\n"
-
-    "load 1 r1              ; r1 = 1 (disable)\n"
-    "write 0 r2 r1            ; write to SPI1_CS\n"
-
-    "; restore regs\n"
-    "pop r2\n"
-    "pop r1\n"
-    );
-}
-
-word BOTTOM_spiTransfer(word dataByte)
-{
-  word retval = 0;
-  asm(
-    "load32 0xC0272B r2       ; r2 = 0xC0272B\n"
-    "write 0 r2 r4            ; write r4 over SPI1\n"
-    "read 0 r2 r2             ; read return value\n"
-    "write -4 r14 r2          ; write to stack to return\n"
-    );
-
-  return retval;
-}
-
-
-void TOP_spiBeginTransfer()
-{
-    asm(
-        "; backup regs\n"
-        "push r1\n"
-        "push r2\n"
-
-        "load32 0xC0272F r2                 ; r2 = 0xC0272F\n"
-
-        "load 0 r1                          ; r1 = 0 (enable)\n"
-        "write 0 r2 r1                      ; write to SPI2_CS\n"
-
-        "; restore regs\n"
-        "pop r2\n"
-        "pop r1\n"
-        );
-}
-
-void TOP_spiEndTransfer()
-{
-    asm(
-        "; backup regs\n"
-        "push r1\n"
-        "push r2\n"
-
-        "load32 0xC0272F r2                 ; r2 = 0xC0272F\n"
-
-        "load 1 r1                          ; r1 = 1 (disable)\n"
-        "write 0 r2 r1                      ; write to SPI2_CS\n"
-
-        "; restore regs\n"
-        "pop r2\n"
-        "pop r1\n"
-        );
-}
-
-word TOP_spiTransfer(word dataByte)
-{
-    word retval = 0;
-    asm(
-        "load32 0xC0272E r2                 ; r2 = 0xC0272E\n"
-        "write 0 r2 r4                      ; write r4 over SPI2\n"
-        "read 0 r2 r2                       ; read return value\n"
-        "write -4 r14 r2                    ; write to stack to return\n"
-        );
-
-    return retval;
-}
-
-word BOTTOM_getICver()
-{
-  BOTTOM_spiBeginTransfer();
-  BOTTOM_spiTransfer(FS_CMD_GET_IC_VER);
-
-  word icVer = BOTTOM_spiTransfer(0x00);
-  BOTTOM_spiEndTransfer();
-
-  return icVer;
-}
-
-word TOP_getICver()
-{
-  TOP_spiBeginTransfer();
-  TOP_spiTransfer(FS_CMD_GET_IC_VER);
-
-  word icVer = TOP_spiTransfer(0x00);
-  TOP_spiEndTransfer();
-
-  return icVer;
-}
-
-
-int main() 
-{
-  BDOS_PrintHexConsole(BOTTOM_getICver());
-  BDOS_PrintcConsole('\n');
-
-  BDOS_PrintHexConsole(TOP_getICver());
-  BDOS_PrintcConsole('\n');
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
-  }
-}

+ 0 - 183
BCC/userBDOS/TESTIMG.C

@@ -1,183 +0,0 @@
-// Test image generator for more advanced color tests
-
-#define word char
-
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
-#include "DATA/TESTIMGD.C"
-
-#define DATA_OFFSET 3
-
-void testCard()
-{
-  GFX_initVram(); // clear all VRAM
-  GFX_copyPaletteTable((word)DATA_PALETTE_COLOR);
-  GFX_copyPatternTable((word)DATA_PATTERN_COLOR);
-
-  word y;
-  for (y = 0; y < 25; y++)
-  {
-    GFX_printWindowColored(((word)tileColor0) + DATA_OFFSET, 5, GFX_WindowPosFromXY(0, y), 1);
-    GFX_printWindowColored(((word)tileColor1) + DATA_OFFSET, 5, GFX_WindowPosFromXY(5, y), 1);
-    GFX_printWindowColored(((word)tileColor2) + DATA_OFFSET, 5, GFX_WindowPosFromXY(10, y), 1);
-    GFX_printWindowColored(((word)tileColor3) + DATA_OFFSET, 5, GFX_WindowPosFromXY(15, y), 1);
-    GFX_printWindowColored(((word)tileColor0) + DATA_OFFSET, 5, GFX_WindowPosFromXY(20, y), 2);
-    GFX_printWindowColored(((word)tileColor1) + DATA_OFFSET, 5, GFX_WindowPosFromXY(25, y), 2);
-    GFX_printWindowColored(((word)tileColor2) + DATA_OFFSET, 5, GFX_WindowPosFromXY(30, y), 2);
-    GFX_printWindowColored(((word)tileColor3) + DATA_OFFSET, 5, GFX_WindowPosFromXY(35, y), 2);
-  }
-}
-
-void writePattern()
-{
-  asm(
-    "; backup registers\n"
-    "push r1\n"
-    "push r2\n"
-    "push r3\n"
-    "push r4\n"
-    "push r5\n"
-    "push r6\n"
-    "push r7\n"
-
-    "; 128 tiles in Window layer to id 252-255\n"
-    "; vram address\n"
-    "load32 0xC01420 r1      ; vram addr 1056+2048 0xC01420\n"
-    "add r1 412 r1         ; add starting offset\n"
-
-    "; loop variables\n"
-    "load 0 r3           ; loopvar\n"
-    "load 128 r4         ; loopmax\n"
-    "or r1 r0 r5         ; vram addr with offset\n"
-    "load 252 r1         ; initial tile ID\n"
-    "load 0 r2           ; counter for next line\n"
-    "load 15 r6          ; compare for next line (-1)\n"
-
-    "; loop\n"
-    "Test_colors_write_tile_id_loop:\n"
-    "write 0 r5 r1       ; set tile\n"
-
-    "; check if tile id is 255, then set back to 252, else increase by one\n"
-    "load 255 r7\n"
-    "bne r7 r1 2\n"
-    "load 252 r1\n"
-    "add r1 1 r1\n"
-
-    "shiftr r3 2 r7      ; only increase color id every 4 tiles\n"
-    "write 2048 r5 r7    ; set color (2048 offset, 0x800 in hex)\n"
-
-    "; if drawn 16 tiles on this line\n"
-    "bne r2 r6 4\n"
-    "add r5 25 r5\n"
-    "load 0 r2\n"
-    "jumpo 3         ; skip the other clause\n"
-
-    "; else\n"
-    "add r2 1 r2\n"
-    "add r5 1 r5       ; incr vram address\n"
-
-    "add r3 1 r3       ; incr counter\n"
-
-    "beq r3 r4 2       ; keep looping until all tiles are set\n"
-    "jump Test_colors_write_tile_id_loop\n"
-
-    "; restore registers\n"
-    "pop r7\n"
-    "pop r6\n"
-    "pop r5\n"
-    "pop r4\n"
-    "pop r3\n"
-    "pop r2\n"
-    "pop r1\n"
-    );
-}
-
-void testPalette1()
-{
-  GFX_initVram(); // clear all VRAM
-  GFX_copyPaletteTable((word)TEST_COLOR_PALETTETABLE_1);
-  GFX_copyPatternTable((word)DATA_ASCII_DEFAULT);
-  writePattern();
-}
-
-void testPalette2()
-{
-  GFX_initVram(); // clear all VRAM
-  GFX_copyPaletteTable((word)TEST_COLOR_PALETTETABLE_2);
-  GFX_copyPatternTable((word)DATA_ASCII_DEFAULT);
-  writePattern();
-}
-
-int main() 
-{
-
-  GFX_clearConsole();
-  GFX_PrintConsole("Image test tool\n");
-  GFX_PrintConsole("Press one of the following keys:\n");
-  GFX_PrintConsole("q: quit\n");
-  GFX_PrintConsole("1: test card\n");
-  GFX_PrintConsole("2: color palette 1/2\n");
-  GFX_PrintConsole("3: color palette 2/2\n");
-
-  while (1)
-  {
-    if (HID_FifoAvailable())
-    {
-      word c = HID_FifoRead();
-      if (c == 'q') // escape
-      {
-        return 'q';
-      }
-      if (c == '1')
-      {
-        testCard();
-      }
-      if (c == '2')
-      {
-        testPalette1();
-      }
-      if (c == '3')
-      {
-        testPalette2();
-      }
-    }
-
-  }
-
-  return 'q';
-}
-
-void interrupt()
-{
-  // handle all interrupts
-  word i = getIntID();
-  switch(i)
-  {
-    case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
-  }
-}

+ 20 - 39
BCC/userBDOS/BENCH.C → BCC/userBDOS/bench.c

@@ -2,9 +2,9 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
 
 #define N    256  // Decimals of pi to compute.
 #define LEN  854  // (10*N) / 3 + 1
@@ -64,7 +64,7 @@ void spigotPiBench()
       {
         --j;
         y = predigit+MATH_div(x,10);
-        BDOS_PrintDecConsole(y);
+        bdos_printdec(y);
       }
 
       for(; nines; --nines)
@@ -74,11 +74,11 @@ void spigotPiBench()
           --j;
           if (x >= 10)
           {
-            BDOS_PrintcConsole('0');
+            bdos_printc('0');
           }
           else
           {
-            BDOS_PrintcConsole('9');
+            bdos_printc('9');
           }
         }
       }
@@ -87,9 +87,9 @@ void spigotPiBench()
     }
   }
 
-  BDOS_PrintConsole("\nPiBench256 took    ");
-  BDOS_PrintDecConsole(frameCount);
-  BDOS_PrintConsole(" frames\n");
+  bdos_print("\nPiBench256 took    ");
+  bdos_printdec(frameCount);
+  bdos_print(" frames\n");
 }
 
 
@@ -140,20 +140,20 @@ int countMillionBench()
 int main() 
 {
 
-  BDOS_PrintlnConsole("---------------FPGCbench---------------\n");
+  bdos_println("---------------FPGCbench---------------\n");
 
 
-  BDOS_PrintConsole("LoopBench:         ");
+  bdos_print("LoopBench:         ");
   frameCount = 0;
   while (frameCount == 0); // wait until next frame to start
-  BDOS_PrintDecConsole(loopBench());
-  BDOS_PrintcConsole('\n');
+  bdos_printdec(loopBench());
+  bdos_printc('\n');
 
-  BDOS_PrintConsole("\nCountMillionBench: ");
-  BDOS_PrintDecConsole(countMillionBench());
-  BDOS_PrintConsole(" frames\n");
+  bdos_print("\nCountMillionBench: ");
+  bdos_printdec(countMillionBench());
+  bdos_print(" frames\n");
 
-  BDOS_PrintConsole("\nPiBench256:\n");
+  bdos_print("\nPiBench256:\n");
   spigotPiBench();
 
   return 'q';
@@ -161,34 +161,15 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
+      timer1Value = 1;  // Notify ending of timer1
       break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
     case INTID_GPU:
       frameCount++;
       break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
   }
 }

+ 9 - 30
BCC/userBDOS/MATRIX.C → BCC/userBDOS/cmatrix.c

@@ -1,9 +1,9 @@
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+#include "lib/gfx.c"
 
 #define SCREEN_WIDTH 40
 #define SCREEN_HEIGHT 25
@@ -128,9 +128,9 @@ int main()
 
   while (1)
   {
-    if (HID_FifoAvailable())
+    if (hid_checkfifo())
     {
-      word c = HID_FifoRead();
+      word c = hid_fiforead();
       if (c == 27) // escape
       {
         GFX_clearWindowtileTable();
@@ -151,33 +151,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 0 - 0
BCC/userBDOS/DATA/RAYDAT.C → BCC/userBDOS/data/raydat.c


+ 35 - 56
BCC/userBDOS/FPCALC.C → BCC/userBDOS/fpcalc.c

@@ -2,10 +2,10 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/FP.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
+#include "lib/math.c"
+#include "lib/fp.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
 
 #define CALC_BUFFER_MAX_LEN 32
 
@@ -29,64 +29,64 @@ word calcLoop()
 {
   if (CALC_state == CALC_STATE_INPUTSTART)
   {
-    BDOS_PrintConsole("Input A:      ");
+    bdos_print("Input A:      ");
     CALC_state = CALC_STATE_INPUTA;
   }
 
 
-  if (HID_FifoAvailable())
+  if (hid_checkfifo())
   {
-    word c = HID_FifoRead();
+    word c = hid_fiforead();
 
     if (CALC_state == CALC_STATE_INPUTOP)
     {
       if (c == '+')
       {
-        BDOS_PrintlnConsole("+");
+        bdos_println("+");
         char buffer[24];
         FP_FPtoString(CALC_a + CALC_b, buffer, 5);
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintlnConsole(buffer);
+        bdos_print("Result =      ");
+        bdos_println(buffer);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '-')
       {
-        BDOS_PrintlnConsole("-");
+        bdos_println("-");
         char buffer[24];
         FP_FPtoString(CALC_a - CALC_b, buffer, 5);
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintlnConsole(buffer);
+        bdos_print("Result =      ");
+        bdos_println(buffer);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '*')
       {
-        BDOS_PrintlnConsole("*");
+        bdos_println("*");
         char buffer[24];
         FP_FPtoString(FP_Mult(CALC_a, CALC_b), buffer, 5);
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintlnConsole(buffer);
+        bdos_print("Result =      ");
+        bdos_println(buffer);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '/')
       {
-        BDOS_PrintlnConsole("/");
+        bdos_println("/");
         char buffer[24];
         FP_FPtoString(FP_Div(CALC_a, CALC_b), buffer, 5);
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintlnConsole(buffer);
+        bdos_print("Result =      ");
+        bdos_println(buffer);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == 0x1b) // escape
       {
-        BDOS_PrintcConsole('\n');
+        bdos_printc('\n');
         return 1;
       }
     }
@@ -99,7 +99,7 @@ word calcLoop()
         CALC_buffer[CALC_buffer_idx] = c;
         CALC_buffer_idx++;
         CALC_buffer[CALC_buffer_idx] = 0; // terminate
-        BDOS_PrintcConsole(c);
+        bdos_printc(c);
       }
     }
     else if (c == 0x8) // backspace
@@ -111,7 +111,7 @@ word calcLoop()
         {
           CALC_buffer_idx--;
           CALC_buffer[CALC_buffer_idx] = 0;
-          BDOS_PrintcConsole(c);
+          bdos_printc(c);
         }
       }
     }
@@ -122,12 +122,12 @@ word calcLoop()
         case CALC_STATE_INPUTA:
           if (CALC_buffer_idx > 0)
           {
-            BDOS_PrintcConsole('\n');
+            bdos_printc('\n');
 
             CALC_a = FP_StringToFP(CALC_buffer);
             CALC_buffer_idx = 0;
 
-            BDOS_PrintConsole("Input B:      ");
+            bdos_print("Input B:      ");
             CALC_state = CALC_STATE_INPUTB;
           }
           break;
@@ -135,12 +135,12 @@ word calcLoop()
         case CALC_STATE_INPUTB:
           if (CALC_buffer_idx > 0)
           {
-            BDOS_PrintcConsole('\n');
+            bdos_printc('\n');
 
             CALC_b = FP_StringToFP(CALC_buffer);
             CALC_buffer_idx = 0;
 
-            BDOS_PrintConsole("Operation:    ");
+            bdos_print("Operation:    ");
             CALC_state = CALC_STATE_INPUTOP;
           }
           break;
@@ -148,7 +148,7 @@ word calcLoop()
     }
     else if (c == 0x1b) // escape
     {
-      BDOS_PrintcConsole('\n');
+      bdos_printc('\n');
       return 1;
     }
   }
@@ -158,7 +158,7 @@ word calcLoop()
 
 int main() 
 {
-  BDOS_PrintlnConsole("Fixed-point calculator test\n");
+  bdos_println("Fixed-point calculator test\n");
 
   word stop = 0;
   while (!stop)
@@ -171,33 +171,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 46 - 67
BCC/userBDOS/ICALC.C → BCC/userBDOS/icalc.c

@@ -2,9 +2,9 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
 
 #define CALC_BUFFER_MAX_LEN 32
 
@@ -28,83 +28,83 @@ word calcLoop()
 {
   if (CALC_state == CALC_STATE_INPUTSTART)
   {
-    BDOS_PrintConsole("Input A:      ");
+    bdos_print("Input A:      ");
     CALC_state = CALC_STATE_INPUTA;
   }
 
 
-  if (HID_FifoAvailable())
+  if (hid_checkfifo())
   {
-    word c = HID_FifoRead();
+    word c = hid_fiforead();
 
     if (CALC_state == CALC_STATE_INPUTOP)
     {
       if (c == '+')
       {
-        BDOS_PrintlnConsole("+");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole(CALC_a + CALC_b);
+        bdos_println("+");
+        bdos_print("Result =      ");
+        bdos_printdec(CALC_a + CALC_b);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '-')
       {
-        BDOS_PrintlnConsole("-");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole(CALC_a - CALC_b);
+        bdos_println("-");
+        bdos_print("Result =      ");
+        bdos_printdec(CALC_a - CALC_b);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '*')
       {
-        BDOS_PrintlnConsole("*");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole(CALC_a * CALC_b);
+        bdos_println("*");
+        bdos_print("Result =      ");
+        bdos_printdec(CALC_a * CALC_b);
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '/')
       {
-        BDOS_PrintlnConsole("/");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole( MATH_div(CALC_a, CALC_b) );
+        bdos_println("/");
+        bdos_print("Result =      ");
+        bdos_printdec( MATH_div(CALC_a, CALC_b) );
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == '%')
       {
-        BDOS_PrintlnConsole("%");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole( MATH_mod(CALC_a, CALC_b) );
+        bdos_println("%");
+        bdos_print("Result =      ");
+        bdos_printdec( MATH_mod(CALC_a, CALC_b) );
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == 'u')
       {
-        BDOS_PrintlnConsole("u/");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole( MATH_divU(CALC_a, CALC_b) );
+        bdos_println("u/");
+        bdos_print("Result =      ");
+        bdos_printdec( MATH_divU(CALC_a, CALC_b) );
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == 'w')
       {
-        BDOS_PrintlnConsole("u%");
-        BDOS_PrintConsole("Result =      ");
-        BDOS_PrintDecConsole( MATH_modU(CALC_a, CALC_b) );
+        bdos_println("u%");
+        bdos_print("Result =      ");
+        bdos_printdec( MATH_modU(CALC_a, CALC_b) );
         CALC_state = CALC_STATE_INPUTA;
-        BDOS_PrintConsole("\n\nInput A:      ");
+        bdos_print("\n\nInput A:      ");
       }
 
       else if (c == 0x1b) // escape
       {
-        BDOS_PrintcConsole('\n');
+        bdos_printc('\n');
         return 1;
       }
     }
@@ -117,7 +117,7 @@ word calcLoop()
         CALC_buffer[CALC_buffer_idx] = c;
         CALC_buffer_idx++;
         CALC_buffer[CALC_buffer_idx] = 0; // terminate
-        BDOS_PrintcConsole(c);
+        bdos_printc(c);
       }
     }
     else if (c == 0x8) // backspace
@@ -129,7 +129,7 @@ word calcLoop()
         {
           CALC_buffer_idx--;
           CALC_buffer[CALC_buffer_idx] = 0;
-          BDOS_PrintcConsole(c);
+          bdos_printc(c);
         }
       }
     }
@@ -140,12 +140,12 @@ word calcLoop()
         case CALC_STATE_INPUTA:
           if (CALC_buffer_idx > 0)
           {
-            BDOS_PrintcConsole('\n');
+            bdos_printc('\n');
             
             CALC_a = strToInt(CALC_buffer);
             CALC_buffer_idx = 0;
 
-            BDOS_PrintConsole("\nInput B:      ");
+            bdos_print("\nInput B:      ");
             CALC_state = CALC_STATE_INPUTB;
           }
           break;
@@ -153,12 +153,12 @@ word calcLoop()
         case CALC_STATE_INPUTB:
           if (CALC_buffer_idx > 0)
           {
-            BDOS_PrintcConsole('\n');
+            bdos_printc('\n');
 
             CALC_b = strToInt(CALC_buffer);
             CALC_buffer_idx = 0;
 
-            BDOS_PrintConsole("Operation:    ");
+            bdos_print("Operation:    ");
             CALC_state = CALC_STATE_INPUTOP;
           }
           break;
@@ -166,7 +166,7 @@ word calcLoop()
     }
     else if (c == 0x1b) // escape
     {
-      BDOS_PrintcConsole('\n');
+      bdos_printc('\n');
       return 1;
     }
   }
@@ -176,7 +176,7 @@ word calcLoop()
 
 int main() 
 {
-  BDOS_PrintlnConsole("Integer calculator test\n");
+  bdos_println("Integer calculator test\n");
 
   word stop = 0;
   while (!stop)
@@ -189,33 +189,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 0 - 0
BCC/userBDOS/LIB/FP.C → BCC/userBDOS/lib/fp.c


+ 0 - 0
BCC/userBDOS/LIB/GFX.C → BCC/userBDOS/lib/gfx.c


+ 0 - 0
BCC/userBDOS/LIB/MATH.C → BCC/userBDOS/lib/math.c


+ 0 - 0
BCC/userBDOS/LIB/SPIFLASH.C → BCC/userBDOS/lib/spiflash.c


+ 0 - 0
BCC/userBDOS/LIB/STDIO.C → BCC/userBDOS/lib/stdio.c


+ 0 - 15
BCC/userBDOS/LIB/STDLIB.C → BCC/userBDOS/lib/stdlib.c

@@ -667,21 +667,6 @@ word millis()
 }
 
 
-// Returns interrupt ID by using the readintid asm instruction
-word getIntID()
-{
-  word retval = 0;
-
-  asm(
-    "readintid r2  ;reads interrupt id to r2\n"
-    "write -4 r14 r2 ;write to stack to return\n"
-    );
-
-  return retval;
-}
-
-
-
 // Converts char c to uppercase if possible
 char toUpper(char c)
 {

+ 372 - 0
BCC/userBDOS/lib/sys.c

@@ -0,0 +1,372 @@
+/**
+ * Contains system functions for user programs
+ * Contains code for system calls and interrupt handling
+*/
+
+// Interrupt IDs for interrupt handler
+#define INTID_TIMER1  0x1
+#define INTID_TIMER2  0x2
+#define INTID_UART0   0x3
+#define INTID_GPU     0x4
+#define INTID_TIMER3  0x5
+#define INTID_PS2     0x6
+#define INTID_UART1   0x7
+#define INTID_UART2   0x8
+
+#define MAX_PATH_LENGTH 127
+
+#define SYSCALL_RETVAL_ADDR 0x200000
+
+// System call IDs
+#define SYS_HID_CHECKFIFO 1
+#define SYS_HID_READFIFO 2
+#define SYS_BDOS_PRINTC 3
+#define SYS_BDOS_PRINT 4
+#define SYS_FS_OPEN 5
+#define SYS_FS_CLOSE 6
+#define SYS_FS_READ 7
+#define SYS_FS_WRITE 8
+#define SYS_FS_SETCURSOR 9
+#define SYS_FS_GETCURSOR 10
+#define SYS_FS_DELETE 11
+#define SYS_FS_MKDIR 12
+#define SYS_FS_MKFILE 13
+#define SYS_FS_STAT 14
+#define SYS_FS_READDIR 15
+#define SYS_FS_GETCWD 16
+// Syscalls 17-19 are reserved for future use
+#define SYS_SHELL_ARGC 20
+#define SYS_SHELL_ARGV 21
+#define SYS_USB_KB_BUF 99
+
+
+/**
+ * Returns the interrupt ID
+*/
+word get_int_id()
+{
+  word retval = 0;
+
+  asm(
+    "readintid r2     ;reads interrupt id to r2\n"
+    "write -4 r14 r2  ;write to stack to return\n"
+    );
+
+  return retval;
+}
+
+/**
+ * Executes system call to BDOS
+ * Argument specifies the system call ID
+ * Returns the address of the return value
+*/
+word* syscall(word ID)
+{
+  word* p = (word*) SYSCALL_RETVAL_ADDR;
+  *p = ID;
+
+  asm("push r1\n"
+    "push r2\n"
+    "push r3\n"
+    "push r4\n"
+    "push r5\n"
+    "push r6\n"
+    "push r7\n"
+    "push r8\n"
+    "push r9\n"
+    "push r10\n"
+    "push r11\n"
+    "push r12\n"
+    "push r13\n"
+    "push r14\n"
+    "push r15\n"
+    "savpc r1\n"
+    "push r1\n"
+    "jump 4\n"
+    "pop r15\n"
+    "pop r14\n"
+    "pop r13\n"
+    "pop r12\n"
+    "pop r11\n"
+    "pop r10\n"
+    "pop r9\n"
+    "pop r8\n"
+    "pop r7\n"
+    "pop r6\n"
+    "pop r5\n"
+    "pop r4\n"
+    "pop r3\n"
+    "pop r2\n"
+    "pop r1\n");
+
+  return p;
+}
+
+/**
+ * Exits the user program and returns to BDOS in a somewhat controlled way
+*/
+void exit()
+{
+  asm("ccache\n");
+  asm("jump Return_BDOS\n");
+}
+
+/**
+ * Returns 1 if the HID buffer is not empty
+*/
+word hid_checkfifo()
+{
+  char* p = syscall(SYS_HID_CHECKFIFO);
+  return p[0];
+}
+
+/**
+ * Reads a character from the HID buffer
+*/
+word hid_fiforead()
+{
+  char* p = syscall(SYS_HID_READFIFO);
+  return p[0];
+}
+
+/**
+ * Prints a character on the BDOS console
+*/
+void bdos_printc(char c)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = c;
+  syscall(SYS_BDOS_PRINTC);
+}
+
+/**
+ * Prints a string on the BDOS console
+*/
+void bdos_print(char* c)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char)c;
+  syscall(SYS_BDOS_PRINT);
+}
+
+/**
+ * Prints a string with newline on the BDOS console
+*/
+void bdos_println(char* str)
+{
+  bdos_print(str);
+  bdos_printc('\n');
+}
+
+/**
+ * Prints a decimal on the BDOS console
+*/
+void bdos_printdec(word i)
+{
+  char buffer[12];
+
+  if (i < 0)
+  {
+    buffer[0] = '-';
+    itoa(MATH_abs(i), &buffer[1]);
+  }
+  else
+  {
+    itoa(i, buffer);
+  }
+  bdos_print(buffer);
+}
+
+/**
+ * Prints a decimal with newline on the BDOS console
+*/
+void bdos_printdecln(word i)
+{
+  bdos_printdec(i);
+  bdos_printc('\n');
+}
+
+/**
+ * Prints a hexadecimal on the BDOS console
+*/
+void bdos_printhex(word i)
+{
+  char buffer[11];
+  itoah(i, buffer);
+  bdos_print(buffer);
+}
+
+/**
+ * Opens a file in the filesystem
+*/
+word fs_open(char* filename)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char) filename;
+  syscall(SYS_FS_OPEN);
+  return p[0];
+}
+
+/**
+ * Closes a file in the filesystem
+*/
+word fs_close(word fp)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = fp;
+  syscall(SYS_FS_CLOSE);
+  return p[0];
+}
+
+/**
+ * Reads from a file in the filesystem
+*/
+word fs_read(word fp, char* buffer, word len)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = fp;
+  p[2] = (char) buffer;
+  p[3] = len;
+  syscall(SYS_FS_READ);
+  return p[0];
+}
+
+/**
+ * Writes to a file in the filesystem
+*/
+word fs_write(word fp, char* buffer, word len)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = fp;
+  p[2] = (char) buffer;
+  p[3] = len;
+  syscall(SYS_FS_WRITE);
+  return p[0];
+}
+
+/**
+ * Sets the cursor position in the filesystem
+*/
+word fs_setcursor(word fp, word pos)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = fp;
+  p[2] = pos;
+  syscall(SYS_FS_SETCURSOR);
+  return p[0];
+}
+
+/**
+ * Gets the cursor position in the filesystem
+*/
+word fs_getcursor(word fp)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = fp;
+  syscall(SYS_FS_GETCURSOR);
+  return p[0];
+}
+
+/**
+ * Deletes a file in the filesystem
+*/
+word fs_delete(char* filename)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char) filename;
+  syscall(SYS_FS_DELETE);
+  return p[0];
+}
+
+/**
+ * Creates a directory in the filesystem
+*/
+word fs_mkdir(char* dirname)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char) dirname;
+  syscall(SYS_FS_MKDIR);
+  return p[0];
+}
+
+/**
+ * Creates a file in the filesystem
+*/
+word fs_mkfile(char* filename)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char) filename;
+  syscall(SYS_FS_MKFILE);
+  return p[0];
+}
+
+/**
+ * Gets the status of a file in the filesystem
+*/
+word fs_stat(char* filename)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char) filename;
+  syscall(SYS_FS_STAT);
+  return p[0];
+}
+
+/**
+ * Lists the contents of a directory in the filesystem
+*/
+word fs_readdir(char* dirname)
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  p[1] = (char) dirname;
+  syscall(SYS_FS_READDIR);
+  return p[0];
+}
+
+/**
+ * Gets the current working directory in the filesystem
+*/
+char* fs_getcwd()
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  syscall(SYS_FS_GETCWD);
+  return (char*) p[0];
+}
+
+/**
+ * Returns the number of command line arguments
+*/
+word shell_argc()
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  syscall(SYS_SHELL_ARGC);
+  return p[0];
+}
+
+/**
+ * Returns the command line arguments
+*/
+char* shell_argv()
+{
+  char* p = (char*) SYSCALL_RETVAL_ADDR;
+  syscall(SYS_SHELL_ARGV);
+  return p[0];
+}
+
+/**
+ * Returns 1 if key is being held on USB keyboard
+*/
+word bdos_usbkey_held(word c)
+{
+  word* p = syscall(SYS_USB_KB_BUF);
+  word* usbKeyBuffer = (char*) p[0];
+  
+  word i;
+  for (i = 0; i < 8; i++)
+  {
+    if (usbKeyBuffer[i] == c)
+    {
+      return 1;
+    }
+  }
+  return 0;
+}

+ 0 - 0
BCC/userBDOS/LIB/WIZ5500.C → BCC/userBDOS/lib/wiz5500.c


+ 9 - 30
BCC/userBDOS/MBROT.C → BCC/userBDOS/mbrot.c

@@ -1,9 +1,9 @@
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+#include "lib/gfx.c"
 
 #define SCREEN_WIDTH 320
 #define SCREEN_HEIGHT 240
@@ -228,9 +228,9 @@ int main()
 
   while (1)
   {
-    if (HID_FifoAvailable())
+    if (hid_checkfifo())
       {
-        word c = HID_FifoRead();
+        word c = hid_fiforead();
 
         if (c == '=') // +
         {
@@ -290,33 +290,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 59 - 0
BCC/userBDOS/mkdir.c

@@ -0,0 +1,59 @@
+#define word char
+
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+
+int main() 
+{
+  // Read number of arguments
+  word argc = shell_argc();
+  if (argc < 2)
+  {
+    bdos_println("Usage: mkdir <directory>");
+    return 1;
+  }
+  
+  // Read directory name
+  char** dirname = shell_argv(1);
+
+  char absolute_path[MAX_PATH_LENGTH];
+  // Check if absolute path
+  if (dirname[1][0] != '/')
+  {
+    char* cwd = fs_getcwd();
+    uprintln("CWD:");
+    uprintln(cwd);
+    strcpy(absolute_path, cwd);
+    strcat(absolute_path, "/");
+    strcat(absolute_path, dirname[1]);
+  }
+  else
+  {
+    strcpy(absolute_path, dirname[1]);
+  }
+
+  // Create directory
+  if (fs_mkdir(absolute_path))
+  {
+    bdos_println("Directory created");
+  }
+  else
+  {
+    bdos_println("Could not create directory");
+  }
+
+  return 'q';
+}
+
+void interrupt()
+{
+  // Handle all interrupts
+  word i = get_int_id();
+  switch(i)
+  {
+    case INTID_TIMER1:
+      timer1Value = 1;  // Notify ending of timer1
+      break;
+  }
+}

+ 17 - 36
BCC/userBDOS/RAYCAST.C → BCC/userBDOS/raycast.c

@@ -11,11 +11,11 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
-#include "LIB/FP.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+#include "lib/gfx.c"
+#include "lib/fp.c"
 
 // Note: these are also hardcoded in the render assembly, so update there as well!
 #define FB_ADDR       0xD00000
@@ -52,7 +52,7 @@
 - LUTplaney
 - texture
 */
-#include "DATA/RAYDAT.C"
+#include "data/raydat.c"
 
 // Framebuffer. fb[Y][X] (bottom right is [239][319])
 char (*fb)[320] = (char (*)[320])FB_ADDR;
@@ -579,7 +579,7 @@ int main() {
     rotationSpeed = renderMillis >> 1;
 
     // check which button is held
-    if (BDOS_USBkeyHeld('a')) {
+    if (bdos_usbkey_held('a')) {
       // both camera direction and camera plane must be rotated
       rotationAngle -= rotationSpeed;
       if (rotationAngle < 0) {
@@ -589,7 +589,7 @@ int main() {
       RAY_dirY = LUTdirY[rotationAngle];
       RAY_planeX = LUTplaneX[rotationAngle];
       RAY_planeY = LUTplaneY[rotationAngle];
-    } else if (BDOS_USBkeyHeld('d')) {
+    } else if (bdos_usbkey_held('d')) {
       // both camera direction and camera plane must be rotated
       rotationAngle += rotationSpeed;
       if (rotationAngle >= 1440) {
@@ -601,7 +601,7 @@ int main() {
       RAY_planeY = LUTplaneY[rotationAngle];
     }
 
-    if (BDOS_USBkeyHeld('w')) {
+    if (bdos_usbkey_held('w')) {
       word worldMapX = FP_FPtoInt(RAY_posX + FP_Mult(RAY_dirX, moveSpeed + movePadding));
       word worldMapY = FP_FPtoInt(RAY_posY);
 
@@ -614,7 +614,7 @@ int main() {
       if (worldMap[worldMapX][worldMapY] == 0) {
         RAY_posY += FP_Mult(RAY_dirY, moveSpeed);
       }
-    } else if (BDOS_USBkeyHeld('s')) {
+    } else if (bdos_usbkey_held('s')) {
       word worldMapX = FP_FPtoInt(RAY_posX - FP_Mult(RAY_dirX, moveSpeed + movePadding));
       word worldMapY = FP_FPtoInt(RAY_posY);
 
@@ -627,7 +627,7 @@ int main() {
       if (worldMap[worldMapX][worldMapY] == 0) {
         RAY_posY -= FP_Mult(RAY_dirY, moveSpeed);
       }
-    } else if (BDOS_USBkeyHeld('e')) {
+    } else if (bdos_usbkey_held('e')) {
       word worldMapX = FP_FPtoInt(RAY_posX + FP_Mult(RAY_planeX, moveSpeed + movePadding));
       word worldMapY = FP_FPtoInt(RAY_posY);
 
@@ -640,7 +640,7 @@ int main() {
       if (worldMap[worldMapX][worldMapY] == 0) {
         RAY_posY += FP_Mult(RAY_planeY, moveSpeed);
       }
-    } else if (BDOS_USBkeyHeld('q')) {
+    } else if (bdos_usbkey_held('q')) {
       word worldMapX = FP_FPtoInt(RAY_posX - FP_Mult(RAY_planeX, moveSpeed + movePadding));
       word worldMapY = FP_FPtoInt(RAY_posY);
 
@@ -655,8 +655,8 @@ int main() {
       }
     }
 
-    if (HID_FifoAvailable()) {
-      word c = HID_FifoRead();
+    if (hid_checkfifo()) {
+      word c = hid_fiforead();
 
       if (c == 27)  // escape
       {
@@ -684,33 +684,14 @@ int main() {
 }
 
 void interrupt() {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch (i) {
     case INTID_TIMER1:
-      timer1Value = 1;  // notify ending of timer1
+      timer1Value = 1;  // Notify ending of timer1
       break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
     case INTID_GPU:
       frameDone++;
       break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
-      break;
   }
 }

+ 15 - 34
BCC/userBDOS/SNAKE.C → BCC/userBDOS/snake.c

@@ -5,10 +5,10 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+#include "lib/gfx.c"
 
 #define START_DELAY 120
 #define STEP_DELAY 20
@@ -231,28 +231,28 @@ word checkFoodCollision()
 void updatePlayer(word keepTail)
 {
   // check which button is held
-  if (BDOS_USBkeyHeld(BTN_LEFT))
+  if (bdos_usbkey_held(BTN_LEFT))
   {
     if (dirOnScreen != RIGHT)
     {
       dir = LEFT;
     }
   }
-  else if (BDOS_USBkeyHeld(BTN_RIGHT))
+  else if (bdos_usbkey_held(BTN_RIGHT))
   {
     if (dirOnScreen != LEFT)
     {
       dir = RIGHT;
     }
   }
-  else if (BDOS_USBkeyHeld(BTN_UP))
+  else if (bdos_usbkey_held(BTN_UP))
   {
     if (dirOnScreen != DOWN)
     {
       dir = UP;
     }
   }
-  else if (BDOS_USBkeyHeld(BTN_DOWN))
+  else if (bdos_usbkey_held(BTN_DOWN))
   {
     if (dirOnScreen != UP)
     {
@@ -371,15 +371,15 @@ int main()
   // main loop
   while (1)
   {
-    if (HID_FifoAvailable())
+    if (hid_checkfifo())
     {
-      word c = HID_FifoRead();
+      word c = hid_fiforead();
       switch(c)
       {
         case 27: //escape
           // cleanup and exit
           clearScreen();
-          BDOS_PrintcConsole('\n');
+          bdos_printc('\n');
           return 'q';
           break;
         
@@ -437,34 +437,15 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
-  word i = getIntID();
+  // Handle all interrupts
+  word i = get_int_id();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
+      timer1Value = 1;  // Notify ending of timer1
       break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
     case INTID_TIMER3:
-      timer3Value = 1; // notify ending of timer3
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer3Value = 1;  // Notify ending of timer3
       break;
   }
 }

+ 23 - 0
BCC/userBDOS/template.c

@@ -0,0 +1,23 @@
+#define word char
+
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+
+int main() 
+{
+  bdos_println("Template program.");
+  return 'q';
+}
+
+void interrupt()
+{
+  // Handle all interrupts
+  word i = get_int_id();
+  switch(i)
+  {
+    case INTID_TIMER1:
+      timer1Value = 1;  // Notify ending of timer1
+      break;
+  }
+}

+ 6 - 27
BCC/userBDOS/CP.C → BCC/userBDOS/toFix/cp.c

@@ -18,10 +18,10 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/SYS.C"
-#include "LIB/STDLIB.C"
-#include "LIB/FS.C"
+#include "lib/math.c"
+#include "lib/sys.c"
+#include "lib/stdlib.c"
+#include "lib/fs.c"
 
 char infilename[96];  // input filename
 char outfilename[96];  // output filename
@@ -320,33 +320,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
+  // Handle all interrupts
   word i = getIntID();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 7 - 28
BCC/userBDOS/EDIT.C → BCC/userBDOS/toFix/edit.c

@@ -36,11 +36,11 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/SYS.C"
-#include "LIB/GFX.C"
-#include "LIB/STDLIB.C"
-#include "LIB/FS.C"
+#include "lib/math.c"
+#include "lib/sys.c"
+#include "lib/gfx.c"
+#include "lib/stdlib.c"
+#include "lib/fs.c"
 
 #define FBUF_ADDR           0x440000 // location of input file buffer
 #define FILE_MEMORY_ADDR    0x480000 // location of file content
@@ -1130,33 +1130,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
+  // Handle all interrupts
   word i = getIntID();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 6 - 27
BCC/userBDOS/MV.C → BCC/userBDOS/toFix/mv.c

@@ -18,10 +18,10 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/SYS.C"
-#include "LIB/STDLIB.C"
-#include "LIB/FS.C"
+#include "lib/math.c"
+#include "lib/sys.c"
+#include "lib/stdlib.c"
+#include "lib/fs.c"
 
 char infilename[96];  // input filename
 char outfilename[96];  // output filename
@@ -337,33 +337,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
+  // Handle all interrupts
   word i = getIntID();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 7 - 28
BCC/userBDOS/WEBSERV.C → BCC/userBDOS/toFix/webserv.c

@@ -3,11 +3,11 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/FS.C"
-#include "LIB/WIZ5500.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+#include "lib/fs.c"
+#include "lib/wiz5500.c"
 
 #define TMPMEM_LOCATION 0x440000
 #define FILE_BUFFER_LOCATION 0x430000
@@ -582,33 +582,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
+  // Handle all interrupts
   word i = getIntID();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 7 - 28
BCC/userBDOS/WGET.C → BCC/userBDOS/toFix/wget.c

@@ -3,11 +3,11 @@
 
 #define word char
 
-#include "LIB/MATH.C"
-#include "LIB/STDLIB.C"
-#include "LIB/SYS.C"
-#include "LIB/FS.C"
-#include "LIB/WIZ5500.C"
+#include "lib/math.c"
+#include "lib/stdlib.c"
+#include "lib/sys.c"
+#include "lib/fs.c"
+#include "lib/wiz5500.c"
 
 #define HEAP_LOCATION 0x500000
 
@@ -430,33 +430,12 @@ int main()
 
 void interrupt()
 {
-  // handle all interrupts
+  // Handle all interrupts
   word i = getIntID();
   switch(i)
   {
     case INTID_TIMER1:
-      timer1Value = 1; // notify ending of timer1
-      break;
-
-    case INTID_TIMER2:
-      break;
-
-    case INTID_UART0:
-      break;
-
-    case INTID_GPU:
-      break;
-
-    case INTID_TIMER3:
-      break;
-
-    case INTID_PS2:
-      break;
-
-    case INTID_UART1:
-      break;
-
-    case INTID_UART2:
+      timer1Value = 1;  // Notify ending of timer1
       break;
   }
 }

+ 38 - 0
Documentation/docs/Software/BDOS/syscalls.md

@@ -0,0 +1,38 @@
+# Syscalls
+
+Syscalls, short for system calls, are a fundamental concept in operating systems. They provide a way for user-level (userBDOS) programs to interact with the underlying operating system (BDOS). Syscalls act as an interface between the user space and the OS space, allowing programs to request services from BDOS. Examples of syscalls include filesystem operations or writing to console.
+
+Syscalls are essential for performing low-level operations and accessing system resources that are not directly/easily accessible from user-level programs. They provide a standardized and controlled way for programs to interact with the operating system.
+
+## Implementation
+
+Syscalls are implemented by using some hardcoded reserved memory in the BDOS memory map. The program starts by writing the ID to this address. Then, the program adds optional arguments to each following word/address (so one word per arg: might be good to use a pointer if it does not fit in one word). Afterwards, the program backs up its registers to the hw stack, pushes the program counter to the hw stack and jumps to address 4.
+
+By jumping to address 4, the CPU will then jump to the `syscall()` function of BDOS, as this jump statement is added during compilation of BDOS by the assembler. Then, BDOS will handle the syscall by reading the reserved memory to obtain the ID and arguments. The output is then written to the same address. Note, during this, a different stack is used to not interfere with the BDOS or program's stack.
+
+Afterwards, BDOS will return from the syscall() function, pop the program counter saved by the user program, and jumpt to this program counter with an offset to land right after the jump to address 4. Afterwards, the registers are restored and the userprogram continues normally. Then, it can read the return values of the syscall by reading from the reserved memory address.
+
+## Syscall table
+
+
+| ID  | Name           | arg1       | arg2      | arg3       | Description                                      | Implemented |
+| --- | -------------- | ---------- | --------- | ---------- | ------------------------------------------------ | ----------- |
+| 1   | hid_checkfifo  | -          | -         | -          | Check if there is data in the HID FIFO           | &#9745;     |
+| 2   | hid_readfifo   | -          | -         | -          | Read next input from the HID FIFO                | &#9745;     |
+| 3   | bdos_printc    | char c     | -         | -          | Print a character to the console                 | &#9745;     |
+| 4   | bdos_print     | char* c    | -         | -          | Print a null-terminated string to the console    | &#9745;     |
+| 5   | fs_open        | char* path | -         | -          | Open a file                                      | &#9745;     |
+| 6   | fs_close       | word fp    | -         | -          | Close a file                                     | &#9745;     |
+| 7   | fs_read        | word fp    | word len  | word* data | Read data from a file                            | &#9745;     |
+| 8   | fs_write       | word fp    | word len  | word* data | Write data to a file                             | &#9745;     |
+| 9   | fs_setcursor   | word fp    | word pos  | -          | Set the cursor position in a file                | &#9745;     |
+| 10  | fs_getcursor   | word fp    | -         | -          | Get the cursor position in a file                | &#9745;     |
+| 11  | fs_delete      | char* path | -         | -          | Delete a file or directory                       | &#9745;     |
+| 12  | fs_mkdir       | char* path | -         | -          | Create a directory                               | &#9745;     |
+| 13  | fs_mkfile      | char* path | -         | -          | Create a file                                    | &#9745;     |
+| 14  | fs_stat        | char* path | -         | -          | Get file or directory information                | &#9745;     |
+| 15  | fs_readdir     | char* path | -         | -          | Read a directory (TODO: think what to return)    | &#9744;     |
+| 16  | fs_getcwd      | -          | -         | -          | Get the current working directory                | &#9745;     |
+|17-19| *reserved*     | -          | -         | -          | Reserved for future use                          |             |
+| 20  | shell_argc     | -          | -         | -          | Get the number of command-line arguments         | &#9745;     |
+| 21  | shell_argv     | -          | -         | -          | Get the command-line arguments                   | &#9745;     |