/[projet1]/public/atari/demos/defenceforce/savetheearth/subtitle.s
Defence Force logotype

Contents of /public/atari/demos/defenceforce/savetheearth/subtitle.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (show annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years ago) by dbug
File size: 4052 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1
2 SECTION TEXT
3
4 even
5
6 SubtitleClearBuffer
7 movem.l a0/a1,-(sp)
8 lea buffer_subtitles,a0
9 lea buffer_subtitles_end,a1
10 bsr MemoryClear
11 movem.l (sp)+,a0/a1
12 rts
13
14
15 ; a0=input text
16 ; a1=buffer destination
17 SubtitleDrawTextPtr
18 move.l a1,character_buffer_base
19 bra.s SubtitleDrawTextMain
20 ; a0=input text
21 SubtitleDrawText
22 move.l #buffer_subtitles+160,character_buffer_base
23 SubtitleDrawTextMain
24 move #0,character_xpos
25 move #0,character_ypos
26
27 move blit_stride,-(sp)
28 move #160,blit_stride
29 lea FontSubtitles,a6
30 bsr CharacterDrawText
31 move (sp)+,blit_stride
32 rts
33
34
35 SubtitleMapFont
36 ; Depack fonts
37 lea PackInfoFontSmall,a0
38 moveq #3,d0
39 bsr DepackBlockMulti
40
41 ; Compute the pointers to fonts+width
42 lea FontSubtitles,a6
43 bsr ComputeCharactersAdressMapFromBitmap
44
45 ; Install 6x6 font
46 lea FontSmall,a6
47 bsr ComputeCharactersAdressMapFromBitmap
48 rts
49
50
51 SubtitleInit
52 move #0,character_xpos
53 move #0,character_ypos
54 rts
55
56
57 ifne enable_debug_text
58
59 ; d0=value to display
60 DebugPrintValue
61 lea ValueBufferEnd,a0
62 lea HexDigits,a1
63 move.b #0,-(a0) ; Null terminator for the string
64 .loop
65 move.b d0,d1
66 and #15,d1
67 move.b (a1,d1),-(a0)
68 lsr.l #4,d0
69 bne.s .loop
70 bsr DebugPrintString
71 rts
72
73 ValueBuffer ds.b 20
74 ValueBufferEnd ds.b 1
75
76 even
77
78 ; a0=zero terminated string
79 DebugPrintString
80 moveq #0,d0
81 .loop_next_car
82 move.b (a0)+,d0
83 beq.s .done
84 cmp.b #13,d0
85 beq.s .carriage_return
86 bsr DebugPrintChar
87 bra.s .loop_next_car
88
89 .carriage_return
90 move #0,character_xpos
91 add #1,character_ypos
92 bra.s .loop_next_car
93
94 .done
95 rts
96
97
98 ; d0=current character
99 DebugPrintChar
100 ; Character adress
101 lea depacked_font_8x8+32,a1
102 ; Y
103 move d0,d1
104 lsr #4,d1
105 mulu #64*8,d1
106 add d1,a1
107 ; X
108 move d0,d1
109 and #15,d1
110 lsr #1,d1
111 lsl #3,d1
112 add d1,a1
113 move d0,d1
114 and #1,d1
115 add d1,a1
116
117
118 ; Y
119 lea buffer_subtitles+160,a2 ; Skip the first line of the buffer
120 move character_ypos,d1
121 mulu #160*8,d1
122 add d1,a2
123
124 ; X
125 move character_xpos,d1
126 lsr #1,d1
127 lsl #3,d1
128 add d1,a2
129 move character_xpos,d1
130 and #1,d1
131 add d1,a2
132
133 var set 0
134 REPT 8
135 move.b var*64(a1),var*160(a2)
136 var set var+1
137 ENDR
138
139 add #1,character_xpos
140 rts
141
142 endc
143
144
145 SECTION DATA
146
147 ; Unpacked: 15320
148 ; Packed: 7578
149 FILE "font_sub.pik",font_subtitles_packed
150
151 ; Unpacked: 6304
152 ; Packed: 1362
153 ; 256x49 pixels
154 FILE "font_6x6.pik",font_6x6_packed
155
156 ; Unpacked: 4128
157 ; Packed: 1049
158 FILE "font_8x8.pik",font_8x8_packed
159
160
161 FontSubtitles
162 dc.l font_subtitles+32
163 dc.l CommonCharacterList
164 dc.l font_subtitles_mapping
165 dc.l font_subtitles_width
166 dc.w 21
167 dc.w 104
168 dc.w 104*21
169 dc.w 8
170 dc.w 0 ; No extra pixel between characters
171 dc.w 8 ; 8 pixels for the space
172
173 FontSmall
174 dc.l font_6x6+32
175 dc.l AtasciiCharacterList
176 dc.l font_6x6_mapping
177 dc.l font_6x6_width
178 dc.w 7
179 dc.w 128
180 dc.w 128*7
181 dc.w 8
182 dc.w 1 ; Add one extra pixel to separate characters
183 dc.w 3 ; 4 pixels for the space
184
185 ; These 3 should stick together, depacked using multidepack
186 PackInfoFontSmall
187 dc.l font_6x6_packed
188 dc.l font_6x6
189 dc.l 6304
190 PackInfoFontSubtitles
191 dc.l font_subtitles_packed
192 dc.l font_subtitles
193 dc.l 15320
194 PackInfoFontSystem
195 dc.l font_8x8_packed
196 dc.l depacked_font_8x8
197 dc.l 4128
198
199 SECTION BSS
200
201 even
202
203 buffer_subtitles ds.l (160*50)/4 ; 50 lines - about 8000 bytes
204 buffer_subtitles_end
205
206 font_subtitles ds.l 15320/4 ; Not a part of the big BSS buffer because used in all parts
207 font_subtitles_mapping ds.l 256 ; Each entry points to the bitmap for this character (or 0 for non existing characters)
208 font_subtitles_width ds.w 256 ; Width in pixels for each character
209
210 font_6x6 ds.l 6304/4
211 font_6x6_mapping ds.l 256 ; Each entry points to the bitmap for this character (or 0 for non existing characters)
212 font_6x6_width ds.w 256 ; Width in pixels for each character
213
214
215 depacked_font_8x8 ds.b 4128
216
217 even
218
219
220

  ViewVC Help
Powered by ViewVC 1.1.26