Skip to content

Instantly share code, notes, and snippets.

@blondie7575
Created July 29, 2019 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blondie7575/de953b637041c775636a7fef602384ad to your computer and use it in GitHub Desktop.
Save blondie7575/de953b637041c775636a7fef602384ad to your computer and use it in GitHub Desktop.
;;;;;;;;;;;;;;;;;;;;;;;
; graphicsVramWriteBlock
; PARAM1 : Destination VRAM address in F18A, high 2 bits must be 01
; PARAM2 : Source address in main RAM, must be page-aligned
; PARAM3 : Number of bytes to copy
;
; Write data to F18A's VRAM
;
; Trashes PARAM2
;
graphicsVramWriteBlock:
SAVE_AXY
; Set up F18A address register
lda PARAM1_L
sta F18AREG1
lda PARAM1_H
sta F18AREG1
ldy #0
ldx PARAM3_H
graphicsVramWriteBlockLoop:
lda (PARAM2_L),y
sta F18AREG0
iny
cpy PARAM3_L
beq graphicsVramWriteBlockLoopLowDone
graphicsVramWriteBlockLoopCont:
cpy #0
bne graphicsVramWriteBlockLoop
; Finished 256 byte page, so wrap to next one
dex
inc PARAM2_H ; Advance source pointer in RAM to next page
jmp graphicsVramWriteBlockLoop
graphicsVramWriteBlockLoopLowDone:
; Low byte of counter matched
cpx #0 ; If high counter is finished, so are we
bne graphicsVramWriteBlockLoopCont
graphicsVramWriteBlockDone:
RESTORE_AXY
rts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment