SOUND AGRESSOR
v.1.0 beta
17.o6.2oo3
(c) Himik's ZxZ/PoS-WT
------------------------------------------
It's done! Despite all life
difficulties and other nonsense that,
Of course, I tried to make adjustments to
fluidity of events, I was able to release
this version of your music packer.
As you probably already knowno,
the main goal that I pursuedpri
creating this converter - ethen
using the program when writingand thatk
called 4k Intro for various types
party.
The main problem with such nominations
this is what in such a small amount of memory
very difficult to insert music
accompaniment. More precisely, you can insert it,
but it will either be too "clumsy",or
tooshort, or just because of the music
there will be no room left for the normal effect.
I think this partly influences the desire
programmer to write intrusion data.
I hope that with the help of my program everything
it will become easier.
I’ll say right away that the result obtained is
"code", can be much largernit
original music file, no moth
"code" after packaging, for example, with RIP
takes many times less.
Small characteristics:
Player size - 400 bytes.
Takes clock cycles - from 900 to 3300,
it all depends on the muse :)
Maximum byte - 16384.
Channel layout - ABC.
Input file - Pro-Tracker v3.5x
doesn't understand DELAY=2
Let me give you some statistics. B
application you will find all the melodies thatrs
I have included it in this list.
-----------T------------T-------T-----------------T------------¬
¦Music Name¦Original Len¦SAG Len¦SAG after RIP Len¦Rask Percent¦
+----------+-----------+-------+-----------------+------------+
¦NOSE.m ¦ 1433 ¦ 08057 ¦ 07b5 ¦ 91 ¦
¦ESP4ANY.m ¦ 2702 ¦ 12b19 ¦ 1912 ¦ 85 ¦
¦PPQ1.m ¦ 2049 ¦ 04411 ¦ 0717 ¦ 83 ¦
¦kukushka.m¦ 4008 ¦ 12985 ¦ 2334 ¦ 82 ¦
¦IMAGIN.m ¦ 419b ¦ 15b10 ¦ 2398 ¦ 85 ¦
L----------+-----------+-------+-----------------+-------------
I would like to point out right away that the original
and the converted melodies werebwithout
player, and the packed filesbwithout
unpacker.
A little more information: I packed the refonethmodule PPQ1.m, and received a file of 617 bytes,
i.e. the packaged source module occupies
less than the packaged converted one :)
But it doesn't matter! My module is playing
player in 400 bytes, and the original how much
takes? That's right, approximately 3400 bytes,
and how crap it packs, approximately2100
byte :) I think now it’s clear what I mean.
Well, I immediately remembered the bug! This version
the program does not “know how” to control the volume
the resulting module. Thus, if
during the conversion, you noticed that the volume
shows more melody16384,to
soon, or everything will freeze, landbo
one of two :) In short, the muse is pgrowtho
will not fit into memory :)
Briefly about the operating algorithm.
Let me clarify, the program understands melodies
only from the editor Pro-Tracker v3.5x and
only without the player.
1. We break down the melody into patterns.
2. We decompose each pattern into channels
A, B and C.
3. Making a list of "original"
channels. Those. remove the duplicateayou
channels from different patterns.
4. Convert each channel separatelysti
according to my algorithm.
5. Create a list of packed channels.
6. We arrange the channels in accordance with
Position List melody, i.e., roughly
speaking, we arrange patterns that
consist of offsets to each channel.
7. Set Loop, i.e. looping
melodies.
Now comes the worst part. Because of
features of the packing algorithm, we get
an impressive list of "NO", which
must be taken into account by the musician when creating
his masterpiece, and this, of course, is very good
sad. But, unfortunately, this is fakt.
I couldn’t predict some disadvantages,and
here is the result - there are glitches :)
You cannot:
1. Use in one of the channels
pattern alternating DELAY commands.
I’ll explain why, I pack by channel, and
this means that when packing channel A of the pattern
5, DELAY will always be equal to the current one,
and if in this pattern in channel Bthere was a change DELAY, then the packing of channel A
will not pay attention to this, because...
I repeat - the packaging goes by channel!!!
And, when I pack channel A, I knownot
I know what pattern it is from, andteat
more, what happens there in channel B.
2. Use the envelope simultaneously in
different channels.
Consider an example:
We had an envelope in channel B and we
it was successfully converted. Then we got caught
channel C from this pattern, where it turned on
envelope without changing frequency, and why is it
will it lead? That's right, the converter will insert
command to turn on the envelope, will indicate it
period, but only the envelope frequencies are not
there will be! It will be equal to zero, which meansnri
during playback, zero values will be entered
to frequency registersenvelope, and you not
hear what happened before thisthin
channel B.
3. Use effects in the melody
"sound continuation" from the previous one
pattern. Those. use in
previous patterns the sound that
must continue to sound in
this channel but in a different pattern.
In this case, the converter will take the channel
pattern in which it should continue
sound and pack it. Ho, because first
there are no notes in the pattern, there will be sound
again zero.
4. Indicate a note at the beginning of the channel, not
containing information about the SE numbermpla,
ornament and volume. The volume is
Let's say that when packing it becomes F, and here it is
sample with ornament will be equal to fig
knows what, which means instead of sound
It will be rubbish and crap. So no
forget at the beginning of each channel
indicate real tool numbers.
This is again due to the fact that the packer
works channel by channel, and it does nothing
knows about what was there before him
installed. Every time everything is reset.
Based on this, you can doat
a small recommendation:
Keep your money in a savings accountass!
Ugh, glitch!
When writing a melody, try more often
use the same channels in different
patterns. For example, creating one bass rhythm
game, try to tie everything to it.
I think once you use it, you will understand.
This version is very crude, after
converting one Mouzon the second already
won't work :) This is a speed error
assemblies,tried to be in time before CAFe'03,
so that you may create your own masterpiecep
4K intro.
In the application you will find compilersannath
under #C000 the muse player, as well as his
sources. And for those who are very interested
The source will be below :)
Now about how to do anything in general,
and how to achieve optimal results.
So... About what to do with
muse, I already wrote, but here’s what to do
after conversion:
I'll consider the option with a player.
To begin, download the SAG module from
player. By the way, after packing the musebudet
reproduced, and on the border you goe
a couple of stripes. Red is so simple, but
blue is, in fact, the player’s taktomep,
- how many cycles does it consume? :)
Then you need to roughly estimate, and
how long will it take when packed?
form? Loading RIP (Real Information Packer)
and pack the muse. We see an approximate result
packages We estimate and, if everything is ok, we write
continue your program :)
I note that packing RIPom is more profitable.
It compresses much more powerfullyHRUSTa. AND
Of course, you understand that the maximumnth
you will receive the result of the package onlypri
packaging your entire program vmnatural.
Suppose you have everything ready, assembled and
object code has been shipped, in the wilds of which
I already have a muse with a player. All that's left is
pack it and that's it.Another tip: for a more soulful
use the packaging result
automatic search of the packaging window in RIP
v0.25, and then you may not win
one ten bytes :)
And finally, I’ll say that the shipped
module SAG slightly non-standard addressesa
input: http://www.the-bravery.ru
#C000 (49152) - Init music
#C043 (49219) - Play music
And there is also one bug :) I think somewhere
lost the BC register, which is why the small
advice, save the BC register after the call
player so that it recovers before
calling the player :)
M1 LD BC,#0000
CALL #C043
LD (M1+1),BC
Perhaps this is an alternative BC, not
I remember. You'll figure it out, I think. If thisoth
not to do it, then it is possible in your programmme
glitches in the music will be heard. I'm onee
player so that it is restored before
calling the player :)
M1 LD BC,#0000
CALL #C043
LD (M1+1),BC
Perhaps this is an alternative BC, not
I remember. You'll figure it out, I think. If this
not to do, it is possible in your program
glitches in the music will be heard. I'm like this
the rake came when I was doing the intro to
Izhnews #0D. Yes! By the way, there is musicain
the interior is packed with exactly this algorithmm.
Upload further, there will be a source :)
Continuation of the article :)
Player source with small explanations
according to the text. Why small? Yes because
I don't remember anything myself :)
TO_PLS EQU #C190 ;Music address
ORG #C000
INIT_MUS
EXX
LD BC,#0000
EXX
JR INIT_MUSIC
ST_PLDECODE
INC HL
LD A,(HL)
CP #FF
JR Z,INSTAL_P
AND %00000011
LD В,A
INC HL
LD C,(HL)
INC HL
RET
INSTAL_P
LD HL,#0001 ;Собственно, тут устанавливаем
LD (INT_A+1),HL ;количество интов, которые
LD (INT_В+1),HL ;пропускаются между изменением
LD (INT_C+1),HL ;звука, проще говоря, QUARKSPOP AF ;почти
INIT_MUSIC
PILA LD (PIL+1),SP
PL_AD LD SP,ТО_PLS
LOOP POP HL ;HL
LD A,H ;H
OR L ;L
JR NZ,NO_LOOP
POP HL ;Надо сделать цикл музы
LD SP,HL
JR LOOP
NO_LOOP
LD (CHN_A+1),HL
POP HL
LD (CHN_В+1),HL
POP HL
AAS1 LD (CHN_C+1),HLLD (PL_AD+1),SP
PIL LD SP,#0000
PLAY_MUSIC
INT_A LD HL,#0001
DEC HL
LD (INT_A+1),HL
LD A,H
OR L
JR NZ,INT_В
INC L
LD (INT_A+1),HL
CHN_A LD HL,#0000
BIT 7,(HL)
JR Z,PL_AD_A
CP_AF LDA,#00 ;Указали регистр тона канала А
CP_A LD Е,#08 ;Указали регистр громкости
CALL ZALUPA2
ЕР_A LD (CHN_A+1),HL
INT_В LD HL,#0001
DEC HL
LD (INT_В+1),HL
LD A,H
OR L
JR NZ,INT_C
INC L
LD (INT_В+1),HL
CHN_В LD HL,#0000
BIT 7,(HL)
JR Z,PL_AD_В
CP_BF LD A,#02 ;тоже для канала В
CP_В LD Е,#09 ;-----------------
CALL ZALUPA2
ЕР_В LD (CHN_В+1),HL
INT_C LD HL,#0001
DEC HL
LD (INT_C+1),HL
LD A,H
OR L
RET NZ
INC L
LD (INT_C+1),HL
CHN_C LD HL,#0000
BIT 7,(HL)
JR Z,PL_AD_C
CP_CF LD A,#04 ;указали все для канала С CP_C LD Е,#0A ;------------------------
CALL ZALUPA2
ЕР_C LD (CHN_C+1),HL
RET
PL_AD_A
CALL DECODE ;Декодер команд
LD (INT_A+1),ВС
JR ЕР_A
PL_AD_В
CALL DECODE
LD (INT_В+1),ВС
JR ЕР_В
PL_AD_C
CALL DECODE
LD (INT_C+1),ВС
JR ЕР_C
ZALUPA2
LD (REG_MT+1),A
INC A
LD (REG_ST+1),A
LD A,Е
LD (REG_VOL+1),A
ZALUPA
LD A,(HL)
INC HL
CP #BF
RET Z
RRA
JR C,TN_1 ;0 BIT
CALL ML_TONE ;Nзmененlow byte of tone
RRA
JR C,TN_2
JR ENV
TN_1
RRA ;1 BIT
JR C,ENV
TN_2 CALL ST_VL_TONE ;The high byte of the tone has been changed
;and volume
ENV
RRA
JR C,ENV_1
CALL ML_FRQ ;The low byte of the envelope has been changed
RRA
JR NC,MIX
JRENV_0
ENV_1
RRA
JR C,MIX
ENV_0
CALL ST_FRQ ;Nзmенен старший байт огибающей
MIX
RRA
JR C,MIX_1
RRA
JR NC,ENV_PER ;Nзmенен период огибающей
MIX_FL
CALL ENV_PER
JR NS_MIX
MIX_1
RRARET C
NS_MIX
LD D,(HL) ;Настройка микшера (7 рег)
LD A,(REG_VOL+1)
CP #09
JR C,MIX_A
JR Z,MIX_В
LD A,D
RRCA
RRCA
LD Е,A
RRCA
RRCA
AND %00000100
OR Е
AND %00100100ЕХХ
LD C,A
MIXER
MIXER_A LD A,#00
OR В
OR C
ЕХХ
LD Е,#0б
CALL OUTS
INC Е
MIXUS CALL ТО_PORT
OUT (C),A
ЕХ AF,AF'
RET
MIX_A
LD A,D
RLCA
RLCA
LD Е,A
RLCA
RLCA
AND %00001000
OR Е
AND %00001001
LD (MIXER_A+1),A
ЕХХ
JR MIXER
MIX_В
LD A,D
RRCA
RRCA
RRCA
AND %11111101
LD Е,A
RRCA
RRCA
AND %00000010
OR Е
AND %00010010
ЕХХ
LD В,A
JR MIXER
ML_TONE
REG_MT LD Е,#04
JR OUTS
ML_FRQ
LD Е,#0В
ENV_EN LD C,A
LD A,(HL)
INC HL
OR A
LD A,C
RET Z
DEC HL
JR OUTS
ST_FRQ
LD Е,#0C
JR ENV_EN
ENV_PER
LD Е,#0D
JR ENV_EN
OUTS CALL ТО_PORT
OUTI
RET
ТО_PORTLD ВС,#FFFD
OUT (C),Е
LD В,#BF
RET
ST_VL_TONE
LD D,A
ЕХ AF,AF'
LD A,D
RLA
RLA
AND %01000000
RLCA
RLCA
LD C,A
LD A,(HL)
INCHL
LD D,A
RLCA
AND %00001110
OR C
REG_ST LD Е,#05
CALL ТО_PORT
OUT (C),A
LD A,D
RRCA
RRCA
RRCA
REG_VOL LD Е,#0A
JR MIXUS
------------------------------------------
A small piece of extra
code. This subroutine can be placed
at will, because there is no special meaning in
she doesn't. She customizes the player to suit your
channel layout that you need for it
specify yourself :)
CHN DEFB "ABC" ;Indicate your layout
………
LD HL,CHN
LD A,(HL)
SUB "A"-8
LD(CP_A+1),A
SUB #08
ADD A,A
LD(CP_AF+1),A
INC HL
LD A,(HL)SUB "A"-8
LD (CP_В+1),A
SUB #08
ADD A,A
LD (CP_BF+1),A
INC HL
LD A,(HL)
SUB "A"-8
LD (CP_C+1),A
SUB #08
ADD A,A
LD (CP_CF+1),A
………
А вот на всякий случай мои писульки o
формате хранения данных. Может, кому чего
подскажет. Вдруг, кто родит идею круче :)
; 7б543210
;%00000000
;
;10 - bit number
;----------------
;00 - change TONE ml. byte (1 byte)
;01 - uolume change and TONE st. byte (1 byte)
;10 - full change TONE ml. byte + Vol + st. byte (2 byte)
;11 - no change
;
;32
;----------------
;00 - change ml.byte Enuelope FRQ (1 byte)
;01 - change st.byte Enuelope FRQ (1 byte)
;10 - full change Enuelope FRQ (2 byte)
;11 - no change
;54
;----------------
;00 - change Enuelope Period (1 byte)
;01 - change NOISE and MIXER (1 byte)
;10 - change Enuelope Period AND Noise AND Mixer
;11 - no change
;б
;----------------
;0 - 0 bit from Volume
;7
;----------------
;1 - no change
;0 - spec command in next byte
;Next byte
;7 = 0 - skip ints (1)
;б = 0 - play from (2Ь), ints (2Ь)
;5 =
;4 =
;3 =
;2 =
;1 - two bits from st byte INTS skip counter
;0 - ///
;TONE and Volume
;-------------------------------
;4 %11111111
;5 %00001111
;A %00011111
;mixed reg5 and regA;%11111111
; ^^^^ - uolume
; ^^^^ - FRQ st. byte
;-------------------------------
;ENVELOPE FRQ
;-------------------------------
;В %11111111
;C %11111111
;-------------------------------
;PERIOD
;D %00001111
;б %00011111
;7 %00100100 only two bits (2 and 5)
;MIXED
;б %00011111
;% ^- Mixer tone (bit 2 reg7)
; %^-- Mixer noise (bit 5 reg7)
That's it, use it...
Send all questions to zxz@fmshop.ru,
or call (3412) 75-37-47 Ilya.
------------------------------------------
Share your thoughts about the article