Recent

Author Topic: Velthuis.Console.pas - Won't compile in Lazarus  (Read 3156 times)

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #15 on: May 26, 2024, 10:27:48 pm »
Still the same error. I'm on win7 x64.
https://i.postimg.cc/0NrQqqCj/Capture.png
To make velthuisconsole2.zip from Thaddy compile, here a tutorial:
1. download velthuisconsole2.zip
2. extract it in its own project folder
3. rename ConsoleDemo.dpr to ConsoleDemo.lpr
4. open lazarus "Project -> Close Project" if anything is opened
5. select "Open Project"
6. change filemask filter from "Lazarus Project (*.lpi)"  to "All Files (*.*)"
7. locate and doubleclick ConsoleDemo.lpr
8. select "Create Project" -> "Simple Program"
9. press F9 so the file "Velthuis.Console" gets opened
10. scroll to start of file "Velthuis.Console" and...
replace this
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5. {$ENDIF}
  6.  
with that
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5.   {$ASMMODE intel}
  6. {$ENDIF}
  7.  
and save project.

Does it compile and run?
I just quick tested as 64bit windows target with Lazarus 3.99 (rev main_3_99-2053-g3635aa3044) FPC 3.2.2 x86_64-win64-win32/win64

And please in future copy the error message and paste it in here instead of taking a screenshot and upload it not here.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 16132
  • Censorship about opinions does not belong here.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #16 on: May 27, 2024, 09:01:29 am »
@KodeZwerg
In mode delphi asmmode is already intel, because basm is intel. No need.
Indeed you can rename dpr to lpr, but I use Geany so I don't need that.
It does only contain 16 assembly for a hardware sound. I would simply remove that part of the code. I just left it in, but I think Rudy would not have mind if it is removed.
[edit] I found an older working version in which I had actually removed the 16 bit assembler.
Apart from that, the code was the same, though.
« Last Edit: May 27, 2024, 09:12:45 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #17 on: May 27, 2024, 10:01:29 am »
@KodeZwerg
In mode delphi asmmode is already intel, because basm is intel. No need.
If you say so but why does it not compile saying the register variables are undeclared and with "{$ASMMODE intel}" they are defined so I can compile, a bug found?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 16132
  • Censorship about opinions does not belong here.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #18 on: May 27, 2024, 10:18:10 am »
For {$mode delphi} the asm mode should be intel, because of the basm syntax being Intel style. intel. If it isn't it, is a bug.
« Last Edit: May 27, 2024, 10:20:52 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Atak_Snajpera

  • New Member
  • *
  • Posts: 31
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #19 on: May 28, 2024, 11:56:08 am »
Still the same error. I'm on win7 x64.
https://i.postimg.cc/0NrQqqCj/Capture.png
To make velthuisconsole2.zip from Thaddy compile, here a tutorial:
1. download velthuisconsole2.zip
2. extract it in its own project folder
3. rename ConsoleDemo.dpr to ConsoleDemo.lpr
4. open lazarus "Project -> Close Project" if anything is opened
5. select "Open Project"
6. change filemask filter from "Lazarus Project (*.lpi)"  to "All Files (*.*)"
7. locate and doubleclick ConsoleDemo.lpr
8. select "Create Project" -> "Simple Program"
9. press F9 so the file "Velthuis.Console" gets opened
10. scroll to start of file "Velthuis.Console" and...
replace this
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5. {$ENDIF}
  6.  
with that
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5.   {$ASMMODE intel}
  6. {$ENDIF}
  7.  
and save project.

Does it compile and run?
I just quick tested as 64bit windows target with Lazarus 3.99 (rev main_3_99-2053-g3635aa3044) FPC 3.2.2 x86_64-win64-win32/win64

And please in future copy the error message and paste it in here instead of taking a screenshot and upload it not here.
Thank you for all your help! Now everything works fine.

Thaddy

  • Hero Member
  • *****
  • Posts: 16132
  • Censorship about opinions does not belong here.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #20 on: May 28, 2024, 04:57:16 pm »
Glad to be of help. It is a nice piece of code from Rudy. Most of his code is still on-line. There are more gems.
If I smell bad code it usually is bad code and that includes my own code.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11919
  • FPC developer.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #21 on: May 28, 2024, 05:31:42 pm »
Except that I warned him (and Jedi) already in 2002-2003 to not use delphi versions directly as a condition in sources.  http://www.stack.nl/~marcov/porting.pdf

Thaddy

  • Hero Member
  • *****
  • Posts: 16132
  • Censorship about opinions does not belong here.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #22 on: May 29, 2024, 07:12:18 am »
Well, that's why I spoof the Delphi version to what is usually compatible with fpc. Saves a lot of work.
You may want to revise your porting.pdf, though: although helpful it is out of date at some points.
Has always been helpful, though.
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018