Split file_system into decompress

This commit is contained in:
Kermalis 2023-09-07 03:26:32 -04:00
parent 36b18f6348
commit 012094c503
30 changed files with 3058 additions and 3235 deletions

File diff suppressed because it is too large Load Diff

1764
asm/file_system.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,150 +1,6 @@
.section .rodata
@ code_2
.string "pksdir0\0"
.global gUnknown_80B690C
gUnknown_80B690C: @ 80B690C
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x19, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x34, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x85, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x45, 0x01, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00
.byte 0x9e, 0x00, 0x00, 0x00
.byte 0x06, 0x00, 0x00, 0x00
.byte 0x1b, 0x01, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x36, 0x00, 0x00, 0x00
.byte 0x08, 0x00, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.byte 0x09, 0x00, 0x00, 0x00
.byte 0x18, 0x01, 0x00, 0x00
.byte 0x0a, 0x00, 0x00, 0x00
.byte 0x9b, 0x00, 0x00, 0x00
.byte 0x0b, 0x00, 0x00, 0x00
.byte 0x68, 0x00, 0x00, 0x00
.byte 0x0c, 0x00, 0x00, 0x00
.byte 0x42, 0x00, 0x00, 0x00
.byte 0x0d, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x0e, 0x00, 0x00, 0x00
.byte 0x98, 0x00, 0x00, 0x00
.byte 0x0f, 0x00, 0x00, 0x00
.byte 0x15, 0x01, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gUnknown_80B6994
gUnknown_80B6994: @ 80B6994
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x9e, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x18, 0x01, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x98, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gPMDBuildVersion
gPMDBuildVersion: @ 80B69BC
.string "PKDi ver 1.0 [Apr 28 2006] 16:37:54\0"
.align 2,0
.global titlen0_text
titlen0_text:
.string "titlen0\0"
.align 2,0
.global titlen1_text
titlen1_text:
.string "titlen1\0"
.align 2,0
.global titlen2_text
titlen2_text:
.string "titlen2\0"
.align 2,0
.global gLoadScreenBackgroundFileNames
gLoadScreenBackgroundFileNames: @ 80B69F8
.4byte titlen0_text
.4byte titlen1_text
.4byte titlen2_text
.global titlen0p_text
titlen0p_text:
.string "titlen0p\0"
.align 2,0
.global titlen1p_text
titlen1p_text:
.string "titlen1p\0"
.align 2,0
.global titlen2p_text
titlen2p_text:
.string "titlen2p\0"
.align 2,0
.global gLoadScreenBackgroundPaletteFileNames
gLoadScreenBackgroundPaletteFileNames: @ 80B6A28
.4byte titlen0p_text
.4byte titlen1p_text
.4byte titlen2p_text
gSaveTextQuicksaving:: @ 80B6A34
.string "{CENTER_ALIGN}Quicksaving your adventure...\n"
.string "{CENTER_ALIGN}Please don{APOSTROPHE}t turn off the power.\0"
.align 2, 0
gSaveTextYourAdventureHasBeenSaved:: @ 80B6A7C
.string "{CENTER_ALIGN}Your adventure has been saved.\0"
.align 2, 0
gSaveTextYourAdventureHasBeenSavedLong:: @ 80B6AA0
.string "{CENTER_ALIGN}Your adventure has been saved.\n"
.string "{CENTER_ALIGN}When you are in a dungeon{COMMA} quicksave\n"
.string "{CENTER_ALIGN}your progress before ending the game.\0"
.align 2, 0
gSaveTextTheDataCouldNotBeWritten:: @ 80B6B14
.string "{CENTER_ALIGN}The data could not be written.\n"
.string "{CENTER_ALIGN}Please turn off the power and remove\n"
.string "{CENTER_ALIGN}and reinsert the DS Card.\0"
.align 2, 0
gSaveTextFailed:: @ 80B6B78
.string "{CENTER_ALIGN}Save failed.\0"
.align 2, 0
gSaveTextError:: @ 80B6B88
.string "{CENTER_ALIGN}Error reading data.\n"
.string "{CENTER_ALIGN}Please turn off the power and reinsert\n"
.string "{CENTER_ALIGN}the DS Game Card.\0"
.align 2, 0
gSaveTextCantResume:: @ 80B6BDC
.string "{CENTER_ALIGN}Your data was not properly saved{COMMA}\n"
.string "{CENTER_ALIGN}so your game cannot be resumed\n"
.string "{CENTER_ALIGN}from your last spot.{EXTRA_MSG}{CENTER_ALIGN}Your last outing is considered a defeat.\n"
.string "{CENTER_ALIGN}Before shutting down{COMMA} save in your\n"
.string "{CENTER_ALIGN}team base{COMMA} or quicksave in a dungeon.\0"
.align 2, 0
gSaveTextMayNotResume:: @ 80B6CB8
.string "{CENTER_ALIGN}You may not resume your dungeon\n"
.string "{CENTER_ALIGN}adventure using this saved data.\n"
.string "{CENTER_ALIGN}Your last outing is considered a defeat.\0"
.align 2, 0
@ event_flag.c
.string "pksdir0\0"
@ -2082,10 +1938,10 @@ gUnknown_80B88CC: @ 80B88CC
.string "fontpal\0"
.align 2,0
@ ???
@ code_8009804.s
.string "pksdir0\0"
@ code_8009804.s
@ file_system
.string "pksdir0\0"
.global gFastMod3Lookup
@ -2270,306 +2126,4 @@ gUnknown_80B92E4: @ 80B92E4
.4byte 30, 30, 30, 30, 31, 31, 31, 31
.4byte 31, 31, 31, 31, 31, 31, 31, 31
.global gUnknown_80B96E4
gUnknown_80B96E4: @ 80B96E4
@ It's an array..
.4byte 0
.4byte 0
.4byte 45426
.4byte 71998
.4byte 90852
.4byte 105476
.4byte 117424
.4byte 127527
.4byte 136278
.4byte 143997
.4byte 150902
.4byte 157148
.4byte 162850
.4byte 168096
.4byte 172953
.4byte 177474
.4byte 181704
.4byte 185677
.4byte 189423
.4byte 192966
.4byte 196328
.4byte 199525
.4byte 202574
.4byte 205487
.4byte 208276
.4byte 210952
.4byte 213522
.4byte 215995
.4byte 218379
.4byte 220679
.4byte 222900
.4byte 225049
.4byte 227130
.4byte 229147
.4byte 231103
.4byte 233003
.4byte 234849
.4byte 236645
.4byte 238392
.4byte 240095
.4byte 241754
.4byte 243372
.4byte 244951
.4byte 246494
.4byte 248000
.4byte 249473
.4byte 250913
.4byte 252323
.4byte 253703
.4byte 255054
.4byte 256378
.4byte 257676
.4byte 258948
.4byte 260197
.4byte 261422
.4byte 262624
.4byte 263805
.4byte 264965
.4byte 266105
.4byte 267225
.4byte 268326
.4byte 269410
.4byte 270475
.4byte 271524
.4byte 272556
.4byte 273572
.4byte 274573
.4byte 275558
.4byte 276529
.4byte 277486
.4byte 278429
.4byte 279358
.4byte 280275
.4byte 281179
.4byte 282071
.4byte 282950
.4byte 283818
.4byte 284675
.4byte 285521
.4byte 286356
.4byte 287180
.4byte 287994
.4byte 288798
.4byte 289593
.4byte 290378
.4byte 291153
.4byte 291920
.4byte 292677
.4byte 293426
.4byte 294167
.4byte 294899
.4byte 295623
.4byte 296339
.4byte 297048
.4byte 297749
.4byte 298442
.4byte 299129
.4byte 299808
.4byte 300480
.4byte 301145
.4byte 301804
.4byte 302456
.4byte 303102
.4byte 303741
.4byte 304374
.4byte 305001
.4byte 305623
.4byte 306238
.4byte 306848
.4byte 307452
.4byte 308050
.4byte 308643
.4byte 309231
.4byte 309814
.4byte 310391
.4byte 310963
.4byte 311531
.4byte 312093
.4byte 312651
.4byte 313204
.4byte 313753
.4byte 314296
.4byte 314836
.4byte 315371
.4byte 315901
.4byte 316428
.4byte 316950
.4byte 317468
.4byte 317982
.4byte 318492
.4byte 318998
.4byte 319500
.4byte 319999
.4byte 320493
.4byte 320984
.4byte 321472
.4byte 321955
.4byte 322435
.4byte 322912
.4byte 323385
.4byte 323855
.4byte 324321
.4byte 324785
.4byte 325244
.4byte 325701
.4byte 326155
.4byte 326605
.4byte 327052
.4byte 327497
.4byte 327938
.4byte 328376
.4byte 328812
.4byte 329245
.4byte 329674
.4byte 330101
.4byte 330525
.4byte 330947
.4byte 331366
.4byte 331782
.4byte 332195
.4byte 332606
.4byte 333014
.4byte 333420
.4byte 333824
.4byte 334224
.4byte 334623
.4byte 335019
.4byte 335412
.4byte 335804
.4byte 336193
.4byte 336579
.4byte 336964
.4byte 337346
.4byte 337726
.4byte 338103
.4byte 338479
.4byte 338852
.4byte 339224
.4byte 339593
.4byte 339960
.4byte 340325
.4byte 340688
.4byte 341049
.4byte 341408
.4byte 341766
.4byte 342121
.4byte 342474
.4byte 342825
.4byte 343175
.4byte 343523
.4byte 343868
.4byte 344212
.4byte 344555
.4byte 344895
.4byte 345234
.4byte 345571
.4byte 345906
.4byte 346240
.4byte 346571
.4byte 346902
.4byte 347230
.4byte 347557
.4byte 347882
.4byte 348206
.4byte 348528
.4byte 348848
.4byte 349167
.4byte 349485
.4byte 349800
.4byte 350115
.4byte 350428
.4byte 350739
.4byte 351049
.4byte 351357
.4byte 351664
.4byte 351970
.4byte 352274
.4byte 352576
.4byte 352878
.4byte 353178
.4byte 353476
.4byte 353773
.4byte 354069
.4byte 354364
.4byte 354657
.4byte 354949
.4byte 355240
.4byte 355529
.4byte 355817
.4byte 356104
.4byte 356389
.4byte 356674
.4byte 356957
.4byte 357239
.4byte 357519
.4byte 357799
.4byte 358077
.4byte 358354
.4byte 358630
.4byte 358905
.4byte 359179
.4byte 359451
.4byte 359723
.4byte 359993
.4byte 360262
.4byte 360530
.4byte 360797
.4byte 361063
.4byte 361328
.4byte 361591
.4byte 361854
.4byte 362116
.4byte 362376
.4byte 362636
.4byte 362894
.4byte 363152
.4byte 363408
.4byte 363664
.4byte 363918
.4byte 364172
.4byte 364424
.4byte 364676
.4byte 364927
.4byte 365176
.4byte 365425
.4byte 365673
.4byte 365920
.4byte 366165
.4byte 366410
.4byte 366655
.4byte 366898
.4byte 367140
.4byte 367381
.4byte 367622
.4byte 367861
.4byte 368100
.4byte 368338
.4byte 368575
.4byte 368811
.4byte 369047
.4byte 369281
.4byte 369515
.4byte 369748
.4byte 369980
.4byte 370211
.4byte 370441
.4byte 370671
.4byte 370899
.4byte 371127
.4byte 371354
.4byte 371581
.4byte 371806
.4byte 372031
.4byte 372255
.4byte 372479
.4byte 372701
.4byte 372923
.4byte 373144
.4byte 373364
.4byte 373584
@ END file_system

View File

@ -1,6 +1,14 @@
#define TILE_SIZE_2BPP 32
.section .rodata
@ ???
.align 2, 0
.string "pksdir0\0"
.align 2,0
@ main.c
.string "pksdir0\0"
.string "PKD ROM USER DATA 000000\0"
.global gUnknown_80B9BF1

View File

@ -1,6 +1,7 @@
.section .rodata
@ START code_80130A8 #1
@ START code_80130A8 #1 (probably part of menu_input)
.align 2, 0
.global UnkData_80D47C4
UnkData_80D47C4:
@ -8,7 +9,6 @@
.global gUnknown_80D47C8
gUnknown_80D47C8: @ 80D47C8
@ replacing .incbin "baserom.gba", 0x000d47c8, 0x60
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x06, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x02, 0x00
@ -46,11 +46,11 @@ gUnknown_80D4828: @ 80D4828
gUnknown_80D4830: @ 80D4830
.byte 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0xe8, 0x03, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0xa0, 0x86, 0x01, 0x00, 0x40, 0x42, 0x0f, 0x00, 0x80, 0x96, 0x98, 0x00
.byte 0x00, 0xe1, 0xf5, 0x05
.asciz "pksdir0"
@ END code_80130A8 #1
@ START code_80130A8 #2
.asciz "pksdir0"
.global gUnknown_80D485C
gUnknown_80D485C: @ 80D485C
@ -148,11 +148,11 @@ gUnknown_80D4908: @ 80D4908
gUnknown_80D4910: @ 80D4910
.string "$\0"
.align 2,0
.string "pksdir0\0"
@ END code_80130A8 #2
@ START [some global strings]
.string "pksdir0\0"
.global Yes_80D491C
Yes_80D491C:
@ -2773,11 +2773,10 @@ gUnknown_80DAF54:
.string "Controls in Town 1\0"
.align 2, 0
.string "pksdir0\0"
@ END [some global strings]
@ START code_80130A8 #3
.string "pksdir0\0"
.global gUnknown_80DAF70
gUnknown_80DAF70: @ 80DAF70
@ -2806,11 +2805,11 @@ gUnknown_80DAFA0: @ 80DAFA0
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.string "pksdir0\0"
@ END code_80130A8 #3
@ START code_80130A8 #4
.string "pksdir0\0"
.global gUnknown_80DAFC0
gUnknown_80DAFC0: @ 80DAFC0
@ -3141,11 +3140,11 @@ gUnknown_80DB65C: @ 80DB65C
gUnknown_80DB664: @ 80DB664
.string "%s\0"
.align 2,0
.string "pksdir0\0"
@ END code_80130A8 #4
@ START code_8012A18_1
.string "pksdir0\0"
.align 2,0
.byte 0x00, 0x00, 0x00, 0x00
@ -3169,12 +3168,11 @@ gUnknown_80DB6A4: @ 80DB6A4
gUnknown_80DB6BC: @ 80DB6BC
.string "Please enter a name.\0"
.align 2,0
.string "pksdir0\0"
.align 2,0
@ END code_8012A18_1
@ START felicity_bank
.string "pksdir0\0"
.align 2,0
.global gUnknown_80DB6DC
gUnknown_80DB6DC: @ 80DB6DC
@ -3216,7 +3214,5 @@ gFelicitySavings: @ 80DB72C
.global gUnknown_80DB738
gUnknown_80DB738: @ 80DB738
.string "Money\0"
.align 2,0
.string "pksdir0\0"
@ END FELICITY BANK

View File

@ -1,5 +1,9 @@
.section .rodata
@ code_801C620
.align 2,0
.string "pksdir0\0"
.global gUnknown_80DBD98
gUnknown_80DBD98: @ 80DBD98
.byte 0x00, 0x00, 0x00, 0x00

144
data/data_code_2.s Normal file
View File

@ -0,0 +1,144 @@
.section .rodata
.string "pksdir0\0"
.global gUnknown_80B690C
gUnknown_80B690C: @ 80B690C
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x19, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x34, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x85, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x45, 0x01, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00
.byte 0x9e, 0x00, 0x00, 0x00
.byte 0x06, 0x00, 0x00, 0x00
.byte 0x1b, 0x01, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x36, 0x00, 0x00, 0x00
.byte 0x08, 0x00, 0x00, 0x00
.byte 0x04, 0x00, 0x00, 0x00
.byte 0x09, 0x00, 0x00, 0x00
.byte 0x18, 0x01, 0x00, 0x00
.byte 0x0a, 0x00, 0x00, 0x00
.byte 0x9b, 0x00, 0x00, 0x00
.byte 0x0b, 0x00, 0x00, 0x00
.byte 0x68, 0x00, 0x00, 0x00
.byte 0x0c, 0x00, 0x00, 0x00
.byte 0x42, 0x00, 0x00, 0x00
.byte 0x0d, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x0e, 0x00, 0x00, 0x00
.byte 0x98, 0x00, 0x00, 0x00
.byte 0x0f, 0x00, 0x00, 0x00
.byte 0x15, 0x01, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gUnknown_80B6994
gUnknown_80B6994: @ 80B6994
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0x00, 0x00
.byte 0x9e, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x18, 0x01, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00
.byte 0x98, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gPMDBuildVersion
gPMDBuildVersion: @ 80B69BC
.string "PKDi ver 1.0 [Apr 28 2006] 16:37:54\0"
.align 2,0
.global titlen0_text
titlen0_text:
.string "titlen0\0"
.align 2,0
.global titlen1_text
titlen1_text:
.string "titlen1\0"
.align 2,0
.global titlen2_text
titlen2_text:
.string "titlen2\0"
.align 2,0
.global gLoadScreenBackgroundFileNames
gLoadScreenBackgroundFileNames: @ 80B69F8
.4byte titlen0_text
.4byte titlen1_text
.4byte titlen2_text
.global titlen0p_text
titlen0p_text:
.string "titlen0p\0"
.align 2,0
.global titlen1p_text
titlen1p_text:
.string "titlen1p\0"
.align 2,0
.global titlen2p_text
titlen2p_text:
.string "titlen2p\0"
.align 2,0
.global gLoadScreenBackgroundPaletteFileNames
gLoadScreenBackgroundPaletteFileNames: @ 80B6A28
.4byte titlen0p_text
.4byte titlen1p_text
.4byte titlen2p_text
gSaveTextQuicksaving:: @ 80B6A34
.string "{CENTER_ALIGN}Quicksaving your adventure...\n"
.string "{CENTER_ALIGN}Please don{APOSTROPHE}t turn off the power.\0"
.align 2, 0
gSaveTextYourAdventureHasBeenSaved:: @ 80B6A7C
.string "{CENTER_ALIGN}Your adventure has been saved.\0"
.align 2, 0
gSaveTextYourAdventureHasBeenSavedLong:: @ 80B6AA0
.string "{CENTER_ALIGN}Your adventure has been saved.\n"
.string "{CENTER_ALIGN}When you are in a dungeon{COMMA} quicksave\n"
.string "{CENTER_ALIGN}your progress before ending the game.\0"
.align 2, 0
gSaveTextTheDataCouldNotBeWritten:: @ 80B6B14
.string "{CENTER_ALIGN}The data could not be written.\n"
.string "{CENTER_ALIGN}Please turn off the power and remove\n"
.string "{CENTER_ALIGN}and reinsert the DS Card.\0"
.align 2, 0
gSaveTextFailed:: @ 80B6B78
.string "{CENTER_ALIGN}Save failed.\0"
.align 2, 0
gSaveTextError:: @ 80B6B88
.string "{CENTER_ALIGN}Error reading data.\n"
.string "{CENTER_ALIGN}Please turn off the power and reinsert\n"
.string "{CENTER_ALIGN}the DS Game Card.\0"
.align 2, 0
gSaveTextCantResume:: @ 80B6BDC
.string "{CENTER_ALIGN}Your data was not properly saved{COMMA}\n"
.string "{CENTER_ALIGN}so your game cannot be resumed\n"
.string "{CENTER_ALIGN}from your last spot.{EXTRA_MSG}{CENTER_ALIGN}Your last outing is considered a defeat.\n"
.string "{CENTER_ALIGN}Before shutting down{COMMA} save in your\n"
.string "{CENTER_ALIGN}team base{COMMA} or quicksave in a dungeon.\0"
.align 2, 0
gSaveTextMayNotResume:: @ 80B6CB8
.string "{CENTER_ALIGN}You may not resume your dungeon\n"
.string "{CENTER_ALIGN}adventure using this saved data.\n"
.string "{CENTER_ALIGN}Your last outing is considered a defeat.\0"

14
include/decompress.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef GUARD_DECOMPRESS_H
#define GUARD_DECOMPRESS_H
#include "file_system.h"
u32 DecompressAT(u8 *, s32, const u8 *);
u32 DecompressATFile(u8 *, s32, OpenedFile *);
u32 DecompressATGlobalFile(u32 *, s32, OpenedFile *);
u8 *GetSiroPtr(OpenedFile *);
void nullsub_16(void);
bool8 sub_800B2D4(char *, char *, s32);
#endif // GUARD_DECOMPRESS_H

View File

@ -31,19 +31,19 @@ typedef struct SiroArchive
} SiroArchive;
// size: 0x8
typedef struct UnkFileStruct1
typedef struct UnkFileStruct
{
/* 0x0 */ u32 unk0;
/* 0x4 */ u32 unk4;
} UnkFileStruct1;
} UnkFileStruct;
OpenedFile *Call_OpenFileAndGetFileDataPtr(const u8 *, const FileArchive *);
void CloseFile(OpenedFile *);
u8 *GetFileDataPtr(OpenedFile *, s32);
void InitFileSystem(void);
OpenedFile *OpenFile(const u8 *, const FileArchive *);
u8 *GetFileDataPtr(OpenedFile *, s32);
OpenedFile *OpenFileAndGetFileDataPtr(const u8 *, const FileArchive *);
OpenedFile *Call_OpenFileAndGetFileDataPtr(const u8 *, const FileArchive *);
u32 DecompressATFile(u8 *, s32, OpenedFile *);
void CloseFile(OpenedFile *);
u32 DecompressATGlobalFile(u32 *, s32, OpenedFile *);
u32 sub_800A8F8(u32);
#endif //GUARD_FILE_SYSTEM_H

View File

@ -68,7 +68,9 @@ SECTIONS {
asm/text.o(.text);
src/code_8009804.o(.text);
asm/code_8009804.o(.text);
asm/file_system.o(.text);
src/file_system.o(.text);
src/decompress.o(.text);
src/main.o(.text);
src/unused_vblank.o(.text);
src/reg_control.o(.text);
@ -381,8 +383,10 @@ SECTIONS {
.rodata :
ALIGN(4)
{
data/data_code_2.o(.rodata);
data/data.o(.rodata);
src/file_system.o(.rodata);
src/decompress.o(.rodata);
data/data_80B9BB8.o(.rodata);
src/debug.o(.rodata);
src/save.o(.rodata);

View File

@ -38,7 +38,6 @@ extern void sub_800DAAC(void);
extern void sub_800135C(void);
extern void xxx_script_related_8001334(u32);
extern void sub_80015C0(u32, u32);
extern void sub_800A8F8(u32);
extern void LoadTitleScreen(void);
extern void sub_80095CC(u32, u32);
extern s32 GetFirstIndexofMailType(u8);

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sFmtWhoWillLearnTheMove[] = _(
"{CENTER_ALIGN}Who will learn the move\n"
"{CENTER_ALIGN}{COLOR_1 CYAN}{ARG_POKEMON_7}{END_COLOR_TEXT_1}?");
@ -6,5 +8,4 @@ ALIGNED(4) static const u8 sFmtLearnedTheMove[] = _(
"{CENTER_ALIGN}the move {COLOR_1 CYAN}{ARG_POKEMON_7}{END_COLOR_TEXT_1}!");
ALIGNED(4) static const u8 sFmtNoOneCanLearnThisMove[] = _(
"{CENTER_ALIGN}No one in the current team\n"
"{CENTER_ALIGN}can learn this move. ");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
"{CENTER_ALIGN}can learn this move. ");

View File

@ -1,2 +1,3 @@
ALIGNED(4) static const u8 sFmtPkmn0[] = _("{ARG_POKEMON_0}");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sFmtPkmn0[] = _("{ARG_POKEMON_0}");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DBA58 = {
0, 0, 0, 0,
3,
@ -60,5 +62,4 @@ ALIGNED(4) static const u8 sFmtDiscardedForReceive[] = _(
ALIGNED(4) static const u8 sTrashToolboxItem[] = _("Trash Toolbox Item");
ALIGNED(4) static const u8 sTrashReceivedItem[] = _("Trash Received Item");
ALIGNED(4) static const u8 sStorage[] = _("Storage");
ALIGNED(4) static const u8 sTrash[] = _("Trash");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sTrash[] = _("Trash");

4
src/data/decompress.h Normal file
View File

@ -0,0 +1,4 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const u32 gByteShiftLookup[4] = {0, 8, 16, 24};

87
src/data/file_system.h Normal file
View File

@ -0,0 +1,87 @@
// ALIGNED(4) static const u8 sFill[] = _("pksdir0");
// gFastMod3Lookup
// gFastDiv3Lookup
// gUnknown_80B8AE4
// gUnknown_80B92E4
static const u32 gUnknown_80B96E4[300] = {
0, 0, 45426, 71998,
90852, 105476, 117424, 127527,
136278, 143997, 150902, 157148,
162850, 168096, 172953, 177474,
181704, 185677, 189423, 192966,
196328, 199525, 202574, 205487,
208276, 210952, 213522, 215995,
218379, 220679, 222900, 225049,
227130, 229147, 231103, 233003,
234849, 236645, 238392, 240095,
241754, 243372, 244951, 246494,
248000, 249473, 250913, 252323,
253703, 255054, 256378, 257676,
258948, 260197, 261422, 262624,
263805, 264965, 266105, 267225,
268326, 269410, 270475, 271524,
272556, 273572, 274573, 275558,
276529, 277486, 278429, 279358,
280275, 281179, 282071, 282950,
283818, 284675, 285521, 286356,
287180, 287994, 288798, 289593,
290378, 291153, 291920, 292677,
293426, 294167, 294899, 295623,
296339, 297048, 297749, 298442,
299129, 299808, 300480, 301145,
301804, 302456, 303102, 303741,
304374, 305001, 305623, 306238,
306848, 307452, 308050, 308643,
309231, 309814, 310391, 310963,
311531, 312093, 312651, 313204,
313753, 314296, 314836, 315371,
315901, 316428, 316950, 317468,
317982, 318492, 318998, 319500,
319999, 320493, 320984, 321472,
321955, 322435, 322912, 323385,
323855, 324321, 324785, 325244,
325701, 326155, 326605, 327052,
327497, 327938, 328376, 328812,
329245, 329674, 330101, 330525,
330947, 331366, 331782, 332195,
332606, 333014, 333420, 333824,
334224, 334623, 335019, 335412,
335804, 336193, 336579, 336964,
337346, 337726, 338103, 338479,
338852, 339224, 339593, 339960,
340325, 340688, 341049, 341408,
341766, 342121, 342474, 342825,
343175, 343523, 343868, 344212,
344555, 344895, 345234, 345571,
345906, 346240, 346571, 346902,
347230, 347557, 347882, 348206,
348528, 348848, 349167, 349485,
349800, 350115, 350428, 350739,
351049, 351357, 351664, 351970,
352274, 352576, 352878, 353178,
353476, 353773, 354069, 354364,
354657, 354949, 355240, 355529,
355817, 356104, 356389, 356674,
356957, 357239, 357519, 357799,
358077, 358354, 358630, 358905,
359179, 359451, 359723, 359993,
360262, 360530, 360797, 361063,
361328, 361591, 361854, 362116,
362376, 362636, 362894, 363152,
363408, 363664, 363918, 364172,
364424, 364676, 364927, 365176,
365425, 365673, 365920, 366165,
366410, 366655, 366898, 367140,
367381, 367622, 367861, 368100,
368338, 368575, 368811, 369047,
369281, 369515, 369748, 369980,
370211, 370441, 370671, 370899,
371127, 371354, 371581, 371806,
372031, 372255, 372479, 372701,
372923, 373144, 373364, 373584
};
ALIGNED(4) static const u8 gUnknown_80B9B94[] = _("pksdir0");
ALIGNED(4) static const u8 gUnknown_80B9B9C[] = _("not find file [%s]\n");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DB748 = {
0, 0, 0, 0,
3,
@ -34,5 +36,4 @@ static const UnkTextStruct2 sUnknown_80DB790 = {
NULL
};
ALIGNED(4) static const u8 sNumber[] = _("Number?");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sNumber[] = _("Number?");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DB7B8 = {
0, 0, 0, 0,
3,
@ -43,5 +45,4 @@ static const UnkTextStruct2 sUnknown_80DB818 = {
NULL
};
ALIGNED(4) static const u8 sNumber[] = _("Number?");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sNumber[] = _("Number?");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DB840 = {
0, 0, 0, 0,
3,
@ -34,5 +36,4 @@ static const UnkTextStruct2 sUnknown_80DB888 = {
NULL
};
ALIGNED(4) static const u8 sSellAll[] = _("Sell All");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sSellAll[] = _("Sell All");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DB8B4 = {
0, 0, 0, 0,
3,
@ -17,5 +19,4 @@ static const UnkTextStruct2 sUnknown_80DB8CC = {
};
ALIGNED(4) static const u8 sGoods[] = _("Goods");
ALIGNED(4) static const u8 sFmtRed[] = _("{COLOR_1 RED}%s{END_COLOR_TEXT_1}");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sFmtRed[] = _("{COLOR_1 RED}%s{END_COLOR_TEXT_1}");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DB8FC = {
0, 0, 0, 0,
3,
@ -17,5 +19,4 @@ static const UnkTextStruct2 sUnknown_80DB914 = {
};
ALIGNED(4) static const u8 sGoods[] = _("Goods");
ALIGNED(4) static const u8 sFmtRed[] = _("{COLOR_1 RED}%s{END_COLOR_TEXT_1}");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sFmtRed[] = _("{COLOR_1 RED}%s{END_COLOR_TEXT_1}");

View File

@ -1,3 +1,5 @@
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const UnkTextStruct2 sUnknown_80DB944 = {
0, 0, 0, 0,
3,
@ -21,5 +23,4 @@ ALIGNED(4) static const u8 sTeamToolboxB[] = _("Team Toolbox B");
ALIGNED(4) static const u8 sFmtMoveItem0[] = _("{COLOR_1 UNK_COLOR_2}{ARG_MOVE_ITEM_0}{END_COLOR_TEXT_1}");
ALIGNED(4) static const u8 sFmtRed[] = _("{COLOR_1 RED}%s{END_COLOR_TEXT_1}");
ALIGNED(4) static const u8 sItems[] = _("Items");
ALIGNED(4) static const u8 sSlash[] = _("/");
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sSlash[] = _("/");

View File

@ -50,7 +50,6 @@ ALIGNED(4) static const char debug_fill4[] = "pksdir0";
ALIGNED(4) static const char debug_fill5[] = "pksdir0";
ALIGNED(4) static const char debug_fill6[] = "pksdir0";
ALIGNED(4) static const char debug_fill7[] = "pksdir0";
ALIGNED(4) static const char debug_fill8[] = "pksdir0";
void NDS_DebugInit(void)
{

942
src/decompress.c Normal file
View File

@ -0,0 +1,942 @@
#include "global.h"
#include "decompress.h"
#define MAGIC_SIR0 0x30524953
#define MAGIC_SIRO 0x4F524953
EWRAM_DATA u32 *gDecompressBufferPtr = {0};
EWRAM_DATA u32 *gDecompressBufferStart = {0};
EWRAM_DATA u32 gDecompressBufferCurrent = {0};
EWRAM_DATA u32 gDecompressBufferByteInInt = {0};
#include "data/decompress.h"
#ifndef NONMATCHING
UNUSED // Remove "UNUSED" when DecompressATGlobal is done
static void DecompressAT_AppendByte(char);
UNUSED
static void DecompressAT_Finish(void);
UNUSED
static char DecompressAT_GetByte(s32);
UNUSED
static void DecompressAT_Init(u32 *);
#else
static void DecompressAT_AppendByte(char);
static void DecompressAT_Finish(void);
static char DecompressAT_GetByte(s32);
static void DecompressAT_Init(u32 *);
#endif
static u32 DecompressATGlobal(u32 *, s32, const char *);
static void NDS_DecompressRLE(void *);
u8 *GetSiroPtr(OpenedFile *openedFile)
{
struct SiroArchive *siro = (struct SiroArchive *)openedFile->data;
if (siro->magic == MAGIC_SIR0)
NDS_DecompressRLE(openedFile->data);
else if (siro->magic != MAGIC_SIRO)
return openedFile->data;
openedFile->data = siro->data;
return openedFile->data;
}
UNUSED static void *UnusedGetSir0Ptr(struct SiroArchive *siro)
{
if (siro->magic != MAGIC_SIR0)
return siro;
NDS_DecompressRLE(siro);
return siro->data;
}
static void NDS_DecompressRLE(void *unused)
{
}
void nullsub_16(void)
{
}
UNUSED static void nullsub_175(void)
{
}
u32 DecompressATFile(u8 *result, s32 resultLength, OpenedFile *file)
{
return DecompressAT(result, resultLength, file->data);
}
u32 DecompressAT(u8 *result, s32 resultLength, const u8 *compressedData)
{
s32 compressedLength = compressedData[5] + (compressedData[6] << 8);
s32 bytesWritten = 0;
s32 currentByte = 0;
s32 cmdBit = 8;
s32 curIndex;
s32 flags[9];
s32 idxStart;
if (compressedData[0] == 'A'
&& compressedData[1] == 'T'
&& compressedData[2] == '4'
&& compressedData[3] == 'P') {
u32 tmp2 = compressedData[0x10] + (compressedData[0x11] << 8);
if (resultLength != 0 && resultLength != tmp2)
return 0;
idxStart = 0x12;
}
else if (compressedData[0] == 'A'
&& compressedData[1] == 'T'
&& compressedData[2] == '3'
&& compressedData[3] == 'P') {
idxStart = 0x10;
}
else
return 0;
if (compressedData[4] == 'N') {
// uncompressed mode, unused
for (curIndex = 0; curIndex < compressedLength; curIndex++) {
result[curIndex] = compressedData[curIndex + 7];
}
return curIndex;
}
flags[0] = compressedData[0x7] + 3;
flags[1] = compressedData[0x8] + 3;
flags[2] = compressedData[0x9] + 3;
flags[3] = compressedData[0xa] + 3;
flags[4] = compressedData[0xb] + 3;
flags[5] = compressedData[0xc] + 3;
flags[6] = compressedData[0xd] + 3;
flags[7] = compressedData[0xe] + 3;
flags[8] = compressedData[0xf] + 3;
curIndex = idxStart;
if (curIndex < compressedLength) {
do {
if (resultLength != 0 && bytesWritten >= resultLength)
return 0;
if (cmdBit == 8) {
currentByte = compressedData[curIndex++];
cmdBit = 0;
}
if ((currentByte & 0x80) == 0) {
// if bit is unset, process command
u32 command = (compressedData[curIndex] >> 4) + 3;
u32 tmp = (compressedData[curIndex] & 0xf) << 8;
u32 c;
if (command == flags[0]) command = 0x1f;
if (command == flags[1]) command = 0x1e;
if (command == flags[2]) command = 0x1d;
if (command == flags[3]) command = 0x1c;
if (command == flags[4]) command = 0x1b;
if (command == flags[5]) command = 0x1a;
if (command == flags[6]) command = 0x19;
if (command == flags[7]) command = 0x18;
if (command == flags[8]) command = 0x17;
switch (command) {
case 0x1f: { // aaaa
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x1e: { // abbb
u8 byte = compressedData[curIndex];
c = 0xF;
c = byte & c;
curIndex++;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
result[bytesWritten++] = ((((c + 1) & 0xf) << 4) | ((c + 1) & 0xf));
break;
}
case 0x1d: { // babb
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x1c: { // bbab
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c - 1) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x1b: { // bbba
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
break;
}
case 0x1a: { // baaa -- the horrible, hard-to-match case
u8 byte = compressedData[curIndex];
c = 0xF;
c = byte & c;
curIndex++;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf));
result[bytesWritten++] = ((((c - 1) & 0xf) << 4) | ((c - 1) & 0xf));
break;
}
case 0x19: { // abaa
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x18: { // aaba
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 1) & 0xf) << 4) | ((c + 0) & 0xf));
break;
}
case 0x17: { // aaab
c = compressedData[curIndex++] & 0xf;
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf));
result[bytesWritten++] = ((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf));
break;
}
default: {
tmp += (compressedData[curIndex++, curIndex++]);
tmp += bytesWritten - 0x1000;
for(;command;command--)
{
result[bytesWritten++] = result[tmp];
tmp++;
}
}
}
} else {
// if bit is set, just copy next byte
result[bytesWritten++] = (compressedData[curIndex]);
curIndex++;
}
cmdBit++;
currentByte <<= 1;
} while (curIndex < compressedLength);
}
return bytesWritten;
}
u32 DecompressATGlobalFile(u32 *result, s32 resultLength, OpenedFile *file)
{
return DecompressATGlobal(result, resultLength, file->data);
}
#ifndef NONMATCHING
NAKED
#endif
static u32 DecompressATGlobal(u32 *result, s32 resultLength, const char *compressedData)
{
#ifdef NONMATCHING
s32 compressedLength;
s32 curIndex;
s32 bytesWritten;
s32 cmdBit;
s32 currentByte;
s32 flags1;
s32 flags2;
s32 flags3;
s32 flags4;
s32 flags5;
s32 flags6;
s32 flags7;
s32 flags8;
s32 flags9;
u32 command;
u32 tmp;
u32 tmp2;
u32 c;
compressedLength = compressedData[5] + (compressedData[6] << 8);
bytesWritten = 0;
currentByte = 0;
cmdBit = 8;
DecompressAT_Init(result);
if (compressedData[0] == 'A'
&& compressedData[1] == 'T'
&& compressedData[2] == '4'
&& compressedData[3] == 'P') {
tmp2 = compressedData[0x10] + (compressedData[0x11] << 8);
if (resultLength != 0 && resultLength != tmp2)
return bytesWritten;
curIndex = 0x12;
} else if (compressedData[0] == 'A'
&& compressedData[1] == 'T'
&& compressedData[2] == '3'
&& compressedData[3] == 'P') {
curIndex = 0x10;
} else {
return 0;
}
if (compressedData[4] == 'N') {
// uncompressed mode, unused
for (bytesWritten = 0; bytesWritten < compressedLength; bytesWritten++) {
DecompressAT_AppendByte(compressedData[bytesWritten + 7]);
}
DecompressAT_Finish();
return bytesWritten;
}
flags1 = compressedData[0x7] + 3;
flags2 = compressedData[0x8] + 3;
flags3 = compressedData[0x9] + 3;
flags4 = compressedData[0xa] + 3;
flags5 = compressedData[0xb] + 3;
flags6 = compressedData[0xc] + 3;
flags7 = compressedData[0xd] + 3;
flags8 = compressedData[0xe] + 3;
flags9 = compressedData[0xf] + 3;
if (curIndex < compressedLength) {
do {
if (resultLength != 0 && bytesWritten >= resultLength)
return 0;
if (cmdBit == 8) {
currentByte = compressedData[curIndex++];
cmdBit = 0;
}
if ((currentByte & 0x80) == 0) {
// if bit is unset, process command
command = (compressedData[curIndex] >> 4) + 3;
tmp2 = (compressedData[curIndex] & 0xf) << 8;
if (command == flags1) command = 0x1f;
if (command == flags2) command = 0x1e;
if (command == flags3) command = 0x1d;
if (command == flags4) command = 0x1c;
if (command == flags5) command = 0x1b;
if (command == flags6) command = 0x1a;
if (command == flags7) command = 0x19;
if (command == flags8) command = 0x18;
if (command == flags9) command = 0x17;
switch (command) {
case 0x1f: { // aaaa
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
break;
}
case 0x1e: { // abbb
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 1) & 0xf) << 4) | ((c + 1) & 0xf)); bytesWritten++;
break;
}
case 0x1d: { // babb
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
break;
}
case 0x1c: { // bbab
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c - 1) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
break;
}
case 0x1b: { // bbba
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf)); bytesWritten++;
break;
}
case 0x1a: { // baaa -- the horrible, unmatching case
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c - 1) & 0xf)); bytesWritten++;
c -= 1;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
break;
}
case 0x19: { // abaa
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
break;
}
case 0x18: { // aaba
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 1) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
break;
}
case 0x17: { // aaab
c = compressedData[curIndex++] & 0xf;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 0) & 0xf)); bytesWritten++;
DecompressAT_AppendByte((((c + 0) & 0xf) << 4) | ((c + 1) & 0xf)); bytesWritten++;
break;
}
default: {
tmp = compressedData[curIndex++, curIndex++] + tmp2 - 0x1000 + bytesWritten;
for (; command != 0; tmp++, command--) {
DecompressAT_AppendByte(DecompressAT_GetByte(tmp)); bytesWritten++;
}
}
}
} else {
// if bit is set, just copy next byte
DecompressAT_AppendByte(compressedData[curIndex]); bytesWritten++;
curIndex++;
}
cmdBit++;
currentByte <<= 1;
} while (curIndex < compressedLength);
DecompressAT_Finish();
}
return bytesWritten;
#else
asm_unified(
"DecompressATGlobal:\n"
" push {r4-r7,lr}\n"
" mov r7, r10\n"
" mov r6, r9\n"
" mov r5, r8\n"
" push {r5-r7}\n"
" sub sp, 0x34\n"
" str r1, [sp, 0x24]\n"
" mov r10, r2\n"
" ldrb r2, [r2, 0x5]\n"
" mov r3, r10\n"
" ldrb r1, [r3, 0x6]\n"
" lsls r1, 8\n"
" adds r2, r1\n"
" str r2, [sp, 0x28]\n"
" movs r1, 0\n"
" mov r9, r1\n"
" movs r2, 0\n"
" str r2, [sp, 0x2C]\n"
" movs r3, 0x8\n"
" str r3, [sp, 0x30]\n"
" bl DecompressAT_Init\n"
" mov r1, r10\n"
" ldrb r0, [r1]\n"
" cmp r0, 0x41\n"
" bne _0800AE90\n"
" ldrb r0, [r1, 0x1]\n"
" adds r1, r0, 0\n"
" cmp r1, 0x54\n"
" bne _0800AE98\n"
" mov r2, r10\n"
" ldrb r0, [r2, 0x2]\n"
" cmp r0, 0x34\n"
" bne _0800AE98\n"
" ldrb r0, [r2, 0x3]\n"
" cmp r0, 0x50\n"
" bne _0800AE98\n"
" ldrb r1, [r2, 0x10]\n"
" ldrb r0, [r2, 0x11]\n"
" lsls r0, 8\n"
" adds r1, r0\n"
" ldr r3, [sp, 0x24]\n"
" cmp r3, 0\n"
" beq _0800AE94\n"
" cmp r3, r1\n"
" beq _0800AE94\n"
"_0800AE90:\n"
" movs r0, 0\n"
" b _0800B1AA\n"
"_0800AE94:\n"
" movs r1, 0x12\n"
" b _0800AEB2\n"
"_0800AE98:\n"
" mov r2, r10\n"
" ldrb r0, [r2]\n"
" cmp r0, 0x41\n"
" bne _0800AE90\n"
" cmp r1, 0x54\n"
" bne _0800AE90\n"
" ldrb r0, [r2, 0x2]\n"
" cmp r0, 0x33\n"
" bne _0800AE90\n"
" ldrb r0, [r2, 0x3]\n"
" cmp r0, 0x50\n"
" bne _0800AE90\n"
" movs r1, 0x10\n"
"_0800AEB2:\n"
" mov r3, r10\n"
" ldrb r0, [r3, 0x4]\n"
" cmp r0, 0x4E\n"
" bne _0800AEE0\n"
" movs r0, 0\n"
" mov r8, r0\n"
" ldr r1, [sp, 0x28]\n"
" cmp r8, r1\n"
" bge _0800AED8\n"
"_0800AEC4:\n"
" mov r0, r8\n"
" add r0, r10\n"
" ldrb r0, [r0, 0x7]\n"
" bl DecompressAT_AppendByte\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" ldr r3, [sp, 0x28]\n"
" cmp r8, r3\n"
" blt _0800AEC4\n"
"_0800AED8:\n"
" bl DecompressAT_Finish\n"
" mov r0, r8\n"
" b _0800B1AA\n"
"_0800AEE0:\n"
" mov r2, r10\n"
" ldrb r0, [r2, 0x7]\n"
" adds r0, 0x3\n"
" str r0, [sp]\n"
" ldrb r0, [r2, 0x8]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x4]\n"
" ldrb r0, [r2, 0x9]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x8]\n"
" ldrb r0, [r2, 0xA]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0xC]\n"
" ldrb r0, [r2, 0xB]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x10]\n"
" ldrb r0, [r2, 0xC]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x14]\n"
" ldrb r0, [r2, 0xD]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x18]\n"
" ldrb r0, [r2, 0xE]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x1C]\n"
" ldrb r0, [r2, 0xF]\n"
" adds r0, 0x3\n"
" str r0, [sp, 0x20]\n"
" mov r8, r1\n"
" ldr r3, [sp, 0x28]\n"
" cmp r8, r3\n"
" blt _0800AF22\n"
" b _0800B1A4\n"
"_0800AF22:\n"
" ldr r0, [sp, 0x24]\n"
" cmp r0, 0\n"
" beq _0800AF2C\n"
" cmp r9, r0\n"
" bge _0800AE90\n"
"_0800AF2C:\n"
" ldr r1, [sp, 0x30]\n"
" cmp r1, 0x8\n"
" bne _0800AF42\n"
" mov r0, r10\n"
" add r0, r8\n"
" ldrb r0, [r0]\n"
" str r0, [sp, 0x2C]\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" movs r3, 0\n"
" str r3, [sp, 0x30]\n"
"_0800AF42:\n"
" movs r0, 0x80\n"
" ldr r1, [sp, 0x2C]\n"
" ands r0, r1\n"
" cmp r0, 0\n"
" beq _0800AF4E\n"
" b _0800B180\n"
"_0800AF4E:\n"
" mov r2, r10\n"
" add r2, r8\n"
" ldrb r1, [r2]\n"
" lsrs r0, r1, 4\n"
" adds r3, r0, 0x3\n"
" movs r0, 0xF\n"
" ands r0, r1\n"
" lsls r7, r0, 8\n"
" ldr r0, [sp]\n"
" cmp r3, r0\n"
" bne _0800AF66\n"
" movs r3, 0x1F\n"
"_0800AF66:\n"
" ldr r0, [sp, 0x4]\n"
" cmp r3, r0\n"
" bne _0800AF6E\n"
" movs r3, 0x1E\n"
"_0800AF6E:\n"
" ldr r0, [sp, 0x8]\n"
" cmp r3, r0\n"
" bne _0800AF76\n"
" movs r3, 0x1D\n"
"_0800AF76:\n"
" ldr r0, [sp, 0xC]\n"
" cmp r3, r0\n"
" bne _0800AF7E\n"
" movs r3, 0x1C\n"
"_0800AF7E:\n"
" ldr r0, [sp, 0x10]\n"
" cmp r3, r0\n"
" bne _0800AF86\n"
" movs r3, 0x1B\n"
"_0800AF86:\n"
" ldr r0, [sp, 0x14]\n"
" cmp r3, r0\n"
" bne _0800AF8E\n"
" movs r3, 0x1A\n"
"_0800AF8E:\n"
" ldr r0, [sp, 0x18]\n"
" cmp r3, r0\n"
" bne _0800AF96\n"
" movs r3, 0x19\n"
"_0800AF96:\n"
" ldr r0, [sp, 0x1C]\n"
" cmp r3, r0\n"
" bne _0800AF9E\n"
" movs r3, 0x18\n"
"_0800AF9E:\n"
" ldr r0, [sp, 0x20]\n"
" cmp r3, r0\n"
" bne _0800AFA6\n"
" movs r3, 0x17\n"
"_0800AFA6:\n"
" adds r0, r3, 0\n"
" subs r0, 0x17\n"
" cmp r0, 0x8\n"
" bls _0800AFB0\n"
" b _0800B13C\n"
"_0800AFB0:\n"
" lsls r0, 2\n"
" ldr r1, _0800AFBC\n"
" adds r0, r1\n"
" ldr r0, [r0]\n"
" mov pc, r0\n"
" .align 2, 0\n"
"_0800AFBC: .4byte _0800AFC0\n"
" .align 2, 0\n"
"_0800AFC0:\n"
" .4byte _0800B104\n"
" .4byte _0800B0DE\n"
" .4byte _0800B0BA\n"
" .4byte _0800B090\n"
" .4byte _0800B06E\n"
" .4byte _0800B048\n"
" .4byte _0800B024\n"
" .4byte _0800AFFE\n"
" .4byte _0800AFE4\n"
"_0800AFE4:\n"
" ldrb r0, [r2]\n"
" movs r1, 0xF\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" ands r1, r0\n"
" lsls r4, r1, 4\n"
" orrs r4, r1\n"
" adds r0, r4, 0\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" b _0800B128\n"
"_0800AFFE:\n"
" ldrb r0, [r2]\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" movs r1, 0xF\n"
" lsls r0, r6, 4\n"
" adds r4, r6, 0x1\n"
" ands r4, r1\n"
" orrs r0, r4\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" lsls r0, r4, 4\n"
" orrs r0, r4\n"
" lsls r0, 24\n"
" lsrs r0, 24\n"
" b _0800B12A\n"
"_0800B024:\n"
" ldrb r0, [r2]\n"
" movs r1, 0xF\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" adds r5, r6, 0\n"
" ands r5, r1\n"
" lsls r4, r5, 4\n"
" subs r0, r6, 0x1\n"
" ands r0, r1\n"
" orrs r0, r4\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" orrs r4, r5\n"
" b _0800B128\n"
"_0800B048:\n"
" ldrb r0, [r2]\n"
" movs r5, 0xF\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" adds r4, r6, 0\n"
" ands r4, r5\n"
" lsls r0, r4, 4\n"
" orrs r0, r4\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" subs r0, r6, 0x1\n"
" ands r0, r5\n"
" lsls r0, 4\n"
" orrs r0, r4\n"
" b _0800B12A\n"
"_0800B06E:\n"
" ldrb r0, [r2]\n"
" movs r5, 0xF\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" adds r1, r6, 0\n"
" ands r1, r5\n"
" lsls r4, r1, 4\n"
" adds r0, r4, 0\n"
" orrs r0, r1\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" subs r0, r6, 0x1\n"
" b _0800B124\n"
"_0800B090:\n"
" ldrb r0, [r2]\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" movs r1, 0xF\n"
" lsls r0, r6, 4\n"
" subs r4, r6, 0x1\n"
" ands r4, r1\n"
" orrs r0, r4\n"
" lsls r0, 24\n"
" lsrs r0, 24\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" lsls r0, r4, 4\n"
" orrs r0, r4\n"
" lsls r0, 24\n"
" lsrs r0, 24\n"
" b _0800B12A\n"
"_0800B0BA:\n"
" ldrb r0, [r2]\n"
" movs r1, 0xF\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" adds r5, r6, 0\n"
" ands r5, r1\n"
" lsls r4, r5, 4\n"
" adds r0, r6, 0x1\n"
" ands r0, r1\n"
" orrs r0, r4\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" orrs r4, r5\n"
" b _0800B128\n"
"_0800B0DE:\n"
" ldrb r0, [r2]\n"
" movs r5, 0xF\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" adds r4, r6, 0\n"
" ands r4, r5\n"
" lsls r0, r4, 4\n"
" orrs r0, r4\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" adds r0, r6, 0x1\n"
" ands r0, r5\n"
" lsls r0, 4\n"
" orrs r0, r4\n"
" b _0800B12A\n"
"_0800B104:\n"
" ldrb r0, [r2]\n"
" movs r5, 0xF\n"
" movs r6, 0xF\n"
" ands r6, r0\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" adds r1, r6, 0\n"
" ands r1, r5\n"
" lsls r4, r1, 4\n"
" adds r0, r4, 0\n"
" orrs r0, r1\n"
" bl DecompressAT_AppendByte\n"
" movs r3, 0x1\n"
" add r9, r3\n"
" adds r0, r6, 0x1\n"
"_0800B124:\n"
" ands r0, r5\n"
" orrs r4, r0\n"
"_0800B128:\n"
" adds r0, r4, 0\n"
"_0800B12A:\n"
" bl DecompressAT_AppendByte\n"
" movs r0, 0x1\n"
" add r9, r0\n"
" ldr r5, [sp, 0x30]\n"
" adds r5, 0x1\n"
" ldr r1, [sp, 0x2C]\n"
" lsls r4, r1, 1\n"
" b _0800B198\n"
"_0800B13C:\n"
" movs r2, 0x1\n"
" add r8, r2\n"
" mov r0, r10\n"
" add r0, r8\n"
" ldrb r0, [r0]\n"
" adds r7, r0\n"
" add r8, r2\n"
" ldr r1, _0800B17C\n"
" adds r0, r7, r1\n"
" mov r2, r9\n"
" adds r7, r0, r2\n"
" ldr r5, [sp, 0x30]\n"
" adds r5, 0x1\n"
" ldr r0, [sp, 0x2C]\n"
" lsls r4, r0, 1\n"
" cmp r3, 0\n"
" beq _0800B198\n"
" adds r6, r3, 0\n"
"_0800B160:\n"
" adds r0, r7, 0\n"
" bl DecompressAT_GetByte\n"
" lsls r0, 24\n"
" lsrs r0, 24\n"
" bl DecompressAT_AppendByte\n"
" movs r1, 0x1\n"
" add r9, r1\n"
" adds r7, 0x1\n"
" subs r6, 0x1\n"
" cmp r6, 0\n"
" bne _0800B160\n"
" b _0800B198\n"
" .align 2, 0\n"
"_0800B17C: .4byte 0xfffff000\n"
"_0800B180:\n"
" mov r0, r10\n"
" add r0, r8\n"
" ldrb r0, [r0]\n"
" bl DecompressAT_AppendByte\n"
" movs r2, 0x1\n"
" add r9, r2\n"
" add r8, r2\n"
" ldr r5, [sp, 0x30]\n"
" adds r5, 0x1\n"
" ldr r3, [sp, 0x2C]\n"
" lsls r4, r3, 1\n"
"_0800B198:\n"
" str r5, [sp, 0x30]\n"
" str r4, [sp, 0x2C]\n"
" ldr r0, [sp, 0x28]\n"
" cmp r8, r0\n"
" bge _0800B1A4\n"
" b _0800AF22\n"
"_0800B1A4:\n"
" bl DecompressAT_Finish\n"
" mov r0, r9\n"
"_0800B1AA:\n"
" add sp, 0x34\n"
" pop {r3-r5}\n"
" mov r8, r3\n"
" mov r9, r4\n"
" mov r10, r5\n"
" pop {r4-r7}\n"
" pop {r1}\n"
" bx r1");
#endif
}
static void DecompressAT_Init(u32 *buffer)
{
gDecompressBufferPtr = buffer;
gDecompressBufferStart = buffer;
gDecompressBufferCurrent = 0;
gDecompressBufferByteInInt = 0;
}
static char DecompressAT_GetByte(s32 index)
{
u32 data;
s32 offset;
offset = index < 0 ? index + 3 : index;
data = gDecompressBufferStart[offset >> 2];
switch (index & 3) {
case 0: return data;
case 1: return data >> 8;
case 2: return data >> 16;
case 3: return data >> 24;
}
return data;
}
static void DecompressAT_AppendByte(char value)
{
gDecompressBufferCurrent |= value << gByteShiftLookup[gDecompressBufferByteInInt];
*gDecompressBufferPtr = gDecompressBufferCurrent;
gDecompressBufferByteInInt++;
if (gDecompressBufferByteInInt == 4) {
gDecompressBufferPtr++;
gDecompressBufferCurrent = 0;
gDecompressBufferByteInInt = 0;
}
}
static void DecompressAT_Finish(void)
{
if (gDecompressBufferByteInInt)
*gDecompressBufferPtr = gDecompressBufferCurrent;
}
UNUSED static bool32 IsATxPCompressed_unused(char *data)
{
if ((data[0] == 'A' && data[1] == 'T' && data[2] == '4' && data[3] == 'P')) return TRUE;
if ((data[0] == 'A' && data[1] == 'T' && data[2] == '3' && data[3] == 'P')) return TRUE;
return FALSE;
}
bool8 sub_800B2D4(char *arg0, char *arg1, s32 length)
{
s32 i;
char a, b;
for (i = 0; i < length; i++) {
a = arg0[i];
b = arg1[i];
// convert to lowercase
if ('A' <= a && a <= 'Z') a += 0x20;
if ('A' <= b && b <= 'Z') b += 0x20;
if (a != b)
return TRUE;
if (a == '\0')
break;
}
return FALSE;
}

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "code_8004AA0.h"
#include "constants/walkable_tile.h"
#include "decompress.h"
#include "dungeon_map_access.h"
#include "dungeon_global_data.h"
#include "tile_types.h"

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@ static void sub_8013134(MenuInputStruct *, u32, u32);
static void sub_801332C(s16 *);
static void sub_8013470(MenuInputStruct *);
ALIGNED(4) static const char fill_save7[] = _("pksdir0");
const u32 gDefaultMenuTextColors[3] = { COLOR_WHITE_2, COLOR_RED, COLOR_RED };
u32 sub_8012A64(MenuInputStructSub *r0, s32 r1)

View File

@ -2,7 +2,7 @@
#include "code_800D090.h"
#include "constants/colors.h"
#include "constants/move_id.h"
#include "file_system.h"
#include "decompress.h"
#include "items.h"
#include "moves.h"
#include "pokemon.h"

View File

@ -79,6 +79,7 @@ EWRAM_DATA_2 struct QuickSaveWrite *gQuickSaveWrite = {0};
extern s32 gUnknown_202DE28;
extern u32 *gUnknown_203B488;
ALIGNED(4) static const char debug_fill8[] = "pksdir0";
ALIGNED(4) const char sGameInternalVersion[] = _("POKE_DUNGEON__05");
ALIGNED(4) static const char fill_save0[] = _("pksdir0");
@ -86,7 +87,7 @@ ALIGNED(4) static const char fill_save1[] = _("pksdir0");
ALIGNED(4) static const char fill_save2[] = _("pksdir0");
ALIGNED(4) static const char fill_save3[] = _("pksdir0");
ALIGNED(4) const char gSaveCorrupted[] = _("{CENTER_ALIGN}The game data is corrupted.\n"
ALIGNED(4) static const char gSaveCorrupted[] = _("{CENTER_ALIGN}The game data is corrupted.\n"
"{CENTER_ALIGN}Your data will be erased.");
ALIGNED(4) static const char fill_save4[] = _("pksdir0");
@ -136,7 +137,6 @@ ALIGNED(4) const char gSaveNotWritten2[] = _("{CENTER_ALIGN}The data could not b
"{CENTER_ALIGN}and reinsert the DS Card.");
ALIGNED(4) const char gSaveFailed2[] = _("{CENTER_ALIGN}Save failed.");
ALIGNED(4) static const char fill_save7[] = _("pksdir0");
extern bool8 sub_800DAB0(u16, u8*, s32);

View File

@ -156,6 +156,7 @@ gUnknown_202D2A0: /* 202D2A0 (code_8009804) */
.space 0x4
.include "src/file_system.o"
.include "src/decompress.o"
.include "src/main.o"
gUnknown_202D608: /* 202D608 (reg_control / unused_vblank) */