diff options
| author | xCrystal <rgr.crystal@gmail.com> | 2016-01-17 23:34:15 +0100 | 
|---|---|---|
| committer | xCrystal <rgr.crystal@gmail.com> | 2016-01-17 23:34:15 +0100 | 
| commit | 328868404d2640f7928f81e21c114dee7767ee2e (patch) | |
| tree | 84dd1ee10860b23b0fe09b219809fb919d4abb9e | |
| parent | 4d327d108061d6d49f217c78dbea8846320010b5 (diff) | |
more draw text box and related functions
| -rwxr-xr-x | src/engine/bank4.asm | 6 | ||||
| -rwxr-xr-x | src/engine/bank6.asm | 2 | ||||
| -rwxr-xr-x | src/engine/home.asm | 123 | ||||
| -rwxr-xr-x | src/wram.asm | 8 | 
4 files changed, 121 insertions, 18 deletions
| diff --git a/src/engine/bank4.asm b/src/engine/bank4.asm index 3e27c97..2c4e66e 100755 --- a/src/engine/bank4.asm +++ b/src/engine/bank4.asm @@ -68,7 +68,7 @@ BoosterPack_1031b: ; 1031b (4:431b)  	call DisableLCD  	call $4000  	xor a -	ld [$ccf3], a +	ld [wFrameType], a  	pop bc  	push bc  	ld b, $0 @@ -118,7 +118,7 @@ BoosterPack_1031b: ; 1031b (4:431b)  	ld a, $1  	ld [$cac0], a  	ld a, $4 -	ld [$ccf3], a +	ld [wFrameType], a  	farcallx $1, $7599  	farcall Func_c1a4  	call Func_3c48 @@ -138,7 +138,7 @@ Duel_Init: ; 103d3 (4:43d3)  	call DisableLCD  	call $4000  	ld a, $4 -	ld [$ccf3], a +	ld [wFrameType], a  	ld de, $000c  	ld bc, $1406  	call DrawMenuBox diff --git a/src/engine/bank6.asm b/src/engine/bank6.asm index 77ca9b9..8d38e74 100755 --- a/src/engine/bank6.asm +++ b/src/engine/bank6.asm @@ -104,7 +104,7 @@ Func_19a12: ; 19a12 (6:5a12)  	ld h, [hl]  	ld l, a  	ld de, $c590 -	call Func_2e89 +	call PrintTextBoxBorderLabel  	ret  ; 0x19a1f diff --git a/src/engine/home.asm b/src/engine/home.asm index 01a89a8..90e8137 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2164,7 +2164,7 @@ Func_1c8e: ; 1c8e (0:1c8e)  	ld a, [hld]  	ld l, [hl]  	ld h, a -	jp Func_2e89 +	jp PrintTextBoxBorderLabel  .asm_1c9b  	ld hl, $c500  	ld a, [hl] @@ -2173,7 +2173,7 @@ Func_1c8e: ; 1c8e (0:1c8e)  	jr asm_1c83  .asm_1ca4  	ld hl, $0092 -	jp Func_2e89 +	jp PrintTextBoxBorderLabel  ; 0x1caa  INCBIN "baserom.gbc",$1caa,$1dca - $1caa @@ -2232,9 +2232,98 @@ AdjustCoordinatesForWindow: ; 1deb (0:1deb)  	ret  ; 0x1e00 -INCBIN "baserom.gbc",$1e00,$1e7c - $1e00 +; Draws a bxc text box at de printing a name in the left side of the top border.  +; Name's text offset must be at hl when this function is called. +; Mostly used to print text boxes for talked-to NPCs, but occasionally used in duels as well. +DrawTextBox: ; 1e00 (0:1e00) +	ld a, [wConsole] +	cp CONSOLE_SGB +	jr nz, .drawTextBox +	ld a, [wFrameType] +	or a +	jr z, .drawTextBox +; Console is SGB and frame type is != 0 +; wFrameType is handled differently in SGB and CGB +	push de +	push bc +	call .drawTextBox +	pop bc +	pop de +	jp asm_1f1b + +.drawTextBox +	push de +	push bc +	push hl +; top left tile of the box and white tile before the text +	ld hl, $c000 +	ld a, $5 +	ld [hli], a +	ld a, $18 +	ld [hli], a +	ld a, $70 +	ld [hli], a +	ld e, l +	ld d, h +	pop hl +	call PrintTextBoxBorderLabel +	ld hl, $c003 +	call Func_23c1 +	ld l, e +	ld h, d +; white tile after the text +	ld a, $7 +	ld [hli], a +	ld a, $70 +	ld [hli], a +	pop de +	push de +	ld a, d +	sub b +	sub $4 +	jr z, .printTopRightTile +	ld b, a +.printTopBorderLoop +	ld a, $5 +	ld [hli], a +	ld a, $1c +	ld [hli], a +	dec b +	jr nz, .printTopBorderLoop + +.printTopRightTile +	ld a, $5 +	ld [hli], a +	ld a, $19 +	ld [hli], a +	ld [hl], $0 +	pop bc +	pop de +	push de +	push bc +	call Func_22ae +	ld hl, $c000 +	call Func_21c5 +	pop bc +	pop de +	ld a, [wConsole] +	cp CONSOLE_CGB +	jr z, .cgb +; DMG or SGB +	inc e +	call CalculateBGMap0Address +	jr asm_1e93 -; Draws a bxc text box at de to print menu data +.cgb +	call CalculateBGMap0Address +	push de +	call asm_1f00 +	pop de +	inc e +	jp asm_1ed4 + +; Draws a bxc text box at de to print menu data in the overworld.  +; Also used to print a text box during a duel.  DrawMenuBox: ; 1e7c (0:1e7c)  	ld a, [wConsole]  	cp CONSOLE_CGB @@ -2247,6 +2336,7 @@ DrawMenuBoxDMG: ; 1e88 (0:1e88)  	ld a, $1c  	ld de, $1819  	call Func_1ea5 +asm_1e93  	dec c  	dec c  .asm_1e95 @@ -2292,6 +2382,7 @@ DrawMenuBoxCGB:  	ld a, $1c  	ld de, $1819  	call Func_1efb +asm_1ed4	  	dec c  	dec c  .asm_1ed6 @@ -2301,7 +2392,7 @@ DrawMenuBoxCGB:  	call Func_1ea5  	pop hl  	call BankswitchVRAM_1 -	ld a, [$ccf3] +	ld a, [wFrameType]  	ld e, a  	ld d, a  	xor a @@ -2318,8 +2409,9 @@ Func_1efb: ; 1efb (0:1efb)  	push hl  	call Func_1ea5  	pop hl +asm_1f00	  	call BankswitchVRAM_1 -	ld a, [$ccf3] +	ld a, [wFrameType]  	ld e, a  	ld d, a  	call Func_1ea5 @@ -2332,9 +2424,10 @@ DrawMenuBoxSGB: ; 1f0f (0:1f0f)  	call DrawMenuBoxDMG  	pop de  	pop bc -	ld a, [$ccf3] +	ld a, [wFrameType]  	or a  	ret z +asm_1f1b  	push bc  	push de  	ld hl, $cae0 @@ -2361,7 +2454,7 @@ DrawMenuBoxSGB: ; 1f0f (0:1f0f)  	add c  	dec a  	ld [hli], a -	ld a, [$ccf3] +	ld a, [wFrameType]  	and $80  	jr z, .asm_1f48  	ld a, $2 @@ -3770,24 +3863,28 @@ Func_2e76: ; 2e76 (0:2e76)  	call BankswitchHome  	ret -Func_2e89: ; 2e89 (0:2e89) +; Prints a name in the left side of the top border of a text box, usually to identify the talked-to NPC. +; input: +	; hl: text offset +	; de: where to print the name +PrintTextBoxBorderLabel: ; 2e89 (0:2e89)  	ld a, l  	or h -	jr z, .asm_2e9f +	jr z, .done  	ld a, [hBankROM]  	push af  	call ReadTextOffset -.asm_2e93 +.nextTileLoop  	ld a, [hli]  	ld [de], a  	inc de  	or a -	jr nz, .asm_2e93 +	jr nz, .nextTileLoop  	pop af  	call BankswitchHome  	dec de  	ret -.asm_2e9f +.done  	ld a, [$ff97]  	cp $c3  	jp z, Func_1c8e diff --git a/src/wram.asm b/src/wram.asm index df993a9..4e05d3e 100755 --- a/src/wram.asm +++ b/src/wram.asm @@ -150,7 +150,13 @@ wCardBuffer2:: ; cc65  wCurrentMoveOrCardEffect:: ; ccb2  	ds $1 -	ds $5a +	ds $40 + +; color/pattern of the text box border, values between 0 and 7. +; interpreted differently depending on console type +wFrameType:: ; ccf3 +	ds $1 +	ds $19  ;--- Overworld -------------------------------------------- | 
