5b.s

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


	.setcpu	"6502"


player_xpos	:= $0010
player_ypos	:= $0011
tile_xpos	:= $0012
tile_ypos	:= $0013
map_x		:= $0014
map_y		:= $0015
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
attacking_monster_type:= $0040
attacking_monster_xpos:= $0041
attacking_monster_ypos:= $0042
attacking_monster_terrain:= $0043
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
j_waitkey	:= $0800
j_player_teleport:= $0803
j_move_east	:= $0806
j_move_west	:= $0809
j_move_south	:= $080C
j_move_north	:= $080F
j_drawinterface	:= $0812
j_drawview	:= $0815
j_update_britannia:= $0818
j_primm_xy	:= $081E
j_primm		:= $0821
j_console_out	:= $0824
j_clearbitmap	:= $0827
j_mulax		:= $082A
j_get_stats_ptr	:= $082D
j_printname	:= $0830
j_printbcd	:= $0833
j_drawcursor	:= $0836
j_drawcursor_xy	:= $0839
j_drawvert	:= $083C
j_drawhoriz	:= $083F
j_request_disk	:= $0842
j_update_status	:= $0845
j_blocked_tile	:= $0848
j_idle		:= $084B
j_rand		:= $084E
j_loadsector	:= $0851
j_playsfx	:= $0854
j_idle_combat	:= $0857
j_getnumber	:= $085A
j_getplayernum	:= $085D
j_update_wind	:= $0860
j_animate_view	:= $0863
j_printdigit	:= $0866
j_clearstatwindow:= $0869
j_animate_creatures:= $086C
j_centername	:= $086F
j_print_direction:= $0872
j_clearview	:= $0875
j_invertview	:= $0878
j_centerstring	:= $087B
j_printstring	:= $087E
j_gettile_bounds:= $0881
j_gettile	:= $0884
L0887		:= $0887
L088A		:= $088A
j_gettile_combat:= $088D
L0890		:= $0890
j_gettile_town	:= $0893
j_gettile_dungeon:= $0896
L8800		:= $8800
L8803		:= $8803
L8859		:= $8859
L8C00		:= $8C00
dungeon_update	:= $8C03
L8C06		:= $8C06
L9000		:= $9000
gettile_bounds	:= $9F00
gettile		:= $9F26
mul11		:= $9F49
gettile_combat	:= $9F85
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	$4000				; 3FFE

j_startgate:
	jmp	startgame			; 4000

j_camp_ambushed:
	jmp	camp_ambushed			; 4003

	jmp	dungeon_combat_start		; 4006

startgame:
	lda	#$00				; 4009  .
	jsr	music_ctl			; 400B
	jsr	j_drawinterface			; 400E
	lda	#$0D				; 4011  M
	sta	console_ypos			; 4013
	lda	#$18				; 4015  X
	sta	console_xpos			; 4017
	lda	#$00				; 4019  .
	sta	game_mode			; 401B
	lda	#$25				; 401D  %
	sta	magic_aura			; 401F
	lda	#$02				; 4021  B
	jsr	j_request_disk			; 4023
	lda	party_size			; 4026
	beq	@loadgame			; 4028
	jmp	@gamestarted			; 402A

@loadgame:
	lda	#$CC				; 402D  L
	ldx	#$1A				; 402F  Z
	jsr	j_fileio			; 4031
	lda	party_size			; 4034
	bne	@gotgame			; 4036
	jsr	j_primm				; 4038
	.byte	$8D,$CE,$CF,$A0,$C1,$C3,$D4,$C9	; 403B  MNO ACTI
	.byte	$D6,$C5,$A0,$C7,$C1,$CD,$C5,$A1	; 4043  VE GAME!
	.byte	$8D,$00				; 404B  M.

@nogame:
	jmp	@nogame				; 404D

@gotgame:
	lda	#$CC				; 4050  L
	ldx	#$7F				; 4052  .
	jsr	j_fileio			; 4054
	ldx	#$80				; 4057  .
	jsr	j_fileio			; 4059
@gamestarted:
	lda	#$00				; 405C  .
	sta	$1D				; 405E
	sta	movement_mode			; 4060
	sta	current_location		; 4062
	sta	horse_mode			; 4064
	lda	#$01				; 4066  A
	sta	game_mode			; 4068
	sta	direction			; 406A
	jsr	j_update_status			; 406C
	jsr	j_player_teleport		; 406F
	lda	#$FF				; 4072  .
	sta	music_volume			; 4074
	lda	#$CF				; 4076  O
	jsr	music_ctl			; 4078
game_main:
	jsr	j_idle				; 407B
	jsr	check_triggers			; 407E
	jsr	check_party_alive		; 4081
	bpl	@prompt				; 4084
	jmp	cmd_sleep			; 4086

@prompt:
	jsr	j_primm				; 4089
	.byte	$8D,$1E,$00			; 408C  M^.

	jsr	j_waitkey			; 408F
	cmp	#$00				; 4092  .
	bne	@gotkey				; 4094
	jmp	cmd_pass			; 4096

@gotkey:
	cmp	#$A0				; 4099   
	bne	@north				; 409B
	jmp	cmd_pass			; 409D

@north:
	cmp	#$C0				; 40A0  @
	bne	@south				; 40A2
	jmp	cmd_north			; 40A4

@south:
	cmp	#$AF				; 40A7  /
	bne	@east				; 40A9
	jmp	cmd_south			; 40AB

@east:
	cmp	#$BA				; 40AE  :
	bne	@west				; 40B0
	jmp	cmd_west			; 40B2

@west:
	cmp	#$BB				; 40B5  ;
	bne	@home				; 40B7
	jmp	cmd_east			; 40B9

@home:
	cmp	#$93				; 40BC  S
	bne	@atoz				; 40BE
	jsr	printcr				; 40C0
	lda	#$00				; 40C3  .
	sta	$6A				; 40C5
@printvirtue:
	ldx	$6A				; 40C7
	lda	game_stats,x			; 40C9
	jsr	j_printbcd			; 40CC
	inc	$6A				; 40CF
	lda	$6A				; 40D1
	cmp	#$08				; 40D3  H
	bcc	@printvirtue			; 40D5
	jsr	printcr				; 40D7
	jmp	game_main			; 40DA

@atoz:
	cmp	#$C1				; 40DD  A
	bcc	cmd_unknown			; 40DF
	cmp	#$DB				; 40E1  [
	bcs	cmd_unknown			; 40E3
	sec					; 40E5
	sbc	#$C1				; 40E6  A
	asl	a				; 40E8
	tay					; 40E9
	lda	cmd_jump_table,y		; 40EA
	sta	ptr1				; 40ED
	lda	cmd_jump_table+1,y		; 40EF
	sta	ptr1+1				; 40F2
	jmp	(ptr1)				; 40F4

cmd_sleep:
	jsr	j_primm				; 40F7
	.byte	$8D,$1E,$DA,$FA,$FA,$FA,$FA,$8D	; 40FA  M^ZzzzzM
	.byte	$00				; 4102  .

	jmp	cmd_done			; 4103

cmd_pass:
	jsr	j_primm				; 4106
	.byte	$D0,$E1,$F3,$F3,$8D,$00		; 4109  PassM.

	jmp	cmd_done			; 410F

cmd_unknown:
	jsr	j_primm				; 4112
	.byte	$D7,$C8,$C1,$D4,$BF,$8D,$00	; 4115  WHAT?M.

cmd_error:
	lda	#$02				; 411C  B
	jsr	j_playsfx			; 411E
	jmp	cmd_done			; 4121

print_not_a_player:
	jsr	j_primm				; 4124
	.byte	$CE,$CF,$D4,$A0,$C1,$A0,$D0,$CC	; 4127  NOT A PL
	.byte	$C1,$D9,$C5,$D2,$A1,$8D,$00	; 412F  AYER!M.

	jmp	cmd_done			; 4136

print_only_on_foot:
	jsr	j_primm				; 4139
	.byte	$CF,$CE,$CC,$D9,$A0,$CF,$CE,$A0	; 413C  ONLY ON 
	.byte	$C6,$CF,$CF,$D4,$A1,$8D,$00	; 4144  FOOT!M.

	jmp	cmd_error			; 414B

print_nothing_there:
	jsr	j_primm				; 414E
	.byte	$CE,$CF,$D4,$C8,$C9,$CE,$C7,$A0	; 4151  NOTHING 
	.byte	$D4,$C8,$C5,$D2,$C5,$A1,$8D,$00	; 4159  THERE!M.

	jmp	cmd_done			; 4161

print_slow_progress:
	jsr	j_primm				; 4164
	.byte	$D3,$CC,$CF,$D7,$A0,$D0,$D2,$CF	; 4167  SLOW PRO
	.byte	$C7,$D2,$C5,$D3,$D3,$A1,$8D,$00	; 416F  GRESS!M.

	rts					; 4177

print_not_here:
	jsr	j_primm				; 4178
	.byte	$CE,$CF,$D4,$A0,$C8,$C5,$D2,$C5	; 417B  NOT HERE
	.byte	$A1,$8D,$00			; 4183  !M.

	jmp	cmd_done			; 4186

print_cant:
	jsr	j_primm				; 4189
	.byte	$C3,$C1,$CE,$A7,$D4,$A1,$8D,$00	; 418C  CAN'T!M.

	jmp	cmd_done			; 4194

print_aborted:
	jsr	j_primm				; 4197
	.byte	$C1,$C2,$CF,$D2,$D4,$C5,$C4,$A1	; 419A  ABORTED!
	.byte	$8D,$00				; 41A2  M.

	jmp	cmd_done			; 41A4

print_done:
	jsr	j_update_status			; 41A7
	jsr	j_primm				; 41AA
	.byte	$C4,$CF,$CE,$C5,$AE,$8D,$00	; 41AD  DONE.M.

	jmp	cmd_done			; 41B4

print_you_have_none:
	jsr	j_primm				; 41B7
	.byte	$D9,$CF,$D5,$A0,$C8,$C1,$D6,$C5	; 41BA  YOU HAVE
	.byte	$A0,$CE,$CF,$CE,$C5,$A1,$8D,$00	; 41C2   NONE!M.

	jmp	cmd_done			; 41CA

print_disabled:
	jsr	j_primm				; 41CD
	.byte	$C4,$C9,$D3,$C1,$C2,$CC,$C5,$C4	; 41D0  DISABLED
	.byte	$A1,$8D,$00			; 41D8  !M.

	jmp	cmd_done			; 41DB

move_blocked:
	jsr	j_primm				; 41DE
	.byte	$C2,$CC,$CF,$C3,$CB,$C5,$C4,$A1	; 41E1  BLOCKED!
	.byte	$8D,$00				; 41E9  M.

	lda	#$01				; 41EB  A
	jsr	j_playsfx			; 41ED
	lda	#$00				; 41F0  .
	sta	key_buf_len			; 41F2
	jmp	cmd_done			; 41F4

print_drift_only:
	jsr	j_primm				; 41F7
	.byte	$C4,$D2,$C9,$C6,$D4,$A0,$CF,$CE	; 41FA  DRIFT ON
	.byte	$CC,$D9,$A1,$8D,$00		; 4202  LY!M.

	jmp	cmd_done			; 4207

cmd_jump_table:
	.addr	cmd_attack			; 420A
	.addr	cmd_board			; 420C
	.addr	cmd_cast			; 420E
	.addr	cmd_descend			; 4210
	.addr	cmd_enter			; 4212
	.addr	cmd_fire			; 4214
	.addr	cmd_get_chest			; 4216
	.addr	cmd_hole_up_and_camp		; 4218
	.addr	cmd_ignite			; 421A
	.addr	cmd_jimmy_lock			; 421C
	.addr	cmd_klimb			; 421E
	.addr	cmd_locate			; 4220
	.addr	cmd_mix_reagents		; 4222
	.addr	cmd_new_order			; 4224
	.addr	cmd_open			; 4226
	.addr	cmd_peer_at_gem			; 4228
	.addr	cmd_quit_and_save		; 422A
	.addr	cmd_ready_weapon		; 422C
	.addr	cmd_search			; 422E
	.addr	cmd_talk			; 4230
	.addr	cmd_use				; 4232
	.addr	cmd_volume			; 4234
	.addr	cmd_wear_armor			; 4236
	.addr	cmd_xit				; 4238
	.addr	cmd_yell			; 423A
	.addr	cmd_ztats			; 423C

cmd_north:
	lda	game_mode			; 423E
	cmp	#$03				; 4240  C
	bne	@balloon			; 4242
	jmp	cmd_forward			; 4244

@balloon:
	lda	player_transport		; 4247
	cmp	#$18				; 4249  X
	bne	@shipnorth			; 424B
	jmp	print_drift_only		; 424D

@shipnorth:
	cmp	#$11				; 4250  Q
	bne	@shipother			; 4252
	jmp	@checkshipmove			; 4254

@shipother:
	cmp	#$10				; 4257  P
	beq	@turnship			; 4259
	cmp	#$12				; 425B  R
	beq	@turnship			; 425D
	cmp	#$13				; 425F  S
	beq	@turnship			; 4261
	lda	#$00				; 4263  .
	jsr	j_playsfx			; 4265
	jsr	print_north			; 4268
	lda	horse_mode			; 426B
	beq	@nohorse			; 426D
	jsr	@checkblock			; 426F
	jsr	j_idle				; 4272
@nohorse:
	jsr	@checkblock			; 4275
	jmp	cmd_done			; 4278

@turnship:
	lda	#$11				; 427B  Q
	sta	player_transport		; 427D
	jsr	print_turn			; 427F
	jsr	print_north			; 4282
	jmp	cmd_done			; 4285

@checkshipmove:
	jsr	print_sail			; 4288
	jsr	print_north			; 428B
	lda	tile_north			; 428E
	jsr	check_sailable			; 4290
	bpl	@shipnotblocked			; 4293
	jmp	move_blocked			; 4295

@shipnotblocked:
	lda	#$01				; 4298  A
	jsr	check_wind_direction		; 429A
	beq	@moveship			; 429D
	jsr	print_slow_progress		; 429F
	jmp	cmd_done			; 42A2

@moveship:
	jsr	j_move_north			; 42A5
	jmp	cmd_done			; 42A8

@checkblock:
	lda	tile_under_player		; 42AB
	cmp	#$0E				; 42AD  N
	beq	@blocked			; 42AF
	lda	tile_north			; 42B1
	cmp	#$0E				; 42B3  N
	beq	@notblocked			; 42B5
	jsr	j_blocked_tile			; 42B7
	bpl	@notblocked			; 42BA
@blocked:
	pla					; 42BC
	pla					; 42BD
	jmp	move_blocked			; 42BE

@notblocked:
	lda	tile_north			; 42C1
	jsr	check_slow_progress		; 42C3
	beq	@notslow			; 42C6
	jsr	print_slow_progress		; 42C8
	jmp	@done				; 42CB

@notslow:
	lda	#$00				; 42CE  .
	jsr	j_playsfx			; 42D0
	lda	game_mode			; 42D3
	cmp	#$01				; 42D5  A
	bne	@checkexit			; 42D7
	jsr	j_move_north			; 42D9
	lda	tile_north			; 42DC
	jmp	check_moongate			; 42DE

@checkexit:
	dec	player_ypos			; 42E1
	lda	player_ypos			; 42E3
	bpl	@done				; 42E5
	pla					; 42E7
	pla					; 42E8
	jmp	exit_location			; 42E9

@done:
	rts					; 42EC

cmd_forward:
	jsr	j_primm				; 42ED
	.byte	$C1,$E4,$F6,$E1,$EE,$E3,$E5,$8D	; 42F0  AdvanceM
	.byte	$00				; 42F8  .

	lda	tile_north			; 42F9
	jsr	dng_check_forward_block		; 42FB
	bpl	@notblocked			; 42FE
	jmp	move_blocked			; 4300

@notblocked:
	ldx	dng_direction			; 4303
dng_move:
	clc					; 4305
	lda	player_xpos			; 4306
	adc	dng_move_deltax,x		; 4308
	and	#$07				; 430B  G
	sta	player_xpos			; 430D
	clc					; 430F
	lda	player_ypos			; 4310
	adc	dng_move_deltay,x		; 4312
	and	#$07				; 4315  G
	sta	player_ypos			; 4317
	jmp	cmd_done			; 4319

dng_move_deltax:
	.byte	$00,$01,$00,$FF			; 431C  .A..
dng_move_deltay:
	.byte	$FF,$00,$01,$00			; 4320  ..A.

cmd_south:
	lda	game_mode			; 4324
	cmp	#$03				; 4326  C
	bne	@balloon			; 4328
	jsr	j_primm				; 432A
	.byte	$D2,$E5,$F4,$F2,$E5,$E1,$F4,$8D	; 432D  RetreatM
	.byte	$00				; 4335  .

	lda	tile_west			; 4336
	jsr	dng_check_retreat_block		; 4338
	bpl	@retreat			; 433B
	jmp	move_blocked			; 433D

@retreat:
	lda	dng_direction			; 4340
	eor	#$02				; 4342  B
	tax					; 4344
	jmp	dng_move			; 4345

@balloon:
	lda	player_transport		; 4348
	cmp	#$18				; 434A  X
	bne	@shipsouth			; 434C
	jmp	print_drift_only		; 434E

@shipsouth:
	cmp	#$13				; 4351  S
	bne	@shipother			; 4353
	jmp	@checkshipmove			; 4355

@shipother:
	cmp	#$12				; 4358  R
	beq	@turnship			; 435A
	cmp	#$10				; 435C  P
	beq	@turnship			; 435E
	cmp	#$11				; 4360  Q
	beq	@turnship			; 4362
	lda	#$00				; 4364  .
	jsr	j_playsfx			; 4366
	jsr	print_south			; 4369
	lda	horse_mode			; 436C
	beq	@nohorse			; 436E
	jsr	@checkblock			; 4370
	jsr	j_idle				; 4373
@nohorse:
	jsr	@checkblock			; 4376
	lda	player_xpos			; 4379
	cmp	#$E5				; 437B  e
	bcc	@notisleofabyss			; 437D
	cmp	#$EA				; 437F  j
	bcs	@notisleofabyss			; 4381
	lda	player_ypos			; 4383
	cmp	#$D4				; 4385  T
	bcc	@notisleofabyss			; 4387
	cmp	#$D9				; 4389  Y
	bcs	@notisleofabyss			; 438B
	jmp	generate_daemons		; 438D

@notisleofabyss:
	jmp	cmd_done			; 4390

@turnship:
	lda	#$13				; 4393  S
	sta	player_transport		; 4395
	jsr	print_turn			; 4397
	jsr	print_south			; 439A
	jmp	cmd_done			; 439D

@checkshipmove:
	jsr	print_sail			; 43A0
	jsr	print_south			; 43A3
	lda	tile_south			; 43A6
	jsr	check_sailable			; 43A8
	bpl	@shipnotblocked			; 43AB
	jmp	move_blocked			; 43AD

@shipnotblocked:
	lda	#$03				; 43B0  C
	jsr	check_wind_direction		; 43B2
	beq	@moveship			; 43B5
	jsr	print_slow_progress		; 43B7
	jmp	cmd_done			; 43BA

@moveship:
	jsr	j_move_south			; 43BD
	jmp	cmd_done			; 43C0

@checkblock:
	lda	tile_south			; 43C3
	jsr	j_blocked_tile			; 43C5
	bpl	@notblocked			; 43C8
	pla					; 43CA
	pla					; 43CB
	jmp	move_blocked			; 43CC

@notblocked:
	lda	tile_south			; 43CF
	jsr	check_slow_progress		; 43D1
	beq	@notslow			; 43D4
	jsr	print_slow_progress		; 43D6
	jmp	@done				; 43D9

@notslow:
	lda	#$00				; 43DC  .
	jsr	j_playsfx			; 43DE
	lda	game_mode			; 43E1
	cmp	#$01				; 43E3  A
	bne	@checkexit			; 43E5
	jsr	j_move_south			; 43E7
	lda	tile_south			; 43EA
	jmp	check_moongate			; 43EC

@checkexit:
	inc	player_ypos			; 43EF
	lda	player_ypos			; 43F1
	cmp	#$20				; 43F3   
	bcc	@done				; 43F5
	pla					; 43F7
	pla					; 43F8
	jmp	exit_location			; 43F9

@done:
	rts					; 43FC

cmd_west:
	lda	game_mode			; 43FD
	cmp	#$03				; 43FF  C
	bne	@balloon			; 4401
	jsr	print_turn			; 4403
	jsr	j_primm				; 4406
	.byte	$EC,$E5,$E6,$F4,$8D,$00		; 4409  leftM.

	sec					; 440F
	lda	dng_direction			; 4410
	sbc	#$01				; 4412  A
	and	#$03				; 4414  C
	sta	dng_direction			; 4416
	jsr	L8C00				; 4418
	jsr	j_print_direction		; 441B
	jmp	game_main			; 441E

@balloon:
	lda	player_transport		; 4421
	cmp	#$18				; 4423  X
	bne	@shipwest			; 4425
	jmp	print_drift_only		; 4427

@shipwest:
	cmp	#$10				; 442A  P
	bne	@shipother			; 442C
	jmp	@checkshipmove			; 442E

@shipother:
	cmp	#$11				; 4431  Q
	beq	@turnship			; 4433
	cmp	#$13				; 4435  S
	beq	@turnship			; 4437
	cmp	#$12				; 4439  R
	beq	@turnship			; 443B
	cmp	#$15				; 443D  U
	bne	@notturnhorse			; 443F
	lda	#$14				; 4441  T
	sta	player_transport		; 4443
@notturnhorse:
	lda	#$00				; 4445  .
	jsr	j_playsfx			; 4447
	jsr	print_west			; 444A
	lda	horse_mode			; 444D
	beq	@nohorse			; 444F
	jsr	@checkblock			; 4451
	jsr	j_idle				; 4454
@nohorse:
	jsr	@checkblock			; 4457
	jmp	cmd_done			; 445A

@turnship:
	lda	#$10				; 445D  P
	sta	player_transport		; 445F
	jsr	print_turn			; 4461
	jsr	print_west			; 4464
	jmp	cmd_done			; 4467

@checkshipmove:
	jsr	print_sail			; 446A
	jsr	print_west			; 446D
	lda	tile_west			; 4470
	jsr	check_sailable			; 4472
	bpl	@shipnotblocked			; 4475
	jmp	move_blocked			; 4477

@shipnotblocked:
	lda	#$00				; 447A  .
	jsr	check_wind_direction		; 447C
	beq	@moveship			; 447F
	jsr	print_slow_progress		; 4481
	jmp	cmd_done			; 4484

@moveship:
	jsr	j_move_west			; 4487
	jmp	cmd_done			; 448A

@checkblock:
	lda	tile_west			; 448D
	jsr	j_blocked_tile			; 448F
	bpl	@notblocked			; 4492
	pla					; 4494
	pla					; 4495
	jmp	move_blocked			; 4496

@notblocked:
	lda	tile_west			; 4499
	jsr	check_slow_progress		; 449B
	beq	@notslow			; 449E
	jsr	print_slow_progress		; 44A0
	jmp	@done				; 44A3

@notslow:
	lda	#$00				; 44A6  .
	jsr	j_playsfx			; 44A8
	lda	game_mode			; 44AB
	cmp	#$01				; 44AD  A
	bne	@checkexit			; 44AF
	jsr	j_move_west			; 44B1
	lda	tile_west			; 44B4
	jmp	check_moongate			; 44B6

@checkexit:
	dec	player_xpos			; 44B9
	lda	player_xpos			; 44BB
	bpl	@done				; 44BD
	pla					; 44BF
	pla					; 44C0
	jmp	exit_location			; 44C1

@done:
	rts					; 44C4

cmd_east:
	lda	game_mode			; 44C5
	cmp	#$03				; 44C7  C
	bne	@balloon			; 44C9
	jsr	print_turn			; 44CB
	jsr	j_primm				; 44CE
	.byte	$F2,$E9,$E7,$E8,$F4,$8D,$00	; 44D1  rightM.

	clc					; 44D8
	lda	dng_direction			; 44D9
	adc	#$01				; 44DB  A
	and	#$03				; 44DD  C
	sta	dng_direction			; 44DF
	jsr	L8C00				; 44E1
	jsr	j_print_direction		; 44E4
	jmp	game_main			; 44E7

@balloon:
	lda	player_transport		; 44EA
	cmp	#$18				; 44EC  X
	bne	@shipeast			; 44EE
	jmp	print_drift_only		; 44F0

@shipeast:
	cmp	#$12				; 44F3  R
	bne	@shipother			; 44F5
	jmp	@checkshipmove			; 44F7

@shipother:
	cmp	#$11				; 44FA  Q
	beq	@turnship			; 44FC
	cmp	#$13				; 44FE  S
	beq	@turnship			; 4500
	cmp	#$10				; 4502  P
	beq	@turnship			; 4504
	cmp	#$14				; 4506  T
	bne	@notturnhorse			; 4508
	lda	#$15				; 450A  U
	sta	player_transport		; 450C
@notturnhorse:
	lda	#$00				; 450E  .
	jsr	j_playsfx			; 4510
	jsr	print_east			; 4513
	lda	horse_mode			; 4516
	beq	@nohorse			; 4518
	jsr	@checkblock			; 451A
	jsr	j_idle				; 451D
@nohorse:
	jsr	@checkblock			; 4520
	jmp	cmd_done			; 4523

@turnship:
	jsr	print_turn			; 4526
	jsr	print_east			; 4529
	lda	#$12				; 452C  R
	sta	player_transport		; 452E
	jmp	cmd_done			; 4530

@checkshipmove:
	jsr	print_sail			; 4533
	jsr	print_east			; 4536
	lda	tile_east			; 4539
	jsr	check_sailable			; 453B
	bpl	@shipnotblocked			; 453E
	jmp	move_blocked			; 4540

@shipnotblocked:
	lda	#$02				; 4543  B
	jsr	check_wind_direction		; 4545
	beq	@moveship			; 4548
	jsr	print_slow_progress		; 454A
	jmp	cmd_done			; 454D

@moveship:
	jsr	j_move_east			; 4550
	lda	player_xpos			; 4553
	cmp	#$DD				; 4555  ]
	bne	@notmouthofabyss		; 4557
	lda	player_ypos			; 4559
	cmp	#$E0				; 455B  `
	bne	@notmouthofabyss		; 455D
	jmp	generate_pirates		; 455F

@notmouthofabyss:
	jmp	cmd_done			; 4562

@checkblock:
	lda	tile_east			; 4565
	jsr	j_blocked_tile			; 4567
	bpl	@notblocked			; 456A
	pla					; 456C
	pla					; 456D
	jmp	move_blocked			; 456E

@notblocked:
	lda	tile_east			; 4571
	jsr	check_slow_progress		; 4573
	beq	@notslow			; 4576
	jsr	print_slow_progress		; 4578
	jmp	@done				; 457B

@notslow:
	lda	#$00				; 457E  .
	jsr	j_playsfx			; 4580
	lda	game_mode			; 4583
	cmp	#$01				; 4585  A
	bne	@checkexit			; 4587
	jsr	j_move_east			; 4589
	lda	tile_east			; 458C
	jmp	check_moongate			; 458E

@checkexit:
	inc	player_xpos			; 4591
	lda	player_xpos			; 4593
	cmp	#$20				; 4595   
	bcc	@done				; 4597
	pla					; 4599
	pla					; 459A
	jmp	exit_location			; 459B

@done:
	rts					; 459E

print_turn:
	jsr	j_primm				; 459F
	.byte	$D4,$F5,$F2,$EE,$A0,$00		; 45A2  Turn .

	rts					; 45A8

print_sail:
	jsr	j_primm				; 45A9
	.byte	$D3,$E1,$E9,$EC,$A0,$00		; 45AC  Sail .

	rts					; 45B2

generate_pirates:
	ldy	#$07				; 45B3  G
@next:
	lda	pirate_xpos,y			; 45B5
	sta	object_xpos,y			; 45B8
	lda	pirate_ypos,y			; 45BB
	sta	object_ypos,y			; 45BE
	lda	#$80				; 45C1  .
	sta	object_tile,y			; 45C3
	lda	pirate_tile,y			; 45C6
	sta	map_status,y			; 45C9
	dey					; 45CC
	bpl	@next				; 45CD
	jmp	cmd_done			; 45CF

pirate_xpos:
	.byte	$E0,$E0,$E2,$E3,$E4,$E5,$E5,$E4	; 45D2  ``bcdeed
pirate_ypos:
	.byte	$DC,$E4,$DC,$E4,$E3,$E1,$DF,$DE	; 45DA  \d\dca_^
pirate_tile:
	.byte	$82,$82,$82,$82,$83,$83,$81,$81	; 45E2  BBBBCCAA

generate_daemons:
	lda	magic_aura			; 45EA
	cmp	#$5F				; 45EC  _
	beq	@done				; 45EE
	ldy	#$07				; 45F0  G
@next:
	lda	#$F0				; 45F2  p
	sta	object_tile,y			; 45F4
	sta	map_status,y			; 45F7
	lda	#$E7				; 45FA  g
	sta	object_xpos,y			; 45FC
	lda	player_ypos			; 45FF
	clc					; 4601
	adc	#$01				; 4602  A
	sta	object_ypos,y			; 4604
	dey					; 4607
	bpl	@next				; 4608
@done:
	jmp	cmd_done			; 460A

exit_location:
	lda	#$00				; 460D  .
	jsr	music_ctl			; 460F
	jsr	j_primm				; 4612
	.byte	$CC,$C5,$C1,$D6,$C9,$CE,$C7,$AE	; 4615  LEAVING.
	.byte	$AE,$AE,$8D,$00			; 461D  ..M.

	jsr	j_clearkbd			; 4621
	lda	#$00				; 4624  .
	sta	game_mode			; 4626
	lda	#$02				; 4628  B
	jsr	j_request_disk			; 462A
	lda	#$CC				; 462D  L
	ldx	#$7E				; 462F  ~
	jsr	j_fileio			; 4631
	lda	$18				; 4634
	sta	player_xpos			; 4636
	lda	$19				; 4638
	sta	player_ypos			; 463A
	jsr	j_player_teleport		; 463C
	lda	#$01				; 463F  A
	sta	game_mode			; 4641
	lda	#$00				; 4643  .
	sta	current_location		; 4645
	lda	player_xpos			; 4647
	cmp	#$EF				; 4649  o
	bne	@nothythloth			; 464B
	lda	player_ypos			; 464D
	cmp	#$F0				; 464F  p
	bne	@nothythloth			; 4651
	lda	#$18				; 4653  X
	sta	$AC7F				; 4655
	sta	$AC1F				; 4658
	lda	#$E9				; 465B  i
	sta	$AC3F				; 465D
	lda	#$F2				; 4660  r
	sta	$AC5F				; 4662
@nothythloth:
	jsr	j_update_britannia		; 4665
	lda	#$CF				; 4668  O
	jsr	music_ctl			; 466A
	lda	#$00				; 466D  .
	sta	key_buf_len			; 466F
	jmp	cmd_done			; 4671

check_slow_progress:
	cmp	#$03				; 4674  C
	beq	slow_one_in_four		; 4676
	cmp	#$05				; 4678  E
	beq	slow_one_in_eight		; 467A
	cmp	#$06				; 467C  F
	beq	slow_one_in_four		; 467E
	cmp	#$07				; 4680  G
	beq	slow_one_in_two			; 4682
	cmp	#$46				; 4684  F
	beq	slow_one_in_two			; 4686
notslow:
	lda	#$00				; 4688  .
	rts					; 468A

slow:
	lda	#$FF				; 468B  .
	rts					; 468D

slow_one_in_eight:
	jsr	j_rand				; 468E
	and	#$07				; 4691  G
	beq	slow				; 4693
	bne	notslow				; 4695
slow_one_in_four:
	jsr	j_rand				; 4697
	and	#$03				; 469A  C
	beq	slow				; 469C
	bne	notslow				; 469E
slow_one_in_two:
	jsr	j_rand				; 46A0
	and	#$01				; 46A3  A
	beq	notslow				; 46A5
	bne	slow				; 46A7
check_sailable:
	cmp	#$02				; 46A9  B
	bcc	@sailable			; 46AB
	cmp	#$8C				; 46AD  L
	bcc	@blocked			; 46AF
	cmp	#$90				; 46B1  P
	bcs	@blocked			; 46B3
@sailable:
	lda	#$00				; 46B5  .
	rts					; 46B7

@blocked:
	lda	#$FF				; 46B8  .
	rts					; 46BA

cmd_attack:
	jsr	j_primm				; 46BB
	.byte	$C1,$F4,$F4,$E1,$E3,$EB,$AD,$00	; 46BE  Attack-.

	lda	game_mode			; 46C6
	cmp	#$03				; 46C8  C
	bne	@notdungeon			; 46CA
	jmp	cmd_unknown			; 46CC

@notdungeon:
	jsr	getdirection			; 46CF
	bne	@gotdir				; 46D2
	jmp	cmd_pass			; 46D4

@gotdir:
	jsr	find_creature			; 46D7
	bpl	@gotcreature			; 46DA
@nothinghere:
	jmp	print_nothing_there		; 46DC

@gotcreature:
	stx	$58				; 46DF
	lda	object_tile,x			; 46E1
	cmp	#$8C				; 46E4  L
	beq	@nothinghere			; 46E6
	cmp	#$8E				; 46E8  N
	beq	@nothinghere			; 46EA
	lda	game_mode			; 46EC
	cmp	#$02				; 46EE  B
	bne	@nottowne			; 46F0
	ldx	#$1F				; 46F2  _
@townecheck:
	lda	object_tile,x			; 46F4
	cmp	#$50				; 46F7  P
	beq	@invincible			; 46F9
	cmp	#$5E				; 46FB  ^
	bne	@townenext			; 46FD
@invincible:
	lda	#$FF				; 46FF  .
	sta	$ACC0,x				; 4701
	lda	#$00				; 4704  .
	sta	$ACE0,x				; 4706
@townenext:
	dex					; 4709
	bpl	@townecheck			; 470A
@nottowne:
	lda	game_mode			; 470C
	cmp	#$02				; 470E  B
	beq	@losekarma			; 4710
	ldx	$58				; 4712
	lda	object_tile,x			; 4714
	jsr	check_evil			; 4717
	bmi	prepare_combat			; 471A
@losekarma:
	ldy	#$01				; 471C  A
	lda	#$05				; 471E  E
	jsr	virtue_dec			; 4720
	ldy	#$03				; 4723  C
	lda	#$03				; 4725  C
	jsr	virtue_dec			; 4727
	ldy	#$05				; 472A  E
	lda	#$03				; 472C  C
	jsr	virtue_dec			; 472E
prepare_combat:
	ldx	$58				; 4731
	lda	object_tile,x			; 4733
	sta	attacking_monster_type		; 4736
	lda	object_xpos,x			; 4738
	sta	attacking_monster_xpos		; 473B
	sta	$7A				; 473D
	lda	object_ypos,x			; 473F
	sta	attacking_monster_ypos		; 4742
	sta	$7B				; 4744
	lda	game_mode			; 4746
	cmp	#$01				; 4748  A
	bne	@notbritannia			; 474A
	jsr	j_gettile_bounds		; 474C
	sta	attacking_monster_terrain	; 474F
	jmp	@deletecreature			; 4751

@notbritannia:
	jsr	j_gettile_town			; 4754
	sta	attacking_monster_terrain	; 4757
@deletecreature:
	lda	#$00				; 4759  .
	ldx	$58				; 475B
	sta	object_tile,x			; 475D
	sta	map_status,x			; 4760
	sta	$ACC0,x				; 4763
	jmp	generate_combat			; 4766

cmd_board:
	lda	player_transport		; 4769
	cmp	#$1F				; 476B  _
	beq	@onfoot				; 476D
	jsr	j_primm				; 476F
	.byte	$C2,$EF,$E1,$F2,$E4,$A0,$BC,$AD	; 4772  Board <-
	.byte	$00				; 477A  .

	jmp	print_cant			; 477B

@onfoot:
	lda	tile_under_player		; 477E
	cmp	#$14				; 4780  T
	beq	board_horse			; 4782
	cmp	#$15				; 4784  U
	beq	board_horse			; 4786
	jsr	j_primm				; 4788
	.byte	$C2,$EF,$E1,$F2,$E4,$A0,$00	; 478B  Board .

	lda	tile_under_player		; 4792
	cmp	#$10				; 4794  P
	beq	@ship				; 4796
	cmp	#$11				; 4798  Q
	beq	@ship				; 479A
	cmp	#$12				; 479C  R
	beq	@ship				; 479E
	cmp	#$13				; 47A0  S
	beq	@ship				; 47A2
	cmp	#$18				; 47A4  X
	bne	@unknown			; 47A6
	jmp	board_balloon			; 47A8

@unknown:
	jmp	cmd_unknown			; 47AB

@ship:
	lda	#$10				; 47AE  P
	jsr	board_find_object		; 47B0
	jsr	j_primm				; 47B3
	.byte	$E6,$F2,$E9,$E7,$E1,$F4,$E5,$A1	; 47B6  frigate!
	.byte	$8D,$00				; 47BE  M.

	lda	player_xpos			; 47C0
	cmp	player_ship_xpos		; 47C2
	bne	@newship			; 47C5
	lda	player_ypos			; 47C7
	cmp	player_ship_ypos		; 47C9
	bne	@newship			; 47CC
	jmp	cmd_done			; 47CE

@newship:
	lda	#$50				; 47D1  P
	sta	ship_hull			; 47D3
	jmp	cmd_done			; 47D5

player_ship_xpos:
	.byte	$00				; 47D8  .
player_ship_ypos:
	.byte	$00				; 47D9  .

board_horse:
	lda	#$14				; 47DA  T
	jsr	board_find_object		; 47DC
	jsr	j_primm				; 47DF
	.byte	$CD,$EF,$F5,$EE,$F4,$A0,$E8,$EF	; 47E2  Mount ho
	.byte	$F2,$F3,$E5,$A1,$8D,$00		; 47EA  rse!M.

	jmp	cmd_done			; 47F0

board_balloon:
	lda	#$18				; 47F3  X
	jsr	board_find_object		; 47F5
	jsr	j_primm				; 47F8
	.byte	$E2,$E1,$EC,$EC,$EF,$EF,$EE,$8D	; 47FB  balloonM
	.byte	$00				; 4803  .

	lda	#$00				; 4804  .
	sta	movement_mode			; 4806
	jmp	cmd_done			; 4808

board_find_object:
	sta	$58				; 480B
	ldx	#$1F				; 480D  _
@checkobject:
	lda	object_tile,x			; 480F
	and	#$FC				; 4812  |
	cmp	$58				; 4814
	bne	@next				; 4816
	lda	object_xpos,x			; 4818
	cmp	player_xpos			; 481B
	bne	@next				; 481D
	lda	object_ypos,x			; 481F
	cmp	player_ypos			; 4822
	beq	@foundobject			; 4824
@next:
	dex					; 4826
	cpx	#$08				; 4827  H
	bcs	@checkobject			; 4829
	bcc	@noobject			; 482B
@foundobject:
	lda	#$00				; 482D  .
	sta	object_tile,x			; 482F
	sta	map_status,x			; 4832
@noobject:
	lda	tile_under_player		; 4835
	sta	player_transport		; 4837
	rts					; 4839

cmd_cast:
	jsr	j_primm				; 483A
	.byte	$C3,$E1,$F3,$F4,$A0,$F3,$F0,$E5	; 483D  Cast spe
	.byte	$EC,$EC,$BA,$8D,$F0,$EC,$E1,$F9	; 4845  ll:Mplay
	.byte	$E5,$F2,$AD,$00			; 484D  er-.

	jsr	j_getplayernum			; 4851
	bne	@checknum			; 4854
@none:
	jmp	print_not_a_player		; 4856

@checknum:
	cmp	party_size			; 4859
	beq	@gotplayer			; 485B
	bcs	@none				; 485D
@gotplayer:
	sta	currplayer			; 485F
	jsr	check_awake			; 4861
	bpl	@playerok			; 4864
	jmp	print_disabled			; 4866

@playerok:
	jsr	list_mixtures			; 4869
	jsr	j_primm				; 486C
	.byte	$D3,$D0,$C5,$CC,$CC,$AD,$00	; 486F  SPELL-.

	jsr	getandprintkey			; 4876
	pha					; 4879
	jsr	j_clearstatwindow		; 487A
	jsr	j_update_status			; 487D
	lda	game_mode			; 4880
	bpl	@notcombat			; 4882
	jsr	invert_player_line		; 4884
@notcombat:
	pla					; 4887
	sec					; 4888
	sbc	#$C1				; 4889  A
	cmp	#$1A				; 488B  Z
	bcc	@validspell			; 488D
	jmp	cmd_unknown			; 488F

@validspell:
	sta	@currspell			; 4892
	clc					; 4895
	adc	#$65				; 4896  e
	jsr	j_printstring			; 4898
	jsr	j_primm				; 489B
	.byte	$A1,$8D,$00			; 489E  !M.

	ldy	@currspell			; 48A1
	lda	mixtures,y			; 48A4
	bne	@havemixed			; 48A7
	jmp	print_you_have_none		; 48A9

@havemixed:
	sed					; 48AC
	sec					; 48AD
	sbc	#$01				; 48AE  A
	sta	mixtures,y			; 48B0
	cld					; 48B3
	jsr	j_get_stats_ptr			; 48B4
	ldy	#$16				; 48B7  V
	lda	(ptr1),y			; 48B9
	ldx	@currspell			; 48BB
	sed					; 48BE
	sec					; 48BF
	sbc	@mpcost,x			; 48C0
	cld					; 48C3
	bcs	@decmp				; 48C4
	jsr	j_primm				; 48C6
	.byte	$CD,$AE,$D0,$AE,$A0,$D4,$CF,$CF	; 48C9  M.P. TOO
	.byte	$A0,$CC,$CF,$D7,$A1,$8D,$00	; 48D1   LOW!M.

	jmp	spell_failed			; 48D8

@decmp:
	sta	(ptr1),y			; 48DB
	lda	@currspell			; 48DD
	asl	a				; 48E0
	tay					; 48E1
	lda	@spelljumptable,y		; 48E2
	sta	ptr1				; 48E5
	lda	@spelljumptable+1,y		; 48E7
	sta	ptr1+1				; 48EA
	jmp	(ptr1)				; 48EC

@currspell:
	.byte	$00				; 48EF  .

@spelljumptable:
	.addr	spell_awaken			; 48F0
	.addr	spell_blink			; 48F2
	.addr	spell_cure			; 48F4
	.addr	spell_dispel			; 48F6
	.addr	spell_energyfield		; 48F8
	.addr	spell_fireball			; 48FA
	.addr	spell_gate			; 48FC
	.addr	spell_heal			; 48FE
	.addr	spell_iceball			; 4900
	.addr	spell_jinx			; 4902
	.addr	spell_kill			; 4904
	.addr	spell_light			; 4906
	.addr	spell_magicmissle		; 4908
	.addr	spell_negate			; 490A
	.addr	spell_open			; 490C
	.addr	spell_protect			; 490E
	.addr	spell_quick			; 4910
	.addr	spell_resurrect			; 4912
	.addr	spell_sleep			; 4914
	.addr	spell_tremor			; 4916
	.addr	spell_undead			; 4918
	.addr	spell_view			; 491A
	.addr	spell_winds			; 491C
	.addr	spell_xit			; 491E
	.addr	spell_yup			; 4920
	.addr	spell_zdown			; 4922

@mpcost:
	.byte	$05,$15,$05,$20,$10,$15,$40,$10	; 4924  EUE PU@P
	.byte	$20,$30,$25,$05,$05,$20,$05,$15	; 492C   0%EE EU
	.byte	$20,$45,$15,$30,$15,$15,$10,$15	; 4934   EU0UUPU
	.byte	$10,$05				; 493C  PE

spell_awaken:
	jsr	j_primm				; 493E
	.byte	$D7,$C8,$CF,$AD,$00		; 4941  WHO-.

	jsr	j_getplayernum			; 4946
	bne	@gotnum				; 4949
@fail:
	jmp	spell_failed			; 494B

@gotnum:
	jsr	spell_play_effect		; 494E
	jsr	j_get_stats_ptr			; 4951
	ldy	#$12				; 4954  R
	lda	(ptr1),y			; 4956
	cmp	#$D3				; 4958  S
	bne	@fail				; 495A
	lda	#$C7				; 495C  G
	sta	(ptr1),y			; 495E
	lda	game_mode			; 4960
	bpl	@notcombat			; 4962
	jsr	something_based_on_status_and_class; 4964
	ldx	currplayer			; 4967
	sta	$AD9F,x				; 4969
@notcombat:
	jmp	print_done			; 496C

spell_blink:
	lda	player_transport		; 496F
	cmp	#$14				; 4971  T
	bcs	@notinship			; 4973
@fail:
	jmp	spell_failed			; 4975

@notinship:
	jsr	spell_ensure_outdoors		; 4978
	jsr	print_direction			; 497B
	jsr	getdirection			; 497E
	jsr	spell_play_effect		; 4981
	lda	player_xpos			; 4984
	and	player_ypos			; 4986
	cmp	#$C0				; 4988  @
	bcc	@notnearabyss			; 498A
	jmp	spell_failed			; 498C

@notnearabyss:
	jsr	@incdist			; 498F
	cmp	#$FF				; 4992  .
	bne	@notnearabyss			; 4994
@next:
	jsr	@decdist			; 4996
	cmp	#$FF				; 4999  .
	beq	@fail				; 499B
	jsr	j_blocked_tile			; 499D
	bmi	@next				; 49A0
	lda	$7A				; 49A2
	sta	player_xpos			; 49A4
	lda	$7B				; 49A6
	sta	player_ypos			; 49A8
	jsr	music_nop			; 49AA
	jsr	j_player_teleport		; 49AD
	jmp	print_done			; 49B0

@incdist:
	clc					; 49B3
	lda	$7A				; 49B4
	adc	$78				; 49B6
	sta	$7A				; 49B8
	clc					; 49BA
	lda	$7B				; 49BB
	adc	$79				; 49BD
	sta	$7B				; 49BF
	jsr	j_gettile_bounds		; 49C1
	rts					; 49C4

@decdist:
	sec					; 49C5
	lda	$7A				; 49C6
	sbc	$78				; 49C8
	sta	$7A				; 49CA
	sec					; 49CC
	lda	$7B				; 49CD
	sbc	$79				; 49CF
	sta	$7B				; 49D1
	jsr	j_gettile_bounds		; 49D3
	rts					; 49D6

spell_cure:
	jsr	j_primm				; 49D7
	.byte	$D7,$C8,$B0,$AD,$00		; 49DA  WH0-.

	jsr	j_getplayernum			; 49DF
	bne	@gotnum				; 49E2
@fail:
	jmp	spell_failed			; 49E4

@gotnum:
	jsr	spell_play_effect		; 49E7
	jsr	j_get_stats_ptr			; 49EA
	ldy	#$12				; 49ED  R
	lda	(ptr1),y			; 49EF
	cmp	#$D0				; 49F1  P
	bne	@fail				; 49F3
	lda	#$C7				; 49F5  G
	sta	(ptr1),y			; 49F7
	jmp	print_done			; 49F9

spell_dispel:
	lda	game_mode			; 49FC
	cmp	#$03				; 49FE  C
	beq	@dungeon			; 4A00
	jsr	print_direction			; 4A02
	lda	game_mode			; 4A05
	bmi	@combat				; 4A07
	cmp	#$01				; 4A09  A
	bne	@towne				; 4A0B
	beq	@britannia			; 4A0D
@fail:
	jmp	spell_failed			; 4A0F

@britannia:
	jsr	getdirection			; 4A12
	beq	@fail				; 4A15
	jsr	spell_play_effect		; 4A17
	jsr	j_gettile_bounds		; 4A1A
@checktile:
	cmp	#$44				; 4A1D  D
	bcc	@fail				; 4A1F
	cmp	#$48				; 4A21  H
	bcs	@fail				; 4A23
	lda	tile_under_player		; 4A25
	sta	(ptr2),y			; 4A27
	jmp	print_done			; 4A29

@towne:
	jsr	getdirection			; 4A2C
	beq	@fail				; 4A2F
	jsr	spell_play_effect		; 4A31
	jsr	j_gettile_town			; 4A34
	jmp	@checktile			; 4A37

@combat:
	jsr	combat_getdirection		; 4A3A
	beq	@fail				; 4A3D
	jsr	spell_play_effect		; 4A3F
	jsr	j_gettile_combat		; 4A42
	sta	tile_under_player		; 4A45
	clc					; 4A47
	lda	$16				; 4A48
	adc	$78				; 4A4A
	sta	$16				; 4A4C
	clc					; 4A4E
	lda	$17				; 4A4F
	adc	$79				; 4A51
	sta	$17				; 4A53
	jsr	j_gettile_combat		; 4A55
	cmp	#$44				; 4A58  D
	bcc	@fail				; 4A5A
	cmp	#$48				; 4A5C  H
	bcs	@fail				; 4A5E
	lda	tile_under_player		; 4A60
	sta	tempmap,y			; 4A62
	jmp	print_done			; 4A65

@dungeon:
	jsr	spell_play_effect		; 4A68
	clc					; 4A6B
	ldx	dng_direction			; 4A6C
	lda	player_xpos			; 4A6E
	adc	dng_move_deltax,x		; 4A70
	sta	$16				; 4A73
	clc					; 4A75
	lda	player_ypos			; 4A76
	adc	dng_move_deltay,x		; 4A78
	sta	$17				; 4A7B
	jsr	j_gettile_dungeon		; 4A7D
	and	#$F0				; 4A80  p
	cmp	#$A0				; 4A82   
	bne	@fail				; 4A84
	lda	#$00				; 4A86  .
	sta	(ptr1),y			; 4A88
	jmp	print_done			; 4A8A

spell_energyfield:
	jsr	j_primm				; 4A8D
	.byte	$D4,$D9,$D0,$C5,$AD,$00		; 4A90  TYPE-.

	jsr	getandprintkey			; 4A96
	ldx	#$44				; 4A99  D
	cmp	#$D0				; 4A9B  P
	beq	@gottype			; 4A9D
	inx					; 4A9F
	cmp	#$CC				; 4AA0  L
	beq	@gottype			; 4AA2
	inx					; 4AA4
	cmp	#$C6				; 4AA5  F
	beq	@gottype			; 4AA7
	inx					; 4AA9
	cmp	#$D3				; 4AAA  S
	beq	@gottype			; 4AAC
@fail:
	jmp	spell_failed			; 4AAE

@gottype:
	stx	$6A				; 4AB1
	lda	game_mode			; 4AB3
	bmi	@combat				; 4AB5
	cmp	#$03				; 4AB7  C
	bne	@fail				; 4AB9
	jsr	spell_play_effect		; 4ABB
	ldx	dng_direction			; 4ABE
	clc					; 4AC0
	lda	player_xpos			; 4AC1
	adc	dng_move_deltax,x		; 4AC3
	sta	$16				; 4AC6
	clc					; 4AC8
	lda	player_ypos			; 4AC9
	adc	dng_move_deltay,x		; 4ACB
	sta	$17				; 4ACE
	jsr	j_gettile_dungeon		; 4AD0
	bne	@fail				; 4AD3
	lda	$6A				; 4AD5
	and	#$03				; 4AD7  C
	ora	#$A0				; 4AD9   
	sta	(ptr1),y			; 4ADB
	jmp	print_done			; 4ADD

@combat:
	jsr	print_direction			; 4AE0
	jsr	combat_getdirection		; 4AE3
	beq	@fail				; 4AE6
	clc					; 4AE8
	lda	$16				; 4AE9
	adc	$78				; 4AEB
	sta	$16				; 4AED
	cmp	#$0B				; 4AEF  K
	bcs	@fail				; 4AF1
	clc					; 4AF3
	lda	$17				; 4AF4
	adc	$79				; 4AF6
	sta	$17				; 4AF8
	cmp	#$0B				; 4AFA  K
	bcs	@fail				; 4AFC
	jsr	spell_play_effect		; 4AFE
	jsr	j_gettile_combat		; 4B01
	jsr	j_blocked_tile			; 4B04
	bmi	@fail				; 4B07
	lda	$6A				; 4B09
	sta	tempmap,y			; 4B0B
	jmp	print_done			; 4B0E

spell_fireball:
	jsr	spell_ensure_combat		; 4B11
	jsr	print_direction			; 4B14
	jsr	combat_getdirection		; 4B17
	bne	@gotdir				; 4B1A
@fail:
	lda	#$00				; 4B1C  .
	sta	missile				; 4B1E
	jmp	spell_failed			; 4B21

@gotdir:
	jsr	spell_play_effect		; 4B24
	lda	#$4F				; 4B27  O
	sta	missile				; 4B29
spell_shoot_missile:
	lda	$16				; 4B2C
	sta	missile_xpos			; 4B2E
	lda	$17				; 4B31
	sta	missile_ypos			; 4B33
@again:
	jsr	combat_fire_missile		; 4B36
	bmi	@fail				; 4B39
	jsr	j_idle_combat			; 4B3B
	jsr	combat_find_monster		; 4B3E
	bmi	@again				; 4B41
	lda	#$06				; 4B43  F
	jsr	j_playsfx			; 4B45
	lda	missile				; 4B48
	cmp	#$4D				; 4B4B  M
	beq	@magic_missile			; 4B4D
	cmp	#$4E				; 4B4F  N
	beq	@iceball			; 4B51
	cmp	#$4F				; 4B53  O
	beq	@fireball			; 4B55
	lda	#$E8				; 4B57  h
	jmp	@gotdmg				; 4B59

@fireball:
	lda	#$80				; 4B5C  .
	jsr	randmax				; 4B5E
	ora	#$18				; 4B61  X
	jmp	@gotdmg				; 4B63

@iceball:
	lda	#$E0				; 4B66  `
	jsr	randmax				; 4B68
	ora	#$20				; 4B6B   
	jmp	@gotdmg				; 4B6D

@magic_missile:
	lda	#$40				; 4B70  @
	jsr	randmax				; 4B72
	ora	#$10				; 4B75  P
@gotdmg:
	ldx	#$00				; 4B77  .
	stx	missile				; 4B79
	sta	$5C				; 4B7C
	jsr	hurt_monster			; 4B7E
	jmp	print_done			; 4B81

spell_gate:
	lda	player_transport		; 4B84
	cmp	#$14				; 4B86  T
	bcc	@fail				; 4B88
	lda	game_mode			; 4B8A
	cmp	#$01				; 4B8C  A
	beq	@print_to_phase			; 4B8E
	jmp	spell_ensure_outdoors		; 4B90

@print_to_phase:
	jsr	j_primm				; 4B93
	.byte	$D4,$CF,$A0,$D0,$C8,$C1,$D3,$C5	; 4B96  TO PHASE
	.byte	$AD,$00				; 4B9E  -.

	jsr	getandprintkey			; 4BA0
	sec					; 4BA3
	sbc	#$B1				; 4BA4  1
	cmp	#$08				; 4BA6  H
	bcc	@gotphase			; 4BA8
@fail:
	jmp	spell_failed			; 4BAA

@gotphase:
	sta	$6A				; 4BAD
	jsr	spell_play_effect		; 4BAF
	ldx	$6A				; 4BB2
	lda	moongate_xpos,x			; 4BB4
	sta	player_xpos			; 4BB7
	lda	moongate_ypos,x			; 4BB9
	sta	player_ypos			; 4BBC
	jsr	music_nop			; 4BBE
	jsr	j_player_teleport		; 4BC1
	jmp	print_done			; 4BC4

moongate_xpos:
	.byte	$E0,$60,$26,$32,$A6,$68,$17,$BB	; 4BC7  ``&2&hW;
moongate_ypos:
	.byte	$85,$66,$E0,$25,$13,$C2,$7E,$A7	; 4BCF  Ef`%SB~'

spell_heal:
	jsr	j_primm				; 4BD7
	.byte	$D7,$C8,$CF,$AD,$00		; 4BDA  WHO-.

	jsr	j_getplayernum			; 4BDF
	bne	@gotplayer			; 4BE2
@fail:
	jmp	spell_failed			; 4BE4

@gotplayer:
	jsr	spell_play_effect		; 4BE7
	jsr	check_alive			; 4BEA
	bmi	@fail				; 4BED
	lda	#$19				; 4BEF  Y
	jsr	randmax				; 4BF1
	clc					; 4BF4
	adc	#$4B				; 4BF5  K
	jsr	hextobcd			; 4BF7
	jsr	stat_add_hp			; 4BFA
	jmp	print_done			; 4BFD

spell_iceball:
	jsr	spell_ensure_combat		; 4C00
	jsr	print_direction			; 4C03
	jsr	combat_getdirection		; 4C06
	bne	@gotdir				; 4C09
	jmp	spell_failed			; 4C0B

@gotdir:
	jsr	spell_play_effect		; 4C0E
	lda	#$4E				; 4C11  N
	sta	missile				; 4C13
	jmp	spell_shoot_missile		; 4C16

spell_jinx:
	jsr	spell_play_effect		; 4C19
	lda	#$CA				; 4C1C  J
spell_set_aura:
	sta	magic_aura			; 4C1E
	lda	#$0A				; 4C20  J
	sta	aura_duration			; 4C22
	jmp	print_done			; 4C24

spell_kill:
	jsr	spell_ensure_combat		; 4C27
	jsr	print_direction			; 4C2A
	jsr	combat_getdirection		; 4C2D
	bne	@gotdir				; 4C30
	jmp	spell_failed			; 4C32

@gotdir:
	jsr	spell_play_effect		; 4C35
	lda	#$8C				; 4C38  L
	sta	missile				; 4C3A
	jmp	spell_shoot_missile		; 4C3D

spell_light:
	jsr	spell_play_effect		; 4C40
	lda	#$64				; 4C43  d
	sta	light_duration			; 4C45
	lda	game_mode			; 4C47
	cmp	#$03				; 4C49  C
	bne	@notdungeon			; 4C4B
	jsr	L8C06				; 4C4D
@notdungeon:
	jmp	print_done			; 4C50

spell_magicmissle:
	jsr	spell_ensure_combat		; 4C53
	jsr	print_direction			; 4C56
	jsr	combat_getdirection		; 4C59
	bne	@gotdir				; 4C5C
	jmp	spell_failed			; 4C5E

@gotdir:
	jsr	spell_play_effect		; 4C61
	lda	#$4D				; 4C64  M
	sta	missile				; 4C66
	jmp	spell_shoot_missile		; 4C69

spell_negate:
	jsr	spell_play_effect		; 4C6C
	lda	#$CE				; 4C6F  N
	jmp	spell_set_aura			; 4C71

spell_open:
	jsr	spell_play_effect		; 4C74
	lda	game_mode			; 4C77
	bmi	@combat				; 4C79
	lda	#$00				; 4C7B  .
	sta	currplayer			; 4C7D
	jmp	get_chest			; 4C7F

@combat:
	jmp	combat_open_chest		; 4C82

spell_protect:
	jsr	spell_play_effect		; 4C85
	lda	#$D0				; 4C88  P
	jmp	spell_set_aura			; 4C8A

spell_quick:
	jsr	spell_play_effect		; 4C8D
	lda	#$D1				; 4C90  Q
	jmp	spell_set_aura			; 4C92

spell_resurrect:
	lda	game_mode			; 4C95
	bpl	L4C9C				; 4C97
L4C99:
	jmp	spell_failed			; 4C99

L4C9C:
	jsr	j_primm				; 4C9C
	.byte	$D7,$C8,$CF,$AD,$00		; 4C9F  WHO-.

	jsr	j_getplayernum			; 4CA4
	bne	L4CAC				; 4CA7
	jmp	spell_failed			; 4CA9

L4CAC:
	jsr	spell_play_effect		; 4CAC
	jsr	j_get_stats_ptr			; 4CAF
	ldy	#$12				; 4CB2  R
	lda	(ptr1),y			; 4CB4
	cmp	#$C4				; 4CB6  D
	beq	L4CBD				; 4CB8
	jmp	spell_failed			; 4CBA

L4CBD:
	lda	#$C7				; 4CBD  G
	sta	(ptr1),y			; 4CBF
	jmp	print_done			; 4CC1

spell_sleep:
	jsr	spell_ensure_combat		; 4CC4
	jsr	spell_play_effect		; 4CC7
	ldx	#$0F				; 4CCA  O
L4CCC:
	lda	cbt_monster_type,x		; 4CCC
	beq	L4CE7				; 4CCF
	jsr	L4ECD				; 4CD1
	beq	L4CE7				; 4CD4
	cmp	#$FC				; 4CD6  |
	beq	L4CE7				; 4CD8
	jsr	j_rand				; 4CDA
	cmp	monster_hp,x			; 4CDD
	bcc	L4CE7				; 4CE0
	lda	#$01				; 4CE2  A
	sta	$AD70,x				; 4CE4
L4CE7:
	dex					; 4CE7
	bpl	L4CCC				; 4CE8
	jmp	print_done			; 4CEA

spell_tremor:
	jsr	spell_ensure_combat		; 4CED
	jsr	spell_play_effect		; 4CF0
	jsr	shake_screen			; 4CF3
	ldx	#$0F				; 4CF6  O
L4CF8:
	lda	cbt_monster_type,x		; 4CF8
	beq	L4D42				; 4CFB
	cmp	#$5E				; 4CFD  ^
	beq	L4D42				; 4CFF
	lda	monster_hp,x			; 4D01
	cmp	#$C0				; 4D04  @
	bcs	L4D42				; 4D06
	jsr	j_rand				; 4D08
	bmi	L4D19				; 4D0B
	and	#$01				; 4D0D  A
	bne	L4D42				; 4D0F
	lda	#$17				; 4D11  W
	sta	monster_hp,x			; 4D13
	jmp	L4D42				; 4D16

L4D19:
	stx	$6A				; 4D19
	lda	monster_xpos,x			; 4D1B
	sta	missile_xpos			; 4D1E
	lda	monster_ypos,x			; 4D21
	sta	missile_ypos			; 4D24
	lda	#$4F				; 4D27  O
	sta	missile				; 4D29
	jsr	j_idle_combat			; 4D2C
	lda	#$06				; 4D2F  F
	jsr	j_playsfx			; 4D31
	lda	#$00				; 4D34  .
	sta	missile				; 4D36
	lda	#$FF				; 4D39  .
	sta	$5C				; 4D3B
	jsr	hurt_monster			; 4D3D
	ldx	$6A				; 4D40
L4D42:
	dex					; 4D42
	bpl	L4CF8				; 4D43
	jmp	print_done			; 4D45

spell_undead:
	jsr	spell_ensure_combat		; 4D48
	jsr	spell_play_effect		; 4D4B
	ldx	#$0F				; 4D4E  O
L4D50:
	lda	cbt_monster_type,x		; 4D50
	jsr	L4ECD				; 4D53
	bne	L4D62				; 4D56
	jsr	j_rand				; 4D58
	bmi	L4D62				; 4D5B
	lda	#$17				; 4D5D  W
	sta	monster_hp,x			; 4D5F
L4D62:
	dex					; 4D62
	bpl	L4D50				; 4D63
	jmp	print_done			; 4D65

spell_view:
	lda	game_mode			; 4D68
	bpl	L4D6F				; 4D6A
	jmp	L4C99				; 4D6C

L4D6F:
	jsr	spell_play_effect		; 4D6F
	jsr	L57E8				; 4D72
	jmp	print_done			; 4D75

spell_winds:
	jsr	spell_ensure_outdoors		; 4D78
	jsr	print_direction			; 4D7B
	jsr	getdirection			; 4D7E
	bne	L4D86				; 4D81
	jmp	spell_failed			; 4D83

L4D86:
	jsr	spell_play_effect		; 4D86
	lda	$78				; 4D89
	bne	L4D9B				; 4D8B
	lda	$79				; 4D8D
	bpl	L4D96				; 4D8F
	lda	#$01				; 4D91  A
	jmp	L4DA4				; 4D93

L4D96:
	lda	#$03				; 4D96  C
	jmp	L4DA4				; 4D98

L4D9B:
	bpl	L4DA2				; 4D9B
	lda	#$00				; 4D9D  .
	jmp	L4DA4				; 4D9F

L4DA2:
	lda	#$02				; 4DA2  B
L4DA4:
	sta	direction			; 4DA4
	jmp	print_done			; 4DA6

spell_xit:
	jsr	spell_ensure_dungeon		; 4DA9
	jsr	spell_play_effect		; 4DAC
	jmp	exit_location			; 4DAF

spell_yup:
	jsr	spell_ensure_dungeon		; 4DB2
	jsr	spell_play_effect		; 4DB5
	jsr	L4E2C				; 4DB8
	dec	dungeon_level			; 4DBB
	bpl	L4DC2				; 4DBD
	jmp	exit_location			; 4DBF

L4DC2:
	lda	#$20				; 4DC2   
	sta	$70				; 4DC4
L4DC6:
	jsr	j_rand				; 4DC6
	and	#$07				; 4DC9  G
	sta	$16				; 4DCB
	jsr	j_rand				; 4DCD
	and	#$07				; 4DD0  G
	sta	$17				; 4DD2
	jsr	j_gettile_dungeon		; 4DD4
	beq	L4DE2				; 4DD7
	dec	$70				; 4DD9
	bne	L4DC6				; 4DDB
	inc	dungeon_level			; 4DDD
	jmp	spell_failed			; 4DDF

L4DE2:
	lda	$16				; 4DE2
	sta	player_xpos			; 4DE4
	lda	$17				; 4DE6
	sta	player_ypos			; 4DE8
	jmp	print_done			; 4DEA

spell_zdown:
	jsr	spell_ensure_dungeon		; 4DED
	jsr	spell_play_effect		; 4DF0
	jsr	L4E2C				; 4DF3
	lda	dungeon_level			; 4DF6
	cmp	#$07				; 4DF8  G
	bcc	L4DFF				; 4DFA
	jsr	spell_failed			; 4DFC
L4DFF:
	inc	dungeon_level			; 4DFF
	lda	#$20				; 4E01   
	sta	$70				; 4E03
L4E05:
	jsr	j_rand				; 4E05
	and	#$07				; 4E08  G
	sta	$16				; 4E0A
	jsr	j_rand				; 4E0C
	and	#$07				; 4E0F  G
	sta	$17				; 4E11
	jsr	j_gettile_dungeon		; 4E13
	beq	L4E21				; 4E16
	dec	$70				; 4E18
	bne	L4E05				; 4E1A
	dec	dungeon_level			; 4E1C
	jmp	spell_failed			; 4E1E

L4E21:
	lda	$16				; 4E21
	sta	player_xpos			; 4E23
	lda	$17				; 4E25
	sta	player_ypos			; 4E27
	jmp	print_done			; 4E29

L4E2C:
	lda	current_location		; 4E2C
	cmp	#$18				; 4E2E  X
	bne	L4E37				; 4E30
	pla					; 4E32
	pla					; 4E33
	jmp	spell_failed			; 4E34

L4E37:
	rts					; 4E37

spell_ensure_dungeon:
	lda	game_mode			; 4E38
	cmp	#$03				; 4E3A  C
	beq	@dungeon			; 4E3C
	jsr	j_primm				; 4E3E
	.byte	$C4,$D5,$CE,$C7,$C5,$CF,$CE,$A0	; 4E41  DUNGEON 
	.byte	$CF,$CE,$CC,$D9,$A1,$8D,$00	; 4E49  ONLY!M.

	pla					; 4E50
	pla					; 4E51
	jmp	spell_failed			; 4E52

@dungeon:
	rts					; 4E55

spell_ensure_combat:
	lda	game_mode			; 4E56
	bmi	@combat				; 4E58
	jsr	j_primm				; 4E5A
	.byte	$C3,$CF,$CD,$C2,$C1,$D4,$A0,$CF	; 4E5D  COMBAT O
	.byte	$CE,$CC,$D9,$A1,$8D,$00		; 4E65  NLY!M.

	pla					; 4E6B
	pla					; 4E6C
	jmp	spell_failed			; 4E6D

@combat:
	rts					; 4E70

spell_ensure_outdoors:
	lda	game_mode			; 4E71
	cmp	#$01				; 4E73  A
	beq	@britannia			; 4E75
	jsr	j_primm				; 4E77
	.byte	$CF,$D5,$D4,$C4,$CF,$CF,$D2,$D3	; 4E7A  OUTDOORS
	.byte	$A0,$CF,$CE,$CC,$D9,$A1,$8D,$00	; 4E82   ONLY!M.

	pla					; 4E8A
	pla					; 4E8B
	jmp	spell_failed			; 4E8C

@britannia:
	rts					; 4E8F

spell_play_effect:
	ldy	@currspell			; 4E90
	ldx	@mpcost,y			; 4E93
	lda	#$0A				; 4E96  J
	jsr	j_playsfx			; 4E98
	jsr	j_invertview			; 4E9B
	lda	@currspell			; 4E9E
	clc					; 4EA1
	adc	#$60				; 4EA2  `
	tax					; 4EA4
	lda	#$09				; 4EA5  I
	jsr	j_playsfx			; 4EA7
	jsr	j_invertview			; 4EAA
	lda	magic_aura			; 4EAD
	cmp	#$CE				; 4EAF  N
	bne	L4EB8				; 4EB1
	pla					; 4EB3
	pla					; 4EB4
	jmp	spell_failed			; 4EB5

L4EB8:
	rts					; 4EB8

spell_failed:
	jsr	j_primm				; 4EB9
	.byte	$C6,$C1,$C9,$CC,$C5,$C4,$A1,$8D	; 4EBC  FAILED!M
	.byte	$00				; 4EC4  .

	lda	#$08				; 4EC5  H
	jsr	j_playsfx			; 4EC7
	jmp	cmd_done			; 4ECA

L4ECD:
	cmp	#$9C				; 4ECD  \
	beq	L4EE0				; 4ECF
	cmp	#$BC				; 4ED1  <
	beq	L4EE0				; 4ED3
	cmp	#$C4				; 4ED5  D
	beq	L4EE0				; 4ED7
	cmp	#$E4				; 4ED9  d
	beq	L4EE0				; 4EDB
	lda	#$FF				; 4EDD  .
	rts					; 4EDF

L4EE0:
	lda	#$00				; 4EE0  .
	rts					; 4EE2

print_direction:
	jsr	j_primm				; 4EE3
	.byte	$C4,$C9,$D2,$C5,$C3,$D4,$C9,$CF	; 4EE6  DIRECTIO
	.byte	$CE,$AD,$00			; 4EEE  N-.

	rts					; 4EF1

cmd_descend:
	lda	player_transport		; 4EF2
	cmp	#$18				; 4EF4  X
	beq	@balloon			; 4EF6
	jsr	j_primm				; 4EF8
	.byte	$C4,$E5,$F3,$E3,$E5,$EE,$E4,$A0	; 4EFB  Descend 
	.byte	$00				; 4F03  .

	lda	current_location		; 4F04
	cmp	#$01				; 4F06  A
	beq	@lbcastle			; 4F08
	lda	game_mode			; 4F0A
	cmp	#$03				; 4F0C  C
	beq	@dungeon			; 4F0E
	jmp	cmd_unknown			; 4F10

@dungeon:
	lda	tile_under_player		; 4F13
	and	#$F0				; 4F15  p
	cmp	#$20				; 4F17   
	beq	@downlevel			; 4F19
	cmp	#$30				; 4F1B  0
	beq	@downlevel			; 4F1D
	jmp	cmd_unknown			; 4F1F

@downlevel:
	inc	dungeon_level			; 4F22
	jsr	j_primm				; 4F24
	.byte	$E4,$EF,$F7,$EE,$A1,$8D,$D4,$EF	; 4F27  down!MTo
	.byte	$A0,$EC,$E5,$F6,$E5,$EC,$A0,$00	; 4F2F   level .

	clc					; 4F37
	lda	dungeon_level			; 4F38
	adc	#$01				; 4F3A  A
	jsr	j_printdigit			; 4F3C
	jsr	printcr				; 4F3F
	jmp	cmd_done			; 4F42

@balloon:
	jsr	j_primm				; 4F45
	.byte	$CC,$E1,$EE,$E4,$A0,$C2,$E1,$EC	; 4F48  Land Bal
	.byte	$EC,$EF,$EF,$EE,$8D,$00		; 4F50  loonM.

	lda	tile_under_player		; 4F56
	cmp	#$04				; 4F58  D
	bne	@nothere			; 4F5A
	lda	#$00				; 4F5C  .
	sta	movement_mode			; 4F5E
	sta	$1D				; 4F60
	jmp	cmd_done			; 4F62

@nothere:
	jmp	print_not_here			; 4F65

@noladder:
	jmp	cmd_unknown			; 4F68

@lbcastle:
	lda	player_transport		; 4F6B
	cmp	#$1F				; 4F6D  _
	beq	@onfoot				; 4F6F
	jmp	print_only_on_foot		; 4F71

@onfoot:
	lda	tile_under_player		; 4F74
	cmp	#$1C				; 4F76  \
	bne	@noladder			; 4F78
	lda	player_ypos			; 4F7A
	cmp	#$02				; 4F7C  B
	beq	@intodungeon			; 4F7E
	jsr	j_primm				; 4F80
	.byte	$F4,$EF,$8D,$E6,$E9,$F2,$F3,$F4	; 4F83  toMfirst
	.byte	$A0,$E6,$EC,$EF,$EF,$F2,$A1,$8D	; 4F8B   floor!M
	.byte	$00				; 4F93  .

	lda	#$00				; 4F94  .
	jsr	music_ctl			; 4F96
	lda	#$C1				; 4F99  A
	jsr	enter_location			; 4F9B
	lda	#$01				; 4F9E  A
	jsr	music_ctl			; 4FA0
	jmp	cmd_done			; 4FA3

@intodungeon:
	jsr	j_primm				; 4FA6
	.byte	$E9,$EE,$F4,$EF,$8D,$F4,$E8,$E5	; 4FA9  intoMthe
	.byte	$A0,$E4,$E5,$F0,$F4,$E8,$F3,$A1	; 4FB1   depths!
	.byte	$8D,$00				; 4FB9  M.

	lda	#$05				; 4FBB  E
	sta	$7A				; 4FBD
	sta	$7B				; 4FBF
	lda	#$EF				; 4FC1  o
	sta	$18				; 4FC3
	lda	#$F0				; 4FC5  p
	sta	$19				; 4FC7
	lda	#$17				; 4FC9  W
	sta	current_location		; 4FCB
	jmp	enter_dungeon			; 4FCD

cmd_enter:
	jsr	j_primm				; 4FD0
	.byte	$C5,$EE,$F4,$E5,$F2,$A0,$00	; 4FD3  Enter .

	lda	current_location		; 4FDA
	beq	L4FE1				; 4FDC
	jmp	cmd_unknown			; 4FDE

L4FE1:
	ldx	#$20				; 4FE1   
L4FE3:
	dex					; 4FE3
	bpl	L4FE9				; 4FE4
	jmp	cmd_unknown			; 4FE6

L4FE9:
	lda	L519A,x				; 4FE9
	cmp	player_xpos			; 4FEC
	bne	L4FE3				; 4FEE
	lda	L51BA,x				; 4FF0
	cmp	player_ypos			; 4FF3
	bne	L4FE3				; 4FF5
	stx	current_location		; 4FF7
	inc	current_location		; 4FF9
	lda	player_xpos			; 4FFB
	sta	$18				; 4FFD
	lda	player_ypos			; 4FFF
	sta	$19				; 5001
	lda	tile_under_player		; 5003
	cmp	#$09				; 5005  I
	beq	L5052				; 5007
	cmp	#$0A				; 5009  J
	bne	L5010				; 500B
	jmp	L50D3				; 500D

L5010:
	cmp	#$0B				; 5010  K
	bne	L5017				; 5012
	jmp	L513B				; 5014

L5017:
	cmp	#$0C				; 5017  L
	bne	L501E				; 5019
	jmp	L512B				; 501B

L501E:
	cmp	#$0E				; 501E  N
	bne	L5025				; 5020
	jmp	L513B				; 5022

L5025:
	cmp	#$1D				; 5025  ]
	bne	L502C				; 5027
	jmp	L50C6				; 5029

L502C:
	cmp	#$1E				; 502C  ^
	bne	L5033				; 502E
	jmp	L5166				; 5030

L5033:
	cmp	#$46				; 5033  F
	beq	L503E				; 5035
	lda	#$00				; 5037  .
	sta	current_location		; 5039
	jmp	cmd_unknown			; 503B

L503E:
	lda	$AB0E				; 503E
	cmp	#$77				; 5041  w
	beq	L504C				; 5043
	lda	#$00				; 5045  .
	sta	current_location		; 5047
	jmp	print_cant			; 5049

L504C:
	jsr	print_location_name		; 504C
	jmp	L5062				; 504F

L5052:
	jsr	j_primm				; 5052
	.byte	$E4,$F5,$EE,$E7,$E5,$EF,$EE,$A1	; 5055  dungeon!
	.byte	$8D,$00				; 505D  M.

	jsr	print_location_name		; 505F
L5062:
	lda	player_transport		; 5062
	cmp	#$1F				; 5064  _
	beq	L506F				; 5066
	lda	#$00				; 5068  .
	sta	current_location		; 506A
	jmp	print_only_on_foot		; 506C

L506F:
	lda	#$01				; 506F  A
	sta	$7A				; 5071
	sta	$7B				; 5073
	lda	#$00				; 5075  .
	jsr	music_ctl			; 5077
	jsr	save_tempmap			; 507A
enter_dungeon:
	lda	#$00				; 507D  .
	jsr	music_ctl			; 507F
	lda	#$04				; 5082  D
	jsr	j_request_disk			; 5084
	lda	#$CC				; 5087  L
	ldx	#$95				; 5089  U
	jsr	j_fileio			; 508B
	jsr	@loaddungeon			; 508E
	lda	#$03				; 5091  C
	sta	game_mode			; 5093
	lda	#$01				; 5095  A
	sta	dng_direction			; 5097
	lda	$7A				; 5099
	sta	player_xpos			; 509B
	lda	$7B				; 509D
	sta	player_ypos			; 509F
	lda	#$00				; 50A1  .
	sta	dungeon_level			; 50A3
	lda	#$C4				; 50A5  D
	jsr	music_ctl			; 50A7
	jmp	cmd_done			; 50AA

@loaddungeon:
	clc					; 50AD
	lda	current_location		; 50AE
	sec					; 50B0
	sbc	#$11				; 50B1  Q
	clc					; 50B3
	adc	#$8C				; 50B4  L
	tax					; 50B6
	lda	#$CC				; 50B7  L
	jsr	j_fileio			; 50B9
	ldx	#$00				; 50BC  .
	txa					; 50BE
L50BF:
	sta	map_status,x			; 50BF
	inx					; 50C2
	bne	L50BF				; 50C3
	rts					; 50C5

L50C6:
	jsr	j_primm				; 50C6
	.byte	$F2,$F5,$E9,$EE,$A1,$8D,$00	; 50C9  ruin!M.

	jmp	L50DE				; 50D0

L50D3:
	jsr	j_primm				; 50D3
	.byte	$F4,$EF,$F7,$EE,$E5,$A1,$8D,$00	; 50D6  towne!M.

L50DE:
	lda	#$00				; 50DE  .
	jsr	music_ctl			; 50E0
	jsr	print_location_name		; 50E3
	jsr	L51F6				; 50E6
	lda	#$0F				; 50E9  O
	sta	player_ypos			; 50EB
	lda	#$01				; 50ED  A
	sta	player_xpos			; 50EF
	lda	current_location		; 50F1
	sec					; 50F3
	sbc	#$05				; 50F4  E
	cmp	#$08				; 50F6  H
	bcs	L5123				; 50F8
	sta	$58				; 50FA
	lda	party_size			; 50FC
	sta	currplayer			; 50FE
L5100:
	lda	currplayer			; 5100
	cmp	#$02				; 5102  B
	bcc	L5123				; 5104
	jsr	j_get_stats_ptr			; 5106
	ldy	#$11				; 5109  Q
	lda	(ptr1),y			; 510B
	cmp	$58				; 510D
	beq	L5116				; 510F
	dec	currplayer			; 5111
	jmp	L5100				; 5113

L5116:
	lda	#$00				; 5116  .
	ldx	#$1F				; 5118  _
	sta	object_tile,x			; 511A
	sta	map_status,x			; 511D
	sta	$ACC0,x				; 5120
L5123:
	lda	#$D4				; 5123  T
	jsr	music_ctl			; 5125
	jmp	cmd_done			; 5128

L512B:
	jsr	j_primm				; 512B
	.byte	$F6,$E9,$EC,$EC,$E1,$E7,$E5,$A1	; 512E  village!
	.byte	$8D,$00				; 5136  M.

	jmp	L50DE				; 5138

L513B:
	lda	#$00				; 513B  .
	jsr	music_ctl			; 513D
	jsr	j_primm				; 5140
	.byte	$E3,$E1,$F3,$F4,$EC,$E5,$A1,$8D	; 5143  castle!M
	.byte	$00				; 514B  .

	jsr	print_location_name		; 514C
	jsr	L51F6				; 514F
	lda	#$0F				; 5152  O
	sta	player_xpos			; 5154
	lda	#$1E				; 5156  ^
	sta	player_ypos			; 5158
	lda	#$00				; 515A  .
	sta	dungeon_level			; 515C
	lda	#$C3				; 515E  C
	jsr	music_ctl			; 5160
	jmp	cmd_done			; 5163

L5166:
	jsr	j_primm				; 5166
	.byte	$F4,$E8,$E5,$8D,$F3,$E8,$F2,$E9	; 5169  theMshri
	.byte	$EE,$E5,$A0,$EF,$E6,$8D,$00	; 5171  ne ofM.

	lda	current_location		; 5178
	clc					; 517A
	adc	#$7E				; 517B  ~
	jsr	j_printstring			; 517D
	jsr	printcr				; 5180
L5183:
	lda	#$00				; 5183  .
	jsr	music_ctl			; 5185
	lda	#$CC				; 5188  L
	ldx	#$82				; 518A  B
	jsr	j_fileio			; 518C
	jsr	L8800				; 518F
	lda	#$01				; 5192  A
	jsr	music_ctl			; 5194
	jmp	cmd_done			; 5197

L519A:
	.byte	$56,$DA,$1C,$92,$E8,$52,$24,$3A	; 519A  VZ\RhR$:
	.byte	$9F,$6A,$16,$BB,$62,$88,$C9,$88	; 51A2  _jV;bHIH
	.byte	$F0,$5B,$48,$7E,$9C,$3A,$EF,$E9	; 51AA  p[H~\:oi
	.byte	$E9,$80,$24,$49,$CD,$51,$E7,$E7	; 51B2  i.$IMQgg
L51BA:
	.byte	$6B,$6B,$32,$F1,$87,$6A,$DE,$2B	; 51BA  kk2qGj^+
	.byte	$14,$B8,$80,$A9,$91,$9E,$3B,$5A	; 51C2  T8.)Q^;Z
	.byte	$49,$43,$A8,$14,$1B,$66,$F0,$E9	; 51CA  IC(T[fpi
	.byte	$42,$5C,$E5,$0B,$2D,$CF,$D8,$D8	; 51D2  B\eK-OXX

print_location_name:
	jsr	printcr				; 51DA
	lda	current_location		; 51DD
	clc					; 51DF
	adc	#$7E				; 51E0  ~
	jsr	j_centerstring			; 51E2
	jsr	printcr				; 51E5
	rts					; 51E8

save_tempmap:
	lda	#$02				; 51E9  B
	jsr	j_request_disk			; 51EB
	lda	#$D3				; 51EE  S
	ldx	#$7E				; 51F0  ~
	jsr	j_fileio			; 51F2
	rts					; 51F5

L51F6:
	jsr	save_tempmap			; 51F6
	lda	#$03				; 51F9  C
	jsr	j_request_disk			; 51FB
	lda	current_location		; 51FE
	clc					; 5200
	adc	#$C0				; 5201  @
enter_location:
	cmp	#$C0				; 5203  @
	bne	@notlbcfloor2			; 5205
	lda	#$6C				; 5207  l
	jmp	@lbcfloor2			; 5209

@notlbcfloor2:
	sec					; 520C
	sbc	#$C0				; 520D  @
	clc					; 520F
	adc	#$5B				; 5210  [
@lbcfloor2:
	tax					; 5212
	lda	#$CC				; 5213  L
	jsr	j_fileio			; 5215
	ldx	#$00				; 5218  .
@copy:
	lda	$8B00,x				; 521A
	sta	$E800,x				; 521D
	lda	L8C00,x				; 5220
	sta	$E900,x				; 5223
	lda	$8D00,x				; 5226
	sta	$EA00,x				; 5229
	lda	$8E00,x				; 522C
	sta	$EB00,x				; 522F
	lda	$8F00,x				; 5232
	sta	map_status,x			; 5235
	inx					; 5238
	bne	@copy				; 5239
	lda	#$02				; 523B  B
	sta	game_mode			; 523D
	rts					; 523F

cmd_fire_unknown:
	jmp	cmd_unknown			; 5240

cmd_fire:
	jsr	j_primm				; 5243
	.byte	$C6,$E9,$F2,$E5,$AD,$00		; 5246  Fire-.

	lda	player_transport		; 524C
	cmp	#$10				; 524E  P
	bcc	cmd_fire_unknown		; 5250
	cmp	#$14				; 5252  T
	bcs	cmd_fire_unknown		; 5254
	jsr	getdirection			; 5256
	bne	L525E				; 5259
	jmp	cmd_pass			; 525B

L525E:
	lda	$78				; 525E
	beq	L5289				; 5260
	lda	player_transport		; 5262
	cmp	#$11				; 5264  Q
	beq	L5296				; 5266
	cmp	#$13				; 5268  S
	beq	L5296				; 526A
L526C:
	jsr	j_primm				; 526C
	.byte	$CF,$CE,$CC,$D9,$A0,$C2,$D2,$CF	; 526F  ONLY BRO
	.byte	$C1,$C4,$D3,$C9,$C4,$C5,$D3,$A1	; 5277  ADSIDES!
	.byte	$8D,$00				; 527F  M.

	lda	#$02				; 5281  B
	jsr	j_playsfx			; 5283
	jmp	cmd_done			; 5286

L5289:
	lda	player_transport		; 5289
	cmp	#$10				; 528B  P
	beq	L5296				; 528D
	cmp	#$12				; 528F  R
	beq	L5296				; 5291
	jmp	L526C				; 5293

L5296:
	lda	#$03				; 5296  C
	jsr	j_playsfx			; 5298
	lda	#$03				; 529B  C
	sta	$6A				; 529D
L529F:
	jsr	find_target			; 529F
	bpl	L52CA				; 52A2
	jsr	L0887				; 52A4
	pha					; 52A7
	lda	#$4D				; 52A8  M
	sta	(ptr1),y			; 52AA
	jsr	j_animate_view			; 52AC
	jsr	L0887				; 52AF
	pla					; 52B2
	sta	(ptr1),y			; 52B3
	clc					; 52B5
	lda	$7A				; 52B6
	adc	$78				; 52B8
	sta	$7A				; 52BA
	clc					; 52BC
	lda	$7B				; 52BD
	adc	$79				; 52BF
	sta	$7B				; 52C1
	dec	$6A				; 52C3
	bne	L529F				; 52C5
	jmp	cmd_done			; 52C7

L52CA:
	stx	$59				; 52CA
	jsr	L0887				; 52CC
	pha					; 52CF
	lda	#$4F				; 52D0  O
	sta	(ptr1),y			; 52D2
	jsr	j_animate_view			; 52D4
	lda	#$06				; 52D7  F
	jsr	j_playsfx			; 52D9
	jsr	L0887				; 52DC
	pla					; 52DF
	sta	(ptr1),y			; 52E0
	lda	$59				; 52E2
	cmp	#$08				; 52E4  H
	bcs	L52EF				; 52E6
	jsr	j_rand				; 52E8
	and	#$03				; 52EB  C
	bne	L5300				; 52ED
L52EF:
	lda	#$00				; 52EF  .
	ldx	$59				; 52F1
	ldy	object_tile,x			; 52F3
	cpy	#$5E				; 52F6  ^
	beq	L5300				; 52F8
	sta	object_tile,x			; 52FA
	sta	map_status,x			; 52FD
L5300:
	jmp	cmd_done			; 5300

cmd_get_chest:
	jsr	j_primm				; 5303
	.byte	$C7,$E5,$F4,$A0,$E3,$E8,$E5,$F3	; 5306  Get ches
	.byte	$F4,$AC,$A0,$F7,$E8,$EF,$8D,$F7	; 530E  t, whoMw
	.byte	$E9,$EC,$EC,$A0,$EF,$F0,$E5,$EE	; 5316  ill open
	.byte	$AD,$00				; 531E  -.

	jsr	j_getplayernum			; 5320
	bne	@gotnum				; 5323
	jmp	print_aborted			; 5325

@gotnum:
	cmp	party_size			; 5328
	bcc	@gotplayer			; 532A
	beq	@gotplayer			; 532C
	jmp	print_not_a_player		; 532E

@gotplayer:
	jsr	check_awake			; 5331
	beq	get_chest			; 5334
	jmp	print_disabled			; 5336

get_chest:
	lda	game_mode			; 5339
	cmp	#$03				; 533B  C
	beq	@dungeon			; 533D
	lda	tile_under_player		; 533F
	cmp	#$3C				; 5341  <
	beq	@chest				; 5343
	jmp	print_not_here			; 5345

@chest:
	lda	current_location		; 5348
	beq	@checkobjects			; 534A
	jsr	L0890				; 534C
	cmp	#$3C				; 534F  <
	bne	@checkobjects			; 5351
	lda	#$3E				; 5353  >
	sta	(ptr2),y			; 5355
	ldy	#$00				; 5357  .
	lda	#$01				; 5359  A
	jsr	virtue_dec			; 535B
	ldy	#$03				; 535E  C
	lda	#$01				; 5360  A
	jsr	virtue_dec			; 5362
	ldy	#$05				; 5365  E
	lda	#$01				; 5367  A
	jsr	virtue_dec			; 5369
	jmp	@gotchest			; 536C

@checkobjects:
	ldx	#$1F				; 536F  _
@check:
	lda	object_tile,x			; 5371
	cmp	#$3C				; 5374  <
	bne	@next				; 5376
	lda	object_xpos,x			; 5378
	cmp	player_xpos			; 537B
	bne	@next				; 537D
	lda	object_ypos,x			; 537F
	cmp	player_ypos			; 5382
	beq	@foundchest			; 5384
@next:
	dex					; 5386
	bpl	@check				; 5387
	bmi	@gotchest			; 5389
@foundchest:
	lda	#$00				; 538B  .
	sta	object_tile,x			; 538D
	sta	map_status,x			; 5390
@gotchest:
	jmp	openchest			; 5393

@dungeon:
	lda	tile_under_player		; 5396
	cmp	#$40				; 5398  @
	beq	@dngchest			; 539A
	jmp	print_not_here			; 539C

@dngchest:
	lda	player_xpos			; 539F
	sta	$16				; 53A1
	lda	player_ypos			; 53A3
	sta	$17				; 53A5
	jsr	j_gettile_dungeon		; 53A7
	lda	#$00				; 53AA  .
	sta	(ptr1),y			; 53AC
openchest:
	jsr	j_rand				; 53AE
	bpl	@checktrap			; 53B1
	jmp	@getgold			; 53B3

@checktrap:
	and	#$03				; 53B6  C
	sta	zptmp1				; 53B8
	jsr	j_rand				; 53BA
	and	zptmp1				; 53BD
	sta	zptmp1				; 53BF
	bne	@sleep				; 53C1
	jsr	j_primm				; 53C3
	.byte	$C1,$C3,$C9,$C4,$00		; 53C6  ACID.

	jmp	@print_trap			; 53CB

@sleep:
	cmp	#$01				; 53CE  A
	bne	@poison				; 53D0
	jsr	j_primm				; 53D2
	.byte	$D3,$CC,$C5,$C5,$D0,$00		; 53D5  SLEEP.

	jmp	@print_trap			; 53DB

@poison:
	cmp	#$02				; 53DE  B
	bne	@bomb				; 53E0
	jsr	j_primm				; 53E2
	.byte	$D0,$CF,$C9,$D3,$CF,$CE,$00	; 53E5  POISON.

	jmp	@print_trap			; 53EC

@bomb:
	jsr	j_primm				; 53EF
	.byte	$C2,$CF,$CD,$C2,$00		; 53F2  BOMB.

@print_trap:
	jsr	j_primm				; 53F7
	.byte	$A0,$D4,$D2,$C1,$D0,$A1,$8D,$00	; 53FA   TRAP!M.

	lda	currplayer			; 5402
	beq	@evaded				; 5404
	jsr	j_get_stats_ptr			; 5406
	ldy	#$14				; 5409  T
	lda	(ptr1),y			; 540B
	jsr	bcdtohex			; 540D
	clc					; 5410
	adc	#$19				; 5411  Y
	sta	$59				; 5413
	lda	#$64				; 5415  d
	jsr	randmax				; 5417
	cmp	$59				; 541A
	bcs	@trapped			; 541C
@evaded:
	jsr	j_primm				; 541E
	.byte	$C5,$D6,$C1,$C4,$C5,$C4,$A1,$8D	; 5421  EVADED!M
	.byte	$00				; 5429  .

	lda	#$08				; 542A  H
	jsr	j_playsfx			; 542C
	jmp	@getgold			; 542F

@trapped:
	lda	zptmp1				; 5432
	bne	@suffersleep			; 5434
	jsr	hurt_player_random_val		; 5436
	jmp	@getgold			; 5439

@suffersleep:
	cmp	#$01				; 543C  A
	bne	@sufferpoison			; 543E
	jsr	j_get_stats_ptr			; 5440
	ldy	#$12				; 5443  R
	lda	#$D3				; 5445  S
	sta	(ptr1),y			; 5447
	jsr	flash_player_line		; 5449
	lda	game_mode			; 544C
	bpl	@getgold			; 544E
	lda	#$38				; 5450  8
	ldx	currplayer			; 5452
	sta	$AD9F,x				; 5454
	jmp	@getgold			; 5457

@sufferpoison:
	cmp	#$02				; 545A  B
	bne	@sufferbomb			; 545C
	jsr	j_get_stats_ptr			; 545E
	ldy	#$12				; 5461  R
	lda	#$D0				; 5463  P
	sta	(ptr1),y			; 5465
	jsr	flash_player_line		; 5467
	jmp	@getgold			; 546A

@sufferbomb:
	jsr	hurt_all_players		; 546D
@getgold:
	jsr	j_primm				; 5470
	.byte	$D4,$C8,$C5,$A0,$C3,$C8,$C5,$D3	; 5473  THE CHES
	.byte	$D4,$A0,$C8,$CF,$CC,$C4,$D3,$BA	; 547B  T HOLDS:
	.byte	$8D,$00				; 5483  M.

	lda	#$64				; 5485  d
	jsr	randmax				; 5487
	jsr	hextobcd			; 548A
	jsr	stat_add_gold			; 548D
	lda	zptmp1				; 5490
	jsr	j_printbcd			; 5492
	jsr	j_primm				; 5495
	.byte	$AD,$C7,$CF,$CC,$C4,$A1,$8D,$00	; 5498  -GOLD!M.

	jmp	cmd_done			; 54A0

cmd_hole_up_and_camp:
	jsr	j_primm				; 54A3
	.byte	$C8,$EF,$EC,$E5,$A0,$F5,$F0,$A0	; 54A6  Hole up 
	.byte	$A6,$A0,$E3,$E1,$ED,$F0,$8D,$00	; 54AE  & campM.

	lda	current_location		; 54B6
	beq	L54C3				; 54B8
	lda	game_mode			; 54BA
	cmp	#$03				; 54BC  C
	beq	L54C3				; 54BE
	jmp	print_not_here			; 54C0

L54C3:
	lda	player_transport		; 54C3
	cmp	#$1F				; 54C5  _
	beq	L54E1				; 54C7
	jsr	j_primm				; 54C9
	.byte	$CD,$D5,$D3,$D4,$A0,$C2,$C5,$A0	; 54CC  MUST BE 
	.byte	$CF,$CE,$A0,$C6,$CF,$CF,$D4,$A1	; 54D4  ON FOOT!
	.byte	$8D,$00				; 54DC  M.

	jmp	cmd_done			; 54DE

L54E1:
	lda	#$00				; 54E1  .
	jsr	music_ctl			; 54E3
	lda	#$CC				; 54E6  L
	ldx	#$85				; 54E8  E
	jsr	j_fileio			; 54EA
	jsr	L8800				; 54ED
	jsr	j_update_status			; 54F0
	lda	#$01				; 54F3  A
	jsr	music_ctl			; 54F5
	lda	game_mode			; 54F8
	cmp	#$03				; 54FA  C
	bne	L5501				; 54FC
	jsr	L8C06				; 54FE
L5501:
	jmp	cmd_done			; 5501

cmd_ignite:
	jsr	j_primm				; 5504
	.byte	$C9,$E7,$EE,$E9,$F4,$E5,$A0,$F4	; 5507  Ignite t
	.byte	$EF,$F2,$E3,$E8,$A1,$8D,$00	; 550F  orch!M.

	ldy	#$08				; 5516  H
	jsr	stat_dec			; 5518
	bcs	L5520				; 551B
	jmp	print_you_have_none		; 551D

L5520:
	lda	#$64				; 5520  d
	sta	light_duration			; 5522
	lda	game_mode			; 5524
	cmp	#$03				; 5526  C
	bne	L552D				; 5528
	jsr	L8C06				; 552A
L552D:
	jmp	cmd_done			; 552D

cmd_jimmy_lock:
	jsr	j_primm				; 5530
	.byte	$CA,$E9,$ED,$ED,$F9,$A0,$EC,$EF	; 5533  Jimmy lo
	.byte	$E3,$EB,$AD,$00			; 553B  ck-.

	jsr	getdirection			; 553F
	lda	game_mode			; 5542
	cmp	#$01				; 5544  A
	bne	L554B				; 5546
	jmp	print_not_here			; 5548

L554B:
	jsr	j_gettile_town			; 554B
	cmp	#$3A				; 554E  :
	beq	L5555				; 5550
	jmp	print_not_here			; 5552

L5555:
	ldy	#$0A				; 5555  J
	jsr	stat_dec			; 5557
	bcs	L555F				; 555A
	jmp	print_you_have_none		; 555C

L555F:
	lda	#$3B				; 555F  ;
	ldy	#$00				; 5561  .
	sta	(ptr2),y			; 5563
	jmp	print_done			; 5565

cmd_klimb:
	jsr	j_primm				; 5568
	.byte	$CB,$EC,$E9,$ED,$E2,$A0,$00	; 556B  Klimb .

	lda	current_location		; 5572
	beq	L55B9				; 5574
	cmp	#$01				; 5576  A
	beq	L55D5				; 5578
	lda	game_mode			; 557A
	cmp	#$03				; 557C  C
	beq	L5583				; 557E
L5580:
	jmp	cmd_unknown			; 5580

L5583:
	lda	tile_under_player		; 5583
	and	#$F0				; 5585  p
	cmp	#$10				; 5587  P
	beq	L558F				; 5589
	cmp	#$30				; 558B  0
	bne	L5580				; 558D
L558F:
	jsr	j_primm				; 558F
	.byte	$F5,$F0,$A1,$8D,$00		; 5592  up!M.

	dec	dungeon_level			; 5597
	bpl	L559E				; 5599
	jmp	exit_location			; 559B

L559E:
	jsr	j_primm				; 559E
	.byte	$D4,$EF,$A0,$EC,$E5,$F6,$E5,$EC	; 55A1  To level
	.byte	$A0,$00				; 55A9   .

	clc					; 55AB
	lda	dungeon_level			; 55AC
	adc	#$01				; 55AE  A
	jsr	j_printdigit			; 55B0
	jsr	printcr				; 55B3
	jmp	cmd_done			; 55B6

L55B9:
	lda	player_transport		; 55B9
	cmp	#$18				; 55BB  X
	bne	L5580				; 55BD
	jsr	j_primm				; 55BF
	.byte	$E1,$EC,$F4,$E9,$F4,$F5,$E4,$E5	; 55C2  altitude
	.byte	$8D,$00				; 55CA  M.

	lda	#$FF				; 55CC  .
	sta	movement_mode			; 55CE
	sta	$1D				; 55D0
	jmp	cmd_done			; 55D2

L55D5:
	lda	tile_under_player		; 55D5
	cmp	#$1B				; 55D7  [
	bne	L5580				; 55D9
	lda	player_transport		; 55DB
	cmp	#$1F				; 55DD  _
	beq	L55E7				; 55DF
	jsr	printcr				; 55E1
	jmp	print_only_on_foot		; 55E4

L55E7:
	jsr	j_primm				; 55E7
	.byte	$F4,$EF,$8D,$F3,$E5,$E3,$EF,$EE	; 55EA  toMsecon
	.byte	$E4,$A0,$E6,$EC,$EF,$EF,$F2,$A1	; 55F2  d floor!
	.byte	$8D,$00				; 55FA  M.

	lda	#$00				; 55FC  .
	jsr	music_ctl			; 55FE
	lda	#$C0				; 5601  @
	jsr	enter_location			; 5603
	lda	#$01				; 5606  A
	jsr	music_ctl			; 5608
	jmp	cmd_done			; 560B

cmd_locate:
	jsr	j_primm				; 560E
	.byte	$CC,$EF,$E3,$E1,$F4,$E5,$A0,$F0	; 5611  Locate p
	.byte	$EF,$F3,$E9,$F4,$E9,$EF,$EE,$8D	; 5619  ositionM
	.byte	$00				; 5621  .

	lda	$AB0B				; 5622
	bne	L5633				; 5625
	jsr	j_primm				; 5627
	.byte	$D7,$C9,$D4,$C8,$A0,$00		; 562A  WITH .

	jmp	cmd_unknown			; 5630

L5633:
	jsr	j_primm				; 5633
	.byte	$F7,$E9,$F4,$E8,$A0,$F3,$E5,$F8	; 5636  with sex
	.byte	$F4,$E1,$EE,$F4,$BA,$8D,$8D,$A0	; 563E  tant:MM 
	.byte	$EC,$E1,$F4,$E9,$F4,$F5,$E4,$E5	; 5646  latitude
	.byte	$BA,$00				; 564E  :.

	lda	player_ypos			; 5650
	lsr	a				; 5652
	lsr	a				; 5653
	lsr	a				; 5654
	lsr	a				; 5655
	clc					; 5656
	adc	#$C1				; 5657  A
	jsr	j_console_out			; 5659
	lda	#$A7				; 565C  '
	jsr	j_console_out			; 565E
	lda	player_ypos			; 5661
	and	#$0F				; 5663  O
	clc					; 5665
	adc	#$C1				; 5666  A
	jsr	j_console_out			; 5668
	jsr	j_primm				; 566B
	.byte	$A2,$8D,$EC,$EF,$EE,$E7,$E9,$F4	; 566E  \"Mlongit
	.byte	$F5,$E4,$E5,$BA,$00		; 5676  ude:.

	lda	player_xpos			; 567B
	lsr	a				; 567D
	lsr	a				; 567E
	lsr	a				; 567F
	lsr	a				; 5680
	clc					; 5681
	adc	#$C1				; 5682  A
	jsr	j_console_out			; 5684
	lda	#$A7				; 5687  '
	jsr	j_console_out			; 5689
	lda	player_xpos			; 568C
	and	#$0F				; 568E  O
	clc					; 5690
	adc	#$C1				; 5691  A
	jsr	j_console_out			; 5693
	lda	#$A2				; 5696  \"
	jsr	j_console_out			; 5698
	jsr	printcr				; 569B
	jmp	cmd_done			; 569E

cmd_mix_reagents:
	jsr	list_mixtures			; 56A1
	jsr	j_primm				; 56A4
	.byte	$CD,$E9,$F8,$A0,$F2,$E5,$E1,$E7	; 56A7  Mix reag
	.byte	$E5,$EE,$F4,$F3,$8D,$00		; 56AF  entsM.

	lda	#$00				; 56B5  .
	jsr	music_ctl			; 56B7
	lda	#$CC				; 56BA  L
	ldx	#$7B				; 56BC  {
	jsr	j_fileio			; 56BE
	jsr	L8800				; 56C1
	lda	#$01				; 56C4  A
	jsr	music_ctl			; 56C6
	jmp	cmd_done			; 56C9

cmd_new_order:
	jsr	j_primm				; 56CC
	.byte	$CE,$E5,$F7,$A0,$EF,$F2,$E4,$E5	; 56CF  New orde
	.byte	$F2,$BA,$8D,$E5,$F8,$E3,$E8,$E1	; 56D7  r:Mexcha
	.byte	$EE,$E7,$E5,$A0,$A3,$00		; 56DF  nge #.

	jsr	j_getplayernum			; 56E5
	bne	L56ED				; 56E8
	jmp	print_aborted			; 56EA

L56ED:
	cmp	#$01				; 56ED  A
	beq	L5758				; 56EF
	cmp	party_size			; 56F1
	bcc	L56FA				; 56F3
	beq	L56FA				; 56F5
	jmp	print_not_here			; 56F7

L56FA:
	sta	$55				; 56FA
	jsr	j_get_stats_ptr			; 56FC
	lda	ptr1				; 56FF
	sta	L5772				; 5701
	lda	ptr1+1				; 5704
	sta	L5773				; 5706
	jsr	j_primm				; 5709
	.byte	$A0,$A0,$A0,$A0,$F7,$E9,$F4,$E8	; 570C      with
	.byte	$A0,$A3,$00			; 5714   #.

	jsr	j_getplayernum			; 5717
	bne	L571F				; 571A
	jmp	print_aborted			; 571C

L571F:
	cmp	#$01				; 571F  A
	beq	L5758				; 5721
	cmp	$55				; 5723
	bne	L572A				; 5725
	jmp	print_done			; 5727

L572A:
	cmp	party_size			; 572A
	bcc	L5733				; 572C
	beq	L5733				; 572E
	jmp	print_not_here			; 5730

L5733:
	jsr	j_get_stats_ptr			; 5733
	ldy	#$1F				; 5736  _
	lda	L5772				; 5738
	sta	ptr2				; 573B
	lda	L5773				; 573D
	sta	ptr2+1				; 5740
L5742:
	lda	(ptr1),y			; 5742
	pha					; 5744
	lda	(ptr2),y			; 5745
	sta	(ptr1),y			; 5747
	pla					; 5749
	sta	(ptr2),y			; 574A
	dey					; 574C
	bpl	L5742				; 574D
	jsr	j_clearstatwindow		; 574F
	jsr	j_update_status			; 5752
	jmp	print_done			; 5755

L5758:
	jsr	j_printname			; 5758
	jsr	j_primm				; 575B
	.byte	$8D,$D9,$CF,$D5,$A0,$CD,$D5,$D3	; 575E  MYOU MUS
	.byte	$D4,$A0,$CC,$C5,$C1,$C4,$A1,$8D	; 5766  T LEAD!M
	.byte	$00				; 576E  .

	jmp	print_aborted			; 576F

L5772:
	brk					; 5772
L5773:
	brk					; 5773
cmd_open:
	jsr	update_door			; 5774
	lda	open_door_counter		; 5777
	bne	cmd_open			; 577A
	jsr	j_primm				; 577C
	.byte	$CF,$F0,$E5,$EE,$AD,$00		; 577F  Open-.

	jsr	getdirection			; 5785
	lda	game_mode			; 5788
	cmp	#$02				; 578A  B
	beq	L5791				; 578C
L578E:
	jmp	print_not_here			; 578E

L5791:
	jsr	j_gettile_town			; 5791
	cmp	#$3B				; 5794  ;
	beq	L579F				; 5796
	cmp	#$3A				; 5798  :
	bne	L578E				; 579A
	jmp	print_cant			; 579C

L579F:
	lda	$7A				; 579F
	sta	open_door_xpos			; 57A1
	lda	$7B				; 57A4
	sta	open_door_ypos			; 57A6
	lda	#$05				; 57A9  E
	sta	open_door_counter		; 57AB
	lda	#$3E				; 57AE  >
	sta	(ptr2),y			; 57B0
	jsr	j_primm				; 57B2
	.byte	$CF,$D0,$C5,$CE,$C5,$C4,$A1,$8D	; 57B5  OPENED!M
	.byte	$00				; 57BD  .

	jmp	cmd_done			; 57BE

cmd_peer_at_gem:
	jsr	j_primm				; 57C1
	.byte	$D0,$E5,$E5,$F2,$A0,$E1,$F4,$A0	; 57C4  Peer at 
	.byte	$00				; 57CC  .

	ldy	#$09				; 57CD  I
	jsr	stat_dec			; 57CF
	bcs	L57D7				; 57D2
	jmp	cmd_unknown			; 57D4

L57D7:
	jsr	j_primm				; 57D7
	.byte	$E1,$A0,$E7,$E5,$ED,$A1,$8D,$00	; 57DA  a gem!M.

	jsr	L57E8				; 57E2
	jmp	cmd_done			; 57E5

L57E8:
	lda	#$00				; 57E8  .
	jsr	music_ctl			; 57EA
	lda	#$CC				; 57ED  L
	ldx	#$77				; 57EF  w
	jsr	j_fileio			; 57F1
	lda	#$03				; 57F4  C
	jsr	music_ctl			; 57F6
	jsr	L9000				; 57F9
	lda	game_mode			; 57FC
	cmp	#$03				; 57FE  C
	bne	L580E				; 5800
	lda	#$00				; 5802  .
	jsr	music_ctl			; 5804
	lda	#$CC				; 5807  L
	ldx	#$95				; 5809  U
	jsr	j_fileio			; 580B
L580E:
	lda	#$01				; 580E  A
	jsr	music_ctl			; 5810
	rts					; 5813

cmd_quit_and_save:
	jsr	j_primm				; 5814
	.byte	$D1,$F5,$E9,$F4,$A0,$A6,$A0,$F3	; 5817  Quit & s
	.byte	$E1,$F6,$E5,$AE,$AE,$AE,$8D,$00	; 581F  ave...M.

	jsr	L5854				; 5827
	lda	current_location		; 582A
	beq	L5831				; 582C
	jmp	print_not_here			; 582E

L5831:
	lda	#$00				; 5831  .
	jsr	music_ctl			; 5833
	lda	#$02				; 5836  B
	jsr	j_request_disk			; 5838
	lda	#$D3				; 583B  S
	ldx	#$7F				; 583D  .
	jsr	j_fileio			; 583F
	ldx	#$80				; 5842  .
	jsr	j_fileio			; 5844
	ldx	#$1A				; 5847  Z
	jsr	j_fileio			; 5849
	lda	#$01				; 584C  A
	jsr	music_ctl			; 584E
	jmp	cmd_done			; 5851

L5854:
	lda	move_counter			; 5854
	cmp	#$10				; 5856  P
	bcs	L587C				; 5858
	cmp	#$00				; 585A  .
	bne	L5881				; 585C
	lda	move_counter+1			; 585E
	cmp	#$10				; 5860  P
	bcs	L5886				; 5862
	cmp	#$00				; 5864  .
	bne	L588B				; 5866
	lda	move_counter+2			; 5868
	cmp	#$10				; 586A  P
	bcs	L5890				; 586C
	cmp	#$00				; 586E  .
	bne	L5895				; 5870
	lda	move_counter+3			; 5872
	cmp	#$10				; 5874  P
	bcs	L589A				; 5876
	cmp	#$00				; 5878  .
	bne	L589F				; 587A
L587C:
	lda	move_counter			; 587C
	jsr	L58B1				; 587E
L5881:
	lda	move_counter			; 5881
	jsr	L58B9				; 5883
L5886:
	lda	move_counter+1			; 5886
	jsr	L58B1				; 5888
L588B:
	lda	move_counter+1			; 588B
	jsr	L58B9				; 588D
L5890:
	lda	move_counter+2			; 5890
	jsr	L58B1				; 5892
L5895:
	lda	move_counter+2			; 5895
	jsr	L58B9				; 5897
L589A:
	lda	move_counter+3			; 589A
	jsr	L58B1				; 589C
L589F:
	lda	move_counter+3			; 589F
	jsr	L58B9				; 58A1
	jsr	j_primm				; 58A4
	.byte	$A0,$ED,$EF,$F6,$E5,$F3,$A1,$8D	; 58A7   moves!M
	.byte	$00				; 58AF  .

	rts					; 58B0

L58B1:
	lsr	a				; 58B1
	lsr	a				; 58B2
	lsr	a				; 58B3
	lsr	a				; 58B4
	jsr	j_printdigit			; 58B5
	rts					; 58B8

L58B9:
	and	#$0F				; 58B9  O
	jsr	j_printdigit			; 58BB
	rts					; 58BE

cmd_ready_weapon:
	jsr	j_primm				; 58BF
	.byte	$D2,$E5,$E1,$E4,$F9,$A0,$E1,$A0	; 58C2  Ready a 
	.byte	$F7,$E5,$E1,$F0,$EF,$EE,$8D,$E6	; 58CA  weaponMf
	.byte	$EF,$F2,$A0,$F0,$EC,$E1,$F9,$E5	; 58D2  or playe
	.byte	$F2,$AD,$00			; 58DA  r-.

	jsr	j_getplayernum			; 58DD
	beq	L58E8				; 58E0
	cmp	party_size			; 58E2
	bcc	L58EB				; 58E4
	beq	L58EB				; 58E6
L58E8:
	jmp	print_not_a_player		; 58E8

L58EB:
	jsr	L5EA4				; 58EB
	jsr	j_primm				; 58EE
	.byte	$D7,$E5,$E1,$F0,$EF,$EE,$BA,$00	; 58F1  Weapon:.

	jsr	getandprintkey			; 58F9
	pha					; 58FC
	jsr	j_clearstatwindow		; 58FD
	jsr	j_update_status			; 5900
	lda	game_mode			; 5903
	bpl	L590A				; 5905
	jsr	invert_player_line		; 5907
L590A:
	pla					; 590A
	sec					; 590B
	sbc	#$C1				; 590C  A
	cmp	#$10				; 590E  P
	bcc	L5915				; 5910
	jmp	print_aborted			; 5912

L5915:
	sta	$6A				; 5915
	cmp	#$00				; 5917  .
	beq	L5927				; 5919
	clc					; 591B
	adc	#$20				; 591C   
	tay					; 591E
	lda	game_stats,y			; 591F
	bne	L5927				; 5922
	jmp	print_you_have_none		; 5924

L5927:
	jsr	j_get_stats_ptr			; 5927
	ldy	#$17				; 592A  W
	lda	(ptr1),y			; 592C
	ldx	$6A				; 592E
	and	weapon_class_table,x		; 5930
	bne	L5938				; 5933
	jmp	L5972				; 5935

L5938:
	ldy	#$1E				; 5938  ^
	lda	(ptr1),y			; 593A
	beq	L5945				; 593C
	clc					; 593E
	adc	#$20				; 593F   
	tay					; 5941
	jsr	stat_inc			; 5942
L5945:
	ldy	#$1E				; 5945  ^
	lda	$6A				; 5947
	sta	(ptr1),y			; 5949
	beq	L5954				; 594B
	clc					; 594D
	adc	#$20				; 594E   
	tay					; 5950
	jsr	stat_dec			; 5951
L5954:
	lda	$6A				; 5954
	clc					; 5956
	adc	#$25				; 5957  %
	jsr	j_printstring			; 5959
	jsr	printcr				; 595C
	jmp	print_done			; 595F

weapon_class_table:
	.byte	$FF,$FF,$FF,$FF,$7F,$6F,$6F,$7E	; 5962  .....oo~
	.byte	$7E,$FF,$2C,$0C,$2E,$5E,$D0,$FF	; 596A  ~.,L.^P.

L5972:
	jsr	printcr				; 5972
	jsr	j_primm				; 5975
	.byte	$C1,$A0,$00			; 5978  A .

	jsr	j_get_stats_ptr			; 597B
	ldy	#$11				; 597E  Q
	lda	(ptr1),y			; 5980
	clc					; 5982
	adc	#$4D				; 5983  M
	jsr	j_printstring			; 5985
	jsr	j_primm				; 5988
	.byte	$8D,$CD,$C1,$D9,$A0,$CE,$CF,$D4	; 598B  MMAY NOT
	.byte	$A0,$D5,$D3,$C5,$A0,$C1,$8D,$00	; 5993   USE AM.

	lda	$6A				; 599B
	clc					; 599D
	adc	#$25				; 599E  %
	jsr	j_printstring			; 59A0
	jsr	printcr				; 59A3
	jmp	print_aborted			; 59A6

cmd_search:
	jsr	j_primm				; 59A9
	.byte	$D3,$E5,$E1,$F2,$E3,$E8,$AE,$AE	; 59AC  Search..
	.byte	$AE,$8D,$00			; 59B4  .M.

	lda	#$00				; 59B7  .
	jsr	music_ctl			; 59B9
	lda	#$CC				; 59BC  L
	ldx	#$79				; 59BE  y
	jsr	j_fileio			; 59C0
	jsr	L8800				; 59C3
	lda	#$01				; 59C6  A
	jsr	music_ctl			; 59C8
	jmp	cmd_done			; 59CB

cmd_talk:
	jsr	j_primm				; 59CE
	.byte	$D4,$E1,$EC,$EB,$AD,$00		; 59D1  Talk-.

	jsr	getdirection			; 59D7
	bne	@gotdir				; 59DA
	jmp	cmd_pass			; 59DC

@gotdir:
	jsr	j_gettile_town			; 59DF
	cmp	#$60				; 59E2  `
	bcc	@notshop			; 59E4
	cmp	#$7E				; 59E6  ~
	bcs	@notshop			; 59E8
	clc					; 59EA
	lda	$7A				; 59EB
	adc	$78				; 59ED
	sta	$7A				; 59EF
	clc					; 59F1
	lda	$7B				; 59F2
	adc	$79				; 59F4
	sta	$7B				; 59F6
	jsr	find_creature			; 59F8
	bmi	@noresponse			; 59FB
	lda	object_tile,x			; 59FD
	cmp	#$52				; 5A00  R
	bne	@noresponse			; 5A02
	jmp	@findshop			; 5A04

@notshop:
	jsr	find_creature			; 5A07
	bmi	@noresponse			; 5A0A
	stx	$6A				; 5A0C
	lda	current_location		; 5A0E
	beq	@noresponse			; 5A10
	cmp	#$11				; 5A12  Q
	bcc	@findnpc			; 5A14
@noresponse:
	jsr	j_primm				; 5A16
	.byte	$C6,$D5,$CE,$CE,$D9,$AC,$A0,$CE	; 5A19  FUNNY, N
	.byte	$CF,$8D,$D2,$C5,$D3,$D0,$CF,$CE	; 5A21  OMRESPON
	.byte	$D3,$C5,$A1,$8D,$00		; 5A29  SE!M.

	jmp	cmd_done			; 5A2E

@findnpc:
	sta	lt_y				; 5A31
	dec	lt_y				; 5A33
	ldx	$6A				; 5A35
	lda	$ACE0,x				; 5A37
	sta	lt_x				; 5A3A
	beq	@noresponse			; 5A3C
	dec	lt_x				; 5A3E
	lda	#$01				; 5A40  A
	sta	lt_rwflag			; 5A42
	lda	#$AD				; 5A44  -
	sta	lt_addr_hi			; 5A46
	lda	#$00				; 5A48  .
	jsr	music_ctl			; 5A4A
	ldx	$6A				; 5A4D
	lda	object_tile,x			; 5A4F
	cmp	#$5E				; 5A52  ^
	bne	@notlordbritish			; 5A54
	lda	#$02				; 5A56  B
	jsr	j_request_disk			; 5A58
	lda	#$CC				; 5A5B  L
	ldx	#$87				; 5A5D  G
	jsr	j_fileio			; 5A5F
	lda	#$C2				; 5A62  B
	jsr	music_ctl			; 5A64
	jsr	L8803				; 5A67
	lda	#$00				; 5A6A  .
	jsr	music_ctl			; 5A6C
	lda	#$03				; 5A6F  C
	jsr	j_request_disk			; 5A71
	lda	#$C3				; 5A74  C
	jsr	music_ctl			; 5A76
	jmp	@talkdone			; 5A79

@notlordbritish:
	jsr	j_loadsector			; 5A7C
	lda	#$CC				; 5A7F  L
	ldx	#$78				; 5A81  x
	jsr	j_fileio			; 5A83
	jsr	L8800				; 5A86
@talkdone:
	lda	#$01				; 5A89  A
	jsr	music_ctl			; 5A8B
	jmp	cmd_done			; 5A8E

@findshop:
	lda	#$00				; 5A91  .
	jsr	music_ctl			; 5A93
	lda	#$CC				; 5A96  L
	ldx	#$19				; 5A98  Y
	jsr	j_fileio			; 5A9A
	lda	#$88				; 5A9D  H
	sta	ptr1+1				; 5A9F
	lda	current_location		; 5AA1
	sec					; 5AA3
	sbc	#$01				; 5AA4  A
	asl	a				; 5AA6
	asl	a				; 5AA7
	asl	a				; 5AA8
	sta	ptr1				; 5AA9
	ldy	#$07				; 5AAB  G
L5AAD:
	lda	(ptr1),y			; 5AAD
	cmp	$17				; 5AAF
	beq	L5ADA				; 5AB1
	dey					; 5AB3
	bpl	L5AAD				; 5AB4
	lda	$17				; 5AB6
	cmp	#$18				; 5AB8  X
	bne	L5AC6				; 5ABA
	lda	current_location		; 5ABC
	cmp	#$0D				; 5ABE  M
	bne	L5AC6				; 5AC0
	ldy	#$08				; 5AC2  H
	bne	L5ADA				; 5AC4
L5AC6:
	lda	$17				; 5AC6
	cmp	#$19				; 5AC8  Y
	bne	L5AD7				; 5ACA
	lda	current_location		; 5ACC
	cmp	#$01				; 5ACE  A
	bne	L5AD7				; 5AD0
	ldy	#$09				; 5AD2  I
	jmp	L5ADA				; 5AD4

L5AD7:
	jmp	@noresponse			; 5AD7

L5ADA:
	tya					; 5ADA
	clc					; 5ADB
	adc	#$6D				; 5ADC  m
	tax					; 5ADE
	lda	#$CC				; 5ADF  L
	jsr	j_fileio			; 5AE1
	lda	#$04				; 5AE4  D
	jsr	music_ctl			; 5AE6
	jsr	L8800				; 5AE9
	lda	#$01				; 5AEC  A
	jsr	music_ctl			; 5AEE
	jmp	cmd_done			; 5AF1

cmd_use:
	jsr	j_primm				; 5AF4
	.byte	$D5,$F3,$E5,$AE,$AE,$AE,$8D,$00	; 5AF7  Use...M.

	lda	#$00				; 5AFF  .
	jsr	music_ctl			; 5B01
	lda	#$CC				; 5B04  L
	ldx	#$7A				; 5B06  z
	jsr	j_fileio			; 5B08
	jsr	L8800				; 5B0B
	lda	game_mode			; 5B0E
	bmi	L5B1A				; 5B10
	lda	#$01				; 5B12  A
	jsr	music_ctl			; 5B14
	jmp	cmd_done			; 5B17

L5B1A:
	lda	#$02				; 5B1A  B
	jsr	music_ctl			; 5B1C
	jmp	cmd_done			; 5B1F

cmd_volume:
	jsr	j_primm				; 5B22
	.byte	$D6,$EF,$EC,$F5,$ED,$E5,$A0,$00	; 5B25  Volume .

	lda	music_volume			; 5B2D
	bne	@off				; 5B2F
	lda	#$FF				; 5B31  .
	sta	music_volume			; 5B33
	jsr	j_primm				; 5B35
	.byte	$CF,$CE,$8D,$00			; 5B38  ONM.

	jmp	cmd_done			; 5B3C

@off:
	lda	#$00				; 5B3F  .
	sta	music_volume			; 5B41
	jsr	j_primm				; 5B43
	.byte	$CF,$C6,$C6,$8D,$00		; 5B46  OFFM.

	jmp	cmd_done			; 5B4B

cmd_wear_armor:
	jsr	j_primm				; 5B4E
	.byte	$D7,$E5,$E1,$F2,$A0,$E1,$F2,$ED	; 5B51  Wear arm
	.byte	$EF,$F5,$F2,$8D,$E6,$EF,$F2,$A0	; 5B59  ourMfor 
	.byte	$F0,$EC,$E1,$F9,$E5,$F2,$AD,$00	; 5B61  player-.

	jsr	j_getplayernum			; 5B69
	beq	L5B74				; 5B6C
	cmp	party_size			; 5B6E
	bcc	L5B77				; 5B70
	beq	L5B77				; 5B72
L5B74:
	jmp	print_not_a_player		; 5B74

L5B77:
	jsr	L5F26				; 5B77
	jsr	j_primm				; 5B7A
	.byte	$C1,$F2,$ED,$EF,$F5,$F2,$BA,$00	; 5B7D  Armour:.

	jsr	getandprintkey			; 5B85
	pha					; 5B88
	jsr	j_clearstatwindow		; 5B89
	jsr	j_update_status			; 5B8C
	lda	game_mode			; 5B8F
	bpl	L5B96				; 5B91
	jsr	invert_player_line		; 5B93
L5B96:
	pla					; 5B96
	sec					; 5B97
	sbc	#$C1				; 5B98  A
	cmp	#$08				; 5B9A  H
	bcc	L5BA1				; 5B9C
	jmp	print_aborted			; 5B9E

L5BA1:
	sta	$6A				; 5BA1
	cmp	#$00				; 5BA3  .
	beq	L5BB3				; 5BA5
	clc					; 5BA7
	adc	#$18				; 5BA8  X
	tay					; 5BAA
	lda	game_stats,y			; 5BAB
	bne	L5BB3				; 5BAE
	jmp	print_you_have_none		; 5BB0

L5BB3:
	jsr	j_get_stats_ptr			; 5BB3
	ldy	#$17				; 5BB6  W
	lda	(ptr1),y			; 5BB8
	ldx	$6A				; 5BBA
	and	L5BF5,x				; 5BBC
	bne	L5BCB				; 5BBF
	lda	$6A				; 5BC1
	clc					; 5BC3
	adc	#$10				; 5BC4  P
	sta	$6A				; 5BC6
	jmp	L5972				; 5BC8

L5BCB:
	ldy	#$1F				; 5BCB  _
	lda	(ptr1),y			; 5BCD
	beq	L5BD8				; 5BCF
	clc					; 5BD1
	adc	#$18				; 5BD2  X
	tay					; 5BD4
	jsr	stat_inc			; 5BD5
L5BD8:
	ldy	#$1F				; 5BD8  _
	lda	$6A				; 5BDA
	sta	(ptr1),y			; 5BDC
	beq	L5BE7				; 5BDE
	clc					; 5BE0
	adc	#$18				; 5BE1  X
	tay					; 5BE3
	jsr	stat_dec			; 5BE4
L5BE7:
	lda	$6A				; 5BE7
	clc					; 5BE9
	adc	#$35				; 5BEA  5
	jsr	j_printstring			; 5BEC
	jsr	printcr				; 5BEF
	jmp	print_done			; 5BF2

L5BF5:
	.byte	$FF				; 5BF5  .
	.byte	$FF				; 5BF6  .
	.byte	$7F				; 5BF7  .
	bit	$242C				; 5BF8
	.byte	$04				; 5BFB  D
	.byte	$FF				; 5BFC  .
cmd_xit:
	jsr	j_primm				; 5BFD
	.byte	$D8,$AD,$E9,$F4,$A0,$00		; 5C00  X-it .

	lda	player_transport		; 5C06
	cmp	#$10				; 5C08  P
	bcc	L5C18				; 5C0A
	cmp	#$14				; 5C0C  T
	bcc	L5C1B				; 5C0E
	cmp	#$16				; 5C10  V
	bcc	L5C28				; 5C12
	cmp	#$18				; 5C14  X
	beq	L5C2F				; 5C16
L5C18:
	jmp	cmd_unknown			; 5C18

L5C1B:
	lda	player_xpos			; 5C1B
	sta	player_ship_xpos		; 5C1D
	lda	player_ypos			; 5C20
	sta	player_ship_ypos		; 5C22
	jmp	L5C36				; 5C25

L5C28:
	lda	#$00				; 5C28  .
	sta	horse_mode			; 5C2A
	jmp	L5C36				; 5C2C

L5C2F:
	lda	movement_mode			; 5C2F
	beq	L5C36				; 5C31
	jmp	print_not_here			; 5C33

L5C36:
	ldx	#$1F				; 5C36  _
L5C38:
	lda	object_tile,x			; 5C38
	beq	L5C4A				; 5C3B
	dex					; 5C3D
	cpx	#$08				; 5C3E  H
	bcs	L5C38				; 5C40
	jsr	j_rand				; 5C42
	and	#$0F				; 5C45  O
	ora	#$10				; 5C47  P
	tax					; 5C49
L5C4A:
	lda	player_transport		; 5C4A
	sta	object_tile,x			; 5C4C
	sta	map_status,x			; 5C4F
	lda	player_xpos			; 5C52
	sta	object_xpos,x			; 5C54
	lda	player_ypos			; 5C57
	sta	object_ypos,x			; 5C59
	lda	#$00				; 5C5C  .
	sta	$ACC0,x				; 5C5E
	sta	$ACE0,x				; 5C61
	lda	#$1F				; 5C64  _
	sta	player_transport		; 5C66
	jsr	printcr				; 5C68
	jmp	cmd_done			; 5C6B

cmd_yell:
	jsr	j_primm				; 5C6E
	.byte	$D9,$E5,$EC,$EC,$A0,$00		; 5C71  Yell .

	lda	player_transport		; 5C77
	cmp	#$14				; 5C79  T
	beq	L5C84				; 5C7B
	cmp	#$15				; 5C7D  U
	beq	L5C84				; 5C7F
	jmp	cmd_unknown			; 5C81

L5C84:
	lda	horse_mode			; 5C84
	eor	#$FF				; 5C86  .
	sta	horse_mode			; 5C88
	bmi	L5C99				; 5C8A
	jsr	j_primm				; 5C8C
	.byte	$F7,$E8,$EF,$E1,$A1,$8D,$00	; 5C8F  whoa!M.

	jmp	cmd_done			; 5C96

L5C99:
	jsr	j_primm				; 5C99
	.byte	$E7,$E9,$E4,$E4,$F9,$F5,$F0,$A1	; 5C9C  giddyup!
	.byte	$8D,$00				; 5CA4  M.

	jmp	cmd_done			; 5CA6

cmd_ztats:
	jsr	j_primm				; 5CA9
	.byte	$DA,$F4,$E1,$F4,$F3,$A0,$E6,$EF	; 5CAC  Ztats fo
	.byte	$F2,$AD,$00			; 5CB4  r-.

	jsr	j_getplayernum			; 5CB7
	bne	L5CBF				; 5CBA
	jmp	L5E30				; 5CBC

L5CBF:
	cmp	party_size			; 5CBF
	bcc	L5CC8				; 5CC1
	beq	L5CC8				; 5CC3
	jmp	print_not_a_player		; 5CC5

L5CC8:
	jsr	j_clearstatwindow		; 5CC8
	jsr	save_console_pos		; 5CCB
	ldx	#$1C				; 5CCE  \
	ldy	#$00				; 5CD0  .
	jsr	j_primm_xy			; 5CD2
	.byte	$1E,$D0,$CC,$D2,$AD,$00		; 5CD5  ^PLR-.

	lda	currplayer			; 5CDB
	jsr	j_printdigit			; 5CDD
	lda	#$1C				; 5CE0  \
	jsr	j_console_out			; 5CE2
	ldx	#$18				; 5CE5  X
	stx	console_xpos			; 5CE7
	ldy	#$01				; 5CE9  A
	sty	console_ypos			; 5CEB
	jsr	j_centername			; 5CED
	ldx	#$18				; 5CF0  X
	stx	console_xpos			; 5CF2
	ldy	#$02				; 5CF4  B
	sty	console_ypos			; 5CF6
	jsr	j_get_stats_ptr			; 5CF8
	ldy	#$10				; 5CFB  P
	lda	(ptr1),y			; 5CFD
	jsr	j_console_out			; 5CFF
	lda	#$A0				; 5D02   
	jsr	j_console_out			; 5D04
	ldx	#$18				; 5D07  X
	stx	console_xpos			; 5D09
	jsr	j_get_stats_ptr			; 5D0B
	ldy	#$11				; 5D0E  Q
	lda	(ptr1),y			; 5D10
	clc					; 5D12
	adc	#$4D				; 5D13  M
	jsr	j_centerstring			; 5D15
	ldx	#$26				; 5D18  &
	stx	console_xpos			; 5D1A
	jsr	j_get_stats_ptr			; 5D1C
	ldy	#$12				; 5D1F  R
	lda	(ptr1),y			; 5D21
	jsr	j_console_out			; 5D23
	ldx	#$19				; 5D26  Y
	ldy	#$03				; 5D28  C
	jsr	j_primm_xy			; 5D2A
	.byte	$CD,$D0,$BA,$00			; 5D2D  MP:.

	jsr	j_get_stats_ptr			; 5D31
	ldy	#$16				; 5D34  V
	lda	(ptr1),y			; 5D36
	jsr	j_printbcd			; 5D38
	ldx	#$20				; 5D3B   
	ldy	#$03				; 5D3D  C
	jsr	j_primm_xy			; 5D3F
	.byte	$CC,$D6,$BA,$00			; 5D42  LV:.

	jsr	j_get_stats_ptr			; 5D46
	ldy	#$1A				; 5D49  Z
	lda	(ptr1),y			; 5D4B
	jsr	j_printdigit			; 5D4D
	ldx	#$18				; 5D50  X
	ldy	#$04				; 5D52  D
	jsr	j_primm_xy			; 5D54
	.byte	$D3,$D4,$D2,$BA,$00		; 5D57  STR:.

	jsr	j_get_stats_ptr			; 5D5C
	ldy	#$13				; 5D5F  S
	lda	(ptr1),y			; 5D61
	jsr	j_printbcd			; 5D63
	ldx	#$18				; 5D66  X
	ldy	#$05				; 5D68  E
	jsr	j_primm_xy			; 5D6A
	.byte	$C4,$C5,$D8,$BA,$00		; 5D6D  DEX:.

	jsr	j_get_stats_ptr			; 5D72
	ldy	#$14				; 5D75  T
	lda	(ptr1),y			; 5D77
	jsr	j_printbcd			; 5D79
	ldx	#$18				; 5D7C  X
	ldy	#$06				; 5D7E  F
	jsr	j_primm_xy			; 5D80
	.byte	$C9,$CE,$D4,$BA,$00		; 5D83  INT:.

	jsr	j_get_stats_ptr			; 5D88
	ldy	#$15				; 5D8B  U
	lda	(ptr1),y			; 5D8D
	jsr	j_printbcd			; 5D8F
	ldx	#$20				; 5D92   
	ldy	#$04				; 5D94  D
	jsr	j_primm_xy			; 5D96
	.byte	$C8,$D0,$BA,$00			; 5D99  HP:.

	jsr	j_get_stats_ptr			; 5D9D
	ldy	#$18				; 5DA0  X
	lda	(ptr1),y			; 5DA2
	jsr	j_printbcd			; 5DA4
	ldy	#$19				; 5DA7  Y
	lda	(ptr1),y			; 5DA9
	jsr	j_printbcd			; 5DAB
	ldx	#$20				; 5DAE   
	ldy	#$05				; 5DB0  E
	jsr	j_primm_xy			; 5DB2
	.byte	$C8,$CD,$BA,$00			; 5DB5  HM:.

	jsr	j_get_stats_ptr			; 5DB9
	ldy	#$1A				; 5DBC  Z
	lda	(ptr1),y			; 5DBE
	jsr	j_printbcd			; 5DC0
	ldy	#$1B				; 5DC3  [
	lda	(ptr1),y			; 5DC5
	jsr	j_printbcd			; 5DC7
	ldx	#$20				; 5DCA   
	ldy	#$06				; 5DCC  F
	jsr	j_primm_xy			; 5DCE
	.byte	$C5,$D8,$BA,$00			; 5DD1  EX:.

	jsr	j_get_stats_ptr			; 5DD5
	ldy	#$1C				; 5DD8  \
	lda	(ptr1),y			; 5DDA
	jsr	j_printbcd			; 5DDC
	ldy	#$1D				; 5DDF  ]
	lda	(ptr1),y			; 5DE1
	jsr	j_printbcd			; 5DE3
	ldx	#$18				; 5DE6  X
	ldy	#$07				; 5DE8  G
	jsr	j_primm_xy			; 5DEA
	.byte	$D7,$BA,$00			; 5DED  W:.

	jsr	j_get_stats_ptr			; 5DF0
	ldy	#$1E				; 5DF3  ^
	lda	(ptr1),y			; 5DF5
	clc					; 5DF7
	adc	#$25				; 5DF8  %
	jsr	j_printstring			; 5DFA
	ldx	#$18				; 5DFD  X
	ldy	#$08				; 5DFF  H
	jsr	j_primm_xy			; 5E01
	.byte	$C1,$BA,$00			; 5E04  A:.

	jsr	j_get_stats_ptr			; 5E07
	ldy	#$1F				; 5E0A  _
	lda	(ptr1),y			; 5E0C
	clc					; 5E0E
	adc	#$35				; 5E0F  5
	jsr	j_printstring			; 5E11
	jsr	restore_console_pos		; 5E14
	jsr	L5E8E				; 5E17
	beq	L5E7A				; 5E1A
	bmi	L5E29				; 5E1C
	inc	currplayer			; 5E1E
	lda	party_size			; 5E20
	cmp	currplayer			; 5E22
	bcc	L5E30				; 5E24
	jmp	L5CC8				; 5E26

L5E29:
	dec	currplayer			; 5E29
	beq	L5E69				; 5E2B
	jmp	L5CC8				; 5E2D

L5E30:
	jsr	L5EA4				; 5E30
	jsr	L5E8E				; 5E33
	beq	L5E7A				; 5E36
	bpl	L5E41				; 5E38
	lda	party_size			; 5E3A
	sta	currplayer			; 5E3C
	jmp	L5CC8				; 5E3E

L5E41:
	jsr	L5F26				; 5E41
	jsr	L5E8E				; 5E44
	beq	L5E7A				; 5E47
	bmi	L5E30				; 5E49
L5E4B:
	jsr	L5FA4				; 5E4B
	jsr	L5E8E				; 5E4E
	beq	L5E7A				; 5E51
	bmi	L5E41				; 5E53
L5E55:
	jsr	L601A				; 5E55
	jsr	L5E8E				; 5E58
	beq	L5E7A				; 5E5B
	bmi	L5E4B				; 5E5D
L5E5F:
	jsr	L6144				; 5E5F
	jsr	L5E8E				; 5E62
	beq	L5E7A				; 5E65
	bmi	L5E55				; 5E67
L5E69:
	jsr	list_mixtures			; 5E69
	jsr	L5E8E				; 5E6C
	beq	L5E7A				; 5E6F
	bmi	L5E5F				; 5E71
	lda	#$01				; 5E73  A
	sta	currplayer			; 5E75
	jmp	L5CC8				; 5E77

L5E7A:
	jsr	j_clearstatwindow		; 5E7A
	jsr	j_update_status			; 5E7D
	lda	game_mode			; 5E80
	bpl	L5E8B				; 5E82
	lda	$45				; 5E84
	sta	currplayer			; 5E86
	jsr	invert_player_line		; 5E88
L5E8B:
	jmp	cmd_done			; 5E8B

L5E8E:
	jsr	j_waitkey			; 5E8E
	bpl	L5E8E				; 5E91
	cmp	#$87				; 5E93  G
	beq	L5E9E				; 5E95
	cmp	#$88				; 5E97  H
	beq	L5EA1				; 5E99
	lda	#$00				; 5E9B  .
	rts					; 5E9D

L5E9E:
	lda	#$FF				; 5E9E  .
	rts					; 5EA0

L5EA1:
	lda	#$01				; 5EA1  A
	rts					; 5EA3

L5EA4:
	jsr	j_clearstatwindow		; 5EA4
	jsr	save_console_pos		; 5EA7
	ldx	#$1B				; 5EAA  [
	ldy	#$00				; 5EAC  .
	sty	$58				; 5EAE
	sty	$59				; 5EB0
	jsr	j_primm_xy			; 5EB2
	.byte	$1F,$D7,$C5,$C1,$D0,$CF,$CE,$D3	; 5EB5  _WEAPONS
	.byte	$1D,$00				; 5EBD  ].

L5EBF:
	lda	$59				; 5EBF
	and	#$08				; 5EC1  H
	clc					; 5EC3
	adc	#$18				; 5EC4  X
	sta	console_xpos			; 5EC6
	lda	$59				; 5EC8
	and	#$07				; 5ECA  G
	sta	console_ypos			; 5ECC
	inc	console_ypos			; 5ECE
	lda	$58				; 5ED0
	beq	L5F16				; 5ED2
	clc					; 5ED4
	adc	#$20				; 5ED5   
	tay					; 5ED7
	lda	game_stats,y			; 5ED8
	beq	L5F0A				; 5EDB
	pha					; 5EDD
	lda	$58				; 5EDE
	clc					; 5EE0
	adc	#$C1				; 5EE1  A
	jsr	j_console_out			; 5EE3
	pla					; 5EE6
	cmp	#$10				; 5EE7  P
	bcs	L5EF8				; 5EE9
	pha					; 5EEB
	lda	#$AD				; 5EEC  -
	jsr	j_console_out			; 5EEE
	pla					; 5EF1
	jsr	j_printdigit			; 5EF2
	jmp	L5EFB				; 5EF5

L5EF8:
	jsr	j_printbcd			; 5EF8
L5EFB:
	lda	#$AD				; 5EFB  -
	jsr	j_console_out			; 5EFD
	lda	$58				; 5F00
	clc					; 5F02
	adc	#$3D				; 5F03  =
	jsr	j_printstring			; 5F05
	inc	$59				; 5F08
L5F0A:
	inc	$58				; 5F0A
	lda	$58				; 5F0C
	cmp	#$10				; 5F0E  P
	bcc	L5EBF				; 5F10
	jsr	restore_console_pos		; 5F12
	rts					; 5F15

L5F16:
	jsr	j_primm				; 5F16
	.byte	$C1,$AD,$C8,$C1,$CE,$C4,$D3,$00	; 5F19  A-HANDS.

	inc	$59				; 5F21
	jmp	L5F0A				; 5F23

L5F26:
	jsr	j_clearstatwindow		; 5F26
	jsr	save_console_pos		; 5F29
	ldx	#$1B				; 5F2C  [
	ldy	#$00				; 5F2E  .
	sty	$58				; 5F30
	sty	$59				; 5F32
	jsr	j_primm_xy			; 5F34
	.byte	$1F,$C1,$D2,$CD,$CF,$D5,$D2,$1C	; 5F37  _ARMOUR\
	.byte	$00				; 5F3F  .

L5F40:
	lda	#$18				; 5F40  X
	sta	console_xpos			; 5F42
	lda	$59				; 5F44
	sta	console_ypos			; 5F46
	inc	console_ypos			; 5F48
	lda	$58				; 5F4A
	beq	L5F90				; 5F4C
	clc					; 5F4E
	adc	#$18				; 5F4F  X
	tay					; 5F51
	lda	game_stats,y			; 5F52
	beq	L5F84				; 5F55
	pha					; 5F57
	lda	$58				; 5F58
	clc					; 5F5A
	adc	#$C1				; 5F5B  A
	jsr	j_console_out			; 5F5D
	pla					; 5F60
	cmp	#$10				; 5F61  P
	bcs	L5F72				; 5F63
	pha					; 5F65
	lda	#$AD				; 5F66  -
	jsr	j_console_out			; 5F68
	pla					; 5F6B
	jsr	j_printdigit			; 5F6C
	jmp	L5F75				; 5F6F

L5F72:
	jsr	j_printbcd			; 5F72
L5F75:
	lda	#$AD				; 5F75  -
	jsr	j_console_out			; 5F77
	lda	$58				; 5F7A
	clc					; 5F7C
	adc	#$35				; 5F7D  5
	jsr	j_printstring			; 5F7F
	inc	$59				; 5F82
L5F84:
	inc	$58				; 5F84
	lda	$58				; 5F86
	cmp	#$08				; 5F88  H
	bcc	L5F40				; 5F8A
	jsr	restore_console_pos		; 5F8C
	rts					; 5F8F

L5F90:
	jsr	j_primm				; 5F90
	.byte	$C1,$AD,$CE,$CF,$A0,$C1,$D2,$CD	; 5F93  A-NO ARM
	.byte	$CF,$D5,$D2,$00			; 5F9B  OUR.

	inc	$59				; 5F9F
	jmp	L5F84				; 5FA1

L5FA4:
	jsr	j_clearstatwindow		; 5FA4
	jsr	save_console_pos		; 5FA7
	ldx	#$1A				; 5FAA  Z
	ldy	#$00				; 5FAC  .
	jsr	j_primm_xy			; 5FAE
	.byte	$1E,$C5,$D1,$D5,$C9,$D0,$CD,$C5	; 5FB1  ^EQUIPME
	.byte	$CE,$D4,$1C,$00			; 5FB9  NT\.

	jsr	L612D				; 5FBD
	ldy	#$08				; 5FC0  H
	lda	game_stats,y			; 5FC2
	jsr	j_printbcd			; 5FC5
	jsr	j_primm				; 5FC8
	.byte	$AD,$D4,$CF,$D2,$C3,$C8,$C5,$D3	; 5FCB  -TORCHES
	.byte	$00				; 5FD3  .

	jsr	L612D				; 5FD4
	ldy	#$09				; 5FD7  I
	lda	game_stats,y			; 5FD9
	jsr	j_printbcd			; 5FDC
	jsr	j_primm				; 5FDF
	.byte	$AD,$C7,$C5,$CD,$D3,$00		; 5FE2  -GEMS.

	jsr	L612D				; 5FE8
	ldy	#$0A				; 5FEB  J
	lda	game_stats,y			; 5FED
	jsr	j_printbcd			; 5FF0
	jsr	j_primm				; 5FF3
	.byte	$AD,$CB,$C5,$D9,$D3,$00		; 5FF6  -KEYS.

	jsr	L612D				; 5FFC
	ldy	#$0B				; 5FFF  K
	lda	game_stats,y			; 6001
	beq	L6016				; 6004
	jsr	j_printbcd			; 6006
	jsr	j_primm				; 6009
	.byte	$AD,$D3,$C5,$D8,$D4,$C1,$CE,$D4	; 600C  -SEXTANT
	.byte	$D3,$00				; 6014  S.

L6016:
	jsr	restore_console_pos		; 6016
	rts					; 6019

L601A:
	jsr	j_clearstatwindow		; 601A
	jsr	save_console_pos		; 601D
	ldx	#$1C				; 6020  \
	ldy	#$00				; 6022  .
	jsr	j_primm_xy			; 6024
	.byte	$1E,$C9,$D4,$C5,$CD,$D3,$1C,$00	; 6027  ^ITEMS\.

	lda	#$00				; 602F  .
	sta	console_ypos			; 6031
	lda	$AB0C				; 6033
	beq	L605B				; 6036
	sta	$58				; 6038
	jsr	L612D				; 603A
	jsr	j_primm				; 603D
	.byte	$D3,$D4,$CF,$CE,$C5,$D3,$BA,$00	; 6040  STONES:.

	ldy	#$07				; 6048  G
L604A:
	rol	$58				; 604A
	bcc	L6058				; 604C
	sty	$59				; 604E
	lda	L6134,y				; 6050
	jsr	j_console_out			; 6053
	ldy	$59				; 6056
L6058:
	dey					; 6058
	bpl	L604A				; 6059
L605B:
	lda	$AB0D				; 605B
	beq	L6082				; 605E
	sta	$58				; 6060
	jsr	L612D				; 6062
	jsr	j_primm				; 6065
	.byte	$D2,$D5,$CE,$C5,$D3,$BA,$00	; 6068  RUNES:.

	ldy	#$07				; 606F  G
L6071:
	rol	$58				; 6071
	bcc	L607F				; 6073
	sty	$59				; 6075
	lda	L613C,y				; 6077
	jsr	j_console_out			; 607A
	ldy	$59				; 607D
L607F:
	dey					; 607F
	bpl	L6071				; 6080
L6082:
	lda	$AB0E				; 6082
	beq	L60BA				; 6085
	jsr	L612D				; 6087
	lda	$AB0E				; 608A
	and	#$04				; 608D  D
	beq	L609A				; 608F
	jsr	j_primm				; 6091
	.byte	$C2,$C5,$CC,$CC,$A0,$00		; 6094  BELL .

L609A:
	lda	$AB0E				; 609A
	and	#$02				; 609D  B
	beq	L60AA				; 609F
	jsr	j_primm				; 60A1
	.byte	$C2,$CF,$CF,$CB,$A0,$00		; 60A4  BOOK .

L60AA:
	lda	$AB0E				; 60AA
	and	#$01				; 60AD  A
	beq	L60DD				; 60AF
	jsr	j_primm				; 60B1
	.byte	$C3,$C1,$CE,$C4,$CC,$00		; 60B4  CANDL.

L60BA:
	lda	$AB0F				; 60BA
	beq	L60F5				; 60BD
	jsr	L612D				; 60BF
	jsr	j_primm				; 60C2
	.byte	$B3,$A0,$D0,$C1,$D2,$D4,$A0,$CB	; 60C5  3 PART K
	.byte	$C5,$D9,$BA,$00			; 60CD  EY:.

	lda	$AB0F				; 60D1
	and	#$04				; 60D4  D
	beq	L60DD				; 60D6
	lda	#$D4				; 60D8  T
	jsr	j_console_out			; 60DA
L60DD:
	lda	$AB0F				; 60DD
	and	#$02				; 60E0  B
	beq	L60E9				; 60E2
	lda	#$CC				; 60E4  L
	jsr	j_console_out			; 60E6
L60E9:
	lda	$AB0F				; 60E9
	and	#$01				; 60EC  A
	beq	L60F5				; 60EE
	lda	#$C3				; 60F0  C
	jsr	j_console_out			; 60F2
L60F5:
	lda	$AB15				; 60F5
	beq	L6105				; 60F8
	jsr	L612D				; 60FA
	jsr	j_primm				; 60FD
	.byte	$C8,$CF,$D2,$CE,$00		; 6100  HORN.

L6105:
	lda	$AB16				; 6105
	beq	L6116				; 6108
	jsr	L612D				; 610A
	jsr	j_primm				; 610D
	.byte	$D7,$C8,$C5,$C5,$CC,$00		; 6110  WHEEL.

L6116:
	lda	$AB17				; 6116
	beq	L6129				; 6119
	bmi	L6129				; 611B
	jsr	L612D				; 611D
	jsr	j_primm				; 6120
	.byte	$D3,$CB,$D5,$CC,$CC,$00		; 6123  SKULL.

L6129:
	jsr	restore_console_pos		; 6129
	rts					; 612C

L612D:
	inc	console_ypos			; 612D
	ldx	#$18				; 612F  X
	stx	console_xpos			; 6131
	rts					; 6133

L6134:
	.byte	$C2,$D7,$D0,$CF,$C7,$D2,$D9,$C2	; 6134  BWPOGRYB
L613C:
	.byte	$C8,$D3,$C8,$D3,$CA,$D6,$C3,$C8	; 613C  HSHSJVCH

L6144:
	jsr	j_clearstatwindow		; 6144
	jsr	save_console_pos		; 6147
	ldx	#$1A				; 614A  Z
	ldy	#$00				; 614C  .
	sty	$70				; 614E
	jsr	j_primm_xy			; 6150
	.byte	$1E,$D2,$C5,$C1,$C7,$C5,$CE,$D4	; 6153  ^REAGENT
	.byte	$D3,$1D,$00			; 615B  S].

L615E:
	clc					; 615E
	lda	$70				; 615F
	adc	#$38				; 6161  8
	tay					; 6163
	lda	game_stats,y			; 6164
	beq	L6199				; 6167
	sta	$6A				; 6169
	jsr	L612D				; 616B
	clc					; 616E
	lda	$70				; 616F
	adc	#$C1				; 6171  A
	jsr	j_console_out			; 6173
	lda	$6A				; 6176
	cmp	#$10				; 6178  P
	bcs	L6189				; 617A
	lda	#$AD				; 617C  -
	jsr	j_console_out			; 617E
	lda	$6A				; 6181
	jsr	j_printdigit			; 6183
	jmp	L618C				; 6186

L6189:
	jsr	j_printbcd			; 6189
L618C:
	lda	#$AD				; 618C  -
	jsr	j_console_out			; 618E
	clc					; 6191
	lda	$70				; 6192
	adc	#$5D				; 6194  ]
	jsr	j_printstring			; 6196
L6199:
	inc	$70				; 6199
	lda	$70				; 619B
	cmp	#$08				; 619D  H
	bcc	L615E				; 619F
	jsr	restore_console_pos		; 61A1
	rts					; 61A4

list_mixtures:
	jsr	j_clearstatwindow		; 61A5
	jsr	save_console_pos		; 61A8
	ldx	#$1A				; 61AB  Z
	ldy	#$00				; 61AD  .
	sty	$58				; 61AF
	sty	$59				; 61B1
	jsr	j_primm_xy			; 61B3
	.byte	$1E,$CD,$C9,$D8,$D4,$D5,$D2,$C5	; 61B6  ^MIXTURE
	.byte	$D3,$1D,$00			; 61BE  S].

@printlist:
	lda	$59				; 61C1
	lsr	a				; 61C3
	lsr	a				; 61C4
	lsr	a				; 61C5
	ldx	#$05				; 61C6  E
	jsr	j_mulax				; 61C8
	clc					; 61CB
	adc	#$18				; 61CC  X
	sta	console_xpos			; 61CE
	cmp	#$24				; 61D0  $
	bcs	@next				; 61D2
	lda	$59				; 61D4
	and	#$07				; 61D6  G
	sta	console_ypos			; 61D8
	inc	console_ypos			; 61DA
	ldy	$58				; 61DC
	lda	mixtures,y			; 61DE
	beq	@next				; 61E1
	lda	$58				; 61E3
	clc					; 61E5
	adc	#$C1				; 61E6  A
	jsr	j_console_out			; 61E8
	lda	#$AD				; 61EB  -
	jsr	j_console_out			; 61ED
	ldy	$58				; 61F0
	lda	mixtures,y			; 61F2
	jsr	j_printbcd			; 61F5
	inc	$59				; 61F8
@next:
	inc	$58				; 61FA
	lda	$58				; 61FC
	cmp	#$1A				; 61FE  Z
	bcc	@printlist			; 6200
	jsr	restore_console_pos		; 6202
	rts					; 6205

save_console_pos:
	lda	console_xpos			; 6206
	sta	L621C				; 6208
	lda	console_ypos			; 620B
	sta	L621D				; 620D
	rts					; 6210

restore_console_pos:
	lda	L621C				; 6211
	sta	console_xpos			; 6214
	lda	L621D				; 6216
	sta	console_ypos			; 6219
	rts					; 621B

L621C:
	.byte	$00				; 621C  .
L621D:
	.byte	$00				; 621D  .

cmd_done:
	jsr	check_party_alive		; 621E
	lda	game_mode			; 6221
	bpl	@notcombat			; 6223
	jmp	L7133				; 6225

@notcombat:
	lda	ship_hull			; 6228
	cmp	#$50				; 622A  P
	bcs	@noshipdamage			; 622C
	jsr	j_rand				; 622E
	and	#$03				; 6231  C
	bne	@noshipdamage			; 6233
	lda	ship_hull			; 6235
	sed					; 6237
	clc					; 6238
	adc	#$01				; 6239  A
	cld					; 623B
	sta	ship_hull			; 623C
@noshipdamage:
	lda	party_size			; 623E
	sta	currplayer			; 6240
@checkstatus:
	jsr	j_get_stats_ptr			; 6242
	ldy	#$12				; 6245  R
	lda	(ptr1),y			; 6247
	cmp	#$D3				; 6249  S
	bne	@checkpoison			; 624B
	jsr	j_rand				; 624D
	and	#$07				; 6250  G
	bne	@next				; 6252
	lda	#$C7				; 6254  G
	sta	(ptr1),y			; 6256
	jmp	@next				; 6258

@checkpoison:
	cmp	#$D0				; 625B  P
	bne	@next				; 625D
	lda	#$02				; 625F  B
	jsr	stat_sub_hp			; 6261
	jsr	invert_player_line		; 6264
	lda	#$06				; 6267  F
	jsr	j_playsfx			; 6269
	jsr	invert_player_line		; 626C
@next:
	dec	currplayer			; 626F
	bne	@checkstatus			; 6271
	lda	party_size			; 6273
	jsr	stat_eat_food			; 6275
	bcs	@dontstarve			; 6278
	jsr	starve				; 627A
@dontstarve:
	jsr	party_add_mp			; 627D
	lda	movement_mode			; 6280
	bmi	@notfastorflying		; 6282
	jsr	check_whirlpool_storm		; 6284
	jsr	spawn_random_monster		; 6287
	jsr	move_creatures			; 628A
	jsr	check_whirlpool_storm		; 628D
@notfastorflying:
	lda	game_mode			; 6290
	cmp	#$03				; 6292  C
	bne	@notdungeon			; 6294
	jsr	j_print_direction		; 6296
	jsr	dungeon_check_tile		; 6299
	lda	tile_under_player		; 629C
	and	#$F0				; 629E  p
	cmp	#$D0				; 62A0  P
	bne	@notdungeon			; 62A2
	jmp	dungeon_room			; 62A4

@notdungeon:
	lda	light_duration			; 62A7
	beq	@dark				; 62A9
	dec	light_duration			; 62AB
@dark:
	jmp	update_counters			; 62AD

check_triggers:
	lda	game_mode			; 62B0
	cmp	#$01				; 62B2  A
	bne	@notrolls			; 62B4
	lda	tile_under_player		; 62B6
	cmp	#$17				; 62B8  W
	bne	@notrolls			; 62BA
	jsr	j_rand				; 62BC
	and	#$07				; 62BF  G
	bne	@notrolls			; 62C1
	jsr	j_primm				; 62C3
	.byte	$8D,$C2,$D2,$C9,$C4,$C7,$C5,$A0	; 62C6  MBRIDGE 
	.byte	$D4,$D2,$CF,$CC,$CC,$D3,$A1,$8D	; 62CE  TROLLS!M
	.byte	$00				; 62D6  .

	lda	#$A4				; 62D7  $
	sta	attacking_monster_type		; 62D9
	lda	player_xpos			; 62DB
	sta	attacking_monster_xpos		; 62DD
	lda	player_ypos			; 62DF
	sta	attacking_monster_ypos		; 62E1
	lda	#$17				; 62E3  W
	sta	attacking_monster_terrain	; 62E5
	jmp	generate_combat			; 62E7

@notrolls:
	lda	movement_mode			; 62EA
	bpl	L62EF				; 62EC
	rts					; 62EE

L62EF:
	lda	game_mode			; 62EF
	bmi	L62FC				; 62F1
	cmp	#$03				; 62F3  C
	beq	L6359				; 62F5
	lda	tile_under_player		; 62F7
	jmp	L63B9				; 62F9

L62FC:
	ldx	currplayer			; 62FC
	lda	$AD9F,x				; 62FE
	beq	L6356				; 6301
	lda	$AD7F,x				; 6303
	sta	$16				; 6306
	lda	$AD8F,x				; 6308
	sta	$17				; 630B
	jsr	j_gettile_combat		; 630D
	cmp	#$03				; 6310  C
	beq	L632A				; 6312
	cmp	#$44				; 6314  D
	beq	L632A				; 6316
	cmp	#$46				; 6318  F
	beq	L6324				; 631A
	cmp	#$47				; 631C  G
	beq	L6340				; 631E
	cmp	#$4C				; 6320  L
	bne	L6356				; 6322
L6324:
	jsr	hurt_player_random_val		; 6324
	jmp	L6356				; 6327

L632A:
	jsr	check_awake			; 632A
	lda	(ptr1),y			; 632D
	cmp	#$C7				; 632F  G
	bne	L6356				; 6331
	lda	#$D0				; 6333  P
	sta	(ptr1),y			; 6335
	jsr	flash_player_line		; 6337
	jsr	j_update_status			; 633A
	jmp	L6356				; 633D

L6340:
	jsr	check_awake			; 6340
	bmi	L6356				; 6343
	lda	#$D3				; 6345  S
	sta	(ptr1),y			; 6347
	ldx	currplayer			; 6349
	lda	#$38				; 634B  8
	sta	$AD9F,x				; 634D
	jsr	flash_player_line		; 6350
	jsr	j_update_status			; 6353
L6356:
	jmp	L63D0				; 6356

L6359:
	lda	tile_under_player		; 6359
	and	#$F0				; 635B  p
	cmp	#$A0				; 635D   
	bne	L6372				; 635F
	lda	tile_under_player		; 6361
	and	#$03				; 6363  C
	beq	L63D3				; 6365
	cmp	#$02				; 6367  B
	beq	L63CD				; 6369
	cmp	#$03				; 636B  C
	bne	L63D0				; 636D
	jmp	L63FA				; 636F

L6372:
	cmp	#$80				; 6372  .
	bne	L63D0				; 6374
	lda	tile_under_player		; 6376
	and	#$0F				; 6378  O
	beq	L6382				; 637A
	cmp	#$08				; 637C  H
	bcc	L6395				; 637E
	bcs	L63AC				; 6380
L6382:
	jsr	j_primm				; 6382
	.byte	$8D,$D7,$C9,$CE,$C4,$D3,$A1,$8D	; 6385  MWINDS!M
	.byte	$00				; 638D  .

	lda	#$00				; 638E  .
	sta	light_duration			; 6390
	jmp	L63D0				; 6392

L6395:
	jsr	j_primm				; 6395
	.byte	$8D,$C6,$C1,$CC,$CC,$C9,$CE,$C7	; 6398  MFALLING
	.byte	$A0,$D2,$CF,$C3,$CB,$D3,$A1,$8D	; 63A0   ROCKS!M
	.byte	$00				; 63A8  .

	jmp	L63CD				; 63A9

L63AC:
	jsr	j_primm				; 63AC
	.byte	$8D,$D0,$C9,$D4,$A1,$8D,$00	; 63AF  MPIT!M.

	jmp	L63CD				; 63B6

L63B9:
	cmp	#$03				; 63B9  C
	beq	L63D3				; 63BB
	cmp	#$44				; 63BD  D
	beq	L63D3				; 63BF
	cmp	#$46				; 63C1  F
	beq	L63CD				; 63C3
	cmp	#$47				; 63C5  G
	beq	L63FA				; 63C7
	cmp	#$4C				; 63C9  L
	bne	L63D0				; 63CB
L63CD:
	jsr	hurt_all_players		; 63CD
L63D0:
	jmp	L641D				; 63D0

L63D3:
	lda	party_size			; 63D3
	sta	currplayer			; 63D5
L63D7:
	jsr	check_awake			; 63D7
	lda	(ptr1),y			; 63DA
	cmp	#$C7				; 63DC  G
	bne	L641D				; 63DE
	jsr	j_rand				; 63E0
	and	#$07				; 63E3  G
	bne	L63F3				; 63E5
	lda	#$D0				; 63E7  P
	ldy	#$12				; 63E9  R
	sta	(ptr1),y			; 63EB
	jsr	flash_player_line		; 63ED
	jsr	j_update_status			; 63F0
L63F3:
	dec	currplayer			; 63F3
	bne	L63D7				; 63F5
	jmp	L641D				; 63F7

L63FA:
	lda	party_size			; 63FA
	sta	currplayer			; 63FC
L63FE:
	jsr	check_awake			; 63FE
	bmi	L6416				; 6401
	jsr	j_rand				; 6403
	and	#$03				; 6406  C
	bne	L6416				; 6408
	lda	#$D3				; 640A  S
	ldy	#$12				; 640C  R
	sta	(ptr1),y			; 640E
	jsr	flash_player_line		; 6410
	jsr	j_update_status			; 6413
L6416:
	dec	currplayer			; 6416
	bne	L63FE				; 6418
	jmp	L641D				; 641A

L641D:
	rts					; 641D

starve:
	jsr	j_primm				; 641E
	.byte	$8D,$D3,$D4,$C1,$D2,$D6,$C9,$CE	; 6421  MSTARVIN
	.byte	$C7,$A1,$A1,$A1,$8D,$00		; 6429  G!!!M.

	lda	party_size			; 642F
	sta	currplayer			; 6431
@checkplayer:
	jsr	check_alive			; 6433
	bmi	@dead				; 6436
	lda	#$02				; 6438  B
	jsr	stat_sub_hp			; 643A
@dead:
	dec	currplayer			; 643D
	bne	@checkplayer			; 643F
	jsr	invert_all_player_lines		; 6441
	lda	#$06				; 6444  F
	jsr	j_playsfx			; 6446
	jsr	invert_all_player_lines		; 6449
	rts					; 644C

party_add_mp:
	lda	party_size			; 644D
	sta	currplayer			; 644F
@next:
	jsr	check_alive			; 6451
	bmi	@done				; 6454
	ldy	#$11				; 6456  Q
	lda	(ptr1),y			; 6458
	sta	$58				; 645A
	ldy	#$15				; 645C  U
	lda	(ptr1),y			; 645E
	jsr	bcdtohex			; 6460
	asl	a				; 6463
	ldx	$58				; 6464
	beq	@timestwo			; 6466
	dex					; 6468
	beq	@timesone			; 6469
	dex					; 646B
	beq	@nomp				; 646C
	dex					; 646E
	beq	@oneandahalf			; 646F
	dex					; 6471
	beq	@onehalf			; 6472
	dex					; 6474
	beq	@timesone			; 6475
	dex					; 6477
	beq	@timesone			; 6478
@nomp:
	lda	#$00				; 647A  .
	jmp	@timestwo			; 647C

@onehalf:
	lsr	a				; 647F
	lsr	a				; 6480
	jmp	@timestwo			; 6481

@timesone:
	lsr	a				; 6484
	jmp	@timestwo			; 6485

@oneandahalf:
	lsr	a				; 6488
	sta	$58				; 6489
	lsr	a				; 648B
	adc	$58				; 648C
@timestwo:
	jsr	hextobcd			; 648E
	sta	$58				; 6491
	ldy	#$16				; 6493  V
	lda	(ptr1),y			; 6495
	cmp	$58				; 6497
	bcs	@done				; 6499
	sed					; 649B
	clc					; 649C
	adc	#$01				; 649D  A
	cld					; 649F
	sta	(ptr1),y			; 64A0
@done:
	dec	currplayer			; 64A2
	bpl	@next				; 64A4
	rts					; 64A6

	.byte	$0D,$20,$06,$87,$01,$3E,$31,$0D	; 64A7  M FGA>1M
	.byte	$20,$04,$9C,$00,$0D,$20,$06,$87	; 64AF   D\.M FG
	.byte	$01,$3E,$32,$0D,$20,$04,$9C,$00	; 64B7  A>2M D\.
	.byte	$0D,$20,$06,$87,$01,$3E,$33,$0D	; 64BF  M FGA>3M
	.byte	$20,$06,$86,$01,$3E,$39,$0D,$20	; 64C7   FFA>9M 
	.byte	$03,$3B,$0D,$20,$0F,$5E,$30,$20	; 64CF  C;M O^0 
	.byte	$20,$20,$20,$20,$20,$CB,$01,$50	; 64D7       KAP
	.byte	$52,$57,$0D,$20,$06,$CA,$01,$3E	; 64DF  RWM FJA>
	.byte	$39,$0D,$20,$0F,$5E,$31,$20,$20	; 64E7  9M O^1  
	.byte	$20,$20,$20,$20,$CB,$01,$50,$52	; 64EF      KAPR
	.byte	$4E,$0D,$20,$06,$CA,$01,$3E,$39	; 64F7  NM FJA>9
	.byte	$0D				; 64FF  M

stat_eat_food:
	sta	$58				; 6500
	sed					; 6502
	sec					; 6503
	lda	food_frac			; 6504
	sbc	$58				; 6507
	sta	food_frac			; 6509
	bcs	@done				; 650C
	lda	food_lo				; 650E
	sbc	#$00				; 6511  .
	sta	food_lo				; 6513
	bcs	@done				; 6516
	lda	food_hi				; 6518
	sbc	#$00				; 651B  .
	sta	food_hi				; 651D
	bcs	@done				; 6520
	lda	#$00				; 6522  .
	sta	food_frac			; 6524
	sta	food_lo				; 6527
	sta	food_hi				; 652A
	clc					; 652D
@done:
	cld					; 652E
	rts					; 652F

spawn_random_monster:
	lda	game_mode			; 6530
	cmp	#$01				; 6532  A
	bne	@notbritannia			; 6534
	jmp	spawn_monster_britannia		; 6536

@notbritannia:
	cmp	#$03				; 6539  C
	bne	@notdngeither			; 653B
	jmp	spawn_monster_dungeon		; 653D

@notdngeither:
	rts					; 6540

spawn_monster_britannia:
	jsr	j_rand				; 6541
	and	#$0F				; 6544  O
	beq	@spawnmonster			; 6546
	jmp	@done				; 6548

@spawnmonster:
	lda	map_x				; 654B
	asl	a				; 654D
	asl	a				; 654E
	asl	a				; 654F
	asl	a				; 6550
	sta	$76				; 6551
	lda	map_y				; 6553
	asl	a				; 6555
	asl	a				; 6556
	asl	a				; 6557
	asl	a				; 6558
	sta	$77				; 6559
	sec					; 655B
	lda	tile_xpos			; 655C
	sbc	#$05				; 655E  E
	sta	$78				; 6560
	sec					; 6562
	lda	tile_ypos			; 6563
	sbc	#$05				; 6565  E
@landcreature:
	sta	$79				; 6567
	ldx	#$03				; 6569  C
@checkobjectslot:
	lda	object_tile,x			; 656B
	bne	@notthisslot			; 656E
	jsr	j_rand				; 6570
	and	#$1F				; 6573  _
	sta	$16				; 6575
	sec					; 6577
	sbc	$78				; 6578
	cmp	#$0B				; 657A  K
	bcc	@notthisslot			; 657C
	jsr	j_rand				; 657E
	and	#$1F				; 6581  _
	sta	$17				; 6583
	sec					; 6585
	sbc	$79				; 6586
	cmp	#$0B				; 6588  K
	bcc	@notthisslot			; 658A
	jsr	j_gettile			; 658C
	cmp	#$02				; 658F  B
	bcc	@seacreature			; 6591
	cmp	#$04				; 6593  D
	bcc	@notthisslot			; 6595
	cmp	#$08				; 6597  H
	bcs	@notthisslot			; 6599
	clc					; 659B
	lda	$16				; 659C
	adc	$76				; 659E
	sta	object_xpos,x			; 65A0
	clc					; 65A3
	lda	$17				; 65A4
	adc	$77				; 65A6
	sta	object_ypos,x			; 65A8
	lda	move_counter			; 65AB
	bne	@maxdaemon			; 65AD
	lda	move_counter+1			; 65AF
	cmp	#$01				; 65B1  A
	bcc	@maxsnake			; 65B3
	beq	@maxwisp			; 65B5
	cmp	#$03				; 65B7  C
	bcs	@maxdaemon			; 65B9
@maxwisp:
	lda	#$07				; 65BB  G
	jmp	L65C7				; 65BD

@maxsnake:
	lda	#$03				; 65C0  C
	jmp	L65C7				; 65C2

@maxdaemon:
	lda	#$0F				; 65C5  O
L65C7:
	sta	$58				; 65C7
	jsr	j_rand				; 65C9
	and	$58				; 65CC
	sta	$58				; 65CE
	jsr	j_rand				; 65D0
	and	$58				; 65D3
	asl	a				; 65D5
	asl	a				; 65D6
	adc	#$C0				; 65D7  @
	sta	object_tile,x			; 65D9
	sta	map_status,x			; 65DC
@notthisslot:
	jmp	@nextslot			; 65DF

@seacreature:
	jsr	j_rand				; 65E2
	and	#$07				; 65E5  G
	bne	@nextslot			; 65E7
	clc					; 65E9
	lda	$16				; 65EA
	adc	$76				; 65EC
	sta	object_xpos,x			; 65EE
	clc					; 65F1
	lda	$17				; 65F2
	adc	$77				; 65F4
	sta	object_ypos,x			; 65F6
	jsr	j_rand				; 65F9
	and	#$07				; 65FC  G
	asl	a				; 65FE
	adc	#$80				; 65FF  .
	cmp	#$82				; 6601  B
	bne	@gotcreature			; 6603
	lda	#$80				; 6605  .
@gotcreature:
	sta	object_tile,x			; 6607
	sta	map_status,x			; 660A
@nextslot:
	dex					; 660D
	bmi	@done				; 660E
	jmp	@checkobjectslot		; 6610

@done:
	rts					; 6613

spawn_monster_dungeon:
	lda	dungeon_level			; 6614
	asl	a				; 6616
	asl	a				; 6617
	adc	#$01				; 6618  A
	tax					; 661A
@checkobjectslot:
	lda	object_tile,x			; 661B
	bne	@notthisslot			; 661E
	stx	$58				; 6620
	jsr	j_rand				; 6622
	and	#$07				; 6625  G
	sta	$16				; 6627
	cmp	player_xpos			; 6629
	beq	@notthisslot			; 662B
	jsr	j_rand				; 662D
	and	#$07				; 6630  G
	sta	$17				; 6632
	cmp	player_ypos			; 6634
	beq	@notthisslot			; 6636
	jsr	j_gettile_dungeon		; 6638
	bne	@notthisslot			; 663B
	jsr	j_rand				; 663D
	and	#$03				; 6640  C
	clc					; 6642
	adc	dungeon_level			; 6643
	asl	a				; 6645
	asl	a				; 6646
	adc	#$90				; 6647  P
	cmp	#$AC				; 6649  ,
	beq	@notthisslot			; 664B
	ldx	$58				; 664D
	sta	object_tile,x			; 664F
	lda	$16				; 6652
	sta	object_xpos,x			; 6654
	sta	$AC80,x				; 6657
	lda	$17				; 665A
	sta	object_ypos,x			; 665C
	sta	$ACA0,x				; 665F
	lda	dungeon_level			; 6662
	sta	$ACC0,x				; 6664
	lda	object_tile,x			; 6667
	jsr	L6A83				; 666A
	ora	(ptr1),y			; 666D
	sta	(ptr1),y			; 666F
@notthisslot:
	dex					; 6671
	bmi	@listfull			; 6672
	txa					; 6674
	lsr	a				; 6675
	lsr	a				; 6676
	cmp	dungeon_level			; 6677
	bcs	@checkobjectslot		; 6679
@listfull:
	rts					; 667B

move_creatures:
	lda	game_mode			; 667C
	cmp	#$01				; 667E  A
	bne	@towne				; 6680
	jmp	update_creatures_britannia	; 6682

@towne:
	cmp	#$02				; 6685  B
	bne	@dungeon			; 6687
	jmp	move_creatures_towne		; 6689

@dungeon:
	cmp	#$03				; 668C  C
	bne	@done				; 668E
	jmp	move_creatures_dungeon		; 6690

@done:
	rts					; 6693

update_creatures_britannia:
	lda	map_x				; 6694
	asl	a				; 6696
	asl	a				; 6697
	asl	a				; 6698
	asl	a				; 6699
	sta	$76				; 669A
	lda	map_y				; 669C
	asl	a				; 669E
	asl	a				; 669F
	asl	a				; 66A0
	asl	a				; 66A1
	sta	$77				; 66A2
	ldx	#$07				; 66A4  G
@checkcreature:
	lda	object_tile,x			; 66A6
	beq	@next				; 66A9
	sec					; 66AB
	lda	object_xpos,x			; 66AC
	sbc	$76				; 66AF
	cmp	#$20				; 66B1   
	bcs	@deletecreature			; 66B3
	sec					; 66B5
	lda	object_ypos,x			; 66B6
	sbc	$77				; 66B9
	cmp	#$20				; 66BB   
	bcs	@deletecreature			; 66BD
	stx	$58				; 66BF
	jsr	@checkaction			; 66C1
	ldx	$58				; 66C4
	jmp	@next				; 66C6

@deletecreature:
	lda	#$00				; 66C9  .
	sta	object_tile,x			; 66CB
	sta	map_status,x			; 66CE
@next:
	dex					; 66D1
	bpl	@checkcreature			; 66D2
	rts					; 66D4

@checkaction:
	lda	object_tile,x			; 66D5
	cmp	#$8C				; 66D8  L
	beq	creature_move			; 66DA
	cmp	#$8E				; 66DC  N
	beq	creature_move			; 66DE
	jsr	obj_player_distance		; 66E0
	cmp	#$02				; 66E3  B
	bcs	creature_move			; 66E5
creature_attack:
	jsr	j_idle				; 66E7
	jsr	j_primm				; 66EA
	.byte	$8D,$C1,$D4,$D4,$C1,$C3,$CB,$C5	; 66ED  MATTACKE
	.byte	$C4,$A0,$C2,$D9,$8D,$00		; 66F5  D BYM.

	jsr	print_object_name		; 66FB
	ldx	$58				; 66FE
	lda	object_xpos,x			; 6700
	sta	$7A				; 6703
	lda	object_ypos,x			; 6705
	sta	$7B				; 6708
	pla					; 670A
	pla					; 670B
	jmp	prepare_combat			; 670C

creature_move:
	cmp	#$04				; 670F  D
	bcs	L673A				; 6711
	lda	object_tile,x			; 6713
	cmp	#$80				; 6716  .
	beq	L671D				; 6718
	jmp	L6825				; 671A

L671D:
	lda	map_status,x			; 671D
	cmp	#$80				; 6720  .
	beq	L6733				; 6722
	cmp	#$81				; 6724  A
	beq	L672C				; 6726
	cmp	#$82				; 6728  B
	beq	L6733				; 672A
L672C:
	lda	$79				; 672C
	bne	L673A				; 672E
	jmp	L6B80				; 6730

L6733:
	lda	$78				; 6733
	bne	L673A				; 6735
	jmp	L6B80				; 6737

L673A:
	lda	object_tile,x			; 673A
	cmp	#$80				; 673D  .
	beq	L6744				; 673F
	jmp	L6825				; 6741

L6744:
	lda	map_status,x			; 6744
	cmp	#$80				; 6747  .
	bne	L6751				; 6749
	lda	$78				; 674B
	bmi	L67A8				; 674D
	bpl	L676F				; 674F
L6751:
	cmp	#$81				; 6751  A
	bne	L675B				; 6753
	lda	$79				; 6755
	bmi	L67CA				; 6757
	bpl	L676F				; 6759
L675B:
	cmp	#$82				; 675B  B
	bne	L6767				; 675D
	lda	$78				; 675F
	beq	L676F				; 6761
	bpl	L67A8				; 6763
	bmi	L676F				; 6765
L6767:
	lda	$79				; 6767
	beq	L676F				; 6769
	bpl	L67CA				; 676B
	bmi	L676F				; 676D
L676F:
	jsr	obj_player_distance		; 676F
	cmp	#$06				; 6772  F
	bcs	L67ED				; 6774
	jsr	j_rand				; 6776
	and	#$03				; 6779  C
	beq	L67ED				; 677B
	lda	map_status,x			; 677D
	cmp	#$80				; 6780  .
	bne	L678B				; 6782
	lda	#$FF				; 6784  .
	sta	$78				; 6786
	jmp	L67A8				; 6788

L678B:
	cmp	#$81				; 678B  A
	bne	L6796				; 678D
	lda	#$FF				; 678F  .
	sta	$79				; 6791
	jmp	L67CA				; 6793

L6796:
	cmp	#$82				; 6796  B
	bne	L67A1				; 6798
	lda	#$01				; 679A  A
	sta	$78				; 679C
	jmp	L67A8				; 679E

L67A1:
	lda	#$01				; 67A1  A
	sta	$79				; 67A3
	jmp	L67CA				; 67A5

L67A8:
	clc					; 67A8
	lda	object_xpos,x			; 67A9
	adc	$78				; 67AC
	sta	$7A				; 67AE
	lda	object_ypos,x			; 67B0
	sta	$7B				; 67B3
	jsr	j_gettile_bounds		; 67B5
	jsr	L7E1D				; 67B8
	bne	L6813				; 67BB
	lda	map_status,x			; 67BD
	and	#$03				; 67C0  C
	jsr	check_wind_direction		; 67C2
	bne	L67EC				; 67C5
	jmp	L68D3				; 67C7

L67CA:
	clc					; 67CA
	lda	object_xpos,x			; 67CB
	sta	$7A				; 67CE
	lda	object_ypos,x			; 67D0
	adc	$79				; 67D3
	sta	$7B				; 67D5
	jsr	j_gettile_bounds		; 67D7
	jsr	L7E1D				; 67DA
	bne	L6813				; 67DD
	lda	map_status,x			; 67DF
	and	#$03				; 67E2  C
	jsr	check_wind_direction		; 67E4
	bne	L67EC				; 67E7
	jmp	L68D3				; 67E9

L67EC:
	rts					; 67EC

L67ED:
	lda	$7A				; 67ED
	cmp	$7B				; 67EF
	bcs	L6803				; 67F1
	lda	$7B				; 67F3
	bpl	L67FD				; 67F5
	lda	#$81				; 67F7  A
	sta	map_status,x			; 67F9
	rts					; 67FC

L67FD:
	lda	#$83				; 67FD  C
	sta	map_status,x			; 67FF
	rts					; 6802

L6803:
	lda	$7A				; 6803
	bpl	L680D				; 6805
	lda	#$80				; 6807  .
	sta	map_status,x			; 6809
	rts					; 680C

L680D:
	lda	#$82				; 680D  B
	sta	map_status,x			; 680F
	rts					; 6812

L6813:
	jsr	j_rand				; 6813
	jsr	getsign				; 6816
	clc					; 6819
	adc	map_status,x			; 681A
	and	#$03				; 681D  C
	ora	#$80				; 681F  .
	sta	map_status,x			; 6821
	rts					; 6824

L6825:
	lda	object_tile,x			; 6825
	cmp	#$88				; 6828  H
	beq	L6834				; 682A
	cmp	#$E8				; 682C  h
	beq	L6834				; 682E
	cmp	#$F4				; 6830  t
	bcc	L6853				; 6832
L6834:
	jsr	obj_player_distance		; 6834
	lda	$7A				; 6837
	jsr	getabs				; 6839
	cmp	#$05				; 683C  E
	bcs	L6853				; 683E
	lda	$7B				; 6840
	jsr	getabs				; 6842
	cmp	#$05				; 6845  E
	bcs	L6853				; 6847
	jsr	j_rand				; 6849
	bmi	L6853				; 684C
	jsr	L6BA0				; 684E
	ldx	$58				; 6851
L6853:
	lda	#$02				; 6853  B
	sta	$70				; 6855
	lda	object_tile,x			; 6857
	cmp	#$8C				; 685A  L
	beq	L68BE				; 685C
	cmp	#$8E				; 685E  N
	beq	L68BE				; 6860
	jsr	check_evil			; 6862
	bmi	L686E				; 6865
	jsr	j_rand				; 6867
	and	#$03				; 686A  C
	bne	L68BE				; 686C
L686E:
	jsr	j_rand				; 686E
	bmi	L688C				; 6871
	lda	$78				; 6873
	beq	L688C				; 6875
	clc					; 6877
	lda	object_xpos,x			; 6878
	adc	$78				; 687B
	sta	$7A				; 687D
	lda	object_ypos,x			; 687F
	sta	$7B				; 6882
	jsr	j_gettile_bounds		; 6884
	jsr	L7E1D				; 6887
	beq	L68D3				; 688A
L688C:
	lda	$79				; 688C
	beq	L68A5				; 688E
	lda	object_xpos,x			; 6890
	sta	$7A				; 6893
	clc					; 6895
	lda	object_ypos,x			; 6896
	adc	$79				; 6899
	sta	$7B				; 689B
	jsr	j_gettile_bounds		; 689D
	jsr	L7E1D				; 68A0
	beq	L68D3				; 68A3
L68A5:
	lda	$78				; 68A5
	beq	L68BE				; 68A7
	clc					; 68A9
	lda	object_xpos,x			; 68AA
	adc	$78				; 68AD
	sta	$7A				; 68AF
	lda	object_ypos,x			; 68B1
	sta	$7B				; 68B4
	jsr	j_gettile_bounds		; 68B6
	jsr	L7E1D				; 68B9
	beq	L68D3				; 68BC
L68BE:
	jsr	j_rand				; 68BE
	jsr	getsign				; 68C1
	sta	$78				; 68C4
	jsr	j_rand				; 68C6
	jsr	getsign				; 68C9
	sta	$79				; 68CC
	dec	$70				; 68CE
	bne	L686E				; 68D0
	rts					; 68D2

L68D3:
	lda	object_xpos,x			; 68D3
	sta	$AC80,x				; 68D6
	lda	object_ypos,x			; 68D9
	sta	$ACA0,x				; 68DC
	lda	$7A				; 68DF
	sta	object_xpos,x			; 68E1
	lda	$7B				; 68E4
	sta	object_ypos,x			; 68E6
	rts					; 68E9

move_creatures_towne:
	cmp	#$10				; 68EA  P
	bcc	L68EF				; 68EC
	rts					; 68EE

L68EF:
	ldx	#$1F				; 68EF  _
L68F1:
	lda	#$02				; 68F1  B
	sta	$70				; 68F3
	lda	object_tile,x			; 68F5
	beq	L692C				; 68F8
	lda	$ACC0,x				; 68FA
	beq	L692C				; 68FD
	bmi	L6919				; 68FF
	jsr	j_rand				; 6901
	bmi	L692C				; 6904
L6906:
	jsr	j_rand				; 6906
	jsr	getsign				; 6909
	sta	$78				; 690C
	jsr	j_rand				; 690E
	jsr	getsign				; 6911
	sta	$79				; 6914
	jmp	L692F				; 6916

L6919:
	jsr	L6C5A				; 6919
	cmp	#$02				; 691C  B
	bcs	L692F				; 691E
	lda	$ACC0,x				; 6920
	cmp	#$FF				; 6923  .
	bne	L692F				; 6925
	stx	$58				; 6927
	jsr	creature_attack			; 6929
L692C:
	jmp	L69AB				; 692C

L692F:
	jsr	j_rand				; 692F
	bmi	L694D				; 6932
	lda	$78				; 6934
	beq	L694D				; 6936
	clc					; 6938
	lda	object_xpos,x			; 6939
	adc	$78				; 693C
	sta	$7A				; 693E
	lda	object_ypos,x			; 6940
	sta	$7B				; 6943
	jsr	j_gettile_town			; 6945
	jsr	L7E1D				; 6948
	beq	L6989				; 694B
L694D:
	lda	$79				; 694D
	beq	L6966				; 694F
	clc					; 6951
	lda	object_ypos,x			; 6952
	adc	$79				; 6955
	sta	$7B				; 6957
	lda	object_xpos,x			; 6959
	sta	$7A				; 695C
	jsr	j_gettile_town			; 695E
	jsr	L7E1D				; 6961
	beq	L6989				; 6964
L6966:
	clc					; 6966
	lda	object_xpos,x			; 6967
	adc	$78				; 696A
	sta	$7A				; 696C
	lda	object_ypos,x			; 696E
	sta	$7B				; 6971
	jsr	j_gettile_town			; 6973
	jsr	L7E1D				; 6976
	beq	L6989				; 6979
	lda	$ACC0,x				; 697B
	cmp	#$80				; 697E  .
	beq	L69AB				; 6980
	dec	$70				; 6982
	bmi	L69AB				; 6984
	jmp	L6906				; 6986

L6989:
	lda	$7A				; 6989
	cmp	#$20				; 698B   
	bcs	L69AB				; 698D
	lda	$7B				; 698F
	cmp	#$20				; 6991   
	bcs	L69AB				; 6993
	lda	object_xpos,x			; 6995
	sta	$AC80,x				; 6998
	lda	object_ypos,x			; 699B
	sta	$ACA0,x				; 699E
	lda	$7A				; 69A1
	sta	object_xpos,x			; 69A3
	lda	$7B				; 69A6
	sta	object_ypos,x			; 69A8
L69AB:
	dex					; 69AB
	bmi	L69B1				; 69AC
	jmp	L68F1				; 69AE

L69B1:
	rts					; 69B1

move_creatures_dungeon:
	ldx	#$1F				; 69B2  _
L69B4:
	lda	object_tile,x			; 69B4
	beq	L69D2				; 69B7
	lda	$ACC0,x				; 69B9
	cmp	dungeon_level			; 69BC
	bne	L69D2				; 69BE
	lda	object_tile,x			; 69C0
	cmp	#$AC				; 69C3  ,
	beq	L69D2				; 69C5
	cmp	#$B0				; 69C7  0
	beq	L69D2				; 69C9
	lda	#$07				; 69CB  G
	sta	$70				; 69CD
	jmp	L69D5				; 69CF

L69D2:
	jmp	L6A79				; 69D2

L69D5:
	lda	object_xpos,x			; 69D5
	cmp	player_xpos			; 69D8
	bne	L69E3				; 69DA
	lda	object_ypos,x			; 69DC
	cmp	player_ypos			; 69DF
	beq	L69D2				; 69E1
L69E3:
	jsr	j_rand				; 69E3
	jsr	getsign				; 69E6
	sta	$78				; 69E9
	jsr	j_rand				; 69EB
	jsr	getsign				; 69EE
	sta	$79				; 69F1
	jsr	j_rand				; 69F3
	bmi	L6A11				; 69F6
	lda	$78				; 69F8
	beq	L6A11				; 69FA
	clc					; 69FC
	adc	object_xpos,x			; 69FD
	and	#$07				; 6A00  G
	sta	$16				; 6A02
	lda	object_ypos,x			; 6A04
	sta	$17				; 6A07
	jsr	j_gettile_dungeon		; 6A09
	jsr	L7FB0				; 6A0C
	beq	L6A48				; 6A0F
L6A11:
	lda	$79				; 6A11
	beq	L6A2A				; 6A13
	clc					; 6A15
	adc	object_ypos,x			; 6A16
	and	#$07				; 6A19  G
	sta	$17				; 6A1B
	lda	object_xpos,x			; 6A1D
	sta	$16				; 6A20
	jsr	j_gettile_dungeon		; 6A22
	jsr	L7FB0				; 6A25
	beq	L6A48				; 6A28
L6A2A:
	clc					; 6A2A
	lda	object_xpos,x			; 6A2B
	adc	$78				; 6A2E
	and	#$07				; 6A30  G
	sta	$16				; 6A32
	lda	object_ypos,x			; 6A34
	sta	$17				; 6A37
	jsr	j_gettile_dungeon		; 6A39
	jsr	L7FB0				; 6A3C
	beq	L6A48				; 6A3F
	dec	$70				; 6A41
	bpl	L69E3				; 6A43
	jmp	L6A79				; 6A45

L6A48:
	lda	object_tile,x			; 6A48
	jsr	L6A83				; 6A4B
	ora	(ptr1),y			; 6A4E
	sta	(ptr1),y			; 6A50
	lda	object_xpos,x			; 6A52
	sta	$AC80,x				; 6A55
	lda	object_ypos,x			; 6A58
	sta	$ACA0,x				; 6A5B
	lda	$16				; 6A5E
	sta	object_xpos,x			; 6A60
	lda	$17				; 6A63
	sta	object_ypos,x			; 6A65
	lda	$AC80,x				; 6A68
	sta	$16				; 6A6B
	lda	$ACA0,x				; 6A6D
	sta	$17				; 6A70
	jsr	j_gettile_dungeon		; 6A72
	and	#$F0				; 6A75  p
	sta	(ptr1),y			; 6A77
L6A79:
	dex					; 6A79
	bmi	L6A7F				; 6A7A
	jmp	L69B4				; 6A7C

L6A7F:
	jsr	L8C00				; 6A7F
	rts					; 6A82

L6A83:
	sec					; 6A83
	sbc	#$90				; 6A84  P
	lsr	a				; 6A86
	lsr	a				; 6A87
	clc					; 6A88
	adc	#$01				; 6A89  A
	ldy	#$00				; 6A8B  .
	rts					; 6A8D

	.byte	$FF				; 6A8E  .
	brk					; 6A8F
	ora	($00,x)				; 6A90
	brk					; 6A92
	.byte	$FF				; 6A93  .
	brk					; 6A94
	.byte	$01				; 6A95  A
check_wind_direction:
	cmp	direction			; 6A96
	beq	L6AAB				; 6A98
	clc					; 6A9A
	adc	#$02				; 6A9B  B
	and	#$03				; 6A9D  C
	cmp	direction			; 6A9F
	bne	L6AB4				; 6AA1
	lda	$69				; 6AA3
	and	#$03				; 6AA5  C
	bne	L6AB4				; 6AA7
	beq	L6AB1				; 6AA9
L6AAB:
	lda	$69				; 6AAB
	and	#$03				; 6AAD  C
	beq	L6AB4				; 6AAF
L6AB1:
	lda	#$FF				; 6AB1  .
	rts					; 6AB3

L6AB4:
	lda	#$00				; 6AB4  .
	rts					; 6AB6

check_whirlpool_storm:
	lda	game_mode			; 6AB7
	cmp	#$01				; 6AB9  A
	beq	@britannia			; 6ABB
	rts					; 6ABD

@britannia:
	ldx	#$03				; 6ABE  C
@checkobject:
	lda	object_tile,x			; 6AC0
	cmp	#$8C				; 6AC3  L
	beq	@whirlpool			; 6AC5
	cmp	#$8E				; 6AC7  N
	beq	@storm				; 6AC9
@checknext:
	dex					; 6ACB
	bpl	@checkobject			; 6ACC
	rts					; 6ACE

@whirlpool:
	lda	#$0B				; 6ACF  K
	sta	$5B				; 6AD1
	lda	object_xpos,x			; 6AD3
	cmp	player_xpos			; 6AD6
	bne	@slurpobjects			; 6AD8
	lda	object_ypos,x			; 6ADA
	cmp	player_ypos			; 6ADD
	bne	@slurpobjects			; 6ADF
	jsr	@go_to_locke_lake		; 6AE1
@slurpobjects:
	ldy	#$1F				; 6AE4  _
@checkslurp:
	stx	$58				; 6AE6
	cpy	$58				; 6AE8
	beq	@slurpnext			; 6AEA
	lda	object_tile,y			; 6AEC
	beq	@slurpnext			; 6AEF
	lda	object_xpos,x			; 6AF1
	cmp	object_xpos,y			; 6AF4
	bne	@slurpnext			; 6AF7
	lda	object_ypos,x			; 6AF9
	cmp	object_ypos,y			; 6AFC
	bne	@slurpnext			; 6AFF
	lda	#$00				; 6B01  .
	sta	object_tile,y			; 6B03
	sta	map_status,y			; 6B06
	stx	$58				; 6B09
	sty	$59				; 6B0B
	jsr	j_idle				; 6B0D
	lda	$5B				; 6B10
	jsr	j_playsfx			; 6B12
	ldx	$58				; 6B15
	ldy	$59				; 6B17
@slurpnext:
	dey					; 6B19
	bpl	@checkslurp			; 6B1A
	jmp	@checknext			; 6B1C

@storm:
	lda	#$0C				; 6B1F  L
	sta	$5B				; 6B21
	lda	object_xpos,x			; 6B23
	cmp	player_xpos			; 6B26
	bne	@slurpobjects			; 6B28
	lda	object_ypos,x			; 6B2A
	cmp	player_ypos			; 6B2D
	bne	@slurpobjects			; 6B2F
	jsr	@storm_damage			; 6B31
	jmp	@slurpobjects			; 6B34

@go_to_locke_lake:
	stx	$58				; 6B37
	jsr	j_idle				; 6B39
	lda	#$8C				; 6B3C  L
	sta	player_transport		; 6B3E
	jsr	j_idle				; 6B40
	lda	#$7F				; 6B43  .
	sta	player_xpos			; 6B45
	lda	#$4E				; 6B47  N
	sta	player_ypos			; 6B49
	lda	#$0B				; 6B4B  K
	jsr	j_playsfx			; 6B4D
	jsr	hurt_all_players		; 6B50
	ldx	$58				; 6B53
	lda	#$10				; 6B55  P
	sta	player_transport		; 6B57
	jsr	j_player_teleport		; 6B59
	rts					; 6B5C

@storm_damage:
	stx	$58				; 6B5D
	lda	player_transport		; 6B5F
	pha					; 6B61
	lda	#$8E				; 6B62  N
	sta	player_transport		; 6B64
	jsr	j_idle				; 6B66
	lda	#$0C				; 6B69  L
	jsr	j_playsfx			; 6B6B
	jsr	hurt_all_players		; 6B6E
	jsr	hurt_all_players		; 6B71
	jsr	hurt_all_players		; 6B74
	jsr	hurt_all_players		; 6B77
	pla					; 6B7A
	sta	player_transport		; 6B7B
	ldx	$58				; 6B7D
	rts					; 6B7F

L6B80:
	lda	#$4D				; 6B80  M
	sta	missile				; 6B82
	jsr	L6BC0				; 6B85
	bpl	L6B8B				; 6B88
	rts					; 6B8A

L6B8B:
	jsr	L0887				; 6B8B
	pha					; 6B8E
	lda	#$4F				; 6B8F  O
	sta	(ptr1),y			; 6B91
	jsr	j_animate_view			; 6B93
	jsr	hurt_all_players		; 6B96
	jsr	L0887				; 6B99
	pla					; 6B9C
	sta	(ptr1),y			; 6B9D
	rts					; 6B9F

L6BA0:
	lda	#$4F				; 6BA0  O
	sta	missile				; 6BA2
	jsr	L6BC0				; 6BA5
	bpl	L6BAB				; 6BA8
	rts					; 6BAA

L6BAB:
	jsr	L0887				; 6BAB
	pha					; 6BAE
	lda	#$4F				; 6BAF  O
	sta	(ptr1),y			; 6BB1
	jsr	j_animate_view			; 6BB3
	jsr	hurt_all_players		; 6BB6
	jsr	L0887				; 6BB9
	pla					; 6BBC
	sta	(ptr1),y			; 6BBD
	rts					; 6BBF

L6BC0:
	lda	#$03				; 6BC0  C
	sta	$6A				; 6BC2
	lda	object_xpos,x			; 6BC4
	sta	$7A				; 6BC7
	lda	object_ypos,x			; 6BC9
	sta	$7B				; 6BCC
	jsr	j_idle				; 6BCE
	lda	#$03				; 6BD1  C
	jsr	j_playsfx			; 6BD3
L6BD6:
	clc					; 6BD6
	lda	$7A				; 6BD7
	adc	$78				; 6BD9
	sta	$7A				; 6BDB
	clc					; 6BDD
	lda	$7B				; 6BDE
	adc	$79				; 6BE0
	sta	$7B				; 6BE2
	cmp	player_ypos			; 6BE4
	bne	L6BF1				; 6BE6
	lda	$7A				; 6BE8
	cmp	player_xpos			; 6BEA
	bne	L6BF1				; 6BEC
	lda	#$00				; 6BEE  .
	rts					; 6BF0

L6BF1:
	jsr	find_target			; 6BF1
	bpl	L6C0F				; 6BF4
	jsr	L0887				; 6BF6
	pha					; 6BF9
	lda	missile				; 6BFA
	sta	(ptr1),y			; 6BFD
	jsr	j_animate_view			; 6BFF
	jsr	L0887				; 6C02
	pla					; 6C05
	sta	(ptr1),y			; 6C06
	dec	$6A				; 6C08
	bne	L6BD6				; 6C0A
	lda	#$FF				; 6C0C  .
	rts					; 6C0E

L6C0F:
	stx	$59				; 6C0F
	lda	#$06				; 6C11  F
	jsr	j_playsfx			; 6C13
	ldx	$59				; 6C16
	cpx	#$08				; 6C18  H
	bcs	L6C23				; 6C1A
	jsr	j_rand				; 6C1C
	and	#$03				; 6C1F  C
	bne	L6C2B				; 6C21
L6C23:
	lda	#$00				; 6C23  .
	sta	object_tile,x			; 6C25
	sta	map_status,x			; 6C28
L6C2B:
	lda	#$FF				; 6C2B  .
	rts					; 6C2D

obj_player_distance:
	sec					; 6C2E
	lda	player_xpos			; 6C2F
	sbc	object_xpos,x			; 6C31
	sta	$7A				; 6C34
	jsr	getsign				; 6C36
	sta	$78				; 6C39
	sec					; 6C3B
	lda	player_ypos			; 6C3C
	sbc	object_ypos,x			; 6C3E
	sta	$7B				; 6C41
	jsr	getsign				; 6C43
	sta	$79				; 6C46
	lda	$7A				; 6C48
	jsr	getabs				; 6C4A
	sta	$59				; 6C4D
	lda	$7B				; 6C4F
	jsr	getabs				; 6C51
	clc					; 6C54
	adc	$59				; 6C55
	sta	$59				; 6C57
	rts					; 6C59

L6C5A:
	sec					; 6C5A
	lda	player_xpos			; 6C5B
	sbc	object_xpos,x			; 6C5D
	sta	$7A				; 6C60
	jsr	getsign				; 6C62
	sta	$78				; 6C65
	sec					; 6C67
	lda	player_ypos			; 6C68
	sbc	object_ypos,x			; 6C6A
	sta	$7B				; 6C6D
	jsr	getsign				; 6C6F
	sta	$79				; 6C72
	lda	$7A				; 6C74
	jsr	getabs				; 6C76
	sta	$59				; 6C79
	lda	$7B				; 6C7B
	jsr	getabs				; 6C7D
	clc					; 6C80
	adc	$59				; 6C81
	sta	$59				; 6C83
	rts					; 6C85

update_counters:
	inc	$69				; 6C86
	sed					; 6C88
	clc					; 6C89
	lda	move_counter+3			; 6C8A
	adc	#$01				; 6C8C  A
	sta	move_counter+3			; 6C8E
	lda	move_counter+2			; 6C90
	adc	#$00				; 6C92  .
	sta	move_counter+2			; 6C94
	lda	move_counter+1			; 6C96
	adc	#$00				; 6C98  .
	sta	move_counter+1			; 6C9A
	lda	move_counter			; 6C9C
	adc	#$00				; 6C9E  .
	sta	move_counter			; 6CA0
	cld					; 6CA2
	lda	aura_duration			; 6CA3
	beq	@skipaura			; 6CA5
	dec	aura_duration			; 6CA7
	bne	@skipaura			; 6CA9
	lda	#$25				; 6CAB  %
	sta	magic_aura			; 6CAD
@skipaura:
	lda	game_mode			; 6CAF
	cmp	#$03				; 6CB1  C
	bne	@skiplight			; 6CB3
	lda	light_duration			; 6CB5
	bne	@skiplight			; 6CB7
	jsr	j_primm				; 6CB9
	.byte	$C9,$D4,$A7,$D3,$A0,$C4,$C1,$D2	; 6CBC  IT'S DAR
	.byte	$CB,$A1,$8D,$00			; 6CC4  K!M.

@skiplight:
	jsr	j_update_status			; 6CC8
	jsr	update_door			; 6CCB
	jmp	game_main			; 6CCE

camp_ambushed:
	ldx	#$00				; 6CD1  .
	lda	#$00				; 6CD3  .
@clear:
	sta	monster_xpos,x			; 6CD5
	inx					; 6CD8
	bne	@clear				; 6CD9
	lda	#$01				; 6CDB  A
	sta	currplayer			; 6CDD
	lda	game_mode			; 6CDF
	sta	game_mode_temp			; 6CE1
	lda	#$82				; 6CE3  B
	sta	game_mode			; 6CE5
	lda	#$C8				; 6CE7  H
	sta	attacking_monster_type		; 6CE9
	sta	monster_type			; 6CEB
	lda	#$C1				; 6CED  A
	jmp	combat_start			; 6CEF

dungeon_check_tile:
	lda	tile_under_player		; 6CF2
	and	#$0F				; 6CF4  O
	beq	@nothinghere			; 6CF6
	lda	tile_under_player		; 6CF8
	and	#$F0				; 6CFA  p
	cmp	#$80				; 6CFC  .
	beq	@nothinghere			; 6CFE
	cmp	#$90				; 6D00  P
	beq	@nothinghere			; 6D02
	cmp	#$A0				; 6D04   
	beq	@nothinghere			; 6D06
	cmp	#$D0				; 6D08  P
	beq	@nothinghere			; 6D0A
	cmp	#$F0				; 6D0C  p
	beq	@nothinghere			; 6D0E
	lda	tile_under_player		; 6D10
	and	#$0F				; 6D12  O
	asl	a				; 6D14
	asl	a				; 6D15
	adc	#$8C				; 6D16  L
	sta	attacking_monster_type		; 6D18
	sta	monster_type			; 6D1A
	lda	player_xpos			; 6D1C
	sta	$16				; 6D1E
	lda	player_ypos			; 6D20
	sta	$17				; 6D22
	jsr	j_gettile_dungeon		; 6D24
	and	#$F0				; 6D27  p
	sta	(ptr1),y			; 6D29
	ldx	#$1F				; 6D2B  _
@check:
	lda	$ACC0,x				; 6D2D
	cmp	dungeon_level			; 6D30
	bne	@next				; 6D32
	lda	object_xpos,x			; 6D34
	cmp	player_xpos			; 6D37
	bne	@next				; 6D39
	lda	object_ypos,x			; 6D3B
	cmp	player_ypos			; 6D3E
	bne	@next				; 6D40
	lda	#$00				; 6D42  .
	sta	$ACC0,x				; 6D44
	sta	object_tile,x			; 6D47
	sta	object_xpos,x			; 6D4A
	sta	object_ypos,x			; 6D4D
	jmp	@attacked			; 6D50

@next:
	dex					; 6D53
	bpl	@check				; 6D54
@attacked:
	ldx	#$00				; 6D56  .
	txa					; 6D58
@clear:
	sta	monster_xpos,x			; 6D59
	dex					; 6D5C
	bne	@clear				; 6D5D
	pla					; 6D5F
	pla					; 6D60
	lda	tile_under_player		; 6D61
	lsr	a				; 6D63
	lsr	a				; 6D64
	lsr	a				; 6D65
	lsr	a				; 6D66
	tax					; 6D67
	lda	@dungeon_combat_map,x		; 6D68
	jmp	combat_start			; 6D6B

@nothinghere:
	rts					; 6D6E

@dungeon_combat_map:
	.byte	$B0,$B1,$B2,$B3,$B4,$B0,$B0,$B0	; 6D6F  01234000
	.byte	$B0,$B0,$B0,$B0,$B5,$B0,$B6,$B0	; 6D77  00005060

dungeon_room:
	lda	#$00				; 6D7F  .
	jsr	music_ctl			; 6D81
	sec					; 6D84
	lda	current_location		; 6D85
	sbc	#$11				; 6D87  Q
	sta	lt_y				; 6D89
	cmp	#$07				; 6D8B  G
	bne	L6D97				; 6D8D
	lda	dungeon_level			; 6D8F
	lsr	a				; 6D91
	clc					; 6D92
	adc	lt_y				; 6D93
	sta	lt_y				; 6D95
L6D97:
	lda	tile_under_player		; 6D97
	and	#$0F				; 6D99  O
	sta	lt_x				; 6D9B
	lda	#$01				; 6D9D  A
	sta	lt_rwflag			; 6D9F
	lda	#$AE				; 6DA1  .
	sta	lt_addr_hi			; 6DA3
	jsr	j_loadsector			; 6DA5
	lda	game_mode			; 6DA8
	sta	game_mode_temp			; 6DAA
	lda	#$81				; 6DAC  A
	sta	game_mode			; 6DAE
	lda	#$00				; 6DB0  .
	sta	L7982				; 6DB2
	sta	L7983				; 6DB5
	ldx	#$FF				; 6DB8  .
	lda	lt_x				; 6DBA
	cmp	#$0F				; 6DBC  O
	bne	L6E0E				; 6DBE
	lda	lt_y				; 6DC0
	cmp	#$07				; 6DC2  G
	bcs	L6E0E				; 6DC4
	jsr	j_primm				; 6DC6
	.byte	$8D,$D4,$C8,$C5,$A0,$C1,$CC,$D4	; 6DC9  MTHE ALT
	.byte	$C5,$D2,$A0,$D2,$CF,$CF,$CD,$8D	; 6DD1  ER ROOMM
	.byte	$CF,$C6,$A0,$00			; 6DD9  OF .

	lda	player_xpos			; 6DDD
	cmp	#$03				; 6DDF  C
	beq	L6DF3				; 6DE1
	bcs	L6E00				; 6DE3
	jsr	j_primm				; 6DE5
	.byte	$D4,$D2,$D5,$D4,$C8,$8D,$00	; 6DE8  TRUTHM.

	ldx	#$00				; 6DEF  .
	beq	L6E0E				; 6DF1
L6DF3:
	jsr	j_primm				; 6DF3
	.byte	$CC,$CF,$D6,$C5,$8D,$00		; 6DF6  LOVEM.

	ldx	#$01				; 6DFC  A
	bne	L6E0E				; 6DFE
L6E00:
	jsr	j_primm				; 6E00
	.byte	$C3,$CF,$D5,$D2,$C1,$C7,$C5,$8D	; 6E03  COURAGEM
	.byte	$00				; 6E0B  .

	ldx	#$02				; 6E0C  B
L6E0E:
	stx	$28				; 6E0E
	lda	#$00				; 6E10  .
	tax					; 6E12
L6E13:
	sta	monster_xpos,x			; 6E13
	inx					; 6E16
	bne	L6E13				; 6E17
	ldx	#$0F				; 6E19  O
L6E1B:
	lda	currmap,x			; 6E1B
	sta	$AF10,x				; 6E1E
	dex					; 6E21
	bpl	L6E1B				; 6E22
	lda	dng_direction			; 6E24
	eor	#$02				; 6E26  B
	asl	a				; 6E28
	asl	a				; 6E29
	asl	a				; 6E2A
	asl	a				; 6E2B
	sta	$58				; 6E2C
	lda	party_size			; 6E2E
	sta	currplayer			; 6E30
L6E32:
	jsr	something_based_on_status_and_class; 6E32
	bmi	L6E57				; 6E35
	pha					; 6E37
	clc					; 6E38
	lda	currplayer			; 6E39
	adc	$58				; 6E3B
	tay					; 6E3D
	dey					; 6E3E
	pla					; 6E3F
	ldx	currplayer			; 6E40
	dex					; 6E42
	sta	player_tile,x			; 6E43
	lda	currmap+64,y			; 6E46
	sta	cbt_player_xpos,x		; 6E49
	lda	currmap+72,y			; 6E4C
	sta	cbt_player_ypos,x		; 6E4F
	jsr	check_alive			; 6E52
	beq	L6E5E				; 6E55
L6E57:
	ldx	currplayer			; 6E57
	lda	#$00				; 6E59  .
	sta	$AD9F,x				; 6E5B
L6E5E:
	dec	currplayer			; 6E5E
	bne	L6E32				; 6E60
	ldx	#$0F				; 6E62  O
L6E64:
	lda	currmap+16,x			; 6E64
	beq	L6E9D				; 6E67
	sta	cbt_monster_type,x		; 6E69
	sta	monster_tile,x			; 6E6C
	lda	currmap+32,x			; 6E6F
	sta	monster_xpos,x			; 6E72
	lda	currmap+48,x			; 6E75
	sta	monster_ypos,x			; 6E78
	lda	cbt_monster_type,x		; 6E7B
	jsr	get_creature_type		; 6E7E
	tay					; 6E81
	lda	monster_xp,y			; 6E82
	sta	$58				; 6E85
	jsr	randmax				; 6E87
	lsr	$58				; 6E8A
	ora	$58				; 6E8C
	sta	monster_hp,x			; 6E8E
	lda	cbt_monster_type,x		; 6E91
	cmp	#$AC				; 6E94  ,
	bne	L6E9D				; 6E96
	lda	#$3C				; 6E98  <
	sta	monster_tile,x			; 6E9A
L6E9D:
	dex					; 6E9D
	bpl	L6E64				; 6E9E
	jmp	L7091				; 6EA0

generate_combat:
	jsr	j_primm				; 6EA3
	.byte	$8D,$8D,$AA,$AA,$AA,$AA,$A0,$C3	; 6EA6  MM**** C
	.byte	$CF,$CD,$C2,$C1,$D4,$A0,$AA,$AA	; 6EAE  OMBAT **
	.byte	$AA,$AA,$8D,$8D,$00		; 6EB6  **MM.

	lda	attacking_monster_type		; 6EBB
	sta	monster_type			; 6EBD
	ldx	#$00				; 6EBF  .
	txa					; 6EC1
@clear:
	sta	monster_xpos,x			; 6EC2
	dex					; 6EC5
	bne	@clear				; 6EC6
	lda	player_transport		; 6EC8
	cmp	#$14				; 6ECA  T
	bcc	@ship				; 6ECC
	lda	tile_under_player		; 6ECE
	cmp	#$14				; 6ED0  T
	bcs	@onland				; 6ED2
	cmp	#$10				; 6ED4  P
	bcc	@onland				; 6ED6
@ship:
	lda	attacking_monster_type		; 6ED8
	cmp	#$80				; 6EDA  .
	bne	@notpirates			; 6EDC
	lda	#$C8				; 6EDE  H
	sta	monster_type			; 6EE0
	lda	#$D4				; 6EE2  T
	jmp	combat_start			; 6EE4

@notpirates:
	lda	attacking_monster_terrain	; 6EE7
	cmp	#$03				; 6EE9  C
	bcc	@seamonster			; 6EEB
	lda	#$C5				; 6EED  E
	jmp	combat_start			; 6EEF

@seamonster:
	lda	#$D0				; 6EF2  P
	jmp	combat_start			; 6EF4

@onland:
	lda	attacking_monster_type		; 6EF7
	cmp	#$80				; 6EF9  .
	bne	@notpirates2			; 6EFB
	lda	#$C8				; 6EFD  H
	sta	monster_type			; 6EFF
	lda	#$C9				; 6F01  I
	jmp	combat_start			; 6F03

@notpirates2:
	lda	attacking_monster_terrain	; 6F06
	cmp	#$03				; 6F08  C
	bcs	@swamp				; 6F0A
	lda	#$CF				; 6F0C  O
	jmp	combat_start			; 6F0E

@swamp:
	lda	tile_under_player		; 6F11
	cmp	#$03				; 6F13  C
	bne	@forest				; 6F15
	lda	#$D3				; 6F17  S
	jmp	combat_start			; 6F19

@forest:
	cmp	#$05				; 6F1C  E
	bne	@deepforest			; 6F1E
	lda	#$C2				; 6F20  B
	jmp	combat_start			; 6F22

@deepforest:
	cmp	#$06				; 6F25  F
	bne	@mountains			; 6F27
	lda	#$C6				; 6F29  F
	jmp	combat_start			; 6F2B

@mountains:
	cmp	#$07				; 6F2E  G
	bne	@flagstones			; 6F30
	lda	#$C8				; 6F32  H
	jmp	combat_start			; 6F34

@flagstones:
	cmp	#$16				; 6F37  V
	bne	@brick				; 6F39
	lda	#$C4				; 6F3B  D
	jmp	combat_start			; 6F3D

@brick:
	cmp	#$3E				; 6F40  >
	bne	@towneorbridge			; 6F42
	lda	#$C3				; 6F44  C
	jmp	combat_start			; 6F46

@towneorbridge:
	cmp	#$17				; 6F49  W
	beq	@bridgeorwood			; 6F4B
	cmp	#$19				; 6F4D  Y
	beq	@bridgeorwood			; 6F4F
	cmp	#$1A				; 6F51  Z
	beq	@bridgeorwood			; 6F53
	cmp	#$3F				; 6F55  ?
	bne	@other				; 6F57
@bridgeorwood:
	lda	#$D2				; 6F59  R
	jmp	combat_start			; 6F5B

@other:
	lda	#$C7				; 6F5E  G
	jmp	combat_start			; 6F60

get_combat_map:
	stx	@savex				; 6F63
	ldx	#$15				; 6F66  U
@next:
	cmp	@combat_map,x			; 6F68
	beq	@gotmap				; 6F6B
	dex					; 6F6D
	bpl	@next				; 6F6E
@gotmap:
	txa					; 6F70
	ldx	@savex				; 6F71
	rts					; 6F74

@combat_map:
	.byte	$C2,$C6,$C7,$C8,$CF,$D2,$D3,$C3	; 6F75  BFGHORSC
	.byte	$C4,$C1,$C5,$C9,$D0,$D4,$D8,$B0	; 6F7D  DAEIPTX0
	.byte	$B1,$B2,$B3,$B4,$B5,$B6		; 6F85  123456
@savex:
	.byte	$A7				; 6F8B  '

combat_start:
	jsr	get_combat_map			; 6F8C
	pha					; 6F8F
	lda	#$00				; 6F90  .
	jsr	music_ctl			; 6F92
	pla					; 6F95
	clc					; 6F96
	adc	#$01				; 6F97  A
	tax					; 6F99
	lda	#$CC				; 6F9A  L
	jsr	j_fileio			; 6F9C
dungeon_combat_start:
	lda	game_mode			; 6F9F
	cmp	#$82				; 6FA1  B
	beq	@towne				; 6FA3
	sta	game_mode_temp			; 6FA5
	lda	#$80				; 6FA7  .
	sta	game_mode			; 6FA9
@towne:
	lda	game_mode_temp			; 6FAB
	cmp	#$02				; 6FAD  B
	bne	@t				; 6FAF
	lda	game_mode			; 6FB1
	cmp	#$82				; 6FB3  B
	beq	@t				; 6FB5
	lda	attacking_monster_type		; 6FB7
	cmp	#$50				; 6FB9  P
	beq	@guards				; 6FBB
	lda	#$00				; 6FBD  .
	jmp	@checksize			; 6FBF

@guards:
	lda	party_size			; 6FC2
	asl	a				; 6FC4
	sec					; 6FC5
	sbc	#$01				; 6FC6  A
	jmp	@checksize			; 6FC8

@t:	lda	monster_type			; 6FCB
	bmi	@monster			; 6FCD
	jsr	j_rand				; 6FCF
	and	#$07				; 6FD2  G
	bne	@checksize			; 6FD4
@monster:
	jsr	get_creature_type		; 6FD6
	tax					; 6FD9
	lda	L7D4E,x				; 6FDA
	jsr	randmax				; 6FDD
	clc					; 6FE0
	adc	L7D4E,x				; 6FE1
	lsr	a				; 6FE4
@checksize:
	sta	$6A				; 6FE5
	sta	L7D72				; 6FE7
	lsr	a				; 6FEA
	cmp	party_size			; 6FEB
	bcc	@placemonsters			; 6FED
	lda	party_size			; 6FEF
	asl	a				; 6FF1
	jsr	randmax				; 6FF2
	jmp	@checksize			; 6FF5

@placemonsters:
	jsr	j_rand				; 6FF8
	and	#$0F				; 6FFB  O
	tax					; 6FFD
	lda	monster_xpos,x			; 6FFE
	bne	@placemonsters			; 7001
	lda	currmap+64,x			; 7003
	sta	monster_xpos,x			; 7006
	lda	currmap+80,x			; 7009
	sta	monster_ypos,x			; 700C
	lda	monster_type			; 700F
	bpl	L7043				; 7011
	lda	$6A				; 7013
	beq	L7022				; 7015
	jsr	j_rand				; 7017
	and	#$1F				; 701A  _
	beq	L7033				; 701C
	and	#$07				; 701E  G
	beq	L7027				; 7020
L7022:
	lda	monster_type			; 7022
	jmp	L7043				; 7024

L7027:
	lda	monster_type			; 7027
	jsr	get_creature_type		; 7029
	tay					; 702C
	lda	L7D2A,y				; 702D
	jmp	L7043				; 7030

L7033:
	lda	monster_type			; 7033
	jsr	get_creature_type		; 7035
	tay					; 7038
	lda	L7D2A,y				; 7039
	jsr	get_creature_type		; 703C
	tay					; 703F
	lda	L7D2A,y				; 7040
L7043:
	sta	cbt_monster_type,x		; 7043
	sta	monster_tile,x			; 7046
	jsr	get_creature_type		; 7049
	tay					; 704C
	lda	monster_xp,y			; 704D
	sta	$58				; 7050
	jsr	randmax				; 7052
	lsr	$58				; 7055
	ora	$58				; 7057
	sta	monster_hp,x			; 7059
	dec	$6A				; 705C
	bpl	@placemonsters			; 705E
	lda	game_mode			; 7060
	cmp	#$82				; 7062  B
	beq	L706A				; 7064
	lda	party_size			; 7066
	sta	currplayer			; 7068
L706A:
	jsr	something_based_on_status_and_class; 706A
	bmi	L7086				; 706D
	ldx	currplayer			; 706F
	dex					; 7071
	sta	player_tile,x			; 7072
	lda	currmap+96,x			; 7075
	sta	cbt_player_xpos,x		; 7078
	lda	currmap+104,x			; 707B
	sta	cbt_player_ypos,x		; 707E
	jsr	check_alive			; 7081
	beq	L708D				; 7084
L7086:
	ldx	currplayer			; 7086
	lda	#$00				; 7088  .
	sta	$AD9F,x				; 708A
L708D:
	dec	currplayer			; 708D
	bne	L706A				; 708F
L7091:
	lda	#$02				; 7091  B
	jsr	music_ctl			; 7093
	jsr	j_clearkbd			; 7096
	lda	#$00				; 7099  .
	sta	key_buf_len			; 709B
L709D:
	lda	#$01				; 709D  A
	sta	currplayer			; 709F
	sta	$45				; 70A1
L70A3:
	jsr	check_alive			; 70A3
	beq	L70B7				; 70A6
	ldx	currplayer			; 70A8
	lda	$AD9F,x				; 70AA
	beq	L70B4				; 70AD
	lda	#$00				; 70AF  .
	sta	$AD9F,x				; 70B1
L70B4:
	jmp	L714E				; 70B4

L70B7:
	ldx	currplayer			; 70B7
	lda	$AD9F,x				; 70B9
	beq	L70B4				; 70BC
	cmp	#$38				; 70BE  8
	beq	L70B4				; 70C0
	jsr	j_idle				; 70C2
	jsr	invert_player_line		; 70C5
	jsr	printcr				; 70C8
	jsr	j_printname			; 70CB
	jsr	j_primm				; 70CE
	.byte	$8D,$D7,$BA,$00			; 70D1  MW:.

	jsr	j_get_stats_ptr			; 70D5
	ldy	#$1E				; 70D8  ^
	lda	(ptr1),y			; 70DA
	sta	L7C74				; 70DC
	clc					; 70DF
	adc	#$25				; 70E0  %
	jsr	j_printstring			; 70E2
	jsr	j_primm				; 70E5
	.byte	$8D,$1E,$00			; 70E8  M^.

	jsr	j_waitkey			; 70EB
	bne	L70F3				; 70EE
	jmp	cmd_pass			; 70F0

L70F3:
	cmp	#$A0				; 70F3   
	bne	L70FA				; 70F5
	jmp	cmd_pass			; 70F7

L70FA:
	cmp	#$C0				; 70FA  @
	bne	L7101				; 70FC
	jmp	L77CE				; 70FE

L7101:
	cmp	#$AF				; 7101  /
	bne	L7108				; 7103
	jmp	L77E9				; 7105

L7108:
	cmp	#$BA				; 7108  :
	bne	L710F				; 710A
	jmp	L781E				; 710C

L710F:
	cmp	#$BB				; 710F  ;
	bne	L7116				; 7111
	jmp	L7804				; 7113

L7116:
	cmp	#$C1				; 7116  A
	bcc	L7130				; 7118
	cmp	#$DB				; 711A  [
	bcs	L7130				; 711C
	sec					; 711E
	sbc	#$C1				; 711F  A
	asl	a				; 7121
	tay					; 7122
	lda	L779A,y				; 7123
	sta	ptr1				; 7126
	lda	L779B,y				; 7128
	sta	ptr1+1				; 712B
	jmp	(ptr1)				; 712D

L7130:
	jmp	cmd_unknown			; 7130

L7133:
	lda	$45				; 7133
	sta	currplayer			; 7135
	jsr	invert_player_line		; 7137
	jsr	check_triggers			; 713A
	jsr	j_update_status			; 713D
	lda	magic_aura			; 7140
	cmp	#$D1				; 7142  Q
	bne	L714E				; 7144
	jsr	j_rand				; 7146
	bmi	L714E				; 7149
	jmp	L70A3				; 714B

L714E:
	jsr	j_get_stats_ptr			; 714E
	ldy	#$12				; 7151  R
	lda	(ptr1),y			; 7153
	cmp	#$D3				; 7155  S
	bne	L716C				; 7157
	jsr	j_rand				; 7159
	and	#$07				; 715C  G
	bne	L716C				; 715E
	lda	#$C7				; 7160  G
	sta	(ptr1),y			; 7162
	jsr	something_based_on_status_and_class; 7164
	ldx	currplayer			; 7167
	sta	$AD9F,x				; 7169
L716C:
	jsr	L7514				; 716C
	inc	currplayer			; 716F
	inc	$45				; 7171
	lda	currplayer			; 7173
	cmp	party_size			; 7175
	bcc	L717E				; 7177
	beq	L717E				; 7179
	jmp	L7181				; 717B

L717E:
	jmp	L70A3				; 717E

L7181:
	lda	#$00				; 7181  .
	sta	$45				; 7183
	jsr	j_idle				; 7185
	lda	#$0F				; 7188  O
	sta	$6A				; 718A
L718C:
	ldx	$6A				; 718C
	lda	cbt_monster_type,x		; 718E
	bne	L7196				; 7191
	jmp	L7422				; 7193

L7196:
	lda	$AD70,x				; 7196
	beq	L71AA				; 7199
	jsr	j_rand				; 719B
	and	#$07				; 719E  G
	beq	L71A5				; 71A0
	jmp	L73C4				; 71A2

L71A5:
	lda	#$00				; 71A5  .
	sta	$AD70,x				; 71A7
L71AA:
	lda	cbt_monster_type,x		; 71AA
	cmp	#$EC				; 71AD  l
	bne	L71BC				; 71AF
	lda	#$CE				; 71B1  N
	sta	magic_aura			; 71B3
	lda	#$02				; 71B5  B
	sta	aura_duration			; 71B7
	jmp	L71EC				; 71B9

L71BC:
	cmp	#$DC				; 71BC  \
	bne	L71EC				; 71BE
	jsr	j_rand				; 71C0
	and	#$07				; 71C3  G
	bne	L71EC				; 71C5
L71C7:
	lda	#$0B				; 71C7  K
	jsr	randmax				; 71C9
	sta	$16				; 71CC
	lda	#$0B				; 71CE  K
	jsr	randmax				; 71D0
	sta	$17				; 71D3
	jsr	j_gettile_combat		; 71D5
	jsr	L7EEA				; 71D8
	bmi	L71C7				; 71DB
	ldx	$6A				; 71DD
	lda	$16				; 71DF
	sta	monster_xpos,x			; 71E1
	lda	$17				; 71E4
	sta	monster_ypos,x			; 71E6
	jmp	L73C4				; 71E9

L71EC:
	lda	monster_xpos,x			; 71EC
	sta	$7A				; 71EF
	lda	monster_ypos,x			; 71F1
	sta	$7B				; 71F4
	lda	party_size			; 71F6
	sta	currplayer			; 71F8
	lda	#$FF				; 71FA  .
	sta	$5B				; 71FC
	lda	#$00				; 71FE  .
	sta	$55				; 7200
L7202:
	jsr	check_alive			; 7202
	bne	L7230				; 7205
	ldx	currplayer			; 7207
	dex					; 7209
	lda	player_tile,x			; 720A
	beq	L7230				; 720D
	sec					; 720F
	lda	cbt_player_xpos,x		; 7210
	sbc	$7A				; 7213
	jsr	getabs				; 7215
	sta	zptmp1				; 7218
	sec					; 721A
	lda	cbt_player_ypos,x		; 721B
	sbc	$7B				; 721E
	jsr	getabs				; 7220
	clc					; 7223
	adc	zptmp1				; 7224
	cmp	$5B				; 7226
	bcs	L7230				; 7228
	sta	$5B				; 722A
	lda	currplayer			; 722C
	sta	$55				; 722E
L7230:
	dec	currplayer			; 7230
	bne	L7202				; 7232
	lda	$55				; 7234
	bne	L723B				; 7236
	jmp	L73C4				; 7238

L723B:
	sta	currplayer			; 723B
	tax					; 723D
	dex					; 723E
	sec					; 723F
	lda	cbt_player_xpos,x		; 7240
	sbc	$7A				; 7243
	jsr	getsign				; 7245
	sta	$78				; 7248
	sec					; 724A
	lda	cbt_player_ypos,x		; 724B
	sbc	$7B				; 724E
	jsr	getsign				; 7250
	sta	$79				; 7253
	ldx	$6A				; 7255
	lda	cbt_monster_type,x		; 7257
	cmp	#$AC				; 725A  ,
	bne	L726E				; 725C
	lda	#$3C				; 725E  <
	sta	monster_tile,x			; 7260
	lda	$5B				; 7263
	cmp	#$05				; 7265  E
	bcs	L7290				; 7267
	lda	#$AC				; 7269  ,
	sta	monster_tile,x			; 726B
L726E:
	jsr	j_rand				; 726E
	and	#$03				; 7271  C
	bne	L7290				; 7273
	lda	cbt_monster_type,x		; 7275
	jsr	L8036				; 7278
	beq	L7290				; 727B
	cmp	#$4E				; 727D  N
	bne	L7287				; 727F
	ldy	magic_aura			; 7281
	cpy	#$CE				; 7283  N
	beq	L7290				; 7285
L7287:
	jsr	L80B1				; 7287
	jsr	j_idle				; 728A
	jmp	L73C4				; 728D

L7290:
	jsr	j_rand				; 7290
	and	#$03				; 7293  C
	bne	L72E7				; 7295
	ldx	$6A				; 7297
	lda	cbt_monster_type,x		; 7299
	cmp	#$FC				; 729C  |
	beq	L72A4				; 729E
	cmp	#$B0				; 72A0  0
	bne	L72E7				; 72A2
L72A4:
	lda	magic_aura			; 72A4
	cmp	#$CE				; 72A6  N
	beq	L72E7				; 72A8
	jsr	j_idle				; 72AA
	jsr	j_invertview			; 72AD
	ldx	#$80				; 72B0  .
	lda	#$09				; 72B2  I
	jsr	j_playsfx			; 72B4
	jsr	j_invertview			; 72B7
	lda	#$08				; 72BA  H
	sta	currplayer			; 72BC
L72BE:
	ldx	currplayer			; 72BE
	lda	$AD9F,x				; 72C0
	beq	L72E0				; 72C3
	jsr	j_get_stats_ptr			; 72C5
	ldy	#$12				; 72C8  R
	lda	(ptr1),y			; 72CA
	cmp	#$C7				; 72CC  G
	bne	L72E0				; 72CE
	jsr	j_rand				; 72D0
	bmi	L72E0				; 72D3
	lda	#$D3				; 72D5  S
	sta	(ptr1),y			; 72D7
	lda	#$38				; 72D9  8
	ldx	currplayer			; 72DB
	sta	$AD9F,x				; 72DD
L72E0:
	dec	currplayer			; 72E0
	bne	L72BE				; 72E2
	jmp	L73C4				; 72E4

L72E7:
	ldx	$6A				; 72E7
	lda	monster_hp,x			; 72E9
	cmp	#$18				; 72EC  X
	bcs	L7301				; 72EE
	lda	$78				; 72F0
	jsr	L8281				; 72F2
	sta	$78				; 72F5
	lda	$79				; 72F7
	jsr	L8281				; 72F9
	sta	$79				; 72FC
	jmp	L7320				; 72FE

L7301:
	lda	$5B				; 7301
	cmp	#$02				; 7303  B
	bcs	L7320				; 7305
	ldx	$6A				; 7307
	lda	cbt_monster_type,x		; 7309
	cmp	#$A8				; 730C  (
	bne	L7316				; 730E
	jsr	L74CF				; 7310
	jmp	L731D				; 7313

L7316:
	cmp	#$C8				; 7316  H
	bne	L731D				; 7318
	jsr	L74DD				; 731A
L731D:
	jmp	L76FD				; 731D

L7320:
	ldx	$6A				; 7320
	lda	cbt_monster_type,x		; 7322
	cmp	#$AC				; 7325  ,
	bne	L732C				; 7327
	jmp	L73C4				; 7329

L732C:
	cmp	#$B0				; 732C  0
	bne	L7333				; 732E
	jmp	L73C4				; 7330

L7333:
	lda	#$02				; 7333  B
	sta	$70				; 7335
L7337:
	jsr	j_rand				; 7337
	bmi	L7354				; 733A
	lda	$78				; 733C
	beq	L7354				; 733E
	clc					; 7340
	adc	$7A				; 7341
	sta	$16				; 7343
	lda	$7B				; 7345
	sta	$17				; 7347
	jsr	L746C				; 7349
	jsr	L088A				; 734C
	jsr	L7EEA				; 734F
	beq	L73A1				; 7352
L7354:
	lda	$79				; 7354
	beq	L736C				; 7356
	clc					; 7358
	adc	$7B				; 7359
	sta	$17				; 735B
	lda	$7A				; 735D
	sta	$16				; 735F
	jsr	L746C				; 7361
	jsr	L088A				; 7364
	jsr	L7EEA				; 7367
	beq	L73A1				; 736A
L736C:
	lda	$78				; 736C
	beq	L7384				; 736E
	clc					; 7370
	adc	$7A				; 7371
	sta	$16				; 7373
	lda	$7B				; 7375
	sta	$17				; 7377
	jsr	L746C				; 7379
	jsr	L088A				; 737C
	jsr	L7EEA				; 737F
	beq	L73A1				; 7382
L7384:
	jsr	j_rand				; 7384
	jsr	getsign				; 7387
	sta	$78				; 738A
	jsr	j_rand				; 738C
	jsr	getsign				; 738F
	sta	$79				; 7392
	dec	$70				; 7394
	bne	L7337				; 7396
	lda	$5B				; 7398
	cmp	#$02				; 739A  B
	bcs	L73C4				; 739C
	jmp	L76FD				; 739E

L73A1:
	ldx	$6A				; 73A1
	lda	monster_xpos,x			; 73A3
	sta	$AD20,x				; 73A6
	lda	monster_ypos,x			; 73A9
	sta	$AD30,x				; 73AC
	lda	$16				; 73AF
	cmp	#$0B				; 73B1  K
	bcs	L742C				; 73B3
	sta	monster_xpos,x			; 73B5
	lda	$17				; 73B8
	cmp	#$0B				; 73BA  K
	bcs	L742C				; 73BC
	sta	monster_ypos,x			; 73BE
	jsr	j_idle_combat			; 73C1
L73C4:
	lda	#$00				; 73C4  .
	sta	currplayer			; 73C6
	ldx	$6A				; 73C8
	lda	monster_xpos,x			; 73CA
	sta	$16				; 73CD
	lda	monster_ypos,x			; 73CF
	sta	$17				; 73D2
	jsr	j_gettile_combat		; 73D4
	ldx	$6A				; 73D7
	cmp	#$44				; 73D9  D
	beq	L7413				; 73DB
	cmp	#$46				; 73DD  F
	beq	L7408				; 73DF
	cmp	#$47				; 73E1  G
	beq	L73EB				; 73E3
	cmp	#$4C				; 73E5  L
	beq	L7408				; 73E7
	bne	L7422				; 73E9
L73EB:
	lda	cbt_monster_type,x		; 73EB
	jsr	L4ECD				; 73EE
	beq	L7422				; 73F1
	jsr	j_rand				; 73F3
	cmp	monster_hp,x			; 73F6
	bcc	L7422				; 73F9
	lda	#$01				; 73FB  A
	sta	$AD70,x				; 73FD
	lda	#$06				; 7400  F
	jsr	j_playsfx			; 7402
	jmp	L7422				; 7405

L7408:
	lda	cbt_monster_type,x		; 7408
	cmp	#$E8				; 740B  h
	beq	L7422				; 740D
	cmp	#$F0				; 740F  p
	bcs	L7422				; 7411
L7413:
	jsr	j_rand				; 7413
	and	#$7F				; 7416  .
	sta	$5C				; 7418
	lda	#$06				; 741A  F
	jsr	j_playsfx			; 741C
	jsr	hurt_monster			; 741F
L7422:
	dec	$6A				; 7422
	bmi	L7429				; 7424
	jmp	L718C				; 7426

L7429:
	jmp	L74B2				; 7429

L742C:
	jsr	printcr				; 742C
	ldx	$6A				; 742F
	lda	cbt_monster_type,x		; 7431
	jsr	print_creature_name		; 7434
	jsr	j_primm				; 7437
	.byte	$C6,$CC,$C5,$C5,$D3,$A1,$8D,$00	; 743A  FLEES!M.

	ldx	$6A				; 7442
	lda	cbt_monster_type,x		; 7444
	jsr	check_evil			; 7447
	bmi	L745A				; 744A
	ldy	#$01				; 744C  A
	lda	#$01				; 744E  A
	jsr	virtue_inc			; 7450
	ldy	#$03				; 7453  C
	lda	#$01				; 7455  A
	jsr	virtue_inc			; 7457
L745A:
	lda	#$00				; 745A  .
	ldx	$6A				; 745C
	sta	cbt_monster_type,x		; 745E
	sta	monster_hp,x			; 7461
	lda	#$08				; 7464  H
	jsr	j_playsfx			; 7466
	jmp	L73C4				; 7469

L746C:
	lda	magic_aura			; 746C
	cmp	#$CA				; 746E  J
	beq	L7473				; 7470
	rts					; 7472

L7473:
	lda	$6A				; 7473
	pha					; 7475
	jsr	combat_find_monster		; 7476
	bmi	L74AE				; 7479
	lda	#$4F				; 747B  O
	sta	missile				; 747D
	lda	$16				; 7480
	sta	missile_xpos			; 7482
	lda	$17				; 7485
	sta	missile_ypos			; 7487
	jsr	j_idle_combat			; 748A
	lda	#$06				; 748D  F
	jsr	j_playsfx			; 748F
	lda	#$00				; 7492  .
	sta	missile				; 7494
	sta	currplayer			; 7497
	jsr	j_rand				; 7499
	and	#$3F				; 749C  ?
	sta	$5C				; 749E
	jsr	hurt_monster			; 74A0
	jsr	j_idle_combat			; 74A3
	pla					; 74A6
	sta	$6A				; 74A7
	pla					; 74A9
	pla					; 74AA
	jmp	L73C4				; 74AB

L74AE:
	pla					; 74AE
	sta	$6A				; 74AF
	rts					; 74B1

L74B2:
	jsr	party_add_mp			; 74B2
	jsr	j_idle_combat			; 74B5
	inc	$69				; 74B8
	jsr	L7514				; 74BA
	lda	aura_duration			; 74BD
	beq	L74C9				; 74BF
	dec	aura_duration			; 74C1
	bne	L74C9				; 74C3
	lda	#$25				; 74C5  %
	sta	magic_aura			; 74C7
L74C9:
	jsr	j_update_status			; 74C9
	jmp	L709D				; 74CC

L74CF:
	lda	#$25				; 74CF  %
	jsr	stat_eat_food			; 74D1
	jsr	j_update_status			; 74D4
	lda	#$08				; 74D7  H
	jsr	j_playsfx			; 74D9
	rts					; 74DC

L74DD:
	jsr	j_rand				; 74DD
	and	#$03				; 74E0  C
	bne	L7513				; 74E2
	jsr	j_rand				; 74E4
	and	#$3F				; 74E7  ?
	jsr	hextobcd			; 74E9
	sta	$58				; 74EC
	sed					; 74EE
	sec					; 74EF
	lda	gold+1				; 74F0
	sbc	$58				; 74F3
	sta	gold+1				; 74F5
	lda	gold				; 74F8
	sbc	#$00				; 74FB  .
	sta	gold				; 74FD
	bcs	L750A				; 7500
	lda	#$00				; 7502  .
	sta	gold+1				; 7504
	sta	gold				; 7507
L750A:
	cld					; 750A
	lda	#$08				; 750B  H
	jsr	j_playsfx			; 750D
	jsr	j_update_status			; 7510
L7513:
	rts					; 7513

L7514:
	lda	game_mode			; 7514
	cmp	#$81				; 7516  A
	beq	L7529				; 7518
	ldx	#$0F				; 751A  O
L751C:
	lda	cbt_monster_type,x		; 751C
	bne	L7529				; 751F
	dex					; 7521
	bpl	L751C				; 7522
	pla					; 7524
	pla					; 7525
	jmp	L75FF				; 7526

L7529:
	ldx	#$07				; 7529  G
L752B:
	lda	player_tile,x			; 752B
	bne	L7538				; 752E
	dex					; 7530
	bpl	L752B				; 7531
	pla					; 7533
	pla					; 7534
	jmp	L7539				; 7535

L7538:
	rts					; 7538

L7539:
	lda	game_mode			; 7539
	cmp	#$81				; 753B  A
	beq	L7576				; 753D
	lda	attacking_monster_type		; 753F
	jsr	check_evil			; 7541
	bpl	L7565				; 7544
	jsr	j_primm				; 7546
	.byte	$8D,$C2,$C1,$D4,$D4,$CC,$C5,$A0	; 7549  MBATTLE 
	.byte	$C9,$D3,$A0,$CC,$CF,$D3,$D4,$A1	; 7551  IS LOST!
	.byte	$8D,$00				; 7559  M.

	ldy	#$02				; 755B  B
	lda	#$02				; 755D  B
	jsr	virtue_dec			; 755F
	jmp	L76D6				; 7562

L7565:
	ldy	#$01				; 7565  A
	lda	#$02				; 7567  B
	jsr	virtue_inc			; 7569
	ldy	#$03				; 756C  C
	lda	#$02				; 756E  B
	jsr	virtue_inc			; 7570
	jmp	L76D6				; 7573

L7576:
	jsr	j_primm				; 7576
	.byte	$8D,$CC,$C5,$C1,$D6,$C5,$A0,$D2	; 7579  MLEAVE R
	.byte	$CF,$CF,$CD,$A1,$8D,$00		; 7581  OOM!M.

	lda	L7982				; 7587
	beq	L7598				; 758A
	bpl	L7593				; 758C
	lda	#$03				; 758E  C
	jmp	L75A4				; 7590

L7593:
	lda	#$01				; 7593  A
	jmp	L75A4				; 7595

L7598:
	lda	L7983				; 7598
	bpl	L75A2				; 759B
	lda	#$00				; 759D  .
	jmp	L75A4				; 759F

L75A2:
	lda	#$02				; 75A2  B
L75A4:
	sta	dng_direction			; 75A4
	lda	game_mode_temp			; 75A6
	sta	game_mode			; 75A8
	lda	$28				; 75AA
	bmi	L75E1				; 75AC
	asl	a				; 75AE
	asl	a				; 75AF
	clc					; 75B0
	adc	dng_direction			; 75B1
	tay					; 75B3
	lda	L75F3,y				; 75B4
	sta	current_location		; 75B7
	tay					; 75B9
	dey					; 75BA
	lda	L519A,y				; 75BB
	sta	$18				; 75BE
	lda	L51BA,y				; 75C0
	sta	$19				; 75C3
	lda	#$00				; 75C5  .
	jsr	music_ctl			; 75C7
	jsr	@loaddungeon			; 75CA
	jsr	j_primm				; 75CD
	.byte	$C9,$CE,$D4,$CF,$A0,$C4,$D5,$CE	; 75D0  INTO DUN
	.byte	$C7,$C5,$CF,$CE,$8D,$00		; 75D8  GEONM.

	jsr	print_location_name		; 75DE
L75E1:
	jsr	printcr				; 75E1
	lda	#$01				; 75E4  A
	jsr	music_ctl			; 75E6
	lda	dng_direction			; 75E9
	tax					; 75EB
	lda	#$00				; 75EC  .
	sta	key_buf_len			; 75EE
	jmp	dng_move			; 75F0

L75F3:
	.byte	$11,$16,$17,$14,$12,$14,$17,$15	; 75F3  QVWTRTWU
	.byte	$13,$15,$17,$16			; 75FB  SUWV

L75FF:
	jsr	j_primm				; 75FF
	.byte	$8D,$D6,$C9,$C3,$D4,$CF,$D2,$D9	; 7602  MVICTORY
	.byte	$A1,$8D,$00			; 760A  !M.

	lda	attacking_monster_type		; 760D
	jsr	check_evil			; 760F
	bpl	L761E				; 7612
	ldy	#$02				; 7614  B
	jsr	j_rand				; 7616
	and	#$01				; 7619  A
	jsr	virtue_inc			; 761B
L761E:
	lda	game_mode			; 761E
	cmp	#$82				; 7620  B
	bne	L7627				; 7622
	jmp	L76D6				; 7624

L7627:
	lda	game_mode_temp			; 7627
	cmp	#$03				; 7629  C
	beq	L7696				; 762B
	lda	attacking_monster_type		; 762D
	cmp	#$90				; 762F  P
	bcs	L7649				; 7631
	cmp	#$80				; 7633  .
	beq	L767E				; 7635
	cmp	#$20				; 7637   
	bcc	L7693				; 7639
	cmp	#$60				; 763B  `
	bcs	L7693				; 763D
	cmp	#$30				; 763F  0
	bcc	L7649				; 7641
	cmp	#$50				; 7643  P
	bcs	L7649				; 7645
	bcc	L7693				; 7647
L7649:
	cmp	#$94				; 7649  T
	beq	L7693				; 764B
	cmp	#$A0				; 764D   
	beq	L7693				; 764F
	cmp	#$B8				; 7651  8
	beq	L7693				; 7653
	cmp	#$B4				; 7655  4
	beq	L7693				; 7657
	cmp	#$DC				; 7659  \
	beq	L7693				; 765B
	lda	attacking_monster_terrain	; 765D
	jsr	j_blocked_tile			; 765F
	bmi	L7693				; 7662
	bcc	L7693				; 7664
	jsr	L76B8				; 7666
	lda	attacking_monster_xpos		; 7669
	sta	object_xpos,x			; 766B
	lda	attacking_monster_ypos		; 766E
	sta	object_ypos,x			; 7670
	lda	#$3C				; 7673  <
	sta	object_tile,x			; 7675
	sta	map_status,x			; 7678
	jmp	L76D6				; 767B

L767E:
	jsr	L76B8				; 767E
	lda	attacking_monster_xpos		; 7681
	sta	object_xpos,x			; 7683
	lda	attacking_monster_ypos		; 7686
	sta	object_ypos,x			; 7688
	lda	#$10				; 768B  P
	sta	object_tile,x			; 768D
	sta	map_status,x			; 7690
L7693:
	jmp	L76D6				; 7693

L7696:
	lda	attacking_monster_type		; 7696
	cmp	#$94				; 7698  T
	beq	L7693				; 769A
	cmp	#$B4				; 769C  4
	beq	L7693				; 769E
	cmp	#$A0				; 76A0   
	beq	L7693				; 76A2
	lda	player_xpos			; 76A4
	sta	$16				; 76A6
	lda	player_ypos			; 76A8
	sta	$17				; 76AA
	jsr	j_gettile_dungeon		; 76AC
	bne	L7693				; 76AF
	lda	#$40				; 76B1  @
	sta	(ptr1),y			; 76B3
	jmp	L76D6				; 76B5

L76B8:
	ldx	#$1F				; 76B8  _
L76BA:
	lda	object_tile,x			; 76BA
	beq	L76D5				; 76BD
	dex					; 76BF
	bmi	L76CC				; 76C0
	lda	game_mode_temp			; 76C2
	cmp	#$01				; 76C4  A
	bne	L76BA				; 76C6
	cpx	#$08				; 76C8  H
	bcs	L76BA				; 76CA
L76CC:
	lda	#$18				; 76CC  X
	jsr	randmax				; 76CE
	clc					; 76D1
	adc	#$08				; 76D2  H
	tax					; 76D4
L76D5:
	rts					; 76D5

L76D6:
	lda	game_mode			; 76D6
	cmp	#$82				; 76D8  B
	beq	L76F3				; 76DA
	lda	game_mode_temp			; 76DC
	sta	game_mode			; 76DE
	cmp	#$03				; 76E0  C
	bne	L76E7				; 76E2
	jsr	L8C06				; 76E4
L76E7:
	lda	#$01				; 76E7  A
	jsr	music_ctl			; 76E9
	lda	#$00				; 76EC  .
	sta	key_buf_len			; 76EE
	jmp	cmd_done			; 76F0

L76F3:
	lda	game_mode_temp			; 76F3
	sta	game_mode			; 76F5
	lda	#$01				; 76F7  A
	jsr	music_ctl			; 76F9
	rts					; 76FC

L76FD:
	ldx	currplayer			; 76FD
	lda	$AD7F,x				; 76FF
	sta	missile_xpos			; 7702
	lda	$AD8F,x				; 7705
	sta	missile_ypos			; 7708
	lda	#$4D				; 770B  M
	sta	missile				; 770D
	jsr	j_idle_combat			; 7710
	lda	#$05				; 7713  E
	jsr	j_playsfx			; 7715
	lda	#$00				; 7718  .
	sta	missile				; 771A
	lda	magic_aura			; 771D
	cmp	#$D0				; 771F  P
	bne	L7728				; 7721
	jsr	j_rand				; 7723
	bmi	L773C				; 7726
L7728:
	jsr	j_get_stats_ptr			; 7728
	lda	#$1F				; 772B  _
	lda	(ptr1),y			; 772D
	tax					; 772F
	lda	L7D83,x				; 7730
	sta	zptmp1				; 7733
	jsr	j_rand				; 7735
	cmp	zptmp1				; 7738
	bcs	L7742				; 773A
L773C:
	jsr	j_idle_combat			; 773C
	jmp	L73C4				; 773F

L7742:
	jsr	L7748				; 7742
	jmp	L73C4				; 7745

L7748:
	lda	#$4F				; 7748  O
	sta	missile				; 774A
	jsr	invert_player_line		; 774D
	jsr	j_idle_combat			; 7750
	lda	#$07				; 7753  G
	jsr	j_playsfx			; 7755
	lda	#$00				; 7758  .
	sta	missile				; 775A
	jsr	j_idle_combat			; 775D
	ldx	$6A				; 7760
	lda	cbt_monster_type,x		; 7762
	jsr	get_creature_type		; 7765
	tax					; 7768
	lda	monster_xp,x			; 7769
	lsr	a				; 776C
	lsr	a				; 776D
	jsr	randmax				; 776E
	jsr	hextobcd			; 7771
	jsr	stat_sub_hp			; 7774
	bne	L7793				; 7777
	jsr	j_printname			; 7779
	jsr	j_primm				; 777C
	.byte	$8D,$C9,$D3,$A0,$CB,$C9,$CC,$CC	; 777F  MIS KILL
	.byte	$C5,$C4,$A1,$8D,$00		; 7787  ED!M.

	ldy	#$04				; 778C  D
	lda	#$01				; 778E  A
	jsr	virtue_inc			; 7790
L7793:
	jsr	invert_player_line		; 7793
	jsr	j_update_status			; 7796
	rts					; 7799

L779A:
	.byte	$84				; 779A  D
L779B:
	adc	cmd_unknown,y			; 779B
	.byte	$77				; 779E  w
	.byte	$7C				; 779F  |
	.byte	$12				; 77A0  R
	eor	(tile_xpos,x)			; 77A1
	eor	(tile_xpos,x)			; 77A3
	eor	($84,x)				; 77A5
	.byte	$7C				; 77A7  |
	.byte	$12				; 77A8  R
	eor	(tile_xpos,x)			; 77A9
	eor	(tile_xpos,x)			; 77AB
	eor	(tile_xpos,x)			; 77AD
	eor	(tile_xpos,x)			; 77AF
	eor	(tile_xpos,x)			; 77B1
	eor	(tile_xpos,x)			; 77B3
	eor	(tile_xpos,x)			; 77B5
	eor	(tile_xpos,x)			; 77B7
	eor	(tile_xpos,x)			; 77B9
	eor	($CB,x)				; 77BB
	.byte	$7C				; 77BD  |
	.byte	$12				; 77BE  R
	eor	(tile_xpos,x)			; 77BF
	eor	($F4,x)				; 77C1
	.byte	$5A				; 77C3  Z
	.byte	$22				; 77C4  \"
	.byte	$5B				; 77C5  [
	.byte	$12				; 77C6  R
	eor	(tile_xpos,x)			; 77C7
	eor	(tile_xpos,x)			; 77C9
	eor	($E0,x)				; 77CB
	.byte	$7C				; 77CD  |
L77CE:
	jsr	j_primm				; 77CE
	.byte	$CE,$EF,$F2,$F4,$E8,$8D,$00	; 77D1  NorthM.

	ldx	currplayer			; 77D8
	dex					; 77DA
	lda	cbt_player_xpos,x		; 77DB
	sta	$16				; 77DE
	ldy	cbt_player_ypos,x		; 77E0
	dey					; 77E3
	sty	$17				; 77E4
	jmp	L7838				; 77E6

L77E9:
	jsr	j_primm				; 77E9
	.byte	$D3,$EF,$F5,$F4,$E8,$8D,$00	; 77EC  SouthM.

	ldx	currplayer			; 77F3
	dex					; 77F5
	lda	cbt_player_xpos,x		; 77F6
	sta	$16				; 77F9
	ldy	cbt_player_ypos,x		; 77FB
	iny					; 77FE
	sty	$17				; 77FF
	jmp	L7838				; 7801

L7804:
	jsr	j_primm				; 7804
	.byte	$C5,$E1,$F3,$F4,$8D,$00		; 7807  EastM.

	ldx	currplayer			; 780D
	dex					; 780F
	lda	cbt_player_ypos,x		; 7810
	sta	$17				; 7813
	ldy	cbt_player_xpos,x		; 7815
	iny					; 7818
	sty	$16				; 7819
	jmp	L7838				; 781B

L781E:
	jsr	j_primm				; 781E
	.byte	$D7,$E5,$F3,$F4,$8D,$00		; 7821  WestM.

	ldx	currplayer			; 7827
	dex					; 7829
	lda	cbt_player_ypos,x		; 782A
	sta	$17				; 782D
	ldy	cbt_player_xpos,x		; 782F
	dey					; 7832
	sty	$16				; 7833
	jmp	L7838				; 7835

L7838:
	lda	#$00				; 7838  .
	jsr	j_playsfx			; 783A
	lda	$16				; 783D
	cmp	#$0B				; 783F  K
	bcc	L7846				; 7841
	jmp	L78E8				; 7843

L7846:
	lda	$17				; 7846
	cmp	#$0B				; 7848  K
	bcc	L784F				; 784A
	jmp	L78E8				; 784C

L784F:
	jsr	L088A				; 784F
	jsr	j_blocked_tile			; 7852
	bpl	L785A				; 7855
	jmp	move_blocked			; 7857

L785A:
	jsr	L088A				; 785A
	jsr	check_slow_progress		; 785D
	beq	L7868				; 7860
	jsr	print_slow_progress		; 7862
	jmp	L7133				; 7865

L7868:
	ldx	currplayer			; 7868
	dex					; 786A
	lda	$16				; 786B
	sta	cbt_player_xpos,x		; 786D
	lda	$17				; 7870
	sta	cbt_player_ypos,x		; 7872
	lda	#$00				; 7875  .
	jsr	j_playsfx			; 7877
	lda	game_mode			; 787A
	cmp	#$81				; 787C  A
	bne	L78C7				; 787E
	ldx	#$00				; 7880  .
	stx	$58				; 7882
L7884:
	lda	$AF10,x				; 7884
	beq	L78BB				; 7887
	lda	$AF11,x				; 7889
	beq	L78BB				; 788C
	lsr	a				; 788E
	lsr	a				; 788F
	lsr	a				; 7890
	lsr	a				; 7891
	cmp	$16				; 7892
	bne	L78BB				; 7894
	lda	$AF11,x				; 7896
	and	#$0F				; 7899  O
	cmp	$17				; 789B
	bne	L78BB				; 789D
	lda	$AF12,x				; 789F
	beq	L78AD				; 78A2
	jsr	L78CA				; 78A4
	lda	$AF10,x				; 78A7
	sta	tempmap,y			; 78AA
L78AD:
	lda	$AF13,x				; 78AD
	beq	L78BB				; 78B0
	jsr	L78CA				; 78B2
	lda	$AF10,x				; 78B5
	sta	tempmap,y			; 78B8
L78BB:
	lda	$58				; 78BB
	clc					; 78BD
	adc	#$04				; 78BE  D
	sta	$58				; 78C0
	tax					; 78C2
	cmp	#$10				; 78C3  P
	bcc	L7884				; 78C5
L78C7:
	jmp	L7133				; 78C7

L78CA:
	pha					; 78CA
	lsr	a				; 78CB
	lsr	a				; 78CC
	lsr	a				; 78CD
	lsr	a				; 78CE
	sta	$59				; 78CF
	pla					; 78D1
	and	#$0F				; 78D2  O
	tay					; 78D4
	lda	L78DD,y				; 78D5
	clc					; 78D8
	adc	$59				; 78D9
	tay					; 78DB
	rts					; 78DC

L78DD:
	.byte	$00,$0B,$16,$21,$2C,$37,$42,$4D	; 78DD  .KV!,7BM
	.byte	$58,$63,$6E			; 78E5  Xcn

L78E8:
	lda	game_mode			; 78E8
	cmp	#$81				; 78EA  A
	bne	L7942				; 78EC
	lda	L7982				; 78EE
	bne	L790C				; 78F1
	lda	L7983				; 78F3
	bne	L7912				; 78F6
	lda	$16				; 78F8
	cmp	#$0B				; 78FA  K
	bcc	L7904				; 78FC
	sta	L7982				; 78FE
	jmp	L7942				; 7901

L7904:
	lda	$17				; 7904
	sta	L7983				; 7906
	jmp	L7942				; 7909

L790C:
	cmp	$16				; 790C
	beq	L7942				; 790E
	bne	L7918				; 7910
L7912:
	cmp	$17				; 7912
	beq	L7942				; 7914
	bne	L7918				; 7916
L7918:
	pla					; 7918
	pla					; 7919
	jsr	j_primm				; 791A
	.byte	$C1,$CC,$CC,$A0,$CD,$D5,$D3,$D4	; 791D  ALL MUST
	.byte	$A0,$D5,$D3,$C5,$8D,$D4,$C8,$C5	; 7925   USEMTHE
	.byte	$A0,$D3,$C1,$CD,$C5,$A0,$C5,$D8	; 792D   SAME EX
	.byte	$C9,$D4,$A1,$8D,$00		; 7935  IT!M.

	lda	#$01				; 793A  A
	jsr	j_playsfx			; 793C
	jmp	L7133				; 793F

L7942:
	ldx	currplayer			; 7942
	dex					; 7944
	lda	#$80				; 7945  .
	sta	cbt_player_xpos,x		; 7947
	sta	cbt_player_ypos,x		; 794A
	lda	#$00				; 794D  .
	sta	player_tile,x			; 794F
	lda	#$08				; 7952  H
	jsr	j_playsfx			; 7954
	lda	game_mode			; 7957
	cmp	#$80				; 7959  .
	bne	L797F				; 795B
	lda	attacking_monster_type		; 795D
	jsr	check_evil			; 795F
	bpl	L797F				; 7962
	jsr	j_get_stats_ptr			; 7964
	ldy	#$18				; 7967  X
	lda	(ptr1),y			; 7969
	ldy	#$1A				; 796B  Z
	cmp	(ptr1),y			; 796D
	bne	L797F				; 796F
	ldy	#$02				; 7971  B
	lda	#$02				; 7973  B
	jsr	virtue_dec			; 7975
	ldy	#$04				; 7978  D
	lda	#$02				; 797A  B
	jsr	virtue_dec			; 797C
L797F:
	jmp	L7133				; 797F

L7982:
	brk					; 7982
L7983:
	brk					; 7983
	lda	#$00				; 7984  .
	sta	L7C76				; 7986
	jsr	j_primm				; 7989
	.byte	$C1,$F4,$F4,$E1,$E3,$EB,$AD,$00	; 798C  Attack-.

	jsr	combat_getdirection		; 7994
	bne	L799C				; 7997
	jmp	cmd_pass			; 7999

L799C:
	lda	$16				; 799C
	sta	missile_xpos			; 799E
	lda	$17				; 79A1
	sta	missile_ypos			; 79A3
	ldx	L7C74				; 79A6
	lda	L7D8B,x				; 79A9
	bne	L79F8				; 79AC
	cpx	#$0A				; 79AE  J
	bne	L79C4				; 79B0
	clc					; 79B2
	lda	missile_xpos			; 79B3
	adc	$78				; 79B6
	sta	missile_xpos			; 79B8
	clc					; 79BB
	lda	missile_ypos			; 79BC
	adc	$79				; 79BF
	sta	missile_ypos			; 79C1
L79C4:
	jsr	combat_fire_missile		; 79C4
	bpl	L79CC				; 79C7
	jmp	L7BFA				; 79C9

L79CC:
	lda	#$4D				; 79CC  M
	sta	missile				; 79CE
	jsr	j_idle_combat			; 79D1
	lda	#$00				; 79D4  .
	sta	missile				; 79D6
	lda	#$04				; 79D9  D
	jsr	j_playsfx			; 79DB
	jsr	combat_find_monster		; 79DE
	bpl	L79F2				; 79E1
	lda	#$01				; 79E3  A
	sta	L7C76				; 79E5
	lda	L7C74				; 79E8
	cmp	#$02				; 79EB  B
	beq	L79F8				; 79ED
	jmp	L7BFA				; 79EF

L79F2:
	inc	L7C76				; 79F2
	jmp	L7A8C				; 79F5

L79F8:
	lda	#$0B				; 79F8  K
	sta	L7C75				; 79FA
	lda	L7C74				; 79FD
	cmp	#$09				; 7A00  I
	bne	L7A1E				; 7A02
	jsr	j_primm				; 7A04
	.byte	$D2,$C1,$CE,$C7,$C5,$AD,$00	; 7A07  RANGE-.

	jsr	getandprintkey			; 7A0E
	sec					; 7A11
	sbc	#$B0				; 7A12  0
	cmp	#$0A				; 7A14  J
	bcc	L7A1B				; 7A16
	jmp	L7BFA				; 7A18

L7A1B:
	sta	L7C75				; 7A1B
L7A1E:
	lda	L7C74				; 7A1E
	cmp	#$02				; 7A21  B
	beq	L7A29				; 7A23
	cmp	#$09				; 7A25  I
	bne	L7A51				; 7A27
L7A29:
	clc					; 7A29
	adc	#$20				; 7A2A   
	tay					; 7A2C
	lda	game_stats,y			; 7A2D
	beq	L7A38				; 7A30
	jsr	stat_dec			; 7A32
	jmp	L7A51				; 7A35

L7A38:
	lda	#$00				; 7A38  .
	jsr	j_get_stats_ptr			; 7A3A
	ldy	#$1E				; 7A3D  ^
	lda	#$00				; 7A3F  .
	sta	(ptr1),y			; 7A41
	jsr	j_primm				; 7A43
	.byte	$CC,$C1,$D3,$D4,$A0,$CF,$CE,$C5	; 7A46  LAST ONE
	.byte	$A1,$8D,$00			; 7A4E  !M.

L7A51:
	jsr	combat_fire_missile		; 7A51
	bpl	L7A59				; 7A54
	jmp	L7BFA				; 7A56

L7A59:
	lda	#$4D				; 7A59  M
	sta	missile				; 7A5B
	lda	L7C74				; 7A5E
	cmp	#$0E				; 7A61  N
	bne	L7A6A				; 7A63
	lda	#$4E				; 7A65  N
	sta	missile				; 7A67
L7A6A:
	jsr	j_idle_combat			; 7A6A
	lda	#$00				; 7A6D  .
	sta	missile				; 7A6F
	lda	L7C76				; 7A72
	bne	L7A7C				; 7A75
	lda	#$04				; 7A77  D
	jsr	j_playsfx			; 7A79
L7A7C:
	inc	L7C76				; 7A7C
	jsr	combat_find_monster		; 7A7F
	bpl	L7A8C				; 7A82
	dec	L7C75				; 7A84
	bne	L7A51				; 7A87
	jmp	L7BFA				; 7A89

L7A8C:
	lda	current_location		; 7A8C
	cmp	#$18				; 7A8E  X
	bne	L7A9C				; 7A90
	lda	L7C74				; 7A92
	cmp	#$0B				; 7A95  K
	bcs	L7A9C				; 7A97
	jmp	L7BFA				; 7A99

L7A9C:
	lda	L7C74				; 7A9C
	cmp	#$09				; 7A9F  I
	bne	L7AAF				; 7AA1
	jsr	j_gettile_combat		; 7AA3
	cmp	#$03				; 7AA6  C
	bcc	L7AAF				; 7AA8
	lda	#$46				; 7AAA  F
	sta	tempmap,y			; 7AAC
L7AAF:
	lda	#$4F				; 7AAF  O
	sta	missile				; 7AB1
	lda	L7C74				; 7AB4
	cmp	#$0E				; 7AB7  N
	bne	L7AC0				; 7AB9
	lda	#$4E				; 7ABB  N
	sta	missile				; 7ABD
L7AC0:
	jsr	j_get_stats_ptr			; 7AC0
	ldy	#$14				; 7AC3  T
	lda	(ptr1),y			; 7AC5
	jsr	bcdtohex			; 7AC7
	asl	a				; 7ACA
	clc					; 7ACB
	adc	#$80				; 7ACC  .
	bcs	L7ADC				; 7ACE
	sta	zptmp1				; 7AD0
	jsr	j_rand				; 7AD2
	cmp	zptmp1				; 7AD5
	bcc	L7ADC				; 7AD7
	jmp	L7BFA				; 7AD9

L7ADC:
	jsr	j_get_stats_ptr			; 7ADC
	ldy	#$13				; 7ADF  S
	lda	(ptr1),y			; 7AE1
	jsr	bcdtohex			; 7AE3
	ldx	L7C74				; 7AE6
	clc					; 7AE9
	adc	L7D73,x				; 7AEA
	bcc	L7AF1				; 7AED
	lda	#$FF				; 7AEF  .
L7AF1:
	jsr	randmax				; 7AF1
	sta	$5C				; 7AF4
	jsr	j_idle_combat			; 7AF6
	lda	#$06				; 7AF9  F
	jsr	j_playsfx			; 7AFB
	lda	#$00				; 7AFE  .
	sta	missile				; 7B00
	jsr	hurt_monster			; 7B03
	jmp	L7C3D				; 7B06

hurt_monster:
	jsr	printcr				; 7B09
	ldx	$6A				; 7B0C
	lda	cbt_monster_type,x		; 7B0E
	sta	monster_type			; 7B11
	jsr	print_creature_name		; 7B13
	ldx	$6A				; 7B16
	lda	cbt_monster_type,x		; 7B18
	cmp	#$5E				; 7B1B  ^
	bne	@subtractdamage			; 7B1D
	jmp	@calcdmgpercent			; 7B1F

@subtractdamage:
	lda	monster_hp,x			; 7B22
	sec					; 7B25
	sbc	$5C				; 7B26
	sta	monster_hp,x			; 7B28
	bcs	@calcdmgpercent			; 7B2B
	lda	#$00				; 7B2D  .
	sta	monster_hp,x			; 7B2F
	sta	cbt_monster_type,x		; 7B32
	jsr	j_primm				; 7B35
	.byte	$CB,$C9,$CC,$CC,$C5,$C4,$A1,$8D	; 7B38  KILLED!M
	.byte	$00				; 7B40  .

	lda	currplayer			; 7B41
	beq	@done				; 7B43
	lda	monster_type			; 7B45
	jsr	get_creature_type		; 7B47
	tay					; 7B4A
	lda	monster_xp,y			; 7B4B
	lsr	a				; 7B4E
	lsr	a				; 7B4F
	lsr	a				; 7B50
	lsr	a				; 7B51
	clc					; 7B52
	adc	#$01				; 7B53  A
	jsr	hextobcd			; 7B55
	jsr	stat_add_exp			; 7B58
	jsr	j_primm				; 7B5B
	.byte	$C5,$D8,$D0,$AE,$AB,$00		; 7B5E  EXP.+.

	lda	$58				; 7B64
	cmp	#$10				; 7B66  P
	bcs	@lessthan10			; 7B68
	jsr	j_printdigit			; 7B6A
	jmp	@done				; 7B6D

@lessthan10:
	jsr	j_printbcd			; 7B70
@done:
	jsr	printcr				; 7B73
	rts					; 7B76

@calcdmgpercent:
	ldx	$6A				; 7B77
	lda	cbt_monster_type,x		; 7B79
	jsr	get_creature_type		; 7B7C
	tax					; 7B7F
	lda	monster_xp,x			; 7B80
	lsr	a				; 7B83
	sta	$59				; 7B84
	sta	zptmp1				; 7B86
	lsr	zptmp1				; 7B88
	clc					; 7B8A
	adc	zptmp1				; 7B8B
	sta	$58				; 7B8D
	ldx	$6A				; 7B8F
	lda	monster_hp,x			; 7B91
	cmp	#$18				; 7B94  X
	bcs	@checkcrit			; 7B96
	jsr	j_primm				; 7B98
	.byte	$C6,$CC,$C5,$C5,$C9,$CE,$C7,$A1	; 7B9B  FLEEING!
	.byte	$8D,$00				; 7BA3  M.

	jmp	@done				; 7BA5

@checkcrit:
	cmp	zptmp1				; 7BA8
	bcs	@checkheavy			; 7BAA
	jsr	j_primm				; 7BAC
	.byte	$C3,$D2,$C9,$D4,$C9,$C3,$C1,$CC	; 7BAF  CRITICAL
	.byte	$A1,$8D,$00			; 7BB7  !M.

	jmp	@done				; 7BBA

@checkheavy:
	cmp	$59				; 7BBD
	bcs	@checklightly			; 7BBF
	jsr	j_primm				; 7BC1
	.byte	$C8,$C5,$C1,$D6,$C9,$CC,$D9,$00	; 7BC4  HEAVILY.

	jmp	@printwounded			; 7BCC

@checklightly:
	cmp	$58				; 7BCF
	bcs	@barely				; 7BD1
	jsr	j_primm				; 7BD3
	.byte	$CC,$C9,$C7,$C8,$D4,$CC,$D9,$00	; 7BD6  LIGHTLY.

	jmp	@printwounded			; 7BDE

@barely:
	jsr	j_primm				; 7BE1
	.byte	$C2,$C1,$D2,$C5,$CC,$D9,$00	; 7BE4  BARELY.

@printwounded:
	jsr	j_primm				; 7BEB
	.byte	$A0,$D7,$CF,$D5,$CE,$C4,$C5,$C4	; 7BEE   WOUNDED
	.byte	$A1,$8D,$00			; 7BF6  !M.

@done:
	rts					; 7BF9

L7BFA:
	lda	L7C76				; 7BFA
	bne	L7C04				; 7BFD
	lda	#$04				; 7BFF  D
	jsr	j_playsfx			; 7C01
L7C04:
	lda	#$00				; 7C04  .
	sta	missile				; 7C06
	jsr	j_primm				; 7C09
	.byte	$CD,$C9,$D3,$D3,$C5,$C4,$A1,$8D	; 7C0C  MISSED!M
	.byte	$00				; 7C14  .

	lda	L7C74				; 7C15
	cmp	#$09				; 7C18  I
	bne	L7C3A				; 7C1A
	lda	missile_xpos			; 7C1C
	cmp	#$0B				; 7C1F  K
	bcs	L7C3A				; 7C21
	sta	$16				; 7C23
	lda	missile_ypos			; 7C25
	cmp	#$0B				; 7C28  K
	bcs	L7C3A				; 7C2A
	sta	$17				; 7C2C
	jsr	j_gettile_combat		; 7C2E
	cmp	#$03				; 7C31  C
	bcc	L7C3A				; 7C33
	lda	#$46				; 7C35  F
	sta	tempmap,y			; 7C37
L7C3A:
	jmp	L7C3D				; 7C3A

L7C3D:
	lda	L7C74				; 7C3D
	cmp	#$0B				; 7C40  K
	bne	L7C71				; 7C42
	lda	L7C76				; 7C44
	cmp	#$02				; 7C47  B
	bcc	L7C71				; 7C49
	dec	L7C76				; 7C4B
	lda	$78				; 7C4E
	jsr	L8281				; 7C50
	sta	$78				; 7C53
	lda	$79				; 7C55
	jsr	L8281				; 7C57
	sta	$79				; 7C5A
	lda	#$4D				; 7C5C  M
	sta	missile				; 7C5E
L7C61:
	jsr	combat_fire_missile		; 7C61
	jsr	j_idle_combat			; 7C64
	dec	L7C76				; 7C67
	bne	L7C61				; 7C6A
	lda	#$00				; 7C6C  .
	sta	missile				; 7C6E
L7C71:
	jmp	L7133				; 7C71

L7C74:
	brk					; 7C74
L7C75:
	brk					; 7C75
L7C76:
	brk					; 7C76
	jsr	j_primm				; 7C77
	.byte	$C3,$E1,$F3,$F4,$AC,$A0,$00	; 7C7A  Cast, .

	jmp	@playerok			; 7C81

	jsr	j_primm				; 7C84
	.byte	$C7,$E5,$F4,$A0,$E3,$E8,$E5,$F3	; 7C87  Get ches
	.byte	$F4,$A1,$8D,$00			; 7C8F  t!M.

combat_open_chest:
	ldx	currplayer			; 7C93
	dex					; 7C95
	lda	cbt_player_xpos,x		; 7C96
	sta	$16				; 7C99
	lda	cbt_player_ypos,x		; 7C9B
	sta	$17				; 7C9E
	jsr	j_gettile_combat		; 7CA0
	cmp	#$3C				; 7CA3  <
	beq	@chest				; 7CA5
	jmp	print_not_here			; 7CA7

@chest:
	lda	#$16				; 7CAA  V
	sta	tempmap,y			; 7CAC
	lda	game_mode_temp			; 7CAF
	cmp	#$03				; 7CB1  C
	bne	@notdungeon			; 7CB3
	lda	player_xpos			; 7CB5
	sta	$16				; 7CB7
	lda	player_ypos			; 7CB9
	sta	$17				; 7CBB
	jsr	j_gettile_dungeon		; 7CBD
	cmp	#$40				; 7CC0  @
	bne	@notdungeon			; 7CC2
	lda	#$00				; 7CC4  .
	sta	(ptr1),y			; 7CC6
@notdungeon:
	jmp	openchest			; 7CC8

	jsr	j_primm				; 7CCB
	.byte	$D2,$E5,$E1,$E4,$F9,$A0,$F7,$E5	; 7CCE  Ready we
	.byte	$E1,$F0,$EF,$EE,$BA,$8D,$00	; 7CD6  apon:M.

	jmp	L58EB				; 7CDD

	jsr	j_primm				; 7CE0
	.byte	$DA,$F4,$E1,$F4,$F3,$8D,$00	; 7CE3  ZtatsM.

	jsr	L5CC8				; 7CEA
	jsr	j_update_status			; 7CED
	jsr	invert_player_line		; 7CF0
	jmp	L7133				; 7CF3

monster_xp:
	.byte	$FF,$FF,$40,$60,$80,$60,$FF,$FF	; 7CF6  ..@`.`..
	.byte	$30,$30,$40,$50,$30,$60,$30,$C0	; 7CFE  00@P0`0@
	.byte	$FF,$30,$F0,$80,$50,$30,$50,$30	; 7D06  .0p.P0P0
	.byte	$70,$40,$80,$40,$B0,$C0,$60,$F0	; 7D0E  p@.@0@`p
	.byte	$70,$D0,$E0,$FF,$70,$30,$60,$40	; 7D16  pP`.p0`@
	.byte	$60,$80,$90,$30,$80,$30,$30,$30	; 7D1E  `.P0.000
	.byte	$20,$20,$80,$FF			; 7D26    ..
L7D2A:
	.byte	$C8,$C8,$8A,$88,$86,$84,$8C,$8E	; 7D2A  HHJHFDLN
	.byte	$C4,$E4,$90,$E4,$A0,$D0,$A8,$AC	; 7D32  DdPd P(,
	.byte	$B0,$90,$BC,$9C,$A4,$E0,$C8,$90	; 7D3A  0P<\$`HP
	.byte	$F0,$B8,$EC,$BC,$F0,$F0,$F4,$B8	; 7D42  p8l<ppt8
	.byte	$FC,$F8,$FC,$FC			; 7D4A  |x||
L7D4E:
	.byte	$01,$01,$0C,$04,$04,$08,$01,$01	; 7D4E  AALDDHAA
	.byte	$0C,$0C,$06,$04,$0F,$06,$0F,$01	; 7D56  LLFDOFOA
	.byte	$01,$0F,$04,$08,$0A,$0C,$0A,$0C	; 7D5E  AODHJLJL
	.byte	$06,$08,$06,$0C,$06,$04,$08,$04	; 7D66  FHFLFDHD
	.byte	$06,$04,$04,$01			; 7D6E  FDDA
L7D72:
	.byte	$00				; 7D72  .
L7D73:
	.byte	$08,$10,$18,$20,$28,$30,$40,$28	; 7D73  HPX (0@(
	.byte	$38,$40,$60,$60,$80,$50,$A0,$FF	; 7D7B  8@``.P .
L7D83:
	.byte	$60,$80,$90,$A0,$B0,$C0,$D0,$F8	; 7D83  `.P 0@Px
L7D8B:
	.byte	$00,$00,$00,$FF,$00,$00,$00,$FF	; 7D8B  ........
	.byte	$FF,$FF,$00,$FF,$00,$FF,$FF,$00	; 7D93  ........

get_creature_type:
	bpl	@npc				; 7D9B
	and	#$7F				; 7D9D  .
	lsr	a				; 7D9F
	cmp	#$08				; 7DA0  H
	bcc	@twoframes			; 7DA2
	lsr	a				; 7DA4
	clc					; 7DA5
	adc	#$04				; 7DA6  D
@twoframes:
	rts					; 7DA8

@npc:
	and	#$1F				; 7DA9  _
	clc					; 7DAB
	adc	#$24				; 7DAC  $
	rts					; 7DAE

check_awake:
	jsr	j_get_stats_ptr			; 7DAF
	ldy	#$12				; 7DB2  R
	lda	(ptr1),y			; 7DB4
	cmp	#$C7				; 7DB6  G
	beq	check_joined			; 7DB8
	cmp	#$D0				; 7DBA  P
	beq	check_joined			; 7DBC
	lda	#$FF				; 7DBE  .
	rts					; 7DC0

check_alive:
	jsr	j_get_stats_ptr			; 7DC1
	ldy	#$12				; 7DC4  R
	lda	(ptr1),y			; 7DC6
	cmp	#$C7				; 7DC8  G
	beq	check_joined			; 7DCA
	cmp	#$D0				; 7DCC  P
	beq	check_joined			; 7DCE
	cmp	#$D3				; 7DD0  S
	beq	check_joined			; 7DD2
not_joined:
	lda	#$FF				; 7DD4  .
	rts					; 7DD6

check_joined:
	lda	currplayer			; 7DD7
	cmp	party_size			; 7DD9
	beq	@ok				; 7DDB
	bcs	not_joined			; 7DDD
@ok:
	lda	#$00				; 7DDF  .
	rts					; 7DE1

something_based_on_status_and_class:
	jsr	j_get_stats_ptr			; 7DE2
	ldy	#$12				; 7DE5  R
	lda	(ptr1),y			; 7DE7
	cmp	#$C7				; 7DE9  G
	beq	L7DF8				; 7DEB
	cmp	#$D0				; 7DED  P
	beq	L7DF8				; 7DEF
	cmp	#$C4				; 7DF1  D
	beq	L7E00				; 7DF3
	lda	#$38				; 7DF5  8
	rts					; 7DF7

L7DF8:
	ldy	#$11				; 7DF8  Q
	lda	(ptr1),y			; 7DFA
	asl	a				; 7DFC
	adc	#$20				; 7DFD   
	rts					; 7DFF

L7E00:
	lda	#$FF				; 7E00  .
	rts					; 7E02

randmax:
	cmp	#$00				; 7E03  .
	beq	@zero				; 7E05
	sta	L7E1C				; 7E07
	jsr	j_rand				; 7E0A
@rollagain:
	cmp	L7E1C				; 7E0D
	bcc	@gotval				; 7E10
	sec					; 7E12
	sbc	L7E1C				; 7E13
	jmp	@rollagain			; 7E16

@gotval:
	cmp	#$00				; 7E19  .
@zero:
	rts					; 7E1B

L7E1C:
	.byte	$00				; 7E1C  .

L7E1D:
	sta	zptmp1				; 7E1D
	stx	$59				; 7E1F
	jsr	check_slow_progress		; 7E21
	bpl	L7E29				; 7E24
	jmp	L7EE5				; 7E26

L7E29:
	lda	object_tile,x			; 7E29
	cmp	#$8C				; 7E2C  L
	beq	L7E6C				; 7E2E
	cmp	#$8E				; 7E30  N
	beq	L7E6C				; 7E32
	ldy	#$1F				; 7E34  _
L7E36:
	lda	object_tile,y			; 7E36
	beq	L7E53				; 7E39
	lda	object_xpos,y			; 7E3B
	cmp	$7A				; 7E3E
	bne	L7E53				; 7E40
	lda	object_ypos,y			; 7E42
	cmp	$7B				; 7E45
	bne	L7E53				; 7E47
	lda	object_tile,y			; 7E49
	cmp	#$3C				; 7E4C  <
	beq	L7E53				; 7E4E
	jmp	L7EE5				; 7E50

L7E53:
	dey					; 7E53
	bpl	L7E36				; 7E54
	lda	$7A				; 7E56
	cmp	player_xpos			; 7E58
	bne	L7E65				; 7E5A
	lda	$7B				; 7E5C
	cmp	player_ypos			; 7E5E
	bne	L7E65				; 7E60
	jmp	L7EE5				; 7E62

L7E65:
	lda	object_tile,x			; 7E65
	cmp	#$80				; 7E68  .
	beq	L7E81				; 7E6A
L7E6C:
	lda	$7A				; 7E6C
	cmp	$AC80,x				; 7E6E
	bne	L7E81				; 7E71
	lda	$7B				; 7E73
	cmp	$ACA0,x				; 7E75
	bne	L7E81				; 7E78
	jsr	j_rand				; 7E7A
	and	#$03				; 7E7D  C
	bne	L7EE5				; 7E7F
L7E81:
	lda	object_tile,x			; 7E81
	bpl	L7EB6				; 7E84
	cmp	#$8E				; 7E86  N
	bcc	L7EBF				; 7E88
	beq	L7ED3				; 7E8A
	cmp	#$94				; 7E8C  T
	beq	L7ED3				; 7E8E
	cmp	#$9C				; 7E90  \
	beq	L7EAA				; 7E92
	cmp	#$B4				; 7E94  4
	beq	L7ED3				; 7E96
	cmp	#$EC				; 7E98  l
	beq	L7EAA				; 7E9A
	cmp	#$F0				; 7E9C  p
	beq	L7ED3				; 7E9E
	cmp	#$F8				; 7EA0  x
	beq	L7ED3				; 7EA2
	cmp	#$FC				; 7EA4  |
	beq	L7ED3				; 7EA6
	bne	L7EB6				; 7EA8
L7EAA:
	lda	zptmp1				; 7EAA
	cmp	#$03				; 7EAC  C
	bcc	L7EE5				; 7EAE
	cmp	#$45				; 7EB0  E
	bne	L7EE0				; 7EB2
	beq	L7EE5				; 7EB4
L7EB6:
	lda	zptmp1				; 7EB6
	jsr	j_blocked_tile			; 7EB8
	bpl	L7EE0				; 7EBB
	bmi	L7EE5				; 7EBD
L7EBF:
	cmp	#$80				; 7EBF  .
	bne	L7ECB				; 7EC1
	lda	zptmp1				; 7EC3
	cmp	#$02				; 7EC5  B
	bcc	L7EE0				; 7EC7
	bcs	L7EE5				; 7EC9
L7ECB:
	lda	zptmp1				; 7ECB
	cmp	#$03				; 7ECD  C
	bcc	L7EE0				; 7ECF
	bcs	L7EE5				; 7ED1
L7ED3:
	lda	zptmp1				; 7ED3
	cmp	#$03				; 7ED5  C
	bcc	L7EE0				; 7ED7
	jsr	j_blocked_tile			; 7ED9
	bpl	L7EE0				; 7EDC
	bmi	L7EE5				; 7EDE
L7EE0:
	ldx	$59				; 7EE0
	lda	#$00				; 7EE2  .
	rts					; 7EE4

L7EE5:
	ldx	$59				; 7EE5
	lda	#$FF				; 7EE7  .
	rts					; 7EE9

L7EEA:
	sta	zptmp1				; 7EEA
	jsr	check_slow_progress		; 7EEC
	bmi	L7F06				; 7EEF
	lda	$16				; 7EF1
	cmp	#$0B				; 7EF3  K
	bcs	L7EFD				; 7EF5
	lda	$17				; 7EF7
	cmp	#$0B				; 7EF9  K
	bcc	L7F0C				; 7EFB
L7EFD:
	ldx	$6A				; 7EFD
	lda	monster_hp,x			; 7EFF
	cmp	#$18				; 7F02  X
	bcc	L7F09				; 7F04
L7F06:
	jmp	L7FAD				; 7F06

L7F09:
	jmp	L7FAA				; 7F09

L7F0C:
	ldx	$6A				; 7F0C
	lda	$AD20,x				; 7F0E
	cmp	$16				; 7F11
	bne	L7F23				; 7F13
	lda	$AD30,x				; 7F15
	cmp	$17				; 7F18
	bne	L7F23				; 7F1A
	jsr	j_rand				; 7F1C
	and	#$03				; 7F1F  C
	bne	L7F06				; 7F21
L7F23:
	ldx	#$0F				; 7F23  O
L7F25:
	lda	cbt_monster_type,x		; 7F25
	beq	L7F38				; 7F28
	lda	monster_xpos,x			; 7F2A
	cmp	$16				; 7F2D
	bne	L7F38				; 7F2F
	lda	monster_ypos,x			; 7F31
	cmp	$17				; 7F34
	beq	L7FAD				; 7F36
L7F38:
	cpx	#$08				; 7F38  H
	bcs	L7F4F				; 7F3A
	lda	player_tile,x			; 7F3C
	beq	L7F4F				; 7F3F
	lda	cbt_player_xpos,x		; 7F41
	cmp	$16				; 7F44
	bne	L7F4F				; 7F46
	lda	cbt_player_ypos,x		; 7F48
	cmp	$17				; 7F4B
	beq	L7FAD				; 7F4D
L7F4F:
	dex					; 7F4F
	bpl	L7F25				; 7F50
	ldx	$6A				; 7F52
	lda	cbt_monster_type,x		; 7F54
	bpl	L7F89				; 7F57
	cmp	#$8E				; 7F59  N
	bcc	L7F92				; 7F5B
	beq	L7F9A				; 7F5D
	cmp	#$94				; 7F5F  T
	beq	L7F9A				; 7F61
	cmp	#$9C				; 7F63  \
	beq	L7F7D				; 7F65
	cmp	#$B4				; 7F67  4
	beq	L7F9A				; 7F69
	cmp	#$EC				; 7F6B  l
	beq	L7F7D				; 7F6D
	cmp	#$F0				; 7F6F  p
	beq	L7F9A				; 7F71
	cmp	#$F8				; 7F73  x
	beq	L7F9A				; 7F75
	cmp	#$FC				; 7F77  |
	beq	L7F9A				; 7F79
	bne	L7F89				; 7F7B
L7F7D:
	lda	zptmp1				; 7F7D
	cmp	#$03				; 7F7F  C
	bcc	L7FAD				; 7F81
	cmp	#$45				; 7F83  E
	bne	L7FAA				; 7F85
	beq	L7FAD				; 7F87
L7F89:
	lda	zptmp1				; 7F89
	jsr	j_blocked_tile			; 7F8B
	bpl	L7FAA				; 7F8E
	bmi	L7FAD				; 7F90
L7F92:
	lda	zptmp1				; 7F92
	cmp	#$03				; 7F94  C
	bcc	L7FAA				; 7F96
	bcs	L7FAD				; 7F98
L7F9A:
	lda	zptmp1				; 7F9A
	cmp	#$03				; 7F9C  C
	bcc	L7FAA				; 7F9E
	jsr	j_blocked_tile			; 7FA0
	jsr	j_blocked_tile			; 7FA3
	bpl	L7FAA				; 7FA6
	bmi	L7FAD				; 7FA8
L7FAA:
	lda	#$00				; 7FAA  .
	rts					; 7FAC

L7FAD:
	lda	#$FF				; 7FAD  .
	rts					; 7FAF

L7FB0:
	pha					; 7FB0
	and	#$0F				; 7FB1  O
	bne	L7FE4				; 7FB3
	pla					; 7FB5
	and	#$F0				; 7FB6  p
	cmp	#$80				; 7FB8  .
	beq	L7FE5				; 7FBA
	cmp	#$90				; 7FBC  P
	beq	L7FE5				; 7FBE
	cmp	#$A0				; 7FC0   
	beq	L7FE5				; 7FC2
	cmp	#$D0				; 7FC4  P
	beq	L7FE5				; 7FC6
	cmp	#$F0				; 7FC8  p
	beq	L7FE5				; 7FCA
	jsr	j_rand				; 7FCC
	and	#$07				; 7FCF  G
	beq	L7FE1				; 7FD1
	lda	$16				; 7FD3
	cmp	$AC80,x				; 7FD5
	bne	L7FE1				; 7FD8
	lda	$17				; 7FDA
	cmp	$ACA0,x				; 7FDC
	beq	L7FE5				; 7FDF
L7FE1:
	lda	#$00				; 7FE1  .
	rts					; 7FE3

L7FE4:
	pla					; 7FE4
L7FE5:
	lda	#$FF				; 7FE5  .
	rts					; 7FE7

dng_check_forward_block:
	sta	$58				; 7FE8
	and	#$F0				; 7FEA  p
	cmp	#$C0				; 7FEC  @
	beq	dng_not_blocked			; 7FEE
	cmp	#$E0				; 7FF0  `
	beq	dng_not_blocked			; 7FF2
	cmp	#$D0				; 7FF4  P
	beq	dng_not_blocked			; 7FF6
	lda	$58				; 7FF8
dng_check_retreat_block:
	cmp	#$A1				; 7FFA  !
	beq	dng_blocked			; 7FFC
	cmp	#$C0				; 7FFE  @
	bcs	dng_blocked			; 8000
	bcc	dng_not_blocked			; 8002
dng_not_blocked:
	lda	#$00				; 8004  .
	rts					; 8006

dng_blocked:
	lda	#$FF				; 8007  .
	rts					; 8009

update_door:
	lda	game_mode			; 800A
	cmp	#$02				; 800C  B
	bne	@done				; 800E
	lda	open_door_counter		; 8010
	bne	@checkclose			; 8013
	rts					; 8015

@checkclose:
	dec	open_door_counter		; 8016
	beq	@close				; 8019
	rts					; 801B

@close:
	lda	open_door_xpos			; 801C
	sta	$7A				; 801F
	lda	open_door_ypos			; 8021
	sta	$7B				; 8024
	jsr	j_gettile_town			; 8026
	lda	#$3B				; 8029  ;
	sta	(ptr2),y			; 802B
@done:
	lda	#$00				; 802D  .
	sta	open_door_counter		; 802F
	rts					; 8032

open_door_xpos:
	.byte	$00				; 8033  .
open_door_ypos:
	.byte	$00				; 8034  .
open_door_counter:
	.byte	$00				; 8035  .

L8036:
	cmp	#$20				; 8036   
	beq	L809C				; 8038
	cmp	#$5E				; 803A  ^
	beq	L809C				; 803C
	cmp	#$84				; 803E  D
	beq	L80A5				; 8040
	cmp	#$86				; 8042  F
	beq	L8090				; 8044
	cmp	#$88				; 8046  H
	beq	L809F				; 8048
	cmp	#$8A				; 804A  J
	beq	L809C				; 804C
	cmp	#$98				; 804E  X
	beq	L808D				; 8050
	cmp	#$A4				; 8052  $
	beq	L80A5				; 8054
	cmp	#$AC				; 8056  ,
	beq	L808D				; 8058
	cmp	#$B8				; 805A  8
	beq	L8096				; 805C
	cmp	#$CC				; 805E  L
	beq	L808D				; 8060
	cmp	#$D0				; 8062  P
	beq	L8099				; 8064
	cmp	#$D8				; 8066  X
	beq	L8099				; 8068
	cmp	#$E0				; 806A  `
	beq	L809C				; 806C
	cmp	#$E4				; 806E  d
	beq	L809C				; 8070
	cmp	#$E8				; 8072  h
	beq	L80A2				; 8074
	cmp	#$F0				; 8076  p
	beq	L809C				; 8078
	cmp	#$F4				; 807A  t
	bcs	L809F				; 807C
	cmp	#$F8				; 807E  x
	beq	L809F				; 8080
	cmp	#$B0				; 8082  0
	beq	L80A8				; 8084
	cmp	#$FC				; 8086  |
	beq	L80A8				; 8088
	lda	#$00				; 808A  .
	rts					; 808C

L808D:
	lda	#$44				; 808D  D
	rts					; 808F

L8090:
	lda	#$45				; 8090  E
	rts					; 8092

	lda	#$46				; 8093  F
	rts					; 8095

L8096:
	lda	#$47				; 8096  G
	rts					; 8098

L8099:
	lda	#$37				; 8099  7
	rts					; 809B

L809C:
	lda	#$4E				; 809C  N
	rts					; 809E

L809F:
	lda	#$4F				; 809F  O
	rts					; 80A1

L80A2:
	lda	#$4C				; 80A2  L
	rts					; 80A4

L80A5:
	lda	#$4D				; 80A5  M
	rts					; 80A7

L80A8:
	jsr	j_rand				; 80A8
	and	#$03				; 80AB  C
	clc					; 80AD
	adc	#$44				; 80AE  D
	rts					; 80B0

L80B1:
	sta	missile				; 80B1
	lda	monster_xpos,x			; 80B4
	sta	missile_xpos			; 80B7
	lda	monster_ypos,x			; 80BA
	sta	missile_ypos			; 80BD
	lda	#$03				; 80C0  C
	jsr	j_playsfx			; 80C2
L80C5:
	jsr	combat_fire_missile		; 80C5
	bmi	L80D5				; 80C8
	jsr	L81DE				; 80CA
	bne	L80F5				; 80CD
	jsr	j_idle_combat			; 80CF
	jmp	L80C5				; 80D2

L80D5:
	lda	missile				; 80D5
	ldx	#$00				; 80D8  .
	stx	missile				; 80DA
	cmp	#$4C				; 80DD  L
	beq	L80E2				; 80DF
	rts					; 80E1

L80E2:
	lda	missile_xpos			; 80E2
	sta	$16				; 80E5
	lda	missile_ypos			; 80E7
	sta	$17				; 80EA
	jsr	L088A				; 80EC
	lda	#$4C				; 80EF  L
	sta	tempmap,y			; 80F1
	rts					; 80F4

L80F5:
	jsr	printcr				; 80F5
	jsr	j_printname			; 80F8
	jsr	printcr				; 80FB
	lda	missile				; 80FE
	cmp	#$44				; 8101  D
	bne	L812B				; 8103
	jsr	j_primm				; 8105
	.byte	$D0,$CF,$C9,$D3,$CF,$CE,$C5,$C4	; 8108  POISONED
	.byte	$A1,$8D,$00			; 8110  !M.

	jsr	L81C0				; 8113
	jsr	j_rand				; 8116
	bpl	L816C				; 8119
	jsr	j_get_stats_ptr			; 811B
	ldy	#$12				; 811E  R
	lda	(ptr1),y			; 8120
	cmp	#$C7				; 8122  G
	bne	L816C				; 8124
	lda	#$D0				; 8126  P
	sta	(ptr1),y			; 8128
	rts					; 812A

L812B:
	cmp	#$45				; 812B  E
	bne	L8144				; 812D
	jsr	j_primm				; 812F
	.byte	$C5,$CC,$C5,$C3,$D4,$D2,$C9,$C6	; 8132  ELECTRIF
	.byte	$C9,$C5,$C4,$A1,$8D,$00		; 813A  IED!M.

	jsr	L7748				; 8140
	rts					; 8143

L8144:
	cmp	#$46				; 8144  F
	bne	L8155				; 8146
	jsr	j_primm				; 8148
	.byte	$C6,$C9,$C5,$D2,$D9,$A0,$00	; 814B  FIERY .

	jmp	L81B3				; 8152

L8155:
	cmp	#$47				; 8155  G
	bne	L8190				; 8157
	jsr	j_primm				; 8159
	.byte	$D3,$CC,$C5,$D0,$D4,$A1,$8D,$00	; 815C  SLEPT!M.

	jsr	L81C0				; 8164
	jsr	j_rand				; 8167
	bmi	L8179				; 816A
L816C:
	jsr	j_primm				; 816C
	.byte	$C6,$C1,$C9,$CC,$C5,$C4,$AE,$8D	; 816F  FAILED.M
	.byte	$00				; 8177  .

	rts					; 8178

L8179:
	jsr	j_get_stats_ptr			; 8179
	ldy	#$12				; 817C  R
	lda	(ptr1),y			; 817E
	cmp	#$C7				; 8180  G
	bne	L816C				; 8182
	lda	#$D3				; 8184  S
	sta	(ptr1),y			; 8186
	lda	#$38				; 8188  8
	ldx	currplayer			; 818A
	sta	$AD9F,x				; 818C
	rts					; 818F

L8190:
	cmp	#$4C				; 8190  L
	bne	L81A0				; 8192
	jsr	j_primm				; 8194
	.byte	$CC,$C1,$D6,$C1,$A0,$00		; 8197  LAVA .

	jmp	L81B3				; 819D

L81A0:
	cmp	#$4E				; 81A0  N
	bne	L81B3				; 81A2
	jsr	j_primm				; 81A4
	.byte	$CD,$C1,$C7,$C9,$C3,$C1,$CC,$A0	; 81A7  MAGICAL 
	.byte	$00				; 81AF  .

	jmp	L81B3				; 81B0

L81B3:
	jsr	j_primm				; 81B3
	.byte	$C8,$C9,$D4,$A1,$8D,$00		; 81B6  HIT!M.

	jsr	L7748				; 81BC
	rts					; 81BF

L81C0:
	jsr	invert_player_line		; 81C0
	lda	$16				; 81C3
	sta	missile_xpos			; 81C5
	lda	$17				; 81C8
	sta	missile_ypos			; 81CA
	jsr	j_idle_combat			; 81CD
	lda	#$07				; 81D0  G
	jsr	j_playsfx			; 81D2
	jsr	invert_player_line		; 81D5
	lda	#$00				; 81D8  .
	sta	missile				; 81DA
	rts					; 81DD

L81DE:
	lda	party_size			; 81DE
	sta	currplayer			; 81E0
L81E2:
	jsr	check_alive			; 81E2
	bne	L81FD				; 81E5
	ldx	currplayer			; 81E7
	dex					; 81E9
	lda	missile_xpos			; 81EA
	cmp	cbt_player_xpos,x		; 81ED
	bne	L81FD				; 81F0
	lda	missile_ypos			; 81F2
	cmp	cbt_player_ypos,x		; 81F5
	bne	L81FD				; 81F8
	lda	currplayer			; 81FA
	rts					; 81FC

L81FD:
	dec	currplayer			; 81FD
	bne	L81E2				; 81FF
	rts					; 8201

combat_find_monster:
	ldy	#$0F				; 8202  O
@checkmonster:
	lda	cbt_monster_type,y		; 8204
	beq	@next				; 8207
	lda	monster_xpos,y			; 8209
	cmp	$16				; 820C
	bne	@next				; 820E
	lda	monster_ypos,y			; 8210
	cmp	$17				; 8213
	beq	@foundmonster			; 8215
@next:
	dey					; 8217
	bpl	@checkmonster			; 8218
@foundmonster:
	tya					; 821A
	sta	$6A				; 821B
	cmp	#$00				; 821D  .
	rts					; 821F

combat_fire_missile:
	clc					; 8220
	lda	missile_xpos			; 8221
	adc	$78				; 8224
	sta	$16				; 8226
	clc					; 8228
	lda	missile_ypos			; 8229
	adc	$79				; 822C
	sta	$17				; 822E
	lda	$16				; 8230
	cmp	#$0B				; 8232  K
	bcs	@miss				; 8234
	lda	$17				; 8236
	cmp	#$0B				; 8238  K
	bcs	@miss				; 823A
	jsr	j_gettile_combat		; 823C
	bmi	@hit				; 823F
	cmp	#$03				; 8241  C
	bcc	@hit				; 8243
	cmp	#$48				; 8245  H
	beq	@hit				; 8247
	cmp	#$49				; 8249  I
	beq	@miss				; 824B
	cmp	#$31				; 824D  1
	bcc	@blocked			; 824F
	cmp	#$35				; 8251  5
	bcc	@hit				; 8253
@blocked:
	jsr	j_blocked_tile			; 8255
	bmi	@miss				; 8258
@hit:
	lda	$16				; 825A
	sta	missile_xpos			; 825C
	lda	$17				; 825F
	sta	missile_ypos			; 8261
	lda	#$00				; 8264  .
	rts					; 8266

@miss:
	lda	#$FF				; 8267  .
	rts					; 8269

getsign:
	cmp	#$00				; 826A  .
	beq	L8275				; 826C
	bmi	L8273				; 826E
	lda	#$01				; 8270  A
	rts					; 8272

L8273:
	lda	#$FF				; 8273  .
L8275:
	rts					; 8275

getabs:
	cmp	#$00				; 8276  .
	bmi	L827B				; 8278
	rts					; 827A

L827B:
	eor	#$FF				; 827B  .
	clc					; 827D
	adc	#$01				; 827E  A
	rts					; 8280

L8281:
	eor	#$FF				; 8281  .
	clc					; 8283
	adc	#$01				; 8284  A
	rts					; 8286

combat_getdirection:
	jsr	getdirection			; 8287
	beq	@cancel				; 828A
	ldx	currplayer			; 828C
	dex					; 828E
	lda	cbt_player_xpos,x		; 828F
	sta	$16				; 8292
	lda	cbt_player_ypos,x		; 8294
	sta	$17				; 8297
	lda	#$01				; 8299  A
@cancel:
	rts					; 829B

getdirection:
	jsr	j_waitkey			; 829C
	bne	@gotkey				; 829F
@cancel:
	jsr	printcr				; 82A1
	lda	#$00				; 82A4  .
	rts					; 82A6

@gotkey:
	pha					; 82A7
	lda	#$00				; 82A8  .
	sta	$78				; 82AA
	sta	$79				; 82AC
	pla					; 82AE
	cmp	#$C0				; 82AF  @
	beq	@north				; 82B1
	cmp	#$AF				; 82B3  /
	beq	@south				; 82B5
	cmp	#$BA				; 82B7  :
	beq	@east				; 82B9
	cmp	#$BB				; 82BB  ;
	beq	@west				; 82BD
	cmp	#$A0				; 82BF   
	beq	@cancel				; 82C1
	jsr	j_console_out			; 82C3
	jmp	@cancel				; 82C6

@north:
	jsr	print_north			; 82C9
	lda	#$FF				; 82CC  .
	sta	$79				; 82CE
	jmp	@calcpos			; 82D0

@south:
	jsr	print_south			; 82D3
	lda	#$01				; 82D6  A
	sta	$79				; 82D8
	jmp	@calcpos			; 82DA

@east:
	jsr	print_west			; 82DD
	lda	#$FF				; 82E0  .
	sta	$78				; 82E2
	jmp	@calcpos			; 82E4

@west:
	jsr	print_east			; 82E7
	lda	#$01				; 82EA  A
	sta	$78				; 82EC
@calcpos:
	clc					; 82EE
	lda	player_xpos			; 82EF
	adc	$78				; 82F1
	sta	$7A				; 82F3
	sta	$16				; 82F5
	clc					; 82F7
	lda	player_ypos			; 82F8
	adc	$79				; 82FA
	sta	$7B				; 82FC
	sta	$17				; 82FE
	lda	#$01				; 8300  A
	rts					; 8302

print_north:
	jsr	j_primm				; 8303
	.byte	$CE,$EF,$F2,$F4,$E8,$8D,$00	; 8306  NorthM.

	rts					; 830D

print_south:
	jsr	j_primm				; 830E
	.byte	$D3,$EF,$F5,$F4,$E8,$8D,$00	; 8311  SouthM.

	rts					; 8318

print_east:
	jsr	j_primm				; 8319
	.byte	$C5,$E1,$F3,$F4,$8D,$00		; 831C  EastM.

	rts					; 8322

print_west:
	jsr	j_primm				; 8323
	.byte	$D7,$E5,$F3,$F4,$8D,$00		; 8326  WestM.

	rts					; 832C

find_creature:
	lda	current_location		; 832D
	bne	@not7				; 832F
	ldx	#$07				; 8331  G
	jmp	find_next_target		; 8333

@not7:
	cmp	#$11				; 8336  Q
	bcs	@notfound			; 8338
find_target:
	ldx	#$1F				; 833A  _
find_next_target:
	lda	$7A				; 833C
	cmp	object_xpos,x			; 833E
	bne	@next				; 8341
	lda	$7B				; 8343
	cmp	object_ypos,x			; 8345
	bne	@next				; 8348
	lda	object_tile,x			; 834A
	beq	@next				; 834D
	txa					; 834F
	rts					; 8350

@next:
	dex					; 8351
	bpl	find_next_target		; 8352
@notfound:
	lda	#$FF				; 8354  .
	rts					; 8356

print_object_name:
	ldx	$58				; 8357
	lda	object_tile,x			; 8359
print_creature_name:
	bpl	@npc				; 835C
	sec					; 835E
	sbc	#$80				; 835F  .
	cmp	#$10				; 8361  P
	bcs	@div4				; 8363
	lsr	a				; 8365
@print:
	clc					; 8366
	adc	#$01				; 8367  A
	jsr	j_printstring			; 8369
	lda	#$8D				; 836C  M
	jsr	j_console_out			; 836E
	rts					; 8371

@div4:
	lsr	a				; 8372
	lsr	a				; 8373
	clc					; 8374
	adc	#$04				; 8375  D
	jmp	@print				; 8377

@npc:
	cmp	#$20				; 837A   
	bcc	@phantom			; 837C
	cmp	#$60				; 837E  `
	bcs	@phantom			; 8380
	cmp	#$30				; 8382  0
	bcc	@profession			; 8384
	cmp	#$50				; 8386  P
	bcc	@phantom			; 8388
@profession:
	and	#$1F				; 838A  _
	lsr	a				; 838C
	clc					; 838D
	adc	#$4C				; 838E  L
	jmp	@print				; 8390

@phantom:
	lda	#$13				; 8393  S
	jmp	@print				; 8395

getandprintkey:
	jsr	j_waitkey			; 8398
	pha					; 839B
	beq	L83A1				; 839C
	jsr	j_console_out			; 839E
L83A1:
	lda	#$8D				; 83A1  M
	jsr	j_console_out			; 83A3
	pla					; 83A6
	rts					; 83A7

check_party_alive:
	lda	party_size			; 83A8
	sta	currplayer			; 83AA
@checkalive:
	jsr	check_alive			; 83AC
	beq	@checkawake			; 83AF
	dec	currplayer			; 83B1
	bne	@checkalive			; 83B3
	jmp	player_dead			; 83B5

@checkawake:
	jsr	check_awake			; 83B8
	beq	@aliveandawake			; 83BB
	dec	currplayer			; 83BD
	bne	@checkawake			; 83BF
	lda	#$FF				; 83C1  .
	rts					; 83C3

@aliveandawake:
	lda	#$00				; 83C4  .
	rts					; 83C6

player_dead:
	lda	#$00				; 83C7  .
	jsr	music_ctl			; 83C9
	lda	#$02				; 83CC  B
	jsr	j_request_disk			; 83CE
	lda	#$CC				; 83D1  L
	ldx	#$89				; 83D3  I
	jsr	j_fileio			; 83D5
	jsr	L8800				; 83D8
	lda	#$01				; 83DB  A
	jsr	music_ctl			; 83DD
	jmp	cmd_done			; 83E0

invert_all_player_lines:
	lda	party_size			; 83E3
	sta	currplayer			; 83E5
@next:
	jsr	invert_player_line		; 83E7
	dec	currplayer			; 83EA
	bne	@next				; 83EC
	rts					; 83EE

invert_player_line:
	lda	currplayer			; 83EF
	asl	a				; 83F1
	asl	a				; 83F2
	asl	a				; 83F3
	tax					; 83F4
	lda	bmplineaddr_lo,x		; 83F5
	sta	ptr1				; 83F8
	lda	bmplineaddr_hi,x		; 83FA
	sta	ptr1+1				; 83FD
	lda	ptr1				; 83FF
	clc					; 8401
	adc	#$C0				; 8402  @
	sta	ptr1				; 8404
	lda	ptr1+1				; 8406
	adc	#$00				; 8408  .
	sta	ptr1+1				; 840A
	ldy	#$00				; 840C  .
@invert:
	lda	(ptr1),y			; 840E
	eor	#$FF				; 8410  .
	sta	(ptr1),y			; 8412
	iny					; 8414
	cpy	#$78				; 8415  x
	bne	@invert				; 8417
	rts					; 8419

hextobcd:
	cmp	#$00				; 841A  .
	beq	L8430				; 841C
	cmp	#$63				; 841E  c
	bcs	L842E				; 8420
	sed					; 8422
	tax					; 8423
	lda	#$00				; 8424  .
L8426:
	clc					; 8426
	adc	#$01				; 8427  A
	dex					; 8429
	bne	L8426				; 842A
	beq	L8430				; 842C
L842E:
	lda	#$99				; 842E  Y
L8430:
	cld					; 8430
	rts					; 8431

bcdtohex:
	cmp	#$00				; 8432  .
	beq	L8441				; 8434
	ldx	#$00				; 8436  .
	sed					; 8438
L8439:
	inx					; 8439
	sec					; 843A
	sbc	#$01				; 843B  A
	bne	L8439				; 843D
	txa					; 843F
	cld					; 8440
L8441:
	rts					; 8441

stat_inc:
	sed					; 8442
	clc					; 8443
	lda	game_stats,y			; 8444
	adc	#$01				; 8447  A
	bcs	@done				; 8449
	sta	game_stats,y			; 844B
@done:
	cld					; 844E
	rts					; 844F

stat_dec:
	sed					; 8450
	sec					; 8451
	lda	game_stats,y			; 8452
	sbc	#$01				; 8455  A
	bcc	@done				; 8457
	sta	game_stats,y			; 8459
@done:
	cld					; 845C
	rts					; 845D

virtue_inc:
	sta	$59				; 845E
	sed					; 8460
	clc					; 8461
	lda	game_stats,y			; 8462
	beq	@done				; 8465
	adc	$59				; 8467
	bcc	@done				; 8469
	lda	#$99				; 846B  Y
@done:
	sta	game_stats,y			; 846D
	cld					; 8470
	rts					; 8471

virtue_dec:
	sta	zptmp1				; 8472
	sty	$59				; 8474
	lda	game_stats,y			; 8476
	beq	@lost_eight			; 8479
@dec:
	sed					; 847B
	sec					; 847C
	sbc	zptmp1				; 847D
	beq	@zero				; 847F
	bcs	@nounderflow			; 8481
@zero:
	lda	#$01				; 8483  A
@nounderflow:
	sta	game_stats,y			; 8485
	cld					; 8488
	rts					; 8489

@lost_eight:
	jsr	j_primm				; 848A
	.byte	$8D,$D4,$C8,$CF,$D5,$A0,$C8,$C1	; 848D  MTHOU HA
	.byte	$D3,$D4,$A0,$CC,$CF,$D3,$D4,$8D	; 8495  ST LOSTM
	.byte	$C1,$CE,$A0,$C5,$C9,$C7,$C8,$D4	; 849D  AN EIGHT
	.byte	$C8,$A1,$8D,$00			; 84A5  H!M.

	ldy	$59				; 84A9
	lda	#$99				; 84AB  Y
	jmp	@dec				; 84AD

stat_sub_hp:
	sta	zptmp1				; 84B0
	jsr	j_get_stats_ptr			; 84B2
	ldy	#$19				; 84B5  Y
	sed					; 84B7
	sec					; 84B8
	lda	(ptr1),y			; 84B9
	sbc	zptmp1				; 84BB
	sta	(ptr1),y			; 84BD
	dey					; 84BF
	lda	(ptr1),y			; 84C0
	sbc	#$00				; 84C2  .
	sta	(ptr1),y			; 84C4
	cld					; 84C6
	bcc	@dead				; 84C7
	lda	#$01				; 84C9  A
	rts					; 84CB

@dead:
	lda	#$00				; 84CC  .
	sta	(ptr1),y			; 84CE
	iny					; 84D0
	sta	(ptr1),y			; 84D1
	jsr	j_get_stats_ptr			; 84D3
	ldy	#$12				; 84D6  R
	lda	#$C4				; 84D8  D
	sta	(ptr1),y			; 84DA
	lda	game_mode			; 84DC
	bpl	@notcombat			; 84DE
	lda	#$38				; 84E0  8
	ldx	currplayer			; 84E2
	sta	$AD9F,x				; 84E4
@notcombat:
	lda	#$00				; 84E7  .
	rts					; 84E9

stat_add_hp:
	sta	zptmp1				; 84EA
	jsr	j_get_stats_ptr			; 84EC
	ldy	#$19				; 84EF  Y
	sed					; 84F1
	clc					; 84F2
	lda	(ptr1),y			; 84F3
	adc	zptmp1				; 84F5
	sta	(ptr1),y			; 84F7
	dey					; 84F9
	lda	(ptr1),y			; 84FA
	adc	#$00				; 84FC  .
	sta	(ptr1),y			; 84FE
	cld					; 8500
	ldy	#$18				; 8501  X
	lda	(ptr1),y			; 8503
	ldy	#$1A				; 8505  Z
	cmp	(ptr1),y			; 8507
	bcc	@done				; 8509
	ldy	#$19				; 850B  Y
	lda	(ptr1),y			; 850D
	ldy	#$1B				; 850F  [
	cmp	(ptr1),y			; 8511
	bcc	@done				; 8513
	ldy	#$1A				; 8515  Z
	lda	(ptr1),y			; 8517
	ldy	#$18				; 8519  X
	sta	(ptr1),y			; 851B
	ldy	#$1B				; 851D  [
	lda	(ptr1),y			; 851F
	ldy	#$19				; 8521  Y
	sta	(ptr1),y			; 8523
@done:
	rts					; 8525

stat_add_gold:
	sta	zptmp1				; 8526
	ldy	#$14				; 8528  T
	sed					; 852A
	clc					; 852B
	lda	game_stats,y			; 852C
	adc	zptmp1				; 852F
	sta	game_stats,y			; 8531
	dey					; 8534
	lda	game_stats,y			; 8535
	adc	#$00				; 8538  .
	sta	game_stats,y			; 853A
	cld					; 853D
	bcc	@nomsb				; 853E
	lda	#$99				; 8540  Y
	sta	game_stats,y			; 8542
	iny					; 8545
	sta	game_stats,y			; 8546
@nomsb:
	rts					; 8549

stat_add_exp:
	sta	$58				; 854A
	jsr	j_get_stats_ptr			; 854C
	ldy	#$1D				; 854F  ]
	sed					; 8551
	clc					; 8552
	lda	(ptr1),y			; 8553
	adc	$58				; 8555
	sta	(ptr1),y			; 8557
	dey					; 8559
	lda	(ptr1),y			; 855A
	adc	#$00				; 855C  .
	sta	(ptr1),y			; 855E
	cld					; 8560
	bcc	@done				; 8561
	lda	#$99				; 8563  Y
	sta	(ptr1),y			; 8565
	iny					; 8567
	sta	(ptr1),y			; 8568
@done:
	rts					; 856A

hurt_player_random_val:
	jsr	flash_player_line		; 856B
	lda	#$1E				; 856E  ^
	jsr	randmax				; 8570
	jsr	hextobcd			; 8573
	jsr	stat_sub_hp			; 8576
	rts					; 8579

hurt_all_players:
	jsr	invert_all_player_lines		; 857A
	lda	#$06				; 857D  F
	jsr	j_playsfx			; 857F
	jsr	shake_screen			; 8582
	lda	game_mode			; 8585
	bmi	L85BC				; 8587
	lda	player_transport		; 8589
	cmp	#$14				; 858B  T
	bcs	L85BC				; 858D
	sed					; 858F
	sec					; 8590
	lda	ship_hull			; 8591
	sbc	#$0A				; 8593  J
	cld					; 8595
	bcs	L85BA				; 8596
	lda	#$00				; 8598  .
	sta	ship_hull			; 859A
	jsr	invert_all_player_lines		; 859C
	jsr	j_update_status			; 859F
	jsr	j_primm				; 85A2
	.byte	$8D,$D4,$C8,$D9,$A0,$D3,$C8,$C9	; 85A5  MTHY SHI
	.byte	$D0,$A0,$D3,$C9,$CE,$CB,$D3,$A1	; 85AD  P SINKS!
	.byte	$8D,$00				; 85B5  M.

	jmp	player_dead			; 85B7

L85BA:
	sta	ship_hull			; 85BA
L85BC:
	lda	party_size			; 85BC
	sta	currplayer			; 85BE
L85C0:
	jsr	j_rand				; 85C0
	bmi	L85E0				; 85C3
	jsr	check_alive			; 85C5
	bne	L85E0				; 85C8
	lda	game_mode			; 85CA
	bpl	L85D5				; 85CC
	ldx	currplayer			; 85CE
	lda	$AD9F,x				; 85D0
	beq	L85E0				; 85D3
L85D5:
	lda	#$19				; 85D5  Y
	jsr	randmax				; 85D7
	jsr	hextobcd			; 85DA
	jsr	stat_sub_hp			; 85DD
L85E0:
	dec	currplayer			; 85E0
	bne	L85C0				; 85E2
	jsr	invert_all_player_lines		; 85E4
	jsr	j_update_status			; 85E7
	rts					; 85EA

flash_player_line:
	jsr	invert_player_line		; 85EB
	lda	#$07				; 85EE  G
	jsr	j_playsfx			; 85F0
	jsr	invert_player_line		; 85F3
	rts					; 85F6

printcr:
	lda	#$8D				; 85F7  M
	jsr	j_console_out			; 85F9
	rts					; 85FC

shake_screen:
	jsr	L8645				; 85FD
	jsr	L8616				; 8600
	jsr	L8645				; 8603
	jsr	L8616				; 8606
	jsr	L8645				; 8609
	jsr	L8616				; 860C
	jsr	L8645				; 860F
	jsr	L8616				; 8612
	rts					; 8615

L8616:
	ldx	#$AE				; 8616  .
L8618:
	lda	bmplineaddr_lo+9,x		; 8618
	sta	ptr1				; 861B
	lda	bmplineaddr_hi+9,x		; 861D
	sta	ptr1+1				; 8620
	lda	bmplineaddr_lo+7,x		; 8622
	sta	ptr2				; 8625
	lda	bmplineaddr_hi+7,x		; 8627
	sta	ptr2+1				; 862A
	ldy	#$B0				; 862C  0
L862E:
	lda	(ptr2),y			; 862E
	sta	(ptr1),y			; 8630
	tya					; 8632
	sec					; 8633
	sbc	#$08				; 8634  H
	tay					; 8636
	bne	L862E				; 8637
	jsr	j_rand				; 8639
	bmi	L8641				; 863C
	jsr	j_togglesnd			; 863E
L8641:
	dex					; 8641
	bne	L8618				; 8642
	rts					; 8644

L8645:
	ldx	#$00				; 8645  .
L8647:
	lda	bmplineaddr_lo+8,x		; 8647
	sta	ptr1				; 864A
	lda	bmplineaddr_hi+8,x		; 864C
	sta	ptr1+1				; 864F
	lda	bmplineaddr_lo+10,x		; 8651
	sta	ptr2				; 8654
	lda	bmplineaddr_hi+10,x		; 8656
	sta	ptr2+1				; 8659
	ldy	#$B0				; 865B  0
L865D:
	lda	(ptr2),y			; 865D
	sta	(ptr1),y			; 865F
	tya					; 8661
	sec					; 8662
	sbc	#$08				; 8663  H
	tay					; 8665
	bne	L865D				; 8666
	jsr	j_rand				; 8668
	bmi	L8670				; 866B
	jsr	j_togglesnd			; 866D
L8670:
	inx					; 8670
	cpx	#$AE				; 8671  .
	bcc	L8647				; 8673
	rts					; 8675

check_moongate:
	cmp	#$43				; 8676  C
	beq	@gateactive			; 8678
	rts					; 867A

@gateactive:
	lda	moon_phase_trammel		; 867B
	cmp	#$04				; 867D  D
	bne	@notfull			; 867F
	lda	moon_phase_felucca		; 8681
	cmp	#$04				; 8683  D
	bne	@notfull			; 8685
	jsr	j_idle				; 8687
	jsr	j_invertview			; 868A
	lda	#$09				; 868D  I
	ldx	#$A0				; 868F   
	jsr	j_playsfx			; 8691
	lda	#$1F				; 8694  _
	sta	current_location		; 8696
	jmp	L5183				; 8698

@notfull:
	jsr	j_idle				; 869B
	ldx	moon_phase_felucca		; 869E
	lda	moongate_xpos,x			; 86A0
	sta	player_xpos			; 86A3
	lda	moongate_ypos,x			; 86A5
	sta	player_ypos			; 86A8
	jsr	j_invertview			; 86AA
	lda	#$09				; 86AD  I
	ldx	#$A0				; 86AF   
	jsr	j_playsfx			; 86B1
	jsr	j_invertview			; 86B4
	jsr	j_player_teleport		; 86B7
	jsr	j_idle				; 86BA
	jsr	j_invertview			; 86BD
	lda	#$09				; 86C0  I
	ldx	#$A0				; 86C2   
	jsr	j_playsfx			; 86C4
	jsr	j_invertview			; 86C7
	jmp	cmd_done			; 86CA

check_evil:
	cmp	#$00				; 86CD  .
	bpl	@not_evil			; 86CF
	cmp	#$8A				; 86D1  J
	beq	@not_evil			; 86D3
	cmp	#$90				; 86D5  P
	beq	@not_evil			; 86D7
	cmp	#$94				; 86D9  T
	beq	@not_evil			; 86DB
	cmp	#$98				; 86DD  X
	beq	@not_evil			; 86DF
	cmp	#$B4				; 86E1  4
	beq	@not_evil			; 86E3
	cmp	#$CC				; 86E5  L
	beq	@not_evil			; 86E7
	lda	#$FF				; 86E9  .
	rts					; 86EB

@not_evil:
	lda	#$00				; 86EC  .
	rts					; 86EE

	php					; 86EF
	ldy	$58				; 86F0
	lda	mixtures,y			; 86F2
	jsr	j_printbcd			; 86F5
	inc	$59				; 86F8
	inc	$58				; 86FA
	lda	$58				; 86FC
	cmp	#$1A				; 86FE  Z
	.byte	$90,$BF				; 8700  P?

	jsr	restore_console_pos		; 8702
	rts					; 8705

	lda	console_xpos			; 8706
	sta	L621C				; 8708
	lda	console_ypos			; 870B
	sta	L621D				; 870D
	rts					; 8710

	lda	L621C				; 8711
	sta	console_xpos			; 8714
	lda	L621D				; 8716
	sta	console_ypos			; 8719
	rts					; 871B

	brk					; 871C
	brk					; 871D
	jsr	check_party_alive		; 871E
	lda	game_mode			; 8721
	bpl	L8728				; 8723
	jmp	L7133				; 8725

L8728:
	lda	ship_hull			; 8728
	cmp	#$50				; 872A  P
	bcs	L873E				; 872C
	jsr	j_rand				; 872E
	and	#$03				; 8731  C
	bne	L873E				; 8733
	lda	ship_hull			; 8735
	sed					; 8737
	clc					; 8738
	adc	#$01				; 8739  A
	cld					; 873B
	sta	ship_hull			; 873C
L873E:
	lda	party_size			; 873E
	sta	currplayer			; 8740
L8742:
	jsr	j_get_stats_ptr			; 8742
	ldy	#$12				; 8745  R
	lda	(ptr1),y			; 8747
	cmp	#$D3				; 8749  S
	bne	L875B				; 874B
	jsr	j_rand				; 874D
	and	#$07				; 8750  G
	bne	L876F				; 8752
	lda	#$C7				; 8754  G
	sta	(ptr1),y			; 8756
	jmp	@next				; 8758

L875B:
	cmp	#$D0				; 875B  P
	bne	L876F				; 875D
	lda	#$02				; 875F  B
	jsr	stat_sub_hp			; 8761
	jsr	invert_player_line		; 8764
	lda	#$06				; 8767  F
	jsr	j_playsfx			; 8769
	jsr	invert_player_line		; 876C
L876F:
	dec	currplayer			; 876F
	bne	L8742				; 8771
	lda	party_size			; 8773
	jsr	stat_eat_food			; 8775
	bcs	L877D				; 8778
	jsr	starve				; 877A
L877D:
	jsr	party_add_mp			; 877D
	lda	movement_mode			; 8780
	bmi	L8790				; 8782
	jsr	check_whirlpool_storm		; 8784
	jsr	spawn_random_monster		; 8787
	jsr	move_creatures			; 878A
	jsr	check_whirlpool_storm		; 878D
L8790:
	lda	game_mode			; 8790
	cmp	#$03				; 8792  C
	bne	L87A7				; 8794
	jsr	j_print_direction		; 8796
	jsr	dungeon_check_tile		; 8799
	lda	tile_under_player		; 879C
	and	#$F0				; 879E  p
	cmp	#$D0				; 87A0  P
	bne	L87A7				; 87A2
	jmp	dungeon_room			; 87A4

L87A7:
	lda	light_duration			; 87A7
	beq	L87AD				; 87A9
	dec	light_duration			; 87AB
L87AD:
	jmp	update_counters			; 87AD

	lda	game_mode			; 87B0
	cmp	#$01				; 87B2  A
	bne	L87EA				; 87B4
	lda	tile_under_player		; 87B6
	cmp	#$17				; 87B8  W
	bne	L87EA				; 87BA
	jsr	j_rand				; 87BC
	and	#$07				; 87BF  G
	bne	L87EA				; 87C1
	jsr	j_primm				; 87C3
	.byte	$8D,$C2,$D2,$C9,$C4,$C7,$C5,$A0	; 87C6  MBRIDGE 
	.byte	$D4,$D2,$CF,$CC,$CC,$D3,$A1,$8D	; 87CE  TROLLS!M
	.byte	$00				; 87D6  .

	lda	#$A4				; 87D7  $
	sta	attacking_monster_type		; 87D9
	lda	player_xpos			; 87DB
	sta	attacking_monster_xpos		; 87DD
	lda	player_ypos			; 87DF
	sta	attacking_monster_ypos		; 87E1
	lda	#$17				; 87E3  W
	sta	attacking_monster_terrain	; 87E5
	jmp	generate_combat			; 87E7

L87EA:
	lda	movement_mode			; 87EA
	bpl	L87EF				; 87EC
	rts					; 87EE

L87EF:
	lda	game_mode			; 87EF
	bmi	L87FC				; 87F1
	cmp	#$03				; 87F3  C
	beq	L8859				; 87F5
	lda	tile_under_player		; 87F7
	jmp	L63B9				; 87F9

L87FC:
	ldx	currplayer			; 87FC
	.byte	$BD				; 87FE  =
	.byte	$9F				; 87FF  _
Valid HTML 4.01 Strict5b.html; generated on Thu Sep 21 17:08:54 2006 by ca65html
uz@cc65.org