
 1000  *SAVE S.KNOUSE'S MONITOR PATCHES
 1010  *--------------------------------
 1020  *
 1030  *  A COMPILATION OF MONITOR MODIFICATIONS
 1040  *--------------------------------
 1050  YES        .EQ 1
 1060  NO         .EQ 0
 1070  *
 1080  *  OPTIONS
 1090  *
 1100  NFC        .EQ YES  SET TO YES IF YOU WANT
 1110  *                   A NON-FLASHING CURSOR
 1120  LOWERCASE  .EQ YES  SET TO YES IF YOU CAN
 1130  *                   DISPLAY LOWER CASE
 1140  W.APPLESOFT .EQ YES SET TO YES IF YOU WANT
 1150  *                   TO MOVE APPLESOFT WITH
 1160  *                   THE MONITOR, ELSE SET
 1170  *                   TO NO IF YOU ONLY WANT
 1180  *                   TO MOVE AND MODIFY THE
 1190  *                   MONITOR
 1200  *--------------------------------
 1210  PNTR   .EQ $00,01
 1220  PATCH  .EQ $02,03
 1230  A1L    .EQ $3C
 1240  A1H    .EQ A1L+1
 1250  A2L    .EQ $3E
 1260  A2H    .EQ A2L+1
 1270  A4L    .EQ $42
 1280  A4H    .EQ A4L+1
 1290  BASL   .EQ $28
 1300  CH     .EQ $24
 1310  KSWL   .EQ $38  
 1320  *--------------------------------
 1330  COUT       .EQ $FDED      
 1340  CRMON      .EQ $FEF6
 1350  CROUT      .EQ $FD8E
 1360  MON.HEADR  .EQ $FCC9
 1370  MON.MOVE   .EQ $FE2C
 1380  NXTA1      .EQ $FCBA
 1390  PRA1       .EQ $FD92
 1400  PRBYTE     .EQ $FDDA
 1410  PRERR      .EQ $FF2D
 1420  RDKEY      .EQ $FD0C
 1430  MON.READ   .EQ $FEFD
 1440  MON.WRITE  .EQ $FECD
 1450  *--------------------------------
 1460  ROMR.RAMW  .EQ $C081
 1470  RAMRW      .EQ $C083
 1480  *--------------------------------
 1490  *
 1500  *  GENERAL PURPOSE PATCHER
 1510  *
 1520  *--------------------------------
 1530         .OR $2D0
 1540         .DO W.APPLESOFT
 1550             .TF PATCH MONITOR & APPLESOFT
 1560  MON.START  .EQ $D000
 1570         .ELSE
 1580             .TF PATCH MONITOR ONLY
 1590  MON.START  .EQ $F800
 1600         .FIN
 1610  MON.END    .EQ $FFFF
 1620  *--------------------------------
 1630  PATCH.MONITOR
 1640         LDA #MON.START    COPY MONITOR TO RAM CARD
 1650         STA A4L
 1660         STA A1L
 1670         LDA /MON.START    
 1680         STA A4H
 1690         STA A1H
 1700         LDA #MON.END
 1710         STA A2L
 1720         LDA /MON.END
 1730         STA A2H
 1740         LDA ROMR.RAMW     WRITE ENABLE RAM CARD
 1750         LDA ROMR.RAMW     BY 2 OF THESE
 1760         LDY #0            SET UP MON.MOVE
 1770         JSR MON.MOVE      COPY FROM MOTHERBOARD TO RAMCARD
 1780  *
 1790         LDA #PATCHES-1
 1800         STA PNTR
 1810         LDA /PATCHES-1
 1820         STA PNTR+1
 1830         LDY #0
 1840  *
 1850  .1     JSR GET.BYTE LENGTH OF NEXT PATCH
 1860         BEQ .4
 1870         TAX          SAVE LENGTH IN X
 1880         JSR GET.BYTE GET ADDR OF PATCH
 1890         STA PATCH
 1900         JSR GET.BYTE
 1910         STA PATCH+1
 1920  *
 1930  .2     JSR GET.BYTE    GET A BYTE
 1940         STA (PATCH),Y   STORE AT DESTINATION
 1950         INC PATCH       BUMP SOURCE ADDRESS
 1960         BNE .3
 1970         INC PATCH+1
 1980  .3     DEX             DECREMENT NUMBER OF BYTES
 1990         BNE .2          LOOP FOR MORE
 2000         BEQ .1      ... ALWAYS
 2010  *
 2020         .DO W.APPLESOFT
 2030  .4     LDA RAMRW 
 2040         RTS
 2050         .ELSE
 2060  .4     RTS
 2070         .FIN
 2080  *--------------------------------
 2090  GET.BYTE
 2100         INC PNTR
 2110         BNE .1
 2120         INC PNTR+1
 2130  .1     LDA (PNTR),Y
 2140         RTS
 2150  *--------------------------------
 2160         .MA PATCH
 2170  ]1.ORG .EQ ]2
 2180         .DA #]1.LENGTH
 2190         .DA ]1.ORG
 2200         .PH ]1.ORG
 2210  ]1
 2220         .EM
 2230  *
 2240         .MA ENDP
 2250  ]1.END .EQ *-1
 2260  ]1.LENGTH  .EQ *-]1
 2270         .EP
 2280         .EM
 2290  *--------------------------------
 2300  PATCHES    .EQ *    
 2310  *--------------------------------
 2320  *  MONITOR LOWERCASE INPUT ROUTINE
 2330  *--------------------------------
 2340  *
 2350  *---DON'T STOMP ON LOWERCASE-----
 2360      >PATCH NOP.CONVERT,$FD82
 2370         AND #$FF     DO NOTHING
 2380      >ENDP  NOP.CONVERT
 2390  *
 2400  *---MAKE SENSIBLE CURSOR---------
 2410      >PATCH HANDLE.CURSOR,$FBB3
 2420         CMP #$E0     IS IT LOWER CASE?
 2430         BCS .1
 2440         AND #$3F     NO - MAKE CHAR INVERSE
 2450         .DO NFC
 2460         ORA #$00
 2470         .ELSE
 2480         ORA #$40     THEN FLASHING
 2490         .FIN
 2500         RTS
 2510  .1     AND #$1F     CONVERT TO UC INVERSE
 2520         RTS
 2530      >ENDP  HANDLE.CURSOR
 2540  *
 2550  *---CALL NEW CURSOR ROUTINE------
 2560      >PATCH VEC.HANDLE.CURSOR,$FD11
 2570         JSR HANDLE.CURSOR  GO TO PATCH
 2580         NOP          FILL BYTE
 2590      >ENDP  VEC.HANDLE.CURSOR
 2600  *--------------------------------
 2610  *  ASCII DUMP
 2620  *--------------------------------
 2630  *
 2640  *---MODIFIED DUMPER--------------
 2650      >PATCH ASC.DUMP,MON.HEADR 
 2660         PHA          SAVE CHAR
 2670         LDA A1L      GET LO ADDR BYTE
 2680         AND #$07     MOD 8
 2690         CLC          ADD DISPLACEMENT
 2700         ADC #30        OF 30 CHAR
 2710         TAY
 2720         PLA          RECOVER CHARACTER
 2730         PHA          SAVE IT AGAIN
 2740         ORA #$80     FORCE NORMAL VIDEO
 2750         CMP #$A0     MAKE CONTROL CHAR INVERSE
 2760         BCS .1       ...NOT CONTROL
 2770         .DO LOWERCASE
 2780         AND #$7F     ...CONTROL
 2790  .1     STA (BASL),Y PUT ON SCREEN
 2800         NOP          TO STAY ALIGNED W/
 2810         NOP          NON-LOWERCASE CODE
 2820         NOP
 2830         NOP
 2840         NOP
 2850         NOP
 2860         .ELSE
 2870         LDA #$DF     MAKE CTRL-CHARS INVERSE
 2880  .1     CMP #$E0     IN LOWER CASE RANGE?
 2890         BCC .2       ..NO, DISPLAY NORMAL VIDEO
 2900         AND #$1F     ..YES, FORCE INVERSE VIDEO
 2910  .2     STA (BASL),Y STORE IT ON SCREEN
 2920         .FIN
 2930         LDY #0       RESTORE Y REG
 2940         PLA          RECOVER BYTE AGAIN
 2950         JMP PRBYTE
 2960      >ENDP  ASC.DUMP
 2970  *
 2980  *---CALL ASCII DUMP--------------
 2990      >PATCH VEC.ASC.DUMP,$FDBD
 3000         JSR ASC.DUMP
 3010      >ENDP  VEC.ASC.DUMP
 3020  *--------------------------------
 3030  *   + CURSOR IN ESCAPE MODE
 3040  *--------------------------------
 3050  *
 3060  *---SAVE SCREEN, SPOT + ---------
 3070      >PATCH RDKEY2,ASC.DUMP.END+1
 3080         LDY CH       SAVE CHARACTER
 3090         LDA (BASL),Y
 3100         PHA
 3110         LDA #'+      PUT AN INVERSE + ON SCREEN
 3120         STA (BASL),Y
 3130         PLA          GET THE CHARACTER BACK
 3140         JMP (KSWL)
 3150         .BS RDKEY-*  FILL W/ 0'S TO RDKEY
 3160      >ENDP  RDKEY2
 3170  *
 3180  *---CALL + CURSOR----------------
 3190      >PATCH VEC.RDKEY2.1,$FBA2
 3200         JSR RDKEY2
 3210      >ENDP  VEC.RDKEY2.1
 3220  *
 3230  *---CALL + CURSOR----------------
 3240      >PATCH VEC.RDKEY2.2,$FD2F
 3250         JSR RDKEY2
 3260      >ENDP  VEC.RDKEY2.2
 3270  *--------------------------------
 3280  *   MASK BIT CONTROL OVER MEMORY RANGE
 3290  *   XXYY<ADR1.ADR2W   FORMS M=(M.AND.XX).OR.YY
 3300  *--------------------------------
 3310  *
 3320      >PATCH WRITE,MON.WRITE
 3330         LDA (A1L),Y  GET A BYTE
 3340         AND A4H      AND IT WITH XX
 3350         ORA A4L      OR  IT WITH YY
 3360         STA (A1L),Y  PUT IT BACK
 3370         JSR NXTA1    INCR ADDRESS
 3380         BCC WRITE    LOOP FOR MORE
 3390         RTS
 3400         .BS CRMON-*  FILL W/ 0'S TO CRMON
 3410      >ENDP  WRITE
 3420  *--------------------------------
 3430  *   SEARCH
 3440  *   XXYY<ADR1.ADR2S 
 3450  *--------------------------------
 3460  *
 3470  *---SEARCH PROCESSOR-------------
 3480      >PATCH SEARCH,MON.READ 
 3490         LDA A4H      IS THIS A 1 OR 2 BYTE COMPARE
 3500         BEQ .2       ..ONE BYTE
 3510         LDA A2L      ..TWO BYTE
 3520         BNE .1       DECREMENT ENDING ADDR
 3530         DEC A2H
 3540  .1     DEC A2L
 3550  *
 3560  .2     LDA A4H      GET FIRST BYTE TO COMPARE
 3570         BEQ .3       IF ZERO DO A ONE BYTE SEARCH
 3580         CMP (A1L),Y  COMPARE WITH MEMORY
 3590         BNE .4       NOT EQUAL - GO TO NEXT BYTE
 3600         INY          GET NEXT BYTE
 3610  .3     LDA (A1L),Y  
 3620         LDY #0       RESTORE Y REG
 3630         CMP A4L      COMPARE
 3640         BNE .4       NOT EQUAL - DRIVE ON
 3650         JSR PRA1
 3660  .4     JSR NXTA1    GET NEXT BYTE
 3670         BCC .2       LOOP FOR MORE
 3680         RTS
 3690         .BS PRERR-*  FILL W/ 0'S TO PRERR
 3700      >ENDP  SEARCH
 3710  *
 3720  *---PATCH COMMAND TABLE----------
 3730      >PATCH VEC.SEARCH,$FFDE
 3740         .DA #$EC     'S' EOR $B0 + $89
 3750      >ENDP  VEC.SEARCH
 3760  *--------------------------------
 3770         .DA #0       END OF PATCHES   
 3780  *--------------------------------
 3790  END    .EQ *-1
 3800  LENGTH .EQ END-PATCH.MONITOR+1
 3810         .LIST OFF

