#include "ti84pce.inc"
 .assume ADL=1
 .org userMem-2
 .db tExtTok,tAsm84CeCmp

 call _homeup
 call _ClrScrnFull
 call 0020848h ;_RunIndicOff - no busy icon
	ld   a,mb
	push af
	push iy
	
	ld iy,0
	
	Call Monitor
	Call GetCurrentMB
	call monitor
	
	
	;ld   a,$d1
	;ld   mb,a
	;ld.sis   sp,$987e
	
 	ld a,'A'
	call PrintChar
	ld a,'b'
	call PrintChar
	ld a,'1'
	call PrintChar
	Call Newline
	ld hl,Hello
	call PrintString
	call NewLine
	ld bc,$FFFFFF
	ld hl,$FFFFFF
	
	ld.lis bc,$1234	;L__=24 bit register  _IS=Load 16 bit val (zero's BCU)
	ld.sis hl,$1234	;S__=16 bit register  _IS=Load 16 bit val (zero's BCU /unk in z80 mode)
	
	;ld.sil bc,$123456	;S__=16 bit reg  _IL=Load 24 bit val  (zero's BCU /unk in z80 mode)
	;ld.lil hl,$123456	;L__=24 bit reg  _IL=Load 24 bit val 
	
	
	
	;Call.lil Monitor	;Only works if Monitor ends RET.L
	;call Test8Bit
	;call.is   Test8Bit & $ffff
	
	;di
	;ld   a,$d1
	;ld   mb,a
	
	;ld.sis   sp,$a845
	;call.is   Test8Bit & $ffff
	ld hl,$123456
	ld bc,$FEDCBA
	ld i,hl
	Call Monitor
	
	Call Monitor
	  
	  
	ld hl,$D10000
	ld bc,128
	call Monitor_MemDump 
	  
	
	call SpriteTest
	pop iy
	pop af
	ld mb,a
 call _GetKey
 call _ClrScrnFull
 res donePrgm,(iy+doneFlags)
 
 ret
 
SpriteTest:
	ld hl,Sprite
	ld de,$D40000+640-128
	ld ixl,54
	
NextLine:
	push de
		ld bc,58*2
		ldir
	pop de
	Call GetNextLine
	
	dec ixl
	jr nz,NextLine
	ret
 
#include "\SrcAll\Functions.asm"
#include "\SrcAll\Monitor.asm"
	
Sprite:
#import "\ResAll\Sprites\SpriteT84.RAW"
Font:
#import "\ResAll\Font96.FNT"

TestVal: .db $11,$22,$33

Xpos: .db 0,0,0
Ypos: .db 0,0,0

Hello:
  .db "Chibi Invasion2!",255

GetCurrentMB:
	di
	ld ix,0
	add ix,sp
	ld a,(ix+2)
	ld mb,a			;Get current block
	ld.sis sp,StackZ80 & $FFFF	;Safe Stack
	ret
;Stack for Classic Z80
	.dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	.dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
StackZ80: 
  
.assume ADL=0
Test8bit:
	ld bc,$45ED
	ld ($0066),bc

	ld bc,$B024	;Backlight

	ld a,255
	out (bc),a
	
	ld bc,$fffE
	call.sil NewLine8Bit
	call.sil Monitor8bit
	;call.sil Monitor		;Only works if Monitor ends RET.L
	dec bc
	call.sil Monitor8bit
	
	call.sil NewLine8Bit
	ret.l
	
.assume ADL=1	

TestVal2: .db $11,$22,$33
