OSDN Git Service

progress support cmd.exe
authornaruko <naruko@24ea1065-a21e-4ca1-99c9-f5125deb0858>
Sun, 15 Nov 2009 03:45:29 +0000 (03:45 +0000)
committernaruko <naruko@24ea1065-a21e-4ca1-99c9-f5125deb0858>
Sun, 15 Nov 2009 03:45:29 +0000 (03:45 +0000)
git-svn-id: svn+ssh://svn.osdn.net/svnroot/unagi@307 24ea1065-a21e-4ca1-99c9-f5125deb0858

client/trunk/anago/progress.c
client/trunk/flashmemory.c
client/trunk/flashmemory.h
client/trunk/header.c
client/trunk/header.h
client/trunk/memory_manage.c [new file with mode: 0644]
client/trunk/memory_manage.h [new file with mode: 0644]
client/trunk/script_engine.c
client/trunk/waveform_dozeu.c [deleted file]

index bcb0e47..54514cc 100644 (file)
@@ -1,7 +1,8 @@
+#include <assert.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdbool.h>
-#include <assert.h>
+#include <windows.h>
 #include "progress.h"
 
 void progress_init(void)
@@ -41,7 +42,22 @@ static void draw(const char *name, long offset, long count)
 }
 void progress_draw(long program_offset, long program_count, long charcter_offset, long charcter_count)
 {
-       printf("\x1b[2A\x1b[35D");
+       if(0){
+               printf("\x1b[2A\x1b[35D");
+       }else{
+               HANDLE c;
+               CONSOLE_SCREEN_BUFFER_INFO info;
+               c = GetStdHandle(STD_OUTPUT_HANDLE);
+               if(GetConsoleScreenBufferInfo(c, &info) == 0){
+                       //command.com, cygwin shell, mingw shell
+                       printf("\x1b[2A\x1b[35D");
+               }else{
+                       //cmd.exe
+                       info.dwCursorPosition.X = 0;
+                       info.dwCursorPosition.Y -= 2;
+                       SetConsoleCursorPosition(c, info.dwCursorPosition);
+               }
+       }
        draw("program memory ", program_offset, program_count);
        draw("charcter memory", charcter_offset, charcter_count);
        fflush(stdout);
index 1333301..8a06ed5 100644 (file)
@@ -41,14 +41,15 @@ static void sram_erase(const struct flash_order *d)
 }
 #endif
 
-static void init_nop(const struct flash_order *d)
+static void init_nop(const struct flash_order *d, long wait)
 {
 }
 
-static void init_erase(const struct flash_order *d)
+static void init_erase(const struct flash_order *d, long wait)
 {
        assert(d->pagesize > 0);
        d->erase(d->command_2aaa, true);
+       Sleep(wait);
 }
 
 static void program_dummy(const struct flash_order *d, long address, long length, const struct memory *m)
index db786e5..df5213a 100644 (file)
@@ -45,7 +45,7 @@ struct flash_driver{
        long erase_wait; //unit is msec
        u8 id_manufacurer, id_device;
        int (*productid_check)(const struct flash_order *d, const struct flash_driver *f);
-       void (*init)(const struct flash_order *d);
+       void (*init)(const struct flash_order *d, long wait);
        void (*program)(const struct flash_order *d, long address, long length, const struct memory *m);
 };
 const struct flash_driver FLASH_DRIVER_UNDEF;
index 9acc21b..3dc3ba4 100644 (file)
@@ -149,7 +149,7 @@ bool nesbuffer_malloc(struct romimage *r, int mode)
 
 static inline void memory_free(struct memory *m)
 {
-       if(m->size != 0){
+       if(m->data != NULL){
                Free(m->data);
                m->data = NULL;
        }
@@ -286,6 +286,9 @@ bool nesfile_load(const char *errorprefix, const char *file, struct romimage *r)
                d += cpusize;
                if(ppusize != 0){
                        nesfile_datapointer_set(d, &r->ppu_rom, ppusize);
+               }else{
+                       r->ppu_rom.data = NULL;
+                       r->ppu_rom.size = 0;
                }
        }
 
index 4e4ab48..d9f799b 100644 (file)
@@ -17,7 +17,7 @@ struct memory{
        int size, offset;
        enum memory_attribute attribute;
        enum trastype transtype;
-       u8 *data;
+       uint8_t *data;
 };
 /*
 ROM image Æâ struct memory ¤Î¥â¡¼¥ÉÊ̤λȤ¤Êý
@@ -57,7 +57,7 @@ enum{
        MEMORY_AREA_CPU_RAM, MEMORY_AREA_CPU_ROM, MEMORY_AREA_PPU
 };
 #ifdef HEADEROUT
-void nesheader_set(const struct romimage *r, u8 *header);
+void nesheader_set(const struct romimage *r, uint8_t *header);
 #endif
 bool nesbuffer_malloc(struct romimage *r, int mode);
 void nesfile_create(struct romimage *r, const char *romfilename);
diff --git a/client/trunk/memory_manage.c b/client/trunk/memory_manage.c
new file mode 100644 (file)
index 0000000..a72000d
--- /dev/null
@@ -0,0 +1,69 @@
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "memory_manage.h"
+enum{
+       MANAGE_NUM = 0x100
+};
+
+struct manage{
+       const char *file, *function;
+       int line;
+       void *addr;
+       int size;
+};
+static const struct manage EMPTY = {
+       .file = NULL, .line = 0, .function = NULL,
+       .addr = NULL, .size = 0
+};
+static struct manage management[MANAGE_NUM];
+void mm_init(void)
+{
+       int i;
+       for(i = 0; i < MANAGE_NUM; i++){
+               management[i] = EMPTY;
+       }
+}
+void *mm_malloc(const char *file, int line, const char *function, int size)
+{
+       int i;
+       struct manage *t = management;
+       for(i = 0; i < MANAGE_NUM; i++){
+               if(t->addr == NULL){
+                       t->addr = malloc(size);
+                       t->size = size;
+                       t->file = file;
+                       t->line = line;
+                       t->function = function;
+                       return t->addr;
+               }
+               t++;
+       }
+       assert(0);
+       return NULL;
+}
+void mm_free(void *addr)
+{
+       int i;
+       struct manage *t = management;
+       for(i = 0; i < MANAGE_NUM; i++){
+               if(t->addr == addr){
+                       free(addr);
+                       *t = EMPTY;
+                       return;
+               }
+               t++;
+       }
+       assert(0);
+}
+void mm_end(void)
+{
+       int i;
+       struct manage *t = management;
+       for(i = 0; i < MANAGE_NUM; i++){
+               if(t->addr != NULL){
+                       printf("**free forgot** %s:%d %s() size %d\n", t->file, t->line, t->function, t->size);
+               }
+               t++;
+       }
+}
diff --git a/client/trunk/memory_manage.h b/client/trunk/memory_manage.h
new file mode 100644 (file)
index 0000000..d438645
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef _MEMORY_MANAGE_H_
+#define _MEMORY_MANAGE_H_
+void mm_init(void);
+void *mm_malloc(const char *file, int line, const char *function, int size);
+void mm_free(void *addr);
+void mm_end(void);
+#if DEBUG == 0
+#include <stdlib.h>
+  #define Malloc(size) malloc(size)
+  #define Free(addr) free(addr)
+#else
+  #define Malloc(size) mm_malloc(__FILE__, __LINE__, __FUNCTION__, size)
+  #define Free(addr) mm_free(addr)
+#endif
+#endif
index c0bc934..eb1280f 100644 (file)
@@ -1129,7 +1129,7 @@ static int execute(const struct script *s, const struct st_config *c, struct rom
                                printf(EXECUTE_PROGRAM_PREPARE, cpu_rom.name);
                                fflush(stdout);
                                //device ¤Ë¤è¤Ã¤Æ¤Ï erase
-                               c->cpu_flash_driver->init(&(r->cpu_flash));
+                               c->cpu_flash_driver->init(&(r->cpu_flash), c->cpu_flash_driver->erase_wait);
                                printf(EXECUTE_PROGRAM_DONE);
                                fflush(stdout);
                        }
@@ -1221,7 +1221,7 @@ static int execute(const struct script *s, const struct st_config *c, struct rom
                        if(programcount_ppu++ == 0){
                                printf(EXECUTE_PROGRAM_PREPARE, ppu_rom.name);
                                fflush(stdout);
-                               c->ppu_flash_driver->init(&(r->ppu_flash));
+                               c->ppu_flash_driver->init(&(r->ppu_flash), c->ppu_flash_driver->erase_wait);
                                printf(EXECUTE_PROGRAM_DONE);
                                fflush(stdout);
                        }
diff --git a/client/trunk/waveform_dozeu.c b/client/trunk/waveform_dozeu.c
deleted file mode 100644 (file)
index 65b16d3..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "type.h"
-#include "waveform_dozeu.h"
-
-const u8 WAVEFORM_INIT[INIT_SIZE]= {
-       0xee,   //IFCONFIG
-       0xc0,0x00,0x00,0x3e,0xee,0x4e,0x00,     //CTL RDY init
-};
-static const u8 WAVEFORM_DATA_PLAIN[] = {
-       // Wave data bank0
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x00,
-       0x3e,0x3c,0x3f,0x3f,0x3c,0x3c,0x3c,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x00,
-       0x3e,0x38,0x3b,0x3b,0x38,0x38,0x38,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0xbf,0x01,0x07,
-       0x00,0x00,0x00,0x02,0x02,0x09,0x00,0x00,
-       0x3e,0x3c,0x3f,0x3f,0x3c,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0xbf,0x01,0x07,
-       0x00,0x00,0x00,0x02,0x02,0x09,0x00,0x00,
-       0x3e,0x38,0x3b,0x3b,0x38,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       // Flow data bank0
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       // Wave data bank1
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,
-       0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x02,0x02,0x00,0x00,0x00,0x00,0x00,
-       0x3c,0x38,0x3c,0x3c,0x3c,0x3c,0x3c,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x80,0x01,0x01,0x01,0x01,0x07,
-       0x02,0x08,0x01,0x00,0x00,0x00,0x00,0x00,
-       0x3c,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x80,0x01,0x07,
-       0x00,0x02,0x02,0x00,0x08,0x01,0x00,0x00,
-       0x3c,0x38,0x3c,0x3c,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       // Flow data bank1
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       // Wave data bank2
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
-       0x3a,0x32,0x22,0x32,0x32,0x32,0x32,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x00,
-       0x3a,0x32,0x12,0x32,0x32,0x32,0x32,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x89,0x01,0x07,
-       0x00,0x00,0x02,0x00,0x08,0x01,0x00,0x00,
-       0x3a,0x32,0x22,0x32,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x89,0x01,0x07,
-       0x00,0x00,0x02,0x02,0x08,0x01,0x00,0x00,
-       0x3a,0x32,0x12,0x32,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       // Flow data bank2
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       // Wave data bank3
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x00,
-       0x3e,0x3f,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x00,
-       0x3e,0x3b,0x3a,0x3a,0x3a,0x3a,0x3a,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x07,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
-       // Flow data bank3
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-};
-/*
-optimize ¤Î¥Ä¡¼¥ë¤¬¤¢¤Þ¤ê¤Ë¤â°ÕÌ£¤¬¤Ê¤¤¥Ç¡¼¥¿¤Ë¤Ð¤é¤¹¤Î¤Ç 
-cast ¤·¤Æ global data ¤È¤¹¤ë¡£
-*/
-const struct gpif_data *const WAVEFORM_DATA = (const struct gpif_data *) &WAVEFORM_DATA_PLAIN;