Skip to content

Commit

Permalink
Add bigdw and dc data macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Nov 20, 2023
1 parent 7a7a6d6 commit b066d3c
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 91 deletions.
54 changes: 27 additions & 27 deletions engine/battle/animations.asm
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ AnimationFlashScreenLong:
push hl
.innerLoop
ld a, [hli]
cp $01 ; is it the end of the palettes?
cp 1
jr z, .endOfPalettes
ldh [rBGP], a
call FlashScreenLongDelay
Expand All @@ -992,35 +992,35 @@ AnimationFlashScreenLong:

; BG palettes
FlashScreenLongMonochrome:
db %11111001 ; 3, 3, 2, 1
db %11111110 ; 3, 3, 3, 2
db %11111111 ; 3, 3, 3, 3
db %11111110 ; 3, 3, 3, 2
db %11111001 ; 3, 3, 2, 1
db %11100100 ; 3, 2, 1, 0
db %10010000 ; 2, 1, 0, 0
db %01000000 ; 1, 0, 0, 0
db %00000000 ; 0, 0, 0, 0
db %01000000 ; 1, 0, 0, 0
db %10010000 ; 2, 1, 0, 0
db %11100100 ; 3, 2, 1, 0
db $01 ; terminator
dc 3, 3, 2, 1
dc 3, 3, 3, 2
dc 3, 3, 3, 3
dc 3, 3, 3, 2
dc 3, 3, 2, 1
dc 3, 2, 1, 0
dc 2, 1, 0, 0
dc 1, 0, 0, 0
dc 0, 0, 0, 0
dc 1, 0, 0, 0
dc 2, 1, 0, 0
dc 3, 2, 1, 0
db 1 ; end

; BG palettes
FlashScreenLongSGB:
db %11111000 ; 3, 3, 2, 0
db %11111100 ; 3, 3, 3, 0
db %11111111 ; 3, 3, 3, 3
db %11111100 ; 3, 3, 3, 0
db %11111000 ; 3, 3, 2, 0
db %11100100 ; 3, 2, 1, 0
db %10010000 ; 2, 1, 0, 0
db %01000000 ; 1, 0, 0, 0
db %00000000 ; 0, 0, 0, 0
db %01000000 ; 1, 0, 0, 0
db %10010000 ; 2, 1, 0, 0
db %11100100 ; 3, 2, 1, 0
db $01 ; terminator
dc 3, 3, 2, 0
dc 3, 3, 3, 0
dc 3, 3, 3, 3
dc 3, 3, 3, 0
dc 3, 3, 2, 0
dc 3, 2, 1, 0
dc 2, 1, 0, 0
dc 1, 0, 0, 0
dc 0, 0, 0, 0
dc 1, 0, 0, 0
dc 2, 1, 0, 0
dc 3, 2, 1, 0
db 1 ; end

; causes a delay of 2 frames for the first cycle
; causes a delay of 1 frame for the second and third cycles
Expand Down
24 changes: 12 additions & 12 deletions engine/battle/battle_transitions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,18 @@ BattleTransition_FlashScreen_:
ret

BattleTransition_FlashScreenPalettes:
db %11111001
db %11111110
db %11111111
db %11111110
db %11111001
db %11100100
db %10010000
db %01000000
db %00000000
db %01000000
db %10010000
db %11100100
dc 3, 3, 2, 1
dc 3, 3, 3, 2
dc 3, 3, 3, 3
dc 3, 3, 3, 2
dc 3, 3, 2, 1
dc 3, 2, 1, 0
dc 2, 1, 0, 0
dc 1, 0, 0, 0
dc 0, 0, 0, 0
dc 1, 0, 0, 0
dc 2, 1, 0, 0
dc 3, 2, 1, 0
db 1 ; end

; used for low level trainer dungeon battles
Expand Down
21 changes: 4 additions & 17 deletions engine/battle/scale_sprites.asm
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,8 @@ ScalePixelsByTwo:
add hl, bc ; add offset
ret

; repeats each input bit twice
; repeats each input bit twice, e.g. DuplicateBitsTable[%0101] = %00110011
DuplicateBitsTable:
db %00000000
db %00000011
db %00001100
db %00001111
db %00110000
db %00110011
db %00111100
db %00111111
db %11000000
db %11000011
db %11001100
db %11001111
db %11110000
db %11110011
db %11111100
db %11111111
FOR n, 16
db (n & 1) * 3 + (n & 2) * 6 + (n & 4) * 12 + (n & 8) * 24
ENDR
8 changes: 4 additions & 4 deletions engine/movie/credits.asm
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ ScrollCreditsMonLeft_SetSCX:
ret

HoFGBPalettes:
db %11000000
db %11010000
db %11100000
db %11110000
dc 3, 0, 0, 0
dc 3, 1, 0, 0
dc 3, 2, 0, 0
dc 3, 3, 0, 0

CreditsCopyTileMapToVRAM:
ld a, l
Expand Down
12 changes: 6 additions & 6 deletions engine/movie/oak_speech/oak_speech.asm
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ FadeInIntroPic:
ret

IntroFadePalettes:
db %01010100
db %10101000
db %11111100
db %11111000
db %11110100
db %11100100
dc 1, 1, 1, 0
dc 2, 2, 2, 0
dc 3, 3, 3, 0
dc 3, 3, 2, 0
dc 3, 3, 1, 0
dc 3, 2, 1, 0

MovePicLeft:
ld a, 119
Expand Down
19 changes: 3 additions & 16 deletions engine/overworld/sprite_collisions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -340,19 +340,6 @@ SetSpriteCollisionValues:
ret

SpriteCollisionBitTable:
db %00000000,%00000001
db %00000000,%00000010
db %00000000,%00000100
db %00000000,%00001000
db %00000000,%00010000
db %00000000,%00100000
db %00000000,%01000000
db %00000000,%10000000
db %00000001,%00000000
db %00000010,%00000000
db %00000100,%00000000
db %00001000,%00000000
db %00010000,%00000000
db %00100000,%00000000
db %01000000,%00000000
db %10000000,%00000000
FOR n, $10
bigdw 1 << n
ENDR
18 changes: 9 additions & 9 deletions home/fade.asm
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ GBFadeDecCommon:
jr nz, GBFadeDecCommon
ret

FadePal1:: db %11111111, %11111111, %11111111
FadePal2:: db %11111110, %11111110, %11111000
FadePal3:: db %11111001, %11100100, %11100100
FadePal4:: db %11100100, %11010000, %11100000
; rBGP rOBP0 rOBP1
FadePal5:: db %11100100, %11010000, %11100000
FadePal6:: db %10010000, %10000000, %10010000
FadePal7:: db %01000000, %01000000, %01000000
FadePal8:: db %00000000, %00000000, %00000000
FadePal1:: dc 3,3,3,3, 3,3,3,3, 3,3,3,3
FadePal2:: dc 3,3,3,2, 3,3,3,2, 3,3,2,0
FadePal3:: dc 3,3,2,1, 3,2,1,0, 3,2,1,0
FadePal4:: dc 3,2,1,0, 3,1,0,0, 3,2,0,0
; rBGP rOBP0 rOBP1
FadePal5:: dc 3,2,1,0, 3,1,0,0, 3,2,0,0
FadePal6:: dc 2,1,0,0, 2,0,0,0, 2,1,0,0
FadePal7:: dc 1,0,0,0, 1,0,0,0, 1,0,0,0
FadePal8:: dc 0,0,0,0, 0,0,0,0, 0,0,0,0
11 changes: 11 additions & 0 deletions macros/data.asm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ MACRO dn ; nybbles
ENDR
ENDM

MACRO dc ; "crumbs"
REPT _NARG / 4
db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4)
SHIFT 4
ENDR
ENDM

MACRO bigdw ; big-endian word
db HIGH(\1), LOW(\1)
ENDM

MACRO dba ; dbw bank, address
REPT _NARG
dbw BANK(\1), \1
Expand Down

0 comments on commit b066d3c

Please sign in to comment.