Advertisement
Guest User

Untitled

a guest
Mar 28th, 2024
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // A simple scroller  -- Written by Fratm and yes, I know it sucks.
  2. // The delay dunction was written mostly by chatGPT, because I kept
  3. // messing it up.  But it didnt' get it right either, so I fixed it. hahahaha
  4. // posting this to pastebin, 100% public domain.  See my video at youtube.com/fratm
  5.  
  6. // Constance
  7.     .const FARRIGHT = $0427
  8.     .const HOME = $0400
  9.     .const HOME2 = $0401
  10.     .const JIFFLOW = $A2
  11.  
  12.  
  13. * = $0801
  14.     .word $0810
  15.     .word $0801
  16.     .byte $9E
  17.     .text "2064"
  18.     .byte 0, 0
  19.  
  20. * = $0810
  21.  
  22.     ldx #0 // Initialize X register to index the message characters
  23.  
  24. print_loop:
  25.     lda message, x // Load each character of the message
  26.     beq done       // If it's the end of the message (0), we're done
  27.     // Calculate the position and store the character
  28.     sta FARRIGHT
  29.     inx            // Move to the next character
  30.     jsr scrollleft
  31.     jmp print_loop
  32.  
  33. done:
  34.     ldx #$00
  35. doneloop:    // Scrolls all the text off the screen
  36.     jsr scrollleft
  37.     inx
  38.     cpx #$28   // need to do it 40 times to get everything.
  39.     bne doneloop
  40.     rts // Return from subroutine
  41.  
  42. // Scroll everything 1 byte to the left
  43. scrollleft:  stx bufferx  // Preserve the x reg so we can use it in this loop
  44.             ldx #00      // set x to zero for loop
  45. loop2:      lda HOME2, x  // lets copy everyting over one byte
  46.             sta HOME, x  //
  47.             inx           // increase x for the loop
  48.             cpx #$27       // See if we did all 40 characters
  49.             bne loop2    // if not continue the loop  
  50.             ldx bufferx // we are done so restore the x register before returning
  51.             ldy #$20     // Let's clear the far right spot so we don't get double characters
  52.             sty FARRIGHT
  53.             jsr delay
  54.             rts
  55. // This delay routine was written by chatGPT4
  56. delay:
  57.     stx bufferx
  58.     sty buffery
  59.     ldx #$A0          // Set X to a high value for the outer loop
  60. outerLoop:
  61.     ldy #$A0          // Set Y to a high value for the inner loop
  62. innerLoop:
  63.     dey               // Decrement Y
  64.     bne innerLoop     // Continue the inner loop until Y is 0
  65.     dex               // Decrement X after the inner loop completes
  66.     bne outerLoop     // Continue the outer loop until X is 0
  67.     ldx bufferx
  68.     ldy buffery
  69.     rts               // Return from subroutine
  70.  
  71. message:
  72.     .text "hello world!  this is a simple scroller written by fratm!  ya this is awesome!  woohoo! visit my web site at https://www.fratm.com or see me at youtube.com/fratm  - this took me way to long to write.  40 years ago this would have taken me 5 minutes hahahaha. "
  73.     .byte 0 // Null terminator
  74.  
  75. // buffer's x y and a -- Probably not needed, but I always felt it was good to protect your registers.
  76.  
  77. bufferx: .byte 00
  78. buffery: .byte 00
  79. buffera: .byte 00
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement