Advertisement
nr0q

ASM program for Telvana

May 1st, 2024
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Set up
  2.             SEI             ; Disable interrupts
  3.             LDA #$20        ; Set for text mode, no bitmap
  4.             STA $D011
  5.             LDA #$00        ; Black background
  6.             STA $D020
  7.             STA $D021
  8.  
  9. ; Main loop
  10. main        JSR random      ; Get a random screen position
  11.             STA $00         ; Store low byte of address
  12.             LDA #$04        ; High byte of screen RAM address
  13.             STA $01
  14.             LDX #$00        ; Counter for "ARF"
  15.  
  16. printChar   LDA message,X   ; Load character from "ARF"
  17.             STA ($00),Y     ; Store at random position
  18.             INX             ; Move to next character
  19.             CPX #$03        ; Check if we printed all three chars
  20.             BNE printChar   ; If not, loop back
  21.  
  22.             JMP main        ; Repeat indefinitely
  23.  
  24. ; Simple random number generator
  25. ; Returns a random byte in A, low byte of address in Y
  26. random      LDA $D012       ; Load current raster line
  27.             STA $D4         ; Store it temporarily
  28.             LDA $D4
  29.             EOR $D4+1       ; XOR with next byte in zero-page
  30.             ASL             ; Multiply by 2
  31.             TAY             ; Transfer to Y to use as index
  32.             RTS
  33.  
  34. message     .byte "ARF"     ; Message to print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement