Pokedex interface

This commit is contained in:
Remnants of Forgotten Disney 2023-08-23 12:50:55 -05:00
parent 5b3e46c5a7
commit 68cdc3c121
24 changed files with 685 additions and 104 deletions

Binary file not shown.

Binary file not shown.

3
graphics/dex_l.grit Normal file
View File

@ -0,0 +1,3 @@
#
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
-gB4 -ps32 -pe48

BIN
graphics/dex_l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

3
graphics/dex_m.grit Normal file
View File

@ -0,0 +1,3 @@
#
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
-gB4 -ps32 -pe48

BIN
graphics/dex_m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

3
graphics/dex_r.grit Normal file
View File

@ -0,0 +1,3 @@
#
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
-gB4 -ps32 -pe48

BIN
graphics/dex_r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

28
include/dex_handler.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef DEX_HANDLER_H
#define DEX_HANDLER_H
#include <tonc.h>
class Dex
{
public:
Dex();
Dex(OBJ_ATTR *L, OBJ_ATTR *M, OBJ_ATTR *R, u32 tidL, u32 tidM, u32 tidR);
void set_location(int x, int y);
void set_highlight(bool highlight);
void hide();
void show();
private:
int x;
int y;
bool highlighted;
OBJ_ATTR *dex_L;
OBJ_ATTR *dex_M;
OBJ_ATTR *dex_R;
u32 tidL;
u32 tidM;
u32 tidR;
};
#endif

View File

@ -0,0 +1,9 @@
#ifndef GLOBAL_FRAME_COUNTER_H
#define GLOBAL_FRAME_COUNTER_H
void global_next_frame();
int get_frame_count();
#endif

18
include/pokedex.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef POKEDEX_H
#define POKEDEX_H
#include <tonc.h>
#include "dex_handler.h"
#define DEX_MAX 6
#define DEX_SHIFT_MAX (251 - DEX_MAX)
#define SPEED_DELAY 30
#define MAX_NAME_SIZE 10
void pokedex_init();
int pokedex_loop();
void pokedex_show();
void pokedex_hide();
#endif

View File

@ -2,6 +2,7 @@
#define POKEMON_DATA_H
#include <tonc.h>
#include <string>
#define erratic_max 600000
#define fast_max 800000
@ -19,6 +20,7 @@ extern const u8 GENDER_RATIO[251];
extern const bool NUM_ABILITIES[251];
extern const byte MOVESETS[251][32];
extern const byte FIRST_MOVES[251];
extern const std::string_view NAMES[251];
u32 get_max_exp(int index_num);
u8 get_gender_threshold(int index_num, bool is_gen_3);

View File

@ -11,6 +11,9 @@ extern OBJ_ATTR *btn_p_l;
extern OBJ_ATTR *btn_p_r;
extern OBJ_ATTR *btn_c_l;
extern OBJ_ATTR *btn_c_r;
extern OBJ_ATTR *dex_l[];
extern OBJ_ATTR *dex_m[];
extern OBJ_ATTR *dex_r[];
void load_background();
void load_textbox_background();
@ -22,4 +25,7 @@ void load_btn_t_r();
void load_btn_p_l();
void load_btn_p_r();
void load_btn_c_l();
void load_btn_c_r();
void load_btn_c_r();
void load_dex_l();
void load_dex_m();
void load_dex_r();

View File

@ -9,9 +9,9 @@ int x, y;
void background_frame()
{
x += key_tri_horz();
y += key_tri_vert();
x++;
y++;
REG_BG0HOFS= x;
REG_BG0VOFS= y;
REG_BG0HOFS = x;
REG_BG0VOFS = y;
}

View File

@ -24,9 +24,9 @@ void Button::set_highlight(bool highlight)
}
void Button::hide()
{
obj_hide_multi(button_L, 3);
obj_hide_multi(button_L, 2);
}
void Button::show()
{
obj_unhide_multi(button_L, 0, 3);
obj_unhide_multi(button_L, 0, 2);
}

36
source/dex_handler.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "dex_handler.h"
Dex::Dex(){}
Dex::Dex(OBJ_ATTR *L, OBJ_ATTR *M, OBJ_ATTR *R, u32 ntidL, u32 ntidM, u32 ntidR)
{
dex_L = L;
dex_M = M;
dex_R = R;
tidL = ntidL;
tidM = ntidM;
tidR = ntidR;
hide();
}
void Dex::set_location(int nx, int ny)
{
x = nx;
y = ny;
obj_set_pos(dex_L, x, y);
obj_set_pos(dex_M, x + 64, y);
obj_set_pos(dex_R, x + 128, y);
}
void Dex::set_highlight(bool highlight)
{
dex_L->attr2 = ATTR2_BUILD(tidL, (highlight ? 3 : 2), 2);
dex_M->attr2 = ATTR2_BUILD(tidM, (highlight ? 3 : 2), 2);
dex_R->attr2 = ATTR2_BUILD(tidR, (highlight ? 3 : 2), 2);
}
void Dex::hide()
{
obj_hide_multi(dex_L, 3);
}
void Dex::show()
{
obj_unhide_multi(dex_L, 0, 3);
}

View File

@ -0,0 +1,11 @@
#include "global_frame_counter.h"
int global_frame_count = 0;
void global_next_frame(){
global_frame_count++;
}
int get_frame_count(){
return global_frame_count;
}

View File

@ -22,6 +22,9 @@
#include "debug_mode.h"
#include "soundbank.h"
#include "soundbank_bin.h"
#include "dex_handler.h"
#include "pokedex.h"
#include "global_frame_counter.h"
/*TODO:
--------
@ -59,7 +62,6 @@ TESTING:
--------
*/
Pokemon_Party party = Pokemon_Party();
int test_main(void)
@ -74,7 +76,6 @@ int test_main(void)
mmInitDefault((mm_addr)soundbank_bin, 8);
mmStart(MOD_FLATOUTLIES, MM_PLAY_LOOP);
// Song is playing now (well... almost)
while (1)
@ -110,14 +111,14 @@ int main(void)
add_script_party_var(party);
// Sound bank init
// Sound bank init
irq_init(NULL);
irq_set(II_VBLANK, mmVBlank, 0);
irq_enable(II_VBLANK);
mmInitDefault((mm_addr)soundbank_bin, 8);
mmStart(MOD_FLATOUTLIES, MM_PLAY_LOOP);
// Graphics init
// Graphics init
oam_init(obj_buffer, 128);
load_background();
@ -131,11 +132,16 @@ int main(void)
load_btn_p_r();
load_btn_c_l();
load_btn_c_r();
load_dex_l();
load_dex_m();
load_dex_r();
Button transfer_btn = Button(btn_t_l, btn_t_r, 128, 160);
Button pokedex_btn = Button(btn_p_l, btn_p_r, 192, 224);
Button credits_btn = Button(btn_c_l, btn_c_r, 256, 288);
pokedex_init();
main_menu_init(transfer_btn, pokedex_btn, credits_btn);
text_disable();
@ -204,7 +210,12 @@ int main(void)
text_enable();
break;
case (POKEDEX):
main_menu_exit();
pokedex_show();
pokedex_loop();
if(key_hit(KEY_B)){
pokedex_hide();
main_menu_exit();
}
break;
case (CREDITS):
tte_set_pos(0, 0);
@ -217,17 +228,15 @@ int main(void)
break;
}
key_poll();
rand_next_frame();
background_frame();
text_next_frame();
oam_copy(oam_mem, obj_buffer, 8);
oam_copy(oam_mem, obj_buffer, 26);
VBlankIntrWait();
mmFrame();
global_next_frame();
}
}

View File

@ -6,7 +6,7 @@ int menu_slot = 1;
int old_menu_slot = 0;
int menu_mode = MAIN_MENU;
int ani_mode = 0;
int x_cord = 128;
int menu_x_cord = 128;
Button button_array[4];
@ -29,12 +29,12 @@ int main_menu_loop()
{
case ENTERING:
{
x_cord = x_cord + 4;
menu_x_cord = menu_x_cord + 4;
for (int i = 1; i < 4; i++)
{
button_array[i].set_location(x_cord, 16 + (48 * (i - 1)));
button_array[i].set_location(menu_x_cord, 16 + (48 * (i - 1)));
}
if (x_cord > 220)
if (menu_x_cord > 240)
{
ani_mode = DISABLE;
}
@ -42,12 +42,12 @@ int main_menu_loop()
}
case EXITING:
{
x_cord = x_cord - 4;
menu_x_cord = menu_x_cord - 4;
for (int i = 1; i < 4; i++)
{
button_array[i].set_location(x_cord, 16 + (48 * (i - 1)));
button_array[i].set_location(menu_x_cord, 16 + (48 * (i - 1)));
}
if (x_cord <= 128)
if (menu_x_cord <= 128)
{
ani_mode = MAIN_MENU;
}

104
source/pokedex.cpp Normal file
View File

@ -0,0 +1,104 @@
#include <tonc.h>
#include <string>
#include <cmath>
#include "pokedex.h"
#include "dex_handler.h"
#include "sprite_data.h"
#include "pokemon_data.h"
#include "global_frame_counter.h"
Dex dex_array[DEX_MAX];
int dex_shift = 0;
int dex_x_cord = 48;
int speed = 0;
int delay = 0;
int count = 0;
void pokedex_init()
{
for (int i = 0; i < DEX_MAX; i++)
{
dex_array[i] = Dex(dex_l[i], dex_m[i], dex_r[i], 320, 352, 384);
dex_array[i].set_location(dex_x_cord, (i * (8 * 3)) + 8);
}
}
int pokedex_loop()
{
if (key_hit(KEY_DOWN) || key_hit(KEY_UP))
{
dex_shift += key_tri_vert();
}
else if (key_held(KEY_DOWN) || key_held(KEY_UP))
{
if (delay > SPEED_DELAY)
{
if ((get_frame_count() % speed == 0))
{
if (count > 3 && speed >= 5)
{
speed = speed / 2;
count = 0;
}
else
{
count++;
}
dex_shift += key_tri_vert();
}
}
else
{
delay++;
}
}
else
{
speed = 20;
delay = 0;
count = 0;
}
if (dex_shift > DEX_SHIFT_MAX)
{
dex_shift = DEX_SHIFT_MAX;
}
else if (dex_shift < 0)
{
dex_shift = 0;
}
for (int i = 0; i < DEX_MAX; i++)
{
tte_set_pos(dex_x_cord + 8, (i * 8 * 3) + 16);
std::string blanks(MAX_NAME_SIZE - NAMES[dex_shift + i].size(), ' ');
std::string zeros(3 - (log10(dex_shift + i + 1 + 1)), '0');
tte_write("X");
tte_write(" ");
tte_write(std::string(NAMES[dex_shift + i]).data());
tte_write(blanks.c_str());
tte_write(" ");
tte_write(zeros.c_str());
tte_write(std::to_string(dex_shift + i + 1).c_str());
}
return 0;
}
void pokedex_show()
{
for (int i = 0; i < DEX_MAX; i++)
{
dex_array[i].show();
}
}
void pokedex_hide()
{
for (int i = 0; i < DEX_MAX; i++)
{
tte_erase_rect(0, 0, 240, 160);
dex_array[i].hide();
}
}

View File

@ -33,7 +33,8 @@ bool can_learn_move(int pkmn_index, int move_index)
return (data_byte >> (move_index % 8)) & 0x1;
}
byte get_earliest_move(int index_num){
byte get_earliest_move(int index_num)
{
return FIRST_MOVES[index_num - 1];
}
@ -1304,3 +1305,257 @@ const byte FIRST_MOVES[251] = {
0x12, // Ho-oh (whirlwind)
0x49, // Celebi (leech-seed)
};
const std::string_view NAMES[251]{
"Bulbasaur",
"Ivysaur",
"Venusaur",
"Charmander",
"Charmeleon",
"Charizard",
"Squirtle",
"Wartortle",
"Blastoise",
"Caterpie",
"Metapod",
"Butterfree",
"Weedle",
"Kakuna",
"Beedrill",
"Pidgey",
"Pidgeotto",
"Pidgeot",
"Rattata",
"Raticate",
"Spearow",
"Fearow",
"Ekans",
"Arbok",
"Pikachu",
"Raichu",
"Sandshrew",
"Sandslash",
"Nidoran♀",
"Nidorina",
"Nidoqueen",
"Nidoran♂",
"Nidorino",
"Nidoking",
"Clefairy",
"Clefable",
"Vulpix",
"Ninetales",
"Jigglypuff",
"Wigglytuff",
"Zubat",
"Golbat",
"Oddish",
"Gloom",
"Vileplume",
"Paras",
"Parasect",
"Venonat",
"Venomoth",
"Diglett",
"Dugtrio",
"Meowth",
"Persian",
"Psyduck",
"Golduck",
"Mankey",
"Primeape",
"Growlithe",
"Arcanine",
"Poliwag",
"Poliwhirl",
"Poliwrath",
"Abra",
"Kadabra",
"Alakazam",
"Machop",
"Machoke",
"Machamp",
"Bellsprout",
"Weepinbell",
"Victreebel",
"Tentacool",
"Tentacruel",
"Geodude",
"Graveler",
"Golem",
"Ponyta",
"Rapidash",
"Slowpoke",
"Slowbro",
"Magnemite",
"Magneton",
"Farfetch'd",
"Doduo",
"Dodrio",
"Seel",
"Dewgong",
"Grimer",
"Muk",
"Shellder",
"Cloyster",
"Gastly",
"Haunter",
"Gengar",
"Onix",
"Drowzee",
"Hypno",
"Krabby",
"Kingler",
"Voltorb",
"Electrode",
"Exeggcute",
"Exeggutor",
"Cubone",
"Marowak",
"Hitmonlee",
"Hitmonchan",
"Lickitung",
"Koffing",
"Weezing",
"Rhyhorn",
"Rhydon",
"Chansey",
"Tangela",
"Kangaskhan",
"Horsea",
"Seadra",
"Goldeen",
"Seaking",
"Staryu",
"Starmie",
"Mr. Mime",
"Scyther",
"Jynx",
"Electabuzz",
"Magmar",
"Pinsir",
"Tauros",
"Magikarp",
"Gyarados",
"Lapras",
"Ditto",
"Eevee",
"Vaporeon",
"Jolteon",
"Flareon",
"Porygon",
"Omanyte",
"Omastar",
"Kabuto",
"Kabutops",
"Aerodactyl",
"Snorlax",
"Articuno",
"Zapdos",
"Moltres",
"Dratini",
"Dragonair",
"Dragonite",
"Mewtwo",
"Mew",
"Chikorita",
"Bayleef",
"Meganium",
"Cyndaquil",
"Quilava",
"Typhlosion",
"Totodile",
"Croconaw",
"Feraligatr",
"Sentret",
"Furret",
"Hoothoot",
"Noctowl",
"Ledyba",
"Ledian",
"Spinarak",
"Ariados",
"Crobat",
"Chinchou",
"Lanturn",
"Pichu",
"Cleffa",
"Igglybuff",
"Togepi",
"Togetic",
"Natu",
"Xatu",
"Mareep",
"Flaaffy",
"Ampharos",
"Bellossom",
"Marill",
"Azumarill",
"Sudowoodo",
"Politoed",
"Hoppip",
"Skiploom",
"Jumpluff",
"Aipom",
"Sunkern",
"Sunflora",
"Yanma",
"Wooper",
"Quagsire",
"Espeon",
"Umbreon",
"Murkrow",
"Slowking",
"Misdreavus",
"Unown",
"Wobbuffet",
"Girafarig",
"Pineco",
"Forretress",
"Dunsparce",
"Gligar",
"Steelix",
"Snubbull",
"Granbull",
"Qwilfish",
"Scizor",
"Shuckle",
"Heracross",
"Sneasel",
"Teddiursa",
"Ursaring",
"Slugma",
"Magcargo",
"Swinub",
"Piloswine",
"Corsola",
"Remoraid",
"Octillery",
"Delibird",
"Mantine",
"Skarmory",
"Houndour",
"Houndoom",
"Kingdra",
"Phanpy",
"Donphan",
"Porygon2",
"Stantler",
"Smeargle",
"Tyrogue",
"Hitmontop",
"Smoochum",
"Elekid",
"Magby",
"Miltank",
"Blissey",
"Raikou",
"Entei",
"Suicune",
"Larvitar",
"Pupitar",
"Tyranitar",
"Lugia",
"Ho-Oh",
"Celebi",
};

View File

@ -5,9 +5,9 @@
OBJ_ATTR obj_buffer[128];
OBJ_AFFINE *obj_aff_buffer = (OBJ_AFFINE *)obj_buffer;
#include "brin.h"
void load_background(){
void load_background()
{
int CBB = 0;
int SBB = 1;
// Load palette
@ -17,11 +17,12 @@ void load_background(){
// Load map into SBB 30
memcpy(&se_mem[SBB][0], brinMap, brinMapLen);
REG_BG0CNT= BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(2);
REG_BG0CNT = BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(2);
}
#include "openingBG.h"
void load_opening_background(){
void load_opening_background()
{
int CBB = 1;
int SBB = 9;
// Load palette
@ -36,7 +37,8 @@ void load_opening_background(){
}
#include "textboxBG.h"
void load_textbox_background(){
void load_textbox_background()
{
int CBB = 2;
int SBB = 17;
// Load palette
@ -52,150 +54,245 @@ void load_textbox_background(){
#include "metr.h"
OBJ_ATTR *testroid = &obj_buffer[0];
void load_testroid(){
void load_testroid()
{
memcpy(&tile_mem[4][0], metrTiles, metrTilesLen);
memcpy(pal_obj_mem, metrPal, metrPalLen);
int x= 0, y= 0;
u32 tid= 0, pb= 0; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 0, pb = 0; // tile id, pal-bank
obj_set_attr(testroid,
ATTR0_SQUARE,
ATTR1_SIZE_64x64,
ATTR2_PALBANK(pb) | tid);
obj_set_attr(testroid,
ATTR0_SQUARE,
ATTR1_SIZE_64x64,
ATTR2_PALBANK(pb) | tid);
obj_set_pos(testroid, x, y);
obj_hide(testroid);
//obj_unhide(testroid, 0);
// obj_unhide(testroid, 0);
}
#include "prof.h"
OBJ_ATTR *prof = &obj_buffer[1];
void load_professor(){
void load_professor()
{
memcpy(&tile_mem[4][64], profTiles, profTilesLen);
memcpy(pal_obj_mem + 16, profPal, profPalLen);
int x= 96, y= 64;
u32 tid= 64, pb= 1; // tile id, pal-bank
int x = 96, y = 64;
u32 tid = 64, pb = 1; // tile id, pal-bank
obj_set_attr(prof,
ATTR0_SQUARE,
ATTR1_SIZE_64x64,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(3));
obj_set_attr(prof,
ATTR0_SQUARE,
ATTR1_SIZE_64x64,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(3));
obj_set_pos(prof, x, y);
obj_hide(prof);
//obj_unhide(prof, 0);
// obj_unhide(prof, 0);
}
#include "btn_t_l.h"
OBJ_ATTR *btn_t_l = &obj_buffer[2];
void load_btn_t_l(){
void load_btn_t_l()
{
memcpy(&tile_mem[4][128], btn_t_lTiles, btn_t_lTilesLen);
memcpy(pal_obj_mem + 32, btn_t_lPal, btn_t_lPalLen);
int x= 0, y= 0;
u32 tid= 128, pb= 2; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 128, pb = 2; // tile id, pal-bank
obj_set_attr(btn_t_l,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_attr(btn_t_l,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_pos(btn_t_l, x, y);
obj_hide(btn_t_l);
//obj_unhide(btn_t_l, 0);
// obj_unhide(btn_t_l, 0);
}
#include "btn_t_r.h"
OBJ_ATTR *btn_t_r = &obj_buffer[3];
void load_btn_t_r(){
void load_btn_t_r()
{
memcpy(&tile_mem[4][160], btn_t_rTiles, btn_t_rTilesLen);
memcpy(pal_obj_mem + 48, btn_t_rPal, btn_t_rPalLen);
int x= 0, y= 0;
u32 tid= 160, pb= 2; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 160, pb = 2; // tile id, pal-bank
obj_set_attr(btn_t_r,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_attr(btn_t_r,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_pos(btn_t_r, x, y);
obj_hide(btn_t_r);
//obj_unhide(btn_t_r, 0);
// obj_unhide(btn_t_r, 0);
}
#include "btn_p_l.h"
OBJ_ATTR *btn_p_l = &obj_buffer[4];
void load_btn_p_l(){
void load_btn_p_l()
{
memcpy(&tile_mem[4][192], btn_p_lTiles, btn_p_lTilesLen);
//memcpy(pal_obj_mem + 32, btn_p_lPal, btn_p_lPalLen);
// memcpy(pal_obj_mem + 32, btn_p_lPal, btn_p_lPalLen);
int x= 0, y= 0;
u32 tid= 192, pb= 2; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 192, pb = 2; // tile id, pal-bank
obj_set_attr(btn_p_l,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_attr(btn_p_l,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_pos(btn_p_l, x, y);
obj_hide(btn_p_l);
//obj_unhide(btn_p_l, 0);
// obj_unhide(btn_p_l, 0);
}
#include "btn_p_r.h"
OBJ_ATTR *btn_p_r = &obj_buffer[5];
void load_btn_p_r(){
void load_btn_p_r()
{
memcpy(&tile_mem[4][224], btn_p_rTiles, btn_p_rTilesLen);
//memcpy(pal_obj_mem + 48, btn_p_rPal, btn_p_rPalLen);
// memcpy(pal_obj_mem + 48, btn_p_rPal, btn_p_rPalLen);
int x= 0, y= 0;
u32 tid= 224, pb= 2; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 224, pb = 2; // tile id, pal-bank
obj_set_attr(btn_p_r,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_attr(btn_p_r,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_pos(btn_p_r, x, y);
obj_hide(btn_p_r);
//obj_unhide(btn_p_r, 0);
// obj_unhide(btn_p_r, 0);
}
#include "btn_c_l.h"
OBJ_ATTR *btn_c_l = &obj_buffer[6];
void load_btn_c_l(){
void load_btn_c_l()
{
memcpy(&tile_mem[4][256], btn_c_lTiles, btn_c_lTilesLen);
//memcpy(pal_obj_mem + 32, btn_c_lPal, btn_c_lPalLen);
// memcpy(pal_obj_mem + 32, btn_c_lPal, btn_c_lPalLen);
int x= 0, y= 0;
u32 tid= 256, pb= 2; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 256, pb = 2; // tile id, pal-bank
obj_set_attr(btn_c_l,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_attr(btn_c_l,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_pos(btn_c_l, x, y);
obj_hide(btn_c_l);
//obj_unhide(btn_c_l, 0);
// obj_unhide(btn_c_l, 0);
}
#include "btn_c_r.h"
OBJ_ATTR *btn_c_r = &obj_buffer[7];
void load_btn_c_r(){
void load_btn_c_r()
{
memcpy(&tile_mem[4][288], btn_c_rTiles, btn_c_rTilesLen);
//memcpy(pal_obj_mem + 48, btn_c_rPal, btn_c_rPalLen);
// memcpy(pal_obj_mem + 48, btn_c_rPal, btn_c_rPalLen);
int x= 0, y= 0;
u32 tid= 288, pb= 2; // tile id, pal-bank
int x = 0, y = 0;
u32 tid = 288, pb = 2; // tile id, pal-bank
obj_set_attr(btn_c_r,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_attr(btn_c_r,
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(1));
obj_set_pos(btn_c_r, x, y);
obj_hide(btn_c_r);
//obj_unhide(btn_c_r, 0);
}
// obj_unhide(btn_c_r, 0);
}
#include "dex_l.h"
OBJ_ATTR *dex_l[6] = {
&obj_buffer[8],
&obj_buffer[11],
&obj_buffer[14],
&obj_buffer[17],
&obj_buffer[20],
&obj_buffer[23]};
void load_dex_l()
{
memcpy(&tile_mem[4][320], dex_lTiles, dex_lTilesLen);
// memcpy(pal_obj_mem + 48, dex_lPal, dex_lPalLen);
int x = 0, y = 0;
u32 tid = 320, pb = 2; // tile id, pal-bank
for (int i = 0; i < 6; i++)
{
obj_set_attr(dex_l[i],
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(2));
obj_set_pos(dex_l[i], x, y);
obj_hide(dex_l[i]);
// obj_unhide(dex_l, 0);
}
}
#include "dex_m.h"
OBJ_ATTR *dex_m[6] = {
&obj_buffer[9],
&obj_buffer[12],
&obj_buffer[15],
&obj_buffer[18],
&obj_buffer[21],
&obj_buffer[24]};
void load_dex_m()
{
memcpy(&tile_mem[4][352], dex_mTiles, dex_mTilesLen);
// memcpy(pal_obj_mem + 48, dex_mPal, dex_mPalLen);
int x = 0, y = 0;
u32 tid = 352, pb = 2; // tile id, pal-bank
for (int i = 0; i < 6; i++)
{
obj_set_attr(dex_m[i],
ATTR0_WIDE,
ATTR1_SIZE_64x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(2));
obj_set_pos(dex_m[i], x, y);
obj_hide(dex_m[i]);
// obj_unhide(dex_m, 0);
}
}
#include "dex_r.h"
OBJ_ATTR *dex_r[6] = {
&obj_buffer[10],
&obj_buffer[13],
&obj_buffer[16],
&obj_buffer[19],
&obj_buffer[22],
&obj_buffer[25]};
void load_dex_r()
{
memcpy(&tile_mem[4][384], dex_rTiles, dex_rTilesLen);
// memcpy(pal_obj_mem + 48, dex_rPal, dex_rPalLen);
int x = 0, y = 0;
u32 tid = 384, pb = 2; // tile id, pal-bank
for (int i = 0; i < 6; i++)
{
obj_set_attr(dex_r[i],
ATTR0_TALL,
ATTR1_SIZE_16x32,
ATTR2_PALBANK(pb) | tid | ATTR2_PRIO(2));
obj_set_pos(dex_r[i], x, y);
obj_hide(dex_r[i]);
// obj_unhide(dex_r, 0);
}
}
// Don't forget to increase the number of sprites loaded in main!!

View File

@ -2,6 +2,7 @@
#include <string>
#include "text_engine.h"
#include "global_frame_counter.h"
#include <cstring>
#define TEXT_CBB 3
@ -15,7 +16,6 @@ const int TOP = 120;
const int BOTTOM = V_MAX;
script_obj curr_line;
int frame_count;
uint char_count;
bool disabled;
@ -28,7 +28,6 @@ void init_text_engine()
// Set default variables
curr_line = script[0];
frame_count = 0;
char_count = 0;
disabled = false;
}
@ -40,7 +39,7 @@ void text_next_frame()
tte_set_pos(LEFT, TOP);
if (char_count < curr_line.get_text().length())
{
if (frame_count % 2 == 0 || key_held(KEY_B))
if (get_frame_count() % 2 == 0 || key_held(KEY_B))
{
char_count++;
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
@ -56,8 +55,6 @@ void text_next_frame()
char_count = 0;
}
}
frame_count++;
}
}