A piece of assembler. .PROGRAMMING
As you may have already noticed, this section will be devoted to
assembler and programming in it. And lead this section, judging
in all likelihood, it will be me, that is, ANDY Inc. The section will present
various procedures: dampers, scrollers, analyzers, etc.
similar gadgets that were written by me or pulled from
any demos, INTR0... If possible, I will describe them
operating principles. Each procedure will be in the application
in the form of a TASM-4.XLD file (the most convenient assembler in my opinion).
But keep in mind that this assembler is designed for 128K, so owners
48K you can try to assemble the procedures and if not
succeeds, then rewrite (or recode) the text into the format
some 48K assembler. Is it better to buy a 128K machine, and how
as quickly as possible. So, as I already wrote, all procedures will be
located in the TASM-4 files, but here I will only describe
the most tricky parts of programs. By the way, I have a bad habit:
mix number systems. So don't be alarmed if you're alone
the address will be decimal, and the adjacent one will be hexadecimal.
Let's start with. First program: LIN+A2
A ticker with some pretty interesting properties. More precisely -
the line can be increased vertically (or decreased) using buttons 8
(increase) and 9 (respectively, decrease). Moreover, if
You have music loaded and playing on the AU, then use the keys
A, B, C You can set the mode of operation of the string as an analyzer
corresponding channels. Green color on the border shows
what part of HALT is occupied by the program (read ZX Review for 199b
year). The program uses memory for the line buffer
#FFOO-#FFFF and for the output buffer 25000-25128.
Now let's look at the most interesting parts of the program.
1. DI ;disable interrupts
LD (DES+1),SP ;save the stack
LD SP,22528 ;set the stack to the end of the screen + 1
LD HL,0 ;write 0 to HL
DEFS 1024,#E5 ;1024 bytes per #E5 (PUSH HL)
DES LD SP,0 ;restore the stack
EI;enable interrupts
This part of the program is very fast (there is nowhere faster)
clears the bottom third of the screen. A stack is used for this. How
it is known that the stack grows down: when you command PUSH HL (or DE, BC...)
the stack pointer is decreased by 2. We set the stack pointer
to the address of the beginning of screen attributes, i.e. to the end of the screen + 1
byte, write to HL 0 and do PUSH HL 1024 times (command
DEFS assembler X,Y makes X repetitions of number Y). Thus we
We push 2048 0 values onto the stack from addresses #4800 to #57FF, i.e.
we do nothing more than clean the screen. This cleaning method is
The fastest way to clear contiguous areas of memory. But he
takes up a lot of memory (more than 1KB), so you can use
Loop like:
LD HL,0 ;we do the same,
LD В,б4 ;but slower
LX1 DEFS 1b,#E5 ;and it takes up much less memory
DJNZ LX1;
2. LD HL,25000;in HL - the beginning of the buffer for the stack
LD DE,#5000 ;in DE - address on the screen (far left)
LD В,б4 ;в В -height of usable screen area
KLP1 LD (HL),E; in (HL) low byte of address
INC HL ;HL=HL+1
LD (HL),D ; in (HL) high byte of the address
INC HL ;HL=HL+1
CALL INCD ;calculate the address of the next line in the screen
DJNZ KLP1 ;Cycle on line b4
RET
INCD INC D; this is a calculation procedure that is already familiar to many
LD A,D ;the next address on the screen for DE.
AND 7 ;(I described the operating principle in HACKER-5)
RET NZ
LD A,E
ADD A,32
LD E,A
RET C
LD A,H
SUB 8
LD H,A
RETThis program is called before the program runs and
creates a buffer (a specified memory area; in a given
program: 25000-25128) table of addresses of the left edges of the screen bottom
thirds. It turns out something like:
25000 - #00 25004 - #00 ...........
25001 - #50 25005 - #52 ..........
25002 - #00 ........... 2512b - #E0
25003 - #51 ........... 25127 - #57
That is a table of addresses is obtained. Setting the address
stack pointer to 25000. After this we do POP HL. B
As a result, we get the line address at the beginning of the lower third of the screen.
We make another POP HL and now we get the address of the next one in HL
screen lines. Those. this buffer was created so that you can
it was very quick to find out the address of the next line on the screen (much
faster than a procedure like INCD). This method is used
in almost all music games, for quick display of flying sprites
or sine lines. This is why it is used in
program.D.I.
LD (STK+1),SP ;save the stack
LD HL,#FFOO ;address of the ticker buffer
LD SP,25000 ;stack to the beginning of the buffer
LD В,8 ;Cycle of 8 lines (letter height)
ХХХ1 POP DE; take the address from the stack to the screen
LD C,#FF ;in C is always 255 so that B does not change
LDI ;32 times LDI (32 LDI takes 512
LDI ;processor cycles, and LDIR for 32 bytes
.... only 32 times; that - more than bb7! YOU WILL FEEL THE DIFFERENCE!
DJNZ ХХХ1 ;B=B-1, if B=0 then
STK LD SP,0 ;restore the stack
EI
This procedure is not from the file, it is a little more complicated there, because
sometimes you have to repeat the same scroll line several times
times. If you understand even a little assembler and have read my
articles in HACKER-5, then in the text of this creeping line you can easily
you will find both the head block, and the calculation of the symbol address, and the line shift
in the buffer (I just expanded the Loop for the program to work
faster, although it can be sped up a little more), andprocedure
analyzer. If you haven’t read those articles, I recommend them
read. Useful for general development.
Label SETT - the procedure is called, reads the volume from the specified
of the AU channel and writes it to the C0PY+1 label. NEXXAX - output
lines to the screen. LINE - head block of the running line.
Second program: WATERSCR
This procedure is also a running line, but it runs
already up. In addition, when scrolling up, it happens
pixel-by-pixel shift of lines to the left, then to the right: the effect is obtained
water. This program takes a little more time than HALT,
because when accelerating she runs much faster and read her
quite difficult. Music can be inserted into a string by hanging it on
IM 2.
Before starting work, the program creates a table of screen addresses,
already familiar to you from the previous program.
Scrolling procedure SCR0LL:
LD SP,2b25b ; stack to the beginning of the screen address table
LD A, b3; move up b3 screen lines:SC1 POP DE ;in DE - line address on the screen
POP HL; in HL - next line address
PUSH HL ;save HL for the next Cycle
LDI - 32 times; copy the bottom line to the top
DEC A;
JP NZ,SC1 ;
SUPPL shift procedure:
.............
LD SP,2525b;
LD B,1b ;Cycle for 1b*4 (=b4) lines
SUP1 POP HL ;skip line
POP HL ; in HL the address of the beginning of the line on the screen
LD C,32;
AND A ;move it to the right
AA1 RR (HL);
INC L ;
DEC C;
JP NZ,AA1 ;
POP HL ;skip the linePOP HL ;
LD A, L ; set the address of the last byte to HL
0R 31 ;lines in the screen
LD L,A ;
LD C,32;
AND A ;
AA2 RL (HL); move the line to the left
DEC L ;
DEC C;
JP NZ,AA2 ;
DJNZ SUP1;
..........
Of course, the program can be significantly speeded up by expanding Loops
AA1 and AA2, but this will not lead to good results. If you remove
lines marked with ";", then the line will be even more "watery".
Number 3: IM2TEST
This program demonstrates the capabilities of IM 2 mode. It
loads a block containing 9 Mouzons (TEST.C) into memory. After
how youassemble the program, exit to BASIC and
dial RAND0MIZE USR b5000. The music will immediately start playing. Switch-
You can play music by simultaneously pressing the key: SYMB0L SHIFT+
ENTER+ button from 1 to 9. IM 2 also works in TR DOS, but really mu-
The language slows down when the disk is being accessed (interrupts
are prohibited). And in BASIC you can work almost without problems.
The only problem is the amount of free memory:
somewhere up to 30,000. But these are details...
Program 4: SETMUL2
Well, this is just a small glitch. More precisely, a curb glitch. When
You run this program, then the screen and border will appear
stripes, which, if you have PROFI+, must match completely.
But this may not be the case, because... the program is configured for my C0MP,
and on different computers the number of cycles in HALT can be
various. Using the "Q" and "A" buttons you can try to adjust
stripes. This may not work, because... this program has
tuning accuracy 4 clock cycles. Well, in general this program can be
consider it an example showing how effects can be adjusted
on the curb for a computer.In addition to the procedures in TASM, the application has a small
very tricky program: WIYЗ. It can show on one screen
two black and white without pixel loss. The program only works
on 128K machines, because she uses two screens to work: 48th
and 128th. It will be very problematic to write it on 48K: you need
terribly fast, taking less than HALT, copying algorithm
memory blocks of 144 bytes each. I've never seen anything like this before...
stripes. This may not work, because... this program has
tuning accuracy 4 clock cycles. Well, in general this program can be
consider it an example showing how effects can be adjusted
on the curb for a computer.
In addition to the procedures in TASM, the application has a small
very tricky program: WIYЗ. It can show on one screen
two black and white without pixel loss. The program only works
on 128K machines, because she uses two screens to work: 48th
and 128th. It will be very problematic to write it on 48K: you need
terribly fast, taking less than HALT, copying algorithm
memory blocks of 144 bytes each. I've never seen anything like this before...With this I will end the section and write what I will consider
in the next issue: these will be various effects from various
INTR0 (RST 7, M0RTAL COMBAT .....). Also in issue 7 there will be
texts in TASM INTR0 to HACKER 5 and b with the corresponding
files.
With that, I say goodbye until the next issue.
Bye!
ANDY Inc.
Share your thoughts about the article