vram convenience functions that are probably wrong

This commit is contained in:
Kat
2019-08-22 19:22:37 -04:00
parent 5a9368fbd5
commit 0bfec6da7d

View File

@@ -667,5 +667,68 @@ db #00, #01, #01, #02, #01, #02, #02, #03, #01, #02, #02, #03, #02, #03, #03, #0
;RTL
;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------
; WriteVRAMStripe
; in: A(w) - VRAM Destination
; in: X(w) - Length in Tiles
; in: Y(w) - Word to Write
;--------------------------------------------------------------------------------
WriteVRAMStripe:
PHX
LDX $1000 ; get pointer
AND.w #$7F : STA $1002, X : INX #2 ; set destination
PLA : ASL : AND.w #7FFF : ORA.w #7000 : STA $1002, X : INX #2 ; set length and enable RLE
TYA : STA $1002, X : INX #2 ; set tile
SEP #$20 ; set 8-bit accumulator
LDA.b #$FF : STA $1002, X
STX $1000
LDA.b #01 : STA $14
REP #$20 ; set 16-bit accumulator
RTL
;--------------------------------------------------------------------------------
;--------------------------------------------------------------------------------
; WriteVRAMBlock
; in: A(w) - VRAM Destination
; in: X(w) - Length in Tiles
; in: Y(w) - Address of Data to Copy
;--------------------------------------------------------------------------------
WriteVRAMStripe:
PHX
LDX $1000 ; get pointer
AND.w #$7F : STA $1002, X : INX #2 ; set destination
PLA : ASL : AND.w #3FFF : STA $1002, X : INX #2 ; set length
PHX
TYX ; set X to source
PHA
TXA : !ADD #$1002 : TAY ; set Y to dest
PLA
;A is already the value we need for mvn
MVN $7F7E ; currently we transfer from our buffers in 7F to the vram buffer in 7E
!ADD 1, s ; add the length in A to the stack pointer on the top of the stack
PLX : TAX ; pull and promptly ignore, copying the value we just got over it
SEP #$20 ; set 8-bit accumulator
LDA.b #$FF : STA $1002, X
STX $1000
LDA.b #01 : STA $14
REP #$20 ; set 16-bit accumulator
RTL
;--------------------------------------------------------------------------------
;Byte 1 byte 2 Byte 3 byte 4
;Evvvvvvv vvvvvvv DRllllll llllllll
;
;E if set indicates that this is not a header, but instead is the terminator byte. Only the topmost bit matters in that case.
;The v's form a vram address.
;if D is set, the dma will increment the vram address by a row per word, instead of incrementing by a column (1).
;R if set enables a run length encoding feature
;the l's are the number of bytes to upload minus 1 (don't forget this -1, it is important)
;
;This is then followed by the bytes to upload, in normal format.
;RLE feature:
;This feature makes it easy to draw the same tile repeatedly. If this bit is set, the length bits should be set to 2 times the number of copies of the tile to upload. (Without subtracting 1!)
;It is followed by a single tile (word). Combining this this with the D bit makes it easy to draw large horizontal or vertical runs of a tile without using much space. Geat for erasing or drawing horizontal or verical box edges.
;================================================================================