How michalklabisz/pascal-wezyk works
Project type and purpose
• This is a standalone DOS-based Snake clone written in Turbo Pascal.
• It consists of Pascal source files, Turbo Pascal units, compiled executables, and game asset files (graphics, sound, data).
File structure
• Source code (.PAS):
• BEFORE.PAS, CREATE.PAS, FNT.PAS, GRA.PAS, M13H.PAS, PLIK.PAS, SOUND.PAS, STEROW.PAS, …
• Compiled unit:
• GVGA.TPU – Turbo Pascal graphics unit
• Executable:
• GRA.EXE
• Data files:
• PALMENU.DAT, Palgame.dat, TOP5.DAT – menu, game data, top-scores
• title.bmp – splash/title screen
• .wav files (begin.wav, brzdek.wav, dzwiek.wav, end.wav, gold.wav, mniam.wav) – sound effects
• Readme and docs:
• README.md, readme.txt
Main components
a. Game Core (main loop)
• Parses command-line or menu selection
• Initializes graphics (GVGA unit) and sound
• Loads configuration/data files
b. Input Handler
• Module STEROW.PAS handles keyboard/game controls
c. Game Logic
• Snake movement, collision detection, score tracking (modules GRA.PAS, CREATE.PAS, BEFORE.PAS)
d. Rendering Engine
• Graphics drawing routines (GRA.PAS, GVGA.TPU, FNT.PAS for fonts)
e. Sound Engine
• SOUND.PAS loads and plays wave files
f. Persistence/File I/O
• PLIK.PAS reads/writes .DAT files (PALMENU.DAT, Palgame.dat, TOP5.DAT)
g. Menu/System UI
• PALMENU.DAT + menu code for starting game, showing top scores
h. Assets
• External data (bitmaps, sounds, level/menu data)
Relationships and interactions
• The Game Core orchestrates the flow:
• Calls Input Handler each frame
• Passes input events to Game Logic
• Game Logic updates state (snake position, score)
• Calls Sound Engine when events occur (e.g. eat, game over)
• File I/O invoked on start/end (load menu, save scores)
• Data assets are loaded once at init or on-demand
• The GVGA.TPU unit underpins all low-level graphics calls
Architectural patterns and design principles
• Modular decomposition: separate .PAS files for graphics, logic, sound, I/O
• Single-threaded game loop pattern
• Layered approach:
• Hardware abstraction (GVGA)
• Engine layers (input, logic, render, sound)
• Data layer (asset files)