Working on main menu
3
graphics/btn_c_l.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
|
||||
-gB4 -ps32 -pe48
|
||||
BIN
graphics/btn_c_l.png
Normal file
|
After Width: | Height: | Size: 927 B |
3
graphics/btn_c_r.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
|
||||
-gB4 -ps32 -pe48
|
||||
BIN
graphics/btn_c_r.png
Normal file
|
After Width: | Height: | Size: 927 B |
3
graphics/btn_p_l.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
|
||||
-gB4 -ps32 -pe48
|
||||
BIN
graphics/btn_p_l.png
Normal file
|
After Width: | Height: | Size: 933 B |
3
graphics/btn_p_r.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
|
||||
-gB4 -ps32 -pe48
|
||||
BIN
graphics/btn_p_r.png
Normal file
|
After Width: | Height: | Size: 929 B |
3
graphics/btn_t_l.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
|
||||
-gB4 -ps32 -pe48
|
||||
BIN
graphics/btn_t_l.png
Normal file
|
After Width: | Height: | Size: 929 B |
3
graphics/btn_t_r.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Button : 4bpp, not compressed. Pallet 2, copy from 32 to 48.
|
||||
-gB4 -ps32 -pe48
|
||||
BIN
graphics/btn_t_r.png
Normal file
|
After Width: | Height: | Size: 928 B |
3
graphics/prof.grit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#
|
||||
# Professor : 4bpp, not compressed. Pallet 1, copy from 16 to 32.
|
||||
-gB4 -ps16 -pe32
|
||||
BIN
graphics/prof.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
graphics/unused graphics/8144.gif
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
graphics/unused graphics/tte_font.png
Normal file
|
After Width: | Height: | Size: 756 B |
26
include/button_handler.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef BUTTON_HANDLER_H
|
||||
#define BUTTON_HANDLER_H
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
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
|
||||
15
include/main_menu.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef MAIN_MENU_H
|
||||
#define MAIN_MENU_H
|
||||
|
||||
#include <tonc.h>
|
||||
|
||||
#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
|
||||
|
|
@ -1,5 +1,24 @@
|
|||
#include <tonc.h>
|
||||
|
||||
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();
|
||||
32
source/button_handler.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#include <tonc.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include "debug.h"
|
||||
#include "flash_mem.h"
|
||||
|
|
@ -15,7 +16,8 @@
|
|||
#include "pokemon_party.h"
|
||||
#include "script_array.h"
|
||||
#include "sprite_data.h"
|
||||
#include <cstring>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
50
source/main_menu.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include <tonc.h>
|
||||
#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;
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
#include <cstring>
|
||||
#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);
|
||||
}
|
||||