Skip to content

Commit ca60cb2

Browse files
committed
Adds DLI samples and documentation.
1 parent 37bf4ca commit ca60cb2

File tree

3 files changed

+274
-0
lines changed

3 files changed

+274
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SAMPLE_FP_BAS=\
7070

7171
SAMPLE_INT_BAS=\
7272
int/carrera3d.bas \
73+
int/dli.bas \
7374
int/iospeed.bas \
7475
int/joyas.bas \
7576
int/pi.bas \

manual.md

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,3 +1587,204 @@ modify memory. Use with care!
15871587
the memory location at _address_.
15881588

15891589

1590+
Display List Interrupts
1591+
-----------------------
1592+
1593+
*Note: This is an advanced topic.*
1594+
1595+
Display list interrupts (normally called
1596+
`DLI`) are a way to modify display
1597+
registers at certain vertical positions
1598+
on the screen.
1599+
1600+
You can use them to:
1601+
1602+
- Display more colors in the image, by
1603+
changing color registers - registers
1604+
from $D012 to $D01A.
1605+
1606+
- Split one Player/Missile graphics to
1607+
different horizontal positions -
1608+
registers from $D000 to D007.
1609+
1610+
- Change scrolling position, screen
1611+
width, P/M width, etc.
1612+
1613+
FastBasic allows you to specify one or
1614+
more DLI routines, activate one or
1615+
deactivate all DLI by using the `DLI`
1616+
statement:
1617+
1618+
1619+
**Define a new DLI**
1620+
**DLI SET _name_ = _op1_, _op2_, ... / DLIS.**
1621+
1622+
Setups a new DLI with the given name
1623+
and performing the _op_ operations.
1624+
1625+
Each operation is of the form:
1626+
_data_ `INTO` _address_. `INTO` can be
1627+
abbreviated to `I.`.
1628+
1629+
_data_ is one constant byte or the
1630+
name of a `DATA BYTE` array, and
1631+
_address_ is a memory location to
1632+
modify.
1633+
1634+
If _data_ is a DATA array, the first
1635+
element (at index 0) will be used at
1636+
the first line with DLI active in the
1637+
screen, the second element at the
1638+
second active line, etc.
1639+
1640+
You can specify any number of
1641+
operations, but as each one takes some
1642+
time you could see display artifacts
1643+
if you use too many.
1644+
1645+
Note that by defining a DLI you are
1646+
simply giving it a name, you need to
1647+
activate the DLI afterwards.
1648+
1649+
You can split a DLI definition over
1650+
multiple lines, just like DATA by
1651+
ending a line with a comma and
1652+
starting the next line with `DLI =`
1653+
1654+
1655+
**Enable a DLI**
1656+
**DLI _name_ / DL.**
1657+
1658+
This statement enables the DLI with
1659+
the given name, the DLI must be
1660+
defined before in the program.
1661+
1662+
This setups the OS DLI pointer to the
1663+
named DLI and activates the interrupt
1664+
bit in the display processor (the
1665+
ANTIC chip), but does not activates on
1666+
which lines the DLI must be called.
1667+
1668+
To define on which lines the DLI is
1669+
active you must modify the _Display
1670+
List_, see the example at the end of
1671+
the section.
1672+
1673+
You can also pass the name of a DATA
1674+
BYTE array with a custom machine
1675+
language routine to the `DLI`
1676+
statement, the routine must begin with
1677+
a _PHA_ and end with _PLA_ and _RTI_.
1678+
1679+
1680+
**Disable a DLI**
1681+
**DLI / DL.**
1682+
1683+
This statement simply disables the
1684+
DLI, returning the display to the
1685+
original
1686+
1687+
1688+
**DLI Examples**
1689+
1690+
This is the most basic example of a
1691+
DLI that simply changes the background
1692+
color at the middle of the screen:
1693+
1694+
' Define the DLI: set background
1695+
' color to $24 = dark red.
1696+
DLI SET d1 = $24 INTO $D01A
1697+
' Setups screen
1698+
GRAPHICS 0
1699+
' Alter the Display List, adds
1700+
' a DLI at line 11 on the screen
1701+
POKE DPEEK(560) + 16, 130
1702+
' Activate DLI
1703+
DLI d1
1704+
' Wait for any keyu
1705+
? "Press a Key" : GET K
1706+
' Disable the DLI
1707+
DLI
1708+
1709+
The next example shows how you can use
1710+
a DLI to change multiple values in the
1711+
screen:
1712+
1713+
' An array with color values
1714+
DATA Colors() BYTE = $24,$46,$68
1715+
' Define the DLI: set background
1716+
' color from the Color() array
1717+
' and text color with value $80
1718+
DLI SET d2 = Colors INTO $D01A, $80 INTO $D018
1719+
' Setups screen
1720+
GRAPHICS 0
1721+
' Adds DLI at three lines:
1722+
POKE DPEEK(560) + 13, 130
1723+
POKE DPEEK(560) + 16, 130
1724+
POKE DPEEK(560) + 19, 130
1725+
' Activate DLI
1726+
DLI d2
1727+
' Wait for any keyu
1728+
? "Press a Key" : GET K
1729+
' Disable the DLI
1730+
DLI
1731+
1732+
The final example shows how you can
1733+
move multiple P/M using one DLI
1734+
1735+
' Player shapes, positions and colors
1736+
DATA p1() BYTE = $E7,$81,$81,$E7
1737+
DATA p2() BYTE = $18,$3C,$3C,$18
1738+
DATA pos() BYTE = $40,$60,$80,$A0
1739+
DATA c1() BYTE = $28,$88,$C8,$08
1740+
DATA c2() BYTE = $2E,$80,$CE,$06
1741+
' Our DLI writes the position and
1742+
' colors to Player 1 and Player 2
1743+
DLI SET d3 = pos INTO $D000, pos INTO $D001,
1744+
DLI = c1 INTO $D012, c2 INTO $D013
1745+
GRAPHICS 0 : PMGRAPHICS 2
1746+
' Setup our 4 DLI and Players
1747+
FOR I = 8 TO 20 STEP 4
1748+
POKE DPEEK(560) + I, 130
1749+
MOVE ADR(p1), PMADR(0)+I*4+5,4
1750+
MOVE ADR(p2), PMADR(1)+I*4+5,4
1751+
NEXT
1752+
' Activate DLI
1753+
DLI d3
1754+
? "Press a Key"
1755+
REPEAT
1756+
PAUSE 0
1757+
pos(0) = pos(0) + 2
1758+
pos(1) = pos(1) + 1
1759+
pos(2) = pos(2) - 1
1760+
pos(3) = pos(3) - 2
1761+
UNTIL KEY()
1762+
DLI
1763+
1764+
1765+
**Some usefull registers**
1766+
1767+
This is a table of some useful
1768+
registers to change during a DLI:
1769+
1770+
|Address| Register |
1771+
| ----- | ------------------------- |
1772+
| $D000 | Player 0 horizontal pos. |
1773+
| $D001 | Player 1 horizontal pos. |
1774+
| $D002 | Player 2 horizontal pos. |
1775+
| $D003 | Player 3 horizontal pos. |
1776+
| $D004 | Missile 0 horizontal pos. |
1777+
| $D005 | Missile 0 horizontal pos. |
1778+
| $D006 | Missile 0 horizontal pos. |
1779+
| $D007 | Missile 0 horizontal pos. |
1780+
| $D012 | Color of Player 0 |
1781+
| $D013 | Color of Player 0 |
1782+
| $D014 | Color of Player 0 |
1783+
| $D015 | Color of Player 0 |
1784+
| $D016 | Color register 0 |
1785+
| $D017 | Color register 1 |
1786+
| $D018 | Color register 2 |
1787+
| $D019 | Color register 3 |
1788+
| $D01A | Color of Background |
1789+
1790+

samples/int/dli.bas

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
' Define the DLI: set background
2+
' color to $24 = dark red.
3+
DLI SET d1 = $24 INTO $D01A
4+
' Setups screen
5+
GRAPHICS 0
6+
' Alter the Display List, adds
7+
' a DLI at line 11 on the screen
8+
POKE DPEEK(560) + 16, 130
9+
' Activate DLI
10+
DLI d1
11+
' Wait for any keyu
12+
? "Press a Key" : GET K
13+
' Disable the DLI
14+
DLI
15+
16+
? "Again..."
17+
GET K
18+
19+
' An array with color values
20+
DATA Colors() BYTE = $24,$46,$68
21+
' Define the DLI: set background
22+
' color from the Color() array
23+
' and text color with value $80
24+
DLI SET d2 = Colors INTO $D01A, $80 INTO $D018
25+
' Setups screen
26+
GRAPHICS 0
27+
' Adds DLI at three lines:
28+
POKE DPEEK(560) + 13, 130
29+
POKE DPEEK(560) + 16, 130
30+
POKE DPEEK(560) + 19, 130
31+
' Activate DLI
32+
DLI d2
33+
' Wait for any keyu
34+
? "Press a Key" : GET K
35+
' Disable the DLI
36+
DLI
37+
38+
? "Again..."
39+
GET K
40+
41+
' Player shapes, positions and colors
42+
DATA p1() BYTE = $E7,$81,$81,$E7
43+
DATA p2() BYTE = $18,$3C,$3C,$18
44+
DATA pos() BYTE = $40,$60,$80,$A0
45+
DATA c1() BYTE = $28,$88,$C8,$08
46+
DATA c2() BYTE = $2E,$80,$CE,$06
47+
' Our DLI writes the position and
48+
' colors to Player 1 and Player 2
49+
DLI SET d3 = pos INTO $D000, pos INTO $D001,
50+
DLI = c1 INTO $D012, c2 INTO $D013
51+
GRAPHICS 0 : PMGRAPHICS 2
52+
' Setup our 4 DLI and Players
53+
FOR I = 8 TO 20 STEP 4
54+
POKE DPEEK(560) + I, 130
55+
MOVE ADR(p1), PMADR(0)+I*4+5,4
56+
MOVE ADR(p2), PMADR(1)+I*4+5,4
57+
NEXT
58+
' Activate DLI
59+
DLI d3
60+
? "Press a Key"
61+
REPEAT
62+
PAUSE 0
63+
pos(0) = pos(0) + 2
64+
pos(1) = pos(1) + 1
65+
pos(2) = pos(2) - 1
66+
pos(3) = pos(3) - 2
67+
UNTIL KEY()
68+
DLI
69+
70+
? "Key to end..."
71+
GET K
72+

0 commit comments

Comments
 (0)