Advertisement
Shaun_B

Demonstrating bitmap buffering C64 SuperCPU

Jan 13th, 2013
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; This program should demonstrate
  2. ;; writing to the bitmap using a buffer -
  3. ;; the bitmap buffer will be at $038000
  4. ;; and it will write to the bitmap at $006000
  5. ;; It's all rather crude and is simply a
  6. ;; proof-of-principle at the moment.
  7. ;; Maybe it will eventually turn into something
  8. ;; more substantial?
  9. ;;
  10. ;; Format:  Commodore 64 + SuperCPU (native 65816)
  11. ;; Author:  Shaun B
  12. ;; Version: 1.0.0.1a
  13. ;; Date:    2013-01-14
  14. ;; Todo:    Lots of stuff!
  15. ;;
  16.  
  17. screen      = $0400
  18. colour      = $d800 ; Currently redundant
  19.         *= $001000  ; Start with sys 4096
  20.         .65816  ; Tells the assembler that we're
  21.             ; in 65816 mode
  22.         .as ; Accumulator short (8-bits)
  23.         .rl ; Registers long (16-bits)
  24.         ; Just to make sure that we're not
  25.         ; in emulation mode:
  26.         clc
  27.         xce
  28.         ; This will set to 16-bit x/y regs
  29.         rep #%00010000
  30.         ; Set border colour to zero
  31.         stz $d020
  32.         ; Sets the VIC-II bank to look at
  33.         ; location $6000 for the bitmap
  34.         lda $d011
  35.         ora #%00100000
  36.         sta $d011
  37.         lda $dd00
  38.         and #%11111100
  39.         ora #%00000010
  40.         sta $dd00
  41.         lda #$5c
  42.         sta $0288
  43.         lda #$79
  44.         sta $d018
  45.         ; Now we'll clear the bitmap screen and
  46.         ; buffer:
  47.         lda #$00
  48.         ldx #$1f40  ; Number of bytes to clear
  49. clearboth
  50.         sta $037fff,x   ; Buffer location
  51.         stz $5fff,x ; Bitmap area
  52.         dex
  53.                 ; When it reaches zero, it'll drop out
  54.                 ; of the loop, so there's a one-byte
  55.                 ; off-set above
  56.         bne clearboth
  57.         ; This will set up the colour nybbles:
  58.         ldx #$03e8  ; Number of nybbles to set
  59.         lda #$e2    ; Foreground/background
  60. setcol
  61.         sta $5bff,x ; Colour nybbles
  62.         dex
  63.                 ; Again, comparing to zero, so one-byte
  64.                 ; off-set (same below)
  65.         bne setcol
  66.         ; Now lets draw something to the back
  67.         ; buffer (just a repeated pattern for
  68.         ; now as this is a crude proof of
  69.         ; principle):
  70.         lda #%11000011
  71.         ldx #$1f40
  72. tobackbuffer
  73.         sta $037fff,x
  74.         dex
  75.         bne tobackbuffer
  76.         ; Now we'll move the back buffer to
  77.         ; our bitmap area:
  78.         rep #%00110000  ;set 16 bit acc/xy regs
  79.         .al
  80.         lda #$1f40  ; Number of bytes to move
  81.         ldx #$8000  ; Source (buffer)
  82.         ldy #$6000  ; Destination (bitmap)
  83.         mvn $03,$00 ; From bank 3 to zero
  84. infinite
  85.         ; Loop around for now
  86.         jmp infinite
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement