-
Notifications
You must be signed in to change notification settings - Fork 1
/
Routines.asm
135 lines (116 loc) · 2.63 KB
/
Routines.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
; ---------------------------------------------------------------------------
; Kosinski decompression algorithm
; ---------------------------------------------------------------------------
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
KosDec:
var_2 = -2
var_1 = -1
subq.l #2,sp
move.b (a0)+,2+var_1(sp)
move.b (a0)+,(sp)
move.w (sp),d5
moveq #$F,d4
loc_18A8:
lsr.w #1,d5
move sr,d6
dbf d4,loc_18BA
move.b (a0)+,2+var_1(sp)
move.b (a0)+,(sp)
move.w (sp),d5
moveq #$F,d4
loc_18BA:
move d6,ccr
bcc.s loc_18C2
move.b (a0)+,(a1)+
bra.s loc_18A8
; ===========================================================================
loc_18C2: ; XREF: KosDec
moveq #0,d3
lsr.w #1,d5
move sr,d6
dbf d4,loc_18D6
move.b (a0)+,2+var_1(sp)
move.b (a0)+,(sp)
move.w (sp),d5
moveq #$F,d4
loc_18D6:
move d6,ccr
bcs.s loc_1906
lsr.w #1,d5
dbf d4,loc_18EA
move.b (a0)+,2+var_1(sp)
move.b (a0)+,(sp)
move.w (sp),d5
moveq #$F,d4
loc_18EA:
roxl.w #1,d3
lsr.w #1,d5
dbf d4,loc_18FC
move.b (a0)+,2+var_1(sp)
move.b (a0)+,(sp)
move.w (sp),d5
moveq #$F,d4
loc_18FC:
roxl.w #1,d3
addq.w #1,d3
moveq #-1,d2
move.b (a0)+,d2
bra.s loc_191C
; ===========================================================================
loc_1906: ; XREF: loc_18C2
move.b (a0)+,d0
move.b (a0)+,d1
moveq #-1,d2
move.b d1,d2
lsl.w #5,d2
move.b d0,d2
andi.w #7,d1
beq.s loc_1928
move.b d1,d3
addq.w #1,d3
loc_191C:
move.b (a1,d2.w),d0
move.b d0,(a1)+
dbf d3,loc_191C
bra.s loc_18A8
; ===========================================================================
loc_1928: ; XREF: loc_1906
move.b (a0)+,d1
beq.s loc_1938
cmpi.b #1,d1
beq.w loc_18A8
move.b d1,d3
bra.s loc_191C
; ===========================================================================
loc_1938: ; XREF: loc_1928
addq.l #2,sp
rts
; ---------------------------------------------------------------------------
; Subroutine to read joypad input, and send it to the RAM
; ---------------------------------------------------------------------------
; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
ReadJoypads:
lea ($FFFFF604).w,a0 ; address where joypad states are written
lea ($A10003).l,a1 ; first joypad port
bsr.s Joypad_Read ; do the first joypad
addq.w #2,a1 ; do the second joypad
Joypad_Read:
move.b #0,(a1)
nop
nop
move.b (a1),d0
lsl.b #2,d0
andi.b #$C0,d0
move.b #$40,(a1)
nop
nop
move.b (a1),d1
andi.b #$3F,d1
or.b d1,d0
not.b d0
move.b (a0),d1
eor.b d0,d1
move.b d0,(a0)+
and.b d0,d1
move.b d1,(a0)+
rts