MRC: Bug (MSX Resource Center MSX Forum)MSX Resource Center               
              
English Nederlands Espa�ol Portugu�s Russian         
 News
   Frontpage
  News archive
  News topics

 Resources
   MSX Forum
  Articles
  Reviews
  Fair reports
  Photo shoots
  Fairs and meetings
  Polls
  Links
  Search

 Software
   Downloads
  Webshop

 MRC
   Who we are
  Join our team
  Donate
  Policies
  Contact us
  Link to Us
  Statistics

 Search
 
  

  

 Login
 

Username

Password




Don't you have an account yet? Become an MSX-friend and register an account now!.


 Statistics
 

There are 36 guests and 5 MSX friends online

You are an anonymous user.
 

MSX Forum


MSX Forum

MSX Resource Center - MRC: Bug

Goto page ( Previous Page 1 | 2 | 3 Next Page )
Author

MRC: Bug

NYYRIKKI
msx master
Posts: 1528
Posted: October 25 2004, 16:34   
Here is the TODO-list compression program:
10 MAXFILES=2
20 DEFINTA-Y:DIM V(255)
30 FORX=0TO255:FORI=0TO7:B=2^I:V(X)=V(X)+(XANDB)\B:NEXTI,X
40 OPEN"TODO.TXT"FORINPUTAS#1
50 OPEN"TODO.PCK"FOROUTPUTAS#2
60 IFEOF(1)THENPRINT#2,Z1:PRINT#2,Z0:CLOSE:KILL"TODO.TXT":END
70 A=ASC(INPUT$(1,1)):Z1=Z1+V(A):Z0=Z0+8-V(A):GOTO60

... now my TODO list is only 14 bytes long! ;9

NYYRIKKI
msx master
Posts: 1528
Posted: October 25 2004, 18:02   

Ah, I forgot to put here also TODO decompression program... Here it is:
10 DEFINTA-Y:DIM V(255)
20 OPEN"TODO.PCK"FORINPUTAS#1
30 LINEINPUT#1,A$:Z1=VAL(A$)
40 LINEINPUT#1,A$:Z0=VAL(A$)+(RND(-Z0-Z1)=Z1):ZL=(Z0+Z1)\8:CLOSE
50 OPEN"TODO.TXT"FOROUTPUTAS#1
60 FORZI=1TOZL
70 IFZL-ZI<10THENO=0ELSEO=(RND(1)*7)-3
80 A=O+(Z1/Z0)*4:Z1=Z1-A:Z0=Z0-8+A:B=0:IFA>8THENA=8
90 IF A<1THEN110ELSEFORI=1TOA
100 P=RND(1)*8:IFBAND2^PTHEN100ELSEB=B+2^P:NEXTI
110 PRINT#1,CHR$(B);
120 NEXTZI:CLOSE

I also forget to mention, that this is lossy packing method, but at least I can't notice any remarkable difference between original and packed TODO list after few days... (You know, I don't usually make too accurate notes to my self.) I have noticed, that you can get best result, if you use this routine to pack your notes about files you binary patched.

Grauw
msx professional
Posts: 1006
Posted: October 25 2004, 20:35   
I especially like the application of RND ;p.

The compression routine is a bit slow though eh? Especially the construction of the V array takes its time. Perhaps you should attempt an assembly implementation.

And er... why does it delete the input file... that's annoying. Maybe doing the output to a TODO.OUT or TODO_OUT.TXT file would be a good option. Did you do a usability test with a panel of random users before publishing this software? That would probably have gisted out issues like this before going public.

Anyways, I think there is huge market potential in the TODOPACK.BAS and TODOEXT.BAS applications... You should consider a PC version though, because MSX is not the system with the widest audience reach. Maybe a console version as well.

By the way, are you sure the output is as expected? My current implementation outputs the following:

b▐¶àδũ¶R) ¿I▲Hö▄)8αÆΩà%uè▂σϊó₧&▚
[0x0B (home)]
¡é¶◦¿½ø{Xëcⁿu¿


Perhaps it is because you use the uninitialized Z0 variable in line 40...


~Grauw

p.s. I still need to finish that MSX<>UTF-8 converter sometime.
p.s.2. argh stupid MRC smiley converter makes a out of the ) character
snout

msx legend
Posts: 4992
Posted: October 25 2004, 20:56   
code tags are your friends
NYYRIKKI
msx master
Posts: 1528
Posted: October 25 2004, 21:32   
Quote:

The compression routine is a bit slow though eh? Especially the construction of the V array takes its time. Perhaps you should attempt an assembly implementation.



This is freeware packer, you can port this freely to any language or platform.

Quote:

And er... why does it delete the input file... that's annoying. Maybe doing the output to a TODO.OUT or TODO_OUT.TXT file would be a good option. Did you do a usability test with a panel of random users before publishing this software? That would probably have gisted out issues like this before going public.



Ok, maybe next version is better. I just thought, that original file will just waste space from disk. Unfortunately I didn't do any tests on users as this was an alpha release. I really appreciate your comments.

Quote:


By the way, are you sure the output is as expected? My current implementation outputs the following:

b▐¶àδũ¶R) ¿I▲Hö▄)8αÆΩà%uè▂σϊó₧&▚
[0x0B (home)]
¡é¶◦¿½ø{Xëcⁿu¿


Perhaps it is because you use the uninitialized Z0 variable in line 40...



I don't see any problem with your data. If I compress it and then use decompress routine, the data is 100% same.

You are right with that error on line 40, but that bug is so small, that I'm not going to release a patch for this as correcting this feature will also make this program incompatible with previous version. Maybe there will be a compatibility mode in version 2.0

How ever, if you add following line:
45 IFZL<>(Z0+Z1)/8THENPRINT"CRC Error!":END


... you will get also error detection and you don't need to worry anymore about broken downloaded files...

Grauw
msx professional
Posts: 1006
Posted: October 25 2004, 21:42   
Amazing!
NYYRIKKI
msx master
Posts: 1528
Posted: October 25 2004, 22:18   
Quote:

Amazing!


I agree...

Warning:

[D-Tail]

msx guru
Posts: 3020
Posted: October 26 2004, 12:05   

AuroraMSX

msx master
Posts: 1262
Posted: October 26 2004, 13:53   
An alternative compressor. Main difference is the (faster?) construction of the V() array

10 DIM V(256)
20 L=0: N=1: Z=1: GOSUB 1000
30 OPEN "TODO.TXT" AS #1 LEN=1: FIELD 1, 1 AS X$
40 IF EOF(1) THEN 70
50 GET #1: N1=N1+V(ASC(X$)): N0=N0+8-(ASC(X$))
60 GOTO 40
70 CLOSE #1: OPEN "TODO.PCK" FOR OUTPUT AS #1
80 PRINT #1,Z0, Z1
90 CLOSE #1
100 END
1000 IF L=8 THEN RETURN
1010 V(N)=Z: N=N*2: L=L+1: GOSUB 1000: N=N+1: Z=Z+1: GOSUB 1000
1020 N=(N-1)/2: Z=Z-1: L=L-1: RETURN


/me digs recursion in BASIC

IC
msx professional
Posts: 538
Posted: October 26 2004, 14:15   
recursion my but..
it's mainly a loop, but the loop var is constantly being changed

even with djnz you can make such a loop by simply changing the B reg
AuroraMSX

msx master
Posts: 1262
Posted: October 27 2004, 09:38   
Quote:

recursion my but..


The sub routine at 1000 calls itself. I don't know how *you* would call such a construction, but it *is* recursion.

Quote:

it's mainly a loop, but the loop var is constantly being changed



I can't help it that BASIC is such a crappy language to write recursive algorithms in 8)

Quote:

even with djnz you can make such a loop by simply changing the B reg



Not in BASIC you can't!
IC
msx professional
Posts: 538
Posted: October 27 2004, 12:19   
imho it does the same as this:
1000 V(N)=Z: N=N*2: L=L+1: IF L < 8 then goto 1000:N=N+1: Z=Z+1
1010 N=(N-1)/2: Z=Z-1: L=L-1: RETURN


But I might be wrong about this
GuyveR800
msx guru
Posts: 3048
Posted: October 27 2004, 13:34   
yes, everything after the GOTO isn't executed, and in the original code there was an extra GOSUB1000. So while your GOTO thingy does speed up the first part of the routine, the routine still needs recursion to function.
IC
msx professional
Posts: 538
Posted: October 27 2004, 13:44   
1000 V(N)=Z: N=N*2: L=L+1: IF L < 8 then goto 1000 else N=N+1: Z=Z+1
1010 N=(N-1)/2: Z=Z-1: L=L-1: RETURN

and the extra gosub does just return eh.. cauz the L = 8 at that point (so why use the extra gosub while it isn't really needed).

but ok.. the heck with this... back to work
AuroraMSX

msx master
Posts: 1262
Posted: October 27 2004, 13:51   
Quote:

imho it does the same as this:
1000 V(N)=Z: N=N*2: L=L+1: IF L < 8 then goto 1000:N=N+1: Z=Z+1
1010 N=(N-1)/2: Z=Z-1: L=L-1: RETURN


But I might be wrong about this



You are Your routine only fills V(0), V(2), V(4), V(8) .. V(128), and misses all other entries in V(). Then, when L equals 8, line 1010 is executed and the routine RETURNs to the call earlier in the program and all other entries in V() are left 0.

The fun in my routine is in the use of GOSUBs
 
Goto page ( Previous Page 1 | 2 | 3 Next Page )
 







(c) 1994 - 2008 MSX Resource Center Foundation. MSX is a trademark of MSX Licensing Corporation.