August 16th, 2013

Second Reality Code Review: Part 3 (DIS)

Second Reality's Demo Interrupt Server (DIS) provides services to each PARTs, ranging from inter-parts-communication to synchronization with the VGA. Here are a few pointers if you want to read more about this component.

Part 1: Introduction
Part 2: Engine
Part 3: Demo Interrupt Server
Part 4: Dev Vs Prod
Part 5: Parts

DIS Services

The DIS provides services to a PART while it runs. A list of the functions can be found in DIS/DIS.H. The most important services :

  • Inter-PARTs communication (dis_msgarea) : The DIS provides three buffers of 64 bytes each so a PART can receive parameters from the loader or the previous PART.
  • Copper emulation (dis_setcopper) : Amiga Copper simulator that enable operations to be triggered by the VGA state.
  • Dev / Prod mode (dis_indemo) : Allowed a PART to know if it was running in DEV mode (and hence had to perform video initializations) or if it was being run from the Loader in PROD mode.
  • VGA frame counting (_dis_getmframe)
  • VGA retrace waiting (dis_waitb).

Demo Interrupt Server code

The DIS source is also 100% ASM...and moderately well commented:

How it works

The DIS is installed as an Interrupt Handler for software int 0fch.
The cool thing is that is can run from within SECOND.EXE when the demo is running or as a resident program (TSR) for dev mode.

This flexibility allows PART of the demo to be tested directly and individually during development :



                          // Let's pretend we are a FC developer and want to start the STAR part directly.
  C:\>CD DDSTARS            
  C:\DDSTARS>K

  ERROR: DIS not loaded. 

                          // Oops, the PART could not find the DIS at int 0fch.
  C:\DDSTARS>CD ..\DIS
  C:\DIS>DIS

  Demo Int Server (DIS) V1.0   Copyright (C) 1993 The Future Crew
  BETA VERSION - Compiled: 07/26/93 03:15:53 
  Installed (int fc).
  NOTE: This DIS server doesn't support copper or music synchronization!
                          // DIS is installed, let's try again.

  C:\DIS>CD ../DDSTARS
  C:\DDSTARS>K


  

Et Voila !



Copper


The "Copper" was a co-processor loved by Amiga demomakers. Part of the Original Chip Set , it allowed execution of a programmed instruction stream, synchronized with the video hardware. The PC had no such co-processor and Future Crew had to write a Copper simulator that run within the DIS.

FC used the 8254-PIT and 8259-PIC chipset from the PC in order to simulate a Copper. They build a system synchronized with the VGA frequency that could trigger a custom routines in three vertical retrace locations :

  • Location 0 : After display start (about scan line 25)
  • Location 1 : Just before retrace (AVOID USING THIS IF POSSIBLE)
  • Location 2 : In the retrace

How it is done can be read in MAIN/COPPER.ASM (and see drawing to the right) :

  1. The 8254 chip timer is adjusted to trigger an IRQ0 at desired frequency.
  2. The interrupt 8h handler (which is called by the 8259 PIC upon receiving an IRQ0) is changed to intti8 routine here.


Note: The frame counting service of the DIS is actually provided by the copper simulator.

Next

Second Reality DEV Vs PROD

 

@