a2d/desk.acc/puzzle.s

1223 lines
37 KiB
ArmAsm
Raw Normal View History

.setcpu "6502"
2017-09-11 03:40:32 +00:00
.include "apple2.inc"
2017-09-15 04:13:54 +00:00
.include "../inc/apple2.inc"
2017-09-11 03:40:32 +00:00
.include "../inc/auxmem.inc"
.include "../a2d.inc"
.include "../desktop.inc" ; needed to redraw DeskTop icons after window mode
.org $800
2017-09-11 03:40:32 +00:00
jmp copy2aux
.res 36, 0
2017-09-11 03:40:32 +00:00
;;; ==================================================
;;; Copy the DA to AUX and invoke it
2017-09-11 06:09:33 +00:00
stash_stack: .byte 0
.proc copy2aux
tsx
2017-09-11 03:40:32 +00:00
stx stash_stack
start := enter_da
end := last
sta ALTZPOFF
2017-09-12 04:06:37 +00:00
lda ROMIN2
lda #<start
2017-09-11 03:40:32 +00:00
sta STARTLO
lda #>start
2017-09-11 03:40:32 +00:00
sta STARTHI
lda #<end
2017-09-11 03:40:32 +00:00
sta ENDLO
lda #>end
2017-09-11 03:40:32 +00:00
sta ENDHI
lda #<start
2017-09-11 03:40:32 +00:00
sta DESTINATIONLO
lda #>start
2017-09-11 03:40:32 +00:00
sta DESTINATIONHI
sec ; main>aux
jsr AUXMOVE
lda #<enter_da
sta XFERSTARTLO
lda #>enter_da
sta XFERSTARTHI
php
pla
ora #$40 ; set overflow: use aux zp/stack
pha
plp
sec ; control main>aux
jmp XFER
.endproc
;;; ==================================================
;;; Set up / tear down
.proc exit_da
sta ALTZPON
lda LCBANK1
lda LCBANK1
2017-09-11 03:40:32 +00:00
ldx stash_stack
txs
rts
.endproc
.proc enter_da
sta ALTZPON
lda LCBANK1
lda LCBANK1
2017-09-11 06:09:33 +00:00
lda #0
sta $08
2017-09-12 03:38:58 +00:00
jmp create_window
.endproc
window_id := 51
2017-09-11 06:09:33 +00:00
;;; ==================================================
2017-09-18 15:10:19 +00:00
;;; Redraw the screen (all windows) after a drag
2017-09-18 15:10:19 +00:00
.proc redraw_screen
dest := $20
2017-09-18 15:10:19 +00:00
;; copy following routine to $20 and call it
2017-09-12 03:38:58 +00:00
ldx #sizeof_routine
loop: lda routine,x
sta dest,x
dex
bpl loop
jsr dest
2017-09-15 02:11:21 +00:00
;; now check the window pos
2017-09-11 06:09:33 +00:00
lda #window_id
2017-09-15 02:11:21 +00:00
jsr check_window_pos
2017-09-12 04:06:37 +00:00
2017-09-15 02:11:21 +00:00
bit window_pos_flag
bmi skip
2017-09-11 06:38:20 +00:00
DESKTOP_CALL DESKTOP_REDRAW_ICONS
2017-09-11 06:38:20 +00:00
2017-09-15 02:11:21 +00:00
skip: lda #0
sta window_pos_flag
rts
.proc routine
sta RAMRDOFF
sta RAMWRTOFF
2017-09-18 15:10:19 +00:00
jsr JUMP_TABLE_REDRAW_ALL
sta RAMRDON
sta RAMWRTON
rts
.endproc
2017-09-12 03:38:58 +00:00
sizeof_routine := * - routine
.endproc
;;; ==================================================
2017-09-12 03:38:58 +00:00
;;; ???
screen_height := 192
2017-09-15 02:11:21 +00:00
window_pos_flag:
.byte 0 ; ???
2017-09-12 04:06:37 +00:00
;; called with window_id in A
2017-09-15 02:11:21 +00:00
check_window_pos:
sta query_state_params_id
2017-09-12 04:06:37 +00:00
lda create_window_params_top ; is top on screen?
2017-09-12 03:38:58 +00:00
cmp #screen_height-1
2017-09-12 04:06:37 +00:00
bcc :+ ; yes
lda #$80 ; no, so ... ???
2017-09-15 02:11:21 +00:00
sta window_pos_flag
rts
2017-09-15 02:11:21 +00:00
: A2D_CALL A2D_QUERY_STATE, query_state_params
A2D_CALL A2D_SET_STATE, set_state_params
lda query_state_params_id
2017-09-11 06:09:33 +00:00
cmp #window_id
2017-09-12 03:38:58 +00:00
bne :+
2017-09-15 02:11:21 +00:00
jmp draw_window
2017-09-12 03:38:58 +00:00
: rts
;;; ==================================================
;;; Param Blocks
2017-09-12 04:06:37 +00:00
;; following memory space is re-used so x/y overlap
.proc drag_window_params
2017-09-25 04:02:13 +00:00
id := * + 0
xcoord := * + 1 ; x overlap
ycoord := * + 3 ; y overlap
moved := * + 5 ; ignored
.endproc
.proc map_coords_params
id := * + 0
2017-09-12 04:06:37 +00:00
screenx := * + 1 ; x overlap
screeny := * + 3 ; y overlap
clientx := * + 5
clienty := * + 7
.endproc
.proc get_input_params
state: .byte 0
key := *
modifiers := *+1
2017-09-12 04:06:37 +00:00
xcoord := * ; x overlap
ycoord := *+2 ; y overlap
.endproc
2017-09-12 04:06:37 +00:00
.proc query_target_params
queryx := * ; x overlap
queryy := *+2 ; y overlap
element := *+4
id := *+5
.endproc
.res 8, 0 ; storage for above
2017-09-12 04:06:37 +00:00
.byte 0,0 ; ???
2017-09-12 03:38:58 +00:00
.proc close_click_params
clicked:.byte 0
.endproc
2017-09-15 02:11:21 +00:00
.proc query_state_params
id: .byte 0
2017-09-15 02:11:21 +00:00
addr: .addr set_state_params
.endproc
2017-09-15 02:11:21 +00:00
query_state_params_id := query_state_params::id
2017-09-12 04:06:37 +00:00
;; Puzzle piece row/columns
2017-09-12 03:38:58 +00:00
cw := 28
c1 := 5
c2 := c1 + cw
c3 := c2 + cw
c4 := c3 + cw
rh := 16
r1 := 3
r2 := r1 + rh
r3 := r2 + rh
r4 := r3 + rh
space_positions: ; left, top for all 16 holes
.word c1,r1
.word c2,r1
.word c3,r1
.word c4,r1
.word c1,r2
.word c2,r2
.word c3,r2
.word c4,r2
.word c1,r3
.word c2,r3
.word c3,r3
.word c4,r3
.word c1,r4
.word c2,r4
.word c3,r4
.word c4,r4
2017-09-11 05:58:30 +00:00
2017-09-14 04:58:37 +00:00
.proc bitmap_table
2017-09-12 04:06:37 +00:00
.addr piece1, piece2, piece3, piece4
.addr piece5, piece6, piece7, piece8
.addr piece9, piece10, piece11, piece12
.addr piece13, piece14, piece15, piece16
2017-09-11 05:58:30 +00:00
.endproc
2017-09-11 06:09:33 +00:00
;; Current position table
position_table:
.res 16, 0
2017-09-11 05:58:30 +00:00
2017-09-14 04:58:37 +00:00
.proc draw_bitmap_params
2017-09-11 05:58:30 +00:00
left: .word 0
top: .word 0
addr: .addr 0
stride: .byte 4
.byte 0 ; ???
2017-10-08 03:22:39 +00:00
hoff: .word 0
voff: .word 0
2017-09-11 05:58:30 +00:00
width: .word 27
height: .word 15
.endproc
piece1:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece2:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%0000000),px(%0011111),px(%1111110)
.byte px(%0111000),px(%1010101),px(%0100001),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece3:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1110001),px(%1111110)
.byte px(%0111111),px(%1111111),px(%0010101),px(%0111110)
.byte px(%0111111),px(%1111101),px(%0101010),px(%1011110)
.byte px(%0111111),px(%1110010),px(%1010101),px(%0111110)
.byte px(%0111111),px(%1100101),px(%0101010),px(%0111110)
.byte px(%0111111),px(%0001010),px(%1010100),px(%1111110)
.byte px(%0111110),px(%1010101),px(%0101001),px(%1111110)
.byte px(%0111101),px(%0101010),px(%1000111),px(%1111110)
.byte px(%0111010),px(%1010101),px(%0011111),px(%1111110)
.byte px(%0110101),px(%0101000),px(%0111111),px(%1111110)
.byte px(%0110010),px(%1010011),px(%1111111),px(%1111110)
.byte px(%0110101),px(%0001111),px(%1111100),px(%0000000)
.byte px(%0110000),px(%1111111),px(%1000010),px(%1010100)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece4:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0000111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0101000),px(%0111111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece5:
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1110100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1101010)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1011110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%0111110)
.byte px(%0111111),px(%1111111),px(%1111110),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111101),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111101),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111011),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1110111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1110111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1110110),px(%1101100)
.byte px(%0111111),px(%1111111),px(%1101101),px(%1011010)
.byte px(%0111111),px(%1111111),px(%1101011),px(%0110110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece6:
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0010101),px(%0101010),px(%1010101),px(%0101010)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0010101),px(%0101010),px(%1010101),px(%0101010)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0110110),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0101101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece7:
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0010101),px(%0101010),px(%1010101),px(%0101010)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0010101),px(%0101010),px(%1010101),px(%0101010)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0110110),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0101101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece8:
.byte px(%0101010),px(%1010001),px(%1111111),px(%1111110)
.byte px(%0010101),px(%0101010),px(%0111111),px(%1111110)
.byte px(%0101010),px(%1010101),px(%0001111),px(%1111110)
.byte px(%0010101),px(%0101010),px(%1000111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%0011111),px(%1111110)
.byte px(%0111111),px(%1111110),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111101),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111011),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1110111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1110111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1101111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1101111),px(%1111111),px(%1111110)
.byte px(%0101101),px(%1001111),px(%1111111),px(%1111110)
.byte px(%0011011),px(%0011111),px(%1111111),px(%1111110)
.byte px(%0110110),px(%1011111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece9:
.byte px(%0111111),px(%1111111),px(%1110011),px(%0110110)
.byte px(%0111111),px(%1111111),px(%1110110),px(%1101100)
.byte px(%0111111),px(%1111111),px(%1110101),px(%1011010)
.byte px(%0111111),px(%1111111),px(%1110011),px(%0110110)
.byte px(%0111111),px(%1111111),px(%1111010),px(%1010100)
.byte px(%0111111),px(%1111111),px(%1111010),px(%1010100)
.byte px(%0111111),px(%1111111),px(%1111100),px(%1010100)
.byte px(%0111111),px(%1111111),px(%1111110),px(%1010100)
.byte px(%0111111),px(%1111111),px(%1111110),px(%1010100)
.byte px(%0111111),px(%1111111),px(%1111110),px(%1010100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%0010100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1001100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1100110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1110100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111010)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece10:
.byte px(%0101101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0110110),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0101101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0100110),px(%0110011),px(%0011001),px(%1001100)
.byte px(%0110011),px(%0011001),px(%1001100),px(%1100110)
.byte px(%0100110),px(%0110011),px(%0011001),px(%1001100)
.byte px(%0110011),px(%0011001),px(%1001100),px(%1100110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece11:
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0110110),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0101101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0101010),px(%1010101),px(%0101010),px(%1010100)
.byte px(%0100110),px(%0110011),px(%0011001),px(%1001100)
.byte px(%0110011),px(%0011001),px(%1001100),px(%1100110)
.byte px(%0100110),px(%0110011),px(%0011001),px(%1001100)
.byte px(%0110011),px(%0011001),px(%1001100),px(%1100110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece12:
.byte px(%0110110),px(%1011111),px(%1111111),px(%1111110)
.byte px(%0101101),px(%1011111),px(%1111111),px(%1111110)
.byte px(%0011011),px(%0101111),px(%1111111),px(%1111110)
.byte px(%0110110),px(%1101111),px(%1111111),px(%1111110)
.byte px(%0101010),px(%1010111),px(%1111111),px(%1111110)
.byte px(%0101010),px(%1010011),px(%1111111),px(%1111110)
.byte px(%0101010),px(%1010011),px(%1111111),px(%1111110)
.byte px(%0101010),px(%1010101),px(%1111111),px(%1111110)
.byte px(%0101010),px(%1010100),px(%1111111),px(%1111110)
.byte px(%0101010),px(%1010101),px(%0011111),px(%1111110)
.byte px(%0101010),px(%1010101),px(%0100111),px(%1111110)
.byte px(%0100110),px(%0110011),px(%0010111),px(%1111110)
.byte px(%0110011),px(%0011001),px(%1001111),px(%1111110)
.byte px(%0100110),px(%0110011),px(%0001111),px(%1111110)
.byte px(%0110011),px(%0011001),px(%1011111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
2017-09-12 03:38:58 +00:00
piece13: ; the hole
2017-09-11 05:58:30 +00:00
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111011),px(%1011101),px(%1101110),px(%1110110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0101110),px(%1110111),px(%0111011),px(%1011100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111011),px(%1011101),px(%1101110),px(%1110110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0101110),px(%1110111),px(%0111011),px(%1011100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111011),px(%1011101),px(%1101110),px(%1110110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0101110),px(%1110111),px(%0111011),px(%1011100)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111011),px(%1011101),px(%1101110),px(%1110110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece14:
.byte px(%0001100),px(%1100110),px(%0110011),px(%0011000)
.byte px(%0100110),px(%0110011),px(%0011001),px(%1001100)
.byte px(%0110011),px(%0011001),px(%1001100),px(%1100110)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0100101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0110010),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0111001),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0111110),px(%0111011),px(%0110110),px(%1101100)
.byte px(%0111111),px(%1000101),px(%1011000),px(%0000000)
.byte px(%0111111),px(%1111000),px(%0000001),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece15:
.byte px(%0001100),px(%1100110),px(%0110011),px(%0011000)
.byte px(%0100110),px(%0110011),px(%0011001),px(%1001100)
.byte px(%0110011),px(%0011001),px(%1001100),px(%1100110)
.byte px(%0110110),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0101101),px(%1011011),px(%0110110),px(%1101100)
.byte px(%0110110),px(%1101101),px(%1011011),px(%0110110)
.byte px(%0011011),px(%0110110),px(%1101101),px(%1011010)
.byte px(%0000000),px(%0000000),px(%0000110),px(%1101100)
.byte px(%0111111),px(%1111111),px(%1100000),px(%0000010)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
piece16:
.byte px(%0001100),px(%1100110),px(%0011111),px(%1111110)
.byte px(%0100110),px(%0110011),px(%0111111),px(%1111110)
.byte px(%0110011),px(%0011000),px(%1111111),px(%1111110)
.byte px(%0101101),px(%1011001),px(%1111111),px(%1111110)
.byte px(%0110110),px(%1100111),px(%1111111),px(%1111110)
.byte px(%0011011),px(%0011111),px(%1111111),px(%1111110)
.byte px(%0101110),px(%0111111),px(%1111111),px(%1111110)
.byte px(%0100111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0111111),px(%1111111),px(%1111111),px(%1111110)
.byte px(%0000000),px(%0000000),px(%0000000),px(%0000000)
.proc fill_rect_params
2017-09-12 04:06:37 +00:00
.word 1, 0, default_width, default_height
.endproc
.proc pattern_speckles
.byte $77,$DD,$77,$DD,$77,$DD,$77,$DD
.endproc
.byte $00 ; ???
.proc pattern_black
.res 8, 0
.endproc
2017-09-11 05:58:30 +00:00
2017-09-12 04:06:37 +00:00
;; ???
.byte $00
.res 8, $FF
.byte $00
2017-09-19 04:43:35 +00:00
;; line across top of puzzle (bitmaps include bottom edges)
.proc set_pos_params
xcoord: .word 5
ycoord: .word 2
.endproc
.proc draw_line_params
xdelta: .word 112
ydelta: .word 0
.endproc
2017-09-12 03:38:58 +00:00
;; hole position (0..3, 0..3)
hole_x: .byte 0
hole_y: .byte 0
;; click location (0..3, 0..3)
click_x: .byte $00
2017-09-15 02:11:21 +00:00
click_y: .byte $00
2017-09-12 03:38:58 +00:00
;; param for draw_row/draw_col
draw_rc: .byte $00
;; params for draw_selected
draw_end: .byte $00
draw_inc: .byte $00
2017-09-12 04:06:37 +00:00
.proc destroy_window_params
id: .byte window_id
.endproc
2017-09-15 02:11:21 +00:00
.byte $73,$00,$F7,$FF
.addr str
.byte $01
.byte $00,$00,$00,$00,$00,$06,$00,$05
2017-09-15 02:11:21 +00:00
.byte $00
str: .byte $41,$35,$47,$37,$36,$49 ; "A#G%#I" ?
2017-09-14 04:35:23 +00:00
;; SET_STATE params (filled in by QUERY_STATE)
2017-09-15 02:11:21 +00:00
set_state_params:
2017-09-12 04:06:37 +00:00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$0D
.byte $00,$00,$20,$80,$00,$00,$00,$00
.byte $00,$2F,$02,$B1,$00,$00,$01,$02
.byte $06
2017-09-12 03:38:58 +00:00
2017-09-12 04:06:37 +00:00
default_left := 220
default_top := 80
default_width := $79
default_height := $44
2017-09-12 03:38:58 +00:00
.proc create_window_params
2017-09-12 04:06:37 +00:00
id: .byte window_id
2017-09-12 03:38:58 +00:00
flags: .byte A2D_CWF_ADDCLOSE
title: .addr name
hscroll:.byte A2D_CWS_NOSCROLL
vscroll:.byte A2D_CWS_NOSCROLL
2017-09-12 03:38:58 +00:00
hsmax: .byte 0
hspos: .byte 0
vsmax: .byte 0
vspos: .byte 0
2017-09-15 02:11:21 +00:00
.byte 0,0 ; ???
w1: .word default_width
h1: .word default_height
w2: .word default_width
h2: .word default_height
2017-09-12 03:38:58 +00:00
2017-09-12 04:06:37 +00:00
left: .word default_left
top: .word default_top
2017-10-08 03:22:39 +00:00
addr: .addr A2D_SCREEN_ADDR
2017-09-12 03:38:58 +00:00
stride: .word A2D_SCREEN_STRIDE
2017-10-08 03:22:39 +00:00
hoff: .word 0
voff: .word 0
2017-09-12 03:38:58 +00:00
width: .word default_width
height: .word default_height
pattern:.res 8, $FF
2017-09-15 08:02:38 +00:00
mskand: .byte A2D_DEFAULT_MSKAND
mskor: .byte A2D_DEFAULT_MSKOR
2017-10-07 20:59:25 +00:00
xpos: .word 0
ypos: .word 0
hthick: .byte 1
vthick: .byte 1
2017-10-08 03:22:39 +00:00
mode: .byte 0
tmask: .byte $7F
font: .addr A2D_DEFAULT_FONT
next: .addr 0
2017-09-15 02:11:21 +00:00
.endproc
2017-09-14 04:35:23 +00:00
;; This is QUERY_STATE/SET_BOX cruft only below
2017-09-15 02:11:21 +00:00
.proc box_cruft ; Unknown usage
left: .word default_left
top: .word default_top
2017-10-08 03:22:39 +00:00
addr: .addr A2D_SCREEN_ADDR
2017-09-15 02:11:21 +00:00
stride: .word A2D_SCREEN_STRIDE
2017-10-08 03:22:39 +00:00
hoff: .word 0
voff: .word 0
2017-09-15 02:11:21 +00:00
width: .word default_width
height: .word default_height
pattern:.res 8, $FF
2017-09-15 08:02:38 +00:00
mskand: .byte A2D_DEFAULT_MSKAND
mskor: .byte A2D_DEFAULT_MSKOR
2017-10-07 20:59:25 +00:00
xpos: .word 0
ypos: .word 0
2017-09-15 02:11:21 +00:00
hthick: .byte 1
vthick: .byte 1
2017-10-08 03:22:39 +00:00
mode: .byte 0
tmask: .byte $7F
font: .addr A2D_DEFAULT_FONT
.byte 0,0 ; ???
2017-09-12 03:38:58 +00:00
.endproc
2017-09-15 02:11:21 +00:00
2017-09-12 03:38:58 +00:00
name: PASCAL_STRING "Puzzle"
2017-09-12 04:06:37 +00:00
create_window_params_top := create_window_params::top
2017-09-11 06:09:33 +00:00
;;; ==================================================
;;; Create the window
2017-09-12 03:38:58 +00:00
.proc create_window
jsr save_zp
A2D_CALL A2D_CREATE_WINDOW, create_window_params
;; init pieces
ldy #15
loop: tya
2017-09-11 06:09:33 +00:00
sta position_table,y
dey
2017-09-12 03:38:58 +00:00
bpl loop
2017-09-11 06:09:33 +00:00
lda #window_id
2017-09-15 02:11:21 +00:00
jsr check_window_pos
2017-09-12 04:06:37 +00:00
A2D_CALL $2B ; ???
;; Scramble?
2017-09-15 02:11:21 +00:00
.proc scramble
ldy #3
sloop: tya
pha
2017-09-11 06:09:33 +00:00
ldx position_table
2017-09-12 03:38:58 +00:00
ldy #0
ploop: lda position_table+1,y
2017-09-11 06:09:33 +00:00
sta position_table,y
iny
2017-09-12 03:38:58 +00:00
cpy #15
bcc ploop
2017-09-11 06:09:33 +00:00
stx position_table+15
pla
tay
dey
2017-09-15 02:11:21 +00:00
bne sloop
2017-09-11 06:09:33 +00:00
ldx position_table
lda position_table+1
sta position_table
stx position_table+1
2017-09-15 02:11:21 +00:00
.endproc
2017-09-12 03:38:58 +00:00
A2D_CALL A2D_GET_INPUT, get_input_params
lda get_input_params::state
2017-09-15 02:11:21 +00:00
beq scramble
2017-09-11 06:38:20 +00:00
jsr check_victory
2017-09-15 02:11:21 +00:00
bcs scramble
2017-09-12 03:38:58 +00:00
jsr draw_all
jsr find_hole
; fall through
.endproc
;;; ==================================================
;;; Input loop and processing
2017-09-12 03:38:58 +00:00
.proc input_loop
A2D_CALL A2D_GET_INPUT, get_input_params
lda get_input_params::state
cmp #A2D_INPUT_DOWN
bne :+
2017-09-12 03:38:58 +00:00
jsr on_click
jmp input_loop
;; key?
: cmp #A2D_INPUT_KEY
bne input_loop
jsr check_key
jmp input_loop
;; click - where?
2017-09-12 03:38:58 +00:00
on_click:
A2D_CALL A2D_QUERY_TARGET, query_target_params
2017-09-12 04:06:37 +00:00
lda query_target_params::id
2017-09-11 06:09:33 +00:00
cmp #window_id
bne bail
2017-09-12 04:06:37 +00:00
lda query_target_params::element
bne :+
bail: rts
;; client area?
: cmp #A2D_ELEM_CLIENT
bne :+
jsr find_click_piece
bcc bail
2017-09-12 06:16:29 +00:00
jmp process_click
;; close box?
: cmp #A2D_ELEM_CLOSE
bne check_title
2017-09-12 03:38:58 +00:00
A2D_CALL A2D_CLOSE_CLICK, close_click_params
lda close_click_params::clicked
beq bail
2017-09-12 03:38:58 +00:00
destroy:
A2D_CALL A2D_DESTROY_WINDOW, destroy_window_params
DESKTOP_CALL DESKTOP_REDRAW_ICONS
2017-09-11 03:40:32 +00:00
2017-09-12 03:38:58 +00:00
target = $20 ; copy following to ZP and run it
ldx #sizeof_routine
loop: lda routine,x
sta target,x
dex
2017-09-12 03:38:58 +00:00
bpl loop
jmp target
2017-09-12 03:38:58 +00:00
.proc routine
2017-09-15 02:11:21 +00:00
sta RAMRDOFF
sta RAMWRTOFF
jmp exit_da
2017-09-12 03:38:58 +00:00
.endproc
sizeof_routine := * - routine
;; title bar?
check_title:
cmp #A2D_ELEM_TITLE
bne bail
2017-09-11 06:09:33 +00:00
lda #window_id
sta drag_window_params::id
A2D_CALL A2D_DRAG_WINDOW, drag_window_params
ldx #$23
2017-09-18 15:10:19 +00:00
jsr redraw_screen
rts
;; on key press - exit if Escape
check_key:
lda get_input_params::modifiers
bne :+
lda get_input_params::key
2017-09-15 04:13:54 +00:00
cmp #KEY_ESCAPE
2017-09-12 03:38:58 +00:00
beq destroy
: rts
2017-09-12 03:38:58 +00:00
.endproc
;;; ==================================================
;;; Map click to piece x/y
.proc find_click_piece
2017-09-15 02:11:21 +00:00
lda #window_id
sta map_coords_params::id
A2D_CALL A2D_MAP_COORDS, map_coords_params
lda map_coords_params::clientx+1
ora map_coords_params::clienty+1
bne nope ; ensure high bytes are 0
lda map_coords_params::clienty
ldx map_coords_params::clientx
2017-09-12 03:38:58 +00:00
cmp #r1
bcc nope
2017-09-12 03:38:58 +00:00
cmp #r2+1
bcs :+
2017-09-15 02:11:21 +00:00
jsr find_click_x
bcc nope
lda #0
beq yep
2017-09-12 03:38:58 +00:00
: cmp #r3+1
bcs :+
2017-09-15 02:11:21 +00:00
jsr find_click_x
bcc nope
lda #1
bne yep
2017-09-12 03:38:58 +00:00
: cmp #r4+1
bcs :+
2017-09-15 02:11:21 +00:00
jsr find_click_x
bcc nope
lda #2
bne yep
2017-09-12 03:38:58 +00:00
: cmp #r4+rh+1
bcs nope
2017-09-15 02:11:21 +00:00
jsr find_click_x
bcc nope
lda #3
2017-09-15 02:11:21 +00:00
yep: sta click_y
sec
rts
nope: clc
rts
.endproc
2017-09-15 02:11:21 +00:00
.proc find_click_x
2017-09-12 03:38:58 +00:00
cpx #c1
bcc nope
2017-09-12 03:38:58 +00:00
cpx #c2
bcs :+
lda #0
beq yep
2017-09-12 03:38:58 +00:00
: cpx #c3+1
bcs :+
lda #1
bne yep
2017-09-12 03:38:58 +00:00
: cpx #c4+1
bcs :+
lda #2
bne yep
2017-09-12 03:38:58 +00:00
: cpx #c4+cw
bcs nope
lda #3
2017-09-15 02:11:21 +00:00
yep: sta click_x
sec
rts
nope: clc
rts
.endproc
;;; ==================================================
;;; Process piece click
2017-09-12 03:38:58 +00:00
hole_piece := 12
2017-09-12 06:16:29 +00:00
.proc process_click
2017-09-15 02:11:21 +00:00
2017-09-12 06:16:29 +00:00
lda #0
2017-09-12 03:38:58 +00:00
ldy hole_y
beq L0FC9
L0FC3: clc
2017-09-12 06:16:29 +00:00
adc #4
dey
bne L0FC3
2017-09-15 02:11:21 +00:00
2017-09-12 03:38:58 +00:00
L0FC9: sta draw_rc
clc
2017-09-12 03:38:58 +00:00
adc hole_x
tay
2017-09-12 03:38:58 +00:00
lda click_x
2017-09-15 02:11:21 +00:00
cmp hole_x
beq click_in_col
lda click_y
2017-09-12 03:38:58 +00:00
cmp hole_y
2017-09-15 02:11:21 +00:00
beq click_in_row
miss: rts ; Click on hole, or not row/col with hole
2017-09-15 02:11:21 +00:00
.proc click_in_row
lda click_x
2017-09-12 03:38:58 +00:00
cmp hole_x
2017-09-15 02:11:21 +00:00
beq miss
bcs after
lda hole_x ; click before of hole
sec
2017-09-15 02:11:21 +00:00
sbc click_x
tax
2017-09-15 02:11:21 +00:00
bloop: lda position_table-1,y
2017-09-11 06:09:33 +00:00
sta position_table,y
dey
dex
2017-09-15 02:11:21 +00:00
bne bloop
2017-09-12 06:16:29 +00:00
beq row
2017-09-15 02:11:21 +00:00
after: lda click_x ; click after hole
sec
2017-09-12 03:38:58 +00:00
sbc hole_x
tax
2017-09-15 02:11:21 +00:00
aloop: lda position_table+1,y
2017-09-11 06:09:33 +00:00
sta position_table,y
iny
dex
2017-09-15 02:11:21 +00:00
bne aloop
2017-09-12 06:16:29 +00:00
beq row
2017-09-15 02:11:21 +00:00
.endproc
.proc click_in_col
lda click_y
2017-09-12 03:38:58 +00:00
cmp hole_y
2017-09-15 02:11:21 +00:00
beq miss
bcs after
lda hole_y ; click before hole
sec
2017-09-15 02:11:21 +00:00
sbc click_y
tax
2017-09-15 02:11:21 +00:00
bloop: lda position_table-4,y
2017-09-11 06:09:33 +00:00
sta position_table,y
dey
dey
dey
dey
dex
2017-09-15 02:11:21 +00:00
bne bloop
2017-09-12 06:16:29 +00:00
beq col
2017-09-15 02:11:21 +00:00
after: lda click_y ; click after hole
sec
2017-09-12 03:38:58 +00:00
sbc hole_y
tax
2017-09-15 02:11:21 +00:00
aloop: lda position_table+4,y
2017-09-11 06:09:33 +00:00
sta position_table,y
iny
iny
iny
iny
dex
2017-09-15 02:11:21 +00:00
bne aloop
.endproc
2017-09-12 06:16:29 +00:00
col: lda #hole_piece
2017-09-11 06:09:33 +00:00
sta position_table,y
2017-09-12 03:38:58 +00:00
jsr draw_col
2017-09-12 06:16:29 +00:00
jmp done
2017-09-12 06:16:29 +00:00
row: lda #hole_piece
2017-09-11 06:09:33 +00:00
sta position_table,y
2017-09-12 03:38:58 +00:00
jsr draw_row
2017-09-12 06:16:29 +00:00
done: jsr check_victory
2017-09-15 02:11:21 +00:00
bcc after_click
2017-09-12 06:16:29 +00:00
;; Yay! Play the sound 4 times
2017-09-15 02:11:21 +00:00
.proc on_victory
2017-09-12 03:38:58 +00:00
ldx #4
2017-09-15 02:11:21 +00:00
loop: txa
pha
jsr play_sound
pla
tax
dex
2017-09-15 02:11:21 +00:00
bne loop
.endproc
after_click:
jmp find_hole
2017-09-12 06:16:29 +00:00
rts ; ???
.endproc
;;; ==================================================
;;; Clear the background
2017-09-15 02:11:21 +00:00
draw_window:
A2D_CALL A2D_SET_PATTERN, pattern_speckles
A2D_CALL A2D_FILL_RECT, fill_rect_params
A2D_CALL A2D_SET_PATTERN, pattern_black
2017-09-19 04:43:35 +00:00
A2D_CALL A2D_SET_POS, set_pos_params
2017-09-19 04:43:35 +00:00
A2D_CALL A2D_DRAW_LINE, draw_line_params
2017-09-12 03:38:58 +00:00
jsr draw_all
2017-09-11 06:09:33 +00:00
lda #window_id
2017-09-15 02:11:21 +00:00
sta query_state_params::id
A2D_CALL A2D_QUERY_STATE, query_state_params
A2D_CALL A2D_SET_STATE, set_state_params
rts
;;; ==================================================
2017-09-11 06:38:20 +00:00
.proc save_zp
ldx #$00
loop: lda $00,x
sta saved_zp,x
dex
2017-09-11 06:38:20 +00:00
bne loop
rts
2017-09-11 06:38:20 +00:00
.endproc
2017-09-11 06:38:20 +00:00
.proc restore_zp
ldx #$00
2017-09-11 06:38:20 +00:00
loop: lda saved_zp,x
sta $00,x
dex
2017-09-11 06:38:20 +00:00
bne loop
rts
2017-09-11 06:38:20 +00:00
.endproc
2017-09-11 06:38:20 +00:00
saved_zp:
.res 256, 0
2017-09-11 03:40:32 +00:00
;;; ==================================================
;;; Draw pieces
2017-09-12 03:38:58 +00:00
.proc draw_all
ldy #1
sty draw_inc
dey
2017-09-12 03:38:58 +00:00
lda #16
sta draw_end
bne draw_selected
.endproc
.proc draw_row ; row specified in draw_rc
lda #1
sta draw_inc
lda draw_rc
tay
clc
2017-09-12 03:38:58 +00:00
adc #4
sta draw_end
bne draw_selected
.endproc
.proc draw_col ; col specified in draw_rc
lda #4
sta draw_inc
ldy hole_x
lda #16
sta draw_end
;; fall through
.endproc
;; Draw pieces from A to draw_end, step draw_inc
.proc draw_selected
tya
pha
2017-09-11 03:40:32 +00:00
A2D_CALL A2D_HIDE_CURSOR
2017-09-11 06:09:33 +00:00
lda #window_id
2017-09-15 02:11:21 +00:00
sta query_state_params::id
A2D_CALL A2D_QUERY_STATE, query_state_params
A2D_CALL A2D_SET_STATE, set_state_params
pla
tay
2017-09-12 03:38:58 +00:00
loop: tya
pha
asl a
asl a
tax
2017-09-12 03:38:58 +00:00
lda space_positions,x
2017-09-14 04:58:37 +00:00
sta draw_bitmap_params::left
2017-09-12 03:38:58 +00:00
lda space_positions+1,x
2017-09-14 04:58:37 +00:00
sta draw_bitmap_params::left+1
2017-09-12 03:38:58 +00:00
lda space_positions+2,x
2017-09-14 04:58:37 +00:00
sta draw_bitmap_params::top
2017-09-12 03:38:58 +00:00
lda space_positions+3,x
2017-09-14 04:58:37 +00:00
sta draw_bitmap_params::top+1
2017-09-11 06:09:33 +00:00
lda position_table,y
asl a
tax
2017-09-14 04:58:37 +00:00
lda bitmap_table,x
sta draw_bitmap_params::addr
lda bitmap_table+1,x
sta draw_bitmap_params::addr+1
A2D_CALL A2D_DRAW_BITMAP, draw_bitmap_params
pla
clc
2017-09-12 03:38:58 +00:00
adc draw_inc
tay
2017-09-12 03:38:58 +00:00
cpy draw_end
bcc loop
2017-09-11 03:40:32 +00:00
A2D_CALL A2D_SHOW_CURSOR
rts
2017-09-12 03:38:58 +00:00
.endproc
;;; ==================================================
;;; Play sound
.proc play_sound
ldx #$80
2017-09-12 03:38:58 +00:00
loop1: lda #$58
loop2: ldy #$1B
delay1: dey
bne delay1
bit SPKR
tay
2017-09-12 03:38:58 +00:00
delay2: dey
bne delay2
sbc #1
beq loop1
bit SPKR
dex
2017-09-12 03:38:58 +00:00
bne loop2
rts
.endproc
;;; ==================================================
;;; Puzzle complete?
2017-09-11 06:38:20 +00:00
;; Returns with carry set if puzzle complete
.proc check_victory ; Allows for swapped indistinct pieces, etc.
;; 0/12 can be swapped
lda position_table
beq :+
cmp #12
bne nope
: ldy #1
c1234: tya
2017-09-11 06:09:33 +00:00
cmp position_table,y
2017-09-11 06:38:20 +00:00
bne nope
iny
2017-09-11 06:38:20 +00:00
cpy #5
bcc c1234
;; 5/6 are identical
2017-09-11 06:09:33 +00:00
lda position_table+5
2017-09-11 06:38:20 +00:00
cmp #5
beq :+
cmp #6
bne nope
: lda position_table+6
cmp #5
beq :+
cmp #6
bne nope
: lda position_table+7
cmp #7
bne nope
2017-09-11 06:09:33 +00:00
lda position_table+8
2017-09-11 06:38:20 +00:00
cmp #8
bne nope
;; 9/10 are identical
2017-09-11 06:09:33 +00:00
lda position_table+9
2017-09-11 06:38:20 +00:00
cmp #9
beq :+
cmp #10
bne nope
: lda position_table+10
cmp #9
beq :+
cmp #10
bne nope
: lda position_table+11
cmp #11
bne nope
;; 0/12 can be swapped
2017-09-11 06:09:33 +00:00
lda position_table+12
2017-09-11 06:38:20 +00:00
beq :+
cmp #12
bne nope
: ldy #13
c131415:tya
2017-09-11 06:09:33 +00:00
cmp position_table,y
2017-09-11 06:38:20 +00:00
bne nope
iny
2017-09-11 06:38:20 +00:00
cpy #16
bcc c131415
rts
2017-09-11 06:38:20 +00:00
nope: clc
rts
2017-09-11 06:38:20 +00:00
.endproc
2017-09-12 03:38:58 +00:00
;;; ==================================================
;;; Find hole piece
2017-09-12 03:38:58 +00:00
.proc find_hole
ldy #15
loop: lda position_table,y
cmp #hole_piece
beq :+
dey
2017-09-12 03:38:58 +00:00
bpl loop
: lda #0
sta hole_x
sta hole_y
tya
2017-09-12 03:38:58 +00:00
again: cmp #4
bcc done
2017-09-11 06:09:33 +00:00
sbc #4
2017-09-12 03:38:58 +00:00
inc hole_y
bne again
done: sta hole_x
rts
2017-09-12 03:38:58 +00:00
.endproc
last := *