;(C)1991,92 Graphic Library V1.1 for UFO2
;Mednonogov V.S.
NOP_ EQU 0
OR_ EQU #B6
XOR_ EQU #AE
AND_ EQU #A6
NEG_ EQU #2F
PUTATR PUSHs;$
LD A,31
SUB L
JR C,RETPAT
INC A
CP B
JR C,PUTAT0
LD A,B
PUTAT0 SUB B
NEG
LD (PUTAT4+1),A
SUB B
NEG
LD (PUTAT2+1),A
LD A,H
RRCA
RRCA
RRCA
LD B,A
AND %11100000
OR L
LD L,A
LD A,B
AND %0000011
SELAT1 ADD A,#58
LD H,A
PUTAT1 LD A,H
SELAT2 CP #5B
JR NC,RETPAT
PUSH HL
PUTAT2 LD B,#FF
PUTAT3 LD A,(DE)
INC DE
LD (HL),A
INC HL
DJNZ PUTAT3
PUTAT4 LD HL,0
ADD HL,DE
EX DE,HL
POP HL
LD A,L
ADD A,%00100000
LD L,A
JR NC,PUTAT7
INC H
PUTAT7 DEC C
JR NZ,PUTAT1
RETPAT POPs;$
RET
PUTSIM PUSHs;$ ;HL(0-23,0-31)
LD A,31
SUB L
JR C,RETSIM
INC A
CP B
JP C, PUTSI0
LD A,B
PUTSI0 SUB B
NEG
LD (PUTSI4+1),A
SUB B
NEG
LD (PUTSI2+1),A
PUTSI1 LD A,H
CP 24
JR NC,RETSIM
PUSH HL
PUSH DE
EX DE,HL
CALL SCOORD
POP DE
PUTSI2 LD B,0
PUSH HL
PUTSI3 LD A,(DE)
INC DE
PUTSID OR (HL)
LD (HL),A
INC L
DJNZ PUTSI3
PUTSI4 LD HL,0
ADD HL,DE
EX DE,HL
POP HL
INC H
LD A,%00000111
AND H
JR NZ,PUTSI2
POP HL
INC H
DEC C
JR NZ,PUTSI1
RETSIM POPs;$
RET
PRINBT DEFB 0
PRINT PUSH AF
LD (PRINBT),A
LD A,D
CP 24
JR NC,RETPRI
PRIN2 LD A,E
CP 32
JR C,PRIN9
LD E,0
INC D
LD A,D
CP 24
JR NC,RETPRI
PRIN9 PUSHs;$
PRIN8 LD L,(HL)
LD H,0
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,BC
PUSH HL
CALL SCOORD
POP DE
LD B,8
PRIN1 LD A,(DE)
PRINCD OR (HL)
LD (HL),A
INC DE
INC H
DJNZ PRIN1
POPs;$
INC HL
INC E
LD A,(PRINBT)
DEC A
LD (PRINBT),A
JR NZ,PRIN2
RETPRI POP AF
RET
GETSIM PUSHs;$
LD A,B
LD (GETSI2+1),A
GETSI1 PUSH HL
PUSH DE
EX DE,HL
CALL SCOORD
POP DE
GETSI2 LD B,0
PUSH HL
GETSI3 LD A,(HL)
LD (DE),A
INC DE
INC L
DJNZ GETSI3
POP HL
INC H
LD A,%00000111
AND H
JR NZ,GETSI2
POP HL
INC H
DEC C
JR NZ,GETSI1
POPs;$
RET
GETATR PUSHs;$
LD A,B
LD (GETAT2+1),A
LD A,H
RRCA
RRCA
RRCA
LD B,A
AND %11100000
OR L
LD L,A
LD A,B
AND %00000011
SELAT3 ADD A,#5B
LD H,A
GETAT2 LD B,#FF
PUSH HL
GETAT3 LD A,(HL)
LD (DE),A
INC DE
INC HL
DJNZ GETAT3
POP HL
GETAT6 LD A,L
ADD A, %00100000
LD L,A
JR NC,GETAT7
INC H
GETAT7 DEC C
JR NZ,GETAT2
POPs;$
RET
SELSCR LD (SCOSCR+1),A ;A-screen address
LD (BCOSCR+1),A
LD (PCOSCR+1),A
ADD A,#18
LD (SELAT1+1),A; A-attr address
LD (SELAT3+1),A
ADD A,3
LD (SELAT2+1),A
RET
PUTSPR PUSHs;$ ;(de)--(hl)(0-191,0-255):b*c
LD A,L
AND %00000111
LD (SHIFTS+1),A
LD A,L
AND %11111000
RRCA
RRCA
RRCA
LD L,A
LD A,B
PUTSP0 LD (PUTSP2+1),A
PUTSP2 LD B,0
LD A,H
CP %11000000
JR NC,RETPSP
PUSH HL
PUSH DE
EX DE,HL
CALL BCOORD
POP DE
PUTSP1 PUSH BC
XOR A
LD C,A
SHIFTS OR 0
LD B,A
LD A,(DE)
JR Z,PTSPD1
SHFTDO RRA
RR C
DJNZ SHFTDO
PTSPD1 OR (HL)
LD (HL),A
LD A,L
AND %00011111
CP %00011111
JR NC,PUTSP6
LD A,C
INC L
PTSPD2 OR (HL)
LD (HL),A
INC DE
POP BC
DJNZ PUTSP1
PUTSP3 POP HL
INC H
DEC C
JR NZ,PUTSP2
RETPSP POPs;$
RET
PUTSP6 POP BC
PUTSP7 INC DE
DJNZ PUTSP7
JR PUTSP3
BCOORD LD A,D ;de(0-191,0-31) -- hl
RRCA
RRCA
RRCA
AND %00011000
LD H,A
LD A,D
AND %00000111
ADD A,H
BCOSCR ADD A,%01000000
LD H,A
LD A,D
RLA
RLA
AND %11100000
OR E
LD L,A
RET
PUTSCR PUSHs;$ ;(de)--(hl)(0-191,0-31):b*c
LD A,31
SUB L
JR C,RETPTS
INC A
CP B
JR C,PUTSCB
LD A,B
PUTSCB SUB B
NEG
LD (PUTSC4+1),A
SUB B
NEG
LD (PUTSC2+1),A
PUTSC2 LD B,0
LD A,H
CP %11000000
JR NC,RETPTS
PUSH HL
PUSH DE
EX DE,HL
CALL BCOORD
POP DE
PUTSC1 LD A,(DE)
PUTSCD OR (HL)
LD (HL),A
INC DE
INC L
DJNZ PUTSC1
PUTSC4 LD HL,0
ADD HL,DE
EX DE,HL
POP HL
INC H
DEC C
JR NZ,PUTSC2
RETPTS POPs;$
RET
SCOORD LD A,D ;de(0-23,0-31)--hl
AND %00011000
SCOSCR ADD A,%01000000
LD H,A
LD A,D
RRCA
RRCA
RRCA
AND %11100000
OR E
LD L,A
RET
LINE PUSHs;$ ; line from p1(l,h) to p2(e,d)
PUSH IX
LD IX,DATA01
LD B,#15
LD C,#1D
LD A,E
SUB L
JR NC,M1LIN
NEG
EX DE,HL
M1LIN LD L,A
LD A,D
SUB H
JR NC,M2LIN
NEG
DEC B
M2LIN LD H,A
CP L
JR C,M3LIN
LD A,B
LD B,C
LD C,A
LD A,H
LD H,L
LD L,A
M3LIN LD A,B
LD (DEPENC),A
LD A,C
LD (INDEPC),A
PUSH DE
LD C,L
LD E,L
LD L,H
CALL DIVB
LD A,E
LD (SIMLIN+1),A
LD L,C
LD A,L
LD (LDLIN+1),A
LD A,D
LD (DECLIN+1),A
OR A
LD B,E
RR B
INC B
OR A
RR C
POP DE
INC L
JR L4LIN
SIMLIN LD B,#FF
L4LIN PUSH HL
CALL DOT
POP HL
INDEPC DEC D
DEC L
JR Z,RETLIN
LD A,C
DECLIN SUB #02
LD C,A
JR C,LDLIN
DJNZ L4LIN
DEPENC DEC E
JR SIMLIN
LDLIN ADD A,#FF
LD C,A
JR L4LIN
RETLIN POP IX
POPs;$
RET
PCOORD LD A,D ;de(0-191,0-255) -- hl
RRCA
RRCA
RRCA
LD L,A
AND %00011000
LD H,A
LD A,D
AND %00000111
ADD A,H
PCOSCR ADD A,%01000000
LD H,A
LD A,L
LD L,E
RRA
RR L
RRA
RR L
RRA
RR L
RET
DATA01 DEFB 128,64,32,16,8,4,2,1
OUTBT OR (HL)
LD (HL),A
RET
DOT LD A,D ;POINT(X:=E,Y:=D)
CP %11000000
RET NC
LD A,E
AND %00000111
LD (DCDOT+2),A
CALL PCOORD
DCDOT LD A,(IX+0)
DOTREG OR (HL)
LD (HL),A
RET
CHNGRG LD (OUTBT),A
LD (PUTSCD),A
LD (DOTREG),A
LD (PTSPD1),A
LD (PTSPD2),A
LD (PUTSID),A
LD (PRINCD),A
RET
PLOT PUSH IX ;*********PLOT E,D
PUSH HL
LD IX,DATA01
CALL DOT
POP HL
POP IX
RET
;MATHEMATICAL LIBRARY MATH-ZX
FREE16 DEFW #F5F5
MULB2 PUSH HL ;HL*E--DE (C)
JR MULENT
MULB PUSH HL ;L*E--DE
LD H,0
MULENT LD A,E
LD E,0
LD D,E
JR MMULB2
MMULB1 ADD HL,HL
JR C,ENDMUL
MMULB2 OR A
JR Z,ENDMUL
RRA
JR NC,MMULB1
EX DE,HL
ADD HL,DE
EX DE,HL
JR MMULB1
ENDMUL POP HL
RET
MUL PUSH HL ;HL*DE--DE
XOR A
OR D
JR Z,MULENT
EX DE,HL
XOR A
OR D
JR Z,MULENT
SCF
POP HL
RET
DIVB LD D,0 ;E/L--E (MOD in D)
DIVB2 PUSH HL ;DE/L--E
PUSH BC
LD B,8
EX DE,HL
LD D,E
LD E,0
DIV1B OR A
RR D
RR E
SBC HL,DE
JR NC,MDIVB
ADD HL,DE
MDIVB RLA
DJNZ DIV1B
CPL
LD D,L
LD E,A
POP BC
POP HL
RET
SYMBOL PUSH HL;in L -sym.code
LD H,L
LD L,#21
LD (PRIN8),HL
CALL PRINT
LD HL,#266E
LD (PRIN8),HL
POP HL
RET
ATRBAR PUSH HL; A -ATTR
LD H,A
LD L,#3E
LD (PUTAT3),HL
POP HL
CALL PUTATR
PUSH HL
LD HL,#131A
LD (PUTAT3),HL
POP HL
RET
SIMBAR PUSH HL
LD H,A ; A-filled byte
LD L,#3E
LD (PUTSI3),HL
POP HL
CALL PUTSIM
PUSH HL
LD HL,#131A
LD (PUTSI3),HL
POP HL
RET
; GrLib end
macro ATRs _hl,_bc,_a;$ MAC
LD HL,_hl;=0
LD BC,_bc;=1
LD A,_a;=2
CALL ATRBAR
ENDM
macro BYTs _hl,_bc,_a;$ MAC
LD HL,_hl;=0
LD BC,_bc;=1
LD A,_a;=2
CALL SIMBAR
ENDM
macro SYMs _de,_a,_l;$ MAC
LD DE,_de;=0
LD A,_a;=1
LD L,_l;=2
CALL SYMBOL
ENDM
macro CHNs _a;$ MAC
LD A,_a;=0
CALL CHNGRG
ENDM
if 0
;Декомпрессор
;HL-откуда DE-куда
DLPCB DEFS 4
DELPC PUSH DE
LD DE,DLPCB
LD BC,4
LDIR
POP DE
xpD0 LD A,(HL)
BIT 7,A
JR NZ,xpD1
PUSH AF
AND 1
LD B,A
LD A,(HL)
AND #E
RRCA
ADD A,3
LD C,A
xpD0X INC HL
LD A,E
SUB (HL)
INC HL
PUSH HL
LD L,A
LD A,D
SBC A,B
LD H,A
LD B,0
LDIR
D00 POP HL
POP AF
RLCA
RLCA
RLCA
RLCA
AND #F
JR Z,xpD0
JR xpDRR
xpD1 INC HL
BIT 6,A
JR NZ,xpD2
AND #3F
JR Z,xpDEND
xpDRR LD C,A
xpDLO LD A,(HL) ;неразрушающий
RRCA
LD (DE),A
INC DE
INC HL
DEC C
JP NZ,xpDLO
JR xpD0
xpD2 AND #3F
ADD A,4
LD C,A
LD A,(HL)
PUSH AF
AND #F
LD B,A
JR xpD0X
xpDEND LD HL,DLPCB
LD C,4
LDIR
RET
endif
;XECUTE MOUSE
;TAKE COORDINATES FROM CURPOS==MX
MOUSE LD HL,(COORD)
LD BC,#FBDF
LD DE,(OLDCO)
IN A,(C)
LD (OLDCO),A
SUB E
JR Z,NM_X
JP P,MX_PL
ADD A,L
JR C,ZER_X
XOR A
ZER_X LD L,A
JR NM_X
MX_PL ADD A,L
JR C,BEX_Z
CP #FD ;MAXIMUM X
JR C,BEX_B
BEX_Z LD A,#FD ;MAXIMUM X
BEX_B LD L,A
NM_X LD B,#FF
IN A,(C)
LD (OLDCO+1),A
SUB D
JR Z,NM_Y
NEG
JP P,MY_PL
ADD A,H
JR C,ZER_Y
XOR A
ZER_Y LD H,A
JR NM_Y
MY_PL ADD A,H
JR C,BEY_Z
CP #BE ;MAXIMUM Y
JR C,BEY_B
BEY_Z LD A,#BE ;MAXIMUM Y
BEY_B LD H,A
NM_Y LD A,H
CP #FF
JR C,BIGY
LD H,#FF
BIGY CP #02 ;MINIMUM Y
JR NC,SMALY
LD H,#02 ;MINIMUM Y
SMALY LD A,L
CP #FF
JR C,DIRY
LD L,#FF
DIRY CP #02 ;MINIMUM X
JR NC,DIMENS
LD L,#02 ;MINIMUM X
DIMENS LD (COORD),HL
LD BC,#FADF
LD HL,CONTRB
IN A,(C)
CPL
AND 7
RLCA
RLCA
RLCA
RLCA
OR (HL)
LD (HL),A
RET
COORD DEFW #8FE4
MX EQU COORD
MY EQU MX+1
OLDCO DEFW 0 ;WORKING
;=========================================Мeнeджер памяти
if 0
PT128 LD A,6;Cтандартная страница
JR MEM
MEM7 LD A,7
MEM OR %11011000
_128 ;LD BC,#7FFD
;OUT (C),A
ld b,tpgs/256
and 7
ld c,a
ld a,(bc)
SETPGC000
RET
endif
OFFD LD DE,DSCR+#1AFE
JR offx
OFFS CALL MEM7
LD DE,SCR+#1AFE
offx PUSH DE
POP HL
INC HL
LD BC,768
LD (HL),0
LDDR
LD BC,6143
LD (HL),255
LDDR
RET
COLOR DEFB #38,#68
COPY ;копир.экр
LD BC,6144
CY_ LD HL,DSCR
LD DE,SCR
LDIR
RET
COPYAT LD BC,6912
JR CY_
MNU CALL INIMNU ;Вывод меню с ожид.
CALL MENU
CALL MEM7
LD HL,#FFFF
LD (MBEG),HL
CALL COPYAT
MnU CALL MARK_
JR C,MnU
MNu CALL MARK_
RET C
JR MNu
STD LD A,DSCR/256 ;выбор экрана
JR STDS
STS LD A,SCR/256
STDS CALL SELSCR
XOR A
JP CHNGRG
;поиск по таблицам
BT PUSH HL
ADD A,L
LD L,A
JR NC,BT_
INC H
BT_ LD A,(HL)
POP HL
RET
WT RLCA
ADD A,L
LD L,A
JR NC,WT_
INC H
WT_ LD A,(HL)
INC HL
LD H,(HL)
LD L,A
RET
;описатели вода текста
SX DEFB 0
SY DEFB 0
TXT DEFW 0
HIGH DEFB 0 ;высота(1/0)
;вывод слова
WORDHL LD (TXT),HL
WORD LD HL,(TXT)
LD A,(HL)
INC HL
LD (TXT),HL
CP #80
JR NC,Compr
CP #7E
RET NC
CALL LETTER
JR WORD
Compr AND #7F
LD HL,TWCMPR
CALL WT
PUSH HL
LD A,L
CALL LETTER
POP HL
LD A,H
CALL LETTER
JR WORD
LETTER LD L,A
LD H,0
LD A,(SY)
CP 24
JR NC,W2
ADD HL,HL
ADD HL,HL
ADD HL,HL
LD BC,FONT
ADD HL,BC
LD DE,(SX)
LD A,(HIGH)
OR A
JR NZ,WH2
PUSH HL
CALL SCOORD
POP DE
LD B,8
WH1 LD A,(DE)
LD (HL),A
INC DE
INC H
DJNZ WH1
JR W2
WH2 LD C,2
WH21 PUSH DE
PUSH HL
CALL SCOORD
POP DE
LD B,4
WH22 LD A,(DE)
INC DE
LD (HL),A
INC H
LD (HL),A
INC H
DJNZ WH22
EX DE,HL
POP DE
INC D
DEC C
JR NZ,WH21
W2 LD A,(SX)
INC A
CP 32
JR C,W3
XOR A
W3 LD (SX),A
RET
;вывод текста
TEXT LD (TXT),HL ;выв.текста
TT CALL WORD
PUSH AF
LD HL,(SX)
LD L,0
INC H
LD A,(HIGH)
AND A
JR Z,TQ
INC H
TQ LD (SX),HL
POP AF
JR Z,TT
RET
MWINX DEFB 1
MWINY DEFB 1
MMOV CALL CONTR
MMOV_ LD C,A
LD HL,(MX)
RR C
JR NC,_1A
INC L
INC L
_1A LD A,252
CP L
JR NC,_1
LD L,A
_1 RR C
JR NC,_2A
DEC L
DEC L
_2A LD A,(MWINX)
CP L
JR C,_2
INC A
LD L,A
_2 RR C
JR NC,_3A
INC H
INC H
_3A LD A,187
CP H
JR NC,_3
LD H,A
_3 RR C
JR NC,_4A
DEC H
DEC H
_4A LD A,(MWINY)
CP H
JR C,_4
INC A
LD H,A
_4 LD (MX),HL
RR C
RET
;---------NUMERIC I/O------
DCM DEFW 51712,15258
DEFW 57600,1525
DEFW 38528,152
DEFW 16960,15
DEFW 34464,1
DEFW 10000,0
DEFW 1000,0
DEFW 100,0
DEFW 10,0
DEFW 1,0
WTRB LD L,A;байт в DCS
LD H,0
WTRW EXX ;слово в DCS
LD HL,0
EXX
WTRD PUSH IX ;двойное слово в DCS
LD A,15
LD (WWB+1),A
LD IX,DCM
LD BC,DCS
EX AF,AF
LD A,10
WWW CP 1
PUSH AF
EX AF,AF
POP AF
JR NZ,WW5
XOR A
LD (WWB+1),A
WW5 PUSH BC
LD C,0
LD E,(IX)
LD D,(IX+1)
EXX
LD E,(IX+2)
LD D,(IX+3)
EXX
INC IX
INC IX
INC IX
INC IX
WWM CALL SUBD
INC C
JR NC,WWM
DEC C
CALL ADDD
LD A,C
OR A
JR Z,WWB
XOR A
LD (WWB+1),A
JR WW4
WWB LD C,0
WW4 LD A,C
POP BC
LD (BC),A
INC BC
EX AF,AF
DEC A
JR NZ,WWW
POP IX
RET
DCS DEFM "cooperfeet"
DEFB 126,103,126 ;$
SUBDW EXX
LD DE,0
EXX
SUBD OR A
SBC HL,DE
EXX
SBC HL,DE
EXX
RET
ADDDW EXX
LD DE,0
EXX
ADDD ADD HL,DE
EXX
ADC HL,DE
EXX
RET
;вывод байта
WBHL LD A,(HL)
WB PUSHs;$
EXX
PUSH DE
PUSH HL
EXX
CALL WTRB
LD HL,DCS+7
JR WX
;вывод слова
WW PUSHs;$
EXX
PUSH DE
PUSH HL
EXX
LD A,(HL)
INC HL
LD H,(HL)
LD L,A
CALL WTRW
LD HL,DCS+5
JR WX
;вывод двойного слова
WD PUSHs;$
EXX
PUSH DE
EXX
LD E,(HL)
INC HL
LD D,(HL)
INC HL
LD C,(HL)
INC HL
LD B,(HL)
PUSH BC
EXX
EX (SP),HL
EXX
EX DE,HL
CALL WTRD
LD HL,DCS
WX CALL WORDHL
EXX
POP HL
POP DE
EXX
POPs;$
RET
;==================Прямая траектория
LINini LD B,#15 ;инициализ. линии (DE->hl)
LD C,#1D
LD A,E
SUB L
JR NC,M1l
NEG
DEC C
M1l LD L,A
LD A,D
SUB H
JR NC,M2l
NEG
DEC B
M2l LD H,A
CP L
JR C,M3l
LD A,B
LD B,C
LD C,A
LD A,H
LD H,L
LD L,A
M3l LD A,B
LD (DENC),A
LD A,C
LD (INDC),A
PUSH DE
LD C,L
LD E,L
LD L,H
CALL DIVB
LD A,E
LD (SIMl+1),A
LD L,C
LD A,L
LD (LDl+1),A
LD A,D
LD (DECl+1),A
OR A
LD B,E
RR B
INC B
OR A
RR C
POP DE
INC L
LD A,L
LD (LIN_LN),A
LD (LIN_BC),BC
LD (LIN_XY),DE
RET
LIN_BC DEFW 0
LIN_XY DEFW 0 ;тек.поз
LIN_LN DEFB 0 ;длина
LINnxt ;след. точка (DE)
LD BC,(LIN_BC)
LD DE,(LIN_XY)
LINnx_
INDC DEC D
LD A,C
DECl SUB 00
LD C,A
JR C,LDl
DJNZ L4RT
DENC DEC E
SIMl LD B,#FF
JR L4RT
LDl ADD A,#FF
LD C,A
L4RT LD (LIN_BC),BC
LD (LIN_XY),DE
RET
;--------------- Звук -----------------
EXS1 ;ракетн, диср, термоп, Г-пушка, взрывы
DEFB 7,%11010010, 6,1, 4,99, 8,16, 10,16, 5,#C, 1,#F, 12,70, 13,1
DEFB 255
SOU0 ;ракетница, диср
DEFB 7,%11111010, 0,0, 4,33, 8,16, 10,16, 5,9, 1,#E, 12,130, 13,1
DEFB 255
SOU4 ;термоп
DEFB 7,%11111110, 0,0, 8,16, 1,#C, 12,144, 13,1
DEFB 255
SOU5 ;Г-пушка
DEFB 7,%11111010, 0,10, 4,15, 8,16, 10,16, 5,9, 1,9, 12,125, 13,1
DEFB 255
EXS3 ;морт,руж,гарп,газ
DEFB 7,%11010111, 6,17, 12,26, 13,1
DEFB 255
SOU2 ; волн.р & м, MC-контр
DEFB 7,%11010010, 6,1, 4,100, 8,16, 10,16, 5,12, 1,10, 12,20, 13,1
DEFB 255
SOU6 ; гарп
DEFB 7,%11010010, 6,15, 8,16, 10,16, 5,7, 1,7, 12,9, 13,1
DEFB 255
TCH7 ;резаки
DEFB 7,%11111010, 8,16, 10,16, 5,8, 1,9, 12,16, 13,1
DEFB 255
TCH8 ;шок, аптечка, тент
DEFB 7,%11111010, 8,16, 1,9, 12,3, 13,1
DEFB 255
SOU9 ; газ.р
DEFB 7,%11011010, 6,1, 4,10, 8,16, 10,16, 5,14, 1,14, 12,14, 13,1
DEFB 255
BEP10 ;beep
DEFB 7,%11111010, 4,200, 8,16, 10,16, 5,1, 1,1, 12,7, 13,1
DEFB 255
tSOUND DEFW SOU0,EXS1,SOU2,EXS3,SOU4,SOU5,SOU6,TCH7,TCH8,SOU9,BEP10
NOTA DEFW 1;текущ нота
iSOUND ;инициализ мелодии #A
LD HL,tSOUND
CALL WT
LD (NOTA),HL
RET
SOUNDn CALL iSOUND ;играть звук А
;форматы нот
;(254) - конец ноты
;(255) - конец мелодии
;(0..15) - регистр, (N) - значение
pSOUND ;вып. ноту мелодии
LD HL,(NOTA)
pS0 LD A,(HL)
CP 254
JR Z,pS1
RET NC
LD BC,#FFFD
OUT (C),A
INC HL
LD A,(HL)
LD B,#BF
OUT (C),A
INC HL
LD (NOTA),HL
JR pS0
pS1 INC HL
LD (NOTA),HL
RET