diff --git a/graphics/btn_c_l.grit b/graphics/btn_c_l.grit new file mode 100644 index 0000000..aa1971c --- /dev/null +++ b/graphics/btn_c_l.grit @@ -0,0 +1,3 @@ +# +# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48. +-gB4 -ps32 -pe48 \ No newline at end of file diff --git a/graphics/btn_c_l.png b/graphics/btn_c_l.png new file mode 100644 index 0000000..8321a1d Binary files /dev/null and b/graphics/btn_c_l.png differ diff --git a/graphics/btn_c_r.grit b/graphics/btn_c_r.grit new file mode 100644 index 0000000..aa1971c --- /dev/null +++ b/graphics/btn_c_r.grit @@ -0,0 +1,3 @@ +# +# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48. +-gB4 -ps32 -pe48 \ No newline at end of file diff --git a/graphics/btn_c_r.png b/graphics/btn_c_r.png new file mode 100644 index 0000000..8d9afe7 Binary files /dev/null and b/graphics/btn_c_r.png differ diff --git a/graphics/btn_p_l.grit b/graphics/btn_p_l.grit new file mode 100644 index 0000000..aa1971c --- /dev/null +++ b/graphics/btn_p_l.grit @@ -0,0 +1,3 @@ +# +# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48. +-gB4 -ps32 -pe48 \ No newline at end of file diff --git a/graphics/btn_p_l.png b/graphics/btn_p_l.png new file mode 100644 index 0000000..3406b19 Binary files /dev/null and b/graphics/btn_p_l.png differ diff --git a/graphics/btn_p_r.grit b/graphics/btn_p_r.grit new file mode 100644 index 0000000..aa1971c --- /dev/null +++ b/graphics/btn_p_r.grit @@ -0,0 +1,3 @@ +# +# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48. +-gB4 -ps32 -pe48 \ No newline at end of file diff --git a/graphics/btn_p_r.png b/graphics/btn_p_r.png new file mode 100644 index 0000000..881e325 Binary files /dev/null and b/graphics/btn_p_r.png differ diff --git a/graphics/btn_t_l.grit b/graphics/btn_t_l.grit new file mode 100644 index 0000000..aa1971c --- /dev/null +++ b/graphics/btn_t_l.grit @@ -0,0 +1,3 @@ +# +# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48. +-gB4 -ps32 -pe48 \ No newline at end of file diff --git a/graphics/btn_t_l.png b/graphics/btn_t_l.png new file mode 100644 index 0000000..e8eca1b Binary files /dev/null and b/graphics/btn_t_l.png differ diff --git a/graphics/btn_t_r.grit b/graphics/btn_t_r.grit new file mode 100644 index 0000000..aa1971c --- /dev/null +++ b/graphics/btn_t_r.grit @@ -0,0 +1,3 @@ +# +# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48. +-gB4 -ps32 -pe48 \ No newline at end of file diff --git a/graphics/btn_t_r.png b/graphics/btn_t_r.png new file mode 100644 index 0000000..8574fa4 Binary files /dev/null and b/graphics/btn_t_r.png differ diff --git a/graphics/prof.grit b/graphics/prof.grit new file mode 100644 index 0000000..1e14e7a --- /dev/null +++ b/graphics/prof.grit @@ -0,0 +1,3 @@ +# +# Professor : 4bpp, not compressed. Pallet 1, copy from 16 to 32. +-gB4 -ps16 -pe32 \ No newline at end of file diff --git a/graphics/prof.png b/graphics/prof.png new file mode 100644 index 0000000..1beabc4 Binary files /dev/null and b/graphics/prof.png differ diff --git a/graphics/textBoxBG.grit b/graphics/textBoxBG.grit index 6115697..f7af107 100644 --- a/graphics/textBoxBG.grit +++ b/graphics/textBoxBG.grit @@ -1,5 +1,6 @@ # -# Text Box (Background) : 64x64t, 4bpp, SBB-layout, not compressed. +# Text Box (Background) : 64x64t, 4bpp, SBB-layout, not compressed. +# Pallet bank 1, copy from 16 to 32. # -gt -gB4 -mR4 -mLs -mp1 -ps16 -pe32 diff --git a/graphics/textBoxBG.png b/graphics/textBoxBG.png index 056c8b5..0db4ec8 100644 Binary files a/graphics/textBoxBG.png and b/graphics/textBoxBG.png differ diff --git a/graphics/unused graphics/8144.gif b/graphics/unused graphics/8144.gif new file mode 100644 index 0000000..b4ea61c Binary files /dev/null and b/graphics/unused graphics/8144.gif differ diff --git a/graphics/unused graphics/tte_font.png b/graphics/unused graphics/tte_font.png new file mode 100644 index 0000000..d1bf495 Binary files /dev/null and b/graphics/unused graphics/tte_font.png differ diff --git a/include/button_handler.h b/include/button_handler.h new file mode 100644 index 0000000..f22e349 --- /dev/null +++ b/include/button_handler.h @@ -0,0 +1,26 @@ +#ifndef BUTTON_HANDLER_H +#define BUTTON_HANDLER_H + +#include + +class Button +{ +public: + Button(); + Button(OBJ_ATTR *L, OBJ_ATTR *R, u32 tidL, 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 *button_L; + OBJ_ATTR *button_R; + u32 tidL; + u32 tidR; +}; + +#endif \ No newline at end of file diff --git a/include/main_menu.h b/include/main_menu.h new file mode 100644 index 0000000..2a5884e --- /dev/null +++ b/include/main_menu.h @@ -0,0 +1,15 @@ +#ifndef MAIN_MENU_H +#define MAIN_MENU_H + +#include + +#include "button_handler.h" + +#define TRANSFER 1 +#define POKEDEX 2 +#define CREDITS 3 + +void main_menu_init(Button transfer, Button pokedex, Button credits); +int main_menu_loop(); + +#endif \ No newline at end of file diff --git a/include/sprite_data.h b/include/sprite_data.h index b19ffac..684ce19 100644 --- a/include/sprite_data.h +++ b/include/sprite_data.h @@ -1,5 +1,24 @@ #include +extern OBJ_ATTR obj_buffer[128]; +extern OBJ_AFFINE *obj_aff_buffer; + +extern OBJ_ATTR *testroid; +extern OBJ_ATTR *prof; +extern OBJ_ATTR *btn_t_l; +extern OBJ_ATTR *btn_t_r; +extern OBJ_ATTR *btn_p_l; +extern OBJ_ATTR *btn_p_r; +extern OBJ_ATTR *btn_c_l; +extern OBJ_ATTR *btn_c_r; + void load_background(); void load_textbox_background(); -void load_testroid(OBJ_ATTR obj_buffer[]); +void load_testroid(); +void load_professor(); +void load_btn_t_l(); +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(); \ No newline at end of file diff --git a/source/button_handler.cpp b/source/button_handler.cpp new file mode 100644 index 0000000..f3b33b5 --- /dev/null +++ b/source/button_handler.cpp @@ -0,0 +1,32 @@ +#include "button_handler.h" + +Button::Button(){} + +Button::Button(OBJ_ATTR *L, OBJ_ATTR *R, u32 ntidL, u32 ntidR) +{ + button_L = L; + button_R = R; + tidL = ntidL; + tidR = ntidR; + hide(); +} +void Button::set_location(int nx, int ny) +{ + x = nx; + y = ny; + obj_set_pos(button_L, x, y); + obj_set_pos(button_R, x + 48, y); +} +void Button::set_highlight(bool highlight) +{ + button_L->attr2 = ATTR2_BUILD(tidL, (highlight ? 3 : 2), 0); + button_R->attr2 = ATTR2_BUILD(tidR, (highlight ? 3 : 2), 0); +} +void Button::hide() +{ + obj_hide_multi(button_L, 3); +} +void Button::show() +{ + obj_unhide_multi(button_L, 0, 3); +} \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 0416994..a310221 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "debug.h" #include "flash_mem.h" @@ -15,7 +16,8 @@ #include "pokemon_party.h" #include "script_array.h" #include "sprite_data.h" -#include +#include "button_handler.h" +#include "main_menu.h" /*TODO: -------- @@ -53,9 +55,6 @@ TESTING: -------- */ -OBJ_ATTR obj_buffer[128]; -OBJ_AFFINE *obj_aff_buffer = (OBJ_AFFINE *)obj_buffer; - Pokemon_Party party = Pokemon_Party(); text_engine main_text = text_engine(); @@ -76,18 +75,48 @@ int main(void) add_script_party_var(party); + oam_init(obj_buffer, 128); + load_background(); load_textbox_background(); - load_testroid(obj_buffer); + load_testroid(); + load_professor(); + load_btn_t_l(); + load_btn_t_r(); + load_btn_p_l(); + load_btn_p_r(); + load_btn_c_l(); + load_btn_c_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); + + main_menu_init(transfer_btn, pokedex_btn, credits_btn); + + + // Set up blend to fade to white/black // MAIN LOOP while (1) { + switch (main_menu_loop()) + { + case (TRANSFER): + break; + case (POKEDEX): + + break; + case (CREDITS): + + break; + } + key_poll(); rand_next_frame(); background_frame(); - main_text.next_frame(); - oam_copy(oam_mem, obj_buffer, 1); + //main_text.next_frame(); + oam_copy(oam_mem, obj_buffer, 8); } } diff --git a/source/main_menu.cpp b/source/main_menu.cpp new file mode 100644 index 0000000..d8ddbad --- /dev/null +++ b/source/main_menu.cpp @@ -0,0 +1,50 @@ +#include +#include "main_menu.h" +#include "button_handler.h" + + + +int menu_slot = 1; +int old_menu_slot = 0; + +Button button_array[4]; + +void main_menu_init(Button nTransfer, Button nPokedex, Button nCredits) +{ + button_array[TRANSFER] = nTransfer; + button_array[POKEDEX] = nPokedex; + button_array[CREDITS] = nCredits; + button_array[TRANSFER].set_location(10, 10); + button_array[POKEDEX].set_location(10, 60); + button_array[CREDITS].set_location(10, 100); + button_array[TRANSFER].show(); + button_array[POKEDEX].show(); + button_array[CREDITS].show(); +} + +int main_menu_loop() +{ + if(key_hit(KEY_DOWN)){ + if (menu_slot != CREDITS){ + menu_slot++; + } + } + + if (key_hit(KEY_UP)){ + if (menu_slot != TRANSFER){ + menu_slot--; + } + } + + if (key_hit(KEY_A)){ + return (menu_slot); + } + + if (menu_slot != old_menu_slot) + { + button_array[menu_slot].set_highlight(true); + button_array[old_menu_slot].set_highlight(false); + old_menu_slot = menu_slot; + } + return 0; +} diff --git a/source/sprite_data.cpp b/source/sprite_data.cpp index e617426..a1c559e 100644 --- a/source/sprite_data.cpp +++ b/source/sprite_data.cpp @@ -2,6 +2,8 @@ #include #include "sprite_data.h" +OBJ_ATTR obj_buffer[128]; +OBJ_AFFINE *obj_aff_buffer = (OBJ_AFFINE *)obj_buffer; #include "brin.h" @@ -15,9 +17,7 @@ void load_background(){ // Load map into SBB 30 memcpy(&se_mem[SBB][0], brinMap, brinMapLen); - // set up BG0 for a 4bpp 32x32t map, using - // using charblock CBB and screenblock SBB - REG_BG0CNT= BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(3); + REG_BG0CNT= BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(2); } #include "textboxBG.h" @@ -31,36 +31,156 @@ void load_textbox_background(){ // Load map into SBB 0 memcpy(&se_mem[SBB][0], textBoxBGMap, textBoxBGMapLen); - // set up BG0 for a 4bpp 32x32t map, using - // using charblock CBB and screenblock SBB REG_BG2VOFS = 96; - REG_BG2CNT = BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(2); + REG_BG2CNT = BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(3); } -#include "metr.h" // 41 tiles -void load_testroid(OBJ_ATTR obj_buffer[]){ - // Text box - // (1) Places the tiles of a 4bpp boxed sprite - // into LOW obj memory (cbb == 4) +#include "metr.h" +OBJ_ATTR *testroid = &obj_buffer[0]; +void load_testroid(){ + memcpy(&tile_mem[4][0], metrTiles, metrTilesLen); memcpy(pal_obj_mem, metrPal, metrPalLen); - // (2) Initialize all sprites - //oam_init(obj_buffer, 128); - int x= 0, y= 0; - u32 tid= 0, pb= 0; // (3) tile id, pal-bank - OBJ_ATTR *testroid= &obj_buffer[0]; + u32 tid= 0, pb= 0; // tile id, pal-bank obj_set_attr(testroid, - ATTR0_SQUARE, // Square, regular sprite - ATTR1_SIZE_64x64, // 64x64p, - ATTR2_PALBANK(pb) | tid); // palbank 0, tile 0 + ATTR0_SQUARE, + ATTR1_SIZE_64x64, + ATTR2_PALBANK(pb) | tid); - // (4) position sprite (redundant here; the _real_ position - // is set further down 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(){ + 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 + + 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); +} + + +#include "btn_t_l.h" +OBJ_ATTR *btn_t_l = &obj_buffer[2]; +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 + + 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); +} + +#include "btn_t_r.h" +OBJ_ATTR *btn_t_r = &obj_buffer[3]; +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 + + 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); +} + +#include "btn_p_l.h" +OBJ_ATTR *btn_p_l = &obj_buffer[4]; +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); + + 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_pos(btn_p_l, x, y); + obj_hide(btn_p_l); + //obj_unhide(btn_p_l, 0); +} + +#include "btn_p_r.h" +OBJ_ATTR *btn_p_r = &obj_buffer[5]; +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); + + 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_pos(btn_p_r, x, y); + obj_hide(btn_p_r); + //obj_unhide(btn_p_r, 0); +} + +#include "btn_c_l.h" +OBJ_ATTR *btn_c_l = &obj_buffer[6]; +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); + + 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_pos(btn_c_l, x, y); + obj_hide(btn_c_l); + //obj_unhide(btn_c_l, 0); +} + +#include "btn_c_r.h" +OBJ_ATTR *btn_c_r = &obj_buffer[7]; +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); + + 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_pos(btn_c_r, x, y); + obj_hide(btn_c_r); + //obj_unhide(btn_c_r, 0); +} \ No newline at end of file