         org   $1000
         lst   off
         xc
COUT     equ   $FDED
CROUT    equ   $FD8E
HEXOUT   equ   $FDDA
MLI      equ   $BF00
KEYBOARD equ   $C000
KBRDSTRB equ   $C010
HTAB     equ   $F7EA
VTAB     equ   $F259
********************************
* ProDOS Cheat & Cracker Maker *
* Version 1.0 - Roctober 1988  *
********************************
         LDX   #$DC
         LDA   #$00
         PHA
         PLX
         CPX   #$00
         BNE   J1         ;65C02 not present
         JMP   START      ;65C02 is present
*-------------------------------
J1       PLA              ;Clear last PHA
         LDX   #<DATA
         LDY   #>DATA
         JSR   STROUT     ;Print out error message
         RTS
*-------------------------------
DATA     hex   8D87
         asc   "?ERROR - 65C02 MACHINES ONLY",8D00
DATA1    hex   1C         ;Inverse backslash
         inv   "                                      / "
         asc   "   ProDOS Cheat & Cracker Maker v1.0  "
         inv   "  "
         asc   " Written by -DC- in Rocktober of '88  "
         inv   "  "
         asc   " Call Shooting Star 20mg 206/838-7686 "
         inv   " /                                      ",1C8D00
DATA2    asc   "Inverse ",00
DATA3    asc   "Flashing",00
DATA4    asc   "Enter top five lines for cheat file:",8D8D
         asc   "^O = Inverse, ^F = Flashing, ^N = Normal",8D00
DATA5    hex   8D
         asc   "Acceptable?    ",88888800
DATA6    asc   "No",00
DATA7    asc   "Yes",00
DATA8    hex   8D8D
         asc   "Now enter in the following information.",8D
         asc   "Hit RETURN alone when done.",00
DATA9    hex   8D8D
         asc   "   Block #$",00
DATA10   hex   8D
         asc   "Old data #$",00
DATA11   hex   8D
         asc   "New data #$",00
*-------------------------------
START    LDX   #23        ;Place cursor at bottom
         JSR   VTAB       ;of screen.
         LDX   #<DATA1
         LDY   #>DATA1
         JSR   STROUT     ;Print data
         LDX   #17
SCROLL1  JSR   CROUT      ;<cr>
         DEX
         BNE   SCROLL1    ;Keep printing <cr>'s
         LDX   #7
         JSR   VTAB       ;Place cursor on correct line
         LDX   #<DATA4
         LDY   #>DATA4
         JSR   STROUT
         LDA   #$06       ;Lock first 6 lines on screen
         STA   $22        ;Locks it
         LDA   #$DF       ;Cursor "_"
         STA   $06        ;Store it in safe spot for use
         STZ   $07        ;Set to NORMAL mode
         STZ   $08        ;Zero line count
*-------------------------------
IN       LDA   $06        ;Defined cursor type
         JSR   COUT       ;Print the cursor
IN1      STZ   KBRDSTRB   ;Clear input buffer
IN2      LDA   KEYBOARD
         CMP   #128       ;Key pressed?
         BMI   IN2        ;Nope
         CMP   #$9A       ;Is it a ^Z?
         BEQ   ZAPJMP
         CMP   #$8F       ;Is it a ^O?
         BEQ   INVJMP
         CMP   #$86       ;Is it a ^F?
         BEQ   FLSJMP
         CMP   #$8E       ;Is it a ^N?
         BEQ   NORJMP
         CMP   #$FF       ;Is it the Delete key?
         BEQ   DELJMP
         CMP   #$88       ;Is it a backspace key?
         BEQ   DELJMP
         CMP   #$8D       ;Is it the RETURN key?
         BEQ   RETJMP
         CMP   #$A0       ;Determine whether it
         BMI   IN1        ;is a valid input.
         JMP   OVER2
*-------------------------------
ZAPJMP   JMP   ZAP
INVJMP   JMP   INVERSE
FLSJMP   JMP   FLASH
NORJMP   JMP   NORMAL
DELJMP   JMP   DELETE
RETJMP   JMP   RETURN
*-------------------------------
OVER2    PHA              ;Store input for a min
         JSR   BSOUT      ;Erase cursor
         PLA              ;Get input back
         LDY   $07        ;Display mode (inverse, etc)
         BEQ   IN3        ;Normal mode
         CPY   #$01       ;Is it Inverse mode?
         BNE   IN4        ;No, flashing
         AND   #%00111111 ;Turn input into inverse
         BRA   IN3
IN4      AND   #%01111111 ;Activate flash mode
         ORA   #%01000000
IN3      JMP   OVER1      ;Jump over next stuff
*-------------------------------
INVERSE  LDA   #$01       ;Set inverse mode
         STA   $07
         JSR   SUB        ;Move cursor
* Cursor can be changed if wanted
         LDX   #<DATA2
         LDY   #>DATA2
         JSR   STROUT
         JSR   SUB1       ;All done here
         JMP   IN1
*-------------------------------
FLASH    LDA   #$02       ;Set flash mode
         STA   $07
         JSR   SUB        ;Do cursor movements
* Cursor can be changed if wanted
         LDX   #<DATA3
         LDY   #>DATA3
         JSR   STROUT
         JSR   SUB1
         JMP   IN1
*-------------------------------
NORMAL   STZ   $07        ;Set normal mode
         JSR   SUB        ;Move cursor
* Change cursor back if needed
         LDA   #$A0       ;Print spaces
NORMAL1  JSR   COUT
         INX
         CPX   #$08
         BNE   NORMAL1
         JSR   SUB1
         JMP   IN1
*-------------------------------
ZAP      LDA   TOPLEN
         CMP   #$FF
         BEQ   ZAP3       ;Nothing to Zap
         LDA   #$FF
         STA   TOPLEN
         STZ   $08
         LDX   #11        ;Move to line 11
         JSR   VTAB
         LDX   #1
         JSR   HTAB       ;Move to column 1
         LDA   #$A0       ;Space
         LDX   #$00
ZAP2     JSR   COUT
         INX
         CPX   #200
         BNE   ZAP2
         LDX   #11
         JSR   VTAB
         LDX   #1
         JSR   HTAB
         JMP   IN
ZAP3     JMP   IN1
*-------------------------------
DELETE   JSR   BSOUT      ;Print a backspace over cursor
         LDY   $24        ;Get horizontal cursor location
         BEQ   DELETE1    ;Edge of screen, abort this function
         JSR   BSOUT
         LDA   #$A0       ;Erase cursor
         JSR   COUT
         JSR   COUT
         JSR   BSOUT
         JSR   BSOUT
         DEC   TOPLEN     ;Minus one byte for length
DELETE1  JMP   IN         ;All done here
*-------------------------------
RETURN   JSR   BSOUT      ;Move over cursor
         LDA   #$A0       ;Erase cursor
         JSR   COUT
         LDA   #$8D
         JMP   OVER1
*-------------------------------
INDONE   STZ   $07        ;Normal mode
         JSR   SUB        ;Get current cursor location
         LDX   #$08
         LDA   #$A0       ;Space
INDONE1  JSR   COUT       ;Erase bottom line
         DEX
         BNE   INDONE1
         JSR   SUB1       ;Put cursor back to old location
         LDX   #<DATA5
         LDY   #>DATA5
         JSR   STROUT
INDONE3  JSR   INPUT
         CMP   #$CE       ;"No"
         BNE   INDONE4
INDONE5  LDX   #<DATA6
         LDY   #>DATA6
         JSR   STROUT
         JMP   ZAP
INDONE4  CMP   #$EE       ;"no"
         BEQ   INDONE5
         CMP   #$D9       ;"Yes"
         BEQ   INDONE6
         CMP   #$F9
         BNE   INDONE3    ;Bad input
INDONE6  LDX   #<DATA7
         LDY   #>DATA7
         JSR   STROUT
*-------------------------------
         LDX   #<DATA8
         LDY   #>DATA8
         JSR   STROUT
INFO     LDX   #<DATA9
         LDY   #>DATA9    ;Ask for block number
         JSR   STROUT
         JSR   INFO1      ;Get hi byte input
         LDY   DSKCNT
         STA   DSKDATA+1,Y
         JSR   INFO1      ;Get lo byte input
         LDY   DSKCNT
         STA   DSKDATA,Y

*===============================
OVER1    JSR   COUT
         LDY   #$00       ;For marker
OVER5    INC   TOPLEN     ;Add another byte to length
         LDX   TOPLEN
         STA   TOPDATA,X  ;Write byte in memory
         LDX   $24        ;Horizontal cursor location
         BNE   OVER4
         CPY   #$DC       ;Have we done this before?
         BEQ   OVER4
         LDY   #$DC       ;Marker
         LDA   #$8D
         BRA   OVER5      ;End of line was reached
OVER4    CMP   #$8D       ;Was it a return?
         BNE   OVER3      ;No
         INC   $08        ;Increment line count
         LDX   $08
         CPX   #$05       ;Is there five lines now?
         BEQ   OVER6      ;Yes, done with input
OVER3    JMP   IN
OVER6    JMP   INDONE
********************************
SUB      LDA   $25        ;Get vertical cursor location
         INC              ;Correct value
         STA   $19        ;Store it
         LDA   $24        ;Get horizontal location
         INC              ;Correct value
         STA   $1A        ;Store it
         LDX   #23        ;Place cursor at bottom, center
         JSR   VTAB       ;Vertical placement routine
         LDX   #16        ;Place cursor in center
         JSR   HTAB       ;Horizontal placement routine
         LDX   #$00
         RTS
*-------------------------------
SUB1     LDX   $1A        ;Get old horizontal position
         JSR   HTAB       ;Horizontal placement location
         LDX   $19        ;Get old vertical position
         JSR   VTAB       ;Vertical placement routine
         RTS              ;All done here
********************************
BSOUT    LDA   #$88
         JMP   COUT
********************************
STROUT   STX   $00
         STY   $01
         LDY   #$00
STROUT1  LDA   ($00),Y
         BEQ   STROUT2
         JSR   COUT
         INY
         BRA   STROUT1
STROUT2  RTS
********************************
INPUT    LDA   $06        ;Defined cursor type
         JSR   COUT       ;Print the cursor
         STZ   KBRDSTRB   ;Clear input buffer
INPUT1   LDA   KEYBOARD
         CMP   #128       ;Key pressed?
         BMI   INPUT1     ;Nope
         PHA
         JSR   BSOUT      ;Erase cursor
         PLA
         RTS
********************************
INFO1    JSR   INPUT
         STA   $300       ;Store it for a min
         AND   #%01111111 ;Turn off hi bit
         SEC
         SBC   #31        ;Convert input to valid data
         BCS   INFO1      ;Went below #$00
         CMP   #$0F+1     ;Is it over a valid block #?
         BPL   INFO1      ;Yes, try again
         PHA              ;Store it for a min
         LDA   $300       ;Get printable value
         JSR   COUT       ;Print it
         PLA              ;Get raw value
         ASL
         ASL
         ASL
         ASL              ;Shift it over to the left
         PHA              ;Store it for later
INFO2    JSR   INPUT      ;Get lo nibble
         STA   $300
         AND   #%01111111
         SEC
         SBC   #31
         BCS   INFO2
         CMP   #$0F+1
         BPL   INFO2
         PHA
         LDA   $300
         JSR   COUT       ;Print it
         PLA
         STA   $300       ;Safe spot
         PLA              ;Get first input
         ORA   $300       ;Put two nibbles together
         RTS
********************************
TOPLEN   hex   FF         ;Length of top five lines
*-------------------------------
TOPDATA  ds    $C8        ;Puts 201 bytes of data here
********************************
DSKCNT   hex   FF         ;Number of blocks to modify
*-------------------------------
DSKDATA  hex   0000       ;Block number (LO/HI)
         hex   00         ;Old byte data
         hex   00         ;New byte data
********************************
         sav   /files/c.and.c.1.0
