Advertisement
EmanueleBonin

C=64 Smooth single - line hscroll

Jun 26th, 2020
3,378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *               = $C000
  2.  
  3. RASTERBEGIN     = 58
  4. RASTEREND       = 66
  5.  
  6.  
  7.  
  8.                 lda $d016       ; Horizzontal scroll register -> A
  9.                 and #%11110111  ; 38 column mode
  10.                 sta $d016      
  11.  
  12.                 sei             ; Disable Interrupts
  13.  
  14.                 ldy #$7f        ; $7f = %01111111
  15.                 sty $dc0d       ; Disable the CIA Interrupts
  16.                 sty $dd0d       ; Found at $DC0D and $DD0D
  17.                 lda $dc0d       ; So we cancel all the interrupts
  18.                 lda $dd0d       ; that has yet to happeand and not processed
  19.  
  20.                 lda #$01        ; Bit 0 of the Interrupt Enable Register is for the Raster Interrupt
  21.                 sta $d01a       ; Set this to 1 to Enable the  Raster Interrupt
  22.  
  23.                 lda #<IrqStart  ; Get Lo-Byte Pointer to our Raster Interrupt Routine
  24.                 ldx #>IrqStart  ; Get Lo-Byte Pointer to our Raster Interrupt Routine
  25.  
  26.                 sta $0314       ; Lo-Byte
  27.                 stx $0315       ; Hi-Byte
  28.  
  29.                 lda #RASTERBEGIN; The scan line where the raster interrupt has to happend
  30.                 sta $d012       ; Store this in $D012
  31.  
  32.                 lda $d011       ; We make sure that the high bit of the Raster
  33.                 and #$7f        ; line is zero. Like this we make sure that
  34.                 sta $d011       ; the interrupts always happen at scan line 250
  35.  
  36.                 cli             ; Initialize the interrupts
  37.  
  38.                 jmp *          
  39.  
  40. smooth          byte $7         ; offset in pixel
  41. shift           byte $00        ; flag to shift all char at left
  42.  
  43. IrqStart
  44.                                 ;lda #0
  45.                                 ;sta 53281
  46.  
  47.                 lda $d016       ; Horizzontal scroll register -> A
  48.                 ora smooth      ; "add" smooth value (0..7)
  49.                 sta $d016       ; place new value
  50.                 dec smooth      ; decrement smooth offset
  51.                 bpl IrqStart_Continue ; if non negative ok
  52.                 lda #7          ; else set smooth
  53.                 sta smooth      ; offset to seven and
  54.                 sta shift       ; indicate to do line shift at next raster interrupt
  55.                                 ; at the end of this line (see below)
  56.                                
  57. IrqStart_Continue
  58.  
  59.  
  60.                 lda #<IrqEnd    
  61.                 sta $0314      
  62.                 lda #>IrqEnd    
  63.                 sta $0315       ; Re-direct next interrupt to IrqEnd service routine
  64.                 lda #RASTEREND  ; Scan line where the raster interrupt has to happend
  65.                 sta $d012       ; store it
  66.                 asl $d019       ; "Acknowledge" the interrupt by clearing the VIC's interrupt flag.
  67.  
  68.                 jmp $ea81       ; Jump to normal interrupt routine ... no keyscan
  69.                                 ;jmp $ea31           ; return normally to the kernal (keyscan) via its Interrupt routine
  70.  
  71.  
  72.  
  73. IrqEnd
  74.                                 ;lda #1
  75.                                 ;sta 53281
  76.                 lda shift       ; check shify flag
  77.                 beq IrqEContinue; if = 0 ok continue normally
  78.                                 ; else shift (better rollup) character line
  79.                 ldy $0400+40    
  80.                 ldx #00        
  81. IrqELoop
  82.                 lda $0400+41,x  
  83.                 sta $0400+40,x  
  84.                 inx
  85.                 cpx #39        
  86.                 bne IrqELoop    
  87.                 sty $0400+79    
  88.  
  89.                 lda #0          ; reset  
  90.                 sta shift       ; shift flag
  91.  
  92. IrqEContinue
  93.  
  94.                 lda $d016       ; Horizzontal scroll register -> A
  95.                 and #%11111000  ; reset horizzontal bit-shift
  96.                 sta $d016      
  97.  
  98.                 lda #<IrqStart  
  99.                 sta $0314      
  100.                 lda #>IrqStart  
  101.                 sta $0315       ; Re-direct next interrupt to IrqMiddle service routine
  102.                 lda #RASTERBEGIN; Scan line where the raster interrupt has to happend
  103.                 sta $d012       ; store it
  104.                 asl $d019       ; "Acknowledge" the interrupt by clearing the VIC's interrupt flag.
  105.  
  106.                 jmp $ea81       ; Jump to normal interrupt routine ... no keyscan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement