2823a4c8 |
1 | /* display.c for GP2X (CPU/LCD/RAM-Tuner Version 2.0) |
2 | Copyright (C) 2006 god_at_hell |
3 | original CPU-Overclocker (c) by Hermes/PS2Reality |
4 | parts (c) Rlyehs Work |
5 | |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. |
10 | |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | |
20 | */ |
21 | |
22 | #include <stdio.h> |
23 | #include <sys/mman.h> |
24 | #include <fcntl.h> |
25 | #include <math.h> |
26 | #include <unistd.h> |
27 | |
28 | #include "gp2xminilib.h" |
29 | #include "cpuctrl.h" |
30 | #define WIDTH 320 |
31 | #define HEIGHT 240 |
32 | |
33 | //unsigned TEXTBACK=0x900000; // text-background-color |
34 | |
35 | extern unsigned char msx[]; // define la fuente externa usada para dibujar letras y numeros |
36 | |
37 | void ClearScreen(unsigned val) // se usa para 'borrar' la pantalla virtual con un color |
38 | { |
39 | int n; |
40 | unsigned char *c; |
41 | unsigned short col; |
42 | c=&val; |
43 | col=gp2x_video_color15(c[0],c[1],c[2],0); |
44 | for(n=0;n<320*240;n++) |
45 | { |
46 | gp2x_screen15[n]=col; |
47 | } |
48 | } |
49 | |
50 | void DrawBox(unsigned val) |
51 | { |
52 | int n; |
53 | unsigned char *c; |
54 | unsigned short col; |
55 | c=&val; |
56 | col=gp2x_video_color15(c[0],c[1],c[2],0); |
57 | |
58 | for(n=320*27+2;n<320*28-1;n++) |
59 | { |
60 | gp2x_screen15[n]=col; |
61 | gp2x_screen15[n+320*209]=col; |
62 | } |
63 | |
64 | for(n=320*29+4;n<320*30-3;n++) |
65 | { |
66 | gp2x_screen15[n]=col; |
67 | gp2x_screen15[n+320*169]=col; |
68 | gp2x_screen15[n+320*205]=col; |
69 | } |
70 | |
71 | for(n=320*28;n<320*237;n=n+320) |
72 | { |
73 | gp2x_screen15[n+2]=col; |
74 | gp2x_screen15[n-2]=col; |
75 | } |
76 | |
77 | for(n=320*30;n<320*235;n=n+320) |
78 | { |
79 | gp2x_screen15[n+4]=col; |
80 | gp2x_screen15[n-4]=col; |
81 | } |
82 | |
83 | for(n=320*30;n<320*199;n=n+320) |
84 | { |
85 | gp2x_screen15[n-120]=col; |
86 | } |
87 | |
88 | for(n=320*55-120;n<320*55-4;n++) |
89 | { |
90 | gp2x_screen15[n]=col; |
91 | } |
92 | |
93 | } |
94 | |
95 | void v_putchar( unsigned x, unsigned y, unsigned color, unsigned textback, unsigned char ch) // rutina usada para dibujar caracteres (coordenadas de 8x8) |
96 | { |
97 | int i,j,v; |
98 | unsigned char *font; |
99 | unsigned char *c; |
100 | unsigned short col,col2; |
101 | if(x>=WIDTH || y>=HEIGHT) return; |
102 | c=&color; |
103 | col=gp2x_video_color15(c[0],c[1],c[2],0); |
104 | c=&textback; |
105 | col2=gp2x_video_color15(c[0],c[1],c[2],0); |
106 | v=(y*320*8); |
107 | font = &msx[ (int)ch * 8]; |
108 | for (i=0; i < 8; i++, font++) |
109 | { |
110 | for (j=0; j < 8; j++) |
111 | { |
112 | if ((*font & (128 >> j))) |
113 | { |
114 | gp2x_screen15[v+(((x<<3)+j))]=col; |
115 | } |
116 | else gp2x_screen15[v+(((x<<3)+j))]=col2; |
117 | } |
118 | v+=WIDTH; |
119 | } |
120 | } |
121 | |
122 | // display array of chars |
123 | |
124 | void v_putcad(int x,int y,unsigned color,unsigned textback,char *cad) // dibuja una cadena de texto |
125 | { |
126 | while(cad[0]!=0) {v_putchar(x,y,color,textback,cad[0]);cad++;x++;} |
127 | } |
128 | |
129 | |
130 | void gp2x_sound_frame(void *unused, unsigned char *stream, int samples) |
131 | { |
132 | int n; |
133 | short *pu; |
134 | pu=stream; |
135 | for(n=0;n<(samples);n++) |
136 | { |
137 | *pu++=0;*pu++=0; |
138 | } |
139 | } |