Advertisement
Guest User

Small "writer" program on C64.

a guest
Sep 15th, 2021
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // ¯\_(ツ)_/¯
  3. //
  4.  
  5. BasicUpstart2(start)
  6.  
  7. start:      jsr $e544       // clear screen
  8.             ldx #0
  9.             stx $d020
  10.             stx $d021
  11.             inx
  12.             stx $0286
  13.  
  14. //
  15. // Record
  16. //
  17.  
  18.             // cursor shit
  19.  
  20. record:     ldy $d3         // get cursor column       
  21.             lda ($d1),y     // get character under cursor. $d1 points to current line
  22.             pha             // save it
  23.             lda #$a0        // fake cursor (reversed space) char
  24.             sta ($d1),y     // paste it in current cursor location
  25.             pla             // get the char that was under the cursor
  26.             sta ($d1),y     // paste it back
  27.  
  28.             // handle keyboard input
  29.  
  30.             jsr $ffe4       // wait for key to be pressed
  31.             beq record      // meanwhile, paste the cursor
  32.             jsr $ffd2       // paste it to the screen
  33.             cmp #$85        // is it "F1"?
  34.             beq endrec      // if yes, stop recording
  35.  
  36.             clc             // carry controls program flow here
  37. recaddr:    sta buffer      // paste the pressed key into the buffer
  38.             bcs playback    // carry set = we're in the playback mode
  39.  
  40.             // update buffer record address
  41.  
  42.             inc recaddr+1  
  43.             bne !skip+
  44.             inc recaddr+2
  45.  
  46. !skip:      jmp record      // get next key
  47.  
  48.             // paste "F1" code to buffer
  49.  
  50. endrec:     sec             // alter program flow
  51.             jmp recaddr
  52.  
  53. //
  54. // Playback
  55. //
  56.  
  57. playback:   jsr $e544       // clear screen
  58.  
  59.             // cursor shit again
  60.  
  61. playit:     ldy $d3         // but we restore the char under the cursor, later 
  62.             lda ($d1),y    
  63.             pha            
  64.             lda #$a0       
  65.             sta ($d1),y
  66.             tya
  67.             pha
  68.  
  69. wait:       cmp $d012       // wait for next frame
  70.             bne wait   
  71.  
  72.             lda #15         // create noise by alternating between max volume...
  73.             sta $d418
  74.            
  75.             // waste cycles to make the playback go slower
  76.  
  77.             ldx #40         // is there a better loop?
  78.             ldy #1
  79. waste:      dey
  80.             bne waste
  81.             dex
  82.             bne waste
  83.  
  84.             lda #0          // ... and volume 0
  85.             sta $d418      
  86.  
  87.             // cursor shit
  88.  
  89.             pla
  90.             tay             // altid godt med thai
  91.             pla             // get the char that was under the cursor
  92.             sta ($d1),y     // paste it back           
  93.  
  94.             // handle playback from buffer
  95.  
  96. playaddr:   lda buffer
  97.             cmp #$85        // is it "F1"?
  98.             beq endplay     // if yes, then stop playback          
  99.             jsr $ffd2       // paste the char to the screen
  100.  
  101.             // update buffer playback address
  102.  
  103.             inc playaddr+1
  104.             bne !skip+
  105.             inc playaddr+2
  106.  
  107. !skip:      jmp playit      // keep going
  108.  
  109. endplay:    rts             // releasing control...
  110.  
  111.             // Buffer
  112.  
  113. buffer:     .byte 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement