Initial commit.
[amiga/xmodule.git] / Gadgets / PattEditClassAsm.asm
1 **
2 **      PattEditClassAsm.asm
3 **
4 **      Copyright (C) 1995,96 Bernardo Innocenti
5 **
6 **      Pattern Editor gadget assembler subroutines
7 **
8
9         INCDIR  Include:
10
11         SECTION __merged,code
12
13         include libraries/SongClass.i
14
15         xdef _Note2ASCIIBlank0
16         xdef _Note2ASCII
17
18
19
20 * void Note2ASCIIBlank0 (UBYTE *s, struct Note *note)
21 *                        A1        A2
22 *
23 * Fill the buffer pointed by A1 with the ASCII representation of the
24 * Note structure pointed by A2.  The buffer will be able to hold at
25 * least <ped->TrackChars> characters.
26
27 _Note2ASCIIBlank0:
28         move.w  d2,-(sp)
29         moveq   #0,d1
30         moveq   #0,d2
31         lea     TextNotes(pc),a0
32         move.b  note_Note(a2),d1        ; note_Note
33         add.w   d1,d1
34         add.w   d1,d1
35         move.l  (a0,d1.w),d0
36
37         move.b  note_Inst(a2),d1
38         lea     HexValuesNo0(pc),a0
39         move.b  d1,d2
40         lsr.b   #4,d2
41         move.b  (a0,d2.w),d0
42         move.l  d0,(a1)+                ; Put Note and Instrument high nibble
43
44         tst.b   d1
45         beq.s   .noinst
46
47         and.w   #$0F,d1
48         lea     HexValues(pc),a0
49         move.b  (a0,d1),d1
50         lsl.w   #8,d1
51         move.b  #' ',d1
52         move.w  d1,(a1)+                ; Put Instrument low nibble and white space
53
54         bra.s   .endif
55 .noinst
56         move.w  #'- ',(a1)+             ; Put Instrument low nibble and white space
57
58 .endif
59
60         moveq   #0,d0
61         lea     HexValues(pc),a0
62         move.b  note_EffNum(a2),d0
63         move.b  note_EffVal(a2),d1
64         move.b  d1,d2
65         sub.b   d0,d1
66         beq.s   .noeff
67
68         moveq   #0,d1
69         move.b  (a0,d0.w),d0
70         move.b  d2,d1
71         lsl.w   #8,d0
72         lsr.b   #4,d1
73         move.b  (a0,d1.w),d0
74         move.w  d0,(a1)+                ;Put EffNum and EffVal high nibble
75
76         and.w   #$F,d2
77         move.b  (a0,d2.w),d2
78         lsl.w   #8,d2
79         move.b  #' ',d2
80         move.w  d2,(a1)+                ; Put EffVal low nibble and space
81         move.w  (sp)+,d2
82         rts
83
84         move.w  (sp)+,d2
85         rts
86
87 .noeff
88         move.l  #' .  ',(a1)+           ; Put white spaces
89         move.w  (sp)+,d2
90         rts
91
92
93 * void Note2ASCII (UBYTE *s, struct Note *note)
94 *                  A1        A2
95 *
96 * Fill the buffer pointed by A1 with the ASCII representation of the
97 * Note structure pointed by A2.  The buffer will be able to hold at
98 * least <ped->TrackChars> characters.
99
100 _Note2ASCII:
101         moveq   #0,d0
102         move.b  note_Note(a2),d0        ; note_Note
103         beq.s   .nonote
104
105         lea     TextNotes(pc),a0
106         add.w   d0,d0
107         add.w   d0,d0
108         move.l  (a0,d0.w),(a1)          ; Put Note
109         bra.s   .endif
110
111 .nonote
112         move.l  #'--- ',(a1)
113
114 .endif
115         lea             3(a1),a1
116
117         move.b  note_Inst(a2),d0
118         moveq   #0,d1
119         move.b  d0,d1
120
121         lea     HexValuesNo0(pc),a0
122         lsr.b   #4,d1
123         move.b  (a0,d1),(a1)+           ; Put Instrument high nibble
124
125         and.w   #$0F,d0
126         lea     HexValues(pc),a0
127         move.b  (a0,d0),(a1)+           ; Put Instrument low nibble
128
129         move.b  #' ',(a1)+              ; Put white space
130
131         move.w  d2,-(sp)
132         moveq   #0,d0
133         lea     HexValues(pc),a0
134         move.b  note_EffNum(a2),d0
135         move.b  note_EffVal(a2),d1
136         move.b  d1,d2
137
138         move.b  (a0,d0.w),d0
139         move.b  d2,d1
140         lsl.w   #8,d0
141         lsr.b   #4,d1
142         move.b  (a0,d1.w),d0
143         move.w  d0,(a1)+                ;Put EffNum and EffVal high nibble
144
145         and.w   #$F,d2
146         move.b  (a0,d2.w),d2
147         lsl.w   #8,d2
148         move.b  #' ',d2
149         move.w  d2,(a1)+                ; Put EffVal low nibble and space
150         move.w  (sp)+,d2
151         rts
152
153
154         CNOP    0,4
155 TextNotes:
156
157         dc.l    ' -  '
158
159         dc.l    'C-0 ', 'C#0 ', 'D-0 ', 'D#0 ', 'E-0 ', 'F-0 '
160         dc.l    'F#0 ', 'G-0 ', 'G#0 ', 'A-0 ', 'A#0 ', 'B-0 '
161
162         dc.l    'C-1 ', 'C#1 ', 'D-1 ', 'D#1 ', 'E-1 ', 'F-1 '
163         dc.l    'F#1 ', 'G-1 ', 'G#1 ', 'A-1 ', 'A#1 ', 'B-1 '
164
165         dc.l    'C-2 ', 'C#2 ', 'D-2 ', 'D#2 ', 'E-2 ', 'F-2 '
166         dc.l    'F#2 ', 'G-2 ', 'G#2 ', 'A-2 ', 'A#2 ', 'B-2 '
167
168         dc.l    'C-3 ', 'C#3 ', 'D-3 ', 'D#3 ', 'E-3 ', 'F-3 '
169         dc.l    'F#3 ', 'G-3 ', 'G#3 ', 'A-3 ', 'A#3 ', 'B-3 '
170
171         dc.l    'C-4 ', 'C#4 ', 'D-4 ', 'D#4 ', 'E-4 ', 'F-4 '
172         dc.l    'F#4 ', 'G-4 ', 'G#4 ', 'A-4 ', 'A#4 ', 'B-4 '
173
174         dc.l    'C-5 ', 'C#5 ', 'D-5 ', 'D#5 ', 'E-5 ', 'F-5 '
175         dc.l    'F#5 ', 'G-5 ', 'G#5 ', 'A-5 ', 'A#5 ', 'B-5 '
176
177 HexValues:
178         dc.b    '0','1','2','3','4','5','6','7','8','9'
179         dc.b    'A','B','C','D','E','F','G','H','I','J'
180
181 HexValuesNo0:
182         dc.b    ' ','1','2','3','4','5','6','7','8','9'
183         dc.b    'A','B','C','D','E','F'