10 ;  УГТПММ ›20 ;›30 ; COPYRIGHT (C) 1982 BY DAVID FOX AND MITCHELL WAITE›40 ;›0100  .TITLE "CLK-SCROLL.ASM;v01.09-810719,820619"›0110  .PAGE "Interrupt-driven Screen Scroller"›0120 ;›0130 ; BY COREY L. KOSAK›0140 ;›0150 ; B=$4000,FREL›0160 ;›0170 BASE=$4000›0180 ;›0190  *=$400›0200 ;›0210 ; CASBUF DATABASE EQUATES›0220 ;›0230 PMBAS *=*+1 ;HIBYTE OF PLAYER MISSILE AREA (LOBYTE EQUALS 0)›0240 PMBUF *=*+2 ;ADDRESS OF 128 BYTE BUFFER (FOR PMOVER)›0250 ANIMINIT *=*+1 ;INIT LOCATION FOR ANIMATE›0260 AUTOINIT *=*+1 ;INIT LOCATION FOR AUTOMOVE›0270 SCRLINIT *=*+1 ;INIT LOCATION FOR SCROLLER›0280 HPLR *=*+4 ;PLAYERS 0-3 X COORDINATE (FOR PMOVER)›0290 VPLR *=*+4 ;PLRS 0-3 Y COORD (FOR PMOVER)›0300 RATE *=*+4 ;PLRS 0-3 RATE (FOR ANIMATE)›0310 FLSTPTR *=*+8 ;PLRS 0-3 FRAME LIST POINTERS (FOR ANIMATE)›0320 SCRLADR *=*+2 ;SCREEN ADDRESS (FOR SCROLL)›0330 SCRLLEN *=*+2 ;LINE LENGTH OF SCROLLED AREA (FOR SCROLL)›0340 SCRLCLK *=*+1 ;COLOR CLOCKS IN SCREEN BYTE (FOR SCROLL)›0350 SCRLSTEP *=*+1 ;SCROLL STEP (FOR SCROLL)›0360 MOVERATE *=*+4 ;PLRS 0-3 HORIZONTAL STEP (FOR AUTOMOVE)›0370 DLIADR *=*+2 ;ADDRESS OF COLOR TABLE›0380 ;›0390 ;*LOCAL* DATABASE EQUATES›0400 ; THESE LOCATIONS ARE *LOCAL* TO THE ROUTINES›0410 ; AND SHOULD *NOT* BE MODIFIED BY THE HOST PROGRAM›0420 ;›0430 O0X *=*+4 ;PLRS 0-3 X COORDINATE›0440 O0Y *=*+4 ;PLRS 0-3 Y COORD›0450 ORATE0 *=*+4 ;PLRS 0-3 FRAME CHANGE RATE›0460 OADR0 *=*+8 ;PLRS 0-3 FRAME LIST ADDRESS›0470 TIMR0 *=*+4 ;PLRS 0-3 COUNTDOWN TIMERS (HOW MANY JIFFIES UNTIL FRAME CHANGE)›0480 POS0 *=*+4 ;PLRS 0-3 FRAME LIST POSITION›0490 OSADR *=*+2 ;SCREEN ADDRESS FOR SCROLLER›0500 CPOS *=*+2 ;COARSE SCROLL POSITION FOR SCROLLER (0-SCRLLEN)›0510 FPOS *=*+1 ;FINE SCROLL POSITION (0-7)›0520 OXSTEP0 *=*+4 ;PLRS 0-3 HORIZONTAL STEP›0530 DLIPOS *=*+1 ;CURRENT POSITION IN COLOR TABLE›0540 PM1 *=*+1 ;4 LOCATIONS RESERVED FOR PMOVER›0550 PM2 *=*+1›0560 PM3 *=*+1›0570 PM4 *=*+1›0580 EX1 *=*+1 ;4 LOCATIONS RESERVED FOR ANIMATE, AUTOMOVE, SCROLL, AND MFILL›0590 EX2 *=*+1›0600 EX3 *=*+1›0610 EX4 *=*+1›0620 PMSAVE *=*+5 ;ZERO PAGE SAVE AREA FOR PMOVER›0630 ZSAVE *=*+4 ;ZERO PAGE SAVE AREA FOR ALL OTHER ROUTINES›0640 ;›0650 XITVBV=$E462›0660 HSCROLL=$D404›0670 SDLSTL=$230›0680 ;›0690 ZERO=$E0›0700 ONE=$E2›0710 ;›0720  *=BASE›0730 ;›0740 START›0750  CLV›0760  BVC START1 ;SKIP OVER VBLANK EXIT ROUTINE›0770 ;›0780 EXIT›0790  JMP XITVBV›0800 ;›0810 START1›0820  CLD  ;CLEAR DECIMAL MODE FOR ATARI BASIC!›0830  LDA SCRLINIT ;IS THE INIT BYTE SET?›0840  BEQ EXIT ;NO, LEAVE›0850  BPL BBINIT2 ;YES, INIT EVERYTHING›0860 ;›0870  LDA ZERO ;SAVE ZERO PAGE TEMPS›0880  STA ZSAVE›0890  LDA ZERO+1›0900  STA ZSAVE+1›0910  LDA SDLSTL ;MOVE DISPLAY LIST POINTER›0920  STA ZERO ;INTO TEMPORARY POINTER›0930  LDA SDLSTL+1›0940  STA ZERO+1›0950 ;›0960 ; NOW WE SPLIT SCRLSTEP INTO A COARSE›0970 ; AND FINE STEP, AND ALSO COMPUTE, VIA›0980 ; SCRLCLK, THE NUMBER OF BYTES PER SCREEN LINE (IN WIDE PLAYFIELD)›0990 ;›1000  LDA SCRLCLK ;MOVE CLOCK VALUE TO EX1›1010  STA EX1›1020  LDA #$C0 ;BYTES PER MODE LINE›1030  STA EX2›1040  LDA SCRLSTEP ;SHIFT OUT FINE SCROLL›1050  LDY #$00 ;OFFSET IN SCREEN BYTE TABLE›1060 CLOOP›1070  LSR EX1 ;SHIFT RIGHT CLOCK VALUE›1080  BCC CDONE ;ANY BITS LEFT?›1090  LSR A ;YES, SHIFT SCROLL VALUE›1100  LSR EX2 ;DIVIDE MODE LINE LENGTH BY 2›1110  INY ;AND BUMP POINTER›1120  BNE CLOOP ;ALWAYS TAKEN›1130 CDONE›1140  STA EX1 ;STORE COARSE STEP›1150 ;›1160  LDA SCRLSTEP›1170  AND SCRLCLK ;GET FINE STEP›1180 ;›1190  CLC›1200  ADC FPOS ;ADD CURRENT FINESCROLL VALUE›1210  CMP SCRLCLK ;DID IT GO OVER CLOCK VALUE?›1220  BEQ OK ;NOPE.›1230  BCC OK ;NOPE.›1240  BCS INCIT ;SKIP OVER BUCKET-BRIGADES›1250 ;›1260 BBEXIT2›1270  BVC EXIT›1280 BBINIT2›1290  BNE BBINIT›1300 ;›1310 INCIT›1320  INC EX1 ;YES. INCREMENT COARSE STEP›1330  AND SCRLCLK ;AND PUT FINE STEP IN RANGE›1340 ;›1350 OK›1360  STA FPOS ;STORE IN CURRENT SCROLL VALUE›1370  EOR SCRLCLK ;HSCROLL REGISTER IS›1380  STA HSCROLL ;'BACKWARDS'›1390 ;›1400  LDA EX1 ;GET COARSE SCROLL STEP›1410  CLC›1420  ADC CPOS ;ADD CURRENT SCROLL VALUE›1430  STA CPOS ;AND STORE BACK›1440  BCC OK4›1450  INC CPOS+1›1460 ;›1470 OK4›1480  LDA CPOS ;ADD EX2+1 TO TEST FOR›1490  SEC  ;END OF SCREEN›1500  ADC EX2›1510  STA CPOS›1520  BCC OK5›1530  INC CPOS+1›1540 OK5›1550  LDA CPOS+1›1560  CMP SCRLLEN+1 ;HAVE WE SCROLLED TO EDGE OF SCREEN?›1570  BCC OK2 ;NO, WE'RE OK›1580  BNE RESET ;YES, SET BACK TO BEGINNING›1590  LDA CPOS ;MAYBE?›1600  CMP SCRLLEN›1610  BCC OK2 ;NO, WE'RE OK›1620 RESET›1630  LDA #$00 ;SET POINTERS TO BEGINNING OF›1640  STA CPOS ;SCREEN LINE›1650  STA CPOS+1›1660  STA EX1›1670  LDA SCRLADR ;MOVE START ADDRESS›1680  STA OSADR ;OF SCROLL WINDOW›1690  LDA SCRLADR+1 ;INTO LOCAL AREA›1700  STA OSADR+1›1710  CLV ;JUMP OVER BUCKET BRIGADE BRANCHES›1720  BVC OK6 ;AND DON'T SUBTRACT EX2›1730 ;›1740 BBINIT›1750  BNE INIT›1760 BBEXIT›1770  BVC BBEXIT2›1780 ;›1790 OK2›1800  LDA CPOS ;SUBTRACT THE EX2 WE ADDED EARLIER›1810  CLC›1820  SBC EX2›1830  STA CPOS›1840  BCS OK6›1850  DEC CPOS+1›1860 OK6›1870  LDA OSADR›1880  CLC›1890  ADC EX1 ;ADD STEP TO SCREEN ADDRESS›1900  STA OSADR ;AND MOVE INTO EX3 AND EX4›1910  STA EX3›1920  BCC OK3›1930  INC OSADR+1›1940 ;›1950 OK3›1960  LDA OSADR+1›1970  STA EX4›1980  LDY #$03 ;SKIP OVER FIRST THREE DL INSTRUCTIONS›1990 LOOP›2000  LDA (ZERO),Y ;GET BYTE IN DISPLAY LIST›2010  CMP #$41 ;JVB? (END OF DLIST?)›2020  BEQ DONE ;YES, QUIT›2030 ;›2040  AND #$50 ;HSCROLL OR LMS BITS SET?›2050  BEQ NOCHANGE ;NO, FORGET IT›2060  AND #$10 ;HSCROLL SET?›2070  BEQ NSCROLL ;NO, SKIP OVER NEXT TWO BYTES›2080  INY ;NEXT 2 BYTES ARE MEMORY ADDRESS OF CURRENT LINE›2090  LDA EX3 ;MOVE SCREEN ADDRESS›2100  STA (ZERO),Y ;INTO DISPLAY LIST›2110  CLC›2120  ADC SCRLLEN ;AND ADD SCRLLENGTH›2130  STA EX3›2140  INY›2150  LDA EX4 ;DO HIBYTE›2160  STA (ZERO),Y›2170  ADC SCRLLEN+1›2180  STA EX4›2190 ;›2200  .BYTE $AD ;"LDA ABSOLUTE" OPCODE SKIPS NEXT 2 BYTES›2210 ;›2220 NSCROLL›2230  INY›2240  INY›2250 ;›2260 NOCHANGE›2270  INY›2280  BNE LOOP ;ALWAYS (DISPLAY LIST MUSTN'T BE LONGER THAN 256 BYTES)›2290 ;›2300 BBEXIT3›2310  BVC BBEXIT›2320 ;›2330 DONE›2340  LDA ZSAVE ;RESTORE ZERO PAGE TEMPS›2350  STA ZERO›2360  LDA ZSAVE+1›2370  STA ZERO+1›2380  CLV›2390  BVC BBEXIT›2400 ;›2410 INIT›2420  LDA #$80›2430  STA SCRLINIT ;SET INIT BYTE TO "ON"›2440  LDA SCRLCLK ;SET SCROLL POINTERS TO LEFT OF SCREEN›2450  STA FPOS›2460  LDA #$00›2470  STA CPOS›2480  STA CPOS+1›2490  LDA SCRLADR ;MOVE SCREEN ADDRESS TO LOCAL AREA›2500  STA OSADR›2510  LDA SCRLADR+1›2520  STA OSADR+1›2530 LEAVE›2540  CLV›2550  BVC BBEXIT3 ;LEAVE.›2560 ;›2570  .END›