瀏覽代碼

firmware/SPC: zero echo buffer to avoid artifacts

Maximilian Rehkopf 12 年之前
父節點
當前提交
a1ca5f1dad
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/memory.c

+ 12 - 0
src/memory.c

@@ -361,6 +361,18 @@ uint32_t load_spc(uint8_t* filename, uint32_t spc_data_addr, uint32_t spc_header
   }
   FPGA_DESELECT();
   file_close(); /* Done ! */
+
+  /* clear echo buffer to avoid artifacts */
+  uint8_t esa = sram_readbyte(spc_header_addr+0x100+0x6d);
+  uint8_t edl = sram_readbyte(spc_header_addr+0x100+0x7d);
+  uint8_t flg = sram_readbyte(spc_header_addr+0x100+0x6c);
+  if(!(flg & 0x20) && (edl & 0x0f)) {
+    int echo_start = esa << 8;
+    int echo_length = (edl & 0x0f) << 11;
+    printf("clearing echo buffer %04x-%04x...\n", echo_start, echo_start+echo_length-1);
+    sram_memset(spc_data_addr+echo_start, echo_length, 0);
+  }
+
   return (uint32_t)filesize;
 }