shithub: pokecrystal

Download patch

ref: 226d1812b34dad7ee0bb758c4c4970a731c9c79e
parent: 99f26a60973b33185d46720edfad8067c35e1a5a
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Thu Jan 18 06:16:24 EST 2018

Only graphics data goes in gfx/
Introduce PALRGB_WHITE constant for $7fff

--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -4,6 +4,8 @@
 
 NUM_PAL_COLORS EQU 4
 
+PALRGB_WHITE EQUS "palred 31 + palgreen 31 + palblue 31" ; $7fff
+
 SCREEN_WIDTH  EQU 20 ; tiles
 SCREEN_HEIGHT EQU 18 ; tiles
 SCREEN_WIDTH_PX  EQU SCREEN_WIDTH  * TILE_WIDTH ; pixels
--- /dev/null
+++ b/data/maps/sgb_roof_pal_inds.asm
@@ -1,0 +1,32 @@
+; Crystal does not support SGB, so this is unused.
+
+MapGroupRoofSGBPalInds: ; 8a45
+; entries correspond to map groups
+	db PREDEFPAL_00
+	db PREDEFPAL_OLIVINE
+	db PREDEFPAL_MAHOGANY
+	db PREDEFPAL_DUNGEONS
+	db PREDEFPAL_ECRUTEAK
+	db PREDEFPAL_BLACKTHORN
+	db PREDEFPAL_CINNABAR
+	db PREDEFPAL_CERULEAN
+	db PREDEFPAL_AZALEA
+	db PREDEFPAL_LAKE_OF_RAGE
+	db PREDEFPAL_VIOLET
+	db PREDEFPAL_GOLDENROD
+	db PREDEFPAL_VERMILION
+	db PREDEFPAL_PALLET
+	db PREDEFPAL_PEWTER
+	db PREDEFPAL_VERMILION
+	db PREDEFPAL_INDIGO
+	db PREDEFPAL_FUCHSIA
+	db PREDEFPAL_LAVENDER
+	db PREDEFPAL_SILVER_CAVE
+	db PREDEFPAL_FUCHSIA
+	db PREDEFPAL_CELADON
+	db PREDEFPAL_CIANWOOD
+	db PREDEFPAL_VIRIDIAN
+	db PREDEFPAL_NEW_BARK
+	db PREDEFPAL_SAFFRON
+	db PREDEFPAL_CHERRYGROVE
+; 8a60
--- /dev/null
+++ b/data/sgb_ctrl_packets.asm
@@ -1,0 +1,135 @@
+; macros taken from pokered's data/sgb_packets.asm
+; names taken from pandocs
+; http://gbdev.gg8.se/wiki/articles/SGB_Functions#SGB_Palette_Commands
+
+sgb_pal_trn: MACRO
+	db (SGB_PAL_TRN << 3) + 1
+	ds 15
+ENDM
+
+sgb_mlt_req: MACRO
+	db (SGB_MLT_REG << 3) + 1
+	db \1 - 1
+	ds 14
+ENDM
+
+sgb_chr_trn: MACRO
+	db (SGB_CHR_TRN << 3) + 1
+	db \1 + (\2 << 1)
+	ds 14
+ENDM
+
+sgb_pct_trn: MACRO
+	db (SGB_PCT_TRN << 3) + 1
+	ds 15
+ENDM
+
+sgb_mask_en: MACRO
+	db (SGB_MASK_EN << 3) + 1
+	db \1
+	ds 14
+ENDM
+
+sgb_data_snd: MACRO
+	db (SGB_DATA_SND << 3) + 1
+	dw \1 ; address
+	db \2 ; bank
+	db \3 ; length (1-11)
+ENDM
+
+
+; Crystal does not support SGB, so this is unused.
+
+PalTrnPacket:  sgb_pal_trn
+MltReq1Packet: sgb_mlt_req 1
+MltReq2Packet: sgb_mlt_req 2
+ChrTrnPacket:  sgb_chr_trn 0, 0
+PctTrnPacket:  sgb_pct_trn
+
+MaskEnFreezePacket: sgb_mask_en 1
+MaskEnCancelPacket: sgb_mask_en 0
+
+
+; These are packets containing SNES code.
+; This set of packets is found in several Japanese SGB-compatible titles.
+; It appears to be part of NCL's SGB devkit.
+
+DataSndPacket1:
+	sgb_data_snd $085d, $0, 11
+	db  $8c                 ; cpx #$8c (2)
+	db  $d0, $f4            ; bne -$0c
+	db  $60                 ; rts
+	ds  7
+
+DataSndPacket2:
+	sgb_data_snd $0852, $0, 11
+	db  $a9, $e7            ; lda #$e7
+	db  $9f, $01, $c0, $7e  ; sta $7ec001, x
+	db  $e8                 ; inx
+	db  $e8                 ; inx
+	db  $e8                 ; inx
+	db  $e8                 ; inx
+	db  $e0                 ; cpx #$8c (1)
+        
+DataSndPacket3:
+	sgb_data_snd $0847, $0, 11
+	db  $c4                 ; cmp #$c4 (2)
+	db  $d0, $16            ; bne +$16
+	db  $a5                 ; lda dp
+	db  $cb                 ; wai
+	db  $c9, $05            ; cmp #$05
+	db  $d0, $10            ; bne +$10
+	db  $a2, $28            ; ldx #$28
+        
+DataSndPacket4:
+	sgb_data_snd $083c, $0, 11
+	db  $f0, $12            ; beq +$12
+	db  $a5                 ; lda dp
+	db  $c9, $c9            ; cmp #$c9
+	db  $c8                 ; iny
+	db  $d0, $1c            ; bne +$1c
+	db  $a5                 ; lda dp
+	db  $ca                 ; dex
+	db  $c9                 ; cmp #$c4 (1)
+
+DataSndPacket5:
+	sgb_data_snd $0831, $0, 11
+	dbw $0c, $caa5          ; tsb $caa5
+	db  $c9, $7e            ; cmp #$7e
+	db  $d0, $06            ; bne +$06
+	db  $a5                 ; lda dp
+	db  $cb                 ; wai
+	db  $c9, $7e            ; cmp #$7e
+
+DataSndPacket6:
+	sgb_data_snd $0826, $0, 11
+	db  $39                 ; bne +$39 (2)
+	dbw $cd, $0c48          ; cmp $0c48
+	db  $d0, $34            ; bne +$34
+	db  $a5                 ; lda dp
+	db  $c9, $c9            ; cmp #$c9
+	db  $80, $d0            ; bra -$30
+
+DataSndPacket7:
+	sgb_data_snd $081b, $0, 11
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	                        ; $0820:
+	db  $a9, $01            ; lda #01
+	dbw $cd, $0c4f          ; cmp $c4f
+	db  $d0                 ; bne +$39 (1)
+
+DataSndPacket8:
+	sgb_data_snd $0810, $0, 11
+	dbw $4c, $0820          ; jmp $0820
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $ea                 ; nop
+	db  $60                 ; rts
+	db  $ea                 ; nop
+	db  $ea                 ; nop
--- a/engine/color.asm
+++ b/engine/color.asm
@@ -514,10 +514,10 @@
 	ld a, BANK(wBGPals1)
 	ld [rSVBK], a
 
-	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+	ld a, LOW(PALRGB_WHITE)
 	ld [de], a
 	inc de
-	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+	ld a, HIGH(PALRGB_WHITE)
 	ld [de], a
 	inc de
 
@@ -903,9 +903,9 @@
 	ld [rBGPI], a
 	ld c, 4 * 8
 .bgpals_loop
-	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+	ld a, LOW(PALRGB_WHITE)
 	ld [rBGPD], a
-	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+	ld a, HIGH(PALRGB_WHITE)
 	ld [rBGPD], a
 	dec c
 	jr nz, .bgpals_loop
@@ -913,9 +913,9 @@
 	ld [rOBPI], a
 	ld c, 4 * 8
 .obpals_loop
-	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+	ld a, LOW(PALRGB_WHITE)
 	ld [rOBPD], a
-	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+	ld a, HIGH(PALRGB_WHITE)
 	ld [rOBPD], a
 	dec c
 	jr nz, .obpals_loop
@@ -934,9 +934,9 @@
 .LoadWhitePals:
 	ld c, 4 * 16
 .loop
-	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+	ld a, LOW(PALRGB_WHITE)
 	ld [hli], a
-	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+	ld a, HIGH(PALRGB_WHITE)
 	ld [hli], a
 	dec c
 	jr nz, .loop
@@ -1189,7 +1189,7 @@
 
 INCLUDE "gfx/sgb/blk_packets.asm"
 INCLUDE "gfx/sgb/pal_packets.asm"
-INCLUDE "gfx/sgb/data_snd_packets.asm"
+INCLUDE "data/sgb_ctrl_packets.asm"
 
 PredefPals:
 INCLUDE "gfx/sgb/predef.pal"
--- a/engine/init_hof_credits.asm
+++ b/engine/init_hof_credits.asm
@@ -46,9 +46,9 @@
 	ld hl, wBGPals1
 	ld c, 4 tiles
 .load_white_palettes
-	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+	ld a, LOW(PALRGB_WHITE)
 	ld [hli], a
-	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+	ld a, HIGH(PALRGB_WHITE)
 	ld [hli], a
 	dec c
 	jr nz, .load_white_palettes
--- a/engine/sgb_layouts.asm
+++ b/engine/sgb_layouts.asm
@@ -595,7 +595,7 @@
 	ret
 ; 8a45
 
-INCLUDE "gfx/sgb/roof_pal_inds.asm"
+INCLUDE "data/maps/sgb_roof_pal_inds.asm"
 
 _LoadSGBLayout_ReturnFromJumpTable: ; 8a60
 	push de
--- a/gfx/sgb/data_snd_packets.asm
+++ /dev/null
@@ -1,95 +1,0 @@
-; macros taken from pokered's data/sgb_packets.asm
-; names taken from pandocs
-; http://gbdev.gg8.se/wiki/articles/SGB_Functions#SGB_Palette_Commands
-
-sgb_data_snd: MACRO
-	db (SGB_DATA_SND << 3) + 1
-	dw \1 ; address
-	db \2 ; bank
-	db \3 ; length (1-11)
-ENDM
-
-
-; These are packets containing SNES code.
-; This set of packets is found in several Japanese SGB-compatible titles.
-; It appears to be part of NCL's SGB devkit.
-
-DataSndPacket1:
-	sgb_data_snd $085d, $0, 11
-	db  $8c                 ; cpx #$8c (2)
-	db  $d0, $f4            ; bne -$0c
-	db  $60                 ; rts
-	ds  7
-
-DataSndPacket2:
-	sgb_data_snd $0852, $0, 11
-	db  $a9, $e7            ; lda #$e7
-	db  $9f, $01, $c0, $7e  ; sta $7ec001, x
-	db  $e8                 ; inx
-	db  $e8                 ; inx
-	db  $e8                 ; inx
-	db  $e8                 ; inx
-	db  $e0                 ; cpx #$8c (1)
-        
-DataSndPacket3:
-	sgb_data_snd $0847, $0, 11
-	db  $c4                 ; cmp #$c4 (2)
-	db  $d0, $16            ; bne +$16
-	db  $a5                 ; lda dp
-	db  $cb                 ; wai
-	db  $c9, $05            ; cmp #$05
-	db  $d0, $10            ; bne +$10
-	db  $a2, $28            ; ldx #$28
-        
-DataSndPacket4:
-	sgb_data_snd $083c, $0, 11
-	db  $f0, $12            ; beq +$12
-	db  $a5                 ; lda dp
-	db  $c9, $c9            ; cmp #$c9
-	db  $c8                 ; iny
-	db  $d0, $1c            ; bne +$1c
-	db  $a5                 ; lda dp
-	db  $ca                 ; dex
-	db  $c9                 ; cmp #$c4 (1)
-
-DataSndPacket5:
-	sgb_data_snd $0831, $0, 11
-	dbw $0c, $caa5          ; tsb $caa5
-	db  $c9, $7e            ; cmp #$7e
-	db  $d0, $06            ; bne +$06
-	db  $a5                 ; lda dp
-	db  $cb                 ; wai
-	db  $c9, $7e            ; cmp #$7e
-
-DataSndPacket6:
-	sgb_data_snd $0826, $0, 11
-	db  $39                 ; bne +$39 (2)
-	dbw $cd, $0c48          ; cmp $0c48
-	db  $d0, $34            ; bne +$34
-	db  $a5                 ; lda dp
-	db  $c9, $c9            ; cmp #$c9
-	db  $80, $d0            ; bra -$30
-
-DataSndPacket7:
-	sgb_data_snd $081b, $0, 11
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	                        ; $0820:
-	db  $a9, $01            ; lda #01
-	dbw $cd, $0c4f          ; cmp $c4f
-	db  $d0                 ; bne +$39 (1)
-
-DataSndPacket8:
-	sgb_data_snd $0810, $0, 11
-	dbw $4c, $0820          ; jmp $0820
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $ea                 ; nop
-	db  $60                 ; rts
-	db  $ea                 ; nop
-	db  $ea                 ; nop
--- a/gfx/sgb/pal_packets.asm
+++ b/gfx/sgb/pal_packets.asm
@@ -16,35 +16,7 @@
 	db (SGB_PAL23 << 3) + 1
 ENDM
 
-sgb_pal_trn: MACRO
-	db (SGB_PAL_TRN << 3) + 1
-	ds 15
-ENDM
 
-sgb_mlt_req: MACRO
-	db (SGB_MLT_REG << 3) + 1
-	db \1 - 1
-	ds 14
-ENDM
-
-sgb_chr_trn: MACRO
-	db (SGB_CHR_TRN << 3) + 1
-	db \1 + (\2 << 1)
-	ds 14
-ENDM
-
-sgb_pct_trn: MACRO
-	db (SGB_PCT_TRN << 3) + 1
-	ds 15
-ENDM
-
-sgb_mask_en: MACRO
-	db (SGB_MASK_EN << 3) + 1
-	db \1
-	ds 14
-ENDM
-
-
 PalPacket_GSTitleScreen:
 	sgb_pal_set GS_TITLE_SCREEN_0, GS_TITLE_SCREEN_1, GS_TITLE_SCREEN_2, GS_TITLE_SCREEN_3
 
@@ -108,6 +80,7 @@
 PalPacket_GamefreakLogo:
 	sgb_pal_set GS_INTRO_GAMEFREAK_LOGO, 00, 00, 00
 
+
 PalPacket_9ce6:
 	sgb_pal01
 	RGB 31, 31, 31
@@ -123,12 +96,3 @@
 	RGB 00, 00, 00
 endr
 	ds 1
-
-PalTrnPacket:  sgb_pal_trn
-MltReq1Packet: sgb_mlt_req 1
-MltReq2Packet: sgb_mlt_req 2
-ChrTrnPacket:  sgb_chr_trn 0, 0
-PctTrnPacket:  sgb_pct_trn
-
-MaskEnFreezePacket: sgb_mask_en 1
-MaskEnCancelPacket: sgb_mask_en 0
--- a/gfx/sgb/roof_pal_inds.asm
+++ /dev/null
@@ -1,32 +1,0 @@
-; Crystal does not support SGB, so this is unused.
-
-MapGroupRoofSGBPalInds: ; 8a45
-; entries correspond to map groups
-	db PREDEFPAL_00
-	db PREDEFPAL_OLIVINE
-	db PREDEFPAL_MAHOGANY
-	db PREDEFPAL_DUNGEONS
-	db PREDEFPAL_ECRUTEAK
-	db PREDEFPAL_BLACKTHORN
-	db PREDEFPAL_CINNABAR
-	db PREDEFPAL_CERULEAN
-	db PREDEFPAL_AZALEA
-	db PREDEFPAL_LAKE_OF_RAGE
-	db PREDEFPAL_VIOLET
-	db PREDEFPAL_GOLDENROD
-	db PREDEFPAL_VERMILION
-	db PREDEFPAL_PALLET
-	db PREDEFPAL_PEWTER
-	db PREDEFPAL_VERMILION
-	db PREDEFPAL_INDIGO
-	db PREDEFPAL_FUCHSIA
-	db PREDEFPAL_LAVENDER
-	db PREDEFPAL_SILVER_CAVE
-	db PREDEFPAL_FUCHSIA
-	db PREDEFPAL_CELADON
-	db PREDEFPAL_CIANWOOD
-	db PREDEFPAL_VIRIDIAN
-	db PREDEFPAL_NEW_BARK
-	db PREDEFPAL_SAFFRON
-	db PREDEFPAL_CHERRYGROVE
-; 8a60
--- a/mobile/mobile_42.asm
+++ b/mobile/mobile_42.asm
@@ -1484,7 +1484,7 @@
 	push af
 	ld a, $5
 	ld [rSVBK], a
-	ld de, palred 31 + palgreen 31 + palblue 31
+	ld de, PALRGB_WHITE
 	ld hl, wBGPals1
 	ld a, e
 	ld [hli], a
@@ -1525,7 +1525,7 @@
 	ld a, c
 	and $2
 	jr z, .Orange
-	ld de, palred 31 + palgreen 31 + palblue 31
+	ld de, PALRGB_WHITE
 	jr .load_pal
 
 .Orange:
--- a/mobile/mobile_45.asm
+++ b/mobile/mobile_45.asm
@@ -7611,9 +7611,9 @@
 	ld c, 8
 .loop
 	push hl
-	ld a, LOW(palred 31 + palgreen 31 + palblue 31)
+	ld a, LOW(PALRGB_WHITE)
 	ld [hli], a
-	ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
+	ld a, HIGH(PALRGB_WHITE)
 	ld [hl], a
 	pop hl
 	add hl, de