Recent

Author Topic: OLD code with machine specific instructions  (Read 13187 times)

Bart

  • Hero Member
  • *****
  • Posts: 5701
    • Bart en Mariska's Webstek
Re: OLD code with machine specific instructions
« Reply #15 on: July 12, 2021, 12:31:22 am »
In the old days of TP 6, there was a unit called win.
It came with a win.obj file, no source code.
It was very fast.
It was used by TurboVision framework IIRC.
I used it in all my DOS programs that had title and statusbars.

It had IIRC the following functions
  • FrameWin: single- or double frame a window, with a title, then shrink the dimensions of the window by 1 in all directions
  • UnFrameWin: remove the frame border, increase window by 1 in all directions. It acted on the current defined Window IIRC.
  • SaveWin: save the contents of the current window in an untyped buffer
  • RestoreWin: put the saved content of a window back in the current window (dimensions must match)
  • WriteStr: writes a string at current position, but does not cause a linefeed to occur. So you could write a character at the last X position of the screen

I made a modified implementation of the first 2.
It only needs the functionality of Crt unit.

The latter 3 and 4 might be hard to implement.
Don't know if 5 is possible.

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12693
  • FPC developer.
Re: OLD code with machine specific instructions
« Reply #16 on: July 12, 2021, 10:37:02 am »
Afaik TV does not use CRT.

win.obj probably are assembler implementation of direct screenwrites. So 16-bit and optimized for old CPUs with slow muls, without cheap LEA etc. 

Unless you plan to develop for 16-bit, probably useless.

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: OLD code with machine specific instructions
« Reply #17 on: July 12, 2021, 11:22:11 am »
AFAICT that unit has nothing to do with TV; it was just example code introduced in TP55 and, yes, it relies mostly on 16 bit assembler.

I do have the source code (as would anyone with TP55), if anyone is interested; being an example I don't think Borland would care much about it ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Bart

  • Hero Member
  • *****
  • Posts: 5701
    • Bart en Mariska's Webstek
Re: OLD code with machine specific instructions
« Reply #18 on: July 12, 2021, 11:58:05 am »
win.obj probably are assembler implementation of direct screenwrites. So 16-bit and optimized for old CPUs with slow muls, without cheap LEA etc. 

Unless you plan to develop for 16-bit, probably useless.

I don't plan to do so.
I was just trying to say that above similar procedures/functions as mentioned above would be a nice thing to have.

I do have the source code (as would anyone with TP55), if anyone is interested; being an example I don't think Borland would care much about it ;)

Well, I do have the interface.
Implementation  is most in the form of function_header; external; {WIN}

Bart

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: OLD code with machine specific instructions
« Reply #19 on: July 12, 2021, 03:24:36 pm »
Well, I do have the interface.
Implementation  is most in the form of function_header; external; {WIN}

I've got the three: win.pas, win.asm and win.obj. Tell me if you're interested; it's basically what one would expect, direct read/writes from video memory, but it has some interesting quirks :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Bart

  • Hero Member
  • *****
  • Posts: 5701
    • Bart en Mariska's Webstek
Re: OLD code with machine specific instructions
« Reply #20 on: July 12, 2021, 11:08:52 pm »
I've got the three: win.pas, win.asm and win.obj. Tell me if you're interested; it's basically what one would expect, direct read/writes from video memory, but it has some interesting quirks :)

I imagine it has.
But, I'm not interested in the implementation code.
I just was curious if similar functionality could be implemented in fpc, cross-platform that is.
FrameWin/UnframeWin are the easy ones.
Having WriteChar/WriteStr, especially the "don't insert a new line" when writing to the the right most X value, would really be nice.

Bart

MarkMLl

  • Hero Member
  • *****
  • Posts: 8538
Re: OLD code with machine specific instructions
« Reply #21 on: July 13, 2021, 08:50:04 am »
I just was curious if similar functionality could be implemented in fpc, cross-platform that is.

I would suggest that that depends entirely on whether the underlying platforms allow you to do such a thing.

If you're writing to a shell (command line) session in a character-oriented terminal emulator which doesn't provide an API for getting the instantaneous screen/window size (and doesn't provide an API for raising size-change events) then being 100% confident in your edge handling is impossible.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018