Jump to content

Recommended Posts

 

On 5/20/2023 at 2:53 AM, danwinslow said:

Ah. Ok, thanks. The guy asking about it seemed to have some expectation of it working that way, so I kind of thought it was supposed to. Maybe it's kind of a language hole, and only works in variants that MadPascal is not implementing.

Yes, I assumed that local variables are initialized every time you call a function, but it seems local variables in (Mad) Pascal act more like static local variables in C language.  

 

I like Mad Pascal. It makes me more productive.

  • Like 4
  • Thanks 1
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5260944
Share on other sites

  • 2 months later...

Hi Tebe,

thank you very much for the compiler update! Woke me up to restart some A8 coding after summer break :)

 

Recompiling my project with 1.6.8 gave me an error with "mod", which did not happen under 1.6.6.

It looks like a 'mod 16' (or 2,4,8,..) produces a 'jsr #$00' .

 

 

line 1288: textline[13]:=chr(33+w1 mod 16); 

--> 

RTLIB: $22AB..$29D3
        jsr #$00
BRIT.a65 (12562) ERROR: Illegal addressing mode (CPU 6502)

 

The corresponding code in .a65 @ line 12562:

; optimize OK (BRIT.PAS), line = 1288

    lda GLOBALS.W1
    and #$0F
    jsr #$00
    lda #$21
    add @BYTE.MOD.RESULT
    sta adr.TEXTLINE+$0D

 

for context: 

 [..]
    'u' : begin           // Use sextant
        textline:='Use-sextant'~;
        write_text;

        if night < 50 then begin
            xms_textline(103); // Only     
            xms_textline(105); // at night!     
        end else begin
            xms_textline(101); // Position: Y"y' X"x'
            w1:=byte(my*16)+ay_m;
            w2:=byte(mx*16)+ax_m;
            textline[11]:=chr(33+w1 div 16);
            textline[13]:=chr(33+w1 mod 16); //rogi@2023.08.17: new compiler error??
            textline[16]:=chr(33+w2 div 16);
            //textline[18]:=chr(33+w2 mod 16); rogi@2023.08.17: new compiler error??
        end;
     end;
 [..]

 

Edited by Atlan_Roland
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5300070
Share on other sites

MP newest version, new features

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

- improved memory allocation for arrays [0..0], 'ABSOLUTE $0000' is enforced initially, 1 byte of memory is saved
- added possibility to declare arrays without specifying their size, e.g.:

 tab: array of byte = [1,3,4,3,1];
 tb: array of char = 'abcdefghij';

- new compiler directive {$bin2csv filename} allows you to initialize arrays e.g.:

 tb: array of byte = [ {$bin2csv filename} ];

 

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/a8/bin2csv

  • Like 3
  • Thanks 1
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5302119
Share on other sites

Hi Tebe,
 

in MP 1.6.8+, the usage of a pstring variable as parameter to unzx0() does not work anymore.

(compiles, but the unzx0ed datastream seems to get written unpredictably into memory, at least not in the specified target adress).

 

The same workes fine with MP1.6.6 though.

 

Has there been any change in usage of pstring that i'm missing?

 

Attached the .a65 outputs of MP 1.6.6 and MP 1.6.8 of given code below. If you should need more data tell me.


Thank you for all your efforts with mp! 👍

 

program test_mp_1_6_8;
uses crt,zx0;

const
	IMPORT   = $5000;	  

var
	i		: byte;
	fname		: pstring;
begin

fname:='D:RESOURCE.ZX0';
unzx0(fname, pointer(IMPORT));  		// was fine MP 1.6.6, but not anymore in MP 1.6.8 ?
//unzx0('D:RESOURCE.ZX0', pointer(IMPORT));	// to verify, works fine if the filestring is given directly.
 
gotoxy(1,1);
for i:=0 to 39 do
	write(chr(peek(IMPORT+i)));

repeat until false;

end.

 

 

testcode_mp_1.6.6.a65 testcode_mp_1.6.9.a65

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5303405
Share on other sites

On 8/21/2023 at 11:37 PM, tebe said:
- improved memory allocation for arrays [0..0], 'ABSOLUTE $0000' is enforced initially, 1 byte of memory is saved
- added possibility to declare arrays without specifying their size, e.g.:

 tab: array of byte = [1,3,4,3,1];
 tb: array of char = 'abcdefghij';

- new compiler directive {$bin2csv filename} allows you to initialize arrays e.g.:

 tb: array of byte = [ {$bin2csv filename} ];

 

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/a8/bin2csv

I'm a bit confused about the name "$bin2csv". I'd expect CSV means "Comma Separated Values", so read a "1,2,3" text file. But this looks like a "bin2bytearray," e.g. INS in MADS. ?!

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5305206
Share on other sites

On 8/26/2023 at 11:15 PM, tebe said:

https://github.com/t-edson/P65Pas

 

Tokenizer sees this as "Comma Separated Values."

I see, this this is actually a compile-time expression that resolves into source; not a binary include directive.

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5305833
Share on other sites

  • 1 month later...

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

 

new directive {$optimization LOOPUNROLL}, {$optimization NOLOOPUNROLL}, works only with FOR with const parameters

 

{$optimization LOOPUNROLL}

 for a:='a' to 'd' do writeln(a);

{$optimization NOLOOPUNROLL}

 

Edited by tebe
  • Like 4
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5327575
Share on other sites

@tebe

 

When looking into the loading of Arcadia here:


There seemed to be issues:
1) The mechanism works with a hard-OS but left the NMIEN as $C0
2) With a soft-OS the code is never entered and so the NMIEN remains as the OS set it, $40
3) The game itself never loads & copies blocks under the OS and so call/PORTB flip is not required.
 

So with 2) the fault appears to lay with the game not asserting NMIEN should be $C0, rather than the framework?

 

With 3, could the compiler detect RAM under OS is not used (during loading) and so flip to off/on entry points to RTS?

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5328198
Share on other sites

  • 2 weeks later...

MP 1.6.9

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

 

- improved memory allocation for arrays [0..0], 'ABSOLUTE $0000' is enforced initially, 1 byte of memory is saved
- added possibility to declare arrays without specifying their size, e.g.:

var tab: array of byte = [1,3,4,3,1];
var tb: array of char = 'abcdefghij';

- new compiler directive {$bin2csv filename} allows you to initialize arrays e.g.:

var tb: array of byte = [ {$bin2csv filename} ];

- new compiler directive {$optimization loopunroll}, {$optimization noloopunroll}, performs FOR loop unrolling with fixed parameters
- new BLOWFISH module allowing to encrypt, decrypt character strings according to specified key
- new example a8\AES-Rijndeal

 

new samples (AES-Rijndeal, Blowfish)

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/a8/math/AES-Rijndael

 

https://github.com/tebe6502/Mad-Pascal/blob/master/lib/blowfish.pas

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/common/math/blowfish

 

blowfish_test.obx

  • Like 4
  • Thanks 1
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5332053
Share on other sites

21 hours ago, tebe said:

MP 1.6.9

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

 

- improved memory allocation for arrays [0..0], 'ABSOLUTE $0000' is enforced initially, 1 byte of memory is saved
- added possibility to declare arrays without specifying their size, e.g.:

var tab: array of byte = [1,3,4,3,1];
var tb: array of char = 'abcdefghij';

- new compiler directive {$bin2csv filename} allows you to initialize arrays e.g.:

var tb: array of byte = [ {$bin2csv filename} ];

- new compiler directive {$optimization loopunroll}, {$optimization noloopunroll}, performs FOR loop unrolling with fixed parameters
- new BLOWFISH module allowing to encrypt, decrypt character strings according to specified key
- new example a8\AES-Rijndeal

 

new samples (AES-Rijndeal, Blowfish)

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/a8/math/AES-Rijndael

 

https://github.com/tebe6502/Mad-Pascal/blob/master/lib/blowfish.pas

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/common/math/blowfish

 

blowfish_test.obx 7.75 kB · 2 downloads

 

Question:

 

String handling seems to have changed again.

This example worked in MP v1.6.8+:

var 
 fname		: string[14]				absolute NPC_ARRAY + 64+6+7+16+1+1; // fname: "D:X#.ZX0"  --> todo: reduce to [8] 					 
[..]
fname:='D:UA.ZX0'; 						//Initialize fname (D:**.ZX0) and set to Atascii  font file. 
unzx0(fname,pointer(FONT)); 			//load font before text is displayed

 

Now with 1.6.9 it throws:

Mad Pascal Compiler version 1.6.9 [2023/10/13] for 6502
Compiling U_LOADER.PAS
U_LOADER.PAS (537,8) Error: Incompatible types: got "STRING" expected "POINTER"
 

Ok, changing it to:

unzx0(pointer(fname),pointer(FONT));

 

compiles, but crashes at running.

 

--> What would be the correct syntax/data structure now?

 

 

Edited by Atlan_Roland
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5332417
Share on other sites

https://github.com/tebe6502/Mad-Pascal/tree/master/samples/a8/compression

 

https://github.com/tebe6502/Mad-Pascal/blob/master/lib/zx0.pas

 

interface

	procedure unZX0(inputPointer, outputPointer: pointer); assembler; register; overload;
	procedure unZX0(fnam: PString; outputPointer: pointer; a: byte); register; overload;

 

  • Thanks 1
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5332579
Share on other sites

42 minutes ago, Atlan_Roland said:

missed the new "a:byte" parameter for stream loading.. (is that used for anything?)

Without this additional parameter, it will not be possible to distinguish between the calls of these two variants of the UNZX0 procedure

 

	procedure unZX0(inputPointer, outputPointer: pointer); assembler; register; overload;
	procedure unZX0(fnam: PString; outputPointer: pointer); register; overload;

 

Error: Can't determine which overloaded function 'UNZX0' to call

 

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5333022
Share on other sites

procedure unZX0(fnam: PString; outputPointer: pointer; a: byte); register; overload;

 

this was probably supposed to be a temporary procedure until I corrected it, but I forgot

 

it has now been fixed

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

 

procedure unZX0(fnam: PString; outputPointer: pointer); register; overload;

https://github.com/tebe6502/Mad-Pascal/blob/master/lib/zx0.pas

 

  • Thanks 2
Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5333542
Share on other sites

31 minutes ago, tebe said:
procedure unZX0(fnam: PString; outputPointer: pointer; a: byte); register; overload;

 

this was probably supposed to be a temporary procedure until I corrected it, but I forgot

 

it has now been fixed

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

 

procedure unZX0(fnam: PString; outputPointer: pointer); register; overload;

https://github.com/tebe6502/Mad-Pascal/blob/master/lib/zx0.pas

 

wow, you are the best - and you are fast! :)

 

though just tested it with main branch (1.7.0)  and with 1.6.9 with the new zx0.pas lib; but seems not to work here in my constellation though - the compiler seems to choose the inputPointer version. That is probably because I used it like the example below, pointing to a file-string. The version with the indicator byte was a good decision then 😄

var
    fname        : string[14];
begin
    [..]
    fname:='D:QSTON.ZX0';
    unzx0(@fname,pointer(QuickMusic_Song)); 

 

 

By the way, i see that the compiler output in the 1.7.0 branch is listening procedures.. maybe this is some preliminary testing for the ORIGIN proposal ? 😆https://github.com/tebe6502/Mad-Pascal/issues/119 

(that would really be an cool feature, saving me enormous amout of RAM, as i would use it as some kind of 'overlay' function.)

 

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5333573
Share on other sites

Sorry, Tebe, i didn't check the paramters!

your new unzx0() stream overload works perfectly of course!

 

Like you stated in your example code:

https://github.com/tebe6502/Mad-Pascal/blob/master/samples/a8/compression/unzx0_stream.pas

fn:='D:KORONIS.ZX0';
unZX0(fn, pointer(dpeek(88)) );

 

 

 

so to correct my code sample from above

var
	fname        : string[14];

begin
    [..]
    fname:='D:QSTON.ZX0';
    unzx0(fname,pointer(QuickMusic_Song));

 

 

 

 

Link to comment
https://forums.atariage.com/topic/240919-mad-pascal/page/33/#findComment-5333719
Share on other sites

  • 4 weeks later...
  • 2 weeks 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...