10 void load_attribute(unsigned char bank, int tile_index, struct palette *plt);
11 void load_pattern(unsigned char bank, unsigned char ptn_index, struct tile_2* pattern);
13 struct tile_rgb15_line {
18 struct tile_rgb15_line l[8];
21 static struct tile_rgb15 *vscreen;
24 void set_bgtile(int tile_id) {
27 unsigned char name_index;
28 struct tile_rgb15* set_data;
31 load_attribute(0, tile_id, &plt);
33 name_index = name_tbl_get(0, tile_id);
34 load_pattern(0, name_index, &ptn);
36 set_data = vscreen + tile_id;
37 for (i = 0; i < TILE_DOT_SIZE; i++) {
38 set_data->l[i].d[0] = plt.col[ptn.b0.l[i].dot0 + ptn.b1.l[i].dot0];
39 set_data->l[i].d[1] = plt.col[ptn.b0.l[i].dot1 + ptn.b1.l[i].dot1];
40 set_data->l[i].d[2] = plt.col[ptn.b0.l[i].dot2 + ptn.b1.l[i].dot2];
41 set_data->l[i].d[3] = plt.col[ptn.b0.l[i].dot3 + ptn.b1.l[i].dot3];
42 set_data->l[i].d[4] = plt.col[ptn.b0.l[i].dot4 + ptn.b1.l[i].dot4];
43 set_data->l[i].d[5] = plt.col[ptn.b0.l[i].dot5 + ptn.b1.l[i].dot5];
44 set_data->l[i].d[6] = plt.col[ptn.b0.l[i].dot6 + ptn.b1.l[i].dot6];
45 set_data->l[i].d[7] = plt.col[ptn.b0.l[i].dot7 + ptn.b1.l[i].dot7];
53 //struct tile_rgb15* set_data = vscreen + tile_id;
56 struct tile_2 pattern;
61 //load character pattern
62 p = (unsigned char*)&pattern;
63 addr = tile_id * sizeof(struct tile_2);
64 for (i = 0; i < sizeof(struct tile_2); i++) {
65 data = pattern_tbl_get(bg_bank, addr);
74 void vscreenn_dot_get(int x, int y, struct rgb15 *col) {
75 int tile_id, tile_id_x, tile_id_y;
77 struct tile_rgb15* tile;
79 tile_id_x = x / TILE_DOT_SIZE;
80 tile_id_y = y / TILE_DOT_SIZE;
81 tile_id = tile_id_x + tile_id_y * H_SCREEN_TILE_SIZE;
82 tile = vscreen + tile_id;
84 inner_x = x % TILE_DOT_SIZE;
85 inner_y = y % TILE_DOT_SIZE;
86 *col = tile->l[inner_y].d[inner_x];
90 int vscreen_init(void) {
91 vscreen = (struct tile_rgb15 *) malloc(
92 sizeof (struct tile_rgb15) * VIRT_SCREEN_TILE_SIZE * VIRT_SCREEN_TILE_SIZE);
95 memset(vscreen, 0, sizeof (struct tile_rgb15) * VIRT_SCREEN_TILE_SIZE * VIRT_SCREEN_TILE_SIZE);
97 //dprint("tile_1_line:%d tile_2 size:%d\n", sizeof(struct tile_1_line), sizeof(struct tile_2));
102 void clean_vscreen(void) {