Jump to content

Mad Pascal

Recommended Posts

5 hours ago, Gury said:

Variables using Type declaration


I found a strange behaviour when using type variable (array of type). Let's explain...


I increment a type variable element by some value:


monster[0].x := monster[0].x + 2;


This code runs ok.


But using a procedure, which consists of incrementing such variable, doesn't work correctly.

The example works when commenting (remarking) the call to MoveMonster at the end of listing example.


This is modified example from Mad Pascal repository:

uses crt;

	monsters = packed record
   	  x: byte ;
	  a: cardinal;
	  y: byte;

	monster: array [0..3] of ^monsters;
	i: byte;

procedure MoveMonster(p : byte);
  monster[p].x := monster[p].x + 2;

  for i:=0 to High(monster) do begin
    GetMem(monster[i], sizeof(monsters));

    monster[i].x := i;
    monster[i].a := $ffffffff;
    monster[i].y := i * 2;

  for i:=0 to High(monster) do
    writeln(monster[i].x,',', monster[i].y);

  // Let's move first monster
  writeln('Let''s move first monster');
//  monster[0].x := 2;
  monster[0].x := monster[0].x + 2;
  writeln(monster[0].x,',', monster[0].y);

  writeln(monster[0].x,',', monster[0].y);

  repeat until keypressed;



bug fixed, https://github.com/tebe6502/Mad-Pascal  (master branch)


Edited by tebe
  • Thanks 2
Link to comment
Share on other sites

Github, master branch


new feature, variable as REGISTER (utilized zero page, 16 bytes)



 a: byte register;
 b: word register;


be careful, the compiler also uses these areas (Fillchar, Fillbyte, Move)


Edited by tebe
  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...
Link to comment
Share on other sites

Wow, this is the first time I see the new github style documentation. That is really awesome and good to read! The support for the players and modules as resource is also great.

I tried to click the "edit on github" button to report a minor fix: "null side" instead of "zero page". But the link results in "404 - https://github.com/tebe6502/Mad-Pascal/edit/master/docs/map.md".
Might of course be due to not being part of the repo... 

Link to comment
Share on other sites


i'd like to create an array of records, like this:


    tNPC =  record ai,x,y,z: array [0..2] of byte;
                           t: array [0..3] of byte;
                           person: byte;
                           dialog: byte

    npc: array [0..7] of tNPC;


which MP says it does not support:


Mad Pascal Compiler version 1.6.6 [2021/09/19] for 6502
Compiling City.pas
City.pas (33,25) Error: Only Array [0..2] of ^RECORD supported

maybe i'm missing something basic in pascal; but i couldn't figure out yet how to create an alternative datastructure that would be as easy to access and manipulate like with the example above ? ( like:  write(npc[0].x[1]); )


--> sorry: yes, i missed something basic: question solved by reading this very thread:


-->  npc: array [0..2] of ^tNPC;

just that nested arrays of records don't seem to be accessible?


write(npc[0].person);  -> ok

write(npc[0].x[0]);      -> Error: Can't read or write variables of this type


Edited by Atlan_Roland
question rephrased.
Link to comment
Share on other sites

  • 3 weeks later...
17 hours ago, tebe said:


hmm, just tried the example for for/in/do with your latest github master branch mp.exe.  is the code not in yet?

program for_in_do;
    days : array [0..6] of string =
    ('poniedzialek', 'wtorek', 'sroda' ,'czwartek', 'piatek', 'sobota', 'niedziela');
    a: string;

	for a in days do 

Mad Pascal Compiler version 1.6.6 [2021/10/08] for 6502
Compiling pathfinder.pas
pathfinder.pas (8,6) Error: Ordinal variable expected as 'FOR' loop counter

Link to comment
Share on other sites

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.

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.

  • Recently Browsing   0 members

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