-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update internal imports to v7 * add magic timestamps used for game identification * create game version consts * choose validation strategy based on game version * implement game version identification * remove redundant parens * implement chunk reading for HGSS * improve logging * improve logging * create savefile abstractions * create common savefile interface * make savefiles implement ISave * make block constructor * add todo * add temporary parsing constant * add tests for new savefile interface * add more metods to ISave, implement them per game variant * remove unused packages (functionality merged into sav packge) * merged in validator package functionality * import ttypes from sav * use new ISave interface * update type comments * add todos * use indicated party size to fetch pokemon * use indicated party size to fetch pokemon * test fmt * fix formatting * fix formatting * deleet problematic test * update gitignore * move constants to sav * separate logically related functions into different files * rename ISave methods, add more methods for write support * update interface to use ISave methods
- Loading branch information
Showing
24 changed files
with
480 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ pkmn-rom-parser | |
dev/* | ||
|
||
main | ||
results* | ||
results* | ||
|
||
sav/*_test.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package gamever | ||
|
||
type GameVer int | ||
|
||
const ( | ||
DP GameVer = iota | ||
PLAT | ||
HGSS | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/dingdongg/pkmn-rom-parser/v6 | ||
module github.com/dingdongg/pkmn-rom-parser/v7 | ||
|
||
go 1.22.3 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
package parser | ||
|
||
import ( | ||
"github.com/dingdongg/pkmn-rom-parser/v6/consts" | ||
"github.com/dingdongg/pkmn-rom-parser/v6/rom_reader" | ||
"github.com/dingdongg/pkmn-rom-parser/v6/rom_writer" | ||
"github.com/dingdongg/pkmn-rom-parser/v6/rom_writer/req" | ||
"github.com/dingdongg/pkmn-rom-parser/v6/validator" | ||
"github.com/dingdongg/pkmn-rom-parser/v6/validator/locator" | ||
"github.com/dingdongg/pkmn-rom-parser/v7/rom_reader" | ||
"github.com/dingdongg/pkmn-rom-parser/v7/rom_writer" | ||
"github.com/dingdongg/pkmn-rom-parser/v7/rom_writer/req" | ||
"github.com/dingdongg/pkmn-rom-parser/v7/sav" | ||
) | ||
|
||
func Parse(savefile []byte) ([]rom_reader.Pokemon, error) { | ||
if err := validator.Validate(savefile); err != nil { | ||
game, err := sav.Validate(savefile) | ||
if err != nil { | ||
return []rom_reader.Pokemon{}, err | ||
} | ||
|
||
chunk := locator.GetLatestSaveChunk(savefile) | ||
partyData := chunk.SmallBlock.BlockData[consts.PERSONALITY_OFFSET:] | ||
|
||
return rom_reader.GetPartyPokemon(partyData), nil | ||
partyData := rom_reader.GetPartyPokemon(game) | ||
return partyData, nil | ||
} | ||
|
||
func Write(savefile []byte, newBytes []req.WriteRequest) ([]byte, error) { | ||
if err := validator.Validate(savefile); err != nil { | ||
game, err := sav.Validate(savefile) | ||
if err != nil { | ||
return []byte{}, err | ||
} | ||
|
||
chunk := locator.GetLatestSaveChunk(savefile) | ||
return rom_writer.UpdatePartyPokemon(savefile, *chunk, newBytes) | ||
return rom_writer.UpdatePartyPokemon(game, newBytes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.