
 1000  *SAVE S.MOTOROLA S-TYPE OBJECT
 1010         .OR $800
 1020  *--------------------------------
 1030  PORT       .EQ $00,01
 1040  HI.BIT     .EQ $02
 1050  NAME       .EQ $03 ... $0A
 1060  CHECK.SUM  .EQ $12
 1070  TYPE       .EQ $13
 1080  COUNT      .EQ $14
 1090  REMAINING  .EQ $15,16
 1100  START      .EQ $17,18
 1110  END        .EQ $19,1A
 1120  TARGET     .EQ $1B,1C
 1130  *--------------------------------
 1140  A1     .EQ $3C,3D
 1150  A2     .EQ $3E,3F
 1160  A3     .EQ $40,41
 1170  A4     .EQ $42,43
 1180  A5     .EQ $44,45
 1190  *--------------------------------
 1200  CTRLY.VECTOR        .EQ $3F8 THRU $3FA
 1210  DOS.REHOOK          .EQ $3EA
 1220  *--------------------------------
 1230  MON.NXTA4           .EQ $FCB4
 1240  MON.CROUT           .EQ $FD8E
 1250  MON.PRHEX           .EQ $FDDA
 1260  MON.COUT            .EQ $FDED
 1270  MON.SETVID          .EQ $FE93
 1280  *--------------------------------
 1290  *      SETUP CONTROL-Y
 1300  *--------------------------------
 1310  SETUP  LDA #SEND.DATA
 1320         STA CTRLY.VECTOR+1
 1330         LDA /SEND.DATA
 1340         STA CTRLY.VECTOR+2
 1350         LDA #$4C
 1360         STA CTRLY.VECTOR
 1370         RTS
 1380  *--------------------------------
 1390  *   *0:XX YY   (LO,HI OF PORT)
 1400  *   *:ZZ       (00 OR 80, FOR ASCII HI-BIT)
 1410  *   *:C1 C2 C3 C4 C5 C6 C7 C8   ASCII VALUES FOR
 1420  *                   THE 8 CHARACTERS OF THE NAME
 1430  *   *TARGET<START.END<Y>
 1440  *      IF PORT IS 0, DO NOT CHANGE OUTPUT
 1450  *      IF PORT IS 1...7, OUTPUT TO SLOT.
 1460  *         ELSE OUTPUT TO SUBROUTINE
 1470  *      SEND BYTES START...END
 1480  *
 1490  *      1.  TURN ON OUTPUT PORT
 1500  *      2.  SEND ID RECORD
 1510  *      3.  SEND DATA RECORDS
 1520  *      4.  SEND EOF RECORD
 1530  *      5.  TURN OFF OUTPUT PORT
 1540  *--------------------------------
 1550  SEND.DATA
 1560         JSR SAVE.PARAMETERS
 1570         JSR TURN.ON.OUTPUT.PORT
 1580         JSR SEND.ID.RECORD
 1590         JSR RESTORE.PARAMETERS
 1600         JSR SEND.DATA.RECORDS
 1610         JSR SEND.EOF.RECORD
 1620         JMP TURN.OFF.OUTPUT.PORT
 1630  *--------------------------------
 1640  SAVE.PARAMETERS
 1650         LDX #1
 1660  .1     LDA A1,X
 1670         STA START,X
 1680         LDA A2,X
 1690         STA END,X
 1700         LDA A4,X
 1710         STA TARGET,X
 1720         DEX
 1730         BPL .1
 1740         RTS
 1750  *--------------------------------
 1760  RESTORE.PARAMETERS
 1770         LDX #1
 1780  .1     LDA START,X
 1790         STA A1,X
 1800         LDA END,X
 1810         STA A2,X
 1820         LDA TARGET,X
 1830         STA A4,X
 1840         DEX
 1850         BPL .1
 1860         RTS
 1870  *--------------------------------
 1880  TURN.ON.OUTPUT.PORT
 1890         LDX PORT+1     HI-BYTE OF PORT SPECIFIED
 1900         BNE .1
 1910         LDA PORT       LO-BYTE, MUST BE SLOT
 1920         AND #$07
 1930         BEQ .3       SLOT 0, JUST SCREEN
 1940         ORA #$C0
 1950         BNE .2       ...ALWAYS
 1960  .1     TXA          HI-BYTE OF SUBROUTINE
 1970         LDX PORT       LO-BYTE OF SUBROUTINE
 1980  .2     STA $37
 1990         STX $36
 2000         JSR DOS.REHOOK
 2010  .3     RTS
 2020  *--------------------------------
 2030  SEND.ID.RECORD
 2040         LDA #'0'     TYPE = "0"
 2050         STA TYPE
 2060         LDA #8       COUNT = 8
 2070         STA COUNT
 2080         LDA #0       ADDR=0
 2090         STA A4
 2100         STA A4+1
 2110         STA A1+1
 2120         STA A2+1
 2130         LDA #NAME
 2140         STA A1
 2150         LDA #NAME+7
 2160         STA A2
 2170         JMP SEND.RECORD
 2180  *--------------------------------
 2190  SEND.DATA.RECORDS
 2200         LDA #'1'     TYPE = "1"
 2210         STA TYPE
 2220         INC A2       POINT JUST BEYOND THE END
 2230         BNE .1
 2240         INC A2+1
 2250  .1     SEC
 2260         LDX #20
 2270         LDA A2       SEE HOW MANY BYTES LEFT
 2280         SBC A1
 2290         STA REMAINING
 2300         LDA A2+1
 2310         SBC A1+1
 2320         STA REMAINING+1
 2330         BNE .2       USE MIN(20,A2-A1+1)
 2340         CPX REMAINING
 2350         BCC .2
 2360         LDX REMAINING
 2370         BEQ .3       ...FINISHED
 2380  .2     STX COUNT
 2390         JSR SEND.RECORD
 2400         JMP .1       ...ALWAYS
 2410  .3     RTS
 2420  *--------------------------------
 2430  SEND.EOF.RECORD
 2440         LDA #0       # OF DATA BYTES = 0
 2450         STA COUNT
 2460         LDA #'9'     TYPE="9"
 2470         STA TYPE
 2480         LDA TARGET   RUN ADDRESS (LO)
 2490         STA A4
 2500         LDA TARGET+1 RUN ADDRESS (HI)
 2510         STA A4+1
 2520         JMP SEND.RECORD
 2530  *--------------------------------
 2540  TURN.OFF.OUTPUT.PORT
 2550         JSR MON.SETVID
 2560         JMP DOS.REHOOK
 2570  *--------------------------------
 2580  SEND.RECORD
 2590         LDA #'S'     LETTER "S"
 2600         JSR SEND.FRAME
 2610         LDA TYPE     TYPE "0", "1", OR "9"
 2620         JSR SEND.FRAME
 2630         LDA #0       INIT CHECKSUM
 2640         STA CHECK.SUM
 2650         CLC
 2660         LDA COUNT    SEND BYTE COUNT
 2670         ADC #3       ...INCLUDING ADDR AND CSUM
 2680         JSR SEND.BYTE
 2690         LDA A4+1     SEND ADDRESS
 2700         JSR SEND.BYTE
 2710         LDA A4
 2720         JSR SEND.BYTE
 2730         LDA COUNT    ANY DATA?
 2740         BEQ .2       ...NO
 2750         LDY #0       ...YES, SEND DATA
 2760  .1     LDA (A1),Y
 2770         JSR SEND.BYTE
 2780         JSR MON.NXTA4
 2790         DEC COUNT
 2800         BNE .1
 2810  .2     LDA CHECK.SUM     SEND CHECK SUM
 2820         EOR #$FF
 2830         JSR SEND.BYTE
 2840         LDA #$0D     SEND CRLF
 2850         JSR SEND.FRAME
 2860         LDA #$0A     LINEFEED
 2870         JMP SEND.FRAME
 2880  *--------------------------------
 2890  SEND.BYTE
 2900         PHA          SAVE BYTE
 2910         CLC
 2920         ADC CHECK.SUM     ACCUMULATE CHECKSUM
 2930         STA CHECK.SUM
 2940         PLA          RECOVER BYTE
 2950         PHA          SAVE ANOTHER COPY
 2960         LSR          READY FIRST DIGIT
 2970         LSR
 2980         LSR
 2990         LSR
 3000         JSR SEND.DIGIT
 3010         PLA          RECOVER BYTE
 3020         AND #$0F     READY SECOND DIGIT
 3030  SEND.DIGIT
 3040         ORA #$30     CHANGE TO ASCII
 3050         CMP #$3A
 3060         BCC SEND.FRAME
 3070         ADC #6       CHANGE TO A...F
 3080  SEND.FRAME
 3090         ORA HI.BIT   $00 OR $80
 3100         JMP MON.COUT
 3110  *--------------------------------
 3120         .OR $300
 3130  SAMPLE
 3140         .HS 86.44.B7.01.00.41.42.43
 3150         .HS 44.45.46.47.48.49.4A.4B
 3160         .HS 4C.4D.4E

