mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-26 13:49:21 +00:00
100 lines
3.3 KiB
Plaintext
100 lines
3.3 KiB
Plaintext
|
; Vera Display Composer Assembly Language Routines for C02
|
||
|
; Requires External Routines NYBCAT, NYBCUT, REGADR, and SAVRXY
|
||
|
; and External Variables TEMP1 and TEMP2
|
||
|
|
||
|
|
||
|
|
||
|
;rgbclr(r,g,b) - Convert RGB Values to Palette Color
|
||
|
;Args: A = Red Value (0-15)
|
||
|
; Y = Green Value (0-15)
|
||
|
; X = Blue Value (0-15)
|
||
|
;Affects: A
|
||
|
;Returns: Y = Color MSB (0000RRRR)
|
||
|
; X = Color LSB (GGGGBBBB)
|
||
|
RGBCLR: PHA ;Save Red Value
|
||
|
TYA ;Copy Green Value to Left Nybble
|
||
|
.DC $DA ;PHX Copy Blue Value
|
||
|
.DC $7A ;PLY to Right Nybble
|
||
|
JSR NYBCAT ;Concatanate Green and Blue
|
||
|
TAX ;and Return as LSB
|
||
|
.DC $7A ;PLY Return Red as MSB
|
||
|
RTS
|
||
|
|
||
|
;clrrgb(c) - Convert Palette Color to RGB Values
|
||
|
;Args: Y = Color MSB (0000RRRR)
|
||
|
; X = Color LSB (GGGGBBBB)
|
||
|
;Returns: A = Red Value (0-15)
|
||
|
; Y = Green Value (0-15)
|
||
|
; X = Blue Value (0-15)
|
||
|
CLRRGB: .DC $5A ;PHY Save MSB
|
||
|
TXA ;Copy LSB into Accumulator
|
||
|
JSR NYBCUT ;and Split into Nybbles
|
||
|
.DC $5A ;PHY Return Blue Value
|
||
|
.DC $FA ;PLX in X Register
|
||
|
TAY ;Green Value in Y Register
|
||
|
PLA ;and Red Value in Accumulator
|
||
|
RTS
|
||
|
|
||
|
;getclr(idx) - Get Color Entry idx from Paleftte
|
||
|
;Args: A = Color Entry Index
|
||
|
;Affects: A
|
||
|
;Returns: Y = Color MSB (0000RRRR)
|
||
|
; X = Color LSB (GGGGBBBB)
|
||
|
GETCLR: JSR SETIDX ;Set Vera Address to Palette Index
|
||
|
LDX $9F25 ;Get Current Data Port
|
||
|
LDA $9F23,X ;Read LSB from Data Port
|
||
|
LDY $9F23,X ;Read MSB from Data Port
|
||
|
TAX ;Copy LSB to X Register
|
||
|
RTS
|
||
|
|
||
|
;setclr(idx) - Set Color Entry idx in Palette
|
||
|
;Args: A = Color Entry Index
|
||
|
; Y = Color MSB (0000RRRR)
|
||
|
; X = Color LSB (GGGGBBBB)
|
||
|
;Affects: A
|
||
|
;Returns: Y,X = Color Entry Address
|
||
|
SETCLR: JSR SAVRXY ;Save Color Value
|
||
|
JSR SETIDX ;Set Vera Address to Palette Index
|
||
|
LDX $9F25 ;Get Current Data Port
|
||
|
LDA TEMP1 ;Retrieve Color Value LSB
|
||
|
STA $9F23,X ;and Write to Data Port
|
||
|
LDA TEMP2 ;Retrieve Color Value MSB
|
||
|
STA $9F23,X ;Read MSB from Data Port
|
||
|
RTS
|
||
|
|
||
|
|
||
|
;setidy(idx) - Set Palette Index and Entry Count
|
||
|
;Args: A = Palette Index
|
||
|
; Y = Number of Entries
|
||
|
;Returns: A = Bank + Auto-Increment
|
||
|
; Y,X = Address
|
||
|
SETIDY: STY TEMP0 ;Store Number of Colors
|
||
|
ASL TEMP0 ;and Multiply by 2
|
||
|
|
||
|
;setidx(idx) - Set Vera Address to Palette Index
|
||
|
;Args: A = Index
|
||
|
;Returns: A = Bank + Auto-Increment
|
||
|
; Y,X = Address
|
||
|
SETIDX: ASL ;Multiply Index by 2
|
||
|
TAX ;and Set as LSB
|
||
|
LDA #$10 ;Get Palette Page
|
||
|
ADC #$00 ;Add Carry from Multiply
|
||
|
TAY ;and Set as MSB
|
||
|
JMP REGADR ;and Set Address to Register
|
||
|
|
||
|
;getplt(idx,num) - Set Palette Colors
|
||
|
;Args: A = Starting Index
|
||
|
; Y = Number of Colors (1-128)
|
||
|
;Uses: DSTLO,DSTHI = Address of Destination Array
|
||
|
;Affects: A,X,Y
|
||
|
GETPLT: JSR SETIDY ;Set Vera Address and Entry Count
|
||
|
JMP GETMEA ;Read Color Entries from Vera Memory
|
||
|
|
||
|
;setplt(idx,num) - Set Palette Colors
|
||
|
;Args: A = Starting Index
|
||
|
; Y = Number of Colors (1-128)
|
||
|
;Uses: SRCLO,SRCHI = Address of Color Entries
|
||
|
;Affects: A,X,Y
|
||
|
SETPLT: JSR SETIDY ;Set Vera Address and Entry Count
|
||
|
JMP SETMEA ;Write Color Entries to Vera Memory
|