	org 512
__START_PROGRAM:
	di
	push ix
	push iy
	exx
	push hl
	exx
	ld hl, 0
	add hl, sp
	ld (__CALL_BACK__), hl
	ei
	jp __LABEL__charmap01end
__LABEL__charmap01:
#line 2
		defb $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
		defb $9A,$9A,$8A,$8A,$BA,$AA,$BA,$AA
		defb $66,$66,$AA,$AA,$AA,$AA,$AA,$AA
		defb $66,$9A,$22,$22,$BA,$EE,$AA,$AA
		defb $9A,$96,$2A,$8A,$AE,$FA,$BA,$AA
		defb $66,$A6,$8A,$8A,$EA,$EE,$AA,$AA
		defb $9A,$66,$8A,$2A,$EE,$FE,$EA,$AA
		defb $A6,$9A,$AA,$AA,$AA,$AA,$AA,$AA
		defb $9A,$6A,$2A,$2A,$EA,$BA,$AA,$AA
		defb $9A,$A6,$A2,$A2,$AE,$BA,$AA,$AA
		defb $AA,$66,$8A,$02,$BA,$EE,$AA,$AA
		defb $AA,$9A,$8A,$02,$BA,$BA,$AA,$AA
		defb $AA,$AA,$AA,$AA,$AE,$BA,$AA,$AA
		defb $AA,$AA,$AA,$02,$AA,$AA,$AA,$AA
		defb $AA,$AA,$AA,$AA,$BA,$BA,$AA,$AA
		defb $A9,$A9,$A2,$A2,$BA,$BA,$AA,$AA
		defb $9A,$66,$22,$22,$EE,$EE,$BA,$AA
		defb $9A,$5A,$8A,$8A,$BA,$BE,$EA,$AA
		defb $9A,$66,$A2,$8A,$EA,$FE,$EA,$AA
		defb $56,$A6,$8A,$A2,$AE,$BA,$EA,$AA
		defb $A6,$66,$22,$02,$AE,$AE,$BA,$AA
		defb $56,$6A,$0A,$22,$AE,$BA,$EA,$AA
		defb $9A,$6A,$0A,$22,$EE,$BA,$AA,$AA
		defb $56,$A6,$22,$8A,$BE,$EA,$EA,$AA
		defb $9A,$66,$8A,$22,$EE,$BA,$AA,$AA
		defb $9A,$66,$22,$82,$AE,$BA,$EA,$AA
		defb $AA,$AA,$8A,$8A,$AA,$BA,$BA,$AA
		defb $AA,$AA,$8A,$8A,$AA,$BA,$EA,$AA
		defb $AA,$A6,$8A,$2A,$BA,$AE,$AA,$AA
		defb $AA,$AA,$02,$AA,$FE,$AA,$AA,$AA
		defb $AA,$6A,$8A,$A2,$BA,$EA,$AA,$AA
		defb $9A,$66,$A2,$8A,$BA,$AA,$BA,$AA
		defb $9A,$66,$02,$22,$FA,$EA,$BA,$AA
		defb $9A,$9A,$22,$22,$FE,$EE,$EA,$AA
		defb $5A,$66,$0A,$22,$EE,$FA,$EA,$AA
		defb $9A,$66,$2A,$2A,$EE,$BA,$AA,$AA
		defb $5A,$66,$22,$22,$EE,$FA,$EA,$AA
		defb $56,$6A,$0A,$2A,$EA,$FE,$EA,$AA
		defb $56,$6A,$0A,$2A,$EA,$EA,$EA,$AA
		defb $9A,$66,$2A,$22,$EE,$BE,$AE,$AA
		defb $66,$66,$02,$22,$EE,$EE,$EA,$AA
		defb $56,$9A,$8A,$8A,$BA,$BE,$EA,$AA
		defb $56,$A6,$A2,$22,$EE,$FA,$EA,$AA
		defb $6A,$66,$0A,$22,$EE,$EE,$EA,$AA
		defb $6A,$6A,$2A,$2A,$EE,$FE,$EA,$AA
		defb $66,$56,$02,$02,$EE,$EE,$EA,$AA
		defb $66,$56,$22,$22,$EE,$EE,$EA,$AA
		defb $96,$66,$22,$22,$EE,$FA,$EA,$AA
		defb $5A,$66,$22,$0A,$EA,$EA,$EA,$AA
		defb $96,$66,$22,$22,$FE,$FE,$EA,$AA
		defb $5A,$66,$22,$0A,$EE,$EE,$EA,$AA
		defb $96,$6A,$8A,$A2,$AE,$BA,$EA,$AA
		defb $56,$9A,$8A,$8A,$BA,$BA,$AA,$AA
		defb $66,$66,$22,$22,$EE,$FE,$EA,$AA
		defb $66,$66,$22,$22,$EE,$FA,$EA,$AA
		defb $66,$66,$22,$02,$FE,$FE,$EE,$AA
		defb $66,$66,$8A,$22,$EE,$EE,$EA,$AA
		defb $66,$66,$22,$8A,$BA,$BE,$EA,$AA
		defb $56,$A6,$8A,$2A,$EA,$FE,$EA,$AA
		defb $5A,$6A,$2A,$2A,$EA,$FA,$AA,$AA
		defb $6A,$6A,$8A,$8A,$AE,$AE,$AA,$AA
		defb $96,$A6,$A2,$A2,$AE,$BE,$AA,$AA
		defb $9A,$66,$AA,$AA,$AA,$AA,$AA,$AA
		defb $AA,$AA,$AA,$AA,$AA,$AA,$AF,$FA
		defb $AA,$AB,$AB,$AF,$AF,$BF,$AB,$96
		defb $EA,$F8,$F8,$F8,$F8,$58,$58,$5A
		defb $66,$66,$EF,$BB,$E2,$BB,$EF,$BB
		defb $99,$99,$FB,$EE,$8B,$EE,$FB,$EE
		defb $FE,$D4,$D8,$D0,$A0,$82,$AA,$82
		defb $3F,$17,$07,$07,$A8,$08,$08,$0A
		defb $FE,$D6,$D0,$D8,$22,$28,$20,$28
		defb $BF,$97,$07,$27,$88,$28,$08,$28
		defb $AA,$96,$65,$80,$60,$6C,$2C,$2C
		defb $AA,$AA,$A9,$64,$18,$C8,$C6,$B1
		defb $AB,$AF,$AF,$BF,$BF,$BF,$F7,$FD
		defb $EA,$FA,$FA,$FE,$7E,$FE,$7F,$DF
		defb $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
		defb $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
		defb $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
		defb $AA,$AA,$AA,$AA,$AA,$AA,$AA,$AA
		defb $AA,$56,$12,$46,$12,$CE,$BA,$AB
		defb $A9,$09,$BE,$2A,$8A,$3A,$E2,$8E
		defb $6E,$BF,$BF,$BF,$BE,$AF,$BE,$6E
		defb $F9,$FE,$EE,$FA,$EE,$BA,$EE,$B9
		defb $AA,$82,$82,$82,$D2,$DA,$D6,$FE
		defb $A8,$08,$82,$2A,$87,$27,$97,$BF
		defb $22,$80,$80,$80,$D0,$D0,$D6,$FE
		defb $08,$02,$22,$0A,$27,$87,$17,$BF
		defb $38,$38,$39,$09,$02,$59,$96,$AA
		defb $B0,$2C,$2C,$EF,$FB,$EA,$AA,$AA
		defb $F7,$DD,$F5,$D5,$F5,$D5,$B5,$DD
		defb $77,$5F,$57,$5F,$57,$5F,$76,$5F
		defb $02,$21,$21,$21,$23,$02,$AA,$AA
		defb $AA,$55,$5F,$5A,$FA,$AA,$AA,$AA
		defb $64,$92,$49,$26,$98,$61,$84,$52
		defb $96,$69,$20,$08,$EF,$EB,$BE,$AA
#line 98
__LABEL__charmap01end:
	ld a, 152
	call _mc1000screen
	ld a, 2
	push af
	call _mc1000cls
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, 34
	push hl
	ld hl, 5
	push hl
	call _mc1000vpokechr
	ld hl, 0
	ld (_eey), hl
	jp __LABEL0
__LABEL3:
	ld hl, 0
	ld (_eex), hl
	jp __LABEL5
__LABEL8:
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (_eey)
	ld de, 16
	call __MUL16_FAST
	ex de, hl
	ld hl, (_eex)
	add hl, de
	push hl
	ld hl, (_eey)
	ld de, 32
	call __MUL16_FAST
	ld de, 239
	add hl, de
	ex de, hl
	ld hl, (_eex)
	add hl, de
	push hl
	call _mc1000vpokechr
	ld hl, (_eex)
	inc hl
	ld (_eex), hl
__LABEL5:
	ld hl, 15
	ld de, (_eex)
	or a
	sbc hl, de
	jp nc, __LABEL8
	ld hl, (_eey)
	inc hl
	ld (_eey), hl
__LABEL0:
	ld hl, 15
	ld de, (_eey)
	or a
	sbc hl, de
	jp nc, __LABEL3
	ld a, 2
	push af
	call _mc1000cls
__LABEL__start01:
__LABEL__titulodeljuegoymenu:
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text02) - (__LABEL__text01)
	push hl
	ld hl, __LABEL__text01
	push hl
	ld hl, 1
	push hl
	ld hl, 8
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text03) - (__LABEL__text02)
	push hl
	ld hl, __LABEL__text02
	push hl
	ld hl, 2
	push hl
	ld hl, 4
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, 19
	push hl
	ld hl, __LABEL__text03b
	push hl
	ld hl, 16
	push hl
	ld hl, 7
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, 13
	push hl
	ld hl, (__LABEL__text03b) + (19)
	push hl
	ld hl, 17
	push hl
	ld hl, 10
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, 14
	push hl
	ld hl, __LABEL__text03c
	push hl
	ld hl, 19
	push hl
	ld hl, 9
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, 12
	push hl
	ld hl, (__LABEL__text03c) + (14)
	push hl
	ld hl, 20
	push hl
	ld hl, 10
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text05) - (__LABEL__text04)
	push hl
	ld hl, __LABEL__text04
	push hl
	ld hl, 22
	push hl
	ld hl, 5
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text06) - (__LABEL__text05)
	push hl
	ld hl, __LABEL__text05
	push hl
	ld hl, 8
	push hl
	ld hl, 5
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text07) - (__LABEL__text06)
	push hl
	ld hl, __LABEL__text06
	push hl
	ld hl, 10
	push hl
	ld hl, 9
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text08) - (__LABEL__text07)
	push hl
	ld hl, __LABEL__text07
	push hl
	ld hl, 11
	push hl
	ld hl, 9
	push hl
	call _mc1000writetext
	ld hl, (__LABEL__charmap01) - (256)
	push hl
	ld hl, (__LABEL__text09) - (__LABEL__text08)
	push hl
	ld hl, __LABEL__text08
	push hl
	ld hl, 12
	push hl
	ld hl, 9
	push hl
	call _mc1000writetext
	ld hl, 1
	ld (_di), hl
__LABEL10:
	jp __LABEL10
__LABEL__selecciondenivel:
	jp __LABEL__selecciondenivel
__LABEL__variablesglobales:
	ld hl, 1
	ld (_x), hl
	ld hl, 1
	ld (_y), hl
	ld hl, 0
	ld (_su), hl
	ld hl, 16
	ld (_ba), hl
__LABEL__variablesfase:
	ld de, 1
	ld hl, (_di)
	call __EQ16
	or a
	jp z, __LABEL13
	ld hl, 10
	ld (_ca), hl
	ld hl, 2000
	ld (_t), hl
__LABEL13:
	ld de, 2
	ld hl, (_di)
	call __EQ16
	or a
	jp z, __LABEL15
	ld hl, 20
	ld (_ca), hl
	ld hl, 3000
	ld (_t), hl
__LABEL15:
	ld de, 3
	ld hl, (_di)
	call __EQ16
	or a
	jp z, __LABEL17
	ld hl, 30
	ld (_ca), hl
	ld hl, 4000
	ld (_t), hl
__LABEL17:
__LABEL__255:
	ld de, 8
	ld hl, (_ba)
	or a
	sbc hl, de
	sbc a, a
	push af
	ld hl, 23
	ld de, (_ba)
	or a
	sbc hl, de
	sbc a, a
	ld h, a
	pop af
	or h
	or a
	jp nz, __LABEL__finaldeljuego
	call __LABEL__pintartablero
	call __LABEL__pintarcursor
__LABEL__bucleprincipal:
__LABEL__controldeltiempo:
	ld hl, (_t)
	dec hl
	ld (_t), hl
__LABEL__controldeltiempodelay:
	ld hl, 1
	ld (_eee0), hl
	jp __LABEL20
__LABEL23:
	ld hl, (_eee0)
	inc hl
	ld (_eee0), hl
__LABEL20:
	ld hl, 4000
	ld de, (_eee0)
	or a
	sbc hl, de
	jp nc, __LABEL23
__LABEL__condiciones:
	jp __LABEL__bucleprincipal
__LABEL__pasadefase:
	ld de, 64
	ld hl, (_su)
	call __EQ16
	or a
	jp z, __LABEL26
	ld hl, (_ba)
	dec hl
	ld (_ba), hl
	ld hl, 0
	ld (_su), hl
	ld hl, 1
	ld (_x), hl
	ld hl, 1
	ld (_y), hl
	jp __LABEL__6020
__LABEL26:
	ld de, 128
	ld hl, (_su)
	call __EQ16
	or a
	jp z, __LABEL28
	ld hl, (_ba)
	inc hl
	ld (_ba), hl
	ld hl, 0
	ld (_su), hl
	ld hl, 1
	ld (_x), hl
	ld hl, 1
	ld (_y), hl
	jp __LABEL__6020
__LABEL28:
__LABEL__6020:
	ld de, 1
	ld hl, (_di)
	call __EQ16
	or a
	jp z, __LABEL30
	ld hl, 2000
	ld (_t), hl
__LABEL30:
	ld de, 2
	ld hl, (_di)
	call __EQ16
	or a
	jp z, __LABEL32
	ld hl, 3000
	ld (_t), hl
__LABEL32:
	ld de, 3
	ld hl, (_di)
	call __EQ16
	or a
	jp z, __LABEL34
	ld hl, 4000
	ld (_t), hl
__LABEL34:
	jp __LABEL__255
__LABEL__utilizaunapica:
__LABEL__6510:
__LABEL__pintarcursor:
	ld de, 1
	ld hl, (_d)
	call __EQ16
	or a
	jp z, __LABEL36
	ld hl, (_x)
	dec hl
	ld (_x), hl
__LABEL36:
	ld de, 2
	ld hl, (_d)
	call __EQ16
	or a
	jp z, __LABEL38
	ld hl, (_x)
	inc hl
	ld (_x), hl
__LABEL38:
	ld de, 3
	ld hl, (_d)
	call __EQ16
	or a
	jp z, __LABEL40
	ld hl, (_y)
	dec hl
	ld (_y), hl
__LABEL40:
	ld de, 4
	ld hl, (_d)
	call __EQ16
	or a
	jp z, __LABEL42
	ld hl, (_y)
	inc hl
	ld (_y), hl
__LABEL42:
__LABEL__replacedthecursorhere:
__LABEL__cambiarfichas:
__LABEL__minirutinadecambio:
__LABEL__7508:
__LABEL__7510:
__LABEL__7512:
__LABEL__7514:
__LABEL__7520:
__LABEL__minirutinadepintado:
__LABEL__7535:
__LABEL__7540:
__LABEL__7545:
__LABEL__7550:
__LABEL__pintartablero:
	ld hl, 1
	ld (_r), hl
	jp __LABEL43
__LABEL46:
	ld hl, 1
	ld (_c), hl
	jp __LABEL48
__LABEL51:
	ld hl, (_su)
	inc hl
	ld (_su), hl
	ld hl, (_c)
	inc hl
	ld (_c), hl
__LABEL48:
	ld hl, 8
	ld de, (_c)
	or a
	sbc hl, de
	jp nc, __LABEL51
	ld hl, (_r)
	inc hl
	ld (_r), hl
__LABEL43:
	ld hl, 8
	ld de, (_r)
	or a
	sbc hl, de
	jp nc, __LABEL46
	ld hl, 1
	ld (_n), hl
	jp __LABEL53
__LABEL56:
__LABEL__8010:
__LABEL__8012:
__LABEL__8014:
__LABEL__8016:
__LABEL__8018:
	ld hl, (_n)
	inc hl
	ld (_n), hl
__LABEL53:
	ld hl, (_ca)
	ld de, (_n)
	or a
	sbc hl, de
	jp nc, __LABEL56
	ld hl, 1
	ld (_r), hl
	jp __LABEL58
__LABEL61:
	ld hl, 1
	ld (_c), hl
	jp __LABEL63
__LABEL66:
	ld hl, (_c)
	inc hl
	ld (_c), hl
__LABEL63:
	ld hl, 8
	ld de, (_c)
	or a
	sbc hl, de
	jp nc, __LABEL66
	ld hl, (_r)
	inc hl
	ld (_r), hl
__LABEL58:
	ld hl, 8
	ld de, (_r)
	or a
	sbc hl, de
	jp nc, __LABEL61
	ret
__LABEL__pausa:
	ret
__LABEL__gameover:
	jp __LABEL__titulodeljuegoymenu
__LABEL__finaldeljuego:
	ld hl, 23
	ld de, (_ba)
	or a
	sbc hl, de
	jp c, __LABEL__titulodeljuegoymenu
	ld de, 8
	ld hl, (_ba)
	or a
	sbc hl, de
	sbc a, a
	push af
	ld de, 1
	ld hl, (_di)
	call __EQ16
	ld h, a
	pop af
	call __AND8
	or a
	jp nz, __LABEL__titulodeljuegoymenu
	ld de, 8
	ld hl, (_ba)
	or a
	sbc hl, de
	sbc a, a
	push af
	ld de, 2
	ld hl, (_di)
	call __EQ16
	ld h, a
	pop af
	call __AND8
	or a
	jp nz, __LABEL__titulodeljuegoymenu
	ld de, 8
	ld hl, (_ba)
	or a
	sbc hl, de
	sbc a, a
	push af
	ld de, 3
	ld hl, (_di)
	call __EQ16
	ld h, a
	pop af
	call __AND8
	or a
	jp nz, __LABEL__titulodeljuegoymenu
__LABEL__pintadodeifs:
__LABEL__9001:
__LABEL__9002:
__LABEL__9003:
__LABEL__9004:
__LABEL__9005:
__LABEL__9006:
__LABEL__9007:
__LABEL__9008:
__LABEL__cambiodeifs:
__LABEL__9101:
__LABEL__9102:
__LABEL__9103:
__LABEL__9104:
__LABEL__9105:
__LABEL__9106:
__LABEL__9107:
__LABEL__9108:
__LABEL__text01:
#line 722
		defb "KNIGHTS & DEMONS"
#line 723
__LABEL__text02:
#line 726
		defb "A GAME BY KABUTO FACTORY"
#line 727
__LABEL__text03:
__LABEL__text03a:
#line 731
		defb "CASIO PV-1000 VERSION BY MANUEL GOMEZ"
#line 732
__LABEL__text03b:
#line 736
		defb "ORIGINAL VERSION BY MANUEL GOMEZ"
#line 737
__LABEL__text03c:
#line 740
		defb "SMS VERSION BY PAULO SILVA"
#line 741
__LABEL__text03d:
__LABEL__text04:
#line 745
		defb $7F
		defb " 2015 KABUTO FACTORY"
#line 747
__LABEL__text05:
#line 750
		defb "SELECT DIFFICULT LEVEL"
#line 751
__LABEL__text06:
#line 754
		defb "1. EASY LEVEL  "
#line 755
__LABEL__text07:
#line 758
		defb "2. MEDIUM LEVEL"
#line 759
__LABEL__text08:
#line 762
		defb "3. HARD LEVEL  "
#line 763
__LABEL__text09:
#line 766
		defb "PIKES"
#line 767
__LABEL__text10:
#line 770
		defb "TIME "
#line 771
__LABEL__text11:
#line 774
		defb "BOARD CLEAR"
#line 775
__LABEL__text12:
#line 778
		defb "...ON THE GOOD SIDE"
#line 779
__LABEL__text13:
#line 782
		defb "...ON THE EVIL SIDE"
#line 783
__LABEL__text14:
#line 786
		defb "A NEW BATTLE BEGINS..."
#line 787
__LABEL__text15:
#line 790
		defb "GAME OVER"
#line 791
__LABEL__text16:
#line 794
		defb "THE EVIL LORD IS LOOKING FOR"
#line 795
__LABEL__text17:
#line 798
		defb "A PUPIL AND YOU'RE THE BEST"
#line 799
__LABEL__text18:
#line 802
		defb "CANDIDATE"
#line 803
__LABEL__text19:
#line 806
		defb "WELCOME TO THE DARK SIDE"
#line 807
__LABEL__text20:
#line 810
		defb "BAKELOR IS HAPPY WITH YOU..."
#line 811
__LABEL__text21:
#line 814
		defb "BUT THERE IS A LOT OF WORK "
#line 815
__LABEL__text22:
#line 818
		defb "TO DO...."
#line 819
__LABEL__text23:
#line 822
		defb "TRY WITH A HARDER LEVEL."
#line 823
__LABEL__text24:
#line 826
		defb "YOU ARE THE NEW LORD OF WAR."
#line 827
__LABEL__text25:
#line 830
		defb "YOU'VE MASTERED THE GAME..."
#line 831
__LABEL__text26:
#line 834
		defb "         "
#line 835
__LABEL__text27:
#line 838
		defb "THANKS FOR PLAYING......"
#line 839
__LABEL__text28:
#line 842
		defb "PAUSED"
#line 843
__LABEL__text29:
__LABEL__tile01:
#line 849
		defb "`apq"
#line 850
__LABEL__tile02:
#line 853
		defb "bcrs"
#line 854
__LABEL__tile03:
#line 857
		defb "detu"
#line 858
__LABEL__tile04:
#line 861
		defb "fgvw"
#line 862
__LABEL__tile05:
#line 865
		defb "hixy"
#line 866
__LABEL__tile06:
#line 869
		defb "jkz{"
#line 870
__LABEL__tile07:
__LABEL__finger01:
#line 874
		defb $6E,$6F,$20,$20
#line 875
__LABEL__snakesheads01:
#line 878
		defb "hx"
#line 879
__LABEL__tilechry01:
#line 884
		defb $7E,$7E,$7E,$7E
#line 885
	ld hl, 0
	ld b, h
	ld c, l
__END_PROGRAM:
	di
	ld hl, (__CALL_BACK__)
	ld sp, hl
	exx
	pop hl
	pop iy
	pop ix
	exx
	ei
	ret
__CALL_BACK__:
	DEFW 0
_mc1000screen:
#line 1
		out($80),a
		ld($00F5),a
#line 3
_mc1000screen__leave:
	ret
_mc1000cls:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 0
	push hl
	push hl
	push hl
	inc sp
	ld (ix-3), 0
	ld (ix-2), 2
	ld (ix-1), 0
	ld a, (245)
	ld h, 248
	and h
	sub 128
	sub 1
	jp nc, __LABEL77
	ld (ix-3), 0
	ld (ix-2), 4
__LABEL77:
	ld a, (245)
	ld h, 252
	and h
	sub 136
	sub 1
	jp nc, __LABEL79
	ld (ix-3), 0
	ld (ix-2), 8
__LABEL79:
	ld a, (245)
	ld h, 252
	and h
	sub 140
	sub 1
	jp nc, __LABEL81
	ld (ix-3), 0
	ld (ix-2), 6
__LABEL81:
	ld a, (245)
	ld h, 248
	and h
	sub 144
	sub 1
	jp nc, __LABEL83
	ld (ix-3), 0
	ld (ix-2), 12
__LABEL83:
	ld a, (245)
	ld h, 248
	and h
	sub 152
	sub 1
	jp nc, __LABEL85
	ld (ix-3), 0
	ld (ix-2), 24
__LABEL85:
	ld a, (245)
	ld h, 132
	and h
	sub 128
	sub 1
	jp nc, __LABEL87
	ld a, (ix+5)
	ld h, 3
	and h
	ld h, 85
	call __MUL8_FAST
	ld (ix-1), a
__LABEL87:
	ld a, (245)
	ld h, 132
	and h
	sub 132
	sub 1
	jp nc, __LABEL89
	ld a, (ix+5)
	ld h, 1
	and h
	ld h, 255
	call __MUL8_FAST
	ld (ix-1), a
__LABEL89:
	ld a, (245)
	ld h, 96
	and h
	sub 96
	sub 1
	jp nc, __LABEL91
	ld (ix-1), 0
	ld a, (ix+5)
	ld h, 7
	and h
	ld h, 4
	cp h
	jp nc, __LABEL93
	ld a, (ix+5)
	ld h, 3
	and h
	ld b, 6
__LABEL110:
	add a, a
	djnz __LABEL110
	ld h, a
	ld a, 63
	or h
	ld (ix-1), a
__LABEL93:
__LABEL91:
	ld a, (245)
	ld h, 96
	and h
	sub 64
	sub 1
	jp nc, __LABEL95
	ld (ix-1), 0
	ld a, (ix+5)
	ld h, 15
	and h
	ld h, 8
	cp h
	jp nc, __LABEL97
	ld a, (ix+5)
	ld h, 7
	and h
	add a, a
	add a, a
	add a, a
	add a, a
	ld h, a
	ld a, 15
	or h
	ld (ix-1), a
__LABEL97:
__LABEL95:
	ld a, (245)
	ld h, 252
	and h
	sub 1
	jp nc, __LABEL99
	ld a, (ix+5)
	ld h, 1
	and h
	ld b, 7
__LABEL111:
	add a, a
	djnz __LABEL111
	ld h, a
	ld a, 32
	or h
	ld (ix-1), a
__LABEL99:
	ld (ix-5), 0
	ld (ix-4), 0
	jp __LABEL100
__LABEL103:
	ld l, (ix-5)
	ld h, (ix-4)
	ld de, 32768
	add hl, de
	push hl
	ld a, (ix-1)
	pop hl
	ld (hl), a
	ld l, (ix-5)
	ld h, (ix-4)
	inc hl
	ld (ix-5), l
	ld (ix-4), h
__LABEL100:
	ld l, (ix-5)
	ld h, (ix-4)
	push hl
	ld l, (ix-3)
	ld h, (ix-2)
	dec hl
	pop de
	or a
	sbc hl, de
	jp nc, __LABEL103
_mc1000cls__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	ex (sp), hl
	exx
	ret
_mc1000vpokechr:
	push ix
	ld ix, 0
	add ix, sp
	ld l, (ix+4)
	ld h, (ix+5)
	ld de, 768
	call __MODU16
	ld (ix+4), l
	ld (ix+5), h
	ld hl, 8
	push hl
	ld l, (ix+8)
	ld h, (ix+9)
	push hl
	ld l, (ix+6)
	ld h, (ix+7)
	add hl, hl
	add hl, hl
	add hl, hl
	ex de, hl
	pop hl
	add hl, de
	push hl
	ld l, (ix+4)
	ld h, (ix+5)
	ld h, 0
	ld a, l
	and 31
	ld l, a
	ld de, 32768
	add hl, de
	ld de, 0
	push de
	push hl
	ld l, (ix+4)
	ld h, (ix+5)
	ld de, 32
	call __DIVU16
	ld de, 0
	push de
	push hl
	ld de, 0
	ld hl, 256
	call __MUL32
	pop bc
	add hl, bc
	pop bc
	ex de, hl
	adc hl, bc
	ex de, hl
	push hl
	call _minivadersldir32b
_mc1000vpokechr__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
_minivadersldir32b:
	push ix
	ld ix, 0
	add ix, sp
#line 2
		ld d,(ix+5)
		ld e,(ix+4)
		ld h,(ix+7)
		ld l,(ix+6)
		ld b,(ix+9)
		ld c,(ix+8)
minivadersldir32bloop:
		ld a,(hl)
		ld (de),a
		inc hl
		ex de,hl
		push de
		ld de,32
		add hl,de
		pop de
		ex de,hl
		dec bc
		ld a,b
		or c
		jp nz,minivadersldir32bloop
#line 22
_minivadersldir32b__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
_mc1000writetext:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 0
	ld (_tq2), hl
	jp __LABEL105
__LABEL108:
	ld l, (ix+12)
	ld h, (ix+13)
	push hl
	ld l, (ix+8)
	ld h, (ix+9)
	ex de, hl
	ld hl, (_tq2)
	add hl, de
	ld b, h
	ld c, l
	ld a, (bc)
	ld l, a
	ld h, 0
	push hl
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 32
	call __MUL16_FAST
	push hl
	ld l, (ix+4)
	ld h, (ix+5)
	ex de, hl
	pop hl
	add hl, de
	ex de, hl
	ld hl, (_tq2)
	add hl, de
	push hl
	call _mc1000vpokechr
	ld hl, (_tq2)
	inc hl
	ld (_tq2), hl
__LABEL105:
	ld l, (ix+10)
	ld h, (ix+11)
	dec hl
	ld de, (_tq2)
	or a
	sbc hl, de
	jp nc, __LABEL108
_mc1000writetext__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
#line 1 "and8.asm"
	; FASTCALL boolean and 8 version.
	; result in Accumulator (0 False, not 0 True)
; __FASTCALL__ version (operands: A, H)
	; Performs 8bit and 8bit and returns the boolean
	
__AND8:
		or a
		ret z
		ld a, h
		ret 
	
#line 1159 "knightsanddemons.bas"
#line 1 "div16.asm"
	; 16 bit division and modulo functions 
	; for both signed and unsigned values
	
#line 1 "neg16.asm"
	; Negates HL value (16 bit)
__ABS16:
		bit 7, h
		ret z
	
__NEGHL:
		ld a, l			; HL = -HL
		cpl
		ld l, a
		ld a, h
		cpl
		ld h, a
		inc hl
		ret
	
#line 5 "div16.asm"
	
__DIVU16:    ; 16 bit unsigned division
	             ; HL = Dividend, Stack Top = Divisor
	
		;   -- OBSOLETE ; Now uses FASTCALL convention
		;   ex de, hl
	    ;	pop hl      ; Return address
	    ;	ex (sp), hl ; CALLEE Convention
	
__DIVU16_FAST:
	    ld a, h
	    ld c, l
	    ld hl, 0
	    ld b, 16
	
__DIV16LOOP:
	    sll c
	    rla
	    adc hl,hl
	    sbc hl,de
	    jr  nc, __DIV16NOADD
	    add hl,de
	    dec c
	
__DIV16NOADD:
	    djnz __DIV16LOOP
	
	    ex de, hl
	    ld h, a
	    ld l, c
	
	    ret     ; HL = quotient, DE = Mudulus
	
	
	
__MODU16:    ; 16 bit modulus
	             ; HL = Dividend, Stack Top = Divisor
	
	    ;ex de, hl
	    ;pop hl
	    ;ex (sp), hl ; CALLEE Convention
	
	    call __DIVU16_FAST
	    ex de, hl	; hl = reminder (modulus)
					; de = quotient
	
	    ret
	
	
__DIVI16:	; 16 bit signed division
		;	--- The following is OBSOLETE ---
		;	ex de, hl
		;	pop hl
		;	ex (sp), hl 	; CALLEE Convention
	
__DIVI16_FAST:
		ld a, d
		xor h
		ex af, af'		; BIT 7 of a contains result
	
		bit 7, d		; DE is negative?
		jr z, __DIVI16A	
	
		ld a, e			; DE = -DE
		cpl
		ld e, a
		ld a, d
		cpl
		ld d, a
		inc de
	
__DIVI16A:
		bit 7, h		; HL is negative?
		call nz, __NEGHL
	
__DIVI16B:
		call __DIVU16_FAST
		ex af, af'
	
		or a	
		ret p	; return if positive
	    jp __NEGHL
	
		
__MODI16:    ; 16 bit modulus
	             ; HL = Dividend, Stack Top = Divisor
	
	    ;ex de, hl
	    ;pop hl
	    ;ex (sp), hl ; CALLEE Convention
	
	    call __DIVI16_FAST
	    ex de, hl	; hl = reminder (modulus)
					; de = quotient
	
	    ret
	
#line 1160 "knightsanddemons.bas"
#line 1 "eq16.asm"
__EQ16:	; Test if 16bit values HL == DE
		; Returns result in A: 0 = False, FF = True
			or a	; Reset carry flag
			sbc hl, de 
	
			ld a, h
			or l
			sub 1  ; sets carry flag only if a = 0
			sbc a, a
			
			ret
	
#line 1161 "knightsanddemons.bas"
#line 1 "mul16.asm"
__MUL16:	; Mutiplies HL with the last value stored into de stack
				; Works for both signed and unsigned
	
			PROC
	
			LOCAL __MUL16LOOP
	        LOCAL __MUL16NOADD
			
			ex de, hl
			pop hl		; Return address
			ex (sp), hl ; CALLEE caller convention
	
;;__MUL16_FAST:	; __FASTCALL ENTRY: HL = 1st operand, DE = 2nd Operand
	;;		ld c, h
	;;		ld a, l	 ; C,A => 1st Operand
	;;
	;;		ld hl, 0 ; Accumulator
	;;		ld b, 16
	;;
;;__MUL16LOOP:
	;;		sra c	; C,A >> 1  (Arithmetic)
	;;		rra
	;;
	;;		jr nc, __MUL16NOADD
	;;		add hl, de
	;;
;;__MUL16NOADD:
	;;		sla e
	;;		rl d
	;;			
	;;		djnz __MUL16LOOP
	
__MUL16_FAST:
	        ld b, 16
	        ld a, d
	        ld c, e
	        ex de, hl
	        ld hl, 0
	
__MUL16LOOP:
	        add hl, hl  ; hl << 1
	        sla c
	        rla         ; a,c << 1
	        jp nc, __MUL16NOADD
	        add hl, de
	
__MUL16NOADD:
	        djnz __MUL16LOOP
	
			ret	; Result in hl (16 lower bits)
	
			ENDP
	
#line 1162 "knightsanddemons.bas"
#line 1 "mul32.asm"
#line 1 "_mul32.asm"
	
; Ripped from: http://www.andreadrian.de/oldcpu/z80_number_cruncher.html#moztocid784223
	; Used with permission.
	; Multiplies 32x32 bit integer (DEHL x D'E'H'L')
	; 64bit result is returned in H'L'H L B'C'A C
	
	
__MUL32_64START:
			push hl
			exx
			ld b, h
			ld c, l		; BC = Low Part (A)
			pop hl		; HL = Load Part (B)
			ex de, hl	; DE = Low Part (B), HL = HightPart(A) (must be in B'C')
			push hl
	
			exx
			pop bc		; B'C' = HightPart(A)
			exx			; A = B'C'BC , B = D'E'DE
	
				; multiply routine 32 * 32bit = 64bit
				; h'l'hlb'c'ac = b'c'bc * d'e'de
				; needs register a, changes flags
				;
				; this routine was with tiny differences in the
				; sinclair zx81 rom for the mantissa multiply
	
__LMUL:
	        and     a               ; reset carry flag
	        sbc     hl,hl           ; result bits 32..47 = 0
	        exx
	        sbc     hl,hl           ; result bits 48..63 = 0
	        exx
	        ld      a,b             ; mpr is b'c'ac
	        ld      b,33            ; initialize loop counter
	        jp      __LMULSTART  
	
__LMULLOOP:
	        jr      nc,__LMULNOADD  ; JP is 2 cycles faster than JR. Since it's inside a LOOP
	                                ; it can save up to 33 * 2 = 66 cycles
	                                ; But JR if 3 cycles faster if JUMP not taken!
	        add     hl,de           ; result += mpd
	        exx
	        adc     hl,de
	        exx
	
__LMULNOADD:
	        exx
	        rr      h               ; right shift upper
	        rr      l               ; 32bit of result
	        exx
	        rr      h
	        rr      l
	
__LMULSTART:
	        exx
	        rr      b               ; right shift mpr/
	        rr      c               ; lower 32bit of result
	        exx
	        rra                     ; equivalent to rr a
	        rr      c
	        djnz    __LMULLOOP
	
			ret						; result in h'l'hlb'c'ac
	       
#line 2 "mul32.asm"
	
__MUL32:	; multiplies 32 bit un/signed integer.
				; First operand stored in DEHL, and 2nd onto stack
				; Lowest part of 2nd operand on top of the stack
				; returns the result in DE.HL
			exx
			pop hl	; Return ADDRESS
			pop de	; Low part
			ex (sp), hl ; CALLEE -> HL = High part
			ex de, hl
			call __MUL32_64START
	
__TO32BIT:  ; Converts H'L'HLB'C'AC to DEHL (Discards H'L'HL)
			exx
			push bc
			exx
			pop de
			ld h, a
			ld l, c
			ret
	
	
#line 1163 "knightsanddemons.bas"
#line 1 "mul8.asm"
__MUL8:		; Performs 8bit x 8bit multiplication
		PROC
	
		;LOCAL __MUL8A
		LOCAL __MUL8LOOP
		LOCAL __MUL8B
				; 1st operand (byte) in A, 2nd operand into the stack (AF)
		pop hl	; return address
		ex (sp), hl ; CALLE convention
	
;;__MUL8_FAST: ; __FASTCALL__ entry
	;;	ld e, a
	;;	ld d, 0
	;;	ld l, d
	;;	
	;;	sla h	
	;;	jr nc, __MUL8A
	;;	ld l, e
	;;
;;__MUL8A:
	;;
	;;	ld b, 7
;;__MUL8LOOP:
	;;	add hl, hl
	;;	jr nc, __MUL8B
	;;
	;;	add hl, de
	;;
;;__MUL8B:
	;;	djnz __MUL8LOOP
	;;
	;;	ld a, l ; result = A and HL  (Truncate to lower 8 bits)
	
__MUL8_FAST: ; __FASTCALL__ entry, a = a * h (8 bit mul) and Carry
	
	    ld b, 8
	    ld l, a
	    xor a
	
__MUL8LOOP:
	    add a, a ; a *= 2
	    sla l
	    jp nc, __MUL8B
	    add a, h
	
__MUL8B:
	    djnz __MUL8LOOP
		
		ret		; result = HL
		ENDP
	
#line 1164 "knightsanddemons.bas"
	
ZXBASIC_USER_DATA:
_tadrv2:
	DEFB 00, 00
_eex:
	DEFB 00, 00
_eey:
	DEFB 00, 00
_tq2:
	DEFB 00, 00
_eee0:
	DEFB 00, 00
_d:
	DEFB 00, 00
_n:
	DEFB 00, 00
_r:
	DEFB 00, 00
_c:
	DEFB 00, 00
_di:
	DEFB 00, 00
_x:
	DEFB 00, 00
_y:
	DEFB 00, 00
_su:
	DEFB 00, 00
_ba:
	DEFB 00, 00
_ca:
	DEFB 00, 00
_t:
	DEFB 00, 00
	; Defines DATA END --> HEAP size is 0
ZXBASIC_USER_DATA_END EQU ZXBASIC_MEM_HEAP
	; Defines USER DATA Length in bytes
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
	END
