diff --git a/mist/Makefile b/mist/Makefile index 08ce5e47..2c7658ed 100644 --- a/mist/Makefile +++ b/mist/Makefile @@ -97,6 +97,7 @@ octagon.o: octagon.s zp.inc hardware.inc common_defines.inc \ keyboard.s \ draw_pointer.s \ end_level.s \ + handle_pages.s \ octagon_bookshelf.s \ octagon_rotation.s \ gr_copy.s audio.s text_print.s decompress_fast_v2.s diff --git a/mist/brother_books.s b/mist/brother_books.s index 003a2570..c3f7abe4 100644 --- a/mist/brother_books.s +++ b/mist/brother_books.s @@ -22,6 +22,7 @@ yes_touching_red_book: ; if have a red page, take it and increment count lda HOLDING_PAGE + and #$c0 cmp #HOLDING_RED_PAGE bne not_red_page @@ -30,6 +31,10 @@ yes_touching_red_book: inc RED_PAGE_COUNT ; increment page count + ; in actual game plays sound effect here + + rts + not_red_page: lda #0 @@ -67,6 +72,7 @@ yes_touching_blue_book: ; if have a blue page, take it and increment count lda HOLDING_PAGE + and #$c0 cmp #HOLDING_BLUE_PAGE bne not_blue_page @@ -75,6 +81,10 @@ yes_touching_blue_book: inc BLUE_PAGE_COUNT ; increment page count + ; in actual game plays sound effect here + + rts + not_blue_page: lda #0 diff --git a/mist/draw_pointer.s b/mist/draw_pointer.s index 66b65457..5457f3e4 100644 --- a/mist/draw_pointer.s +++ b/mist/draw_pointer.s @@ -97,6 +97,7 @@ really_not_special: finger_point: lda HOLDING_PAGE + and #$c0 beq real_finger_point cmp #HOLDING_BLUE_PAGE beq blue_finger diff --git a/mist/handle_pages.s b/mist/handle_pages.s index eb7db8fa..c299de8c 100644 --- a/mist/handle_pages.s +++ b/mist/handle_pages.s @@ -9,39 +9,80 @@ ; A should be page to take (i.e. MECHE_PAGE or similar) take_blue_page: + pha jsr drop_current_page + pla + pha eor BLUE_PAGES_TAKEN ; toggle the taken flag sta BLUE_PAGES_TAKEN + pla - lda #HOLDING_BLUE_PAGE ; put it in hand + ora #HOLDING_BLUE_PAGE ; put it in hand sta HOLDING_PAGE rts take_red_page: - + pha jsr drop_current_page + pla + pha eor RED_PAGES_TAKEN sta RED_PAGES_TAKEN + pla - lda #HOLDING_RED_PAGE + ora #HOLDING_RED_PAGE sta HOLDING_PAGE rts take_white_page: - + pha jsr drop_current_page + pla -; lda #1 -; sta WHITE_PAGE_TAKEN + pha + lda #1 + sta WHITE_PAGE_TAKEN + pla - lda #HOLDING_WHITE_PAGE + ora #HOLDING_WHITE_PAGE sta HOLDING_PAGE rts -drop_current_page: - ; FIXME + ; clicked on a page while holding another +drop_current_page: + lda HOLDING_PAGE + and #$c0 + + cmp #HOLDING_RED_PAGE + beq drop_red_page + cmp #HOLDING_BLUE_PAGE + beq drop_blue_page + cmp #HOLDING_WHITE_PAGE + beq drop_white_page + + ; there was no page? rts +drop_white_page: + lda #0 + sta WHITE_PAGE_TAKEN + rts + +drop_red_page: + lda HOLDING_PAGE + and #$3f + eor RED_PAGES_TAKEN + sta RED_PAGES_TAKEN + rts + +drop_blue_page: + lda HOLDING_PAGE + and #$3f + eor BLUE_PAGES_TAKEN + sta BLUE_PAGES_TAKEN + rts + + diff --git a/mist/octagon.s b/mist/octagon.s index ca15eccc..79fe5c30 100644 --- a/mist/octagon.s +++ b/mist/octagon.s @@ -78,6 +78,7 @@ check_page_close_red: check_page_close_blue: cmp #OCTAGON_BLUE_BOOKSHELF + bne done_foreground jsr draw_octagon_page_close_blue done_foreground: diff --git a/mist/zp.inc b/mist/zp.inc index b1750d0b..8aa63939 100644 --- a/mist/zp.inc +++ b/mist/zp.inc @@ -114,9 +114,9 @@ MECHE_LOCK2 = $A3 MECHE_LOCK3 = $A4 MECHE_LOCK4 = $A5 HOLDING_PAGE = $A6 - HOLDING_RED_PAGE = 1 - HOLDING_BLUE_PAGE = 2 - HOLDING_WHITE_PAGE = 3 + HOLDING_RED_PAGE = $80 + HOLDING_BLUE_PAGE = $40 + HOLDING_WHITE_PAGE = $C0 RED_PAGE_COUNT = $A7 BLUE_PAGE_COUNT = $A8 VIEWER_CHANNEL = $A9 @@ -132,7 +132,7 @@ PUMP_STATE = $AD BATTERY_CHARGE = $AE COMPASS_ANGLE = $AF CRANK_ANGLE = $B0 - +WHITE_PAGE_TAKEN= $B1 ; done game puzzle state