1
2	MODULE	generic_console_ioctl
3	PUBLIC	generic_console_ioctl
4
5	SECTION	code_clib
6	INCLUDE	"ioctl.def"
7
8	EXTERN	generic_console_cls
9	EXTERN	__console_h
10	EXTERN	__console_w
11	EXTERN	copy_font
12	EXTERN	__excali64_font32
13	EXTERN	__excali64_udg32
14	EXTERN	__excali64_mode
15
16        PUBLIC  CLIB_GENCON_CAPS
17        defc    CLIB_GENCON_CAPS = CAP_GENCON_CUSTOM_FONT | CAP_GENCON_UDGS | CAP_GENCON_FG_COLOUR | CAP_GENCON_BG_COLOUR
18
19
20
21; a = ioctl
22; de = arg
23generic_console_ioctl:
24	ex	de,hl
25	ld	c,(hl)	;bc = where we point to
26	inc	hl
27	ld	b,(hl)
28        cp      IOCTL_GENCON_SET_FONT32
29        jr      nz,check_set_udg
30	ld	(__excali64_font32),bc
31	ld	hl,$6020		;96 chars, start from 32
32	ld	a,(__excali64_mode)
33	cp	2
34	call	nz,copy_font
35success:
36        and     a
37        ret
38check_set_udg:
39        cp      IOCTL_GENCON_SET_UDGS
40        jr      nz,check_mode
41	ld	(__excali64_udg32),bc
42	ld	hl,$8080		;128 chars, start from 128
43	ld	a,(__excali64_mode)
44	cp	2
45	call	nz,copy_font
46	jr	success
47
48check_mode:
49	cp	IOCTL_GENCON_SET_MODE
50	jr	nz,failure
51	ld	a,c
52	ld	l,80
53	ld	h,24
54	ld	de,screen_80x25
55	and	a
56	jr	z,set_mode
57	ld	l,40
58	ld	h,24
59	ld	de,screen_40x25
60	cp	1
61	jr	nz,failure
62set_mode:
63	ld	(__console_w),hl
64	ld	c,0
65	ld	b,16
66vduloop:
67	ld	a,c
68	out	($30),a
69	ld	a,(de)
70	out	($31),a
71	inc	de
72	inc	c
73	djnz	vduloop
74	call	generic_console_cls
75	jr	success
76failure:
77	scf
78dummy_return:
79	ret
80
81
82	SECTION		rodata_clib
83
84screen_40x25:
85        defb    0x3f    ; -> FC66  ......Total No. of character intervals in horiz scan
86        defb    0x28    ; -> FC67  ......No. of characters displayed in a horiz scan
87        defb    0x31    ; -> FC68  ......Horiz sync position    (values between 0x31 and 0x2F were used to center the display depending on the video monitor, possibly older ROMs had different values)
88        defb    0x05    ; -> FC69  ......horiz sync pulse width
89        defb    0x18    ; -> FC6A  ......Total No. of character lines
90        defb    0x0c    ; -> FC6B  ......Adjust for vertical sync
91        defb    0x18    ; -> FC6C  ......No of lines displayed by CRTC
92        defb    0x18    ; -> FC6D  ......Vertical sync position
93        defb    0x00    ; -> FC6E  ......Interlace mode
94        defb    0x0b    ; -> FC6F  ......crtc reg.9
95        defb    0x20    ; -> FC70  ......crtc reg.10    -> Cursor blinking
96        defb    0x0b    ; -> FC71  ......crtc reg 11
97        defb    0x00    ; -> FC72  ......crtc reg 12
98        defb    0x00    ; -> FC73  ......crtc reg 13
99        defb    0x00    ; -> FC74  ......crtc reg 14    -> cursor position (high byte)
100        defb    0x00    ; -> FC75  ......crtc reg 15    -> cursor position (low byte)
101
102screen_80x25:
103        defb    0x7f    ; -> FC76  ......Total No. of character intervals in horiz scan
104        defb    0x50    ; -> FC77  ......No. of characters displayed in a horiz scan
105        defb    0x62    ; -> FC78  ......Horiz sync position    (see above about video display centering)
106        defb    0x0a    ; -> FC79  ......horiz sync pulse width
107        defb    0x18    ; -> FC7A  ......Total No. of character lines
108        defb    0x0c    ; -> FC7B  ......Adjust for vertical sync
109        defb    0x18    ; -> FC7C  ......No of lines displayed by CRTC
110        defb    0x18    ; -> FC7D  ......Vertical sync position
111        defb    0x00    ; -> FC7E  ......Interlace mode
112        defb    0x0b    ; -> FC7F  ......crtc reg.9
113        defb    0x20    ; -> FC80  ......crtc reg.10    -> Cursor blinking
114        defb    0x0b    ; -> FC81  ......crtc reg 11
115        defb    0x00    ; -> FC82  ......crtc reg 12
116        defb    0x00    ; -> FC83  ......crtc reg 13
117        defb    0x00    ; -> FC84  ......crtc reg 14    -> cursor position (high byte)
118        defb    0x00    ; -> FC85  ......crtc reg 15    -> cursor position (low byte)
119
120