Welcome, Guest. Please login or register.

Author Topic: PED81C - pseudo-native, no C2P chunky screens for AGA  (Read 3984 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline saimoTopic starter

PED81C - pseudo-native, no C2P chunky screens for AGA
« on: March 05, 2022, 10:29:14 AM »
PED81C is a video system for AGA Amigas that provides pseudo-native chunky screens, i.e. screens where each byte in CHIP RAM corresponds to a dot on the display. In short, it offers chunky screens without chunky-to-planar conversion or any CPU/Blitter/Copper sweat.

Download: https://www.retream.com/PED81C

These videos show a few examples:
* https://www.youtube.com/watch?v=4eikEo45v1I
* https://www.youtube.com/watch?v=tLtLhJXInOY
Notes:
 * due to the nature of the system, the videos must be watched in their original size (1920x1080);
 * YouTube's video processing has slightly reduced the visual quality (i.e. the result is better on real machines).

For the details, please check out the documentation included in the archive.

Originally I had planned to use PED81C to make a new game. However, I could not come up with a satisfactory idea; moreover, due to personal reasons, I had to stop software development. Given that I could not predict when/if I would able to produce something with PED81C and given that the war in Ukraine put the world in deep uncertainty, I decided that it was better to release PED81C to avoid that it went wasted and also as a gift to the Amiga community.
I must admit I have been tempted to provide an implementation of PED81C in the form of a library or of a collection of functions, but since setting up PED81C screens is easy and since general-purpose routines would perform worse than tailor-made ones, I decided to let programmers implement it in the way that fits best their projects.
« Last Edit: June 21, 2023, 04:04:13 PM by saimo »
RETREAM - retro dreams for Amiga, Commodore 64 and PC
 
The following users thanked this post: klx300r

Offline klx300r

  • Amiga 1000+AmigaOne X1000
  • Hero Member
  • *****
  • Join Date: Sep 2007
  • Posts: 3238
  • Country: ca
  • Thanked: 19 times
  • Gender: Male
    • Show only replies by klx300r
    • http://mancave-ramblings.blogspot.ca/
Re: PED81C - pseudo-native, no C2P chunky screens for AGA
« Reply #1 on: March 05, 2022, 09:23:13 PM »
I think it will be awesome for a new horizontal shooter ;D
____________________________________________________________________
c64-dual sids, A1000, A1200-060@50, A4000-CSMKIII
Indivision AGA & Catweasel MK4+= Amazing
! My Master Miggies-Amiga 1000 & AmigaOne X1000 !
--- www.mancave-ramblings.blogspot.ca ---
  -AspireOS.com & Amikit- Amiga for your netbook-
***X1000- I BELIEVE *** :angel:
 

Offline saimoTopic starter

Re: PED81C - pseudo-native, no C2P chunky screens for AGA
« Reply #2 on: June 21, 2023, 04:05:16 PM »
Uploaded an archive with updated documentation.
While at it, given that I was asked for a source code example, I whipped up an AMOS Professional program that shows how to set up a PED81C screen and to perform some basic operations on it - hopefully, this will be easy to understand and also open the door to AMOS programmers. The program source is included in the archive.

Code: [Select]
'-----------------------------------------------------------------------------
'$VER: PED81C example 1.3 (28.11.2023) (c) 2023 RETREAM
'Legal terms: please refer to the accompanying documentation.
'www.retream.com/PED81C 
'contact@retream.com   
'-----------------------------------------------------------------------------

'-----------------------------------------------------------------------------
'DESCRIPTION
'This shows how to set up a PED81C screen and to perform some basic operations
'on it.
'Screen features:
' * equivalent to a 319x256 LORES screen
' * 160 dots wide raster
' * single buffer
' * blanked border
' * 64-bit bitplanes fetch mode
' * CMYW color model
'
'NOTES
'The code is written to be readable, not to be general-purpose/optimal.
'-----------------------------------------------------------------------------

'-----------------------------------------------------------------------------
'GLOBAL VARIABLES

Global RASTERADDRESS,RASTERWIDTH,RASTERHEIGHT,RASTERSIZE

RASTERWIDTH=160
RASTERHEIGHT=256
RASTERSIZE=RASTERWIDTH*RASTERHEIGHT

'-----------------------------------------------------------------------------
'MAIN

'Initialize everything.

_INITIALIZE_AMOS_ENVIRONMENT
_INITIALIZE_SCREEN

'If the initialization succeeded, load a picture into the raster and, in case
'of success, execute a simple effect on it.

If Param
   _LOAD_PICTURE_INTO_RASTER["picture-160x256.raw"]
   If Param
      _TURN_DISPLAY_DMA_ON[0]
      _RANDOMIZE_RASTER
      _TURN_DISPLAY_DMA_OFF
   End If
End If

'Deinitialize everything.

_DEINITIALIZE_SCREEN
_RESTORE_AMOS_ENVIRONMENT

'-----------------------------------------------------------------------------
'ROUTINES

Procedure _ALLOCATE_BITPLANE[BANKINDEX,SIZE]
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Allocates a CHIP RAM buffer to be used as a bitplane.
   '
   'INPUT
   'BANKINDEX = index of bank to use
   'SIZE      = size [bytes] of bitplane
   '
   'OUTPUT
   '64-bit-aligned bitplane address (0 = error)
   '
   'WARNINGS
   'The buffer must be freed with Erase BANKINDEX or Erase All.
   '--------------------------------------------------------------------------   
   
   Trap Reserve As Chip Data BANKINDEX,SIZE+8
   If Errtrap=0 Then A=(Start(BANKINDEX)+7) and $FFFFFFF8
   
End Proc[A]
Procedure _DEINITIALIZE_SCREEN
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Deinitializes the screen.
   '
   'WARNINGS
   'Can be called only if the display is off.
   '--------------------------------------------------------------------------
   
   Erase All
   Doke $DFF1FC,0 : Rem FMODE
   
End Proc
Procedure _INITIALIZE_AMOS_ENVIRONMENT
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Ensures the program cannot be interrupted or brought to back, and turns
   'off the AMOS video system.
   '--------------------------------------------------------------------------
   
   Break Off
   Amos Lock
   Comp Test Off
   Auto View Off
   Update Off
   Copper Off
   _TURN_DISPLAY_DMA_OFF
   
End Proc
Procedure _INITIALIZE_SCREEN
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Initializes the screen.
   '
   'OUTPUT
   '-1/0 = OK/error
   '
   'WARNINGS
   '_DEINITIALIZE_SCREEN[] must be called also in case of failure. 
   '
   'NOTES
   'Sets RASTERADDRESS.
   '--------------------------------------------------------------------------
   
   'Allocate the raster.
   
   _ALLOCATE_BITPLANE[10,RASTERSIZE] : If Param=0 Then Pop Proc[0]
   RASTERADDRESS=Param
   
   'Allocate and fill the selector bitplanes.
   
   _ALLOCATE_BITPLANE[11,RASTERSIZE] : If Param=0 Then Pop Proc[0]
   B3A=Param
   Fill B3A To B3A+RASTERSIZE,$55555555
   
   _ALLOCATE_BITPLANE[12,RASTERSIZE] : If Param=0 Then Pop Proc[0]
   B4A=Param
   Fill B4A To B4A+RASTERSIZE,$33333333
   
   'Set the chipset.
   
   DIWSTRTX=$81+(160-RASTERWIDTH)
   DIWSTRTY=$2C+(128-RASTERHEIGHT/2)
   DIWSTRT=((DIWSTRTY and $FF)*256) or((DIWSTRTX+1) and $FF)
   DIWSTOPX=DIWSTRTX+RASTERWIDTH*2
   DIWSTOPY=DIWSTRTY+RASTERHEIGHT
   DIWSTOP=((DIWSTOPY and $FF)*256) or(DIWSTOPX and $FF)
   DIWHIGH=((DIWSTOPX and $100)*32) or(DIWSTOPY and $700) or((DIWSTRTX and $100)/8) or(DIWSTRTY/256)
   DDFSTRT=(DIWSTRTX-17)/2
   DDFSTOP=DDFSTRT+RASTERWIDTH-8
   
   Doke $DFF092,DDFSTRT
   Doke $DFF094,DDFSTOP
   Doke $DFF08E,DIWSTRT
   Doke $DFF090,DIWSTOP
   Doke $DFF1E4,DIWHIGH
   
   Doke $DFF100,$4241 : Rem BPLCON0
   Doke $DFF102,$10 : Rem BPLCON1
   Doke $DFF104,$224 : Rem BPLCON2
   Doke $DFF108,0 : Rem BPLMOD1
   Doke $DFF10A,0 : Rem BPLMOD2
   Doke $DFF1FC,$3 : Rem FMODE
   
   'Set COLORxx. 
   
   Doke $DFF106,$20 : Rem BPLCON3
   Doke $DFF180,0
   Doke $DFF182,$88
   Doke $DFF184,$88
   Doke $DFF186,$FF
   Doke $DFF188,0
   Doke $DFF18A,$808
   Doke $DFF18C,$808
   Doke $DFF18E,$F0F
   Doke $DFF190,0
   Doke $DFF192,$880
   Doke $DFF194,$880
   Doke $DFF196,$FF0
   Doke $DFF198,0
   Doke $DFF19A,$888
   Doke $DFF19C,$888
   Doke $DFF19E,$FFF
   Doke $DFF106,$220 : Rem BPLCON3
   Doke $DFF180,0
   Doke $DFF182,0
   Doke $DFF184,0
   Doke $DFF188,0
   Doke $DFF18A,0
   Doke $DFF18C,0
   Doke $DFF190,0
   Doke $DFF192,0
   Doke $DFF194,0
   Doke $DFF198,0
   Doke $DFF19A,0
   Doke $DFF19C,0
   Doke $DFF106,$20 : Rem BPLCON3
   
   'Build a Copperlist that sets the bitplanes pointers. 
   
   Cop Movel $E0,RASTERADDRESS
   Cop Movel $E4,RASTERADDRESS
   Cop Movel $E8,B3A
   Cop Movel $EC,B4A
   Cop Swap
   
End Proc[-1]
Procedure _LOAD_PICTURE_INTO_RASTER[FILEPATH$]
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Loads a raw 8-bit chunky picture into the raster, ensuring that its size
   'is correct.
   '
   'IN
   'FILEPATHS = path of picture file
   '
   'OUTPUT
   '-1/0 = OK/error
   '--------------------------------------------------------------------------
   
   Trap Open In 1,FILEPATH$ : If Errtrap Then Pop Proc[0]
   L=Lof(1)
   Close(1)
   If L<>RASTERSIZE Then Pop Proc[0]
   Trap Bload FILEPATH$,RASTERADDRESS
   
End Proc[Errtrap=0]
Procedure _RANDOMIZE_RASTER
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Randomizes the raster by swapping 16 dots per frame, until a mouse button
   'is pressed.
   '--------------------------------------------------------------------------
   
   XM=RASTERWIDTH-1
   YM=RASTERHEIGHT-1
   Repeat
      C=16
      While C
         X0=Rnd(XM)
         Y0=Rnd(YM)
         X1=Rnd(XM)
         Y1=Rnd(YM)
         A0=Y0*RASTERWIDTH+X0+RASTERADDRESS
         A1=Y1*RASTERWIDTH+X1+RASTERADDRESS
         C0=Peek(A0)
         Poke A0,Peek(A1)
         Poke A1,A0
         Dec C
      Wend
      _WAIT_SCREEN_BOTTOM
   Until Mouse Click
   
End Proc
Procedure _RESTORE_AMOS_ENVIRONMENT
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Restores the AMOS environment.
   '--------------------------------------------------------------------------
   
   Copper On
   Update On
   Auto View On
   Amos Unlock
   Break On
   _TURN_DISPLAY_DMA_ON[$20]
   
End Proc
Procedure _TURN_DISPLAY_DMA_OFF
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Disables the bitplanes, Copper and sprites DMA.
   '--------------------------------------------------------------------------
   
   _WAIT_SCREEN_BOTTOM
   Doke $DFF096,$3A0 : Rem DMACON
   
End Proc
Procedure _TURN_DISPLAY_DMA_ON[SSPRITESFLAG]
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Enables the bitplanes and Copper DMA.
   '
   'INPUT
   'SSPRITESFLAG = $20/0 = turn / do not turn sprites on
   '
   'WARNINGS
   'The chipset must have been set up properly.
   '--------------------------------------------------------------------------
   
   _WAIT_SCREEN_BOTTOM
   Doke $DFF096,$8380 or SSPRITESFLAG : Rem DMACON
   
End Proc
Procedure _WAIT_SCREEN_BOTTOM
   '--------------------------------------------------------------------------
   'DESCRIPTION
   'Waits for the bottom of the screen.
   '--------------------------------------------------------------------------
   
   While Deek($DFF004) and $3 : Wend
   Repeat : Until(Leek($DFF004) and $3FF00)>$12C00
   
End Proc
« Last Edit: November 28, 2023, 10:59:24 PM by saimo »
RETREAM - retro dreams for Amiga, Commodore 64 and PC
 

Offline Coolrasta

  • Newbie
  • *
  • Join Date: Jul 2023
  • Posts: 1
    • Show only replies by Coolrasta
Re: PED81C - pseudo-native, no C2P chunky screens for AGA
« Reply #3 on: July 18, 2023, 08:41:40 AM »
It's wonderful to see that you've included a source code example for PED81C! This will undoubtedly aid programmers in understanding how to set up a PED81C screen and perform some basic operations on it.

Your detailed documentation and the comments within the code are also very helpful in understanding how each section of the program functions. This demonstrates the attention you've put into making it as accessible and comprehensible as possible for other developers.

Thank you again for sharing these resources.

My website : www.la-crypte-aux-monnaies.fr
« Last Edit: September 11, 2023, 03:36:37 PM by Coolrasta »
 

Offline saimoTopic starter

Re: PED81C - pseudo-native, no C2P chunky screens for AGA
« Reply #4 on: July 18, 2023, 08:44:30 PM »
@Coolrasta

Thank you for the nice comments. I'm glad you appreciate the documentation.
RETREAM - retro dreams for Amiga, Commodore 64 and PC
 

Offline saimoTopic starter

Re: PED81C - pseudo-native, no C2P chunky screens for AGA
« Reply #5 on: November 28, 2023, 10:59:48 PM »
I have just released a little update, accompanied by the PED81C Voxel Engine (PVE), i.e. a new demo. If you can't be bothered trying it yourself, you can see it in this video - but beware: YouTube's video compression degraded the visual quality (especially the colors saturation and brightness).

https://www.youtube.com/watch?v=0xunQ6ldVKU

Details about PVE straight from the manual:
Code: [Select]
--------------------------------------------------------------------------------
OVERVIEW

PVE is an experiment to test the graphical quality and computational performance
of the PED81C system. It allows to move freely around a typical voxel landscape.


--------------------------------------------------------------------------------
GETTING STARTED

PVE requires:
 * Amiga computer
 * AGA chipset
 * 200 kB of CHIP RAM
 * 4 MB of FAST RAM
 * PAL SHRES support
 * digital joystick/joypad and mouse
 * 2.1 MB of storage space

If the monitor / graphics card / scan doubler do(es) not support SHRES, the
colors will look off or even not show at all.
For example:
 * MNT's VA2000 graphics card displays only the even columns of pixels, so only
   reds and blues show;
 * Irix Labs' ScanPlus AGA displays only the odd columns of pixels (contrary to
   how is was originally marketed), so only greens and grays show.

To install PVE, unpack the LhA archive to any directory of your choice.

To start PVE, open the program directory and double-click the program icon from
Workbench or execute the program from shell.


--------------------------------------------------------------------------------
MISCELLANEOUS

* The map wraps around at its edges.
* The number shown in the top-left corner of the action screen indicates the
  number of frames rendered in the last second.
* Upon returning to AmigaOS, PVE prints out:
   * the total number of frames rendered;
   * the total number of frames shown;
   * the average number of frames rendered per second;
   * the average time (expressed in frames) taken by the rendering of a frame.


--------------------------------------------------------------------------------
TECHNICAL NOTES

* The graphics are first rendered in a raster in FAST RAM and then copied to a
  triple-buffered PED81C raster in CHIP RAM.
* The screen resolution is 1020x200 SHRES pixels, which correspond to 255x200
  LORES-sized dots and to 128x200 logical dots.
* Rendering is done by columns, from bottom to top and then left to right.
* The code applies a depth of 256 steps per column, so it evaluates 256*128 =
  32768 dots per frame (and then renders only those which are actually visible).
* The code is 100% assembly.
* The code is optimized for 68030.
* The program supports only maps of 1024x1024 pixels, but it can be made to
  support maps of other sizes by simply redefining the width and height
  constants and reassembling the code.
* The height of the camera adapts automatically to that of the point it is at,
  but it can be made user-controllable and its maximum value can be increased
  almost to the point that the lanscape disappears at the bottom of the screen.
* On an Amiga 1200 equipped with a Blizzard 1230 IV mounting a 50 MHz 68030 and
  60 ns RAM:
   * the program runs at about 20.2 fps;
   * the rendering of graphics alone runs at about 22.2 fps;
   * the impact of PED81C is of about 22.2-20.2 = 2 fps - in other words,
     writing the graphics to the PED81C raster requires about 50/22.2-50/20.2 =
     0.223 frames (when only the bitplanes DMA is active);
   * rendering the graphics directly to the PED81C raster degrades the
     performance by about 2 to 3 fps (tested only with an older and less
     optimized version).
* On an Amiga 1200 equipped with a PiStorm32, the program runs at 50 fps
  (unsurprisingly).
* The map size is 1024x1024 pixels.
* The map requires 2 MB of FAST RAM.
* The program takes over the system entirely and returns to AmigaOS cleanly.


--------------------------------------------------------------------------------
BACKSTORY

After a hiatus from programming of several months (due to a computer-unrelated
project), I decided to finally create something for PED81C because I had made
nothing with it other than a few little examples, I wanted to test its
graphical quality and computational performance, and... I felt like having some
good fun.
After some inconclusive mental wandering, the idea of making a voxel engine came
to mind for unknown reasons (I had never dabbled with voxel before).
When the engine was mature enough I decided to distribute PVE publicly (which
initially was not planned).

About the update, I fixed some palette values in a table in the documentation, added the formulas for calculating DIWSTRT, DIWSTOP, DIWHIGH, DDFSTRT and DDFSTOP to the documentation and implemented them in the AMOS Professional source code example. This is the snippet relative to the register settings:
Code: [Select]
In general, given a raster which is RASTERWIDTH dots wide and RASTERHEIGHT dots
tall, the values to write to the chipset registers in order to create a centered
screen can be calculated as follows:
 * SCREENWIDTH  = RASTERWIDTH * 8
 * SCREENHEIGHT = RASTERHEIGHT
 * DIWSTRTX     = $81 + (160 - SCREENWIDTH / 8)
 * DIWSTRTY     = $2c + (128 - SCREENHEIGHT / 2)
 * DIWSTRT      = ((DIWSTRTY & $ff) << 8) | ((DIWSTRTX + 1) & $ff)
 * DIWSTOPX     = DIWSTRTX + SCREENWIDTH / 4
 * DIWSTOPY     = DIWSTRTY + SCREENHEIGHT
 * DIWSTOP      = ((DIWSTOPY & $ff) << 8) | (DIWSTOPX & $ff)
 * DIWHIGH      = ((DIWSTOPX & $100) << 5) | (DIWSTOPY & $700) |
                  ((DIWSTRTX & $100) >> 3) | (DIWSTRTY >> 8)
 * DDFSTRT      = (DIWSTRTX - 17) / 2
 * DDFSTOP      = DDFSTRT+SCREENWIDTH / 8 - 8
RETREAM - retro dreams for Amiga, Commodore 64 and PC