5b.s
.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
j_startgate:
jmp startgame
j_camp_ambushed:
jmp camp_ambushed
jmp dungeon_combat_start
startgame:
lda #$00
jsr music_ctl
jsr j_drawinterface
lda #$0D
sta console_ypos
lda #$18
sta console_xpos
lda #$00
sta game_mode
lda #$25
sta magic_aura
lda #$02
jsr j_request_disk
lda party_size
beq @loadgame
jmp @gamestarted
@loadgame:
lda #$CC
ldx #$1A
jsr j_fileio
lda party_size
bne @gotgame
jsr j_primm
.byte $8D,$CE,$CF,$A0,$C1,$C3,$D4,$C9
.byte $D6,$C5,$A0,$C7,$C1,$CD,$C5,$A1
.byte $8D,$00
@nogame:
jmp @nogame
@gotgame:
lda #$CC
ldx #$7F
jsr j_fileio
ldx #$80
jsr j_fileio
@gamestarted:
lda #$00
sta $1D
sta movement_mode
sta current_location
sta horse_mode
lda #$01
sta game_mode
sta direction
jsr j_update_status
jsr j_player_teleport
lda #$FF
sta music_volume
lda #$CF
jsr music_ctl
game_main:
jsr j_idle
jsr check_triggers
jsr check_party_alive
bpl @prompt
jmp cmd_sleep
@prompt:
jsr j_primm
.byte $8D,$1E,$00
jsr j_waitkey
cmp #$00
bne @gotkey
jmp cmd_pass
@gotkey:
cmp #$A0
bne @north
jmp cmd_pass
@north:
cmp #$C0
bne @south
jmp cmd_north
@south:
cmp #$AF
bne @east
jmp cmd_south
@east:
cmp #$BA
bne @west
jmp cmd_west
@west:
cmp #$BB
bne @home
jmp cmd_east
@home:
cmp #$93
bne @atoz
jsr printcr
lda #$00
sta $6A
@printvirtue:
ldx $6A
lda game_stats,x
jsr j_printbcd
inc $6A
lda $6A
cmp #$08
bcc @printvirtue
jsr printcr
jmp game_main
@atoz:
cmp #$C1
bcc cmd_unknown
cmp #$DB
bcs cmd_unknown
sec
sbc #$C1
asl a
tay
lda cmd_jump_table,y
sta ptr1
lda cmd_jump_table+1,y
sta ptr1+1
jmp (ptr1)
cmd_sleep:
jsr j_primm
.byte $8D,$1E,$DA,$FA,$FA,$FA,$FA,$8D
.byte $00
jmp cmd_done
cmd_pass:
jsr j_primm
.byte $D0,$E1,$F3,$F3,$8D,$00
jmp cmd_done
cmd_unknown:
jsr j_primm
.byte $D7,$C8,$C1,$D4,$BF,$8D,$00
cmd_error:
lda #$02
jsr j_playsfx
jmp cmd_done
print_not_a_player:
jsr j_primm
.byte $CE,$CF,$D4,$A0,$C1,$A0,$D0,$CC
.byte $C1,$D9,$C5,$D2,$A1,$8D,$00
jmp cmd_done
print_only_on_foot:
jsr j_primm
.byte $CF,$CE,$CC,$D9,$A0,$CF,$CE,$A0
.byte $C6,$CF,$CF,$D4,$A1,$8D,$00
jmp cmd_error
print_nothing_there:
jsr j_primm
.byte $CE,$CF,$D4,$C8,$C9,$CE,$C7,$A0
.byte $D4,$C8,$C5,$D2,$C5,$A1,$8D,$00
jmp cmd_done
print_slow_progress:
jsr j_primm
.byte $D3,$CC,$CF,$D7,$A0,$D0,$D2,$CF
.byte $C7,$D2,$C5,$D3,$D3,$A1,$8D,$00
rts
print_not_here:
jsr j_primm
.byte $CE,$CF,$D4,$A0,$C8,$C5,$D2,$C5
.byte $A1,$8D,$00
jmp cmd_done
print_cant:
jsr j_primm
.byte $C3,$C1,$CE,$A7,$D4,$A1,$8D,$00
jmp cmd_done
print_aborted:
jsr j_primm
.byte $C1,$C2,$CF,$D2,$D4,$C5,$C4,$A1
.byte $8D,$00
jmp cmd_done
print_done:
jsr j_update_status
jsr j_primm
.byte $C4,$CF,$CE,$C5,$AE,$8D,$00
jmp cmd_done
print_you_have_none:
jsr j_primm
.byte $D9,$CF,$D5,$A0,$C8,$C1,$D6,$C5
.byte $A0,$CE,$CF,$CE,$C5,$A1,$8D,$00
jmp cmd_done
print_disabled:
jsr j_primm
.byte $C4,$C9,$D3,$C1,$C2,$CC,$C5,$C4
.byte $A1,$8D,$00
jmp cmd_done
move_blocked:
jsr j_primm
.byte $C2,$CC,$CF,$C3,$CB,$C5,$C4,$A1
.byte $8D,$00
lda #$01
jsr j_playsfx
lda #$00
sta key_buf_len
jmp cmd_done
print_drift_only:
jsr j_primm
.byte $C4,$D2,$C9,$C6,$D4,$A0,$CF,$CE
.byte $CC,$D9,$A1,$8D,$00
jmp cmd_done
cmd_jump_table:
.addr cmd_attack
.addr cmd_board
.addr cmd_cast
.addr cmd_descend
.addr cmd_enter
.addr cmd_fire
.addr cmd_get_chest
.addr cmd_hole_up_and_camp
.addr cmd_ignite
.addr cmd_jimmy_lock
.addr cmd_klimb
.addr cmd_locate
.addr cmd_mix_reagents
.addr cmd_new_order
.addr cmd_open
.addr cmd_peer_at_gem
.addr cmd_quit_and_save
.addr cmd_ready_weapon
.addr cmd_search
.addr cmd_talk
.addr cmd_use
.addr cmd_volume
.addr cmd_wear_armor
.addr cmd_xit
.addr cmd_yell
.addr cmd_ztats
cmd_north:
lda game_mode
cmp #$03
bne @balloon
jmp cmd_forward
@balloon:
lda player_transport
cmp #$18
bne @shipnorth
jmp print_drift_only
@shipnorth:
cmp #$11
bne @shipother
jmp @checkshipmove
@shipother:
cmp #$10
beq @turnship
cmp #$12
beq @turnship
cmp #$13
beq @turnship
lda #$00
jsr j_playsfx
jsr print_north
lda horse_mode
beq @nohorse
jsr @checkblock
jsr j_idle
@nohorse:
jsr @checkblock
jmp cmd_done
@turnship:
lda #$11
sta player_transport
jsr print_turn
jsr print_north
jmp cmd_done
@checkshipmove:
jsr print_sail
jsr print_north
lda tile_north
jsr check_sailable
bpl @shipnotblocked
jmp move_blocked
@shipnotblocked:
lda #$01
jsr check_wind_direction
beq @moveship
jsr print_slow_progress
jmp cmd_done
@moveship:
jsr j_move_north
jmp cmd_done
@checkblock:
lda tile_under_player
cmp #$0E
beq @blocked
lda tile_north
cmp #$0E
beq @notblocked
jsr j_blocked_tile
bpl @notblocked
@blocked:
pla
pla
jmp move_blocked
@notblocked:
lda tile_north
jsr check_slow_progress
beq @notslow
jsr print_slow_progress
jmp @done
@notslow:
lda #$00
jsr j_playsfx
lda game_mode
cmp #$01
bne @checkexit
jsr j_move_north
lda tile_north
jmp check_moongate
@checkexit:
dec player_ypos
lda player_ypos
bpl @done
pla
pla
jmp exit_location
@done:
rts
cmd_forward:
jsr j_primm
.byte $C1,$E4,$F6,$E1,$EE,$E3,$E5,$8D
.byte $00
lda tile_north
jsr dng_check_forward_block
bpl @notblocked
jmp move_blocked
@notblocked:
ldx dng_direction
dng_move:
clc
lda player_xpos
adc dng_move_deltax,x
and #$07
sta player_xpos
clc
lda player_ypos
adc dng_move_deltay,x
and #$07
sta player_ypos
jmp cmd_done
dng_move_deltax:
.byte $00,$01,$00,$FF
dng_move_deltay:
.byte $FF,$00,$01,$00
cmd_south:
lda game_mode
cmp #$03
bne @balloon
jsr j_primm
.byte $D2,$E5,$F4,$F2,$E5,$E1,$F4,$8D
.byte $00
lda tile_west
jsr dng_check_retreat_block
bpl @retreat
jmp move_blocked
@retreat:
lda dng_direction
eor #$02
tax
jmp dng_move
@balloon:
lda player_transport
cmp #$18
bne @shipsouth
jmp print_drift_only
@shipsouth:
cmp #$13
bne @shipother
jmp @checkshipmove
@shipother:
cmp #$12
beq @turnship
cmp #$10
beq @turnship
cmp #$11
beq @turnship
lda #$00
jsr j_playsfx
jsr print_south
lda horse_mode
beq @nohorse
jsr @checkblock
jsr j_idle
@nohorse:
jsr @checkblock
lda player_xpos
cmp #$E5
bcc @notisleofabyss
cmp #$EA
bcs @notisleofabyss
lda player_ypos
cmp #$D4
bcc @notisleofabyss
cmp #$D9
bcs @notisleofabyss
jmp generate_daemons
@notisleofabyss:
jmp cmd_done
@turnship:
lda #$13
sta player_transport
jsr print_turn
jsr print_south
jmp cmd_done
@checkshipmove:
jsr print_sail
jsr print_south
lda tile_south
jsr check_sailable
bpl @shipnotblocked
jmp move_blocked
@shipnotblocked:
lda #$03
jsr check_wind_direction
beq @moveship
jsr print_slow_progress
jmp cmd_done
@moveship:
jsr j_move_south
jmp cmd_done
@checkblock:
lda tile_south
jsr j_blocked_tile
bpl @notblocked
pla
pla
jmp move_blocked
@notblocked:
lda tile_south
jsr check_slow_progress
beq @notslow
jsr print_slow_progress
jmp @done
@notslow:
lda #$00
jsr j_playsfx
lda game_mode
cmp #$01
bne @checkexit
jsr j_move_south
lda tile_south
jmp check_moongate
@checkexit:
inc player_ypos
lda player_ypos
cmp #$20
bcc @done
pla
pla
jmp exit_location
@done:
rts
cmd_west:
lda game_mode
cmp #$03
bne @balloon
jsr print_turn
jsr j_primm
.byte $EC,$E5,$E6,$F4,$8D,$00
sec
lda dng_direction
sbc #$01
and #$03
sta dng_direction
jsr L8C00
jsr j_print_direction
jmp game_main
@balloon:
lda player_transport
cmp #$18
bne @shipwest
jmp print_drift_only
@shipwest:
cmp #$10
bne @shipother
jmp @checkshipmove
@shipother:
cmp #$11
beq @turnship
cmp #$13
beq @turnship
cmp #$12
beq @turnship
cmp #$15
bne @notturnhorse
lda #$14
sta player_transport
@notturnhorse:
lda #$00
jsr j_playsfx
jsr print_west
lda horse_mode
beq @nohorse
jsr @checkblock
jsr j_idle
@nohorse:
jsr @checkblock
jmp cmd_done
@turnship:
lda #$10
sta player_transport
jsr print_turn
jsr print_west
jmp cmd_done
@checkshipmove:
jsr print_sail
jsr print_west
lda tile_west
jsr check_sailable
bpl @shipnotblocked
jmp move_blocked
@shipnotblocked:
lda #$00
jsr check_wind_direction
beq @moveship
jsr print_slow_progress
jmp cmd_done
@moveship:
jsr j_move_west
jmp cmd_done
@checkblock:
lda tile_west
jsr j_blocked_tile
bpl @notblocked
pla
pla
jmp move_blocked
@notblocked:
lda tile_west
jsr check_slow_progress
beq @notslow
jsr print_slow_progress
jmp @done
@notslow:
lda #$00
jsr j_playsfx
lda game_mode
cmp #$01
bne @checkexit
jsr j_move_west
lda tile_west
jmp check_moongate
@checkexit:
dec player_xpos
lda player_xpos
bpl @done
pla
pla
jmp exit_location
@done:
rts
cmd_east:
lda game_mode
cmp #$03
bne @balloon
jsr print_turn
jsr j_primm
.byte $F2,$E9,$E7,$E8,$F4,$8D,$00
clc
lda dng_direction
adc #$01
and #$03
sta dng_direction
jsr L8C00
jsr j_print_direction
jmp game_main
@balloon:
lda player_transport
cmp #$18
bne @shipeast
jmp print_drift_only
@shipeast:
cmp #$12
bne @shipother
jmp @checkshipmove
@shipother:
cmp #$11
beq @turnship
cmp #$13
beq @turnship
cmp #$10
beq @turnship
cmp #$14
bne @notturnhorse
lda #$15
sta player_transport
@notturnhorse:
lda #$00
jsr j_playsfx
jsr print_east
lda horse_mode
beq @nohorse
jsr @checkblock
jsr j_idle
@nohorse:
jsr @checkblock
jmp cmd_done
@turnship:
jsr print_turn
jsr print_east
lda #$12
sta player_transport
jmp cmd_done
@checkshipmove:
jsr print_sail
jsr print_east
lda tile_east
jsr check_sailable
bpl @shipnotblocked
jmp move_blocked
@shipnotblocked:
lda #$02
jsr check_wind_direction
beq @moveship
jsr print_slow_progress
jmp cmd_done
@moveship:
jsr j_move_east
lda player_xpos
cmp #$DD
bne @notmouthofabyss
lda player_ypos
cmp #$E0
bne @notmouthofabyss
jmp generate_pirates
@notmouthofabyss:
jmp cmd_done
@checkblock:
lda tile_east
jsr j_blocked_tile
bpl @notblocked
pla
pla
jmp move_blocked
@notblocked:
lda tile_east
jsr check_slow_progress
beq @notslow
jsr print_slow_progress
jmp @done
@notslow:
lda #$00
jsr j_playsfx
lda game_mode
cmp #$01
bne @checkexit
jsr j_move_east
lda tile_east
jmp check_moongate
@checkexit:
inc player_xpos
lda player_xpos
cmp #$20
bcc @done
pla
pla
jmp exit_location
@done:
rts
print_turn:
jsr j_primm
.byte $D4,$F5,$F2,$EE,$A0,$00
rts
print_sail:
jsr j_primm
.byte $D3,$E1,$E9,$EC,$A0,$00
rts
generate_pirates:
ldy #$07
@next:
lda pirate_xpos,y
sta object_xpos,y
lda pirate_ypos,y
sta object_ypos,y
lda #$80
sta object_tile,y
lda pirate_tile,y
sta map_status,y
dey
bpl @next
jmp cmd_done
pirate_xpos:
.byte $E0,$E0,$E2,$E3,$E4,$E5,$E5,$E4
pirate_ypos:
.byte $DC,$E4,$DC,$E4,$E3,$E1,$DF,$DE
pirate_tile:
.byte $82,$82,$82,$82,$83,$83,$81,$81
generate_daemons:
lda magic_aura
cmp #$5F
beq @done
ldy #$07
@next:
lda #$F0
sta object_tile,y
sta map_status,y
lda #$E7
sta object_xpos,y
lda player_ypos
clc
adc #$01
sta object_ypos,y
dey
bpl @next
@done:
jmp cmd_done
exit_location:
lda #$00
jsr music_ctl
jsr j_primm
.byte $CC,$C5,$C1,$D6,$C9,$CE,$C7,$AE
.byte $AE,$AE,$8D,$00
jsr j_clearkbd
lda #$00
sta game_mode
lda #$02
jsr j_request_disk
lda #$CC
ldx #$7E
jsr j_fileio
lda $18
sta player_xpos
lda $19
sta player_ypos
jsr j_player_teleport
lda #$01
sta game_mode
lda #$00
sta current_location
lda player_xpos
cmp #$EF
bne @nothythloth
lda player_ypos
cmp #$F0
bne @nothythloth
lda #$18
sta $AC7F
sta $AC1F
lda #$E9
sta $AC3F
lda #$F2
sta $AC5F
@nothythloth:
jsr j_update_britannia
lda #$CF
jsr music_ctl
lda #$00
sta key_buf_len
jmp cmd_done
check_slow_progress:
cmp #$03
beq slow_one_in_four
cmp #$05
beq slow_one_in_eight
cmp #$06
beq slow_one_in_four
cmp #$07
beq slow_one_in_two
cmp #$46
beq slow_one_in_two
notslow:
lda #$00
rts
slow:
lda #$FF
rts
slow_one_in_eight:
jsr j_rand
and #$07
beq slow
bne notslow
slow_one_in_four:
jsr j_rand
and #$03
beq slow
bne notslow
slow_one_in_two:
jsr j_rand
and #$01
beq notslow
bne slow
check_sailable:
cmp #$02
bcc @sailable
cmp #$8C
bcc @blocked
cmp #$90
bcs @blocked
@sailable:
lda #$00
rts
@blocked:
lda #$FF
rts
cmd_attack:
jsr j_primm
.byte $C1,$F4,$F4,$E1,$E3,$EB,$AD,$00
lda game_mode
cmp #$03
bne @notdungeon
jmp cmd_unknown
@notdungeon:
jsr getdirection
bne @gotdir
jmp cmd_pass
@gotdir:
jsr find_creature
bpl @gotcreature
@nothinghere:
jmp print_nothing_there
@gotcreature:
stx $58
lda object_tile,x
cmp #$8C
beq @nothinghere
cmp #$8E
beq @nothinghere
lda game_mode
cmp #$02
bne @nottowne
ldx #$1F
@townecheck:
lda object_tile,x
cmp #$50
beq @invincible
cmp #$5E
bne @townenext
@invincible:
lda #$FF
sta $ACC0,x
lda #$00
sta $ACE0,x
@townenext:
dex
bpl @townecheck
@nottowne:
lda game_mode
cmp #$02
beq @losekarma
ldx $58
lda object_tile,x
jsr check_evil
bmi prepare_combat
@losekarma:
ldy #$01
lda #$05
jsr virtue_dec
ldy #$03
lda #$03
jsr virtue_dec
ldy #$05
lda #$03
jsr virtue_dec
prepare_combat:
ldx $58
lda object_tile,x
sta attacking_monster_type
lda object_xpos,x
sta attacking_monster_xpos
sta $7A
lda object_ypos,x
sta attacking_monster_ypos
sta $7B
lda game_mode
cmp #$01
bne @notbritannia
jsr j_gettile_bounds
sta attacking_monster_terrain
jmp @deletecreature
@notbritannia:
jsr j_gettile_town
sta attacking_monster_terrain
@deletecreature:
lda #$00
ldx $58
sta object_tile,x
sta map_status,x
sta $ACC0,x
jmp generate_combat
cmd_board:
lda player_transport
cmp #$1F
beq @onfoot
jsr j_primm
.byte $C2,$EF,$E1,$F2,$E4,$A0,$BC,$AD
.byte $00
jmp print_cant
@onfoot:
lda tile_under_player
cmp #$14
beq board_horse
cmp #$15
beq board_horse
jsr j_primm
.byte $C2,$EF,$E1,$F2,$E4,$A0,$00
lda tile_under_player
cmp #$10
beq @ship
cmp #$11
beq @ship
cmp #$12
beq @ship
cmp #$13
beq @ship
cmp #$18
bne @unknown
jmp board_balloon
@unknown:
jmp cmd_unknown
@ship:
lda #$10
jsr board_find_object
jsr j_primm
.byte $E6,$F2,$E9,$E7,$E1,$F4,$E5,$A1
.byte $8D,$00
lda player_xpos
cmp player_ship_xpos
bne @newship
lda player_ypos
cmp player_ship_ypos
bne @newship
jmp cmd_done
@newship:
lda #$50
sta ship_hull
jmp cmd_done
player_ship_xpos:
.byte $00
player_ship_ypos:
.byte $00
board_horse:
lda #$14
jsr board_find_object
jsr j_primm
.byte $CD,$EF,$F5,$EE,$F4,$A0,$E8,$EF
.byte $F2,$F3,$E5,$A1,$8D,$00
jmp cmd_done
board_balloon:
lda #$18
jsr board_find_object
jsr j_primm
.byte $E2,$E1,$EC,$EC,$EF,$EF,$EE,$8D
.byte $00
lda #$00
sta movement_mode
jmp cmd_done
board_find_object:
sta $58
ldx #$1F
@checkobject:
lda object_tile,x
and #$FC
cmp $58
bne @next
lda object_xpos,x
cmp player_xpos
bne @next
lda object_ypos,x
cmp player_ypos
beq @foundobject
@next:
dex
cpx #$08
bcs @checkobject
bcc @noobject
@foundobject:
lda #$00
sta object_tile,x
sta map_status,x
@noobject:
lda tile_under_player
sta player_transport
rts
cmd_cast:
jsr j_primm
.byte $C3,$E1,$F3,$F4,$A0,$F3,$F0,$E5
.byte $EC,$EC,$BA,$8D,$F0,$EC,$E1,$F9
.byte $E5,$F2,$AD,$00
jsr j_getplayernum
bne @checknum
@none:
jmp print_not_a_player
@checknum:
cmp party_size
beq @gotplayer
bcs @none
@gotplayer:
sta currplayer
jsr check_awake
bpl @playerok
jmp print_disabled
@playerok:
jsr list_mixtures
jsr j_primm
.byte $D3,$D0,$C5,$CC,$CC,$AD,$00
jsr getandprintkey
pha
jsr j_clearstatwindow
jsr j_update_status
lda game_mode
bpl @notcombat
jsr invert_player_line
@notcombat:
pla
sec
sbc #$C1
cmp #$1A
bcc @validspell
jmp cmd_unknown
@validspell:
sta @currspell
clc
adc #$65
jsr j_printstring
jsr j_primm
.byte $A1,$8D,$00
ldy @currspell
lda mixtures,y
bne @havemixed
jmp print_you_have_none
@havemixed:
sed
sec
sbc #$01
sta mixtures,y
cld
jsr j_get_stats_ptr
ldy #$16
lda (ptr1),y
ldx @currspell
sed
sec
sbc @mpcost,x
cld
bcs @decmp
jsr j_primm
.byte $CD,$AE,$D0,$AE,$A0,$D4,$CF,$CF
.byte $A0,$CC,$CF,$D7,$A1,$8D,$00
jmp spell_failed
@decmp:
sta (ptr1),y
lda @currspell
asl a
tay
lda @spelljumptable,y
sta ptr1
lda @spelljumptable+1,y
sta ptr1+1
jmp (ptr1)
@currspell:
.byte $00
@spelljumptable:
.addr spell_awaken
.addr spell_blink
.addr spell_cure
.addr spell_dispel
.addr spell_energyfield
.addr spell_fireball
.addr spell_gate
.addr spell_heal
.addr spell_iceball
.addr spell_jinx
.addr spell_kill
.addr spell_light
.addr spell_magicmissle
.addr spell_negate
.addr spell_open
.addr spell_protect
.addr spell_quick
.addr spell_resurrect
.addr spell_sleep
.addr spell_tremor
.addr spell_undead
.addr spell_view
.addr spell_winds
.addr spell_xit
.addr spell_yup
.addr spell_zdown
@mpcost:
.byte $05,$15,$05,$20,$10,$15,$40,$10
.byte $20,$30,$25,$05,$05,$20,$05,$15
.byte $20,$45,$15,$30,$15,$15,$10,$15
.byte $10,$05
spell_awaken:
jsr j_primm
.byte $D7,$C8,$CF,$AD,$00
jsr j_getplayernum
bne @gotnum
@fail:
jmp spell_failed
@gotnum:
jsr spell_play_effect
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$D3
bne @fail
lda #$C7
sta (ptr1),y
lda game_mode
bpl @notcombat
jsr something_based_on_status_and_class
ldx currplayer
sta $AD9F,x
@notcombat:
jmp print_done
spell_blink:
lda player_transport
cmp #$14
bcs @notinship
@fail:
jmp spell_failed
@notinship:
jsr spell_ensure_outdoors
jsr print_direction
jsr getdirection
jsr spell_play_effect
lda player_xpos
and player_ypos
cmp #$C0
bcc @notnearabyss
jmp spell_failed
@notnearabyss:
jsr @incdist
cmp #$FF
bne @notnearabyss
@next:
jsr @decdist
cmp #$FF
beq @fail
jsr j_blocked_tile
bmi @next
lda $7A
sta player_xpos
lda $7B
sta player_ypos
jsr music_nop
jsr j_player_teleport
jmp print_done
@incdist:
clc
lda $7A
adc $78
sta $7A
clc
lda $7B
adc $79
sta $7B
jsr j_gettile_bounds
rts
@decdist:
sec
lda $7A
sbc $78
sta $7A
sec
lda $7B
sbc $79
sta $7B
jsr j_gettile_bounds
rts
spell_cure:
jsr j_primm
.byte $D7,$C8,$B0,$AD,$00
jsr j_getplayernum
bne @gotnum
@fail:
jmp spell_failed
@gotnum:
jsr spell_play_effect
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$D0
bne @fail
lda #$C7
sta (ptr1),y
jmp print_done
spell_dispel:
lda game_mode
cmp #$03
beq @dungeon
jsr print_direction
lda game_mode
bmi @combat
cmp #$01
bne @towne
beq @britannia
@fail:
jmp spell_failed
@britannia:
jsr getdirection
beq @fail
jsr spell_play_effect
jsr j_gettile_bounds
@checktile:
cmp #$44
bcc @fail
cmp #$48
bcs @fail
lda tile_under_player
sta (ptr2),y
jmp print_done
@towne:
jsr getdirection
beq @fail
jsr spell_play_effect
jsr j_gettile_town
jmp @checktile
@combat:
jsr combat_getdirection
beq @fail
jsr spell_play_effect
jsr j_gettile_combat
sta tile_under_player
clc
lda $16
adc $78
sta $16
clc
lda $17
adc $79
sta $17
jsr j_gettile_combat
cmp #$44
bcc @fail
cmp #$48
bcs @fail
lda tile_under_player
sta tempmap,y
jmp print_done
@dungeon:
jsr spell_play_effect
clc
ldx dng_direction
lda player_xpos
adc dng_move_deltax,x
sta $16
clc
lda player_ypos
adc dng_move_deltay,x
sta $17
jsr j_gettile_dungeon
and #$F0
cmp #$A0
bne @fail
lda #$00
sta (ptr1),y
jmp print_done
spell_energyfield:
jsr j_primm
.byte $D4,$D9,$D0,$C5,$AD,$00
jsr getandprintkey
ldx #$44
cmp #$D0
beq @gottype
inx
cmp #$CC
beq @gottype
inx
cmp #$C6
beq @gottype
inx
cmp #$D3
beq @gottype
@fail:
jmp spell_failed
@gottype:
stx $6A
lda game_mode
bmi @combat
cmp #$03
bne @fail
jsr spell_play_effect
ldx dng_direction
clc
lda player_xpos
adc dng_move_deltax,x
sta $16
clc
lda player_ypos
adc dng_move_deltay,x
sta $17
jsr j_gettile_dungeon
bne @fail
lda $6A
and #$03
ora #$A0
sta (ptr1),y
jmp print_done
@combat:
jsr print_direction
jsr combat_getdirection
beq @fail
clc
lda $16
adc $78
sta $16
cmp #$0B
bcs @fail
clc
lda $17
adc $79
sta $17
cmp #$0B
bcs @fail
jsr spell_play_effect
jsr j_gettile_combat
jsr j_blocked_tile
bmi @fail
lda $6A
sta tempmap,y
jmp print_done
spell_fireball:
jsr spell_ensure_combat
jsr print_direction
jsr combat_getdirection
bne @gotdir
@fail:
lda #$00
sta missile
jmp spell_failed
@gotdir:
jsr spell_play_effect
lda #$4F
sta missile
spell_shoot_missile:
lda $16
sta missile_xpos
lda $17
sta missile_ypos
@again:
jsr combat_fire_missile
bmi @fail
jsr j_idle_combat
jsr combat_find_monster
bmi @again
lda #$06
jsr j_playsfx
lda missile
cmp #$4D
beq @magic_missile
cmp #$4E
beq @iceball
cmp #$4F
beq @fireball
lda #$E8
jmp @gotdmg
@fireball:
lda #$80
jsr randmax
ora #$18
jmp @gotdmg
@iceball:
lda #$E0
jsr randmax
ora #$20
jmp @gotdmg
@magic_missile:
lda #$40
jsr randmax
ora #$10
@gotdmg:
ldx #$00
stx missile
sta $5C
jsr hurt_monster
jmp print_done
spell_gate:
lda player_transport
cmp #$14
bcc @fail
lda game_mode
cmp #$01
beq @print_to_phase
jmp spell_ensure_outdoors
@print_to_phase:
jsr j_primm
.byte $D4,$CF,$A0,$D0,$C8,$C1,$D3,$C5
.byte $AD,$00
jsr getandprintkey
sec
sbc #$B1
cmp #$08
bcc @gotphase
@fail:
jmp spell_failed
@gotphase:
sta $6A
jsr spell_play_effect
ldx $6A
lda moongate_xpos,x
sta player_xpos
lda moongate_ypos,x
sta player_ypos
jsr music_nop
jsr j_player_teleport
jmp print_done
moongate_xpos:
.byte $E0,$60,$26,$32,$A6,$68,$17,$BB
moongate_ypos:
.byte $85,$66,$E0,$25,$13,$C2,$7E,$A7
spell_heal:
jsr j_primm
.byte $D7,$C8,$CF,$AD,$00
jsr j_getplayernum
bne @gotplayer
@fail:
jmp spell_failed
@gotplayer:
jsr spell_play_effect
jsr check_alive
bmi @fail
lda #$19
jsr randmax
clc
adc #$4B
jsr hextobcd
jsr stat_add_hp
jmp print_done
spell_iceball:
jsr spell_ensure_combat
jsr print_direction
jsr combat_getdirection
bne @gotdir
jmp spell_failed
@gotdir:
jsr spell_play_effect
lda #$4E
sta missile
jmp spell_shoot_missile
spell_jinx:
jsr spell_play_effect
lda #$CA
spell_set_aura:
sta magic_aura
lda #$0A
sta aura_duration
jmp print_done
spell_kill:
jsr spell_ensure_combat
jsr print_direction
jsr combat_getdirection
bne @gotdir
jmp spell_failed
@gotdir:
jsr spell_play_effect
lda #$8C
sta missile
jmp spell_shoot_missile
spell_light:
jsr spell_play_effect
lda #$64
sta light_duration
lda game_mode
cmp #$03
bne @notdungeon
jsr L8C06
@notdungeon:
jmp print_done
spell_magicmissle:
jsr spell_ensure_combat
jsr print_direction
jsr combat_getdirection
bne @gotdir
jmp spell_failed
@gotdir:
jsr spell_play_effect
lda #$4D
sta missile
jmp spell_shoot_missile
spell_negate:
jsr spell_play_effect
lda #$CE
jmp spell_set_aura
spell_open:
jsr spell_play_effect
lda game_mode
bmi @combat
lda #$00
sta currplayer
jmp get_chest
@combat:
jmp combat_open_chest
spell_protect:
jsr spell_play_effect
lda #$D0
jmp spell_set_aura
spell_quick:
jsr spell_play_effect
lda #$D1
jmp spell_set_aura
spell_resurrect:
lda game_mode
bpl L4C9C
L4C99:
jmp spell_failed
L4C9C:
jsr j_primm
.byte $D7,$C8,$CF,$AD,$00
jsr j_getplayernum
bne L4CAC
jmp spell_failed
L4CAC:
jsr spell_play_effect
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C4
beq L4CBD
jmp spell_failed
L4CBD:
lda #$C7
sta (ptr1),y
jmp print_done
spell_sleep:
jsr spell_ensure_combat
jsr spell_play_effect
ldx #$0F
L4CCC:
lda cbt_monster_type,x
beq L4CE7
jsr L4ECD
beq L4CE7
cmp #$FC
beq L4CE7
jsr j_rand
cmp monster_hp,x
bcc L4CE7
lda #$01
sta $AD70,x
L4CE7:
dex
bpl L4CCC
jmp print_done
spell_tremor:
jsr spell_ensure_combat
jsr spell_play_effect
jsr shake_screen
ldx #$0F
L4CF8:
lda cbt_monster_type,x
beq L4D42
cmp #$5E
beq L4D42
lda monster_hp,x
cmp #$C0
bcs L4D42
jsr j_rand
bmi L4D19
and #$01
bne L4D42
lda #$17
sta monster_hp,x
jmp L4D42
L4D19:
stx $6A
lda monster_xpos,x
sta missile_xpos
lda monster_ypos,x
sta missile_ypos
lda #$4F
sta missile
jsr j_idle_combat
lda #$06
jsr j_playsfx
lda #$00
sta missile
lda #$FF
sta $5C
jsr hurt_monster
ldx $6A
L4D42:
dex
bpl L4CF8
jmp print_done
spell_undead:
jsr spell_ensure_combat
jsr spell_play_effect
ldx #$0F
L4D50:
lda cbt_monster_type,x
jsr L4ECD
bne L4D62
jsr j_rand
bmi L4D62
lda #$17
sta monster_hp,x
L4D62:
dex
bpl L4D50
jmp print_done
spell_view:
lda game_mode
bpl L4D6F
jmp L4C99
L4D6F:
jsr spell_play_effect
jsr L57E8
jmp print_done
spell_winds:
jsr spell_ensure_outdoors
jsr print_direction
jsr getdirection
bne L4D86
jmp spell_failed
L4D86:
jsr spell_play_effect
lda $78
bne L4D9B
lda $79
bpl L4D96
lda #$01
jmp L4DA4
L4D96:
lda #$03
jmp L4DA4
L4D9B:
bpl L4DA2
lda #$00
jmp L4DA4
L4DA2:
lda #$02
L4DA4:
sta direction
jmp print_done
spell_xit:
jsr spell_ensure_dungeon
jsr spell_play_effect
jmp exit_location
spell_yup:
jsr spell_ensure_dungeon
jsr spell_play_effect
jsr L4E2C
dec dungeon_level
bpl L4DC2
jmp exit_location
L4DC2:
lda #$20
sta $70
L4DC6:
jsr j_rand
and #$07
sta $16
jsr j_rand
and #$07
sta $17
jsr j_gettile_dungeon
beq L4DE2
dec $70
bne L4DC6
inc dungeon_level
jmp spell_failed
L4DE2:
lda $16
sta player_xpos
lda $17
sta player_ypos
jmp print_done
spell_zdown:
jsr spell_ensure_dungeon
jsr spell_play_effect
jsr L4E2C
lda dungeon_level
cmp #$07
bcc L4DFF
jsr spell_failed
L4DFF:
inc dungeon_level
lda #$20
sta $70
L4E05:
jsr j_rand
and #$07
sta $16
jsr j_rand
and #$07
sta $17
jsr j_gettile_dungeon
beq L4E21
dec $70
bne L4E05
dec dungeon_level
jmp spell_failed
L4E21:
lda $16
sta player_xpos
lda $17
sta player_ypos
jmp print_done
L4E2C:
lda current_location
cmp #$18
bne L4E37
pla
pla
jmp spell_failed
L4E37:
rts
spell_ensure_dungeon:
lda game_mode
cmp #$03
beq @dungeon
jsr j_primm
.byte $C4,$D5,$CE,$C7,$C5,$CF,$CE,$A0
.byte $CF,$CE,$CC,$D9,$A1,$8D,$00
pla
pla
jmp spell_failed
@dungeon:
rts
spell_ensure_combat:
lda game_mode
bmi @combat
jsr j_primm
.byte $C3,$CF,$CD,$C2,$C1,$D4,$A0,$CF
.byte $CE,$CC,$D9,$A1,$8D,$00
pla
pla
jmp spell_failed
@combat:
rts
spell_ensure_outdoors:
lda game_mode
cmp #$01
beq @britannia
jsr j_primm
.byte $CF,$D5,$D4,$C4,$CF,$CF,$D2,$D3
.byte $A0,$CF,$CE,$CC,$D9,$A1,$8D,$00
pla
pla
jmp spell_failed
@britannia:
rts
spell_play_effect:
ldy @currspell
ldx @mpcost,y
lda #$0A
jsr j_playsfx
jsr j_invertview
lda @currspell
clc
adc #$60
tax
lda #$09
jsr j_playsfx
jsr j_invertview
lda magic_aura
cmp #$CE
bne L4EB8
pla
pla
jmp spell_failed
L4EB8:
rts
spell_failed:
jsr j_primm
.byte $C6,$C1,$C9,$CC,$C5,$C4,$A1,$8D
.byte $00
lda #$08
jsr j_playsfx
jmp cmd_done
L4ECD:
cmp #$9C
beq L4EE0
cmp #$BC
beq L4EE0
cmp #$C4
beq L4EE0
cmp #$E4
beq L4EE0
lda #$FF
rts
L4EE0:
lda #$00
rts
print_direction:
jsr j_primm
.byte $C4,$C9,$D2,$C5,$C3,$D4,$C9,$CF
.byte $CE,$AD,$00
rts
cmd_descend:
lda player_transport
cmp #$18
beq @balloon
jsr j_primm
.byte $C4,$E5,$F3,$E3,$E5,$EE,$E4,$A0
.byte $00
lda current_location
cmp #$01
beq @lbcastle
lda game_mode
cmp #$03
beq @dungeon
jmp cmd_unknown
@dungeon:
lda tile_under_player
and #$F0
cmp #$20
beq @downlevel
cmp #$30
beq @downlevel
jmp cmd_unknown
@downlevel:
inc dungeon_level
jsr j_primm
.byte $E4,$EF,$F7,$EE,$A1,$8D,$D4,$EF
.byte $A0,$EC,$E5,$F6,$E5,$EC,$A0,$00
clc
lda dungeon_level
adc #$01
jsr j_printdigit
jsr printcr
jmp cmd_done
@balloon:
jsr j_primm
.byte $CC,$E1,$EE,$E4,$A0,$C2,$E1,$EC
.byte $EC,$EF,$EF,$EE,$8D,$00
lda tile_under_player
cmp #$04
bne @nothere
lda #$00
sta movement_mode
sta $1D
jmp cmd_done
@nothere:
jmp print_not_here
@noladder:
jmp cmd_unknown
@lbcastle:
lda player_transport
cmp #$1F
beq @onfoot
jmp print_only_on_foot
@onfoot:
lda tile_under_player
cmp #$1C
bne @noladder
lda player_ypos
cmp #$02
beq @intodungeon
jsr j_primm
.byte $F4,$EF,$8D,$E6,$E9,$F2,$F3,$F4
.byte $A0,$E6,$EC,$EF,$EF,$F2,$A1,$8D
.byte $00
lda #$00
jsr music_ctl
lda #$C1
jsr enter_location
lda #$01
jsr music_ctl
jmp cmd_done
@intodungeon:
jsr j_primm
.byte $E9,$EE,$F4,$EF,$8D,$F4,$E8,$E5
.byte $A0,$E4,$E5,$F0,$F4,$E8,$F3,$A1
.byte $8D,$00
lda #$05
sta $7A
sta $7B
lda #$EF
sta $18
lda #$F0
sta $19
lda #$17
sta current_location
jmp enter_dungeon
cmd_enter:
jsr j_primm
.byte $C5,$EE,$F4,$E5,$F2,$A0,$00
lda current_location
beq L4FE1
jmp cmd_unknown
L4FE1:
ldx #$20
L4FE3:
dex
bpl L4FE9
jmp cmd_unknown
L4FE9:
lda L519A,x
cmp player_xpos
bne L4FE3
lda L51BA,x
cmp player_ypos
bne L4FE3
stx current_location
inc current_location
lda player_xpos
sta $18
lda player_ypos
sta $19
lda tile_under_player
cmp #$09
beq L5052
cmp #$0A
bne L5010
jmp L50D3
L5010:
cmp #$0B
bne L5017
jmp L513B
L5017:
cmp #$0C
bne L501E
jmp L512B
L501E:
cmp #$0E
bne L5025
jmp L513B
L5025:
cmp #$1D
bne L502C
jmp L50C6
L502C:
cmp #$1E
bne L5033
jmp L5166
L5033:
cmp #$46
beq L503E
lda #$00
sta current_location
jmp cmd_unknown
L503E:
lda $AB0E
cmp #$77
beq L504C
lda #$00
sta current_location
jmp print_cant
L504C:
jsr print_location_name
jmp L5062
L5052:
jsr j_primm
.byte $E4,$F5,$EE,$E7,$E5,$EF,$EE,$A1
.byte $8D,$00
jsr print_location_name
L5062:
lda player_transport
cmp #$1F
beq L506F
lda #$00
sta current_location
jmp print_only_on_foot
L506F:
lda #$01
sta $7A
sta $7B
lda #$00
jsr music_ctl
jsr save_tempmap
enter_dungeon:
lda #$00
jsr music_ctl
lda #$04
jsr j_request_disk
lda #$CC
ldx #$95
jsr j_fileio
jsr @loaddungeon
lda #$03
sta game_mode
lda #$01
sta dng_direction
lda $7A
sta player_xpos
lda $7B
sta player_ypos
lda #$00
sta dungeon_level
lda #$C4
jsr music_ctl
jmp cmd_done
@loaddungeon:
clc
lda current_location
sec
sbc #$11
clc
adc #$8C
tax
lda #$CC
jsr j_fileio
ldx #$00
txa
L50BF:
sta map_status,x
inx
bne L50BF
rts
L50C6:
jsr j_primm
.byte $F2,$F5,$E9,$EE,$A1,$8D,$00
jmp L50DE
L50D3:
jsr j_primm
.byte $F4,$EF,$F7,$EE,$E5,$A1,$8D,$00
L50DE:
lda #$00
jsr music_ctl
jsr print_location_name
jsr L51F6
lda #$0F
sta player_ypos
lda #$01
sta player_xpos
lda current_location
sec
sbc #$05
cmp #$08
bcs L5123
sta $58
lda party_size
sta currplayer
L5100:
lda currplayer
cmp #$02
bcc L5123
jsr j_get_stats_ptr
ldy #$11
lda (ptr1),y
cmp $58
beq L5116
dec currplayer
jmp L5100
L5116:
lda #$00
ldx #$1F
sta object_tile,x
sta map_status,x
sta $ACC0,x
L5123:
lda #$D4
jsr music_ctl
jmp cmd_done
L512B:
jsr j_primm
.byte $F6,$E9,$EC,$EC,$E1,$E7,$E5,$A1
.byte $8D,$00
jmp L50DE
L513B:
lda #$00
jsr music_ctl
jsr j_primm
.byte $E3,$E1,$F3,$F4,$EC,$E5,$A1,$8D
.byte $00
jsr print_location_name
jsr L51F6
lda #$0F
sta player_xpos
lda #$1E
sta player_ypos
lda #$00
sta dungeon_level
lda #$C3
jsr music_ctl
jmp cmd_done
L5166:
jsr j_primm
.byte $F4,$E8,$E5,$8D,$F3,$E8,$F2,$E9
.byte $EE,$E5,$A0,$EF,$E6,$8D,$00
lda current_location
clc
adc #$7E
jsr j_printstring
jsr printcr
L5183:
lda #$00
jsr music_ctl
lda #$CC
ldx #$82
jsr j_fileio
jsr L8800
lda #$01
jsr music_ctl
jmp cmd_done
L519A:
.byte $56,$DA,$1C,$92,$E8,$52,$24,$3A
.byte $9F,$6A,$16,$BB,$62,$88,$C9,$88
.byte $F0,$5B,$48,$7E,$9C,$3A,$EF,$E9
.byte $E9,$80,$24,$49,$CD,$51,$E7,$E7
L51BA:
.byte $6B,$6B,$32,$F1,$87,$6A,$DE,$2B
.byte $14,$B8,$80,$A9,$91,$9E,$3B,$5A
.byte $49,$43,$A8,$14,$1B,$66,$F0,$E9
.byte $42,$5C,$E5,$0B,$2D,$CF,$D8,$D8
print_location_name:
jsr printcr
lda current_location
clc
adc #$7E
jsr j_centerstring
jsr printcr
rts
save_tempmap:
lda #$02
jsr j_request_disk
lda #$D3
ldx #$7E
jsr j_fileio
rts
L51F6:
jsr save_tempmap
lda #$03
jsr j_request_disk
lda current_location
clc
adc #$C0
enter_location:
cmp #$C0
bne @notlbcfloor2
lda #$6C
jmp @lbcfloor2
@notlbcfloor2:
sec
sbc #$C0
clc
adc #$5B
@lbcfloor2:
tax
lda #$CC
jsr j_fileio
ldx #$00
@copy:
lda $8B00,x
sta $E800,x
lda L8C00,x
sta $E900,x
lda $8D00,x
sta $EA00,x
lda $8E00,x
sta $EB00,x
lda $8F00,x
sta map_status,x
inx
bne @copy
lda #$02
sta game_mode
rts
cmd_fire_unknown:
jmp cmd_unknown
cmd_fire:
jsr j_primm
.byte $C6,$E9,$F2,$E5,$AD,$00
lda player_transport
cmp #$10
bcc cmd_fire_unknown
cmp #$14
bcs cmd_fire_unknown
jsr getdirection
bne L525E
jmp cmd_pass
L525E:
lda $78
beq L5289
lda player_transport
cmp #$11
beq L5296
cmp #$13
beq L5296
L526C:
jsr j_primm
.byte $CF,$CE,$CC,$D9,$A0,$C2,$D2,$CF
.byte $C1,$C4,$D3,$C9,$C4,$C5,$D3,$A1
.byte $8D,$00
lda #$02
jsr j_playsfx
jmp cmd_done
L5289:
lda player_transport
cmp #$10
beq L5296
cmp #$12
beq L5296
jmp L526C
L5296:
lda #$03
jsr j_playsfx
lda #$03
sta $6A
L529F:
jsr find_target
bpl L52CA
jsr L0887
pha
lda #$4D
sta (ptr1),y
jsr j_animate_view
jsr L0887
pla
sta (ptr1),y
clc
lda $7A
adc $78
sta $7A
clc
lda $7B
adc $79
sta $7B
dec $6A
bne L529F
jmp cmd_done
L52CA:
stx $59
jsr L0887
pha
lda #$4F
sta (ptr1),y
jsr j_animate_view
lda #$06
jsr j_playsfx
jsr L0887
pla
sta (ptr1),y
lda $59
cmp #$08
bcs L52EF
jsr j_rand
and #$03
bne L5300
L52EF:
lda #$00
ldx $59
ldy object_tile,x
cpy #$5E
beq L5300
sta object_tile,x
sta map_status,x
L5300:
jmp cmd_done
cmd_get_chest:
jsr j_primm
.byte $C7,$E5,$F4,$A0,$E3,$E8,$E5,$F3
.byte $F4,$AC,$A0,$F7,$E8,$EF,$8D,$F7
.byte $E9,$EC,$EC,$A0,$EF,$F0,$E5,$EE
.byte $AD,$00
jsr j_getplayernum
bne @gotnum
jmp print_aborted
@gotnum:
cmp party_size
bcc @gotplayer
beq @gotplayer
jmp print_not_a_player
@gotplayer:
jsr check_awake
beq get_chest
jmp print_disabled
get_chest:
lda game_mode
cmp #$03
beq @dungeon
lda tile_under_player
cmp #$3C
beq @chest
jmp print_not_here
@chest:
lda current_location
beq @checkobjects
jsr L0890
cmp #$3C
bne @checkobjects
lda #$3E
sta (ptr2),y
ldy #$00
lda #$01
jsr virtue_dec
ldy #$03
lda #$01
jsr virtue_dec
ldy #$05
lda #$01
jsr virtue_dec
jmp @gotchest
@checkobjects:
ldx #$1F
@check:
lda object_tile,x
cmp #$3C
bne @next
lda object_xpos,x
cmp player_xpos
bne @next
lda object_ypos,x
cmp player_ypos
beq @foundchest
@next:
dex
bpl @check
bmi @gotchest
@foundchest:
lda #$00
sta object_tile,x
sta map_status,x
@gotchest:
jmp openchest
@dungeon:
lda tile_under_player
cmp #$40
beq @dngchest
jmp print_not_here
@dngchest:
lda player_xpos
sta $16
lda player_ypos
sta $17
jsr j_gettile_dungeon
lda #$00
sta (ptr1),y
openchest:
jsr j_rand
bpl @checktrap
jmp @getgold
@checktrap:
and #$03
sta zptmp1
jsr j_rand
and zptmp1
sta zptmp1
bne @sleep
jsr j_primm
.byte $C1,$C3,$C9,$C4,$00
jmp @print_trap
@sleep:
cmp #$01
bne @poison
jsr j_primm
.byte $D3,$CC,$C5,$C5,$D0,$00
jmp @print_trap
@poison:
cmp #$02
bne @bomb
jsr j_primm
.byte $D0,$CF,$C9,$D3,$CF,$CE,$00
jmp @print_trap
@bomb:
jsr j_primm
.byte $C2,$CF,$CD,$C2,$00
@print_trap:
jsr j_primm
.byte $A0,$D4,$D2,$C1,$D0,$A1,$8D,$00
lda currplayer
beq @evaded
jsr j_get_stats_ptr
ldy #$14
lda (ptr1),y
jsr bcdtohex
clc
adc #$19
sta $59
lda #$64
jsr randmax
cmp $59
bcs @trapped
@evaded:
jsr j_primm
.byte $C5,$D6,$C1,$C4,$C5,$C4,$A1,$8D
.byte $00
lda #$08
jsr j_playsfx
jmp @getgold
@trapped:
lda zptmp1
bne @suffersleep
jsr hurt_player_random_val
jmp @getgold
@suffersleep:
cmp #$01
bne @sufferpoison
jsr j_get_stats_ptr
ldy #$12
lda #$D3
sta (ptr1),y
jsr flash_player_line
lda game_mode
bpl @getgold
lda #$38
ldx currplayer
sta $AD9F,x
jmp @getgold
@sufferpoison:
cmp #$02
bne @sufferbomb
jsr j_get_stats_ptr
ldy #$12
lda #$D0
sta (ptr1),y
jsr flash_player_line
jmp @getgold
@sufferbomb:
jsr hurt_all_players
@getgold:
jsr j_primm
.byte $D4,$C8,$C5,$A0,$C3,$C8,$C5,$D3
.byte $D4,$A0,$C8,$CF,$CC,$C4,$D3,$BA
.byte $8D,$00
lda #$64
jsr randmax
jsr hextobcd
jsr stat_add_gold
lda zptmp1
jsr j_printbcd
jsr j_primm
.byte $AD,$C7,$CF,$CC,$C4,$A1,$8D,$00
jmp cmd_done
cmd_hole_up_and_camp:
jsr j_primm
.byte $C8,$EF,$EC,$E5,$A0,$F5,$F0,$A0
.byte $A6,$A0,$E3,$E1,$ED,$F0,$8D,$00
lda current_location
beq L54C3
lda game_mode
cmp #$03
beq L54C3
jmp print_not_here
L54C3:
lda player_transport
cmp #$1F
beq L54E1
jsr j_primm
.byte $CD,$D5,$D3,$D4,$A0,$C2,$C5,$A0
.byte $CF,$CE,$A0,$C6,$CF,$CF,$D4,$A1
.byte $8D,$00
jmp cmd_done
L54E1:
lda #$00
jsr music_ctl
lda #$CC
ldx #$85
jsr j_fileio
jsr L8800
jsr j_update_status
lda #$01
jsr music_ctl
lda game_mode
cmp #$03
bne L5501
jsr L8C06
L5501:
jmp cmd_done
cmd_ignite:
jsr j_primm
.byte $C9,$E7,$EE,$E9,$F4,$E5,$A0,$F4
.byte $EF,$F2,$E3,$E8,$A1,$8D,$00
ldy #$08
jsr stat_dec
bcs L5520
jmp print_you_have_none
L5520:
lda #$64
sta light_duration
lda game_mode
cmp #$03
bne L552D
jsr L8C06
L552D:
jmp cmd_done
cmd_jimmy_lock:
jsr j_primm
.byte $CA,$E9,$ED,$ED,$F9,$A0,$EC,$EF
.byte $E3,$EB,$AD,$00
jsr getdirection
lda game_mode
cmp #$01
bne L554B
jmp print_not_here
L554B:
jsr j_gettile_town
cmp #$3A
beq L5555
jmp print_not_here
L5555:
ldy #$0A
jsr stat_dec
bcs L555F
jmp print_you_have_none
L555F:
lda #$3B
ldy #$00
sta (ptr2),y
jmp print_done
cmd_klimb:
jsr j_primm
.byte $CB,$EC,$E9,$ED,$E2,$A0,$00
lda current_location
beq L55B9
cmp #$01
beq L55D5
lda game_mode
cmp #$03
beq L5583
L5580:
jmp cmd_unknown
L5583:
lda tile_under_player
and #$F0
cmp #$10
beq L558F
cmp #$30
bne L5580
L558F:
jsr j_primm
.byte $F5,$F0,$A1,$8D,$00
dec dungeon_level
bpl L559E
jmp exit_location
L559E:
jsr j_primm
.byte $D4,$EF,$A0,$EC,$E5,$F6,$E5,$EC
.byte $A0,$00
clc
lda dungeon_level
adc #$01
jsr j_printdigit
jsr printcr
jmp cmd_done
L55B9:
lda player_transport
cmp #$18
bne L5580
jsr j_primm
.byte $E1,$EC,$F4,$E9,$F4,$F5,$E4,$E5
.byte $8D,$00
lda #$FF
sta movement_mode
sta $1D
jmp cmd_done
L55D5:
lda tile_under_player
cmp #$1B
bne L5580
lda player_transport
cmp #$1F
beq L55E7
jsr printcr
jmp print_only_on_foot
L55E7:
jsr j_primm
.byte $F4,$EF,$8D,$F3,$E5,$E3,$EF,$EE
.byte $E4,$A0,$E6,$EC,$EF,$EF,$F2,$A1
.byte $8D,$00
lda #$00
jsr music_ctl
lda #$C0
jsr enter_location
lda #$01
jsr music_ctl
jmp cmd_done
cmd_locate:
jsr j_primm
.byte $CC,$EF,$E3,$E1,$F4,$E5,$A0,$F0
.byte $EF,$F3,$E9,$F4,$E9,$EF,$EE,$8D
.byte $00
lda $AB0B
bne L5633
jsr j_primm
.byte $D7,$C9,$D4,$C8,$A0,$00
jmp cmd_unknown
L5633:
jsr j_primm
.byte $F7,$E9,$F4,$E8,$A0,$F3,$E5,$F8
.byte $F4,$E1,$EE,$F4,$BA,$8D,$8D,$A0
.byte $EC,$E1,$F4,$E9,$F4,$F5,$E4,$E5
.byte $BA,$00
lda player_ypos
lsr a
lsr a
lsr a
lsr a
clc
adc #$C1
jsr j_console_out
lda #$A7
jsr j_console_out
lda player_ypos
and #$0F
clc
adc #$C1
jsr j_console_out
jsr j_primm
.byte $A2,$8D,$EC,$EF,$EE,$E7,$E9,$F4
.byte $F5,$E4,$E5,$BA,$00
lda player_xpos
lsr a
lsr a
lsr a
lsr a
clc
adc #$C1
jsr j_console_out
lda #$A7
jsr j_console_out
lda player_xpos
and #$0F
clc
adc #$C1
jsr j_console_out
lda #$A2
jsr j_console_out
jsr printcr
jmp cmd_done
cmd_mix_reagents:
jsr list_mixtures
jsr j_primm
.byte $CD,$E9,$F8,$A0,$F2,$E5,$E1,$E7
.byte $E5,$EE,$F4,$F3,$8D,$00
lda #$00
jsr music_ctl
lda #$CC
ldx #$7B
jsr j_fileio
jsr L8800
lda #$01
jsr music_ctl
jmp cmd_done
cmd_new_order:
jsr j_primm
.byte $CE,$E5,$F7,$A0,$EF,$F2,$E4,$E5
.byte $F2,$BA,$8D,$E5,$F8,$E3,$E8,$E1
.byte $EE,$E7,$E5,$A0,$A3,$00
jsr j_getplayernum
bne L56ED
jmp print_aborted
L56ED:
cmp #$01
beq L5758
cmp party_size
bcc L56FA
beq L56FA
jmp print_not_here
L56FA:
sta $55
jsr j_get_stats_ptr
lda ptr1
sta L5772
lda ptr1+1
sta L5773
jsr j_primm
.byte $A0,$A0,$A0,$A0,$F7,$E9,$F4,$E8
.byte $A0,$A3,$00
jsr j_getplayernum
bne L571F
jmp print_aborted
L571F:
cmp #$01
beq L5758
cmp $55
bne L572A
jmp print_done
L572A:
cmp party_size
bcc L5733
beq L5733
jmp print_not_here
L5733:
jsr j_get_stats_ptr
ldy #$1F
lda L5772
sta ptr2
lda L5773
sta ptr2+1
L5742:
lda (ptr1),y
pha
lda (ptr2),y
sta (ptr1),y
pla
sta (ptr2),y
dey
bpl L5742
jsr j_clearstatwindow
jsr j_update_status
jmp print_done
L5758:
jsr j_printname
jsr j_primm
.byte $8D,$D9,$CF,$D5,$A0,$CD,$D5,$D3
.byte $D4,$A0,$CC,$C5,$C1,$C4,$A1,$8D
.byte $00
jmp print_aborted
L5772:
brk
L5773:
brk
cmd_open:
jsr update_door
lda open_door_counter
bne cmd_open
jsr j_primm
.byte $CF,$F0,$E5,$EE,$AD,$00
jsr getdirection
lda game_mode
cmp #$02
beq L5791
L578E:
jmp print_not_here
L5791:
jsr j_gettile_town
cmp #$3B
beq L579F
cmp #$3A
bne L578E
jmp print_cant
L579F:
lda $7A
sta open_door_xpos
lda $7B
sta open_door_ypos
lda #$05
sta open_door_counter
lda #$3E
sta (ptr2),y
jsr j_primm
.byte $CF,$D0,$C5,$CE,$C5,$C4,$A1,$8D
.byte $00
jmp cmd_done
cmd_peer_at_gem:
jsr j_primm
.byte $D0,$E5,$E5,$F2,$A0,$E1,$F4,$A0
.byte $00
ldy #$09
jsr stat_dec
bcs L57D7
jmp cmd_unknown
L57D7:
jsr j_primm
.byte $E1,$A0,$E7,$E5,$ED,$A1,$8D,$00
jsr L57E8
jmp cmd_done
L57E8:
lda #$00
jsr music_ctl
lda #$CC
ldx #$77
jsr j_fileio
lda #$03
jsr music_ctl
jsr L9000
lda game_mode
cmp #$03
bne L580E
lda #$00
jsr music_ctl
lda #$CC
ldx #$95
jsr j_fileio
L580E:
lda #$01
jsr music_ctl
rts
cmd_quit_and_save:
jsr j_primm
.byte $D1,$F5,$E9,$F4,$A0,$A6,$A0,$F3
.byte $E1,$F6,$E5,$AE,$AE,$AE,$8D,$00
jsr L5854
lda current_location
beq L5831
jmp print_not_here
L5831:
lda #$00
jsr music_ctl
lda #$02
jsr j_request_disk
lda #$D3
ldx #$7F
jsr j_fileio
ldx #$80
jsr j_fileio
ldx #$1A
jsr j_fileio
lda #$01
jsr music_ctl
jmp cmd_done
L5854:
lda move_counter
cmp #$10
bcs L587C
cmp #$00
bne L5881
lda move_counter+1
cmp #$10
bcs L5886
cmp #$00
bne L588B
lda move_counter+2
cmp #$10
bcs L5890
cmp #$00
bne L5895
lda move_counter+3
cmp #$10
bcs L589A
cmp #$00
bne L589F
L587C:
lda move_counter
jsr L58B1
L5881:
lda move_counter
jsr L58B9
L5886:
lda move_counter+1
jsr L58B1
L588B:
lda move_counter+1
jsr L58B9
L5890:
lda move_counter+2
jsr L58B1
L5895:
lda move_counter+2
jsr L58B9
L589A:
lda move_counter+3
jsr L58B1
L589F:
lda move_counter+3
jsr L58B9
jsr j_primm
.byte $A0,$ED,$EF,$F6,$E5,$F3,$A1,$8D
.byte $00
rts
L58B1:
lsr a
lsr a
lsr a
lsr a
jsr j_printdigit
rts
L58B9:
and #$0F
jsr j_printdigit
rts
cmd_ready_weapon:
jsr j_primm
.byte $D2,$E5,$E1,$E4,$F9,$A0,$E1,$A0
.byte $F7,$E5,$E1,$F0,$EF,$EE,$8D,$E6
.byte $EF,$F2,$A0,$F0,$EC,$E1,$F9,$E5
.byte $F2,$AD,$00
jsr j_getplayernum
beq L58E8
cmp party_size
bcc L58EB
beq L58EB
L58E8:
jmp print_not_a_player
L58EB:
jsr L5EA4
jsr j_primm
.byte $D7,$E5,$E1,$F0,$EF,$EE,$BA,$00
jsr getandprintkey
pha
jsr j_clearstatwindow
jsr j_update_status
lda game_mode
bpl L590A
jsr invert_player_line
L590A:
pla
sec
sbc #$C1
cmp #$10
bcc L5915
jmp print_aborted
L5915:
sta $6A
cmp #$00
beq L5927
clc
adc #$20
tay
lda game_stats,y
bne L5927
jmp print_you_have_none
L5927:
jsr j_get_stats_ptr
ldy #$17
lda (ptr1),y
ldx $6A
and weapon_class_table,x
bne L5938
jmp L5972
L5938:
ldy #$1E
lda (ptr1),y
beq L5945
clc
adc #$20
tay
jsr stat_inc
L5945:
ldy #$1E
lda $6A
sta (ptr1),y
beq L5954
clc
adc #$20
tay
jsr stat_dec
L5954:
lda $6A
clc
adc #$25
jsr j_printstring
jsr printcr
jmp print_done
weapon_class_table:
.byte $FF,$FF,$FF,$FF,$7F,$6F,$6F,$7E
.byte $7E,$FF,$2C,$0C,$2E,$5E,$D0,$FF
L5972:
jsr printcr
jsr j_primm
.byte $C1,$A0,$00
jsr j_get_stats_ptr
ldy #$11
lda (ptr1),y
clc
adc #$4D
jsr j_printstring
jsr j_primm
.byte $8D,$CD,$C1,$D9,$A0,$CE,$CF,$D4
.byte $A0,$D5,$D3,$C5,$A0,$C1,$8D,$00
lda $6A
clc
adc #$25
jsr j_printstring
jsr printcr
jmp print_aborted
cmd_search:
jsr j_primm
.byte $D3,$E5,$E1,$F2,$E3,$E8,$AE,$AE
.byte $AE,$8D,$00
lda #$00
jsr music_ctl
lda #$CC
ldx #$79
jsr j_fileio
jsr L8800
lda #$01
jsr music_ctl
jmp cmd_done
cmd_talk:
jsr j_primm
.byte $D4,$E1,$EC,$EB,$AD,$00
jsr getdirection
bne @gotdir
jmp cmd_pass
@gotdir:
jsr j_gettile_town
cmp #$60
bcc @notshop
cmp #$7E
bcs @notshop
clc
lda $7A
adc $78
sta $7A
clc
lda $7B
adc $79
sta $7B
jsr find_creature
bmi @noresponse
lda object_tile,x
cmp #$52
bne @noresponse
jmp @findshop
@notshop:
jsr find_creature
bmi @noresponse
stx $6A
lda current_location
beq @noresponse
cmp #$11
bcc @findnpc
@noresponse:
jsr j_primm
.byte $C6,$D5,$CE,$CE,$D9,$AC,$A0,$CE
.byte $CF,$8D,$D2,$C5,$D3,$D0,$CF,$CE
.byte $D3,$C5,$A1,$8D,$00
jmp cmd_done
@findnpc:
sta lt_y
dec lt_y
ldx $6A
lda $ACE0,x
sta lt_x
beq @noresponse
dec lt_x
lda #$01
sta lt_rwflag
lda #$AD
sta lt_addr_hi
lda #$00
jsr music_ctl
ldx $6A
lda object_tile,x
cmp #$5E
bne @notlordbritish
lda #$02
jsr j_request_disk
lda #$CC
ldx #$87
jsr j_fileio
lda #$C2
jsr music_ctl
jsr L8803
lda #$00
jsr music_ctl
lda #$03
jsr j_request_disk
lda #$C3
jsr music_ctl
jmp @talkdone
@notlordbritish:
jsr j_loadsector
lda #$CC
ldx #$78
jsr j_fileio
jsr L8800
@talkdone:
lda #$01
jsr music_ctl
jmp cmd_done
@findshop:
lda #$00
jsr music_ctl
lda #$CC
ldx #$19
jsr j_fileio
lda #$88
sta ptr1+1
lda current_location
sec
sbc #$01
asl a
asl a
asl a
sta ptr1
ldy #$07
L5AAD:
lda (ptr1),y
cmp $17
beq L5ADA
dey
bpl L5AAD
lda $17
cmp #$18
bne L5AC6
lda current_location
cmp #$0D
bne L5AC6
ldy #$08
bne L5ADA
L5AC6:
lda $17
cmp #$19
bne L5AD7
lda current_location
cmp #$01
bne L5AD7
ldy #$09
jmp L5ADA
L5AD7:
jmp @noresponse
L5ADA:
tya
clc
adc #$6D
tax
lda #$CC
jsr j_fileio
lda #$04
jsr music_ctl
jsr L8800
lda #$01
jsr music_ctl
jmp cmd_done
cmd_use:
jsr j_primm
.byte $D5,$F3,$E5,$AE,$AE,$AE,$8D,$00
lda #$00
jsr music_ctl
lda #$CC
ldx #$7A
jsr j_fileio
jsr L8800
lda game_mode
bmi L5B1A
lda #$01
jsr music_ctl
jmp cmd_done
L5B1A:
lda #$02
jsr music_ctl
jmp cmd_done
cmd_volume:
jsr j_primm
.byte $D6,$EF,$EC,$F5,$ED,$E5,$A0,$00
lda music_volume
bne @off
lda #$FF
sta music_volume
jsr j_primm
.byte $CF,$CE,$8D,$00
jmp cmd_done
@off:
lda #$00
sta music_volume
jsr j_primm
.byte $CF,$C6,$C6,$8D,$00
jmp cmd_done
cmd_wear_armor:
jsr j_primm
.byte $D7,$E5,$E1,$F2,$A0,$E1,$F2,$ED
.byte $EF,$F5,$F2,$8D,$E6,$EF,$F2,$A0
.byte $F0,$EC,$E1,$F9,$E5,$F2,$AD,$00
jsr j_getplayernum
beq L5B74
cmp party_size
bcc L5B77
beq L5B77
L5B74:
jmp print_not_a_player
L5B77:
jsr L5F26
jsr j_primm
.byte $C1,$F2,$ED,$EF,$F5,$F2,$BA,$00
jsr getandprintkey
pha
jsr j_clearstatwindow
jsr j_update_status
lda game_mode
bpl L5B96
jsr invert_player_line
L5B96:
pla
sec
sbc #$C1
cmp #$08
bcc L5BA1
jmp print_aborted
L5BA1:
sta $6A
cmp #$00
beq L5BB3
clc
adc #$18
tay
lda game_stats,y
bne L5BB3
jmp print_you_have_none
L5BB3:
jsr j_get_stats_ptr
ldy #$17
lda (ptr1),y
ldx $6A
and L5BF5,x
bne L5BCB
lda $6A
clc
adc #$10
sta $6A
jmp L5972
L5BCB:
ldy #$1F
lda (ptr1),y
beq L5BD8
clc
adc #$18
tay
jsr stat_inc
L5BD8:
ldy #$1F
lda $6A
sta (ptr1),y
beq L5BE7
clc
adc #$18
tay
jsr stat_dec
L5BE7:
lda $6A
clc
adc #$35
jsr j_printstring
jsr printcr
jmp print_done
L5BF5:
.byte $FF
.byte $FF
.byte $7F
bit $242C
.byte $04
.byte $FF
cmd_xit:
jsr j_primm
.byte $D8,$AD,$E9,$F4,$A0,$00
lda player_transport
cmp #$10
bcc L5C18
cmp #$14
bcc L5C1B
cmp #$16
bcc L5C28
cmp #$18
beq L5C2F
L5C18:
jmp cmd_unknown
L5C1B:
lda player_xpos
sta player_ship_xpos
lda player_ypos
sta player_ship_ypos
jmp L5C36
L5C28:
lda #$00
sta horse_mode
jmp L5C36
L5C2F:
lda movement_mode
beq L5C36
jmp print_not_here
L5C36:
ldx #$1F
L5C38:
lda object_tile,x
beq L5C4A
dex
cpx #$08
bcs L5C38
jsr j_rand
and #$0F
ora #$10
tax
L5C4A:
lda player_transport
sta object_tile,x
sta map_status,x
lda player_xpos
sta object_xpos,x
lda player_ypos
sta object_ypos,x
lda #$00
sta $ACC0,x
sta $ACE0,x
lda #$1F
sta player_transport
jsr printcr
jmp cmd_done
cmd_yell:
jsr j_primm
.byte $D9,$E5,$EC,$EC,$A0,$00
lda player_transport
cmp #$14
beq L5C84
cmp #$15
beq L5C84
jmp cmd_unknown
L5C84:
lda horse_mode
eor #$FF
sta horse_mode
bmi L5C99
jsr j_primm
.byte $F7,$E8,$EF,$E1,$A1,$8D,$00
jmp cmd_done
L5C99:
jsr j_primm
.byte $E7,$E9,$E4,$E4,$F9,$F5,$F0,$A1
.byte $8D,$00
jmp cmd_done
cmd_ztats:
jsr j_primm
.byte $DA,$F4,$E1,$F4,$F3,$A0,$E6,$EF
.byte $F2,$AD,$00
jsr j_getplayernum
bne L5CBF
jmp L5E30
L5CBF:
cmp party_size
bcc L5CC8
beq L5CC8
jmp print_not_a_player
L5CC8:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1C
ldy #$00
jsr j_primm_xy
.byte $1E,$D0,$CC,$D2,$AD,$00
lda currplayer
jsr j_printdigit
lda #$1C
jsr j_console_out
ldx #$18
stx console_xpos
ldy #$01
sty console_ypos
jsr j_centername
ldx #$18
stx console_xpos
ldy #$02
sty console_ypos
jsr j_get_stats_ptr
ldy #$10
lda (ptr1),y
jsr j_console_out
lda #$A0
jsr j_console_out
ldx #$18
stx console_xpos
jsr j_get_stats_ptr
ldy #$11
lda (ptr1),y
clc
adc #$4D
jsr j_centerstring
ldx #$26
stx console_xpos
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
jsr j_console_out
ldx #$19
ldy #$03
jsr j_primm_xy
.byte $CD,$D0,$BA,$00
jsr j_get_stats_ptr
ldy #$16
lda (ptr1),y
jsr j_printbcd
ldx #$20
ldy #$03
jsr j_primm_xy
.byte $CC,$D6,$BA,$00
jsr j_get_stats_ptr
ldy #$1A
lda (ptr1),y
jsr j_printdigit
ldx #$18
ldy #$04
jsr j_primm_xy
.byte $D3,$D4,$D2,$BA,$00
jsr j_get_stats_ptr
ldy #$13
lda (ptr1),y
jsr j_printbcd
ldx #$18
ldy #$05
jsr j_primm_xy
.byte $C4,$C5,$D8,$BA,$00
jsr j_get_stats_ptr
ldy #$14
lda (ptr1),y
jsr j_printbcd
ldx #$18
ldy #$06
jsr j_primm_xy
.byte $C9,$CE,$D4,$BA,$00
jsr j_get_stats_ptr
ldy #$15
lda (ptr1),y
jsr j_printbcd
ldx #$20
ldy #$04
jsr j_primm_xy
.byte $C8,$D0,$BA,$00
jsr j_get_stats_ptr
ldy #$18
lda (ptr1),y
jsr j_printbcd
ldy #$19
lda (ptr1),y
jsr j_printbcd
ldx #$20
ldy #$05
jsr j_primm_xy
.byte $C8,$CD,$BA,$00
jsr j_get_stats_ptr
ldy #$1A
lda (ptr1),y
jsr j_printbcd
ldy #$1B
lda (ptr1),y
jsr j_printbcd
ldx #$20
ldy #$06
jsr j_primm_xy
.byte $C5,$D8,$BA,$00
jsr j_get_stats_ptr
ldy #$1C
lda (ptr1),y
jsr j_printbcd
ldy #$1D
lda (ptr1),y
jsr j_printbcd
ldx #$18
ldy #$07
jsr j_primm_xy
.byte $D7,$BA,$00
jsr j_get_stats_ptr
ldy #$1E
lda (ptr1),y
clc
adc #$25
jsr j_printstring
ldx #$18
ldy #$08
jsr j_primm_xy
.byte $C1,$BA,$00
jsr j_get_stats_ptr
ldy #$1F
lda (ptr1),y
clc
adc #$35
jsr j_printstring
jsr restore_console_pos
jsr L5E8E
beq L5E7A
bmi L5E29
inc currplayer
lda party_size
cmp currplayer
bcc L5E30
jmp L5CC8
L5E29:
dec currplayer
beq L5E69
jmp L5CC8
L5E30:
jsr L5EA4
jsr L5E8E
beq L5E7A
bpl L5E41
lda party_size
sta currplayer
jmp L5CC8
L5E41:
jsr L5F26
jsr L5E8E
beq L5E7A
bmi L5E30
L5E4B:
jsr L5FA4
jsr L5E8E
beq L5E7A
bmi L5E41
L5E55:
jsr L601A
jsr L5E8E
beq L5E7A
bmi L5E4B
L5E5F:
jsr L6144
jsr L5E8E
beq L5E7A
bmi L5E55
L5E69:
jsr list_mixtures
jsr L5E8E
beq L5E7A
bmi L5E5F
lda #$01
sta currplayer
jmp L5CC8
L5E7A:
jsr j_clearstatwindow
jsr j_update_status
lda game_mode
bpl L5E8B
lda $45
sta currplayer
jsr invert_player_line
L5E8B:
jmp cmd_done
L5E8E:
jsr j_waitkey
bpl L5E8E
cmp #$87
beq L5E9E
cmp #$88
beq L5EA1
lda #$00
rts
L5E9E:
lda #$FF
rts
L5EA1:
lda #$01
rts
L5EA4:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1B
ldy #$00
sty $58
sty $59
jsr j_primm_xy
.byte $1F,$D7,$C5,$C1,$D0,$CF,$CE,$D3
.byte $1D,$00
L5EBF:
lda $59
and #$08
clc
adc #$18
sta console_xpos
lda $59
and #$07
sta console_ypos
inc console_ypos
lda $58
beq L5F16
clc
adc #$20
tay
lda game_stats,y
beq L5F0A
pha
lda $58
clc
adc #$C1
jsr j_console_out
pla
cmp #$10
bcs L5EF8
pha
lda #$AD
jsr j_console_out
pla
jsr j_printdigit
jmp L5EFB
L5EF8:
jsr j_printbcd
L5EFB:
lda #$AD
jsr j_console_out
lda $58
clc
adc #$3D
jsr j_printstring
inc $59
L5F0A:
inc $58
lda $58
cmp #$10
bcc L5EBF
jsr restore_console_pos
rts
L5F16:
jsr j_primm
.byte $C1,$AD,$C8,$C1,$CE,$C4,$D3,$00
inc $59
jmp L5F0A
L5F26:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1B
ldy #$00
sty $58
sty $59
jsr j_primm_xy
.byte $1F,$C1,$D2,$CD,$CF,$D5,$D2,$1C
.byte $00
L5F40:
lda #$18
sta console_xpos
lda $59
sta console_ypos
inc console_ypos
lda $58
beq L5F90
clc
adc #$18
tay
lda game_stats,y
beq L5F84
pha
lda $58
clc
adc #$C1
jsr j_console_out
pla
cmp #$10
bcs L5F72
pha
lda #$AD
jsr j_console_out
pla
jsr j_printdigit
jmp L5F75
L5F72:
jsr j_printbcd
L5F75:
lda #$AD
jsr j_console_out
lda $58
clc
adc #$35
jsr j_printstring
inc $59
L5F84:
inc $58
lda $58
cmp #$08
bcc L5F40
jsr restore_console_pos
rts
L5F90:
jsr j_primm
.byte $C1,$AD,$CE,$CF,$A0,$C1,$D2,$CD
.byte $CF,$D5,$D2,$00
inc $59
jmp L5F84
L5FA4:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1A
ldy #$00
jsr j_primm_xy
.byte $1E,$C5,$D1,$D5,$C9,$D0,$CD,$C5
.byte $CE,$D4,$1C,$00
jsr L612D
ldy #$08
lda game_stats,y
jsr j_printbcd
jsr j_primm
.byte $AD,$D4,$CF,$D2,$C3,$C8,$C5,$D3
.byte $00
jsr L612D
ldy #$09
lda game_stats,y
jsr j_printbcd
jsr j_primm
.byte $AD,$C7,$C5,$CD,$D3,$00
jsr L612D
ldy #$0A
lda game_stats,y
jsr j_printbcd
jsr j_primm
.byte $AD,$CB,$C5,$D9,$D3,$00
jsr L612D
ldy #$0B
lda game_stats,y
beq L6016
jsr j_printbcd
jsr j_primm
.byte $AD,$D3,$C5,$D8,$D4,$C1,$CE,$D4
.byte $D3,$00
L6016:
jsr restore_console_pos
rts
L601A:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1C
ldy #$00
jsr j_primm_xy
.byte $1E,$C9,$D4,$C5,$CD,$D3,$1C,$00
lda #$00
sta console_ypos
lda $AB0C
beq L605B
sta $58
jsr L612D
jsr j_primm
.byte $D3,$D4,$CF,$CE,$C5,$D3,$BA,$00
ldy #$07
L604A:
rol $58
bcc L6058
sty $59
lda L6134,y
jsr j_console_out
ldy $59
L6058:
dey
bpl L604A
L605B:
lda $AB0D
beq L6082
sta $58
jsr L612D
jsr j_primm
.byte $D2,$D5,$CE,$C5,$D3,$BA,$00
ldy #$07
L6071:
rol $58
bcc L607F
sty $59
lda L613C,y
jsr j_console_out
ldy $59
L607F:
dey
bpl L6071
L6082:
lda $AB0E
beq L60BA
jsr L612D
lda $AB0E
and #$04
beq L609A
jsr j_primm
.byte $C2,$C5,$CC,$CC,$A0,$00
L609A:
lda $AB0E
and #$02
beq L60AA
jsr j_primm
.byte $C2,$CF,$CF,$CB,$A0,$00
L60AA:
lda $AB0E
and #$01
beq L60DD
jsr j_primm
.byte $C3,$C1,$CE,$C4,$CC,$00
L60BA:
lda $AB0F
beq L60F5
jsr L612D
jsr j_primm
.byte $B3,$A0,$D0,$C1,$D2,$D4,$A0,$CB
.byte $C5,$D9,$BA,$00
lda $AB0F
and #$04
beq L60DD
lda #$D4
jsr j_console_out
L60DD:
lda $AB0F
and #$02
beq L60E9
lda #$CC
jsr j_console_out
L60E9:
lda $AB0F
and #$01
beq L60F5
lda #$C3
jsr j_console_out
L60F5:
lda $AB15
beq L6105
jsr L612D
jsr j_primm
.byte $C8,$CF,$D2,$CE,$00
L6105:
lda $AB16
beq L6116
jsr L612D
jsr j_primm
.byte $D7,$C8,$C5,$C5,$CC,$00
L6116:
lda $AB17
beq L6129
bmi L6129
jsr L612D
jsr j_primm
.byte $D3,$CB,$D5,$CC,$CC,$00
L6129:
jsr restore_console_pos
rts
L612D:
inc console_ypos
ldx #$18
stx console_xpos
rts
L6134:
.byte $C2,$D7,$D0,$CF,$C7,$D2,$D9,$C2
L613C:
.byte $C8,$D3,$C8,$D3,$CA,$D6,$C3,$C8
L6144:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1A
ldy #$00
sty $70
jsr j_primm_xy
.byte $1E,$D2,$C5,$C1,$C7,$C5,$CE,$D4
.byte $D3,$1D,$00
L615E:
clc
lda $70
adc #$38
tay
lda game_stats,y
beq L6199
sta $6A
jsr L612D
clc
lda $70
adc #$C1
jsr j_console_out
lda $6A
cmp #$10
bcs L6189
lda #$AD
jsr j_console_out
lda $6A
jsr j_printdigit
jmp L618C
L6189:
jsr j_printbcd
L618C:
lda #$AD
jsr j_console_out
clc
lda $70
adc #$5D
jsr j_printstring
L6199:
inc $70
lda $70
cmp #$08
bcc L615E
jsr restore_console_pos
rts
list_mixtures:
jsr j_clearstatwindow
jsr save_console_pos
ldx #$1A
ldy #$00
sty $58
sty $59
jsr j_primm_xy
.byte $1E,$CD,$C9,$D8,$D4,$D5,$D2,$C5
.byte $D3,$1D,$00
@printlist:
lda $59
lsr a
lsr a
lsr a
ldx #$05
jsr j_mulax
clc
adc #$18
sta console_xpos
cmp #$24
bcs @next
lda $59
and #$07
sta console_ypos
inc console_ypos
ldy $58
lda mixtures,y
beq @next
lda $58
clc
adc #$C1
jsr j_console_out
lda #$AD
jsr j_console_out
ldy $58
lda mixtures,y
jsr j_printbcd
inc $59
@next:
inc $58
lda $58
cmp #$1A
bcc @printlist
jsr restore_console_pos
rts
save_console_pos:
lda console_xpos
sta L621C
lda console_ypos
sta L621D
rts
restore_console_pos:
lda L621C
sta console_xpos
lda L621D
sta console_ypos
rts
L621C:
.byte $00
L621D:
.byte $00
cmd_done:
jsr check_party_alive
lda game_mode
bpl @notcombat
jmp L7133
@notcombat:
lda ship_hull
cmp #$50
bcs @noshipdamage
jsr j_rand
and #$03
bne @noshipdamage
lda ship_hull
sed
clc
adc #$01
cld
sta ship_hull
@noshipdamage:
lda party_size
sta currplayer
@checkstatus:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$D3
bne @checkpoison
jsr j_rand
and #$07
bne @next
lda #$C7
sta (ptr1),y
jmp @next
@checkpoison:
cmp #$D0
bne @next
lda #$02
jsr stat_sub_hp
jsr invert_player_line
lda #$06
jsr j_playsfx
jsr invert_player_line
@next:
dec currplayer
bne @checkstatus
lda party_size
jsr stat_eat_food
bcs @dontstarve
jsr starve
@dontstarve:
jsr party_add_mp
lda movement_mode
bmi @notfastorflying
jsr check_whirlpool_storm
jsr spawn_random_monster
jsr move_creatures
jsr check_whirlpool_storm
@notfastorflying:
lda game_mode
cmp #$03
bne @notdungeon
jsr j_print_direction
jsr dungeon_check_tile
lda tile_under_player
and #$F0
cmp #$D0
bne @notdungeon
jmp dungeon_room
@notdungeon:
lda light_duration
beq @dark
dec light_duration
@dark:
jmp update_counters
check_triggers:
lda game_mode
cmp #$01
bne @notrolls
lda tile_under_player
cmp #$17
bne @notrolls
jsr j_rand
and #$07
bne @notrolls
jsr j_primm
.byte $8D,$C2,$D2,$C9,$C4,$C7,$C5,$A0
.byte $D4,$D2,$CF,$CC,$CC,$D3,$A1,$8D
.byte $00
lda #$A4
sta attacking_monster_type
lda player_xpos
sta attacking_monster_xpos
lda player_ypos
sta attacking_monster_ypos
lda #$17
sta attacking_monster_terrain
jmp generate_combat
@notrolls:
lda movement_mode
bpl L62EF
rts
L62EF:
lda game_mode
bmi L62FC
cmp #$03
beq L6359
lda tile_under_player
jmp L63B9
L62FC:
ldx currplayer
lda $AD9F,x
beq L6356
lda $AD7F,x
sta $16
lda $AD8F,x
sta $17
jsr j_gettile_combat
cmp #$03
beq L632A
cmp #$44
beq L632A
cmp #$46
beq L6324
cmp #$47
beq L6340
cmp #$4C
bne L6356
L6324:
jsr hurt_player_random_val
jmp L6356
L632A:
jsr check_awake
lda (ptr1),y
cmp #$C7
bne L6356
lda #$D0
sta (ptr1),y
jsr flash_player_line
jsr j_update_status
jmp L6356
L6340:
jsr check_awake
bmi L6356
lda #$D3
sta (ptr1),y
ldx currplayer
lda #$38
sta $AD9F,x
jsr flash_player_line
jsr j_update_status
L6356:
jmp L63D0
L6359:
lda tile_under_player
and #$F0
cmp #$A0
bne L6372
lda tile_under_player
and #$03
beq L63D3
cmp #$02
beq L63CD
cmp #$03
bne L63D0
jmp L63FA
L6372:
cmp #$80
bne L63D0
lda tile_under_player
and #$0F
beq L6382
cmp #$08
bcc L6395
bcs L63AC
L6382:
jsr j_primm
.byte $8D,$D7,$C9,$CE,$C4,$D3,$A1,$8D
.byte $00
lda #$00
sta light_duration
jmp L63D0
L6395:
jsr j_primm
.byte $8D,$C6,$C1,$CC,$CC,$C9,$CE,$C7
.byte $A0,$D2,$CF,$C3,$CB,$D3,$A1,$8D
.byte $00
jmp L63CD
L63AC:
jsr j_primm
.byte $8D,$D0,$C9,$D4,$A1,$8D,$00
jmp L63CD
L63B9:
cmp #$03
beq L63D3
cmp #$44
beq L63D3
cmp #$46
beq L63CD
cmp #$47
beq L63FA
cmp #$4C
bne L63D0
L63CD:
jsr hurt_all_players
L63D0:
jmp L641D
L63D3:
lda party_size
sta currplayer
L63D7:
jsr check_awake
lda (ptr1),y
cmp #$C7
bne L641D
jsr j_rand
and #$07
bne L63F3
lda #$D0
ldy #$12
sta (ptr1),y
jsr flash_player_line
jsr j_update_status
L63F3:
dec currplayer
bne L63D7
jmp L641D
L63FA:
lda party_size
sta currplayer
L63FE:
jsr check_awake
bmi L6416
jsr j_rand
and #$03
bne L6416
lda #$D3
ldy #$12
sta (ptr1),y
jsr flash_player_line
jsr j_update_status
L6416:
dec currplayer
bne L63FE
jmp L641D
L641D:
rts
starve:
jsr j_primm
.byte $8D,$D3,$D4,$C1,$D2,$D6,$C9,$CE
.byte $C7,$A1,$A1,$A1,$8D,$00
lda party_size
sta currplayer
@checkplayer:
jsr check_alive
bmi @dead
lda #$02
jsr stat_sub_hp
@dead:
dec currplayer
bne @checkplayer
jsr invert_all_player_lines
lda #$06
jsr j_playsfx
jsr invert_all_player_lines
rts
party_add_mp:
lda party_size
sta currplayer
@next:
jsr check_alive
bmi @done
ldy #$11
lda (ptr1),y
sta $58
ldy #$15
lda (ptr1),y
jsr bcdtohex
asl a
ldx $58
beq @timestwo
dex
beq @timesone
dex
beq @nomp
dex
beq @oneandahalf
dex
beq @onehalf
dex
beq @timesone
dex
beq @timesone
@nomp:
lda #$00
jmp @timestwo
@onehalf:
lsr a
lsr a
jmp @timestwo
@timesone:
lsr a
jmp @timestwo
@oneandahalf:
lsr a
sta $58
lsr a
adc $58
@timestwo:
jsr hextobcd
sta $58
ldy #$16
lda (ptr1),y
cmp $58
bcs @done
sed
clc
adc #$01
cld
sta (ptr1),y
@done:
dec currplayer
bpl @next
rts
.byte $0D,$20,$06,$87,$01,$3E,$31,$0D
.byte $20,$04,$9C,$00,$0D,$20,$06,$87
.byte $01,$3E,$32,$0D,$20,$04,$9C,$00
.byte $0D,$20,$06,$87,$01,$3E,$33,$0D
.byte $20,$06,$86,$01,$3E,$39,$0D,$20
.byte $03,$3B,$0D,$20,$0F,$5E,$30,$20
.byte $20,$20,$20,$20,$20,$CB,$01,$50
.byte $52,$57,$0D,$20,$06,$CA,$01,$3E
.byte $39,$0D,$20,$0F,$5E,$31,$20,$20
.byte $20,$20,$20,$20,$CB,$01,$50,$52
.byte $4E,$0D,$20,$06,$CA,$01,$3E,$39
.byte $0D
stat_eat_food:
sta $58
sed
sec
lda food_frac
sbc $58
sta food_frac
bcs @done
lda food_lo
sbc #$00
sta food_lo
bcs @done
lda food_hi
sbc #$00
sta food_hi
bcs @done
lda #$00
sta food_frac
sta food_lo
sta food_hi
clc
@done:
cld
rts
spawn_random_monster:
lda game_mode
cmp #$01
bne @notbritannia
jmp spawn_monster_britannia
@notbritannia:
cmp #$03
bne @notdngeither
jmp spawn_monster_dungeon
@notdngeither:
rts
spawn_monster_britannia:
jsr j_rand
and #$0F
beq @spawnmonster
jmp @done
@spawnmonster:
lda map_x
asl a
asl a
asl a
asl a
sta $76
lda map_y
asl a
asl a
asl a
asl a
sta $77
sec
lda tile_xpos
sbc #$05
sta $78
sec
lda tile_ypos
sbc #$05
@landcreature:
sta $79
ldx #$03
@checkobjectslot:
lda object_tile,x
bne @notthisslot
jsr j_rand
and #$1F
sta $16
sec
sbc $78
cmp #$0B
bcc @notthisslot
jsr j_rand
and #$1F
sta $17
sec
sbc $79
cmp #$0B
bcc @notthisslot
jsr j_gettile
cmp #$02
bcc @seacreature
cmp #$04
bcc @notthisslot
cmp #$08
bcs @notthisslot
clc
lda $16
adc $76
sta object_xpos,x
clc
lda $17
adc $77
sta object_ypos,x
lda move_counter
bne @maxdaemon
lda move_counter+1
cmp #$01
bcc @maxsnake
beq @maxwisp
cmp #$03
bcs @maxdaemon
@maxwisp:
lda #$07
jmp L65C7
@maxsnake:
lda #$03
jmp L65C7
@maxdaemon:
lda #$0F
L65C7:
sta $58
jsr j_rand
and $58
sta $58
jsr j_rand
and $58
asl a
asl a
adc #$C0
sta object_tile,x
sta map_status,x
@notthisslot:
jmp @nextslot
@seacreature:
jsr j_rand
and #$07
bne @nextslot
clc
lda $16
adc $76
sta object_xpos,x
clc
lda $17
adc $77
sta object_ypos,x
jsr j_rand
and #$07
asl a
adc #$80
cmp #$82
bne @gotcreature
lda #$80
@gotcreature:
sta object_tile,x
sta map_status,x
@nextslot:
dex
bmi @done
jmp @checkobjectslot
@done:
rts
spawn_monster_dungeon:
lda dungeon_level
asl a
asl a
adc #$01
tax
@checkobjectslot:
lda object_tile,x
bne @notthisslot
stx $58
jsr j_rand
and #$07
sta $16
cmp player_xpos
beq @notthisslot
jsr j_rand
and #$07
sta $17
cmp player_ypos
beq @notthisslot
jsr j_gettile_dungeon
bne @notthisslot
jsr j_rand
and #$03
clc
adc dungeon_level
asl a
asl a
adc #$90
cmp #$AC
beq @notthisslot
ldx $58
sta object_tile,x
lda $16
sta object_xpos,x
sta $AC80,x
lda $17
sta object_ypos,x
sta $ACA0,x
lda dungeon_level
sta $ACC0,x
lda object_tile,x
jsr L6A83
ora (ptr1),y
sta (ptr1),y
@notthisslot:
dex
bmi @listfull
txa
lsr a
lsr a
cmp dungeon_level
bcs @checkobjectslot
@listfull:
rts
move_creatures:
lda game_mode
cmp #$01
bne @towne
jmp update_creatures_britannia
@towne:
cmp #$02
bne @dungeon
jmp move_creatures_towne
@dungeon:
cmp #$03
bne @done
jmp move_creatures_dungeon
@done:
rts
update_creatures_britannia:
lda map_x
asl a
asl a
asl a
asl a
sta $76
lda map_y
asl a
asl a
asl a
asl a
sta $77
ldx #$07
@checkcreature:
lda object_tile,x
beq @next
sec
lda object_xpos,x
sbc $76
cmp #$20
bcs @deletecreature
sec
lda object_ypos,x
sbc $77
cmp #$20
bcs @deletecreature
stx $58
jsr @checkaction
ldx $58
jmp @next
@deletecreature:
lda #$00
sta object_tile,x
sta map_status,x
@next:
dex
bpl @checkcreature
rts
@checkaction:
lda object_tile,x
cmp #$8C
beq creature_move
cmp #$8E
beq creature_move
jsr obj_player_distance
cmp #$02
bcs creature_move
creature_attack:
jsr j_idle
jsr j_primm
.byte $8D,$C1,$D4,$D4,$C1,$C3,$CB,$C5
.byte $C4,$A0,$C2,$D9,$8D,$00
jsr print_object_name
ldx $58
lda object_xpos,x
sta $7A
lda object_ypos,x
sta $7B
pla
pla
jmp prepare_combat
creature_move:
cmp #$04
bcs L673A
lda object_tile,x
cmp #$80
beq L671D
jmp L6825
L671D:
lda map_status,x
cmp #$80
beq L6733
cmp #$81
beq L672C
cmp #$82
beq L6733
L672C:
lda $79
bne L673A
jmp L6B80
L6733:
lda $78
bne L673A
jmp L6B80
L673A:
lda object_tile,x
cmp #$80
beq L6744
jmp L6825
L6744:
lda map_status,x
cmp #$80
bne L6751
lda $78
bmi L67A8
bpl L676F
L6751:
cmp #$81
bne L675B
lda $79
bmi L67CA
bpl L676F
L675B:
cmp #$82
bne L6767
lda $78
beq L676F
bpl L67A8
bmi L676F
L6767:
lda $79
beq L676F
bpl L67CA
bmi L676F
L676F:
jsr obj_player_distance
cmp #$06
bcs L67ED
jsr j_rand
and #$03
beq L67ED
lda map_status,x
cmp #$80
bne L678B
lda #$FF
sta $78
jmp L67A8
L678B:
cmp #$81
bne L6796
lda #$FF
sta $79
jmp L67CA
L6796:
cmp #$82
bne L67A1
lda #$01
sta $78
jmp L67A8
L67A1:
lda #$01
sta $79
jmp L67CA
L67A8:
clc
lda object_xpos,x
adc $78
sta $7A
lda object_ypos,x
sta $7B
jsr j_gettile_bounds
jsr L7E1D
bne L6813
lda map_status,x
and #$03
jsr check_wind_direction
bne L67EC
jmp L68D3
L67CA:
clc
lda object_xpos,x
sta $7A
lda object_ypos,x
adc $79
sta $7B
jsr j_gettile_bounds
jsr L7E1D
bne L6813
lda map_status,x
and #$03
jsr check_wind_direction
bne L67EC
jmp L68D3
L67EC:
rts
L67ED:
lda $7A
cmp $7B
bcs L6803
lda $7B
bpl L67FD
lda #$81
sta map_status,x
rts
L67FD:
lda #$83
sta map_status,x
rts
L6803:
lda $7A
bpl L680D
lda #$80
sta map_status,x
rts
L680D:
lda #$82
sta map_status,x
rts
L6813:
jsr j_rand
jsr getsign
clc
adc map_status,x
and #$03
ora #$80
sta map_status,x
rts
L6825:
lda object_tile,x
cmp #$88
beq L6834
cmp #$E8
beq L6834
cmp #$F4
bcc L6853
L6834:
jsr obj_player_distance
lda $7A
jsr getabs
cmp #$05
bcs L6853
lda $7B
jsr getabs
cmp #$05
bcs L6853
jsr j_rand
bmi L6853
jsr L6BA0
ldx $58
L6853:
lda #$02
sta $70
lda object_tile,x
cmp #$8C
beq L68BE
cmp #$8E
beq L68BE
jsr check_evil
bmi L686E
jsr j_rand
and #$03
bne L68BE
L686E:
jsr j_rand
bmi L688C
lda $78
beq L688C
clc
lda object_xpos,x
adc $78
sta $7A
lda object_ypos,x
sta $7B
jsr j_gettile_bounds
jsr L7E1D
beq L68D3
L688C:
lda $79
beq L68A5
lda object_xpos,x
sta $7A
clc
lda object_ypos,x
adc $79
sta $7B
jsr j_gettile_bounds
jsr L7E1D
beq L68D3
L68A5:
lda $78
beq L68BE
clc
lda object_xpos,x
adc $78
sta $7A
lda object_ypos,x
sta $7B
jsr j_gettile_bounds
jsr L7E1D
beq L68D3
L68BE:
jsr j_rand
jsr getsign
sta $78
jsr j_rand
jsr getsign
sta $79
dec $70
bne L686E
rts
L68D3:
lda object_xpos,x
sta $AC80,x
lda object_ypos,x
sta $ACA0,x
lda $7A
sta object_xpos,x
lda $7B
sta object_ypos,x
rts
move_creatures_towne:
cmp #$10
bcc L68EF
rts
L68EF:
ldx #$1F
L68F1:
lda #$02
sta $70
lda object_tile,x
beq L692C
lda $ACC0,x
beq L692C
bmi L6919
jsr j_rand
bmi L692C
L6906:
jsr j_rand
jsr getsign
sta $78
jsr j_rand
jsr getsign
sta $79
jmp L692F
L6919:
jsr L6C5A
cmp #$02
bcs L692F
lda $ACC0,x
cmp #$FF
bne L692F
stx $58
jsr creature_attack
L692C:
jmp L69AB
L692F:
jsr j_rand
bmi L694D
lda $78
beq L694D
clc
lda object_xpos,x
adc $78
sta $7A
lda object_ypos,x
sta $7B
jsr j_gettile_town
jsr L7E1D
beq L6989
L694D:
lda $79
beq L6966
clc
lda object_ypos,x
adc $79
sta $7B
lda object_xpos,x
sta $7A
jsr j_gettile_town
jsr L7E1D
beq L6989
L6966:
clc
lda object_xpos,x
adc $78
sta $7A
lda object_ypos,x
sta $7B
jsr j_gettile_town
jsr L7E1D
beq L6989
lda $ACC0,x
cmp #$80
beq L69AB
dec $70
bmi L69AB
jmp L6906
L6989:
lda $7A
cmp #$20
bcs L69AB
lda $7B
cmp #$20
bcs L69AB
lda object_xpos,x
sta $AC80,x
lda object_ypos,x
sta $ACA0,x
lda $7A
sta object_xpos,x
lda $7B
sta object_ypos,x
L69AB:
dex
bmi L69B1
jmp L68F1
L69B1:
rts
move_creatures_dungeon:
ldx #$1F
L69B4:
lda object_tile,x
beq L69D2
lda $ACC0,x
cmp dungeon_level
bne L69D2
lda object_tile,x
cmp #$AC
beq L69D2
cmp #$B0
beq L69D2
lda #$07
sta $70
jmp L69D5
L69D2:
jmp L6A79
L69D5:
lda object_xpos,x
cmp player_xpos
bne L69E3
lda object_ypos,x
cmp player_ypos
beq L69D2
L69E3:
jsr j_rand
jsr getsign
sta $78
jsr j_rand
jsr getsign
sta $79
jsr j_rand
bmi L6A11
lda $78
beq L6A11
clc
adc object_xpos,x
and #$07
sta $16
lda object_ypos,x
sta $17
jsr j_gettile_dungeon
jsr L7FB0
beq L6A48
L6A11:
lda $79
beq L6A2A
clc
adc object_ypos,x
and #$07
sta $17
lda object_xpos,x
sta $16
jsr j_gettile_dungeon
jsr L7FB0
beq L6A48
L6A2A:
clc
lda object_xpos,x
adc $78
and #$07
sta $16
lda object_ypos,x
sta $17
jsr j_gettile_dungeon
jsr L7FB0
beq L6A48
dec $70
bpl L69E3
jmp L6A79
L6A48:
lda object_tile,x
jsr L6A83
ora (ptr1),y
sta (ptr1),y
lda object_xpos,x
sta $AC80,x
lda object_ypos,x
sta $ACA0,x
lda $16
sta object_xpos,x
lda $17
sta object_ypos,x
lda $AC80,x
sta $16
lda $ACA0,x
sta $17
jsr j_gettile_dungeon
and #$F0
sta (ptr1),y
L6A79:
dex
bmi L6A7F
jmp L69B4
L6A7F:
jsr L8C00
rts
L6A83:
sec
sbc #$90
lsr a
lsr a
clc
adc #$01
ldy #$00
rts
.byte $FF
brk
ora ($00,x)
brk
.byte $FF
brk
.byte $01
check_wind_direction:
cmp direction
beq L6AAB
clc
adc #$02
and #$03
cmp direction
bne L6AB4
lda $69
and #$03
bne L6AB4
beq L6AB1
L6AAB:
lda $69
and #$03
beq L6AB4
L6AB1:
lda #$FF
rts
L6AB4:
lda #$00
rts
check_whirlpool_storm:
lda game_mode
cmp #$01
beq @britannia
rts
@britannia:
ldx #$03
@checkobject:
lda object_tile,x
cmp #$8C
beq @whirlpool
cmp #$8E
beq @storm
@checknext:
dex
bpl @checkobject
rts
@whirlpool:
lda #$0B
sta $5B
lda object_xpos,x
cmp player_xpos
bne @slurpobjects
lda object_ypos,x
cmp player_ypos
bne @slurpobjects
jsr @go_to_locke_lake
@slurpobjects:
ldy #$1F
@checkslurp:
stx $58
cpy $58
beq @slurpnext
lda object_tile,y
beq @slurpnext
lda object_xpos,x
cmp object_xpos,y
bne @slurpnext
lda object_ypos,x
cmp object_ypos,y
bne @slurpnext
lda #$00
sta object_tile,y
sta map_status,y
stx $58
sty $59
jsr j_idle
lda $5B
jsr j_playsfx
ldx $58
ldy $59
@slurpnext:
dey
bpl @checkslurp
jmp @checknext
@storm:
lda #$0C
sta $5B
lda object_xpos,x
cmp player_xpos
bne @slurpobjects
lda object_ypos,x
cmp player_ypos
bne @slurpobjects
jsr @storm_damage
jmp @slurpobjects
@go_to_locke_lake:
stx $58
jsr j_idle
lda #$8C
sta player_transport
jsr j_idle
lda #$7F
sta player_xpos
lda #$4E
sta player_ypos
lda #$0B
jsr j_playsfx
jsr hurt_all_players
ldx $58
lda #$10
sta player_transport
jsr j_player_teleport
rts
@storm_damage:
stx $58
lda player_transport
pha
lda #$8E
sta player_transport
jsr j_idle
lda #$0C
jsr j_playsfx
jsr hurt_all_players
jsr hurt_all_players
jsr hurt_all_players
jsr hurt_all_players
pla
sta player_transport
ldx $58
rts
L6B80:
lda #$4D
sta missile
jsr L6BC0
bpl L6B8B
rts
L6B8B:
jsr L0887
pha
lda #$4F
sta (ptr1),y
jsr j_animate_view
jsr hurt_all_players
jsr L0887
pla
sta (ptr1),y
rts
L6BA0:
lda #$4F
sta missile
jsr L6BC0
bpl L6BAB
rts
L6BAB:
jsr L0887
pha
lda #$4F
sta (ptr1),y
jsr j_animate_view
jsr hurt_all_players
jsr L0887
pla
sta (ptr1),y
rts
L6BC0:
lda #$03
sta $6A
lda object_xpos,x
sta $7A
lda object_ypos,x
sta $7B
jsr j_idle
lda #$03
jsr j_playsfx
L6BD6:
clc
lda $7A
adc $78
sta $7A
clc
lda $7B
adc $79
sta $7B
cmp player_ypos
bne L6BF1
lda $7A
cmp player_xpos
bne L6BF1
lda #$00
rts
L6BF1:
jsr find_target
bpl L6C0F
jsr L0887
pha
lda missile
sta (ptr1),y
jsr j_animate_view
jsr L0887
pla
sta (ptr1),y
dec $6A
bne L6BD6
lda #$FF
rts
L6C0F:
stx $59
lda #$06
jsr j_playsfx
ldx $59
cpx #$08
bcs L6C23
jsr j_rand
and #$03
bne L6C2B
L6C23:
lda #$00
sta object_tile,x
sta map_status,x
L6C2B:
lda #$FF
rts
obj_player_distance:
sec
lda player_xpos
sbc object_xpos,x
sta $7A
jsr getsign
sta $78
sec
lda player_ypos
sbc object_ypos,x
sta $7B
jsr getsign
sta $79
lda $7A
jsr getabs
sta $59
lda $7B
jsr getabs
clc
adc $59
sta $59
rts
L6C5A:
sec
lda player_xpos
sbc object_xpos,x
sta $7A
jsr getsign
sta $78
sec
lda player_ypos
sbc object_ypos,x
sta $7B
jsr getsign
sta $79
lda $7A
jsr getabs
sta $59
lda $7B
jsr getabs
clc
adc $59
sta $59
rts
update_counters:
inc $69
sed
clc
lda move_counter+3
adc #$01
sta move_counter+3
lda move_counter+2
adc #$00
sta move_counter+2
lda move_counter+1
adc #$00
sta move_counter+1
lda move_counter
adc #$00
sta move_counter
cld
lda aura_duration
beq @skipaura
dec aura_duration
bne @skipaura
lda #$25
sta magic_aura
@skipaura:
lda game_mode
cmp #$03
bne @skiplight
lda light_duration
bne @skiplight
jsr j_primm
.byte $C9,$D4,$A7,$D3,$A0,$C4,$C1,$D2
.byte $CB,$A1,$8D,$00
@skiplight:
jsr j_update_status
jsr update_door
jmp game_main
camp_ambushed:
ldx #$00
lda #$00
@clear:
sta monster_xpos,x
inx
bne @clear
lda #$01
sta currplayer
lda game_mode
sta game_mode_temp
lda #$82
sta game_mode
lda #$C8
sta attacking_monster_type
sta monster_type
lda #$C1
jmp combat_start
dungeon_check_tile:
lda tile_under_player
and #$0F
beq @nothinghere
lda tile_under_player
and #$F0
cmp #$80
beq @nothinghere
cmp #$90
beq @nothinghere
cmp #$A0
beq @nothinghere
cmp #$D0
beq @nothinghere
cmp #$F0
beq @nothinghere
lda tile_under_player
and #$0F
asl a
asl a
adc #$8C
sta attacking_monster_type
sta monster_type
lda player_xpos
sta $16
lda player_ypos
sta $17
jsr j_gettile_dungeon
and #$F0
sta (ptr1),y
ldx #$1F
@check:
lda $ACC0,x
cmp dungeon_level
bne @next
lda object_xpos,x
cmp player_xpos
bne @next
lda object_ypos,x
cmp player_ypos
bne @next
lda #$00
sta $ACC0,x
sta object_tile,x
sta object_xpos,x
sta object_ypos,x
jmp @attacked
@next:
dex
bpl @check
@attacked:
ldx #$00
txa
@clear:
sta monster_xpos,x
dex
bne @clear
pla
pla
lda tile_under_player
lsr a
lsr a
lsr a
lsr a
tax
lda @dungeon_combat_map,x
jmp combat_start
@nothinghere:
rts
@dungeon_combat_map:
.byte $B0,$B1,$B2,$B3,$B4,$B0,$B0,$B0
.byte $B0,$B0,$B0,$B0,$B5,$B0,$B6,$B0
dungeon_room:
lda #$00
jsr music_ctl
sec
lda current_location
sbc #$11
sta lt_y
cmp #$07
bne L6D97
lda dungeon_level
lsr a
clc
adc lt_y
sta lt_y
L6D97:
lda tile_under_player
and #$0F
sta lt_x
lda #$01
sta lt_rwflag
lda #$AE
sta lt_addr_hi
jsr j_loadsector
lda game_mode
sta game_mode_temp
lda #$81
sta game_mode
lda #$00
sta L7982
sta L7983
ldx #$FF
lda lt_x
cmp #$0F
bne L6E0E
lda lt_y
cmp #$07
bcs L6E0E
jsr j_primm
.byte $8D,$D4,$C8,$C5,$A0,$C1,$CC,$D4
.byte $C5,$D2,$A0,$D2,$CF,$CF,$CD,$8D
.byte $CF,$C6,$A0,$00
lda player_xpos
cmp #$03
beq L6DF3
bcs L6E00
jsr j_primm
.byte $D4,$D2,$D5,$D4,$C8,$8D,$00
ldx #$00
beq L6E0E
L6DF3:
jsr j_primm
.byte $CC,$CF,$D6,$C5,$8D,$00
ldx #$01
bne L6E0E
L6E00:
jsr j_primm
.byte $C3,$CF,$D5,$D2,$C1,$C7,$C5,$8D
.byte $00
ldx #$02
L6E0E:
stx $28
lda #$00
tax
L6E13:
sta monster_xpos,x
inx
bne L6E13
ldx #$0F
L6E1B:
lda currmap,x
sta $AF10,x
dex
bpl L6E1B
lda dng_direction
eor #$02
asl a
asl a
asl a
asl a
sta $58
lda party_size
sta currplayer
L6E32:
jsr something_based_on_status_and_class
bmi L6E57
pha
clc
lda currplayer
adc $58
tay
dey
pla
ldx currplayer
dex
sta player_tile,x
lda currmap+64,y
sta cbt_player_xpos,x
lda currmap+72,y
sta cbt_player_ypos,x
jsr check_alive
beq L6E5E
L6E57:
ldx currplayer
lda #$00
sta $AD9F,x
L6E5E:
dec currplayer
bne L6E32
ldx #$0F
L6E64:
lda currmap+16,x
beq L6E9D
sta cbt_monster_type,x
sta monster_tile,x
lda currmap+32,x
sta monster_xpos,x
lda currmap+48,x
sta monster_ypos,x
lda cbt_monster_type,x
jsr get_creature_type
tay
lda monster_xp,y
sta $58
jsr randmax
lsr $58
ora $58
sta monster_hp,x
lda cbt_monster_type,x
cmp #$AC
bne L6E9D
lda #$3C
sta monster_tile,x
L6E9D:
dex
bpl L6E64
jmp L7091
generate_combat:
jsr j_primm
.byte $8D,$8D,$AA,$AA,$AA,$AA,$A0,$C3
.byte $CF,$CD,$C2,$C1,$D4,$A0,$AA,$AA
.byte $AA,$AA,$8D,$8D,$00
lda attacking_monster_type
sta monster_type
ldx #$00
txa
@clear:
sta monster_xpos,x
dex
bne @clear
lda player_transport
cmp #$14
bcc @ship
lda tile_under_player
cmp #$14
bcs @onland
cmp #$10
bcc @onland
@ship:
lda attacking_monster_type
cmp #$80
bne @notpirates
lda #$C8
sta monster_type
lda #$D4
jmp combat_start
@notpirates:
lda attacking_monster_terrain
cmp #$03
bcc @seamonster
lda #$C5
jmp combat_start
@seamonster:
lda #$D0
jmp combat_start
@onland:
lda attacking_monster_type
cmp #$80
bne @notpirates2
lda #$C8
sta monster_type
lda #$C9
jmp combat_start
@notpirates2:
lda attacking_monster_terrain
cmp #$03
bcs @swamp
lda #$CF
jmp combat_start
@swamp:
lda tile_under_player
cmp #$03
bne @forest
lda #$D3
jmp combat_start
@forest:
cmp #$05
bne @deepforest
lda #$C2
jmp combat_start
@deepforest:
cmp #$06
bne @mountains
lda #$C6
jmp combat_start
@mountains:
cmp #$07
bne @flagstones
lda #$C8
jmp combat_start
@flagstones:
cmp #$16
bne @brick
lda #$C4
jmp combat_start
@brick:
cmp #$3E
bne @towneorbridge
lda #$C3
jmp combat_start
@towneorbridge:
cmp #$17
beq @bridgeorwood
cmp #$19
beq @bridgeorwood
cmp #$1A
beq @bridgeorwood
cmp #$3F
bne @other
@bridgeorwood:
lda #$D2
jmp combat_start
@other:
lda #$C7
jmp combat_start
get_combat_map:
stx @savex
ldx #$15
@next:
cmp @combat_map,x
beq @gotmap
dex
bpl @next
@gotmap:
txa
ldx @savex
rts
@combat_map:
.byte $C2,$C6,$C7,$C8,$CF,$D2,$D3,$C3
.byte $C4,$C1,$C5,$C9,$D0,$D4,$D8,$B0
.byte $B1,$B2,$B3,$B4,$B5,$B6
@savex:
.byte $A7
combat_start:
jsr get_combat_map
pha
lda #$00
jsr music_ctl
pla
clc
adc #$01
tax
lda #$CC
jsr j_fileio
dungeon_combat_start:
lda game_mode
cmp #$82
beq @towne
sta game_mode_temp
lda #$80
sta game_mode
@towne:
lda game_mode_temp
cmp #$02
bne @t
lda game_mode
cmp #$82
beq @t
lda attacking_monster_type
cmp #$50
beq @guards
lda #$00
jmp @checksize
@guards:
lda party_size
asl a
sec
sbc #$01
jmp @checksize
@t: lda monster_type
bmi @monster
jsr j_rand
and #$07
bne @checksize
@monster:
jsr get_creature_type
tax
lda L7D4E,x
jsr randmax
clc
adc L7D4E,x
lsr a
@checksize:
sta $6A
sta L7D72
lsr a
cmp party_size
bcc @placemonsters
lda party_size
asl a
jsr randmax
jmp @checksize
@placemonsters:
jsr j_rand
and #$0F
tax
lda monster_xpos,x
bne @placemonsters
lda currmap+64,x
sta monster_xpos,x
lda currmap+80,x
sta monster_ypos,x
lda monster_type
bpl L7043
lda $6A
beq L7022
jsr j_rand
and #$1F
beq L7033
and #$07
beq L7027
L7022:
lda monster_type
jmp L7043
L7027:
lda monster_type
jsr get_creature_type
tay
lda L7D2A,y
jmp L7043
L7033:
lda monster_type
jsr get_creature_type
tay
lda L7D2A,y
jsr get_creature_type
tay
lda L7D2A,y
L7043:
sta cbt_monster_type,x
sta monster_tile,x
jsr get_creature_type
tay
lda monster_xp,y
sta $58
jsr randmax
lsr $58
ora $58
sta monster_hp,x
dec $6A
bpl @placemonsters
lda game_mode
cmp #$82
beq L706A
lda party_size
sta currplayer
L706A:
jsr something_based_on_status_and_class
bmi L7086
ldx currplayer
dex
sta player_tile,x
lda currmap+96,x
sta cbt_player_xpos,x
lda currmap+104,x
sta cbt_player_ypos,x
jsr check_alive
beq L708D
L7086:
ldx currplayer
lda #$00
sta $AD9F,x
L708D:
dec currplayer
bne L706A
L7091:
lda #$02
jsr music_ctl
jsr j_clearkbd
lda #$00
sta key_buf_len
L709D:
lda #$01
sta currplayer
sta $45
L70A3:
jsr check_alive
beq L70B7
ldx currplayer
lda $AD9F,x
beq L70B4
lda #$00
sta $AD9F,x
L70B4:
jmp L714E
L70B7:
ldx currplayer
lda $AD9F,x
beq L70B4
cmp #$38
beq L70B4
jsr j_idle
jsr invert_player_line
jsr printcr
jsr j_printname
jsr j_primm
.byte $8D,$D7,$BA,$00
jsr j_get_stats_ptr
ldy #$1E
lda (ptr1),y
sta L7C74
clc
adc #$25
jsr j_printstring
jsr j_primm
.byte $8D,$1E,$00
jsr j_waitkey
bne L70F3
jmp cmd_pass
L70F3:
cmp #$A0
bne L70FA
jmp cmd_pass
L70FA:
cmp #$C0
bne L7101
jmp L77CE
L7101:
cmp #$AF
bne L7108
jmp L77E9
L7108:
cmp #$BA
bne L710F
jmp L781E
L710F:
cmp #$BB
bne L7116
jmp L7804
L7116:
cmp #$C1
bcc L7130
cmp #$DB
bcs L7130
sec
sbc #$C1
asl a
tay
lda L779A,y
sta ptr1
lda L779B,y
sta ptr1+1
jmp (ptr1)
L7130:
jmp cmd_unknown
L7133:
lda $45
sta currplayer
jsr invert_player_line
jsr check_triggers
jsr j_update_status
lda magic_aura
cmp #$D1
bne L714E
jsr j_rand
bmi L714E
jmp L70A3
L714E:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$D3
bne L716C
jsr j_rand
and #$07
bne L716C
lda #$C7
sta (ptr1),y
jsr something_based_on_status_and_class
ldx currplayer
sta $AD9F,x
L716C:
jsr L7514
inc currplayer
inc $45
lda currplayer
cmp party_size
bcc L717E
beq L717E
jmp L7181
L717E:
jmp L70A3
L7181:
lda #$00
sta $45
jsr j_idle
lda #$0F
sta $6A
L718C:
ldx $6A
lda cbt_monster_type,x
bne L7196
jmp L7422
L7196:
lda $AD70,x
beq L71AA
jsr j_rand
and #$07
beq L71A5
jmp L73C4
L71A5:
lda #$00
sta $AD70,x
L71AA:
lda cbt_monster_type,x
cmp #$EC
bne L71BC
lda #$CE
sta magic_aura
lda #$02
sta aura_duration
jmp L71EC
L71BC:
cmp #$DC
bne L71EC
jsr j_rand
and #$07
bne L71EC
L71C7:
lda #$0B
jsr randmax
sta $16
lda #$0B
jsr randmax
sta $17
jsr j_gettile_combat
jsr L7EEA
bmi L71C7
ldx $6A
lda $16
sta monster_xpos,x
lda $17
sta monster_ypos,x
jmp L73C4
L71EC:
lda monster_xpos,x
sta $7A
lda monster_ypos,x
sta $7B
lda party_size
sta currplayer
lda #$FF
sta $5B
lda #$00
sta $55
L7202:
jsr check_alive
bne L7230
ldx currplayer
dex
lda player_tile,x
beq L7230
sec
lda cbt_player_xpos,x
sbc $7A
jsr getabs
sta zptmp1
sec
lda cbt_player_ypos,x
sbc $7B
jsr getabs
clc
adc zptmp1
cmp $5B
bcs L7230
sta $5B
lda currplayer
sta $55
L7230:
dec currplayer
bne L7202
lda $55
bne L723B
jmp L73C4
L723B:
sta currplayer
tax
dex
sec
lda cbt_player_xpos,x
sbc $7A
jsr getsign
sta $78
sec
lda cbt_player_ypos,x
sbc $7B
jsr getsign
sta $79
ldx $6A
lda cbt_monster_type,x
cmp #$AC
bne L726E
lda #$3C
sta monster_tile,x
lda $5B
cmp #$05
bcs L7290
lda #$AC
sta monster_tile,x
L726E:
jsr j_rand
and #$03
bne L7290
lda cbt_monster_type,x
jsr L8036
beq L7290
cmp #$4E
bne L7287
ldy magic_aura
cpy #$CE
beq L7290
L7287:
jsr L80B1
jsr j_idle
jmp L73C4
L7290:
jsr j_rand
and #$03
bne L72E7
ldx $6A
lda cbt_monster_type,x
cmp #$FC
beq L72A4
cmp #$B0
bne L72E7
L72A4:
lda magic_aura
cmp #$CE
beq L72E7
jsr j_idle
jsr j_invertview
ldx #$80
lda #$09
jsr j_playsfx
jsr j_invertview
lda #$08
sta currplayer
L72BE:
ldx currplayer
lda $AD9F,x
beq L72E0
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C7
bne L72E0
jsr j_rand
bmi L72E0
lda #$D3
sta (ptr1),y
lda #$38
ldx currplayer
sta $AD9F,x
L72E0:
dec currplayer
bne L72BE
jmp L73C4
L72E7:
ldx $6A
lda monster_hp,x
cmp #$18
bcs L7301
lda $78
jsr L8281
sta $78
lda $79
jsr L8281
sta $79
jmp L7320
L7301:
lda $5B
cmp #$02
bcs L7320
ldx $6A
lda cbt_monster_type,x
cmp #$A8
bne L7316
jsr L74CF
jmp L731D
L7316:
cmp #$C8
bne L731D
jsr L74DD
L731D:
jmp L76FD
L7320:
ldx $6A
lda cbt_monster_type,x
cmp #$AC
bne L732C
jmp L73C4
L732C:
cmp #$B0
bne L7333
jmp L73C4
L7333:
lda #$02
sta $70
L7337:
jsr j_rand
bmi L7354
lda $78
beq L7354
clc
adc $7A
sta $16
lda $7B
sta $17
jsr L746C
jsr L088A
jsr L7EEA
beq L73A1
L7354:
lda $79
beq L736C
clc
adc $7B
sta $17
lda $7A
sta $16
jsr L746C
jsr L088A
jsr L7EEA
beq L73A1
L736C:
lda $78
beq L7384
clc
adc $7A
sta $16
lda $7B
sta $17
jsr L746C
jsr L088A
jsr L7EEA
beq L73A1
L7384:
jsr j_rand
jsr getsign
sta $78
jsr j_rand
jsr getsign
sta $79
dec $70
bne L7337
lda $5B
cmp #$02
bcs L73C4
jmp L76FD
L73A1:
ldx $6A
lda monster_xpos,x
sta $AD20,x
lda monster_ypos,x
sta $AD30,x
lda $16
cmp #$0B
bcs L742C
sta monster_xpos,x
lda $17
cmp #$0B
bcs L742C
sta monster_ypos,x
jsr j_idle_combat
L73C4:
lda #$00
sta currplayer
ldx $6A
lda monster_xpos,x
sta $16
lda monster_ypos,x
sta $17
jsr j_gettile_combat
ldx $6A
cmp #$44
beq L7413
cmp #$46
beq L7408
cmp #$47
beq L73EB
cmp #$4C
beq L7408
bne L7422
L73EB:
lda cbt_monster_type,x
jsr L4ECD
beq L7422
jsr j_rand
cmp monster_hp,x
bcc L7422
lda #$01
sta $AD70,x
lda #$06
jsr j_playsfx
jmp L7422
L7408:
lda cbt_monster_type,x
cmp #$E8
beq L7422
cmp #$F0
bcs L7422
L7413:
jsr j_rand
and #$7F
sta $5C
lda #$06
jsr j_playsfx
jsr hurt_monster
L7422:
dec $6A
bmi L7429
jmp L718C
L7429:
jmp L74B2
L742C:
jsr printcr
ldx $6A
lda cbt_monster_type,x
jsr print_creature_name
jsr j_primm
.byte $C6,$CC,$C5,$C5,$D3,$A1,$8D,$00
ldx $6A
lda cbt_monster_type,x
jsr check_evil
bmi L745A
ldy #$01
lda #$01
jsr virtue_inc
ldy #$03
lda #$01
jsr virtue_inc
L745A:
lda #$00
ldx $6A
sta cbt_monster_type,x
sta monster_hp,x
lda #$08
jsr j_playsfx
jmp L73C4
L746C:
lda magic_aura
cmp #$CA
beq L7473
rts
L7473:
lda $6A
pha
jsr combat_find_monster
bmi L74AE
lda #$4F
sta missile
lda $16
sta missile_xpos
lda $17
sta missile_ypos
jsr j_idle_combat
lda #$06
jsr j_playsfx
lda #$00
sta missile
sta currplayer
jsr j_rand
and #$3F
sta $5C
jsr hurt_monster
jsr j_idle_combat
pla
sta $6A
pla
pla
jmp L73C4
L74AE:
pla
sta $6A
rts
L74B2:
jsr party_add_mp
jsr j_idle_combat
inc $69
jsr L7514
lda aura_duration
beq L74C9
dec aura_duration
bne L74C9
lda #$25
sta magic_aura
L74C9:
jsr j_update_status
jmp L709D
L74CF:
lda #$25
jsr stat_eat_food
jsr j_update_status
lda #$08
jsr j_playsfx
rts
L74DD:
jsr j_rand
and #$03
bne L7513
jsr j_rand
and #$3F
jsr hextobcd
sta $58
sed
sec
lda gold+1
sbc $58
sta gold+1
lda gold
sbc #$00
sta gold
bcs L750A
lda #$00
sta gold+1
sta gold
L750A:
cld
lda #$08
jsr j_playsfx
jsr j_update_status
L7513:
rts
L7514:
lda game_mode
cmp #$81
beq L7529
ldx #$0F
L751C:
lda cbt_monster_type,x
bne L7529
dex
bpl L751C
pla
pla
jmp L75FF
L7529:
ldx #$07
L752B:
lda player_tile,x
bne L7538
dex
bpl L752B
pla
pla
jmp L7539
L7538:
rts
L7539:
lda game_mode
cmp #$81
beq L7576
lda attacking_monster_type
jsr check_evil
bpl L7565
jsr j_primm
.byte $8D,$C2,$C1,$D4,$D4,$CC,$C5,$A0
.byte $C9,$D3,$A0,$CC,$CF,$D3,$D4,$A1
.byte $8D,$00
ldy #$02
lda #$02
jsr virtue_dec
jmp L76D6
L7565:
ldy #$01
lda #$02
jsr virtue_inc
ldy #$03
lda #$02
jsr virtue_inc
jmp L76D6
L7576:
jsr j_primm
.byte $8D,$CC,$C5,$C1,$D6,$C5,$A0,$D2
.byte $CF,$CF,$CD,$A1,$8D,$00
lda L7982
beq L7598
bpl L7593
lda #$03
jmp L75A4
L7593:
lda #$01
jmp L75A4
L7598:
lda L7983
bpl L75A2
lda #$00
jmp L75A4
L75A2:
lda #$02
L75A4:
sta dng_direction
lda game_mode_temp
sta game_mode
lda $28
bmi L75E1
asl a
asl a
clc
adc dng_direction
tay
lda L75F3,y
sta current_location
tay
dey
lda L519A,y
sta $18
lda L51BA,y
sta $19
lda #$00
jsr music_ctl
jsr @loaddungeon
jsr j_primm
.byte $C9,$CE,$D4,$CF,$A0,$C4,$D5,$CE
.byte $C7,$C5,$CF,$CE,$8D,$00
jsr print_location_name
L75E1:
jsr printcr
lda #$01
jsr music_ctl
lda dng_direction
tax
lda #$00
sta key_buf_len
jmp dng_move
L75F3:
.byte $11,$16,$17,$14,$12,$14,$17,$15
.byte $13,$15,$17,$16
L75FF:
jsr j_primm
.byte $8D,$D6,$C9,$C3,$D4,$CF,$D2,$D9
.byte $A1,$8D,$00
lda attacking_monster_type
jsr check_evil
bpl L761E
ldy #$02
jsr j_rand
and #$01
jsr virtue_inc
L761E:
lda game_mode
cmp #$82
bne L7627
jmp L76D6
L7627:
lda game_mode_temp
cmp #$03
beq L7696
lda attacking_monster_type
cmp #$90
bcs L7649
cmp #$80
beq L767E
cmp #$20
bcc L7693
cmp #$60
bcs L7693
cmp #$30
bcc L7649
cmp #$50
bcs L7649
bcc L7693
L7649:
cmp #$94
beq L7693
cmp #$A0
beq L7693
cmp #$B8
beq L7693
cmp #$B4
beq L7693
cmp #$DC
beq L7693
lda attacking_monster_terrain
jsr j_blocked_tile
bmi L7693
bcc L7693
jsr L76B8
lda attacking_monster_xpos
sta object_xpos,x
lda attacking_monster_ypos
sta object_ypos,x
lda #$3C
sta object_tile,x
sta map_status,x
jmp L76D6
L767E:
jsr L76B8
lda attacking_monster_xpos
sta object_xpos,x
lda attacking_monster_ypos
sta object_ypos,x
lda #$10
sta object_tile,x
sta map_status,x
L7693:
jmp L76D6
L7696:
lda attacking_monster_type
cmp #$94
beq L7693
cmp #$B4
beq L7693
cmp #$A0
beq L7693
lda player_xpos
sta $16
lda player_ypos
sta $17
jsr j_gettile_dungeon
bne L7693
lda #$40
sta (ptr1),y
jmp L76D6
L76B8:
ldx #$1F
L76BA:
lda object_tile,x
beq L76D5
dex
bmi L76CC
lda game_mode_temp
cmp #$01
bne L76BA
cpx #$08
bcs L76BA
L76CC:
lda #$18
jsr randmax
clc
adc #$08
tax
L76D5:
rts
L76D6:
lda game_mode
cmp #$82
beq L76F3
lda game_mode_temp
sta game_mode
cmp #$03
bne L76E7
jsr L8C06
L76E7:
lda #$01
jsr music_ctl
lda #$00
sta key_buf_len
jmp cmd_done
L76F3:
lda game_mode_temp
sta game_mode
lda #$01
jsr music_ctl
rts
L76FD:
ldx currplayer
lda $AD7F,x
sta missile_xpos
lda $AD8F,x
sta missile_ypos
lda #$4D
sta missile
jsr j_idle_combat
lda #$05
jsr j_playsfx
lda #$00
sta missile
lda magic_aura
cmp #$D0
bne L7728
jsr j_rand
bmi L773C
L7728:
jsr j_get_stats_ptr
lda #$1F
lda (ptr1),y
tax
lda L7D83,x
sta zptmp1
jsr j_rand
cmp zptmp1
bcs L7742
L773C:
jsr j_idle_combat
jmp L73C4
L7742:
jsr L7748
jmp L73C4
L7748:
lda #$4F
sta missile
jsr invert_player_line
jsr j_idle_combat
lda #$07
jsr j_playsfx
lda #$00
sta missile
jsr j_idle_combat
ldx $6A
lda cbt_monster_type,x
jsr get_creature_type
tax
lda monster_xp,x
lsr a
lsr a
jsr randmax
jsr hextobcd
jsr stat_sub_hp
bne L7793
jsr j_printname
jsr j_primm
.byte $8D,$C9,$D3,$A0,$CB,$C9,$CC,$CC
.byte $C5,$C4,$A1,$8D,$00
ldy #$04
lda #$01
jsr virtue_inc
L7793:
jsr invert_player_line
jsr j_update_status
rts
L779A:
.byte $84
L779B:
adc cmd_unknown,y
.byte $77
.byte $7C
.byte $12
eor (tile_xpos,x)
eor (tile_xpos,x)
eor ($84,x)
.byte $7C
.byte $12
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor (tile_xpos,x)
eor ($CB,x)
.byte $7C
.byte $12
eor (tile_xpos,x)
eor ($F4,x)
.byte $5A
.byte $22
.byte $5B
.byte $12
eor (tile_xpos,x)
eor (tile_xpos,x)
eor ($E0,x)
.byte $7C
L77CE:
jsr j_primm
.byte $CE,$EF,$F2,$F4,$E8,$8D,$00
ldx currplayer
dex
lda cbt_player_xpos,x
sta $16
ldy cbt_player_ypos,x
dey
sty $17
jmp L7838
L77E9:
jsr j_primm
.byte $D3,$EF,$F5,$F4,$E8,$8D,$00
ldx currplayer
dex
lda cbt_player_xpos,x
sta $16
ldy cbt_player_ypos,x
iny
sty $17
jmp L7838
L7804:
jsr j_primm
.byte $C5,$E1,$F3,$F4,$8D,$00
ldx currplayer
dex
lda cbt_player_ypos,x
sta $17
ldy cbt_player_xpos,x
iny
sty $16
jmp L7838
L781E:
jsr j_primm
.byte $D7,$E5,$F3,$F4,$8D,$00
ldx currplayer
dex
lda cbt_player_ypos,x
sta $17
ldy cbt_player_xpos,x
dey
sty $16
jmp L7838
L7838:
lda #$00
jsr j_playsfx
lda $16
cmp #$0B
bcc L7846
jmp L78E8
L7846:
lda $17
cmp #$0B
bcc L784F
jmp L78E8
L784F:
jsr L088A
jsr j_blocked_tile
bpl L785A
jmp move_blocked
L785A:
jsr L088A
jsr check_slow_progress
beq L7868
jsr print_slow_progress
jmp L7133
L7868:
ldx currplayer
dex
lda $16
sta cbt_player_xpos,x
lda $17
sta cbt_player_ypos,x
lda #$00
jsr j_playsfx
lda game_mode
cmp #$81
bne L78C7
ldx #$00
stx $58
L7884:
lda $AF10,x
beq L78BB
lda $AF11,x
beq L78BB
lsr a
lsr a
lsr a
lsr a
cmp $16
bne L78BB
lda $AF11,x
and #$0F
cmp $17
bne L78BB
lda $AF12,x
beq L78AD
jsr L78CA
lda $AF10,x
sta tempmap,y
L78AD:
lda $AF13,x
beq L78BB
jsr L78CA
lda $AF10,x
sta tempmap,y
L78BB:
lda $58
clc
adc #$04
sta $58
tax
cmp #$10
bcc L7884
L78C7:
jmp L7133
L78CA:
pha
lsr a
lsr a
lsr a
lsr a
sta $59
pla
and #$0F
tay
lda L78DD,y
clc
adc $59
tay
rts
L78DD:
.byte $00,$0B,$16,$21,$2C,$37,$42,$4D
.byte $58,$63,$6E
L78E8:
lda game_mode
cmp #$81
bne L7942
lda L7982
bne L790C
lda L7983
bne L7912
lda $16
cmp #$0B
bcc L7904
sta L7982
jmp L7942
L7904:
lda $17
sta L7983
jmp L7942
L790C:
cmp $16
beq L7942
bne L7918
L7912:
cmp $17
beq L7942
bne L7918
L7918:
pla
pla
jsr j_primm
.byte $C1,$CC,$CC,$A0,$CD,$D5,$D3,$D4
.byte $A0,$D5,$D3,$C5,$8D,$D4,$C8,$C5
.byte $A0,$D3,$C1,$CD,$C5,$A0,$C5,$D8
.byte $C9,$D4,$A1,$8D,$00
lda #$01
jsr j_playsfx
jmp L7133
L7942:
ldx currplayer
dex
lda #$80
sta cbt_player_xpos,x
sta cbt_player_ypos,x
lda #$00
sta player_tile,x
lda #$08
jsr j_playsfx
lda game_mode
cmp #$80
bne L797F
lda attacking_monster_type
jsr check_evil
bpl L797F
jsr j_get_stats_ptr
ldy #$18
lda (ptr1),y
ldy #$1A
cmp (ptr1),y
bne L797F
ldy #$02
lda #$02
jsr virtue_dec
ldy #$04
lda #$02
jsr virtue_dec
L797F:
jmp L7133
L7982:
brk
L7983:
brk
lda #$00
sta L7C76
jsr j_primm
.byte $C1,$F4,$F4,$E1,$E3,$EB,$AD,$00
jsr combat_getdirection
bne L799C
jmp cmd_pass
L799C:
lda $16
sta missile_xpos
lda $17
sta missile_ypos
ldx L7C74
lda L7D8B,x
bne L79F8
cpx #$0A
bne L79C4
clc
lda missile_xpos
adc $78
sta missile_xpos
clc
lda missile_ypos
adc $79
sta missile_ypos
L79C4:
jsr combat_fire_missile
bpl L79CC
jmp L7BFA
L79CC:
lda #$4D
sta missile
jsr j_idle_combat
lda #$00
sta missile
lda #$04
jsr j_playsfx
jsr combat_find_monster
bpl L79F2
lda #$01
sta L7C76
lda L7C74
cmp #$02
beq L79F8
jmp L7BFA
L79F2:
inc L7C76
jmp L7A8C
L79F8:
lda #$0B
sta L7C75
lda L7C74
cmp #$09
bne L7A1E
jsr j_primm
.byte $D2,$C1,$CE,$C7,$C5,$AD,$00
jsr getandprintkey
sec
sbc #$B0
cmp #$0A
bcc L7A1B
jmp L7BFA
L7A1B:
sta L7C75
L7A1E:
lda L7C74
cmp #$02
beq L7A29
cmp #$09
bne L7A51
L7A29:
clc
adc #$20
tay
lda game_stats,y
beq L7A38
jsr stat_dec
jmp L7A51
L7A38:
lda #$00
jsr j_get_stats_ptr
ldy #$1E
lda #$00
sta (ptr1),y
jsr j_primm
.byte $CC,$C1,$D3,$D4,$A0,$CF,$CE,$C5
.byte $A1,$8D,$00
L7A51:
jsr combat_fire_missile
bpl L7A59
jmp L7BFA
L7A59:
lda #$4D
sta missile
lda L7C74
cmp #$0E
bne L7A6A
lda #$4E
sta missile
L7A6A:
jsr j_idle_combat
lda #$00
sta missile
lda L7C76
bne L7A7C
lda #$04
jsr j_playsfx
L7A7C:
inc L7C76
jsr combat_find_monster
bpl L7A8C
dec L7C75
bne L7A51
jmp L7BFA
L7A8C:
lda current_location
cmp #$18
bne L7A9C
lda L7C74
cmp #$0B
bcs L7A9C
jmp L7BFA
L7A9C:
lda L7C74
cmp #$09
bne L7AAF
jsr j_gettile_combat
cmp #$03
bcc L7AAF
lda #$46
sta tempmap,y
L7AAF:
lda #$4F
sta missile
lda L7C74
cmp #$0E
bne L7AC0
lda #$4E
sta missile
L7AC0:
jsr j_get_stats_ptr
ldy #$14
lda (ptr1),y
jsr bcdtohex
asl a
clc
adc #$80
bcs L7ADC
sta zptmp1
jsr j_rand
cmp zptmp1
bcc L7ADC
jmp L7BFA
L7ADC:
jsr j_get_stats_ptr
ldy #$13
lda (ptr1),y
jsr bcdtohex
ldx L7C74
clc
adc L7D73,x
bcc L7AF1
lda #$FF
L7AF1:
jsr randmax
sta $5C
jsr j_idle_combat
lda #$06
jsr j_playsfx
lda #$00
sta missile
jsr hurt_monster
jmp L7C3D
hurt_monster:
jsr printcr
ldx $6A
lda cbt_monster_type,x
sta monster_type
jsr print_creature_name
ldx $6A
lda cbt_monster_type,x
cmp #$5E
bne @subtractdamage
jmp @calcdmgpercent
@subtractdamage:
lda monster_hp,x
sec
sbc $5C
sta monster_hp,x
bcs @calcdmgpercent
lda #$00
sta monster_hp,x
sta cbt_monster_type,x
jsr j_primm
.byte $CB,$C9,$CC,$CC,$C5,$C4,$A1,$8D
.byte $00
lda currplayer
beq @done
lda monster_type
jsr get_creature_type
tay
lda monster_xp,y
lsr a
lsr a
lsr a
lsr a
clc
adc #$01
jsr hextobcd
jsr stat_add_exp
jsr j_primm
.byte $C5,$D8,$D0,$AE,$AB,$00
lda $58
cmp #$10
bcs @lessthan10
jsr j_printdigit
jmp @done
@lessthan10:
jsr j_printbcd
@done:
jsr printcr
rts
@calcdmgpercent:
ldx $6A
lda cbt_monster_type,x
jsr get_creature_type
tax
lda monster_xp,x
lsr a
sta $59
sta zptmp1
lsr zptmp1
clc
adc zptmp1
sta $58
ldx $6A
lda monster_hp,x
cmp #$18
bcs @checkcrit
jsr j_primm
.byte $C6,$CC,$C5,$C5,$C9,$CE,$C7,$A1
.byte $8D,$00
jmp @done
@checkcrit:
cmp zptmp1
bcs @checkheavy
jsr j_primm
.byte $C3,$D2,$C9,$D4,$C9,$C3,$C1,$CC
.byte $A1,$8D,$00
jmp @done
@checkheavy:
cmp $59
bcs @checklightly
jsr j_primm
.byte $C8,$C5,$C1,$D6,$C9,$CC,$D9,$00
jmp @printwounded
@checklightly:
cmp $58
bcs @barely
jsr j_primm
.byte $CC,$C9,$C7,$C8,$D4,$CC,$D9,$00
jmp @printwounded
@barely:
jsr j_primm
.byte $C2,$C1,$D2,$C5,$CC,$D9,$00
@printwounded:
jsr j_primm
.byte $A0,$D7,$CF,$D5,$CE,$C4,$C5,$C4
.byte $A1,$8D,$00
@done:
rts
L7BFA:
lda L7C76
bne L7C04
lda #$04
jsr j_playsfx
L7C04:
lda #$00
sta missile
jsr j_primm
.byte $CD,$C9,$D3,$D3,$C5,$C4,$A1,$8D
.byte $00
lda L7C74
cmp #$09
bne L7C3A
lda missile_xpos
cmp #$0B
bcs L7C3A
sta $16
lda missile_ypos
cmp #$0B
bcs L7C3A
sta $17
jsr j_gettile_combat
cmp #$03
bcc L7C3A
lda #$46
sta tempmap,y
L7C3A:
jmp L7C3D
L7C3D:
lda L7C74
cmp #$0B
bne L7C71
lda L7C76
cmp #$02
bcc L7C71
dec L7C76
lda $78
jsr L8281
sta $78
lda $79
jsr L8281
sta $79
lda #$4D
sta missile
L7C61:
jsr combat_fire_missile
jsr j_idle_combat
dec L7C76
bne L7C61
lda #$00
sta missile
L7C71:
jmp L7133
L7C74:
brk
L7C75:
brk
L7C76:
brk
jsr j_primm
.byte $C3,$E1,$F3,$F4,$AC,$A0,$00
jmp @playerok
jsr j_primm
.byte $C7,$E5,$F4,$A0,$E3,$E8,$E5,$F3
.byte $F4,$A1,$8D,$00
combat_open_chest:
ldx currplayer
dex
lda cbt_player_xpos,x
sta $16
lda cbt_player_ypos,x
sta $17
jsr j_gettile_combat
cmp #$3C
beq @chest
jmp print_not_here
@chest:
lda #$16
sta tempmap,y
lda game_mode_temp
cmp #$03
bne @notdungeon
lda player_xpos
sta $16
lda player_ypos
sta $17
jsr j_gettile_dungeon
cmp #$40
bne @notdungeon
lda #$00
sta (ptr1),y
@notdungeon:
jmp openchest
jsr j_primm
.byte $D2,$E5,$E1,$E4,$F9,$A0,$F7,$E5
.byte $E1,$F0,$EF,$EE,$BA,$8D,$00
jmp L58EB
jsr j_primm
.byte $DA,$F4,$E1,$F4,$F3,$8D,$00
jsr L5CC8
jsr j_update_status
jsr invert_player_line
jmp L7133
monster_xp:
.byte $FF,$FF,$40,$60,$80,$60,$FF,$FF
.byte $30,$30,$40,$50,$30,$60,$30,$C0
.byte $FF,$30,$F0,$80,$50,$30,$50,$30
.byte $70,$40,$80,$40,$B0,$C0,$60,$F0
.byte $70,$D0,$E0,$FF,$70,$30,$60,$40
.byte $60,$80,$90,$30,$80,$30,$30,$30
.byte $20,$20,$80,$FF
L7D2A:
.byte $C8,$C8,$8A,$88,$86,$84,$8C,$8E
.byte $C4,$E4,$90,$E4,$A0,$D0,$A8,$AC
.byte $B0,$90,$BC,$9C,$A4,$E0,$C8,$90
.byte $F0,$B8,$EC,$BC,$F0,$F0,$F4,$B8
.byte $FC,$F8,$FC,$FC
L7D4E:
.byte $01,$01,$0C,$04,$04,$08,$01,$01
.byte $0C,$0C,$06,$04,$0F,$06,$0F,$01
.byte $01,$0F,$04,$08,$0A,$0C,$0A,$0C
.byte $06,$08,$06,$0C,$06,$04,$08,$04
.byte $06,$04,$04,$01
L7D72:
.byte $00
L7D73:
.byte $08,$10,$18,$20,$28,$30,$40,$28
.byte $38,$40,$60,$60,$80,$50,$A0,$FF
L7D83:
.byte $60,$80,$90,$A0,$B0,$C0,$D0,$F8
L7D8B:
.byte $00,$00,$00,$FF,$00,$00,$00,$FF
.byte $FF,$FF,$00,$FF,$00,$FF,$FF,$00
get_creature_type:
bpl @npc
and #$7F
lsr a
cmp #$08
bcc @twoframes
lsr a
clc
adc #$04
@twoframes:
rts
@npc:
and #$1F
clc
adc #$24
rts
check_awake:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C7
beq check_joined
cmp #$D0
beq check_joined
lda #$FF
rts
check_alive:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C7
beq check_joined
cmp #$D0
beq check_joined
cmp #$D3
beq check_joined
not_joined:
lda #$FF
rts
check_joined:
lda currplayer
cmp party_size
beq @ok
bcs not_joined
@ok:
lda #$00
rts
something_based_on_status_and_class:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C7
beq L7DF8
cmp #$D0
beq L7DF8
cmp #$C4
beq L7E00
lda #$38
rts
L7DF8:
ldy #$11
lda (ptr1),y
asl a
adc #$20
rts
L7E00:
lda #$FF
rts
randmax:
cmp #$00
beq @zero
sta L7E1C
jsr j_rand
@rollagain:
cmp L7E1C
bcc @gotval
sec
sbc L7E1C
jmp @rollagain
@gotval:
cmp #$00
@zero:
rts
L7E1C:
.byte $00
L7E1D:
sta zptmp1
stx $59
jsr check_slow_progress
bpl L7E29
jmp L7EE5
L7E29:
lda object_tile,x
cmp #$8C
beq L7E6C
cmp #$8E
beq L7E6C
ldy #$1F
L7E36:
lda object_tile,y
beq L7E53
lda object_xpos,y
cmp $7A
bne L7E53
lda object_ypos,y
cmp $7B
bne L7E53
lda object_tile,y
cmp #$3C
beq L7E53
jmp L7EE5
L7E53:
dey
bpl L7E36
lda $7A
cmp player_xpos
bne L7E65
lda $7B
cmp player_ypos
bne L7E65
jmp L7EE5
L7E65:
lda object_tile,x
cmp #$80
beq L7E81
L7E6C:
lda $7A
cmp $AC80,x
bne L7E81
lda $7B
cmp $ACA0,x
bne L7E81
jsr j_rand
and #$03
bne L7EE5
L7E81:
lda object_tile,x
bpl L7EB6
cmp #$8E
bcc L7EBF
beq L7ED3
cmp #$94
beq L7ED3
cmp #$9C
beq L7EAA
cmp #$B4
beq L7ED3
cmp #$EC
beq L7EAA
cmp #$F0
beq L7ED3
cmp #$F8
beq L7ED3
cmp #$FC
beq L7ED3
bne L7EB6
L7EAA:
lda zptmp1
cmp #$03
bcc L7EE5
cmp #$45
bne L7EE0
beq L7EE5
L7EB6:
lda zptmp1
jsr j_blocked_tile
bpl L7EE0
bmi L7EE5
L7EBF:
cmp #$80
bne L7ECB
lda zptmp1
cmp #$02
bcc L7EE0
bcs L7EE5
L7ECB:
lda zptmp1
cmp #$03
bcc L7EE0
bcs L7EE5
L7ED3:
lda zptmp1
cmp #$03
bcc L7EE0
jsr j_blocked_tile
bpl L7EE0
bmi L7EE5
L7EE0:
ldx $59
lda #$00
rts
L7EE5:
ldx $59
lda #$FF
rts
L7EEA:
sta zptmp1
jsr check_slow_progress
bmi L7F06
lda $16
cmp #$0B
bcs L7EFD
lda $17
cmp #$0B
bcc L7F0C
L7EFD:
ldx $6A
lda monster_hp,x
cmp #$18
bcc L7F09
L7F06:
jmp L7FAD
L7F09:
jmp L7FAA
L7F0C:
ldx $6A
lda $AD20,x
cmp $16
bne L7F23
lda $AD30,x
cmp $17
bne L7F23
jsr j_rand
and #$03
bne L7F06
L7F23:
ldx #$0F
L7F25:
lda cbt_monster_type,x
beq L7F38
lda monster_xpos,x
cmp $16
bne L7F38
lda monster_ypos,x
cmp $17
beq L7FAD
L7F38:
cpx #$08
bcs L7F4F
lda player_tile,x
beq L7F4F
lda cbt_player_xpos,x
cmp $16
bne L7F4F
lda cbt_player_ypos,x
cmp $17
beq L7FAD
L7F4F:
dex
bpl L7F25
ldx $6A
lda cbt_monster_type,x
bpl L7F89
cmp #$8E
bcc L7F92
beq L7F9A
cmp #$94
beq L7F9A
cmp #$9C
beq L7F7D
cmp #$B4
beq L7F9A
cmp #$EC
beq L7F7D
cmp #$F0
beq L7F9A
cmp #$F8
beq L7F9A
cmp #$FC
beq L7F9A
bne L7F89
L7F7D:
lda zptmp1
cmp #$03
bcc L7FAD
cmp #$45
bne L7FAA
beq L7FAD
L7F89:
lda zptmp1
jsr j_blocked_tile
bpl L7FAA
bmi L7FAD
L7F92:
lda zptmp1
cmp #$03
bcc L7FAA
bcs L7FAD
L7F9A:
lda zptmp1
cmp #$03
bcc L7FAA
jsr j_blocked_tile
jsr j_blocked_tile
bpl L7FAA
bmi L7FAD
L7FAA:
lda #$00
rts
L7FAD:
lda #$FF
rts
L7FB0:
pha
and #$0F
bne L7FE4
pla
and #$F0
cmp #$80
beq L7FE5
cmp #$90
beq L7FE5
cmp #$A0
beq L7FE5
cmp #$D0
beq L7FE5
cmp #$F0
beq L7FE5
jsr j_rand
and #$07
beq L7FE1
lda $16
cmp $AC80,x
bne L7FE1
lda $17
cmp $ACA0,x
beq L7FE5
L7FE1:
lda #$00
rts
L7FE4:
pla
L7FE5:
lda #$FF
rts
dng_check_forward_block:
sta $58
and #$F0
cmp #$C0
beq dng_not_blocked
cmp #$E0
beq dng_not_blocked
cmp #$D0
beq dng_not_blocked
lda $58
dng_check_retreat_block:
cmp #$A1
beq dng_blocked
cmp #$C0
bcs dng_blocked
bcc dng_not_blocked
dng_not_blocked:
lda #$00
rts
dng_blocked:
lda #$FF
rts
update_door:
lda game_mode
cmp #$02
bne @done
lda open_door_counter
bne @checkclose
rts
@checkclose:
dec open_door_counter
beq @close
rts
@close:
lda open_door_xpos
sta $7A
lda open_door_ypos
sta $7B
jsr j_gettile_town
lda #$3B
sta (ptr2),y
@done:
lda #$00
sta open_door_counter
rts
open_door_xpos:
.byte $00
open_door_ypos:
.byte $00
open_door_counter:
.byte $00
L8036:
cmp #$20
beq L809C
cmp #$5E
beq L809C
cmp #$84
beq L80A5
cmp #$86
beq L8090
cmp #$88
beq L809F
cmp #$8A
beq L809C
cmp #$98
beq L808D
cmp #$A4
beq L80A5
cmp #$AC
beq L808D
cmp #$B8
beq L8096
cmp #$CC
beq L808D
cmp #$D0
beq L8099
cmp #$D8
beq L8099
cmp #$E0
beq L809C
cmp #$E4
beq L809C
cmp #$E8
beq L80A2
cmp #$F0
beq L809C
cmp #$F4
bcs L809F
cmp #$F8
beq L809F
cmp #$B0
beq L80A8
cmp #$FC
beq L80A8
lda #$00
rts
L808D:
lda #$44
rts
L8090:
lda #$45
rts
lda #$46
rts
L8096:
lda #$47
rts
L8099:
lda #$37
rts
L809C:
lda #$4E
rts
L809F:
lda #$4F
rts
L80A2:
lda #$4C
rts
L80A5:
lda #$4D
rts
L80A8:
jsr j_rand
and #$03
clc
adc #$44
rts
L80B1:
sta missile
lda monster_xpos,x
sta missile_xpos
lda monster_ypos,x
sta missile_ypos
lda #$03
jsr j_playsfx
L80C5:
jsr combat_fire_missile
bmi L80D5
jsr L81DE
bne L80F5
jsr j_idle_combat
jmp L80C5
L80D5:
lda missile
ldx #$00
stx missile
cmp #$4C
beq L80E2
rts
L80E2:
lda missile_xpos
sta $16
lda missile_ypos
sta $17
jsr L088A
lda #$4C
sta tempmap,y
rts
L80F5:
jsr printcr
jsr j_printname
jsr printcr
lda missile
cmp #$44
bne L812B
jsr j_primm
.byte $D0,$CF,$C9,$D3,$CF,$CE,$C5,$C4
.byte $A1,$8D,$00
jsr L81C0
jsr j_rand
bpl L816C
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C7
bne L816C
lda #$D0
sta (ptr1),y
rts
L812B:
cmp #$45
bne L8144
jsr j_primm
.byte $C5,$CC,$C5,$C3,$D4,$D2,$C9,$C6
.byte $C9,$C5,$C4,$A1,$8D,$00
jsr L7748
rts
L8144:
cmp #$46
bne L8155
jsr j_primm
.byte $C6,$C9,$C5,$D2,$D9,$A0,$00
jmp L81B3
L8155:
cmp #$47
bne L8190
jsr j_primm
.byte $D3,$CC,$C5,$D0,$D4,$A1,$8D,$00
jsr L81C0
jsr j_rand
bmi L8179
L816C:
jsr j_primm
.byte $C6,$C1,$C9,$CC,$C5,$C4,$AE,$8D
.byte $00
rts
L8179:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$C7
bne L816C
lda #$D3
sta (ptr1),y
lda #$38
ldx currplayer
sta $AD9F,x
rts
L8190:
cmp #$4C
bne L81A0
jsr j_primm
.byte $CC,$C1,$D6,$C1,$A0,$00
jmp L81B3
L81A0:
cmp #$4E
bne L81B3
jsr j_primm
.byte $CD,$C1,$C7,$C9,$C3,$C1,$CC,$A0
.byte $00
jmp L81B3
L81B3:
jsr j_primm
.byte $C8,$C9,$D4,$A1,$8D,$00
jsr L7748
rts
L81C0:
jsr invert_player_line
lda $16
sta missile_xpos
lda $17
sta missile_ypos
jsr j_idle_combat
lda #$07
jsr j_playsfx
jsr invert_player_line
lda #$00
sta missile
rts
L81DE:
lda party_size
sta currplayer
L81E2:
jsr check_alive
bne L81FD
ldx currplayer
dex
lda missile_xpos
cmp cbt_player_xpos,x
bne L81FD
lda missile_ypos
cmp cbt_player_ypos,x
bne L81FD
lda currplayer
rts
L81FD:
dec currplayer
bne L81E2
rts
combat_find_monster:
ldy #$0F
@checkmonster:
lda cbt_monster_type,y
beq @next
lda monster_xpos,y
cmp $16
bne @next
lda monster_ypos,y
cmp $17
beq @foundmonster
@next:
dey
bpl @checkmonster
@foundmonster:
tya
sta $6A
cmp #$00
rts
combat_fire_missile:
clc
lda missile_xpos
adc $78
sta $16
clc
lda missile_ypos
adc $79
sta $17
lda $16
cmp #$0B
bcs @miss
lda $17
cmp #$0B
bcs @miss
jsr j_gettile_combat
bmi @hit
cmp #$03
bcc @hit
cmp #$48
beq @hit
cmp #$49
beq @miss
cmp #$31
bcc @blocked
cmp #$35
bcc @hit
@blocked:
jsr j_blocked_tile
bmi @miss
@hit:
lda $16
sta missile_xpos
lda $17
sta missile_ypos
lda #$00
rts
@miss:
lda #$FF
rts
getsign:
cmp #$00
beq L8275
bmi L8273
lda #$01
rts
L8273:
lda #$FF
L8275:
rts
getabs:
cmp #$00
bmi L827B
rts
L827B:
eor #$FF
clc
adc #$01
rts
L8281:
eor #$FF
clc
adc #$01
rts
combat_getdirection:
jsr getdirection
beq @cancel
ldx currplayer
dex
lda cbt_player_xpos,x
sta $16
lda cbt_player_ypos,x
sta $17
lda #$01
@cancel:
rts
getdirection:
jsr j_waitkey
bne @gotkey
@cancel:
jsr printcr
lda #$00
rts
@gotkey:
pha
lda #$00
sta $78
sta $79
pla
cmp #$C0
beq @north
cmp #$AF
beq @south
cmp #$BA
beq @east
cmp #$BB
beq @west
cmp #$A0
beq @cancel
jsr j_console_out
jmp @cancel
@north:
jsr print_north
lda #$FF
sta $79
jmp @calcpos
@south:
jsr print_south
lda #$01
sta $79
jmp @calcpos
@east:
jsr print_west
lda #$FF
sta $78
jmp @calcpos
@west:
jsr print_east
lda #$01
sta $78
@calcpos:
clc
lda player_xpos
adc $78
sta $7A
sta $16
clc
lda player_ypos
adc $79
sta $7B
sta $17
lda #$01
rts
print_north:
jsr j_primm
.byte $CE,$EF,$F2,$F4,$E8,$8D,$00
rts
print_south:
jsr j_primm
.byte $D3,$EF,$F5,$F4,$E8,$8D,$00
rts
print_east:
jsr j_primm
.byte $C5,$E1,$F3,$F4,$8D,$00
rts
print_west:
jsr j_primm
.byte $D7,$E5,$F3,$F4,$8D,$00
rts
find_creature:
lda current_location
bne @not7
ldx #$07
jmp find_next_target
@not7:
cmp #$11
bcs @notfound
find_target:
ldx #$1F
find_next_target:
lda $7A
cmp object_xpos,x
bne @next
lda $7B
cmp object_ypos,x
bne @next
lda object_tile,x
beq @next
txa
rts
@next:
dex
bpl find_next_target
@notfound:
lda #$FF
rts
print_object_name:
ldx $58
lda object_tile,x
print_creature_name:
bpl @npc
sec
sbc #$80
cmp #$10
bcs @div4
lsr a
@print:
clc
adc #$01
jsr j_printstring
lda #$8D
jsr j_console_out
rts
@div4:
lsr a
lsr a
clc
adc #$04
jmp @print
@npc:
cmp #$20
bcc @phantom
cmp #$60
bcs @phantom
cmp #$30
bcc @profession
cmp #$50
bcc @phantom
@profession:
and #$1F
lsr a
clc
adc #$4C
jmp @print
@phantom:
lda #$13
jmp @print
getandprintkey:
jsr j_waitkey
pha
beq L83A1
jsr j_console_out
L83A1:
lda #$8D
jsr j_console_out
pla
rts
check_party_alive:
lda party_size
sta currplayer
@checkalive:
jsr check_alive
beq @checkawake
dec currplayer
bne @checkalive
jmp player_dead
@checkawake:
jsr check_awake
beq @aliveandawake
dec currplayer
bne @checkawake
lda #$FF
rts
@aliveandawake:
lda #$00
rts
player_dead:
lda #$00
jsr music_ctl
lda #$02
jsr j_request_disk
lda #$CC
ldx #$89
jsr j_fileio
jsr L8800
lda #$01
jsr music_ctl
jmp cmd_done
invert_all_player_lines:
lda party_size
sta currplayer
@next:
jsr invert_player_line
dec currplayer
bne @next
rts
invert_player_line:
lda currplayer
asl a
asl a
asl a
tax
lda bmplineaddr_lo,x
sta ptr1
lda bmplineaddr_hi,x
sta ptr1+1
lda ptr1
clc
adc #$C0
sta ptr1
lda ptr1+1
adc #$00
sta ptr1+1
ldy #$00
@invert:
lda (ptr1),y
eor #$FF
sta (ptr1),y
iny
cpy #$78
bne @invert
rts
hextobcd:
cmp #$00
beq L8430
cmp #$63
bcs L842E
sed
tax
lda #$00
L8426:
clc
adc #$01
dex
bne L8426
beq L8430
L842E:
lda #$99
L8430:
cld
rts
bcdtohex:
cmp #$00
beq L8441
ldx #$00
sed
L8439:
inx
sec
sbc #$01
bne L8439
txa
cld
L8441:
rts
stat_inc:
sed
clc
lda game_stats,y
adc #$01
bcs @done
sta game_stats,y
@done:
cld
rts
stat_dec:
sed
sec
lda game_stats,y
sbc #$01
bcc @done
sta game_stats,y
@done:
cld
rts
virtue_inc:
sta $59
sed
clc
lda game_stats,y
beq @done
adc $59
bcc @done
lda #$99
@done:
sta game_stats,y
cld
rts
virtue_dec:
sta zptmp1
sty $59
lda game_stats,y
beq @lost_eight
@dec:
sed
sec
sbc zptmp1
beq @zero
bcs @nounderflow
@zero:
lda #$01
@nounderflow:
sta game_stats,y
cld
rts
@lost_eight:
jsr j_primm
.byte $8D,$D4,$C8,$CF,$D5,$A0,$C8,$C1
.byte $D3,$D4,$A0,$CC,$CF,$D3,$D4,$8D
.byte $C1,$CE,$A0,$C5,$C9,$C7,$C8,$D4
.byte $C8,$A1,$8D,$00
ldy $59
lda #$99
jmp @dec
stat_sub_hp:
sta zptmp1
jsr j_get_stats_ptr
ldy #$19
sed
sec
lda (ptr1),y
sbc zptmp1
sta (ptr1),y
dey
lda (ptr1),y
sbc #$00
sta (ptr1),y
cld
bcc @dead
lda #$01
rts
@dead:
lda #$00
sta (ptr1),y
iny
sta (ptr1),y
jsr j_get_stats_ptr
ldy #$12
lda #$C4
sta (ptr1),y
lda game_mode
bpl @notcombat
lda #$38
ldx currplayer
sta $AD9F,x
@notcombat:
lda #$00
rts
stat_add_hp:
sta zptmp1
jsr j_get_stats_ptr
ldy #$19
sed
clc
lda (ptr1),y
adc zptmp1
sta (ptr1),y
dey
lda (ptr1),y
adc #$00
sta (ptr1),y
cld
ldy #$18
lda (ptr1),y
ldy #$1A
cmp (ptr1),y
bcc @done
ldy #$19
lda (ptr1),y
ldy #$1B
cmp (ptr1),y
bcc @done
ldy #$1A
lda (ptr1),y
ldy #$18
sta (ptr1),y
ldy #$1B
lda (ptr1),y
ldy #$19
sta (ptr1),y
@done:
rts
stat_add_gold:
sta zptmp1
ldy #$14
sed
clc
lda game_stats,y
adc zptmp1
sta game_stats,y
dey
lda game_stats,y
adc #$00
sta game_stats,y
cld
bcc @nomsb
lda #$99
sta game_stats,y
iny
sta game_stats,y
@nomsb:
rts
stat_add_exp:
sta $58
jsr j_get_stats_ptr
ldy #$1D
sed
clc
lda (ptr1),y
adc $58
sta (ptr1),y
dey
lda (ptr1),y
adc #$00
sta (ptr1),y
cld
bcc @done
lda #$99
sta (ptr1),y
iny
sta (ptr1),y
@done:
rts
hurt_player_random_val:
jsr flash_player_line
lda #$1E
jsr randmax
jsr hextobcd
jsr stat_sub_hp
rts
hurt_all_players:
jsr invert_all_player_lines
lda #$06
jsr j_playsfx
jsr shake_screen
lda game_mode
bmi L85BC
lda player_transport
cmp #$14
bcs L85BC
sed
sec
lda ship_hull
sbc #$0A
cld
bcs L85BA
lda #$00
sta ship_hull
jsr invert_all_player_lines
jsr j_update_status
jsr j_primm
.byte $8D,$D4,$C8,$D9,$A0,$D3,$C8,$C9
.byte $D0,$A0,$D3,$C9,$CE,$CB,$D3,$A1
.byte $8D,$00
jmp player_dead
L85BA:
sta ship_hull
L85BC:
lda party_size
sta currplayer
L85C0:
jsr j_rand
bmi L85E0
jsr check_alive
bne L85E0
lda game_mode
bpl L85D5
ldx currplayer
lda $AD9F,x
beq L85E0
L85D5:
lda #$19
jsr randmax
jsr hextobcd
jsr stat_sub_hp
L85E0:
dec currplayer
bne L85C0
jsr invert_all_player_lines
jsr j_update_status
rts
flash_player_line:
jsr invert_player_line
lda #$07
jsr j_playsfx
jsr invert_player_line
rts
printcr:
lda #$8D
jsr j_console_out
rts
shake_screen:
jsr L8645
jsr L8616
jsr L8645
jsr L8616
jsr L8645
jsr L8616
jsr L8645
jsr L8616
rts
L8616:
ldx #$AE
L8618:
lda bmplineaddr_lo+9,x
sta ptr1
lda bmplineaddr_hi+9,x
sta ptr1+1
lda bmplineaddr_lo+7,x
sta ptr2
lda bmplineaddr_hi+7,x
sta ptr2+1
ldy #$B0
L862E:
lda (ptr2),y
sta (ptr1),y
tya
sec
sbc #$08
tay
bne L862E
jsr j_rand
bmi L8641
jsr j_togglesnd
L8641:
dex
bne L8618
rts
L8645:
ldx #$00
L8647:
lda bmplineaddr_lo+8,x
sta ptr1
lda bmplineaddr_hi+8,x
sta ptr1+1
lda bmplineaddr_lo+10,x
sta ptr2
lda bmplineaddr_hi+10,x
sta ptr2+1
ldy #$B0
L865D:
lda (ptr2),y
sta (ptr1),y
tya
sec
sbc #$08
tay
bne L865D
jsr j_rand
bmi L8670
jsr j_togglesnd
L8670:
inx
cpx #$AE
bcc L8647
rts
check_moongate:
cmp #$43
beq @gateactive
rts
@gateactive:
lda moon_phase_trammel
cmp #$04
bne @notfull
lda moon_phase_felucca
cmp #$04
bne @notfull
jsr j_idle
jsr j_invertview
lda #$09
ldx #$A0
jsr j_playsfx
lda #$1F
sta current_location
jmp L5183
@notfull:
jsr j_idle
ldx moon_phase_felucca
lda moongate_xpos,x
sta player_xpos
lda moongate_ypos,x
sta player_ypos
jsr j_invertview
lda #$09
ldx #$A0
jsr j_playsfx
jsr j_invertview
jsr j_player_teleport
jsr j_idle
jsr j_invertview
lda #$09
ldx #$A0
jsr j_playsfx
jsr j_invertview
jmp cmd_done
check_evil:
cmp #$00
bpl @not_evil
cmp #$8A
beq @not_evil
cmp #$90
beq @not_evil
cmp #$94
beq @not_evil
cmp #$98
beq @not_evil
cmp #$B4
beq @not_evil
cmp #$CC
beq @not_evil
lda #$FF
rts
@not_evil:
lda #$00
rts
php
ldy $58
lda mixtures,y
jsr j_printbcd
inc $59
inc $58
lda $58
cmp #$1A
.byte $90,$BF
jsr restore_console_pos
rts
lda console_xpos
sta L621C
lda console_ypos
sta L621D
rts
lda L621C
sta console_xpos
lda L621D
sta console_ypos
rts
brk
brk
jsr check_party_alive
lda game_mode
bpl L8728
jmp L7133
L8728:
lda ship_hull
cmp #$50
bcs L873E
jsr j_rand
and #$03
bne L873E
lda ship_hull
sed
clc
adc #$01
cld
sta ship_hull
L873E:
lda party_size
sta currplayer
L8742:
jsr j_get_stats_ptr
ldy #$12
lda (ptr1),y
cmp #$D3
bne L875B
jsr j_rand
and #$07
bne L876F
lda #$C7
sta (ptr1),y
jmp @next
L875B:
cmp #$D0
bne L876F
lda #$02
jsr stat_sub_hp
jsr invert_player_line
lda #$06
jsr j_playsfx
jsr invert_player_line
L876F:
dec currplayer
bne L8742
lda party_size
jsr stat_eat_food
bcs L877D
jsr starve
L877D:
jsr party_add_mp
lda movement_mode
bmi L8790
jsr check_whirlpool_storm
jsr spawn_random_monster
jsr move_creatures
jsr check_whirlpool_storm
L8790:
lda game_mode
cmp #$03
bne L87A7
jsr j_print_direction
jsr dungeon_check_tile
lda tile_under_player
and #$F0
cmp #$D0
bne L87A7
jmp dungeon_room
L87A7:
lda light_duration
beq L87AD
dec light_duration
L87AD:
jmp update_counters
lda game_mode
cmp #$01
bne L87EA
lda tile_under_player
cmp #$17
bne L87EA
jsr j_rand
and #$07
bne L87EA
jsr j_primm
.byte $8D,$C2,$D2,$C9,$C4,$C7,$C5,$A0
.byte $D4,$D2,$CF,$CC,$CC,$D3,$A1,$8D
.byte $00
lda #$A4
sta attacking_monster_type
lda player_xpos
sta attacking_monster_xpos
lda player_ypos
sta attacking_monster_ypos
lda #$17
sta attacking_monster_terrain
jmp generate_combat
L87EA:
lda movement_mode
bpl L87EF
rts
L87EF:
lda game_mode
bmi L87FC
cmp #$03
beq L8859
lda tile_under_player
jmp L63B9
L87FC:
ldx currplayer
.byte $BD
.byte $9F
5b.html; generated on Thu Sep 21 17:08:54 2006 by ca65html
uz@cc65.org