 MODULE VENDOR

;; www.cpcwiki.eu/index.php/LK-selectable_Brand_Names
;; www.cpcwiki.eu/index.php/LK_Links
;; LK1,LK2,LK3 are optional links on the CPC mainboard, connected to PPI Port B, Bit1-3. 
;; The links select the distributor name (which is displayed by the BIOS in the boot message). 

;; www.cpcwiki.eu/index.php/8255#PPI_Port_B
;; LK4 default 50Hz screen refresh

; ALL in UPPERCASE, we do not have lowercase chars in this ROM!!!
@VendorNames:                    
TxtAmstrad:   db "AMSTRAD",0
TxtOrion:     db "ORION",0
TxtSchneider: db "SCHNEIDER",0
TxtAwa:       db "AWA",0
TxtSolavox:   db "SOLAVOX",0
TxtSaisho:    db "SAISHO",0
TxtTriumph:   db "TRIUMPH",0
TxtIsp:       db "ISP",0            

@VendorTableOffset:
	db 0
	db TxtOrion     - TxtAmstrad
	db TxtSchneider - TxtAmstrad
	db TxtAwa       - TxtAmstrad
	db TxtSolavox   - TxtAmstrad
	db TxtSaisho    - TxtAmstrad
	db TxtTriumph   - TxtAmstrad
	db TxtIsp       - TxtAmstrad

@RefreshNames:
Txt60HZ: db "60Hz",0
Txt50HZ: db "50Hz",0

@RefreshTableOffset:
	db 0
	db Txt50HZ - Txt60HZ

;; OUT: (Vendor) - vendor from LK3-1 configuration
@DetectVendor:
	ld	b,#f5            	; PPI port B.
	in 	a,(c)            	; Addressing, B in top half, C in bottom half (ignored)
	cpl                 		; invert bits
	and 	%00001110       	; Links LK3-LK1 define machine
	rrca                		; get rid of bit0
	ld 	(VendorName), a
	ret

;;  OUT: (Frequency) - frequency from LK4 configuration
@DetectFrequency:
	ld	b, #F5           	; PPI port B input
	in	a, (c)            	; 
	and	%00010000       	; LK4 50/60 Hz  &10/&00
	sra	a
	sra	a
	sra	a
	sra	a
	ld      (RefreshFrequency), a	; 1: 50 Hz, 0: 60 Hz
	ret
	
 ENDMODULE
