;*Z80
*O
;*L-
*M-
;*D-
;******** МОДУЛЬ ИНСТРУКЦИИ ДЛЯ НЛО-2********
*P7
ORG #DB00
PIC3
*B ..\DATA\XN3.DTA
PIC2
*B ..\DATA\XN2.DTA
PIC4
*B ..\DATA\XN4.DTA
DEFS 300,222
DEFM " DON'T TOUGHT ME NOW "
PICbeg
*B ..\DATA\XN5.DTA
DEFS 50,50
*L-
*P0
ORG #7000
ENT $
DI
IM 1
XOR A
OUT (254),A
LD (SPSP+1),SP
LD SP,PIC1-4
JP START
DEFM " *** UFO-2 *** Instruction V1.0 ***"
DEFM " Made by Slava MEDNONOGOGV (C) 1996 ***"
DEFM " All right reserved *** "
DEFM " STACK STACK STACK STACK "
PIC1
*B ..\DATA\XN1.DTA
MEM0 LD A,%10011000
MEM_ LD BC,#7FFD
OUT (C),A
RET
MEM7 LD A,%01011111
JP MEM_
MEMR LD A,%10000
JR MEM_
FONT
*B ..\DATA\XNF1.DTA
*B ..\DATA\XNF2.DTA
WTR EI
HALT
HALT
DI
RET
;Декомпрессор
;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
WA RLCA
BA ADD A,L
LD L,A
JR NC,BA_
INC H
BA_ LD A,(HL)
RET
WT RLCA
ADD A,L
LD L,A
JR NC,JA_
INC H
JA_ LD A,(HL)
INC HL
LD H,(HL)
LD L,A
RET
PIC_T DEFW PIC1,PIC2,PIC3,PIC4,PICbeg
DLPPIC ;A-N экр
PUSH AF
LD DE,#4000-17
LD HL,PIC_T
CALL WT
INC HL
INC HL
CALL MEM7
CALL DELPC
CALL OFFS
CALL COPY
POP AF
JP ATRIB
ATR_T DEFB #38,#28,#60,#68,#61,#6
ATRIB LD HL,ATR_T
CALL BA
LD HL,#D800
LD (HL),A
LD DE,#D801
CALL MEM7
LD BC,#2FF
JR AC
SCR EQU #C000
COPY CALL MEM7
LD HL,#4000
LD DE,SCR
LD BC,#1800
AC LDIR
RET
OFFD LD (SPP+1),SP
LD SP,#5B00
JR OFF_
OFFS CALL MEM7
LD (SPP+1),SP
LD SP,SCR+#1B00
OFF_ LD DE,0
LD C,27
OFFF DEFS 128,#D5 ;256 PUSH DE
DEC C
JP NZ,OFFF
SPP LD SP,1111
RET
KEYS ;0-none ;1..5 - <1>..<5> ;6-<A> ;7-<Q> ;8-<E>;9-<O>;10-<P>
LD BC,#F7FE
IN A,(C)
CPL
AND %11111
JR Z,K768
LD C,1
RRA
JR C,K1_5
INC C
RRA
JR C,K1_5
INC C
RRA
JR C,K1_5
INC C
RRA
JR C,K1_5
INC C
K1_5 LD A,C
OR A
RET
K768 LD B,#FD
IN A,(C)
RRA
JR C,K78
LD A,6
OR A
RET
K78 LD B,#FB
IN A,(C)
RRA
JR C,K8
LD A,7
OR A
RET
K8 RRA
RRA
JR C,Kop
LD A,8
OR A
RET
Kop LD B,#DF
IN A,(C)
RRA
JR C,K10
LD A,9
OR A
RET
K10 RRA
JR C,Knon
LD A,10
OR A
RET
Knon XOR A
RET
WAIT CALL KEYS
JR NZ,WAIT
LD BC,#88
WA2 DEC BC
LD A,C
OR B
JR NZ,WA2
RET
START LD A,4
CALL DLPPIC
XI1 CALL KEYS
JR Z,XI1
CALL WAIT
CALL OFFS
XI00 CALL MEM0
CALL OFFD
CALL TEXT
CALL OFFS
CALL COPY
LD A,5
CALL ATRIB
XI0 CALL OFFD
CALL MEM0
CALL TEXT
CALL COPY
CALL MEM0
LD SP,#4004
XI2 CALL KEYS
JR Z,XI2
LD SP,#5B34
CP 6
JR NC,XI3
DEC A
CALL DLPPIC
CALL WAIT
CALL WTR
JR XI00
XI3 CP 7
JR Z,XI4
JR C,XI5
CP 9
JR Z,XI8
JR NC,XI9
CALL OFFS
CALL OFFD
CALL MEMR
SPSP LD SP,#5C00
RET
XI4 CALL PgUp
JR XI0
XI5 CALL PgDwn
JR XI0
XI9 CALL LnUp
JR XI0
XI8 CALL LnDwn
JR XI0
LnUp LD B,2
JR _Up
PgUp LD B,24
_Up LD HL,(TXT1)
LD DE,Instr
PU1 LD A,L
CP E
JR NZ,PU0
LD A,H
CP D
JR NZ,PU0
LD (TXT1),DE
RET
PU0 DEC HL
LD A,(HL)
CP 126
JR NZ,PU1
DJNZ PU1
INC HL
LD (TXT1),HL
RET
LnDwn LD B,1
JR _Dwn
PgDwn LD B,23
_Dwn LD HL,(TXT1)
PD1 LD A,(HL)
INC HL
CP 127
RET Z
CP 126
JR NZ,PD1
DJNZ PD1
LD (TXT1),HL
RET
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,INCMPR
CALL WT
PUSH HL
LD A,L
CALL LETTER
POP HL
LD A,H
CALL LETTER
JR WORD
LETTER OR A
JR Z,W2
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
PUSH HL
LD A,(SY)
LD HL,YT
CALL WT
EX DE,HL
LD A,(SX)
LD C,A
LD HL,XDT
CALL BA
LD L,A
LD H,0
ADD HL,DE
POP DE
LD B,8
LD A,C
AND 3
JP Z,L00
CP 2
JP Z,L04
JP C,L06
JP L02
W2 LD A,(SX)
INC A
CP 42
JR C,W3
XOR A
W3 LD (SX),A
RET
Instr
*B ..\DATA\XINSTR.DAT
YT DEFW #4000,#4020,#4040,#4060,#4080,#40A0,#40C0,#40E0
DEFW #4800,#4820,#4840,#4860,#4880,#48A0,#48C0,#48E0
DEFW #5000,#5020,#5040,#5060,#5080,#50A0,#50C0,#50E0
L00 LD A,(DE)
LD (HL),A
INC H
INC DE
DJNZ L00
JP W2
L02 LD A,(DE)
RRCA
RRCA
LD C,A
AND %111111
OR (HL)
LD (HL),A
INC L
LD A,C
AND %11000000
OR (HL)
LD (HL),A
DEC L
INC H
INC DE
DJNZ L02
JP W2
L04 LD A,(DE)
RRCA
RRCA
RRCA
RRCA
LD C,A
AND %1111
OR (HL)
LD (HL),A
INC L
LD A,C
AND %11110000
OR (HL)
LD (HL),A
DEC L
INC H
INC DE
DJNZ L04
JP W2
L06 LD A,(DE)
RLCA
RLCA
LD C,A
AND %11
OR (HL)
LD (HL),A
INC L
LD A,C
AND %11111100
OR (HL)
LD (HL),A
DEC L
INC H
INC DE
DJNZ L06
JP W2
TEXT LD HL,0
LD (SX),HL ;выв.текста
LD HL,(TXT1)
LD (TXT),HL
TT CALL WORD
RET NZ
LD HL,(SX)
LD L,0
INC H
LD (SX),HL
LD A,H
CP 24
JR C,TT
RET
TXT1 DEFW Instr
SX DEFB 2
SY DEFB 1
TXT DEFW 1
XDT DEFB 0,0,1,2,3,3,4,5,6,6,7,8,9,9,10,11,12,12
DEFB 13,14,15,15,16,17,18,18,19,20,21,21,22,23
DEFB 24,24,25,26,27,27,28,29,30,30,30,30
INCMPR
*B ..\DATA\XINSTRCM.DAT
DEFM "*** END OF DATA BLOCK ***"