/[projet1]/users/twilighte/Stormlord/IRQRoutine.s
Defence Force logotype

Contents of /users/twilighte/Stormlord/IRQRoutine.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 412 - (show annotations)
Thu Oct 7 20:50:23 2010 UTC (8 years, 3 months ago) by dbug
File size: 1911 byte(s)
Added Stormlord
1 ;IRQRoutine.s
2 ; Read keyboard (Left,Right,Up,Down,Fire,Esc)
3 ; Programmable Countdown
4 ; Update Sunmoon
5 ; Read Joystick
6
7 SetupIRQ ;Intercept Main IRQ jump at 246
8 sei
9 lda $FFFE
10 sta source
11 lda $FFFF
12 sta source+1
13 ldy #00
14 lda #$4C
15 sta (source),y
16 iny
17 lda #<IRQDriver
18 sta (source),y
19 iny
20 lda #>IRQDriver
21 sta (source),y
22
23 ;Slow IRQ Timer1 to 25Hz
24 lda #<40000
25 sta VIA_T1CL
26 sta VIA_T1LL
27 lda #>40000
28 sta VIA_T1CH
29 sta VIA_T1LH
30 cli
31 rts
32
33 IRQDriver ;Backup Registers
34 sta IRQ_A+1
35 stx IRQ_X+1
36 sty IRQ_Y+1
37 ;Protect BCD mode
38 php
39
40 ;Ensure BCD is disabled
41 cld
42
43 ;Reset IRQ
44 cmp VIA_T1CL
45
46 ;Read keyboard
47 lda #00
48 sta KeyRegister
49 lda #$0E
50 sta VIA_PORTA
51 lda #$FF
52 sta VIA_PCR
53 ldy #$DD
54 sty VIA_PCR
55 ldx #6
56 .(
57 loop1 lda KeyRow,x
58 sta VIA_PORTB
59 lda KeyColumn,x
60 sta VIA_PORTA
61 lda #$FD
62 sta VIA_PCR
63 sty VIA_PCR
64 nop
65 nop
66 nop
67 nop
68 nop
69 lda VIA_PORTB
70 and #8
71 beq skip1
72 lda KeyRegister
73 ora Bitpos,x
74 sta KeyRegister
75 skip1 dex
76 bpl loop1
77 .)
78 ;Read Joysticks if configured and in game
79 lda GameFlag
80 .(
81 beq skip1
82 ldx Option_Input
83 beq skip1
84 dex
85 bne skip2
86 jsr ReadIJK
87 jmp skip1
88 skip2 jsr ReadPASE
89 skip1 ;Update Sunmoon every 10 seconds (25 per second)
90 .)
91 dec SecondCounter
92 .(
93 bne skip1
94 lda CounterReference
95 sta SecondCounter
96 ;Alternate time so doubling res of Second Counter
97 lda TimeAlt
98 eor #128
99 sta TimeAlt
100 bpl skip1
101 jsr UpdateSunMoon
102
103 skip1 ;Are we in game or title?
104 .)
105 lda GameFlag
106 .(
107 bmi skip1
108 beq PlayMusic
109
110 lda Option_Ingame
111 beq PlayMusic
112
113 ;In game
114 jsr sfx_ScriptEngine
115 jmp skip1
116 PlayMusic
117 ; nop
118 ; jmp PlayMusic
119 jsr MusicIRQ
120
121 skip1 ;Programmable Countdown
122 .)
123 lda ProgrammableCountdown
124 .(
125 beq skip1
126 dec ProgrammableCountdown
127 skip1
128 .)
129 ;Restore Registers
130 plp
131 IRQ_A lda #00
132 IRQ_X ldx #00
133 IRQ_Y ldy #00
134 rti
135

  ViewVC Help
Powered by ViewVC 1.1.26