Skip to content

Commit

Permalink
View history
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoAiresCastello committed May 11, 2023
1 parent 8b9c8bb commit d1fde38
Show file tree
Hide file tree
Showing 59 changed files with 6,003 additions and 0 deletions.
File renamed without changes.
Binary file added PTM/Build/PTM.exe
Binary file not shown.
Binary file added PTM/Build/SDL2.dll
Binary file not shown.
31 changes: 31 additions & 0 deletions PTM/PTM.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PTM", "PTM.vcxproj", "{DD6F5822-D1AB-4473-BB41-7D631F7926B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Debug|x64.ActiveCfg = Debug|x64
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Debug|x64.Build.0 = Debug|x64
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Debug|x86.ActiveCfg = Debug|Win32
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Debug|x86.Build.0 = Debug|Win32
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Release|x64.ActiveCfg = Release|x64
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Release|x64.Build.0 = Release|x64
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Release|x86.ActiveCfg = Release|Win32
{DD6F5822-D1AB-4473-BB41-7D631F7926B3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {25D12A45-CE56-418C-90E8-3A6D888E9E84}
EndGlobalSection
EndGlobal
152 changes: 152 additions & 0 deletions PTM/PTM.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{dd6f5822-d1ab-4473-bb41-7d631f7926b3}</ProjectGuid>
<RootNamespace>PTM</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<CompileAs>CompileAsC</CompileAs>
<AdditionalIncludeDirectories>C:\Lib\SDL2-2.26.5\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerOutput>AssemblyCode</AssemblerOutput>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Lib\SDL2-2.26.5\lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy "$(TargetDir)SDL2.dll" "$(SolutionDir)Build\SDL2.dll"
copy "$(TargetPath)" "$(SolutionDir)Build\$(TargetFileName)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="api_private.cpp" />
<ClCompile Include="api_public.cpp" />
<ClCompile Include="main.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="api_private.h" />
<ClInclude Include="api_public.h" />
<ClInclude Include="common.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
13 changes: 13 additions & 0 deletions PTM/PTM.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="main.c" />
<ClCompile Include="api_public.cpp" />
<ClCompile Include="api_private.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="api_public.h" />
<ClInclude Include="api_private.h" />
<ClInclude Include="common.h" />
</ItemGroup>
</Project>
43 changes: 43 additions & 0 deletions PTM/api_private.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "api_private.h"

#define BUF_W 256
#define BUF_H 192
#define WND_SIZE 4

struct {
SDL_Window* wnd;
SDL_Renderer* rend;
SDL_Texture* tx;
rgb* buf;
int buf_len;
int buf_w;
int buf_h;
rgb back_color;
int pixel_w;
int pixel_h;
} screen;

void init_screen()
{
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
screen.wnd = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WND_SIZE * BUF_W, WND_SIZE * BUF_H, 0);
screen.rend = SDL_CreateRenderer(screen.wnd, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
SDL_RenderSetLogicalSize(screen.rend, BUF_W, BUF_H);
screen.tx = SDL_CreateTexture(screen.rend, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, BUF_W, BUF_H);
SDL_SetTextureBlendMode(screen.tx, SDL_BLENDMODE_NONE);
SDL_SetRenderDrawBlendMode(screen.rend, SDL_BLENDMODE_NONE);
SDL_SetRenderDrawColor(screen.rend, 0, 0, 0, 255);
SDL_RenderClear(screen.rend);
SDL_RenderPresent(screen.rend);
SDL_SetWindowPosition(screen.wnd, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_RaiseWindow(screen.wnd);
}
void free_screen()
{
free(screen.buf); screen.buf = NULL;
SDL_DestroyTexture(screen.tx); screen.tx = NULL;
SDL_DestroyRenderer(screen.rend); screen.rend = NULL;
SDL_DestroyWindow(screen.wnd); screen.wnd = NULL;

}
5 changes: 5 additions & 0 deletions PTM/api_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include "common.h"

void init_screen();
void free_screen();
35 changes: 35 additions & 0 deletions PTM/api_public.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "api_public.h"
#include "api_private.h"

void ptm_init()
{
SDL_Init(SDL_INIT_EVERYTHING);
init_screen();
}
void ptm_exit()
{
free_screen();
SDL_Quit();
exit(0);
}
void ptm_halt()
{
while (true) {
SDL_Event e = { 0 };
SDL_PollEvent(&e);
if (e.type == SDL_QUIT) {
ptm_exit();
break;
}
else if (e.type == SDL_KEYDOWN) {
const SDL_Keycode key = e.key.keysym.sym;
if (key == SDLK_ESCAPE) {
ptm_exit();
break;
}
else if (key == SDLK_RETURN && (SDL_GetModState() & KMOD_ALT)) {
// toggle fullscreen
}
}
}
}
6 changes: 6 additions & 0 deletions PTM/api_public.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include "common.h"

void ptm_init();
void ptm_exit();
void ptm_halt();
6 changes: 6 additions & 0 deletions PTM/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include <SDL.h>
#include <stdbool.h>

typedef unsigned int rgb;
typedef unsigned char byte;
9 changes: 9 additions & 0 deletions PTM/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "api_public.h"

int main(int argc, char* argv[])
{
ptm_init();
ptm_halt();

return 0;
}
25 changes: 25 additions & 0 deletions v1/PTM/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.vs
bin
obj
*.ini
*.pro
*.user
*.vs
*.log
*.ilk
*.pdb
*.map
*.exp
*.dia
*.dia~
*.props
*.pdb
hiscore.dat
Docs/Generated
old
Debug
PTM.dbg
PTM.cfg
PTM.last
main.ptm
temp.ptm
Binary file added v1/PTM/Build/PTM.exe
Binary file not shown.
Binary file added v1/PTM/Build/SDL2.dll
Binary file not shown.
Loading

0 comments on commit d1fde38

Please sign in to comment.