Skip to content

Commit

Permalink
fixed preset reading, added curse timer
Browse files Browse the repository at this point in the history
  • Loading branch information
TalicZealot committed Apr 6, 2021
1 parent dd689d9 commit e257cc0
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 6 deletions.
12 changes: 12 additions & 0 deletions SotnApi/SotnApi/AlucardApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,18 @@ public uint ShineTimer
}
}

public uint CurseTimer
{
get
{
return memAPI.ReadByte(Timers.Curse);
}
set
{
memAPI.WriteByte(Timers.Curse, value);
}
}

public string GetSelectedItemName()
{
string item;
Expand Down
2 changes: 1 addition & 1 deletion SotnApi/SotnApi/Constants/Addresses/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ public static class Game
public static long ActorsStart = 0x07650C;
public static long VramMapStart = 0x08AE80;
public static long SeedStart = 0x1A78B4;
public static long PresetStart = 0x1A78E1;
public static long PresetStart = 0x1A78D4;
}
}
2 changes: 1 addition & 1 deletion SotnApi/SotnApi/Constants/Values/Game/Actors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class Actors
public static int PaletteOffset = 0x16;
public static int ColorMode = 0x18;
public static int ItemIndexOffset = 0x30;
public static int HitboxTypeOffset = 0x3A;
public static int EnemyNameIndex = 0x3A;
public static int HitboxAutoToggleOffset = 0x3C;
public static int HpOffset = 0x3E;
public static int DamageOffset = 0x40;
Expand Down
10 changes: 7 additions & 3 deletions SotnApi/SotnApi/GameApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.RegularExpressions;
using BizHawk.Client.Common;
using SotnApi.Constants.Addresses;
using SotnApi.Constants.Values.Game;
Expand Down Expand Up @@ -50,11 +51,11 @@ public Character CurrentCharacter
}
}

public uint SecondCastle
public bool SecondCastle
{
get
{
return memAPI.ReadByte(Game.SecondCastle);
return memAPI.ReadByte(Game.SecondCastle) > 0;
}
}

Expand Down Expand Up @@ -181,7 +182,10 @@ public string ReadSeedName()

public string ReadPresetName()
{
return ReadString(Game.PresetStart).Trim();
string preset = ReadString(Game.PresetStart).Trim();
string pattern = @" ([a-z.]{4,10}) ";
Match match = Regex.Match(preset, pattern, RegexOptions.IgnoreCase);
return match.Value.Trim();
}

private string ReadString(long address)
Expand Down
1 change: 1 addition & 0 deletions SotnApi/SotnApi/Interfaces/IAlucardApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public interface IAlucardApi
uint DefencePotionTimer { get; set; }
uint InvincibilityTimer { get; set; }
uint ShineTimer { get; set; }
uint CurseTimer { get; set; }

void ClearInventory();
string GetSelectedItemName();
Expand Down
68 changes: 67 additions & 1 deletion SotnApi/SotnApi/Interfaces/IGameApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,97 @@

namespace SotnApi.Interfaces
{
/// <returns>
/// Controls
/// </returns>
public interface IGameApi
{
/// <returns>
/// The current Status of the game.
/// </returns>
/// <example>
/// MainMenu
/// </example>
/// <example>
/// InGame
/// </example>
uint Status { get; }
/// <returns>
/// Returns the currently selected category in the menu.
/// </returns>
MainMenuCategory CurrentMainMenuCategory { get; }
/// <returns>
/// The current character, but prologue Richter still counts as Alucard.
/// </returns>
Character CurrentCharacter { get; }
/// <returns>
/// Index for the current area or subarea.
/// </returns>
uint Area { get; }
/// <returns>
/// Room for the current room or subroom.
/// </returns>
uint Room { get; }
uint SecondCastle { get; }
/// <returns>
/// True if the player is in the second castle.
/// </returns>
bool SecondCastle { get; }
/// <returns>
/// Zone Byte1.
/// </returns>
uint Zone { get; }
/// <returns>
/// Zone Byte2.
/// </returns>
uint Zone2 { get; }
/// <returns>
/// True of the game is in the process of loading a new area.
/// </returns>
bool IsLoading { get; }
/// <returns>
/// True of the game is in the process of loading a new screen.
/// </returns>
bool InTransition { get; }

/// <summary>
/// Checks if the item equip menu is currently open.
/// </summary>
bool EquipMenuOpen();
/// <summary>
/// Checks if the relic equip menu is currently open.
/// </summary>
bool RelicMenuOpen();
/// <summary>
/// Checks if it is currently possible for the player to access the menu.
/// </summary>
bool CanMenu();
/// <summary>
/// Sets an address value to zero.
/// </summary>
void ClearByte(long address);
/// <summary>
/// Checks if the game is in Alucard mode.
/// </summary>
bool InAlucardMode();
/// <summary>
/// Checks if the menu si currently open.
/// </summary>
bool IsInMenu();
/// <summary>
/// Overwrites a string in the game.
/// </summary>
void OverwriteString(long address, string text);
/// <summary>
/// Reads the start menu string, where the Randomizer preset is stored.
/// </summary>
string ReadPresetName();
/// <summary>
/// Reads the start menu string, where the Randomizer seed is stored.
/// </summary>
string ReadSeedName();
/// <summary>
/// Enables all the bosses in the game, even if they have been defeated.
/// </summary>
void RespawnBosses();
}
}
12 changes: 12 additions & 0 deletions SotnApi/SotnApi/Interfaces/IRenderingApi.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
namespace SotnApi.Interfaces
{
/// <summary>
/// Manipulates VRAM elements.
/// </summary>
public interface IRenderingApi
{
/// <summary>
/// Colors a room on the map as a 3x3 square with borders.
/// </summary>
void ColorMapRoom(uint row, uint col, uint color, uint borderColor);
/// <summary>
/// Colors a location on the map as a 2x2 square.
/// </summary>
void ColorMapLocation(uint row, uint col, uint color);
/// <summary>
/// Checks if a room on the minimap is rendered.
/// </summary>
bool RoomIsRendered(uint row, uint col);
}
}
126 changes: 126 additions & 0 deletions SotnApi/SotnApi/SotnApi.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e257cc0

Please sign in to comment.