@@ -16,29 +16,29 @@
; palmac_PalBufIndex
; Internal macro for calculating the palette buffer index.

; xxx: possibly broken
; xxx: possibly broken?

; Trashes: d5, d4

; (Params)
; d7 Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d7 Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)

; (Returns)
; a0 Location in palette buffer
; a0 Location in palette buffer

palmac_PalBufIndex: macro
; d5 = (d7 & $FF00)>>3) (palette set number)
move.w d7,d5
andi.w #$FF00,d5 ; d7 & $FF00
lsr.w #3,d5 ; d7 >> 3
move.w d7,d5
andi.w #$FF00,d5 ; d7 & $FF00
lsr.w #3,d5 ; d7 >> 3

; d4 = d7 & $0F (index inside of palette set)
move.w d7,d4
andi.w #$0F,d4
add.w d4,d5 ; add palette set and palette index
move.w d7,d4
andi.w #$0F,d4
add.w d4,d5 ; add palette set and palette index

addi.l #PaletteBuffer,d5 ; add palette buffer location
movea.l d5,a0 ; palette buffer location in a0
addi.l #PaletteBuffer,d5 ; add palette buffer location
movea.l d5,a0 ; palette buffer location in a0

endm

@@ -47,92 +47,94 @@ palmac_PalBufIndex: macro
; A macro for placing an RGB (0-31) value (with dark bit) in the binary.

; (Params)
; \1 [byte] Red value ($00-$1F; 0-31)
; \2 [byte] Green value ($00-$1F; 0-31)
; \3 [byte] Blue value ($00-$1F; 0-31)
; \4 [byte] Dark bit (0 or 1; subtracts RGB by 1 if enabled)
; \1 [byte] Red value ($00-$1F; 0-31)
; \2 [byte] Green value ($00-$1F; 0-31)
; \3 [byte] Blue value ($00-$1F; 0-31)
; \4 [byte] Dark bit (0 or 1; subtracts RGB by 1 if enabled)

palmac_ColorRGBD: macro
dc.w ((\4&1)<<15)|((\1&1)<<14)|((\2&1)<<13)|((\3&1)<<12)|(((\1&$1E)>>1)<<8)|(((\2&$1E)>>1)<<4)|((\3&$1E)>>1)
palmac_ColorRGBD: macro
dc.w ((\4&1)<<15)|((\1&1)<<14)|((\2&1)<<13)|((\3&1)<<12)|(((\1&$1E)>>1)<<8)|(((\2&$1E)>>1)<<4)|((\3&$1E)>>1)
endm

;==============================================================================;
; pal_LoadData
; Load raw color data into the palette RAM.

; (Params)
; d7 Number of color entries-1 (loop counter)
; a0 Address to load palette data from
; a1 Beginning palette address to load data into ($400000-$401FFE)
; d7 Number of color entries-1 (loop counter)
; a0 Address to load palette data from
; a1 Beginning palette address to load data into ($400000-$401FFE)

pal_LoadData:
move.w (a0)+,(a1)+
dbra d7,pal_LoadData
move.w (a0)+,(a1)+
dbra d7,pal_LoadData
rts

;------------------------------------------------------------------------------;
; palmac_LoadData
; For extremely lazy people. \1 through \3 are the same params as pal_LoadData.

palmac_LoadData: macro
move.l #\1,d7
lea \2,a0
lea \3,a1
jsr pal_LoadData
palmac_LoadData: macro
move.l #\1,d7
lea \2,a0
lea \3,a1
jsr pal_LoadData
endm

;==============================================================================;
; pal_LoadBuf
; Load raw color data into the palette buffer.

; (Params)
; d7 [????] Number of color entries-1 (loop counter)
; d6 [word] Beginning buffer index to load data into (multiplied by 2)
; a0 [long] Address to load palette data from
; d7 [????] Number of color entries-1 (loop counter)
; d6 [word] Beginning buffer index to load data into (multiplied by 2)
; a0 [long] Address to load palette data from

pal_LoadBuf:
lea PaletteBuffer,a1
lsl.w #1,d6 ; shift left once (multiply by 2)
add.w d6,a1 ; get offset into PaletteBuffer
lea PaletteBuffer,a1
lsl.w #1,d6 ; shift left once (multiply by 2)
add.w d6,a1 ; get offset into PaletteBuffer

.pal_LoadBuf_Loop:
move.w (a0)+,(a1)+
dbra d7,.pal_LoadBuf_Loop
move.w (a0)+,(a1)+
dbra d7,.pal_LoadBuf_Loop

rts

;------------------------------------------------------------------------------;
; palmac_LoadBuf
; For extremely lazy people. \1 through \3 are the same params as pal_LoadBuf.

palmac_LoadBuf: macro
move.l #\1,d7
move.w #\2,d6
lea \3,a0
jsr pal_LoadBuf
palmac_LoadBuf: macro
move.l #\1,d7
move.w #\2,d6
lea \3,a0
jsr pal_LoadBuf
endm

;==============================================================================;
; pal_LoadSetBuf
; Load a single palette set (16 colors) into the palette buffer.

; (Params)
; d7 [byte] Palette set to load data into ($00-$FF)
; a0 [long] Address to load palette data from
; d7 [byte] Palette set to load data into ($00-$FF)
; a0 [long] Address to load palette data from

pal_LoadSetBuf:
; calculate starting address in palette buffer
lsl.w #5,d7 ; (d7<<5)
addi.l #PaletteBuffer,d7 ; add palette buffer location
movea.l d7,a1
lsl.w #5,d7 ; (d7<<5)
addi.l #PaletteBuffer,d7 ; add palette buffer location
movea.l d7,a1

; 2 colors x8 times = 16 colors
move.l (a0)+,(a1)+ ; color indices $00 and $01
move.l (a0)+,(a1)+ ; color indices $02 and $03
move.l (a0)+,(a1)+ ; color indices $04 and $05
move.l (a0)+,(a1)+ ; color indices $06 and $07
move.l (a0)+,(a1)+ ; color indices $08 and $09
move.l (a0)+,(a1)+ ; color indices $0A and $0B
move.l (a0)+,(a1)+ ; color indices $0C and $0D
move.l (a0)+,(a1)+ ; color indices $0E and $0F
move.l (a0)+,(a1)+ ; color indices $00 and $01
move.l (a0)+,(a1)+ ; color indices $02 and $03
move.l (a0)+,(a1)+ ; color indices $04 and $05
move.l (a0)+,(a1)+ ; color indices $06 and $07
move.l (a0)+,(a1)+ ; color indices $08 and $09
move.l (a0)+,(a1)+ ; color indices $0A and $0B
move.l (a0)+,(a1)+ ; color indices $0C and $0D
move.l (a0)+,(a1)+ ; color indices $0E and $0F

rts

@@ -141,29 +143,29 @@ pal_LoadSetBuf:
; Set the value of a single color in the palette buffer.

; (Params)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [word] New color value
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [word] New color value

pal_SetColor:
palmac_PalBufIndex ; get address in palette buffer
move.w d6,(a0) ; write new color value
palmac_PalBufIndex ; get address in palette buffer
move.w d6,(a0) ; write new color value
rts

;==============================================================================;
; pal_FillColors
; Sets the value of multiple colors in the palette buffer.

; (Params)
; d7 [word] Beginning Palette Set & Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [word] New color value
; d3 [????] Number of entries to write-1 (loop counter)
; d7 [word] Beginning Palette Set & Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [word] New color value
; d3 [????] Number of entries to write-1 (loop counter)

pal_FillColors:
palmac_PalBufIndex ; get address in palette buffer
palmac_PalBufIndex ; get address in palette buffer
; do loop
.pal_FillColors_Loop:
move.w d6,(a0)+
dbra d3,.pal_FillColors_Loop
move.w d6,(a0)+
dbra d3,.pal_FillColors_Loop

rts

@@ -172,18 +174,18 @@ pal_FillColors:
; Halves the color values of the specified color in the palette buffer.

; (Params)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)

pal_SoftShadow:
palmac_PalBufIndex ; get address in palette buffer
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d6 ; get current color value
move.w (a0),d6 ; get current color value

; separate components
; multiply components (0.5)
; re-combine components

move.w d6,(a0) ; update color value
move.w d6,(a0) ; update color value

rts

@@ -192,18 +194,18 @@ pal_SoftShadow:
; Doubles the color values of the specified color in the palette buffer.

; (Params)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)

pal_SoftBright:
palmac_PalBufIndex ; get address in palette buffer
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d6 ; get current color value
move.w (a0),d6 ; get current color value

; separate components
; multiply components (1.5)
; re-combine components

move.w d6,(a0) ; update color value
move.w d6,(a0) ; update color value

rts

@@ -212,24 +214,24 @@ pal_SoftBright:
; Modify the Red channel of the specified color in the palette buffer.

; (Params)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [byte] New Red channel value (0011111d)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [byte] New Red channel value (0011111d)

; Dr__RRRR________

pal_SetSingleRed:
palmac_PalBufIndex ; get address in palette buffer
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d5 ; get current color value
move.w (a0),d5 ; get current color value

; get values of Green and Blue channels for re-combining
move.w d5,d4 ; save copy for other channels
andi.w #$B0FF,d4 ; get values for Green and Blue
move.w d5,d4 ; save copy for other channels
andi.w #$B0FF,d4 ; get values for Green and Blue

; deconstruct passed Red channel value into palette Red
; change Red

move.w d5,(a0) ; update color value in palette buffer
move.w d5,(a0) ; update color value in palette buffer

rts

@@ -238,24 +240,24 @@ pal_SetSingleRed:
; Modify the Green channel of the specified color in the palette buffer.

; (Params)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [byte] New Green channel value (0011111d)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [byte] New Green channel value (0011111d)

; D_g_____GGGG____

pal_SetSingleGreen:
palmac_PalBufIndex ; get address in palette buffer
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d5 ; get current color value
move.w (a0),d5 ; get current color value

; get values of Red and Blue channels for re-combining
move.w d5,d4 ; save copy for other channels
andi.w #$DF0F,d4 ; get values for Red and Blue
move.w d5,d4 ; save copy for other channels
andi.w #$DF0F,d4 ; get values for Red and Blue

; deconstruct passed Green channel value into palette Green
; change Green

move.w d5,(a0) ; update color value in palette buffer
move.w d5,(a0) ; update color value in palette buffer

rts

@@ -264,24 +266,24 @@ pal_SetSingleGreen:
; Modify the Blue channel of the specified color in the palette buffer.

; (Params)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [byte] New Blue channel value (0011111d)
; d7 [word] Palette Set, Palette Index ($SS0i; SS=$00-$FF, i=$0-$F)
; d6 [byte] New Blue channel value (0011111d)

; D__b________BBBB

pal_SetSingleBlue:
palmac_PalBufIndex ; get address in palette buffer
palmac_PalBufIndex ; get address in palette buffer

move.w (a0),d5 ; get current color value
move.w (a0),d5 ; get current color value

; get values of Red and Green channels for re-combining
move.w d5,d4 ; save copy for other channels
andi.w #$EFF0,d4 ; get values for Red and Green
move.w d5,d4 ; save copy for other channels
andi.w #$EFF0,d4 ; get values for Red and Green

; deconstruct passed Blue channel value into palette Blue
; change Blue

move.w d5,(a0) ; update color value in palette buffer
move.w d5,(a0) ; update color value in palette buffer

rts

@@ -297,11 +299,11 @@ palAction_Handler:
rts

palAction_Commands:
dc.l palAction_Nop
dc.l palAction_IndexCycle
dc.l palAction_ColorAnim
dc.l palAction_ColorPulse
dc.l palAction_ColorRamp
dc.l palAction_Nop
dc.l palAction_IndexCycle
dc.l palAction_ColorAnim
dc.l palAction_ColorPulse
dc.l palAction_ColorRamp

;==============================================================================;
; <Palette Actions>
@@ -332,9 +334,9 @@ palAction_IndexCycle:
; Perform color animation using fixed values.

; (Params)
; d? [byte] Palette set number ($00-$FF)
; d? [byte] Starting index (1-15)
; a? [long] Color animation data pointer
; d? [byte] Palette set number ($00-$FF)
; d? [byte] Starting index (1-15)
; a? [long] Color animation data pointer

palAction_ColorAnim:
; find index in palette buffer
@@ -3,14 +3,14 @@
; todo: a lot of things need to exist here.

; Overall a sprite consists of values written to four sections:
; * SCB1 ($0000-$6FFF) Tilemaps, palette, auto-animation, and flip bits
; * SCB2 ($8000-$81FF) Shrinking coefficients
; * SCB3 ($8200-$83FF) Y position, Sticky bit, Sprite height
; * SCB4 ($8400-$85FF) X position
; * SCB1 ($0000-$6FFF) Tilemaps, palette, auto-animation, and flip bits
; * SCB2 ($8000-$81FF) Shrinking coefficients
; * SCB3 ($8200-$83FF) Y position, Sticky bit, Sprite height
; * SCB4 ($8400-$85FF) X position

; There's also some values that I'm not sure of yet:
; * ($8600-$867F) Sprite list for even scanlines
; * ($8680-$86FF) Sprite list for odd scanlines
; * ($8600-$867F) Sprite list for even scanlines
; * ($8680-$86FF) Sprite list for odd scanlines

;==============================================================================;
; Calculating X position:
@@ -24,12 +24,12 @@
; Calculates a Sprite's X value (for SCB4).

; (Input)
; \1 X value
; \1 X value
; (Output)
; d0 Shifted X value
; d0 Shifted X value

utilmac_CalcSprX: macro
move.w (\1<<7),d0
utilmac_CalcSprX: macro
move.w (\1<<7),d0
endm

;------------------------------------------------------------------------------;
@@ -46,12 +46,12 @@ utilmac_CalcSprX: macro
; Calculates a Sprite's Y value (for SCB3).

; (Input)
; \1 Y value
; \1 Y value
; (Output)
; d0 Calculated Y value
; d0 Calculated Y value

utilmac_CalcSprY: macro
move.w ((496-\1)<<7),d0
utilmac_CalcSprY: macro
move.w ((496-\1)<<7),d0
endm

;==============================================================================;
@@ -61,34 +61,34 @@ utilmac_CalcSprY: macro
; Loads a single sprite into the VRAM. Can be called on its own, or by mspr_Load.

; (Params)
; d0 [word] Sprite index (0-511; sprite 0 is not recommended!)
; a0 [long] Pointer to Sprite Data Block
; d0 [word] Sprite index (0-511; sprite 0 is not recommended!)
; a0 [long] Pointer to Sprite Data Block

spr_LoadDirect:
; start reading from sprite data block
move.w (a0)+,d1 ; $00 sprite height (in tiles)
move.w (a0)+,d1 ; $00: sprite height (in tiles)

; Handle SCB1
move.l (a0)+,a1 ; $02-05 pointer to SCB1 tilemap data
jsr spr_ParseSCB1
move.l (a0)+,a1 ; $02-05: pointer to SCB1 tilemap data
jsr spr_ParseSCB1

; SCB2 ($8000-$81FF)
move.w #$8000,d2 ; begin at $8000
add.w d0,d2 ; add sprite index
move.w d2,LSPC_ADDR ; set new VRAM address
move.w (a0)+,LSPC_DATA ; $06 SCB2 data
move.w #$8000,d2 ; begin at $8000
add.w d0,d2 ; add sprite index
move.w d2,LSPC_ADDR ; set new VRAM address
move.w (a0)+,LSPC_DATA ; $06: SCB2 data

; SCB3 ($8200-$83FF)
move.w #$8200,d2 ; begin at $8200
add.w d0,d2 ; add sprite index
move.w d2,LSPC_ADDR ; set new VRAM address
move.w (a0)+,LSPC_DATA ; $08 SCB3 data
move.w #$8200,d2 ; begin at $8200
add.w d0,d2 ; add sprite index
move.w d2,LSPC_ADDR ; set new VRAM address
move.w (a0)+,LSPC_DATA ; $08: SCB3 data

; SCB4 ($8400-$85FF)
move.w #$8400,d2 ; begin at $8400
add.w d0,d2 ; add sprite index
move.w d2,LSPC_ADDR ; set new VRAM address
move.w (a0)+,LSPC_DATA ; $0A SCB4 data
move.w #$8400,d2 ; begin at $8400
add.w d0,d2 ; add sprite index
move.w d2,LSPC_ADDR ; set new VRAM address
move.w (a0)+,LSPC_DATA ; $0A: SCB4 data

rts

@@ -97,39 +97,39 @@ spr_LoadDirect:
; Internal routine for writing SCB1 tilemap data.

; (Params)
; d0 [word] Sprite index (carried over from spr_LoadDirect or mspr_Load)
; d1 [word] Number of tiles to parse
; a1 [long] Pointer to SCB1 tilemap data
; d0 [word] Sprite index (carried over from spr_LoadDirect or mspr_Load)
; d1 [word] Number of tiles to parse
; a1 [long] Pointer to SCB1 tilemap data

spr_ParseSCB1:
move.w #1,LSPC_INCR ; VRAM increment +1
move.w #1,LSPC_INCR ; VRAM increment +1

moveq #0,d2 ; clear d2
moveq #0,d2 ; clear d2
; convert sprite index into starting SCB1 location
;(either d0*64 or d0<<6) = SCB1 VRAM location
move.w d0,d2 ; copy sprite index (d0) to temp
lsl.w #6,d2 ; d2 << 6
move.w d2,LSPC_ADDR ; write new vram address
move.w d0,d2 ; copy sprite index (d0) to temp
lsl.w #6,d2 ; d2 << 6
move.w d2,LSPC_ADDR ; write new vram address

; check number of tiles
cmpi.w #1,d1 ; numTiles == 1?
bgt .spr_ParseSCB1_Multiple ; otherwise, loop.
cmpi.w #1,d1 ; numTiles == 1?
bgt .spr_ParseSCB1_Multiple ; otherwise, loop.

; if numTiles == 1, do a single write.
.spr_ParseSCB1_Single:
move.w (a1)+,LSPC_DATA ; 1) Tile Number LSB
move.w (a1)+,LSPC_DATA ; 2) Palette, Tile Number MSB, Auto-Animation flags, V/H flip flags
bra .spr_ParseSCB1_End
move.w (a1)+,LSPC_DATA ; 1) Tile Number LSB
move.w (a1)+,LSPC_DATA ; 2) Palette, Tile Number MSB, Auto-Animation flags, V/H flip flags
bra .spr_ParseSCB1_End

.spr_ParseSCB1_Multiple:
move.w d1,d7 ; copy num tiles (d1) to temp
subi.w #1,d7 ; subtract 1 for loop counter
move.w d1,d7 ; copy num tiles (d1) to temp
subi.w #1,d7 ; subtract 1 for loop counter

; tile loop
.spr_ParseSCB1_Loop:
move.w (a1)+,LSPC_DATA ; 1) Tile Number LSB
move.w (a1)+,LSPC_DATA ; 2) Palette, Tile Number MSB, Auto-Animation flags, V/H flip flags
dbra d7,.spr_ParseSCB1_Loop
move.w (a1)+,LSPC_DATA ; 1) Tile Number LSB
move.w (a1)+,LSPC_DATA ; 2) Palette, Tile Number MSB, Auto-Animation flags, V/H flip flags
dbra d7,.spr_ParseSCB1_Loop

.spr_ParseSCB1_End:
rts
@@ -138,14 +138,14 @@ spr_ParseSCB1:
; Sprite Macros
;------------------------------------------------------------------------------;
; semantic names for SCB1Data flags
AUTOANIM_NONE equ 0 ; no auto animation
AUTOANIM_4 equ 4 ; 4-frame auto animation
AUTOANIM_8 equ 8 ; 8-frame auto animation
AUTOANIM_NONE equ 0 ; no auto animation
AUTOANIM_4 equ 4 ; 4-frame auto animation
AUTOANIM_8 equ 8 ; 8-frame auto animation
;-----------------------;
VFLIP_NO equ 0 ; no vertical flip
VFLIP_YES equ 1 ; vertical flip
HFLIP_NO equ 0 ; no horizontal flip
HFLIP_YES equ 1 ; horizontal flip
VFLIP_NO equ 0 ; no vertical flip
VFLIP_YES equ 1 ; vertical flip
HFLIP_NO equ 0 ; no horizontal flip
HFLIP_YES equ 1 ; horizontal flip
;------------------------------------------------------------------------------;
; sprmac_SCB1Data
; Writes a single SCB1 data entry into the binary.
@@ -157,15 +157,15 @@ HFLIP_YES equ 1 ; horizontal flip
; initialization and other such tasks.)

; (Params)
; \1 Tile Number (long) 20 bits; SCB1 even, SCB1 odd (bits 4-7)
; \2 Palette Number (byte) 8 bits; SCB1 odd (bits 8-15)
; \3 Auto-Animation (0,4,8) (byte) 2 bits; SCB1 odd (bits 2,3) 4=2bit, 8=3bit
; \4 Vertical Flip (byte) 1 bit; SCB1 odd (bit 1)
; \5 Horizontal Flip (byte) 1 bit; SCB1 odd (bit 0)

sprmac_SCB1Data: macro
dc.w (\1&$0FFFF)
dc.w (\2<<8)|((\1&$F0000)>>12)|(\3)|(\4<<1)|\5
; \1 [long] Tile Number (20 bits; SCB1 even, SCB1 odd (bits 4-7))
; \2 [byte] Palette Number (8 bits; SCB1 odd (bits 8-15))
; \3 [byte] Auto-Animation (0,4,8) (2 bits; SCB1 odd (bits 2,3) 4=2bit, 8=3bit)
; \4 [byte] Vertical Flip (1 bit; SCB1 odd (bit 1))
; \5 [byte] Horizontal Flip (1 bit; SCB1 odd (bit 0))

sprmac_SCB1Data: macro
dc.w (\1&$0FFFF)
dc.w (\2<<8)|((\1&$F0000)>>12)|(\3)|(\4<<1)|\5
endm

;------------------------------------------------------------------------------;
@@ -180,19 +180,19 @@ sprmac_SCB1Data: macro
; Major Note: This does not handle the sticky bit in SCB3.

; (Params)
; \1 Sprite Height (in tiles) (word) (bottom 6 bits of SCB3)
; \2 X position (word) 9 bits (SCB4); converted to X<<7
; \3 Y position (word) 9 bits (SCB3); converted to (496-Y)<<7
; \4 Pointer to SCB1 tilemap data (long)
; \5 Horizontal Shrink (0-F) (byte)
; \6 Vertical Shrink (00-FF) (byte)

sprmac_SpriteData: macro
dc.w \1 ; Sprite Height (in tiles)
dc.l \4 ; pointer to SCB1 data
dc.w ((\5&$0F)<<8)|(\6&$FF) ; SCB2
dc.w ((496-\3)<<7)|(\1&$3F) ; SCB3 (sans sticky bit)
dc.w (\2)<<7 ; SCB4
; \1 [word] Sprite Height, in tiles (bottom 6 bits of SCB3)
; \2 [word] X position (9 bits (SCB4); converted to X<<7)
; \3 [word] Y position (9 bits (SCB3); converted to (496-Y)<<7)
; \4 [long] Pointer to SCB1 tilemap data
; \5 [byte] Horizontal Shrink (0-F)
; \6 [byte] Vertical Shrink (00-FF)

sprmac_SpriteData: macro
dc.w \1 ; Sprite Height (in tiles)
dc.l \4 ; pointer to SCB1 data
dc.w ((\5&$0F)<<8)|(\6&$FF) ; SCB2
dc.w ((496-\3)<<7)|(\1&$3F) ; SCB3 (sans sticky bit)
dc.w (\2)<<7 ; SCB4
endm

;==============================================================================;
@@ -205,33 +205,33 @@ sprmac_SpriteData: macro
; Uses spr_LoadDirect, forces sticky bit.

; (Params)
; d0 [word] Metasprite starting sprite index
; a0 [long] Pointer to Metasprite Data Block
; d0 [word] Metasprite starting sprite index
; a0 [long] Pointer to Metasprite Data Block

mspr_Load:
move.w d0,d5 ; save initial sprite number
movea.l a0,a2 ; a0 is used by other routines
move.w (a2)+,d6 ; $00 number of sprites in metasprite
subi.w #1,d6 ; subtract 1 for loop counter
move.w d0,d5 ; save initial sprite number
movea.l a0,a2 ; a0 is used by other routines
move.w (a2)+,d6 ; $00: number of sprites in metasprite
subi.w #1,d6 ; subtract 1 for loop counter

; metasprite sprite loading loop
.mspr_Load_Loop:
movea.l (a2)+,a0 ; get sprite data block pointer
jsr spr_LoadDirect ; load sprite
movea.l (a2)+,a0 ; get sprite data block pointer
jsr spr_LoadDirect ; load sprite

; something about automatically setting sticky bit if d0 > d5
cmp.w d5,d0
beq .mspr_LoadLoop_Continue
cmp.w d5,d0
beq .mspr_LoadLoop_Continue

; set sticky bit for this sprite
move.w d0,d4 ; temporary for getting SCB3 addr
addi.w #$8200,d4 ; address into SCB3
move.w d4,LSPC_ADDR ; set VRAM addr
move.w #$0040,LSPC_DATA ; set sticky bit
move.w d0,d4 ; temporary for getting SCB3 addr
addi.w #$8200,d4 ; address into SCB3
move.w d4,LSPC_ADDR ; set VRAM addr
move.w #$0040,LSPC_DATA ; set sticky bit

.mspr_LoadLoop_Continue:
addq.w #1,d0 ; update sprite index
dbra d6,.mspr_Load_Loop ; loop until finished
addq.w #1,d0 ; update sprite index
dbra d6,.mspr_Load_Loop ; loop until finished

.mspr_Load_End:
rts
@@ -12,12 +12,12 @@
; or the two Count values (BIOS_GAMEDIP_COUNT1, BIOS_GAMEDIP_COUNT2).

; (Params)
; \1 Soft DIP number to read (0-9)
; \1 Soft DIP number to read (0-9)
; (Returns)
; d0 Value of requested Soft DIP
; d0 Value of requested Soft DIP

macr_GetSoftDipNum: macro
move.b BIOS_GAMEDIP_01+\1,d0
macr_GetSoftDipNum: macro
move.b BIOS_GAMEDIP_01+\1,d0
endm
;------------------------------------------------------------------------------;

@@ -37,24 +37,24 @@ macr_GetSoftDipNum: macro
; If we are not on MVS, the routine ends early.

; (Returns)
; d0 (word) Day number 1-366, or 0 if routine not run (e.g. home system)
; d0 (word) Day number 1-366, or 0 if routine not run (e.g. home system)

; (Thrashes)
; d0 Used for return value
; d0 Used for return value

mvsCal_GetDayNum:
moveq #0,d0
moveq #0,d0
ifd TARGET_CD
rts ; short circuit when building for CD systems
rts ; short circuit when building for CD systems
else

; check for MVS
move.b REG_STATUS_B,d0
andi.b #$80
beq .mvsCal_GetDayNum_end ; not MVS, skip this.
move.b REG_STATUS_B,d0
andi.b #$80
beq .mvsCal_GetDayNum_end ; not MVS, skip this.

; MVS mode, get the calendar values
jsr READ_CALENDAR
jsr READ_CALENDAR

; (rest of this routine is WIP)
; Check for leap year