comparison menu.s68 @ 1011:4a14d80584b6

Fully functional next/previous buttons
author Michael Pavone <pavone@retrodev.com>
date Sun, 01 May 2016 23:44:14 -0700
parents edab85c29d4d
children 8c90982429e3
comparison
equal deleted inserted replaced
1010:edab85c29d4d 1011:4a14d80584b6
180 page_stack rs.l 1 180 page_stack rs.l 1
181 page_pointers rs.l 1024 181 page_pointers rs.l 1024
182 mouse_sprite rs.l 1 182 mouse_sprite rs.l 1
183 menu_functions rs.l 1 183 menu_functions rs.l 1
184 cursor_show_fun rs.l 1 184 cursor_show_fun rs.l 1
185 special_click rs.l 1
185 mouse_x rs.w 1 186 mouse_x rs.w 1
186 selection_top rs.w 1 187 selection_top rs.w 1
187 selection_bot rs.w 1 188 selection_bot rs.w 1
188 selection_mask rs.w 1 189 selection_mask rs.w 1
189 num_sprites rs.b 1 190 num_sprites rs.b 1
421 move.w #$100, mouse_x.w 422 move.w #$100, mouse_x.w
422 addq #1, d2 423 addq #1, d2
423 move.b d2, num_sprites.w 424 move.b d2, num_sprites.w
424 425
425 move.b #1, mouse_shown.w 426 move.b #1, mouse_shown.w
427
428 move.l cursor_show_fun.w, d2
429 beq .skip_show_check
430 move.l d2, a2
431 jsr (a2)
432
426 433
427 .skip_show_check 434 .skip_show_check
428 neg.w d1 435 neg.w d1
429 move.l mouse_sprite.w, a2 436 move.l mouse_sprite.w, a2
430 add.w d1, (a2) 437 add.w d1, (a2)
434 move.w d0, (6, a2) 441 move.w d0, (6, a2)
435 move.w (a2), d1 442 move.w (a2), d1
436 cmp.w selection_top.w, d1 443 cmp.w selection_top.w, d1
437 blo .done 444 blo .done
438 cmp.w selection_bot.w, d1 445 cmp.w selection_bot.w, d1
439 bhi .done 446 bhi .special_click
440 tst.b num_menu.w 447 tst.b num_menu.w
441 bne .handle_menu 448 bne .handle_menu
442 tst.b num_slots.w 449 tst.b num_slots.w
443 bne .handle_slots 450 bne .handle_slots
444 and.w #$FFF0, d1 451 and.w #$FFF0, d1
447 move.w d1, (sprite_list+8).w 454 move.w d1, (sprite_list+8).w
448 455
449 sub.w #264, d1 456 sub.w #264, d1
450 lsr.w #4, d1 457 lsr.w #4, d1
451 move.b d1, selected.w 458 move.b d1, selected.w
452 bra .no_mouse_move 459 bra .normal_click
453 .handle_menu 460 .handle_menu
454 ;TODO: FIXME 461 ;TODO: FIXME
455 and.w #$FFF0, d1 462 and.w #$FFF0, d1
456 moveq #0, d0 463 moveq #0, d0
457 move.w d1, d0 464 move.w d1, d0
479 move.w d1, (sprite_list).w 486 move.w d1, (sprite_list).w
480 move.w d1, (sprite_list+8).w 487 move.w d1, (sprite_list+8).w
481 488
482 move.b d0, selected.w 489 move.b d0, selected.w
483 490
484 bra .no_mouse_move 491 bra .normal_click
485 .handle_slots 492 .handle_slots
486 and.w #$FFE0, d1 493 and.w #$FFE0, d1
487 subq #8, d1 494 subq #8, d1
488 move.w d1, (sprite_list).w 495 move.w d1, (sprite_list).w
489 move.w d1, (sprite_list+8).w 496 move.w d1, (sprite_list+8).w
490 497
491 sub.w #264, d1 498 sub.w #264, d1
492 lsr.w #5, d1 499 lsr.w #5, d1
493 move.b d1, selected.w 500 move.b d1, selected.w
494 .no_mouse_move 501 .normal_click
495 btst #0, d4 502 btst #0, d4
496 bne select_entry 503 bne select_entry
497 .done 504 .done
498 rts 505 rts
506 .no_mouse_move
507 tst.b mouse_shown
508 bne .skip_show_check
509 rts
510 .special_click:
511 btst #0, d4
512 beq .done
513 move.l special_click.w, d2
514 beq .done
515 move.l d2, a2
516 jmp (a2)
499 int_4: 517 int_4:
500 empty_handler: 518 empty_handler:
501 rte 519 rte
502 520
503 id_lookup: 521 id_lookup:
684 draw_menu: 702 draw_menu:
685 moveq #0, d7 703 moveq #0, d7
686 moveq #0, d5 704 moveq #0, d5
687 ;clear out save slot state 705 ;clear out save slot state
688 move.b d5, num_slots.w 706 move.b d5, num_slots.w
707 ;clear out event handlers
708 move.l d5, cursor_show_fun.w
709 move.l d5, special_click.w
689 ;select first item 710 ;select first item
690 move.b d7, selected.w 711 move.b d7, selected.w
691 ;save menu pointer for second pass 712 ;save menu pointer for second pass
692 movea.l a5, a4 713 movea.l a5, a4
693 ;adjust arrow mask 714 ;adjust arrow mask
879 lea pause_menu(pc), a5 900 lea pause_menu(pc), a5
880 bsr draw_menu 901 bsr draw_menu
881 bra gamepad_setup 902 bra gamepad_setup
882 903
883 menu_start: 904 menu_start:
905 moveq #0, d0
884 ;init vertical scroll RAM 906 ;init vertical scroll RAM
885 vdpaccess $0, VDP_VSRAM_WRITE 907 vdpaccess $0, VDP_VSRAM_WRITE
886 move.w #0, (a0) 908 move.w d0, (a0)
887 move.w #0, (a0) 909 move.w d0, (a0)
888 910
889 ;reset arrow position 911 ;reset arrow position
890 move.w #$0108, sprite_list.w 912 move.w #$0108, sprite_list.w
891 move.w #$0108, (sprite_list + 8).w 913 move.w #$0108, (sprite_list + 8).w
892 move.w #$0086, (sprite_list + 6).w 914 move.w #$0086, (sprite_list + 6).w
893 move.w #$01AA, (sprite_list + 6 + 8).w 915 move.w #$01AA, (sprite_list + 6 + 8).w
894 916
895 ;reset selection 917 ;reset selection
896 move.b #0, selected.w 918 move.b d0, selected.w
919
920 ;reset special click handler
921 move.l d0, special_click.w
897 922
898 923
899 lea page_pointers.w, a5 924 lea page_pointers.w, a5
900 lea dir_buffer, a6 925 lea dir_buffer, a6
901 move.l a6, (a5)+ 926 move.l a6, (a5)+
1000 1025
1001 cmp.l #(page_pointers+8), a5 1026 cmp.l #(page_pointers+8), a5
1002 beq .no_prev_page 1027 beq .no_prev_page
1003 1028
1004 ;draw Prev button 1029 ;draw Prev button
1005 moveq #4, d0 1030 moveq #3, d0
1006 moveq #26, d1 1031 moveq #26, d1
1007 moveq #6, d2 1032 moveq #6, d2
1008 bsr draw_button 1033 bsr draw_button
1009 1034
1010 ;base attribute 1035 ;base attribute
1011 move.w #$206B, d0 1036 move.w #$206B, d0
1012 ;x pos 1037 ;x pos
1013 moveq #6, d1 1038 moveq #5, d1
1014 ;y pos 1039 ;y pos
1015 moveq #26, d2 1040 moveq #26, d2
1016 lea prev_str(pc), a6 1041 lea prev_str(pc), a6
1017 bsr print_string_fixed 1042 bsr print_string_fixed
1018 1043
1020 1045
1021 move.l #0, cursor_show_fun.w 1046 move.l #0, cursor_show_fun.w
1022 1047
1023 bra .done_page_buttons 1048 bra .done_page_buttons
1024 .no_mouse 1049 .no_mouse
1025 ;TODO - setup cusrsor_show_fun 1050 move.l #show_prev_next_buttons, cursor_show_fun.w
1026 .done_page_buttons 1051 .done_page_buttons
1052 move.l #handle_prev_next_click, special_click.w
1027 1053
1028 gamepad_setup: 1054 gamepad_setup:
1029 ;setup gamepads 1055 ;setup gamepads
1030 move.b #$40, PAD1_CTRL 1056 move.b #$40, PAD1_CTRL
1031 move.b #$40, PAD2_CTRL 1057 move.b #$40, PAD2_CTRL
1034 1060
1035 1061
1036 wait_forever 1062 wait_forever
1037 stop #2500 1063 stop #2500
1038 bra wait_forever 1064 bra wait_forever
1065
1066 handle_prev_next_click:
1067 ;make sure we're actually low enough
1068 cmp.w #663, d1
1069 bls .no_prev_page
1070
1071
1072 tst.b more_pages.w
1073 beq .no_next_page
1074
1075 cmp.w #373, d0
1076 blo .no_next_page
1077
1078 cmp.w #419, d0
1079 bhi .no_next_page
1080
1081 ;switch to the next page
1082 move.l page_stack.w, a6
1083 move.l (-4, a6), a6
1084
1085 add.w #10, a7
1086 bra render_page
1087
1088 .no_next_page
1089 cmp.l #(page_pointers+8), a5
1090 beq .no_prev_page
1091
1092 cmp.w #157, d0
1093 blo .no_prev_page
1094
1095 cmp.w #203, d0
1096 bhi .no_prev_page
1097
1098 ;switch to previous page
1099 lea (-12, a5), a5
1100 move.l (a5)+, a6
1101 move.l a5, page_stack.w
1102
1103 add.w #10, a7
1104 bra render_page
1105
1106 .no_prev_page
1107 rts
1108
1109 show_prev_next_buttons:
1110 movem.l d0-d2/a6, -(a7)
1111 tst.b more_pages.w
1112 beq .no_next_page
1113
1114 ;draw Next button
1115 moveq #30, d0
1116 moveq #26, d1
1117 moveq #6, d2
1118 bsr draw_button
1119
1120 ;base attribute
1121 move.w #$206B, d0
1122 ;x pos
1123 moveq #32, d1
1124 ;y pos
1125 moveq #26, d2
1126 lea next_str(pc), a6
1127 bsr print_string_fixed
1128
1129 .no_next_page
1130
1131 cmp.l #(page_pointers+8), a5
1132 beq .no_prev_page
1133
1134 ;draw Prev button
1135 moveq #3, d0
1136 moveq #26, d1
1137 moveq #6, d2
1138 bsr draw_button
1139
1140 ;base attribute
1141 move.w #$206B, d0
1142 ;x pos
1143 moveq #5, d1
1144 ;y pos
1145 moveq #26, d2
1146 lea prev_str(pc), a6
1147 bsr print_string_fixed
1148
1149 .no_prev_page
1150 move.l #0, cursor_show_fun.w
1151 movem.l (a7)+, d0-d2/a6
1152 rts
1039 1153
1040 show_about: 1154 show_about:
1041 bsr clear_screen 1155 bsr clear_screen
1042 moveq #1, d7 1156 moveq #1, d7
1043 lea about_text(pc), a6 1157 lea about_text(pc), a6