SoundTrack:! -0;) -: BY SECTOR AFTER INSTY
__________________________________________
(C) Max / CYBERAX Software
Supplement: dAn!! L
__________________________________________
- - -
It's about packer MS-PACK, but rather on DEPACKER'e, which
he attaches to the compressed file.
In its original form UNPACKER MS-PACK'a should work with
illicit interrupts. Also does not provide the possibility of
its separation from the block (for example, in your program a
lot of compressed files and does not make sense all of them
have an extractor - enough one instance).
The work enabled interrupt is useful if you want to unzip
chtolibo not braking at the same music or animatsiyu.V this
case, the music hangs in IM 2, and DEPACKER works in native
mode.
To implement all the above and
are the following two programs.
The first program, in BASIC. It is intended to separate from
DEPACKER'a compress the block. When run, it
Requests to enter the file name (no more than 7 letters).
She then writes to the disk block without unpacker. Go to the
source file name is added an apostrophe. The length of the
resulting block will be less than the block on DEPACKER'om
247 bytes.
1 INPUT "Name:"; A $: RANDOMIZE USR VAL
"15619": REM: LOAD A $ CODE
2 LET O = VAL "PEEK 23782 + 256 * PEEK 23783:
LET A = VAL "PEEK (O +233) + 256 * PEEK (O +
234) ": LET L = VAL" 3 + PEEK (O +239) +
256 * PEEK (O +240) "
3 FOR J = NOT PI TO VAL "4": POKE VAL "O +
238 + J ", PEEK VAL" A - 4 + J ": NEXT J
4 RANDOMIZE USR VAL "15619": REM: SAVE
A $ + "'" CODE VAL "O + 238", L
The second program - in assembler. This
is, in fact, DEPACKER.
(Frankly, I did not understand the algorithm of the unpacker. I
just replaced it with a stack of all operations on the
operations of the register IX, and also tried fit the new
version DEPACKER'a 256 bytes.)
ORG 40000
;+---------------------------------------+
;|*** MS-PACK UNPACKER WITH INTERRUPT *** |
;|---------------------------------------|
; | Originally written by 'MICROSPACE', |
; | Remixed by Max 'CYBERAX Software' |
;+---------------------------------------+
UNPACK LD C, 16
LD B, C
LD D, 3
EXX
LD HL, SOURCE
; Address packed block without UNPACKER'a.
, (How to unpack)
; Unit must be received by the previous prog; rammkoy in BASIC.
LD DE, BUF
LD BC, 5
LDIR
PUSH HL
POP IX
LD DE, DESTIN
; Memory address where will be
; Unpacking.
LD H, B
EXX
CALL POP_HL
JR ENTRY
FIRST CALL POP_AF
EXX
LD (DE), A
INC DE
EXX
ENTRY CALL NEWBIT
JR NC, FIRST
LD E, 2
L1 XOR A
CALL NEWBIT
RLA
CALL NEWBIT
RLA
CP D
JR C, MET1
ADD A, E
LD E, A
CP 1917
JR NZ, L1
XOR A
MET1 ADD A, E
CP 5
JR NC, MET2
CP 2
JR NZ, MET3
EXX
LD C, A
L3 CALL POP_AF
LD L, A
LD A, E
SCF
SBC A, L
LD L, A
LD A, D
SBC A, H
LD H, A
LDIR
LD H, B
EXX
JR ENTRY
L2 EXX
CALL POP_AF
INC A
JR Z, END
INC A
JR NZ, MET4
CALL POP_BC
JR MET5
MET4 ADD A, 15
JR NC, MET6
INC B
JR MET6
MET2 JR Z, L2
DEC A
MET3 EXX
MET6 LD C, A
MET5 EXX
CALL NEWBIT
EXX
JR C, L3
EXX
XOR A
LD E, D
L4 CALL NEWBIT
RLA
DEC E
JR NZ, L4
CP 2
JR NC, MET7
INC A
LOOP EXX
LD H, A
JR L3
MET7 CALL NEWBIT
RLA
CP 8
JR NC, MET8
DEC A
JR LOOP
MET8 CALL NEWBIT
RLA
CP 1923
JR NC, MET9
SUB 9
JR LOOP
MET9 CALL NEWBIT
RLA
AND 31
CP 1931
JR C, LOOP
CALL POP_AF
JR LOOP
END LD HL, BUF
LD C, 5
LDIR
; If you use this
; Decompressor from BASIC, here it is desirable
; Insert commands restore the register
; HL '(another BASIC messed up ...).
RET
NEWBIT ADD HL, HL
DJNZ MET
LD B, C
POP_HL LD L, (IX)
LD H, (IX +1)
FIN INC IX
INC IX
MET RET
POP_DE LD E, (IX)
LD D, (IX +1)
JR FIN
POP_BC LD C, (IX)
LD B, (IX +1)
JR FIN
POP_AF LD A, (IX)
JR FIN +2
BUF DEFS 5
SIZE EQU $-DEPACK
SOURCE DESTIN address and chosen not
arbitrarily. Rather arbitrarily, but according to certain
rules. Let the length of the source block (nezapakovannogo) is
LEN1, and the length of the packed (without UNPACKER'a) - LEN2.
There are two cases:
1) Let us specify an address DESTIN, then the address of SOURCE
can range from 16,384 to DESTIN-LEN2 or in the range of
DESTIN + LEN1-LEN2 65536-LEN2.
2) You can fix the address of SOURCE, then
DESTIN may lie in the range of 16,384
to SOURCE-LEN1 + LEN2 or SOURCE + LEN2 to
65536-LEN1.
This is true provided that LEN1
more LEN2 (ie, if the block a little,
but it has shrunk), otherwise the formula
do not fit. Moreover, if such unit is not separated extractor,
the latter generally not be able to extract the block
correctly (eg, reset).
In conclusion a few words.
Reworked so UNPACKER a bit slower of the original (it
even without taking into account the time occupied by the
processing of IM 2). If you want maximum speed, we can proceed
as follows: start with original UNPACKER interrupt enable ...
To do this, separate procedure
unpacking from a block and alter its origin
similar to my version.
When you call to adjust the parameters of the SOURCE and
DESTIN so that the distance between these blocks has increased
by as much bytes, how much enters the stack handler
IM 2 (or more).
I will explain a little bit. Original DEPACKER
when you start put a stack on the block zapachenny
and begins to unpack the address DESTIN, while the decompressed
block increases up and packed 'escapes' from him,
decreasing in length. Bytes are packed
block removed commands POP. The most interesting thing that the
end of the decompressed block will never 'catch up' started to
unpack, as between them on clearance at 5 bytes. If we
artificially increase this gap (or modifying SOURCE DESTIN),
then we can save here registers and return address in the
processing of IM 2.
I should also note that the second method I do not
tested, and this is the first successful in
one of my programs.
*
In addition, from the editors, or as done in DEJA VU.
To suffer for long and do not ask
manually address and if you do not have to work
with preemption, then the
The following manipulations:
1) pack MS-PACK'om code files and cool
crazy about compression ratio (if
multiple files, of course, pack them
all).
2) Run the following program from on
Basic'e:
10 CLEAR 25000
20 INPUT "MS:"; N $
22 IF N $ = "" THEN GO SUB 100: GO TO 20
25 RANDOMIZE USR 15619: REM: LOAD N $ CODE
26 IF PEEK 23823 <> 0 THEN GO TO 20
28 LET LEN = PEEK 23784 +256 * PEEK 23785
30 LET AD = PEEK 23782 +256 * PEEK 23783:
LET AD2 = AD +36: LET AD3 = AD +231
40 POKE AD3, PEEK AD2: POKE AD3 +1,
PEEK (AD2 +1)
50 INPUT "NEW:"; M $
1960 IF M $ = "" THEN GO SUB 100: GO TO 50
70 RANDOMIZE USR 15619: REM: SAVE M $ CODE
AD3, LEN-231
80 GO TO 20
100 RANDOMIZE USR 15619: REM: CAT
110 RETURN
3) Enter the name zapkovannogo MS-PACK'om
file (line 20) if no such file exists,
nothing happens, otherwise ask for a name the new file, and
after enter the name of the new file is written to address
Old address 231, length LENGTH OF OLD-231,
ie at 231 bytes shorter!
4) Create a universal depaker, assembliruya in your favorite
assembler next listing:
ORG # 5B00
LL5B00 LDDR; or LDIR see below
LD H, B
POP DE
EXX
POP HL
JR LL5B0E
LL5B08 DEC SP
POP AF
EXX
LD (DE), A
INC DE
EXX
LL5B0E ADD HL, HL
DJNZ LL5B13
POP HL
LD B, C
LL5B13 JR NC, LL5B08
LD E, # 02
LL5B17 XOR A
ADD HL, HL
DJNZ LL5B1D
POP HL
LD B, C
LL5B1D RLA
ADD HL, HL
DJNZ LL5B23
POP HL
LD B, C
LL5B23 RLA
CP D
JR C, LL5B2E
ADD A, E
LD E, A
CP # 11
JR NZ, LL5B17
XOR A
LL5B2E ADD A, E
CP # 05
JR NC, LL5B5C
CP # 02
JR NZ, LL5B5F
EXX
LD C, A
LL5B39 DEC SP
POP AF
LD L, A
LD A, E
SCF
SBC A, L
LD L, A
LD A, D
SBC A, H
LD H, A
LDIR
LD H, B
EXX
JR LL5B0E
LL5B49 EXX
DEC SP
POP AF
INC A
JR Z, LL5BAA
INC A
JR NZ, LL5B55
POP BC
JR LL5B61
LL5B55 ADD A, # 0F
JR NC, LL5B60
INC B
JR LL5B60
LL5B5C JR Z, LL5B49
DEC A
LL5B5F EXX
LL5B60 LD C, A
LL5B61 EXX
ADD HL, HL
DJNZ LL5B67
POP HL
LD B, C
LL5B67 EXX
JR C, LL5B39
EXX
XOR A
LD E, D
LL5B6D ADD HL, HL
DJNZ LL5B72
POP HL
LD B, C
LL5B72 RLA
DEC E
JR NZ, LL5B6D
CP # 02
JR NC, LL5B7F
INC A
LL5B7B EXX
LD H, A
JR LL5B39
LL5B7F ADD HL, HL
DJNZ LL5B84
POP HL
LD B, C
LL5B84 RLA
CP # 08
JR NC, LL5B8C
DEC A
JR LL5B7B
LL5B8C ADD HL, HL
DJNZ LL5B91
POP HL
LD B, C
LL5B91 RLA
CP # 17
JR NC, LL5B9A
SUB # 09
JR LL5B7B
LL5B9A ADD HL, HL
DJNZ LL5B9F
POP HL
LD B, C
LL5B9F RLA
AND # 1F
CP # 1F
JR C, LL5B7B
DEC SP
POP AF
JR LL5B7B
LL5BAA LD HL, LL5BBC
LD C, # 2005
LDIR
LD HL, # 0000
LL5BB2 EQU $ - # 02
EXX
LD SP, # 0000
LL5BB6 EQU $ - # 02
EI; or DI
RET;
NOP; or JP # nnnn NOP; /
LL5BBC NOP
NOP
NOP
NOP
LL5BC0 NOP
; Run depakera input hl = address of the file
; Without depakera
DEPACK DI
LD (LL5BB6), SP
EXX
LD (LL5BB2), HL
LD C, # 1910
LD B, C
LD D, # 03
EXX
LD SP, HL
POP HL
LD (LL5BE2), HL
POP HL
LD DE, LL5BC0
LD BC, # 0005
LDDR
POP HL
POP DE
POP BC
LD SP, # 0000
LL5BE2 EQU $ - # 02
JP LL5B00
Comments: universal extractor
occupies less than 256 bytes! Traditionally located in the
printer buffer from the address # 5B00. (In this case, the
address will start is # 5BC1 = label DEPACK). At the entrance
to a pair of HL, you must specify the address loaded
block codes without depakera (what happened in paragraph 3). To
avoid problems with imposing decompressed data to another
not unpacked, I advise you to load a file from the
address specified in the catalog! Unpacking
will occur in the address that was
given in the MS-PACK'e.
For example, we have packaged MS-PACK'om
file:
"FILE" CODE 49152,10000;
Process it BASIC'om (paragraphs 2 and 3)
obtain a new file without depakera:
"FILE +" CODE 49383,9769;
To unzip the file, put
unpacking at # 5B00 and extract follows:
LD HL, 49383
JP # 5BC1; label DEPACK
Unpack the file at a given
when packed in MS-PACK'e (eg # C000).
And, finally, a little nuance - if
package file, the longer the initial
(And this may be, if we pack a small file or already zapachenny
file - it is can be seen on the compression ratio given in
percentage), then you must change depaker, at # 5B00 not put
LDDR and LDIR! Thus it makes sense to pack and small files (2
sectors).
As a result, if guided by the number of sectors is 90% of
cases can save one sector in the file!
If we use the method that results in MAX, then 96% saves one
sector! And most importantly - there is a possibility
choice!
MS-PACK good packs are small text files. If you pack the
large code blocks, use HRUST 1.0, surely it will show the best
result, but and the ability to save the file without the
wrapper provided by the author.
Continue to give the floor MAX'u.
-----------------------------------------*********
*********************************
-----------------------------------------
Download and run the BASIC files.
I think everyone knows how to boot'ah usually
run the program. File name throws
in line BASIC (instead of spaces in the command RUN ""), then
this string starts.
In this article I'll show you how you can
download and run the BASIC program without
use of such tricks.
The program in Listing written with the active use of
fragments ROM TR-DOS, so do not be surprised its clumsy form.
Suppose there is a specific file that you want to run. Also
assume that we know the title of the file (16 bytes). For
BitTorrent will use a driver able to read 'B' sector to the
'HL' with tracks and sectors 'DE' (label LOAD). Oposlya load,
the driver must enter the last track and sector of the variable
# 5CF4.
CLEAR is desirable to have installed on
65367.
The first thing perekinem heading to the HEADER, equal to
23,773. File number is desirable to put on # 5D1E. Then run
prog following:
BAS_RUN LD DE, (23635) Home Base. etc.
LD HL, (23641) Region. Ed. line
DEC HL
PUSH HL
PUSH DE
AND A
SBC HL, DE
; In HL have a length of old beisik-prog,
, Ie one that is (or is not)
; In memory to boot.
LD DE, (HEADER +9)
; In DE have a header length of a new beat, sika, ie the fact
that you want to ship.
PUSH DE
PUSH HL
LD HL, 5
ADD HL, DE
The length of the new prog increased by 5 bytes.
LD (23771), HL
; Stuck in a variable, as in TR-DOS.
POP HL
POP BC
POP DE
POP HL
PUSH BC
CALL # 19E5
; Remove the old BASIC, shifting memory.
POP BC
CALL # 1655
; Reserve a room for the new.
INC HL
LD BC, (HEADER +11)
, Took a header length of the new BASIC
And without the program variables.
ADD HL, BC
; Added the address of the beginning.
LD (23627), HL
, Set the system variable VARS.
LD HL, (23635)
; HL - to be shipped.
LD A, (23772)
; Byte length.
LD B, A
LD DE, (HEADER +14)
; DE - track and sector.
LD (# 5CF4), DE
DEC B
INC B
CALL NZ, LOAD
And if there is shipping - Georgia.
LD A, (23771)
AND A
JR Z, NOLOW
, Is equal to zero if the low byte length?
PUSH HL
LD DE, (# 5CF4)
LD HL, BUF
LD B, 1
CALL LOAD
; Gruzanuli last sector in the buffer.
POP DE
LD BC, (23,771)
LD B, 0
LD HL, BUF
LDIR
The residue was transferred where necessary.
NOLOW LD HL, (23641)
DEC HL
LD (HL), 128
; Have brought just in case the marker end.
INC HL
INC HL
LD E, (HL)
INC HL
LD D, (HL)
, Took the line auto-
LD (23618), DE
, And have brought it to the acc. variable.
XOR A
LD (23620), A
; Neutral earthing operator number in the string.
LD (23824), A
CALL # 16B0
; Do not remember exactly what it seems clean
; Stack calculator.
LD HL, (23635)
DEC HL
LD (23639), HL
; Did RESTORE.
LD HL, (23613)
LD (23827), HL
EXX
LD HL, 10072
EXX
LD IY, # 5C3A
LD (IY), 255
SET 7, (IY +1)
RES 5, (IY +1)
; Other settings.
JP 7037; launch ...
BUF DEFS 256; loading buffer.
Have this very program better in the display area. It would
be nice to clean the screen before transferring control to the
ROM, as is makes the TR-DOS.
For example, instead of JP 7037:
LD HL, 7037
PUSH HL
JP 3435
In conclusion I wish to thank Fedin PY for the book "A
complete description and full disassembler TR-SOS 5.04T (5.03).