Schrijver
| MRC: Bug
|
NYYRIKKI msx master Berichten: 1503 | Geplaatst: 25 Oktober 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 Berichten: 1002 | Geplaatst: 25 Oktober 2004, 21:42   |
Amazing!
|
|
NYYRIKKI msx master Berichten: 1503 | Geplaatst: 25 Oktober 2004, 22:18   |
I agree...
Warning:
 |
|
[D-Tail]
 msx guru Berichten: 2994 | Geplaatst: 26 Oktober 2004, 12:05   |
|
|
AuroraMSX
 msx master Berichten: 1231 | Geplaatst: 26 Oktober 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 Berichten: 538 | Geplaatst: 26 Oktober 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 Berichten: 1231 | Geplaatst: 27 Oktober 2004, 09:38   |
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 Berichten: 538 | Geplaatst: 27 Oktober 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 Berichten: 3048 | Geplaatst: 27 Oktober 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 Berichten: 538 | Geplaatst: 27 Oktober 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 Berichten: 1231 | Geplaatst: 27 Oktober 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 GO SUBs  |
|
IC msx professional Berichten: 538 | Geplaatst: 27 Oktober 2004, 14:00   |
I just proven myself I am dumb 
I wasn't really paying attention.. It's recursive...
(and to add to it: forget that goto stuff cauz it's nonsense) |
|
NYYRIKKI msx master Berichten: 1503 | Geplaatst: 27 Oktober 2004, 16:15   |
Ok, here is really fast version:
10 DEFINTA-Y
20 A$="AF572100C08A77AF2CC85D8ACB3B20FB18F3"
30 FORI=0TO17:POKE&HD000+I,VAL("&H"+MID$(A$,I*2+1,2)):NEXTI
40 DEFUSR=&HD000:A=USR(0)
50 OPEN"TODO.TXT"FORINPUTAS#1
60 IFEOF(1)THENCLOSE:OPEN"TODO.PCK"FOROUTPUTAS#1:PRINT#1,Z1:PRINT#1,Z0:END
70 A=ASC(INPUT$(1,1)):Z1=Z1+PEEK(&HC000+A):Z0=Z0+8-PEEK(&HC000+A)
80 GOTO60
... and here is tokenized version of the ML routine:
xor a
ld d,a
ld hl,#C000
l1:
adc a,d
ld (hl),a
xor a
inc l
ret z
ld e,l
l2:
adc a,d
srl e
jr nz,l2
jr l1
|
|
Sonic_aka_T
 msx guru Berichten: 2262 | Geplaatst: 27 Oktober 2004, 16:26   |
Uhm, what does this do again?
|
|
IC msx professional Berichten: 538 | Geplaatst: 27 Oktober 2004, 16:36   |
compress your todo list perhaps  |
|
|
|
|