4f.s

; da65 V2.11.9 - (C) Copyright 2000-2005,  Ullrich von Bassewitz
; Created:    2006-09-21 17:08:52
; Input	file: 4f.prg
; Page:	      1


	.setcpu	"6502"


player_xpos	:= $0010
player_ypos	:= $0011
tile_xpos	:= $0012
tile_ypos	:= $0013
map_x		:= $0014
map_y		:= $0015
@britannia	:= $0019
current_location:= $001A
game_mode	:= $001B
dungeon_level	:= $001C
player_transport:= $001E
party_size	:= $001F
dng_direction	:= $0020
light_duration	:= $0021
moon_phase_trammel:= $0022
moon_phase_felucca:= $0023
horse_mode	:= $0024
ship_hull	:= $002B
move_counter	:= $002C
key_buf		:= $0030
key_buf_len	:= $0038
charptr		:= $003D
magic_aura	:= $0046
aura_duration	:= $0047
tile_under_player:= $0048
tile_north	:= $0049
tile_south	:= $004A
tile_east	:= $004B
tile_west	:= $004C
music_volume	:= $004D
console_xpos	:= $004E
console_ypos	:= $004F
diskid		:= $0050
numdrives	:= $0051
currdisk_drive1	:= $0052
currdisk_drive2	:= $0053
currplayer	:= $0054
hexnum		:= $0056
bcdnum		:= $0057
zptmp1		:= $005A
reqdisk		:= $005E
currdrive	:= $005F
lt_y		:= $0060
lt_x		:= $0061
lt_rwflag	:= $0062
lt_addr_hi	:= $0063
monster_type	:= $0066
game_mode_temp	:= $0068
moongate_tile	:= $006D
moongate_xpos	:= $006E
moongate_ypos	:= $006F
movement_mode	:= $0074
direction	:= $0075
ptr2		:= $007C
ptr1		:= $007E
L8C03		:= $8C03
gettile_bounds	:= $9F00
gettile		:= $9F26
mul11		:= $9F49
L9F54		:= $9F54
L9F78		:= $9F78
gettile_combat	:= $9F85
L9F8C		:= $9F8C
gettile_town	:= $9FAF
gettile_dungeon	:= $9FCE
j_fileio	:= $A100
j_readblock	:= $A103
j_loadtitle	:= $A106
j_togglesnd	:= $A109
j_kernalin	:= $A10C
j_setirqv	:= $A10F
j_clearkbd	:= $A112
j_irqhandler	:= $A115
party_stats	:= $AA00
game_stats	:= $AB00
food_hi		:= $AB10
food_lo		:= $AB11
food_frac	:= $AB12
gold		:= $AB13
mixtures	:= $AB40
map_status	:= $AC00
object_xpos	:= $AC20
object_ypos	:= $AC40
object_tile	:= $AC60
monster_xpos	:= $AD00
monster_ypos	:= $AD10
monster_hp	:= $AD40
cbt_monster_type:= $AD50
monster_tile	:= $AD60
cbt_player_xpos	:= $AD80
cbt_player_ypos	:= $AD90
player_tile	:= $ADA0
missile		:= $ADFD
missile_xpos	:= $ADFE
missile_ypos	:= $ADFF
currmap		:= $AE00
tempmap		:= $AE80
music_ctl	:= $AF20
music_nop	:= $AF23
bmplineaddr_lo	:= $E000
bmplineaddr_hi	:= $E0C0
chrlineaddr_lo	:= $E180
chrlineaddr_hi	:= $E198
tile_color	:= $E1B0
music_init	:= $EC00

	.word	$0800				; 07FE

j_waitkey:
	jmp	waitkey				; 0800

j_player_teleport:
	jmp	player_teleport			; 0803

j_move_east:
	jmp	move_east			; 0806

j_move_west:
	jmp	move_west			; 0809

j_move_south:
	jmp	move_south			; 080C

j_move_north:
	jmp	move_north			; 080F

j_drawinterface:
	jmp	drawinterface			; 0812

j_drawview:
	jmp	drawview			; 0815

j_update_britannia:
	jmp	update_britannia		; 0818

	nop					; 081B
	nop					; 081C
	nop					; 081D
j_primm_xy:
	jmp	primm_xy			; 081E

j_primm:
	jmp	primm				; 0821

j_console_out:
	jmp	console_out			; 0824

j_clearbitmap:
	jmp	clearbitmap			; 0827

j_mulax:
	jmp	mulax				; 082A

j_get_stats_ptr:
	jmp	get_stats_ptr			; 082D

j_printname:
	jmp	printname			; 0830

j_printbcd:
	jmp	printbcd			; 0833

j_drawcursor:
	jmp	drawcursor			; 0836

j_drawcursor_xy:
	jmp	drawcursor_xy			; 0839

j_drawvert:
	jmp	drawvert			; 083C

j_drawhoriz:
	jmp	drawhoriz			; 083F

j_request_disk:
	jmp	request_disk			; 0842

j_update_status:
	jmp	update_status			; 0845

j_blocked_tile:
	jmp	blocked_tile			; 0848

j_idle:
	jmp	idle				; 084B

j_rand:
	jmp	rand				; 084E

j_loadsector:
	jmp	loadsector			; 0851

j_playsfx:
	jmp	playsfx				; 0854

j_idle_combat:
	jmp	idle_combat			; 0857

j_getnumber:
	jmp	getnumber			; 085A

j_getplayernum:
	jmp	getplayernum			; 085D

j_update_wind:
	jmp	update_wind			; 0860

j_animate_view:
	jmp	animate_view			; 0863

j_printdigit:
	jmp	printdigit			; 0866

j_clearstatwindow:
	jmp	clearstatwindow			; 0869

j_animate_creatures:
	jmp	animate_creatures		; 086C

j_centername:
	jmp	centername			; 086F

j_print_direction:
	jmp	print_direction			; 0872

j_clearview:
	jmp	clearview			; 0875

j_invertview:
	jmp	invertview			; 0878

j_centerstring:
	jmp	centerstring			; 087B

j_printstring:
	jmp	printstring			; 087E

j_gettile_bounds:
	jmp	gettile_bounds			; 0881

j_gettile:
	jmp	gettile				; 0884

	jmp	L9F54				; 0887

	jmp	L9F78				; 088A

j_gettile_combat:
	jmp	gettile_combat			; 088D

	jmp	L9F8C				; 0890

j_gettile_town:
	jmp	gettile_town			; 0893

j_gettile_dungeon:
	jmp	gettile_dungeon			; 0896

move_east:
	inc	player_xpos			; 0899
	inc	tile_xpos			; 089B
	lda	tile_xpos			; 089D
	cmp	#$18				; 089F  X
	bcc	@notileborder			; 08A1
	jsr	music_nop			; 08A3
@notileborder:
	cmp	#$1B				; 08A6  [
	bcc	movedone			; 08A8
	and	#$0F				; 08AA  O
	sta	tile_xpos			; 08AC
	jsr	map_scroll_east			; 08AE
	inc	map_x				; 08B1
	lda	map_x				; 08B3
	and	#$0F				; 08B5  O
	sta	map_x				; 08B7
	jsr	loadtiles_east			; 08B9
movedone:
	rts					; 08BC

move_west:
	dec	player_xpos			; 08BD
	dec	tile_xpos			; 08BF
	lda	tile_xpos			; 08C1
	cmp	#$08				; 08C3  H
	bcs	@notileborder			; 08C5
	jsr	music_nop			; 08C7
@notileborder:
	cmp	#$05				; 08CA  E
	bcs	movedone			; 08CC
	ora	#$10				; 08CE  P
	sta	tile_xpos			; 08D0
	jsr	map_scroll_west			; 08D2
	dec	map_x				; 08D5
	lda	map_x				; 08D7
	and	#$0F				; 08D9  O
	sta	map_x				; 08DB
	jmp	loadtiles_west			; 08DD

move_south:
	inc	player_ypos			; 08E0
	inc	tile_ypos			; 08E2
	lda	tile_ypos			; 08E4
	cmp	#$18				; 08E6  X
	bcc	@notileborder			; 08E8
	jsr	music_nop			; 08EA
@notileborder:
	cmp	#$1B				; 08ED  [
	bcc	@done				; 08EF
	and	#$0F				; 08F1  O
	sta	tile_ypos			; 08F3
	jsr	map_scroll_south		; 08F5
	inc	map_y				; 08F8
	lda	map_y				; 08FA
	and	#$0F				; 08FC  O
	sta	map_y				; 08FE
	jsr	loadtiles_south			; 0900
@done:
	rts					; 0903

move_north:
	dec	player_ypos			; 0904
	dec	tile_ypos			; 0906
	lda	tile_ypos			; 0908
	cmp	#$08				; 090A  H
	bcs	@notileborder			; 090C
	jsr	music_nop			; 090E
@notileborder:
	cmp	#$05				; 0911  E
	bcs	@done				; 0913
	ora	#$10				; 0915  P
	sta	tile_ypos			; 0917
	jsr	map_scroll_north		; 0919
	dec	map_y				; 091C
	lda	map_y				; 091E
	and	#$0F				; 0920  O
	sta	map_y				; 0922
	jsr	loadtiles_north			; 0924
@done:
	rts					; 0927

map_scroll_east:
	ldx	#$00				; 0928  .
@scroll:
	lda	$E900,x				; 092A
	sta	$E800,x				; 092D
	lda	$EB00,x				; 0930
	sta	$EA00,x				; 0933
	inx					; 0936
	bne	@scroll				; 0937
	rts					; 0939

map_scroll_west:
	ldx	#$00				; 093A  .
@scroll:
	lda	$E800,x				; 093C
	sta	$E900,x				; 093F
	lda	$EA00,x				; 0942
	sta	$EB00,x				; 0945
	inx					; 0948
	bne	@scroll				; 0949
	rts					; 094B

map_scroll_south:
	ldx	#$00				; 094C  .
@scroll:
	lda	$EA00,x				; 094E
	sta	$E800,x				; 0951
	lda	$EB00,x				; 0954
	sta	$E900,x				; 0957
	inx					; 095A
	bne	@scroll				; 095B
	rts					; 095D

map_scroll_north:
	ldx	#$00				; 095E  .
@scroll:
	lda	$E800,x				; 0960
	sta	$EA00,x				; 0963
	lda	$E900,x				; 0966
	sta	$EB00,x				; 0969
	inx					; 096C
	bne	@scroll				; 096D
	rts					; 096F

loadtiles_east:
	lda	#$01				; 0970  A
	sta	lt_rwflag			; 0972
	clc					; 0974
	lda	map_x				; 0975
	adc	#$01				; 0977  A
	and	#$0F				; 0979  O
	sta	lt_x				; 097B
	lda	map_y				; 097D
	sta	lt_y				; 097F
	lda	#$E9				; 0981  i
	sta	lt_addr_hi			; 0983
	jsr	loadsector			; 0985
	clc					; 0988
	lda	map_y				; 0989
	adc	#$01				; 098B  A
	and	#$0F				; 098D  O
	sta	lt_y				; 098F
	lda	#$EB				; 0991  k
	sta	lt_addr_hi			; 0993
	jmp	loadsector			; 0995

loadtiles_west:
	lda	#$01				; 0998  A
	sta	lt_rwflag			; 099A
	clc					; 099C
	lda	map_x				; 099D
	sta	lt_x				; 099F
	lda	map_y				; 09A1
	sta	lt_y				; 09A3
	lda	#$E8				; 09A5  h
	sta	lt_addr_hi			; 09A7
	jsr	loadsector			; 09A9
	clc					; 09AC
	lda	map_y				; 09AD
	adc	#$01				; 09AF  A
	and	#$0F				; 09B1  O
	sta	lt_y				; 09B3
	lda	#$EA				; 09B5  j
	sta	lt_addr_hi			; 09B7
	jmp	loadsector			; 09B9

loadtiles_south:
	lda	#$01				; 09BC  A
	sta	lt_rwflag			; 09BE
	clc					; 09C0
	lda	map_y				; 09C1
	adc	#$01				; 09C3  A
	and	#$0F				; 09C5  O
	sta	lt_y				; 09C7
	lda	map_x				; 09C9
	sta	lt_x				; 09CB
	lda	#$EA				; 09CD  j
	sta	lt_addr_hi			; 09CF
	jsr	loadsector			; 09D1
	clc					; 09D4
	lda	map_x				; 09D5
	adc	#$01				; 09D7  A
	and	#$0F				; 09D9  O
	sta	lt_x				; 09DB
	lda	#$EB				; 09DD  k
	sta	lt_addr_hi			; 09DF
	jmp	loadsector			; 09E1

loadtiles_north:
	lda	#$01				; 09E4  A
	sta	lt_rwflag			; 09E6
	clc					; 09E8
	lda	map_y				; 09E9
	sta	lt_y				; 09EB
	lda	map_x				; 09ED
	sta	lt_x				; 09EF
	lda	#$E8				; 09F1  h
	sta	lt_addr_hi			; 09F3
	jsr	loadsector			; 09F5
	clc					; 09F8
	lda	map_x				; 09F9
	adc	#$01				; 09FB  A
	and	#$0F				; 09FD  O
	sta	lt_x				; 09FF
	lda	#$E9				; 0A01  i
	sta	lt_addr_hi			; 0A03
	jmp	loadsector			; 0A05

player_teleport:
	lda	player_xpos			; 0A08
	jsr	div16				; 0A0A
	sta	map_x				; 0A0D
	lda	player_xpos			; 0A0F
	and	#$0F				; 0A11  O
	sta	tile_xpos			; 0A13
	cmp	#$08				; 0A15  H
	bcs	@eastern			; 0A17
	clc					; 0A19
	adc	#$10				; 0A1A  P
	sta	tile_xpos			; 0A1C
	dec	map_x				; 0A1E
	lda	map_x				; 0A20
	and	#$0F				; 0A22  O
	sta	map_x				; 0A24
@eastern:
	lda	player_ypos			; 0A26
	jsr	div16				; 0A28
	sta	map_y				; 0A2B
	lda	player_ypos			; 0A2D
	and	#$0F				; 0A2F  O
	sta	tile_ypos			; 0A31
	cmp	#$08				; 0A33  H
	bcs	@southern			; 0A35
	clc					; 0A37
	adc	#$10				; 0A38  P
	sta	tile_ypos			; 0A3A
	dec	map_y				; 0A3C
	lda	map_y				; 0A3E
	and	#$0F				; 0A40  O
	sta	map_y				; 0A42
@southern:
	lda	#$01				; 0A44  A
	sta	lt_rwflag			; 0A46
	lda	map_x				; 0A48
	sta	lt_x				; 0A4A
	lda	map_y				; 0A4C
	sta	lt_y				; 0A4E
	lda	#$E8				; 0A50  h
	sta	lt_addr_hi			; 0A52
	jsr	loadsector			; 0A54
	clc					; 0A57
	lda	map_x				; 0A58
	adc	#$01				; 0A5A  A
	and	#$0F				; 0A5C  O
	sta	lt_x				; 0A5E
	lda	#$E9				; 0A60  i
	sta	lt_addr_hi			; 0A62
	jsr	loadsector			; 0A64
	clc					; 0A67
	lda	map_y				; 0A68
	adc	#$01				; 0A6A  A
	and	#$0F				; 0A6C  O
	sta	lt_y				; 0A6E
	lda	#$EB				; 0A70  k
	sta	lt_addr_hi			; 0A72
	jsr	loadsector			; 0A74
	lda	map_x				; 0A77
	sta	lt_x				; 0A79
	lda	#$EA				; 0A7B  j
	sta	lt_addr_hi			; 0A7D
loadsector:
	lda	lt_rwflag			; 0A7F
	sta	$A000				; 0A81
	lda	#$01				; 0A84  A
	sta	$A001				; 0A86
	lda	#$00				; 0A89  .
	sta	$A002				; 0A8B
	lda	lt_addr_hi			; 0A8E
	sta	$A003				; 0A90
	lda	lt_y				; 0A93
	asl	a				; 0A95
	asl	a				; 0A96
	asl	a				; 0A97
	asl	a				; 0A98
	ora	lt_x				; 0A99
	adc	#$01				; 0A9B  A
	sta	$A004				; 0A9D
	lda	#$00				; 0AA0  .
	adc	#$00				; 0AA2  .
	sta	$A005				; 0AA4
	jsr	j_readblock			; 0AA7
	bcs	loadsector			; 0AAA
	rts					; 0AAC

waitkey:
	lda	#$80				; 0AAD  .
	sta	idletimeout			; 0AAF
@wait:
	jsr	scankey				; 0AB2
	jsr	drawcursor			; 0AB5
	jsr	getkey				; 0AB8
	bmi	@gotkey				; 0ABB
	jsr	idle				; 0ABD
	dec	idletimeout			; 0AC0
	bne	@wait				; 0AC3
	jsr	clearcursor			; 0AC5
	lda	#$00				; 0AC8  .
	rts					; 0ACA

@gotkey:
	pha					; 0ACB
	jsr	clearcursor			; 0ACC
	pla					; 0ACF
	cmp	#$00				; 0AD0  .
	rts					; 0AD2

idletimeout:
	.byte	$00				; 0AD3  .

idle:
	lda	game_mode			; 0AD4
	beq	delay				; 0AD6
	bmi	idle_other			; 0AD8
idle_britannia:
	cmp	#$01				; 0ADA  A
	bne	idle_towne			; 0ADC
	jsr	update_wind			; 0ADE
	jsr	update_balloon			; 0AE1
	jsr	update_britannia		; 0AE4
	rts					; 0AE7

idle_towne:
	cmp	#$02				; 0AE8  B
	bne	idle_dungeon			; 0AEA
	jsr	update_towne			; 0AEC
	rts					; 0AEF

idle_dungeon:
	cmp	#$03				; 0AF0  C
	bne	idle_delay			; 0AF2
	jsr	animatetiles			; 0AF4
	jsr	animate_fire			; 0AF7
	jsr	L8C03				; 0AFA
idle_delay:
	jmp	delay				; 0AFD

idle_other:
	cmp	#$FF				; 0B00  .
	beq	@animate			; 0B02
	jmp	idle_combat			; 0B04

@animate:
	jmp	animate_view			; 0B07

delay:
	ldx	#$4B				; 0B0A  K
	ldy	#$00				; 0B0C  .
@delay:
	dey					; 0B0E
	bne	@delay				; 0B0F
	dex					; 0B11
	bne	@delay				; 0B12
	rts					; 0B14

update_balloon:
	lda	player_transport		; 0B15
	cmp	#$18				; 0B17  X
	bne	@done				; 0B19
	lda	movement_mode			; 0B1B
	beq	@done				; 0B1D
	dec	movement_counter		; 0B1F
	lda	movement_counter		; 0B22
	and	#$03				; 0B25  C
	bne	@done				; 0B27
@east:
	ldx	direction			; 0B29
	bne	@south				; 0B2B
	jmp	move_east			; 0B2D

@south:
	dex					; 0B30
	bne	@west				; 0B31
	jmp	move_south			; 0B33

@west:
	dex					; 0B36
	bne	@north				; 0B37
	jmp	move_west			; 0B39

@north:
	jmp	move_north			; 0B3C

@done:
	rts					; 0B3F

movement_counter:
	.byte	$00				; 0B40  .

animate_view:
	jsr	animatetiles			; 0B41
	jsr	animate_fire			; 0B44
	jmp	drawview			; 0B47

idle_combat:
	jsr	animatetiles			; 0B4A
	jsr	animate_fire			; 0B4D
	ldx	#$7F				; 0B50  .
@copy:
	lda	tempmap,x			; 0B52
	sta	currmap,x			; 0B55
	dex					; 0B58
	bpl	@copy				; 0B59
	ldx	#$0F				; 0B5B  O
@nextmonster:
	ldy	monster_ypos,x			; 0B5D
	lda	mul11,y				; 0B60
	clc					; 0B63
	adc	monster_xpos,x			; 0B64
	tay					; 0B67
	lda	cbt_monster_type,x		; 0B68
	beq	@next				; 0B6B
	lda	$AD70,x				; 0B6D
	bne	@dontanim			; 0B70
	lda	cbt_monster_type,x		; 0B72
	cmp	#$90				; 0B75  P
	bcs	@checkmimic			; 0B77
	jsr	rand				; 0B79
	and	#$01				; 0B7C  A
@settile:
	clc					; 0B7E
	adc	cbt_monster_type,x		; 0B7F
	sta	monster_tile,x			; 0B82
	sta	currmap,y			; 0B85
	jmp	@next				; 0B88

@checkmimic:
	cmp	#$AC				; 0B8B  ,
	bne	@anim4				; 0B8D
	lda	monster_tile,x			; 0B8F
	cmp	#$3C				; 0B92  <
	bne	@anim4				; 0B94
	sta	currmap,y			; 0B96
	jmp	@next				; 0B99

@anim4:
	jsr	rand				; 0B9C
	and	#$01				; 0B9F  A
	beq	@dontanim			; 0BA1
	inc	monster_tile,x			; 0BA3
	lda	monster_tile,x			; 0BA6
	and	#$03				; 0BA9  C
	jmp	@settile			; 0BAB

@dontanim:
	lda	monster_tile,x			; 0BAE
	sta	currmap,y			; 0BB1
@next:
	dex					; 0BB4
	bpl	@nextmonster			; 0BB5
animateplayers:
	ldx	party_size			; 0BB7
@nextplayer:
	lda	$AD9F,x				; 0BB9
	beq	@next				; 0BBC
	ldy	$AD8F,x				; 0BBE
	lda	mul11,y				; 0BC1
	clc					; 0BC4
	adc	$AD7F,x				; 0BC5
	tay					; 0BC8
	lda	$AD9F,x				; 0BC9
	cmp	#$38				; 0BCC  8
	beq	@settile			; 0BCE
	cpx	$45				; 0BD0
	bne	@animate			; 0BD2
	dec	movement_counter		; 0BD4
	lda	movement_counter		; 0BD7
	and	#$03				; 0BDA  C
	bne	@animate			; 0BDC
	lda	#$7D				; 0BDE  }
	jmp	@settile			; 0BE0

@animate:
	jsr	rand				; 0BE3
	and	#$01				; 0BE6  A
	clc					; 0BE8
	adc	$AD9F,x				; 0BE9
@settile:
	sta	currmap,y			; 0BEC
@next:
	dex					; 0BEF
	bne	@nextplayer			; 0BF0
	lda	missile				; 0BF2
	beq	@done				; 0BF5
	ldx	missile_ypos			; 0BF7
	lda	mul11,x				; 0BFA
	clc					; 0BFD
	adc	missile_xpos			; 0BFE
	tay					; 0C01
	lda	missile				; 0C02
	sta	currmap,y			; 0C05
@done:
	jmp	drawview			; 0C08

update_towne:
	jsr	animate_creatures		; 0C0B
	sec					; 0C0E
	lda	player_xpos			; 0C0F
	sbc	#$05				; 0C11  E
	sta	$40				; 0C13
	sec					; 0C15
	lda	player_ypos			; 0C16
	sbc	#$05				; 0C18  E
	sta	$41				; 0C1A
	lda	#$00				; 0C1C  .
	sta	$42				; 0C1E
	sta	$43				; 0C20
	tay					; 0C22
	tax					; 0C23
@nexttile:
	clc					; 0C24
	lda	$40				; 0C25
	adc	$42				; 0C27
	sta	$44				; 0C29
	cmp	#$20				; 0C2B   
	bcs	@grass				; 0C2D
	clc					; 0C2F
	lda	$41				; 0C30
	adc	$43				; 0C32
	sta	$45				; 0C34
	cmp	#$20				; 0C36   
	bcs	@grass				; 0C38
	sta	ptr2+1				; 0C3A
	lda	#$00				; 0C3C  .
	lsr	ptr2+1				; 0C3E
	ror	a				; 0C40
	lsr	ptr2+1				; 0C41
	ror	a				; 0C43
	lsr	ptr2+1				; 0C44
	ror	a				; 0C46
	adc	$44				; 0C47
	sta	ptr2				; 0C49
	clc					; 0C4B
	lda	ptr2+1				; 0C4C
	adc	#$E8				; 0C4E  h
	sta	ptr2+1				; 0C50
	lda	(ptr2),y			; 0C52
	jmp	@settile			; 0C54

@grass:
	lda	#$04				; 0C57  D
@settile:
	sta	tempmap,x			; 0C59
	inx					; 0C5C
	inc	$42				; 0C5D
	lda	$42				; 0C5F
	cmp	#$0B				; 0C61  K
	bne	@nexttile			; 0C63
	sty	$42				; 0C65
	inc	$43				; 0C67
	lda	$43				; 0C69
	cmp	#$0B				; 0C6B  K
	bne	@nexttile			; 0C6D
	jmp	update_monsters			; 0C6F

update_britannia:
	jsr	animate_creatures		; 0C72
	jsr	update_moons			; 0C75
	sec					; 0C78
	lda	tile_xpos			; 0C79
	sbc	#$05				; 0C7B  E
	sta	$40				; 0C7D
	sec					; 0C7F
	lda	tile_ypos			; 0C80
	sbc	#$05				; 0C82  E
	sta	$41				; 0C84
	lda	#$00				; 0C86  .
	sta	$42				; 0C88
	sta	$43				; 0C8A
	tay					; 0C8C
	tax					; 0C8D
@copymap:
	clc					; 0C8E
	lda	$40				; 0C8F
	adc	$42				; 0C91
	sta	$44				; 0C93
	clc					; 0C95
	lda	$41				; 0C96
	adc	$43				; 0C98
	sta	$45				; 0C9A
	jsr	mul16				; 0C9C
	sta	ptr2				; 0C9F
	lda	$44				; 0CA1
	and	#$0F				; 0CA3  O
	ora	ptr2				; 0CA5
	sta	ptr2				; 0CA7
	lda	$45				; 0CA9
	and	#$10				; 0CAB  P
	asl	a				; 0CAD
	ora	$44				; 0CAE
	jsr	div16				; 0CB0
	clc					; 0CB3
	adc	#$E8				; 0CB4  h
	sta	ptr2+1				; 0CB6
	lda	(ptr2),y			; 0CB8
	sta	tempmap,x			; 0CBA
	inx					; 0CBD
	inc	$42				; 0CBE
	lda	$42				; 0CC0
	cmp	#$0B				; 0CC2  K
	bne	@copymap			; 0CC4
	sty	$42				; 0CC6
	inc	$43				; 0CC8
	lda	$43				; 0CCA
	cmp	#$0B				; 0CCC  K
	bne	@copymap			; 0CCE
update_monsters:
	ldx	#$1F				; 0CD0  _
@nextmonster:
	lda	map_status,x			; 0CD2
	beq	@nomonster			; 0CD5
	lda	object_xpos,x			; 0CD7
	clc					; 0CDA
	adc	#$05				; 0CDB  E
	sec					; 0CDD
	sbc	player_xpos			; 0CDE
	cmp	#$0B				; 0CE0  K
	bcs	@nomonster			; 0CE2
	sta	$44				; 0CE4
	lda	object_ypos,x			; 0CE6
	clc					; 0CE9
	adc	#$05				; 0CEA  E
	sec					; 0CEC
	sbc	player_ypos			; 0CED
	cmp	#$0B				; 0CEF  K
	bcs	@nomonster			; 0CF1
	sta	$45				; 0CF3
	ldy	$45				; 0CF5
	lda	mul11,y				; 0CF7
	clc					; 0CFA
	adc	$44				; 0CFB
	tay					; 0CFD
	lda	map_status,x			; 0CFE
	sta	tempmap,y			; 0D01
@nomonster:
	dex					; 0D04
	bpl	@nextmonster			; 0D05
	lda	moongate_tile			; 0D07
	beq	@skipmoongates			; 0D09
	lda	moongate_xpos			; 0D0B
	clc					; 0D0D
	adc	#$05				; 0D0E  E
	sec					; 0D10
	sbc	player_xpos			; 0D11
	cmp	#$0B				; 0D13  K
	bcs	@skipmoongates			; 0D15
	sta	$44				; 0D17
	lda	moongate_ypos			; 0D19
	clc					; 0D1B
	adc	#$05				; 0D1C  E
	sec					; 0D1E
	sbc	player_ypos			; 0D1F
	cmp	#$0B				; 0D21  K
	bcs	@skipmoongates			; 0D23
	sta	$45				; 0D25
	ldy	$45				; 0D27
	lda	mul11,y				; 0D29
	clc					; 0D2C
	adc	$44				; 0D2D
	tay					; 0D2F
	lda	moongate_tile			; 0D30
	sta	tempmap,y			; 0D32
@skipmoongates:
	lda	tempmap+49			; 0D35
	sta	tile_north			; 0D38
	lda	tempmap+71			; 0D3A
	sta	tile_south			; 0D3D
	lda	tempmap+61			; 0D3F
	sta	tile_east			; 0D42
	lda	tempmap+59			; 0D44
	sta	tile_west			; 0D47
	lda	tempmap+60			; 0D49
	sta	tile_under_player		; 0D4C
	lda	player_transport		; 0D4E
	sta	tempmap+60			; 0D50
	lda	$1D				; 0D53
	beq	lineofsight			; 0D55
	ldx	#$78				; 0D57  x
@copy:
	lda	tempmap,x			; 0D59
	sta	currmap,x			; 0D5C
	dex					; 0D5F
	bpl	@copy				; 0D60
	jmp	drawview			; 0D62

lineofsight:
	ldx	#$78				; 0D65  x
	lda	#$7E				; 0D67  ~
@clear:
	sta	currmap,x			; 0D69
	dex					; 0D6C
	bpl	@clear				; 0D6D
	lda	#$78				; 0D6F  x
	sta	$70				; 0D71
	lda	#$0A				; 0D73  J
	sta	$44				; 0D75
	sta	$45				; 0D77
lospass1:
	lda	$44				; 0D79
	sta	$40				; 0D7B
	lda	$45				; 0D7D
	sta	$41				; 0D7F
	lda	$70				; 0D81
	sta	$71				; 0D83
@nexttile:
	ldx	$40				; 0D85
	ldy	$41				; 0D87
	lda	$71				; 0D89
	clc					; 0D8B
	adc	deltax,x			; 0D8C
	clc					; 0D8F
	adc	deltay,y			; 0D90
	cmp	#$3C				; 0D93  <
	beq	@playertile			; 0D95
	sta	$71				; 0D97
	tax					; 0D99
	lda	tempmap,x			; 0D9A
	cmp	#$06				; 0D9D  F
	beq	@blocking			; 0D9F
	cmp	#$08				; 0DA1  H
	beq	@blocking			; 0DA3
	cmp	#$49				; 0DA5  I
	beq	@blocking			; 0DA7
	cmp	#$7E				; 0DA9  ~
	beq	@blocking			; 0DAB
	cmp	#$7F				; 0DAD  .
	beq	@blocking			; 0DAF
	lda	$40				; 0DB1
	tax					; 0DB3
	clc					; 0DB4
	adc	deltax,x			; 0DB5
	sta	$40				; 0DB8
	lda	$41				; 0DBA
	tax					; 0DBC
	clc					; 0DBD
	adc	deltax,x			; 0DBE
	sta	$41				; 0DC1
	jmp	@nexttile			; 0DC3

@playertile:
	ldx	$70				; 0DC6
	lda	tempmap,x			; 0DC8
	sta	currmap,x			; 0DCB
@blocking:
	dec	$70				; 0DCE
	dec	$44				; 0DD0
	bpl	lospass1			; 0DD2
	lda	#$0A				; 0DD4  J
	sta	$44				; 0DD6
	dec	$45				; 0DD8
	bpl	lospass1			; 0DDA
lospass2:
	lda	#$78				; 0DDC  x
	sta	$70				; 0DDE
	lda	#$0A				; 0DE0  J
	sta	$44				; 0DE2
	sta	$45				; 0DE4
@next:
	lda	$44				; 0DE6
	sta	$40				; 0DE8
	lda	$45				; 0DEA
	sta	$41				; 0DEC
	lda	$70				; 0DEE
	sta	$71				; 0DF0
	tax					; 0DF2
	lda	currmap,x			; 0DF3
	cmp	#$7E				; 0DF6  ~
	bne	@blocking			; 0DF8
@continue:
	ldx	$40				; 0DFA
	ldy	$41				; 0DFC
	lda	distance,x			; 0DFE
	cmp	distance,y			; 0E01
	beq	@diagonal			; 0E04
	bcc	@vertical			; 0E06
	bcs	@horizontal			; 0E08
@diagonal:
	lda	$71				; 0E0A
	clc					; 0E0C
	adc	deltax,x			; 0E0D
	clc					; 0E10
	adc	deltay,y			; 0E11
	jsr	nexthoriz			; 0E14
	jsr	nextvert			; 0E17
	jmp	@checkblock			; 0E1A

@horizontal:
	lda	$71				; 0E1D
	clc					; 0E1F
	adc	deltax,x			; 0E20
	jsr	nexthoriz			; 0E23
	jmp	@checkblock			; 0E26

@vertical:
	lda	$71				; 0E29
	clc					; 0E2B
	adc	deltay,y			; 0E2C
	jsr	nextvert			; 0E2F
@checkblock:
	cmp	#$3C				; 0E32  <
	beq	@playertile			; 0E34
	sta	$71				; 0E36
	tax					; 0E38
	lda	tempmap,x			; 0E39
	cmp	#$06				; 0E3C  F
	beq	@blocking			; 0E3E
	cmp	#$08				; 0E40  H
	beq	@blocking			; 0E42
	cmp	#$49				; 0E44  I
	beq	@blocking			; 0E46
	cmp	#$7E				; 0E48  ~
	beq	@blocking			; 0E4A
	cmp	#$7F				; 0E4C  .
	beq	@blocking			; 0E4E
	jmp	@continue			; 0E50

@playertile:
	ldx	$70				; 0E53
	lda	tempmap,x			; 0E55
	sta	currmap,x			; 0E58
@blocking:
	dec	$70				; 0E5B
	dec	$44				; 0E5D
	bpl	@next				; 0E5F
	lda	#$0A				; 0E61  J
	sta	$44				; 0E63
	dec	$45				; 0E65
	bmi	drawview			; 0E67
	jmp	@next				; 0E69

drawview:
	lda	ptr1				; 0E6C
	pha					; 0E6E
	lda	ptr1+1				; 0E6F
	pha					; 0E71
	lda	ptr2				; 0E72
	pha					; 0E74
	lda	ptr2+1				; 0E75
	pha					; 0E77
	lda	$58				; 0E78
	pha					; 0E7A
	lda	$59				; 0E7B
	pha					; 0E7D
	lda	#$00				; 0E7E  .
	sta	@ldy_addr			; 0E80
	lda	#$29				; 0E83  )
	sta	$58				; 0E85
	lda	#$04				; 0E87  D
	sta	$59				; 0E89
	ldy	#$08				; 0E8B  H
	lda	bmplineaddr_lo,y		; 0E8D
	sta	ptr2				; 0E90
	lda	bmplineaddr_hi,y		; 0E92
	sta	ptr2+1				; 0E95
	lda	ptr2				; 0E97
	clc					; 0E99
	adc	#$08				; 0E9A  H
	sta	ptr2				; 0E9C
	lda	ptr2+1				; 0E9E
	adc	#$00				; 0EA0  .
	sta	ptr2+1				; 0EA2
	lda	#$00				; 0EA4  .
	sta	$72				; 0EA6
@nextline:
	lda	#$00				; 0EA8  .
	sta	tilenum				; 0EAA
@nexttile:
	.byte	$AC				; 0EAD  ,
@ldy_addr:
	.word	$AE00				; 0EAE

	tya					; 0EB0
	pha					; 0EB1
	jsr	gettileaddr			; 0EB2
	lda	tilenum				; 0EB5
	sec					; 0EB8
	asl	a				; 0EB9
	tay					; 0EBA
	pla					; 0EBB
	tax					; 0EBC
	lda	tile_color,x			; 0EBD
	sta	($58),y				; 0EC0
	iny					; 0EC2
	sta	($58),y				; 0EC3
	pha					; 0EC5
	tya					; 0EC6
	clc					; 0EC7
	adc	#$27				; 0EC8  '
	tay					; 0ECA
	pla					; 0ECB
	sta	($58),y				; 0ECC
	iny					; 0ECE
	sta	($58),y				; 0ECF
	ldy	#$0F				; 0ED1  O
@drawupper:
	lda	(ptr1),y			; 0ED3
	sta	(ptr2),y			; 0ED5
	dey					; 0ED7
	bpl	@drawupper			; 0ED8
	lda	ptr1+1				; 0EDA
	eor	#$70				; 0EDC  p
	sta	ptr1+1				; 0EDE
	lda	ptr2				; 0EE0
	pha					; 0EE2
	clc					; 0EE3
	adc	#$40				; 0EE4  @
	sta	ptr2				; 0EE6
	lda	ptr2+1				; 0EE8
	pha					; 0EEA
	adc	#$01				; 0EEB  A
	sta	ptr2+1				; 0EED
	ldy	#$0F				; 0EEF  O
@drawlower:
	lda	(ptr1),y			; 0EF1
	sta	(ptr2),y			; 0EF3
	dey					; 0EF5
	bpl	@drawlower			; 0EF6
	lda	ptr1+1				; 0EF8
	eor	#$70				; 0EFA  p
	sta	ptr1+1				; 0EFC
	pla					; 0EFE
	sta	ptr2+1				; 0EFF
	pla					; 0F01
	sta	ptr2				; 0F02
	inc	@ldy_addr			; 0F04
	lda	ptr2				; 0F07
	clc					; 0F09
	adc	#$10				; 0F0A  P
	sta	ptr2				; 0F0C
	lda	ptr2+1				; 0F0E
	adc	#$00				; 0F10  .
	sta	ptr2+1				; 0F12
	inc	tilenum				; 0F14
	lda	tilenum				; 0F17
	cmp	#$0B				; 0F1A  K
	bne	@nexttile			; 0F1C
	lda	$58				; 0F1E
	clc					; 0F20
	adc	#$50				; 0F21  P
	sta	$58				; 0F23
	lda	$59				; 0F25
	adc	#$00				; 0F27  .
	sta	$59				; 0F29
	lda	ptr2				; 0F2B
	clc					; 0F2D
	adc	#$D0				; 0F2E  P
	sta	ptr2				; 0F30
	lda	ptr2+1				; 0F32
	adc	#$01				; 0F34  A
	sta	ptr2+1				; 0F36
	inc	$72				; 0F38
	lda	$72				; 0F3A
	cmp	#$0B				; 0F3C  K
	beq	@done				; 0F3E
	jmp	@nextline			; 0F40

@done:
	pla					; 0F43
	sta	$59				; 0F44
	pla					; 0F46
	sta	$58				; 0F47
	pla					; 0F49
	sta	ptr2+1				; 0F4A
	pla					; 0F4C
	sta	ptr2				; 0F4D
	pla					; 0F4F
	sta	ptr1+1				; 0F50
	pla					; 0F52
	sta	ptr1				; 0F53
	rts					; 0F55

tilenum:
	.byte	$00				; 0F56  .
deltax:
	.byte	$01,$01,$01,$01,$01,$00,$FF,$FF	; 0F57  AAAAA...
	.byte	$FF,$FF,$FF			; 0F5F  ...
deltay:
	.byte	$0B,$0B,$0B,$0B,$0B,$00,$F5,$F5	; 0F62  KKKKK.uu
	.byte	$F5,$F5,$F5			; 0F6A  uuu
distance:
	.byte	$05,$04,$03,$02,$01,$00,$01,$02	; 0F6D  EDCBA.AB
	.byte	$03,$04,$05			; 0F75  CDE

nexthoriz:
	pha					; 0F78
	lda	$40				; 0F79
	tax					; 0F7B
	clc					; 0F7C
	adc	deltax,x			; 0F7D
	sta	$40				; 0F80
	pla					; 0F82
	rts					; 0F83

nextvert:
	pha					; 0F84
	lda	$41				; 0F85
	tax					; 0F87
	clc					; 0F88
	adc	deltax,x			; 0F89
	sta	$41				; 0F8C
	pla					; 0F8E
	rts					; 0F8F

animate_creatures:
	ldx	#$00				; 0F90  .
@animate_next:
	lda	object_tile,x			; 0F92
	beq	@animend			; 0F95
	bpl	@animate_nonmonster		; 0F97
	cmp	#$90				; 0F99  P
	bcs	@animate_monster		; 0F9B
	cmp	#$80				; 0F9D  .
	beq	@animdone			; 0F9F
@animate_seamonster:
	jsr	fastrand			; 0FA1
	cmp	#$C0				; 0FA4  @
	bcs	@animdone			; 0FA6
	lda	map_status,x			; 0FA8
	eor	#$01				; 0FAB  A
	and	#$01				; 0FAD  A
	ora	object_tile,x			; 0FAF
	sta	map_status,x			; 0FB2
	jmp	@animdone			; 0FB5

@animate_monster:
	jsr	fastrand			; 0FB8
	cmp	#$C0				; 0FBB  @
	bcs	@animdone			; 0FBD
	lda	map_status,x			; 0FBF
	clc					; 0FC2
	adc	#$01				; 0FC3  A
	and	#$03				; 0FC5  C
	ora	object_tile,x			; 0FC7
	sta	map_status,x			; 0FCA
	jmp	@animdone			; 0FCD

@animate_nonmonster:
	cmp	#$50				; 0FD0  P
	bcc	@animate_player			; 0FD2
	cmp	#$60				; 0FD4  `
	bcs	@dontanim			; 0FD6
@animate_npc:
	jmp	@animate_seamonster		; 0FD8

@animate_player:
	cmp	#$20				; 0FDB   
	bcc	@dontanim			; 0FDD
	cmp	#$30				; 0FDF  0
	bcs	@dontanim			; 0FE1
	jmp	@animate_seamonster		; 0FE3

@dontanim:
	lda	object_tile,x			; 0FE6
	sta	map_status,x			; 0FE9
	jmp	@animdone			; 0FEC

@animend:
	lda	#$00				; 0FEF  .
	sta	map_status,x			; 0FF1
@animdone:
	inx					; 0FF4
	cpx	#$20				; 0FF5   
	bcc	@animate_next			; 0FF7
	jsr	animatetiles			; 0FF9
	jsr	animate_fire			; 0FFC
	jmp	animate_flags			; 0FFF

primm_xy:
	stx	console_xpos			; 1002
	sty	console_ypos			; 1004
primm:
	pla					; 1006
	sta	primmaddr			; 1007
	pla					; 100A
	sta	L1018				; 100B
@next:
	inc	primmaddr			; 100E
	bne	@skip				; 1011
	inc	L1018				; 1013
@skip:
primmaddr	:= * + 1
L1018		:= * + 2
	lda	$FFFF				; 1016
	beq	@done				; 1019
	jsr	console_out			; 101B
	jmp	@next				; 101E

@done:
	lda	L1018				; 1021
	pha					; 1024
	lda	primmaddr			; 1025
	pha					; 1028
	rts					; 1029

console_out:
	cmp	#$8D				; 102A  M
	beq	console_newline			; 102C
	and	#$7F				; 102E  .
	ldx	console_xpos			; 1030
	cpx	#$28				; 1032  (
	bcc	@noteol				; 1034
	pha					; 1036
	jsr	console_newline			; 1037
	pla					; 103A
@noteol:
	jsr	drawchar			; 103B
	inc	console_xpos			; 103E
	rts					; 1040

console_newline:
	lda	#$18				; 1041  X
	sta	console_xpos			; 1043
	inc	console_ypos			; 1045
	lda	console_ypos			; 1047
	cmp	#$18				; 1049  X
	bcc	@notbottom			; 104B
	dec	console_ypos			; 104D
	jsr	console_scroll			; 104F
@notbottom:
	rts					; 1052

get_stats_ptr:
	lda	currplayer			; 1053
	sec					; 1055
	sbc	#$01				; 1056  A
	jsr	mul32				; 1058
	sta	ptr1				; 105B
	lda	#$AA				; 105D  *
	sta	ptr1+1				; 105F
	rts					; 1061

centername:
	jsr	get_stats_ptr			; 1062
	lda	#$00				; 1065  .
	sta	zptmp1				; 1067
@count:
	ldy	zptmp1				; 1069
	lda	(ptr1),y			; 106B
	beq	@gotlen				; 106D
	inc	zptmp1				; 106F
	lda	zptmp1				; 1071
	cmp	#$0F				; 1073  O
	bcc	@count				; 1075
@gotlen:
	lda	#$0F				; 1077  O
	sec					; 1079
	sbc	zptmp1				; 107A
	lsr	a				; 107C
	clc					; 107D
	adc	console_xpos			; 107E
	sta	console_xpos			; 1080
printname:
	jsr	get_stats_ptr			; 1082
	lda	#$00				; 1085  .
	sta	zptmp1				; 1087
@print:
	ldy	zptmp1				; 1089
	lda	(ptr1),y			; 108B
	beq	@done				; 108D
	jsr	console_out			; 108F
	inc	zptmp1				; 1092
	lda	zptmp1				; 1094
	cmp	#$0F				; 1096  O
	bcc	@print				; 1098
@done:
	rts					; 109A

printname8:
	jsr	get_stats_ptr			; 109B
	lda	#$00				; 109E  .
	sta	zptmp1				; 10A0
@print:
	ldy	zptmp1				; 10A2
	lda	(ptr1),y			; 10A4
	beq	@done				; 10A6
	jsr	console_out			; 10A8
	inc	zptmp1				; 10AB
	lda	zptmp1				; 10AD
	cmp	#$08				; 10AF  H
	bcc	@print				; 10B1
@done:
	rts					; 10B3

drawcursor_xy:
	stx	console_xpos			; 10B4
	sty	console_ypos			; 10B6
drawcursor:
	dec	cursor_ctr			; 10B8
	lda	cursor_ctr			; 10BB
	and	#$7F				; 10BE  .
	ora	#$7C				; 10C0  |
	bne	dodrawcursor			; 10C2
clearcursor:
	lda	#$20				; 10C4   
dodrawcursor:
	jsr	console_out			; 10C6
	dec	console_xpos			; 10C9
	rts					; 10CB

cursor_ctr:
	.byte	$00				; 10CC  .

printbcd:
	sta	zptmp1				; 10CD
	jsr	div16				; 10CF
	clc					; 10D2
	adc	#$30				; 10D3  0
	jsr	console_out			; 10D5
	lda	zptmp1				; 10D8
	and	#$0F				; 10DA  O
printdigit:
	clc					; 10DC
	adc	#$30				; 10DD  0
	jmp	console_out			; 10DF

clearstatwindow:
	jsr	drawhoriz			; 10E2
	.byte	$18,$00,$04,$05,$04,$05,$04,$05	; 10E5  X.DEDEDE
	.byte	$04,$05,$04,$05,$04,$05,$04,$05	; 10ED  DEDEDEDE
	.byte	$04,$FF				; 10F5  D.

	ldx	#$08				; 10F7  H
@clearstatline:
	lda	bmplineaddr_lo,x		; 10F9
	sta	ptr1				; 10FC
	lda	bmplineaddr_hi,x		; 10FE
	sta	ptr1+1				; 1101
	lda	ptr1				; 1103
	clc					; 1105
	adc	#$C0				; 1106  @
	sta	ptr1				; 1108
	lda	ptr1+1				; 110A
	adc	#$00				; 110C  .
	sta	ptr1+1				; 110E
	ldy	#$00				; 1110  .
@clear:
	lda	#$00				; 1112  .
	sta	(ptr1),y			; 1114
	iny					; 1116
	cpy	#$78				; 1117  x
	bcc	@clear				; 1119
	txa					; 111B
	clc					; 111C
	adc	#$08				; 111D  H
	tax					; 111F
	cpx	#$48				; 1120  H
	bcc	@clearstatline			; 1122
	rts					; 1124

	.byte	$CD				; 1125  M
update_status:
	lda	#$E5				; 1126  e
	sta	ptr1+1				; 1128
	lda	#$00				; 112A  .
	sta	ptr1				; 112C
	ldx	#$00				; 112E  .
@next_virtue:
	lda	game_stats,x			; 1130
	beq	@partial_avatar			; 1133
	lda	#$00				; 1135  .
	beq	@not_avatar			; 1137
@partial_avatar:
	txa					; 1139
	clc					; 113A
	adc	#$78				; 113B  x
	tay					; 113D
	lda	(ptr1),y			; 113E
@not_avatar:
	pha					; 1140
	txa					; 1141
	clc					; 1142
	adc	#$28				; 1143  (
	tay					; 1145
	pla					; 1146
	sta	(ptr1),y			; 1147
	inx					; 1149
	cpx	#$08				; 114A  H
	bne	@next_virtue			; 114C
	jsr	stats_save_pos			; 114E
	lda	currplayer			; 1151
	pha					; 1153
	lda	party_size			; 1154
	sta	currplayer			; 1156
@nextplayer:
	ldx	currplayer			; 1158
	jsr	get_stats_ptr			; 115A
	lda	currplayer			; 115D
	sta	console_ypos			; 115F
	lda	#$18				; 1161  X
	sta	console_xpos			; 1163
	lda	currplayer			; 1165
	jsr	printdigit			; 1167
	lda	#$AD				; 116A  -
	jsr	console_out			; 116C
	jsr	printname8			; 116F
	lda	#$23				; 1172  #
	sta	console_xpos			; 1174
	jsr	get_stats_ptr			; 1176
	ldy	#$18				; 1179  X
	lda	(ptr1),y			; 117B
	jsr	printdigit			; 117D
	ldy	#$19				; 1180  Y
	lda	(ptr1),y			; 1182
	jsr	printbcd			; 1184
	ldy	#$12				; 1187  R
	lda	(ptr1),y			; 1189
	jsr	console_out			; 118B
	jsr	scankey				; 118E
	dec	currplayer			; 1191
	bne	@nextplayer			; 1193
@printfood:
	ldx	#$18				; 1195  X
	ldy	#$0A				; 1197  J
	jsr	primm_xy			; 1199
	.byte	$C6,$BA,$00			; 119C  F:.

	ldy	#$10				; 119F  P
	lda	game_stats,y			; 11A1
	jsr	printbcd			; 11A4
	ldy	#$11				; 11A7  Q
	lda	game_stats,y			; 11A9
	jsr	printbcd			; 11AC
	lda	#$A0				; 11AF   
	jsr	console_out			; 11B1
	lda	magic_aura			; 11B4
	jsr	console_out			; 11B6
	lda	player_transport		; 11B9
	cmp	#$14				; 11BB  T
	bcc	@ship				; 11BD
	jsr	primm				; 11BF
	.byte	$A0,$C7,$BA,$00			; 11C2   G:.

	ldy	#$13				; 11C6  S
	lda	game_stats,y			; 11C8
	jsr	printbcd			; 11CB
	ldy	#$14				; 11CE  T
	lda	game_stats,y			; 11D0
	jsr	printbcd			; 11D3
	jmp	@done				; 11D6

@ship:
	jsr	primm				; 11D9
	.byte	$A0,$D3,$C8,$D0,$BA,$00		; 11DC   SHP:.

	lda	ship_hull			; 11E2
	jsr	printbcd			; 11E4
@done:
	pla					; 11E7
	sta	currplayer			; 11E8
	jmp	stats_rest_pos			; 11EA

stats_saved_xpos:
	.byte	$00				; 11ED  .
stats_saved_xpos:
	.byte	$00				; 11EE  .

update_wind:
	jsr	rand				; 11EF
	bne	@nochange			; 11F2
	jsr	rand				; 11F4
	jsr	getsign				; 11F7
	clc					; 11FA
	adc	direction			; 11FB
	and	#$03				; 11FD  C
	sta	direction			; 11FF
@nochange:
	jsr	stats_save_pos			; 1201
	lda	#$17				; 1204  W
	sta	console_ypos			; 1206
	lda	#$06				; 1208  F
	sta	console_xpos			; 120A
	jsr	primm				; 120C
	.byte	$1E,$D7,$C9,$CE,$C4,$A0,$00	; 120F  ^WIND .

	ldx	direction			; 1216
	beq	@west				; 1218
	dex					; 121A
	beq	@north				; 121B
	dex					; 121D
	beq	@east				; 121E
	dex					; 1220
	beq	@south				; 1221
	bne	@done				; 1223
@west:
	jsr	printwest			; 1225
	jmp	@done				; 1228

@north:
	jsr	printnorth			; 122B
	jmp	@done				; 122E

@east:
	jsr	printeast			; 1231
	jmp	@done				; 1234

@south:
	jsr	printsouth			; 1237
@done:
	lda	#$1D				; 123A  ]
	jsr	console_out			; 123C
	jmp	stats_rest_pos			; 123F

print_direction:
	jsr	stats_save_pos			; 1242
	lda	#$17				; 1245  W
	sta	console_ypos			; 1247
	lda	#$07				; 1249  G
	sta	console_xpos			; 124B
	jsr	primm				; 124D
	.byte	$C4,$C9,$D2,$BA,$A0,$00		; 1250  DIR: .

	ldx	dng_direction			; 1256
	beq	@north				; 1258
	dex					; 125A
	beq	@east				; 125B
	dex					; 125D
	beq	@south				; 125E
	bne	@west				; 1260
@north:
	jsr	printnorth			; 1262
	jmp	@printlevel			; 1265

@east:
	jsr	printeast			; 1268
	jmp	@printlevel			; 126B

@south:
	jsr	printsouth			; 126E
	jmp	@printlevel			; 1271

@west:
	jsr	printwest			; 1274
@printlevel:
	lda	#$00				; 1277  .
	sta	console_ypos			; 1279
	lda	#$0B				; 127B  K
	sta	console_xpos			; 127D
	lda	#$CC				; 127F  L
	jsr	console_out			; 1281
	lda	dungeon_level			; 1284
	clc					; 1286
	adc	#$01				; 1287  A
	jsr	printdigit			; 1289
	jmp	stats_rest_pos			; 128C

printnorth:
	jsr	primm				; 128F
	.byte	$CE,$CF,$D2,$D4,$C8,$00		; 1292  NORTH.

	rts					; 1298

printsouth:
	jsr	primm				; 1299
	.byte	$D3,$CF,$D5,$D4,$C8,$00		; 129C  SOUTH.

	rts					; 12A2

printeast:
	jsr	primm				; 12A3
	.byte	$A0,$C5,$C1,$D3,$D4,$00		; 12A6   EAST.

	rts					; 12AC

printwest:
	jsr	primm				; 12AD
	.byte	$A0,$D7,$C5,$D3,$D4,$00		; 12B0   WEST.

	rts					; 12B6

getsign:
	cmp	#$00				; 12B7  .
	beq	@zero				; 12B9
	bmi	@negative			; 12BB
	lda	#$01				; 12BD  A
	rts					; 12BF

@negative:
	lda	#$FF				; 12C0  .
@zero:
	rts					; 12C2

stats_save_pos:
	lda	console_xpos			; 12C3
	sta	stats_saved_xpos		; 12C5
	lda	console_ypos			; 12C8
	sta	stats_saved_xpos		; 12CA
	rts					; 12CD

stats_rest_pos:
	lda	stats_saved_xpos		; 12CE
	sta	console_xpos			; 12D1
	lda	stats_saved_xpos		; 12D3
	sta	console_ypos			; 12D6
	rts					; 12D8

getnumdel:
	dec	console_xpos			; 12D9
getnumber:
	jsr	waitkey				; 12DB
	sec					; 12DE
	sbc	#$B0				; 12DF  0
	cmp	#$0A				; 12E1  J
	bcs	getnumber			; 12E3
	sta	bcdnum				; 12E5
	sta	hexnum				; 12E7
	jsr	printdigit			; 12E9
@seconddigit:
	jsr	waitkey				; 12EC
	cmp	#$8D				; 12EF  M
	beq	@done				; 12F1
	cmp	#$88				; 12F3  H
	beq	getnumdel			; 12F5
	sec					; 12F7
	sbc	#$B0				; 12F8  0
	cmp	#$0A				; 12FA  J
	bcs	@seconddigit			; 12FC
	sta	hexnum				; 12FE
	jsr	printdigit			; 1300
@notretordel:
	jsr	waitkey				; 1303
	cmp	#$8D				; 1306  M
	beq	@convhex			; 1308
	cmp	#$88				; 130A  H
	bne	@notretordel			; 130C
	dec	console_xpos			; 130E
	bpl	@seconddigit			; 1310
@convhex:
	lda	bcdnum				; 1312
	jsr	mul16				; 1314
	ora	hexnum				; 1317
	sta	bcdnum				; 1319
	ldx	#$00				; 131B  .
	sed					; 131D
	sec					; 131E
@count:
	sbc	#$01				; 131F  A
	bcc	@counted			; 1321
	inx					; 1323
	bne	@count				; 1324
@counted:
	stx	hexnum				; 1326
	cld					; 1328
@done:
	rts					; 1329

getplayernum:
	jsr	waitkey				; 132A
	beq	@gotnum				; 132D
	sec					; 132F
	sbc	#$B0				; 1330  0
	cmp	#$09				; 1332  I
	bcc	@gotnum				; 1334
	lda	#$00				; 1336  .
@gotnum:
	sta	currplayer			; 1338
	jsr	printdigit			; 133A
	jsr	console_newline			; 133D
	lda	currplayer			; 1340
	rts					; 1342

blocked_tile:
	ldx	#$28				; 1343  (
@next:
	dex					; 1345
	bmi	@blocked			; 1346
	cmp	walkable_tiles,x		; 1348
	bne	@next				; 134B
	rts					; 134D

@blocked:
	lda	#$FF				; 134E  .
	rts					; 1350

walkable_tiles:
	.byte	$03,$04,$05,$06,$07,$09,$0A,$0B	; 1351  CDEFGIJK
	.byte	$0C,$10,$11,$12,$13,$14,$15,$16	; 1359  LPQRSTUV
	.byte	$17,$18,$19,$1A,$1B,$1C,$1D,$1E	; 1361  WXYZ[\]^
	.byte	$3C,$3E,$3F,$43,$44,$46,$47,$49	; 1369  <>?CDFGI
	.byte	$4A,$4C,$4C,$4C,$8C,$8D,$8E,$8F	; 1371  JLLLLMNO

clearbitmap:
	lda	#$00				; 1379  .
	sta	ptr1				; 137B
	tay					; 137D
	ldx	#$20				; 137E   
	stx	ptr1+1				; 1380
@clear:
	sta	(ptr1),y			; 1382
	iny					; 1384
	bne	@clear				; 1385
	inc	ptr1+1				; 1387
	dex					; 1389
	bne	@clear				; 138A
	rts					; 138C

clearchars:
	lda	#$00				; 138D  .
	sta	ptr1				; 138F
	lda	#$04				; 1391  D
	sta	ptr1+1				; 1393
	ldx	#$04				; 1395  D
	ldy	#$00				; 1397  .
	lda	#$10				; 1399  P
@clear:
	sta	(ptr1),y			; 139B
	iny					; 139D
	bne	@clear				; 139E
	inc	ptr1+1				; 13A0
	dex					; 13A2
	bne	@clear				; 13A3
	rts					; 13A5

clearview:
	lda	#$40				; 13A6  @
	sta	ptr1				; 13A8
	lda	#$21				; 13AA  !
	sta	ptr1+1				; 13AC
	ldx	#$01				; 13AE  A
@nextline:
	lda	#$00				; 13B0  .
	ldy	#$08				; 13B2  H
@clear:
	sta	(ptr1),y			; 13B4
	iny					; 13B6
	cpy	#$B8				; 13B7  8
	bne	@clear				; 13B9
	lda	ptr1				; 13BB
	clc					; 13BD
	adc	#$40				; 13BE  @
	sta	ptr1				; 13C0
	lda	ptr1+1				; 13C2
	adc	#$01				; 13C4  A
	sta	ptr1+1				; 13C6
	inx					; 13C8
	cpx	#$17				; 13C9  W
	bne	@nextline			; 13CB
	rts					; 13CD

invertview:
	lda	#$40				; 13CE  @
	sta	ptr1				; 13D0
	lda	#$21				; 13D2  !
	sta	ptr1+1				; 13D4
	ldx	#$01				; 13D6  A
@nextline:
	ldy	#$08				; 13D8  H
@invert:
	lda	(ptr1),y			; 13DA
	eor	#$FF				; 13DC  .
	sta	(ptr1),y			; 13DE
	iny					; 13E0
	cpy	#$B8				; 13E1  8
	bne	@invert				; 13E3
	lda	ptr1				; 13E5
	clc					; 13E7
	adc	#$40				; 13E8  @
	sta	ptr1				; 13EA
	lda	ptr1+1				; 13EC
	adc	#$01				; 13EE  A
	sta	ptr1+1				; 13F0
	inx					; 13F2
	cpx	#$17				; 13F3  W
	bne	@nextline			; 13F5
	rts					; 13F7

mulax:
	sta	zptmp1				; 13F8
	lda	#$00				; 13FA  .
	cpx	#$00				; 13FC  .
	beq	@zero				; 13FE
@add:
	clc					; 1400
	adc	zptmp1				; 1401
	dex					; 1403
	bne	@add				; 1404
@zero:
	rts					; 1406

	lda	tile_ypos			; 1407
	jsr	mul16				; 1409
	sta	ptr2				; 140C
	lda	tile_xpos			; 140E
	and	#$0F				; 1410  O
	ora	ptr2				; 1412
	sta	ptr2				; 1414
	lda	tile_ypos			; 1416
	and	#$10				; 1418  P
	asl	a				; 141A
	ora	tile_xpos			; 141B
	jsr	div16				; 141D
	clc					; 1420
	adc	#$E8				; 1421  h
	sta	ptr2+1				; 1423
	rts					; 1425

animatetiles:
	lda	#$00				; 1426  .
	jsr	@animate			; 1428
	lda	#$01				; 142B  A
	jsr	@animate			; 142D
	lda	#$02				; 1430  B
	jsr	@animate			; 1432
	lda	#$4C				; 1435  L
	jmp	@animate			; 1437

@animate:
	tay					; 143A
	txa					; 143B
	pha					; 143C
	lda	ptr1				; 143D
	pha					; 143F
	lda	ptr1+1				; 1440
	pha					; 1442
	jsr	animatetile			; 1443
	pla					; 1446
	sta	ptr1+1				; 1447
	pla					; 1449
	sta	ptr1				; 144A
	pla					; 144C
	tax					; 144D
	rts					; 144E

animatetile:
	jsr	gettileaddr			; 144F
	jsr	@shiftcolumn			; 1452
	lda	ptr1				; 1455
	clc					; 1457
	adc	#$08				; 1458  H
	sta	ptr1				; 145A
@shiftcolumn:
	ldy	#$00				; 145C  .
	lda	(ptr1),y			; 145E
	sta	@savebyte			; 1460
	iny					; 1463
	ldx	#$0F				; 1464  O
@shift:
	lda	(ptr1),y			; 1466
	pha					; 1468
	lda	@savebyte			; 1469
	sta	(ptr1),y			; 146C
	pla					; 146E
	sta	@savebyte			; 146F
	iny					; 1472
	cpy	#$08				; 1473  H
	bne	@s				; 1475
	ldy	#$00				; 1477  .
	lda	ptr1+1				; 1479
	eor	#$70				; 147B  p
	sta	ptr1+1				; 147D
@s:	dex					; 147F
	bne	@shift				; 1480
	ldy	#$00				; 1482  .
	lda	@savebyte			; 1484
	sta	(ptr1),y			; 1487
	rts					; 1489

@savebyte:
	.byte	$22				; 148A  \"
gettileaddr:
	sty	ptr1				; 148B
	lda	#$00				; 148D  .
	sta	ptr1+1				; 148F
	asl	ptr1				; 1491
	rol	ptr1+1				; 1493
	asl	ptr1				; 1495
	rol	ptr1+1				; 1497
	asl	ptr1				; 1499
	rol	ptr1+1				; 149B
	asl	ptr1				; 149D
	rol	ptr1+1				; 149F
	lda	ptr1+1				; 14A1
	clc					; 14A3
	adc	#$B0				; 14A4  0
	sta	ptr1+1				; 14A6
	rts					; 14A8

animate_fire:
	ldy	#$44				; 14A9  D
	jsr	gettileaddr			; 14AB
	jsr	fillrand			; 14AE
	lda	ptr1+1				; 14B1
	eor	#$70				; 14B3  p
	sta	ptr1+1				; 14B5
	jsr	fillrand			; 14B7
	ldy	#$4A				; 14BA  J
	jsr	gettileaddr			; 14BC
	jsr	randfire			; 14BF
	lda	ptr1+1				; 14C2
	eor	#$70				; 14C4  p
	sta	ptr1+1				; 14C6
	jsr	randfire			; 14C8
	rts					; 14CB

fillrand:
	ldy	#$00				; 14CC  .
@fill:
	jsr	fastrand			; 14CE
	sta	(ptr1),y			; 14D1
	iny					; 14D3
	cpy	#$40				; 14D4  @
	bne	@fill				; 14D6
	rts					; 14D8

randfire:
	ldy	#$00				; 14D9  .
@rand:
	jsr	fastrand			; 14DB
	and	(ptr1),y			; 14DE
	pha					; 14E0
	tya					; 14E1
	clc					; 14E2
	adc	#$10				; 14E3  P
	tay					; 14E5
	pla					; 14E6
	eor	(ptr1),y			; 14E7
	sta	(ptr1),y			; 14E9
	tya					; 14EB
	sec					; 14EC
	sbc	#$10				; 14ED  P
	tay					; 14EF
	iny					; 14F0
	cpy	#$10				; 14F1  P
	bne	@rand				; 14F3
	rts					; 14F5

	iny					; 14F6
	cpy	#$08				; 14F7  H
	bne	L1503				; 14F9
	ldy	#$00				; 14FB  .
	lda	ptr1+1				; 14FD
	eor	#$70				; 14FF  p
	sta	ptr1+1				; 1501
L1503:
	rts					; 1503

animate_flags:
	jsr	fastrand			; 1504
	bmi	@castle				; 1507
	ldx	$B0A3				; 1509
	ldy	$B0A4				; 150C
	sty	$B0A3				; 150F
	stx	$B0A4				; 1512
@castle:
	jsr	fastrand			; 1515
	bmi	@lbcastle			; 1518
	ldx	$B0B9				; 151A
	ldy	$B0BA				; 151D
	sty	$B0B9				; 1520
	stx	$B0BA				; 1523
@lbcastle:
	jsr	fastrand			; 1526
	bmi	@shipwest			; 1529
	ldx	$B0E1				; 152B
	ldy	$B0E2				; 152E
	sty	$B0E1				; 1531
	stx	$B0E2				; 1534
@shipwest:
	jsr	fastrand			; 1537
	bmi	@shipeast			; 153A
	ldx	$B102				; 153C
	ldy	$B103				; 153F
	sty	$B102				; 1542
	stx	$B103				; 1545
	ldx	$B10A				; 1548
	ldy	$B10B				; 154B
	sty	$B10A				; 154E
	stx	$B10B				; 1551
@shipeast:
	jsr	fastrand			; 1554
	bmi	@flagsdone			; 1557
	ldx	$B122				; 1559
	ldy	$B123				; 155C
	sty	$B122				; 155F
	stx	$B123				; 1562
	ldx	$B12A				; 1565
	ldy	$B12B				; 1568
	sty	$B12A				; 156B
	stx	$B12B				; 156E
@flagsdone:
	rts					; 1571

div32:
	lsr	a				; 1572
div16:
	lsr	a				; 1573
	lsr	a				; 1574
	lsr	a				; 1575
	lsr	a				; 1576
	rts					; 1577

mul32:
	asl	a				; 1578
mul16:
	asl	a				; 1579
	asl	a				; 157A
	asl	a				; 157B
	asl	a				; 157C
	rts					; 157D

scankey:
	lda	$C6				; 157E
	php					; 1580
	lda	$0277				; 1581
	ora	#$80				; 1584  .
	plp					; 1586
	beq	@done				; 1587
	cmp	#$A0				; 1589   
	bne	@notspace			; 158B
	ldy	#$00				; 158D  .
	sty	key_buf_len			; 158F
@notspace:
	nop					; 1591
	ldy	key_buf_len			; 1592
	cpy	#$08				; 1594  H
	bcs	@done				; 1596
	sta	key_buf,y			; 1598
	inc	key_buf_len			; 159B
	jsr	clearkbd			; 159D
@done:
	rts					; 15A0

clearkbd:
	pha					; 15A1
	lda	#$00				; 15A2  .
	sta	$C6				; 15A4
	pla					; 15A6
	rts					; 15A7

getkey:
	lda	key_buf_len			; 15A8
	beq	@empty				; 15AA
	lda	key_buf				; 15AC
	pha					; 15AE
	dec	key_buf_len			; 15AF
	beq	@gotkey				; 15B1
	ldy	#$00				; 15B3  .
@movebuf:
	lda	key_buf+1,y			; 15B5
	sta	key_buf,y			; 15B8
	iny					; 15BB
	cpy	key_buf_len			; 15BC
	bcc	@movebuf			; 15BE
@gotkey:
	pla					; 15C0
	cmp	#$00				; 15C1  .
@empty:
	rts					; 15C3

rand:
	txa					; 15C4
	pha					; 15C5
	clc					; 15C6
	ldx	#$0E				; 15C7  N
	lda	rndf				; 15C9
@add:
	adc	rnd0,x				; 15CC
	sta	rnd0,x				; 15CF
	dex					; 15D2
	bpl	@add				; 15D3
	ldx	#$0F				; 15D5  O
@inc:
	inc	rnd0,x				; 15D7
	bne	@done				; 15DA
	dex					; 15DC
	bpl	@inc				; 15DD
@done:
	pla					; 15DF
	tax					; 15E0
	lda	rnd0				; 15E1
	rts					; 15E4

rnd0:
	.byte	$64				; 15E5  d
rnd1:
	.byte	$76				; 15E6  v
rnd2:
	.byte	$85				; 15E7  E
rnd3:
	.byte	$54,$F6,$5C,$76,$1F,$E7,$12,$A7	; 15E8  Tv\v_gR'
	.byte	$6B,$93,$C4,$6E			; 15F0  kSDn
rndf:
	.byte	$1B				; 15F4  [

fastrand:
	lda	rnd3				; 15F5
	adc	rnd2				; 15F8
	sta	rnd2				; 15FB
	eor	rnd1				; 15FE
	sta	rnd1				; 1601
	adc	rnd0				; 1604
	sta	rnd0				; 1607
	sta	rnd3				; 160A
	rts					; 160D

console_scroll:
	ldx	#$60				; 160E  `
doscroll:
	lda	bmplineaddr_lo,x		; 1610
	clc					; 1613
	adc	#$C0				; 1614  @
	sta	@scrolldst			; 1616
	lda	bmplineaddr_hi,x		; 1619
	adc	#$00				; 161C  .
	sta	@scrolldst+1			; 161E
	lda	bmplineaddr_lo+8,x		; 1621
	clc					; 1624
	adc	#$C0				; 1625  @
	sta	@scrollsrc			; 1627
	lda	bmplineaddr_hi+8,x		; 162A
	adc	#$00				; 162D  .
	sta	@scrollsrc+1			; 162F
	ldy	#$00				; 1632  .
@scroll:
	.byte	$B9				; 1634  9
@scrollsrc:
	.word	$FFFF				; 1635

	.byte	$99				; 1637  Y
@scrolldst:
	.word	$FFFF				; 1638

	iny					; 163A
	bpl	@scroll				; 163B
	txa					; 163D
	lsr	a				; 163E
	lsr	a				; 163F
	lsr	a				; 1640
	tay					; 1641
	lda	chrlineaddr_lo,y		; 1642
	sta	@scdst				; 1645
	lda	chrlineaddr_hi,y		; 1648
	sta	@scdst+1			; 164B
	lda	chrlineaddr_lo+1,y		; 164E
	sta	@scsrc				; 1651
	lda	chrlineaddr_hi+1,y		; 1654
	sta	@scsrc+1			; 1657
	ldy	#$18				; 165A  X
@scrollchar:
	.byte	$B9				; 165C  9
@scsrc:
	.word	$FFFF				; 165D

	.byte	$99				; 165F  Y
@scdst:
	.word	$FFFF				; 1660

	iny					; 1662
	cpy	#$28				; 1663  (
	bne	@scrollchar			; 1665
	txa					; 1667
	clc					; 1668
	adc	#$08				; 1669  H
	tax					; 166B
	cpx	#$B8				; 166C  8
	bne	doscroll			; 166E
	jsr	drawhoriz			; 1670
	.byte	$18,$17,$20,$20,$20,$20,$20,$20	; 1673  XW      
	.byte	$20,$20,$20,$20,$20,$20,$20,$20	; 167B          
	.byte	$20,$20,$FF			; 1683    .

	rts					; 1686

drawchar:
	sta	charptr				; 1687
	lda	console_ypos			; 1689
	asl	a				; 168B
	asl	a				; 168C
	asl	a				; 168D
	sta	charptr+1			; 168E
	lda	charptr				; 1690
	jsr	mul8				; 1692
	sta	@charsrc			; 1695
	txa					; 1698
	clc					; 1699
	adc	#$E4				; 169A  d
	sta	@charsrc+1			; 169C
	ldy	charptr+1			; 169F
	lda	bmplineaddr_lo,y		; 16A1
	sta	@chardst			; 16A4
	lda	bmplineaddr_hi,y		; 16A7
	sta	@chardst+1			; 16AA
	lda	console_xpos			; 16AD
	jsr	mul8				; 16AF
	clc					; 16B2
	adc	@chardst			; 16B3
	sta	@chardst			; 16B6
	txa					; 16B9
	adc	@chardst+1			; 16BA
	sta	@chardst+1			; 16BD
	ldy	#$07				; 16C0  G
@drawchar:
	.byte	$B9				; 16C2  9
@charsrc:
	.word	$FFFF				; 16C3

	.byte	$99				; 16C5  Y
@chardst:
	.word	$FFFF				; 16C6

	dey					; 16C8
	bpl	@drawchar			; 16C9
	ldy	console_ypos			; 16CB
	lda	chrlineaddr_lo,y		; 16CD
	sta	@charaddr			; 16D0
	lda	chrlineaddr_hi,y		; 16D3
	sta	@charaddr+1			; 16D6
	ldy	charptr				; 16D9
	lda	$E2B0,y				; 16DB
	ldy	console_xpos			; 16DE
	.byte	$99				; 16E0  Y
@charaddr:
	.word	$FFFF				; 16E1

	ldy	#$00				; 16E3  .
	rts					; 16E5

mul8:
	pha					; 16E6
	lda	#$00				; 16E7  .
	sta	@msb				; 16E9
	pla					; 16EC
	asl	a				; 16ED
	rol	@msb				; 16EE
	asl	a				; 16F1
	rol	@msb				; 16F2
	asl	a				; 16F5
	rol	@msb				; 16F6
	ldx	@msb				; 16F9
	rts					; 16FC

@msb:
	.byte	$2C				; 16FD  ,
drawvert:
	lda	#$80				; 16FE  .
	sta	draw_hvflag			; 1700
	jmp	dodrawvh			; 1703

drawhoriz:
	lda	#$00				; 1706  .
	sta	draw_hvflag			; 1708
dodrawvh:
	lda	console_xpos			; 170B
	sta	draw_savex			; 170D
	lda	console_ypos			; 1710
	sta	draw_savey			; 1712
	pla					; 1715
	sta	ptr2				; 1716
	pla					; 1718
	sta	ptr2+1				; 1719
	jsr	@next				; 171B
	ldy	#$00				; 171E  .
	lda	(ptr2),y			; 1720
	sta	console_xpos			; 1722
	jsr	@next				; 1724
	lda	(ptr2),y			; 1727
	sta	console_ypos			; 1729
@draw:
	jsr	@next				; 172B
	lda	(ptr2),y			; 172E
	bmi	@drawdone			; 1730
	jsr	drawchar			; 1732
	bit	draw_hvflag			; 1735
	bmi	@vert				; 1738
	inc	console_xpos			; 173A
	jmp	@draw				; 173C

@vert:
	inc	console_ypos			; 173F
	jmp	@draw				; 1741

@drawdone:
	lda	ptr2+1				; 1744
	pha					; 1746
	lda	ptr2				; 1747
	pha					; 1749
	lda	draw_savex			; 174A
	sta	console_xpos			; 174D
	lda	draw_savey			; 174F
	sta	console_ypos			; 1752
	rts					; 1754

@next:
	inc	ptr2				; 1755
	bne	@gotnext			; 1757
	inc	ptr2+1				; 1759
@gotnext:
	rts					; 175B

draw_hvflag:
	.byte	$00				; 175C  .
draw_savex:
	.byte	$00				; 175D  .
draw_savey:
	.byte	$00				; 175E  .

drawinterface:
	jsr	clearbitmap			; 175F
	jsr	clearchars			; 1762
	jsr	drawhoriz			; 1765
	.byte	$00,$00,$10,$05,$04,$05,$04,$05	; 1768  ..PEDEDE
	.byte	$04,$05,$04,$05,$1E,$20,$20,$1D	; 1770  DEDE^  ]
	.byte	$04,$05,$04,$05,$04,$05,$04,$05	; 1778  DEDEDEDE
	.byte	$04,$01,$04,$05,$04,$05,$04,$05	; 1780  DADEDEDE
	.byte	$04,$05,$04,$05,$04,$05,$04,$05	; 1788  DEDEDEDE
	.byte	$04,$13,$FF			; 1790  DS.

	jsr	drawvert			; 1793
	.byte	$00,$01,$0A,$0A,$0A,$0A,$0A,$0A	; 1796  .AJJJJJJ
	.byte	$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A	; 179E  JJJJJJJJ
	.byte	$0A,$0A,$0A,$0A,$0A,$0A,$0A,$0A	; 17A6  JJJJJJJJ
	.byte	$14,$FF				; 17AE  T.

	jsr	drawhoriz			; 17B0
	.byte	$01,$17,$03,$02,$03,$02,$03,$02	; 17B3  AWCBCBCB
	.byte	$03,$02,$03,$02,$03,$02,$03,$02	; 17BB  CBCBCBCB
	.byte	$03,$02,$03,$02,$03,$02,$03,$02	; 17C3  CBCBCBCB
	.byte	$FF				; 17CB  .

	jsr	drawvert			; 17CC
	.byte	$17,$01,$0D,$0D,$0D,$0D,$0D,$0D	; 17CF  WAMMMMMM
	.byte	$0D,$0D,$09,$0D,$09,$0D,$0D,$0D	; 17D7  MMIMIMMM
	.byte	$0D,$0D,$0D,$0D,$0D,$0D,$0D,$0D	; 17DF  MMMMMMMM
	.byte	$0B,$FF				; 17E7  K.

	jsr	drawvert			; 17E9
	.byte	$27,$01,$09,$09,$09,$09,$09,$09	; 17EC  'AIIIIII
	.byte	$09,$09,$01,$09,$05,$FF		; 17F4  IIAIE.

	jsr	drawhoriz			; 17FA
	.byte	$18,$09,$06,$07,$06,$07,$06,$07	; 17FD  XIFGFGFG
	.byte	$06,$07,$06,$07,$06,$07,$06,$07	; 1805  FGFGFGFG
	.byte	$06,$FF				; 180D  F.

	jsr	drawhoriz			; 180F
	.byte	$18,$0B,$06,$07,$06,$07,$06,$07	; 1812  XKFGFGFG
	.byte	$06,$07,$06,$07,$06,$07,$06,$07	; 181A  FGFGFGFG
	.byte	$06,$FF				; 1822  F.

	rts					; 1824

moon_gfx:
	.byte	$00,$00,$00,$00,$00,$00,$00,$00	; 1825  ........
	.byte	$00,$10,$20,$40,$40,$20,$10,$00	; 182D  .P @@ P.
	.byte	$00,$10,$30,$70,$70,$30,$10,$00	; 1835  .P0pp0P.
	.byte	$00,$18,$38,$7C,$7C,$38,$18,$00	; 183D  .X8||8X.
	.byte	$00,$18,$3C,$7E,$7E,$3C,$18,$00	; 1845  .X<~~<X.
	.byte	$00,$18,$1C,$3E,$3E,$1C,$18,$00	; 184D  .X\>>\X.
	.byte	$00,$08,$0C,$0E,$0E,$0C,$08,$00	; 1855  .HLNNLH.
	.byte	$00,$08,$04,$02,$02,$04,$08,$00	; 185D  .HDBBDH.

update_moons:
	txa					; 1865
	pha					; 1866
	clc					; 1867
	lda	moon_counter			; 1868
	adc	#$40				; 186B  @
	sta	moon_counter			; 186D
	bne	@noupdate			; 1870
	inc	moon_ctr_trammel		; 1872
	inc	moon_ctr_trammel		; 1875
	lda	moon_ctr_trammel		; 1878
	and	#$E0				; 187B  `
	lsr	a				; 187D
	lsr	a				; 187E
	tay					; 187F
	ldx	#$00				; 1880  .
@trammel:
	lda	moon_gfx,y			; 1882
	sta	$2058,x				; 1885
	iny					; 1888
	inx					; 1889
	cpx	#$08				; 188A  H
	bne	@trammel			; 188C
	clc					; 188E
	lda	moon_ctr_felucca		; 188F
	adc	#$06				; 1892  F
	sta	moon_ctr_felucca		; 1894
	and	#$E0				; 1897  `
	lsr	a				; 1899
	lsr	a				; 189A
	tay					; 189B
	pha					; 189C
	ldx	#$00				; 189D  .
@felucca:
	lda	moon_gfx,y			; 189F
	sta	$2060,x				; 18A2
	iny					; 18A5
	inx					; 18A6
	cpx	#$08				; 18A7  H
	bne	@felucca			; 18A9
	pla					; 18AB
	tay					; 18AC
@noupdate:
	pla					; 18AD
	tax					; 18AE
	lda	moon_ctr_trammel		; 18AF
	jsr	div32				; 18B2
	sta	moon_phase_trammel		; 18B5
	lda	moon_ctr_felucca		; 18B7
	jsr	div32				; 18BA
	sta	moon_phase_felucca		; 18BD
	lda	moon_ctr_trammel		; 18BF
	and	#$1F				; 18C2  _
	beq	@moongate_appears		; 18C4
	cmp	#$1E				; 18C6  ^
	beq	@moongate_disappears		; 18C8
	rts					; 18CA

@moongate_appears:
	jsr	moongate_update			; 18CB
	lda	$71				; 18CE
	clc					; 18D0
	adc	#$40				; 18D1  @
	sta	moongate_tile			; 18D3
	rts					; 18D5

@moongate_disappears:
	jsr	moongate_update			; 18D6
	lda	$71				; 18D9
	eor	#$03				; 18DB  C
	clc					; 18DD
	adc	#$40				; 18DE  @
	sta	moongate_tile			; 18E0
	rts					; 18E2

moongate_update:
	lda	moon_ctr_trammel		; 18E3
	and	#$E0				; 18E6  `
	jsr	div32				; 18E8
	tax					; 18EB
	lda	moongate_xtab,x			; 18EC
	sta	moongate_xpos			; 18EF
	lda	moongate_ytab,x			; 18F1
	sta	moongate_ypos			; 18F4
	lda	moon_counter			; 18F6
	and	#$C0				; 18F9  @
	rol	a				; 18FB
	rol	a				; 18FC
	rol	a				; 18FD
	sta	$71				; 18FE
	rts					; 1900

moon_counter:
	.byte	$00				; 1901  .
moon_ctr_trammel:
	.byte	$00				; 1902  .
moon_ctr_felucca:
	.byte	$00				; 1903  .
moongate_xtab:
	.byte	$E0,$60,$26,$32,$A6,$68,$17,$BB	; 1904  ``&2&hW;
moongate_ytab:
	.byte	$85,$66,$E0,$25,$13,$C2,$7E,$A7	; 190C  Ef`%SB~'

request_disk:
	sta	reqdisk				; 1914
@request:
	lda	reqdisk				; 1916
	cmp	#$02				; 1918  B
	beq	@twodrives			; 191A
	cmp	#$04				; 191C  D
	beq	@twodrives			; 191E
@onedrive:
	lda	#$01				; 1920  A
	sta	currdrive			; 1922
	lda	reqdisk				; 1924
	cmp	currdisk_drive1			; 1926
	beq	@checkdisk			; 1928
@askchange:
	jsr	primm				; 192A
	.byte	$8D,$D0,$CC,$C5,$C1,$D3,$C5,$A0	; 192D  MPLEASE 
	.byte	$D0,$CC,$C1,$C3,$C5,$A0,$D4,$C8	; 1935  PLACE TH
	.byte	$C5,$8D,$00			; 193D  EM.

	jsr	askdisk				; 1940
	jsr	primm				; 1943
	.byte	$A0,$C4,$C9,$D3,$CB,$8D,$C9,$CE	; 1946   DISKMIN
	.byte	$D4,$CF,$A0,$C4,$C5,$D6,$C9,$C3	; 194E  TO DEVIC
	.byte	$C5,$A0,$00			; 1956  E .

	lda	currdrive			; 1959
	clc					; 195B
	adc	#$07				; 195C  G
	jsr	printdigit			; 195E
	jsr	primm				; 1961
	.byte	$8D,$C1,$CE,$C4,$A0,$D0,$D2,$C5	; 1964  MAND PRE
	.byte	$D3,$D3,$A0,$DB,$C6,$B1,$DD,$8D	; 196C  SS [F1]M
	.byte	$00				; 1974  .

@wait:
	jsr	waitkey				; 1975
	cmp	#$85				; 1978  E
	bne	@wait				; 197A
	beq	@checkdisk			; 197C
@twodrives:
	lda	numdrives			; 197E
	cmp	#$02				; 1980  B
	bcc	@onedrive			; 1982
	lda	#$02				; 1984  B
	sta	currdrive			; 1986
	lda	reqdisk				; 1988
	cmp	currdisk_drive2			; 198A
	beq	@checkdisk			; 198C
	bne	@askchange			; 198E
@checkdisk:
	lda	currdrive			; 1990
	lda	#$CC				; 1992  L
	ldx	#$00				; 1994  .
	jsr	j_fileio			; 1996
	ldx	currdrive			; 1999
	lda	diskid				; 199B
	sta	numdrives,x			; 199D
	cmp	reqdisk				; 199F
	beq	@done				; 19A1
	jmp	@request			; 19A3

@done:
	rts					; 19A6

askdisk:
	ldx	reqdisk				; 19A7
@program:
	dex					; 19A9
	bne	@britannia			; 19AA
	jsr	primm				; 19AC
	.byte	$D0,$D2,$CF,$C7,$D2,$C1,$CD,$00	; 19AF  PROGRAM.

	rts					; 19B7

@britannia:
	dex					; 19B8
	bne	@towne				; 19B9
	jsr	primm				; 19BB
	.byte	$C2,$D2,$C9,$D4,$C1,$CE,$CE,$C9	; 19BE  BRITANNI
	.byte	$C1,$00				; 19C6  A.

	rts					; 19C8

@towne:
	dex					; 19C9
	bne	@underworld			; 19CA
	jsr	primm				; 19CC
	.byte	$D4,$CF,$D7,$CE,$C5,$00		; 19CF  TOWNE.

	rts					; 19D5

@underworld:
	jsr	primm				; 19D6
	.byte	$D5,$CE,$C4,$C5,$D2,$D7,$CF,$D2	; 19D9  UNDERWOR
	.byte	$CC,$C4,$00			; 19E1  LD.

	rts					; 19E4

playsfx:
	jsr	@play				; 19E5
	lda	#$0F				; 19E8  O
	sta	$D418				; 19EA
	rts					; 19ED

@play:
	asl	a				; 19EE
	tay					; 19EF
	lda	sfxtab+1,y			; 19F0
	pha					; 19F3
	lda	sfxtab,y			; 19F4
	pha					; 19F7
	rts					; 19F8

sfxtab:
	.word	sfx_walk-1			; 19F9
	.word	sfx_error2-1			; 19FB
	.word	sfx_error1-1			; 19FD
	.word	sfx_unknown1-1			; 19FF
	.word	sfx_attack-1			; 1A01
	.word	sfx_unknown2-1			; 1A03
	.word	sfx_player_hits-1		; 1A05
	.word	sfx_monster_hits-1		; 1A07
	.word	sfx_flee-1			; 1A09
	.word	sfx_magic2-1			; 1A0B
	.word	sfx_magic1-1			; 1A0D
	.word	sfx_unknown3-1			; 1A0F
	.word	sfx_unknown4-1			; 1A11

sfx_walk:
	ldy	#$06				; 1A13  F
@repeat:
	jsr	rand				; 1A15
	and	#$3F				; 1A18  ?
	ora	#$20				; 1A1A   
	tax					; 1A1C
@delay:
	dex					; 1A1D
	bne	@delay				; 1A1E
	jsr	j_togglesnd			; 1A20
	dey					; 1A23
	bne	@repeat				; 1A24
	rts					; 1A26

sfx_error2:
	ldy	#$32				; 1A27  2
@delay:
	pha					; 1A29
	pla					; 1A2A
	dex					; 1A2B
	bne	@delay				; 1A2C
	jsr	j_togglesnd			; 1A2E
	dey					; 1A31
	bne	@delay				; 1A32
	rts					; 1A34

sfx_error1:
	ldy	#$32				; 1A35  2
@delay:
	nop					; 1A37
	nop					; 1A38
	dex					; 1A39
	bne	@delay				; 1A3A
	jsr	j_togglesnd			; 1A3C
	dey					; 1A3F
	bne	@delay				; 1A40
	jmp	sfx_error2			; 1A42

sfx_unknown1:
	ldx	#$00				; 1A45  .
	stx	zptmp1				; 1A47
@delay:
	inx					; 1A49
	bne	@delay				; 1A4A
	jsr	j_togglesnd			; 1A4C
	dec	zptmp1				; 1A4F
	ldx	zptmp1				; 1A51
	bne	@delay				; 1A53
	rts					; 1A55

sfx_attack:
	lda	#$FF				; 1A56  .
	tax					; 1A58
	tay					; 1A59
@delay:
	dex					; 1A5A
	bne	@delay				; 1A5B
	jsr	j_togglesnd			; 1A5D
	dey					; 1A60
	tya					; 1A61
	tax					; 1A62
	bmi	@delay				; 1A63
	rts					; 1A65

sfx_unknown2:
	lda	#$80				; 1A66  .
	tax					; 1A68
	tay					; 1A69
@delay:
	dex					; 1A6A
	bne	@delay				; 1A6B
	jsr	j_togglesnd			; 1A6D
	iny					; 1A70
	tya					; 1A71
	tax					; 1A72
	bmi	@delay				; 1A73
	rts					; 1A75

sfx_player_hits:
	ldy	#$FF				; 1A76  .
@repeat:
	jsr	rand				; 1A78
	and	#$7F				; 1A7B  .
	tax					; 1A7D
@delay:
	dex					; 1A7E
	bne	@delay				; 1A7F
	jsr	j_togglesnd			; 1A81
	dey					; 1A84
	bne	@repeat				; 1A85
	rts					; 1A87

sfx_monster_hits:
	ldy	#$FF				; 1A88  .
@repeat:
	jsr	rand				; 1A8A
	ora	#$80				; 1A8D  .
	tax					; 1A8F
@delay:
	dex					; 1A90
	bne	@delay				; 1A91
	jsr	j_togglesnd			; 1A93
	dey					; 1A96
	bne	@repeat				; 1A97
	rts					; 1A99

sfx_magic2:
	stx	sfx_m2_ctr2			; 1A9A
	lda	#$01				; 1A9D  A
	sta	sfx_m2_ctr1			; 1A9F
@1:	lda	#$30				; 1AA2  0
	sta	$70				; 1AA4
@2:	ldx	sfx_m2_ctr2			; 1AA6
@3:	dex					; 1AA9
	bne	@3				; 1AAA
	jsr	j_togglesnd			; 1AAC
	ldx	sfx_m2_ctr1			; 1AAF
@4:	dex					; 1AB2
	bne	@4				; 1AB3
	jsr	j_togglesnd			; 1AB5
	dec	$70				; 1AB8
	bne	@2				; 1ABA
	dec	sfx_m2_ctr2			; 1ABC
	inc	sfx_m2_ctr1			; 1ABF
	lda	sfx_m2_ctr1			; 1AC2
	cmp	#$1B				; 1AC5  [
	bne	@1				; 1AC7
@5:	lda	#$30				; 1AC9  0
	sta	$70				; 1ACB
@6:	ldx	sfx_m2_ctr2			; 1ACD
@7:	dex					; 1AD0
	bne	@7				; 1AD1
	jsr	j_togglesnd			; 1AD3
	ldx	sfx_m2_ctr1			; 1AD6
@8:	dex					; 1AD9
	bne	@8				; 1ADA
	jsr	j_togglesnd			; 1ADC
	dec	$70				; 1ADF
	bne	@6				; 1AE1
	dec	sfx_m2_ctr1			; 1AE3
	inc	sfx_m2_ctr2			; 1AE6
	lda	sfx_m2_ctr1			; 1AE9
	cmp	#$00				; 1AEC  .
	bne	@5				; 1AEE
	rts					; 1AF0

sfx_m2_ctr1:
	brk					; 1AF1
sfx_m2_ctr2:
	brk					; 1AF2
sfx_flee:
	ldx	#$7F				; 1AF3  .
	stx	zptmp1				; 1AF5
@delay:
	dex					; 1AF7
	bne	@delay				; 1AF8
	jsr	j_togglesnd			; 1AFA
	dec	zptmp1				; 1AFD
	ldx	zptmp1				; 1AFF
	bne	@delay				; 1B01
	rts					; 1B03

sfx_magic1:
	stx	$70				; 1B04
@again:
	jsr	rand				; 1B06
	ldx	#$28				; 1B09  (
@repeat:
	tay					; 1B0B
@delay:
	dey					; 1B0C
	bne	@delay				; 1B0D
	jsr	j_togglesnd			; 1B0F
	dex					; 1B12
	bne	@repeat				; 1B13
	dec	$70				; 1B15
	bne	@again				; 1B17
	rts					; 1B19

sfx_unknown3:
	lda	#$40				; 1B1A  @
@1:	ldy	#$20				; 1B1C   
@2:	tax					; 1B1E
@3:	pha					; 1B1F
	pla					; 1B20
	dex					; 1B21
	bne	@3				; 1B22
	jsr	j_togglesnd			; 1B24
	dey					; 1B27
	bne	@2				; 1B28
	clc					; 1B2A
	adc	#$01				; 1B2B  A
	cmp	#$C0				; 1B2D  @
	bcc	@1				; 1B2F
	rts					; 1B31

sfx_unknown4:
	lda	#$C0				; 1B32  @
@1:	ldy	#$20				; 1B34   
@2:	tax					; 1B36
@3:	pha					; 1B37
	pla					; 1B38
	dex					; 1B39
	bne	@3				; 1B3A
	jsr	j_togglesnd			; 1B3C
	dey					; 1B3F
	bne	@2				; 1B40
	sec					; 1B42
	sbc	#$01				; 1B43  A
	cmp	#$40				; 1B45  @
	bcs	@1				; 1B47
	rts					; 1B49

centerstring:
	pha					; 1B4A
	tay					; 1B4B
	lda	#$BA				; 1B4C  :
	sta	ptr1				; 1B4E
	lda	#$1B				; 1B50  [
	sta	ptr1+1				; 1B52
	ldx	#$00				; 1B54  .
	stx	$58				; 1B56
@checkeos:
	lda	(ptr1,x)			; 1B58
	bpl	@endofstr			; 1B5A
@next:
	jsr	nextstrchar			; 1B5C
	jmp	@checkeos			; 1B5F

@endofstr:
	dey					; 1B62
	beq	@foundstr			; 1B63
	jmp	@next				; 1B65

@foundstr:
	jsr	nextstrchar			; 1B68
	ldx	#$00				; 1B6B  .
	lda	(ptr1,x)			; 1B6D
	bpl	@lastchar			; 1B6F
	inc	$58				; 1B71
	jmp	@foundstr			; 1B73

@lastchar:
	inc	$58				; 1B76
	lda	#$0F				; 1B78  O
	sec					; 1B7A
	sbc	$58				; 1B7B
	lsr	a				; 1B7D
	clc					; 1B7E
	adc	console_xpos			; 1B7F
	sta	console_xpos			; 1B81
	pla					; 1B83
printstring:
	tay					; 1B84
	lda	#$BA				; 1B85  :
	sta	ptr1				; 1B87
	lda	#$1B				; 1B89  [
	sta	ptr1+1				; 1B8B
	ldx	#$00				; 1B8D  .
@checkeos:
	lda	(ptr1,x)			; 1B8F
	bpl	@endofstr			; 1B91
@next:
	jsr	nextstrchar			; 1B93
	jmp	@checkeos			; 1B96

@endofstr:
	dey					; 1B99
	beq	@foundstr			; 1B9A
	jmp	@next				; 1B9C

@foundstr:
	jsr	nextstrchar			; 1B9F
	ldx	#$00				; 1BA2  .
	lda	(ptr1,x)			; 1BA4
	bpl	@lastchar			; 1BA6
	jsr	console_out			; 1BA8
	jmp	@foundstr			; 1BAB

@lastchar:
	ora	#$80				; 1BAE  .
	jmp	console_out			; 1BB0

nextstrchar:
	inc	ptr1				; 1BB3
	bne	@nomsb				; 1BB5
	inc	ptr1+1				; 1BB7
@nomsb:
	rts					; 1BB9

strings:
	.byte	$00				; 1BBA  .
@pirate0:
	.byte	$D0,$C9,$D2,$C1,$D4,$45		; 1BBB  PIRATE
@pirate:
	.byte	$D0,$C9,$D2,$C1,$D4,$45		; 1BC1  PIRATE
@nixie:
	.byte	$CE,$C9,$D8,$C9,$45		; 1BC7  NIXIE
@squid:
	.byte	$D3,$D1,$D5,$C9,$44		; 1BCC  SQUID
@serpent:
	.byte	$D3,$C5,$D2,$D0,$C5,$CE,$54	; 1BD1  SERPENT
@seahorse:
	.byte	$D3,$C5,$C1,$C8,$CF,$D2,$D3,$45	; 1BD8  SEAHORSE
@whirlpool:
	.byte	$D7,$C8,$C9,$D2,$CC,$D0,$CF,$CF	; 1BE0  WHIRLPOO
	.byte	$4C				; 1BE8  L
@twister:
	.byte	$D4,$D7,$C9,$D3,$D4,$C5,$52	; 1BE9  TWISTER
@rat:
	.byte	$D2,$C1,$54			; 1BF0  RAT
@bat:
	.byte	$C2,$C1,$54			; 1BF3  BAT
@spider:
	.byte	$D3,$D0,$C9,$C4,$C5,$52		; 1BF6  SPIDER
@ghost:
	.byte	$C7,$C8,$CF,$D3,$54		; 1BFC  GHOST
@slime:
	.byte	$D3,$CC,$C9,$CD,$45		; 1C01  SLIME
@troll:
	.byte	$D4,$D2,$CF,$CC,$4C		; 1C06  TROLL
@gremlin:
	.byte	$C7,$D2,$C5,$CD,$CC,$C9,$4E	; 1C0B  GREMLIN
@mimic:
	.byte	$CD,$C9,$CD,$C9,$43		; 1C12  MIMIC
@reaper:
	.byte	$D2,$C5,$C1,$D0,$C5,$52		; 1C17  REAPER
@insects:
	.byte	$C9,$CE,$D3,$C5,$C3,$D4,$53	; 1C1D  INSECTS
@gazer:
	.byte	$C7,$C1,$DA,$C5,$52		; 1C24  GAZER
@phantom:
	.byte	$D0,$C8,$C1,$CE,$D4,$CF,$4D	; 1C29  PHANTOM
@orc:
	.byte	$CF,$D2,$43			; 1C30  ORC
@skeleton:
	.byte	$D3,$CB,$C5,$CC,$C5,$D4,$CF,$4E	; 1C33  SKELETON
@rogue:
	.byte	$D2,$CF,$C7,$D5,$45		; 1C3B  ROGUE
@python:
	.byte	$D0,$D9,$D4,$C8,$CF,$4E		; 1C40  PYTHON
@ettin:
	.byte	$C5,$D4,$D4,$C9,$4E		; 1C46  ETTIN
@headless:
	.byte	$C8,$C5,$C1,$C4,$CC,$C5,$D3,$53	; 1C4B  HEADLESS
@cyclops:
	.byte	$C3,$D9,$C3,$CC,$CF,$D0,$53	; 1C53  CYCLOPS
@wisp:
	.byte	$D7,$C9,$D3,$50			; 1C5A  WISP
@mage:
	.byte	$CD,$C1,$C7,$45			; 1C5E  MAGE
@liche:
	.byte	$CC,$C9,$C3,$C8,$45		; 1C62  LICHE
@lava_lizard:
	.byte	$CC,$C1,$D6,$C1,$A0,$CC,$C9,$DA	; 1C67  LAVA LIZ
	.byte	$C1,$D2,$44			; 1C6F  ARD
@zorn:
	.byte	$DA,$CF,$D2,$4E			; 1C72  ZORN
@daemon:
	.byte	$C4,$C1,$C5,$CD,$CF,$4E		; 1C76  DAEMON
@hydra:
	.byte	$C8,$D9,$C4,$D2,$41		; 1C7C  HYDRA
@dragon:
	.byte	$C4,$D2,$C1,$C7,$CF,$4E		; 1C81  DRAGON
@balron:
	.byte	$C2,$C1,$CC,$D2,$CF,$4E		; 1C87  BALRON
@hands:
	.byte	$C8,$C1,$CE,$C4,$53		; 1C8D  HANDS
@staff:
	.byte	$D3,$D4,$C1,$C6,$46		; 1C92  STAFF
@dagger:
	.byte	$C4,$C1,$C7,$C7,$C5,$52		; 1C97  DAGGER
@sling:
	.byte	$D3,$CC,$C9,$CE,$47		; 1C9D  SLING
@mace:
	.byte	$CD,$C1,$C3,$45			; 1CA2  MACE
@axe:
	.byte	$C1,$D8,$45			; 1CA6  AXE
@sword:
	.byte	$D3,$D7,$CF,$D2,$44		; 1CA9  SWORD
@bow:
	.byte	$C2,$CF,$57			; 1CAE  BOW
@crossbow:
	.byte	$C3,$D2,$CF,$D3,$D3,$C2,$CF,$57	; 1CB1  CROSSBOW
@flaming_oil:
	.byte	$C6,$CC,$C1,$CD,$C9,$CE,$C7,$A0	; 1CB9  FLAMING 
	.byte	$CF,$C9,$4C			; 1CC1  OIL
@halberd:
	.byte	$C8,$C1,$CC,$C2,$C5,$D2,$44	; 1CC4  HALBERD
@magic_axe:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$C1,$D8	; 1CCB  MAGIC AX
	.byte	$45				; 1CD3  E
@magic_sword:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$D3,$D7	; 1CD4  MAGIC SW
	.byte	$CF,$D2,$44			; 1CDC  ORD
@magic_bow:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$C2,$CF	; 1CDF  MAGIC BO
	.byte	$57				; 1CE7  W
@magic_wand:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$D7,$C1	; 1CE8  MAGIC WA
	.byte	$CE,$44				; 1CF0  ND
@mystic_sword:
	.byte	$CD,$D9,$D3,$D4,$C9,$C3,$A0,$D3	; 1CF2  MYSTIC S
	.byte	$D7,$CF,$D2,$44			; 1CFA  WORD
@skin:
	.byte	$D3,$CB,$C9,$4E			; 1CFE  SKIN
@cloth:
	.byte	$C3,$CC,$CF,$D4,$48		; 1D02  CLOTH
@leather:
	.byte	$CC,$C5,$C1,$D4,$C8,$C5,$52	; 1D07  LEATHER
@chain_mail:
	.byte	$C3,$C8,$C1,$C9,$CE,$A0,$CD,$C1	; 1D0E  CHAIN MA
	.byte	$C9,$4C				; 1D16  IL
@plate_mail:
	.byte	$D0,$CC,$C1,$D4,$C5,$A0,$CD,$C1	; 1D18  PLATE MA
	.byte	$C9,$4C				; 1D20  IL
@magic_chain:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$C3,$C8	; 1D22  MAGIC CH
	.byte	$C1,$C9,$4E			; 1D2A  AIN
@magic_plate:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$D0,$CC	; 1D2D  MAGIC PL
	.byte	$C1,$D4,$45			; 1D35  ATE
@mystic_robe:
	.byte	$CD,$D9,$D3,$D4,$C9,$C3,$A0,$D2	; 1D38  MYSTIC R
	.byte	$CF,$C2,$45			; 1D40  OBE
@hnd:
	.byte	$C8,$CE,$44			; 1D43  HND
@stf:
	.byte	$D3,$D4,$46			; 1D46  STF
@dag:
	.byte	$C4,$C1,$47			; 1D49  DAG
@sln:
	.byte	$D3,$CC,$4E			; 1D4C  SLN
@mac:
	.byte	$CD,$C1,$43			; 1D4F  MAC
@axe:
	.byte	$C1,$D8,$45			; 1D52  AXE
@swd:
	.byte	$D3,$D7,$44			; 1D55  SWD
@bow:
	.byte	$C2,$CF,$57			; 1D58  BOW
@xbo:
	.byte	$D8,$C2,$4F			; 1D5B  XBO
@oil:
	.byte	$CF,$C9,$4C			; 1D5E  OIL
@hal:
	.byte	$C8,$C1,$4C			; 1D61  HAL
@max:
	.byte	$AB,$C1,$58			; 1D64  +AX
@msw:
	.byte	$AB,$D3,$57			; 1D67  +SW
@mbo:
	.byte	$AB,$C2,$4F			; 1D6A  +BO
@wnd:
	.byte	$D7,$CE,$44			; 1D6D  WND
@ysw:
	.byte	$DE,$D3,$57			; 1D70  ^SW
@mage:
	.byte	$CD,$C1,$C7,$45			; 1D73  MAGE
@bard:
	.byte	$C2,$C1,$D2,$44			; 1D77  BARD
@fighter:
	.byte	$C6,$C9,$C7,$C8,$D4,$C5,$52	; 1D7B  FIGHTER
@druid:
	.byte	$C4,$D2,$D5,$C9,$44		; 1D82  DRUID
@tinker:
	.byte	$D4,$C9,$CE,$CB,$C5,$52		; 1D87  TINKER
@paladin:
	.byte	$D0,$C1,$CC,$C1,$C4,$C9,$4E	; 1D8D  PALADIN
@ranger:
	.byte	$D2,$C1,$CE,$C7,$C5,$52		; 1D94  RANGER
@shepherd:
	.byte	$D3,$C8,$C5,$D0,$C8,$C5,$D2,$44	; 1D9A  SHEPHERD
@guard:
	.byte	$C7,$D5,$C1,$D2,$44		; 1DA2  GUARD
@merchant:
	.byte	$CD,$C5,$D2,$C3,$C8,$C1,$CE,$54	; 1DA7  MERCHANT
@bard:
	.byte	$C2,$C1,$D2,$44			; 1DAF  BARD
@jester:
	.byte	$CA,$C5,$D3,$D4,$C5,$52		; 1DB3  JESTER
@beggar:
	.byte	$C2,$C5,$C7,$C7,$C1,$52		; 1DB9  BEGGAR
@child:
	.byte	$C3,$C8,$C9,$CC,$44		; 1DBF  CHILD
@bull:
	.byte	$C2,$D5,$CC,$4C			; 1DC4  BULL
@lord_british:
	.byte	$CC,$CF,$D2,$C4,$A0,$C2,$D2,$C9	; 1DC8  LORD BRI
	.byte	$D4,$C9,$D3,$48			; 1DD0  TISH
@sulfur_ash:
	.byte	$D3,$D5,$CC,$C6,$D5,$D2,$A0,$C1	; 1DD4  SULFUR A
	.byte	$D3,$48				; 1DDC  SH
@ginseng:
	.byte	$C7,$C9,$CE,$D3,$C5,$CE,$47	; 1DDE  GINSENG
@garlic:
	.byte	$C7,$C1,$D2,$CC,$C9,$43		; 1DE5  GARLIC
@spider_silk:
	.byte	$D3,$D0,$C9,$C4,$C5,$D2,$A0,$D3	; 1DEB  SPIDER S
	.byte	$C9,$CC,$4B			; 1DF3  ILK
@blood_moss:
	.byte	$C2,$CC,$CF,$CF,$C4,$A0,$CD,$CF	; 1DF6  BLOOD MO
	.byte	$D3,$53				; 1DFE  SS
@black_pearl:
	.byte	$C2,$CC,$C1,$C3,$CB,$A0,$D0,$C5	; 1E00  BLACK PE
	.byte	$C1,$D2,$4C			; 1E08  ARL
@nightshade:
	.byte	$CE,$C9,$C7,$C8,$D4,$D3,$C8,$C1	; 1E0B  NIGHTSHA
	.byte	$C4,$45				; 1E13  DE
@mandrake:
	.byte	$CD,$C1,$CE,$C4,$D2,$C1,$CB,$45	; 1E15  MANDRAKE
@awaken:
	.byte	$C1,$D7,$C1,$CB,$C5,$4E		; 1E1D  AWAKEN
@blink:
	.byte	$C2,$CC,$C9,$CE,$4B		; 1E23  BLINK
@cure:
	.byte	$C3,$D5,$D2,$45			; 1E28  CURE
@dispell:
	.byte	$C4,$C9,$D3,$D0,$C5,$CC,$4C	; 1E2C  DISPELL
@energy:
	.byte	$C5,$CE,$C5,$D2,$C7,$59		; 1E33  ENERGY
@fireball:
	.byte	$C6,$C9,$D2,$C5,$C2,$C1,$CC,$4C	; 1E39  FIREBALL
@gate:
	.byte	$C7,$C1,$D4,$45			; 1E41  GATE
@heal:
	.byte	$C8,$C5,$C1,$4C			; 1E45  HEAL
@iceball:
	.byte	$C9,$C3,$C5,$C2,$C1,$CC,$4C	; 1E49  ICEBALL
@jinx:
	.byte	$CA,$C9,$CE,$58			; 1E50  JINX
@kill:
	.byte	$CB,$C9,$CC,$4C			; 1E54  KILL
@light:
	.byte	$CC,$C9,$C7,$C8,$54		; 1E58  LIGHT
@magic_misl:
	.byte	$CD,$C1,$C7,$C9,$C3,$A0,$CD,$C9	; 1E5D  MAGIC MI
	.byte	$D3,$4C				; 1E65  SL
@negate:
	.byte	$CE,$C5,$C7,$C1,$D4,$45		; 1E67  NEGATE
@open:
	.byte	$CF,$D0,$C5,$4E			; 1E6D  OPEN
@protection:
	.byte	$D0,$D2,$CF,$D4,$C5,$C3,$D4,$C9	; 1E71  PROTECTI
	.byte	$CF,$4E				; 1E79  ON
@quickness:
	.byte	$D1,$D5,$C9,$C3,$CB,$CE,$C5,$D3	; 1E7B  QUICKNES
	.byte	$53				; 1E83  S
@ressurect:
	.byte	$D2,$C5,$D3,$D3,$D5,$D2,$C5,$C3	; 1E84  RESSUREC
	.byte	$54				; 1E8C  T
@sleep:
	.byte	$D3,$CC,$C5,$C5,$50		; 1E8D  SLEEP
@tremmor:
	.byte	$D4,$D2,$C5,$CD,$CD,$CF,$52	; 1E92  TREMMOR
@undead:
	.byte	$D5,$CE,$C4,$C5,$C1,$44		; 1E99  UNDEAD
@view:
	.byte	$D6,$C9,$C5,$57			; 1E9F  VIEW
@winds:
	.byte	$D7,$C9,$CE,$C4,$53		; 1EA3  WINDS
@xit:
	.byte	$D8,$AD,$C9,$54			; 1EA8  X-IT
@yup:
	.byte	$D9,$AD,$D5,$50			; 1EAC  Y-UP
@zdown:
	.byte	$DA,$AD,$C4,$CF,$D7,$4E		; 1EB0  Z-DOWN
@britannia:
	.byte	$C2,$D2,$C9,$D4,$C1,$CE,$CE,$C9	; 1EB6  BRITANNI
	.byte	$41				; 1EBE  A
@the_lycaeum:
	.byte	$D4,$C8,$C5,$A0,$CC,$D9,$C3,$C1	; 1EBF  THE LYCA
	.byte	$C5,$D5,$4D			; 1EC7  EUM
@empath_abbey:
	.byte	$C5,$CD,$D0,$C1,$D4,$C8,$A0,$C1	; 1ECA  EMPATH A
	.byte	$C2,$C2,$C5,$59			; 1ED2  BBEY
@serpants_hold:
	.byte	$D3,$C5,$D2,$D0,$C1,$CE,$D4,$D3	; 1ED6  SERPANTS
	.byte	$A0,$C8,$CF,$CC,$44		; 1EDE   HOLD
@moonglow:
	.byte	$CD,$CF,$CF,$CE,$C7,$CC,$CF,$57	; 1EE3  MOONGLOW
@britain:
	.byte	$C2,$D2,$C9,$D4,$C1,$C9,$4E	; 1EEB  BRITAIN
@jhelom:
	.byte	$CA,$C8,$C5,$CC,$CF,$4D		; 1EF2  JHELOM
@yew:
	.byte	$D9,$C5,$57			; 1EF8  YEW
@minoc:
	.byte	$CD,$C9,$CE,$CF,$43		; 1EFB  MINOC
@trinsic:
	.byte	$D4,$D2,$C9,$CE,$D3,$C9,$43	; 1F00  TRINSIC
@skara_brae:
	.byte	$D3,$CB,$C1,$D2,$C1,$A0,$C2,$D2	; 1F07  SKARA BR
	.byte	$C1,$45				; 1F0F  AE
@magincia:
	.byte	$CD,$C1,$C7,$C9,$CE,$C3,$C9,$41	; 1F11  MAGINCIA
@paws:
	.byte	$D0,$C1,$D7,$53			; 1F19  PAWS
@buccaneers_den:
	.byte	$C2,$D5,$C3,$C3,$C1,$CE,$C5,$C5	; 1F1D  BUCCANEE
	.byte	$D2,$D3,$A0,$C4,$C5,$4E		; 1F25  RS DEN
@vesper:
	.byte	$D6,$C5,$D3,$D0,$C5,$52		; 1F2B  VESPER
@cove:
	.byte	$C3,$CF,$D6,$45			; 1F31  COVE
@deceit:
	.byte	$C4,$C5,$C3,$C5,$C9,$54		; 1F35  DECEIT
@despise:
	.byte	$C4,$C5,$D3,$D0,$C9,$D3,$45	; 1F3B  DESPISE
@dasterd:
	.byte	$C4,$C1,$D3,$D4,$C5,$D2,$44	; 1F42  DASTERD
@wrong:
	.byte	$D7,$D2,$CF,$CE,$47		; 1F49  WRONG
@covetous:
	.byte	$C3,$CF,$D6,$C5,$D4,$CF,$D5,$53	; 1F4E  COVETOUS
@shame:
	.byte	$D3,$C8,$C1,$CD,$45		; 1F56  SHAME
@hylothe:
	.byte	$C8,$D9,$CC,$CF,$D4,$C8,$45	; 1F5B  HYLOTHE
@the_greatstygian_abyss:
	.byte	$D4,$C8,$C5,$A0,$C7,$D2,$C5,$C1	; 1F62  THE GREA
	.byte	$D4,$8D,$D3,$D4,$D9,$C7,$C9,$C1	; 1F6A  TMSTYGIA
	.byte	$CE,$A0,$C1,$C2,$D9,$D3,$D3	; 1F72  N ABYSS
@honesty:
	.byte	$21,$C8,$CF,$CE,$C5,$D3,$D4	; 1F79  !HONEST
@compassion:
	.byte	$59,$C3,$CF,$CD,$D0,$C1,$D3,$D3	; 1F80  YCOMPASS
	.byte	$C9,$CF				; 1F88  IO
@valor:
	.byte	$4E,$D6,$C1,$CC,$CF		; 1F8A  NVALO
@justice:
	.byte	$52,$CA,$D5,$D3,$D4,$C9,$C3	; 1F8F  RJUSTIC
@sacrifice:
	.byte	$45,$D3,$C1,$C3,$D2,$C9,$C6,$C9	; 1F96  ESACRIFI
	.byte	$C3				; 1F9E  C
@honor:
	.byte	$45,$C8,$CF,$CE,$CF		; 1F9F  EHONO
@spirituality:
	.byte	$52,$D3,$D0,$C9,$D2,$C9,$D4,$D5	; 1FA4  RSPIRITU
	.byte	$C1,$CC,$C9,$D4			; 1FAC  ALIT
@humility:
	.byte	$59,$C8,$D5,$CD,$C9,$CC,$C9,$D4	; 1FB0  YHUMILIT
	.byte	$59				; 1FB8  Y

_garbage:
	.byte	"T3"				; 1FB9  .
	.byte	$0D,$02				; 1FBB  MB
	.byte	";"				; 1FBD  .
	.byte	$0D,$05,$CD,$01			; 1FBE  MEMA
	.byte	"PL"				; 1FC2  .
	.byte	$0D,$03,$99,$00,$0D,$05,$C0,$02	; 1FC4  MCY.ME@B
	.byte	"#8"				; 1FCC  .
	.byte	$0D,$05,$D0,$01			; 1FCE  MEPA
	.byte	"PL"				; 1FD2  .
	.byte	$0D,$02				; 1FD4  MB
	.byte	";"				; 1FD6  .
	.byte	$0D,$0A				; 1FD7  MJ
	.byte	"ROT3	 :"			; 1FD9  .
						; 1FE1
	.byte	$0D,$05,$CF,$02			; 1FE2  MEOB
	.byte	"#0"				; 1FE6  .
	.byte	$0D,$09,$CD,$05			; 1FE8  MIME
	.byte	"(PL),Y"			; 1FEC  ..
	.byte	$0D,$0A,$D0,$01			; 1FF2  MJPA
	.byte	"ROTTEMP"			; 1FF6  .
	.byte	$0D,$03,$9F			; 1FFD  MC_
Valid HTML 4.01 Strict4f.html; generated on Thu Sep 21 17:08:53 2006 by ca65html
uz@cc65.org