Jump to content
IGNORED

Games in Mad Pascal


Recommended Posts

Hello there,

 

I've got an idea of posting games written in Mad Pascal. Here you can post any game you created in this language, it could even be a type-in listing game from any magazine or book, but converted to Mad Pascal.

 

I begin with Wolves, type-in listing from ex-Yu book Mirko Tipka Na Radirko, which included games and utility listings written in Sinclair BASIC for ZX Spectrum. Game was originally written by Primoz Petrlin. There is executable file at the bottom of this post. If you wish, you can modify it and make it even better.

 

post-7301-0-84139000-1457260603_thumb.png post-7301-0-84529200-1457260612_thumb.png

 

Story: Small village in Bosnian mountains is attacked by hord of hungry wolves. Your 5 heroes must defend your people by stopping wolves eating them. When five of them reach your village, people are doomed and game is over.

 

Controls: 5 - left, 6 - down, 7 - up, 8 - right

 

I tried to make game close to the original, but making some changes, for example, in sounds which are not the same. I also added title music, which is actually a code excerpt from De re Atari book.
// Wolves
// Ported from the book Mirko tipka na radirko
// Original author: Primoz Petrlin
// Original game written for ZX Spectrum in Sinclair BASIC
// Ported to Atari XL/XE/400/800 in Mad Pascal: Bostjan Gorisek 2016

uses
  graph, crt, sysutils;

var
  topMem : word;
  CHBAS : byte absolute $2F4;
  RAMTOP : byte absolute $6A;  
  playerName : string[15] = 'M.M';
  playerScore : shortInt = 10;
  score, lives,
  a, b,          // Our hero's coordinates
  s, d  : byte;  // Wolf coordinates  
  isNewGame : boolean = true;
  
  // Data for new characters
  _grave : array[0..6] of byte = (
    %01111100, %10000010, %10000010, %10000010, %10000010, %01010100, %11111110);  // character g
  _hero02 : array[0..7] of byte = (
    %00011100, %00101010, %00010100, %00001000, %00111111, %01001000, %00010100, %00110110);  // character c
  _dead_wolf : array[0..7] of byte = (
    %00010000, %00010000, %11111110, %00010000, %00010000, %00010000, %00010000, %00010000);  // character j
  _hero : array[0..7] of byte = (
    %00011100, %00101010, %10010100, %01001001, %00111110, %00001000, %00010100, %00110110);  // character p
  _weapon : array[0..7] of byte = (
    0, %01100000, %01100000, %01000000, %11000000, %01000000, %01000000, 0);  // character o
  _wolf : array[0..6] of byte = (
    0, %00100000, %11100010, %01111100, %00111100, %00100100, %00100100);  // character d
  _tree : array[0..7] of byte = (
    0, %00011100, %00111110, %01111111, %00111110, %00010100, %00010100, 0);  // character h

// Custom write routines
procedure PrintAt(x, y : byte; text : string); overload; begin GotoXY(x+1, y+1); Write(text); end;
procedure PrintAt(x, y : byte; text : char); overload; begin GotoXY(x+1, y+1); Write(text); end;

// New game?
function NewGame : boolean;
var
  ch : char;
begin
  if KeyPressed then ReadKey;
  Writeln(#$9b#$9b'ANOTHER GAME? (Y/N)');
  isNewGame := false;
  ch := #255;
  repeat
    if KeyPressed then begin
      ch := UpCase(ReadKey);
      isNewGame := (ch = 'Y');
    end;
  until (ch = 'Y') or (ch = 'N');

  result := isNewGame;
end;

// High score code block 
function HighScore : boolean;
var
  i, j : byte;
begin  
  Poke($D201, 168);
  for i:=200 downTo 100 do begin
    Poke($D200, i); Delay(10);
  end;
  ClrScr;
  for j:=1 to 10 do begin
    PrintAt(18, 16, 'HURA!'); PrintAt(18, 6, 'HURA!');
    PrintAt(20, 11, 'P');
    Delay(40);
    Poke($D200, 90);
    ClrScr;
    PrintAt(20, 11, 'c');
    Delay(40);
    Poke($D200, 154);
    for i:=6 to 16 do begin
      PrintAt(11, i, 'HURA'); PrintAt(26, i, 'HURA');
    end;
  end;  
  for i:=255 downTo 60 do begin
    Poke($D200, i); Delay(10);
  end;
  FillChar(Pointer($D200), 2, 0);
  Delay(40); ClrScr; CursorOn;
  if KeyPressed then ReadKey;
  Writeln('YOU REACHED HIGH SCORE!'#$9b'ENTER YOUR NAME:');
  ReadLn(playerName);
  CursorOff;
  playerScore := score;
  result := NewGame;
end;

// Game is on
procedure Game;
var
  y, x, z, n, m : byte;
  ch : char;  
begin
  FillChar(Pointer($D200), 8, 0);
  ClrScr;
  PrintAt(1, 0, 'ppppp');
  score := 0;  // Initialize score
  lives := 5;  // You have 5 lives  
  Randomize;
  
  // Draw trees on random locations
  for y := 1 to 38 do begin
    z := Random(22);
    x := Random(38);
    PrintAt(x, z+1, 'h');
  end;
  // Row of trees
  for y := 0 to 22 do PrintAt(38, y, 'h');

  // Hero position
  a := 11; b := 11;

  // Wolf coordinates
  d := 36; s := Random(22) + 1;

  // Game play loop  
  repeat
    PrintAt(b, a, 'po');  // Hero position

    // Keep track of hero deaths
    if lives < 5 then
      PrintAt(lives+1, 0, ' g');
    
    PrintAt(d, s, 'd');  // Draw attacking wolf
          
    Dec(d);
    //if d = 0 then Continue;
    // Wolf reached your village 
    if d = 0 then begin
      PrintAt(d+2, s, ' '); PrintAt(d, s, ' ');
      Dec(lives);
      d := 36; s := Random(22) + 1;
      if lives = 0 then begin
        break;
      end;
    end;
        
    PrintAt(d+2, s, ' ');

    // Hero control
    if KeyPressed then begin
      ch := UpCase(ReadKey);
      case ch of
        '8': begin
          Inc(b); 
          if b = 37 then b := 36;
          PrintAt(b-1, a, '  ');
        end;
        '5': begin
          Dec(b);
          if b = 1 then b := 2;
          PrintAt(b+1, a, '  ');
        end;
        '6': begin
          Inc(a);
          if a = 23 then a := 22;
          PrintAt(b, a-1, '  ');
        end;
        '7': begin
          Dec(a);
          if a = 0 then a := 1;
          PrintAt(b, a+1, '  ');
        end;
      end;
    end;
    
    // You hit a wolf
    if (a = s) and (b = d) then begin
      // beep beep
      PrintAt(d, a, ' ');
      Poke($D201, 168);
      for m := 1 to 50 do begin
        for n:=40 to 100 do Poke($D200, n);
      end;
      Poke($D200, 0);  Poke($D201, 0);
      d := 36; s := Random(22) + 1;
      Inc(score);
      GotoXY(30, 1); Write('DEAD=', score);
      PrintAt(b+2, a, 'j');
    end;
    
    Delay(75);
  until lives = 0;
  
  ClrScr;
  if score <= playerScore then begin
    PrintAt(1, 11, 'VILLAGE PEOPLE ARE DEAD.'#$9b'YOU KILLED ');
    Write(IntToStr(score), ' WOLVES!');
    NewGame;
    //if not NewGame then Halt(0);
  end else begin
    // If you break new record...
    HighScore;
  end;
end;

begin
  // Set display mode, colors and left margin
  InitGraph(0); CursorOff;
  Poke(710, 34); Poke(709, 30); Poke(82, 1);
  //Poke($D201, 168);  // sound channel 0 volume and distortion

  // Prepare new character set
  topMem := RAMTOP - 8;
  topMem := topMem * 256;
  CHBAS := topMem div 256;  
  move(pointer(57344), pointer(topMem), 1023);
  
  // Redefine characters for the game
  move(_grave, pointer(topMem+103*, sizeOf(_grave));          // g
  move(_hero02, pointer(topMem+99*, sizeOf(_hero02));         // c
  move(_dead_wolf, pointer(topMem+106*, sizeOf(_dead_wolf));  // j
  move(_hero, pointer(topMem+112*, sizeOf(_hero));            // p
  move(_weapon, pointer(topMem+111*, sizeOf(_weapon));        // o
  move(_wolf, pointer(topMem+100*, sizeOf(_wolf));            // d
  move(_tree, pointer(topMem+104*, sizeOf(_tree));            // h

  // Title screen
  Writeln(#$9b'           ddd WOLVES ddd' +
          #$9b#$9b'SMALL VILLAGE IN BOSNIAN MOUNTAINS IS' +
          #$9b'ATTACKED BY HORD OF HUNGRY WOLVES.' +
          #$9b'YOU MUST DEFEND YOUR PEOPLE BY STOPPING' +
              'WOLVES BY ANY COST.' +
          #$9b#$9b'                  po'#$9b +
          #$9b'WHEN FIVE OF THEM REACH THE VILLAGE,' +
          #$9b'PEOPLE ARE EATEN AND GAME IS OVER.');

  // Some title music
  // Taken from the book De Re Atari
  Poke(53768, 24); Poke( 53761, 168); Poke( 53763, 168); Poke( 53765, 168);
  Poke(53767, 168); Poke( 53760, 240); Poke( 53764, 252); Poke( 53762, 28);
  Poke(53766, 49);

  // Main game loop
  repeat
    // Best score information
    Writeln(#$9b'BEST SCORE ', playerScore, ' HOLDS ', playerName);
    Writeln(#$9b#$9b'PRESS ANY KEY...');
    repeat until keypressed;
    // Game
    Game;
  until not isNewGame;
end.

ZX Spectrum type-in listing in Sinclair BASIC (Mirko Tipka Na Radirko):

Page 1

Page 2

wolves.xex

wolves.zip

Edited by Gury
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Another conversion from the book Mirko tipka na radirko, a story about kangaroo in game called Stupid Kangaroo. You are a kangaroo, who was captured by crazy evil king. The king decided to test your intelligence and psychical abilities hoping to break you, because he thinks you are stupid. He was way too WRONG :)

 

You control your hero kangaroo with joystick (left / right). He jumps all the time, so you don't have to jump yourself with joystick button. Your goal is to reach each level by finding red brick, which brings you one point and open door for the next level. Each new level brings you additional points. When you finish all four levels, you come back to first level, but with a surprising twist :)

 

You start with 3 lives and additional life when you finish all 4 levels.

 

post-7301-0-25737000-1459017455_thumb.png post-7301-0-03129200-1459017464_thumb.png

 

In Mad Pascal code, don't be confused with coordinate system of PrintAt and Screen routines, because they simulate Sinclair BASIC way of handling coordinate system (y axis first, x axis second). I put these routine in special unit for easier handling of Sinclair BASIC commands.

 

Attached below are source code and binary files.

 

Enjoy the game!

Gury

 

ZX Spectrum type-in listing in Sinclair BASIC (Mirko Tipka Na Radirko):

Page 1 Page 2 Page 3

sk.zip

sk.xex

Edited by Gury
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Yet another conversion from the book Mirko tipka na radirko, now it is time for some action from the second world war. The game is titled Parachute, originally written by Bostjan Jerko. The game begins with flying plane over war zone on the ocean. Your mission is to land as many soldiers as you can in the middle of the island.

 

post-7301-0-96660100-1462015484_thumb.png post-7301-0-37752300-1462015492_thumb.png post-7301-0-87964600-1462016718_thumb.png

 

When your soldier jumps, it drops very quickly, so you must open your parachute before you land on the island. You control a soldier with joystick by pressing trigger button first time for jump and second time for opening the parachute. Later you open it, more score points you get. But be sure to do this before landing if you don't want to die. When your parachute opens, you can control soldier with joystick (left/right). After five jumps the plane moves lower, making jumping area lower and harder. When you succeed to land soldiers in some 5 jump waves, you progress to next wave (level), where plane moves faster and faster.

 

The game is written in Mad Pascal, version 1.3.1. You can download executable file and source code listing below.

 

Original ZX Spectrum game is written in Sinclair BASIC:

 

Page 1 Page 2 Page 3

Greetings,
Gury

parachute.zip

Parachute.xex

Edited by Gury
  • Like 3
Link to comment
Share on other sites

  • 1 year later...

Hello,

 

Here is another little game conversion from the book Mirko tipka na radirko, titled Formula 126PZ by Branislav Milosavljevic. In this game you control a car which must struggle through the scrolling screen with obstacles on the way. The car is shaking, but you will be comfortable with it very soon. The score increases as long as you manage not to crash.

 

post-7301-0-40263700-1497478833.png post-7301-0-40013400-1497478841.png post-7301-0-89023900-1497478848.png

Enjoy!
Gury

formula126pz.xex

formula126pz.zip

Edited by Gury
  • Like 6
Link to comment
Share on other sites

On the main section, under "More Games to Come..." people had been suggesting this game called "Klax" looks like another Tempest and Columns type game. I feel this will be perfect for the Mad Pascal People to make because it is not complicated and does not require heavy machine language to make this game run on the Atari 8-bit. In there I suggested something with GTIA mode 10 or Super IRG, but that will be the programmer to decide. I know we can do better with our Atari Computers.

 

https://www.youtube.com/watch?v=2cLb3g4IH4U

Edited by peteym5
Link to comment
Share on other sites

On the main section, under "More Games to Come..." people had been suggesting this game called "Klax" looks like another Tempest and Columns type game. I feel this will be perfect for the Mad Pascal People to make because it is not complicated and does not require heavy machine language to make this game run on the Atari 8-bit. In there I suggested something with GTIA mode 10 or Super IRG, but that will be the programmer to decide. I know we can do better with our Atari Computers.

 

https://www.youtube.com/watch?v=2cLb3g4IH4U

If you want to do Klax, please look at the Lynx version! Excellent graphics, digitised sounds.

Link to comment
Share on other sites

Another little conversion from the book Mirko tipka na radirko, now it is time for shooting the stars with the game called Hit Star. The goal is to shoot all stars at the top of the screen. You can do that with two space ships on the left and right side. Use your joystick to move left and right to trigger both ships. When ships collide, the missile is fired. Let's see how many shoots do you need to remove all the stars.

 

post-7301-0-12761400-1497769233.png post-7301-0-95308800-1497769240.png post-7301-0-35149900-1497769260.png post-7301-0-99413100-1497769305.png

 

Link to the source book

 

Greetings

hit_star.zip

hit_star.xex

Edited by Gury
  • Like 1
Link to comment
Share on other sites

Hello,

 

Today I represent you a game full of adrenalin. Why? Because you must save your planet from enemy attack from outer space. You have to bring four space ships to safe place to prepare them for a fight against the enemy. But, there is always a but... you must do this very quickly, because time is not your friend. Hurry up, hero, defend your planet.

 

post-7301-0-36954000-1498395046.png post-7301-0-69327400-1498395055.png post-7301-0-82988200-1498395063.pngpost-7301-0-88051400-1498395070.png post-7301-0-50247700-1498395079.png post-7301-0-72940100-1498395086.png

 

Enjoy!

Gury

 

galactica.xex

galactica.zip

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...