mist: meche: rotation now works

This commit is contained in:
Vince Weaver 2020-03-22 16:14:49 -04:00
parent ec2992676f
commit f06fd91233
14 changed files with 369 additions and 15 deletions

View File

@ -46,7 +46,8 @@ meche_graphics.inc: \
eastturn_e.lzsa eastturn_w.lzsa \
east_arch_w.lzsa east_arch_s.lzsa \
east_hint_e.lzsa \
east_top_e.lzsa east_top_w.lzsa
east_top_e.lzsa east_top_w.lzsa \
fort_exit_n.lzsa fort_exit_w.lzsa fort_exit_e.lzsa
echo "departure_e_lzsa: .incbin \"departure_e.lzsa\"" > meche_graphics.inc
echo "arrival_w_lzsa: .incbin \"arrival_w.lzsa\"" >> meche_graphics.inc
echo "entrance_e_lzsa: .incbin \"entrance_e.lzsa\"" >> meche_graphics.inc
@ -121,10 +122,9 @@ meche_graphics.inc: \
echo "east_hint_e_lzsa: .incbin \"east_hint_e.lzsa\"" >> meche_graphics.inc
echo "east_top_e_lzsa: .incbin \"east_top_e.lzsa\"" >> meche_graphics.inc
echo "east_top_w_lzsa: .incbin \"east_top_w.lzsa\"" >> meche_graphics.inc
echo "fort_exit_n_lzsa: .incbin \"fort_exit_n.lzsa\"" >> meche_graphics.inc
echo "fort_exit_w_lzsa: .incbin \"fort_exit_w.lzsa\"" >> meche_graphics.inc
echo "fort_exit_e_lzsa: .incbin \"fort_exit_e.lzsa\"" >> meche_graphics.inc
%.gr: %.png
$(PNG2GR) $< $@
@ -135,4 +135,4 @@ meche_graphics.inc: \
####
clean:
rm -f *~ *.o *.lst *.gr meche_graphics.inc
rm -f *~ *.o *.lst *.gr *.lzsa meche_graphics.inc

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -72,3 +72,6 @@ east_arch_s_lzsa: .incbin "east_arch_s.lzsa"
east_hint_e_lzsa: .incbin "east_hint_e.lzsa"
east_top_e_lzsa: .incbin "east_top_e.lzsa"
east_top_w_lzsa: .incbin "east_top_w.lzsa"
fort_exit_n_lzsa: .incbin "fort_exit_n.lzsa"
fort_exit_w_lzsa: .incbin "fort_exit_w.lzsa"
fort_exit_e_lzsa: .incbin "fort_exit_e.lzsa"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 994 B

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 928 B

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 808 B

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 907 B

After

Width:  |  Height:  |  Size: 724 B

View File

@ -36,5 +36,9 @@ init_state:
; meche elevator
sta MECHE_ELEVATOR
sta MECHE_ROTATION
sta MECHE_LOCK1
sta MECHE_LOCK2
sta MECHE_LOCK3
sta MECHE_LOCK4
rts

View File

@ -180,8 +180,8 @@ location9:
.byte MECHE_FORT_ENTRY ; east exit
.byte $ff ; west exit
.byte $ff ; north exit_dir
.byte DIRECTION_N ; south exit_dir
.byte $ff ; east exit_dir
.byte $ff ; south exit_dir
.byte DIRECTION_N ; east exit_dir
.byte $ff ; west exit_dir
.word westturn_n_lzsa ; north bg
.word westturn_s_lzsa ; south bg
@ -193,11 +193,11 @@ location9:
; MECHE_NORTH_PLATFORM -- rotated to north platform
location10:
.byte $ff ; north exit
.byte MECHE_NORTH_DIP ; north exit
.byte MECHE_FORT_ENTRY ; south exit
.byte $ff ; east exit
.byte $ff ; west exit
.byte $ff ; north exit_dir
.byte DIRECTION_N ; north exit_dir
.byte DIRECTION_N ; south exit_dir
.byte $ff ; east exit_dir
.byte $ff ; west exit_dir
@ -214,7 +214,7 @@ location11:
.byte $ff ; south exit
.byte $ff ; east exit
.byte $ff ; west exit
.byte DIRECTION_N ; north exit_dir
.byte DIRECTION_S ; north exit_dir
.byte $ff ; south exit_dir
.byte $ff ; east exit_dir
.byte $ff ; west exit_dir
@ -228,11 +228,11 @@ location11:
; MECHE_NORTH_TOP -- north top
location12:
.byte MECHE_NORTH_HINT ; north exit
.byte $ff ; south exit
.byte MECHE_NORTH_DIP ; south exit
.byte $ff ; east exit
.byte $ff ; west exit
.byte DIRECTION_N ; north exit_dir
.byte $ff ; south exit_dir
.byte DIRECTION_S ; south exit_dir
.byte $ff ; east exit_dir
.byte $ff ; west exit_dir
.word north_top_n_lzsa ; north bg
@ -525,8 +525,10 @@ location28:
.word rotate_controls_e_lzsa ; east bg
.word $0000 ; west bg
.byte BG_EAST|BG_WEST
.byte $ff ; special exit
.byte DIRECTION_E ; special exit
.byte 13,28 ; special x
.byte 18,42 ; special y
.word handle_rotation_controls-1 ; special function
; MECHE EAST_PLATFORM -- rotated to east platform
location29:

View File

@ -66,6 +66,8 @@ game_loop:
beq animate_meche_book
cmp #MECHE_ELEVATOR_ROTATE
beq animate_elevator_rotate
cmp #MECHE_ROTATE_CONTROLS
beq animate_rotate_controls
jmp nothing_special
animate_meche_book:
@ -103,6 +105,10 @@ done_animate_book:
animate_elevator_rotate:
jsr draw_elevator_panel
jmp nothing_special
animate_rotate_controls:
jsr draw_rotation_controls
nothing_special:

View File

@ -1,3 +1,301 @@
;=================================
;=================================
; rotation stuff
;=================================
;=================================
handle_rotation_controls:
lda CURSOR_Y
cmp #34
bcs rot_button_press
lda CURSOR_X
cmp #19
bcc handle_left ; blt
handle_right:
lda MECHE_LEVERS
eor #RIGHT_LEVER
sta MECHE_LEVERS
rts
handle_left:
lda MECHE_LEVERS
eor #LEFT_LEVER
sta MECHE_LEVERS
; if flip to 0, then update rotation
and #LEFT_LEVER
bne done_handle_left
jsr rotate_fortress
done_handle_left:
rts
rot_button_press:
; get outside and face elevator
lda #MECHE_TOP_FLOOR
sta LOCATION
lda #DIRECTION_W
sta DIRECTION
; change to plain elevator
ldy #LOCATION_WEST_BG
lda #<top_floor_ye_w_lzsa
sta location27,Y
lda #>top_floor_ye_w_lzsa
sta location27+1,Y
; change destination to controls
ldy #LOCATION_WEST_EXIT
lda #MECHE_IN_ELEVATOR
sta location27,Y
jmp change_location ; tail call
;=================================
; draw rotation controls
;=================================
draw_rotation_controls:
;==========================
; rotate, where applicable
lda MECHE_LEVERS
and #LEFT_LEVER
beq draw_rotation
lda MECHE_LEVERS
and #RIGHT_LEVER
beq draw_rotation
lda FRAMEL
and #$f
bne draw_rotation
inc MECHE_ROTATION
lda MECHE_ROTATION
and #$f
sta MECHE_ROTATION
draw_rotation:
; draw rotation
lda MECHE_ROTATION
lsr
lsr
; 0 -> $C1 at 19,8
; 1 -> $10 at 21,4
; 2 -> $01 at 19,2
; 3 -> $10 at 17,4
beq rot0
cmp #1
beq rot1
cmp #2
beq rot2
bne rot3
rot0:
lda #$C1
sta $613
sta $A13
jmp draw_levers
rot1:
lda #$10
sta $515
sta $915
jmp draw_levers
rot2:
lda #$01
sta $493
sta $893
jmp draw_levers
rot3:
lda #$10
sta $511
sta $911
jmp draw_levers
draw_levers:
; draw left lever
lda #<lever_sprite
sta INL
lda #>lever_sprite
sta INH
lda #15
sta XPOS
lda MECHE_LEVERS
and #LEFT_LEVER
eor #LEFT_LEVER
asl
asl
asl
clc
adc #20
sta YPOS
jsr put_sprite_crop
; draw right lever
lda #<lever_sprite
sta INL
lda #>lever_sprite
sta INH
lda #21
sta XPOS
lda MECHE_LEVERS
and #RIGHT_LEVER
eor #RIGHT_LEVER
asl
asl
clc
adc #20
sta YPOS
jsr put_sprite_crop
rts
lever_sprite:
.byte 4,3
.byte $0A,$00,$00,$0A
.byte $00,$00,$05,$00
.byte $A0,$00,$00,$A0
;========================
; rotate fortress
rotate_fortress:
lda MECHE_ROTATION
lsr
lsr
beq fortress_south
cmp #1
beq fortress_east
cmp #2
beq fortress_north
bne fortress_west
fortress_south:
; point exit south (original entry point)
ldy #LOCATION_SOUTH_EXIT
lda #MECHE_BRIDGE2
sta location8,Y ; MECH_FORT_ENTRY
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_S
sta location8,Y ; MECH_FORT_ENTRY
; set bg to orig entry background
ldy #LOCATION_SOUTH_BG
lda #<fort_entry_s_lzsa
sta location8,Y
lda #>fort_entry_s_lzsa
jmp rotate_fortress_done
fortress_west:
; point exit south (original entry point)
ldy #LOCATION_SOUTH_EXIT
lda #MECHE_WEST_PLATFORM
sta location8,Y ; MECH_FORT_ENTRY
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_W
sta location8,Y ; MECH_FORT_ENTRY
; set bg to orig entry background
ldy #LOCATION_SOUTH_BG
lda #<fort_exit_w_lzsa
sta location8,Y
lda #>fort_exit_w_lzsa
jmp rotate_fortress_done
fortress_east:
; point exit south (original entry point)
ldy #LOCATION_SOUTH_EXIT
lda #MECHE_EAST_PLATFORM
sta location8,Y ; MECH_FORT_ENTRY
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_E
sta location8,Y ; MECH_FORT_ENTRY
; set bg to orig entry background
ldy #LOCATION_SOUTH_BG
lda #<fort_exit_e_lzsa
sta location8,Y
lda #>fort_exit_e_lzsa
jmp rotate_fortress_done
fortress_north:
; point exit south (original entry point)
ldy #LOCATION_SOUTH_EXIT
lda #MECHE_NORTH_PLATFORM
sta location8,Y ; MECH_FORT_ENTRY
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_N
sta location8,Y ; MECH_FORT_ENTRY
; set bg to orig entry background
ldy #LOCATION_SOUTH_BG
lda #<fort_exit_n_lzsa
sta location8,Y
lda #>fort_exit_n_lzsa
jmp rotate_fortress_done
rotate_fortress_done:
sta location8+1,Y
rts
;==================================
; elevator stuff
@ -56,6 +354,38 @@ elevator_goto_ground:
elevator_goto_half:
; if at top kick outside and lower
; TODO: animation?
ldy #LOCATION_EAST_EXIT
cpy #MECHE_TOP_FLOOR
beq regular_half
half_and_controls:
;=============================
; kick us out, lower controls
; get outside and face elevator
lda #MECHE_TOP_FLOOR
sta LOCATION
lda #DIRECTION_W
sta DIRECTION
; change to elevator roof
ldy #LOCATION_WEST_BG
lda #<top_floor_ne_w_lzsa
sta location27,Y
lda #>top_floor_ne_w_lzsa
sta location27+1,Y
; change destination to controls
ldy #LOCATION_WEST_EXIT
lda #MECHE_ROTATE_CONTROLS
sta location27,Y
jmp elevator_button_done_no_update
regular_half:
; set exit to top floor
ldy #LOCATION_EAST_EXIT
@ -80,6 +410,8 @@ elevator_button_done:
sta location26+1,Y
elevator_button_done_no_update:
jsr change_location ; tail call?
rts

View File

@ -89,6 +89,13 @@ ROCKET_NOTE3 = $9D
ROCKET_NOTE4 = $9E
MECHE_ELEVATOR = $9F
MECHE_ROTATION = $A0
MECHE_LEVERS = $A1
LEFT_LEVER = 1
RIGHT_LEVER = 2
MECHE_LOCK1 = $A2
MECHE_LOCK2 = $A3
MECHE_LOCK3 = $A4
MECHE_LOCK4 = $A5
; done game puzzle state