DEVICE ZXSPECTRUM128
include "../../_sdk/sys_h.asm"
;CLIENT=1
ObWa=16
Cont=6
R7i=%10000000
IRAs=15
IRBl=14
;Font=#C000
;Sprites=#D000
;Maps=#D100
STACK=0x4000
macro HALTER
call yielder
endm
ORG PROGSTART
begin
ld sp,STACK
OS_HIDEFROMPARENT
ld e,3|0x80
OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
ld e,0 ;color byte
OS_CLS
ld a,(user_scr0_high) ;ok
SETPG16K
;CALL Im2 ;Включаем IM 2
LD A,R
LD (SEED),A
LD A,R
LD (SEED+1),A
ifdef CLIENT
ld de,0x0203
OS_NETSOCKET
ld a,l
ld (soc),a
or a
jp m,inet_exiterr_nosoc
inet_exiterr_nosoc
if CLIENT==0
ld a,(soc)
LD DE,port_ia
OS_BIND
ld a,l
or a
jp m,inet_exiterr
endif
if 1==0
ld a,(soc)
LD DE,port_ia
OS_NETCONNECT
ld a,l
or a
jp m,inet_exiterr
endif
;начальная синхронизация
;если master - при этом посылаем свои клавиши, если slave - принимаем клавиши
;TODO для двух игроков:
;???
if CLIENT ;посылаем событие старта
ld a,1
call sendbyte
else ;slave - принимаем событие старта
waitbegin0
call receivebyte
jr z,waitbegin0
endif
endif
CALL Init
Start LD HL,#4000
LD DE,#4001
LD BC,#17FF
LD (HL),L
LDIR
XOR A
LD (FragLim),A
LD (TimeLim),A
LD BC,TGame1
CALL PrintText
LD IX,MGame1
CALL Menu
PUSH AF
CALL Init
POP AF
CP 1
JR Z,Rede
CP 2
JR Z,Info
CP 3
JP Z,Chat
JP StartGame
Info
LD HL,#4000
LD DE,#4001
LD BC,#17FF
LD (HL),L
LDIR
LD BC,TInfo1
CALL PrintText
LD IX,MInfo1
CALL Menu
JP Start
inet_exitcode
inet_exiterr
quit
QUIT
ret
yielder
push af
push bc
push de
push hl
push ix
push iy
YIELD
pop iy
pop ix
pop hl
pop de
pop bc
pop af
ret
Rede
LD HL,#4000
LD DE,#4001
LD BC,#17FF
LD (HL),L
LDIR
Rede1 LD BC,TRede1
CALL PrintText
LD IX,MRede1
CALL Menu
CP 0
JP Z,RedeLeft
CP 1
JP Z,RedeRight
CP 2
JP Z,RedeUp
CP 3
JP Z,RedeDown
CP 4
JP Z,RedeFire
CP 5
JP Z,RedeCGun
CP 6
JP Z,RedeQuit
CP 7
JP Z,RedeExit
JP Start
RedeExit
LD BC,(KeyLeftBC)
LD A,(KeyLeftA)
LD (KeyMe51+1),A
LD (KeyMe5+1),BC
LD BC,(KeyRightBC)
LD A,(KeyRightA)
LD (KeyMe41+1),A
LD (KeyMe4+1),BC
LD BC,(KeyUpBC)
LD A,(KeyUpA)
LD (KeyMe21+1),A
LD (KeyMe2+1),BC
LD BC,(KeyDownBC)
LD A,(KeyDownA)
LD (KeyMe31+1),A
LD (KeyMe3+1),BC
LD BC,(KeyFireBC)
LD A,(KeyFireA)
LD (KeyMe11+1),A
LD (KeyMe1+1),BC
LD BC,(KeyCGunBC)
LD A,(KeyCGunA)
LD (KeyMe61+1),A
LD (KeyMe6+1),BC
LD BC,(KeyExitBC)
LD A,(KeyExitA)
LD (KeyMe71+1),A
LD (KeyMe7+1),BC
JP Start
RedeLeft
LD A," "
LD (TRede2+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeLeft1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeLeft1
LD (TRede2+8),A
CALL KEyAny
LD (KeyLeftBC),BC
LD (KeyLeftA),A
JP Rede1
RedeRight
LD A," "
LD (TRede3+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeRight1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeRight1
LD (TRede3+8),A
CALL KEyAny
LD (KeyRightBC),BC
LD (KeyRightA),A
JP Rede1
RedeDown
LD A," "
LD (TRede5+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeDown1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeDown1
LD (TRede5+8),A
CALL KEyAny
LD (KeyDownBC),BC
LD (KeyDownA),A
JP Rede1
RedeUp
LD A," "
LD (TRede4+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeUp1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeUp1
LD (TRede4+8),A
CALL KEyAny
LD (KeyUpBC),BC
LD (KeyUpA),A
JP Rede1
RedeFire
LD A," "
LD (TRede6+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeFire1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeFire1
LD (TRede6+8),A
CALL KEyAny
LD (KeyFireBC),BC
LD (KeyFireA),A
JP Rede1
RedeCGun
LD A," "
LD (TRede7+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeCGun1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeCGun1
LD (TRede7+8),A
CALL KEyAny
LD (KeyCGunBC),BC
LD (KeyCGunA),A
JP Rede1
RedeQuit
LD A," "
LD (TRede8+8),A
LD BC,TRede1
CALL PrintText
DUP 5
HALTER
EDUP
RedeQuit1 HALTER
CALL RedeKeyn
CP 255
JR Z,RedeQuit1
LD (TRede8+8),A
CALL KEyAny
LD (KeyExitBC),BC
LD (KeyExitA),A
JP Rede1
PrintText
LD DE,(PrintY)
SRL D
LD A,E
AND 7
RRCA
RRCA
RRCA
ADD A,D
LD D,E
LD E,A
LD A,D
AND #18
OR #40
LD D,A
LD (PrinLine),DE
PrintTx LD A,(BPrintAtr)
LD (PrintAtr),A
LD A,(BC)
INC BC
CP 22
JR Z,PrintXYcom
CP 16
JR Z,PrintAtrcom
CP 0
RET Z
CP 8
CALL C,PntAtr
PUSH BC
CALL Pall
POP BC
JP PrintTx
PrintXYcom LD A,(BC)
INC BC
LD (PrintY),A
LD A,(BC)
INC BC
LD (PrintX),A
LD DE,(PrintY)
SRL D
LD A,E
AND 7
RRCA
RRCA
RRCA
ADD A,D
LD D,E
LD E,A
LD A,D
AND #18
OR #40
LD D,A
LD (PrinLine),DE
JP PrintTx
PrintAtrcom LD A,(BC)
INC BC
LD (PrintAtr),A
LD (BPrintAtr),A
JP PrintTx
PntAtr
LD (BPrintAtr),A
RET
Pall
CALL Pfast
LD A,(PrintX)
CP 64
RET NC
CALL Pcolor
RET
Print PUSH AF
LD DE,(PrintY)
SRL D
LD A,E
AND 7
RRCA
RRCA
RRCA
ADD A,D
LD D,E
LD E,A
LD A,D
AND #18
OR #40
LD D,A
LD (PrinLine),DE
POP AF
Pfast PUSH AF
LD A,(PrintX)
AND %1
JP NZ,PrintRight
JP Z,PrintLeft
Pcolor EX DE,HL
SRL H
SRL H
SRL H
SET 4,H
SET 6,H
LD A,(PrintAtr)
LD (HL),A
LD A,(PrintX)
INC A
LD (PrintX),A
RET
PrintLeft POP AF
LD L,A
LD H,Font/256+9
LD A,(PrintX)
CP 64
RET NC
LD DE,(PrinLine)
INC D
DUP 7
LD A,(DE)
AND %00001111
OR (HL)
LD (DE),A
INC H
INC D
EDUP
DEC D
RET
PrintRight POP AF
LD L,A
LD H,Font/256+#1
LD A,(PrintX)
CP 64
RET NC
LD DE,(PrinLine)
INC D
DUP 7
LD A,(DE)
AND %11110000
OR (HL)
LD (DE),A
INC H
INC D
EDUP
PUSH DE
LD DE,(PrinLine)
INC DE
LD (PrinLine),DE
POP DE
DEC D
RET
PrinLine DW 0
PrintY DB 0
PrintX DB 0
PrintAtr DB 7
BPrintAtr DB 7
Menu
LD A,(IX+5)
LD (MenuY),A
MenuCi HALTER
CALL MenuPrint
HALTER
CALL MenuPrint
CALL KeyMe
LD A,(Key)
BIT 3,A
CALL Z,MenuCQ
LD A,(Key)
BIT 2,A
CALL Z,MenuCA
LD A,(Key)
BIT 4,A
JR NZ,MenuCi
LD A,(MenuY)
LD (IX+5),A
RET
MenuCQ LD A,(MenuY)
CP 0
RET Z
DEC A
LD (MenuY),A
RET
MenuCA LD B,(IX+3)
DEC B
LD A,(MenuY)
CP B
RET NC
INC A
LD (MenuY),A
RET
MenuPrint LD L,(IX)
LD A,(MenuY)
LD C,A
LD A,(IX+4)
DEC A
CP 0
LD B,A
LD A,C
JR Z,$+5
ADD A,A
DJNZ $-1
ADD A,L
LD L,A
LD H,(IX+1)
LD A,H
ADD HL,HL
ADD HL,HL
ADD HL,HL
LD H,#16
ADD HL,HL
ADD HL,HL
ADD A,L
LD L,A
LD A,H
OR #40
LD H,A
LD B,(IX+2)
MenuC1 LD A,(HL)
XOR %001000
LD (HL),A
INC HL
DJNZ MenuC1
RET
KEyAny LD E,8
LD BC,#7FFE
KEyNotR IN A,(C)
LD L,0
LD D,5
KEyNotP BIT 0,A
JR Z,KEyPush
RRCA
INC L
DEC D
JR NZ,KEyNotP
LD A,B
RRCA
LD B,A
DEC E
JR NZ,KEyNotR
RET
KEyPush
LD A,L
RET
KeyMe LD D,0
KeyMe7 LD BC,#BFFE ;Exit
IN A,(C)
LD E,A
KeyMe71 LD A,4 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
KeyMe6 LD BC,#7FFE ;Exit
IN A,(C)
LD E,A
KeyMe61 LD A,2 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
KeyMe1 LD BC,#7FFE ;Fire
IN A,(C)
LD E,A
KeyMe11 LD A,0 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
KeyMe2 LD BC,#FBFE ;Down
IN A,(C)
LD E,A
KeyMe21 LD A,0 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
KeyMe3 LD BC,#FDFE ;Up
IN A,(C)
LD E,A
KeyMe31 LD A,0 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
KeyMe4 LD BC,#DFFE ;Right
IN A,(C)
LD E,A
KeyMe41 LD A,0 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
KeyMe5 LD BC,#DFFE ;Left
IN A,(C)
LD E,A
KeyMe51 LD A,1 ;Bit
INC A
LD B,A
LD A,E
RRCA
DJNZ $-1
RL D
LD A,D
LD (Key),A
RET
MenuY DB 0
TGame1 DB 22, 0,24,16,7,"Q U A K E I"
DB 22, 9,24,16,7," Start Game"
DB 22,10,24,16,7,"Redefine Keys"
DB 22,11,24,16,7," Information"
DB 22,12,24,16,7," Chat "
DB 22,23,0,16,7,"Code:Firestarter "
DB "Hackerz' Design Software 23.08.2003",0
MGame1 DB 9,10,11,4,1,0 ;X,Y,LEN,кол-во,STEP,Стрый Y
TRede1 DB 22,0,24,16,7,"Redefine Keys"
DB 22,6,26,16,7
TRede2 DB " Left: ",34,"o",34
DB 22,7,26,16,7
TRede3 DB "Right: ",34,"p",34
DB 22,8,26,16,7
TRede4 DB " Up: ",34,"q",34
DB 22,9,26,16,7
TRede5 DB " Down: ",34,"a",34
DB 22,10,26,16,7
TRede6 DB " Fire: ",34," ",34
DB 22,11,26,16,7
TRede7 DB "C.Gun: ",34,"m",34
DB 22,12,26,16,7
TRede8 DB " Exit: ",34,"h",34
DB 22,13,24,16,7
DB " Exit",0
MRede1 DB 6,12,7,8,1,0
KeyLeftBC DW #DFFE
KeyLeftA DB 1
KeyRightBC DW #DFFE
KeyRightA DB 0
KeyDownBC DW #FDFE
KeyDownA DB 0
KeyUpBC DW #FBFE
KeyUpA DB 0
KeyFireBC DW #7FFE
KeyFireA DB 0
KeyCGunBC DW #7FFE
KeyCGunA DB 2
KeyExitBC DW #BFFE
KeyExitA DB 4
Key DB 0
Line DB 22,22,0,16,4
DS 64,196
DB 0
TChat1 DB 22,23,0,16,7
DB " Edit-Rus/Lat, CS+SS+1...7-Color, Break-Exit,"
DB " CS+SS+I-Ins/Ovr."
DB 22,10,11,16,7,"Enter your name: ",0
Text DB 16,7
TxtBuffer DB 22,10,28
TxtName DS 13,32
TxtEnd DB 0
DB 0
DB 0
Chat
CALL Init
XOR A
LD (SetChanger),A
LD HL,#4000
LD DE,#4001
LD BC,#17FF
LD (HL),L
LDIR
LD BC,TChat1
CALL PrintText
LD BC,Line
CALL PrintText
CALL Rus_Lat
CALL Ovr_Ins
Ename HALTER
LD BC,TxtBuffer+2
LD A,(BC)
PUSH AF
LD A,28
LD (BC),A
LD BC,Text
CALL PrintText
POP AF
LD BC,TxtBuffer+2
LD (BC),A
CALL KeyAny
CALL KeyFont
CALL KeyWait
LD HL,TxtBuffer
LD E,28
LD B,12
CALL KeyPrint
LD A,(KeyAtr)
BIT 2,A
JR Z,Ename
LD HL,TxtEnd
NotName LD A,(HL)
CP 33
JR NC,NameWod
DEC HL
JR NotName
NameWod
LD DE,TxtName
OR A
SBC HL,DE
INC HL
LD A,H
CP 1
JR NC,NopName
PUSH HL
POP BC
LD A,C
LD (NameLen),A
LD HL,TxtName
LD DE,NameChater
LDIR
NopName
LD HL,#4000
LD DE,#4001
LD (HL),L
LD BC,6143
LDIR
LD BC,Line
CALL PrintText
CALL Rus_Lat
CALL Ovr_Ins
Snowa
LD HL,ChatMy1+3
LD DE,ChatMy1+4
LD BC,65
LD (HL),32
LDIR
LD HL,NameChater
LD DE,ChatMy+3
LD BC,0
LD A,(NameLen)
LD C,A
LDIR
EX DE,HL
LD (HL),">"
INC HL
LD (HL),0
LD A,(NameLen)
INC A
INC A
LD (ChatMy1+2),A
LD (ColBig2+1),A
LD (ColBig3+1),A
LD (ColBig1+1),A
LD B,A
LD A,64
SUB B
LD (ColLen+1),A
INC A
INC A
INC A
INC A
LD (ColEnd+1),A
LD BC,ChatMy
CALL PrintText
Chatru
HALTER
LD A,(DobKeyAtr)
BIT 0,A
CALL NZ,ChDiscon
CALL Joiner
HALTER
LD A,(SetChanger)
CP 1
CALL Z,Bukwa
LD HL,ChatMy1
ColEnd LD E,0
LD D,0
ADD HL,DE
LD (HL),0
LD BC,ChatMy1+2
LD A,(BC)
PUSH AF
ColBig1 LD A,0
LD (BC),A
LD BC,Chatmy
CALL PrintText
POP AF
LD BC,ChatMy1+2
LD (BC),A
CALL KeyAny
CALL KeyFont
CALL KeyWait
LD (KeyMey),A
LD HL,ChatMy1
ColBig2 LD E,28
ColLen LD B,64
CALL KeyPrint
LD A,(KeyAtr)
BIT 0,A
JR NZ,ChatExit
ChatNoE LD A,(KeyAtr)
BIT 2,A
JR Z,Chatru
LD BC,ChatMy1+2
ColBig3 LD A,0
LD (BC),A
LD BC,Chatmy
CALL PrintText
CALL ScrollUp
LD HL,#5B00-32
LD DE,#5B00-32-32-32
LD BC,32
LDIR
LD HL,#50E0
LD DE,#50A0
LD BC,32
LDIR
LD HL,#51E0
LD DE,#51A0
LD BC,32
LDIR
LD HL,#52E0
LD DE,#52A0
LD BC,32
LDIR
LD HL,#53E0
LD DE,#53A0
LD BC,32
LDIR
LD HL,#54E0
LD DE,#54A0
LD BC,32
LDIR
LD HL,#55E0
LD DE,#55A0
LD BC,32
LDIR
LD HL,#56E0
LD DE,#56A0
LD BC,32
LDIR
LD HL,#57E0
LD DE,#57A0
LD BC,32
LDIR
JP Snowa
RET
ChatExit LD BC,#7FFE
IN A,(C)
BIT 0,A
JP NZ,ChatNoE
CALL Joiner
LD BC,#FFFD
LD DE,#FFBF
LD B,D
LD A,IRAs
OUT (C),A
LD B,E
XOR A
OUT (C),A
JP Start
ChatMy DB 22,23,0
DS 12+4,0
Chatmy DB 16,7
ChatMy1 DB 22,23,7
DS 66,32
ChatYou DB 22,21,0
DS 12+4,0
Chatyou DB 16,7
ChatYou1 DB 22,21,7
DS 66,32
NameLen DB 9
NameChater
DB 16,7
DB "No Name"
DS 9
NameYLen DB 9
NameChaterYou
DB 16,7
DB "No Name"
DS 9
XYchat DB 22,21,0,0
Joiner LD (Steck),SP
LD A,(SetChanger)
CP 1
JR Z,Realset
LD L,IRAs
LD H,IRBl
LD BC,#FFFD
LD DE,#FFBF
OUT (C),L
LD B,E
OUT (C),D
LD B,D
OUT (C),H
IN A,(C)
AND %10000000 ;TODO
ld a,%10000000
CP %10000000
JR Z,HasJoin
RET
HasJoin
CALL NameOb
CALL ScrollUp
LD BC,XYchat
CALL PrintText
LD HL,NameChaterYou
LD A,(NameYLen)
LD C,A
LD B,0
ADD HL,BC
LD (HL),0
LD BC,NameChaterYou
CALL PrintText
LD BC,JoinTXT
CALL PrintText
LD A,1
LD (SetChanger),A
LD HL,NameChaterYou
LD A,(NameYLen)
LD C,A
LD B,0
ADD HL,BC
LD (HL),32
CALL YouLine2
HALTER
LD A,255
LD (KeyYour),A
LD A,0
LD (DobKeyAtr),A
RET
Realset
CALL Sinhro ;Процедура синхронизации
LD A,(KeyMey)
CALL Obmen
LD (KeyYour),A
CALL MiniSinhro
LD A,(KeyAtr)
CALL Obmen
LD (DobKeyAtr),A
CALL MiniSinhro
LD B,0
NOP
DJNZ $-1
RET
JoinTXT DB 4,"joined",0
ScrollUp
LD DE,#4000
LD HL,#4020
LD B,21
Scroll2 PUSH BC
PUSH DE
PUSH HL
LD B,8
Scroll1 PUSH HL
PUSH DE
PUSH BC
DUP 32
LDI
EDUP
POP BC
POP DE
POP HL
INC H
INC D
DJNZ Scroll1
POP HL
POP DE
POP BC
CALL HL_Down8
CALL DE_Down8
DJNZ Scroll2
LD DE,#5800
LD HL,#5820
LD BC,21*32
LDIR
LD HL,#50A0
LD B,8
ScrollX PUSH HL
PUSH BC
LD A,0
DUP 32
LD (HL),A
INC L
EDUP
POP BC
POP HL
INC H
DJNZ ScrollX
RET
HL_Down8
LD A,L
ADD A,32
LD L,A
RET NC
LD A,H
ADD A,8
LD H,A
RET
DE_Down8
LD A,E
ADD A,32
LD E,A
RET NC
LD A,D
ADD A,8
LD D,A
RET
KeyPrint
PUSH AF
LD A,B
ADD A,E
LD D,A
INC HL
LD IX,PrintY
LD A,(HL)
LD (IX),A
INC HL
LD A,(HL)
LD (IX+1),A
LD A,(HL)
SUB E
LD C,A
POP AF
CP 255
JP Z,KeyCurs
CP 12
JP Z,KeyDelete
CP 8
JP Z,KeyLeft
CP 9
JP Z,KeyRight
CP 28
JP Z,Rus_Lat
CP 27
JP Z,Ovr_Ins
PUSH AF
LD A,(HL)
CP D
JR Z,Keyend
INC C
POP AF
PUSH HL
PUSH DE
PUSH BC
PUSH BC
LD B,0
ADD HL,BC
POP BC
PUSH AF
LD A,(KeyAtr)
BIT 5,A
CALL Z,Insert
POP AF
LD (HL),A
POP BC
POP DE
POP HL
LD A,(HL)
CP D
JR Z,KeyCurs
INC (HL)
KeyCurs
KeyCurS LD A,(ChatHidden)
CP 1
RET Z
LD A,(PrintX)
CP 64
RET NC
LD A,(Cursor)
CALL Print
RET
Keyend POP AF
RET
KeyDelete
PUSH AF
LD A,(HL)
CP E
JR Z,Keyend
POP AF
PUSH BC
DEC (HL)
LD A,(HL)
LD (IX+1),A
LD A,(HL)
SUB E
LD C,A
INC C
LD B,0
ADD HL,BC
POP BC
LD A,(KeyAtr)
BIT 5,A
JP Z,Insert2
LD (HL),32
CALL KeyCurS
RET
KeyLeft
PUSH HL,DE,BC
LD A,(HL)
SUB E
LD C,A
INC C
LD B,0
ADD HL,BC
LD A,(HL)
CALL Print
POP BC,DE,HL
PUSH AF
LD A,(HL)
CP E
JR Z,Keyend
POP AF
DEC (HL)
LD A,(HL)
LD (IX+1),A
CALL KeyCurs
RET
KeyRight
PUSH HL,DE,BC
LD A,(HL)
SUB E
LD C,A
INC C
LD B,0
ADD HL,BC
LD A,(HL)
CALL Print
POP BC,DE,HL
PUSH AF
LD A,(HL)
CP D
JR Z,Keyend
POP AF
INC (HL)
LD A,(HL)
LD (IX+1),A
CALL KeyCurs
RET
Rus_Lat
LD A,(KeyAtr)
XOR %00010000
LD (KeyAtr),A
XOR %00010000
BIT 4,A
JR NZ,_Lat
LD A,(ChatHidden)
CP 1
RET Z
LD BC,Rus1
CALL PrintText
RET
_Lat LD A,(ChatHidden)
CP 1
RET Z
LD BC,Lat1
CALL PrintText
RET
Ovr_Ins
LD A,(KeyAtr)
XOR %00100000
LD (KeyAtr),A
XOR %00100000
BIT 5,A
JR NZ,_Ins
LD A,(ChatHidden)
CP 1
RET Z
LD BC,Ovr1
CALL PrintText
RET
_Ins LD A,(ChatHidden)
CP 1
RET Z
LD BC,Ins1
CALL PrintText
RET
Insert PUSH HL,DE,BC
PUSH HL
PUSH BC
LD A,B
SUB C
CP 0
JR Z,Ines
LD B,0
LD C,A
ADD HL,BC
POP BC
POP DE
PUSH HL
OR A
SBC HL,DE
PUSH HL
POP BC
POP HL
PUSH HL
POP DE
DEC HL
LDDR
POP BC,DE,HL
RET
Ines POP AF
POP AF
POP BC,DE,HL
RET
Insert2
PUSH HL
POP DE
INC HL
LD A,B
SUB C
INC A
CP 0
JR Z,Ines2
CP 255
JR Z,Ines2
LD C,A
LD B,0
LDIR
Ines2 CALL KeyCurs
RET
Rus1 DB 22,22,9,16,4," ",16,7,"Rus ",0
Lat1 DB 22,22,9,16,4," ",16,7,"Lat ",0
Ovr1 DB 22,22,15,16,4," ",16,7,"Ovr ",0
Ins1 DB 22,22,15,16,4," ",16,7,"Ins ",0
SetChanger DB 0
Cursor DB "█"
KeyAny
CALL Enter
CALL Symbol
CALL Caps
LD E,8
LD BC,#7FFE
KeyNotR IN A,(C)
LD L,0
LD D,5
KeyNotP BIT 0,A
JR Z,KeyPush
KeyNext RRCA
INC L
DEC D
JR NZ,KeyNotP
RRC B
DEC E
JR NZ,KeyNotR
LD BC,#0000
XOR A
RET
KeyPush PUSH AF
LD A,B
CP #FE
JR Z,KeyCaps
CP #BF
JR Z,KeyCaps; (Enter)
CP #7F
JR Z,KeySymbol
POP AF
LD A,L
RET
KeyCaps LD A,L
CP 0
JR Z,KeyNextP
POP AF
LD A,L
RET
KeySymbol LD A,L
CP 1
JR Z,KeyNextP
POP AF
LD A,L
RET
KeyNextP POP AF
JR KeyNext
Enter LD BC,#BFFE
IN A,(C)
BIT 0,A
JR NZ,EnterR
LD A,(KeyAtr)
SET 2,A
LD (KeyAtr),A
RET
EnterR LD A,(KeyAtr)
RES 2,A
LD (KeyAtr),A
RET
Caps LD BC,#FEFE
IN A,(C)
BIT 0,A
JR NZ,CapsR
LD A,(KeyAtr)
SET 0,A
LD (KeyAtr),A
RET
CapsR LD A,(KeyAtr)
RES 0,A
LD (KeyAtr),A
RET
Symbol LD BC,#7FFE
IN A,(C)
BIT 1,A
JR NZ,SymbolR
LD A,(KeyAtr)
SET 1,A
LD (KeyAtr),A
RET
SymbolR LD A,(KeyAtr)
RES 1,A
LD (KeyAtr),A
RET
KeyFont
LD L,A
LD A,B
CP #F7
JR Z,_F7FE_
CP #EF
JR Z,_EFFE_
CP #7F
JR Z,_7FFE_
CP #FB
JR Z,_FBFE_
CP #DF
JR Z,_DFFE_
CP #FD
JR Z,_FDFE_
CP #FE
JR Z,_FEFE_
CP #BF
JR Z,_BFFE_
LD A,255
RET
_F7FE_ LD BC,_F7FE
JR _FontForm
_EFFE_ LD BC,_EFFE
JR _FontForm
_7FFE_ LD BC,_7FFE
JR _FontForm
_FBFE_ LD BC,_FBFE
JR _FontForm
_DFFE_ LD BC,_DFFE
JR _FontForm
_FDFE_ LD BC,_FDFE
JR _FontForm
_FEFE_ LD BC,_FEFE
JR _FontForm
_BFFE_ LD BC,_BFFE
JR _FontForm
_FontForm
LD H,0
ADD HL,HL
ADD HL,HL
PUSH HL
ADD HL,HL
POP DE
ADD HL,DE
ADD HL,BC
LD A,(KeyAtr)
BIT 0,A
JR Z,$+6
LD BC,1
ADD HL,BC
LD A,(KeyAtr)
BIT 1,A
JR Z,$+6
LD BC,2
ADD HL,BC
LD A,(KeyAtr)
BIT 3,A
JR Z,$+8
LD BC,8
ADD HL,BC
JR _FontTake
LD A,(KeyAtr)
BIT 4,A
JR Z,$+6
LD BC,4
ADD HL,BC
_FontTake
LD A,(HL)
RET
KeyWait LD L,A
LD A,(KeyOld)
CP L
JR Z,_KeyWait
LD A,10
LD (KeyDoble),A
LD A,L
LD (KeyOld),A
RET
_KeyWait
LD A,(KeyDoble)
DEC A
CP 255
JR Z,__KeyWait
LD (KeyDoble),A
LD A,255
RET
__KeyWait
LD A,L
RET
KeyDoble DB 0
KeyOld DB 0
; LAT
; RUS
; UDG
_F7FE DB "1",28,"!",1,"1",28,"!",1,1,1,1,1
DB "2",29,"@",2,"2",29,"@",2,2,2,2,2
DB "33#",3,"33#",3,3,3,3,3
DB "44$",4,"44$",4,4,4,4,4
DB "5",8,"%",5,"5",8,"%",5,5,5,5,5
_EFFE DB "0",12,"__0",12,"Ъ_" ,0,12,0,0
DB "99))99)) 9 "
DB "8",9,"((8",9,"(( 8 "
DB "77'",7,"77'",7,7,7,7,7
DB "66&",6,"66&",6,6,6,6,6
_FBFE DB "qQ яЯ ╔┌╒ "
DB "wW вВ ╦┬╤ "
DB "eE еЕ ╗┐╕ "
DB "rR<<рР<< 4 "
DB "tT>>тТ>> 5 "
_DFFE DB "pP",34,34,"пП",34,34," 1 "
DB "oO;;оО;; 2 "
DB "iI ",27,"иИ ",27," 3 "
DB "uU]]уУ]] 4 "
DB "yY[[ыЫ[[ 5 "
_FDFE DB "aA~~аАчЧ╠├╞ "
DB "sS||сСэЭ╬┼╪ "
DB "dD дД ╣┤╡ "
DB "fF{{фФшШ 4 "
DB "gG}}гГщЩ 5 "
_BFFE DB 13,13,13,13,13,13,13,13,13,13,13,13
DB "lL==лЛ== 2 "
DB "kK++кК++ 3 "
DB "jJ--йЙ-- 4 "
DB "hH^^хХ^^ 5 "
_FEFE DB 30,30,30,30,30,30,30,30,30,30,30,30
DB "zZ::зЗ::╚└╘ "
DB "xX``ьЬюЮ╩┴╧ "
DB "cC??цЦ??╝┘╛ "
DB "vV//жЖ// 5 "
_7FFE DB " "
DB 31,31,31,31,31,31,31,31,31,31,31,31
DB "mM..мМ.. 3 "
DB "nN,,нН,, 4 "
DB "bB**бБ** 5 "
;31 - Symbol Shift
;30 - Caps Shift
;29 - Caps Lock
;28 - Edit
;27 - Ovr/Ins
;13 - Enter
;╔╦╗═║╒╤╕
;╠╬╣ ╞╪╡
;╚╩╝ ╘╧╛
;┌┬┐─│╓╥╖
;├┼┤ ╟╫╢
;└┴┘ ╙╨╜
Init
if 1==0
LD BC,#FFFD ;Записываем в регистр R7 число чтение/записи
LD DE,#FFBF ;
LD A,7
OUT (C),A
LD B,E
LD A,R7i
OUT (C),A
LD B,D ;Сбрасиваем 7 бит (то есть программа обмена
LD A,IRAs ;не работает)
OUT (C),A
LD B,E
XOR A
OUT (C),A
endif
RET
Sinhro
ret
LD L,IRAs
LD H,IRBl
LD BC,#FFFD ;Устанвливаем 7 бит что обмен должен быть
LD DE,#FFBF ;начат. ждем опонента пока он не установил
;7 бит
OUT (C),L
LD B,E
OUT (C),D
LD B,D ;Собствено цикл ожидание.
;Синхронезация до линии бордера (по тактам)
OUT (C),H ;
Sinhro1
IN A,(C)
RLA
JR NC,Sinhro1
OUT (C),L
LD B,E
XOR A ;выключаем бит 7 и ждем от другого компа
OUT (C),A
LD B,D ;Собствено цикл ожидание.
;Синхронезация по тактом полностю один в один
OUT (C),H ;
PUSH HL
LD HL,#0000
Sinhro2
INC HL
LD A,H
CP #FF
JP Z,OffLine
IN A,(C)
RLA
JR C,Sinhro2
POP HL
OUT (C),L
LD B,E ;Устанавливаем 7 бит
OUT (C),D
LD B,D ;Собствено цикл ожидания.
;Собственно иногда без этого цикла у меня
OUT (C),H;почемуто сбоит :( передача (никода не убирать)
Sinhro3
IN A,(C)
RLA
JR NC,Sinhro3
RET
Obmen
;Hа вход регистр A - байт передачи и на выходе A - байт приема
ifdef CLIENT
if CLIENT
push af
call sendbyte
pop af
waitkey0
waitkey_receivebytepatch=$+1
call receivebyte
jr z,waitkey0
; or a
; jr z,mastergetkeyskipreceiveq
;mastergetkeyskipreceive
; ld (curdirection2),a
;mastergetkeyskipreceiveq
else ;slave (server)
push af
waitkey0
call receivebyte
jr z,waitkey0
;or a
;jr z,$+5
;ld (curdirection),a
ld b,a
pop af
push bc
call sendbyte
pop af
endif
else
xor a
endif
ret
;Hа вход регистр A - байт передачи и на выходе A - байт приема
LD L,IRAs
LD BC,#FFFD
LD DE,#FFBF ;начат. ждем оппонента пока он не установил
EXX
LD L,IRBl
LD BC,#FFFD
EXX
DUP 8
LD B,D ;В это время оба компа записывают бит
OUT (C),L
LD B,E
OUT (C),A
RLCA
DUP ObWa;Небольшая задержка, потому что с разной тактовой
NOP ;чистотой постепенно происходит рассинхронизация
EDUP ;
EXX
OUT (C),L ;В это время оба компа читают бит
IN E,(C)
RL E
RL H
EXX
DUP ObWa;Небольшая задержка, потому что с разной тактовой
NOP ;чистотой постепенно происходит рассинхронизация
EDUP ;
EDUP
LD B,D ;Сбрасываем 7 бит
OUT (C),L ;То есть передача окончена
LD B,E
XOR A
OUT (C),A
EXX
LD A,H
RET
NameOb CALL Waiting
LD HL,NameLen
LD DE,NameYLen
LD BC,16
CALL Cycle
LD HL,ChatMy
LD DE,ChatYou
LD BC,88
CALL Cycle
RET
Cycle
;push bc
;push de
;push hl
;push ix
HALTER
;pop ix
;pop hl
;pop de
;pop bc
Cycle2 PUSH BC
PUSH DE
PUSH HL
CALL Sinhro ;Процедура синхронизации
POP HL
POP DE
POP BC
LD A,Cont
Cycl2 PUSH AF
PUSH BC
LD A,(HL)
PUSH HL
PUSH DE
CALL Obmen
PUSH AF
POP AF
POP DE
POP HL
LD (DE),A
INC HL
INC DE
PUSH DE
PUSH HL
CALL MiniSinhro
POP HL
POP DE
POP BC
DEC BC
LD A,B
OR C
JP Z,Ok
POP AF
DEC A
JR NZ,Cycl2
PUSH BC
LD B,0
DJNZ $
POP BC
JP Cycle
Ok POP AF
CALL MWaiting
LD BC,#FFFD ;Записываем в регистр R7 число чтение/записи
LD DE,#FFBF ;
LD B,D ;Сбрасываем 7 бит (то есть программа обмена
LD A,IRAs ;не работает)
OUT (C),A
LD B,E
XOR A
OUT (C),A
RET
MiniSinhro
LD L,IRAs
LD H,IRBl
LD BC,#FFFD ;Устанавливаем 7 бит, что обмен должен быть
LD DE,#FFBF ;начат. Ждем оппонента, пока он не установил
LD B,D
;7 бит
OUT (C),L
LD B,E
OUT (C),D
LD B,D
OUT (C),H
MSinhro
IN A,(C)
RLA
;JR NC,MSinhro
LD B,D
;7 бит
OUT (C),L
LD B,E
XOR A
OUT (C),A
RET
Waiting
HALTER
HALTER
HALTER
HALTER
LD L,IRAs
LD H,IRBl
LD BC,#FFFD
LD DE,#FFBF
OUT (C),L
LD B,E
XOR A
OUT (C),A
LD B,D
OUT (C),H
SinhrH
IN A,(C)
RLA
;JR C,SinhrH
LD BC,#FFFD
LD DE,#FFBF
LD B,D
LD A,IRAs
OUT (C),A
LD B,E
XOR A
OUT (C),A
RET
MWaiting
LD L,IRAs
LD H,IRBl
LD BC,#FFFD
LD DE,#FFBF
OUT (C),L
LD B,E
OUT (C),D
LD B,D
OUT (C),H
MSinhrH
IN A,(C)
RLA
;JR NC,MSinhrH
LD BC,#FFFD
LD DE,#FFBF
LD B,D
LD A,IRAs
OUT (C),A
LD B,E
XOR A
OUT (C),A
RET
YouLine
LD HL,ChatYou1+3
LD DE,ChatYou1+4
LD BC,65
LD (HL),32
LDIR
LD HL,NameChaterYou
LD DE,ChatYou+3
LD BC,0
LD A,(NameYLen)
LD C,A
LDIR
EX DE,HL
LD (HL),">"
INC HL
LD (HL),0
LD A,(NameYLen)
INC A
INC A
LD (ChatYou1+2),A
YouLine2
LD A,(NameYLen)
INC A
INC A
LD (ColBig2Y+1),A
LD (ColBig3Y+1),A
LD B,A
LD A,64
SUB B
LD (ColLenY+1),A
INC A
INC A
INC A
INC A
LD (ColEndY+1),A
LD A,21
LD (ChatYou+1),A
LD (ChatYou1+1),A
RET
Bukwa
LD A,1
LD (ChatHidden),A
PUSH AF
LD A,(DobKeyAtr)
LD B,A
LD A,(KeyAtr)
LD (DobKeyAtr),A
LD A,B
LD (KeyAtr),A
POP AF
LD HL,ChatYou1
ColEndY LD E,0
LD D,0
ADD HL,DE
LD (HL),0
LD A,(KeyYour)
LD HL,ChatYou1
ColBig2Y LD E,28
ColLenY LD B,64
CALL KeyPrint
LD A,0
LD (ChatHidden),A
LD A,(KeyAtr)
BIT 2,A
PUSH AF
LD A,(DobKeyAtr)
LD B,A
LD A,(KeyAtr)
LD (DobKeyAtr),A
LD A,B
LD (KeyAtr),A
POP AF
JR NZ,PrintYou
RET
ChDiscon
LD A,(KeyYour)
CP 32
RET NZ
CALL ScUpNa
LD BC,DiscTXT
CALL PrintText
CALL OffSet
RET
PrintYou
CALL ScrollUp
LD BC,ChatYou
CALL PrintText
ColBig3Y LD A,0
LD (ChatYou1+2),A
LD BC,Chatyou
CALL PrintText
CALL YouLine
RET
; ChatYou DB 22,21,0
;ChatYou1 DB 22,21,7
ChatHidden DB 0
KeyYour DB 0
DobKeyAtr DB 0
KeyMey DB 0
KeyAtr DB %00010000;-Caps
; |||||
; ||||Symbol
; |||Enter
; ||UDG
; |RUS/LAT
; Ovr/Ins
Steck DW 0
OffLine
LD SP,(Steck)
OfLine1
CALL ScUpNa
LD BC,DiscTX2
CALL PrintText
CALL OffSet
RET
DiscTXT DB 4,"Disconect (Quit)",0
DiscTX2 DB 4,"Disconect (OffLine)",0
ScUpNa
CALL ScrollUp
LD BC,XYchat
CALL PrintText
LD HL,NameChaterYou
LD A,(NameYLen)
LD C,A
LD B,0
ADD HL,BC
LD (HL),0
LD BC,NameChaterYou
CALL PrintText
RET
OffSet
LD A,0
LD (SetChanger),A
LD BC,#FFFD
LD DE,#FFBF
LD B,D
LD A,IRAs
OUT (C),A
LD B,E
XOR A
OUT (C),A
LD A,255
LD (KeyYour),A
RET
RedeKeyn
CALL KeyAny
CALL KeyFont
PUSH AF
LD A,1
LD (KeyAtr),A
POP AF
CALL KeyWait
RET
if 1==0
Im2
DI
LD HL,#BE00
LD A,H
LD I,A
INC A
_IM2 LD (HL),A
INC L
JP NZ,_IM2
INC H
LD (HL),A
LD A,#C3
LD (#BFBF),A
LD HL,BREAKING_2
LD (#BFC0),HL
IM 2
EI
RET
BREAKING_2
EI
RET
endif
INCLUDE "Quake1_2.asm"
INCLUDE "Quake1_3.asm"
getbreak
ld a,0x7f
in a,(0xfe)
rra
ret c
ld a,0xfe
in a,(0xfe)
rra
ret
ifdef CLIENT
sendbuf
db "isnk"
sendbufdata
sendbufdatashift=$-sendbuf
sendbufsz=sendbufdatashift+1 ;1 byte
ds sendbuf+256-$
recvbuf
ds 256
sendbyte
ld (sendbufdata),a
ld hl,sendbufsz
LD a,(soc)
ld ix,sendbuf
ld de,port_ia
OS_WIZNETWRITE
bit 7,h
jp nz,inet_exitcode
ret
receivebyte_fake
xor a
dec a ;nz
ld a,0
ret
receivebyte
;from UDP
;z=no data
receivebyte0
call getbreak
jp nc,quit
ld hl,sendbufsz
LD a,(soc)
ld ix,recvbuf
ld de,port_ia
OS_WIZNETREAD
bit 7,h
;ld a,h
;or l
jr nz,receivebyte_fail ;jr z,receivebyte0
ld hl,recvbuf
ld de,sendbuf
ld b,sendbufdatashift
receivebytecp0
ld a,(de)
cp (hl)
jr nz,receivebyte_fail
inc hl
inc de
djnz receivebytecp0
xor a
dec a ;nz
ld a,(recvbuf+sendbufdatashift)
ret
receivebyte_fail
xor a ;z=no data
ret
soc
db 0
;socrecv
; db 0
;struct sockaddr_in {unsigned char sin_family;unsigned short sin_port;
; struct in_addr sin_addr;char sin_zero[8];};
if CLIENT
;master(net1): from 192.168.1.2 to 192.168.1.177
port_ia:
defb 0
db 100,53 ;port (big endian)
db 192,168,0,7;127,0,0,1 ;ip (big endian)
;port_iarecv:
; defb 0
; db 100,53 ;port (big endian)
; db 192,168,1,177 ;ip (big endian)
else
;slave(net2): from 192.168.1.177 to 192.168.1.2
port_ia:
defb 0
db 100,53 ;port (big endian)
db 255,255,255,255 ;ip (big endian)
;port_iasend:
; defb 0
; db 100,53 ;port (big endian)
; db 192,168,1,2 ;ip (big endian)
endif
endif ;ifdef CLIENT
ds 0x3f00-$
ds 0x8000-$
align 256
Font
INCBIN "Fontlr.bin"
align 256
Sprites
INCBIN "QuakeSPR.bin"
align 256
Maps
INCBIN "MAPS.bin"
end
display "end=",end
ifdef CLIENT
if CLIENT
savebin "q1_1.com",begin,end-begin
else
savebin "q1_2.com",begin,end-begin
endif
else
savebin "q1.com",begin,end-begin
endif
LABELSLIST "../../../us/user.l"