ソースを参照

Merge branch 'master' into qdinc

Conflicts:
	avr/usbload/main.c
	avr/usbload/shell.c
optixx 14 年 前
コミット
a019317b6e

+ 1 - 1
avr/usbload/Makefile

@@ -39,7 +39,7 @@ else
     CFLAGS  =-Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
     OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o  main.o usb_bulk.o \
               uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o \
-              pwm.o uril.o shell.o info.o shared_memory.o command.o irq.o
+              pwm.o util.o shell.o info.o shared_memory.o command.o irq.o
 endif
 
 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)

+ 66 - 2
avr/usbload/command.c

@@ -29,8 +29,12 @@
 #include "info.h"
 #include "irq.h"
 #include "usbdrv.h"
+#include "rle.h"
+#include "loader.h"
 
-extern uint32_t req_bank_size;
+extern usb_transaction_t usb_trans;
+
+extern const char _rom[] PROGMEM;
 
 void usb_connect()
 {
@@ -73,7 +77,7 @@ void send_irq()
 
 void set_rom_mode()
 {
-    if (req_bank_size == 0x8000) {
+    if (usb_trans.req_bank_size == 0x8000) {
         snes_lorom();
         info_P(PSTR("Set SNES lowrom \n"));
     } else {
@@ -81,3 +85,63 @@ void set_rom_mode()
         info_P(PSTR("Set SNES hirom \n"));
     }
 }
+
+
+void boot_startup_rom(uint16_t init_delay)
+{
+    info_P(PSTR("Fetch loader rom\n"));
+    info_P(PSTR("Activate AVR bus\n"));
+    avr_bus_active();
+    info_P(PSTR("IRQ off\n"));
+    snes_irq_lo();
+    snes_irq_off();
+    snes_lorom();
+    rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
+    info_P(PSTR("\n"));
+
+#if DO_CRC_CHECK_LOADER     
+    dump_memory(0x010000 - 0x100, 0x010000);
+    uint16_t crc;
+    crc = crc_check_bulk_memory((uint32_t)0x000000,0x010000, 0x010000);
+    info(PSTR("crc=%x\n"),crc);
+#endif
+
+    snes_irq_lo();
+    snes_irq_off();
+    snes_hirom();
+    snes_wr_disable();
+    
+    snes_bus_active();
+    info_P(PSTR("Activate SNES bus\n"));
+    send_reset();
+    _delay_ms(init_delay);
+}
+
+void banner(){
+    uint8_t i;
+    for (i=0;i<40;i++)
+        info_P(PSTR("\n"));
+    info_P(PSTR(" ________        .__        __    ________               ____  ________\n"));
+    info_P(PSTR(" \\_____  \\  __ __|__| ____ |  | __\\______ \\   _______  _/_   |/  _____/\n"));
+    info_P(PSTR("  /  / \\  \\|  |  \\  |/ ___\\|  |/ / |    |  \\_/ __ \\  \\/ /|   /   __  \\ \n"));
+    info_P(PSTR(" /   \\_/.  \\  |  /  \\  \\___|    <  |    `   \\  ___/\\   / |   \\  |__\\  \\ \n"));
+    info_P(PSTR(" \\_____\\ \\_/____/|__|\\___  >__|_ \\/_______  /\\___  >\\_/  |___|\\_____  / \n"));
+    info_P(PSTR("        \\__>             \\/     \\/        \\/     \\/                 \\/ \n"));
+    info_P(PSTR("\n"));
+    info_P(PSTR("                               www.optixx.org\n"));
+    info_P(PSTR("\n"));
+    info_P(PSTR("System Hw: %s Sw: %s\n"),HW_VERSION,SW_VERSION);
+    
+}
+
+void transaction_status(){
+    info_P(PSTR("\nAddr           0x%06lx\n"),usb_trans.req_addr);
+    info_P(PSTR("Bank           0x%02x\n"),usb_trans.req_bank);
+    info_P(PSTR("Banksize       0x%06lx\n"),usb_trans.req_bank_size);
+    info_P(PSTR("Bankcount      0x%02x\n"),usb_trans.req_bank_cnt);
+    info_P(PSTR("Status         0x%02x\n"),usb_trans.req_state);
+    info_P(PSTR("Percent        %02i\n"),usb_trans.req_percent);
+    info_P(PSTR("TX buffer      %02i\n"),usb_trans.tx_remaining);
+    info_P(PSTR("RX buffer      %02i\n"),usb_trans.rx_remaining);
+    info_P(PSTR("Syncerr        %02i\n"),usb_trans.sync_errors);
+}

+ 4 - 0
avr/usbload/command.h

@@ -26,5 +26,9 @@ void send_reset();
 void send_irq();
 void set_rom_mode();
 void usb_connect();
+void boot_startup_rom(uint16_t init_delay);
+void banner();
+void transaction_status();
+
 
 #endif

+ 3 - 1
avr/usbload/config.h

@@ -43,7 +43,8 @@
 #define USB_CRC_CHECK               0x01
 
 #define TRANSFER_BUFFER_SIZE        0x000
-#define FORMAT_BUFFER_LEN           0x100
+#define FORMAT_BUFFER_LEN           0x080
+#define RECEIVE_BUF_LEN             0x030
 #define HW_VERSION                  "2.6"
 #define SW_VERSION                  "1.0"
 
@@ -51,5 +52,6 @@
 #define DO_CRC_CHECK                0
 #define DO_SHM_SCRATCHPAD           1
 #define DO_SHM                      1
+#define DO_TIMER                    1
 
 #endif 

+ 87 - 159
avr/usbload/main.c

@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <avr/pgmspace.h>       
 #include <avr/eeprom.h>
+#include <string.h>
 
 #include "usbdrv.h"
 #include "oddebug.h"            
@@ -51,31 +52,17 @@
 
 
 
-extern const char _rom[] PROGMEM;
 extern FILE uart_stdout;
 
 uint8_t debug_level = (DEBUG | DEBUG_USB | DEBUG_CRC | DEBUG_SHM );
 
-uint8_t read_buffer[TRANSFER_BUFFER_SIZE];
-uint32_t req_addr = 0;
-uint32_t req_addr_end = 0;
-uint32_t req_size;
-uint8_t req_bank;
-uint32_t req_bank_size;
-uint16_t req_bank_cnt;
-uint8_t req_percent;
-uint8_t req_percent_last;
-uint8_t req_state = REQ_STATUS_IDLE;
-uint8_t rx_remaining = 0;
-uint8_t tx_remaining = 0;
-uint16_t sync_errors = 0;
-uint8_t tx_buffer[32];
-uint8_t data_buffer[4];
-uint32_t addr;
-uint16_t crc = 0;
-uint8_t loader_enabled = 1;
-
+typedef struct system_t {
+    uint8_t bus_mode;
+    uint8_t rom_mode;
+    uint8_t req_bank;
+} system_t;
 
+usb_transaction_t usb_trans;
 
 usbMsgLen_t usbFunctionSetup(uchar data[8])
 {
@@ -85,129 +72,139 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
 
     if (rq->bRequest == USB_BULK_UPLOAD_INIT) {
 
-        req_bank = 0;
-        rx_remaining = 0;
+        usb_trans.req_bank = 0;
+        usb_trans.rx_remaining = 0;
         debug_P(DEBUG_USB, PSTR("USB_BULK_UPLOAD_INIT: %i %i\n"), rq->wValue.word,
               rq->wIndex.word);
-        req_bank_size = (uint32_t) (1L << rq->wValue.word);
-        req_bank_cnt = rq->wIndex.word;
-        req_addr_end = (uint32_t) req_bank_size *req_bank_cnt;
-        req_percent = 0;
-        req_percent_last = 0;
-        sync_errors = 0;
+        usb_trans.req_bank_size = (uint32_t) (1L << rq->wValue.word);
+        usb_trans.req_bank_cnt = rq->wIndex.word;
+        usb_trans.req_addr_end = (uint32_t) usb_trans.req_bank_size * usb_trans.req_bank_cnt;
+        usb_trans.req_percent = 0;
+        usb_trans.req_percent_last = 0;
+        usb_trans.sync_errors = 0;
         debug_P(DEBUG_USB,
               PSTR("USB_BULK_UPLOAD_INIT: bank_size=0x%08lx bank_cnt=0x%x end_addr=0x%08lx\n"),
-              req_bank_size, req_bank_cnt, req_addr_end);
+              usb_trans.req_bank_size, usb_trans.req_bank_cnt, usb_trans.req_addr_end);
 
         shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_START, 0);
-        shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, req_bank_cnt);
-        if (req_addr == 0x000000) {
+        shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, usb_trans.req_bank_cnt);
+#if DO_TIMER
+        if (usb_trans.req_addr == 0x000000) {
             timer_start();
         }
+#endif       
         /*
          * -------------------------------------------------------------------------
          */
     } else if (rq->bRequest == USB_BULK_UPLOAD_ADDR) {
 
-        req_state = REQ_STATUS_BULK_UPLOAD;
-        req_addr = rq->wValue.word;
-        req_addr = req_addr << 16;
-        req_addr = req_addr | rq->wIndex.word;
-        rx_remaining = rq->wLength.word;
+        usb_trans.req_state = REQ_STATUS_BULK_UPLOAD;
+        usb_trans.req_addr = rq->wValue.word;
+        usb_trans.req_addr = usb_trans.req_addr << 16;
+        usb_trans.req_addr = usb_trans.req_addr | rq->wIndex.word;
+        usb_trans.rx_remaining = rq->wLength.word;
 
         
 
-        if (req_addr && req_addr % req_bank_size == 0) {
+        if (usb_trans.req_addr && usb_trans.req_addr % usb_trans.req_bank_size == 0) {
+#if DO_TIMER
+
 #ifdef FLT_DEBUG
             debug_P(DEBUG_USB,
                   PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
-                  req_bank, req_addr, timer_stop());
+                  usb_trans.req_bank, usb_trans.req_addr, timer_stop());
 #else
             debug_P(DEBUG_USB,
                   PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n"),
-                  req_bank, req_addr, timer_stop_int());
+                  usb_trans.req_bank, usb_trans.req_addr, timer_stop_int());
 #endif
-            req_bank++;
-            timer_start();
+              timer_start();
+#endif
+            usb_trans.req_bank++;
 
+        } else {
+            sram_bulk_write_start(usb_trans.req_addr);
         }
-        sram_bulk_write_start(req_addr);
-
         ret_len = USB_MAX_TRANS;
 
         /*
          * -------------------------------------------------------------------------
          */
     } else if (rq->bRequest == USB_BULK_UPLOAD_NEXT) {
-        req_state = REQ_STATUS_BULK_UPLOAD;
-        req_addr = rq->wValue.word;
-        req_addr = req_addr << 16;
-        req_addr = req_addr | rq->wIndex.word;
-        rx_remaining = rq->wLength.word;
-
-        req_percent = (uint32_t)( 100 * req_addr )  / req_addr_end;
-        if (req_percent!=req_percent_last){
-            shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, req_percent);
+        usb_trans.req_state = REQ_STATUS_BULK_UPLOAD;
+        usb_trans.req_addr = rq->wValue.word;
+        usb_trans.req_addr = usb_trans.req_addr << 16;
+        usb_trans.req_addr = usb_trans.req_addr | rq->wIndex.word;
+        usb_trans.rx_remaining = rq->wLength.word;
+
+#if DO_SHM
+        usb_trans.req_percent = (uint32_t)( 100 * usb_trans.req_addr )  / usb_trans.req_addr_end;
+        if (usb_trans.req_percent!=usb_trans.req_percent_last){
+            shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, usb_trans.req_percent);
         }
-        req_percent_last = req_percent;
+        usb_trans.req_percent_last = usb_trans.req_percent;
+        shared_memory_scratchpad_region_save_helper(usb_trans.req_addr);
+#endif        
+        if (usb_trans.req_addr && (usb_trans.req_addr % usb_trans.req_bank_size) == 0) {
+#if DO_TIMER
 
-        shared_memory_scratchpad_region_save_helper(req_addr);
-        
-        if (req_addr && (req_addr % req_bank_size) == 0) {
 #ifdef FLT_DEBUG
             debug_P(DEBUG_USB,
                   PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
-                  req_bank, req_addr, timer_stop());
+                  usb_trans.req_bank, usb_trans.req_addr, timer_stop());
 #else
             debug_P(DEBUG_USB,
                   PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n"),
-                  req_bank, req_addr, timer_stop_int());
+                  usb_trans.req_bank, usb_trans.req_addr, timer_stop_int());
+#endif
+              timer_start();
+#endif
+            usb_trans.req_bank++;
+#if DO_SHM
+            shared_memory_write(SHARED_MEM_TX_CMD_BANK_CURRENT, usb_trans.req_bank);
 #endif
-            req_bank++;
-            timer_start();
-            shared_memory_write(SHARED_MEM_TX_CMD_BANK_CURRENT, req_bank);
-
         }
         ret_len = USB_MAX_TRANS;
         /*
          * -------------------------------------------------------------------------
          */
     } else if (rq->bRequest == USB_BULK_UPLOAD_END) {
-        if (req_state != REQ_STATUS_BULK_UPLOAD) {
+        if (usb_trans.req_state != REQ_STATUS_BULK_UPLOAD) {
             debug_P(DEBUG_USB,
                   PSTR("USB_BULK_UPLOAD_END: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"));
             return 0;
         }
         debug_P(DEBUG_USB, PSTR("USB_BULK_UPLOAD_END:\n"));
-        req_state = REQ_STATUS_IDLE;
+        usb_trans.req_state = REQ_STATUS_IDLE;
         sram_bulk_write_end();
+#if DO_SHM
         shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_END, 0);
+#endif
         ret_len = 0;
 
         /*
          * -------------------------------------------------------------------------
          */
     } else if (rq->bRequest == USB_CRC) {
-        req_addr = rq->wValue.word;
-        req_addr = req_addr << 16;
-        req_addr = req_addr | rq->wIndex.word;
-        debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"), req_addr);
-        crc_check_bulk_memory(0x000000, req_addr, req_bank_size);
+        usb_trans.req_addr = rq->wValue.word;
+        usb_trans.req_addr = usb_trans.req_addr << 16;
+        usb_trans.req_addr = usb_trans.req_addr | rq->wIndex.word;
+        debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"), usb_trans.req_addr);
+        crc_check_bulk_memory(0x000000, usb_trans.req_addr, usb_trans.req_bank_size);
         ret_len = 0;
         /*
          * -------------------------------------------------------------------------
          */
     } else if (rq->bRequest == USB_MODE_SNES) {
-        req_state = REQ_STATUS_SNES;
+        usb_trans.req_state = REQ_STATUS_SNES;
         debug_P(DEBUG_USB, PSTR("USB_MODE_SNES:\n"));
         ret_len = 0;
-        pwm_stop();
         
         /*
          * -------------------------------------------------------------------------
          */
     } else if (rq->bRequest == USB_MODE_AVR) {
-        req_state = REQ_STATUS_AVR;
+        usb_trans.req_state = REQ_STATUS_AVR;
         debug_P(DEBUG_USB, PSTR("USB_MODE_AVR:\n"));
         ret_len = 0;
         /*
@@ -220,96 +217,29 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
         /*
          * -------------------------------------------------------------------------
          */
-
-    } else if (rq->bRequest == USB_CRC_ADDR) {
-        req_state = REQ_STATUS_CRC;
-        req_addr = rq->wValue.word;
-        req_addr = req_addr << 16;
-        req_addr = req_addr | rq->wIndex.word;
-        debug_P(DEBUG_USB, PSTR("USB_CRC_ADDR: addr=0x%lx size=%i\n"), req_addr,
-              rq->wLength.word);
-        req_size = rq->wLength.word;
-        req_size = req_size << 2;
-        tx_remaining = 2;
-        debug_P(DEBUG_USB, PSTR("USB_CRC_ADDR: addr=0x%lx size=%li\n"), req_addr,
-              req_size);
-
-        crc = crc_check_memory_range(req_addr, req_size, read_buffer);
-        tx_buffer[0] = crc & 0xff;
-        tx_buffer[1] = (crc >> 8) & 0xff;
-        ret_len = 2;
-        req_state = REQ_STATUS_IDLE;
-        
-        
     } else if (rq->bRequest == USB_SET_LAODER) {
-        loader_enabled = rq->wValue.word;
+        usb_trans.loader_enabled = rq->wValue.word;
         ret_len = 0;
     }
-
-    usbMsgPtr = data_buffer;
-    return ret_len;             /* default for not implemented requests: return no data back to host */
+    usbMsgPtr = usb_trans.rx_buffer;
+    return ret_len;             
 }
 
-
 /*
  * ------------------------------------------------------------------------- 
  */
 
 
-void boot_startup_rom(uint16_t init_delay)
-{
-    info_P(PSTR("Fetch loader rom\n"));
-    info_P(PSTR("Activate AVR bus\n"));
-    avr_bus_active();
-    info_P(PSTR("IRQ off\n"));
-    snes_irq_lo();
-    snes_irq_off();
-    snes_lorom();
-    rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
-    info_P(PSTR("\n"));
-
-#if DO_CRC_CHECK_LOADER     
-    dump_memory(0x010000 - 0x100, 0x010000);
-    uint16_t crc;
-    crc = crc_check_bulk_memory((uint32_t)0x000000,0x010000, 0x010000);
-    info(PSTR("crc=%x\n"),crc);
-#endif
-
-    snes_irq_lo();
-    snes_irq_off();
-    snes_hirom();
-    snes_wr_disable();
-    
-    snes_bus_active();
-    info_P(PSTR("Activate SNES bus\n"));
-    send_reset();
-    _delay_ms(init_delay);
-}
-
-void banner(){
-    uint8_t i;
-    for (i=0;i<40;i++)
-        info_P(PSTR("\n"));
-    info_P(PSTR(" ________        .__        __    ________               ____  ________\n"));
-    info_P(PSTR(" \\_____  \\  __ __|__| ____ |  | __\\______ \\   _______  _/_   |/  _____/\n"));
-    info_P(PSTR("  /  / \\  \\|  |  \\  |/ ___\\|  |/ / |    |  \\_/ __ \\  \\/ /|   /   __  \\ \n"));
-    info_P(PSTR(" /   \\_/.  \\  |  /  \\  \\___|    <  |    `   \\  ___/\\   / |   \\  |__\\  \\ \n"));
-    info_P(PSTR(" \\_____\\ \\_/____/|__|\\___  >__|_ \\/_______  /\\___  >\\_/  |___|\\_____  / \n"));
-    info_P(PSTR("        \\__>             \\/     \\/        \\/     \\/                 \\/ \n"));
-    info_P(PSTR("\n"));
-    info_P(PSTR("                               www.optixx.org\n"));
-    info_P(PSTR("\n"));
-    info_P(PSTR("System Hw: %s Sw: %s\n"),HW_VERSION,SW_VERSION);
-    
-}
-
 void globals_init(){
-    req_addr = 0;
-    req_addr_end = 0;
-    req_state = REQ_STATUS_IDLE;
-    rx_remaining = 0;
-    tx_remaining = 0;
-    sync_errors = 0;
+    memset(&usb_trans,0,sizeof(usb_transaction_t));
+    
+    usb_trans.req_addr = 0;
+    usb_trans.req_addr_end = 0;
+    usb_trans.req_state = REQ_STATUS_IDLE;
+    usb_trans.rx_remaining = 0;
+    usb_trans.tx_remaining = 0;
+    usb_trans.sync_errors = 0;
+    usb_trans.loader_enabled = 1;
 }
 
 int main(void)
@@ -341,13 +271,15 @@ int main(void)
         snes_wr_disable();
         sei();
         info_P(PSTR("USB poll\n"));
-        while (req_state != REQ_STATUS_SNES) {
+        while (usb_trans.req_state != REQ_STATUS_SNES) {
             usbPoll();
             shell_run();
         }
         
+#if DO_SHM
         
         shared_memory_write(SHARED_MEM_TX_CMD_TERMINATE, 0);
+#endif
 
 #if DO_SHM_SCRATCHPAD
         shared_memory_scratchpad_region_tx_restore();
@@ -356,7 +288,7 @@ int main(void)
 
 #if DO_CRC_CHECK     
         info_P(PSTR("-->CRC Check\n"));
-        crc_check_bulk_memory(0x000000, req_bank_size * req_bank_cnt, req_bank_size);
+        crc_check_bulk_memory(0x000000, usb_trans.req_bank_size * usb_trans.req_bank_cnt, usb_trans.req_bank_size);
 #endif        
         
         info_P(PSTR("-->Switch TO SNES\n"));
@@ -368,24 +300,20 @@ int main(void)
         irq_stop();
         send_reset();
         info_P(PSTR("Poll USB\n"));
-        while ((req_state != REQ_STATUS_AVR)) {
+        while ((usb_trans.req_state != REQ_STATUS_AVR)) {
             usbPoll();
             shell_run();
         }
         info_P(PSTR("-->Switch TO AVR\n"));
-        
         shared_memory_init();
         irq_init();
-        
-        if(loader_enabled)
+        if(usb_trans.loader_enabled)
             boot_startup_rom(500);
         else
         {
             avr_bus_active();
             send_reset();
         }
-        
-        
     }
     return 0;
 }

+ 18 - 5
avr/usbload/pwm.c

@@ -30,17 +30,17 @@
 
 #define PWM_SINE_MAX 64
 #define PWM_OVERFLOW_MAX 1024
-uint8_t pwm_sine_table[] = {
+uint8_t pwm_sine_table[]  = {
 0x7f,0x8b,0x97,0xa4,0xaf,0xbb,0xc5,0xcf,0xd9,0xe1,0xe8,0xef,0xf4,0xf8,0xfb,0xfd,
 0xfd,0xfd,0xfb,0xf8,0xf3,0xee,0xe7,0xe0,0xd7,0xce,0xc4,0xb9,0xae,0xa2,0x96,0x89,
 0x7e,0x71,0x65,0x59,0x4d,0x42,0x37,0x2d,0x24,0x1c,0x15,0x0f,0x09,0x05,0x03,0x01,
 0x01,0x01,0x03,0x07,0x0b,0x11,0x17,0x1f,0x28,0x31,0x3b,0x46,0x52,0x5e,0x6a,0x76
 };
 
- volatile uint8_t pwm_setting;                    // Einstellungen für die einzelnen PWM-Kanäle
- volatile uint16_t pwm_overflow;                    // Einstellungen für die einzelnen PWM-Kanäle
- volatile uint8_t pwm_idx;                    // Einstellungen für die einzelnen PWM-Kanäle
- volatile uint16_t pwm_overflow_max;                    // Einstellungen für die einzelnen PWM-Kanäle
+volatile uint8_t pwm_setting;                   
+volatile uint16_t pwm_overflow;                    
+volatile uint8_t pwm_idx;                    
+volatile uint16_t pwm_overflow_max;                    
  
  ISR(TIMER2_COMPA_vect) {
     static uint8_t pwm_cnt=0;
@@ -67,6 +67,19 @@ void pwm_speed(uint16_t val) {
     pwm_overflow_max = val; 
 }
 
+void pwm_speed_slow(uint16_t val) {
+    pwm_overflow_max = PWM_OVERFLOW_MAX * 2 ; 
+}
+
+void pwm_speed_fast(uint16_t val) {
+    pwm_overflow_max = PWM_OVERFLOW_MAX / 2; 
+}
+
+void pwm_speed_normal(uint16_t val) {
+    pwm_overflow_max = PWM_OVERFLOW_MAX; 
+}
+
+
 void pwm_set(uint8_t val) {
     pwm_setting = val;
 }

+ 17 - 0
avr/usbload/requests.h

@@ -40,4 +40,21 @@
 #define USB_AVR_RESET           12
 #define USB_SET_LAODER          13
 
+typedef struct usb_transaction_t {
+    uint32_t req_addr;
+    uint32_t req_addr_end;
+    uint8_t req_bank;
+    uint32_t req_bank_size;
+    uint16_t req_bank_cnt;
+    uint8_t req_percent;
+    uint8_t req_percent_last;
+    uint8_t req_state;
+    uint8_t rx_remaining;
+    uint8_t tx_remaining ;
+    uint16_t sync_errors;
+    uint8_t tx_buffer[32];
+    uint8_t rx_buffer[8];
+    uint8_t loader_enabled;
+} usb_transaction_t;
+
 #endif /* __REQUESTS_H_INCLUDED__ */

+ 2 - 2
avr/usbload/shared_memory.h

@@ -37,7 +37,7 @@
 #define SHARED_MEM_TX_CMD_TERMINATE         0x06
 
 #define SHARED_MEM_TX_LOC_STATE             0x000000
-#define SHARED_MEM_TX_LOC_SIZE              0x000100
+#define SHARED_MEM_TX_LOC_SIZE              0x000040
 #define SHARED_MEM_TX_LOC_CMD               0x000001
 #define SHARED_MEM_TX_LOC_PAYLOAD           0x000002
 
@@ -48,7 +48,7 @@
 #define SHARED_MEM_RX_CMD_FILESEL           0x01
 
 #define SHARED_MEM_RX_LOC_STATE             0x001000
-#define SHARED_MEM_RX_LOC_SIZE              0x000100
+#define SHARED_MEM_RX_LOC_SIZE              0x000040
 #define SHARED_MEM_RX_LOC_CMD               0x001001
 #define SHARED_MEM_RX_LOC_LEN               0x001002
 #define SHARED_MEM_RX_LOC_PAYLOAD           0x001003

+ 134 - 28
avr/usbload/shell.c

@@ -35,10 +35,17 @@
 #include "uart.h"
 #include "dump.h"
 #include "irq.h"
+#include "config.h"
+#include "crc.h"
+#include "command.h"
+#include "shared_memory.h"
+
  
-#define RECEIVE_BUF_LEN 40
+
  
-uint8_t			recv_buf[RECEIVE_BUF_LEN];
+uint8_t command_buf[RECEIVE_BUF_LEN];
+uint8_t	recv_buf[RECEIVE_BUF_LEN];
+
 volatile uint8_t	recv_counter = 0;
 volatile uint8_t	cr = 0;
 
@@ -54,11 +61,11 @@ uint8_t *get_token(void)
  	token_ptr = p;
  	do {
  		token_ptr++;
- 		if (*token_ptr == ' ') {
+ 		if (*token_ptr == ' ' || *token_ptr == '\n' || *token_ptr == '\r') {
  			*token_ptr++ = '\0';
  			break;
  		}
- 	} while (*token_ptr != '\0');
+ 	} while (*token_ptr != ' ' && *token_ptr != '\n' && *token_ptr != '\r');
  	return p;
 }
 
@@ -79,8 +86,6 @@ uint8_t get_dec(uint32_t *decval)
 uint8_t parse_hex(const uint8_t *s, uint32_t *hexval)
 {
  	uint32_t x = util_sscanhex(s);
- 	if (x > 0xffffff)
- 		return 0;
  	*hexval = (uint32_t) x;
  	return 1;
  }
@@ -107,7 +112,7 @@ uint8_t get_hex_arg3(uint32_t *hexval1, uint32_t *hexval2, uint32_t *hexval3)
 static uint8_t get_int32(uint32_t *val)
  {
  	if (!get_hex(val)){
- 		printf("Invalid argument!\n");
+ 		info_P(PSTR("Invalid argument!\n"));
         return 0;
     } else {
         return 1;
@@ -118,7 +123,7 @@ static uint8_t get_int32(uint32_t *val)
  {
  	uint32_t ret;
  	if (!get_hex(&ret) ||ret > 0xff){
- 		printf("Invalid argument!\n");
+ 		info_P(PSTR("Invalid argument!\n"));
         return 0;
  	}else{
  		*val = (uint8_t)ret;
@@ -135,14 +140,13 @@ static uint8_t get_int32(uint32_t *val)
  		if (result >= 0)
  			return result;
  	}
- 	printf("Invalid argument (should be 0 or 1)!\n");
+ 	info_P(PSTR("Invalid argument (should be 0 or 1)!\n"));
  	return -1;
  } 
  void prompt(void){
      
      uart_putc('\r');
      uart_putc('\n');
-     uart_putc(':');
      uart_putc('>');
      
  }
@@ -176,8 +180,55 @@ ISR(USART0_RX_vect)		//	Interrupt for UART Byte received
   UCSR0B |= (1<<RXCIE0);//	Interrupts enable for RxD
 }
 
+enum cmds { CMD_DUMP,
+            CMD_CRC,
+            CMD_EXIT,
+            CMD_RESET,
+            CMD_IRQ,
+            CMD_AVR,
+            CMD_SNES,
+            CMD_LOROM,
+            CMD_HIROM,
+            CMD_WR,
+            CMD_SHMWR,
+            CMD_SHMSAVE,
+            CMD_SHMRESTORE,
+            CMD_LOADER,
+            CMD_RECONNECT,
+            CMD_STATUS,
+            CMD_HELP
+};
 
-uint8_t command_buf[RECEIVE_BUF_LEN];
+uint8_t cmdlist[][CMD_HELP] PROGMEM = {
+            {"DUMP"},
+            {"CRC"},
+            {"EXIT"},
+            {"RESET"},
+            {"IRQ"},
+            {"AVR"},
+            {"SNES"},
+            {"LOROM"},
+            {"HIROM"},
+            {"WR"},
+            {"SHMWR"},
+            {"SHMSAVE"},
+            {"SHMRESTORE"},
+            {"LOADER"},
+            {"RECONNECT"},
+            {"STATUS"},
+            {"HELP"},
+        };
+
+
+void shell_help(void){
+	uint8_t i;
+    info_P(PSTR("\n"));
+    for (i=CMD_DUMP; i<CMD_HELP; i++){
+        info_P((PGM_P)cmdlist[i]);
+        info_P(PSTR("\n"));
+        
+    }
+}
 
 void shell_run(void)
 {
@@ -185,6 +236,7 @@ void shell_run(void)
     uint32_t arg1;
     uint32_t arg2;
     uint32_t arg3;
+	uint16_t crc;
     
 	if (!cr)
         return;
@@ -195,36 +247,90 @@ void shell_run(void)
 	t = get_token();
 	
 	if (t == NULL)
-		return;
+        shell_help();
 
 	util_strupper(t);
 
-	if (strcmp((char*)t, "DUMP") == 0) {
+	if (strcmp_P((const char*)t,(PGM_P)cmdlist[CMD_DUMP]) == 0) {
         if (get_hex_arg2(&arg1,&arg2))
             dump_memory(arg1,arg2);
         else 
-            printf("DUMP <start addr> <end addr> %i %i\n",arg1,arg2);
-    }
-	else if (strcmp((char*)t, "RESET") == 0) {
+            info_P(PSTR("DUMP <start addr> <end addr>\n"));
+    
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_CRC]) == 0) {
+        if (get_hex_arg2(&arg1,&arg2)){
+            crc = crc_check_bulk_memory(arg1,arg2,0x8000);
+            info_P(PSTR("0x%06lx - 0x%06lx crc=0x%04x\n"),arg1,arg2,crc);
+        } else 
+            info_P(PSTR("CRC <start addr> <end addr>\n"));
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_EXIT]) == 0) {
         leave_application();
-    }
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_RESET]) == 0) {
+        send_reset();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_IRQ]) == 0) {
+        info_P(PSTR("Send IRQ\n"));
+        snes_irq_on();
+        snes_irq_lo();
+        _delay_us(20);
+        snes_irq_hi();
+        snes_irq_off();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_AVR]) == 0) {
+         info_P(PSTR("Activate AVR bus\n"));
+         avr_bus_active();
+         snes_irq_lo();
+         snes_irq_off();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_SNES]) == 0) {
+        info_P(PSTR("Activate SNES bus\n"));
+        snes_irq_lo();
+        snes_irq_off();
+        snes_wr_disable();
+        snes_bus_active();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_LOROM]) == 0) {
+        info_P(PSTR("Set LOROM\n"));
+        snes_lorom();
+        snes_wr_disable();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_HIROM]) == 0) {
+        info_P(PSTR("Set HIROM\n"));
+        snes_hirom();
+        snes_wr_disable();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_WR]) == 0) {
+        arg1 = get_bool();
+        if(arg1==1){
+            info_P(PSTR("Set WR enable"));
+            snes_wr_enable();
+        }else if (arg1==0){
+            info_P(PSTR("Set WR disable"));
+            snes_wr_disable();
+        }
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_SHMWR]) == 0) {
+        if (get_hex_arg2(&arg1,&arg2))
+            shared_memory_write((uint8_t)arg1, (uint8_t)arg1);
+        else 
+            info_P(PSTR("SHMWR <command> <value>\n"));
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_SHMSAVE]) == 0) {
+        shared_memory_scratchpad_region_tx_save();
+        shared_memory_scratchpad_region_rx_save();
+        info_P(PSTR("Save scratchpad\n"));
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_SHMRESTORE]) == 0) {
+        shared_memory_scratchpad_region_tx_restore();
+        shared_memory_scratchpad_region_rx_restore();
+        info_P(PSTR("Restore scratchpad\n"));
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_LOADER]) == 0) {
+        boot_startup_rom(500);    
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_RECONNECT]) == 0) {
+        usb_connect();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_STATUS]) == 0) {
+            transaction_status();
+    }else if (strcmp_P((char*)t, (PGM_P)cmdlist[CMD_HELP]) == 0) {
+        shell_help();
+    }    
     prompt();
-    
     /*
-    reset
-    reset snes
     dias
-    switch to avr mode
-    swicth to snes mode
-    send irq
-    crc
     set irq vector
     set reset vector
-    set rom mode
+    dump cart header
     */
-    
-    
-    
 }
 
 

+ 2 - 1
avr/usbload/sram.c

@@ -232,8 +232,8 @@ void sram_bulk_write_start(uint32_t addr)
 
 inline void sram_bulk_write_next(void)
 {
+    AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
     addr_current++;
-    AVR_WR_PORT |= (1 << AVR_WR_PIN);
     counter_up();
 }
 
@@ -241,6 +241,7 @@ inline void sram_bulk_write( uint8_t data)
 {
     AVR_WR_PORT &= ~(1 << AVR_WR_PIN);
     AVR_DATA_PORT = data;
+    AVR_WR_PORT |= (1 << AVR_WR_PIN);
 }
 
 void sram_bulk_write_end(void)

+ 13 - 21
avr/usbload/usb_bulk.c

@@ -39,32 +39,24 @@
 #include "crc.h"
 #include "usb_bulk.h"
 
-extern uint8_t read_buffer[TRANSFER_BUFFER_SIZE];
-extern uint32_t req_addr;
-extern uint32_t req_size;
-extern uint8_t req_bank;
-extern uint32_t req_bank_size;
-extern uint8_t req_state;
-extern uint8_t rx_remaining; 
-extern uint8_t tx_remaining;
-extern  uint8_t tx_buffer[32];
-extern uint16_t crc;
+
+extern usb_transaction_t usb_trans;
 
 uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
 {
     uint8_t *ptr;
     uint8_t  i;
     
-    if (len > rx_remaining) {
+    if (len > usb_trans.rx_remaining) {
         info_P(PSTR("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n"),
-               rx_remaining, len);
-        len = rx_remaining;
+                usb_trans.rx_remaining, len);
+        len =  usb_trans.rx_remaining;
     }
-    if (req_state == REQ_STATUS_BULK_UPLOAD) {
+    if (usb_trans.req_state == REQ_STATUS_BULK_UPLOAD) {
 
-        rx_remaining -= len;
+        usb_trans.rx_remaining -= len;
         debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n"),
-               req_addr, len, rx_remaining);
+                usb_trans.req_addr, len,  usb_trans.rx_remaining);
         ptr = data;
         i = len;
         while(i--){
@@ -78,13 +70,13 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
 uint8_t usbFunctionRead(uint8_t * data, uint8_t len)
 {
     uint8_t i;
-    if (len > tx_remaining)
-        len = tx_remaining;
-    tx_remaining -= len;
-    debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionRead len=%i tx_remaining=%i \n"), len, tx_remaining);
+    if (len >  usb_trans.tx_remaining)
+        len =  usb_trans.tx_remaining;
+     usb_trans.tx_remaining -= len;
+    debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionRead len=%i tx_remaining=%i \n"), len, usb_trans.tx_remaining);
 
     for (i = 0; i < len; i++) {
-        *data = tx_buffer[len];
+        *data =  usb_trans.tx_buffer[len];
         data++;
     }
     return len;

+ 1 - 1
avr/usbload/usbconfig.h

@@ -127,7 +127,7 @@ section at the end of this file).
  * (e.g. HID), but never want to send any data. This option saves a couple
  * of bytes in flash memory and the transmit buffers in RAM.
  */
-#define USB_CFG_INTR_POLL_INTERVAL      200
+#define USB_CFG_INTR_POLL_INTERVAL      20
 /* If you compile a version with endpoint 1 (interrupt-in), this is the poll
  * interval. The value is in milliseconds and must not be less than 10 ms for
  * low speed devices.

+ 1 - 1
avr/usbload/util.c

@@ -101,7 +101,7 @@ uint32_t util_sscandec(const uint8_t *s)
 
 uint32_t util_sscanhex(const uint8_t *s)
 {
-	uint32_t result;
+	int32_t result;
 	if (*s == '\0')
 		return -1;
 	result = 0;

+ 404 - 42
quickdev16.tmproj

@@ -21,6 +21,48 @@
 	<integer>271</integer>
 	<key>metaData</key>
 	<dict>
+		<key>avr/usbload/command.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>141</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>94</integer>
+		</dict>
+		<key>avr/usbload/command.h</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>26</integer>
+				<key>line</key>
+				<integer>30</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>0</integer>
+		</dict>
+		<key>avr/usbload/config.h</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>5</integer>
+				<key>line</key>
+				<integer>45</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>10</integer>
+		</dict>
 		<key>avr/usbload/crc.c</key>
 		<dict>
 			<key>caret</key>
@@ -40,69 +82,95 @@
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>0</integer>
+				<integer>5</integer>
 				<key>line</key>
 				<integer>26</integer>
 			</dict>
-			<key>columnSelection</key>
-			<false/>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
 			<integer>0</integer>
-			<key>selectFrom</key>
+		</dict>
+		<key>avr/usbload/debug.h</key>
+		<dict>
+			<key>caret</key>
 			<dict>
 				<key>column</key>
 				<integer>0</integer>
 				<key>line</key>
-				<integer>25</integer>
+				<integer>0</integer>
 			</dict>
-			<key>selectTo</key>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>2</integer>
+		</dict>
+		<key>avr/usbload/dump.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>15</integer>
+				<key>line</key>
+				<integer>28</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>36</integer>
+		</dict>
+		<key>avr/usbload/dump.h</key>
+		<dict>
+			<key>caret</key>
 			<dict>
 				<key>column</key>
 				<integer>0</integer>
 				<key>line</key>
-				<integer>26</integer>
+				<integer>3</integer>
 			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>0</integer>
 		</dict>
-		<key>avr/usbload/dump.c</key>
+		<key>avr/usbload/irq.c</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>12</integer>
+				<integer>10</integer>
 				<key>line</key>
-				<integer>67</integer>
+				<integer>53</integer>
 			</dict>
 			<key>columnSelection</key>
 			<false/>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>35</integer>
+			<integer>25</integer>
 			<key>selectFrom</key>
 			<dict>
 				<key>column</key>
 				<integer>5</integer>
 				<key>line</key>
-				<integer>67</integer>
+				<integer>53</integer>
 			</dict>
 			<key>selectTo</key>
 			<dict>
 				<key>column</key>
-				<integer>16</integer>
+				<integer>22</integer>
 				<key>line</key>
-				<integer>67</integer>
+				<integer>53</integer>
 			</dict>
 		</dict>
-		<key>avr/usbload/main.c</key>
+		<key>avr/usbload/irq.h</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>0</integer>
+				<integer>19</integer>
 				<key>line</key>
-				<integer>28</integer>
+				<integer>26</integer>
 			</dict>
 			<key>columnSelection</key>
 			<false/>
@@ -113,17 +181,101 @@
 			<key>selectFrom</key>
 			<dict>
 				<key>column</key>
-				<integer>0</integer>
+				<integer>5</integer>
 				<key>line</key>
-				<integer>22</integer>
+				<integer>26</integer>
 			</dict>
 			<key>selectTo</key>
+			<dict>
+				<key>column</key>
+				<integer>22</integer>
+				<key>line</key>
+				<integer>26</integer>
+			</dict>
+		</dict>
+		<key>avr/usbload/loader.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>80</integer>
+				<key>line</key>
+				<integer>18</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>734</integer>
+		</dict>
+		<key>avr/usbload/main.c</key>
+		<dict>
+			<key>caret</key>
 			<dict>
 				<key>column</key>
 				<integer>0</integer>
 				<key>line</key>
-				<integer>28</integer>
+				<integer>74</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>46</integer>
+		</dict>
+		<key>avr/usbload/pwm.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>25</integer>
+				<key>line</key>
+				<integer>32</integer>
 			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>20</integer>
+		</dict>
+		<key>avr/usbload/pwm.h</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>20</integer>
+				<key>line</key>
+				<integer>33</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>0</integer>
+		</dict>
+		<key>avr/usbload/requests.h</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>20</integer>
+				<key>line</key>
+				<integer>56</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>9</integer>
+		</dict>
+		<key>avr/usbload/rle.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>40</integer>
+				<key>line</key>
+				<integer>99</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>55</integer>
 		</dict>
 		<key>avr/usbload/rle.h</key>
 		<dict>
@@ -155,40 +307,70 @@
 				<integer>0</integer>
 			</dict>
 		</dict>
-		<key>avr/usbload/shared_memory.h</key>
+		<key>avr/usbload/shared_memory.c</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>45</integer>
+				<integer>0</integer>
 				<key>line</key>
-				<integer>24</integer>
+				<integer>70</integer>
 			</dict>
+			<key>columnSelection</key>
+			<false/>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
+			<integer>61</integer>
+			<key>selectFrom</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>64</integer>
+			</dict>
+			<key>selectTo</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>70</integer>
+			</dict>
+		</dict>
+		<key>avr/usbload/shared_memory.h</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>52</integer>
+				<key>line</key>
+				<integer>50</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
 			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>29</integer>
 		</dict>
 		<key>avr/usbload/shell.c</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>41</integer>
+				<integer>0</integer>
 				<key>line</key>
-				<integer>177</integer>
+				<integer>43</integer>
 			</dict>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>154</integer>
+			<integer>30</integer>
 		</dict>
 		<key>avr/usbload/shell.h</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>0</integer>
+				<integer>22</integer>
 				<key>line</key>
 				<integer>23</integer>
 			</dict>
@@ -211,7 +393,7 @@
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>206</integer>
+			<integer>215</integer>
 			<key>selectFrom</key>
 			<dict>
 				<key>column</key>
@@ -227,6 +409,34 @@
 				<integer>287</integer>
 			</dict>
 		</dict>
+		<key>avr/usbload/timer.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>6</integer>
+				<key>line</key>
+				<integer>80</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>47</integer>
+		</dict>
+		<key>avr/usbload/timer.h</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>29</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>0</integer>
+		</dict>
 		<key>avr/usbload/uart.c</key>
 		<dict>
 			<key>caret</key>
@@ -241,6 +451,36 @@
 			<key>firstVisibleLine</key>
 			<integer>26</integer>
 		</dict>
+		<key>avr/usbload/usb_bulk.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>43</integer>
+			</dict>
+			<key>columnSelection</key>
+			<false/>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>16</integer>
+			<key>selectFrom</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>42</integer>
+			</dict>
+			<key>selectTo</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>43</integer>
+			</dict>
+		</dict>
 		<key>avr/usbload/usb_bulk.h</key>
 		<dict>
 			<key>caret</key>
@@ -255,51 +495,77 @@
 			<key>firstVisibleLine</key>
 			<integer>0</integer>
 		</dict>
-		<key>avr/usbload/util.c</key>
+		<key>avr/usbload/usbconfig.h</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>1</integer>
+				<integer>42</integer>
 				<key>line</key>
-				<integer>25</integer>
+				<integer>129</integer>
 			</dict>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
+			<integer>88</integer>
+		</dict>
+		<key>avr/usbload/util.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>116</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
 			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>84</integer>
 		</dict>
 		<key>avr/usbload/util.h</key>
 		<dict>
 			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>0</integer>
+				<integer>1</integer>
 				<key>line</key>
-				<integer>0</integer>
+				<integer>29</integer>
 			</dict>
-			<key>columnSelection</key>
-			<false/>
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
 			<integer>0</integer>
-			<key>selectFrom</key>
+		</dict>
+		<key>scripts/check_rle.py</key>
+		<dict>
+			<key>caret</key>
 			<dict>
 				<key>column</key>
-				<integer>3</integer>
+				<integer>14</integer>
 				<key>line</key>
-				<integer>18</integer>
+				<integer>9</integer>
 			</dict>
-			<key>selectTo</key>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>0</integer>
+		</dict>
+		<key>snes/banktest/LoadGraphics.asm</key>
+		<dict>
+			<key>caret</key>
 			<dict>
 				<key>column</key>
 				<integer>0</integer>
 				<key>line</key>
 				<integer>0</integer>
 			</dict>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>0</integer>
 		</dict>
-		<key>snes/banktest/LoadGraphics.asm</key>
+		<key>snes/banktest/init.inc</key>
 		<dict>
 			<key>caret</key>
 			<dict>
@@ -311,9 +577,23 @@
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
+			<integer>211</integer>
+		</dict>
+		<key>tools/ucon64/src/backup/quickdev16.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>30</integer>
+				<key>line</key>
+				<integer>71</integer>
+			</dict>
+			<key>firstVisibleColumn</key>
 			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>181</integer>
 		</dict>
-		<key>snes/banktest/init.inc</key>
+		<key>tools/ucon64/src/backup/smsgg-pro.h</key>
 		<dict>
 			<key>caret</key>
 			<dict>
@@ -325,19 +605,70 @@
 			<key>firstVisibleColumn</key>
 			<integer>0</integer>
 			<key>firstVisibleLine</key>
-			<integer>211</integer>
+			<integer>0</integer>
+		</dict>
+		<key>tools/ucon64/src/console/snes.c</key>
+		<dict>
+			<key>caret</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>2695</integer>
+			</dict>
+			<key>columnSelection</key>
+			<false/>
+			<key>firstVisibleColumn</key>
+			<integer>0</integer>
+			<key>firstVisibleLine</key>
+			<integer>3814</integer>
+			<key>selectFrom</key>
+			<dict>
+				<key>column</key>
+				<integer>1</integer>
+				<key>line</key>
+				<integer>2887</integer>
+			</dict>
+			<key>selectTo</key>
+			<dict>
+				<key>column</key>
+				<integer>0</integer>
+				<key>line</key>
+				<integer>2695</integer>
+			</dict>
 		</dict>
 	</dict>
 	<key>openDocuments</key>
 	<array>
 		<string>avr/usbload/sram.c</string>
 		<string>avr/usbload/main.c</string>
+		<string>avr/usbload/usb_bulk.c</string>
+		<string>avr/usbload/usbconfig.h</string>
+		<string>avr/usbload/requests.h</string>
+		<string>avr/usbload/debug.h</string>
 		<string>avr/usbload/shell.c</string>
+		<string>tools/ucon64/src/backup/smsgg-pro.h</string>
+		<string>tools/ucon64/src/console/snes.c</string>
+		<string>tools/ucon64/src/backup/quickdev16.c</string>
+		<string>avr/usbload/config.h</string>
+		<string>avr/usbload/timer.c</string>
+		<string>avr/usbload/rle.c</string>
+		<string>avr/usbload/pwm.c</string>
+		<string>avr/usbload/loader.c</string>
+		<string>scripts/check_rle.py</string>
+		<string>avr/usbload/pwm.h</string>
+		<string>avr/usbload/shared_memory.c</string>
+		<string>avr/usbload/command.c</string>
+		<string>avr/usbload/command.h</string>
+		<string>avr/usbload/irq.c</string>
+		<string>avr/usbload/irq.h</string>
 		<string>avr/usbload/crc.c</string>
 		<string>avr/usbload/dump.c</string>
 		<string>avr/usbload/debug.c</string>
+		<string>avr/usbload/dump.h</string>
 		<string>avr/usbload/uart.c</string>
 		<string>avr/usbload/util.c</string>
+		<string>avr/usbload/timer.h</string>
 		<string>avr/usbload/util.h</string>
 		<string>avr/usbload/usb_bulk.h</string>
 		<string>avr/usbload/rle.h</string>
@@ -378,6 +709,37 @@
 					<key>subItems</key>
 					<dict/>
 				</dict>
+				<key>tools</key>
+				<dict>
+					<key>isExpanded</key>
+					<true/>
+					<key>subItems</key>
+					<dict>
+						<key>ucon64</key>
+						<dict>
+							<key>isExpanded</key>
+							<true/>
+							<key>subItems</key>
+							<dict>
+								<key>src</key>
+								<dict>
+									<key>isExpanded</key>
+									<true/>
+									<key>subItems</key>
+									<dict>
+										<key>console</key>
+										<dict>
+											<key>isExpanded</key>
+											<true/>
+											<key>subItems</key>
+											<dict/>
+										</dict>
+									</dict>
+								</dict>
+							</dict>
+						</dict>
+					</dict>
+				</dict>
 			</dict>
 		</dict>
 	</dict>

BIN
roms/anime.smc


BIN
roms/arkanoid.smc


+ 0 - 0
roms/dezaemon.smc


BIN
roms/dump256.smc


BIN
roms/dump512.smc


BIN
roms/eric.smc


BIN
roms/hungry.smc


BIN
roms/kirby.smc


BIN
roms/spacei.smc


BIN
roms/super01.smc


BIN
roms/super02.smc


BIN
roms/supert.smc


BIN
roms/turrican.smc


BIN
roms/vortex.smc


+ 1 - 1
scripts/check_rle.py

@@ -7,7 +7,7 @@ import glob
 import zlib
 
 
-TARGET="/home/david/Dropbox/Tech/Quickdev16/roms/08"
+TARGET="/Users/david/Dropbox/Tech/Quickdev16/roms/08"
 
 count = 0
 total_zip_len = 0

+ 2 - 0
todo.txt

@@ -8,3 +8,5 @@ Package for Quickdev16
 Bootloader lockbits
 Flash all cartridge with latest firmware and bootloader
 Email to seeed about the retour package
+Add structs for machine state
+Add struct for usb and communcations flags