// nb_line_displayed : if < 0 -> keep ratio (w,h) character : abs(v) -> zoom PolyMesg::PolyMesg(const TextureTable& tt, const char* msg, int x_beg, int y_beg, int w, int h, int nb_line_displayed, int clut_x, int clut_y, char font_begin = '0') : nb_line_displayed(nb_line_displayed), y_shift(0), x_beg(x_beg), y_shift_idx(0), y_beg(y_beg), y_end(y_beg+h) { this->ttt = &tt; this->current_line = 0; this->nb_line_tot = 0; int nb_char_per_line = 0; int nb_char_per_line_max = 0; const char* p = msg; while(true) { if (*p == '\n' || *p == '\0') { this->nb_line_tot++; if ( nb_char_per_line > nb_char_per_line_max ) nb_char_per_line_max = nb_char_per_line; nb_char_per_line = 0; if (*p == '\0') break; } else { nb_char_per_line++; } p++; } if ( this->nb_line_displayed < 0 ) { int zoom = -this->nb_line_displayed; this->nb_poly_per_line = w / FONT_WIDTH; this->nb_line_displayed = zoom * h / FONT_HEIGHT; } else { this->nb_poly_per_line = nb_char_per_line_max; } this->nb_poly = this->nb_poly_per_line * (this->nb_line_displayed+1); this->poly = (POLY_FT4*) MemoryManager::malloc(sizeof(POLY_FT4) * this->nb_poly); int poly_txt_sz = this->nb_line_tot * this->nb_poly_per_line; this->poly_txt = (char*) MemoryManager::malloc(poly_txt_sz); p = msg; for ( int y = 0; y < this->nb_line_tot; y++ ) { int x; for ( x = 0; x < this->nb_poly_per_line && (*p != '\n' && *p != '\0'); x++, p++) { poly_txt[y * this->nb_poly_per_line + x] = *p; } for ( ; x < this->nb_poly_per_line; x++ ) { poly_txt[y * this->nb_poly_per_line + x] = ' '; } if ( *p != '\0' ) p++; } POLY_FT4* pft4 = this->poly; poly_w = w / this->nb_poly_per_line; int poly_h = h / this->nb_line_displayed; for ( int y = 0; y < this->nb_line_displayed+1; y++ ) { for ( int x = 0; x < this->nb_poly_per_line; x++, pft4++ ) { SetPolyFT4(pft4); SetShadeTex(pft4, SHADE_TEXTURE_ON); setXYWH(pft4, x_beg + x * poly_w, y_beg + y * poly_h, poly_w, poly_h); setTPage(pft4, TEXTURE_4BIT, BLEND_UNKNOWN, tt.x(), tt.y()); setClut(pft4, clut_x, clut_y); char c = poly_txt[(y % this->nb_line_tot) * this->nb_poly_per_line + x]; TextureTable::UV uv = (*this->ttt)[c]; setUVWH(pft4, uv.u, uv.v, FONT_WIDTH, FONT_HEIGHT); } } }
void moving_object(void) { static int sx = 0; int sx1; sx1 = ((READ_SECTORS-read_remain_sector) + READ_SECTORS*file_num) * 320 / (READ_FILES * READ_SECTORS); setXYWH(&cdb->prim, sx, 218, sx1, 16); AddPrim(cdb->ot, &cdb->prim); }