blit buffer to display, vro_cpyfm or vrt_cpyfm?

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

tschak909
Atari maniac
Atari maniac
Posts: 83
Joined: Mon Mar 26, 2018 9:29 pm

blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby tschak909 » Sat May 12, 2018 5:38 am

I am in the middle of writing a PLATO terminal for the Atari ST for IRATA.ONLINE.

I'd ultimately like it to work that I would simply write to a buffer, which I would then blit rectangles to the screen when the buffer changes.

Initially, the buffer will be 1-bit monochrome, but I may extend this to multiple planes to support more color, as I get the terminal implementation ironed out.

The first question is, should I use vro_cpyfm or vrt_cpyfm?

While I am a competent programmer, I had not written any software for the ST, and am needing to do this out of necessity...Ideally I would love to work with somebody to do the system specific parts (window control, line draw, point draw, character output, key input) while I implement the protocol decoder and the non-system specific bits, but I'll simply settle for the above question.

-Thom

ThorstenOtto
Captain Atari
Captain Atari
Posts: 417
Joined: Sun Aug 03, 2014 5:54 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby ThorstenOtto » Sat May 12, 2018 6:09 am

tschak909 wrote:The first question is, should I use vro_cpyfm or vrt_cpyfm?


If the buffer is monochrome, you should use vrt_cpyfm. That should work in all resolutions. But if you need colors, vro_cypfm is the only choice. Note that in this case the buffer must have the same format as the screen resolution, even if you need lets say only 16 colors, while the screen has 256 colors.

tschak909
Atari maniac
Atari maniac
Posts: 83
Joined: Mon Mar 26, 2018 9:29 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby tschak909 » Sun May 13, 2018 12:39 am

When dealing with off-screen buffers, how should pxy[0-4] be implemented?

If I have a 512x512 bitmap buffer, would it be something like:

(assuming k is returned from wind_get WF_WORKXYWH)

Code: Select all

pxy[0]=0;
pxy[1]=0;
pxy[2]=511;
pxy[3]=511;
pxy[4]=k.g_x;
pxy[5]=k.g_y;
pxy[6]=k.g_w+k.g_x-1;
pxy[7]=k.g_h+k.g_y-1;


???

-Thom

ThorstenOtto
Captain Atari
Captain Atari
Posts: 417
Joined: Sun Aug 03, 2014 5:54 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby ThorstenOtto » Sun May 13, 2018 6:57 am

No, unfortunately not. That would only work if VDI would also scale the source bitmap up/down while blitting, but it does not (NVDI can do that if you add 0x8000 to the writing mode, but other VDIs cannot handle that; also it might look rather ugly). The source and destination rectangle should be of the same size. That also means: a) if the source bitmap is larger than the window, you have to make sure that the non-displayed parts are clipped away and b) if it is smaller, you have to explicitly clear the remaining parts of your window to the background.

So your code should look something like:

Code: Select all

wind_update(BEG_UPDATE);
wind_get(wh, WF_WORKXYWH, &work);
wind_get(wh, WF_FIRSTXYHW, &k);
while (k.g_w > 0 && k.g_h > 0)
{
   if (rc_intersect(&work, &k))
   {
      pxy[0] = k.g_x;
      pxy[1] = k.g_y;
      pxy[2] = k.g_x + k.g_w - 1;
      pxy[3] = k.g_y + k.g_h - 1;
      vs_clip(vdi_handle, 1, pxy);
      /* clear background */
      vr_recfl(vdihandle, pxy);
      /* no need to draw if destination is outside the bitmap */
      pxy[0] = k.g_x - work.g_x;
      pxy[1] = k.g_y - work.g_y;
      if (pxy[0] < 512 && pxy[1] < 512)
      {
         /* clip rectangle to source bitmap size */
         if (k.g_w > 512) k.g_w = 512;
         if (k.g_h > 512) k.g_h = 512;
         pxy[2] = pxy[0] + k.g_w - 1;
         pxy[3] = pxy[1] + k.g_h - 1;
         pxy[4] = k.g_x;
         pxy[5] = k.g_y;
         pxy[6] = k.g_x + k.g_w - 1;
         pxy[7] = k.g_y + k.g_h - 1;
         vrt_cpyfm(vdi_handle, MD_REPLACE, pxy);
      }
   }
   wind_get(wh, WF_NEXTXYHW, &k);
}
wind_update(END_UPDATE);

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1765
Joined: Sun Jul 31, 2011 1:11 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby Eero Tamminen » Mon May 14, 2018 6:30 pm

ThorstenOtto wrote:No, unfortunately not. That would only work if VDI would also scale the source bitmap up/down while blitting, but it does not (NVDI can do that if you add 0x8000 to the writing mode, but other VDIs cannot handle that; also it might look rather ugly).


Might look ugly? Monochrome scaling looks horrible, unless it's something like 2x or 1/2.

Scaling looks somewhat OK only when there's blending and enough colors for that. However, that (blending) will slow down things on old machines like Ataris too much.

tschak909
Atari maniac
Atari maniac
Posts: 83
Joined: Mon Mar 26, 2018 9:29 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby tschak909 » Mon May 14, 2018 6:36 pm

Unfortunately, because the PLATO terminal is natively 512x512 pixels, I will HAVE to do coordinate scaling when displaying on anything that isn't a TT Hi-Res display. I was initially just going to basically do coordinate mapping for each dot that I output to my internal bitmap, and then blit that result to the target window.

-Thom

arf
Captain Atari
Captain Atari
Posts: 181
Joined: Thu May 17, 2012 9:56 pm
Location: Germany

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby arf » Mon May 14, 2018 6:52 pm

tschak909 wrote:Unfortunately, because the PLATO terminal is natively 512x512 pixels, I will HAVE to do coordinate scaling when displaying on anything that isn't a TT Hi-Res display. I was initially just going to basically do coordinate mapping for each dot that I output to my internal bitmap, and then blit that result to the target window.

-Thom


I don’t know the usecase well, but a typical scenario would “just” output the bitmap 1:1 into a GEM window, which allows scrolling and positioning. People with an original ST resolution could still use a "virtual screen enhancer" – or LaceScan, or Overscan ST. In any case I’d suggest to make the scaling optional.
Last edited by arf on Mon May 14, 2018 6:54 pm, edited 1 time in total.

arf
Captain Atari
Captain Atari
Posts: 181
Joined: Thu May 17, 2012 9:56 pm
Location: Germany

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby arf » Mon May 14, 2018 6:53 pm

arglhowcanideletethispost

tschak909
Atari maniac
Atari maniac
Posts: 83
Joined: Mon Mar 26, 2018 9:29 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby tschak909 » Mon May 14, 2018 7:14 pm

The whole PLATO screen is intended to be displayed as a single visible screen, and would be quite jarring to have to pan around the screen.

These are pictures from PTerm, which runs on modern PCs, and renders a full 512x512 screen and scales up:
avatar.PNG


01_main_menu.png


irata_welcome_pterm.png


On the Atari 800, the cartridge scales drawing down to the target resolution of 320x192 (and the port I am doing to the Commodore 64, does the same),
but since scaling the default font is processor intensive, there is a default font that is scaled 6x5 in the ROM to output directly, while custom fonts from the service are received and scaled directly into memory.

irata_welcome_atari.png


So this CAN be done on the ST. I am trying to get this done and provide a very unique online service for retro-computing users who now have internet connectivity on their devices, but very few places to connect to (much less even interesting).

(p.s. what can do output scaling? Could I just get away with bundling NVDI5 with my terminal? GDOS? I _really_ need this functionality.)

Or maybe I could talk one on one with an experienced ST developer to get a plan of action to write a terminal? I run a Jitsi meet for IRATA, and we can talk there.

(the resulting terminal will be released to the ST community, under the GPL3)

-Thom
You do not have the required permissions to view the files attached to this post.

joska
Hardware Guru
Hardware Guru
Posts: 4162
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby joska » Tue May 15, 2018 8:56 am

tschak909 wrote:(p.s. what can do output scaling? Could I just get away with bundling NVDI5 with my terminal? GDOS? I _really_ need this functionality.)


NVDI 5 is commercial and copyrighted. Also, it needs to be installed and configured on each computer it runs on. NVDI bitmap scaling is OK, but slow and not suitable for realtime screen updates. I suggest you pre-scale the fonts and scale graphics output while rendering. This will be much, much faster (and better looking) than scaling the finished bitmap.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1765
Joined: Sun Jul 31, 2011 1:11 pm

Re: blit buffer to display, vro_cpyfm or vrt_cpyfm?

Postby Eero Tamminen » Thu May 17, 2018 7:32 pm

joska wrote:I suggest you pre-scale the fonts and scale graphics output while rendering. This will be much, much faster (and better looking) than scaling the finished bitmap.


For monochrome mode, best looking output would probably come just by scaling height by 1/2 i.e. dropping every other row.

I don't know how acceptable changing the aspect ratio that much would be though. :-)


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 2 guests