Skip to content

Commit

Permalink
Worked out three more command types
Browse files Browse the repository at this point in the history
  • Loading branch information
xavieran committed Mar 15, 2024
1 parent 6b2b070 commit 1f4bd38
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 46 deletions.
52 changes: 40 additions & 12 deletions bak/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ std::unordered_map<unsigned, Scene> LoadScenes(FileBuffer& fb)
{
imageSlots[*imageSlot] = ImageSlot{};
}
//imageSlots[*imageSlot].mImage = name;
} break;
case Actions::LOAD_SCREEN:
{
Expand All @@ -537,6 +536,8 @@ std::unordered_map<unsigned, Scene> LoadScenes(FileBuffer& fb)
DrawScreen{
glm::vec2{chunk.mArguments[0], chunk.mArguments[1]},
glm::vec2{chunk.mArguments[2], chunk.mArguments[3]},
static_cast<unsigned>(chunk.mArguments[4]),
static_cast<unsigned>(chunk.mArguments[5])
});
} break;
case Actions::DRAW_RECT:
Expand Down Expand Up @@ -571,10 +572,7 @@ std::unordered_map<unsigned, Scene> LoadScenes(FileBuffer& fb)
static_cast<std::int16_t>(scaled ? chunk.mArguments[5] : 0)});
flipped = false;
} break;
case Actions::CLEAR_SCREEN:
{
currentScene.mActions.emplace_back(ClearScreen{});
} break;

case Actions::UPDATE:
{
currentScene.mActions.emplace_back(Update{});
Expand Down Expand Up @@ -755,26 +753,31 @@ std::vector<SceneAction> LoadDynamicScenes(FileBuffer& fb)
actions.emplace_back(LoadPalette{paletteName});
} break;

case Actions::SAVE_IMAGE0: [[fallthrough]];
case Actions::SAVE_IMAGE1:
case Actions::SAVE_IMAGE0:
{
actions.emplace_back(
SaveImage{
glm::vec2{chunk.mArguments[0], chunk.mArguments[1]},
glm::vec2{chunk.mArguments[2], chunk.mArguments[3]}});
} break;

case Actions::PLAY_SOUND:
{
actions.emplace_back(
PlaySoundS{static_cast<unsigned>(chunk.mArguments[0])});
} break;

case Actions::SAVE_BACKGROUND:
{
actions.emplace_back(
SaveBackground{});
} break;

case Actions::SET_COLOR:
//ASSERT(paletteSlot);
//activeColor = std::make_pair(
// *paletteSlot,
// chunk.mArguments[0]);
actions.emplace_back(
SetColors{
static_cast<unsigned>(chunk.mArguments[0]),
static_cast<unsigned>(chunk.mArguments[1])});
break;
case Actions::LOAD_IMAGE:
{
Expand All @@ -795,6 +798,8 @@ std::vector<SceneAction> LoadDynamicScenes(FileBuffer& fb)
DrawScreen{
glm::vec2{chunk.mArguments[0], chunk.mArguments[1]},
glm::vec2{chunk.mArguments[2], chunk.mArguments[3]},
static_cast<unsigned>(chunk.mArguments[4]),
static_cast<unsigned>(chunk.mArguments[5])
});
} break;
case Actions::FADE_IN:
Expand All @@ -805,11 +810,17 @@ std::vector<SceneAction> LoadDynamicScenes(FileBuffer& fb)
{
actions.emplace_back(FadeOut{});
} break;
case Actions::GOTO_TAG:
{
actions.emplace_back(GotoTag{static_cast<unsigned>(chunk.mArguments[0])});
} break;
case Actions::SHOW_DIALOG:
{
actions.emplace_back(
ShowDialog{
chunk.mArguments[1] == 0xff || chunk.mArguments[0] == 0xff,
chunk.mArguments[1] == 0xff
|| chunk.mArguments[0] == 0xff
|| chunk.mArguments[1] == 2, // actually this is .BOK dialog bits
DialogSources::GetTTMDialogKey(chunk.mArguments[0])});
} break;
case Actions::DRAW_RECT:
Expand Down Expand Up @@ -842,6 +853,23 @@ std::vector<SceneAction> LoadDynamicScenes(FileBuffer& fb)
static_cast<std::int16_t>(scaled ? chunk.mArguments[5] : 0)});
flipped = false;
} break;
case Actions::SET_SAVE_LAYER:
{
actions.emplace_back(SetSaveLayer{
static_cast<unsigned>(chunk.mArguments[0])});
} break;
case Actions::CLEAR_SAVE_LAYER:
{
actions.emplace_back(ClearSaveLayer{
static_cast<unsigned>(chunk.mArguments[0])});
} break;
case Actions::SET_CLEAR_REGION:
{
actions.emplace_back(
SetClearRegion{
glm::vec2{chunk.mArguments[0], chunk.mArguments[1]},
glm::vec2{chunk.mArguments[2], chunk.mArguments[3]}});
} break;
case Actions::UPDATE:
{
actions.emplace_back(Update{});
Expand Down
40 changes: 36 additions & 4 deletions bak/sceneData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ std::string_view ToString(Actions a)
case Actions::SLOT_FONT: return "SlotFont";
case Actions::SET_SCENE: return "SetScene";
case Actions::SET_SCENEA: return "SETSCENEA";
case Actions::SET_SCENEB: return "SETSCENEB";
case Actions::SET_SAVE_LAYER: return "SetSaveLayer";
case Actions::GOTO_TAG: return "GotoTag";
case Actions::SET_COLOR: return "SetColors";
case Actions::SHOW_DIALOG: return "ShowDialog";
case Actions::FADE_OUT: return "FadeOut";
case Actions::FADE_IN: return "FadeIn";
case Actions::SAVE_IMAGE0: return "SaveImage0";
case Actions::SAVE_IMAGE1: return "SaveImage1";
case Actions::SET_CLEAR_REGION: return "SetClearRegion";
case Actions::SET_UNKNOWN: return "SETUNKNOWN";
case Actions::SET_WINDOWA: return "SETWINDOWA";
case Actions::SET_WINDOWB: return "SETWINDOWB";
Expand All @@ -77,7 +77,7 @@ std::string_view ToString(Actions a)
case Actions::DRAW_SPRITE_FLIP_Y: return "DrawSpriteFlipY";
case Actions::DRAW_SPRITE_FLIP_XY: return "DrawSpriteFlipXY";
case Actions::DRAW_SPRITE_ROTATE: return "DrawSpriteRotate";
case Actions::CLEAR_SCREEN: return "DRAWSPRITEB";
case Actions::CLEAR_SAVE_LAYER: return "ClearSaveLayer";
case Actions::DRAW_SCREEN: return "DrawScreen";
case Actions::LOAD_SOUND_RESOURCE: return "LoadSoundResource";
case Actions::SELECT_SOUND: return "SelectSound";
Expand Down Expand Up @@ -139,7 +139,8 @@ std::ostream& operator<<(std::ostream& os, const DrawRect& a)

std::ostream& operator<<(std::ostream& os, const DrawScreen& a)
{
os << "DrawScreen{ " << a.mPosition << " - " << a.mDimensions << "}";
os << "DrawScreen{ " << a.mPosition << " - " << a.mDimensions << " ("
<< a.mArg1 << ", " << a.mArg2 << ")}";
return os;
}

Expand Down Expand Up @@ -202,6 +203,11 @@ std::ostream& operator<<(std::ostream& os, const SaveImage& a)
return os << "SaveImage{ pos: " << a.pos << " dims: " << a.dims << "}";
}

std::ostream& operator<<(std::ostream& os, const SetClearRegion& a)
{
return os << "SetClearRegion{ pos: " << a.pos << " dims: " << a.dims << "}";
}

std::ostream& operator<<(std::ostream& os, const LoadPalette& a)
{
return os << "LoadPalette{ " << a.mPalette << "}";
Expand All @@ -217,6 +223,22 @@ std::ostream& operator<<(std::ostream& os, const SlotImage& a)
return os << "SlotImage{ " << a.mSlot << "}";
}

std::ostream& operator<<(std::ostream& os, const SetSaveLayer& a)
{
return os << "SetSaveLayer{ " << a.mLayer << "}";
}

std::ostream& operator<<(std::ostream& os, const ClearSaveLayer& a)
{
return os << "ClearSaveLayer{ " << a.mLayer << "}";
}

std::ostream& operator<<(std::ostream& os, const SetColors& a)
{
return os << "SetColors{ fg: " << a.mForegroundColor << " bg: "
<< a.mBackgroundColor << "}";
}

std::ostream& operator<<(std::ostream& os, const SlotPalette& a)
{
return os << "SlotPalette{ " << a.mSlot << "}";
Expand All @@ -227,6 +249,16 @@ std::ostream& operator<<(std::ostream& os, const ShowDialog& a)
return os << "ShowDialog{ clear: " << std::boolalpha << a.mClearDialog << ", " << std::hex << a.mDialogKey << std::dec << "}";
}

std::ostream& operator<<(std::ostream& os, const PlaySoundS& a)
{
return os << "PlaySound { " << a.mSoundIndex << "}";
}

std::ostream& operator<<(std::ostream& os, const GotoTag& a)
{
return os << "GotoTag{ " << a.mTag << "}";
}

std::ostream& operator<<(std::ostream& os, const SceneAction& sa)
{
std::visit(overloaded{
Expand Down
52 changes: 40 additions & 12 deletions bak/sceneData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ enum class Actions
SLOT_FONT = 0x1070,
SET_SCENEA = 0x1100, // Local taG?
SET_SCENE = 0x1110, // TAG??
SET_SCENEB = 0x1120, // SET BACKGROUND
GOTO_TAG = 0x1200, // GOTO TAG
SET_COLOR = 0x2000, // SET_COLOR
SET_SAVE_LAYER = 0x1120,
GOTO_TAG = 0x1200,
SET_COLOR = 0x2000,
SHOW_DIALOG = 0x2010,
UNKNOWN3 = 0x2300,
UNKNOWN6 = 0x2310,
UNKNOWN7 = 0x2320,
UNKNOWN4 = 0x2400,
SET_CLIP_REGION = 0x4000, // SET_CLIP_REGION
SET_CLIP_REGION = 0x4000,
FADE_OUT = 0x4110,
FADE_IN = 0x4120,
SAVE_IMAGE0 = 0x4200, // DRAW_BACKGROUND_REGION
SAVE_IMAGE1 = 0x4210, // SAVE_IMIAGE_REGION
SAVE_IMAGE0 = 0x4200,
SET_CLEAR_REGION = 0x4210,
SET_WINDOWA = 0xa010,
SET_WINDOWB = 0xa030,
SET_UNKNOWN = 0xa090,
Expand All @@ -82,8 +82,8 @@ enum class Actions
DRAW_SPRITE_FLIP_Y = 0xa520,
DRAW_SPRITE_FLIP_XY = 0xa530,
DRAW_SPRITE_ROTATE = 0xa5a0,
CLEAR_SCREEN = 0xa600, // CLEAR_SCREEN
DRAW_SCREEN = 0xb600,
CLEAR_SAVE_LAYER = 0xa600,
DRAW_SCREEN = 0xb600, // COPY_LAYER_TO_LAYER?
LOAD_SOUND_RESOURCE = 0xc020,
SELECT_SOUND = 0xc030,
DESELECT_SOUND = 0xc040,
Expand Down Expand Up @@ -141,11 +141,13 @@ struct DrawScreen
{
glm::ivec2 mPosition;
glm::ivec2 mDimensions;
unsigned mArg1;
unsigned mArg2;
};

struct PlaySoundS
{
std::uint16_t mSoundIndex;
unsigned mSoundIndex;
};

struct ClipRegion
Expand All @@ -170,12 +172,23 @@ struct DrawBackground
{
};

struct GotoTag
{
unsigned mTag;
};

struct SaveImage
{
glm::ivec2 pos;
glm::ivec2 dims;
};

struct SetClearRegion
{
glm::ivec2 pos;
glm::ivec2 dims;
};

struct Purge
{
};
Expand All @@ -201,9 +214,8 @@ struct Update

struct SetColors
{
unsigned mSlot; // which slot palette to pull colors from
std::uint16_t mForegroundColor;
std::uint16_t mBackgroundColor;
unsigned mForegroundColor;
unsigned mBackgroundColor;
};

struct FadeIn
Expand All @@ -214,6 +226,16 @@ struct FadeOut
{
};

struct SetSaveLayer
{
unsigned mLayer;
};

struct ClearSaveLayer
{
unsigned mLayer;
};

struct SlotImage
{
unsigned mSlot;
Expand Down Expand Up @@ -259,8 +281,14 @@ using SceneAction = std::variant<
FadeIn,
LoadScreen,
SetScene,
SetColors,
SlotImage,
SetSaveLayer,
ClearSaveLayer,
ShowDialog,
PlaySoundS,
SetClearRegion,
GotoTag,
SlotPalette>;

std::ostream& operator<<(std::ostream& os, const SceneAction& sa);
Expand Down
Loading

0 comments on commit 1f4bd38

Please sign in to comment.