IRIS.ss
music by IRONMAN
(C) Ivan Roshchin, Moscow, 1998
________________________________
For the first time seeing this beautiful effect on
PC in the Dos Navigator program (screen sa-
ver 'iris.ss') I transferred it to the Spectrum.
Here is the full text of the program with details
comments:
M_X EQU 7 ; X scale
M_Y EQU 7 ; Y scale
ORG #6000
;Set attributes:
HALT
LD HL,#5800 LD DE,#5801
LD BC,#2FF
LD (HL),L
LDIR
;Рисуем сетку:
LD HL,#4000
LP1 LD A,%01010101
BIT 0,H
JR NZ,NE_FF
CPL
NE_FF LD (HL),AINC HL
LD A,H
CP #58
JR NZ,LP1
;Main loop:
MAIN_LP LD IX,BUFER+#2FF
;The buffer is filled "from end to beginning",
and in the same order it will be displayed
;to the screen in the TO_SCR procedure.
LD H,TAB/#100
LD DE,(M_3)
LD A,24
LOOP_V EX AF,AF'
LD BC,(M_1)
EXX
LD B,32
LOOP_H EXX
LD A,(MEM_BP)
LD L,C
ADD A,(HL)
LD L,B
ADD A,(HL)
LD L,E
ADD A,(HL)
LD L,D
ADD A,(HL)
AND #7F
;The most significant bit of the accumulator is cleared, and the buffer is filled with the value
;niyami #00-#7F. This will be useful in the TO_SCR procedure.
LD (IX),A
DEC IX
INC C ; !
ADR_MX LD A,M_X
ADD A,B
LD B,A
EXX
DJNZ LOOP_H
EXX
ADR_MY LD A,M_Y
ADD A,E
LD E,A
INC D ; !
EX AF,AF'
DEC A
JP NZ,LOOP_V
LD HL,(MEM_BP)
DEC HL ; !!
LD (MEM_BP),HL
LD A,L
XOR H
LD HL,BUFER+#2FF
XOR (HL)
XOR E
XOR C
ADD A,D
ADD A,B
LD B,A
LD HL,NAPR
AND 3
LD D,0
LD E,A
ADD HL,DE
LD A,(HL)
BIT 3,B
JR NZ,TO_DEC
CP 3
JP P,TO_END
INC (HL)
JR TO_END
TO_DEC CP #FD
JP M,TO_END
DEC (HL)
TO_END LD A,(NAPR)
LD HL,M_1
ADD A,(HL)
LD (HL),A
LD A,(M_2)
LD HL,NAPR+1 SBC A,(HL)
LD (M_2),A
LD A,(NAPR+2)
LD HL,M_3
ADD A,(HL)
LD (HL),A
LD A,(M_4)
LD HL,NAPR+3
SBC A,(HL)
LD (M_4),A
CALL TO_SCR ; Вывод на экранXOR A ; Что-то
IN A,(254) ; нажато?
CPL
AND 31
JR NZ,OBR_Z
;Если не нажато, восстанавливаем масштаб по X и Y:
CALL INC_M
JP MAIN_LP
;Нажата клавиша Z (Zoom) ?
OBR_Z LD A,#FE
IN A,(254) BIT 1,A
RET NZ ; Если нет - выходим
;Если нажата - изменяем масштаб:
CALL DEC_M
JP MAIN_LP
MEM_BP DW 0
M_1 DB 0
M_2 DB 0
M_3 DB 0
M_4 DB 0
NAPR DB 2,1,3,4
;Процедуры INC_M и DEC_M увеличивают и уменьшают масштаб:
INC_M LD HL,ADR_MX+1
LD A,(HL)
CP M_X
JR NC,INC_Y
INC (HL)
INC_Y LD HL,ADR_MY+1
LD A,(HL)
CP M_Y
RET NC
INC (HL)
RET
DEC_M LD HL,ADR_MX+1
LD A,(HL)
AND A
JR Z,DEC_Y
DEC (HL)
DEC_Y LD HL,ADR_MY+1
LD A,(HL)
AND A
RET Z
DEC (HL) RET
;The TO_SCR procedure recodes bytes from the buffer using the pas-
;liters and outputs the result to the attribute file:
TO_SCR LD HL,PALETTE ; palette
LD DE,#5800 ; screen
LD BC,BUFER+#2FF ; end of the buffet
;ra
HALT
LP_S LD A,(BC)
LD L,A
LDI
;I.e. take a byte from the buffer and place it in the L register. This will be;offset in the palette (that's why it should start with the address-
;sa, multiple #100). The LDI command will take a byte from the palette (HL)
;and will place it on the screen at address (DE), which will increase by 1.
;The position in the buffer (BC) will decrease by 1. That HL also
;increases by 1, does not play any role, because H does not change-
;is present (because the buffer contains values 0..#7F), and L is all
;will change equally in the next step.
LD A,(BC)
LD L,A
LDI
LD A,(BC)
LD L,A
LDI
LD A,(BC)
LD L,A
LDI
LD A,(BC)
LD L,A
LDI
LD A,(BC)
LD L,A
LDI
LD A,(BC)
LD L,A
LDI
LD A,(BC)
LD L,A
LDI
LD A,D
CP #5B
JP NZ,LP_S
RET
;Вспомогательные буферы и таблицы:
ORG #C000
;Вспомогательная таблица, начинается с адреса, кратного #100:
TAB DB #40,#40,#40,#40,#40,#40,#40,#40
DB #3F,#3F,#3F,#3F,#3F,#3E,#3E,#3EDB #3E,#3D,#3D,#3D,#3C,#3C,#3B,#3B
DB #3B,#3A,#3A,#39,#39,#38,#38,#37
DB #37,#3б,#35,#35,#34,#34,#33,#32
DB #32,#31,#30,#30,#2F,#2E,#2E,#2D
DB #2C,#2C,#2B,#2A,#29,#29,#28,#27
DB #2б,#25,#25,#24,#23,#22,#22,#21
DB #20,#1F,#1E,#1E,#1D,#1C,#1B,#1B
DB #1A,#19,#18,#17,#17,#1б,#15,#14
DB #14,#13,#12,#12,#11,#10,#10,#0F
DB#0E,#0E,#0D,#0C,#0C,#0B,#0B,#0A
DB #09,#09,#08,#08,#07,#07,#0б,#0б
DB #05,#05,#05,#04,#04,#03,#03,#03
DB #02,#02,#02,#02,#01,#01,#01,#01
DB #01,#00,#00,#00,#00,#00,#00,#00
DB #00,#00,#00,#00,#00,#00,#00,#00
DB #01,#01,#01,#01,#01,#02,#02,#02
DB #02,#03,#03,#03,#04,#04,#05,#05
DB #05,#0б,#0б,#07,#07,#08,#08,#09
DB #09,#0A,#0B,#0B,#0C,#0C,#0D,#0E
DB #0E,#0F,#10,#10,#11,#12,#12,#13
DB #14,#14,#15,#1б,#17,#17,#18,#19
DB #1A,#1B,#1B,#1C,#1D,#1E,#1E,#1F
DB #20,#21,#22,#22,#23,#24,#25,#25
DB #2б,#27,#28,#29,#29,#2A,#2B,#2C
DB #2C,#2D,#2E,#2E,#2F,#30,#30,#31
DB #32,#32,#33,#34,#34,#35,#35,#3б
DB #37,#37,#38,#38,#39,#39,#3A,#3A
DB #3B,#3B,#3B,#3C,#3C,#3D,#3D,#3D
DB#3E,#3E,#3E,#3E,#3F,#3F,#3F,#3F
DB #3F,#40,#40,#40,#40,#40,#40,#40
;Палитра, определяющая цвет эффекта, начинается с адреса,
;кратного #100:
PALETTE DB #09,#09,#09,#09,#09,#09,#09,#09
DB #09,#09,#09,#0B,#0B,#0B,#0B,#0B
DB #0B,#0B,#0B,#0B,#0B,#0B,#1B,#1B
DB #1B,#1B,#1B,#1B,#1B,#1B,#1B,#1B
DB #1A,#1A,#1A,#1A,#1A,#1A,#1A,#1A
DB #1A,#1A,#1A,#12,#12,#12,#12,#12
DB#12,#12,#12,#12,#12,#12,#1б,#1б
DB #1б,#1б,#1б,#1б,#1б,#1б,#1б,#1б
DB #3б,#3б,#3б,#3б,#3б,#3б,#3б,#3б
DB #3б,#3б,#3б,#34,#34,#34,#34,#34
DB #34,#34,#34,#34,#34,#34,#24,#24
DB #24,#24,#24,#24,#24,#24,#24,#24
DB #25,#25,#25,#25,#25,#25,#25,#25
DB #25,#25,#25,#2D,#2D,#2D,#2D,#2D
DB #2D,#2D,#2D,#2D,#2D,#2D,#29,#29
DB #29,#29,#29,#29,#29,#29,#29,#29;Intermediate buffer, can start at any address:
BUFER DS #300
_____
How can you experiment with this
program:
- change the scale (constants M_X and
M_Y). This can also be done directly
while the program is running by pressing the key
'Z'.
- instead of the commands INC C and INC D, place
enlarged "!", you can put commands that increase
reducing (or decreasing) C registers and
D not by 1, but by any other number.
- DEC HL command marked "!!",
can be replaced with several such commands
(or, for example, INC HL commands).
- change the contents of the TAB table.
- change the set of colors using pa-
liters (PALETTE array).
You can change all the above parameters
parameters and directly during operation
program, if you make it self-modifying
swearing.
________________________________
Share your thoughts about the article