diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio/music1.asm | 4 | ||||
| -rw-r--r-- | src/engine/bank1.asm | 28 | ||||
| -rw-r--r-- | src/engine/bank1c.asm | 12 | ||||
| -rw-r--r-- | src/engine/bank2.asm | 66 | ||||
| -rw-r--r-- | src/engine/bank20.asm | 16 | ||||
| -rw-r--r-- | src/engine/bank3.asm | 20 | ||||
| -rw-r--r-- | src/engine/bank4.asm | 42 | ||||
| -rw-r--r-- | src/engine/bank6.asm | 14 | ||||
| -rw-r--r-- | src/engine/home.asm | 297 | ||||
| -rw-r--r-- | src/sram.asm | 2 | ||||
| -rw-r--r-- | src/vram.asm | 25 | 
11 files changed, 327 insertions, 199 deletions
| diff --git a/src/audio/music1.asm b/src/audio/music1.asm index c4ccf4b..9db9632 100644 --- a/src/audio/music1.asm +++ b/src/audio/music1.asm @@ -25,10 +25,10 @@ Func_f4015:: ; f4015 (3d:4015)  Func_f4018:: ; f4018 (3d:4018)  	jp Func_f406f -Func_f401b:: ; f401b (3d:401b) +_PauseSong:: ; f401b (3d:401b)  	jp Music1_PauseSong -Func_f401e:: ; f401e (3d:401e) +_ResumeSong:: ; f401e (3d:401e)  	jp Music1_ResumeSong  Music1_PlaySong: ; f4021 (3d:4021) diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index eedb048..fdf35c8 100644 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -5,12 +5,12 @@ Start_Cont: ; 4000 (1:4000)  	call ResetSerial  	call EnableInt_VBlank  	call EnableInt_Timer -	call EnableExtRAM +	call EnableSRAM  	ld a, [$a006]  	ld [wTextSpeed], a  	ld a, [$a009]  	ld [wccf2], a -	call DisableExtRAM +	call DisableSRAM  	ld a, $1  	ld [wUppercaseFlag], a  	ei @@ -27,10 +27,10 @@ Start_Cont: ; 4000 (1:4000)  	call YesOrNoMenuWithText  	jr c, .reset_game  ; erase sram -	call EnableExtRAM +	call EnableSRAM  	xor a  	ld [$a000], a -	call DisableExtRAM +	call DisableSRAM  .reset_game  	jp Reset @@ -1215,11 +1215,19 @@ Func_5aeb: ; 5aeb (1:5aeb)  	INCROM $5aeb, $6785  Func_6785: ; 6785 (1:6785) -	INCROM $6785, $6793 +	call EnableSRAM +	ld hl, $bc00 +	xor a +	ld [hli], a +	ld [hli], a +	ld [hl], a +	call DisableSRAM +	ret +; 0x6793  ; loads player deck from SRAM to wPlayerDeck  LoadPlayerDeck: ; 6793 (1:6793) -	call EnableExtRAM +	call EnableSRAM  	ld a, [$b700]  	ld l, a  	ld h, $54 @@ -1234,7 +1242,7 @@ LoadPlayerDeck: ; 6793 (1:6793)  	inc de  	dec c  	jr nz, .next_card_loop -	call DisableExtRAM +	call DisableSRAM  	ret  ; 0x67b2 @@ -1580,10 +1588,10 @@ _TossCoin: ; 71ad (1:71ad)  .asm_72ad  	add a  	ld d, a -	ld bc, $0202 -	ld hl, $0102 +	lb bc, 2, 2 +	lb hl, 1, 2  	pop af -	call Func_1f5f +	call FillRectangle  .asm_72b9  	ld hl, $cd9f diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm index 79994a3..1016ae8 100644 --- a/src/engine/bank1c.asm +++ b/src/engine/bank1c.asm @@ -89,7 +89,7 @@ Func_700a3: ; 700a3 (1c:40a3)  	ld a, [hli]  	ld h, [hl]  	ld l, a -	ld de, vTiles1 +	ld de, v0Tiles1  	call Func_701e9  	call Func_701fe  	ld hl, ChrTrnPacket_BGTiles1 @@ -105,7 +105,7 @@ Func_700a3: ; 700a3 (1c:40a3)  	jr z, .asm_700da  	call Func_70136  	dec hl -	ld de, vTiles1 +	ld de, v0Tiles1  	call Func_701e9  	ld hl, ChrTrnPacket_BGTiles2  	call Func_70177 @@ -136,10 +136,10 @@ Func_700fe: ; 700fe (1c:40fe)  	push hl  	call Func_70136  	pop hl -	ld de, vTiles1 +	ld de, v0Tiles1  	call Func_701e9  	pop hl -	ld de, vTiles2 +	ld de, v0Tiles2  	call Func_701e9  	call Func_701fe  	pop hl @@ -230,7 +230,7 @@ Func_701c0: ; 701c0 (1c:41c0)  	call DisableLCD  	xor a  	ld c, $10 -	ld hl, vTiles2 +	ld hl, v0Tiles2  .asm_701cb  	ld [hli], a  	dec c @@ -269,7 +269,7 @@ Func_701e9: ; 701e9 (1c:41e9)  	ret  Func_701fe: ; 701fe (1c:41fe) -	ld hl, vBGMapTiles +	ld hl, v0BGMapTiles1  	ld de, $000c  	ld a, $80  	ld c, $d diff --git a/src/engine/bank2.asm b/src/engine/bank2.asm index fea3d9b..f2a796c 100644 --- a/src/engine/bank2.asm +++ b/src/engine/bank2.asm @@ -2,7 +2,7 @@  Func_8cd4: ; 8cd4 (2:4cd4)  	push bc -	call EnableExtRAM +	call EnableSRAM  	ld b, $3c  .asm_8cda  	ld a, [de] @@ -12,7 +12,7 @@ Func_8cd4: ; 8cd4 (2:4cd4)  	jr nz, .asm_8cda  	xor a  	ld [hl], a -	call DisableExtRAM +	call DisableSRAM  	pop bc  	ret  ; 0x8ce7 @@ -20,7 +20,7 @@ Func_8cd4: ; 8cd4 (2:4cd4)  	INCROM $8ce7, $8cf9  Func_8cf9: ; 8cf9 (2:4cf9) -	call EnableExtRAM +	call EnableSRAM  	xor a  	ld hl, $b703  	ld [hli], a @@ -29,7 +29,7 @@ Func_8cf9: ; 8cf9 (2:4cf9)  	ld [hli], a  	ld [hl], a  	ld [$b701], a -	call DisableExtRAM +	call DisableSRAM  Func_8d0b: ; 8d0b (2:4d0b)  	ld hl, Unknown_8d15  	ld de, $9380 @@ -178,7 +178,7 @@ Func_8e42: ; 8e42 (2:4e42)  	call Func_92b4  	call Func_9345  	jr nc, .asm_8ec4 -	call EnableExtRAM +	call EnableSRAM  	ld hl, $cf17  	call Func_910a  	call Func_9048 @@ -200,7 +200,7 @@ Func_8e42: ; 8e42 (2:4e42)  	call Func_92ad  	call Func_9038  	ld a, [hl] -	call DisableExtRAM +	call DisableSRAM  	or a  	jr z, .asm_8edb  .asm_8ec4 @@ -262,10 +262,10 @@ Func_8f05: ; 8f05 (2:4f05)  Func_8f38: ; 8f38 (2:4f38)  	ld hl, $b701 -	call EnableExtRAM +	call EnableSRAM  	ld a, [hli]  	ld h, [hl] -	call DisableExtRAM +	call DisableSRAM  	ld l, a  	ld de, wc590  	call Func_0663 @@ -294,7 +294,7 @@ Func_8f38: ; 8f38 (2:4f38)  	xor a  	ld [hl], a  	ld hl, $b701 -	call EnableExtRAM +	call EnableSRAM  	ld e, [hl]  	inc hl  	ld d, [hl] @@ -310,7 +310,7 @@ Func_8f38: ; 8f38 (2:4f38)  	ld [hl], d  	dec hl  	ld [hl], e -	call DisableExtRAM +	call DisableSRAM  	ret  Func_8f8a: ; 8f8a (2:4f8a) @@ -323,28 +323,28 @@ Func_8f8a: ; 8f8a (2:4f8a)  	jp Func_8dbc  Func_8f9d: ; 8f9d (2:4f9d) -	call EnableExtRAM +	call EnableSRAM  	ld a, [$b700] -	call DisableExtRAM +	call DisableSRAM  	ld h, $3  	ld l, a  	call HtimesL  	ld e, l  	inc e -	ld d, $2 +	ld d, 2  	xor a -	ld hl, $0000 -	ld bc, $0202 -	call Func_1f5f +	lb hl, 0, 0 +	lb bc, 2, 2 +	call FillRectangle  	ld a, [wceb1] -	call EnableExtRAM +	call EnableSRAM  	ld [$b700], a -	call DisableExtRAM +	call DisableSRAM  	call Func_9326  	call Func_9038 -	call EnableExtRAM +	call EnableSRAM  	call Func_9253 -	call DisableExtRAM +	call DisableSRAM  	xor a  	ld [wce3f], a  	ld [wce40], a @@ -634,7 +634,7 @@ Func_9168: ; 9168 (2:5168)  	ld a, $1  	ld [wceb5], a  .asm_9214 -	call EnableExtRAM +	call EnableSRAM  	ld a, [$b700]  	ld c, a  	ld b, $0 @@ -656,7 +656,7 @@ Func_9168: ; 9168 (2:5168)  .asm_9234  	ld a, c  	ld [$b700], a -	call DisableExtRAM +	call DisableSRAM  	call Func_9326  	call EnableLCD  	ret @@ -720,9 +720,9 @@ Func_92ad: ; 92ad (2:52ad)  	jr Func_92ad  Func_92b4: ; 92b4 (2:52b4) -	call EnableExtRAM +	call EnableSRAM  	call Func_92ad -	call DisableExtRAM +	call DisableSRAM  	ret  ; 0x92be @@ -731,9 +731,9 @@ Func_92b4: ; 92b4 (2:52b4)  Func_9314: ; 9314 (2:5314)  	ld bc, $0018  	add hl, bc -	call EnableExtRAM +	call EnableSRAM  	ld a, [hl] -	call DisableExtRAM +	call DisableSRAM  	or a  	jr nz, .asm_9324  	scf @@ -743,19 +743,19 @@ Func_9314: ; 9314 (2:5314)  	ret  Func_9326: ; 9326 (2:5326) -	call EnableExtRAM +	call EnableSRAM  	ld a, [$b700] -	call DisableExtRAM -	ld h, $3 +	call DisableSRAM +	ld h, 3  	ld l, a  	call HtimesL  	ld e, l  	inc e -	ld d, $2 +	ld d, 2  	ld a, $38 -	ld hl, $0102 -	ld bc, $0202 -	call Func_1f5f +	lb hl, 1, 2 +	lb bc, 2, 2 +	call FillRectangle  	ret  Func_9345: ; 9345 (2:5345) diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index b551e73..480823f 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -64,9 +64,9 @@ Func_801a1: ; 801a1 (20:41a1)  	ld a, [$ff81]  	push af  	ld a, $1 -	call BankswitchRAM -	ld hl, vEnd -	ld de, vBGMapTiles +	call BankswitchSRAM +	ld hl, v0End +	ld de, v0BGMapTiles1  	ld c, $20  .asm_801b4  	push bc @@ -101,8 +101,8 @@ Func_801a1: ; 801a1 (20:41a1)  	dec c  	jr nz, .asm_801b4  	pop af -	call BankswitchRAM -	call DisableExtRAM +	call BankswitchSRAM +	call DisableSRAM  	pop de  	pop bc  	pop hl @@ -114,14 +114,14 @@ Func_801f1: ; 801f1 (20:41f1)  	ld a, [$ff81]  	push af  	ld a, $1 -	call BankswitchRAM +	call BankswitchSRAM  	ld hl, $a000  	ld bc, $0800  	xor a  	call $3c10  	pop af -	call BankswitchRAM -	call DisableExtRAM +	call BankswitchSRAM +	call DisableSRAM  	pop bc  	pop hl  	ret diff --git a/src/engine/bank3.asm b/src/engine/bank3.asm index c5e2fb4..614e995 100644 --- a/src/engine/bank3.asm +++ b/src/engine/bank3.asm @@ -1,8 +1,8 @@  LoadMap: ; c000 (3:4000)  	call DisableLCD -	call EnableExtRAM +	call EnableSRAM  	bank1call Func_6785 -	call DisableExtRAM +	call DisableSRAM  	ld a, $0  	ld [wd0b5], a  	xor a @@ -266,12 +266,12 @@ Func_c1f8: ; c1f8 (3:41f8)  	ld [wd111], a  	ld [wd112], a  	ld [wd3b8], a -	call EnableExtRAM +	call EnableSRAM  	ld a, [$a007]  	ld [wd421], a  	ld a, [$a006]  	ld [wTextSpeed], a -	call DisableExtRAM +	call DisableSRAM  	farcall Func_10756  	ret @@ -977,7 +977,7 @@ Func_c74d: ; c74d (3:474d)  	ret  MainMenu_c75a: ; c75a (3:475a) -	call Func_379b +	call PauseSong  	ld a, MUSIC_PAUSEMENU  	call PlaySong  	call Func_c797 @@ -1003,7 +1003,7 @@ MainMenu_c75a: ; c75a (3:475a)  	call Func_c32b  	jr .asm_c765  .asm_c793 -	call Func_37a0 +	call ResumeSong  	ret  Func_c797: ; c797 (3:4797) @@ -2645,7 +2645,7 @@ Func_d317: ; d317 (3:5317)  DeckMachine_d336: ; d336 (3:5336)  	push bc  	call Func_c2a3 -	call Func_379b +	call PauseSong  	ld a, MUSIC_DECKMACHINE  	call PlaySong  	call Func_04a2 @@ -2665,7 +2665,7 @@ DeckMachine_d336: ; d336 (3:5336)  .asm_d360  	farcall Func_b19d  .asm_d364 -	call Func_37a0 +	call ResumeSong  	call Func_c2d4  	jp IncreaseOWScriptPointerBy2 @@ -2777,11 +2777,11 @@ Func_d41d: ; d41d (3:541d)  	jp IncreaseOWScriptPointerBy1  Func_d423: ; d423 (3:5423) -	call Func_379b +	call PauseSong  	jp IncreaseOWScriptPointerBy1  Func_d429: ; d429 (3:5429) -	call Func_37a0 +	call ResumeSong  	jp IncreaseOWScriptPointerBy1  Func_d42f: ; d42f (3:542f) diff --git a/src/engine/bank4.asm b/src/engine/bank4.asm index 5aed479..c2de9b9 100644 --- a/src/engine/bank4.asm +++ b/src/engine/bank4.asm @@ -27,9 +27,9 @@ Func_10031: ; 10031 (4:4031)  	ld a, [$ff81]  	push af  	ld a, $1 -	call BankswitchRAM +	call BankswitchSRAM  	call $4cbb -	call DisableExtRAM +	call DisableSRAM  	call $4b28  	call SetFlushAllPalettes  	call EnableLCD @@ -37,8 +37,8 @@ Func_10031: ; 10031 (4:4031)  	call $4cea  	call SetFlushAllPalettes  	pop af -	call BankswitchRAM -	call DisableExtRAM +	call BankswitchSRAM +	call DisableSRAM  	ret  Func_10059: ; 10059 (4:4059) @@ -54,7 +54,7 @@ Medal_1029e: ; 1029e (4:429e)  	ld a, [wd291]  	push af  	push bc -	call Func_379b +	call PauseSong  	ld a, MUSIC_STOP  	call PlaySong  	farcall Func_70000 @@ -93,7 +93,7 @@ Medal_1029e: ; 1029e (4:429e)  	ldtx hl, WonTheMedalText  	call Func_2c73  	call Func_3c96 -	call Func_37a0 +	call ResumeSong  	pop af  	ld [wd291], a  	ret @@ -136,7 +136,7 @@ BoosterPack_1031b: ; 1031b (4:431b)  	ld a, [hl]  	ld [wce40], a  	call $4031 -	call Func_379b +	call PauseSong  	ld a, MUSIC_BOOSTERPACK  	call PlaySong  	pop bc @@ -150,7 +150,7 @@ BoosterPack_1031b: ; 1031b (4:431b)  .asm_10373  	call Func_2c73  	call Func_3c96 -	call Func_37a0 +	call ResumeSong  	ldtx hl, CheckedCardsInBoosterPackText  	call Func_2c73  	call DisableLCD @@ -290,7 +290,7 @@ Func_10c96: ; 10c96 (4:4c96)  	push af  	push bc  	ld a, $1 -	call BankswitchRAM +	call BankswitchSRAM  	call $4cbb  	call Func_10ab4  	pop bc @@ -303,8 +303,8 @@ Func_10c96: ; 10c96 (4:4c96)  .asm_10cb0  	call EnableLCD  	pop af -	call BankswitchRAM -	call DisableExtRAM +	call BankswitchSRAM +	call DisableSRAM  	ret  ; 0x10cbb @@ -1104,12 +1104,12 @@ Func_12704: ; 12704 (4:6704)  	farcall Func_c1b1  	call Func_128a9  	farcall Func_1996e -	call EnableExtRAM +	call EnableSRAM  	ld a, [$a007]  	ld [wd421], a  	ld a, [$a006]  	ld [wTextSpeed], a -	call DisableExtRAM +	call DisableSRAM  	ld a, MUSIC_STOP  	call PlaySong  	farcall Func_70000 @@ -1130,10 +1130,10 @@ Func_12741: ; 12741 (4:6741)  	jr nc, Func_12704  	farcall Func_c1ed  	farcall Func_70000 -	call EnableExtRAM +	call EnableSRAM  	xor a  	ld [$ba44], a -	call DisableExtRAM +	call DisableSRAM  	ld a, $0  	ld [wd0b5], a  	farcallx $03, Func_383d @@ -1499,20 +1499,20 @@ Func_131d3: ; 131d3 (4:71d3)  	INCROM $131d3, $1344d  Func_1344d: ; 1344d (4:744d) -	call Func_379b +	call PauseSong  	ld a, MUSIC_MEDAL  	call PlaySong  	ldtx hl, DefeatedFiveOpponentsText  	call Func_2c73  	call Func_3c96 -	call Func_37a0 +	call ResumeSong  	ret  ; 0x13462  	INCROM $13462, $13485  Func_13485: ; 13485 (4:7485) -	call EnableExtRAM +	call EnableSRAM  	ld a, [$ba68]  	or a  	ret z @@ -1520,14 +1520,14 @@ Func_13485: ; 13485 (4:7485)  	ld [wce43], a  	ld a, [$ba57]  	ld [wce44], a -	call DisableExtRAM -	call Func_379b +	call DisableSRAM +	call PauseSong  	ld a, MUSIC_MEDAL  	call PlaySong  	ldtx hl, ConsecutiveWinRecordIncreasedText  	call Func_2c73  	call Func_3c96 -	call Func_37a0 +	call ResumeSong  	ret  ; 0x134b1 diff --git a/src/engine/bank6.asm b/src/engine/bank6.asm index 6428c3f..fa1c529 100644 --- a/src/engine/bank6.asm +++ b/src/engine/bank6.asm @@ -5,7 +5,7 @@ INCLUDE "data/effect_commands.asm"  	INCROM $18f9c, $1996e  Func_1996e: ; 1996e (6:596e) -	call EnableExtRAM +	call EnableSRAM  	ld a, PLAYER_TURN  	ldh [hWhoseTurn], a  	ld hl, $a100 @@ -26,7 +26,7 @@ Func_1996e: ; 1996e (6:596e)  	ld a, $9  	ld hl, $a3f8  	call Func_199e0 -	call EnableExtRAM +	call EnableSRAM  	ld hl, $a100  	ld a, $80  .asm_199a2 @@ -58,7 +58,7 @@ Func_1996e: ; 1996e (6:596e)  	ld [$a005], a  	ld [$a00a], a  	farcall Func_8cf9 -	call DisableExtRAM +	call DisableSRAM  	ret  Func_199e0: ; 199e0 (6:59e0) @@ -69,7 +69,7 @@ Func_199e0: ; 199e0 (6:59e0)  	jr c, .asm_19a0e  	call Func_19a12  	pop hl -	call EnableExtRAM +	call EnableSRAM  	push hl  	ld de, wc590  .asm_199f3 @@ -90,7 +90,7 @@ Func_199e0: ; 199e0 (6:59e0)  	ld [hli], a  	dec c  	jr nz, .asm_19a04 -	call DisableExtRAM +	call DisableSRAM  	or a  .asm_19a0e  	pop hl @@ -146,7 +146,7 @@ Func_1a61f: ; 1a61f (6:661f)  	ld e, a  	ld d, $0  	call LoadCardDataToBuffer1 -	call Func_379b +	call PauseSong  	ld a, MUSIC_MEDAL  	call PlaySong  	ld hl, $cc27 @@ -162,7 +162,7 @@ Func_1a61f: ; 1a61f (6:661f)  	call Func_378a  	or a  	jr nz, .asm_1a680 -	call Func_37a0 +	call ResumeSong  	bank1call $5773  	ret  ; 0x1a68d diff --git a/src/engine/home.asm b/src/engine/home.asm index cd10623..5a9a7a7 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -45,7 +45,7 @@ Start: ; 0150 (0:0150)  	ld a, $1  	call BankswitchHome  	xor a -	call BankswitchRAM +	call BankswitchSRAM  	call BankswitchVRAM_0  	call DisableLCD  	pop af @@ -198,7 +198,7 @@ SetupTimer: ; 0241 (0:0241)  	ld [rTAC], a  	ret -; carry flag: 0 if CGB +; return carry if not CGB  CheckForCGB: ; 025c (0:025c)  	ld a, [wConsole]  	cp CONSOLE_CGB @@ -411,50 +411,51 @@ InitialPalette: ; 0399 (0:0399)  	rgb 10,10,08  	rgb 00,00,00 +; clear VRAM tile data  SetupVRAM: ; 03a1 (0:03a1)  	call FillTileMap  	call CheckForCGB -	jr c, .asm_3b2 +	jr c, .vram0  	call BankswitchVRAM_1 -	call .asm_3b2 +	call .vram0  	call BankswitchVRAM_0 -.asm_3b2 -	ld hl, vTiles0 -	ld bc, vBGMapTiles - vTiles0 -.asm_3b8 +.vram0 +	ld hl, v0Tiles0 +	ld bc, v0BGMapTiles1 - v0Tiles0 +.loop  	xor a  	ld [hli], a  	dec bc  	ld a, b  	or c -	jr nz, .asm_3b8 +	jr nz, .loop  	ret -; fill VARM tile map banks with [wTileMapFill] +; fill VRAM0 BG maps with [wTileMapFill] and VRAM1 BG Maps with 0  FillTileMap: ; 03c0 (0:03c0)  	call BankswitchVRAM_0 -	ld hl, vBGMapTiles -	ld bc, vBGMapAttrs - vBGMapTiles -.asm_3c9 +	ld hl, v0BGMapTiles1 +	ld bc, v0BGMapTiles2 - v0BGMapTiles1 +.vram0_loop  	ld a, [wTileMapFill]  	ld [hli], a  	dec bc  	ld a, c  	or b -	jr nz, .asm_3c9 +	jr nz, .vram0_loop  	ld a, [wConsole]  	cp CONSOLE_CGB  	ret nz  	call BankswitchVRAM_1 -	ld hl, vBGMapTiles -	ld bc, vBGMapAttrs - vBGMapTiles -.asm_3e1 +	ld hl, v1BGMapTiles1 +	ld bc, v1BGMapTiles2 - v1BGMapTiles1 +.vram1_loop  	xor a  	ld [hli], a  	dec bc  	ld a, c  	or b -	jr nz, .asm_3e1 +	jr nz, .vram1_loop  	call BankswitchVRAM_0  	ret @@ -641,7 +642,7 @@ AttrBlkPacket_04bf: ; 04bf (0:04bf)  	ds 6 ; data set 2  	ds 2 ; data set 3 -; returns vBGMapTiles + BG_MAP_WIDTH * c + b in de. +; returns v0BGMapTiles1 + BG_MAP_WIDTH * c + b in de.  ; used to map coordinates at bc to a BGMap0 address.  BCCoordToBGMap0Address: ; 04cf (0:04cf)  	ld l, c @@ -652,7 +653,7 @@ BCCoordToBGMap0Address: ; 04cf (0:04cf)  	add hl, hl  	add hl, hl  	ld c, b -	ld b, HIGH(vBGMapTiles) +	ld b, HIGH(v0BGMapTiles1)  	add hl, bc  	ld e, l  	ld d, h @@ -1217,8 +1218,8 @@ BankswitchHome: ; 07a3 (0:07a3)  	ld [MBC3RomBank], a  	ret -; switch RAM bank -BankswitchRAM: ; 07a9 (0:07a9) +; switch SRAM bank +BankswitchSRAM: ; 07a9 (0:07a9)  	push af  	ldh [hBankRAM], a  	ld [MBC3SRamBank], a @@ -1228,7 +1229,7 @@ BankswitchRAM: ; 07a9 (0:07a9)  	ret  ; enable external RAM -EnableExtRAM: ; 07b6 (0:07b6) +EnableSRAM: ; 07b6 (0:07b6)  	push af  	ld a, SRAM_ENABLE  	ld [MBC3SRamEnable], a @@ -1236,7 +1237,7 @@ EnableExtRAM: ; 07b6 (0:07b6)  	ret  ; disable external RAM -DisableExtRAM: ; 07be (0:07be) +DisableSRAM: ; 07be (0:07be)  	push af  	xor a ; SRAM_DISABLE  	ld [MBC3SRamEnable], a @@ -1303,7 +1304,7 @@ CGBSpeedSwitch: ; 07f1 (0:07f1)  SetupExtRAM: ; 080b (0:080b)  	xor a -	call BankswitchRAM +	call BankswitchSRAM  	ld hl, $a000  	ld bc, $1000  .asm_815 @@ -1320,7 +1321,7 @@ SetupExtRAM: ; 080b (0:080b)  	call Func_084d  	scf  	call Func_4050 -	call DisableExtRAM +	call DisableSRAM  	ret  .asm_82f  	ld hl, $a000 @@ -1338,7 +1339,7 @@ SetupExtRAM: ; 080b (0:080b)  	call Func_084d  	or a  	call Func_4050 -	call DisableExtRAM +	call DisableSRAM  	ret  Func_084d: ; 084d (0:084d) @@ -1358,8 +1359,8 @@ Func_084d: ; 084d (0:084d)  ClearExtRAMBank: ; 0863 (0:0863)  	push af -	call BankswitchRAM -	call EnableExtRAM +	call BankswitchSRAM +	call EnableSRAM  	ld hl, $a000  	ld bc, $2000  .asm_870 @@ -1875,8 +1876,8 @@ Func_0bcb: ; 0bcb (0:0bcb)  	ld [rLCDC], a  	ld a, %11100100  	ld [rBGP], a -	ld de, vTiles1 -	ld bc, vBGMapTiles - vTiles1 +	ld de, v0Tiles1 +	ld bc, v0BGMapTiles1 - v0Tiles1  .loop  	ld a, [hli]  	ld [de], a @@ -1885,7 +1886,7 @@ Func_0bcb: ; 0bcb (0:0bcb)  	ld a, b  	or c  	jr nz, .loop -	ld hl, vBGMapTiles +	ld hl, v0BGMapTiles1  	ld de, $000c  	ld a, $80  	ld c, $d @@ -2519,15 +2520,15 @@ Func_0fe9: ; 0fe9 (0:0fe9)  Func_100b: ; 100b (0:100b)  	ld a, $2 -	call BankswitchRAM +	call BankswitchSRAM  	call $669d  	xor a -	call BankswitchRAM -	call EnableExtRAM +	call BankswitchSRAM +	call EnableSRAM  	ld hl, $a008  	ld a, [hl]  	inc [hl] -	call DisableExtRAM +	call DisableSRAM  	and $3  	add $28  	ld l, $0 @@ -2535,7 +2536,7 @@ Func_100b: ; 100b (0:100b)  	add hl, hl  	add hl, hl  	ld a, $3 -	call BankswitchRAM +	call BankswitchSRAM  	push hl  	ld a, DUELVARS_ARENA_CARD  	call GetTurnDuelistVariable @@ -2551,7 +2552,7 @@ Func_100b: ; 100b (0:100b)  	call SwapTurn  	pop hl  	push hl -	call EnableExtRAM +	call EnableSRAM  	ld a, [wcc06]  	ld [hli], a  	ld a, [wTempNonTurnDuelistCardId] @@ -2563,10 +2564,10 @@ Func_100b: ; 100b (0:100b)  	add hl, de  	ld e, l  	ld d, h -	call DisableExtRAM +	call DisableSRAM  	bank1call $66a4  	xor a -	call BankswitchRAM +	call BankswitchSRAM  	ret  ; copies the deck pointed to by de to wPlayerDeck or wOpponentDeck @@ -3707,7 +3708,7 @@ SwapTurn: ; 1c72 (0:1c72)  	ret  PrintPlayerName: ; 1c7d (0:1c7d) -	call EnableExtRAM +	call EnableSRAM  	ld hl, $a010  .loop  	ld a, [hli] @@ -3716,7 +3717,7 @@ PrintPlayerName: ; 1c7d (0:1c7d)  	or a  	jr nz, .loop  	dec de -	call DisableExtRAM +	call DisableSRAM  	ret  PrintOpponentName: ; 1c8e (0:1c8e) @@ -3741,7 +3742,7 @@ PrintOpponentName: ; 1c8e (0:1c8e)  Func_1caa: ; 1caa (0:1caa)  	push de  	push bc -	call EnableExtRAM +	call EnableSRAM  	ld hl, $0000  	ld de, sDeck1Cards  	ld c, $4 @@ -3775,7 +3776,7 @@ Func_1caa: ; 1caa (0:1caa)  .asm_1cd8  	inc e  	jr nz, .asm_1ccf -	call DisableExtRAM +	call DisableSRAM  	pop bc  	pop de  	ret @@ -3784,7 +3785,7 @@ Func_1ce1: ; 1ce1 (0:1ce1)  	push hl  	push de  	push bc -	call EnableExtRAM +	call EnableSRAM  	ld c, a  	ld b, $0  	ld hl, sDeck1Cards @@ -3822,7 +3823,7 @@ Func_1ce1: ; 1ce1 (0:1ce1)  .asm_1d11  	and $7f -	call DisableExtRAM +	call DisableSRAM  	pop bc  	pop de  	pop hl @@ -3833,11 +3834,11 @@ Func_1ce1: ; 1ce1 (0:1ce1)  Func_1d1d: ; 1d1d (0:1d1d)  	push hl -	call EnableExtRAM +	call EnableSRAM  	ld h, $a1  	ld l, a  	ld a, [hl] -	call DisableExtRAM +	call DisableSRAM  	pop hl  	and $7f  	ret nz @@ -3846,7 +3847,7 @@ Func_1d1d: ; 1d1d (0:1d1d)  ; creates a list at $c000 of every card the player owns and how many  CreateTempCardCollection: ; 1d2e (0:1d2e) -	call EnableExtRAM +	call EnableSRAM  	ld hl, sCardCollection  	ld de, wTempCardCollection  	ld bc, CARD_COLLECTION_SIZE @@ -3859,7 +3860,7 @@ CreateTempCardCollection: ; 1d2e (0:1d2e)  	call AddDeckCardsToTempCardCollection  	ld de, sDeck4Name  	call AddDeckCardsToTempCardCollection -	call DisableExtRAM +	call DisableSRAM  	ret  AddDeckCardsToTempCardCollection: ; 1d59 (0:1d59) @@ -3890,7 +3891,7 @@ AddCardToCollection: ; 1d6e (0:1d6e)  	push hl  	call CreateTempCardCollection  	pop hl -	call EnableExtRAM +	call EnableSRAM  	ld h, wTempCardCollection >> 8  	ld a, [hl]  	and $7f @@ -3902,7 +3903,7 @@ AddCardToCollection: ; 1d6e (0:1d6e)  	inc a  	ld [hl], a  .asm_1d8a -	call DisableExtRAM +	call DisableSRAM  	pop bc  	pop de  	pop hl @@ -3910,7 +3911,7 @@ AddCardToCollection: ; 1d6e (0:1d6e)  Func_1d91: ; 1d91 (0:1d91)  	push hl -	call EnableExtRAM +	call EnableSRAM  	ld h, $a1  	ld l, a  	ld a, [hl] @@ -3920,7 +3921,7 @@ Func_1d91: ; 1d91 (0:1d91)  	ld [hl], a  .asm_1d9f -	call DisableExtRAM +	call DisableSRAM  	pop hl  	ret  ; 0x1da4 @@ -3943,7 +3944,7 @@ SafeCopyDataDEtoHL: ; 1dca (0:1dca)  .lcd_on  	jp HblankCopyDataDEtoHL -; returns vBGMapTiles + BG_MAP_WIDTH * e + d in hl. +; returns v0BGMapTiles1 + BG_MAP_WIDTH * e + d in hl.  ; used to map coordinates at de to a BGMap0 address.  DECoordToBGMap0Address: ; 1ddb (0:1ddb)  	ld l, e @@ -3957,7 +3958,7 @@ DECoordToBGMap0Address: ; 1ddb (0:1ddb)  	add d  	ld l, a  	ld a, h -	adc HIGH(vBGMapTiles) +	adc HIGH(v0BGMapTiles1)  	ld h, a  	ret @@ -4106,7 +4107,7 @@ ContinueDrawingTextBoxDMGorSGB:  	lb de, $1a, $1b  ;	fallthrough -; copies b bytes of data to sp+$1c and to hl, and returns hl += BG_MAP_WIDTH +; copies b bytes of data to sp-$1f and to hl, and returns hl += BG_MAP_WIDTH  ; d = value of byte 0  ; e = value of byte b  ; a = value of bytes [1, b-1] @@ -4246,13 +4247,18 @@ AttrBlkPacket_1f4f: ; 1f4f (0:1f4f)  	ds 6 ; data set 2  	ds 2 ; data set 3 -Func_1f5f: ; 1f5f (0:1f5f) +; Fill a bxc rectangle at de and at sp-$26, +; using tile a and the subsequent ones in the following pattern: +; | a+0*l+0*h | a+0*l+1*h | a+0*l+2*h | +; | a+1*l+0*h | a+1*l+1*h | a+1*l+2*h | +; | a+2*l+0*h | a+2*l+1*h | a+2*l+2*h | +FillRectangle: ; 1f5f (0:1f5f)  	push de  	push af  	push hl -	add sp, $e0 +	add sp, -BG_MAP_WIDTH  	call DECoordToBGMap0Address -.asm_1f67 +.next_row  	push hl  	push bc  	ld hl, sp+$25 @@ -4261,18 +4267,18 @@ Func_1f5f: ; 1f5f (0:1f5f)  	ld a, [hl]  	ld hl, sp+$4  	push hl -.asm_1f72 +.next_tile  	ld [hli], a  	add d  	dec b -	jr nz, .asm_1f72 +	jr nz, .next_tile  	pop de  	pop bc  	pop hl  	push hl  	push bc  	ld c, b -	ld b, $0 +	ld b, 0  	call SafeCopyDataDEtoHL  	ld hl, sp+$24  	ld a, [hl] @@ -4281,10 +4287,10 @@ Func_1f5f: ; 1f5f (0:1f5f)  	ld [hl], a  	pop bc  	pop de -	ld hl, $0020 +	ld hl, BG_MAP_WIDTH  	add hl, de  	dec c -	jr nz, .asm_1f67 +	jr nz, .next_row  	add sp, $24  	pop de  	ret @@ -4299,7 +4305,7 @@ Func_20b0: ; 20b0 (0:20b0)  	jr nz, .asm_20bd  	ld hl, DuelGraphics + $e90 - $4000  .asm_20bd -	ld de, vTiles1 + $500 +	ld de, v0Tiles1 + $500  	ld b, $30  	jr CopyFontsOrDuelGraphicsTiles @@ -4310,7 +4316,7 @@ Func_20c4: ; 20c4 (0:20c4)  	jr nz, .copy  	ld hl, DuelGraphics + $ed0 - $4000  .copy -	ld de, vTiles1 + $540 +	ld de, v0Tiles1 + $540  	ld b, $c  	jr CopyFontsOrDuelGraphicsTiles @@ -4327,12 +4333,12 @@ asm_20de  	jr nz, .copy  	ld hl, DuelGraphics + $1190 - $4000  .copy -	ld de, vTiles1 + $500 +	ld de, v0Tiles1 + $500  	jr CopyFontsOrDuelGraphicsTiles  Func_20f0: ; 20f0 (0:20f0)  	ld hl, Fonts + $8 -	ld de, vTiles1 + $200 +	ld de, v0Tiles1 + $200  	ld b, $d  	call CopyFontsOrDuelGraphicsTiles  	ld hl, DuelGraphics + $bc0 - $4000 @@ -4341,24 +4347,24 @@ Func_20f0: ; 20f0 (0:20f0)  	jr nz, .copy  	ld hl, DuelGraphics + $13d0 - $4000  .copy -	ld de, vTiles1 + $500 +	ld de, v0Tiles1 + $500  	ld b, $30  	jr CopyFontsOrDuelGraphicsTiles  Func_210f: ; 210f (0:210f)  	ld hl, DuelGraphics + $1770 - $4000 -	ld de, vTiles2 + $300 +	ld de, v0Tiles2 + $300  	ld b, $8  	jr CopyFontsOrDuelGraphicsTiles  Func_2119: ; 2119 (0:2119)  	ld hl, DuelGraphics - $4000 -	ld de, vTiles2 ; destination +	ld de, v0Tiles2 ; destination  	ld b, $38 ; number of tiles  ;	fallthrough  ; if hl ≤ $3fff -;   copy b tiles from Gfx1:hl to de +;   copy b tiles from Gfx1:(hl+$4000) to de  ; if $4000 ≤ hl ≤ $7fff  ;   copy b tiles from Gfx2:hl to de  CopyFontsOrDuelGraphicsTiles: @@ -4370,7 +4376,34 @@ CopyFontsOrDuelGraphicsTiles:  	ret  ; 0x212f -	INCROM $212f, $2167 +; this function appears to copy duel gfx data into sram +Func_212f: ; 212f (0:212f) +	ld hl, DuelGraphics - $4000 +	ld de, $a400 +	ld b, $30 +	call CopyFontsOrDuelGraphicsTiles +	ld hl, DuelGraphics + $17f0 - $4000 +	ld de, $a700 +	ld b, $08 +	call CopyFontsOrDuelGraphicsTiles +	call GetCardSymbolData +	sub $d0 +	ld l, a +	ld h, $00 +	add hl, hl +	add hl, hl +	add hl, hl +	add hl, hl +	ld de, DuelGraphics + $680 - $4000 +	add hl, de +	ld de, $a780 +	ld b, $04 +	call CopyFontsOrDuelGraphicsTiles +	ld hl, DuelGraphics + $680 - $4000 +	ld de, $b100 +	ld b, $30 +	jr CopyFontsOrDuelGraphicsTiles +; 0x2167  DrawDuelBoxMessage: ; 2167 (0:2167)  	ld l, a @@ -4381,14 +4414,14 @@ DrawDuelBoxMessage: ; 2167 (0:2167)  	; hl = a * $280  	ld de, DuelBoxMessages  	add hl, de -	ld de, vTiles1 + $200 +	ld de, v0Tiles1 + $200  	ld b, $28  	call CopyFontsOrDuelGraphicsTiles  	ld a, $a0 -	ld hl, $010a -	ld bc, $0a04 +	lb hl, 1, 10 +	lb bc, 10, 4  	lb de, 5, 4 -	jp Func_1f5f +	jp FillRectangle  ; 0x2189  	INCROM $2189, $21c5 @@ -4604,7 +4637,7 @@ Func_22f2: ; 22f2 (0:22f2)  	ld l, e  	ld h, d  	ld de, $cd05 -	ld c, $1 +	ld c, 1  	call SafeCopyDataDEtoHL  	ld hl, $ffac  	inc [hl] @@ -5253,7 +5286,83 @@ Func_271a: ; 271a (0:271a)  	ret  ; 0x278d -	INCROM $278d, $29f5 +	INCROM $278d, $2988 + +CardTypeToSymbolID: ; 2988 (0:2988) +	ld a, [wLoadedCard1Type] +	cp TYPE_TRAINER +	jr nc, .trainer_card +	cp TYPE_ENERGY_FIRE +	jr c, .pokemon_card +	; energy card +	and 7 ; convert energy constant to type constant +	ret +.trainer_card +	ld a, 11 +	ret +.pokemon_card +	ld a, [wLoadedCard1Stage] +	add 8 +	ret +; 0x299f + +GetCardSymbolData: ; 299f (0:299f) +	call CardTypeToSymbolID +	add a +	ld c, a +	ld b, 0 +	ld hl, CardSymbolTable +	add hl, bc +	ld a, [hl] +	ret +; 0x29ac + +DrawCardSymbol: ; 29ac (0:29ac) +	push hl +	push de +	push bc +	call GetCardSymbolData +	dec d +	dec d +	dec e +	ld a, [wConsole] +	cp CONSOLE_CGB +	jr nz, .tiles +	; CGB-only attrs (palette) +	push hl +	inc hl +	ld a, [hl] +	lb bc, 2, 2 +	lb hl, 0, 0 +	call BankswitchVRAM_1 +	call FillRectangle +	call BankswitchVRAM_0 +	pop hl +.tiles +	ld a, [hl] +	lb hl, 1, 2 +	lb bc, 2, 2 +	call FillRectangle +	pop bc +	pop de +	pop hl +	ret +; 0x29dd + +CardSymbolTable: +; starting tile, cgb palette (grey, red, blue, pink) +	db $e0, $01 ; TYPE_ENERGY_FIRE +	db $e4, $02 ; TYPE_ENERGY_GRASS +	db $e8, $01 ; TYPE_ENERGY_LIGHTNING +	db $ec, $02 ; TYPE_ENERGY_WATER +	db $f0, $03 ; TYPE_ENERGY_PSYCHIC +	db $f4, $03 ; TYPE_ENERGY_FIGHTING +	db $f8, $00 ; TYPE_ENERGY_DOUBLE_COLORLESS +	db $fc, $02 ; TYPE_ENERGY_UNUSED +	db $d0, $02 ; TYPE_PKMN_*, Stage 0 +	db $d4, $02 ; TYPE_PKMN_*, Stage 1 +	db $d8, $01 ; TYPE_PKMN_*, Stage 2 +	db $dc, $02 ; TYPE_TRAINER  Func_29f5: ; 29f5 (0:29f5)  	farcallx $6, $4000 @@ -7321,12 +7430,12 @@ PlaySFX: ; 3796 (0:3796)  	farcall _PlaySFX  	ret -Func_379b: ; 379b (0:379b) -	farcall Func_f401b +PauseSong: ; 379b (0:379b) +	farcall _PauseSong  	ret -Func_37a0: ; 37a0 (0:37a0) -	farcall Func_f401e +ResumeSong: ; 37a0 (0:37a0) +	farcall _ResumeSong  	ret  ; 0x37a5 @@ -7395,7 +7504,7 @@ Func_3874: ; 3874 (0:3874)  Func_3876: ; 3876 (0:3876)  	ldh a, [hBankROM]  	push af -	call Func_379b +	call PauseSong  	ld a, MUSIC_CARDPOP  	call PlaySong  	ld a, $3 @@ -7407,7 +7516,7 @@ Func_3876: ; 3876 (0:3876)  	ld a, [wd10e]  	and $ef  	ld [wd10e], a -	call Func_37a0 +	call ResumeSong  	pop af  	call BankswitchHome  	scf @@ -7433,10 +7542,10 @@ Func_38c0: ; 38c0 (0:38c0)  	ld [wd0c2], a  	xor a  	ld [wd112], a -	call EnableExtRAM +	call EnableSRAM  	xor a  	ld [$ba44], a -	call DisableExtRAM +	call DisableSRAM  	call Func_3a3b  	bank1call StartDuel  	scf @@ -7446,10 +7555,10 @@ Func_38db: ; 38db (0:38db)  	ld a, $6  	ld [wd111], a  	call Func_39fc -	call EnableExtRAM +	call EnableSRAM  	xor a  	ld [$ba44], a -	call DisableExtRAM +	call DisableSRAM  asm_38ed  	farcall Func_131d3  	ld a, $9 @@ -7462,9 +7571,9 @@ Func_38fb: ; 38fb (0:38fb)  	xor a  	ld [wd112], a  	bank1call Func_406f -	call EnableExtRAM +	call EnableSRAM  	ld a, [$ba44] -	call DisableExtRAM +	call DisableSRAM  	cp $ff  	jr z, asm_38ed  	scf @@ -7478,9 +7587,9 @@ Credits_3911: ; 3911 (0:3911)  Func_3917: ; 3917 (0:3917)  	ld a, $22  	farcall CheckIfEventFlagSet -	call EnableExtRAM +	call EnableSRAM  	ld [$a00a], a -	call DisableExtRAM +	call DisableSRAM  	ret  GetFloorObjectFromPos: ; 3927 (0:3927) diff --git a/src/sram.asm b/src/sram.asm index 40e1f93..1a0bf38 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -1,4 +1,4 @@ -SECTION "Working Cards", SRAM +SECTION "SRAM", SRAM  	ds $100 diff --git a/src/vram.asm b/src/vram.asm index b4a34b2..7adca0a 100644 --- a/src/vram.asm +++ b/src/vram.asm @@ -1,10 +1,21 @@ -SECTION "VRAM", VRAM +SECTION "VRAM0", VRAM -vTiles0:: ds $800 ; 8000 -vTiles1:: ds $800 ; 8800 -vTiles2:: ds $800 ; 9000 +v0Tiles0:: ds $800 ; 8000 +v0Tiles1:: ds $800 ; 8800 +v0Tiles2:: ds $800 ; 9000 -vBGMapTiles:: ds $400 ; 9800 -vBGMapAttrs:: ds $400 ; 9c00 +v0BGMapTiles1:: ds $400 ; 9800 +v0BGMapTiles2:: ds $400 ; 9c00 -vEnd:: ; a000 +v0End:: ; a000 + +SECTION "VRAM1", VRAM + +v1Tiles0:: ds $800 ; 8000 +v1Tiles1:: ds $800 ; 8800 +v1Tiles2:: ds $800 ; 9000 + +v1BGMapTiles1:: ds $400 ; 9800 +v1BGMapTiles2:: ds $400 ; 9c00 + +v1End:: ; a000 | 
