Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Veslyquix committed Mar 26, 2024
1 parent e0027b7 commit 2d04ac0
Show file tree
Hide file tree
Showing 400 changed files with 150,217 additions and 0 deletions.
10 changes: 10 additions & 0 deletions AsmHooks.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.thumb

.global function1
.type function1, %function
function1:
push {lr}
@bl function2
pop {r0}
bx r0
.ltorg
6 changes: 6 additions & 0 deletions AsmHooks.lyn.event
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALIGN 4
PUSH
ORG CURRENTOFFSET+$1;function1:
POP
WORD $BC01B500
SHORT $4700
26 changes: 26 additions & 0 deletions AssembleLyn.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off

SET startDir="C:\devkitPro\devkitARM\bin\"
SET as="%startDir%arm-none-eabi-as"
SET LYN="C:\devkitPro\lyn.exe"

@rem Assemble into an elf
%as% -g -mcpu=arm7tdmi -mthumb-interwork %1 -o "%~n1.elf"

if exist "Definitions.s" (

@rem Assemble definitions into a .elf if exists
%as% -g -mcpu=arm7tdmi -mthumb-interwork "Definitions.s" -o "Definitions.elf"

@rem Assebmle into a .lyn.event with definitions
%LYN% "%~n1.elf" "Definitions.elf" > "%~n1.lyn.event"

echo y | del "%~dp0Definitions.elf"
) else (
@rem Assemble into a .lyn.event
%LYN% "%~n1.elf" > "%~n1.lyn.event"
)

echo y | del "%~n1.elf"

pause
156 changes: 156 additions & 0 deletions C_code.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@

#include "include/aw2.h"

struct RandomizerSettings {
u16 base : 1;
u16 growth : 2; // vanilla, randomized, 0%, 100%
u16 caps : 2; // vanilla, randomized, 30
u16 class : 1;
u16 itemStats : 1;
u16 foundItems : 1;
u16 shopItems : 1;
u16 disp : 1;
};

struct RandomizerValues {
u32 seed : 20; // max value of 999999 /
u32 variance : 5; // up to 5*31 / 100%
u32 bonus : 5; // up to +31 / +20 levels
};

extern struct RandomizerSettings RandBitflags;
extern struct RandomizerValues RandValues;
extern u8 gCh;
extern u32 gGameClock;


int NextSeededRN(u16* currentRN) {
// This generates a pseudorandom string of 16 bits
// In other words, a pseudorandom integer that can range from 0 to 65535

u16 rn = (currentRN[1] << 11) + (currentRN[0] >> 5);

// Shift state[2] one bit
currentRN[2] *= 2;

// "carry" the top bit of state[1] to state[2]
if (currentRN[1] & 0x8000)
currentRN[2]++;

rn ^= currentRN[2];

// Shifting the whole state 16 bits
currentRN[2] = currentRN[1];
currentRN[1] = currentRN[0];
currentRN[0] = rn;

return rn;
}

void InitSeededRN(int seed, u16* currentRN) {
// This table is a collection of 8 possible initial rn state
// 3 entries will be picked based of which "seed" was given

u16 initTable[8] = {
0xA36E,
0x924E,
0xB784,
0x4F67,
0x8092,
0x592D,
0x8E70,
0xA794
};

int mod = Mod(seed, 7);

currentRN[0] = initTable[(mod++ & 7)];
currentRN[1] = initTable[(mod++ & 7)];
currentRN[2] = initTable[(mod & 7)];

if (Mod(seed, 23) > 0)
for (mod = Mod(seed, 23); mod != 0; mod--)
NextSeededRN(currentRN);
}

u16 GetNthRN(int n, int seed) {
u16 currentRN[3] = { 0, 0, 0 };
InitSeededRN(seed, currentRN);
int result = 0;
for (int i = 0; i < n; i++) {
result = NextSeededRN(currentRN);
}

return result;
}

int GetInitialSeed(void) {
int result = RandValues.seed;
if (!result) {
result = 0; //TacticianName[1] | (TacticianName[2]<<8) | (TacticianName[3]<<16);
int clock = gGameClock;
result = (GetNthRN(clock, result)<<4) | GetNthRN(clock, result);
}
if (result > 999999) { result &= 0xEFFFF; }
return result;
}

u16 HashByte_Global(int number, int max, u8 noise[], int offset) {
if (max==0) return 0;
offset = Mod(offset, 256);
u32 hash = 5381;
hash = ((hash << 5) + hash) ^ number;
//hash = ((hash << 5) + hash) ^ *StartTimeSeedRamLabel;
u8 seed[3] = { (RandValues.seed & 0xFF), (RandValues.seed&0xFF00)>>8, (RandValues.seed&0xFF0000)>>16 };
for (int i = 0; i < 3; ++i){
hash = ((hash << 5) + hash) ^ seed[i];
};
int noisy = noise[0] | (noise[1] << 8) | (noise[2] << 16) | (noise[3] << 24);

//u16 currentRN[3] = { 0, 0, 0 };
hash = GetNthRN(offset + 1, noisy+hash);
//InitSeededRN(hash + seed, currentRN);
//hash = NextSeededRN(currentRN);
//for (i = 0; i < 9; i++) {
//if (!noise[i]) { break; }
//hash = ((hash << 5) + hash) ^ noise[i];
//}

return Mod((hash & 0x2FFFFFFF), max);
};

u16 HashByte_Ch(int number, int max, u8 noise[], int offset){
int i = 0;
for (i = 0; i < 9; i++) {
if (!noise[i]) { break; }
}
noise[i+1] = gCh;
noise[i+2] = 0;
return HashByte_Global(number, max, noise, offset);
};

s16 HashPercent(int number, u8 noise[], int offset, int global, int earlygamePromo){
if (number < 0) number = 0;
int variation = (RandValues.variance)*5;
int percentage = 0;
if (global) {
percentage = HashByte_Global(number, variation*2, noise, offset); //rn up to 150 e.g. 125
}
else { percentage = HashByte_Ch(number, variation*2, noise, offset); } //rn up to 150 e.g. 125
percentage += (100-variation); // 125 + 25 = 150
if (earlygamePromo == 1) { if (percentage > 125) { percentage = percentage / 2; } }
if (earlygamePromo == 2) { if (percentage > 150) { percentage = percentage / 2; } }
int ret = (percentage * number) / 100; //1.5 * 120 (we want to negate this)
if (ret > 127) ret = (200 - percentage) * number / 100;
if (ret < 0) ret = 0;
return ret;
};

s16 HashByPercent_Ch(int number, u8 noise[], int offset, int earlygamePromo){
return HashPercent(number, noise, offset, false, earlygamePromo);
};

s16 HashByPercent(int number, u8 noise[], int offset){
return HashPercent(number, noise, offset, true, false);
};

17 changes: 17 additions & 0 deletions C_code.lyn.event
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ALIGN 4
PUSH
ORG CURRENTOFFSET+$1;NextSeededRN:
ORG CURRENTOFFSET+$34;InitSeededRN:
ORG CURRENTOFFSET+$98;GetNthRN:
ORG CURRENTOFFSET+$c4;GetInitialSeed:
ORG CURRENTOFFSET+$3c;HashByte_Global:
ORG CURRENTOFFSET+$14;HashByte_Ch:
ORG CURRENTOFFSET+$3c;HashPercent:
ORG CURRENTOFFSET+$9c;HashByPercent_Ch:
ORG CURRENTOFFSET+$80;HashByPercent:
POP
WORD $B5300003 $88048841 $96202C8 $889A1880 $4520400 $C00040D $142D0C12 $3201D502 $C120412 $80994050 $8018805C $BC02BC30 $46C04708 $46CEB5F0 $B5804647 $466CB085 $46800022 $F4B1F $C223CB23 $6013681B $21074B1D $46994640 $F99EF000 $1A2307 $524002 $1C425B16 $401A3002 $524003 $5B15005B $21175B1C $803E4640 $80BC807D $F98CF000 $DC022800 $35E015 $2EB001E $189B0972 $464041B $C240C1B $D502042A $4243401 $38010C24 $2C4063 $D1EC2800 $807E80BD $B005803B $46B9BCC0 $BCF046B0 $4700BC01
POIN CURRENTOFFSET+732
WORD $808AAB1 $B082B570 $80004 $F7FF4669 $2C00FFAD $466BDD1C $885A2100 $889E881D $2AE001 $2D00005 $181B096B $476041B $C300C1B $D5020416 $4003001 $31010C00 $40580016 $D1EC428C $BC70B002 $4708BC02 $E7F92000 $DB5F8 $72180 $4E170014 $490018 $F935F000 $4A164B15 $407A681B $18BF0157 $E12061A $319407A $41B0157 $E1B18BA $15A4053 $F0B18D2 $40537861 $2097822 $78A24311 $430A0412 $60978E1 $18594311 $F7FF3001 $29FFAD $F911F000 $C000400 $BC02BCF8 $46C04708 $808AAB1 $203FFFC $2B5A5 $681B4B0A $B510031B $2B000B18 $4B08D106 $68182100 $FF92F7FF $43180103 $42984B05 $4B05DD01 $BC104018 $4708BC02 $203FFFC $3004008 $F423F $EFFFF $2900B510 $F7FFD004 $BC10FFA3 $4708BC02 $E7FA2000 $2400B570 $2D005D15 $3401D012 $D1F92C09 $3402260A $782D4D08 $25005595 $29005515 $F7FFD004 $BC70FF8B $4708BC02 $E7FA2000 $34021C66 $46C0E7EE $3004FC2 $4B570 $E43C0 $17C04922 $88484004 $EC005C0 $182D0085 $2B000069 $2800D02C $13D014 $320020 $FF6AF7FF $1B439A04 $2A013364 $2201D02A $DC002B96 $6122200 $9A04D005 $D1022A02 $E000105B $22C82364 $43580020 $42900192 $20C8DB02 $43601AC0 $21644B0D $F88AF000 $17DB43C3 $4004018 $BC701400 $4708BC02 $200013 $F7FF0032 $9A04FFA1 $33641B43 $D1D42A01 $DDDE2B7D $E7DC105B $203FFFC $808AAAD $1DB5F8 $443C3 $17DB000F $4B1A401C $5C08858 $860EC0 $131836 $3A0020 $F7FF0071 $1B82FF81 $2D013264 $2301D01F $DD182A96 $D001061B $D01A2D02 $1023C8 $19B4360 $DB024298 $1A8020C8 $4B0B4360 $F0002164 $43C3F845 $401817DB $14000400 $BC02BCF8 $23004708 $D1E5061B $2A7DE7E6 $1052DDE4 $46C0E7E2 $203FFFC $808AAAD $5B570 $1343C0 $88544A13 $5E417C0 $EE04005 $18240084 $D0052800 $A0060 $280001 $FEDEF7FF $1B0322C8 $183364 $1924368 $DB024290 $1AC020C8 $4B074368 $F0002164 $43C3F80D $401817DB $14000400 $BC02BC70 $46C04708 $203FFFC $808AAAD $47304718 $46C04748
ALIGN 4
WORD $924EA36E $4F67B784 $592D8092 $A7948E70
34 changes: 34 additions & 0 deletions Definitions.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@.include "aw2.s" @ if I find one

.macro SET_FUNC name, value
.global \name
.type \name, function
.set \name, \value
.endm

.macro SET_DATA name, value
.global \name
.type \name, object
.set \name, \value
.endm


SET_FUNC __aeabi_idiv, 0x808AAAD
SET_FUNC Div, 0x808AAAD
SET_FUNC Mod, 0x808AAB1
SET_FUNC CpuSet, 0x808AAA9
SET_FUNC CpuFastSet, 0x808AAA5
SET_FUNC BgAffineSet, 0x808AAA0

SET_DATA gCh, 0x3004FC2 @ from 0x8078E10
SET_DATA RandValues, 0x203FFFC
SET_DATA RandBitflags, 0x203FFF8
SET_DATA gGameClock, 0x3004008 @ in 80368D4

@ GetClassAtt ?
@0804310C - Atk
@0804317C - Def
@080431EC - Mov
@0804325C - Rng


Binary file added EventAssembler/ColorzCore
Binary file not shown.
23 changes: 23 additions & 0 deletions EventAssembler/ColorzCore.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v5.0": {
"ColorzCore/1.0.0": {
"runtime": {
"ColorzCore.dll": {}
}
}
}
},
"libraries": {
"ColorzCore/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file added EventAssembler/ColorzCore.dll
Binary file not shown.
Binary file added EventAssembler/ColorzCore.exe
Binary file not shown.
9 changes: 9 additions & 0 deletions EventAssembler/ColorzCore.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
}
}
}
Binary file added EventAssembler/Core.exe
Binary file not shown.
59 changes: 59 additions & 0 deletions EventAssembler/EA.scheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Scheme>
<!--Codes used by each language-->
<keyword-classes>
<keyword-class name="FE6">ASMC CAM1 CMON CMOF CURF CUMO CURE ENDA JUMP ENUT ENUF MNCH POIN WORD SHORT BYTE STAL WEA1 _0x1 _0x4 _0xA _ASM2 _IF0x21 _0x3E _0x40 _0x41 _0x42 _0x4D _0x4E _0x59 IFAF IFAT ELSE ENIF IFET IFEF IFCNA FADI FADU FAWI FAWU HIDEMAP SHOWMAP REMA BACG TEX1 MORETEXT ITGC ITGV SHLI MONE AFEV AREA CHAR LOCA VILL SHOP CHES DOOR ASME END_MAIN TURN TURN_HM MAC2 MACC LOMA MUS1 MUS2 SOUN MURE MUSI MUNO MUEN CUSI CHAI DISA ENUN FIGH BLDT KILL LOU1 LOU2 MOVE MOVENEXTTO MOMA UNIT ASMWORLDMAP ZOOMTO ZOOMOUT HIGHLIGHT SHOWARROW PLACEDOT REMOVE2 REMOVE1 PLACEFLAG REMOVE4 REMOVE3 SHOWPORTRAIT TEXTWM TEXTBOXTOBOTTOM TEXTBOXTOTOP REMOVETEXTBOX SHOWMAPTEXT ORG ALIGN CURRENTOFFSET MESSAGE ERROR WARNING</keyword-class>
<keyword-class name="FE7">ASMC CAM1 CAM2 CMON CMOF CURF CUMO CURE ENDA ENDB THE_END LYN_END CALL JUMP ENUT ENUF MNCH OOBB POIN WORD SHORT BYTE STAL CGSTAL BLST ENDTRAP FIRE GAST VCBF VCWF WEA1 WEA2 _0x1 _0x8 _0x15 _0x16 _0x17 _0x21 _MOVE0x2C _0x30 _0x33 _ASM0x3F _ASM0x42 _IF0x4A _IF0x4B _IFTT2 _ASM0x59 _ASM0x5A _0x61 _0x6E _0x85 _FADU2 _0x87 _0x89 _0x8A _FADI2 _0x95 _0x96 _0x9A _0xA1 _0xA2 _0xA3 _0xA4 _0xA5 _0xA8 _0xAA _0xAB _0xAD _0xAE _0xB6 _0xBE _0xC1 _0xC2 _0xC3 _0xCA _0xD0 _0xDC _LIGHTNING _0xDE _0xDF _0xE0 _0xE1 _0xE2 _0xE3 _0xE4 _0xE5 _0xE6 IFAF IFAT ELSE ENIF IFET IFEF IFHM IFEM IFYN IFNY IFTT IFTU IFUF IFCA IFCD FADI FADU FAWI FAWU FADICG FADUCG HIDEMAP SHOWMAP REMA RETB REBU BACG SHCG FROMCGTOBG FROMBGTOCG FROMCGTOMAP NEVENTS NCONVOS TEX1 TEX2 MORETEXT TEXTIFEM MORETEXTIFEM TEXTCG MORETEXTCG TEX6 TEX8 TEXTIFTACTF MORETEXTIFTACTF TEXTIFEVENTID MORETEXTIFEVENTID TEXTIFASM MORETEXTIFASM ITGC ITGM ITGV SHLI MONE AFEV AREA CHAR CHARASM LOCA VILL SHOP CHES DOOR ASME END_MAIN UNKWON UNKWON2 COORDS END TURN MAC1 MACC MAC2 MAC3 MACE LOMA MUS1 MUS2 MUS3 SOUN MURE MUSI MUNO MUEN CUSI CHAI UNCM UNCR DISA ENUN FIGH BLDT KILL LOU1 LOUMODE1 LOU2 LOUMODE2 LOEV LOUFILTERED LOUFILTERED2 MOVE MOVENEXTTO MOVEMAINC REPOS MOMA REPA UNIT WARP ASMWORLDMAP PUTSPRITE REMSPRITE LOADWM HIGHLIGHT FADETOWM PLACEDOT RIPPLE SHOWPORTRAIT REMOVEPORTRAIT TEXTWM TEXTBOXTOTOP TEXTBOXTOBOTTOM SCRO REMOVETEXTBOX ORG ALIGN CURRENTOFFSET MESSAGE ERROR WARNING</keyword-class>
<keyword-class name="FE8">ASMC CAM1 CUMO CURE ENDA ENDB CALL MNCH MNC2 POIN WORD SHORT BYTE STAL BLST ENDTRAP FIRE ARROW EGG VCWF WEA1 _SETVAL _SAVEFORBATTLE _CALL_HELL _SETCONDITION _SETCONDITION2 _ASMC2 _MUSICSOMETHING _LOAD1 _LOAD_WHATEVER _LOAD2 _LOAD3 _MOVE _MOVE1 _MOVE2 _MOVE3 _WARP _GIVEITEMTO _GIVEITEMTOMAIN _0x0220 _0x0221 _0x0228 _0x0229 _0x0320 _0x0321 _0x0420 _0x0620 _0x0621 _0x0625 _0x0722 _0x0C44 _0x0C45 _0x0E22 _0x0E23 _0x0F20 _0x0F21 _0x0F23 _0x1020 _0x1120 _0x1322 _0x1324 _0x1326 _0x1328 _0x1620 _0x1860 _0x1861 _0x1862 _0x1920 _0x1922 _0x1923 _0x1924 _0x1925 _0x1927 _0x1928 _0x1929 _0x1A21 _0x1A22 _0x1A23 _0x1A24 _0x1A25 _0x1B21 _0x2140 _0x2141 _0x2220 _0x2620 _0x2629 _0x2720 _0x2721 _0x2920 _0x2A23 _0x2A24 _0x2B22 _0x2D20 _0x2E21 _0x3240 _0x3242 _0x3322 _0x3320 _0x3323 _0x3325 _0x3326 _0x3327 _0x3328 _0x3420 _0x3421 _0x3425 _0x3428 _0x342A _0x342B _0x342C _0x342D _0x342E _0x3640 _0x3722 _0x3920 _0x3921 _0x3A40 _0x3E20 _0x4040 _0x4120 _0x4121 _0x412F _0x4220 _0x422F _0x4320 _0x4420 _0x4520 _0x452F _0x8340 _0x8440 _0x8540 _0x8680 _0x8780 _0x8880 _0x8920 _0x9040 _0x9140 _0x9240 _0x9340 _0x9440 _0x9540 _0x9640 _0x9720 _0x9920 _0x9A40 _0x9B40 _0x9D40 _0xA140 _0xA240 _0xA340 _0xA440 _0xA520 _0xA640 _0xA760 _0xA8C0 _0xA980 _0xAA40 _0xAB40 _0xAC40 _0xAF40 _0xB120 _0xB240 _0xB320 _0xB460 _0xB520 _0xB680 _0xB720 _0xB840 _0xB940 _0xBA40 _0xBD40 _0xBE40 _0xC220 _0xC360 _0xC540 _0xC720 _0xC920 ELSE ENIF FADI FADU FAWU FAWI REMA TEX8 TEXTSTART TEXTSHOW TEXTCONT TEXTEND SHLI AFEV AREA CHAR LOCA VILL SHOP CHES DOOR END_MAIN TURN LOMA MUS1 MUS2 MURE SOUN MUSI MUNO CUSA CUSE CUSN DISA ENUN FIG1 FIG2 MOVE PROM UNIT REDA SKIPWN PUTSPRITE REMSPRITE PLACEDOT SHOWPORTRAIT TEXTWM FE8Code ORG ALIGN CURRENTOFFSET MESSAGE ERROR WARNING</keyword-class>
</keyword-classes>
<base-language name="EA-language-base">
<lexer name="cpp" />
<property name="lexer.cpp.track.preprocessor" value="0" />
<use-styles>
<style name="Default" key="32" />
<style name="Whitespace" key="0" class="whitespace" />
<style name="Comment" key="1" class="commentbox" />
<style name="Comment Line" key="2" class="commentline" />
<style name="Number" key="4" class="number" />
<style name="Keyword" key="5" class="keyword" />
<style name="String" key="6" class="string" />
<style name="Character" key="7" class="string" />
<style name="Operator" key="10" bold="true" />
<style name="Identifier" key="11" />
<style name="End of line string" key="12" fore="000000" back="E0C0E0" eolfilled="true" />
</use-styles>
</base-language>
<language base="EA-language-base" name="FE6" title="FE6 Event Assembly" folding="true" foldcomments="true" foldelse="true" foldcompact="true" foldpreproc="true">
<lexer name="cpp" />
<property name="lexer.cpp.track.preprocessor" value="0" />
<comments line="//" streamStart="/*" streamEnd="*/" />
<use-keywords>
<keyword key="0" name="Code names" class="FE6" />
</use-keywords>
<use-styles>
<style name="Preprocessor" key="9" class="preprocessor" />
</use-styles>
</language>
<language base="EA-language-base" name="FE7" title="FE7 Event Assembly" folding="true" foldcomments="true" foldelse="true" foldcompact="true" foldpreproc="true">
<lexer name="cpp" />
<property name="lexer.cpp.track.preprocessor" value="0" />
<comments line="//" streamStart="/*" streamEnd="*/" />
<use-keywords>
<keyword key="0" name="Code names" class="FE7" />
</use-keywords>
<use-styles>
<style name="Preprocessor" key="9" class="preprocessor" />
</use-styles>
</language>
<language base="EA-language-base" name="FE8" title="FE8 Event Assembly" folding="true" foldcomments="true" foldelse="true" foldcompact="true" foldpreproc="true">
<lexer name="cpp" />
<property name="lexer.cpp.track.preprocessor" value="0" />
<comments line="//" streamStart="/*" streamEnd="*/" />
<use-keywords>
<keyword key="0" name="Code names" class="FE8" />
</use-keywords>
<use-styles>
<style name="Preprocessor" key="9" class="preprocessor" />
</use-styles>
</language>
</Scheme>
Loading

0 comments on commit 2d04ac0

Please sign in to comment.