mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-19 19:31:04 +00:00
Added and updated VERA modules
This commit is contained in:
parent
de56780b03
commit
7f4e98826c
@ -3,17 +3,27 @@
|
||||
; 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)
|
||||
;Args: A = Red Value (0-255)
|
||||
; Y = Green Value (0-255)
|
||||
; X = Blue Value (0-255)
|
||||
;Destroys: TEMP0
|
||||
;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
|
||||
RGBCLR: LSR ;Divide Red Value by 16
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
PHA ;and Save It
|
||||
TYA ;Copy Green Value to Accumulator
|
||||
AND #$F0 ;Strip Low Nybble
|
||||
STA TEMP0 ;and Store It
|
||||
TXA ;Copy Blue Value to Accumulator
|
||||
LSR ;Divide by 16
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
ORA TEMP0 ;Combine with Green
|
||||
TAX ;and Return as LSB
|
||||
.DC $7A ;PLY Return Red as MSB
|
||||
RTS
|
||||
@ -21,30 +31,50 @@ RGBCLR: PHA ;Save Red Value
|
||||
;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)
|
||||
;Returns: A = Red Value (0-255)
|
||||
; Y = Green Value (0-255)
|
||||
; X = Blue Value (0-255)
|
||||
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
|
||||
AND #$F0 ;Isolate Green Value
|
||||
TAY ;and Return in Y
|
||||
TXA ;Copy LSB into Accumulator
|
||||
ASL ;Shift Low Nybble Left
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
TAX ;and Return in X
|
||||
PLA ;Retrieve MSB (Red)
|
||||
ASL ;Shift Low Nybble Left
|
||||
ASL
|
||||
ASL
|
||||
ASL ;and Return in A
|
||||
RTS
|
||||
|
||||
;getclr(idx) - Get Color Entry idx from Paleftte
|
||||
;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
|
||||
|
||||
;getcln() - Get Next Color Entry from Palette
|
||||
;Affects: A
|
||||
;Returns: Y = Color MSB (0000RRRR)
|
||||
; X = Color LSB (GGGGBBBB)
|
||||
GETCLN: 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
|
||||
|
||||
;getrgb() - Get Next Palette Entry as RGB
|
||||
;Returns: A = Red Value (0-255)
|
||||
; Y = Green Value (0-255)
|
||||
; X = Blue Value (0-255)
|
||||
GETRGB: JSR GETCLN ;Get Next Color Entry
|
||||
JMP CLRRGB ;Convert to RGB and Return
|
||||
|
||||
;setclr(idx) - Set Color Entry idx in Palette
|
||||
;Args: A = Color Entry Index
|
||||
; Y = Color MSB (0000RRRR)
|
||||
@ -53,13 +83,30 @@ GETCLR: JSR SETIDX ;Set Vera Address to Palette Index
|
||||
;Returns: Y,X = Color Entry Address
|
||||
SETCLR: JSR SAVRXY ;Save Color Value
|
||||
JSR SETIDX ;Set Vera Address to Palette Index
|
||||
JSR RESRXY ;Restore Color Value
|
||||
|
||||
|
||||
;setcln() - Set Next Color Entry in Palette
|
||||
;Args: Y = Color MSB (0000RRRR)
|
||||
; X = Color LSB (GGGGBBBB)
|
||||
;Affects: A,X
|
||||
SETCLN: TXA ;Copy LSB to Accumulator
|
||||
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
|
||||
TYA ;Copy MSB to Accumulator
|
||||
STA $9F23,X ;and Write to Data Port
|
||||
RTS
|
||||
|
||||
|
||||
;setrgb() - Set Next Palette Entry to RGB Color
|
||||
;Args: A = Red Value (0-255)
|
||||
; Y = Green Value (0-255)
|
||||
; X = Blue Value (0-255)
|
||||
;Destroys: TEMP0
|
||||
;Destroys: TEMP0
|
||||
;Affects: A,Y,X
|
||||
SETRGB: JSR RGBCLR ;Convert RGB to Vera Color Value
|
||||
JMP SETCLN ;and Write to Next Palette Entry
|
||||
|
||||
;setidy(idx) - Set Palette Index and Entry Count
|
||||
;Args: A = Palette Index
|
||||
@ -82,7 +129,7 @@ SETIDX: ASL ;Multiply Index by 2
|
||||
|
||||
;getplt(idx,num) - Set Palette Colors
|
||||
;Args: A = Starting Index
|
||||
; Y = Number of Colors (1-128)
|
||||
; Y = Number of Entries (1-128)
|
||||
;Uses: DSTLO,DSTHI = Address of Destination Array
|
||||
;Affects: A,X,Y
|
||||
GETPLT: JSR SETIDY ;Set Vera Address and Entry Count
|
||||
@ -90,7 +137,7 @@ GETPLT: JSR SETIDY ;Set Vera Address and Entry Count
|
||||
|
||||
;setplt(idx,num) - Set Palette Colors
|
||||
;Args: A = Starting Index
|
||||
; Y = Number of Colors (1-128)
|
||||
; Y = Number of Entries (1-128)
|
||||
;Uses: SRCLO,SRCHI = Address of Color Entries
|
||||
;Affects: A,X,Y
|
||||
SETPLT: JSR SETIDY ;Set Vera Address and Entry Count
|
||||
|
@ -3,14 +3,18 @@
|
||||
* Commander X16 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) */
|
||||
/* Convert Palette Color Value *
|
||||
* to R, G, and B Values *
|
||||
* Args: int c - Color Value *
|
||||
* Returns: Red Value (0-255) *
|
||||
* Green Value (0-255) *
|
||||
* Blue Value (0-255) */
|
||||
char clrrgb();
|
||||
|
||||
/* Read Next Entry from Palette *
|
||||
* Returns: int c - Color Value */
|
||||
char getcln();
|
||||
|
||||
/* Read Color Value from Palette *
|
||||
* Args: char i - Palette Index *
|
||||
* Returns: int c - Color Value */
|
||||
@ -22,18 +26,29 @@ char getclr();
|
||||
* 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 */
|
||||
/* Read RGB Color from Palette *
|
||||
* Requires: setidx() *
|
||||
* Returns: Red Value (0-255) *
|
||||
* Green Value (0-255) *
|
||||
* Blue Value (0-255) */
|
||||
char getrgb();
|
||||
|
||||
/* Convert R, G, and B Values *
|
||||
* to Palette Color Value *
|
||||
* Args: r - Red Value (0-255) *
|
||||
* g - Green Value (0-255) *
|
||||
* b - Blue Value (0-255) *
|
||||
* Returns: int c - Color Value */
|
||||
char rgbclr();
|
||||
|
||||
/* Set Next Palette Entry to Color *
|
||||
* Requires: setidx() *
|
||||
* Args: int c - Color Value */
|
||||
char setcln();
|
||||
|
||||
/* Write Color Value to Palette *
|
||||
* Args: i - Index into Palette *
|
||||
* int c - Color Value *
|
||||
* Returns: int d = Entry Address */
|
||||
* int c - Color Value */
|
||||
char setclr();
|
||||
|
||||
/* Set Vera Address to Palette Index *
|
||||
@ -49,3 +64,9 @@ char setidx();
|
||||
* Requires: setsrc(&entries) */
|
||||
char setplt();
|
||||
|
||||
/* Set Next Palette Entry to RGB *
|
||||
* Requires: setidx() *
|
||||
* Args: r - Red Value (0-255) *
|
||||
* g - Green Value (0-255) *
|
||||
* b - Blue Value (0-255) */
|
||||
char setrgb();
|
||||
|
@ -45,7 +45,6 @@ GETLRS: LDX #1 ;Set Offset to Size Register
|
||||
; X = Current Data Port
|
||||
GETLRC: LDX #0 ;Set Offset to Control Register
|
||||
|
||||
|
||||
;getlrr() - Get Layer 0/1 Register
|
||||
;Args: A = Layer (0/1)
|
||||
; X = Register Offset
|
||||
@ -53,7 +52,7 @@ GETLRC: LDX #0 ;Set Offset to Control Register
|
||||
;Affects: Y
|
||||
;Returns: A = Contents of Register
|
||||
; X = Current Data Port
|
||||
GETLRR: STX TEMP3 ;Save Register Offset
|
||||
GETLRR: STX TEMP3 ;Save Register Offset - Obselete?
|
||||
JSR GETLRP ;Get Layer Page in Y
|
||||
JMP GETVRG ;and Read Vera Register
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
;$9F26 Interrupt Enable
|
||||
;$9F27 Interrupt Status
|
||||
|
||||
|
||||
;asladr() - Shift Vera Address Left`
|
||||
;Args: X = Number of Bits to Shift
|
||||
;Updates: TEMP0 = Bank
|
||||
@ -27,14 +26,57 @@ ASLADR: ASL TEMP1 ;Shift LSB Left
|
||||
BNE ASLADR ;and Loop if Not Zero
|
||||
JMP RESREG ;Return Bank, MSB, LSB
|
||||
|
||||
;chkadr(opts,addr) - Check Vera Address
|
||||
;Args: A = Bank + Auto-Increment
|
||||
; Y,X = Address
|
||||
;Returns: A = $00 - Address is Invalid
|
||||
; $FF - Address is Valid
|
||||
CHKADR: AND #$0F ;Isolate Bank
|
||||
CMP #$0F ;If Registers
|
||||
BEQ GETVRT ; Return True
|
||||
CMP #$02 ;Else If <2
|
||||
BCS GETVRT ; Return True
|
||||
LDA #$0 ;Else Return False
|
||||
RTS
|
||||
|
||||
;clrmem(count) - Write Array to Vera Memory
|
||||
;Args: A = Number of Bytes to Clear
|
||||
;Returns: A,Y = 0
|
||||
; X = Current Data Port
|
||||
CLRMEM: TAY ;Copy Number of Bytes to Y
|
||||
LDA #0 ;Set Write Value to Zero
|
||||
|
||||
;filmem(byte, count) - Fill Vera Memory with Byte
|
||||
;Args: A = Byte to Fill Memory With
|
||||
; Y = Number of Bytes to Fill
|
||||
;Returns: Y = 0
|
||||
; X = Current Data Port
|
||||
FILMEM LDX $9F25 ;Get Current Data Port
|
||||
FILMEL: STA $9F23,X ;Write Byte to Data Port
|
||||
DEY ;Decrement Counter
|
||||
BNE FILMEL ;If Not Zero Loop
|
||||
RTS
|
||||
|
||||
;getadr() - Get Vera Address
|
||||
;Args: A = Bank + Auto-Increment
|
||||
; Y,X = Address
|
||||
GETADR: LDX $9F20 ;Store Address LSB
|
||||
LDY $9F21 ;Store Address MSB
|
||||
LDA $9F22 ;Store Bank & Auto-Increment
|
||||
GETADR: LDX $9F20 ;Read Address LSB
|
||||
LDY $9F21 ;Read Address MSB
|
||||
LDA $9F22 ;Read Bank & Auto-Increment
|
||||
RTS
|
||||
|
||||
;getvrb(&addr) - Get Vera Register Bit Status
|
||||
;Args: A = Bit Mask
|
||||
; Y,X = Address
|
||||
;Returns: A = Mode
|
||||
; X = Current Data Port
|
||||
GETVRB: STA TEMP0 ;Save Bit Mask
|
||||
JSR GETVRG ;Read Register
|
||||
AND TEMP0 ;Mask Register Bit
|
||||
BEQ GETVRX ;If Set
|
||||
GETVRT: LDA #$FF ; Return TRUE
|
||||
GETVRX: RTS ;Else Return FALSE
|
||||
|
||||
;getvrg(&addr) - Read Vera Internal Register
|
||||
;Args: Y,X = Address
|
||||
;Returns: A = Mode
|
||||
@ -70,6 +112,8 @@ GETMEL: LDA $9F23,X ;Read Byte from Data Port
|
||||
INY ;Increment Counter
|
||||
CPY TEMP0 ;If Limit Not Reached
|
||||
BNE GETMEL ; Loop
|
||||
TYA ;Return Count
|
||||
RTS
|
||||
|
||||
;getvri(addr); Read Vera Register Pair
|
||||
;Args: Y,X = Address
|
||||
@ -91,10 +135,15 @@ GETINT: AND #$0F ;Set Auto-Increment to 1
|
||||
TAX ;Copy LSB to X
|
||||
RTS
|
||||
|
||||
;regadr(opts,addr) - Set Vera Address to Internal Register
|
||||
;regadr(addr) - Set Vera Address to Internal Register
|
||||
;Args: Y,X = Register Address
|
||||
;Returns: A= Bank + Auto-Increment
|
||||
REGADR: LDA #$1F ;Set Bank and Auto-Increment
|
||||
;Returns: A = Bank | Auto-Increment
|
||||
REGADR: LDA #$0F ;Set Bank and Auto-Increment
|
||||
|
||||
;setadi(bank,addr) - Set Vera Address with Auto-Increment
|
||||
;Args: A = Bank
|
||||
; Y,X = Address
|
||||
SETADI: ORA #$10 ;Set Auto-Increment to 1
|
||||
|
||||
;setadr(opts,addr) - Set Vera Address
|
||||
;Args: A = Bank + Auto-Increment
|
||||
@ -104,6 +153,18 @@ SETADR: STX $9F20 ;Store Address LSB
|
||||
STA $9F22 ;Store Bank & Auto-Increment
|
||||
RTS
|
||||
|
||||
;setvrb(bits, &addr) - Set Vera Register Bits
|
||||
;Args: A = Bit Pattern
|
||||
; Y,X = Address
|
||||
;Uses: TEMP0 = Bit Mask
|
||||
;Sets: TEMP1 = Bit Pattern
|
||||
;Affects: A,Y,X
|
||||
SETVRB: STA TEMP1 ;Save Bit Pattern
|
||||
JSR GETVRG ;Read Register
|
||||
AND TEMP0 ;Mask Result
|
||||
ORA TEMP1 ;Set Bits
|
||||
JMP SETBYN ;Write Back to Register
|
||||
|
||||
;setreg(addr) - Set Register
|
||||
;Args: A = Value to Write
|
||||
; Y,X = Address
|
||||
@ -121,7 +182,7 @@ SETREH: LDA #$0F ;Set Bank, Auto-Increment
|
||||
; X = Current Data Port
|
||||
SETBYT: JSR SETADR ;Set Vera Address
|
||||
LDA TEMP0 ;Retrieve Value to Write
|
||||
LDX $9F25 ;Get Current Data Port
|
||||
SETBYN: LDX $9F25 ;Get Current Data Port
|
||||
STA $9F23,X ;Write Value to Data Port
|
||||
RTS
|
||||
|
||||
@ -160,11 +221,10 @@ SETINT: TXA ;Copy LSB to Accumlator
|
||||
;Requires: setadr()
|
||||
;Sets: SRCLO,SRCHI = Address of Array
|
||||
; TEMP0 = Number of Bytes to Write
|
||||
;Affects: A
|
||||
;Returns: Y = Number of Bytes Written
|
||||
;Returns: A,Y = Number of Bytes Written
|
||||
; X = Current Data Port
|
||||
SETMEM: STA TEMP0 ;Save Number of Bytes
|
||||
JSR SETSRC ;Save Destination Address
|
||||
SETMEM: JSR SETSRC ;Save Source Address
|
||||
SETMET: STA TEMP0 ;Save Number of Bytes
|
||||
SETMEA: LDX $9F25 ;Get Current Data Port
|
||||
LDY #0 ;Initialize Counter
|
||||
SETMEL: LDA (SRCLO),Y ;Read Byte from Array
|
||||
@ -172,4 +232,5 @@ SETMEL: LDA (SRCLO),Y ;Read Byte from Array
|
||||
INY ;Increment Counter
|
||||
CPY TEMP0 ;If Limit Not Reached
|
||||
BNE SETMEL ; Loop
|
||||
TYA ;Return Count
|
||||
RTS
|
||||
|
@ -6,6 +6,24 @@
|
||||
* stddef.h02 *
|
||||
*********************************************/
|
||||
|
||||
|
||||
/* Check Vera Memory Address *
|
||||
* Args: char opts - Bank | Auto-Increment *
|
||||
* int addr - Address *
|
||||
* Returns: char valid - #TRUE or #FALSE */
|
||||
char chkadr();
|
||||
|
||||
/* Clear Vera Memory *
|
||||
* Args: char n - Number of Bytes *
|
||||
* Requires: setadr(bank,addr) */
|
||||
char clrmem();
|
||||
|
||||
/* Fill Vera Memory *
|
||||
* Args: char b - Byte to Write *
|
||||
* char n - Number of Bytes *
|
||||
* Requires: setadr(bank,addr) */
|
||||
char filmem();
|
||||
|
||||
/* Get Vera Memory Address *
|
||||
* Returns: char bank - Address Bits 16-19 *
|
||||
* int addr - Address Bits 0-15 */
|
||||
@ -30,6 +48,15 @@ char getint();
|
||||
* Returns: char count - Bytes Written */
|
||||
char getmem();
|
||||
|
||||
/* Set Address to Internal Register *
|
||||
* Args: int addr - Register Address *
|
||||
char regadr();
|
||||
|
||||
/* Set Vera Address with Auto-Increment *
|
||||
* Args: char opts - Bank *
|
||||
* int addr - Address *
|
||||
char setadi();
|
||||
|
||||
/* Set Vera Memory Address *
|
||||
* Args: char opts - Bank | Auto-Increment *
|
||||
* int addr - Address *
|
||||
|
17
x16/include/veraspi.h02
Normal file
17
x16/include/veraspi.h02
Normal file
@ -0,0 +1,17 @@
|
||||
/**********************************************
|
||||
* veraspi.h02 - SPI Controller Routines *
|
||||
* for Commander X16 VERA Chip *
|
||||
* Requires: x16.h02 *
|
||||
* stddef.h02 *
|
||||
* veramem.h02 *
|
||||
**********************************************/
|
||||
|
||||
/* Read Bytes From SD Card *
|
||||
* Args: char n = Number of Bytes *
|
||||
* int d = Destination Address */
|
||||
sread();
|
||||
|
||||
/* Write Bytes to SD Card *
|
||||
* Args: char n = Number of Bytes *
|
||||
* int d = Source Address */
|
||||
swrite();
|
535
x16/include/veraspr.a02
Normal file
535
x16/include/veraspr.a02
Normal file
@ -0,0 +1,535 @@
|
||||
;Vera Sprite Manipulation Assembly Language Routines for C02
|
||||
;Requires External Routines GETMEA, GETVRB, GETVRG, SETMET, SETSRD, SETVRB
|
||||
;and External Variables DSTHI, DSTLO, SRCHI, SRCLO, TEMP0, TEMP0, TEMP2
|
||||
|
||||
;Sprite Control Registers
|
||||
;$F4000 SPR_CTRL Bit 0 - Enabled
|
||||
;$F4001 SPR_COLLISION Bits 0-3 Collision Mask
|
||||
|
||||
;Sprite attributes
|
||||
;$F5000 - 128 Entries of the Following Format:
|
||||
|
||||
; Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
|
||||
;+0 ---------------------Address (12:5)---------------------------
|
||||
;+1 Mode -------Address (16:13)-------
|
||||
;+2 ------------------------X (7:0)-------------------------------
|
||||
;+3 ---X (9:8)---
|
||||
;+4 ------------------------Y (7:0)-------------------------------
|
||||
;+5 ---Y (9:8)---
|
||||
;+6 --------Collision mask-------- ---Z-depth--- V-flip H-flip
|
||||
;+7 Sprite height Sprite width --------Palette offset--------
|
||||
|
||||
MAXSPR EQU 128 ;Maximum Sprite Index
|
||||
|
||||
;addspd(index,number) - Add to Sprite Address Register
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Number to Add
|
||||
;Affects: A,X,Y
|
||||
ADDSPD: JSR SAVREG ;Save Sprite Index, Addend
|
||||
JSR GETSPD ;Read Sprite Address Register
|
||||
JSR ADDTXY ;Add Number to Address
|
||||
JMP SETSTD ;Write Sprite (TEMP0) Address Register
|
||||
|
||||
;subspd(index,number) - Decrement Sprite Address Register
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Number to Add
|
||||
;Affects: A,X,Y
|
||||
SUBSPD: JSR SAVREG ;Save Sprite Index, Addend
|
||||
JSR GETSPD ;Read Sprite Address Register
|
||||
JSR ADDTXY ;Add Number to Address
|
||||
JMP SETSTD ;Write Sprite (TEMP0) Address Register
|
||||
|
||||
;clrspr(index) - Set Sprite Attributes
|
||||
;Args: A = Sprite Index
|
||||
;Destroys: TEMP0
|
||||
;Returns: A,Y = 0
|
||||
; X = Current Data Port
|
||||
CLRSPR: JSR SETSP0 ;Set Sprite Attributes Address
|
||||
JMP CLRMEM ;and Read from Vera
|
||||
|
||||
;getspc() - Read Sprites Collision Status
|
||||
;Affects: Y
|
||||
;Returns: A = Sprite Collision Status
|
||||
; X = Current Data Port
|
||||
GETSPC: LDX #$02 ;Set Offset to Sprite Control
|
||||
LDY #$40 ;Set Page to Sprite Registers
|
||||
JSR GETVRG ;Read Vera Register
|
||||
AND #$0F ;Return Bits 0-3
|
||||
RTS
|
||||
|
||||
;getspd(index) - Get Sprite Address Register
|
||||
;Args: A = Index
|
||||
;Affects: A
|
||||
;Returns: Y,X = Address Register Contents
|
||||
GETSPD: JSR GETSP0 ;Get Sprite Attribute Address
|
||||
JSR GETVRI ;Read Vera Register Pair
|
||||
TYA
|
||||
AND #$0F
|
||||
TAY
|
||||
RTS
|
||||
|
||||
;getspe() - Read Sprites Enabled Flag
|
||||
;Affects: Y
|
||||
;Returns: A = $FF - Sprites Enabled
|
||||
; $00 - Sprites Disabled
|
||||
; X = Current Data Port
|
||||
GETSPE: LDA #$01 ;Set Mask to %0000001
|
||||
LDX #$00 ;Set Offset to Sprite Control
|
||||
GETSP4: LDY #$40 ;Set Page to Sprite Registers
|
||||
JMP GETVRB ;Get Register Bit Sratus
|
||||
|
||||
;getspt(mask) - Test Sprite Collision Status
|
||||
;Args: A = Collision Bit Mask
|
||||
;Affects: Y
|
||||
;Returns: A = Sprite Collision Bits
|
||||
; X = Current Data Port
|
||||
GETSPT: LDX #$01 ;Set Offset to Sprite Collisions
|
||||
BNE GETSP4 ;Get Register Bit Status
|
||||
|
||||
;getspa(index) - Get Sprite Data Address
|
||||
;Args: A = Index
|
||||
;Returns: A = Bank
|
||||
; Y,X = Address
|
||||
GETSPA: JSR GETSPD ;Get Address Register Contents
|
||||
|
||||
;getsca(index) - Get Vera Address from Sprite Address
|
||||
;Args: Y,X = Sprite Address
|
||||
;Returns: A = Bank
|
||||
; Y,X = Address
|
||||
GETSCA: LDA #0 ;Set Bank to 0
|
||||
JSR SAVREG ;Save Address
|
||||
LDX #5 ;Set Shift Count
|
||||
JMP ASLADR ;and Shift Address Left
|
||||
|
||||
;getspb(index) - Get Sprite Bits Per Pixel
|
||||
;Args: A = Index
|
||||
;Returns: A = Mode (0=4bpp, 1=8bpp)
|
||||
GETSPB: JSR GETSP1 ;Read Sprite Register #1
|
||||
ASL ;Move High Bit to Carry
|
||||
LDA #0 ;Clear Accumulator
|
||||
ROL ;Move Carry into Low Bit
|
||||
RTS
|
||||
|
||||
;getspv(index) - Get Sprite Vertical Flip
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Vertical Flip Flag
|
||||
GETSPV: LDY #$02 ;Set Bit Mask to Bit 1
|
||||
.DC $2C ;Skip Next Instruction (Bit Absolute)
|
||||
|
||||
;getspf(index) - Get Sprite Horizontal Flip
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Horizontal Flip Flag
|
||||
GETSPF: LDY #$01 ;Set Bit Mask to Bit 0
|
||||
STY TEMP0 ;and Store It
|
||||
JSR GETSPN ;Get Sprite Control Register
|
||||
AND TEMP0 ;Mask Bit(s)
|
||||
BEQ GETSXF ;If Clear, Return FALSE
|
||||
LDA #$FF ;Else Return TRUE
|
||||
GETSXF: RTS
|
||||
|
||||
;getspw(index) - Get Sprite Width Specifier
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Palette Offset
|
||||
GETSPW: JSR GETSPS ;Get Sprite Size Register
|
||||
ASL ;Shift Left 2 Bits
|
||||
ASL
|
||||
JMP GETSP6 ;Then Right 6 Bits
|
||||
|
||||
;getsph(index) - Get Sprite Height Specifier
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Sprite Height Specifier
|
||||
GETSPH: JSR GETSPS ;Get Sprite Size Register
|
||||
GETSP6: LSR ;Shift Right 6 Bits
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
RTS
|
||||
|
||||
;getspm(index) - Get Sprite Collision Mask
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Collision Mask
|
||||
GETSPM: JSR GETSPN ;Get Sprite Control Register
|
||||
LSR ;Shift High Nybble to Low Nybble
|
||||
LSR
|
||||
LSR
|
||||
LSR
|
||||
RTS
|
||||
|
||||
;getspp(index) - Get Sprite Palette Offset
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Palette Offset
|
||||
GETSPP: JSR GETSPS ;Get Sprite Size Register
|
||||
AND #$0F ;Return Low Nybble
|
||||
RTS
|
||||
|
||||
;getspq(mode) - Calculate Bits Per Pixel
|
||||
;Args: A = Mode
|
||||
;Returns: A = Bits per Pixel
|
||||
; Y = Divisor Shift Count
|
||||
GETSPQ: AND #$01 ;Strip High Bits
|
||||
TAX ;Copy Mode to X
|
||||
LDA GETSTQ,X ;Read BPP from Table
|
||||
LDY GETSYQ,X ;Read Shift Count from Table
|
||||
RTS
|
||||
GETSTQ: .DC 4,8 ;Table: Bits Per Pixel
|
||||
GETSYQ: .DC 1,0 ;Table: Divisor SHift Count
|
||||
|
||||
;getsp1(index) - Get Sprite Register 1 (Mode, Addr MSB)
|
||||
;Args: A = Sprite Index
|
||||
GETSP1: LDY #1 ;Set Offset to Sprite Address MSB
|
||||
.DC $2C ;Skip to GETSPG (Bit Absolute)
|
||||
|
||||
;getsps(index) - Get Sprite Size Register
|
||||
;Args: A = Sprite Index
|
||||
GETSPS: LDY #7 ;Set Offset to Sprite Size Register
|
||||
.DC $2C ;Skip to GETSPG (Bit Absolute)
|
||||
|
||||
;getspn(index) - Get Sprite Control Register
|
||||
;Args: A = Sprite Index
|
||||
;Returns: Sprite Control Register Contents
|
||||
GETSPN: LDY #6 ;Set Offset to Sprite Address MSB
|
||||
|
||||
;getspg(index) - Get Sprite Register
|
||||
;Args: A = Sprite Index
|
||||
; Y = Register Offset
|
||||
;Returns: A = Mode (0=4bpp, 1=8bpp)
|
||||
GETSPG: JSR GETSPO ;Get Sprite Attribute Address
|
||||
JMP GETVRG ;Read Vera Register
|
||||
|
||||
;getspx(index) - Get Sprite X-Coordinate
|
||||
;Args: A = Index
|
||||
;Returns: Y,X = X-Coordinate
|
||||
GETSPX: LDY #2 ;Set Offset to X-Coordinate
|
||||
.DC $2C ;Skip to GETSPI (Bit Absolute)
|
||||
|
||||
;getspy(index) - Get Sprite Y-Coordinate
|
||||
;Args: A = Index
|
||||
;Returns: Y,X = X-Coordinate
|
||||
GETSPY: LDY #4 ;Set Offset to Y-Coordinate
|
||||
GETSPI: JSR GETSPO ;Get Sprite Attribute Address
|
||||
JMP GETVRI ;Read Vera Register Pair
|
||||
|
||||
;getspz(index) - Get Sprite Z-Depth
|
||||
;Args: A = Sprite Index
|
||||
;Returns: A = Z-Depth (0-3)
|
||||
GETSPZ: JSR GETSPN ;Get Sprite Control Register
|
||||
AND #$0F ;Clear High Nybble
|
||||
LSR ;Shift Right Two Bits
|
||||
LSR
|
||||
RTS
|
||||
|
||||
;getspk(&spregs) - Get Sprite Control Registers`
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Address of Destination Array
|
||||
GETSPK: JSR SETDST ;Set Destination Address
|
||||
JSR SETSCR ;Set Vera
|
||||
JMP GETMEA ;and Read from Vera
|
||||
|
||||
;setscr() - Set Vera Address to Sprite Control Registers
|
||||
SETSCR: LDY #$40 ;Set Page to Sprite Control Registers
|
||||
LDX #$00 ;Set Offset to 0
|
||||
JSR REGADR ;Set Vera Address to Register
|
||||
LDA #2 ;Set Size to 2 Bytes
|
||||
RTS
|
||||
|
||||
;setspk(&spregs) - Get Sprite Control Registers`
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Address of Destination Array
|
||||
SETSPK: JSR SETSRC ;Set Destination Address
|
||||
JSR SETSCR ;Set Vera
|
||||
JMP SETMET ;and Write to Vera
|
||||
|
||||
;getspr(index,&sprite) - Get Sprite Attributes
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Address of Destination Array
|
||||
GETSPR: JSR SETDST ;Set Destination Address
|
||||
JSR SETSP0 ;Set Sprite Attributes Address
|
||||
JMP GETMEA ;and Read from Vera
|
||||
|
||||
;getspo(index,offset) - Get Sprite Attribute Address
|
||||
;Args: A = Sprite Index
|
||||
; Y = Attribute Offset
|
||||
;Destroys: TEMP3
|
||||
;Returns: A,X = Address LSB
|
||||
; Y = Address MSB
|
||||
GETSP0: LDY #0 ;Set Attribute Offset to 0
|
||||
GETSPO: STA TEMP3 ;Set LSB to Index
|
||||
TYA ;Copy Offset to Accumulator
|
||||
AND #$07 ;Modulo 8
|
||||
PHA ;and Save It
|
||||
LDA #0 ;Set MSB to 0
|
||||
ASL TEMP3 ;Multiply by 8
|
||||
ROL
|
||||
ASL TEMP3
|
||||
ROL
|
||||
ASL TEMP3
|
||||
ROL
|
||||
ORA #$50 ;Add to Register Page
|
||||
TAY ;Return MSB in Y
|
||||
PLA ;Restore Offset
|
||||
ORA TEMP3 ;Add to LSB
|
||||
TAX ;and Return in X
|
||||
RTS
|
||||
|
||||
;setspa(index) - Set Vera Address to Sprite Address
|
||||
;Args: Y,X = Sprite Address
|
||||
;Affects: A,X,Y
|
||||
SETSPA: JSR GETSCA ;Convert Sprite Address to Vera Address
|
||||
JMP SETADI ;Set Vera Address with Auto-Increment
|
||||
|
||||
;setspb() - Set Sprite Bits Per Pixel
|
||||
;Args: A = Sprite Index
|
||||
; Y = Bits Per Pixel
|
||||
;Affects: A,X,Y
|
||||
SETSPB: STY TEMP0 ;Save Bits Per Pixel
|
||||
JSR GETSP1 ;Read Sprite Register #1
|
||||
ASL ;Shift Out Bit 7
|
||||
LSR TEMP0 ;Shift BPP to Carry
|
||||
ROR ;then into Bit 7
|
||||
JMP SETBYN ;and Write to Register
|
||||
|
||||
;setspd(index,addr) - Set Sprite Address Register
|
||||
;Args: A = Index
|
||||
; Y,X = Address Register Value
|
||||
SETSPD: STA TEMP0 ;Save Sprite Index
|
||||
SETSTD: TYA ;Copy MSB to Accumulator
|
||||
AND #$0F ;Strip High Nybble
|
||||
TAY ;and Copy Back to Y
|
||||
JSR SAVRXY ;Copy Value to TEMP1,TEMP2
|
||||
LDA TEMP0 ;Restore Sprite Index
|
||||
JSR GETSP1 ;Read MSB Register
|
||||
AND #$F0 ;Strip Low Nybble
|
||||
ORA TEMP2 ;Combine with MSB
|
||||
STA TEMP2 ;and Save for Write
|
||||
LDA TEMP0 ;Restore Sprite Index
|
||||
JSR GETSP0 ;Get Sprite Attribute Address
|
||||
JMP SETREI ;Write TEMP1,TEMP2 to Attribute
|
||||
|
||||
;setspm(index) - Set Sprite Collision Mask
|
||||
;Args: A = Sprite Index
|
||||
; Y = Collision Mask
|
||||
SETSPM: PHA ;Save Sprite Depth
|
||||
LDX #$0F ;Set Bit Mask
|
||||
TYA ;Copy Mask to Accumulator
|
||||
ASL ;Shift Left Two Byte
|
||||
ASL
|
||||
JMP SETSP2 ;Then Two More and Write
|
||||
|
||||
;setspz(index,depth) - Set Sprite Z-Depth
|
||||
;Args: A = Sprite Index
|
||||
; Y = Z-Depth (0-3)
|
||||
SETSPZ: PHA ;Save Sprite Depth
|
||||
LDX #$F3 ;Set Bit Mask
|
||||
TYA ;Copy Z-Depth to Accumulator
|
||||
AND #$03 ;Isolate Bits 0 and 1
|
||||
SETSP2: ASL ;Move to Bits 2 and 3
|
||||
ASL
|
||||
STX TEMP1 ;Save Bit Mask
|
||||
JMP SETSP6 ;Set Bits in Control Register
|
||||
|
||||
;getspu(index) - Get Sprite Width, Height, and Mode
|
||||
;Args: A = Sprite Index
|
||||
;Sets: TEMP0 = Sprite Index
|
||||
;Returns: A = Width Specifier
|
||||
; Y = Height Specifier
|
||||
; X = Mode
|
||||
GETSPU: STA TEMP0 ;Save Sprite Index
|
||||
JSR GETSPW ;Get Sprite Width Specifier
|
||||
PHA ;and Save It
|
||||
LDA TEMP0 ;Retrieve Sprite Indes
|
||||
JSR GETSPH ;Get Sprite Height Specifier
|
||||
PHA ;and Save It
|
||||
LDA TEMP0 ;Retrieve Sprite Index
|
||||
JSR GETSPP ;Get Mode
|
||||
TAX ;Return Mode in X
|
||||
.DC $7A ;PLY Height in Y
|
||||
PLA ;and Width in A
|
||||
RTS
|
||||
|
||||
;getspl(index) - Get Sprite Data Size
|
||||
;Args: A = Sprite Index
|
||||
;Sets: TEMP0 = Sprite Index
|
||||
; TEMP1,TEMP2 = Data Size LSB,MSB
|
||||
;Affects: A
|
||||
;Returns: Y,X = Data Size in Bytes
|
||||
GETSPL: JSR GETSPU ;Get Width, Height, Mode and Execute GETSCL
|
||||
|
||||
;getscl(width,height,mode) - Calculate Sprite Data Size
|
||||
;Args: A = Width Specifier
|
||||
; Y = Height Specifier
|
||||
; X = Mode (Bits Per Pixel)
|
||||
;Sets: TEMP1,TEMP2 = Data Size LSB,MSB
|
||||
;Affects: A
|
||||
;Returns: Y,X = Data Size in Bytes
|
||||
GETSCL: ;.DC $FF ;Debug
|
||||
.DC $DA ;PHX Save Mode
|
||||
PHA ;Save Width
|
||||
TYA ;Copy Height to Accumulator
|
||||
JSR GETSCS ;Calculate Height in Pixles
|
||||
STA TEMP1 ;Save as LSB
|
||||
PLA ;Retrieve Width
|
||||
JSR GETSCS ;Get Width Shift Counter in Y
|
||||
LDA #0 ;Set MSB to 0
|
||||
GETSLK: ASL TEMP1 ;Multiply LSB
|
||||
ROL ;and MSB by 2
|
||||
DEY ;Decrement Counter
|
||||
BNE GETSLK ;and Loop if Not Zero
|
||||
.DC $FA ;PLX Retrieve Mode
|
||||
BNE GETSSK ;If 0 (4 Bits Per Pixel)
|
||||
LSR ; Divide MSB
|
||||
ROR TEMP1 ; snd LSB by 2
|
||||
GETSSK: STA TEMP2 ;Save MSB in TEMP2
|
||||
JMP RESRXY ;Return LSB snd MSB in X and Y
|
||||
|
||||
;getscs(size) - Calculate Sprite Size in Pixels
|
||||
;Args: A = Height/Width Specifier
|
||||
;Returns: A = Size in Pixels
|
||||
; Y = Width Multiplier Shift Count
|
||||
; X = Height/Width Specifier
|
||||
GETSCS: AND #$03 ;Strip High Bits
|
||||
TAX ;Copy Specifier to X
|
||||
LDA GETSCT,X ;Load Size in Pixels from Table
|
||||
LDY GETSCY,X ;Load Shift Count from Table
|
||||
RTS
|
||||
GETSCT: .DC 8,16,32,64 ;Table: Size in Pixels
|
||||
GETSCY: .DC 3, 4, 5, 6 ;Table: Shift Multiplier
|
||||
|
||||
;setspv(index) - Set Sprite Vertical Flip
|
||||
;Args: A = Sprite Index
|
||||
; Y = Vertical Flip Flag
|
||||
SETSPV: LDX #$02 ;Set Bit Pattern for Register
|
||||
.DC $2C ;Skip Next Instruction (Bit Absolute)
|
||||
|
||||
;setspf(index) - Set Sprite Horizontal Flip
|
||||
;Args: A = Sprite Index
|
||||
; Y = Horizontal Flip Flag
|
||||
SETSPF: LDX #$01 ;Set Bit Pattern for Register
|
||||
PHA ;Save Sprite Index
|
||||
TXA ;Copy Bit Pattern to Accumulator
|
||||
EOR #$FF ;Convert to Bit Mask
|
||||
STA TEMP1 ;and Save It
|
||||
TYA ;Copy Flag to Accumulator
|
||||
BEQ SETSP6 ;If Not Zero
|
||||
TXA ;Change to %00000001
|
||||
SETSP6: STA TEMP0 ;and Store It
|
||||
PLA ;Retrieve Sprite Index
|
||||
JSR GETSPN ;Get Sprite Control Register
|
||||
SETSP8: AND TEMP1 ;Apply Mask
|
||||
ORA TEMP0 ;Set Bit(s)
|
||||
JMP SETBYN ;and Write Back to Register
|
||||
|
||||
;setspn(index,value) - Set Sprite Attribute Control Register
|
||||
;Args: A = Sprite Index
|
||||
; Y = Value to Write
|
||||
;Returns: A = Mode (0=4bpp, 1=8bpp)
|
||||
SETSPN: STY TEMP0 ;Save Value to Write
|
||||
LDY #6 ;Set Offset to Control Register
|
||||
BNE SETSTG ;and Write Value to Register
|
||||
|
||||
;setspg(index,offset,value) - Set Sprite Attribute Register
|
||||
;Args: A = Sprite Index
|
||||
; Y = Register Offset
|
||||
; X = Value to Write
|
||||
;Returns: A = Mode (0=4bpp, 1=8bpp)
|
||||
SETSPG: STX TEMP0 ;Save Value to Write
|
||||
SETSTG: JSR GETSPO ;Get Attribute Address for Sprite A Register Y
|
||||
JMP SETREH ;Write TEMP0 to Register
|
||||
|
||||
;setspw(index) - Set Sprite Width Specifier
|
||||
;Args: A = Sprite Index
|
||||
; Y = Sprite Width Specifier
|
||||
SETSPW: PHA ;Save Sprite Index
|
||||
LDX #$CF ;Set Bit Mask
|
||||
TYA ;Copy Specifier to Accumulator
|
||||
AND #$03 ;Isolate Bits 0 and 1
|
||||
JMP SETSP4 ;Shift Left Four Bits and Write Masked
|
||||
|
||||
;setsph(index) - Set Sprite Height Specifier
|
||||
;Args: A = Sprite Index
|
||||
; Y = Sprite Height Specifier
|
||||
SETSPH: PHA ;Save Sprite Index
|
||||
LDX #$3F ;Set Bit Mask
|
||||
TYA ;Copy Specifier to Accumulator
|
||||
ASL ;Shift Left Six Bits
|
||||
ASL
|
||||
SETSP4: ASL
|
||||
ASL
|
||||
ASL
|
||||
ASL
|
||||
JMP SETSP7 ;Write Masked to Size Register
|
||||
|
||||
;setspp(index) - Set Sprite Palette Offset
|
||||
;Args: A = Sprite Index
|
||||
; Y = Palette Offset
|
||||
SETSPP: PHA ;Save Sprite Index
|
||||
LDX #$F0 ;Set Bit Mask
|
||||
TYA ;Copy Offset to Accumulator
|
||||
AND #$0F ;Isolate Low Nybble
|
||||
SETSP7: STA TEMP0 ;Save Value
|
||||
STX TEMP1 ;Save Bit Mask
|
||||
PLA ;Retrieve Sprite Index
|
||||
JSR GETSPS ;Get Sprite Size Register
|
||||
JMP SETSP8 ;Apply Mask, Set Bits, and Write
|
||||
|
||||
;setsps(index,value) - Set Sprite Attribute Size Register
|
||||
;Args: A = Sprite Index
|
||||
; Y = Value to Write
|
||||
;Returns: A = Mode (0=4bpp, 1=8bpp)
|
||||
SETSPS: STY TEMP0 ;Save Value to Write
|
||||
LDY #7 ;Set Offset to Size Register
|
||||
BNE SETSTG ;and Write Value to Register
|
||||
|
||||
;setspe() - Enable/Disable Sprites
|
||||
;Args: A = Sprites Enabled Flag
|
||||
; 0 for Disabled, Any Other Value for Enabled
|
||||
;Affects: A,X,Y
|
||||
SETSPE: ORA #0 ;If Accumulator
|
||||
BEQ SETSKE ;is Not Zero
|
||||
LDA ##01 ;Set to %00000001
|
||||
SETSKE: LDY #$FE ;Set Mask to %11111110
|
||||
STY TEMP0
|
||||
LDX #$00 ;Set Offset to Sprite Control
|
||||
LDY #$40 ;Set Page to Sprite Registers
|
||||
JMP SETVRB ;Get Register Bit
|
||||
|
||||
;setspo(index,offset) - Set Sprite Attributes Address
|
||||
;Args: A = Sprite Index
|
||||
; Y = Attribute Offset
|
||||
SETSP0: LDY #0 ;Set Offset to 0
|
||||
SETSPO: JSR GETSPO ;Get Sprite Attributes Address
|
||||
JSR REGADR ;Set as Vera Register Address
|
||||
LDA #8 ;Set Size to 8 Bytes
|
||||
RTS
|
||||
|
||||
;setspr(index,&sprite) - Set Sprite Attributes
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Address of Source Structure
|
||||
;Destroys: TEMP0
|
||||
;Returns: A,Y = Number of Bytes Written
|
||||
; X = Current Data Port
|
||||
SETSPR: JSR SETSRC ;Set Destination Address
|
||||
JSR SETSP0 ;Set Sprite Attributes Address
|
||||
JMP SETMET ;and Write from Vera
|
||||
|
||||
;setspy(index,coord) - Set Sprite Y-Coordinate
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = Y-Coordinate
|
||||
SETSPY: JSR SAVRXY ;Store Value in TEMP1,TEMP2
|
||||
LDY #4 ;Set Register Offset to Y-Coordinate
|
||||
BNE SETSPI ;Write TEMP1,TEMP2 to Registers
|
||||
|
||||
;setspx(index,coord) - Set Sprite X-Coordinate
|
||||
;Args: A = Sprite Index
|
||||
; Y,X = X-Coordinate
|
||||
SETSPX: JSR SAVRXY ;Store Value in TEMP1,TEMP2
|
||||
LDY #2 ;Set Register Offset to X-Coordinate
|
||||
|
||||
;setspi(index) - Write to Sprite Attribute Register Pair
|
||||
;Args: A = Sprite Index
|
||||
; Y = Attribute Offset
|
||||
;Uses: TEMP1.TEMP2 = Integer to Write
|
||||
SETSPI: JSR GETSPO ;Get Sprite Attribute Address
|
||||
JMP SETREI ;Write TEMP1,TEMP2 to Attribute
|
||||
|
272
x16/include/veraspr.h02
Normal file
272
x16/include/veraspr.h02
Normal file
@ -0,0 +1,272 @@
|
||||
/**********************************************
|
||||
* veraspr.h02 - Sprite Manipulation Routines *
|
||||
* for Commander X16 VERA Chip *
|
||||
* Requires: x16.h02 *
|
||||
* stddef.h02 *
|
||||
* veramem.h02 *
|
||||
**********************************************/
|
||||
|
||||
#define MAXSPR 128 //Maximum Sprite Index;
|
||||
|
||||
/* Sprite Attributes */
|
||||
struct sprite {
|
||||
int addr; //Data Address
|
||||
int horz; //Horizontal Coordinate
|
||||
int vert; //Vertical Coordinate
|
||||
char ctrl; //Control Register
|
||||
char size; //Size Register
|
||||
};
|
||||
|
||||
/* Sprite Control Registers */
|
||||
struct spregs {
|
||||
char ctrl; //Control Register
|
||||
char clsn; //Collision Mask
|
||||
};
|
||||
|
||||
/* Add to Sprite Address Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* int w - Integer to Add */
|
||||
char addspd();
|
||||
|
||||
/* Clear Sprite Attributes *
|
||||
* Args: char n - Sprite Index */
|
||||
char clrspr();
|
||||
|
||||
/* Get Vera Address from Sprite Address *
|
||||
* Args: int d - Sprite Address *
|
||||
* Returns: char bank - Address Bits 16-19 *
|
||||
* int addr - Address Bits 0-15 */
|
||||
char getsca();
|
||||
|
||||
/* Calculate Sprite Data Size *
|
||||
* Args: char w - Width Specifier *
|
||||
* char h - Height Specifier *
|
||||
* char m - Mode (Bits per Pixel) *
|
||||
* Returns: int s - Data Size in Bytes */
|
||||
char getscl();
|
||||
|
||||
/* Calculate Sprite Size in Pixels *
|
||||
* Args: char s - Height/Width Specifier *
|
||||
* Returns: char p - Height/Width in Pixels *
|
||||
* char m - Multiplier Shift Count */
|
||||
char getscs();
|
||||
|
||||
/* Get Sprite Data Address *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char bank - Address Bits 16-19 *
|
||||
* int addr - Address Bits 0-15 */
|
||||
char getspa();
|
||||
|
||||
/* Get Sprite Bits per Pixel *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char m - Sprite Mode *
|
||||
* 0=4bpp, 1=8bpp */
|
||||
char getspb();
|
||||
|
||||
/* Read Sprite Collision Status *
|
||||
* Returns: char c - Collision Status */
|
||||
char getspc();
|
||||
|
||||
/* Get Sprite Address Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: int w - Address Register Contents */
|
||||
char getspd();
|
||||
|
||||
/* Read Sprite Enabled Status *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char e - Enabled (TRUE/FALSE) */
|
||||
char getspe();
|
||||
|
||||
/* Get Sprite Horizontal Flip Flag *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char f - Flipped (TRUE/FALSE) */
|
||||
char getspf();
|
||||
|
||||
/* Get Sprite Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* char o - Register Offset *
|
||||
* Returns: char r - Register Contents */
|
||||
char getspg();
|
||||
|
||||
/* Get Sprite Height Specifier *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char h - Height Specifier */
|
||||
char getsph();
|
||||
|
||||
/* Read Sprite Attribute Pair *
|
||||
* Args: char n - Sprite Index *
|
||||
* char 0 - Attribute Offset *
|
||||
* Returns: int i - Attribute LSB,MSB */
|
||||
char getspi();
|
||||
|
||||
/* Get Sprite Data Size *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: int s - Data Size in Bytes */
|
||||
char getspl();
|
||||
|
||||
/* Get Sprite Collision Mask *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char m - Collision Mask */
|
||||
char getspm();
|
||||
|
||||
/* Get Sprite Control Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char r - Register Contents */
|
||||
char getspn();
|
||||
|
||||
/* Get Sprite Attribute Address *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: int d - Address */
|
||||
char getspo();
|
||||
|
||||
/* Get Sprite Palette Offset *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char p - Palette Offset */
|
||||
char getspp();
|
||||
|
||||
/* Get Sprite Attributes *
|
||||
* Args: char n - Sprite Index *
|
||||
* int d - Struct Address *
|
||||
* Returns: char b - Number of Bytes */
|
||||
char getspr();
|
||||
|
||||
/* Get Sprite Size Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char r - Register Contents */
|
||||
char getsps();
|
||||
|
||||
/* Test Sprite Collision Status *
|
||||
* Args: char b - Collision Bitmask *
|
||||
* Returns: char c - Collision Status */
|
||||
char getspt();
|
||||
|
||||
/* Get Sprite Width, Height, and Mode *
|
||||
* Args: char n = Sprite Index *
|
||||
* Returns: char w - Width Specifier *
|
||||
* char h - Height Specifier *
|
||||
* char m - Mode (Bits per Pixel) */
|
||||
char getspu();
|
||||
|
||||
/* Get Sprite Vertical Flip Flag *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char f - Flipped (TRUE/FALSE) */
|
||||
char getspv();
|
||||
|
||||
/* Get Sprite Width Specifier *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char w - Width Specifier */
|
||||
char getspw();
|
||||
|
||||
/* Get Sprite X-Coordinate *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: int i - X-Coordinate */
|
||||
char getspx();
|
||||
|
||||
/* Get Sprite Y-Coordinate *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: int i - Y-Coordinate */
|
||||
char getspy();
|
||||
|
||||
/* Get Sprite Z-Depth *
|
||||
* Args: char n - Sprite Index *
|
||||
* Returns: char z - Z-Depth */
|
||||
char getspz();
|
||||
|
||||
/* Set Sprite Bits per Pixel *
|
||||
* Args: char n - Sprite Index *
|
||||
* char m - Sprite Mode *
|
||||
* 0=4bpp, 1=8bpp */
|
||||
char setspb();
|
||||
|
||||
/* Set Sprite Address Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* int w - Address Value */
|
||||
char setspd();
|
||||
|
||||
/* Set Sprite Enabled Status *
|
||||
* Args: char e - Enabled (TRUE/FALSE) */
|
||||
char setspe();
|
||||
|
||||
/* Set Sprite Horizontal Flip Flag *
|
||||
* Args: char n - Sprite Index *
|
||||
* char f - Flipped (TRUE/FALSE) */
|
||||
char setspf();
|
||||
|
||||
/* Set Sprite Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* char o - Register Offset *
|
||||
* char b - Value to Write */
|
||||
char setspg();
|
||||
|
||||
/* Set Sprite Height Specifier *
|
||||
* Args: char n - Sprite Index *
|
||||
* char w - Height Specifier */
|
||||
char setsph();
|
||||
|
||||
/* Write Sprite Attribute Pair *
|
||||
* Args: char n - Sprite Index *
|
||||
* char 0 - Attribute Offset *
|
||||
* Requires: setrxy(integer) */
|
||||
char setspi();
|
||||
|
||||
/* Set Sprite Collision Mask *
|
||||
* Args: char n - Sprite Index *
|
||||
* char m - Collision Mask */
|
||||
char setspm();
|
||||
|
||||
/* Set Sprite Control Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* char r - Register Contents */
|
||||
char setspn();
|
||||
|
||||
/* Set Sprite Attribute Address *
|
||||
* Args: char n - Sprite Index *
|
||||
* char o - Register Offset */
|
||||
char setspo();
|
||||
|
||||
/* Set Sprite Palette Offset *
|
||||
* Args: char n - Sprite Index *
|
||||
* char p - Palette Offset */
|
||||
char setspp();
|
||||
|
||||
/* Set Sprite Attributes *
|
||||
* Args: char n - Sprite Index *
|
||||
* int d - Struct Address *
|
||||
* Returns: char b - Number of Bytes */
|
||||
char setspr();
|
||||
|
||||
/* Aet Sprite Size Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* char r - Register Contents */
|
||||
char setsps();
|
||||
|
||||
/* Set Sprite Vertical Flip Flag *
|
||||
* Args: char n - Sprite Index *
|
||||
* char f - Flipped (TRUE/FALSE) */
|
||||
char setspv();
|
||||
|
||||
/* Set Sprite Width Specifier *
|
||||
* Args: char n - Sprite Index *
|
||||
* char w - Width Specifier */
|
||||
char setspw();
|
||||
|
||||
/* Set Sprite X-Coordinate *
|
||||
* Args: char n - Sprite Index *
|
||||
* int i - X-Coordinate */
|
||||
char setspx();
|
||||
|
||||
/* Set Sprite Y-Coordinate *
|
||||
* Args: char n - Sprite Index *
|
||||
* int i - Y-Coordinate */
|
||||
char setspy();
|
||||
|
||||
/* Set Sprite Z-Depth *
|
||||
* Args: char n - Sprite Index *
|
||||
* char z - Z-Depth */
|
||||
char setspz();
|
||||
|
||||
/* Subtract from Sprite Address Register *
|
||||
* Args: char n - Sprite Index *
|
||||
* int w - Integer to Subtract */
|
||||
char subspd();
|
||||
|
23
x16/include/veratil.a02
Normal file
23
x16/include/veratil.a02
Normal file
@ -0,0 +1,23 @@
|
||||
; Vera Tile Manipulation Assembly Language Routines for C02
|
||||
; Requires External Routines
|
||||
; and External Variables TEMP1
|
||||
|
||||
;gettda() - Get Tile Data Address
|
||||
;Args: A = Layer (0/1)
|
||||
;
|
||||
;Destroys: TEMP1,TEMP2
|
||||
;Returns: A = Tile Base Bank
|
||||
; Y,X = Tile Base Address
|
||||
GETTBA: JSR SET
|
||||
|
||||
;gettdo() - Get Tile Data Offset
|
||||
;Args: A = Layer (0/1)
|
||||
; Y = Tile Offset
|
||||
;Destroys: TEMP1,TEMP2
|
||||
;Returns: A = Tile Base Bank
|
||||
; Y,X = Tile Base Address
|
||||
GETTBA: STA TEMP0 ;Save Layer Number
|
||||
STY TEMP1 ;Set LSB to Offset
|
||||
JSR GETTSZ ;Get Tile Size
|
||||
|
||||
|
9
x16/include/veratil.h02
Normal file
9
x16/include/veratil.h02
Normal file
@ -0,0 +1,9 @@
|
||||
/*********************************************
|
||||
* veratil.h02 - Tile Manipulation Functions *
|
||||
* for Commander X16 VERA Chip *
|
||||
* Requires: x16.h02 *
|
||||
* stddef.h02 *
|
||||
* veramem.h02 *
|
||||
* veralyr.h02 *
|
||||
*********************************************/
|
||||
|
67
x16/include/veratxt.a02
Normal file
67
x16/include/veratxt.a02
Normal file
@ -0,0 +1,67 @@
|
||||
; Vera Layer Control Assembly Language Routines for C02
|
||||
; Requires External Routines GETMEA, GETMBX, GETTBS,
|
||||
; and External Variables TEMP0,TEMP1,TEMP2
|
||||
|
||||
;getvca(layer, index) - Get Vera Character Address
|
||||
;Args: A = Layer (0/1)
|
||||
; Y = Character Index
|
||||
;Sets: TEMP0 = Bank
|
||||
; TEMP1 = Address LSB
|
||||
; TEMP2 = Address MSB
|
||||
;Returns: A = Bank
|
||||
; Y = Address LSB
|
||||
; X = Address MSB
|
||||
GETVCA: PHA ;Save Layer Number
|
||||
STY TEMP1 ;Set Offset LSB to Index
|
||||
LDA #0 ;Set Offset MSB to Zero
|
||||
ASL TEMP1 ;Multiple Offset by 2
|
||||
ROL
|
||||
STA TEMP2 ;and Store MSB
|
||||
PLA ;Restore Layer Number
|
||||
JSR GETTBS ;Get Tile Base
|
||||
TXA ;Add Tile Base LSB
|
||||
CLC
|
||||
ADC TEMP1 ;to Offset LSB
|
||||
STA TEMP1
|
||||
TYA ;Add Tile Base MSB
|
||||
ADC TEMP2 ;to Offset MSB
|
||||
STA TEMP2
|
||||
LDA #0 ;Set Bank
|
||||
ADC #0 ;to Carry
|
||||
STA TEMP0
|
||||
LDX #2 ;Set Count to 2
|
||||
JMP ASLADR ;and Shift Address Left
|
||||
|
||||
;getvcd(layer, index) - Read Vera Character Data to Array
|
||||
;Args: A = Layer (0/1)
|
||||
; Y = Character Index
|
||||
;Uses: DSTLO,DSTHI = Address of Array
|
||||
;Destroys: TEMP0,TEMP1,TEMP2
|
||||
;Returns: A = Number of Bytes Read
|
||||
GETVCD: JSR SETVAC ;Set Vera Address to Character Address
|
||||
LDA #8 ;Set Byte Count to 8
|
||||
JMP GETMEA ;and Read Bytes into Array
|
||||
|
||||
;setvac(layer, index) - Set Vera Address to Character Address
|
||||
;Args: A = Layer (0/1)
|
||||
; Y = Character Index
|
||||
;Sets: TEMP0 = Bank
|
||||
; TEMP1 = Address LSB
|
||||
; TEMP2 = Address MSB
|
||||
;Returns: A = Bank + Auto-Increment
|
||||
; Y = Address LSB
|
||||
; X = Address MSB
|
||||
SETVAC: JSR GETVCA
|
||||
ORA #$10 ;Set Auto-Increment to 1
|
||||
JMP SETADR ;and Set Vera Address
|
||||
|
||||
;setvcd(layer, index) - Write Vera Character Data from Array
|
||||
;Args: A = Layer (0/1)
|
||||
; Y = Character Index
|
||||
;Uses: SRCLO,SRCHI = Address of Array
|
||||
;Destroys: TEMP0,TEMP1,TEMP2
|
||||
;Returns: A = Number of Bytes Read
|
||||
GETVCD: JSR SETVAC ;Set Vera Address to Character Address
|
||||
LDA #8 ;Set Byte Count to 8
|
||||
JMP SETMEA ;and Read Bytes into Array
|
||||
|
16
x16/include/veratxt.h02
Normal file
16
x16/include/veratxt.h02
Normal file
@ -0,0 +1,16 @@
|
||||
/*****************************************
|
||||
* veratxt.h02 - Text Mode Functions for *
|
||||
* Commander X16 VERA Chip *
|
||||
* Requires: x16.h02 *
|
||||
* stddef.h02 *
|
||||
* veramem.h02 *
|
||||
* veralyr.h02 *
|
||||
*****************************************/
|
||||
|
||||
;getvcd(lyr) - Get Vera Character Data
|
||||
;Args: A = Layer (0/1)
|
||||
; Y = Bitmap Palette Offset
|
||||
;Affects: Y
|
||||
;Sets: TEMP3 = Register Offset
|
||||
;Returns: A = Control Register Contents
|
||||
; X = Current Data Port
|
75
x16/sprattrs.c02
Normal file
75
x16/sprattrs.c02
Normal file
@ -0,0 +1,75 @@
|
||||
/************************************
|
||||
* TESTVERA - Test All Vera Modules *
|
||||
************************************/
|
||||
|
||||
//Specify System Header using -H option
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <intlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
#include <string.h02>
|
||||
#include <memory.h02>
|
||||
#include <nybble.h02>
|
||||
#include "include/veramem.h02" //Vera Memory Access
|
||||
#include "include/veraspr.h02" //Vera Sprites
|
||||
|
||||
char i; //Index Variable
|
||||
|
||||
char aa,xx,yy; //Functions Parameters/Variables
|
||||
char ii,oo,ss[128];
|
||||
int yx;
|
||||
|
||||
void prthdr() {
|
||||
putln("SPR ADDRESS MODE XPOS YPOS MASK Z VFLIP HFLIP HGHT WDTH POF");
|
||||
}
|
||||
|
||||
void prtpos(yx) {
|
||||
setdst(&ss); aa = itoa(yx);
|
||||
for (ii=strlen(&ss); ii<4; ii++) putspc();
|
||||
puts(&ss); putspc();
|
||||
}
|
||||
|
||||
void prtflg(aa) {
|
||||
if (aa) puts("TRUE ");
|
||||
else puts("FALSE ");
|
||||
}
|
||||
|
||||
void prtsiz() {
|
||||
select(A) {
|
||||
case 0: puts(" 8");
|
||||
case 1: puts("16");
|
||||
case 2: puts("32");
|
||||
case 3: puts("64");
|
||||
default: puts("??");
|
||||
}
|
||||
puts("PX ");
|
||||
}
|
||||
|
||||
void prtofs(aa) {
|
||||
if (aa) {aa<<;aa<<;aa<<;aa<<;}
|
||||
printf(aa,"%r ");
|
||||
}
|
||||
|
||||
main:
|
||||
newlin();
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
if (!i&31) prthdr();
|
||||
printf(i,"%r ");
|
||||
printf(setdst(getspa(i))," $%g%w ");
|
||||
if (getspb(i)) puts("8BPP "); else puts("4BPP ");
|
||||
prtpos(getspx(i));
|
||||
prtpos(getspy(i));
|
||||
putmsk(getspm(i),$0F); putspc();
|
||||
putdec(getspz(i)); putspc();
|
||||
prtflg(getspf(i));
|
||||
prtflg(getspv(i));
|
||||
prtsiz(getsph(i));
|
||||
prtsiz(getspw(i));
|
||||
prtofs(getspp(i));
|
||||
newlin();
|
||||
if (i&31==31 and anykey() == #ESCKEY) goto exit;
|
||||
}
|
||||
newlin();
|
||||
goto exit;
|
||||
|
77
x16/sprdemo.c02
Normal file
77
x16/sprdemo.c02
Normal file
@ -0,0 +1,77 @@
|
||||
/*********************************
|
||||
* SPRDEMO - Vera Sprite Demo *
|
||||
*********************************/
|
||||
|
||||
//Specify System Header using -H option
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <intlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
#include <memory.h02>
|
||||
#include <nybble.h02>
|
||||
#include "include/veramem.h02" //Vera Memory Access
|
||||
#include "include/veraspr.h02" //Vera Sprites
|
||||
|
||||
char spindx; //Sprite Index
|
||||
int spaddr; //Sprite Address
|
||||
char spxlo,spxhi; //Sprite X-Coordinate
|
||||
char spylo,spyhi; //Sprite Y-Coordinate
|
||||
|
||||
struct spregs spctrl; //Sprite Control Registers
|
||||
struct sprite spattr; //Sprite Attributes
|
||||
|
||||
const char happy =
|
||||
{0,0,7,7,7,7,0,0,
|
||||
0,7,7,7,7,7,7,0,
|
||||
7,7,0,7,7,0,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,0,7,7,7,7,0,7,
|
||||
0,7,0,0,0,0,7,7,
|
||||
0,0,7,7,7,7,0,0};
|
||||
|
||||
|
||||
/*Print Sprite Control Registers*/
|
||||
void prtspk() {
|
||||
printf(spctrl.ctrl, "CTRL=%b, ");
|
||||
printf(spctrl.clsn, "CLSN=%b%n");
|
||||
}
|
||||
|
||||
/*Print Sprite Attributes */
|
||||
void prtspr() {
|
||||
printf(setdst(spattr.addr),"ADR=$%w, ");
|
||||
printf(setdst(spattr.horz),"HRZ=%i, ");
|
||||
printf(setdst(spattr.vert),"VRT=%i, ");
|
||||
printf(spattr.ctrl,"CTL=$%h, ");
|
||||
printf(spattr.size,"SIZ=$%h%n");
|
||||
}
|
||||
|
||||
main:
|
||||
|
||||
spxlo=0; spxhi=0; spylo=0; spyhi=0;
|
||||
for (spindx=0; spindx<#MAXSPR; spindx++) {
|
||||
spaddr=&$800;
|
||||
setspa(spaddr); //Set Vera Address to Sprite Address
|
||||
setmem(@happy,&happy); //Write Sprite Data to Vera
|
||||
setspd(spindx,spaddr); //Set Sprite Address
|
||||
setspb(spindx,1); //Set Mode to 8 Bits per Pixel
|
||||
setspx(spindx,spxhi,spxlo); //Set Sprite X-Coordinate
|
||||
setspy(spindx,spyhi,spylo); //Set Sprite Y-Coordinate
|
||||
setspz(spindx,3); //Display in Front of Layer 1
|
||||
setspe(#TRUE); //Enable Sprites
|
||||
|
||||
spxlo=spxlo+16; if (!spxlo) spylo=spylo+16;
|
||||
|
||||
}
|
||||
|
||||
getspk(&spctrl); //Read Sprite Control Registers
|
||||
puts("SPRITES: ");
|
||||
prtspk(); //Print Sprite Control Registers
|
||||
|
||||
getspr(spindx,&spattr); //Read Sprite Attributes
|
||||
printf(spindx,"SPRITE %d ");
|
||||
prtspr(); //Print Sprite Attributes
|
||||
|
||||
goto exit;
|
||||
|
42
x16/sprsizes.c02
Normal file
42
x16/sprsizes.c02
Normal file
@ -0,0 +1,42 @@
|
||||
/*********************************
|
||||
* SPRSIZES - Print Sprite Sizes *
|
||||
*********************************/
|
||||
|
||||
//Specify System Header using -H option
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <intlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
#include <memory.h02>
|
||||
#include <nybble.h02>
|
||||
#include "include/veramem.h02" //Vera Memory Access
|
||||
#include "include/veraspr.h02" //Vera Sprites
|
||||
|
||||
char aa,yy,xx;
|
||||
char height, width, mode;
|
||||
int size;
|
||||
|
||||
void padint(aa,yy,xx) {
|
||||
if (xx&96) putc(aa);
|
||||
if (yy < 4) putc(aa);
|
||||
}
|
||||
|
||||
main:
|
||||
newlin();
|
||||
|
||||
for (mode=0; mode<2; mode++) {
|
||||
printf(getspq(mode),"%n\18%dBPP");
|
||||
for (width=0;width<4; width++) printf(getspj(width)," %r");
|
||||
for (height=0; height<4; height++) {
|
||||
printf(getspj(height),"%n\$12 %r\$92"); putchr(146); putspc();
|
||||
for (width=0; width<4; width++) {
|
||||
size = getspk(width, height, mode);
|
||||
padint(' ',size); putint(size); putspc();
|
||||
}
|
||||
}
|
||||
newlin();
|
||||
}
|
||||
|
||||
goto exit;
|
||||
|
117
x16/testspr.c02
Normal file
117
x16/testspr.c02
Normal file
@ -0,0 +1,117 @@
|
||||
/************************************
|
||||
* TESTVERA - Test All Vera Modules *
|
||||
************************************/
|
||||
|
||||
//Specify System Header using -H option
|
||||
#include <stddef.h02>
|
||||
#include <stdlib.h02>
|
||||
#include <intlib.h02>
|
||||
#include <stdio.h02>
|
||||
#include <stdiox.h02>
|
||||
#include <memory.h02>
|
||||
#include <nybble.h02>
|
||||
#include "include/veramem.h02" //Vera Memory Access
|
||||
#include "include/veraspr.h02" //Vera Sprites
|
||||
|
||||
const char abcdef = {1,2,3,4,5,6};
|
||||
char buffer[255]; //Buffer for getmem
|
||||
|
||||
char d,e,f,i,j,k; //Index Variables
|
||||
char b,h,l,m,n,p,w; //Temporary Variables
|
||||
char bank,msb,lsb; //Vera Memory Address
|
||||
int addr; //16-bit Address
|
||||
int bytes,size; //Integer Size Values
|
||||
int height,width; //Integer Height and Width Value
|
||||
|
||||
char spenbl; //Sprite Enabled
|
||||
char spmode; //Sprite Mode (Bits Per Pixel)
|
||||
int spaddr; //Sprite Attributes/Data Address
|
||||
int spsize; //Sprite Data Size
|
||||
struct sprite spattr; //Sprite Attributes (Read)
|
||||
struct sprite spattw; //Sprite Attributes (Write)
|
||||
|
||||
char aa,xx,yy; //Functions Parameters/Variables
|
||||
|
||||
void failed() {
|
||||
putln(" FAILED");
|
||||
}
|
||||
|
||||
void passed() {
|
||||
putln(" PASSED");
|
||||
//newlin();
|
||||
}
|
||||
|
||||
void padint(aa,yy,xx) {
|
||||
if (xx&96) putc(aa);
|
||||
if (yy < 4) putc(aa);
|
||||
}
|
||||
|
||||
void prtadr(aa,yy,xx) {
|
||||
putc('$'); prhex(aa); prbyte(yy); prbyte(xx);
|
||||
}
|
||||
|
||||
void prtflg(aa,yy,xx) {
|
||||
if (aa) setdst("TRUE"); else setdst("FALSE");
|
||||
printf(aa,yy,xx);
|
||||
}
|
||||
|
||||
void prtreg(aa,yy,xx) {
|
||||
printf(aa,"(%d,"); printf(yy,"%d,"); printf(xx,"%d) ");
|
||||
}
|
||||
|
||||
/*Print Sprite Attributes */
|
||||
void prtspr() {
|
||||
printf(setdst(spattr.addr),"ADR=$%w, ");
|
||||
printf(setdst(spattr.horz),"HRZ=%i, ");
|
||||
printf(setdst(spattr.vert),"VRT=%i, ");
|
||||
printf(spattr.ctrl,"CTL=$%h, ");
|
||||
printf(spattr.size,"SIZ=$%h%n");
|
||||
}
|
||||
|
||||
void xerror() {
|
||||
putln(" ERROR ENCOUNTERED");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
main:
|
||||
newlin();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
printf("TESTING GETSPL() AND GETSPU()");
|
||||
n = 0; //Sprite Index
|
||||
h = 8; height = &8; //Sprite Height in Pixels
|
||||
for (i=0; i<4; i++) {
|
||||
setsph(n,i); //Set Sprite Height Specifier
|
||||
w = 8; //Sprite Width in Pixels
|
||||
size = height; size<<; size<<; //Set Size to Height*4
|
||||
for (j=0; j<4; j++) {
|
||||
setspw(n,j); //Set Sprite Width Specifier
|
||||
p = 4; //Bits Per Pixeg
|
||||
bytes = size;
|
||||
printf(h,"%nHEIGHT=%d "); if (!i) putspc();
|
||||
printf(w,"WIDTH=%d "); if (!j) putspc();
|
||||
for (k=0; k<2; k++) {
|
||||
setspp(n,k);
|
||||
printf(p,"%dBPP ");
|
||||
d,e,f = getspu(n); prtreg();
|
||||
if (d<>j or e<>i or f<>k) xerror();
|
||||
spsize = getspl(n); //Get Sprite Data Size
|
||||
setdst(spsize); printf("SIZE=%i "); padint(' ',spsize);
|
||||
setdst(bytes); printf("[%i] "); padint(' ',bytes);
|
||||
if (<spsize <> <bytes or >spsize <> >bytes) xerror();
|
||||
p<<; bytes<<; //Multiply BPP, Size by 2
|
||||
}
|
||||
w<<; size<<; //Multiply Width, Size by 2
|
||||
}
|
||||
h<<; height<<; //Multiply Height by 2
|
||||
n++; //Increment Sprite Index
|
||||
newlin();
|
||||
}
|
||||
passed();
|
||||
|
||||
|
||||
newlin();
|
||||
|
||||
goto exit;
|
||||
|
416
x16/testvera.c02
416
x16/testvera.c02
@ -14,24 +14,37 @@
|
||||
#include "include/veradsp.h02" //Vera Display Controller
|
||||
#include "include/veraclr.h02" //Vera Color Palette
|
||||
#include "include/veralyr.h02" //Vera Layer Control
|
||||
#include "include/veraspr.h02" //Vera Sprites
|
||||
#include "include/vera.h02"
|
||||
|
||||
const char abcdef = {1,2,3,4,5,6};
|
||||
char buffer[255]; //Buffer for getmem
|
||||
|
||||
char d,e,f,i,j,k; //Index Variables
|
||||
char b,h,l,m,n,p,w; //Temporary Variables
|
||||
char bank,msb,lsb; //Vera Memory Address
|
||||
int addr,bytes,size; //16-bit Address and Sizes
|
||||
int height,width; //16-bit Height and Width Value
|
||||
|
||||
char hscale,vscale; //Video Scaling
|
||||
char hrzvrt[5]; //Horizontal and Vertical Register Contents
|
||||
char index; //Color Palette Index
|
||||
char mode,mono,field; //Video Output Mode, Monochrome Flag, Current Field
|
||||
char red,green,blue; //Color Components
|
||||
char enabld; //Layer Enabled
|
||||
char i,j,k,l;
|
||||
|
||||
int color,colour;
|
||||
int hstart,hstop; //Horizontal Start and Stop
|
||||
int vstart,vstop; //Vertical Start and Stop
|
||||
int irqlin; //IRQ Line#
|
||||
|
||||
char spenbl; //Sprite Enabled
|
||||
char spmode; //Sprite Mode (Bits Per Pixel)
|
||||
int spaddr; //Sprite Attributes Address
|
||||
int spsize; //Sprite Data Size
|
||||
struct sprite spattr; //Sprite Attributes (Read)
|
||||
struct sprite spattw; //Sprite Attributes (Write)
|
||||
|
||||
/* Layer 0/1 */
|
||||
|
||||
const char msizel = {32,64,128,0};
|
||||
@ -41,7 +54,6 @@ const char tsizel = {8,16};
|
||||
char layer; //Layer Number
|
||||
char layer0[9]; //Layer 0 Register Contents
|
||||
char layer1[9]; //Layer 1 Register Contents
|
||||
char height,width; //Map/Tile Height, Width Specifiers
|
||||
char tsize; //Tile Size in Pixels
|
||||
int msize; //Map Size in Pixeks
|
||||
int mbase0,mbase1; //Map Base, Layer 0 and 1
|
||||
@ -50,7 +62,8 @@ int mbaddr,tbaddr; //Map and Tile Base Address
|
||||
int hscrl0,hscrl1; //Horizontal Scroll, Layer 0 and 1
|
||||
int vscrl0,vscrl1; //Vertical Scroll, Layer 0 and 1
|
||||
|
||||
char aa,xx,yy;
|
||||
|
||||
char aa,xx,yy; //Functions Parameters/Variables
|
||||
|
||||
void failed() {
|
||||
putln(" FAILED");
|
||||
@ -61,13 +74,43 @@ void passed() {
|
||||
//newlin();
|
||||
}
|
||||
|
||||
void prtadr() {
|
||||
aa, yy, xx = getadr();
|
||||
puts("ADDRESS=");
|
||||
prbyte(aa); prbyte(yy); prbyte(xx); newlin();
|
||||
void padint(aa,yy,xx) {
|
||||
if (xx&96) putc(aa);
|
||||
if (yy < 4) putc(aa);
|
||||
}
|
||||
|
||||
void prtayx(aa,yy,xx) {prhex(aa); prhex(yy); prhex(xx); putspc(); putspc();}
|
||||
void prtadr(aa,yy,xx) {
|
||||
putc('$'); prhex(aa); prbyte(yy); prbyte(xx);
|
||||
}
|
||||
|
||||
void prtflg(aa,yy,xx) {
|
||||
if (aa) setdst("TRUE"); else setdst("FALSE");
|
||||
printf(aa,yy,xx);
|
||||
}
|
||||
|
||||
void prtreg(aa,yy,xx) {
|
||||
printf(aa,"(%d,"); printf(yy,"%d,"); printf(xx,"%d) ");
|
||||
}
|
||||
|
||||
void prtrgb(aa,yy,xx) {
|
||||
prbyte(aa); putchr(',');
|
||||
prbyte(yy); putchr(',');
|
||||
prbyte(xx); putspc();
|
||||
}
|
||||
|
||||
void prtscl() {
|
||||
printf(hscale, "HSCALE=%h, ");
|
||||
printf(vscale, "VSCALE=%h%n");
|
||||
}
|
||||
|
||||
/*Print Sprite Attributes */
|
||||
void prtspr() {
|
||||
printf(setdst(spattr.addr),"ADR=$%w, ");
|
||||
printf(setdst(spattr.horz),"HRZ=%i, ");
|
||||
printf(setdst(spattr.vert),"VRT=%i, ");
|
||||
printf(spattr.ctrl,"CTL=$%h, ");
|
||||
printf(spattr.size,"SIZ=$%h%n");
|
||||
}
|
||||
|
||||
void prttmp() {
|
||||
printf(temp0, "TEMP0=$%h%n");
|
||||
@ -76,11 +119,6 @@ void prttmp() {
|
||||
printf(temp3, "TEMP3=$%h%n");
|
||||
}
|
||||
|
||||
void prtscl() {
|
||||
printf(hscale, "HSCALE=%h, ");
|
||||
printf(vscale, "VSCALE=%h%n");
|
||||
}
|
||||
|
||||
void prtvid() {
|
||||
select (mode) {
|
||||
case 0: puts("DISABLED");
|
||||
@ -95,6 +133,8 @@ void prtvid() {
|
||||
putln(" FIELD");
|
||||
}
|
||||
|
||||
int toint(.,yy,xx) {}
|
||||
|
||||
void xerror() {
|
||||
putln(" ERROR ENCOUNTERED");
|
||||
goto exit;
|
||||
@ -103,6 +143,8 @@ void xerror() {
|
||||
main:
|
||||
newlin();
|
||||
|
||||
|
||||
|
||||
puts("TESTING GETMEM() AND SETMEM()");
|
||||
setadr($20,&0); setmem(@abcdef,&abcdef);
|
||||
setadr($20,&0); getmem(@abcdef,&buffer);
|
||||
@ -122,8 +164,7 @@ main:
|
||||
passed();
|
||||
|
||||
puts("TESTING GETBDR() AND SETBDR()");
|
||||
i = 0;
|
||||
do {
|
||||
i=0; do {
|
||||
setbdr(i);
|
||||
index = getbdr();
|
||||
if (index<>i) xerror();
|
||||
@ -133,8 +174,7 @@ main:
|
||||
passed();
|
||||
|
||||
puts("TESTING GETSCL() AND SETSCL()");
|
||||
i=1;
|
||||
do {
|
||||
i=1; do {
|
||||
j=1;
|
||||
do {
|
||||
setscl(i,j); hscale,vscale = getscl();
|
||||
@ -186,21 +226,24 @@ main:
|
||||
}
|
||||
passed();
|
||||
|
||||
newlin();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
puts("TESTING RGBCLR() AND CLRRGB()");
|
||||
for (red=0;red<16;red++) {
|
||||
for (green=0;green<16;green++) {
|
||||
for (blue=0;blue<16;blue++) {
|
||||
//prtayx(red,green,blue);
|
||||
for (red=7;red<255;red=red+8) {
|
||||
for (green=7;green<255;green=green+8) {
|
||||
for (blue=7;blue<255;blue=blue+8) {
|
||||
color = rgbclr(red,green,blue);
|
||||
//putwrd(color); putspc();
|
||||
i,j,k = clrrgb();
|
||||
//prtayx(i,j,k);
|
||||
if (i<>red or j<>green or blue<>k) xerror();
|
||||
i,j,k = clrrgb(color);
|
||||
if (red&$f0<>i or green&$f0<>j or blue&$f0<>k) {
|
||||
prtrgb(red,green,blue);
|
||||
putwrd(color); putspc();
|
||||
prtrgb(i,j,k); newlin();
|
||||
xerror();
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (anykey()==#ESCKEY) goto exit;
|
||||
}
|
||||
passed();
|
||||
|
||||
@ -215,11 +258,9 @@ main:
|
||||
//passed();
|
||||
|
||||
//puts("TESTING SETCLR()");
|
||||
for (i=128; i<144; i++) {
|
||||
for (i=128; i<160; i++) {
|
||||
//puthex(i); putspc();
|
||||
red = i+8&15;
|
||||
green = 144-i;
|
||||
blue = i&15;
|
||||
red = i; green = i + 32; blue = i + 64;
|
||||
//prhex(red); prhex(green); prhex(blue); putspc(); putspc();
|
||||
color = rgbclr(red,green,blue);
|
||||
setclr(i,color);
|
||||
@ -230,6 +271,23 @@ main:
|
||||
}
|
||||
passed();
|
||||
|
||||
puts("TESTING GETRGB() AND SETRGB()");
|
||||
for (l=128; l<160; l++) {
|
||||
red = l; green = l + 32; blue = l + 64;
|
||||
setidx(i); setrgb(red,green,blue);
|
||||
setidx(l); i,j,k = getrgb();
|
||||
if (red&$f0<>i or green&$f0<>j or blue&$f0<>k) {
|
||||
puthex(l); putspc();
|
||||
prtrgb(red,green,blue);
|
||||
putwrd(color); putspc();
|
||||
prtrgb(i,j,k); newlin();
|
||||
xerror();
|
||||
}
|
||||
}
|
||||
passed();
|
||||
|
||||
newlin();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
//putln("SAVING LAYER REGISTERS");
|
||||
@ -252,18 +310,18 @@ main:
|
||||
printf("TESTING GETMSZ() AND SETMSZ()");
|
||||
for (i=0;i<2;i++) {for (j=0;j<4;j++) {for (k=0;k<4;k++) {
|
||||
//printf(j,"%nJ=%h, "); printf(k,"K=%h");
|
||||
setmsz(i,j,k); width, height = getmsz(i);
|
||||
//printf(width," WIDTH=%h, "); printf(height,"HEIGHT=%h");
|
||||
if (width<>j or height<>k) xerror();
|
||||
setmsz(i,j,k); w, h = getmsz(i);
|
||||
//printf(w," WIDTH=%h, "); printf(h,"HEIGHT=%h");
|
||||
if (w<>j or h<>k) xerror();
|
||||
}}}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETTSZ() AND SETTSZ()");
|
||||
for (i=0;i<2;i++) {for (j=0;j<2;j++) {for (k=0;k<2;k++) {
|
||||
//printf(j,"%nJ=%h, "); printf(k,"K=%h");
|
||||
settsz(i,j,k); width, height = gettsz(i);
|
||||
//printf(width," WIDTH=%h, "); printf(height,"HEIGHT=%h");
|
||||
if (width<>j or height<>k) xerror();
|
||||
settsz(i,j,k); w, h = gettsz(i);
|
||||
//printf(w," WIDTH=%h, "); printf(h,"HEIGHT=%h");
|
||||
if (w<>j or h<>k) xerror();
|
||||
}}}
|
||||
passed();
|
||||
|
||||
@ -331,6 +389,292 @@ main:
|
||||
setadr($1F, &$2000); setmem(@layer0, &layer0);
|
||||
setadr($1F, &$3000); setmem(@layer1, &layer1);
|
||||
|
||||
newlin();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
printf("TESTING GETSPE() AND SETSPE()");
|
||||
setspe(#FALSE); if (getspe()) xerror();
|
||||
setspe(#TRUE); if (!getspe()) xerror();
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPO() AND SETSPO()");
|
||||
addr = &$5000;
|
||||
for (i=0; i<#MAXSPR;i++) {
|
||||
for (j=0;j<8;j++) {
|
||||
spaddr = getspo(i,j);
|
||||
//printf(i,"%nSPRITE %r "); printf(j,"OFFSET %d ADDRESS=$"); putwrd(spaddr);
|
||||
if (<spaddr <> <addr or >spaddr <> >addr) xerror();
|
||||
if (setspo(i,j)<>8) xerror(); //Returns number of attribute bytes per sprite
|
||||
b,m,l = getadr();
|
||||
//puts(", $"); putexh(b,m,l);
|
||||
if (b <> $1F or l <> <addr or m <> >addr) xerror();
|
||||
addr++;
|
||||
}
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPR() AND SETSPR()");
|
||||
bank=$1f;msb=$50; lsb=$00;
|
||||
for (i=0; i<#MAXSPR;i++) {
|
||||
lsb=lsb+8; if (!lsb) msb++;
|
||||
/* Set Sprite Attributes */
|
||||
spattw[0]=i^$FF; spattw[1]=i|$80; //Sprite Address & Mode
|
||||
spattw[2]=i|$80; spattw[3]=0; spattw.horz<<; spattw.horz<<;
|
||||
spattw[4]=i^$FF; spattw[5]=0; spattw.vert<<; spattw.vert<<;
|
||||
spattw[6]=(i&1) ? $80|i : i;//Sprite Control
|
||||
spattw[7]=(i&1) ? i : $80|i; //Sprite Size
|
||||
l = setspr(i,&spattw); if (l<>8) xerror();
|
||||
b,m,l = getadr(); if (b<>bank or m<>msb or l<>lsb) xerror();
|
||||
/* Get Sprite Attributes */
|
||||
l = getspr(i,&spattr); if (l<>8) xerror();
|
||||
b,m,l = getadr(); if (b<>bank or m<>msb or l<>lsb) xerror();
|
||||
//printf(i, "SPRITE %r ATTRS: "); prtspr();
|
||||
for (j=0; j<@spattr; j++) {if (spattr[j]<>spattw[j]) xerror();}
|
||||
/* Clear Sprite Attributes */
|
||||
clrspr(i); b,m,l = getadr(); if (b<>bank or m<>msb or l<>lsb) xerror();
|
||||
getspr(i, &spattr); b,m,l = getadr(); if (b<>bank or m<>msb or l<>lsb) xerror();
|
||||
for (j=0; j<@spattr; j++) {if (spattr[j]) xerror();}
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPD() AND SETSPD()");
|
||||
spaddr=&$800; //Sprite Address Register Value
|
||||
bank=1; msb=0; lsb=0; //Sprite Data Address (spaddr<<5)
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i,"%nSPRITE %r ");
|
||||
setspg(i,1,$80); //Set Bit 7 of Register 1 (Mode)
|
||||
setspd(i,spaddr);
|
||||
//printf(getspg(i,1),"REG=$%h"); printf(getspg(i,0),"%h ");
|
||||
if (!getspg(i,1)&$80) xerror(); //Check Bit 7 of Register 1
|
||||
addr = getspd(i);
|
||||
//printf(setdst(addr),"ADDRESS=$%w");
|
||||
if (<addr <> <spaddr or >addr <> >spaddr) xerror();
|
||||
b,m,l = getspa(i);
|
||||
//printf(setdst(b,m,l)," ($%g%w)");
|
||||
if (b<>bank or m<>msb or l<>lsb) xerror();
|
||||
spaddr++;
|
||||
lsb = lsb + $20; if (!lsb) msb++;
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING SETSPB() AND GETSPB()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r ");
|
||||
k=127-i; setspg(i,1,k); //Set Bits 0-6 of Register
|
||||
for (j=1; j:+; j--) {
|
||||
setspb(i,j);
|
||||
spmode = getspb(i);
|
||||
//printf(spmode,"MODE=%d ");
|
||||
//printf(getspg(i,1),"REG=$%h ");
|
||||
if (spmode<>j) xerror();
|
||||
}
|
||||
if (getspg(i,1)<>k) xerror(); //Check Bits 0-6 of Register
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPX() AND SETSPX()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r ");
|
||||
lsb = i&3; msb = i+64;
|
||||
setspx(i, msb, lsb); l = getspg(i,2); m = getspg(i,3);
|
||||
//printf(setdst(.,m,l),"REG=$%w ");
|
||||
if (l<>lsb or m<>msb) xerror();
|
||||
n,m,l = getspx(i);
|
||||
//printf(setdst(.,m,l),"X=%i ");
|
||||
if (m<>msb or l<>lsb) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPY() AND SETSPY()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r ");
|
||||
lsb = i&3^3; msb = 192-i;
|
||||
setspy(i, msb, lsb); l = getspg(i,4); m = getspg(i,5);
|
||||
//printf(setdst(.,m,l),"REG=$%w ");
|
||||
if (l<>lsb or m<>msb) xerror();
|
||||
n,m,l = getspy(i);
|
||||
//printf(setdst(.,m,l),"Y=%i ");
|
||||
if (m<>msb or l<>lsb) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPF() AND SETSPF()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r ");
|
||||
setspn(i,$ff); //Set All Bits in Control Register
|
||||
for (j=1; j:+; j--) { //1 to 0
|
||||
k = j-1; //#FALSE then #TRUE
|
||||
setspf(i,k);
|
||||
//printf(getspn(i),"REG=$%h ");
|
||||
n = getspf(i);
|
||||
//prtflg(n,"HFLIP=$%h (%s) ");
|
||||
if (n<>k) xerror();
|
||||
}
|
||||
if (getspn(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPV() AND SETSPV()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r ");
|
||||
setspn(i,$ff); //Set All Bits in Control Register
|
||||
for (j=1; j:+; j--) { //1 to 0
|
||||
k = j-1; //#FALSE then #TRUE
|
||||
setspv(i,k);
|
||||
//printf(getspn(i),"REG=$%h ");
|
||||
n = getspv(i);
|
||||
//prtflg(n,"HFLIP=$%h (%s) ");
|
||||
if (n<>k) xerror();
|
||||
}
|
||||
if (getspn(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPZ() AND SETSPZ()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r ");
|
||||
setspn(i,$ff); //Set All Bits in Control Register
|
||||
for (j=0; j<4; j++) {
|
||||
setspz(i,j);
|
||||
//printf(getspn(i),"REG=$%h ");
|
||||
n = getspz(i);
|
||||
//printf(n,"ZDEPTH=%d ");
|
||||
if (n<>j) xerror();
|
||||
}
|
||||
if (getspn(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPM() AND SETSPM()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%n%r ");
|
||||
setspn(i,$ff); //Set All Bits in Control Register
|
||||
for (j=0; j<16; j++) {
|
||||
setspm(i,j);
|
||||
//printf(getspn(i),"%h:");
|
||||
n = getspm(i);
|
||||
//printf(n,"%g ");
|
||||
if (n<>j) xerror();
|
||||
}
|
||||
if (getspn(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPP() AND SETSPP()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%n%r ");
|
||||
setsps(i,$ff); //Set All Bits in Control Register
|
||||
for (j=0; j<16; j++) {
|
||||
setspp(i,j);
|
||||
//printf(getsps(i),"%h:");
|
||||
n = getspp(i);
|
||||
//printf(n,"%g ");
|
||||
if (n<>j) xerror();
|
||||
}
|
||||
if (getsps(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPH() AND SETSPH()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r HEIGHT ");
|
||||
setsps(i,$ff); //Set All Bits in Control Register
|
||||
for (j=0; j<4; j++) {
|
||||
setsph(i,j);
|
||||
//printf(getsps(i),"[$%h] ");
|
||||
n = getsph(i);
|
||||
//printf(n,"%d ");
|
||||
if (n<>j) xerror();
|
||||
}
|
||||
if (getsps(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPW() AND SETSPW()");
|
||||
for (i=0; i<#MAXSPR; i++) {
|
||||
//printf(i, "%nSPRITE %r WIDTH ");
|
||||
setsps(i,$ff); //Set All Bits in Control Register
|
||||
for (j=0; j<4; j++) {
|
||||
setspw(i,j);
|
||||
//printf(getsps(i),"[$%h] ");
|
||||
n = getspw(i);
|
||||
//printf(n,"%d ");
|
||||
if (n<>j) xerror();
|
||||
}
|
||||
if (getsps(i)<>$ff) xerror();
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPJ() AND GETSPK()");
|
||||
l = 8; m = 3; //Size in Pixels, Shift Counter
|
||||
for (i=0; i<4; i++) {
|
||||
//printf(i,"%nSIZE %r =");
|
||||
j,k = getspj(i);
|
||||
//printf(j,"%r PIXELS, ");
|
||||
//printf(k,"SHIFT COUNT %d");
|
||||
if (j<>l or k<>m) xerror();
|
||||
l<<; m++; //Multiply Size by Two, Increment Shift Counter
|
||||
}
|
||||
h = 8; height = &8; //Sprite Height in Pixels
|
||||
for (i=0; i<4; i++) {
|
||||
w = 8; //Sprite Width in Pixels
|
||||
size = height; size<<; size<<; //Set Size to Height*4
|
||||
for (j=0; j<4; j++) {
|
||||
p = 4; //Bits Per Pixeg
|
||||
bytes = size;
|
||||
//printf(h,"%nSPRITE HEIGHT=%l"); printf(w,"WIDTH=%l");
|
||||
for (k=0; k<2; k++) {
|
||||
//printf(p,"%d BPP ");
|
||||
spsize = getspk(j,i,k); //Calculate Sprite Data Size
|
||||
//printf(setdst(spsize),"SIZE=%i "); padint(' ',spsize);
|
||||
//printf(setdst(bytes),"[%i] "); padint(' ',bytes);
|
||||
if (<spsize <> <bytes or >spsize <> >bytes) xerror();
|
||||
p<<; bytes<<; //Multiply BPP, Size by 2
|
||||
}
|
||||
w<<; size<<; //Multiply Width, Size by 2
|
||||
}
|
||||
h<<; height<<; //Multiply Height by 2
|
||||
}
|
||||
passed();
|
||||
|
||||
printf("TESTING GETSPL() AND GETSPU()");
|
||||
n = 0; //Sprite Index
|
||||
h = 8; height = &8; //Sprite Height in Pixels
|
||||
for (i=0; i<4; i++) {
|
||||
setsph(n,i); //Set Sprite Height Specifier
|
||||
w = 8; //Sprite Width in Pixels
|
||||
size = height; size<<; size<<; //Set Size to Height*4
|
||||
for (j=0; j<4; j++) {
|
||||
setspw(n,j); //Set Sprite Width Specifier
|
||||
p = 4; //Bits Per Pixeg
|
||||
bytes = size;
|
||||
//printf(h,"%nHEIGHT=%d "); if (!i) putspc();
|
||||
//printf(w,"WIDTH=%d "); if (!j) putspc();
|
||||
for (k=0; k<2; k++) {
|
||||
setspp(n,k);
|
||||
d,e,f = getspu(n);
|
||||
//printf(p,"%dBPP "); prtreg();
|
||||
if (d<>j or e<>i or f<>k) xerror();
|
||||
spsize = getspl(n); //Get Sprite Data Size
|
||||
//printf(setdst(spsize),"SIZE=%i "); padint(' ',spsize);
|
||||
//printf(setdst(bytes),"[%i] "); padint(' ',bytes);
|
||||
if (<spsize <> <bytes or >spsize <> >bytes) xerror();
|
||||
p<<; bytes<<; //Multiply BPP, Size by 2
|
||||
}
|
||||
w<<; size<<; //Multiply Width, Size by 2
|
||||
}
|
||||
h<<; height<<; //Multiply Height by 2
|
||||
n++; //Increment Sprite Index
|
||||
}
|
||||
passed();
|
||||
|
||||
newlin();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
newlin();
|
||||
|
||||
goto exit;
|
||||
|
||||
|
@ -15,11 +15,11 @@
|
||||
#include "include/veradsp.h02" //Vera Display Controller
|
||||
#include "include/veraclr.h02" //Vera Color Palette
|
||||
#include "include/veralyr.h02" //Vera Layer Control
|
||||
#include "include/vera.h02"
|
||||
|
||||
//#include "include/veraspr.h02" //Vera Sprites
|
||||
/* Globals */
|
||||
char i,j,k; //Loop Indexes
|
||||
char aa,yy,xx; //Function Paramaters
|
||||
char zz; //Function Variable
|
||||
int yx; //Function Paramater
|
||||
|
||||
/* Display Composer */
|
||||
@ -41,6 +41,16 @@ void prtadr(aa,yx) {
|
||||
puts("ADDRESS: $"); putnyb(aa); putwrd(yx);
|
||||
}
|
||||
|
||||
//Print Masked Bits (byte, mask)
|
||||
void prtmsk(aa,yy) {
|
||||
xx = $80;
|
||||
do {
|
||||
zz = (aa&xx) ? '1' : '0';
|
||||
if (yy&xx) putchr(zz);
|
||||
xx>>;
|
||||
} while(xx);
|
||||
}
|
||||
|
||||
//Print Three Values Enclosed in Parentheses
|
||||
void prtprn(aa,yy,xx) {
|
||||
printf(aa,"($%h"); printf(yy,",$%h"); printf(xx,",$%h)");
|
||||
@ -69,10 +79,10 @@ main:
|
||||
prtprn(clrrgb(bcolor)); newlin();
|
||||
|
||||
hscale,vscale = getscl(); hstart = gethsr(); hstop = gethsp(); vstart = getvsr(); vstop = getvsp();
|
||||
printf(hscale, " HORIZONTAL SCALE: $%h, "); setdst(hstart); printf("START: $%w, "); setdst(hstop); printf("STOP: $%q%n");
|
||||
printf(vscale, " VERTICAL SCALE: $%h, "); setdst(vstart); printf("START: $%q, "); setdst(vstop); printf("STOP: $%q%n");
|
||||
printf(hscale, " HORIZONTAL SCALE: %d, "); setdst(hstart); printf("START: %i, "); setdst(hstop); printf("STOP: %i%n");
|
||||
printf(vscale, " VERTICAL SCALE: %d, "); setdst(vstart); printf("START: %i, "); setdst(vstop); printf("STOP: %i%n");
|
||||
|
||||
setdst(getiql()); printf(" IRQ LINE: $%w%n");
|
||||
setdst(getiql()); printf(" IRQ LINE: $%i%n");
|
||||
newlin();
|
||||
|
||||
/*************************************************************************/
|
||||
@ -94,7 +104,7 @@ main:
|
||||
|
||||
for (layer=0; layer<2; layer++) {
|
||||
|
||||
printf(layer, "LAYER %h%n");
|
||||
printf(layer, "LAYER %d%n");
|
||||
|
||||
puts(" MODE: "); lmode = getmod(layer);
|
||||
select(getmod(layer)) {
|
||||
@ -111,12 +121,12 @@ main:
|
||||
if (getenb(layer)) putln(", ENABLED"); else putln(", DISABLED");
|
||||
|
||||
width, height = getmsz(layer);
|
||||
setdst(mapsiz(width)); printf(width," MAP WIDTH: $%h ($%w PIXELS)");
|
||||
setdst(mapsiz(height)); printf(height,", HEIGHT: $%h ($%w PIXELS)%n");
|
||||
setdst(mapsiz(width)); printf(width," MAP WIDTH: %d (%i PIXELS)");
|
||||
setdst(mapsiz(height)); printf(height,", HEIGHT: %d (%i PIXELS)%n");
|
||||
|
||||
width, height = gettsz(layer);
|
||||
printf(width," TILE WIDTH: $%h"); printf(tilsiz(width)," ($%w PIXELS)");
|
||||
printf(height,", HEIGHT: $%h "); printf(tilsiz(height)," ($%h PIXELS)%n");
|
||||
printf(width," TILE WIDTH: %d"); printf(tilsiz(width)," (%d PIXELS)");
|
||||
printf(height,", HEIGHT: %d"); printf(tilsiz(height)," (%d PIXELS)%n");
|
||||
|
||||
setdst(getmbs(layer)); printf(" MAP BASE: $%w, ");
|
||||
prtadr(getmba(layer)); newlin();
|
||||
@ -124,8 +134,8 @@ main:
|
||||
setdst(gettbs(layer)); printf(" TILE BASE: $%w, ");
|
||||
prtadr(gettba(layer)); newlin();
|
||||
|
||||
setdst(gethsc(layer)); printf(" HORIZONTAL SCROLL: $%q");
|
||||
setdst(getvsc(layer)); printf(", VERTICAL SCROLL: $%q%n");
|
||||
setdst(gethsc(layer)); printf(" HORIZONTAL SCROLL: $%i");
|
||||
setdst(getvsc(layer)); printf(", VERTICAL SCROLL: $%i%n");
|
||||
|
||||
printf(getbpo(layer)); printf(" BITMAP PALETTE OFFSET: $%h%n");
|
||||
|
||||
@ -134,5 +144,10 @@ main:
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
//puts("SPRITES "); if (getspe()) puts("ENABLED"); else puts("DISABLED");
|
||||
//puts(", COLLISION STATUS: %"); putmsk(getsps(),$0f); newlin();
|
||||
|
||||
|
||||
|
||||
goto exit;
|
||||
|
19
x16/x16.bat
Normal file
19
x16/x16.bat
Normal file
@ -0,0 +1,19 @@
|
||||
@REM Compile and Run C02 Program for Commander X16 Emulator
|
||||
@ECHO OFF
|
||||
IF EXIST %1.c02 GOTO COMPILE
|
||||
ECHO File %1.c02 not found
|
||||
GOTO EOF
|
||||
|
||||
:COMPILE
|
||||
ECHO Compiling File %1.c02 for Commander X16
|
||||
..\c02.exe -h x16 -s x16 -s cbm %1 >%1.dbg
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||
ECHO Assembling File %1.asm
|
||||
C:\Programs\dasm %1.asm -f1 -o%1.prg -l%1.lst -s%1.sym
|
||||
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO EOF
|
||||
|
||||
ECHO Starting Emulator in Debug Mode
|
||||
REM C:\Programs\x16emu\x16emu -prg %1.prg -run -debug -log v >%1.out
|
||||
C:\Programs\x16emu\x16emu -prg %1.prg -run -debug
|
||||
:EOF
|
Loading…
x
Reference in New Issue
Block a user