
 1000  *---------------------------------
 1010  *
 1020  * APPLE II RELOCATABLE MEMORY DUMP PROGRAM
 1030  *      BY ROBERT H. BERNARD
 1040  *         35 DOGWOOD LANE
 1050  *         WESTPORT, CT 06880
 1060  *
 1070  *         JANUARY 17, 1981
 1080  *
 1090  *      COMMERCIAL RIGHTS RESERVED
 1100  *
 1110  *---------------------------------
 1120  *      MONITOR ROM ROUTINES
 1130  *---------------------------------
 1140  MON.COUT   .EQ $FDED
 1150  MON.RDKEY  .EQ $FD0C
 1160  MON.GTLNZ  .EQ $FD67
 1170  MON.ZMODE  .EQ $FFC7
 1180  MON.GETNUM .EQ $FFA7
 1190  MON.CROUT  .EQ $FD8E
 1200  MON.PRNTYX .EQ $F940
 1210  MON.PRBL2  .EQ $F94A
 1220  MON.PRBYTE .EQ $FDDA
 1230  MON.MON    .EQ $FF65
 1240  MON.HOME   .EQ $FC58
 1250  MON.SETMOD .EQ $FE18
 1260  MON.OUTPOR .EQ $FE95    SET OUTPUT PORT TO SLOT (A)
 1270  MON.SETVID .EQ $FE93    SET VIDEO
 1280  *---------------------------------
 1290  *      I/O ADDRESSES
 1300  *---------------------------------
 1310  KBD    .EQ $C000    KEYBOARD
 1320  KBSTRB .EQ $C010    KBD RESET STROBE 
 1330  *---------------------------------
 1340  *      PAGE-ZERO VARIABLES
 1350  *---------------------------------
 1360  PGCNT  .EQ $2E      LINES LEFT THIS PAGE
 1370  ITEMCT .EQ $30      ITEMS PER LINE
 1380  OPTION .EQ $31      SAME AS MON "MODE"
 1390  PROMPT .EQ $33      LOC OF GETLN PROMPT CHAR
 1400  YSAV   .EQ $34      POINTER TO IN BUFFER
 1410  FRADRL .EQ $3C      STARTING ADR LO ORDER 
 1420  FRADRH .EQ $3D      ..HI ORDER  
 1430  TOADRL .EQ $3E      ENDING ADR LO ORDER 
 1440  TOADRH .EQ $3F      ..HI ORDER  
 1450  *---------------------------------
 1460  *      USER-CHANGEABLE PARAMETERS
 1470  *---------------------------------
 1480  SCITMS .EQ 16       BYTES PER LINE SCREEN
 1490  PRITMS .EQ 32       BYTES PER LINE PRINTER
 1500  ITMSPG .EQ 8        ITEMS PER PAGE
 1510  PRSLOT .EQ 1        PRINTER SLOT
 1520  *---------------------------------
 1530         .OR $0800
 1540  *---------------------------------
 1550  MEMDMP JSR MON.SETVID   SET PR#0
 1560         LDA #$BF     '?' FOR BOUNDS
 1570         STA PROMPT   SET PROMPT CHAR
 1580         JSR MON.GTLNZ    CR, THEN GET INPUT
 1590         JSR MON.ZMODE    SET HEX DECODE MODE
 1600         JSR MON.GETNUM
 1610         STY YSAV     REMEMBER SCAN POS. 
 1620         CPX #0       ANY ADR SCANNED?
 1630         BNE .3       YES 
 1640         RTS          NO. TERMINATE
 1650         .DA MON.MON      MONITOR ENTRY (IN CASE YOU WANT
 1660  *                   TO CHANGE RETURN TO "JMP MON.MON")
 1670  *
 1680  .3     LDA #-SCITMS  BYTES PER SCREEN LINE 
 1690         STA ITEMCT   ITEMS PER LINE
 1700         JSR MON.SETMOD   SET TO SCAN 2ND ARG 
 1710         CMP #$AD     IS OPTION = '-' ?
 1720         BNE .2       NO. CHECK OTHERS
 1730         INC OPTION   MAKE '.'
 1740         LDA #PRSLOT  PRINTER SLOT NO
 1750         JSR MON.OUTPOR   SET OUTPUT PORT
 1760         LDA #-PRITMS  BYTES PER PRINTER LINE
 1770         STA ITEMCT   ITEMS PER LINE
 1780         BNE .1       GO GET 2ND ARG
 1790  *
 1800  .2     CMP #$AE     '.' ?
 1810         BEQ .1       YES. 2 ARGS
 1820         CMP #$AC     ','?
 1830         BNE SETPGL   ONLY ONE ARG
 1840  .1     LDY YSAV     PTR TO IN BUFFER
 1850         JSR MON.GETNUM   SCAN 2ND ARG 
 1860         STY YSAV     PTR TO IN BUFFER
 1870  SETPGL LDA #ITMSPG  ITEMS PER PAGE
 1880         STA PGCNT
 1890  *
 1900  NEXTLN JSR MON.CROUT    SKIP A LINE
 1910         LDA ITEMCT   -ITEMS PER LINE
 1920         AND FRADRL   STARTING ADR 0 MOD ITEMCT
 1930         STA FRADRL
 1940         TAX
 1950         LDY FRADRH   ..TO PRINT
 1960         JSR MON.PRNTYX   PRINT IT IN HEX
 1970         LDX ITEMCT   NO OF BYTES THIS LINE
 1980         LDY #0       POINTER
 1990         BEQ NOBLNK   DON'T SPACE FIRST TIME
 2000  *
 2010  CHKKEY LDA KBD      KEY DOWN?
 2020         BPL CKDONE   NO
 2030         LDA KBSTRB   YES. CLEAR KEYBOARD
 2040         SEC          PREPARE FOR
 2050  MDMP2  BCS MEMDMP   JMP TO START
 2060  *
 2070  NXTCHR TYA          TEST FOR 
 2080         AND #$03       0 MOD 4
 2090         BNE NOBLNK
 2100         LDA #$A0
 2110         JSR MON.COUT PRINT A BLANK
 2120  NOBLNK LDA #$A0 
 2130         JSR MON.COUT PRINT A BLANK
 2140         LDA (FRADRL),Y	 GET CHAR TO PRINT
 2150         CMP #$20     CNTRL CHAR?
 2160         BCC .1       YES. SUBSTITUTE BLANK 
 2170         CMP #$80     CNTRL CHAR?
 2180         BCC .2       NO. OK TO PRINT 
 2190         CMP #$A0     CNTRL CHAR?
 2200         BCS .2       NO. OK TO PRINT  
 2210  .1     LDA #$A0     SUBSTITUTE BLANK
 2220  .2     JSR MON.COUT
 2230         INY          POINT AT NEXT
 2240         INX          DONE ON THIS LINE? 
 2250         BNE NXTCHR   NO
 2260         JSR MON.CROUT    YES. CR
 2270  * PREPARE TO PRINT SAME ITEMS IN HEX
 2280         LDX #3
 2290         JSR MON.PRBL2    OUTPUT (X) BLANKS
 2300         LDX ITEMCT   ITEMS PER LINE 
 2310         LDY #0       POINTER
 2320         BEQ NXTHEX   (JMP)
 2330  *
 2340  SETPL1 BCS SETPGL   JUMP TO SET PG LENGTH 
 2350  CKOPT  CMP #$AC     NO. OPTION=',' ?
 2360  NXTLN1 BNE NEXTLN   NO. JUMP TO PRINT
 2370  CKDONE LDA FRADRL   TEST IF DONE 
 2380         CMP TOADRL 
 2390         LDA FRADRH 
 2400         SBC TOADRH 
 2410         BCC NEXTLN   FROM < TO 
 2420  MDMP1  BCS MDMP2    JMP TO START 
 2430  *
 2440  NXTHEX TYA          TEST FOR
 2450         AND #$03       0 MOD 4
 2460         BNE .1       IF NOT, SKIP BLANK
 2470         LDA #$A0 
 2480         JSR MON.COUT PRINT A BLANK
 2490  .1     LDA (FRADRL),Y BYTE TO OUTPUT  
 2500         JSR MON.PRBYTE   OUTPUT IN HEX
 2510         INY          NEXT
 2520         INX          DONE ON THIS LINE? 
 2530         BNE NXTHEX   NO
 2540         JSR MON.CROUT    YES. CR
 2550  *      ADVANCE DUMP ADDRESS
 2560         SEC          PREPARE FOR SUBTRACT
 2570         LDA FRADRL   INCREMENT ADDRESS
 2580         SBC ITEMCT   -ITEMS PER LINE
 2590         STA FRADRL
 2600         BCC .2       NO CARRY
 2610         INC FRADRH   PAGE BOUNDARY
 2620         BEQ MDMP1    END OF MEMORY
 2630  .2     LDA OPTION
 2640         CMP #$AE     '.'? (OPTION 1)
 2650         BEQ CHKKEY   NO. CHECK IF KEY DOWN
 2660  CHKPAG DEC PGCNT    PAGE END?
 2670         BNE CKOPT    NO. CHECK OPTION
 2680  PAUSE  JSR MON.RDKEY    GET A CHAR
 2690         CMP #$83     CNTRL-C? 
 2700         BEQ MDMP1    YES. START OVER  
 2710         CMP #$C2     WAS CHAR READ A 'B'? 
 2720         BEQ BACKUP   YES 
 2730         LDA OPTION 
 2740         CMP #$AC     OPTION=',' ?
 2750         BEQ SETPL1   YES 
 2760  ADVNCE INC PGCNT    ONE MORE TIME
 2770         BNE NXTLN1   JMP TO NXTLN
 2780  *
 2790  BACKUP LDA FRADRL   CARRY IS SET 
 2800         SBC #144     BACKUP SCITMS*(ITMSPG+1) BYTES 
 2810         STA FRADRL   SAVE LO ORDER
 2820         BCS .1       NO CARRY 
 2830         DEC FRADRH   PROPOGATE CARRY  
 2840  .1     JSR MON.HOME     CLEAR SCREEN
 2850         SEC          SIMULATE JMP
 2860         BCS SETPL1   ..TO SETPGL
 2870  *
 2880  ZZSIZE .EQ *-MEMDMP PROGRAM SIZE 
 9999         .LIF

