1;--------------------------------------------------------------
2; ZX81 HRG library for the G007 expansion
3; by Stefano Bodrato, Fall 2014
4;--------------------------------------------------------------
5;
6;   Set HRG mode and clear screen
7;
8;	$Id: g007_clg_hr.asm,v 1.6 2016-07-14 17:44:17 pauloscustodio Exp $
9;
10
11	SECTION  code_clib
12	PUBLIC    _clg_hr
13	PUBLIC    __clg_hr
14	EXTERN     hrg_on
15
16;	EXTERN    base_graphics
17;	EXTERN    G007_P2
18
19	defc	_clg_hr = hrg_on
20	defc	__clg_hr = hrg_on
21
22;; if hrgpage has not been specified, then set a default value
23;	ld      hl,(base_graphics)
24;	ld      a,h
25;	or      l
26;	jr		nz,gotpage
27;	ld		hl,24600		; on a 16K system we leave a space of a bit more than 1500 bytes for stack
28;	ld		(base_graphics),hl
29;gotpage:
30;
31;	ld		hl,(base_graphics)
32;	ld		de,9
33;	add		hl,de
34;
35;	ld		a,$76	; NEWLINE (HALT in machine code)
36;	ld		(hl),a
37;	inc		hl
38;	ld		(hl),a
39;	inc		hl
40;
41;
42;	ld		(hl),0
43;	ld		d,h
44;	ld		e,l
45;	inc 	de
46;	ld		bc,34*192+4
47;	ldir
48;
49;	ld		(hl),a	; NEWLINE (HALT in machine code)
50;	inc		hl
51;	ld		(hl),a
52;
53;	ld		a,(G007_P2+2)
54;	cp		193
55;	jp		nz,hrg_on
56;
57;	ret
58
59