Some refactors.

This commit is contained in:
GrenderG 2023-09-14 23:58:47 +02:00
parent 664cfd2cba
commit fc559b9f63
2 changed files with 69 additions and 80 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.gb
*.noi
*.map
*.sav
.idea
cmake-build-debug

View File

@ -1,9 +1,10 @@
#include <gb/gb.h>
#include <gb/hardware.h>
//#include <gbdk/console.h>
#include <stdint.h>
#include <stdio.h>
#include <rand.h>
//#include <gbdk/console.h>
#include "gen1.h"
#define PARTY_SIZE 6
@ -18,7 +19,8 @@
#define SER_REG_DIR (*(uint8_t *)0xFF01)
#define SER_OPT_REG_DIR (*(uint8_t *)0xFF02)
const unsigned char MewTiles[] =
const unsigned char mew_tiles[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x03,0x06,0x01,0x08,0x09,0x09,
@ -64,19 +66,13 @@ const unsigned char MewTiles[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define MewMapWidth 5
#define MewMapHeight 5
#define MewMapBank 0
/*const unsigned char MewMap[] =
// It has +128 since we are loading Mew sprites starting at position 128
// to prevent collisions with the font sprites.
const unsigned char mew_map[] =
{
0x14,0x14,0x14,0x0B,0x10,0x14,0x03,0x07,0x0C,0x11,
0x00,0x04,0x08,0x0D,0x12,0x01,0x05,0x09,0x0E,0x14,
0x02,0x06,0x0A,0x0F,0x13
};*/
const unsigned char MewMap[] =
{
0x94,0x94,0x94,0x8b,0x90,0x94,0x83,0x87,0x8c,0x91,0x80,0x84,0x88,0x8d,0x92,0x81,0x85,0x89,0x8e,0x94,0x82,0x86,0x8a,0x8f,0x93
0x94,0x94,0x94,0x8b,0x90,0x94,0x83,0x87,0x8c,0x91,
0x80,0x84,0x88,0x8d,0x92,0x81,0x85,0x89,0x8e,0x94,
0x82,0x86,0x8a,0x8f,0x93
};
enum connection_state_t connection_state = NOT_CONNECTED;
@ -114,7 +110,7 @@ unsigned char nicknames[11] = {
typedef struct TraderPacket {
// Name must not exceed 10 characters + 1 STOP_BYTE
// Any leftover space after STOP_BYTE must be filled with NULL_BYTE
// Any leftover space must be filled with STOP_BYTE
unsigned char name[11];
struct SelectedPokemon selected_pokemon;
struct PartyMember pokemon[6];
@ -480,25 +476,15 @@ void main(void)
}
set_interrupts(SIO_IFLAG); // disable other interrupts. note: this disables sprite movement
puts("");
puts(" Mew Distribution");
puts(" Madrid 2000");
puts("");
puts("");
puts(" Reset: Press Start");
puts("");
puts("");
puts("");
puts("");
puts("");
puts("");
puts("");
puts("");
puts("");
puts("\n Mew Distribution");
puts(" Madrid 2000\n\n");
puts(" Reset: Press Start\n\n\n\n\n\n\n\n\n");
puts(" by @GrenderG");
set_bkg_data(128, 20, MewTiles);
set_bkg_tiles(7, 8, 5, 5, MewMap);
// Load Mew tiles starting at position 128.
set_bkg_data(128, 20, mew_tiles);
// Draw Mew figure in the middle of the screen (more or less).
set_bkg_tiles(7, 8, 5, 5, mew_map);
fill_pokemon_team();
//printf("%u\n", (randw() % (65535 - 60000 + 1)) + 60000);
@ -518,15 +504,17 @@ void main(void)
__endasm;
}
// See https://www.reddit.com/r/retrogamedev/comments/16f4myt/i_homebrewed_a_pokemon_gen_1_mew_distribution/
// and https://github.com/gbdk-2020/gbdk-2020/pull/577
__asm
LD A,#0x02
LD A,#0x02 ; .IO_RECEIVING
LD (__io_status),A ; Store status
LD A,#0x01
LDH (0x02),A ; Use external clock
LDH (0x02),A ; (.SC) Use external clock
LD A,(__io_out)
LDH (0x01),A ; Send __io_out byte
LDH (0x01),A ; (.SB) Send __io_out byte
LD A,#0x81
LDH (0x02),A ; Use external clock
LDH (0x02),A ; (.SC) Use external clock
__endasm;
while(_io_status == IO_RECEIVING || _io_status == IO_SENDING);