100
|
1 #include <malloc.h>
|
|
2 #include "CellScheduler.h"
|
|
3 #include "Load_Texture.h"
|
|
4 #include "error.h"
|
|
5 #include "SchedTask.h"
|
|
6 #include "TaskManager.h"
|
|
7 using namespace std;
|
|
8
|
|
9 #define height 128
|
|
10 #define width 128
|
|
11
|
|
12
|
|
13 int
|
|
14 LoadTexture::run(void *rbuf , void *wbuf)
|
|
15 {
|
|
16 //int rgb;
|
|
17 __debug("[LoadTexture:%s]\n", __FUNCTION__);
|
102
|
18 __debug("%x\n",(int)rbuf);
|
|
19 __debug("run\n");
|
100
|
20
|
|
21 return 0;
|
|
22 }
|
|
23
|
|
24 // byteperpixel = 3 width = 128 dma_height= 32
|
|
25 #define LOAD_SIZE 3*128*32
|
|
26 #define MAX_LOAD_SIZE 16384
|
|
27 #define USE_ARRAY 3
|
|
28
|
|
29 void
|
|
30 LoadTexture::read(void)
|
|
31 {
|
|
32 __debug("[LoadTexture:%s]\n", __FUNCTION__);
|
|
33 #if 1
|
|
34 connector->dma_load(readbuf,task->in_addr,MAX_LOAD_SIZE,DMA_READ);
|
|
35 connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE),
|
|
36 task->in_addr + MAX_LOAD_SIZE, MAX_LOAD_SIZE,DMA_READ + 1);
|
|
37 connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE*2) ,
|
|
38 task->in_addr + MAX_LOAD_SIZE * 2,MAX_LOAD_SIZE,DMA_READ + 2);
|
102
|
39 __debug("readbuf: %x\n", (uint32)readbuf);
|
|
40 __debug("readbuf2:%x\n", (int)readbuf + MAX_LOAD_SIZE);
|
|
41 __debug("readbuf3:%x\n", (int)readbuf + MAX_LOAD_SIZE*2);
|
100
|
42 #else
|
|
43 mfc_list_element buf[USE_ARRAY];
|
|
44 for(int i = 0; i < USE_ARRAY; i++) {
|
|
45 buf[i].notify = 0;
|
|
46 buf[i].reserved = 0;
|
|
47 buf[i].size = MAX_LOAD_SIZE;
|
|
48 buf[i].eal = task->in_addr + i*MAX_LOAD_SIZE;
|
|
49 }
|
102
|
50 __debug("set_load_info\n");
|
100
|
51 connector->dma_load(readbuf, (unsigned int)buf, MAX_LOAD_SIZE, DMA_READ);
|
102
|
52 __debug("dma_load_finish\n");
|
100
|
53
|
|
54 #endif
|
|
55 }
|
|
56
|
|
57 void
|
|
58 LoadTexture::write(void)
|
|
59 {
|
|
60 __debug("[LoadTexture:%s]\n",__FUNCTION__);
|
|
61 connector->dma_wait(DMA_WRITE);
|
|
62 connector->mail_write((uint32)task->self);
|
|
63 }
|
|
64
|
|
65 /*
|
|
66 Uint32 Polygon::get_rgb(int tx, int ty)
|
|
67 {
|
|
68 SDL_PixelFormat *fmt;
|
|
69 Uint8 red, green, blue;
|
|
70
|
|
71 fmt = texture_image->format;
|
|
72
|
|
73 if (tx<0) tx = 0;
|
|
74 if (texture_image->w-1< tx) tx = texture_image->w-1 ;
|
|
75 if (ty<0) ty = 0;
|
|
76 if (texture_image->h-1< ty) ty = texture_image->h-1 ;
|
|
77
|
|
78
|
|
79
|
|
80 char *p = get_pixel(tx,ty,texture_image);
|
|
81 blue = (Uint8) p[0];
|
|
82 green = (Uint8) p[1];
|
|
83 red = (Uint8) p[2];
|
|
84
|
|
85
|
|
86 SDL_PixelFormat *pf;
|
|
87 pf = viewer->screen->format;
|
|
88
|
|
89 //cout << SDL_MapRGB(pf, red, green, blue) << endl;
|
|
90 return SDL_MapRGB(pf, red, green, blue);
|
|
91 }
|
|
92 */
|
|
93
|
|
94 SchedTask *
|
|
95 createTask_LoadTexture(TaskListPtr _taskList, TaskPtr _task,
|
|
96 void *rbuf, void *wbuf, DmaManager *dma) {
|
|
97 CellScheduler::tex = memalign(DEFAULT_ALIGNMENT, DMA_MAX_SIZE*3);
|
|
98 rbuf = CellScheduler::tex;
|
|
99
|
|
100 return new LoadTexture(_taskList, _task, rbuf, wbuf, dma);
|
|
101 }
|