Difference between revisions of "1K Intro"

From SizeCoding
Jump to: navigation, search
Line 25: Line 25:
 
* glRects(-1,-1,1,1) - Draw a single quad with current Shader
 
* glRects(-1,-1,1,1) - Draw a single quad with current Shader
 
* SwapBuffers(hDC) - Swap Buffers
 
* SwapBuffers(hDC) - Swap Buffers
 +
* PeekMessageA(0, 0, 0, 0, PM_REMOVE) - Optional: Unanswered messages might stack up, but in practice you should be fine in fullscreen
 
* GetAsyncKeyState(VK_ESCAPE) - Checks for escape key (required by compo rules)
 
* GetAsyncKeyState(VK_ESCAPE) - Checks for escape key (required by compo rules)
  
 
=== Closedown ===
 
=== Closedown ===
 
* ExitProcess(0) - Close down application
 
* ExitProcess(0) - Close down application
 +
 +
  
 
== Graphics / effect ==
 
== Graphics / effect ==
Line 43: Line 46:
  
 
== Compression ==
 
== Compression ==
* Microsoft Cabinet decmpression
+
 
 +
=== Microsoft Cabinet decmpression ===
 
These functions allow for MSZIP (deflate) and MSLZ content to be loaded from the binary as payload at the cost of a a few more win32 function imports. Well this might be a good solution for 512 byte intros, the tipping point for Crinkler compression at the moment lies at the 800-850 byte mark give or take.
 
These functions allow for MSZIP (deflate) and MSLZ content to be loaded from the binary as payload at the cost of a a few more win32 function imports. Well this might be a good solution for 512 byte intros, the tipping point for Crinkler compression at the moment lies at the 800-850 byte mark give or take.
  
* Crinkler
+
===  Crinkler ===
 
Crinkler is the most commonly used compression at the moment for many 1K and 4K intros.
 
Crinkler is the most commonly used compression at the moment for many 1K and 4K intros.
 
It has a seperate settings for 1K intro, namely /TINYIMPORT and /TINYHEADER which will better match the 1K usecase.
 
It has a seperate settings for 1K intro, namely /TINYIMPORT and /TINYHEADER which will better match the 1K usecase.
  
=== Crinkler reports ===
+
==== Crinkler reports ====
 
When using the /REPORT:intro_report.html feature, crinkler will generate a report and heatmap for your intro binary.
 
When using the /REPORT:intro_report.html feature, crinkler will generate a report and heatmap for your intro binary.
 
This is helpful to see how good your (shader)code compresses and where you can maybe gain a few more bytes.
 
This is helpful to see how good your (shader)code compresses and where you can maybe gain a few more bytes.
  
=== Word about resulting exes ===
+
==== Word about the resulting executable ====
Please note that when using crinkler in TINYEXPORT mode, the resulting windows header will most likely trigger virus scanners / microsoft defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.  
+
Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / microsoft defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice  to include a (slightly larger) safe version too in the final archive.  
  
 
== Frameworks ==
 
== Frameworks ==

Revision as of 05:40, 12 April 2024

Introduction

This category is dedicated to 1K Intros for Windows 32.

Windows 1K Intros can be setup in C or Aseembler, or a combination of both, with only the few windows calls that are used being linked in. In general writing everything in assembler should give you a little more freedom in pushing/popping your function arguments but in th past quality intros have been written in both languages.

Graphics are usualy done using OpenGL / GLSL, but there are 1K intros out there that have used D3D instead.

Setup (Windows)

  • ChangeDisplaySettings(&screenSettings, CDS_FULLSCREEN) - Initialise fullscreen view
  • hwnd = CreateWindow((LPCSTR)0xC018, 0, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0) - Setting up a Maximised Window
  • GetDC(hwnd) - Get DeviceContext handle
  • ChoosePixelFormat(hDC, &pfd) - Set pixelformat describer by pfd to DeviceContext handle
  • ShowCursor(NULL) - Hide mousecursor (usually required by compo rules)

Setup (OpenGL)

  • glContent = wglCreateContext(hDC) - Create OpenGL context
  • wglMakeCurrent(hDC, glContext) - Set OpenGL Context
  • shaderProgam = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1, &shader) - Create and compile GLSL Shader
  • glUseProgram(shaderProgram) - Set active shader

Update Loop

  • t = GetTickCount() - Optional: Get Current ticks
  • glColor3us(t,0,0) / glColor3i(t,0,0) - Parse time via gl_Color (saves importing uniform functions)
  • glRects(-1,-1,1,1) - Draw a single quad with current Shader
  • SwapBuffers(hDC) - Swap Buffers
  • PeekMessageA(0, 0, 0, 0, PM_REMOVE) - Optional: Unanswered messages might stack up, but in practice you should be fine in fullscreen
  • GetAsyncKeyState(VK_ESCAPE) - Checks for escape key (required by compo rules)

Closedown

  • ExitProcess(0) - Close down application


Graphics / effect

  • Passed time via glColor (no uniforms used)
  • GLSL Shadercode

Sound

  • Win32 Single Note MIDI
  • Win32 MIDI player
  • Bytebeat softsynth
  • Shader softsynth

Compression

Microsoft Cabinet decmpression

These functions allow for MSZIP (deflate) and MSLZ content to be loaded from the binary as payload at the cost of a a few more win32 function imports. Well this might be a good solution for 512 byte intros, the tipping point for Crinkler compression at the moment lies at the 800-850 byte mark give or take.

Crinkler

Crinkler is the most commonly used compression at the moment for many 1K and 4K intros. It has a seperate settings for 1K intro, namely /TINYIMPORT and /TINYHEADER which will better match the 1K usecase.

Crinkler reports

When using the /REPORT:intro_report.html feature, crinkler will generate a report and heatmap for your intro binary. This is helpful to see how good your (shader)code compresses and where you can maybe gain a few more bytes.

Word about the resulting executable

Please note that when using crinkler in TINYHEADER mode, the resulting windows header will most likely trigger virus scanners / microsoft defender and mark it as suspicious content, which is a side-effect in recent years. Just exclude your work directory from this scan during development. Compo machines will run without these scanners too, but it is good practice to include a (slightly larger) safe version too in the final archive.

Frameworks

1K intros for Windows