mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-22 01:31:33 +00:00
Moved VERA Display Composer functions to veradisp.h02
This commit is contained in:
parent
7674e11b61
commit
7645862022
@ -1,36 +1,5 @@
|
||||
; C02 module vera.h02 assembly language subroutines
|
||||
|
||||
;getvid() - Get Video Output Mode
|
||||
;Returns: A = Video Mode
|
||||
; Y = Chroma Disabled
|
||||
; X = Current Field
|
||||
GETVID: LDA #$00 ;Set Register Offset to Video Output
|
||||
JSR GETDCR ;Read from Display Composer
|
||||
LDY #$00 ;Set Chroma Disabled to FALSE
|
||||
LDX #$00 ;Set Video Field to EVEN
|
||||
BIT GETVIM ;Test Chroma Disabled Bit
|
||||
BEQ GETVIE ;If Bit 3 is Set
|
||||
DEY ; Set Chroma Disabled to TRUE
|
||||
BIT GETVIM ;Test Chroma Disabled Bit
|
||||
GETVIE: BCC GETVIF ;If Bit 7 is Set
|
||||
DEX ; Set Video Field to ODD
|
||||
GETVIF: AND #$03 ;Isolate Bits 0-2 (Video Output Mode)
|
||||
RTS
|
||||
GETVIM: .DC $04 ;Chroma Disable Bit Mask
|
||||
|
||||
;getbdr() - Get Get Border Color
|
||||
;Returns: A = Border Color Palette Index
|
||||
GETBDR: LDA #$03 ;Set Register Offset to Border Color
|
||||
|
||||
;getdcr() - Get Display Composer Register
|
||||
;Args: A = Register Offset
|
||||
;Affects: Y
|
||||
;Returns: A = Contents of Register
|
||||
; X = Current Data Port
|
||||
GETDCR: LDY #$00 ;Set MSB to Display Composer Page
|
||||
TAX ;Set LSB to Register Offset
|
||||
JMP GETREG ;and Execute GETREG
|
||||
|
||||
;getmod() - Get Layer 0/1 Mode
|
||||
;Args: A = Layer (0/1)
|
||||
;Affects: Y
|
||||
@ -199,177 +168,6 @@ TILSIT: .DC $08,$10
|
||||
;Returns: A = Map Width Specifier
|
||||
; Y = Map Height Specifier
|
||||
|
||||
;getvsp() - Get Vertical Stop
|
||||
;Affects: A
|
||||
;Returns: Y,X = Vertical Stop
|
||||
GETVSP: LDA #7 ;Set Reg Offset to Vertical Stop
|
||||
JSR GETHVS ;Read Registers
|
||||
LSR ;Shift Left One Bit
|
||||
JMP GETVSS ;Then Four More Bits and Mask
|
||||
|
||||
;getvsr() - Get Vertical Start
|
||||
;Affects: A
|
||||
;Returns: Y,X = Vertical Start
|
||||
GETVSR: LDA #6 ;Set Reg Offset to Vertical Start
|
||||
JSR GETHVS ;Read Registers
|
||||
GETVSS: LSR ;Shift Left Four Bit
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
AND #$01 ;Isolate Bit 0
|
||||
TAY ;and Copy MSB to Y
|
||||
RTS
|
||||
|
||||
;gethsp() - Get Horizontal Stop
|
||||
;Affects: A
|
||||
;Returns: Y,X = Horizontal Stop
|
||||
GETHSP: LDA #5 ;Set Lookup Index to Horizontal Start
|
||||
JSR GETHVS ;Read Registers
|
||||
LSR ;Shift Left Two Bits
|
||||
LSR
|
||||
JMP GETHSS ;then Mask and Return
|
||||
|
||||
;gethsr() - Get Horizontal Start
|
||||
;Affects: A
|
||||
;Returns: Y,X = Horizontal Start
|
||||
GETHSR: LDA #4 ;Set Lookup Index to Horizontal Start
|
||||
JSR GETHVS ;Read Registers
|
||||
;.dc $ff ;debug
|
||||
GETHSS: AND #$03 ;Isolate Bit 0
|
||||
TAY ;and Copy MSB to Y
|
||||
RTS
|
||||
|
||||
;gethvs() - Get Start/Stop Low Byte and High Bits
|
||||
;Args: X = Low Register
|
||||
;Affects: Y
|
||||
;Returns: A = High Bits
|
||||
; X = Low Byte
|
||||
GETHVS: JSR GETDCR ;Read LSB from Register
|
||||
;.dc $ff ;debug
|
||||
PHA ;and Save It
|
||||
LDA #8 ;Load Register Offset for High Bits
|
||||
STA $9F20 ;Set As Address LSB
|
||||
LDA $9F23,X ;and Read High Bits into A
|
||||
.DC $FA ;PLX ;Restore LSB into X
|
||||
RTS
|
||||
|
||||
;getiql() - Get Interrupt Line
|
||||
;Affects: A
|
||||
;Returns: Y,X = Interrupt Line#
|
||||
GETIQL: LDA #9 ;Set Register Offset to Interrupt Line
|
||||
.DC $2C ;Skip to SETDCX (BIT Absolute)
|
||||
|
||||
;getscl() - Get Horizontal and Vertical Scale
|
||||
;Returns: A,X = Horizontal Scale
|
||||
; Y = Vertical Scale
|
||||
GETSCL: LDA #1 ;Set Register Offset to HSCALE,VSCALE
|
||||
|
||||
;getdci() - Get Display Composer Register Pair
|
||||
;Args: A = Register Offset
|
||||
;Affects: Y
|
||||
;Returns: A,X = Integer LSB
|
||||
; Y = Integer LSB
|
||||
GETDCI: LDY #$00 ;Set MSB to Display Composer Page
|
||||
TAX ;Set LSB to Register Offset
|
||||
JMP GETREI ;Get Vera Register Pair
|
||||
|
||||
;setvsp() - Set Horizontal Stop
|
||||
;Args: Y,X = Horizontal Stop
|
||||
;Affects: A,X,Y
|
||||
SETVSP: TYA ;Convert MSB to High Bit
|
||||
AND #$01
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #7 ;Set Register Offset to Horizontal Start
|
||||
LDY #$DF ;Set High Bits Mask
|
||||
JMP SETHST ;OR in High Bits and Write Back
|
||||
|
||||
;setvsr() - Set Horizontal Start
|
||||
;Args: Y,X = Horizontal Start
|
||||
;Affects: A,X,Y
|
||||
SETVSR: TYA ;Convert MSB to High Bit
|
||||
AND #$01
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #6 ;Set Register Offset to Horizontal Start
|
||||
LDY #$EF ;Set High Bits Mask
|
||||
JMP SETHST ;OR in High Bits and Write Back
|
||||
|
||||
;sethsp() - Set Horizontal Stop
|
||||
;Args: Y,X = Horizontal Stop
|
||||
;Affects: A,X,Y
|
||||
SETHSP: TYA ;Convert MSB to High Bits
|
||||
AND #$03
|
||||
ASL
|
||||
ASL
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #5 ;Set Register Offset to Horizontal Start
|
||||
LDY #$F3 ;Set High Bits Mask
|
||||
JMP SETHST ;OR in High Bits and Write Back
|
||||
|
||||
;sethsr() - Set Horizontal St7art
|
||||
;Args: Y,X = Horizontal Start
|
||||
;Destroys TEMP0,TEMP1,TEMP2
|
||||
;Affects: A,X,Y
|
||||
SETHSR: TYA ;Convert MSB to High Bits
|
||||
AND #$03
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #4 ;Set Register Offset to Horizontal Start
|
||||
LDY #$FC ;Set High Bits Mask
|
||||
SETHST: STY TEMP2 ;Save
|
||||
JSR SETHVS ;Write LSB and Get High Bits
|
||||
AND TEMP2 ;Mask Start Stop High
|
||||
ORA TEMP1 ;OR in High Bits
|
||||
STA $9F23,X ;and Write back to Register
|
||||
RTS
|
||||
|
||||
|
||||
SETHVS: JSR SETDCX ;Write LSB
|
||||
LDA #8 ;Load Register Offset for High Bits
|
||||
STA $9F20 ;Set As Address LSB
|
||||
LDA $9F23,X ;and Read High Bits into A
|
||||
RTS
|
||||
|
||||
;setvid() - Set Video Output Mode
|
||||
;Args: A = Video Mode
|
||||
; Y = Chroma Disabled
|
||||
;Destroys: TEMP0
|
||||
SETVID: AND #3 ;Isolate Video Mode Bits
|
||||
CPY #0 ;Set Chroma Mask to
|
||||
BEQ SETVIF ; 0 if Y is Zero or
|
||||
LDY #4 ; 4 if it is not
|
||||
SETVIF: STY TEMP0 ;Save Chroma Bit
|
||||
ORA TEMP0 ;Combine with Video Mode Bits
|
||||
LDX #0 ;Set Register Offset to Video Mode
|
||||
BEQ SETDCX ;Write to Register
|
||||
|
||||
;setbdr() - Set Border Color
|
||||
;Args: A = Border Color Palette Index
|
||||
SETBDR: LDX #3 ;Set Register Offset to Border Color
|
||||
.DC $2C ;Skip to SETDCX (BIT Absolute)
|
||||
|
||||
;setdcr() - Set Display Composer Register
|
||||
;Args: A = Register Offset
|
||||
; Y = Value to Write
|
||||
;Affects: Y
|
||||
;Returns: A = Value Written
|
||||
; X = Current Data Port
|
||||
SETDCR: TAX ;Set LSB to Register Offset
|
||||
TYA ;Move Write Value to Accumulator
|
||||
SETDCX: LDY #$00 ;Set MSB to Display Composer Page
|
||||
JMP SETREG ;Write to Register
|
||||
|
||||
;settbs() - Set Layer 0/1 Map Base
|
||||
;Args: A = Layer (0/1)
|
||||
; Y,X = Map Base
|
||||
@ -413,96 +211,4 @@ SETHSC: JSR SAVRXY ;Store Horizontal Scroll in TEMP1,TEMP2
|
||||
SETLRI: JSR GETLRP ;Get Layer Page in Y
|
||||
JMP SETREI ;and Write Integer to Register
|
||||
|
||||
;setiql() - Set IRQ Line
|
||||
;Args: Y,X = IRQ Line Number`
|
||||
;Sets: TEMP1,TEMP2 = IRQ Line Number
|
||||
;Affecta: A,Y,X
|
||||
SETIQL: TXA ;Copy LSB to Accumulator
|
||||
LDX #9 ;Set Register Offset to HSCALE,VSCALE
|
||||
.DC $2C ;Skip to SETDCP (BIT Absolute)
|
||||
|
||||
;setscl() - Set Horizontal and Vertical Scale
|
||||
;Args: A = Horizontal Scale
|
||||
; Y = Vertical Scale
|
||||
SETSCL: LDX #1 ;Set Register Offset to HSCALE,VSCALE
|
||||
|
||||
;setdcp() - Set Display Composer Register Pair
|
||||
;Args: A = First Register Value
|
||||
; Y = Second Register Value
|
||||
; X = Register Offset
|
||||
;Affects: A,Y
|
||||
;Returns: X = Current Data Port
|
||||
SETDCP: STA TEMP1 ;Store First Value as LSB
|
||||
STY TEMP2 ;Store Second Value as MSB
|
||||
LDY #$00 ;Set MSB to Display Composer Page
|
||||
JMP SETREI ;Set Register to Integer
|
||||
|
||||
|
||||
;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 Palette
|
||||
;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
|
||||
|
||||
;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
|
||||
|
@ -15,17 +15,6 @@ char clrrgb();
|
||||
* Returns: int c - Color Value */
|
||||
char getclr();
|
||||
|
||||
/* Read Display Controller Register *
|
||||
* Args: char r - Register Offset *
|
||||
* Returns: char v - Register Value */
|
||||
char getdcr();
|
||||
|
||||
/* Read Video Output Mode *
|
||||
* Returns: m - Output Mode *
|
||||
* c - Chroma Disabled *
|
||||
* f - Current Field */
|
||||
char getvid();
|
||||
|
||||
/* Convert R, G, and B Values *
|
||||
* to Palette Color Value *
|
||||
* Args: r - Red Value (0-15) *
|
||||
|
99
x16/include/veraclr.a02
Normal file
99
x16/include/veraclr.a02
Normal file
@ -0,0 +1,99 @@
|
||||
; 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
|
50
x16/include/veraclr.h02
Normal file
50
x16/include/veraclr.h02
Normal file
@ -0,0 +1,50 @@
|
||||
/***************************************************
|
||||
* vera.h02 - Commander X16 Routines for Vera chip *
|
||||
***************************************************/
|
||||
|
||||
/* Convert Palette Color Value *
|
||||
* to R, G, and B Values *
|
||||
* Args: int c - Color Value *
|
||||
* Returns: Red Value (0-15) *
|
||||
* Green Value (0-15) *
|
||||
* Blue Value (0-15) */
|
||||
char clrrgb();
|
||||
|
||||
/* Read Color Value from Palette *
|
||||
* Args: char i - Palette Index *
|
||||
* Returns: int c - Color Value */
|
||||
char getclr();
|
||||
|
||||
/* Read Color Entries from Palette *
|
||||
* Args: i - Index into Palette *
|
||||
* n - Number of Entries *
|
||||
* Requires: setdst(&array) */
|
||||
char getplt();
|
||||
|
||||
/* Convert R, G, and B Values *
|
||||
* to Palette Color Value *
|
||||
* Args: r - Red Value (0-15) *
|
||||
* g - Green Value (0-15) *
|
||||
* b - Blue Value (0-15) *
|
||||
* Returns: int c - Color Value */
|
||||
char rgbclr();
|
||||
|
||||
/* Write Color Value to Palette *
|
||||
* Args: i - Index into Palette *
|
||||
* int c - Color Value *
|
||||
* Returns: int d = Entry Address */
|
||||
char setclr();
|
||||
|
||||
/* Set Vera Address to Palette Index *
|
||||
* Args: i - Index into Palette *
|
||||
* int c - Color Value *
|
||||
* Returns: char b = Bank |Auto-Incr *
|
||||
* int d = Entry Address */
|
||||
char setidx();
|
||||
|
||||
/* Write Color Entries to Palette *
|
||||
* Args: i - Index into Palette *
|
||||
* n - Number of Entries *
|
||||
* Requires: setsrc(&entries) */
|
||||
char setplt();
|
||||
|
234
x16/include/veradsp.a02
Normal file
234
x16/include/veradsp.a02
Normal file
@ -0,0 +1,234 @@
|
||||
; Vera Display Composer Assembly Language Routines for C02
|
||||
; Requires External Routines GETDCR and SETDCX
|
||||
; and External Variables TEMP0, TEMP1, and TEMP2
|
||||
|
||||
;getbdr() - Get Get Border Color
|
||||
;Returns: A = Border Color Palette Index
|
||||
GETBDR: LDA #$03 ;Set Register Offset to Border Color
|
||||
|
||||
;getdcr() - Get Display Composer Register
|
||||
;Args: A = Register Offset
|
||||
;Affects: Y
|
||||
;Returns: A = Contents of Register
|
||||
; X = Current Data Port
|
||||
GETDCR: LDY #$00 ;Set MSB to Display Composer Page
|
||||
TAX ;Set LSB to Register Offset
|
||||
JMP GETREG ;and Execute GETREG
|
||||
|
||||
;getiql() - Get Interrupt Line
|
||||
;Affects: A
|
||||
;Returns: Y,X = Interrupt Line#
|
||||
GETIQL: LDA #9 ;Set Register Offset to Interrupt Line
|
||||
.DC $2C ;Skip to SETDCX (BIT Absolute)
|
||||
|
||||
;getscl() - Get Horizontal and Vertical Scale
|
||||
;Returns: A,X = Horizontal Scale
|
||||
; Y = Vertical Scale
|
||||
GETSCL: LDA #1 ;Set Register Offset to HSCALE,VSCALE
|
||||
|
||||
;getdci() - Get Display Composer Register Pair
|
||||
;Args: A = Register Offset
|
||||
;Affects: Y
|
||||
;Returns: A,X = Integer LSB
|
||||
; Y = Integer LSB
|
||||
GETDCI: LDY #$00 ;Set MSB to Display Composer Page
|
||||
TAX ;Set LSB to Register Offset
|
||||
JMP GETREI ;Get Vera Register Pair
|
||||
|
||||
;getvid() - Get Video Output Mode
|
||||
;Returns: A = Video Mode
|
||||
; Y = Chroma Disabled
|
||||
; X = Current Field
|
||||
GETVID: LDA #$00 ;Set Register Offset to Video Output
|
||||
JSR GETDCR ;Read from Display Composer
|
||||
LDY #$00 ;Set Chroma Disabled to FALSE
|
||||
LDX #$00 ;Set Video Field to EVEN
|
||||
BIT GETVIM ;Test Chroma Disabled Bit
|
||||
BEQ GETVIE ;If Bit 3 is Set
|
||||
DEY ; Set Chroma Disabled to TRUE
|
||||
BIT GETVIM ;Test Chroma Disabled Bit
|
||||
GETVIE: BCC GETVIF ;If Bit 7 is Set
|
||||
DEX ; Set Video Field to ODD
|
||||
GETVIF: AND #$03 ;Isolate Bits 0-2 (Video Output Mode)
|
||||
RTS
|
||||
GETVIM: .DC $04 ;Chroma Disable Bit Mask
|
||||
|
||||
;getvsp() - Get Vertical Stop
|
||||
;Affects: A
|
||||
;Returns: Y,X = Vertical Stop
|
||||
GETVSP: LDA #7 ;Set Reg Offset to Vertical Stop
|
||||
JSR GETHVS ;Read Registers
|
||||
LSR ;Shift Left One Bit
|
||||
JMP GETVSS ;Then Four More Bits and Mask
|
||||
|
||||
;getvsr() - Get Vertical Start
|
||||
;Affects: A
|
||||
;Returns: Y,X = Vertical Start
|
||||
GETVSR: LDA #6 ;Set Reg Offset to Vertical Start
|
||||
JSR GETHVS ;Read Registers
|
||||
GETVSS: LSR ;Shift Left Four Bit
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
AND #$01 ;Isolate Bit 0
|
||||
TAY ;and Copy MSB to Y
|
||||
RTS
|
||||
|
||||
;gethsp() - Get Horizontal Stop
|
||||
;Affects: A
|
||||
;Returns: Y,X = Horizontal Stop
|
||||
GETHSP: LDA #5 ;Set Lookup Index to Horizontal Start
|
||||
JSR GETHVS ;Read Registers
|
||||
LSR ;Shift Left Two Bits
|
||||
LSR
|
||||
JMP GETHSS ;then Mask and Return
|
||||
|
||||
;gethsr() - Get Horizontal Start
|
||||
;Affects: A
|
||||
;Returns: Y,X = Horizontal Start
|
||||
GETHSR: LDA #4 ;Set Lookup Index to Horizontal Start
|
||||
JSR GETHVS ;Read Registers
|
||||
GETHSS: AND #$03 ;Isolate Bit 0
|
||||
TAY ;and Copy MSB to Y
|
||||
RTS
|
||||
|
||||
;gethvs() - Get Start/Stop Low Byte and High Bits
|
||||
;Args: X = Low Register
|
||||
;Affects: Y
|
||||
;Returns: A = High Bits
|
||||
; X = Low Byte
|
||||
GETHVS: JSR GETDCR ;Read LSB from Register
|
||||
PHA ;and Save It
|
||||
LDA #8 ;Load Register Offset for High Bits
|
||||
STA $9F20 ;Set As Address LSB
|
||||
LDA $9F23,X ;and Read High Bits into A
|
||||
.DC $FA ;PLX ;Restore LSB into X
|
||||
RTS
|
||||
|
||||
;setbdr() - Set Border Color
|
||||
;Args: A = Border Color Palette Index
|
||||
SETBDR: LDX #3 ;Set Register Offset to Border Color
|
||||
.DC $2C ;Skip to SETDCX (BIT Absolute)
|
||||
|
||||
;setdcr() - Set Display Composer Register
|
||||
;Args: A = Register Offset
|
||||
; Y = Value to Write
|
||||
;Affects: Y
|
||||
;Returns: A = Value Written
|
||||
; X = Current Data Port
|
||||
SETDCR: TAX ;Set LSB to Register Offset
|
||||
TYA ;Move Write Value to Accumulator
|
||||
SETDCX: LDY #$00 ;Set MSB to Display Composer Page
|
||||
JMP SETREG ;Write to Register
|
||||
|
||||
;setvid() - Set Video Output Mode
|
||||
;Args: A = Video Mode
|
||||
; Y = Chroma Disabled
|
||||
;Destroys: TEMP0
|
||||
SETVID: AND #3 ;Isolate Video Mode Bits
|
||||
CPY #0 ;Set Chroma Mask to
|
||||
BEQ SETVIF ; 0 if Y is Zero or
|
||||
LDY #4 ; 4 if it is not
|
||||
SETVIF: STY TEMP0 ;Save Chroma Bit
|
||||
ORA TEMP0 ;Combine with Video Mode Bits
|
||||
LDX #0 ;Set Register Offset to Video Mode
|
||||
BEQ SETDCX ;Write to Register
|
||||
|
||||
;setiql() - Set IRQ Line
|
||||
;Args: Y,X = IRQ Line Number`
|
||||
;Sets: TEMP1,TEMP2 = IRQ Line Number
|
||||
;Affecta: A,Y,X
|
||||
SETIQL: TXA ;Copy LSB to Accumulator
|
||||
LDX #9 ;Set Register Offset to HSCALE,VSCALE
|
||||
.DC $2C ;Skip to SETDCP (BIT Absolute)
|
||||
|
||||
;setscl() - Set Horizontal and Vertical Scale
|
||||
;Args: A = Horizontal Scale
|
||||
; Y = Vertical Scale
|
||||
SETSCL: LDX #1 ;Set Register Offset to HSCALE,VSCALE
|
||||
|
||||
;setdcp() - Set Display Composer Register Pair
|
||||
;Args: A = First Register Value
|
||||
; Y = Second Register Value
|
||||
; X = Register Offset
|
||||
;Affects: A,Y
|
||||
;Returns: X = Current Data Port
|
||||
SETDCP: STA TEMP1 ;Store First Value as LSB
|
||||
STY TEMP2 ;Store Second Value as MSB
|
||||
LDY #$00 ;Set MSB to Display Composer Page
|
||||
JMP SETREI ;Set Register to Integer
|
||||
|
||||
;sethsp() - Set Horizontal Stop
|
||||
;Args: Y,X = Horizontal Stop
|
||||
;Destroys TEMP1,TEMP2
|
||||
;Affects: A,X,Y
|
||||
SETHSP: TYA ;Convert MSB to High Bits
|
||||
AND #$03
|
||||
ASL
|
||||
ASL
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #5 ;Set Register Offset to Horizontal Start
|
||||
LDY #$F3 ;Set High Bits Mask
|
||||
BNE SETHVS ;OR in High Bits and Write Back
|
||||
|
||||
;sethsr() - Set Horizontal Start
|
||||
;Args: Y,X = Horizontal Start
|
||||
;Destroys TEMP1,TEMP2
|
||||
;Affects: A,X,Y
|
||||
SETHSR: TYA ;Convert MSB to High Bits
|
||||
AND #$03
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #4 ;Set Register Offset to Horizontal Start
|
||||
LDY #$FC ;Set High Bits Mask
|
||||
|
||||
;sethvs() - Set Horizontal/Vertial Start/Stop
|
||||
;Args: A = Start/Stop LSB
|
||||
; Y = High Bits and Mask
|
||||
; X = LSB Register Offset
|
||||
;Uses: TEMP1 = Start Stop High Bits
|
||||
;Destroys: TEMP2
|
||||
;Affects: A,X,Y
|
||||
SETHVS: STY TEMP2 ;Save
|
||||
JSR SETDCX ;Write LSB
|
||||
LDA #8 ;Load Register Offset for High Bits
|
||||
STA $9F20 ;Set As Address LSB
|
||||
LDA $9F23,X ;and Read High Bits into A
|
||||
AND TEMP2 ;Mask Start Stop High
|
||||
ORA TEMP1 ;OR in High Bits
|
||||
STA $9F23,X ;and Write back to Register
|
||||
RTS
|
||||
|
||||
;setvsp() - Set Horizontal Stop
|
||||
;Args: Y,X = Horizontal Stop
|
||||
;Destroys TEMP1,TEMP2
|
||||
;Affects: A,X,Y
|
||||
SETVSP: TYA ;Convert MSB to High Bit
|
||||
AND #$01
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #7 ;Set Register Offset to Horizontal Start
|
||||
LDY #$DF ;Set High Bits Mask
|
||||
BNE SETHVS ;OR in High Bits and Write Back
|
||||
|
||||
;setvsr() - Set Horizontal Start
|
||||
;Args: Y,X = Horizontal Start
|
||||
;Destroys TEMP1,TEMP2
|
||||
;Affects: A,X,Y
|
||||
SETVSR: TYA ;Convert MSB to High Bit
|
||||
AND #$01
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
STA TEMP1 ;and Save
|
||||
TXA ;Copy LSB to Accumlator
|
||||
LDX #6 ;Set Register Offset to Horizontal Start
|
||||
LDY #$EF ;Set High Bits Mask
|
||||
BNE SETHVS ;OR in High Bits and Write Back
|
73
x16/include/veradsp.h02
Normal file
73
x16/include/veradsp.h02
Normal file
@ -0,0 +1,73 @@
|
||||
/*********************************************
|
||||
* veradsp.h02 - Display Composer Functions *
|
||||
* Commander X16 VERA Chip *
|
||||
*********************************************/
|
||||
|
||||
/* Get Border Color *
|
||||
* Returns: char i = Color Index */
|
||||
char getbdr();
|
||||
|
||||
/* Get Horizontal Stop *
|
||||
* Returns: int i = Horizontal Stop */
|
||||
char gethsp();
|
||||
|
||||
/* Get Horizontal Start *
|
||||
* Returns: int i = Horizontal Start */
|
||||
char gethsr();
|
||||
|
||||
/* Get IRQ Line *
|
||||
* Returns: int i = IRQ Line */
|
||||
char getiql();
|
||||
|
||||
/* Get Horizontal and Vertical Scale *
|
||||
* Returns: char h = Horizontal Scale *
|
||||
* char v - Vertical Scale */
|
||||
char getscl();
|
||||
|
||||
/* Get Video Output Mode *
|
||||
* Returns: char m - Output Mode *
|
||||
* char c - Chroma Disabled *
|
||||
* char f - Current Field */
|
||||
char getvid();
|
||||
|
||||
/* Get Vertical Stop *
|
||||
* Returns: int i = Vertical Stop */
|
||||
char getvsp();
|
||||
|
||||
/* Get Vertical Start *
|
||||
* Returns: int i = Vertical Start */
|
||||
char getvsr();
|
||||
|
||||
/* Set Border Color *
|
||||
* Args: char i = Color Index */
|
||||
char setbdr();
|
||||
|
||||
/* Set Horizontal Stop *
|
||||
* Args: int i = Horizontal Stop */
|
||||
char sethsp();
|
||||
|
||||
/* Set Horizontal Start *
|
||||
* Args: int i = Horizontal Start */
|
||||
char sethsr();
|
||||
|
||||
/* set IRQ Line *
|
||||
* Args: int i = IRQ Line */
|
||||
char setiql();
|
||||
|
||||
/* Set Horizontal and Vertical Scale *
|
||||
* Args: char h = Horizontal Scale *
|
||||
* char v - Vertical Scale */
|
||||
char setscl();
|
||||
|
||||
/* Set Video Output Mode *
|
||||
* Args: char m - Output Mode *
|
||||
* char c - Chroma Disabled */
|
||||
char setvid();
|
||||
|
||||
/* Set Vertical Stop *
|
||||
* Args: int i = Vertical Stop */
|
||||
char setvsp();
|
||||
|
||||
/* Set Vertical Start *
|
||||
* Args: int i = Vertical Start */
|
||||
char setvsr();
|
@ -143,7 +143,7 @@ SETINT: TXA ;Copy LSB to Accumlator
|
||||
; X = Current Data Port
|
||||
SETMEM: STA TEMP0 ;Save Number of Bytes
|
||||
JSR SETSRC ;Save Destination Address
|
||||
LDX $9F25 ;Get Current Data Port
|
||||
SETMEA: LDX $9F25 ;Get Current Data Port
|
||||
LDY #0 ;Initialize Counter
|
||||
SETMEL: LDA (SRCLO),Y ;Read Byte from Array
|
||||
STA $9F23,X ;Write Byte to Data Port
|
||||
|
@ -21,17 +21,12 @@ char getbyt();
|
||||
char getint();
|
||||
|
||||
/* Read from Vera Memory into Array *
|
||||
* Args: char opts - Bank | Auto-Increment *
|
||||
* int addr - Address Bits 0-15 *
|
||||
* Returns: char count - Bytes Written */
|
||||
* Args: char n - Number of Bytes *
|
||||
* int d - Address of Array *
|
||||
* Requires: setadr(bank,addr) *
|
||||
* Returns: char count - Bytes Written */
|
||||
char getmem();
|
||||
|
||||
/* Read Vera Internal Register Pair *
|
||||
* Args: int addr - Register Address *
|
||||
* Returns: char byte - Register LSB *
|
||||
* int word - Register Contents */
|
||||
char getrei();
|
||||
|
||||
/* Set Vera Memory Address *
|
||||
* Args: char opts - Bank | Auto-Increment *
|
||||
* int addr - Address *
|
||||
@ -48,7 +43,8 @@ char setbyt();
|
||||
char setint();
|
||||
|
||||
/* Write from Array to Vera Memory *
|
||||
* Args: int word - Integer to Write *
|
||||
* Args: char n - Number of Bytes *
|
||||
* int d - Address of Array *
|
||||
* Requires: setadr(bank,addr) *
|
||||
* Returns: char count - Bytes Written */
|
||||
char setmem();
|
||||
|
@ -1,6 +1,5 @@
|
||||
/*****************************************************
|
||||
* TESTVERA *
|
||||
* Prints "HELLO WORLD" and exits *
|
||||
*****************************************************/
|
||||
|
||||
//Specify System Header using -H option
|
||||
@ -12,6 +11,8 @@
|
||||
#include <memory.h02>
|
||||
#include <nybble.h02>
|
||||
#include "include/veramem.h02"
|
||||
#include "include/veradsp.h02"
|
||||
#include "include/veraclr.h02"
|
||||
#include "include/vera.h02"
|
||||
|
||||
const char abcdef = {1,2,3,4,5,6};
|
||||
|
Loading…
Reference in New Issue
Block a user