first commit
This commit is contained in:
72
crt.h
Normal file
72
crt.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <math.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#define pi 3.141592653589793
|
||||
|
||||
// Tipos de Pascal
|
||||
typedef double real;
|
||||
typedef int integer;
|
||||
typedef unsigned char byte;
|
||||
typedef bool boolean;
|
||||
typedef uint16_t word;
|
||||
|
||||
byte video[38400];
|
||||
|
||||
SDL_Window *sdlWindow;
|
||||
SDL_Renderer *sdlRenderer;
|
||||
SDL_Texture *sdlTexture;
|
||||
SDL_Event sdlEvent;
|
||||
|
||||
Uint32 *pixels;
|
||||
int pitch;
|
||||
|
||||
void randomize() {
|
||||
srand(SDL_GetTicks());
|
||||
}
|
||||
|
||||
int random(int x) {
|
||||
return rand()%x;
|
||||
}
|
||||
|
||||
void mcga() {
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
sdlWindow = SDL_CreateWindow("Asteroids", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
|
||||
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, 640, 480);
|
||||
}
|
||||
|
||||
void text() {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
void waitretrace() {
|
||||
while (!SDL_PollEvent(&sdlEvent)) {
|
||||
if (sdlEvent.type == SDL_QUIT) { /*Ja vorem*/ }
|
||||
}
|
||||
SDL_LockTexture(sdlTexture, NULL, (void**)&pixels, &pitch);
|
||||
int pos=0;
|
||||
for (int y=0; y<480;y++) {
|
||||
for (int x=0; x<80;x++) {
|
||||
pixels[pos++] = ((video[y*480+x]>>7)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x]>>6)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x]>>5)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x]>>4)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x]>>3)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x]>>2)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x]>>1)&1)?0xffffffff:0x000000ff;
|
||||
pixels[pos++] = ((video[y*480+x] )&1)?0xffffffff:0x000000ff;
|
||||
}
|
||||
}
|
||||
SDL_UnlockTexture(sdlTexture);
|
||||
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
|
||||
SDL_RenderPresent(sdlRenderer);
|
||||
}
|
||||
|
||||
void gotoxy(int x, int y) {
|
||||
|
||||
}
|
||||
void write(const char* text) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user