MRC: Bug

Página 2/4
1 | | 3 | 4

Por NYYRIKKI

Enlighted (5889)

imagem de NYYRIKKI

25-10-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

Por NYYRIKKI

Enlighted (5889)

imagem de NYYRIKKI

25-10-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. Smile

Por Grauw

Ascended (10159)

imagem de Grauw

25-10-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 Wink out of the ) character

Por snout

Ascended (15184)

imagem de snout

25-10-2004, 20:56

code tags are your friends Wink

Por NYYRIKKI

Enlighted (5889)

imagem de NYYRIKKI

25-10-2004, 21:32

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.

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.


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...

Por Grauw

Ascended (10159)

imagem de Grauw

25-10-2004, 21:42

Amazing!

Por NYYRIKKI

Enlighted (5889)

imagem de NYYRIKKI

25-10-2004, 22:18

Amazing!
I agree...

Warning:
www.boysstuff.co.uk/images/prod_zoom_center/stamps_left_500_87707.jpg

Por [D-Tail]

Ascended (8255)

imagem de [D-Tail]

26-10-2004, 12:05

LOL!

Por AuroraMSX

Paragon (1902)

imagem de AuroraMSX

26-10-2004, 13:53

An alternative compressor. Main difference is the (faster?) construction of the V() array Smile

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 Tongue

Por IC

Hero (557)

imagem de IC

26-10-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 Tongue

Página 2/4
1 | | 3 | 4