Jump to content
IGNORED

Mad Pascal examples


Gury

Recommended Posts

Posted (edited)

new unit CURVES

 

Procedure Curve (p1, p2, p3: TPoint; Segments: Byte); 
Procedure CubicBezierCurve (p1, p2, p3, p4: TPoint; Segments: Byte); 
Procedure Catmull_Rom_Spline (NumPoints: Byte; var Points: ArrayPoints; Segments: Byte);
Procedure BSpline (NumPoints: Byte; var Points: ArrayPoints; Segments: Byte);

 

curve_test.obx curve_test.pas

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

Can we get an example of how to use the banked ram option ? As in, load a small binary file to a 130 XE ram bank, and have some code that was loaded into main ram invoke a subroutine that resides in the code that was loaded into the bank. I've read the doc, but it's not clear how you actually define things correctly such that the mainline program can invoke a bank loaded subroutine.

Link to comment
Share on other sites

Posted (edited)

example 1: library loaded into RAM from disk (address $6000 in this example, library are not relocatable)

 

 xio(40,1,0,0,'D:TEST_LIB.OBX');    // load and run executable file

 

test_lib.pas -> Compile -> Assembly -> mads test_lib.a65 -hm -x -i:[madpascal\base]   // switch '-hm' is important for LIBRARY

test.pas -> Compile -> Assembly -> mads test.a65 -x -i:[madpascal\base]                    // in this case switch '-hm' is not relevant

create folder 'disk'

build.bat -> 'copy test_lib.obx disk' -> 'copy test.obx disk\autorun.' -> 'dir2atr.exe -md -B foxdos.obx disk.atr disk\' -> 'altirra64.exe disk.atr'

 

	function dodaj(a,b: integer): integer; external 'TEST_LIB';

define function 'dodaj' as external from library 'test_lib'

 

	w: integer external tmp 'test_lib';

define variable 'w' as external about alias 'tmp' from library 'test_lib', this allows you to redirect names occurring in the library to names occurring in the program

 

p.s.

https://www.freepascal.org/docs-html/prog/progse55.html

 

library_ram.zip

Edited by tebe
Link to comment
Share on other sites

Posted (edited)

example 2: library loaded as resource (DOSFILE)

 

test_lib 	DOSFILE 'test_lib.obx'

RCLABEL 'test_lib' is not relevant, is not considered

 

program test;

{$r test.rc}

uses crt;
	function dodaj(a,b: integer): integer; external 'TEST_LIB';
var
	w: integer external tmp 'test_lib';
begin
 w := dodaj(4512,23345);

 writeln(w);

 repeat until keypressed;
end.

 

library_ram_rc.zip

library_overload.zip

Edited by tebe
Link to comment
Share on other sites

Posted (edited)

example 3: library loaded to banked ram (resource LIBRARY)

 

lib0	library 'test_lib.obx'

 

program test;

{$r loadlib.rc}

uses crt, objects;

	function dodaj(a,b: integer): integer;  external 'TEST_LIB';

const
	lib0=3;      // PORTB BANKS = [0..xx]
var
	w: integer;  // variables are not available in libraries in banked memory
begin

 w := dodaj(4512,23345);

 writeln(W);

 repeat until keypressed;

end.

 

p.s.

https://github.com/tebe6502/Mad-Pascal

revised version of MP to make compilation for banked memory work

 

library_portb.zip

library_game.zip

Edited by tebe
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.

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...