# unit b_pmg

### Player and missile graphics library.

author: bocianu bocianu@gmail.com

Set of useful constants, registers and methods to fiddle with hardware Atari 8-bit sprites (and missiles).
This library is a part of 'blibs' - set of custom Mad-Pascal libraries.
https://gitlab.com/bocianu/blibs

## Constants:

name: | value: | description:
--- | --- | ---
PMG_vdelay_m0 | %00000001 | Vertical delay patterns
PMG_vdelay_m1 | %00000010 |
PMG_vdelay_m2 | %00000100 |
PMG_vdelay_m3 | %00001000 |
PMG_vdelay_p0 | %00010000 |
PMG_vdelay_p1 | %00100000 |
PMG_vdelay_p2 | %01000000 |
PMG_vdelay_p3 | %10000000 |
PMG_gractl_missiles | %00000001 | Turns on missiles
PMG_gractl_players | %00000010 | Turns on players
PMG_gractl_latch | %00000100 |
PMG_gractl_default | PMG_gractl_missiles or PMG_gractl_players |
PMG_sdmctl_DMA_missile | %00000100 | Enable missiles DMA
PMG_sdmctl_DMA_player | %00001000 | Enable players DMA
PMG_sdmctl_DMA_both | %00001100 |
PMG_sdmctl_oneline | %00010000 | Set one line resolution
PMG_sdmctl_default | PMG_sdmctl_DMA_both |
PMG_5player | %00010000 | Turn on 5th player
PMG_overlap | %00100000 | Additional color on players overlap

## Register Variables:

name: | address: | type: | description:
--- | --- | --- | ---
PMG_sdmctl | $D400 | byte | Direct Memory Access (DMA) enable flag.
PMG_sdmctl_S | $22F | byte | Direct Memory Access (DMA) enable flag - shadow register.
PMG_gprior | $D01B | byte | Priority selection register.
PMG_gprior_S | $26F | byte | Priority selection register - shadow register.
PMG_pcolr0 | $D012 | byte | Player colors.
PMG_pcolr1 | $D013 | byte |
PMG_pcolr2 | $D014 | byte |
PMG_pcolr3 | $D015 | byte |
PMG_pcolr0_S | $2C0 | byte | Player colors - shadow registers.
PMG_pcolr1_S | $2C1 | byte |
PMG_pcolr2_S | $2C2 | byte |
PMG_pcolr3_S | $2C3 | byte |
PMG_hpos0 | $D000 | byte | Horizontal positions of players.
PMG_hpos1 | $D001 | byte |
PMG_hpos2 | $D002 | byte |
PMG_hpos3 | $D003 | byte |
PMG_hposm0 | $D004 | byte | Horizontal positions of missiles.
PMG_hposm1 | $D005 | byte |
PMG_hposm2 | $D006 | byte |
PMG_hposm3 | $D007 | byte |
PMG_sizep0 | $D008 | byte | Size of players.
PMG_sizep1 | $D009 | byte |
PMG_sizep2 | $D00A | byte |
PMG_sizep3 | $D00B | byte |
PMG_sizem | $D00C | byte | Size of missiles
PMG_grafp0 | $D00D | byte | Players graphics shapes (non DMA).
PMG_grafp1 | $D00E | byte |
PMG_grafp2 | $D00F | byte |
PMG_grafp3 | $D010 | byte |
PMG_grafm | $D011 | byte | Missile graphics shapes (non DMA).
PMG_p0pl | $D00C | byte | Player to player collison statuses.
PMG_p1pl | $D00D | byte |
PMG_p2pl | $D00E | byte |
PMG_p3pl | $D00F | byte |
PMG_vdelay | $D01C | byte | Vertical delay register.
PMG_gractl | $D01D | byte | Graphics Control register. Controls receipt of Player/Missile DMA data
PMG_hitclr | $D01E | byte | Clear Collisions
PMG_pmbase | $D407 | byte | Upper byte of the player/missile base address

## Global Variables:

name: | type: | description:
--- | --- | ---
PMG_oneline | boolean | contains true if current mode uses single line resolution. contains false for double line resolution
PMG_base | pointer | contains base address
PMG_size | word | contains memory size used by PMG

## Interface:

name: | description:
--- | ---
PMG_Init | #### procedure PMG_Init(base: byte); overload; Initializes PMG engine with default settings. ##### parameters: base - upper byte of PMG memory address
PMG_Init | #### procedure PMG_Init(base, sdmctl: byte); overload; Initializes PMG engine with custom sdmctl value. ##### parameters: base - upper byte of PMG memory address sdmctl - SDMCTL register initial value
PMG_Init | #### procedure PMG_Init(base, sdmctl, gractl: byte); overload; Initializes PMG engine with custom sdmctl and gractl values. ##### parameters: base - upper byte of PMG memory address sdmctl - SDMCTL register initial value gractl - GRACTL register initial value
PMG_Clear | #### procedure PMG_Clear; Clears memory of sprites and missiles filling it with zeroes.