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