adamdunkels | 6b828fb | 2003-08-09 13:13:24 +0000 | [diff] [blame] | 1 | |
| 2 | ;--------------------------------------------------------------------- |
adamdunkels | 6b828fb | 2003-08-09 13:13:24 +0000 | [diff] [blame] | 3 | |
| 4 | .macpack generic |
| 5 | |
| 6 | .import _ctk_mouse_joyx, _ctk_mouse_joyy |
| 7 | .import _ctk_mouse_firebutton |
| 8 | .export _ctk_mouse_joy |
| 9 | ;--------------------------------------------------------------------- |
| 10 | .bss |
| 11 | lastjoydy: .res 1 |
| 12 | lastjoydx: .res 1 |
| 13 | joydycnt: .res 1 |
| 14 | joydxcnt: .res 1 |
| 15 | |
| 16 | ;--------------------------------------------------------------------- |
| 17 | .code |
| 18 | |
| 19 | ;--------------------------------------------------------------------- |
adamdunkels | ec0229d | 2003-08-12 21:08:07 +0000 | [diff] [blame] | 20 | _ctk_mouse_joy: |
| 21 | ldy $dc02 |
| 22 | lda #0 |
| 23 | sta $dc02 |
| 24 | lda $dc00 |
| 25 | sty $dc02 |
adamdunkels | 6b828fb | 2003-08-09 13:13:24 +0000 | [diff] [blame] | 26 | ldy #0 |
| 27 | ldx #0 |
| 28 | lsr |
| 29 | bcs nodey |
| 30 | dey |
| 31 | nodey: |
| 32 | lsr |
| 33 | bcs noiny |
| 34 | iny |
| 35 | noiny: |
| 36 | lsr |
| 37 | bcs nodex |
| 38 | dex |
| 39 | nodex: |
| 40 | lsr |
| 41 | bcs noinx |
| 42 | inx |
| 43 | noinx: |
| 44 | and #1 |
| 45 | eor #1 |
| 46 | ora _ctk_mouse_firebutton |
| 47 | sta _ctk_mouse_firebutton |
| 48 | |
| 49 | cpy lastjoydy |
| 50 | sty lastjoydy |
| 51 | bne noydy |
| 52 | tya |
| 53 | pha |
| 54 | inc joydycnt |
| 55 | lda joydycnt |
| 56 | cmp #$1f |
| 57 | bmi nostajoydycnt |
| 58 | lda #$20 |
| 59 | sta joydycnt |
| 60 | nostajoydycnt: |
| 61 | lsr |
| 62 | lsr |
| 63 | lsr |
| 64 | lsr |
| 65 | tay |
| 66 | pla |
| 67 | asldeyloop: |
| 68 | asl |
| 69 | dey |
| 70 | bpl asldeyloop |
| 71 | tay |
| 72 | jmp ydy |
| 73 | noydy: |
| 74 | lda #0 |
| 75 | sta joydycnt |
| 76 | ydy: |
| 77 | |
| 78 | tya |
| 79 | clc |
| 80 | adc _ctk_mouse_joyy |
| 81 | |
| 82 | cmp #240 |
| 83 | bcc :+ |
| 84 | lda #0 |
| 85 | : |
| 86 | |
| 87 | cmp #200 |
| 88 | bcc :+ |
| 89 | lda #199 |
| 90 | : |
| 91 | sta _ctk_mouse_joyy |
| 92 | |
| 93 | cpx lastjoydx |
| 94 | stx lastjoydx |
| 95 | bne noxdx |
| 96 | txa |
| 97 | pha |
| 98 | inc joydxcnt |
| 99 | lda joydxcnt |
| 100 | cmp #$1f |
| 101 | bmi nostajoydxcnt |
| 102 | lda #$20 |
| 103 | sta joydxcnt |
| 104 | nostajoydxcnt: |
| 105 | lsr |
| 106 | lsr |
| 107 | lsr |
| 108 | lsr |
| 109 | tax |
| 110 | pla |
| 111 | asldexloop: |
| 112 | asl |
| 113 | dex |
| 114 | bpl asldexloop |
| 115 | tax |
| 116 | jmp xdx |
| 117 | noxdx: |
| 118 | lda #0 |
| 119 | sta joydxcnt |
| 120 | xdx: |
| 121 | |
| 122 | txa |
| 123 | clc |
| 124 | adc _ctk_mouse_joyx |
| 125 | sta _ctk_mouse_joyx |
| 126 | php |
| 127 | lda #$ff |
| 128 | cpx #0 |
| 129 | bmi nolda02 |
| 130 | lda #0 |
| 131 | nolda02: |
| 132 | plp |
| 133 | adc _ctk_mouse_joyx+1 |
| 134 | sta _ctk_mouse_joyx+1 |
| 135 | rts |