Skip to content

Commit

Permalink
Merge branch 'pikalax_work' of github.com:PikalaxALT/pokediamond into…
Browse files Browse the repository at this point in the history
… pikalax_work
  • Loading branch information
PikalaxALT committed Nov 11, 2021
2 parents 31601eb + 2e8f24c commit 94edcc1
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 93 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,15 @@ $(CLOBBER_SIZE_VERSION101_NCGR_FILES): GFX_FLAGS = -clobbersize -version101
$(VERSION101_SOPC_8BPP_NCGR_FILES): GFX_FLAGS = -version101 -sopc -bitdepth 8
$(VERSION101_SOPC_NCGR_FILES): GFX_FLAGS = -version101 -sopc
$(SCANNED_NCGR_FILES): GFX_FLAGS = -scanned
$(NOBYTEORDER_NCGR_FILES): GFX_FLAGS = -nobyteorder
$(NOBYTEORDER_WRONGSIZE_NCGR_FILES): GFX_FLAGS = -nobyteorder -wrongsize

$(IR_NCLR_FILES): GFX_FLAGS = -ir
$(4BPP_NCLR_FILES): GFX_FLAGS = -bitdepth 4
$(8BPP_NSCR_FILES): GFX_FLAGS = -bitdepth 8
$(8BPP_COMP10_NOPAD_NCLR_PNG_FILES): GFX_FLAGS = -bitdepth 8 -nopad -comp 10
$(8BPP_COMP10_NOPAD_NCLR_PAL_FILES): GFX_FLAGS = -bitdepth 8 -nopad -comp 10
$(NCPR_NCLR_FILES): GFX_FLAGS = -ncpr

%.NCGR: %.png
$(GFX) $< $@ $(GFX_FLAGS)
Expand Down Expand Up @@ -301,3 +304,4 @@ diamond: ; @$(HOST_VARS) $(MAKE) GAME_VERSION=DIAMOND
pearl: ; @$(HOST_VARS) $(MAKE) GAME_VERSION=PEARL
compare_diamond: ; @$(HOST_VARS) $(MAKE) GAME_VERSION=DIAMOND COMPARE=1
compare_pearl: ; @$(HOST_VARS) $(MAKE) GAME_VERSION=PEARL COMPARE=1
compare: compare_diamond
2 changes: 1 addition & 1 deletion arm9/arm9.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Static arm9
Object unk_02014BF4.o
Object unk_02015CC0.o
Object rs_migrate_string.o
Object unk_02015E30.o
Object play_timer.o
Object game_init.o
Object heap.o
Object bg_window.o
Expand Down
6 changes: 3 additions & 3 deletions arm9/global.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1003,9 +1003,9 @@
.extern FUN_02015CE0
.extern FUN_02015CF8
.extern ConvertRSStringToDPStringInternational
.extern FUN_02015E30
.extern FUN_02015E3C
.extern FUN_02015E60
.extern PlayTimerInit
.extern PlayTimerStart
.extern PlayTimerUpdate
.extern FUN_02015EF4
.extern Main_SetVBlankIntrCB
.extern FUN_02015F1C
Expand Down
6 changes: 3 additions & 3 deletions arm9/modules/52/src/module_52.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "module_52.h"
#include "heap.h"
#include "unk_0205FA2C.h"
#include "unk_02015E30.h"
#include "play_timer.h"


extern struct Unk21DBE18 UNK_020FD144;
Expand Down Expand Up @@ -202,7 +202,7 @@ THUMB_FUNC BOOL MOD52_021D7540(struct UnkStruct_02006234 *param0, u32 *unused)

MOD52_021D7604(0x4d, sav2, 1);
struct IGT *igt = Sav2_PlayerData_GetIGTAddr(sav2);
FUN_02015E3C(igt);
PlayTimerStart(igt);

return 1;
}
Expand Down Expand Up @@ -243,7 +243,7 @@ THUMB_FUNC BOOL MOD52_021D7594(struct UnkStruct_02006234 *param0, u32 *unused)
Sav2_SysInfo_InitFromSystem(sav2_info);
}

FUN_02015E3C(Sav2_PlayerData_GetIGTAddr(sav2));
PlayTimerStart(Sav2_PlayerData_GetIGTAddr(sav2));

return 1;
}
Expand Down
8 changes: 4 additions & 4 deletions arm9/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ struct UnkStruct_02016FA8 UNK_02016FA8;
extern void FUN_02022294(void);
extern void GF_InitRTCWork(void);
extern int FUN_020337E8(int);
extern void FUN_02015E30(void);
extern void PlayTimerInit(void);
extern void FUN_0201B5CC(void *);
extern void GF_RTC_UpdateOnFrame(void);
extern void FUN_02015E60(void);
extern void PlayTimerUpdate(void);
extern void FUN_020222C4(void);
extern void FUN_0200E2D8(void);

Expand Down Expand Up @@ -97,7 +97,7 @@ THUMB_FUNC void NitroMain(void)
gMain.unk30 = 0;
InitializeMainRNG();
InitAllScreenBrightnessData();
FUN_02015E30();
PlayTimerInit();
UNK_02016FA4 = 0;
for (;;)
{
Expand All @@ -120,7 +120,7 @@ THUMB_FUNC void NitroMain(void)
}
}
GF_RTC_UpdateOnFrame();
FUN_02015E60();
PlayTimerUpdate();
FUN_020222C4();
FUN_0201B5CC(gMain.unk24);
OS_WaitIrq(1, 1);
Expand Down
37 changes: 37 additions & 0 deletions arm9/src/play_timer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

#include "play_timer.h"

u64 sTimer3Start;
u64 sUnused;
u64 sDuration;
struct IGT * sIGT_p;
BOOL sTimerActive;

THUMB_FUNC void PlayTimerInit()
{
sTimerActive = FALSE;
}

THUMB_FUNC void PlayTimerStart(struct IGT *igt)
{
sTimerActive = TRUE;
sUnused = 0;
sDuration = 0;
sIGT_p = igt;

sTimer3Start = GetTimer3Count();
}

THUMB_FUNC void PlayTimerUpdate(void)
{
if (sTimerActive)
{
u64 res = Timer3CountToSeconds(GetTimer3Count() - sTimer3Start);

if (sDuration < res)
{
AddIGTSeconds(sIGT_p, (u32)(res - sDuration));
sDuration = res;
}
}
}
37 changes: 0 additions & 37 deletions arm9/src/unk_02015E30.c

This file was deleted.

2 changes: 2 additions & 0 deletions files/data/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
cell0.NCGR
cell0.NCLR
dp_areawindow.NCGR
dp_areawindow.NCLR
Binary file modified files/data/dp_areawindow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions graphics_rules.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#todo data/dp_areawindow.NCGR (weirdness with size)
#todo data/graphic/bag_gra/narc_0007.NCGR (SOPC section) (width 32, palette narc_0003.NCLR)

CLOBBER_SIZE_NCGR_FILES := files/data/cell0.NCGR
Expand Down Expand Up @@ -122,7 +121,7 @@ CLOBBER_SIZE_VERSION101_NCGR_FILES := files/graphic/bag_gra/narc_0002.NCGR \
files/poketool/icongra/poke_icon/narc_0000.NCLR \
files/resource/eng/trial/trial/narc_0000.NCLR \
files/resource/eng/trial/trial/narc_0003.NCLR \
files/resource/eng/trial/trial/narc_0006.NCLR \
files/resource/eng/trial/trial/narc_0006.NCLR

8BPP_NSCR_FILES := files/demo/title/titledemo/narc_0000.NSCR

Expand Down Expand Up @@ -157,6 +156,9 @@ IR_NCLR_FILES := files/itemtool/itemdata/item_icon/narc_0028.NCLR \
files/itemtool/itemdata/item_icon/narc_0111.NCLR \
files/itemtool/itemdata/item_icon/narc_0114.NCLR

NCPR_NCLR_FILES := files/data/dp_areawindow.NCLR
NOBYTEORDER_WRONGSIZE_NCGR_FILES := files/data/dp_areawindow.NCGR

VERSION101_SOPC_8BPP_NCGR_FILES := files/demo/title/titledemo/narc_0001.NCGR \
files/demo/title/titledemo/narc_0003.NCGR

Expand Down
8 changes: 8 additions & 0 deletions include/constants/trdata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Created by scott on 16-Sep-21.
//

#ifndef POKEDIAMOND_TRDATA_H
#define POKEDIAMOND_TRDATA_H

#endif //POKEDIAMOND_TRDATA_H
13 changes: 0 additions & 13 deletions include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ struct UnkStruct_02006234
u32 unk24;
};

struct Unk2106FA0
{
PMBackLightSwitch unk0;
s32 unk4;
FSOverlayID unk8;
struct UnkStruct_02006234 *unkC;
FSOverlayID unk10;
const struct Unk21DBE18 * unk14;
s32 unk18;
s32 unk1C;
struct SaveBlock2 * unk20;
};

struct Unk21C4818
{
u32 unk0;
Expand Down
12 changes: 12 additions & 0 deletions include/play_timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef POKEDIAMOND_PLAY_TIMER_H
#define POKEDIAMOND_PLAY_TIMER_H

#include "global.h"
#include "igt.h"
#include "timer3.h"

void PlayTimerInit(void);
void PlayTimerStart(struct IGT *igt);
void PlayTimerUpdate(void);

#endif //POKEDIAMOND_PLAY_TIMER_H
22 changes: 0 additions & 22 deletions include/unk_02015E30.h

This file was deleted.

14 changes: 8 additions & 6 deletions tools/nitrogfx/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m
free(buffer);
}

void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101, bool sopc, bool scanned, uint32_t key)
void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image,
bool invertColors, bool clobberSize, bool byteOrder, bool version101, bool sopc, bool scanned,
uint32_t key, bool wrongSize)
{
FILE *fp = fopen(path, "wb");

Expand Down Expand Up @@ -499,15 +501,15 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in
}
}

WriteGenericNtrHeader(fp, "RGCN", bufferSize + (sopc ? 0x30 : 0x20), byteOrder, version101, sopc ? 2 : 1);
WriteGenericNtrHeader(fp, "RGCN", bufferSize + (sopc ? 0x30 : 0x20) + (wrongSize ? -8 : 0), byteOrder, version101, sopc ? 2 : 1);

unsigned char charHeader[0x20] = { 0x52, 0x41, 0x48, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00 };

charHeader[4] = (bufferSize + 0x20) & 0xFF;
charHeader[5] = ((bufferSize + 0x20) >> 8) & 0xFF;
charHeader[6] = ((bufferSize + 0x20) >> 16) & 0xFF;
charHeader[7] = ((bufferSize + 0x20) >> 24) & 0xFF;
charHeader[4] = (bufferSize + 0x20 + (wrongSize ? -8 : 0)) & 0xFF;
charHeader[5] = ((bufferSize + 0x20 + (wrongSize ? -8 : 0)) >> 8) & 0xFF;
charHeader[6] = ((bufferSize + 0x20 + (wrongSize ? -8 : 0)) >> 16) & 0xFF;
charHeader[7] = ((bufferSize + 0x20 + (wrongSize ? -8 : 0)) >> 24) & 0xFF;

if (!clobberSize)
{
Expand Down
4 changes: 3 additions & 1 deletion tools/nitrogfx/gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ struct Image {
void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
uint32_t ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors);
void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101, bool sopc, bool scanned, uint32_t key);
void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image,
bool invertColors, bool clobberSize, bool byteOrder, bool version101, bool sopc, bool scanned,
uint32_t key, bool wrongSize);
void FreeImage(struct Image *image);
void ReadGbaPalette(char *path, struct Palette *palette);
void ReadNtrPalette(char *path, struct Palette *palette, int bitdepth, int palIndex);
Expand Down
7 changes: 6 additions & 1 deletion tools/nitrogfx/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ void ConvertPngToNtr(char *inputPath, char *outputPath, struct PngToNtrOptions *
free(string);
}

WriteNtrImage(outputPath, options->numTiles, image.bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette, options->clobberSize, options->byteOrder, options->version101, options->sopc, options->scanned, key);
WriteNtrImage(outputPath, options->numTiles, image.bitDepth, options->metatileWidth, options->metatileHeight,
&image, !image.hasPalette, options->clobberSize, options->byteOrder, options->version101,
options->sopc, options->scanned, key, options->wrongSize);

FreeImage(&image);
}
Expand Down Expand Up @@ -442,6 +444,9 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a
{
options.scanned = true;
}
else if (strcmp(option, "-wrongsize") == 0) {
options.wrongSize = true;
}
else
{
FATAL_ERROR("Unrecognized option \"%s\".\n", option);
Expand Down
1 change: 1 addition & 0 deletions tools/nitrogfx/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct PngToNtrOptions {
bool version101;
bool sopc;
bool scanned;
bool wrongSize;
};

struct Attr0 {
Expand Down

0 comments on commit 94edcc1

Please sign in to comment.