Stars

by Paul Lay

 

Issue 18

Nov/Dec 85

Next Article >>

<< Prev Article

 

 

If you want to write a good space game you need a good background and what better than a scrolling starfield such as used in STAR RAIDERS or GALAXIAN?

The programs presented here give you various starfields to which you can add your own game play. Listing 1 is a simple scrolling star field which uses one missile and a Display List Interrupt service routine to provide an excellent set of scrolling stars which are independent of the playfield. The routine is shorter than it looks as lines 160 - 290 are merely a demo to illustrate how printing to the screen does not affect the stars. Listing 2 is a better version that uses a much more complex Display List Interrupt to give a 3-D effect. Lines 10 - 440 provide the basic routine with the remainder of the program giving a demonstration to show the independence of the stars from the playfield. A further demonstration of the use of this routine is given in Listing 3. This includes some machine code routines to allow you to steer through the stars by using a joystick in port 1. To run this one delete lines 450 - 570 from Listing 2 and add the new lines.

Finally for those of you interested in exploring the routines further I have included the assembler source code for the display list interrupt.

Listing 1

AtariLister - requires Java

Listing 2

AtariLister - requires Java

Listing 3

AtariLister - requires Java

 

Listing 4 - Assembler source code

 

1000 *=$0600
1010 SETUP
1020 PLA
1030 LDA #$00
1040 STA LINECOUNT
1050 REPEAT
1060 LDA $D40B
1070 BNE REPEAT
1080 LDA #192
1090 STA $D40E
1100 RTS
1110 DLI1
1120 PHA
1130 TXA
1140 PHA
1150 TYA
1160 PHA
1170 LDX LINECOUNT
1180 INC LINECOUNT
1190 LDA POSITIONS,X
1200 TAY
1210 STA $D40A
1220 STA $D004
1222 ORA #$08
1224 STA $D012
1230 CPY #120
1240 BCC SKIP1
1241 CPY #136
1242 BCC SKIP1+1
1250 INY
1260 INY
1270 SKIP1
1280 DEY
1290 TYA
1300 CPX #$00
1310 BEQ EXIT1
1320 STA POSITIONS-1,X
1330 EXIT1
1340 CPX #$2F
1350 BNE CONT1
1360 LDA $D20A
1370 STA POSITIONS+$2F
1380 LDA #DLI2&$00FF
1390 STA 512
1400 LDA #DLI2/$0100
1410 STA 513
1420 CONT1

1430 PLA
1440 TAY
1450 PLA

1460 TAX

 

1470 PLA

1480 RTI
1490 DLI2
1500 PHA
1510 TXA
1520 PHA
1530 TYA
1540 PHA
1550 LDX LINECOUNT
1560 INC LINECOUNT
1570 LDA POSITIONS,X
1580 TAY
1590 STA $D40A
1600 STA $D004
1602 ORA #$08
1604 STA $D012
1610 CPY #120
1620 BCC SKIP2
1621 CPY #136
1622 BCC SKIP2+1
1630 INY
1640 INY
1650 SKIP2
1660 DEY
1670 TYA
1680 CPX #$5F
1690 BEQ EXIT2
1700 LDA LAST
1710 STY LAST
1720 STA POSITIONS,X
1730 JMP EXIT3
1740 EXIT2
1750 LDA #$00
1760 STA LINECOUNT
1770 LDA $D20A
1780 STA LAST
1790 LDA #DLI1&$00FF
1800 STA 512
1810 LDA #DLI1/$0100
1820 STA 513
1830 EXIT3
1840 PLA
1850 TAY
1860 PLA
1870 TAX
1880 PLA
1890 RTI
1900 LINECOUNT=$CC
1910 LAST=$CD
1920 POSITIONS=$400

 

top