Remove plugin-specific defines from the pdbox makefile, and add them to m_pd.h, which...
[kugel-rb.git] / apps / plugins / pacbox / pacbox_cf.S
blob94675b2732a48b57dfb5b8a13124c3ebc1da082c
1 /***************************************************************************
2  *             __________               __   ___.
3  *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4  *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5  *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6  *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7  *                     \/            \/     \/    \/            \/
8  * $Id$
9  *
10  * Copyright (c) 2006 Fredrik Ohrn
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18  * KIND, either express or implied.
19  *
20  ****************************************************************************/
22 #include "pacbox.h"
24         .section .text
25         .align  2
28 #if defined(IRIVER_H300_SERIES) && !defined(SIMULATOR)
30         .global blit_display
34  0.75 scaling - display 3 out of 4 pixels = 216x168
35  Skipping pixel #2 out of 4 seems to give the most legible display
37 void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
39     next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1];
40     for (y=ScreenHeight-1;y >= 0; y--) {
41         if ((y & 3) != 1) {
42             dst = (next_dst--);
43             for (x=0;x<ScreenWidth;x++) {
44                 if ((x & 3) == 1) { vbuf++; }
45                 else {
46                    *dst = palette[*(vbuf++)];
47                    dst+=LCD_WIDTH;
48                 }
49             }
50         } else {
51             vbuf+=ScreenWidth;
52         }
53     }
57 /* FIXME: ScreenWidth & ScreenHeight are defined in arcade.h, but all
58           hell breaks loose if you include it... */
60 #define ScreenWidth 224
61 #define ScreenHeight 288
63 #define SHRUNK_WIDTH ((ScreenWidth/4)*3)
64 #define SHRUNK_HEIGHT ((ScreenHeight/4)*3)
66 #define BD_SAVE (9 * 4)
68 process_4_pixels:
69         move.b  %d4, %d2
70         move.w  (%a1, %d2.l * 2), %d3
71         move.w  %d3, (2 * LCD_WIDTH * 2)(%a0)
73         lsr.l   #8, %d4
74         move.b  %d4, %d2
75         move.w  (%a1, %d2.l * 2), %d3
76         move.w  %d3, (1 * LCD_WIDTH * 2)(%a0)
78         swap.w  %d4
79         move.b  %d4, %d2
80         move.w  (%a1, %d2.l * 2), (%a0)
82         lea.l   3 * LCD_WIDTH * 2(%a0), %a0
83         rts
85 process_line:
86         move.l  %a3, %d1
87 bd_x_loop:
88         movem.l (%a2), %d4-%d7  // Read 16 pixels
90         bsr.s   process_4_pixels
91         move.l  %d5, %d4
92         bsr.s   process_4_pixels
93         move.l  %d6, %d4
94         bsr.s   process_4_pixels
95         move.l  %d7, %d4
96         bsr.s   process_4_pixels
98         lea     16(%a2), %a2
99         subq.l  #1, %d1;
100         bne.s   bd_x_loop
102         rts
104 blit_display:
105         lea     -BD_SAVE(%sp), %sp
106         movem.l %d2-%d7/%a2-%a4, (%sp)
108         move.l  BD_SAVE + 4(%sp), %a0   // lcd_framebuffer
109         move.l  BD_SAVE + 8(%sp), %a2   // vbuf
111         lea     palette, %a1
113         lea.l   ((YOFS * LCD_WIDTH + XOFS + SHRUNK_HEIGHT) * 2)(%a0), %a0
115         move.l  #(ScreenHeight / 4), %d0
116         move.l  #(ScreenWidth / 16), %a3
117         move.l  #(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a4
118         moveq.l #0, %d2
120 bd_y_loop:
121         bsr.s   process_line
123         suba.l  %a4, %a0
124         lea.l   ScreenWidth(%a2), %a2   // Skip 1 line
126         bsr.s   process_line
128         suba.l  %a4, %a0
130         bsr.s   process_line
132         suba.l  %a4, %a0
134         subq.l  #1, %d0
135         bne     bd_y_loop
137         movem.l (%sp), %d2-%d7/%a2-%a4
138         lea.l   BD_SAVE(%sp), %sp
139         rts
141 #endif /* defined(IRIVER_H300_SERIES) && !defined(SIMULATOR) */
144 /* See arcade.c for the C implementation of drawChar */
145 /* Note! This version does not handle flipped screen mode. */
147         .global drawChar
149 #define DC_SAVE (4 * 4)
151 drawChar:
152         lea     -DC_SAVE(%sp), %sp
153         movem.l %d2-%d5, (%sp)
155         movea.l DC_SAVE + 4(%sp), %a0   // buffer
157         move.l  DC_SAVE + 16(%sp), %d0  // oy
158         move.l  %d0, %d1
159         lsl.l   #8, %d0
160         lsl.l   #5, %d1
161         sub.l   %d1, %d0
162         adda.l  %d0, %a0
163         adda.l  DC_SAVE + 12(%sp), %a0  // ox
165         move.l  DC_SAVE + 20(%sp), %d0  // color
166         and.l   #0x3F, %d0
167         bne.s   have_color
169         moveq.l #8, %d1
170         moveq.l #0, %d2
171         moveq.l #0, %d3
173 clear_loop:
174         movem.l %d2-%d3, (%a0)
175         lea     224(%a0), %a0
177         subq.l  #1, %d1
178         bne.s   clear_loop
180         bra.s   dc_exit
182 have_color:
183         lsl.l   #2, %d0
185         lea.l   charmap_, %a1
186         move.l  DC_SAVE + 8(%sp), %d2   // index
187         lsl.l   #6, %d2
188         adda.l  %d2, %a1
190         moveq.l #8, %d1
191         moveq.l #0, %d3
192         moveq.l #24, %d5
194 dc_y_loop:
195         move.l  (%a1)+, %d3
196         move.l  %d3, %d4
198         move.l  %d3, %d2        // Pixel 1
199         lsr.l   %d5, %d2
200         add.l   %d0, %d2
201         lsl.l   #8, %d2
203         swap.w  %d4             // Pixel 2
204         move.b  %d4, %d2
205         add.l   %d0, %d2
206         lsl.l   #8, %d2
208         lsr.l   #8, %d3         // Pixel 3
209         move.b  %d3, %d2
210         add.l   %d0, %d2
211         lsl.l   #8, %d2
213         swap.w  %d4             // Pixel 4
214         move.b  %d4, %d2
215         add.l   %d0, %d2
217         move.l  %d2, (%a0)+
219         move.l  (%a1)+, %d3
220         move.l  %d3, %d4
222         move.l  %d3, %d2        // Pixel 1
223         lsr.l   %d5, %d2
224         add.l   %d0, %d2
225         lsl.l   #8, %d2
227         swap.w  %d4             // Pixel 2
228         move.b  %d4, %d2
229         add.l   %d0, %d2
230         lsl.l   #8, %d2
232         lsr.l   #8, %d3         // Pixel 3
233         move.b  %d3, %d2
234         add.l   %d0, %d2
235         lsl.l   #8, %d2
237         swap.w  %d4             // Pixel 4
238         move.b  %d4, %d2
239         add.l   %d0, %d2
241         move.l  %d2, (%a0)+
243         lea     216(%a0), %a0
245         subq.l  #1, %d1
246         bne.s   dc_y_loop
248 dc_exit:
249         movem.l (%sp), %d2-%d5
250         lea.l   DC_SAVE(%sp), %sp
251         rts