2021-08-21 08:29:58 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
2021-08-23 05:22:56 +00:00
|
|
|
#define NOMINMAX
|
2021-08-21 08:29:58 +00:00
|
|
|
#include <windows.h>
|
2021-08-23 05:22:56 +00:00
|
|
|
#undef NOMINMAX
|
2021-08-21 08:29:58 +00:00
|
|
|
|
|
|
|
#include "common.h"
|
2021-08-27 04:12:26 +00:00
|
|
|
#include "AudioDevice.h"
|
2021-08-21 08:29:58 +00:00
|
|
|
#include "Font.h"
|
2021-08-23 05:22:56 +00:00
|
|
|
#include "Game.h"
|
2021-08-21 08:29:58 +00:00
|
|
|
#include "LinearAllocator.h"
|
2021-08-25 03:27:39 +00:00
|
|
|
#include "SystemClock.h"
|
2021-08-21 08:29:58 +00:00
|
|
|
#include "Win32Console.h"
|
|
|
|
|
|
|
|
|
|
|
|
constexpr size_t kHeapSize = 1024*1024*64;
|
|
|
|
|
|
|
|
constexpr uint32_t kWidth = 96;
|
|
|
|
constexpr uint32_t kHeight = 28;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
auto memory = std::make_unique<uint8_t[]>(kHeapSize);
|
|
|
|
gj::LinearAllocator alloc(memory.get(), kHeapSize);
|
|
|
|
|
|
|
|
gj::Win32Console console(&alloc, kWidth, kHeight);
|
|
|
|
console.Show();
|
|
|
|
|
2021-08-27 04:12:26 +00:00
|
|
|
gj::AudioDevice audio;
|
|
|
|
|
2021-08-25 03:27:39 +00:00
|
|
|
gj::Game::Param param;
|
|
|
|
param.alloc = &alloc;
|
2021-08-27 04:12:26 +00:00
|
|
|
param.clock = &audio;
|
|
|
|
param.audio = &audio;
|
2021-08-25 03:27:39 +00:00
|
|
|
param.w = kWidth;
|
|
|
|
param.h = kHeight;
|
|
|
|
gj::Game game(std::move(param));
|
2021-08-27 04:12:26 +00:00
|
|
|
|
2021-08-21 08:29:58 +00:00
|
|
|
while (true) {
|
2021-08-26 05:51:50 +00:00
|
|
|
game.Update(console.TakeInput());
|
2021-08-21 08:29:58 +00:00
|
|
|
{
|
2021-08-23 05:22:56 +00:00
|
|
|
auto& fb = console.TakeColorbuffer();
|
|
|
|
fb.Clear();
|
|
|
|
game.Draw(fb);
|
|
|
|
console.SwapColorbuffer();
|
2021-08-21 08:29:58 +00:00
|
|
|
}
|
|
|
|
{
|
2021-08-23 05:22:56 +00:00
|
|
|
auto& fb = console.TakeTextbuffer();
|
|
|
|
fb.Clear();
|
|
|
|
game.Write(fb);
|
|
|
|
console.SwapTextbuffer();
|
2021-08-21 08:29:58 +00:00
|
|
|
}
|
2021-08-23 09:25:44 +00:00
|
|
|
Sleep(10);
|
2021-08-21 08:29:58 +00:00
|
|
|
}
|
|
|
|
}
|