

#include "\SrcAll\v1_Header.asm"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	
	
;The TI will force an NMI if we try to use the ports :-(

;We can't stop it in eZ80/ADL mode, but if we switch to Z80 mode, we can create our own dummy interrupt handler!

	
	stmix			;Need to use STMIX before using legacy code!
	
	di
	ld   a,$d1 		;Top byte of address in 8 bit mode
	ld   mb,a

	;call.is Test8Bit_Outs & $ffff ;8 bit mode
	call.is Test8Bit_OutRanges & $ffff ;8 bit mode

	rsmix 			;Back to full eZ80/ADL mode
	jp FinishProgram

.assume ADL=0	
Test8Bit_Outs:
	ld bc,$45ED			;RETN command bytecode
	ld ($0066),bc

	ld hl,$0060			;Show our interrupt hander
	ld bc,16
	call.il Monitor_MemDumpL
	
	ld bc,$B024	;Backlight
	ld a,255
	out (bc),a

	ld bc,$0001		;CPU speed (0-3 = 6/12/24/48) 
	in d,(bc)
	
	;We now have special commands for accessing port $00xx!
	
	in0 e,($01)		;load E from port $0001 (Current speed)
	
	ld a,1			;12 mhz :-(
	out0 ($01),a 	;Send A to port $0001
	
	in b,(bc)		;Get New speed
	
	call.il MonitorL
	
	ret.l

Test8Bit_OutRanges:
	ld a,0			;6 mhz :-(
	out0 ($01),a 	;Send A to port $0001
	
	ld bc,$A000
	ld a,3
	;out (bc),a		;Set Port ($A000) to 3 - enable Continuous key scan

;Repeated INC 	
	ld de,$A000		;Port (keyboard)
	ld hl,$1000
	ld bc,$40
	INI2R			;Transfer BC bytes from port (DE+) to address (HL+)

;Repeated DEC
	ld de,$A040		;Port (keyboard)
	ld hl,$1040
	ld bc,$40
	;IND2R			;Transfer BC bytes from port (DE-) to address (HL-)
	
	ld a,1
	ld bc,$600C		;Enable Timer 
	out (bc),a 		;Send A to port $0001
	
	
	
;Read lots of bytes from one port.	
	ld de,$6001		;32 bit Counter
	ld hl,$1040
	ld bc,$40
	INIRX			;Transfer BC bytes from port (DE) to address (HL+)
					;DE never changes
					
;INDRX will Transfer BC bytes from port (DE) to address (HL-)
		
	
	ld b,16
	ld c,0			;Port 0-15
	ld hl,$1080
	INIMR			;Transfer B bytes from port ($00CC+) to address (HL+)
	
	ld hl,$1000
	ld bc,$C0
	call.il Monitor_MemDumpL
	
	ld de,0
	ld hl,ypos & $ffff
	ld (hl),de	;Reset pos
	
	jp Test8Bit_OutRanges & $ffff
	
	
.assume ADL=1	

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	

 
	
#include "\SrcAll\Functions.asm"
#include "\SrcAll\Monitor.asm"
	
Font:
#import "\ResAll\Font96.FNT"

#include "\SrcAll\v1_Footer.asm"
