summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-03-05 22:50:41 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-03-05 22:50:41 +0000
commite5b4913d19b40176cbaebe9453febadcab87b76c (patch)
tree15eb25966a44a80eba5b42b59b86c5a57700f892
parentfabdf1de6f1a8fa8e281a3d428f484778b818344 (diff)
downloadrockbox-e5b4913d19b40176cbaebe9453febadcab87b76c.tar.gz
rockbox-e5b4913d19b40176cbaebe9453febadcab87b76c.zip
Minor bug when writing files; files weren't truncated to 0, so when
writing a file smaller than the previous one, it adds garbage to the end. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6147 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/rockboy/cpu.c2
-rw-r--r--apps/plugins/rockboy/dynarec.c5
-rw-r--r--apps/plugins/rockboy/loader.c6
3 files changed, 7 insertions, 6 deletions
diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c
index 656341aaac..60c76a1302 100644
--- a/apps/plugins/rockboy/cpu.c
+++ b/apps/plugins/rockboy/cpu.c
@@ -949,7 +949,7 @@ next:
949 int fd; 949 int fd;
950 blockcount++; 950 blockcount++;
951 snprintf(meow,499,"/dyna_0x%x_run.rb",PC); 951 snprintf(meow,499,"/dyna_0x%x_run.rb",PC);
952 fd=open(meow,O_WRONLY|O_CREAT); 952 fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC);
953 if(fd>=0) { 953 if(fd>=0) {
954 fdprintf(fd,"Block 0x%x Blockcount: %d\n",PC,blockcount); 954 fdprintf(fd,"Block 0x%x Blockcount: %d\n",PC,blockcount);
955 fdprintf(fd,"before: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", 955 fdprintf(fd,"before: 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
diff --git a/apps/plugins/rockboy/dynarec.c b/apps/plugins/rockboy/dynarec.c
index 9d3be22c03..14ec7a5ca9 100644
--- a/apps/plugins/rockboy/dynarec.c
+++ b/apps/plugins/rockboy/dynarec.c
@@ -384,7 +384,7 @@ void dynamic_recompile (struct dynarec_block *newblock) {
384 newblock->block=dynapointer; 384 newblock->block=dynapointer;
385#ifdef DYNA_DEBUG 385#ifdef DYNA_DEBUG
386 snprintf(meow,499,"/dyna_0x%x_asm.rb",PC); 386 snprintf(meow,499,"/dyna_0x%x_asm.rb",PC);
387 fd=open(meow,O_WRONLY|O_CREAT); 387 fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC);
388 if(fd<0) { 388 if(fd<0) {
389 die("couldn't open dyna debug file"); 389 die("couldn't open dyna debug file");
390 return; 390 return;
@@ -915,6 +915,7 @@ void dynamic_recompile (struct dynarec_block *newblock) {
915 DYNA_BTST_l_r(8,7); /* btst #8,d7 */ 915 DYNA_BTST_l_r(8,7); /* btst #8,d7 */
916 DYNA_DUMMYBRANCH(2,0); 916 DYNA_DUMMYBRANCH(2,0);
917 DYNA_MOVEA_l_i_to_r(&blockclen,3); 917 DYNA_MOVEA_l_i_to_r(&blockclen,3);
918 DYNA_MOVE_l_i_to_m(tclen,3);
918 DYNA_MOVEA_l_i_to_r(readw(PC),1); 919 DYNA_MOVEA_l_i_to_r(readw(PC),1);
919 DYNA_RET(); 920 DYNA_RET();
920 DYNA_BCC_c(0x6,2,0); /* jump here if bit is not zero */ 921 DYNA_BCC_c(0x6,2,0); /* jump here if bit is not zero */
@@ -974,7 +975,7 @@ void dynamic_recompile (struct dynarec_block *newblock) {
974 newblock->length=dynapointer-newblock->block; 975 newblock->length=dynapointer-newblock->block;
975 invalidate_icache(); 976 invalidate_icache();
976 snprintf(meow,499,"/dyna_0x%x_code.rb",PC); 977 snprintf(meow,499,"/dyna_0x%x_code.rb",PC);
977 fd=open(meow,O_WRONLY|O_CREAT); 978 fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC);
978 if(fd>=0) { 979 if(fd>=0) {
979 write(fd,newblock->block,newblock->length); 980 write(fd,newblock->block,newblock->length);
980 close(fd); 981 close(fd);
diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c
index ad7c309bd8..dc89cddf8b 100644
--- a/apps/plugins/rockboy/loader.c
+++ b/apps/plugins/rockboy/loader.c
@@ -218,7 +218,7 @@ int sram_save(void)
218 /* If we crash before we ever loaded sram, DO NOT SAVE! */ 218 /* If we crash before we ever loaded sram, DO NOT SAVE! */
219 if (!mbc.batt || !sramfile || !ram.loaded || !mbc.ramsize) 219 if (!mbc.batt || !sramfile || !ram.loaded || !mbc.ramsize)
220 return -1; 220 return -1;
221 fd = open(sramfile, O_WRONLY|O_CREAT); 221 fd = open(sramfile, O_WRONLY|O_CREAT|O_TRUNC);
222// snprintf(meow,499,"Opening %s %d",sramfile,fd); 222// snprintf(meow,499,"Opening %s %d",sramfile,fd);
223// rb->splash(HZ*2, true, meow); 223// rb->splash(HZ*2, true, meow);
224 if (fd<0) return -1; 224 if (fd<0) return -1;
@@ -240,7 +240,7 @@ void state_save(int n)
240 if (n < 0) n = 0; 240 if (n < 0) n = 0;
241 snprintf(name, 499,"%s.%03d", saveprefix, n); 241 snprintf(name, 499,"%s.%03d", saveprefix, n);
242 242
243 if ((fd = open(name, O_WRONLY|O_CREAT)>=0)) 243 if ((fd = open(name, O_WRONLY|O_CREAT|O_TRUNC)>=0))
244 { 244 {
245 savestate(fd); 245 savestate(fd);
246 close(fd); 246 close(fd);
@@ -272,7 +272,7 @@ void rtc_save(void)
272{ 272{
273 int fd; 273 int fd;
274 if (!rtc.batt) return; 274 if (!rtc.batt) return;
275 if ((fd = open(rtcfile, O_WRONLY|O_CREAT))<0) return; 275 if ((fd = open(rtcfile, O_WRONLY|O_CREAT|O_TRUNC))<0) return;
276 rtc_save_internal(fd); 276 rtc_save_internal(fd);
277 close(fd); 277 close(fd);
278} 278}