Jump to content
IGNORED

Mad Pascal


Recommended Posts

Old Good Sieve: 1899 10x (less is better) on emulator

mad pascal : 607 frames
cc65       : 614 frames
vbcc       : 636 frames
 vc +atari -O3 -speed sieve.c -o sieve-vbcc.xex -c99
cl65 -t atari -Osir -Cl --add-source -o sieve-cc65.xex sieve.c

sieve-vbcc.png

sieve-vbcc.xex sieve.c

 

sieve-cc65.png

sieve-cc65.xex

 

sieve-mp.png

sieve-mp.xex sieve.pas

Edited by zbyti
add mad pascal
Link to comment
Share on other sites

1 hour ago, zbyti said:

Old Good Sieve: 1899 10x (less is better) on emulator


mad pascal : 607 frames
cc65       : 614 frames
vbcc       : 636 frames

 

-O3 does not seem to work too well with this test. -O gives better results.

 

Also, when compiling with vbcc, did you notice this warning?

>  stop_ticks ==- start_ticks;
warning 153 in line 41 of "sieve.c": statement has no effect

Replacing it with stop_ticks -= start_ticks; and using those options

cl65 -t atari -Oisr -Cl sieve.c -o sieve-cc65.xex
vc +atari -O -speed sieve.c -c99 -o sieve-vbcc.xex

I get:

mad pascal : 607
cc65       : 601
vbcc       : 589

 

sieve-vbcc.xex sieve-cc65.xex sieve.c

  • Like 1
Link to comment
Share on other sites

@vbc

 

It's ashamed to admit it, but I missed this warning, I changed it at the end and confused it with the printf warning. I've been programming too much in Action! on A8 last days where it is correct :D 

 

I need to study the compiler flags closely ;) - perfect result, congratulations! 

Edited by zbyti
last days
Link to comment
Share on other sites

  • 1 month later...

I was just curious ;)

program GrandTheftAntic;

uses crt, graph;

var
  i        : byte absolute $d8;
  scores   : array[0..16] of word absolute $da;
  rtclok   : byte absolute $14;
  sdmct    : word absolute $22f;
  x        : single;
  
begin
  for i := 0 to 15 do begin
    InitGraph(i + 16);
    Pause; rtclok := 0;
    while rtclok < 100 do
      Inc(scores[i]);
  end;

  sdmct := 0; i := 16; Pause; rtclok := 0;
  while rtclok < 100 do
    Inc(scores[i]);
  sdmct := $22; InitGraph(0);

  for i := 0 to 15 do begin
    x := (100 * scores[i]) / scores[16];
    writeln(scores[i], ' GR.', i, ' ', x, '%');
  end;
  writeln(scores[16], ' ANTIC OFF');

  ReadKey;
end.

 

GrandTheftAntic.png.d3e13b73469eb236104c72cb7f57bc38.png

 

516319427_GRModes.thumb.png.d2c2de6da311366d64f148a1b252445f.png

 

GrandTheftAntic.pas GrandTheftAntic.xex

Edited by zbyti
scores with %
  • Like 3
Link to comment
Share on other sites

#!/bin/bash

mp="$HOME/Programs/MadPascal/mp"
mads="$HOME/Programs/mads/mads"
base="$HOME/Programs/MadPascal/base"

if [ -z "$1" ]; then
  echo -e "\nPlease call '$0 <argument>' to run this command!\n"
  exit 1
fi

$mp $1 -t c64 -z 10 -o
name=${1::-4}

if [ -f $name.a65 ]; then
  [ ! -d "output" ] && mkdir output
  mv $name.a65 output/
  $mads output/$name.a65 -x -i:$base -o:output/$name.prg
else
  exit 1
fi

if [ ! -z "$2" ]; then
  x64 output/$name.prg
fi
program Multiplatformity;

begin
  {$ifdef c64}
  writeln('YO C64!');
  {$else}
  writeln('YO ATARI!!');
  {$endif}
  while true do;
end.

Screenshot_2020-09-22_09-58-48.thumb.png.76e4f593d913887bdba12b7a37b1f1d4.png

  • Like 1
Link to comment
Share on other sites

For those who like Atari CPU supremacy ;)

program YoshBenchPlus;

var
{$ifdef c64} 
  i : word absolute $70;
  a : word absolute $72;
  b : word absolute $74;
  clock : byte absolute $a2;
{$else}
  i : word absolute $e0;
  a : word absolute $e2;
  b : word absolute $e4;
  clock : byte absolute $14;
{$endif}

procedure vbsync;
var tmp: byte;
begin
  tmp := clock;
  while clock = tmp do;
end;

begin
  i:=0; a:=0; b:=0;
  vbsync; clock := 0;

  while clock < 100 do begin
    Inc(a); b := a;
    Inc(b); a := b;
    Inc(i);
  end;

  writeln('YOSHPLUS - ITERATIONS IN 100 FRAMES.');
  {$ifdef c64}   
  writeln('MAD PASCAL 1.6.4 ON C64');
  {$else}
  writeln('MAD PASCAL 1.6.4 ON ATARI 800XL');
  {$endif}
  writeln('COUNTER = ', i);
  while true do;
end.

Screenshot_2020-09-23_10-28-50.thumb.png.dabebd62fa6876b5bb764f5441560a07.pngScreenshot_2020-09-23_10-30-21.thumb.png.2a2c4865360b3532180f7347a62bc21d.png

 

YoshBenchPlus.xex YoshBenchPlus.prg YoshBenchPlus.pas

Edited by zbyti
change zp
  • Like 1
Link to comment
Share on other sites

// Eratosthenes Sieve benchmark 1899

const
 size = 8192;
 iter_max = 10;

var
  flags: array [0..size] of boolean;

  iter: byte;
  ticks: word = 0;

{$ifdef c64}
  i: word absolute $70;
  k: word absolute $72;
  prime: word absolute $74;
  count: word absolute $76;
  clock1 : byte absolute $a1;
  clock2 : byte absolute $a2;
{$else}
  i: word absolute $e0;
  k: word absolute $e2;
  prime: word absolute $e4;
  count: word absolute $e6;
  clock1 : byte absolute $13;
  clock2 : byte absolute $14;
{$endif}

procedure vbsync;
var tmp: byte;
begin
  tmp := clock2;
  while clock2 = tmp do;
end;

begin

  writeln(iter_max,' ITERATIONS');
  vbsync; clock2 := 0; clock1 := 0;

  for iter := iter_max-1 downto 0 do begin

    fillchar(flags, sizeof(flags), true);

    count := 0;

    for i:=0 to size do
      if flags[i] then begin

        prime := i*2 + 3;
        k := prime + i;

        while (k <= size) do begin
          flags[k] := false;
          inc(k, prime);
        end;
        inc(count);
      end;
  end;

 ticks := clock2 + (clock1 * 256);

 writeln(ticks, ' TICKS');
 writeln(count, ' PRIMES');

 while true do;

end.

Screenshot_2020-09-23_11-15-23.thumb.png.ae3c898ab319578b60b650359e278f92.pngScreenshot_2020-09-23_11-16-05.thumb.png.9f05e333654e3a96225868ecd756d87b.png

 

sieve.pas sieve.xex sieve.prg

  • Like 1
Link to comment
Share on other sites

program MonteCarloPi;

const
  probe = 10000;
  r = 127 * 127;

var
{$ifdef c64}
  stop      : word absolute $70;
  i         : word absolute $70;
  x         : word absolute $74;
  y         : word absolute $76;
  bingo     : word absolute $78;
  foundPi   : word absolute $7a;
  n         : byte absolute $7c;
  clock1    : byte absolute $a1;
  clock2    : byte absolute $a2;
  rndNumber : byte absolute $d41b;  
{$else}
  stop      : word absolute $e0;
  i         : word absolute $e0;
  x         : word absolute $e4;
  y         : word absolute $e6;
  bingo     : word absolute $e8;
  foundPi   : word absolute $ea;
  n         : byte absolute $ec;
  clock1    : byte absolute $13;
  clock2    : byte absolute $14;
  rndNumber : byte absolute $d20a;  
{$endif}

procedure vbsync;
begin
  n := clock2;
  while clock2 = n do;
end;

{$ifdef c64}
//SID's Random Number Generator
procedure c64Randomize; assembler;
asm
{
  lda #$ff  ; maximum frequency value
  sta $D40E ; voice 3 frequency low byte
  sta $D40F ; voice 3 frequency high byte
  lda #$80  ; noise waveform, gate bit off
  sta $D412 ; voice 3 control register
};
end;
{$endif}

begin
  bingo := 0;

  {$ifdef c64}
  c64Randomize;
  {$endif}
  vbsync; clock2 := 0; clock1 := 0;
  
  for i := 1 to probe do begin
    n := rndNumber and 127; x := n * n;
    n := rndNumber and 127; y := n * n;
    if (x + y) <= r then Inc(bingo);
  end;
  
  foundPi := 4 * bingo;
  stop := (clock1 * 256) + clock2;
  
  writeln('PROBE SIZE ', probe);
  writeln('POINTS IN CIRCLE ', bingo);
  writeln('FOUND PI APPROXIMATION ', foundPi / probe);
  writeln('FRAMES COUNTER = ', stop);
  while true do;
end.

Screenshot_2020-09-23_11-48-48.thumb.png.2f20d196afc589374f1358cf2269ee07.pngScreenshot_2020-09-23_11-49-35.thumb.png.0fcf0da3a61706834c969e8e0d7260e3.png

 

MonteCarlo.xex MonteCarlo.prg MonteCarlo.pas

Edited by zbyti
add const
  • Like 1
Link to comment
Share on other sites

Pascal can do it too ;)

(*
* This is a part of Quatari 256B intro
* <https://demozoo.org/productions/280623>
*)
program Landscape;

var
  cursor_y : byte absolute $54;
  cursor_x : byte absolute $55;
  prev_y   : byte absolute $5a;
  prev_x   : byte absolute $5b;
  color4   : byte absolute $02c8;
  color    : byte absolute $02fb;
  rnd      : byte absolute $d20a;
  i        : byte absolute $e0;

  color_height: array[0..13] of byte = (
    170,150,144,144,122,122,110,110,94,94,86,86,82,80
  );

procedure openmode(m : byte); assembler;
asm {
  lda m
  jsr $ef9c
};
end;

procedure drawto; assembler;
asm {
  jsr $f9c2
};
end;

begin
  openmode(9); color4 := $b0;

  for i := 0 to 79 do begin
    cursor_x := i; prev_x := i;
    prev_y := 1; color := 13;

    while color <> $ff do begin
      cursor_y := color_height[color];

      if rnd < $80 then
        inc(color_height[color])
      else
        if rnd < $80 then dec(color_height[color]);

      drawto; dec(color);
    end;
  end;

  repeat until false;
end.

atari000.png.356612f5925b577297c45ab60636e15c.png

 

landscape.pas landscape.xex

 

Edited by zbyti
Doo Dah Day :]
Link to comment
Share on other sites

The bad thing about this program are the illegal system calls. I do realize that you used them to fit in 256 bytes, but straight assembler still can do better.

 

I have a lazy sunday so I sat and translated your program back to assembly (probably the most useless thing one could do considering that the original source probably can be found somewhere, but I was too lazy to search). Features:

 

1) open/close/draw using CIO

2) wait for a key at the end

3) switch to GR.0 before exiting

4) 162 bytes binary

5) VBXE version as a bonus (needs the "S2:" driver loaded)

6) sources included @tschak909

 

:)

land.arc

Edited by drac030
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Thanks. Now I understand the odd conditional you have used in Pascal. This:

	lda RANDOM
	bpl skip1
	iny 
skip1:
	lda RANDOM
	bpl skip2
	dey 	
skip2:		

I would understand rather as an equivalent to:

 if rnd >= $80 then inc(color_height[color]);
 if rnd >= $80 then dec(color_height[color]);

But I do not know Pascal, so...

 

Edited by drac030
corrected obvious mistake
  • Haha 1
Link to comment
Share on other sites

17 minutes ago, drac030 said:

Thanks. Now I understand the odd conditional you have used in Pascal. This:


	lda RANDOM
	bpl skip1
	iny 
skip1:
	lda RANDOM
	bpl skip2
	dey 	
skip2:		

I would understand rather as an equivalent to:


 if rnd >= $80 then inc(color_height[color]);
 if rnd >= $80 then dec(color_height[color]);

But I do not know Pascal, so...

 

Chmm... but:

if rnd < $80 then
  inc(color_height[color])
else
  if rnd < $80 then dec(color_height[color]);

in this case dec have less probability and terrain look not as flat ;) ?

Edited by zbyti
flat
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...