A.N.A.L.O.G. ISSUE 37 / DECEMBER 1985 / PAGE 35

Speedski

16K Cassette or 24K Disk

by Bill Richardson

Can you be the fastest one down the mountain? That’s your objective in Speedski. Ski as fast as you think you dare, but remember, crashing into the trees or gates will cost you precious seconds.

Typing it in.

Before typing anything, look at the listings accompanying this article.

Listing 1 is the BASIC data and data checking routine. This listing is used to create both cassette and disk versions of Speedski.

Listing 2 is the BASIC data for an alternate ski slope. More on how to do this later in the article.

Listing 3 is the assembly language source code for the game of Speedski, created with the Atari Assembler/Editor. You don’t have to type this listing to play the game! It is included for those readers interested in assembly language.

Follow the instructions below to make either a cassette or disk version of Speedski.

Cassette instructions.

  1. Type Listing 1 into your computer using the BASIC cartridge and verify your typing with Unicheck (see page 10).
  2. Type RUN and press RETURN. The program will begin and ask:
    MAKE CASSETTE (0), OR DISK (1)? Type 0 and press RETURN. The program will begin checking the DATA statements, printing the line number of each as it goes. It will alert you if it finds any problems. Fix any incorrect lines and re-RUN the program, if necessary, until all errors are eliminated.
  3. When all of your DATA lines are correct, the computer will beep twice and prompt you to READY CASSETTE AND PRESS RETURN. Now, insert a blank cassette in your recorder, press the RECORD and PLAY buttons simultaneously and hit RETURN. The message WRITING FILE will appear, and the program will create a machine language boot tape version of Speedski, printing each DATA line number as it goes. When the READY prompt appears, the game is recorded and ready to play. CSAVE the BASIC program onto a separate tape before continuing.
  4. To load, rewind the tape created by the BASIC program to the beginning. Turn your computer OFF and remove all cartridges. Press the PLAY button on your recorder and turn ON your computer while holding down the START key. If you have a 600 or 800XL computer, you must hold the START and OPTION keys when you turn on the power. The computer will “beep” once. Hit the RETURN key, and Speedski will load and run automatically.

Disk instructions.

  1. Type Listing 1 into your computer, using the BASIC cartridge and verify your typing with Unicheck (see page 10).
  2. Type RUN and press RETURN. The program will ask:
    MAKE CASSETTE (0) OR DISK (1)? Type 1 and press RETURN. The program will begin checking the DATA lines, printing the line number of each statement as it goes. It will alert you if it finds any problems. Fix incorrect lines and re-RUN the program, if necessary, until all errors are eliminated.
  3. When all the DATA lines are correct, you will be prompted to INSERT DISK WITH DOS, PRESS RETURN. Put a disk containing DOS 2.0S into drive #1 and press RETURN. The message WRITING FILE will appear, and the program will create an AUTORUN.SYS file on the disk, displaying each DATA line number as it goes. When the READY prompt appears, the game is ready to play. Be sure the BASIC program is SAVEd before continuing.
  4. To load the game, insert the disk containing the AUTORUN.SYS file into drive #1. Turn your computer OFF, remove all cartridges and turn the computer back ON. Speedski will load and run automatically.

Playing Speedski.

Speedski is a skiing simulation for one player. You begin your journey down the slope either by pressing START or by hitting your joystick button. The game may be paused at any time by pressing any key, and resumed by pressing OPTION. Press START at any time to start the game over.

Use the joystick to steer your skier. Pulling back on the stick causes you to speed up; pushing forward will slow you down. Steering back and forth will also slow you down, but not as fast as pushing forward on the joystick.

If you crash, your skier will get up again, but it will cost you some time.

To play again, press START or your joystick button. (Try to beat my record time on course #1 of 0:35.56.)

Using course #2.

Mastered course #1 yet? If you have, or if you just want a tougher ski slope, follow the instructions below to create a version of Speedski with course #2.

1. Load Listing 1 into your computer. 2. Substitute the lines in Listing 2 for the lines in Listing 1. 3. Follow the instructions under “Typing it in” to create a new disk or tape version of Speedski with course #2.

Speedski’s graphics.

Speedski takes advantage of several of the features which make Atari graphics unbeatable. Fine scrolling is used to smoothly roll the ski slope up the screen. The screen is scrolled at a rate of one to four scan lines per vertical blank, depending on how fast you’re going. The vertical blank is also used to run the clock.

Speedski uses a completely redefined character set. All eleven of the different trees, the game logo, the numbers and my name are made of redefined characters. These are not ordinary redefined characters, but ANTIC mode 4 and 5 characters, which are multicolored.

Player/missile graphics are used for the skier. The technique of overlapping two players to create a third color which is a logical OR between the two colors (by setting bit 5 in GPRIOR-location 623) is employed to make the skier more detailed. Five different images allow the skier to be well animated.

Speedski utilizes a custom display list. Only the twelve ANTIC mode 5 lines have the fine scrolling enable bit (bit 5) set, making it possible to leave the top of the screen in one place while the ski slope scrolls.

Have fun skiing!


Bill Richardson is a high school sophomore. He’s had an Atari 800 for just over one and a half years, using it for BASIC and assembly programming and word processing. Speedski is his first all-assembly language game.


Listing 1.
BASIC listing.

10 REM *** SPEEDSKI ***
20 TRAP 20:? "MAKE CASSETTE (0), OR DISK (1)";:INPUT DSK:IF DSK>1 THEN 20
30 TRAP 40000:DATA 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,10,11,12,13,14,15
40 DIM DAT$(91),HEX(22):FOR X=0 TO 22:READ N:HEX(X)=N:NEXT X:LINE=990:RESTORE 1000:TRAP 120:? "CHECKING DATA"
50 LINE=LINE+10:? "LINE:";LINE:READ DAT$:IF LEN(DAT$)<>90 THEN 220
60 DATLIN=PEEK(183)+PEEK(184)*256:IF DATLIN<>LINE THEN ? "LINE ";LINE;" MISSING!":END 
70 FOR X=1 TO 89 STEP 2:D1=ASC(DAT$(X))-48:D2=ASC(DAT$(X+1))-48:BYTE=HEX(D1)*16+HEX(D2)
80 IF PASS=2 THEN PUT #1,BYTE:NEXT X:READ CHKSUM:GOTO 50
90 TOTAL=TOTAL+BYTE:IF TOTAL>999 THEN TOTAL=TOTAL-1000
100 NEXT X:READ CHKSUM:IF TOTAL=CHKSUM THEN 50
110 GOTO 220
120 IF PEEK(195)<>6 THEN 220
130 IF PASS=0 THEN 170
140 IF  NOT DSK THEN 160
150 PUT #1,224:PUT #1,2:PUT #1,225:PUT #1,2:PUT #1,202:PUT #1,36:CLOSE #1:END 
160 FOR X=1 TO 110:PUT #1,0:NEXT X:CLOSE #1:END 
170 IF  NOT DSK THEN 200
180 ? "INSERT DISK WITH DOS, PRESS RETURN";:DIM IN$(1):INPUT IN$:OPEN #1,8,0,"D:AUTORUN.SYS"
190 PUT #1,255:PUT #1,255:PUT #1,0:PUT #1,32:PUT #1,105:PUT #1,46:GOTO 210
200 ? "READY CASSETTE AND PRESS RETURN";:OPEN #1,8,128,"C:":RESTORE 230:FOR X=1 TO 40:READ N:PUT #1,N:NEXT X
210 ? :? "WRITING FILE":PASS=2:LINE=990:RESTORE 1000:TRAP 120:GOTO 50
220 ? "BAD DATA: LINE ";LINE:END 
230 DATA 0,30,216,31,255,31,169,0,141,47,2,169,60,141,2,211,169,0,141,231,2,133,14,169,56,141,232,2
240 DATA 133,15,169,202,133,10,169,36,133,11,24,96
1000 DATA 0000000000000000808080AA82AA00AA00000008080A00AA0000002020A020A015101015101015004111115010,958
1010 DATA 104000501050004040400040404040404040004040404040404000005441415544414100100011111111110000,900
1020 DATA 00511151115100010151010101510000005110111111000018180018180000000000001818007E67676767677F,404
1030 DATA 3F1C3C7C1C1C1C7F7F7E67077F7073737F7E67073F07677F3F060F1B337F7F070F7E607E6707677F3F7E67607E,25
1040 DATA 67677F3F7E67070E1C1C1C1C7E67677F67677F3F7E67677F07677F3F0000000000000001010105151555555500,702
1050 DATA 40405040505454000000010501000005151555555500005555555555553F3F5555555555550000000040505455,990
1060 DATA 000000000F3C00FC0F00C0C0C0FCCCCFC0CF0000000000C000C000000F3C30000000FCCFC3C0C0C0C0C00000C0,283
1070 DATA 00000000000000000000000002000002020A2AAAAA20A8A8AAAAAAAAAA000000000080A0A00000000000020000,349
1080 DATA 020A0A2AAAAA0000AAAAAAAAAAAA0303AAAAAAAAAAAAFCFCA8AAAAAAAAAA0000000080A0A8AA00000000000000,947
1090 DATA 000105000001051555555514555555555555550000505455555555000000000050545500000105000000001555,715
1100 DATA 555500000000555555550000000055555555FFFFFFFF55555555C0C0C0C0555555550000000040505455000000,346
1110 DATA 000000004000000000020A0A0A2A2A2A2A0080A0A0A0A8A8A80002020200000000AAAAAAAAAA030303A8AAAAAA,265
1120 DATA AAC0C0C00000000080000000010505051515151500405050505454540001010100000000555555555503030354,316
1130 DATA 55555555C0C0C00000000040000000000000FC0F003F0030303C3CFF3FFC3F000000F000FC00F0F03C0F000000,522
1140 DATA 00003C3CFF3C3F3C3C3C0CC0C0000000000000000000C0F0FFFF00000000000000C00000000000000000000000,730
1150 DATA 000000000300000000030FFFFFC0C0C0C0C0C0C0C003030303030303032A2526262626252AAA55AA0000AA55AA,981
1160 DATA A060A00000A060600000000000AA959A0000000000A858980000000000AA959A00000000008A89890000000000,515
1170 DATA A858A800000000002A252A0202020202AA55AA60606060606060A0989A959A989898A8989858A800000000989A,426
1180 DATA 969A989A95AA090909090989898A80A060A080A858A80000000000AA959A000000000080A0682A252626262625,41
1190 DATA 2AAA55AA0000AA55AAA060A00000A262620000000000A262620000000000A262620000000000AA569A9A989898,443
1200 DATA 9A9A95AA989898989868A08000000000002A252A0202020202AA55AA62626262626262A269665A66696A62A2A0,656
1210 DATA 800080A06262A298989898989A56AA000000114101010100101051111110510000005400540454000000544444,405
1220 DATA 4454000000405444444400000000000000000000000000000000000000000000000058595A5B5C5D5E5F68696A,956
1230 DATA 6B6C6D6E6F6061626364656667707172737475767701020300040506070800090A0C0D0B78797A7B7C70704400,214
1240 DATA 0004000465004025252525252525252525054134240C00180018183C007C003088384424024800482200440088,911
1250 DATA 00000C00180018183C0018243C423C0024002400002400243000180018183C003E000C111C2224401200124400,982
1260 DATA 22001104001902191CFE00B90078803880280040144C224100000010001800806058183A042D021C001A002200,860
1270 DATA 428100420004B8B414340EA200BDC2289D00309DA035BDA22A9DE0319D8037BD822C9DC0339D6039E8D0E2BDC2,20
1280 DATA 299D00319DA036BDA22B9DE0329D8038BD822D9DC0349D603AE8E0E0D0E0A900AA9D403BE8D0FAA5588D3724A5,951
1290 DATA 598D3824A900A07891588810FBA204BDC5249DC402CA10F7A9348D3002A9248D3102A01BA20FBD0024915888CA,735
1300 DATA 10F7A043A21FBD0024915888CAE00FD0F5A9208DF402A9008D08D2A9038D0FD2A9028D1DD0A9048D07D4208E26,854
1310 DATA A9288D6F02A9988DC002A9768DC102A92E8D2F02A06EA213BD2024915888CA10F7A9008D3D24A9308D3E24A900,575
1320 DATA 8587858F858E8588A9018589A900A2069580CA10FB86828EFC02CA8685A978858AA924858BAD1FD06A9005AD84,324
1330 DATA 02D0F520F027A9068D3B24854D209B26A58A8D00D08D01D0208E26A965858CA924858D20AA26E68BA58BC948F0,598
1340 DATA 15A58B4A4A4A8D00D28D01D2A20AA0002087264CE5258D1ED0AD7802C905F00AC906F004C907D005C6894CBE26,368
1350 DATA C909F00AC90AF004C90BD005C6894CCF26C90DD005E6894CEC26C90ED007C689200027C6894CEC26A58A8D00D0,681
1360 DATA 8D01D0ADFC02C9FFF003201027AD1FD0C906D0034C9425AD04D0F003209227A20CA000208726A588F0034C2227,412
1370 DATA 20FC274C102688D0FDCAD0FA60A900AA9D00069D8006CAD0F760A228A00CD004A2E4A05FA9064C5CE4A68BA017,54
1380 DATA B18C9D800688B18C9D0006CA8810F160200027E68AA97D858CA924858DA906D00F200027C68AA94D858CA92485,116
1390 DATA 8DA9048D00D2A90C8D01D220AA264C4F26200027A965858CA924858DA9028D00D2A908D0E3A589C941D003C689,88
1400 DATA 60A589D002E6896020A126A9FF8DFC02AD1FD0C903D0F94C9B2620A126A9798D00D2A9A68D01D2A200A0002087,599
1410 DATA 26A9608D00D2A9798D02D2A9AA8D01D28D03D2A280208726A9518D00D2A9608D02D2A9AC8D01D28D03D2A2C020,88
1420 DATA 8726A93C8D00D2A9518D02D2A9AE8D01D28D03D2208726208726A9008D01D28D03D2AD1FD06A9005AD8402D0F5,205
1430 DATA 4C9425A9018588A90F8590A9FF8D00D2E5908D02D2A5908D01D269C08D03D2C690A214208726A590D0E1A99585,101
1440 DATA 8CA924858D20AA26A21E208726A9AD858CA924858D20AA26208726208726208726A9008588A965858CA924858D,766
1450 DATA A90185894CAA26A900A078915888C04FD0F960A58AC92FD003E68A60C9C4D002C68A60A588D06EA5894A4A4A4A,614
1460 DATA D004A201D001AAE687A5878D05D4C910F005CAD0F2F051A9008D05D48587AD3D241869288D3D249003EE3E24A5,946
1470 DATA 8FD026AD3E24C935D031AD3D24C9A0D02AA9308D3E24A9008D3D24E68EA58EC90AD018A901858FD012AD3E24C9,127
1480 DATA 3AD00BAD3D24C950D004A9018588E680A580C906D02AA9008580E681A581C90AD01EA9008581E683A583C90AD0,753
1490 DATA 12A9008583E684A584C906D006A9008584E686A057A206B5801869D09158C8CAD0F54C5FE40032333435360000,890
1500 DATA 00A9C000000000D1D200000000D1D2001B4600000000454600000000000000003738393A3B3C3D004142434422,31
1510 DATA 2300D60000000000D61D1E1F202100004748494A00000000000000004546000028292A2B000000252627000000,358
1520 DATA 0000000000000028292A2B00000000294000000000004748494A2C2D2E2F303100000000000000000000000000,198
1530 DATA 002C2D2E2F3031000041424344000000004B4C4D00294000000000000029400000000000000000000000000022,215
1540 DATA 232400451C000000000000004E4F5041424344004546004142430000D4D580000000D4D5000000252627474849,531
1550 DATA 4A000000000000001A1B1C0000004748494A451C00002940D70000000000D700000028292A2B00001A1B1C0000,855
1560 DATA 00001D1E1F202100222324004748494A4142434400000000000000002C2D2E2F30311D1E1F2021000000000000,105
1570 DATA 00000025262728292A2B000000000000000000000000000000000000294000002223240000001B1C0000454600,789
1580 DATA 2C2D2E2F30310000000000000000000000001B460000414243440025262700004748494A4748494A00000000D1,334
1590 DATA D200000080D1D200000000004748494A00000000222324000000004B4C4D003233343536000000D60000000000,188
1600 DATA D6000045460000294000001A1B1C00252627004546004E4F503738393A3B3C3D00000000000000000000474849,839
1610 DATA 4A414243441D1E1F20210000004748490000001A1B1C000000000029400000000000000000000000294000004B,916
1620 DATA 4C4D00000028292A2B000000001D1E1F20210000004142434400000000000000000041424344004E4F5000002C,203
1630 DATA 2D2E2F3031000000323334353600000000000045460080D1D200008080D1D2001B460000000022232400002940,366
1640 DATA 00003738393A3B3C3D222324004748494A00D60000000000D61D1E1F2021000000252627004142434400000000,130
1650 DATA 00222300252628292A2B0000000000000000000000000000451C00001B46000000000000000000000025262700,748
1660 DATA 2C2D2E2F30310000000000000000000000004748494A4748494A001B460000000029400000001B460000000000,906
1670 DATA 1A1B1C00000000000000000000000000294000001D1E1F20210000414243441D1E1F20210000001D1E1F20214B,898
1680 DATA 4C4DD4D500000080D4D541424344004546000000000000001B46000000000028292A2B000000004E4F5000D700,149
1690 DATA 00000000D7000000004748494A000000001D1E1F20210000002C2D2E2F30310000000000000000000000000000,88
1700 DATA 0000294000001A1B1C00000000000000004B4C4D0000000000004B4C4D00000000000000000000000041424344,996
1710 DATA 1D1E1F2021000000294000004E4F500045460000004E4F5000000000000000000000222324000029400000451C,176
1720 DATA 000041424344001B46004748494A2223240000D4D500000000D4D5000025262700414243444748494A00000000,454
1730 DATA 004748494A00000000252627000000D70000000000D700000000004546000000000000000000A8A9AAAB000000,105
1740 DATA 1A1B1C000000000000000000000000000028292A2B4748494A004B4C4D000000ACAD2E2F3031001D1E1F202100,560
1750 DATA 00294000000000000000002C2D2E2F3031002940004E4F5000000000000000C5C6000000800000004142434400,75
1760 DATA 00000000000000000000000041424344001A1B1C00000000004748494A002940000000000000D1D280008080D1,829
1770 DATA D2000032333435360000001D1E1F20210000000000000000414243440000000000D60000000000D60000373839,316
1780 DATA 3A3B3C3D00001B460000000000001B460000222324000028292A2B00000000000000004546000029400000001D,292
1790 DATA 1E1F2021000000004748494A00252627002C2D2E2F30310000000000004748494A4142434400292A2B00002223,852
1800 DATA 000000294000000000004B4C4D0000000000000000000000000000294000002C2D2E2F30310025260000414243,842
1810 DATA 4400000000004F5000000000000000000000000000414243440000000000000000000000000000000000000000,335
1820 REM * 3690 BYTES

Listing 2.
BASIC for alternate ski slope.

1490 DATA 12A9008583E684A584C906D006A9008584E686A057A206B5801869D09158C8CAD0F54C5FE4001A1B1C00000000,711
1500 DATA 45460000000000000000000000000000294000000000000000002223240000001D1E1F202100004748494A2940,610
1510 DATA D4D500000000D4D5000041424344004546000000002526270000000000000000002940000041424344D7000000,565
1520 DATA 0000D70000000000004748494A3233343536000000004B4C4D0000414243440000000000000000000000000028,864
1530 DATA 292A2B000000003738393A3B3C3D0000004E4F504546000000222324000000000000000000002C2D2E2F303100,156
1540 DATA 001A1B1C000000000029400000004748494A000025262700000000000000000000004B4C4D0000001D1E1F2021,129
1550 DATA 0000004142430000451C000045460000002940D4D500000000D4D500004E4F5000000000000000001A1B1C0000,836
1560 DATA 00004748C94A4748494A00C1C24344D70000000000D7A9C0000022232400454600001D1E1F202100000000A8A9,593
1570 DATA AAAB000022232400000000000000000041424344002526004748494A294000000000000000ACADAE2F30310025,475
1580 DATA 262700000000000000002223000029400000000000004142434400222324000000000000000000000000000000,97
1590 DATA 0000C5C60025262741424344003233343536000000002526270000222380D1D200000000D1D20022234748494A,640
1600 DATA 292A2B000000003738393A3B3C3D0045460000294000252600D60000000000D60000252627002C2D2E2F303100,312
1610 DATA 1B4600000028292A2B4748494A4142430000000000000000000000001A1B1C00002829400000004748494A002C,623
1620 DATA 2D2E2F3031004B2300000000001B46000000000000001D1E1F202100414243440028292A2B0000001B46000000,749
1630 DATA 002526272223004748494A222324000000000000000000004B4C4D2C2D2E2F3031004748494A28292A2B000025,327
1640 DATA 2600000000002526294000D1D200000000D1D24E4F5000451C00001A1B1C00002C2D2E2F3031000000004B4C4D,305
1650 DATA 0000414243C4D60000000000D6294000004748494A1D1E1F202100000000004B4C4D0000004E4F502223240045,316
1660 DATA 46000000000000414243440000000000004546000028292A2B004E4F500000000000002526274748494A000000,598
1670 DATA 0000000000000028292A2B4748494A2C2D2E2F30310000002940004B230000004B4C4D00454600000000000000,915
1680 DATA 002C2D2E2F303100001A1B1C0000001B46004142430025262700004E4F004748494A000000D1D200000080D1D2,97
1690 DATA 0000001D1E1F2021004748494A000000000000A8A9AAAB000045460000000000D60000000000D6004546000000,926
1700 DATA 22232400294000001B46000000AC2D2E2F30314748494A001A1B1C000000000000004748492940002526274142,577
1710 DATA 43444748494A0000454600002940000000001D1E1F202100000000000000004142434428292A2B00001A1B4600,956
1720 DATA 00004748494A41424344003233343536000000000000000000000000002C2D2E2F30310047484900000000001B,294
1730 DATA 1C000000003738393A3B3C3D2940222300D1D200000080D1D200000000292A2B00004B4C001D1E1F202100A8A9,637
1740 DATA AAAB80000000414243252600D60000000000D62223242C2D2E2F3031004E4F00001B460000ACAD2E2F3031004B,55
1750 DATA 4C4D0029400000000000000000002526271A1B1C000022232400004748494A28292A2B000000004E4F50414243,504
1760 DATA 44454600000000000000001D1E1F20210025262700000000002C2D2E2F303100454600004B4C4D004748494A29,957
1770 DATA 4000000000000000C5C6000029400000000029400029400000004748494A004E4F502940000041424300000000,561
1780 DATA 0000C748494A41424344000041424341424344001A1B1C0000222324414243441A1B1C00D4D500000080D4D500,220
1790 DATA 4B4C4D22232400000029400000001D1E1F2021002526270000001D1E1F202100D70000000000D7004E4F502526,824
1800 DATA 27000041424344222324000045460000000029400000000000000000000000000000001A1B1C00000000000000,559
1810 DATA 0000252627004748494A000041424344000000000000000000000000001D1E1F20210000000000000000000000,384

Listing 3.
Assembly listing.

**************************
*                        *
*        SPEEDSKI        *
*                        *
*   By Bill Richardson   *
*                        *
*   Copyright (c) 1985   *
*    ANALOG Computing    *
*                        *
**************************
;
;OS EQUATES
;----------
;
HPOSP0	=	$D000	;Plr0 horiz pos
HPOSP1	=	$D001	;Plr1 horiz pos
P0PF	=	$D004	;Plr0 collision
GRACTL	=	$D01D	;Graphics ctrl
HITCLR	=	$D01E	;Collision reg
CONSOL	=	$D01F	;Consol keys
AUDF1	=	$D200	;Audio Freq 1
AUDC1	=	$D201	;Audio Ctrl 1
AUDF2	=	$D202	;Audio Freq 2
AUDC2	=	$D203	;Audio Ctrl 2
AUDCTL	=	$D208	;Main audio ctrl
SKCTL	=	$D20F	;Serial ctrl
VSCROL	=	$D405	;Vert Scroll reg
PMBASE	=	$D407	;P/M base addr
SETVBV	=	$E45C	;Set VBLANK
SYSVBV	=	$E45F	;Exit VBLANK
;
;PAGE ZERO
;---------
;
	*=	$80
;
CLOCK	.DS	7	;Special clock
SCROLLED	.DS	1	;# lines scrolled
SCROLFLG	.DS	1	;Scroll done flag
SPEED	.DS	1	;Scrolling speed
XPOS	.DS	1	;Skier's horz pos
YPOS	.DS	1	;Skier's vert pos
IMAGEPTR	.DS	2	;Image pntr
TIMES	.DS	1	;Course scrl cnt
TIMESFLG	.DS	1	;End course flg
VOLUME	.DS	1	;Volume of sounds
;
;SHADOW REGISTERS, ETC.
;----------------------
;
ATRACT	=	77	;Attract mode flg
SAVMSC	=	88	;Scrn memory pntr
SDMCTL	=	$022F	;DMA enable
SDLSTL	=	$0230	;Disp List pntr
GPRIOR	=	$026F	;Priority reg
STICK0	=	$0278	;Joystick 0
STRIG0	=	$0284	;Stick trigger 0
PCOLR0	=	$02C0	;Player 0 color
PCOLR1	=	$02C1	;Player 1 color
COLOR0	=	$02C4	;Playfld Color 0
CHBAS	=	$02F4	;CH Base addr
CH	=	$02FC	;Last Key pressed
;
	*=	$3000
;
SCRN1	.DS	480	;1st screen
SCRN2	.DS	480	;2nd screen
SCRN3	.DS	480	;3rd screen
SCRN4	.DS	480	;4th screen
SCRN5	.DS	480	;5th screen
SCRN6	.DS	240	;6th screen
SCRLFIN	.DS	240	;End scrl adr
;
	*=	$0400
;
PMSTART	.DS	$0200	;P/M area
PLR0	.DS	$80	;Player0
PLR1	.DS	$80	;Player1
;
;CHARACTER SET
;-------------
;
	*=	$2000
;
CHSET	.BYTE	0,0,0,0,0,0,0,0,128,128
	.BYTE	128,170,130,170,0,170
	.BYTE	0,0,0,8,8,10,0,170
	.BYTE	0,0,0,32,32,160,32,160
	.BYTE	21,16,16,21,16,16,21,0
	.BYTE	65,17,17,80,16,16,64,0
	.BYTE	80,16,80,0,64,64,64,0
	.BYTE	64,64,64,64,64,64,64,0
	.BYTE	64,64,64,64,64,64,64,0
	.BYTE	0,84,65,65,85,68,65,65
	.BYTE	0,16,0,17,17,17,17,17
	.BYTE	0,0,0,81,17,81,17,81
	.BYTE	0,1,1,81,1,1,1,81
	.BYTE	0,0,0,81,16,17,17,17
	.BYTE	0,0,24,24,0,24,24,0,0,0
	.BYTE	0,0,0,24,24,0,126,103
	.BYTE	103,103,103,103,127,63
	.BYTE	28,60,124,28,28,28,127
	.BYTE	127,126,103,7,127,112
	.BYTE	115,115,127,126,103,7
	.BYTE	63,7,103,127,63,6,15,27
	.BYTE	51,127,127,7,15,126,96
	.BYTE	126,103,7,103,127,63
	.BYTE	126,103,96,126,103,103
	.BYTE	127,63,126,103,7,14,28
	.BYTE	28,28,28,126,103,103
	.BYTE	127,103,103,127,63,126
	.BYTE	103,103,127,7,103,127
	.BYTE	63,0,0,0,0,0,0,0,1
	.BYTE	1,1,5,21,21,85,85,85
	.BYTE	0,64,64,80,64,80,84,84
	.BYTE	0,0,0,1,5,1,0,0
	.BYTE	5,21,21,85,85,85,0,0
	.BYTE	85,85,85,85,85,85,63,63
	.BYTE	85,85,85,85,85,85,0,0
	.BYTE	0,0,64,80,84,85,0,0
	.BYTE	0,0,15,60,0,252,15,0
	.BYTE	192,192,192,252,204,207
	.BYTE	192,207,0,0,0,0,0,192,0
	.BYTE	192,0,0,15,60,48,0,0,0
	.BYTE	252,207,195,192,192,192
	.BYTE	192,192,0,0,192,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,2,0,0,2
	.BYTE	2,10,42,170,170,32,168
	.BYTE	168,170,170,170,170,170
	.BYTE	0,0,0,0,0,128,160,160
	.BYTE	0,0,0,0,0,2,0,0,2,10,10
	.BYTE	42,170,170,0,0,170,170
	.BYTE	170,170,170,170,3,3,170
	.BYTE	170,170,170,170,170,252
	.BYTE	252,168,170,170,170,170
	.BYTE	170,0,0,0,0,128,160,168
	.BYTE	170,0,0,0,0,0,0,0,0,1,5
	.BYTE	0,0,1,5,21,85,85,85
	.BYTE	20,85,85,85,85,85,85,85
	.BYTE	0,0,80,84,85,85,85,85
	.BYTE	0,0,0,0,0,80,84,85
	.BYTE	0,0,1,5,0,0,0,0
	.BYTE	21,85,85,85,0,0,0,0,85
	.BYTE	85,85,85,0,0,0,0,85,85
	.BYTE	85,85,255,255,255,255
	.BYTE	85,85,85,85,192,192,192
	.BYTE	192,85,85,85,85,0,0,0,0
	.BYTE	64,80,84,85,0,0,0,0
	.BYTE	0,0,0,64,0,0,0,0,2,10
	.BYTE	10,10,42,42,42,42,0,128
	.BYTE	160,160,160,168,168,168
	.BYTE	0,2,2,2,0,0,0,0,170,170
	.BYTE	170,170,170,3,3,3,168
	.BYTE	170,170,170,170,192,192
	.BYTE	192,0,0,0,0,128,0,0,0
	.BYTE	1,5,5,5,21,21,21,21
	.BYTE	0,64,80,80,80,84,84,84
	.BYTE	0,1,1,1,0,0,0,0,85,85
	.BYTE	85,85,85,3,3,3,84,85,85
	.BYTE	85,85,192,192,192
	.BYTE	0,0,0,0,64,0,0,0
	.BYTE	0,0,0,252,15,0,63,0,48
	.BYTE	48,60,60,255,63,252,63
	.BYTE	0,0,0,240,0,252,0,240
	.BYTE	240,60,15,0,0,0,0,0,60
	.BYTE	60,255,60,63,60,60,60
	.BYTE	12,192,192,0,0,0,0,0
	.BYTE	0,0,0,0,192,240,255,255
	.BYTE	0,0,0,0,0,0,0,192
	.BYTE	0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,3,0,0,0
	.BYTE	0,3,15,255,255,192,192
	.BYTE	192,192,192,192,192,192
	.BYTE	3,3,3,3,3,3,3,3,42,37
	.BYTE	38,38,38,38,37,42,170
	.BYTE	85,170,0,0,170,85,170
	.BYTE	160,96,160,0,0,160,96
	.BYTE	96,0,0,0,0,0,170,149
	.BYTE	154,0,0,0,0,0,168,88
	.BYTE	152,0,0,0,0,0,170,149
	.BYTE	154,0,0,0,0,0,138,137
	.BYTE	137,0,0,0,0,0,168,88
	.BYTE	168,0,0,0,0,0,42,37,42
	.BYTE	2,2,2,2,2,170,85,170,96
	.BYTE	96,96,96,96,96,96,160
	.BYTE	152,154,149,154,152,152
	.BYTE	152,168,152,152,88,168
	.BYTE	0,0,0,0,152,154,150,154
	.BYTE	152,154,149,170,9,9,9,9
	.BYTE	9,137,137,138,128,160
	.BYTE	96,160,128,168,88,168
	.BYTE	0,0,0,0,0,170,149,154
	.BYTE	0,0,0,0,0,128,160,104
	.BYTE	42,37,38,38,38,38,37,42
	.BYTE	170,85,170,0,0,170,85
	.BYTE	170,160,96,160,0,0,162
	.BYTE	98,98,0,0,0,0,0,162,98
	.BYTE	98,0,0,0,0,0,162,98,98
	.BYTE	0,0,0,0,0,170,86,154
	.BYTE	154,152,152,152,154,154
	.BYTE	149,170,152,152,152,152
	.BYTE	152,104,160,128,0,0,0,0
	.BYTE	0,42,37,42,2,2,2,2,2
	.BYTE	170,85,170,98,98,98,98
	.BYTE	98,98,98,162,105,102,90
	.BYTE	102,105,106,98,162,160
	.BYTE	128,0,128,160,98,98,162
	.BYTE	152,152,152,152,152,154
	.BYTE	86,170,0,0,0,17,65,1,1
	.BYTE	1,0,16,16,81,17,17,16
	.BYTE	81,0,0,0,84,0,84,4,84
	.BYTE	0,0,0,84,68,68,68,84
	.BYTE	0,0,0,64,84,68,68,68
	.BYTE	0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0
;
;MESSAGES
;--------
;
GAMELOGO	.BYTE	88,89,90,91,92,93,94,95
	.BYTE	104,105,106,107,108,109
	.BYTE	110,111,96,97,98,99,100
	.BYTE	101,102,103,112,113,114
	.BYTE	115,116,117,118,119
MYNAME	.BYTE	1,2,3,0,4,5,6,7,8,0,9
	.BYTE	10,12,13,11,120,121,122
	.BYTE	123,124
;
;DISPLAY LIST
;------------
;
DLIST	.BYTE	$70,$70,$44
	.WORD	$00
	.BYTE	$04,$00,$04,$65
	.WORD	$4000
	.BYTE	$25,$25,$25,$25
	.BYTE	$25,$25,$25,$25
	.BYTE	$25,$25,$05,$41
	.WORD	DLIST
;
;P/M SHAPES
;----------
;
IM1	.BYTE	12,0,24,0,24,24
	.BYTE	60,0,124,0,48,136
	.BYTE	56,68,36,2,72,0
	.BYTE	72,34,0,68,0,136
IM2	.BYTE	0,0,12,0,24,0
	.BYTE	24,24,60,0,24,36
	.BYTE	60,66,60,0,36,0
	.BYTE	36,0,0,36,0,36
IM3	.BYTE	48,0,24,0,24,24
	.BYTE	60,0,62,0,12,17
	.BYTE	28,34,36,64,18,0
	.BYTE	18,68,0,34,0,17
IM4	.BYTE	4,0,25,2,25,28
	.BYTE	254,0,185,0,120,128
	.BYTE	56,128,40,0,64,20
	.BYTE	76,34,65,0,0,0
IM5	.BYTE	16,0,24,0,128,96
	.BYTE	88,24,58,4,45,2
	.BYTE	28,0,26,0,34,0
	.BYTE	66,129,0,66,0,4
;
;Initial screen colors
;---------------------
;
COLTBL	.BYTE	184,180,20,52,14
;
;Copy screens
;------------
;
PRGSTART	LDX	#0
COPY1	LDA	SCRNBASE,X
	STA	SCRN1,X
	STA	SCRN4,X
	LDA	SCRNBASE+480,X
	STA	SCRN2,X
	STA	SCRN5,X
	LDA	SCRNBASE+960,X
	STA	SCRN3,X
	STA	SCRN6,X
	INX
	BNE	COPY1
COPY2	LDA	SCRNBASE+256,X
	STA	SCRN1+256,X
	STA	SCRN4+256,X
	LDA	SCRNBASE+736,X
	STA	SCRN2+256,X
	STA	SCRN5+256,X
	LDA	SCRNBASE+1216,X
	STA	SCRN3+256,X
	STA	SCRN6+256,X
	INX
	CPX	#224
	BNE	COPY2
	LDA	#0
	TAX
CLEAR1	STA	SCRN6+480,X	;Clr bottom
	INX		;of scrolling
	BNE	CLEAR1	;screen memory
	LDA	SAVMSC
	STA	DLIST+3	;Set DLIST
	LDA	SAVMSC+1	;pointer to
	STA	DLIST+4	;screen memory
	LDA	#0	;Clear
	LDY	#120	;top
CLEARSCR	STA	(SAVMSC),Y	;of
	DEY		;screen
	BPL	CLEARSCR
	LDX	#4
COLORSCR	LDA	COLTBL,X	;color tbl
	STA	COLOR0,X
	DEX
	BPL	COLORSCR
	LDA	# <DLIST	;Tell ANTIC
	STA	SDLSTL	;where to
	LDA	# >DLIST	;find custom
	STA	SDLSTL+1	;Display List
	LDY	#27	;This routine
	LDX	#15	;puts the top 16
I1	LDA	GAMELOGO,X	;characters of
	STA	(SAVMSC),Y	;"SPEEDSKI"
	DEY		;logo on the
	DEX		;screen
	BPL	I1
	LDY	#67	;Puts
	LDX	#31	;the last
I2	LDA	GAMELOGO,X
	STA	(SAVMSC),Y	;16 characters
	DEY		;of logo on
	DEX		;the screen
	CPX	#15
	BNE	I2
	LDA	# >CHSET	;Give computer
	STA	CHBAS	;adr of new CHSET
	LDA	#0	;Initialize
	STA	AUDCTL	;POKEY
	LDA	#3	;sound
	STA	SKCTL	;chip
	LDA	#2	;Enable
	STA	GRACTL	;P/M graphics
	LDA	# >PMSTART	;Tell where PM
	STA	PMBASE	;graphics are
	JSR	ERASE	;Clear P/M memory
	LDA	#40	;Multi-color plrs
	STA	GPRIOR	;Set P/M priority
	LDA	#152	;light blue
	STA	PCOLR0
	LDA	#118	;blue
	STA	PCOLR1
	LDA	#46	;Double line
	STA	SDMCTL	;resolution plrs
	LDY	#110
	LDX	#19	;This routine
I3	LDA	MYNAME,X	;puts the
	STA	(SAVMSC),Y	;author's name
	DEY		;on the 3rd line
	DEX		;of the screen
	BPL	I3
;
;EVERY TIME INITIALIZATION
;-------------------------
;
INIT	LDA	# <SCRN1	;Point DLIST
	STA	DLIST+9	;to scrolling
	LDA	# >SCRN1	;screen
	STA	DLIST+10
	LDA	#0	;Reset # scan
	STA	SCROLLED	;lines scrolled
	STA	TIMESFLG	;and TIMESFLG
	STA	TIMES	;+ course scroll
	STA	SCROLFLG	;Do scrolling
	LDA	#1	;Set scroll speed
	STA	SPEED	;to slow
	LDA	#0	;Set
	LDX	#6	;clock
I4	STA	CLOCK,X	;to
	DEX		;0:00.00
	BPL	I4
	STX	CLOCK+2	;"." character
	STX	CH	;Reset last key
	DEX
	STX	CLOCK+5	;":" character
	LDA	#120	;Set horizontal
	STA	XPOS	;pos of skier
	LDA	#36	;Set vertical
	STA	YPOS	;pos of skier
;
;BEGIN GAME
;----------
;
WAITLOOP	LDA	CONSOL
	ROR	A	;START Pressed?
	BCC	LETSGO	;Yes! start game
	LDA	STRIG0	;Trigger pressed?
	BNE	WAITLOOP	;No, wait
LETSGO	JSR	CLEAR3RD	;Clr 3rd line
	LDA	#6	;Chg ANTIC 4 line
	STA	DLIST+7	;to GR.1 line
	STA	ATRACT	;Reset Attract
	JSR	SCROLLIT	;Start VBLANK
;
;INTRODUCTION
;------------
;
	LDA	XPOS	;Position the
	STA	HPOSP0	;skier
	STA	HPOSP1	;horizontally
INTRO	JSR	ERASE	;Erase skier
	LDA	# <IM2	;Tell IMAGEPTR
	STA	IMAGEPTR	;which image
	LDA	# >IM2	;to
	STA	IMAGEPTR+1	;draw
	JSR	DRAW	;Go draw skiers
	INC	YPOS	;Move down screen
	LDA	YPOS	;See if skier has
	CMP	#72	;reached middle
	BEQ	MAINLOOP	;of screen? Yes.
	LDA	YPOS	;Vert position
	LSR	A	;/2
	LSR	A	;/4
	LSR	A	;/8
	STA	AUDF1	;Set frequency,
	STA	AUDC1	;vol, distortion
	LDX	#10	;HI byte and LO
	LDY	#0	;byte of delay
	JSR	DELAY	;Slow down action
	JMP	INTRO	;Do it again
;
;THE MAIN LOOP
;-------------
;
MAINLOOP	STA	HITCLR	;Clr Collision
	LDA	STICK0	;Read joystick
	CMP	#5	;Down and right?
	BEQ	MP2A	;Go draw skier
	CMP	#6	;Up and right?
	BEQ	MP2
	CMP	#7
	BNE	MP3
MP2	DEC	SPEED
MP2A	JMP	RIGHT
;
MP3	CMP	#9	;Down and left?
	BEQ	MP5A
	CMP	#10	;Up and left?
	BEQ	MP5
	CMP	#11	;Left?
	BNE	MP6
MP5	DEC	SPEED
MP5A	JMP	LEFT
;
MP6	CMP	#13	;Down?
	BNE	MP7
	INC	SPEED
	JMP	STRAIGHT
;
MP7	CMP	#14	;Up?
	BNE	MP8
	DEC	SPEED
	JSR	TESTSPD
	DEC	SPEED
MP8	JMP	STRAIGHT
;
CONTINUE	LDA	XPOS	;Horizontal pos
	STA	HPOSP0	;Position Plr0
	STA	HPOSP1	;Position Plr1
	LDA	CH	;Last key pressed
	CMP	#255
	BEQ	MP9	;No key pressed
	JSR	PAUSE	;Activate pause
MP9	LDA	CONSOL
	CMP	#6	;START pressed?
	BNE	MP10	;No.
	JMP	INIT	;Start over
;
MP10	LDA	P0PF	;Check collision
	BEQ	MP11	;Nobody crashed
	JSR	CRASH	;Crash occured
MP11	LDX	#12
	LDY	#0
	JSR	DELAY	;Slow the action
	LDA	SCROLFLG	;scrolling?
	BEQ	MP12	;Yes. continue
	JMP	ENDGAME
;
MP12	JSR	TESTX	;Skier's X coord
	JMP	MAINLOOP	;Loop back
;
;Delay subroutine
;----------------
;
DELAY	DEY
	BNE	DELAY
	DEX
	BNE	DELAY
	RTS
;
;Erase players 0 & 1
;-------------------
;
ERASE	LDA	#0
	TAX
MP13	STA	PLR0,X	;Erase Plr0
	STA	PLR1,X	;Erase Plr1
	DEX
	BNE	MP13
	RTS
;
;Start scrolling & clock
;-----------------------
;
SCROLLIT	LDX	# >VBI
	LDY	# <VBI
	BNE	HALT2
;
;Disable VBLANK
;--------------
;
HALT	LDX	# >SYSVBV
	LDY	# <SYSVBV
HALT2	LDA	#6
	JMP	SETVBV
;
;Subroutine to draw players
;--------------------------
;
DRAW	LDX	YPOS	;Get vert pos
	LDY	#23	;# bytes to draw
DRAWLOOP	LDA	(IMAGEPTR),Y	;Get number
	STA	PLR1,X	;Put it in Plr1
	DEY
	LDA	(IMAGEPTR),Y	;Get another
	STA	PLR0,X	;Put it in Plr0
	DEX
	DEY
	BPL	DRAWLOOP	;Do until Y=255
	RTS
;
;Set skier to right
;------------------
;
RIGHT	JSR	TESTSPD
	INC	XPOS
	LDA	# <IM3	;Point to
	STA	IMAGEPTR	;right
	LDA	# >IM3	;skier
	STA	IMAGEPTR+1
	LDA	#6
	BNE	LEFT1
;
;Set skier to left
;-----------------
;
LEFT	JSR	TESTSPD
	DEC	XPOS
	LDA	# <IM1	;Point to
	STA	IMAGEPTR	;left
	LDA	# >IM1	;skier
	STA	IMAGEPTR+1
	LDA	#4
LEFT1	STA	AUDF1
	LDA	#12
LEFT2	STA	AUDC1
	JSR	DRAW
	JMP	CONTINUE
;
;Set skier to straight
;---------------------
;
STRAIGHT	JSR	TESTSPD
	LDA	# <IM2	;Point to
	STA	IMAGEPTR	;straight
	LDA	# >IM2	;skier
	STA	IMAGEPTR+1
	LDA	#2
	STA	AUDF1
	LDA	#8
	BNE	LEFT2
;
;Test scrolling speed
;--------------------
;
TESTSPD	LDA	SPEED
	CMP	#65	;Is it > maximum?
	BNE	MP14	;No
	DEC	SPEED	;Make maximum
	RTS
MP14	LDA	SPEED	;Speed < minimum?
	BNE	MP15	;No.
	INC	SPEED	;Make minimum
MP15	RTS
;
;Pause subroutine
;----------------
;
PAUSE	JSR	HALT	;Stop scrolling
	LDA	#255	;Reset last
	STA	CH	;key pressed
MP16	LDA	CONSOL	;Wait for OPTION
	CMP	#3	;to be
	BNE	MP16	;pressed
	JMP	SCROLLIT
;
;Gameover
;--------
;
ENDGAME	JSR	HALT	;Stop scrolling
	LDA	#121	;note C
	STA	AUDF1
	LDA	#166	;with pure tone
	STA	AUDC1	;and some volume
	LDX	#0	;hold the tone
	LDY	#0	;for a while
	JSR	DELAY
	LDA	#96	;note E
	STA	AUDF1
	LDA	#121	;note C
	STA	AUDF2
	LDA	#170	;with pure tone
	STA	AUDC1	;and more volume
	STA	AUDC2
	LDX	#128	;Hold tone half
	JSR	DELAY	;as long
	LDA	#81	;note G
	STA	AUDF1
	LDA	#96	;note E
	STA	AUDF2
	LDA	#172	;more volume
	STA	AUDC1
	STA	AUDC2
	LDX	#192	;Hold tone
	JSR	DELAY
	LDA	#60	;note C
	STA	AUDF1
	LDA	#81	;note G
	STA	AUDF2
	LDA	#174	;more volume
	STA	AUDC1
	STA	AUDC2
	JSR	DELAY	;Hold note twice
	JSR	DELAY	;as long as 1st
	LDA	#0
	STA	AUDC1	;Turn off
	STA	AUDC2	;sound
MP17	LDA	CONSOL	;See if START
	ROR	A	;pressed
	BCC	MP18
	LDA	STRIG0	;If trig pressed
	BNE	MP17	;start game over
MP18	JMP	INIT
;
;Crash!
;------
;
CRASH	LDA	#1	;Stop
	STA	SCROLFLG	;scrolling
	LDA	#15	;Set volume
	STA	VOLUME	;to loud
MP19	LDA	#255
	STA	AUDF1
	SBC	VOLUME	;255-VOLUME
	STA	AUDF2	;for Freq 2
	LDA	VOLUME	;dist 0+VOLUME
	STA	AUDC1	;for Ctrl 1
	ADC	#192	;Dist 12+VOLUME
	STA	AUDC2	;for Ctrl 2
	DEC	VOLUME	;Reduce volumn
	LDX	#20
	JSR	DELAY
	LDA	VOLUME	;See if VOLUME=0
	BNE	MP19
	LDA	# <IM4	;Point to
	STA	IMAGEPTR	;1st crashing
	LDA	# >IM4	;skier
	STA	IMAGEPTR+1	;image
	JSR	DRAW
	LDX	#30
	JSR	DELAY
	LDA	# <IM5	;Point to
	STA	IMAGEPTR	;2nd crashing
	LDA	# >IM5	;skier
	STA	IMAGEPTR+1	;image
	JSR	DRAW
	JSR	DELAY
	JSR	DELAY
	JSR	DELAY
	LDA	#0	;Enable
	STA	SCROLFLG	;scroll again
	LDA	# <IM2	;Stand
	STA	IMAGEPTR	;skier
	LDA	# >IM2	;up
	STA	IMAGEPTR+1	;again
	LDA	#1	;Reset speed
	STA	SPEED	;to slow
	JMP	DRAW
;
;Clear screen's 3rd line
;-----------------------
;
CLEAR3RD	LDA	#0
	LDY	#120
MP20	STA	(SAVMSC),Y
	DEY
	CPY	#79
	BNE	MP20
	RTS
;
;Test skier's X position
;-----------------------
;
TESTX	LDA	XPOS
	CMP	#47
	BNE	MP21
	INC	XPOS
	RTS
;
MP21	CMP	#196
	BNE	MP22
	DEC	XPOS
MP22	RTS
;
;VERTICAL BLANK INTERRUPT
;------------------------
;
VBI	LDA	SCROLFLG	;If not 0 do
	BNE	VBICLOCK	;not scroll
;
;Calculate scroll speed
;----------------------
;
	LDA	SPEED	;Current speed
	LSR	A	;/2
	LSR	A	;/4
	LSR	A	;/8
	LSR	A	;/16 If not zero
	BNE	VB1	;do fine scroll
	LDX	#1	;If 0 make it 1
	BNE	SCROLLON
;
VB1	TAX
;
;Perform fine scroll
;-------------------
;
SCROLLON	INC	SCROLLED	;lines scrolled
	LDA	SCROLLED
	STA	VSCROL	;put in vscrol
	CMP	#16	;reached limit?
	BEQ	COARSE	;coarse scroll
	DEX		;No. Scroll until
	BNE	SCROLLON	;X=0
	BEQ	VBICLOCK	;Handle clock
;
;Do a coarse scroll
;------------------
;
COARSE	LDA	#0	;Reset the fine
	STA	VSCROL	;scroll reg and #
	STA	SCROLLED	;lines scrolled
	LDA	DLIST+9	;DLIST's LO byte
	CLC
	ADC	#40	;Add 40 (1 line)
	STA	DLIST+9	;New LO byte
	BCC	COMPEND	;Over 256? No.
	INC	DLIST+10	;Inc HI byte
;
;Check on scrolling limit
;------------------------
;
COMPEND	LDA	TIMESFLG
	BNE	COMPDONE	;check scrolling
	LDA	DLIST+10	;DLIST HI byte
	CMP	# >SCRN4	;Reached end?
	BNE	VBICLOCK	;No, skip this
	LDA	DLIST+9	;Examine LO byte
	CMP	# <SCRN4	;LO byte limit?
	BNE	VBICLOCK	;No, Go on
	LDA	# >SCRN1	;Yes!
	STA	DLIST+10	;Flip back to
	LDA	# <SCRN1	;beginning of
	STA	DLIST+9	;course
	INC	TIMES	;Inc # of times
	LDA	TIMES	;course scrolled
	CMP	#10	;10 times?
	BNE	VBICLOCK	;No
	LDA	#1
	STA	TIMESFLG	;Set times flag
	BNE	VBICLOCK
;
;See if end of scrolling reached
;-------------------------------
;
COMPDONE	LDA	DLIST+10	;DLIST HI byte
	CMP	# >SCRLFIN	;Reached?
	BNE	VBICLOCK	;No
	LDA	DLIST+9	;DLIST LO byte
	CMP	# <SCRLFIN	;Reached?
	BNE	VBICLOCK	;No
	LDA	#1	;Set scroll flag
	STA	SCROLFLG
;
;Clock routine
;-------------
;
VBICLOCK	INC	CLOCK	;Inc the 60ths
	LDA	CLOCK
	CMP	#6	;6/60ths yet?
	BNE	PRTCLOCK	;No
	LDA	#0
	STA	CLOCK	;Reset to zero
	INC	CLOCK+1	;Inc 10ths cntr
	LDA	CLOCK+1
	CMP	#10	;10/10ths yet?
	BNE	PRTCLOCK	;Clock on scrn
	LDA	#0	;Yes!
	STA	CLOCK+1	;Reset to zero
	INC	CLOCK+3	;Inc seconds cntr
	LDA	CLOCK+3
	CMP	#10	;10 secs. yet?
	BNE	PRTCLOCK	;No, branch
	LDA	#0	;Yes!
	STA	CLOCK+3	;Reset to zero
	INC	CLOCK+4	;Inc 10s of secs
	LDA	CLOCK+4
	CMP	#6	;60 seconds yet?
	BNE	PRTCLOCK	;No, branch
	LDA	#0	;Yes!
	STA	CLOCK+4	;Reset to zero
	INC	CLOCK+6	;Inc minutes cntr
;
;Print clock on screen
;---------------------
;
PRTCLOCK	LDY	#87
	LDX	#6
VB2	LDA	CLOCK,X	;Get a character
	CLC
	ADC	#208	;Make screen val
	STA	(SAVMSC),Y	;Put on scrn
	INY
	DEX
	BNE	VB2
	JMP	SYSVBV
;
;SCROLLING SCRN DATA
;---------------------
;
SCRNBASE	.BYTE	0,50,51,52,53,54,0,0,0
	.BYTE	169,192,0,0,0,0,209,210
	.BYTE	0,0,0,0,209,210,0,27,70
	.BYTE	0,0,0,0,69,70,0,0,0,0,0
	.BYTE	0,0,0,55,56,57,58,59,60
	.BYTE	61,0,65,66,67,68,34,35
	.BYTE	0,214,0,0,0,0,0,214,29
	.BYTE	30,31,32,33,0,0,71,72
	.BYTE	73,74,0,0,0,0,0,0,0,0
	.BYTE	69,70,0,0,40,41,42,43,0
	.BYTE	0,0,37,38,39,0,0,0,0,0
	.BYTE	0,0,0,0,0,40,41,42,43,0
	.BYTE	0,0,0,41,64,0,0,0,0,0
	.BYTE	71,72,73,74,44,45,46,47
	.BYTE	48,49,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,44,45,46,47
	.BYTE	48,49,0,0,65,66,67,68,0
	.BYTE	0,0,0,75,76,77,0,41,64
	.BYTE	0,0,0,0,0,0,41,64,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0,34
	.BYTE	35,36,0,69,28,0,0,0,0,0
	.BYTE	0,0,78,79,80,65,66,67
	.BYTE	68,0,69,70,0,65,66,67,0
	.BYTE	0,212,213,128,0,0,0,212
	.BYTE	213,0,0,0,37,38,39,71
	.BYTE	72,73,74,0,0,0,0,0,0,0
	.BYTE	26,27,28,0,0,0,71,72,73
	.BYTE	74,69,28,0,0,41,64,215
	.BYTE	0,0,0,0,0,215,0,0,0,40
	.BYTE	41,42,43,0,0,26,27,28,0
	.BYTE	0,0,0,29,30,31,32,33,0
	.BYTE	34,35,36,0,71,72,73,74
	.BYTE	65,66,67,68,0,0,0,0,0,0
	.BYTE	0,0,44,45,46,47,48,49
	.BYTE	29,30,31,32,33,0,0,0,0
	.BYTE	0,0,0,0,0,37,38,39,40
	.BYTE	41,42,43,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0,0
	.BYTE	41,64,0,0,34,35,36,0,0
	.BYTE	0,27,28,0,0,69,70,0,44
	.BYTE	45,46,47,48,49,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,27,70,0
	.BYTE	0,65,66,67,68,0,37,38
	.BYTE	39,0,0,71,72,73,74,71
	.BYTE	72,73,74,0,0,0,0,209
	.BYTE	210,0,0,0,128,209,210,0
	.BYTE	0,0,0,0,71,72,73,74,0,0
	.BYTE	0,0,34,35,36,0,0,0,0,75
	.BYTE	76,77,0,50,51,52,53,54
	.BYTE	0,0,0,214,0,0,0,0,0,214
	.BYTE	0,0,69,70,0,0,41,64,0,0
	.BYTE	26,27,28,0,37,38,39,0
	.BYTE	69,70,0,78,79,80,55,56
	.BYTE	57,58,59,60,61,0,0,0,0
	.BYTE	0,0,0,0,0,0,71,72,73,74
	.BYTE	65,66,67,68,29,30,31,32
	.BYTE	33,0,0,0,71,72,73,0,0,0
	.BYTE	26,27,28,0,0,0,0,0,41
	.BYTE	64,0,0,0,0,0,0,0,0,0,0
	.BYTE	0,41,64,0,0,75,76,77,0
	.BYTE	0,0,40,41,42,43,0,0,0,0
	.BYTE	29,30,31,32,33,0,0,0,65
	.BYTE	66,67,68,0,0,0,0,0,0,0
	.BYTE	0,0,65,66,67,68,0,78,79
	.BYTE	80,0,0,44,45,46,47,48
	.BYTE	49,0,0,0,50,51,52,53,54
	.BYTE	0,0,0,0,0,0,69,70,0,128
	.BYTE	209,210,0,0,128,128,209
	.BYTE	210,0,27,70,0,0,0,0,34
	.BYTE	35,36,0,0,41,64,0,0,55
	.BYTE	56,57,58,59,60,61,34,35
	.BYTE	36,0,71,72,73,74,0,214
	.BYTE	0,0,0,0,0,214,29,30,31
	.BYTE	32,33,0,0,0,37,38,39,0
	.BYTE	65,66,67,68,0,0,0,0,0
	.BYTE	34,35,0,37,38,40,41,42
	.BYTE	43,0,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,69,28,0,0,27,70
	.BYTE	0,0,0,0,0,0,0,0,0,0,0
	.BYTE	37,38,39,0,44,45,46,47
	.BYTE	48,49,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,71,72,73,74,71,72
	.BYTE	73,74,0,27,70,0,0,0,0
	.BYTE	41,64,0,0,0,27,70,0,0,0
	.BYTE	0,0,26,27,28,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,41,64,0
	.BYTE	0,29,30,31,32,33,0,0,65
	.BYTE	66,67,68,29,30,31,32,33
	.BYTE	0,0,0,29,30,31,32,33,75
	.BYTE	76,77,212,213,0,0,0,128
	.BYTE	212,213,65,66,67,68,0
	.BYTE	69,70,0,0,0,0,0,0,0,27
	.BYTE	70,0,0,0,0,0,40,41,42
	.BYTE	43,0,0,0,0,78,79,80,0
	.BYTE	215,0,0,0,0,0,215,0,0,0
	.BYTE	0,71,72,73,74,0,0,0,0
	.BYTE	29,30,31,32,33,0,0,0,44
	.BYTE	45,46,47,48,49,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0,0,0
	.BYTE	41,64,0,0,26,27,28,0,0
	.BYTE	0,0,0,0,0,0,75,76,77,0
	.BYTE	0,0,0,0,0,75,76,77,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,0,65
	.BYTE	66,67,68,29,30,31,32,33
	.BYTE	0,0,0,41,64,0,0,78,79
	.BYTE	80,0,69,70,0,0,0,78,79
	.BYTE	80,0,0,0,0,0,0,0,0,0,0
	.BYTE	34,35,36,0,0,41,64,0,0
	.BYTE	69,28,0,0,65,66,67,68,0
	.BYTE	27,70,0,71,72,73,74,34
	.BYTE	35,36,0,0,212,213,0,0,0
	.BYTE	0,212,213,0,0,37,38,39
	.BYTE	0,65,66,67,68,71,72,73
	.BYTE	74,0,0,0,0,0,71,72,73
	.BYTE	74,0,0,0,0,37,38,39,0,0
	.BYTE	0,215,0,0,0,0,0,215,0,0
	.BYTE	0,0,0,69,70,0,0,0,0,0,0
	.BYTE	0,0,0,168,169,170,171,0
	.BYTE	0,0,26,27,28,0,0,0,0,0
	.BYTE	0,0,0,0,0,0,0,0,0,40,41
	.BYTE	42,43,71,72,73,74,0,75
	.BYTE	76,77,0,0,0,172,173,46
	.BYTE	47,48,49,0,29,30,31,32
	.BYTE	33,0,0,41,64,0,0,0,0,0
	.BYTE	0,0,0,44,45,46,47,48,49
	.BYTE	0,41,64,0,78,79,80,0,0
	.BYTE	0,0,0,0,0,197,198,0,0,0
	.BYTE	128,0,0,0,65,66,67,68,0
	.BYTE	0,0,0,0,0,0,0,0,0,0,0,0
	.BYTE	65,66,67,68,0,26,27,28
	.BYTE	0,0,0,0,0,71,72,73,74,0
	.BYTE	41,64,0,0,0,0,0,0,209
	.BYTE	210,128,0,128,128,209
	.BYTE	210,0,0,50,51,52,53,54
	.BYTE	0,0,0,29,30,31,32,33,0
	.BYTE	0,0,0,0,0,0,0,65,66,67
	.BYTE	68,0,0,0,0,0,214,0,0,0
	.BYTE	0,0,214,0,0,55,56,57,58
	.BYTE	59,60,61,0,0,27,70,0,0
	.BYTE	0,0,0,0,27,70,0,0,34,35
	.BYTE	36,0,0,40,41,42,43,0,0
	.BYTE	0,0,0,0,0,0,69,70,0,0
	.BYTE	41,64,0,0,0,29,30,31,32
	.BYTE	33,0,0,0,0,71,72,73,74
	.BYTE	0,37,38,39,0,44,45,46
	.BYTE	47,48,49,0,0,0,0,0,0,71
	.BYTE	72,73,74,65,66,67,68,0
	.BYTE	41,42,43,0,0,34,35,0,0
	.BYTE	0,41,64,0,0,0,0,0,75,76
	.BYTE	77,0,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,41,64,0,0,44
	.BYTE	45,46,47,48,49,0,37,38
	.BYTE	0,0,65,66,67,68,0,0,0,0
	.BYTE	0,79,80,0,0,0,0,0,0,0,0
	.BYTE	0,0,0,0,0,65,66,67,68,0
	.BYTE	0,0,0,0,0,0,0,0,0,0,0
;
	*=	$02E0
;
	.WORD	PRGSTART
	.END