MEMORYASM;--------------------------------
;				\
; Speichereingabeprogramm MEMORY\
;				\
; Version 2 (verschieblich)	\
;				\
;		` ml 02.11.1990	\
;--------------------------------
ARGN	EQU 0B781H
ARG1	EQU 0B782H	;Adresse
BYT	EQU 0B796H	;Byte
OFF	EQU 0B797H	;Abstand
WINON	EQU 0B79CH
WINLG	EQU 0B79EH
CURSO	EQU 0B7A0H
PV1	EQU 0F003H
REL	EQU 0F00FH
CRT	EQU 00H
KBD	EQU 04H
INLIN	EQU 17H
ERRM	EQU 19H
HLHX	EQU 1AH
AHEX	EQU 1CH
GARG	EQU 22H
OSTR	EQU 23H
WININ	EQU 3CH
WINAK	EQU 3DH
;-------------
	ORG 0
	DEFW 7F7FH
	DEFM 'MEMORY'
	DEFB 1
	AND A
	JR NZ,NERR
	CALL PV1
	DEFB ERRM
	RET
NERR	XOR A		;Fenster 0
	LD HL,0		;Fensteranfang
	LD DE,2028H	;Fensterl{nge
	CALL PV1
	DEFB WININ
	LD A,1		;Fenster 1
	LD HL,0400H
	LD DE,1828H
	CALL PV1
	DEFB WININ
	LD A,2		;Fenster 2
	LD HL,1E04H
	LD DE,0120H
	CALL PV1
	DEFB WININ
	XOR A		;Fenster 0
	CALL PV1
	DEFB WINAK
	CALL PV1
	DEFB OSTR
	DEFW 0A0CH
	DEFB 12H
	DEFM '       MEMORY Vers.2'
	DEFM ' ` ml 1991'
	DEFW 0D0AH
	DEFM ' Adr.  '
	DEFB 0
	LD B,23
	LD A,'_'
ZYK	CALL PV1
	DEFB CRT
	DJNZ ZYK
	CALL PV1
	DEFB OSTR
	DEFM ' Checksum'
	DEFB 0
;-------
START	LD A,1		;Fenster 1
	CALL PV1
	DEFB WINAK
	CALL PV1
	DEFB OSTR
	DEFB 11H	;Page-Mode
	DEFB 0
	CALL REL
	DEFW BILD-$-2
	LD HL,0107H	;CPOS 1.Byte
	LD (CURSO),HL
	LD HL,0
	LD (OFF),HL	;Abstand
	XOR A
	LD (BYT),A	;High-Byte
EING	CALL PV1
	DEFB KBD
	CP 3		;BRK
	JR NZ,NBR
	CALL REL
	DEFW END-$-2
	RET
NBR	CP '/'
	JR NZ,NST
	LD A,2
	CALL PV1
	DEFB WINAK
	CALL PV1
	DEFB OSTR
	DEFW 0211H
	DEFM 'Neue Adresse:'
	DEFB 0
	CALL PV1
	DEFB INLIN
	LD HL,13
	ADD HL,DE
	EX DE,HL
	CALL PV1
	DEFB GARG
	LD A,0CH
	CALL PV1
	DEFB CRT
	LD A,(ARGN)
	AND A
	JR Z,KADR
	JR START
KADR	LD A,1
	CALL PV1
	DEFB WINAK
	JR EING
NST	CP 9		;rechts
	JR NZ,NRE
	CALL REL
	DEFW RECHTS-$-2
EING2	JR EING
NRE	CP 8		;links
	JR NZ,NLI
	LD A,(BYT)
	AND A
	LD A,(CURSO)
	JR Z,LI1	;H-Byte
	DEC A
	LD (CURSO),A
	JR LI5
LI1	CP 9
	JR NC,LI3	;nicht links
	LD A,1CH
	LD (CURSO),A
	LD A,(CURSO+1)
	CP 2
	JR NC,LI2	;nicht oben
	LD BC,8
	LD HL,(ARG1)
	AND A
	SBC HL,BC
	LD (ARG1),HL
	LD HL,(OFF)
	DEC BC
	ADD HL,BC
	LD (OFF),HL	;Abstand
	CALL REL
	DEFW BILD-$-2
	JR LI5
LI2	DEC A
	DEC A
	LD (CURSO+1),A
	JR LI4
LI3	DEC A
	DEC A
	DEC A
	LD (CURSO),A
LI4	LD HL,(OFF)
	DEC HL		;Abstand
	LD (OFF),HL
LI5	XOR A
	LD (BYT),A
EING3	JR EING2
NLI	CP 10		;runter
	JR NZ,NRU
	LD A,(CURSO+1)
	CP 17H
	LD BC,8
	JR C,RU1	;nicht unten
	LD HL,(ARG1)
	ADD HL,BC
	LD (ARG1),HL
	CALL REL
	DEFW BILD-$-2
	JR RU2
RU1	LD HL,(OFF)
	ADD HL,BC
	LD (OFF),HL
	LD A,(CURSO+1)
	INC A
	INC A
	LD (CURSO+1),A
RU2	LD A,(BYT)
	AND A
	JR Z,RU3	;High-Byte
	LD A,(CURSO)
	DEC A
	LD (CURSO),A
RU3	XOR A
	LD (BYT),A
EING4	JR EING3
NRU	CP 11		;hoch
	JR NZ,NHO
	LD A,(CURSO+1)
	CP 2
	LD BC,8
	JR NC,HO1	;nicht oben
	LD HL,(ARG1)
	AND A
	SBC HL,BC
	LD (ARG1),HL
	CALL REL
	DEFW BILD-$-2
	JR RU2
HO1	LD HL,(OFF)
	AND A
	SBC HL,BC
	LD (OFF),HL
	LD A,(CURSO+1)
	DEC A
	DEC A
	LD (CURSO+1),A
	JR RU2
NHO	CP 13
	JR NZ,NET
ET1	CALL REL
	DEFW RECHTS-$-2
	LD A,(CURSO)
	CP 7
	JR NZ,ET1
	JR EING4
NET	CP 17		;Bild hoch
	JR NZ,NBHO
	LD HL,(ARG1)
	LD BC,50H
	AND A
	SBC HL,BC
BHO1	LD (ARG1),HL
	CALL REL
	DEFW BILD-$-2
	LD A,(BYT)
	AND A
	JR Z,BHO2
	LD A,(CURSO)
	DEC A
	LD (CURSO),A
BHO2	XOR A
	LD (BYT),A
EING5	JR EING4
NBHO	CP 18		;Bild runter
	JR NZ,NBRU
	LD HL,(ARG1)
	LD BC,50H
	ADD HL,BC
	JR BHO1
NBRU	CP 20		;Click
	JR NZ,NCL
	CALL PV1
	DEFB CRT
	JR EING5
NCL	CP '.'
	JR NZ,NPK
	LD A,2
	CALL PV1
	DEFB WINAK
	CALL PV1
	DEFB OSTR
	DEFB 2
	DEFM 'Beenden (J/N) ?'
	DEFB 0
	CALL PV1
	DEFB KBD
	RES 5,A
	PUSH AF
	LD A,0CH
	CALL PV1
	DEFB CRT
	POP AF
	CP 'J'
	JR NZ,NEND
	CALL REL
	DEFW END-$-2
	RET
NEND	LD A,1
	CALL PV1
	DEFB WINAK
EING6	JR EING5
NPK	CP ','
	JR NZ,NKO
	LD A,2
	CALL PV1
	DEFB WINAK
	CALL PV1
	DEFB OSTR
	DEFB 2
	DEFM 'Eingabe ASCII-Code:'
	DEFB 0
	CALL PV1
	DEFB KBD
	CP 20H
	JR C,KASC
	CP 80H
	JR NC,KASC
	CALL PV1
	DEFB CRT
	LD HL,(ARG1)
	LD BC,(OFF)
	ADD HL,BC
	LD M,A
	LD A,1
	CALL PV1
	DEFB WINAK
	CALL REL
	DEFW BILD-$-2
	CALL REL
	DEFW RECHTS-$-2
	LD A,2
	CALL PV1
	DEFB WINAK
KASC	LD A,0CH
	CALL PV1
	DEFB CRT
	LD A,1
	CALL PV1
	DEFB WINAK
EING7	JR EING6
NKO	CP '0'
	JR C,EING6	;<'0'
	CP 3AH
	JR C,ZA1	;'0'-'9'
	RES 5,A		;klein->gro~
	CP 'A'
	JR C,EING6	;<'A'
	CP 'G'
	JR NC,EING6	;>'F'
	CALL PV1
	DEFB CRT
	ADD 9
	JR ZA2
ZA1	CALL PV1
	DEFB CRT
ZA2	AND 0FH
	LD E,A		;HEX-Code
	LD HL,(ARG1)
	LD BC,(OFF)
	ADD HL,BC
	LD A,(BYT)
	AND A
	JR Z,ZA3	;H-Byte
	RRD
	XOR A
	OR E
	RLD
	LD A,(CURSO)
	DEC A
	LD (CURSO),A
	CALL REL
	DEFW CSUM-$-2
	CALL REL
	DEFW RECHTS-$-2
	JR EING7
ZA3	RLD
	XOR A
	OR E
	RRD
	LD A,1
	LD (BYT),A
	CALL REL
	DEFW CSUM-$-2
	JR EING7
;Cursor nach rechts:
;-------------------
RECHTS	LD A,(CURSO)
	CP 1CH
	JR C,RE2	;nicht rechts
	LD A,7
	LD (CURSO),A
	LD A,(CURSO+1)
	CP 17H
	JR C,RE1	;nicht unten
	LD BC,8
	LD HL,(ARG1)
	ADD HL,BC
	LD (ARG1),HL
	LD HL,(OFF)
	DEC BC
	AND A
	SBC HL,BC
	LD (OFF),HL	;Abstand
	CALL REL
	DEFW BILD-$-2
	JR RE5
RE1	INC A
	INC A
	LD (CURSO+1),A
	JR RE4
RE2	LD A,(BYT)
	AND A
	LD HL,(CURSO)
	JR NZ,RE3	;Low-Byte
	INC HL
RE3	INC HL
	INC HL
	LD (CURSO),HL
RE4	LD HL,(OFF)
	INC HL		;Abstand
	LD (OFF),HL
RE5	XOR A
	LD (BYT),A
	RET
;Neuberechnen Checksum:
;----------------------
CSUM	LD HL,(CURSO)
	PUSH HL
	LD HL,(ARG1)
	LD BC,(OFF)
	LD A,C
	AND 0F8H
	LD C,A
	ADD HL,BC	;Zeilenbeginn
	LD B,8
	LD DE,0
CS1	LD A,M
	ADD E
	LD E,A
	JR NC,CS2
	INC D
CS2	INC HL
	DJNZ CS1
	LD A,21H
	LD (CURSO),A
	EX DE,HL
	CALL PV1
	DEFB HLHX
	POP HL
	LD (CURSO),HL
	RET
;Anzeige des Bildes:
;-------------------
BILD	LD HL,(CURSO)
	PUSH HL
	LD HL,0100H
	LD (CURSO),HL
	LD HL,(ARG1)
	LD C,12		;12 Zeilen
ZEIL	LD A,' '
	CALL PV1
	DEFB CRT
	CALL PV1
	DEFB HLHX	;Adresse
	LD A,' '
	CALL PV1
	DEFB CRT
	LD B,8		;8Byte=1Zeile
	LD DE,0
SPAL	LD A,M		;Byte
	ADD E
	LD E,A
	JR NC,B1
	INC D
B1	LD A,M		;Byte
	CALL PV1
	DEFB AHEX
	LD A,' '
	CALL PV1
	DEFB CRT
	INC HL
	DJNZ SPAL
	CALL PV1
	DEFB OSTR
	DEFM '  '
	DEFB 0
	EX DE,HL
	CALL PV1
	DEFB HLHX	;Checksum
	EX DE,HL
	CALL PV1
	DEFB OSTR
	DEFB 0DH
	DEFW 0A0AH
	DEFB 0
	DEC C
	JR NZ,ZEIL	;10 Zeilen
	POP HL
	LD (CURSO),HL
	RET
;Programmende:
;------------
END	XOR A		;Fenster 0
	CALL PV1
	DEFB WINAK
	LD HL,1D00H
	LD (CURSO),HL
	RET
;-------
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ