ORG 23845
ORGX
*D+
; НЛО-2. Дьяволы бездны
; Стартовый менеджер загрузки заставки
; а затем - введение, инструкция или игра
; #6200-#6fff
DSCR EQU #4000
SCR EQU #C000
DEFM " UFO-2 StartUp Manager *"
DEFM " Wrote by Slava MEDNONOGOV *"
DEFM " (c) 1996, COPPER FEET *"
;Декомпрессор
;HL-откуда DE-куда
DLPCB DEFM "2105"
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
DELPCF LD DE,#FFFE
;Декомпрессор
;HL - ОТКУДА И КУДА, DE - ВЕРХНЯЯ ГРАНИЦА ОБЛАСТИ
DELPCX PUSH HL
LD C,(HL)
INC HL
LD B,(HL)
ADD HL,BC
LDDR
EX DE,HL
INC HL
POP DE
JP DELPC
MEM0 XOR A;Cтандартная страница-0
JR MEM
MEM7 LD A,7
MEM OR %11000
PUSH BC
LD BC,#7FFD
OUT (C),A
POP BC
RET
OFFD LD DE,DSCR+#1AFE
LD HL,DSCR+#1AFF
LD BC,768
LD (HL),0
LDDR
LD BC,6143
LD (HL),255
LDDR
RET
OFFS CALL MEM7
OFFS_ LD DE,SCR+#1AFE
LD HL,SCR+#1AFF
LD BC,768
LD (HL),0
LDDR
LD BC,6143
LD (HL),255
LDDR
RET
DEFS 256+ORGX-$
DEFW S,S,S,S,S,S,S,S,S,S,S,S,S,S
TR00 DI
LD IX,#2F5F
CALL DOS
LD IX,#2F65
JP DOS
MEMS OR %10000
PUSH BC
LD BC,#7FFD
OUT (C),A
POP BC
RET
F_DAT
*F XDISK1
S
START ;начало начал
DI
IM 1
LD SP,#6F00
;Теневик off
CALL ON256
XOR A
CALL MEMS
LD DE,#C000
LD BC,#4700
PUSH BC
POP HL
LDIR
CALL OFF256
;Заставка
XOR A
OUT (254),A
CALL OFFD
CALL OFFS
CALL MEM0
LD A,1
CALL LOADF
LD HL,#7000
CALL DELPCF
CALL #7000
;Что нажато
CP 1
JP Z,GAME
JP C,INTRO
;------------
INSTR CALL MEM7
LD A,2
CALL LOADF
LD HL,#DB00
CALL DELPCF
CALL MEM0
LD A,3
CALL LOADF
LD HL,#7000
CALL DELPCF
CALL #7000
JP START
;-----------
INTRO LD A,1
CALL MEMS
LD A,14
CALL LOADF
LD A,4
CALL MEMS
LD A,15
CALL LOADF
XOR A
CALL MEMS
LD A,16
CALL LOADF
LD A,6
CALL MEMS
LD A,17
CALL LOADF
LD A,7
CALL MEMS
LD A,18
CALL LOADF
LD A,3
CALL MEMS
LD A,19
CALL LOADF
XOR A
CALL MEMS
LD A,20
CALL LOADF
LD HL,#7000
LD DE,#BFF0
CALL DELPCX
CALL OFFD
CALL #7000
LD A,7
CALL MEMS
CALL OFFS_
JP START
;-------------
LOADG CALL LOADF
LD HL,#C000
JP DELPCF
GAME DI
CALL OFFD
CALL OFFS
LD A,7
CALL MEMS
LD A,4
CALL LOADG
CALL MEM0
LD A,5
CALL LOADF
LD A,1
CALL MEM
LD A,6
CALL LOADG
LD A,3
CALL MEM
LD A,7
CALL LOADG
LD A,4
CALL MEM
LD A,8
CALL LOADG
LD A,2
CALL MEM
LD A,9
CALL LOADF
LD HL,#8000
CALL DELPCF
LD A,6
CALL MEM
LD A,10
CALL LOADG
; CALL OFFS
DI
LD HL,S_UP
LD DE,S_AD
LD BC,8
LDIR
LD HL,#8000
LD DE,#4000
LD BC,#9000
JP S_AD
S_AD EQU #FFF8
S_UP LDIR
JP #4010
;ФАЙЛЫ:
;1-DANGEROU.LPC L:#7000 *P0 S:#7000
;-----------------
;2-XBINSTR.LP0 L:#DB00 *P7
;3-XBINSTR.LP1 L:#7000 *P0 S:#7000
;-----------------
;4-XCOM3.PG7 L:#C000 *P7
;5-XCOM3.PG0 L:#C000 *P0 /некомпр
;6-XCOM3.PG1 L:#C000 *P1
;7-XCOM3.PG3 L:#C000 *P3
;8-XCOM3.PG4 L:#C000 *P4
;9-XCOM3.PG5 L:#7000 *P5 S:?
;10-XCOM3.PG2 L:#7000 *P2 S:?
;11-?
;12-?
;13-?
;-----------------
;14-XDEMO0.LPC L:#C000 *P1
;15-XDEMO1.LPC L:#C000 *P4
;16-XDEMO2.LPC L:#C000 *P0
;17-XDEMOS6.LPC L:#C000 *P6
;18-XDEMOS7.LPC L:#C000 *P7
;19-XDEMOTXT.LPC L:#C000 *P3
;20-XBEGIN.LPC L:#7000 *P0 S:#7000 E:#BFF0
;-----------------
ST_ADR DEFB #70,#DB,#70
DEFB #C0,#C0,#C0,#C0,#C0,#80,#C0,#70,#70,#DB
DEFB #C0,#C0,#C0,#C0,#C0,#C0,#70,#70
READ DI ;E-sec,D-trk,B-sec.num,HL-mem.adr
CALL POS
LD A,(#5CD6)
EX AF,AF'
NXT_S DEFB #DD
LD L,#3 ;retry.num
NXT_SC PUSH HL
PUSH BC
NXC_C1 PUSH IX
LD C,#5F
LD A,E
CALL RG_DOS
CALL RD_SCT
DI
LD HL,#5CD6
EX AF,AF'
CP (HL)
POP IX
JR Z,GOOD
LD (HL),A
DEFB #DD
DEC L
POP BC
POP HL
JP Z,ERR_RW
EX AF,AF'
JR NXT_SC
GOOD POP BC
POP HL
EX AF,AF'
GOOD1 INC E
LD A,E
CP #FE
JR C,OLD_TR
LD E,#F5
INC D
CALL POS
OLD_TR INC H
INC H
DJNZ NXT_S
DI
XOR A
RET
POS LD A,(SIDE)
OR A
LD A,#3C
JR Z,DW_SID
RES 4,A
DW_SID LD C,#FF
CALL RG_DOS
LD A,D
LD C,#7F
CALL RG_DOS
LD A,#18
LD C,#1F
CALL RG_DOS
CALL COM_EX
DI
RET
RD_SCT LD BC,RD_SCT
PUSH BC
LD BC,#17F
LD IX,#2090
JR DOS
RG_DOS LD IX,#2A53
JR DOS
COM_EX LD IX,#3EF5
DOS PUSH IX
JP #3D2F
ERR_RW SCF
RET
WA RLCA
BA ADD A,L
LD L,A
JR NC,B1
INC H
B1 LD A,(HL)
RET
SIDE DEFB 0
LOADF ;A-N ф-ла (0..20)
PUSH AF
LD D,A
ADD A,A
ADD A,D
LD HL,F_DAT-3
CALL BA
LD E,(HL)
INC HL
LD D,(HL)
INC HL
LD B,(HL)
POP AF
LD HL,ST_ADR-1
CALL BA
LD H,A
XOR A
LD L,A
LD (SIDE),A
RETRY1 CALL READ
RET NC
LD A,(SIDE)
CPL
LD (SIDE),A
DI
CALL TR00
CALL TR00
CALL TR00
JR RETRY1
ON256 LD A,#10
JR M2
OFF256 XOR A
M2 LD BC,#1FFD
OUT (C),A
RET