summaryrefslogtreecommitdiff
path: root/apps/plugins/pacbox/pacbox_cf.S
blob: 7dc6140b44903fe7269d37d577048fbc1f124ea6 (plain)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (c) 2006 Fredrik Ohrn
 *
 * All files in this archive are subject to the GNU General Public License.
 * See the file COPYING in the source tree root for full license agreement.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include "pacbox.h"

	.section .text
	.align  2
	.global blit_display

/*

 0.75 scaling - display 3 out of 4 pixels = 216x168
 Skipping pixel #2 out of 4 seems to give the most legible display
 
void blit_display(fb_data* lcd_framebuffer, unsigned char* vbuf)
{
    next_dst=&lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1];
    for (y=ScreenHeight-1;y >= 0; y--) {
        if ((y & 3) != 1) {
            dst = (next_dst--);
            for (x=0;x<ScreenWidth;x++) {
                if ((x & 3) == 1) { vbuf++; }
                else {
                   *dst = palette[*(vbuf++)];
                   dst+=LCD_WIDTH;
                }
            }
        } else {
            vbuf+=ScreenWidth;
        }
    }
}
*/

/* FIXME: ScreenWidth & ScreenHeight are defined in arcade.h, but all
          hell breaks loose if you include it... */

#define ScreenWidth 224
#define ScreenHeight 288

#define SHRUNK_WIDTH ((ScreenWidth/4)*3)
#define SHRUNK_HEIGHT ((ScreenHeight/4)*3)

blit_display:
	lea	-28(%sp), %sp
	movem.l	%d2-%d6/%a2, (%sp)

	move.l	32(%sp), %a0	// lcd_framebuffer
	move.l	36(%sp), %a2	// vbuf

	lea	palette, %a1

	lea.l	((YOFS * LCD_WIDTH + XOFS + SHRUNK_HEIGHT) * 2)(%a0), %a0

	move.l	#(ScreenHeight / 4), %d0
	move.l	#(ScreenWidth / 4), %d1
	moveq.l	#0, %d2

y_loop:
	move.l	%d1, %d5
x_loop1:
	move.l	(%a2)+, %d3

	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), %d6
	move.w	%d6, (2 * LCD_WIDTH * 2)(%a0)

	lsr.l	#8, %d3
	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), %d6
	move.w	%d6, (1 * LCD_WIDTH * 2)(%a0)

	swap.w	%d3
	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), (%a0)

	lea.l	3 * LCD_WIDTH * 2(%a0), %a0

	subq.l	#1, %d5
	bne.s	x_loop1

	suba.l	#(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0
	lea.l	ScreenWidth(%a2), %a2	// Skip 1 line

	move.l	%d1, %d5
x_loop2:
	move.l	(%a2)+, %d3

	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), %d6
	move.w	%d6, 2 * LCD_WIDTH * 2(%a0)

	lsr.l	#8, %d3
	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), %d6
	move.w	%d6, 1 * LCD_WIDTH * 2(%a0)

	swap.w	%d3
	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), (%a0)

	lea.l	3 * LCD_WIDTH * 2(%a0), %a0

	subq.l	#1, %d5
	bne.s	x_loop2

	suba.l	#(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0

	move.l	%d1, %d5
x_loop3:
	move.l	(%a2)+, %d3

	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), %d6
	move.w	%d6, 2 * LCD_WIDTH * 2(%a0)

	lsr.l	#8, %d3
	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), %d6
	move.w	%d6, 1 * LCD_WIDTH * 2(%a0)

	swap.w	%d3
	move.b	%d3, %d2
	move.w	(%a1, %d2.l * 2), (%a0)

	lea.l	3 * LCD_WIDTH * 2(%a0), %a0

	subq.l	#1, %d5
	bne.s	x_loop3

	suba.l	#(LCD_WIDTH * SHRUNK_WIDTH + 1) * 2, %a0

	subq.l	#1, %d0
	bne	y_loop

	movem.l	(%sp), %d2-%d6/%a2
	lea.l	28(%sp), %sp
	rts