Mad-Pascal
Mad-Pascal copied to clipboard
Mad Pascal Compiler for 6502 (Atari XE/XL, C64, C4Plus, Neo6502)
Mad-Pascal
Introduction
Mad-Pascal (MP) is a 32-bit Turbo Pascal compiler for Atari XE/XL. By design, it is compatible with the Free Pascal Compilator (FPC) (the -MDelphi switch should be active), which means the possibility of obtaining executable code for XE/XL, PC and every other platform for which FPC exists.
MP is not a port of FPC; it has been written based on of SUB-Pascal (2009), XD-Pascal (2010), the author of which is Vasiliy Tereshkov.
A program that works on Atari might have problems on PC if, for example, the pointers have not been initialized with the address of a variable and the program attempts to write to the address $0000 (memory protection fault).
The strengths of MP include fast and convenient possibility of inclusion of inline assembly. A program using inline ASM does not work on platforms other than 6502 CPU. MP uses 64KB of primary memory; TMemoryStream provides usage of extended memory.
Variable allocation is static; there is no dynamic memory management. Parameters are passed to functions by value, variable or constant.
The available features are:
IfCaseFor ToFor InWhileRepeatstatements- Compound statements
LabelGotostatements- Arithmetic and boolean operators
- Procedures and functions with up to 8 parameters. Returned value of a function is assigned to a predefined
RESULTvariable - Static local variables
- Primitive data types, all types except the
ShortReal,Realtype are compatible. Pointers are dereferenced as pointers toWord:CardinalWordByteBooleanIntegerSmallIntShortIntCharStringPCharPointerFileTextShortRealRealfixed-pointFloat16Single/ Float
- One-dimensional and Two-dimensional arrays (with zero lower bound) of any primitive type. Arrays are treated as pointers to their origins (like in C) and can be passed to subroutines as parameters
- Predefined type
String[N]which is equivalent toarray [0..N] of Char TypealiasesRecordsObjects- Separate program modules
- Recursion
Compile
fpc -MDelphi -vh -O3 mp.pas
Usage
Atari XE/XL
mp.exe filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\base
BAT
<MadPascalPath>\MP.exe %1 -ipath:<MadPascalPath>\lib -ipath:<MadPascalPath>\blibs
if exist %~dp1%~n1.a65 (
mads.exe "%~dp1%~n1.a65" -xli:<MadPascalPath>\base
if exist "%~dp1%~n1.obx" altirra "%~dp1%~n1.obx"
)
Commodore 64
mp.exe -t c64 filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\base
Commodore Plus/4
mp.exe -t c4p filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\base
Neo6502
mp.exe -t neo filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\base
RAW
mp.exe -t raw filename.pas -ipath:<MadPascalPath>\lib
mads.exe filename.a65 -x -i:<MadPascalPath>\base
Tools
MadStrap
Simple Atari Mad-Pascal common project bootstrap.
Source code at GitLab
BLIBS
Set of custom libraries for MadPascal.
Lastest documentation always at GitLab
pasdoc
Custom tool for generating documentation from pascal comments in units.
Source code at GitLab
Effectus - Action! compiler
In new version the source code is generated by using Mad Pascal cross-compiler, which is further compiled to binary code with Mad Assembler.
Game tutorial
Simple game tutorial by using Mad Pascal
FiDL
Display List program editor for 8-bit Atari ANTIC chipset
CutAs
Simple binary data manipulation tool written in javascript (export to Action!, Assembler, C, Pascal)
Bocianu's Atari Toolkit HUB
CutAs, FiDL, SprED, Sprite XL
A8 Mad-Pascal Window Library
This is a text mode windowing library complete with window controls and modern gadgets (widgets). The gadgets allow you to build input forms that use buttons, radio buttons, input strings (with scrolled lengths and type restrictions), check boxes, progress bars, etc. This allows you to build applications with "modern"-ish interfaces.
Projects in Mad-Pascal
- StarVagrant
- MadKingdom
- zilch
- justpong
- hoppe
- PacMad
- PacMad neo6502
- k12trailer
- gr10
- Old Mansion
- Old Mansion X16
- artur
- jcq
- Fujinet udp shoutbox
- speedway
- chessnet
- gr9Lab
- SortViz
- weather
- cart builder
- Mole
- SFX-Tracker
- SFX-Engine
- MIDICar-Player
- heatmap
- sinus scroll 2x2
- Flob
- Ultima V
- mad-pascal-playground
- simple-games-easy-for-develop
- siege-ai-playground
- Cartfall
- gravity
- Unicode
- Arcadia
- atascii compo3
- ProHiBan
- The Hangmad
- Block Attack
- Dungeon Adventurer
- Tetris neo6502
- µSoukoban
- Time Wizard
Benchmarks
| CC65 | Mad Pascal | Millfork | |
|---|---|---|---|
| Sieve (less is better) | 602 | 577 | 579 |
| YoshPlus (higher is better) | 41933 | 41933 | 41933 |
| Chessboard (higher is better) | 76 | 88 | 82 |
https://github.com/tebe6502/Mad-Pascal/blob/master/samples/benchmark.7z
Floating Point
| iteration x 256 | Atari OS | FastChip | MP Single | MP Real |
|---|---|---|---|---|
| add, sub, mul, div | 232 | 118 | 64 | 99 |
| add, sub, mul, div, sin, cos | 5820 | 2915 | 3728 | 1231 |
- MP Single: IEEE754-32bit
- MP Real: Q24.8 Fixed Point
https://github.com/tebe6502/Mad-Pascal/blob/master/samples/fp_benchmark.7z
Suite

Links
- HOME Page
- Mad Pascal on Atari Age Forum
- Games in Mad Pascal
- Mad Pascal examples
- Mad Pascal on Atari Area Forum
- Mad Pascal Announcement for WUDSN
- Some advice
- Programowanie w Mad Pascal dla C+4
- Commodore Plus/4, Mad Pascal i bitmapy
YouTube
- Arcadia
- Flob
- ProHiBan (Sokoban)
- The Hangmad
- gravity
- Block Attack
- Turbo Pascal "Sokoban"
- Tron +4. Mad Pascal i C+4
- Mad Pascal Commodore Plus/4 plasma effect with TEDzakker demo music
- Dungeon Adventurer