	org 59392
__START_PROGRAM:
	di
	push ix
	push iy
	exx
	push hl
	exx
	ld hl, 0
	add hl, sp
	ld (__CALL_BACK__), hl
	ei
#line 0
		menust equ $0218
		org $2000
		defb "U"
		defw menust
		defw prgnam
		defw start
prgnam:
		defb "EXAMPLE01"
		defb $00
start:
#line 10
	jp __LABEL__charmap01end
__LABEL__charmap01:
#line 2
		defb %11111111
		defb %11111110
		defb %11111110
		defb %11111101
		defb %11110010
		defb %11110001
		defb %10101001
		defb %11111010
		defb %10100001
		defb %10010001
		defb %01100000
		defb %10010101
		defb %10100110
		defb %10100110
		defb %10111010
		defb %10100110
		defb %01011011
		defb %10010110
		defb %11110101
		defb %10101010
		defb %10011010
		defb %10100110
		defb %11101010
		defb %11101010
		defb %01101111
		defb %01101111
		defb %11111010
		defb %11101010
		defb %10101111
		defb %01101111
		defb %11101000
		defb %11110001
		defb %10111010
		defb %10111011
		defb %11101010
		defb %10101001
		defb %01010000
		defb %01101010
		defb %11101010
		defb %11111110
		defb %11111111
		defb %11111010
		defb %10101010
		defb %11111110
		defb %11111111
		defb %10011100
		defb %11011100
		defb %10011010
		defb %00101111
		defb %10111111
		defb %11111011
		defb %11111111
		defb %11111111
		defb %10111111
		defb %11011100
		defb %11011010
		defb %10111010
		defb %00111000
		defb %01110100
		defb %01101011
		defb %10111011
		defb %10101111
		defb %10111111
		defb %10101010
		defb %10101001
		defb %10011010
		defb %01000110
		defb %10100110
		defb %10101010
		defb %10101010
		defb %01100110
		defb %00011010
		defb %01010101
		defb %10101010
		defb %10101010
		defb %10100110
		defb %01110101
		defb %10111000
		defb %10100111
		defb %01011001
		defb %00101001
		defb %00011001
		defb %00100101
		defb %00100110
		defb %11111110
		defb %11111111
		defb %11101010
		defb %11111110
		defb %10111010
		defb %01111010
		defb %10101110
		defb %10101111
		defb %00010010
		defb %11101000
		defb %10101000
		defb %10111100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %00110000
		defb %00110000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %11001100
		defb %11001100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %11001100
		defb %11111100
		defb %11001100
		defb %11111100
		defb %11001100
		defb %00000000
		defb %00110000
		defb %11111100
		defb %11110000
		defb %00111100
		defb %11111100
		defb %00110000
		defb %11001100
		defb %00001100
		defb %00110000
		defb %11000000
		defb %11001100
		defb %00000000
		defb %11110000
		defb %11110000
		defb %00111100
		defb %11110000
		defb %11111100
		defb %00000000
		defb %00110000
		defb %00110000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %00110000
		defb %00000000
		defb %00110000
		defb %00001100
		defb %00001100
		defb %00001100
		defb %00110000
		defb %00000000
		defb %00110000
		defb %11111100
		defb %11001100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %11111100
		defb %00110000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %11000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %11111100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %00001100
		defb %00001100
		defb %00110000
		defb %11000000
		defb %11000000
		defb %00000000
		defb %00110000
		defb %11001100
		defb %11001100
		defb %11001100
		defb %00110000
		defb %00000000
		defb %00110000
		defb %11110000
		defb %00110000
		defb %00110000
		defb %11111100
		defb %00000000
		defb %11110000
		defb %00001100
		defb %00110000
		defb %11000000
		defb %11111100
		defb %00000000
		defb %11110000
		defb %00001100
		defb %00110000
		defb %00001100
		defb %11110000
		defb %00000000
		defb %00111100
		defb %11001100
		defb %11001100
		defb %11111100
		defb %00001100
		defb %00000000
		defb %11111100
		defb %11000000
		defb %11110000
		defb %00001100
		defb %11110000
		defb %00000000
		defb %00111100
		defb %11000000
		defb %11110000
		defb %11001100
		defb %00110000
		defb %00000000
		defb %11111100
		defb %00001100
		defb %00001100
		defb %00110000
		defb %00110000
		defb %00000000
		defb %00110000
		defb %11001100
		defb %00110000
		defb %11001100
		defb %00110000
		defb %00000000
		defb %00110000
		defb %11001100
		defb %00111100
		defb %00001100
		defb %00110000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %00110000
		defb %11000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %11000000
		defb %00110000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %11111100
		defb %00000000
		defb %11111100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00110000
		defb %00001100
		defb %00110000
		defb %00000000
		defb %11110000
		defb %00001100
		defb %00110000
		defb %00000000
		defb %00110000
		defb %00000000
		defb %00110000
		defb %11001100
		defb %11111100
		defb %11000000
		defb %00111100
		defb %00000000
		defb %00110000
		defb %11001100
		defb %11001100
		defb %11111100
		defb %11001100
		defb %00000000
		defb %11110000
		defb %11001100
		defb %11110000
		defb %11001100
		defb %11110000
		defb %00000000
		defb %00110000
		defb %11001100
		defb %11000000
		defb %11001100
		defb %00110000
		defb %00000000
		defb %11110000
		defb %11001100
		defb %11001100
		defb %11001100
		defb %11110000
		defb %00000000
		defb %11111100
		defb %11000000
		defb %11110000
		defb %11000000
		defb %11111100
		defb %00000000
		defb %11111100
		defb %11000000
		defb %11110000
		defb %11000000
		defb %11000000
		defb %00000000
		defb %00111100
		defb %11000000
		defb %11001100
		defb %11001100
		defb %00111100
		defb %00000000
		defb %11001100
		defb %11001100
		defb %11111100
		defb %11001100
		defb %11001100
		defb %00000000
		defb %11111100
		defb %00110000
		defb %00110000
		defb %00110000
		defb %11111100
		defb %00000000
		defb %00001100
		defb %00001100
		defb %00001100
		defb %11001100
		defb %00110000
		defb %00000000
		defb %11001100
		defb %11110000
		defb %11110000
		defb %11001100
		defb %11001100
		defb %00000000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11111100
		defb %00000000
		defb %11001100
		defb %11111100
		defb %11111100
		defb %11111100
		defb %11111100
		defb %00000000
		defb %11001100
		defb %11111100
		defb %11111100
		defb %11111100
		defb %11001100
		defb %00000000
		defb %00110000
		defb %11001100
		defb %11001100
		defb %11001100
		defb %00110000
		defb %00000000
		defb %11110000
		defb %11001100
		defb %11001100
		defb %11110000
		defb %11000000
		defb %00000000
		defb %00110000
		defb %11001100
		defb %11001100
		defb %11111100
		defb %00111100
		defb %00000000
		defb %11110000
		defb %11001100
		defb %11001100
		defb %11110000
		defb %11001100
		defb %00000000
		defb %00111100
		defb %11000000
		defb %00110000
		defb %00001100
		defb %11110000
		defb %00000000
		defb %11111100
		defb %00110000
		defb %00110000
		defb %00110000
		defb %00110000
		defb %00000000
		defb %11001100
		defb %11001100
		defb %11001100
		defb %11001100
		defb %11111100
		defb %00000000
		defb %11001100
		defb %11001100
		defb %11001100
		defb %11111100
		defb %00110000
		defb %00000000
		defb %11001100
		defb %11001100
		defb %11111100
		defb %11111100
		defb %11001100
		defb %00000000
		defb %11001100
		defb %11001100
		defb %00110000
		defb %11001100
		defb %11001100
		defb %00000000
		defb %11001100
		defb %11001100
		defb %11111100
		defb %00110000
		defb %00110000
		defb %00000000
		defb %11111100
		defb %00001100
		defb %00110000
		defb %11000000
		defb %11111100
		defb %00000000
		defb %11111100
		defb %11000000
		defb %11000000
		defb %11000000
		defb %11111100
		defb %00000000
		defb %11000000
		defb %11000000
		defb %00110000
		defb %00001100
		defb %00001100
		defb %00000000
		defb %11111100
		defb %00001100
		defb %00001100
		defb %00001100
		defb %11111100
		defb %00000000
		defb %00110000
		defb %11001100
		defb %00000000
		defb %00000000
		defb %00000000
		defb %00000000
		defb %10011001
		defb %01100110
		defb %10011001
		defb %01100110
		defb %10011001
		defb %01100110
#line 482
__LABEL__charmap01end:
	ld hl, 3840
	push hl
	ld hl, 0
	push hl
	ld hl, 16384
	push hl
	call _pacmanfillram
	ld a, 44
	push af
	call _ballyastrocadescreenmode
	ld a, 2
	push af
	ld hl, 3
	push hl
	call _ballyastrocadepalette
	ld a, 2
	push af
	ld hl, 7
	push hl
	call _ballyastrocadepalette
	ld a, 115
	push af
	ld hl, 2
	push hl
	call _ballyastrocadepalette
	ld a, 115
	push af
	ld hl, 6
	push hl
	call _ballyastrocadepalette
	ld a, 124
	push af
	ld hl, 1
	push hl
	call _ballyastrocadepalette
	ld a, 124
	push af
	ld hl, 5
	push hl
	call _ballyastrocadepalette
	ld a, 6
	push af
	ld hl, 0
	push hl
	call _ballyastrocadepalette
	ld a, 6
	push af
	ld hl, 4
	push hl
	call _ballyastrocadepalette
	xor a
	push af
	xor a
	push af
	call _ballyastrocadeborderandpaletteoffset
__LABEL__loopmain:
	call _clearscreen
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld hl, (__LABEL__text01end) - (__LABEL__text01)
	push hl
	ld hl, __LABEL__text01
	push hl
	ld hl, 11
	push hl
	ld hl, 1
	push hl
	call _ballyastrocadewritetext
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld hl, (__LABEL__text02end) - (__LABEL__text02)
	push hl
	ld hl, __LABEL__text02
	push hl
	ld hl, 12
	push hl
	ld hl, 1
	push hl
	call _ballyastrocadewritetext
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld hl, (__LABEL__text03end) - (__LABEL__text03)
	push hl
	ld hl, __LABEL__text03
	push hl
	ld hl, 14
	push hl
	ld hl, 1
	push hl
	call _ballyastrocadewritetext
__LABEL__looptitlekbchk:
	ld bc, 16
	in a, (c)
	push af
	ld bc, 17
	in a, (c)
	ld h, a
	pop af
	or h
	ld h, 31
	and h
	ld (_keyband), a
	sub 1
	jp c, __LABEL__looptitlekbchk
	xor a
	ld (_gameover), a
	call _clearscreen
	xor a
	ld (_ccur), a
	ld hl, 4
	ld (_snkln), hl
	ld a, 8
	ld (_xpos), a
	ld a, 12
	ld (_ypos), a
	ld a, 1
	ld (_xdir), a
	xor a
	ld (_ydir), a
	ld hl, (_eesd)
	call _smsrnd
	ld (_eesd), hl
	ld de, 40
	call __MODU16
	ld (_xntz), hl
	ld hl, (_eesd)
	call _smsrnd
	ld (_eesd), hl
	ld h, 0
	ld a, l
	and 15
	ld l, a
	ld (_yntz), hl
	ld hl, 20288
	ld (_ee1x), hl
	jp __LABEL2
__LABEL5:
	xor a
	ld hl, (_ee1x)
	ld (hl), a
	ld hl, (_ee1x)
	inc hl
	ld (_ee1x), hl
__LABEL2:
	ld hl, 20463
	ld de, (_ee1x)
	or a
	sbc hl, de
	jp nc, __LABEL5
	ld hl, 20288
	ld (_ee1x), hl
	jp __LABEL7
__LABEL10:
	ld a, 65
	ld hl, (_ee1x)
	ld (hl), a
	ld hl, (_ee1x)
	inc hl
	ld (_ee1x), hl
__LABEL7:
	ld hl, 20463
	ld de, (_ee1x)
	or a
	sbc hl, de
	jp nc, __LABEL10
__LABEL__loopgame:
	ld bc, 16
	in a, (c)
	push af
	ld bc, 17
	in a, (c)
	ld h, a
	pop af
	or h
	ld (_keybbf), a
	ld h, 1
	ld a, (_keybbf)
	and h
	push af
	ld a, (_xdir)
	ld h, a
	pop af
	call __AND8
	or a
	jp z, __LABEL13
	xor a
	ld (_xdir), a
	ld a, 255
	ld (_ydir), a
__LABEL13:
	ld h, 2
	ld a, (_keybbf)
	and h
	push af
	ld a, (_xdir)
	ld h, a
	pop af
	call __AND8
	or a
	jp z, __LABEL15
	xor a
	ld (_xdir), a
	ld a, 1
	ld (_ydir), a
__LABEL15:
	ld h, 4
	ld a, (_keybbf)
	and h
	push af
	ld a, (_ydir)
	ld h, a
	pop af
	call __AND8
	or a
	jp z, __LABEL17
	ld a, 255
	ld (_xdir), a
	xor a
	ld (_ydir), a
__LABEL17:
	ld h, 8
	ld a, (_keybbf)
	and h
	push af
	ld a, (_ydir)
	ld h, a
	pop af
	call __AND8
	or a
	jp z, __LABEL19
	ld a, 1
	ld (_xdir), a
	xor a
	ld (_ydir), a
__LABEL19:
	ld a, (_keybbf)
	ld l, a
	ld h, 0
	ex de, hl
	ld hl, (_eesd)
	call __BXOR16
	call _smsrnd
	ld (_eesd), hl
	ld hl, (_xpos - 1)
	ld a, (_xdir)
	add a, h
	ld (_xpos), a
	ld hl, (_ypos - 1)
	ld a, (_ydir)
	add a, h
	ld (_ypos), a
	ld a, (_xpos)
	ld l, a
	add a, a
	sbc a, a
	ld h, a
	push hl
	ld hl, (_xntz)
	ex de, hl
	pop hl
	call __EQ16
	push af
	ld a, (_ypos)
	ld l, a
	add a, a
	sbc a, a
	ld h, a
	push hl
	ld hl, (_yntz)
	ex de, hl
	pop hl
	call __EQ16
	ld h, a
	pop af
	call __AND8
	or a
	jp z, __LABEL21
	ld hl, (_eesd)
	call _smsrnd
	ld (_eesd), hl
	ld de, 40
	call __MODU16
	ld (_xntz), hl
	ld hl, (_eesd)
	call _smsrnd
	ld (_eesd), hl
	ld h, 0
	ld a, l
	and 15
	ld l, a
	ld (_yntz), hl
	ld hl, (_snkln)
	inc hl
	ld (_snkln), hl
__LABEL21:
	ld h, 0
	ld a, (_ypos)
	call __LTI8
	or a
	jp z, __LABEL23
	ld a, 15
	ld (_ypos), a
__LABEL23:
	ld h, 0
	ld a, (_xpos)
	call __LTI8
	or a
	jp z, __LABEL25
	ld a, 39
	ld (_xpos), a
__LABEL25:
	ld a, 15
	ld hl, (_ypos - 1)
	call __LTI8
	or a
	jp z, __LABEL27
	xor a
	ld (_ypos), a
__LABEL27:
	ld a, 39
	ld hl, (_xpos - 1)
	call __LTI8
	or a
	jp z, __LABEL29
	xor a
	ld (_xpos), a
__LABEL29:
	ld hl, 20288
	ld (_eelp), hl
	jp __LABEL30
__LABEL33:
	ld hl, (_eelp)
	inc hl
	inc hl
	ld a, (hl)
	inc hl
	ld h, (hl)
	ld l, a
	ex de, hl
	ld hl, (_eelp)
	ld (hl), e
	inc hl
	ld (hl), d
	ld hl, (_eelp)
	inc hl
	inc hl
	ld (_eelp), hl
__LABEL30:
	ld hl, 20463
	ld de, (_eelp)
	or a
	sbc hl, de
	jp nc, __LABEL33
	ld a, (_xpos)
	ld (20464), a
	ld a, (_ypos)
	ld (20465), a
	ld a, (_ccur)
	inc a
	ld h, 15
	and h
	ld (_ccur), a
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld hl, 32
	push hl
	ld hl, (_snkln)
	add hl, hl
	ex de, hl
	ld hl, 52991
	or a
	sbc hl, de
	ld b, h
	ld c, l
	ld a, (bc)
	ld l, a
	ld h, 0
	push hl
	ld hl, (_snkln)
	add hl, hl
	ex de, hl
	ld hl, 52990
	or a
	sbc hl, de
	ld b, h
	ld c, l
	ld a, (bc)
	add a, 2
	ld l, a
	ld h, 0
	push hl
	call _ballyastrocadeputchar4x6
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld hl, 32
	push hl
	ld hl, (_yntz)
	push hl
	ld hl, (_xntz)
	inc hl
	inc hl
	push hl
	call _ballyastrocadeputchar4x6
	ld a, (_ypos)
	ld l, a
	add a, a
	sbc a, a
	ld h, a
	push hl
	ld a, (_xpos)
	add a, 2
	ld l, a
	add a, a
	sbc a, a
	ld h, a
	push hl
	call _peekmap
	ld h, 32
	cp h
	jp nc, __LABEL36
	ld a, 1
	ld (_gameover), a
__LABEL36:
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld a, (_ccur)
	add a, 97
	ld l, a
	ld h, 0
	push hl
	ld hl, (_yntz)
	push hl
	ld hl, (_xntz)
	inc hl
	inc hl
	push hl
	call _ballyastrocadeputchar4x6
	ld hl, (__LABEL__charmap01) - (96)
	push hl
	ld a, (_ccur)
	add a, 16
	ld l, a
	ld h, 0
	push hl
	ld a, (_ypos)
	ld l, a
	add a, a
	sbc a, a
	ld h, a
	push hl
	ld a, (_xpos)
	add a, 2
	ld l, a
	add a, a
	sbc a, a
	ld h, a
	push hl
	call _ballyastrocadeputchar4x6
	ld hl, 2000
	push hl
	call _smsdelay
	ld a, (_gameover)
	sub 1
	jp c, __LABEL__loopgame
	ld hl, 1
	ld (_ee1x), hl
	jp __LABEL39
__LABEL42:
	ld hl, 2000
	push hl
	call _smsdelay
	ld hl, (_ee1x)
	inc hl
	ld (_ee1x), hl
__LABEL39:
	ld hl, 50
	ld de, (_ee1x)
	or a
	sbc hl, de
	jp nc, __LABEL42
	jp __LABEL__loopmain
__LABEL44:
	jp __LABEL44
__LABEL__text01:
#line 193
		defb " JUST ANOTHER SNAKE GAME "
#line 194
__LABEL__text01end:
__LABEL__text02:
#line 198
		defb " PAULO SILVA, '13-'18 "
#line 199
__LABEL__text02end:
__LABEL__text03:
#line 203
		defb " PUSH ANY KEY "
#line 204
__LABEL__text03end:
	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
_smsrnd:
#line 2
		ld  d, h
		ld  e, l
		ld  a, d
		ld  h, e
		ld  l, 253
		or  a
		sbc  hl, de
		sbc  a, 0
		sbc  hl, de
		ld  d, 0
		sbc  a, d
		ld  e, a
		sbc  hl, de
		jr  nc, smsrndloop
		inc  hl
smsrndloop:
		ret
#line 19
_smsrnd__leave:
	ret
_smsdelay:
	push ix
	ld ix, 0
	add ix, sp
#line 1
		ld b,(ix+5)
		ld c,(ix+4)
smsdelayloop:
		dec bc
		ld a,b
		or c
		jp nz,smsdelayloop
#line 8
_smsdelay__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	ex (sp), hl
	exx
	ret
_ballyastrocadeldir40b:
	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)
ballyastrocadeldir40bloop:
		ld a,(hl)
		ld (de),a
		inc hl
		ex de,hl
		push de
		ld de,40
		add hl,de
		pop de
		ex de,hl
		dec bc
		ld a,b
		or c
		jp nz,ballyastrocadeldir40bloop
#line 22
_ballyastrocadeldir40b__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
_pacmanfillram:
	push ix
	ld ix, 0
	add ix, sp
#line 1
		ld l,(ix+4)
		ld h,(ix+5)
		ld b,(ix+9)
		ld c,(ix+8)
pacmanfillramloop:
		ld a,(ix+6)
		ld (hl),a
		dec bc
		inc hl
		ld a,b
		or c
		jp nz,pacmanfillramloop
#line 13
_pacmanfillram__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
_ballyastrocadeputchar4x6:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 6
	push hl
	ld l, (ix+10)
	ld h, (ix+11)
	push hl
	ld l, (ix+8)
	ld h, (ix+9)
	ld de, 6
	call __MUL16_FAST
	ex de, hl
	pop hl
	add hl, de
	push hl
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 240
	call __MUL16_FAST
	ld de, 16384
	add hl, de
	push hl
	ld l, (ix+4)
	ld h, (ix+5)
	ex de, hl
	pop hl
	add hl, de
	push hl
	call _ballyastrocadeldir40b
_ballyastrocadeputchar4x6__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
_ballyastrocadescreenmode:
	push ix
	ld ix, 0
	add ix, sp
	ld a, (ix+5)
	ld bc, 8
	out (c), a
_ballyastrocadescreenmode__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	ex (sp), hl
	exx
	ret
_ballyastrocadeborderandpaletteoffset:
	push ix
	ld ix, 0
	add ix, sp
	ld a, (ix+5)
	ld h, 3
	and h
	ld h, 64
	call __MUL8_FAST
	push af
	ld a, (ix+7)
	ld h, 63
	and h
	ld h, a
	pop af
	or h
	ld bc, 9
	out (c), a
_ballyastrocadeborderandpaletteoffset__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	ex (sp), hl
	exx
	ret
_ballyastrocadepalette:
	push ix
	ld ix, 0
	add ix, sp
	ld l, (ix+4)
	ld h, (ix+5)
	ld de, 7
	call __BAND16
	push hl
	ld a, (ix+7)
	pop bc
	out (c), a
_ballyastrocadepalette__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	ex (sp), hl
	exx
	ret
_ballyastrocadewritetext:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 0
	ld (_ballyastrocadewritetext_twrt2), hl
	jp __LABEL46
__LABEL49:
	ld l, (ix+12)
	ld h, (ix+13)
	push hl
	ld l, (ix+8)
	ld h, (ix+9)
	ex de, hl
	ld hl, (_ballyastrocadewritetext_twrt2)
	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)
	push hl
	ld l, (ix+4)
	ld h, (ix+5)
	ex de, hl
	ld hl, (_ballyastrocadewritetext_twrt2)
	add hl, de
	push hl
	call _ballyastrocadeputchar4x6
	ld hl, (_ballyastrocadewritetext_twrt2)
	inc hl
	ld (_ballyastrocadewritetext_twrt2), hl
__LABEL46:
	ld l, (ix+10)
	ld h, (ix+11)
	dec hl
	ld de, (_ballyastrocadewritetext_twrt2)
	or a
	sbc hl, de
	jp nc, __LABEL49
_ballyastrocadewritetext__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	pop bc
	pop bc
	pop bc
	ex (sp), hl
	exx
	ret
_peekmap:
	push ix
	ld ix, 0
	add ix, sp
	ld l, (ix+6)
	ld h, (ix+7)
	ld de, 240
	call __MUL16_FAST
	ld de, 16384
	add hl, de
	push hl
	ld l, (ix+4)
	ld h, (ix+5)
	ex de, hl
	pop hl
	add hl, de
	ld b, h
	ld c, l
	ld a, (bc)
_peekmap__leave:
	ld sp, ix
	pop ix
	exx
	pop hl
	pop bc
	ex (sp), hl
	exx
	ret
_clearscreen:
	push ix
	ld ix, 0
	add ix, sp
	ld hl, 0
	ld (_ee0), hl
	jp __LABEL51
__LABEL54:
	ld hl, 40
	push hl
	ld hl, 153
	push hl
	ld hl, (_ee0)
	ld de, 80
	call __MUL16_FAST
	ld de, 16384
	add hl, de
	push hl
	call _pacmanfillram
	ld hl, 40
	push hl
	ld hl, 102
	push hl
	ld hl, (_ee0)
	ld de, 80
	call __MUL16_FAST
	ld de, 16424
	add hl, de
	push hl
	call _pacmanfillram
	ld hl, (_ee0)
	inc hl
	ld (_ee0), hl
__LABEL51:
	ld hl, 47
	ld de, (_ee0)
	or a
	sbc hl, de
	jp nc, __LABEL54
_clearscreen__leave:
	ld sp, ix
	pop ix
	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 1351 "justanothersnakegame.bas"
#line 1 "band16.asm"
; vim:ts=4:et:
	; FASTCALL bitwise and16 version.
	; result in hl 
; __FASTCALL__ version (operands: A, H)
	; Performs 16bit or 16bit and returns the boolean
; Input: HL, DE
; Output: HL <- HL AND DE
	
__BAND16:
		ld a, h
		and d
	    ld h, a
	
	    ld a, l
	    and e
	    ld l, a
	
	    ret 
	
#line 1352 "justanothersnakegame.bas"
#line 1 "bxor16.asm"
; vim:ts=4:et:
	; FASTCALL bitwise xor 16 version.
	; result in Accumulator (0 False, not 0 True)
; __FASTCALL__ version (operands: A, H)
	; Performs 16bit xor 16bit and returns the boolean
; Input: HL, DE
; Output: HL <- HL XOR DE
	
__BXOR16:
		ld a, h
		xor d
	    ld h, a
	
	    ld a, l
	    xor e
	    ld l, a
	
	    ret 
	
#line 1353 "justanothersnakegame.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 1354 "justanothersnakegame.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 1355 "justanothersnakegame.bas"
#line 1 "lti8.asm"
	
__LTI8: ; Test 8 bit values A < H
        ; Returns result in A: 0 = False, !0 = True
	        sub h
	
__LTI:  ; Signed CMP
	        PROC
	        LOCAL __PE
	
	        ld a, 0  ; Sets default to false
__LTI2:
	        jp pe, __PE
	        ; Overflow flag NOT set
	        ret p
	        dec a ; TRUE
	
__PE:   ; Overflow set
	        ret m
	        dec a ; TRUE
	        ret
	        
	        ENDP
#line 1356 "justanothersnakegame.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 1357 "justanothersnakegame.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 1358 "justanothersnakegame.bas"
	
ZXBASIC_USER_DATA:
	_ee0 EQU 20244
	_ee1x EQU 20256
	_eelp EQU 20262
	_snkln EQU 20266
	_eesd EQU 20270
	_xntz EQU 20272
	_yntz EQU 20274
	_keybbf EQU 20231
	_gameover EQU 20232
	_xdir EQU 20233
	_ydir EQU 20234
	_xpos EQU 20235
	_ypos EQU 20236
	_ccur EQU 20237
	_keyband EQU 20239
	_ballyastrocadewritetext_twrt2 EQU 20224
	; 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
