junglejourney
changeset 163:a5121cf016ad
Added preliminary support for analogue joysticks.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sun Sep 18 02:23:15 2011 +0200 |
| parents | b52224881b19 |
| children | e0bda78f458f |
| files | build.py loader.oph mapcode.oph |
| diffstat | 3 files changed, 131 insertions(+), 18 deletions(-) [+] |
line diff
1.1 --- a/build.py Sun Sep 18 00:59:39 2011 +0200 1.2 +++ b/build.py Sun Sep 18 02:23:15 2011 +0200 1.3 @@ -114,6 +114,7 @@ 1.4 # 1.5 # 5760 space 1.6 # 1.7 + # 577E joystick support (0=off; 1=on) 1.8 # 577F weapon counter (0=fire one subtile below; 1=fire two subtiles below) 1.9 # 5780 item/player flags (128=leave level, 64=player demise, 1.10 # bits 4,5,6=enemy limit, 2=complete game,
2.1 --- a/loader.oph Sun Sep 18 00:59:39 2011 +0200 2.2 +++ b/loader.oph Sun Sep 18 02:23:15 2011 +0200 2.3 @@ -94,8 +94,8 @@ 2.4 code_block: .byte <code_file_name, >code_file_name 2.5 .byte $00, $1e, 0, 0 2.6 .byte $00, $1e, 0, 0 2.7 - .byte $9c, $1f, 0, 0 2.8 - .byte $9c, $3d, 0, 0 2.9 + .byte $30, $20, 0, 0 2.10 + .byte $30, $3e, 0, 0 2.11 2.12 init_load_window_vdu_bytes: .byte 28,0,29,19,24 2.13
3.1 --- a/mapcode.oph Sun Sep 18 00:59:39 2011 +0200 3.2 +++ b/mapcode.oph Sun Sep 18 02:23:15 2011 +0200 3.3 @@ -1749,6 +1749,37 @@ 3.4 lda #$52 3.5 sta $75 3.6 3.7 + ; Handle joystick 3.8 + 3.9 + lda $577e 3.10 + cmp #0 3.11 + beq move_player_handle_left_key 3.12 + 3.13 + lda #128 3.14 + ldx #1 3.15 + jsr $fff4 3.16 + cpy #0 3.17 + beq move_player_handle_joystick_up_down 3.18 + cpy #128 3.19 + bpl move_player_left 3.20 + jmp move_player_right 3.21 + 3.22 + move_player_handle_joystick_up_down: 3.23 + 3.24 + lda #128 3.25 + ldx #2 3.26 + jsr $fff4 3.27 + cpy #0 3.28 + beq move_player_handle_left_key 3.29 + cpy #128 3.30 + bpl move_player_not_up 3.31 + jmp move_player_up 3.32 + 3.33 + move_player_not_up: 3.34 + jmp move_player_down 3.35 + 3.36 + move_player_handle_left_key: 3.37 + 3.38 ; Handle the left key. 3.39 3.40 ldx #158 ; (Z) 3.41 @@ -1756,6 +1787,8 @@ 3.42 cpy #255 3.43 bne move_player_not_left_key 3.44 3.45 + move_player_left: 3.46 + 3.47 lda $5285 ; read dx 3.48 cmp #0 3.49 beq move_player_left_check_x 3.50 @@ -1846,10 +1879,11 @@ 3.51 ldx #189 ; (X) 3.52 jsr check_key 3.53 cpy #255 3.54 - beq move_player_right_key 3.55 + beq move_player_right 3.56 jmp move_player_not_right_key 3.57 3.58 - move_player_right_key: 3.59 + move_player_right: 3.60 + 3.61 lda $5285 ; read dx 3.62 cmp #2 3.63 beq move_player_right_check_x 3.64 @@ -1947,6 +1981,8 @@ 3.65 cpy #255 3.66 bne move_player_not_up_key 3.67 3.68 + move_player_up: 3.69 + 3.70 lda $5283 ; read dy 3.71 cmp #0 3.72 beq move_player_up_check_y 3.73 @@ -2033,10 +2069,11 @@ 3.74 ldx #151 ; (/) 3.75 jsr check_key 3.76 cpy #255 3.77 - beq move_player_down_key 3.78 + beq move_player_down 3.79 jmp move_player_not_down_key 3.80 3.81 - move_player_down_key: 3.82 + move_player_down: 3.83 + 3.84 lda $5283 ; read dy 3.85 cmp #0 3.86 beq move_player_down_check_y 3.87 @@ -2148,11 +2185,24 @@ 3.88 lda $578d 3.89 bne check_fire_key_exit 3.90 3.91 + lda $577e 3.92 + beq check_fire_key_no_joystick 3.93 + 3.94 + lda #128 3.95 + ldx #0 3.96 + jsr $fff4 3.97 + cpx #0 3.98 + bne check_fire_key_fire 3.99 + 3.100 + check_fire_key_no_joystick: 3.101 + 3.102 ldx #182 ; (Return) 3.103 jsr check_key 3.104 cpy #255 3.105 bne check_fire_key_exit 3.106 3.107 + check_fire_key_fire: 3.108 + 3.109 lda $5286 3.110 cmp #0 3.111 bne check_fire_key_exit 3.112 @@ -4324,12 +4374,18 @@ 3.113 cpy #96 3.114 bne init_define_high_scores_loop 3.115 3.116 + ; Disable joystick support. 3.117 + lda #0 3.118 + sta $577e 3.119 + 3.120 rts 3.121 3.122 high_score_default_name1: .byte "RETRO " 3.123 high_score_default_name2: .byte " SOFTWARE" 3.124 3.125 -title_vdu_bytes: .byte 17,2, 31,4,27, "Press SPACE", 31,7,28, "to play" 3.126 +title_vdu_bytes: .byte 17,2, 31,7,28, "to play" 3.127 +keyboard_message: .byte 31,4,27, 17,2, "Press SPACE" 3.128 +joystick_message: .byte 31,4,27, 17,2, "Press FIRE " 3.129 title_vdu_bytes1: .byte 17,3, 31,1,30, "Copyright (c) 2011" 3.130 title_vdu_bytes2: .byte 17,3, 31,1,30, " David Boddie " 3.131 title_vdu_bytes3: .byte 17,1, 31,1,30, "for Retro Software" 3.132 @@ -4417,15 +4473,17 @@ 3.133 lda title_vdu_bytes,x 3.134 jsr $ffee 3.135 inx 3.136 - cpx #27 3.137 + cpx #12 3.138 bmi write_title_text_loop 3.139 3.140 + jsr show_keyboard_or_joystick_message 3.141 + 3.142 ; Show the title. 3.143 jsr copy_title_up 3.144 3.145 ; Show the high scores. 3.146 3.147 - jsr colour3 3.148 + jsr colour1 3.149 3.150 lda #$80 3.151 sta $70 3.152 @@ -4510,6 +4568,27 @@ 3.153 beq show_title_wait_loop 3.154 3.155 show_title_wait_loop_no_update: 3.156 + ldx #186 3.157 + jsr check_key 3.158 + cpy #255 3.159 + bne show_title_no_j 3.160 + 3.161 + lda #1 ; enable joystick support 3.162 + sta $577e 3.163 + jsr show_joystick_message 3.164 + jmp show_title_no_k 3.165 + 3.166 + show_title_no_j: 3.167 + ldx #185 3.168 + jsr check_key 3.169 + cpy #255 3.170 + bne show_title_no_k 3.171 + 3.172 + lda #0 ; disable joystick support 3.173 + sta $577e 3.174 + jsr show_keyboard_message 3.175 + 3.176 + show_title_no_k: 3.177 ldx #157 3.178 jsr check_key 3.179 cpy #255 3.180 @@ -4517,6 +4596,39 @@ 3.181 3.182 rts 3.183 3.184 +show_keyboard_or_joystick_message: 3.185 + 3.186 + lda $577e 3.187 + cmp #0 3.188 + bne show_joystick_message 3.189 + 3.190 +show_keyboard_message: 3.191 + 3.192 + ldx #0 3.193 + show_keyboard_message_loop: 3.194 + 3.195 + lda keyboard_message,x 3.196 + jsr $ffee 3.197 + inx 3.198 + cpx #16 3.199 + bne show_keyboard_message_loop 3.200 + 3.201 + rts 3.202 + 3.203 +show_joystick_message: 3.204 + 3.205 + ldx #0 3.206 + show_joystick_message_loop: 3.207 + 3.208 + lda joystick_message,x 3.209 + jsr $ffee 3.210 + inx 3.211 + cpx #16 3.212 + bne show_joystick_message_loop 3.213 + 3.214 + rts 3.215 + 3.216 + 3.217 wait_for_vsync: 3.218 3.219 lda #19 3.220 @@ -4793,7 +4905,6 @@ 3.221 complete_game_vdu_bytes2: .byte 17,3, 31,2,20, "Congratulations!" 3.222 complete_game_vdu_bytes3: .byte 17,2, 31,1,22, "Now journey onward" 3.223 complete_game_vdu_bytes4: .byte 17,2, 31,1,24, "to a new adventure" 3.224 -complete_game_vdu_bytes5: .byte 17,1, 31,4,27, "Press SPACE" 3.225 3.226 show_complete_game: 3.227 3.228 @@ -4822,14 +4933,8 @@ 3.229 dec $5785 3.230 bne show_complete_game_no_message 3.231 3.232 - ldx #0 3.233 - show_complete_game_message_loop: 3.234 - 3.235 - lda complete_game_vdu_bytes5,x 3.236 - jsr $ffee 3.237 - inx 3.238 - cpx #16 3.239 - bne show_complete_game_message_loop 3.240 + jsr colour1 3.241 + jsr show_keyboard_or_joystick_message 3.242 3.243 show_complete_game_no_message: 3.244 ldx #157 3.245 @@ -5176,6 +5281,13 @@ 3.246 jsr $ffee 3.247 rts 3.248 3.249 +colour1: 3.250 + lda #17 3.251 + jsr $ffee 3.252 + lda #1 3.253 + jsr $ffee 3.254 + rts 3.255 + 3.256 colour3: 3.257 lda #17 3.258 jsr $ffee
