S-C DocuMentor — Applesoft

               SAVE S.F3D8
               1010 *--------------------------------
               1020 *      "HGR" AND "HGR2" STATEMENTS
               1030 *--------------------------------
F3D8- 2C 55 C0 1040 HGR2   BIT SW.HISCR      SELECT PAGE 2 ($4000-5FFF)
F3DB- 2C 52 C0 1050        BIT SW.MIXCLR     DEFAULT TO FULL SCREEN
F3DE- A9 40    1060        LDA /$4000        SET STARTING PAGE FOR HIRES
F3E0- D0 08    1070        BNE SETHPG        ...ALWAYS
F3E2- A9 20    1080 HGR    LDA /$2000        SET STARTING PAGE FOR HIRES
F3E4- 2C 54 C0 1090        BIT SW.LOWSCR     SELECT PAGE 1 ($2000-3FFF)
F3E7- 2C 53 C0 1100        BIT SW.MIXSET     DEFAULT TO MIXED SCREEN
F3EA- 85 E6    1110 SETHPG STA HGR.PAGE          BASE PAGE OF HIRES BUFFER
F3EC- AD 57 C0 1120        LDA SW.HIRES      TURN ON HIRES
F3EF- AD 50 C0 1130        LDA SW.TXTCLR     TURN ON GRAPHICS
               1140 *--------------------------------
               1150 *      CLEAR SCREEN
               1160 *--------------------------------
F3F2- A9 00    1170 HCLR   LDA #0            SET FOR BLACK BACKGROUND
F3F4- 85 1C    1180        STA HGR.BITS
               1190 *--------------------------------
               1200 *      FILL SCREEN WITH (HGR.BITS)
               1210 *--------------------------------
F3F6- A5 E6    1220 BKGND  LDA HGR.PAGE     PUT BUFFER ADDRESS IN HGR.SHAPE
F3F8- 85 1B    1230        STA HGR.SHAPE+1
F3FA- A0 00    1240        LDY #0
F3FC- 84 1A    1250        STY HGR.SHAPE
F3FE- A5 1C    1260 .1     LDA HGR.BITS  COLOR BYTE
F400- 91 1A    1270        STA (HGR.SHAPE),Y  CLEAR HIRES TO HGR.BITS
F402- 20 7E F4 1280        JSR COLOR.SHIFT   CORRECT FOR COLOR SHIFT
F405- C8       1290        INY          (SLOWS CLEAR BY FACTOR OF 2)
F406- D0 F6    1300        BNE .1
F408- E6 1B    1310        INC HGR.SHAPE+1
F40A- A5 1B    1320        LDA HGR.SHAPE+1
F40C- 29 1F    1330        AND #$1F     DONE?  ($40 OR$60)
F40E- D0 EE    1340        BNE .1       NO
F410- 60       1350        RTS          YES, RETURN
               1360 *--------------------------------
               1370 *      SET THE HIRES CURSOR POSITION
               1380 *
               1390 *      (Y,X) = HORIZONTAL COORDINATE  (0-279)
               1400 *      (A)   = VERTICAL COORDINATE    (0-191)
               1410 *--------------------------------
F411- 85 E2    1420 HPOSN  STA HGR.Y       SAVE Y- AND X-POSITIONS
F413- 86 E0    1430        STX HGR.X
F415- 84 E1    1440        STY HGR.X+1
F417- 48       1450        PHA          Y-POS ALSO ON STACK
F418- 29 C0    1460        AND #$C0     CALCULATE BASE ADDRESS FOR Y-POS
F41A- 85 26    1470        STA MON.GBASL     FOR Y=ABCDEFGH
F41C- 4A       1480        LSR               GBASL=ABAB0000
F41D- 4A       1490        LSR
F41E- 05 26    1500        ORA MON.GBASL
F420- 85 26    1510        STA MON.GBASL
F422- 68       1520        PLA                (A)      (GBASH)   (GBASL)
F423- 85 27    1530        STA MON.GBASH  ?-ABCDEFGH  ABCDEFGH  ABAB0000
F425- 0A       1540        ASL            A-BCDEFGH0  ABCDEFGH  ABAB0000
F426- 0A       1550        ASL            B-CDEFGH00  ABCDEFGH  ABAB0000
F427- 0A       1560        ASL            C-DEFGH000  ABCDEFGH  ABAB0000
F428- 26 27    1570        ROL MON.GBASH  A-DEFGH000  BCDEFGHC  ABAB0000
F42A- 0A       1580        ASL            D-EFGH0000  BCDEFGHC  ABAB0000
F42B- 26 27    1590        ROL MON.GBASH  B-EFGH0000  CDEFGHCD  ABAB0000
F42D- 0A       1600        ASL            E-FGH00000  CDEFGHCD  ABAB0000
F42E- 66 26    1610        ROR MON.GBASL  0-FGH00000  CDEFGHCD  EABAB000
F430- A5 27    1620        LDA MON.GBASH  0-CDEFGHCD  CDEFGHCD  EABAB000
F432- 29 1F    1630        AND #$1F       0-000FGHCD  CDEFGHCD  EABAB000
F434- 05 E6    1640        ORA HGR.PAGE   0-PPPFGHCD  CDEFGHCD  EABAB000
F436- 85 27    1650        STA MON.GBASH  0-PPPFGHCD  PPPFGHCD  EABAB000
F438- 8A       1660        TXA          DIVIDE X-POS BY 7 FOR INDEX FROM BASE
F439- C0 00    1670        CPY #0       IS X-POS < 256?
F43B- F0 05    1680        BEQ .2       YES
F43D- A0 23    1690        LDY #35      NO: 256/7 = 36 REM 4
               1700 *                   CARRY=1, SO ADC #4 IS TOO LARGE;
               1710 *                   HOWEVER, ADC #4 CLEARS CARRY
               1720 *                   WHICH MAKES SBC #7 ONLY -6
               1730 *                   BALANCING IT OUT.
F43F- 69 04    1740        ADC #4       FOLLOWING INY MAKES Y=36
F441- C8       1750 .1     INY
F442- E9 07    1760 .2     SBC #7
F444- B0 FB    1770        BCS .1
F446- 84 E5    1780        STY HGR.HORIZ     HORIZONTAL INDEX
F448- AA       1790        TAX          USE REMAINDER-7 TO LOOK UP THE
F449- BD B9 F4 1800        LDA MSKTBL-$100+7,X  BIT MASK
F44C- 85 30    1810        STA MON.HMASK
F44E- 98       1820        TYA          QUOTIENT GIVES BYTE INDEX
F44F- 4A       1830        LSR          ODD OR EVEN COLUMN?
F450- A5 E4    1840        LDA HGR.COLOR  IF ON ODD BYTE (CARRY SET)
F452- 85 1C    1850        STA HGR.BITS  THEN ROTATE BITS
F454- B0 28    1860        BCS COLOR.SHIFT   ODD COLUMN
F456- 60       1870        RTS          EVEN COLUMN
               1880 *--------------------------------
               1890 *      PLOT A DOT
               1900 *
               1910 *      (Y,X) = HORIZONTAL POSITION
               1920 *      (A)   = VERTICAL POSITION
               1930 *--------------------------------
F457- 20 11 F4 1940 HPLOT0 JSR HPOSN
F45A- A5 1C    1950        LDA HGR.BITS      CALCULATE BIT POSN IN GBAS,
F45C- 51 26    1960        EOR (MON.GBASL),Y HGR.HORIZ, AND HMASK FROM
F45E- 25 30    1970        AND MON.HMASK     Y-COOR IN A-REG,
F460- 51 26    1980        EOR (MON.GBASL),Y X-COOR IN X,Y REGS.
F462- 91 26    1990        STA (MON.GBASL),Y FOR ANY 1-BITS, SUBSTITUTE
F464- 60       2000        RTS               CORRESPONDING BIT OF HGR.BITS
               2010 *--------------------------------
               2020 *      MOVE LEFT OR RIGHT ONE PIXEL
               2030 *
               2040 *      IF STATUS IS +, MOVE RIGHT; IF -, MOVE LEFT
               2050 *      IF ALREADY AT LEFT OR RIGHT EDGE, WRAP AROUND
               2060 *
               2070 *      REMEMBER BITS IN HI-RES BYTE ARE BACKWARDS ORDER:
               2080 *          BYTE N   BYTE N+1
               2090 *        S7654321   SEDCBA98
               2100 *--------------------------------
               2110 MOVE.LEFT.OR.RIGHT
F465- 10 23    2120        BPL MOVE.RIGHT  + MOVE RIGHT, - MOVE LEFT
F467- A5 30    2130        LDA MON.HMASK     MOVE LEFT ONE PIXEL
F469- 4A       2140        LSR          SHIFT MASK RIGHT, MOVES DOT LEFT
F46A- B0 05    2150        BCS LR.2     ...DOT MOVED TO NEXT BYTE
F46C- 49 C0    2160        EOR #$C0     MOVE SIGN BIT BACK WHERE IT WAS
F46E- 85 30    2170 LR.1   STA MON.HMASK     NEW MASK VALUE
F470- 60       2180        RTS
F471- 88       2190 LR.2   DEY          MOVED TO NEXT BYTE, SO DECR INDEX
F472- 10 02    2200        BPL LR.3     STILL NOT PAST EDGE
F474- A0 27    2210        LDY #39      OFF LEFT EDGE, SO WRAP AROUND SCREEN
F476- A9 C0    2220 LR.3   LDA #$C0     NEW HMASK, RIGHTMOST BIT ON SCREEN
F478- 85 30    2230 LR.4   STA MON.HMASK     NEW MASK AND INDEX
F47A- 84 E5    2240        STY HGR.HORIZ
F47C- A5 1C    2250        LDA HGR.BITS       ALSO NEED TO ROTATE COLOR
               2260 *--------------------------------
               2270 COLOR.SHIFT
F47E- 0A       2280        ASL          ROTATE LOW-ORDER 7 BITS
F47F- C9 C0    2290        CMP #$C0      OF HGR.BITS ONE BIT POSN.
F481- 10 06    2300        BPL .1
F483- A5 1C    2310        LDA HGR.BITS
F485- 49 7F    2320        EOR #$7F
F487- 85 1C    2330        STA HGR.BITS
F489- 60       2340 .1     RTS
               2350 *--------------------------------
               2360 *      MOVE RIGHT ONE PIXEL
               2370 *      IF ALREADY AT RIGHT EDGE, WRAP AROUND
               2380 *--------------------------------
               2390 MOVE.RIGHT
F48A- A5 30    2400        LDA MON.HMASK
F48C- 0A       2410        ASL          SHIFTING BYTE LEFT MOVES PIXEL RIGHT
F48D- 49 80    2420        EOR #$80
               2430 *          ORIGINAL:  C0 A0 90 88 84 82 81
               2440 *          SHIFTED:   80 40 20 10 08 02 01
               2450 *          EOR #$80:  00 C0 A0 90 88 84 82
F48F- 30 DD    2460        BMI LR.1     FINISHED
F491- A9 81    2470        LDA #$81     NEW MASK VALUE
F493- C8       2480        INY          MOVE TO NEXT BYTE RIGHT
F494- C0 28    2490        CPY #40      UNLESS THAT IS TOO FAR
F496- 90 E0    2500        BCC LR.4     NOT TOO FAR
F498- A0 00    2510        LDY #0       TOO FAR, SO WRAP AROUND
F49A- B0 DC    2520        BCS LR.4     ...ALWAYS
               2530 *--------------------------------