diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/constants/misc_constants.asm | 8 | ||||
| -rw-r--r-- | src/data/npcs.asm | 4 | ||||
| -rwxr-xr-x | src/engine/bank1.asm | 52 | ||||
| -rwxr-xr-x | src/engine/home.asm | 130 | 
4 files changed, 106 insertions, 88 deletions
| diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm index 11693b4..422fda4 100644 --- a/src/constants/misc_constants.asm +++ b/src/constants/misc_constants.asm @@ -1,3 +1,11 @@ +; screen size +SCREEN_WIDTH  EQU 20 ; tiles +SCREEN_HEIGHT EQU 18 ; tiles + +; background map size +BG_MAP_WIDTH  EQU 32 ; tiles +BG_MAP_HEIGHT EQU 32 ; tiles +  ; console types (for wConsole)  CONSOLE_DMG EQU $00  CONSOLE_SGB EQU $01 diff --git a/src/data/npcs.asm b/src/data/npcs.asm index c6f4e4d..d7a3a61 100644 --- a/src/data/npcs.asm +++ b/src/data/npcs.asm @@ -1,5 +1,5 @@  ; When you press the a button in front of something it will find a data entry somewhere on this list -; it will then jump to the pointer in the data item. All jumps lead to an RST20 operation.  +; it will then jump to the pointer in the data item. All jumps lead to an RST20 operation.  PointerTable_118f5:  	dw Data_119dd  	dw Data_119dd @@ -529,7 +529,7 @@ AmandaData:  	dw OWSequence_Amanda ; Pointer to NPC Data  	db $bd  	db $03 -	db AMANDA_PIC +	db AMANDA_PIC ; battle profile picture  	db $23  	db $03  	db $15 diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index b1a879d..7a3f72a 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -16,20 +16,21 @@ Func_4000: ; 4000 (1:4000)  	farcall Func_1a6cc  	ldh a, [hButtonsHeld]  	cp A_BUTTON | B_BUTTON -	jr z, .asm_4035 +	jr z, .ask_erase_backup_ram  	farcall Func_126d1  	jr Func_4000 -.asm_4035 +.ask_erase_backup_ram  	call Func_405a  	call Func_04a2  	text_hl ResetBackUpRamText  	call Func_2af0 -	jr c, .asm_404d +	jr c, .reset_game +; erase sram  	call EnableExtRAM  	xor a  	ld [$a000], a  	call DisableExtRAM -.asm_404d +.reset_game  	jp Reset  Func_4050: ; 4050 (1:4050) @@ -333,16 +334,16 @@ Func_42ac:  	ld [wCurrentDuelMenuItem], a  	jr nc, Func_42ac  	ldh a, [hCurrentMenuItem] -	ld hl, BattleMenuFunctionTable +	ld hl, DuelMenuFunctionTable  	jp JumpToFunctionInTable -BattleMenuFunctionTable: ; 42f1 (1:42f1) -	dw OpenHandMenu -	dw OpenBattleAttackMenu -	dw OpenBattleCheckMenu -	dw OpenPokemonPowerMenu -	dw PlayerRetreat -	dw PlayerEndTurn +DuelMenuFunctionTable: ; 42f1 (1:42f1) +	dw DuelMenu_Hand +	dw DuelMenu_Attack +	dw DuelMenu_Check +	dw DuelMenu_PkmnPower +	dw DuelMenu_Retreat +	dw DuelMenu_Done  	INCROM $42fd,  $430b @@ -384,13 +385,13 @@ Func_4342: ; 4342 (1:4342)  	INCROM $4345,  $438e -OpenPokemonPowerMenu: ; 438e (1:438e) +DuelMenu_PkmnPower: ; 438e (1:438e)  	call $6431  	jp c, Func_426d  	call Func_1730  	jp Func_426d -PlayerEndTurn: ; 439a (1:439a) +DuelMenu_Done: ; 439a (1:439a)  	ld a, $08  	call $51e7  	jp c, Func_4268 @@ -399,7 +400,7 @@ PlayerEndTurn: ; 439a (1:439a)  	call $717a  	ret -PlayerRetreat: ; 43ab (1:43ab) +DuelMenu_Retreat: ; 43ab (1:43ab)  	ld a, DUELVARS_ARENA_CARD_STATUS  	call GetTurnDuelistVariable  	and a,PASSIVE_STATUS_MASK @@ -457,7 +458,7 @@ Func_441f: ; 441f (1:441f)  	call DrawWideTextBox_WaitForInput  	jp PrintDuelMenu -OpenHandMenu: ; 4425 (1:4425) +DuelMenu_Hand: ; 4425 (1:4425)  	ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND  	call GetTurnDuelistVariable  	or a @@ -523,14 +524,14 @@ PlayerUseEnergyCard: ; 4477 (1:4477)  	INCROM $44db,  $4585 -OpenBattleCheckMenu: ; 4585 (1:4585) +DuelMenu_Check: ; 4585 (1:4585)  	call Func_3b31  	call Func_3096  	jp Func_426d  	INCROM $458e,  $46fc -OpenBattleAttackMenu: ; 46fc (1:46fc) +DuelMenu_Attack: ; 46fc (1:46fc)  	call HandleCantAttackSubstatus  	jr c, .alertCantAttackAndCancelMenu  	call CheckIfActiveCardParalyzedOrAsleep @@ -660,14 +661,13 @@ Func_478b: ; 478b (1:478b)  	ret  AttackMenuCursorData: -	db $01 -	db $0d -	db $02 -	db $02 -	db $0f -	db $00 -	db $00 -	db $00 +	db 1, 13 ; x, y +	db 2 ; y displacement between items +	db 2 ; number of items +	db $0f ; cursor tile number +	db $00 ; tile behind cursor +	db $00 ; ??? +	db $00 ; ???  Func_47ec: ; $47ec (1:47ec)  	ld a, [wcc04] diff --git a/src/engine/home.asm b/src/engine/home.asm index b1fa021..60f1739 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -231,7 +231,7 @@ EnableLCD: ; 0277 (0:0277)  	or rLCDC_ENABLE_MASK ;  	ld [wLCDC], a        ;  	ld [rLCDC], a        ; turn LCD on -	ld a, $c0 +	ld a, %11000000  	ld [wFlushPaletteFlags], a  	ret @@ -246,7 +246,7 @@ DisableLCD: ; 028a (0:028a)  	ld [rIE], a          ; disable vblank interrupt  .asm_298  	ld a, [rLY]          ; -	cp $91               ; +	cp LY_VBLANK         ;  	jr nz, .asm_298      ; wait for vblank  	ld a, [rLCDC]        ;  	and $7f              ; @@ -350,7 +350,7 @@ SetupLCD: ; 030b (0:030b)  	ld [wLCDC], a  	ld a, $1  	ld [MBC3LatchClock], a -	ld a, $a +	ld a, SRAM_ENABLE  	ld [MBC3SRamEnable], a  NopF: ; 0348 (0:0348)  	ret @@ -377,7 +377,7 @@ DetectConsole: ; 0349 (0:0349)  ; initialize the palettes (both monochrome and color)  SetupPalettes: ; 036a (0:036a)  	ld hl, wBGP -	ld a, $e4 +	ld a, %11100100  	ld [rBGP], a  	ld [hli], a  	ld [rOBP0], a @@ -460,23 +460,23 @@ FillTileMap: ; 03c0 (0:03c0)  ; zero work RAM, stack area & high RAM ($C000-$DFFF, $FF80-$FFEF)  ZeroRAM: ; 03ec (0:03ec) -	ld hl, wTempCardCollection -	ld bc, $2000 -.asm_3f2 +	ld hl, $c000 +	ld bc, $e000 - $c000 +.zero_wram_loop  	xor a  	ld [hli], a  	dec bc  	ld a, c  	or b -	jr nz, .asm_3f2 -	ld c, $80 -	ld b, $70 +	jr nz, .zero_wram_loop +	ld c, LOW($ff80) +	ld b, $fff0 - $ff80  	xor a -.asm_3fe +.zero_hram_loop  	ld [$ff00+c], a  	inc c  	dec b -	jr nz, .asm_3fe +	jr nz, .zero_hram_loop  	ret  Func_0404: ; 0404 (0:0404) @@ -627,7 +627,7 @@ SGB_ATTR_BLK_04bf: ; 04bf (0:04bf)  	sgb ATTR_BLK, 1 ; sgb_command, length  	db $01,$03,$00,$00,$00,$13,$11,$00,$00,$00,$00,$00,$00,$00,$00 -; returns vBGMapTiles + 32 * c + b in de. +; returns vBGMapTiles + BG_MAP_WIDTH * c + b in de.  ; used to map coordinates at bc to a BGMap0 address.  BCCoordToBGMap0Address: ; 04cf (0:04cf)  	ld l, c @@ -638,7 +638,7 @@ BCCoordToBGMap0Address: ; 04cf (0:04cf)  	add hl, hl  	add hl, hl  	ld c, b -	ld b, $98 +	ld b, HIGH(vBGMapTiles)  	add hl, bc  	ld e, l  	ld d, h @@ -1203,7 +1203,7 @@ BankswitchRAM: ; 07a9 (0:07a9)  	push af  	ldh [hBankRAM], a  	ld [MBC3SRamBank], a -	ld a, $a +	ld a, SRAM_ENABLE  	ld [MBC3SRamEnable], a  	pop af  	ret @@ -1211,7 +1211,7 @@ BankswitchRAM: ; 07a9 (0:07a9)  ; enable external RAM  EnableExtRAM: ; 07b6 (0:07b6)  	push af -	ld a, $a +	ld a, SRAM_ENABLE  	ld [MBC3SRamEnable], a  	pop af  	ret @@ -1219,7 +1219,7 @@ EnableExtRAM: ; 07b6 (0:07b6)  ; disable external RAM  DisableExtRAM: ; 07be (0:07be)  	push af -	xor a +	xor a ; SRAM_DISABLE  	ld [MBC3SRamEnable], a  	pop af  	ret @@ -1832,7 +1832,7 @@ Func_0bcb: ; 0bcb (0:0bcb)  	jr nz, .wait_vbalnk  	ld a, $43  	ld [rLCDC], a -	ld a, $e4 +	ld a, %11100100  	ld [rBGP], a  	ld de, vTiles1  	ld bc, vBGMapTiles - vTiles1 @@ -2796,7 +2796,7 @@ _GetCardInDeckPosition: ; 1362 (0:1362)  	ld a, [hl]  	pop de  	ret -
 +  ; load data of card in position a to wLoadedCard1  LoadDeckCardToBuffer1: ; 1376 (0:1376)  	push hl @@ -2813,7 +2813,7 @@ LoadDeckCardToBuffer1: ; 1376 (0:1376)  	pop de  	pop hl  	ret -
 +  ; load data of card in position a to wLoadedCard2  LoadDeckCardToBuffer2: ; 138c (0:138c)  	push hl @@ -3312,25 +3312,25 @@ CheckSelfConfusionDamage: ; 18d7 (0:18d7)  ; 0x18f9  	INCROM $18f9, $1944 -
 -; this loads HP and Stage (1 byte each) of card with id at $ff9f into wLoadedMoveEffectCommands
 -Func_1944: ; 1944 (0:1944)
 -	ld a, [$ff9f]
 -	call LoadDeckCardToBuffer1
 -	ld hl, wLoadedCard1HP
 -	ld de, wLoadedMoveEffectCommands
 -	ld a, [hli]
 -	ld [de], a
 -	inc de
 -	ld a, [hl]
 -	ld [de], a
 -	ret
 -; 0x1955
 -
 -Func_1955: ; 1955 (0:1955)
 -	push af
 -	ld a, $7a
 -	ld [wLoadedMoveAnimation], a
 + +; this loads HP and Stage (1 byte each) of card with id at $ff9f into wLoadedMoveEffectCommands +Func_1944: ; 1944 (0:1944) +	ld a, [$ff9f] +	call LoadDeckCardToBuffer1 +	ld hl, wLoadedCard1HP +	ld de, wLoadedMoveEffectCommands +	ld a, [hli] +	ld [de], a +	inc de +	ld a, [hl] +	ld [de], a +	ret +; 0x1955 + +Func_1955: ; 1955 (0:1955) +	push af +	ld a, $7a +	ld [wLoadedMoveAnimation], a  	pop af  ; this function appears to apply several damage modifiers  Func_195c: ; 195c (0:195c) @@ -3902,7 +3902,7 @@ SafeCopyDataDEtoHL: ; 1dca (0:1dca)  .lcd_on  	jp HblankCopyDataDEtoHL -; returns vBGMapTiles + 32 * e + d in hl. +; returns vBGMapTiles + BG_MAP_WIDTH * e + d in hl.  ; used to map coordinates at de to a BGMap0 address.  DECoordToBGMap0Address: ; 1ddb (0:1ddb)  	ld l, e @@ -3916,7 +3916,7 @@ DECoordToBGMap0Address: ; 1ddb (0:1ddb)  	add d  	ld l, a  	ld a, h -	adc $98 +	adc HIGH(vBGMapTiles)  	ld h, a  	ret @@ -4047,29 +4047,29 @@ DrawRegularTextBoxDMG: ; 1e88 (0:1e88)  	call DECoordToBGMap0Address  	; top line (border) of the text box  	ld a, $1c -	ld de, $1819 +	lb de, $18, $19  	call CopyLine  ContinueDrawingTextBoxDMGorSGB  	dec c  	dec c  .draw_text_box_body_loop  	ld a, $0 -	ld de, $1e1f +	lb de, $1e, $1f  	call CopyLine  	dec c  	jr nz, .draw_text_box_body_loop  	; bottom line (border) of the text box  	ld a, $1d -	ld de, $1a1b +	lb de, $1a, $1b  ;	fallthrough -; copies b bytes of data to sp+$1c and to hl, and returns hl += SCREEN_WIDTH +; copies b bytes of data to sp+$1c 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] -; b is supposed to be SCREEN_WIDTH or smaller, else the stack would get corrupted +; b is supposed to be BG_MAP_WIDTH or smaller, else the stack would get corrupted  CopyLine: ; 1ea5 (0:1ea5) -	add sp, -$20 +	add sp, -BG_MAP_WIDTH  	push hl  	push bc  	ld hl, sp+$4 @@ -4093,24 +4093,24 @@ CopyLine: ; 1ea5 (0:1ea5)  	call SafeCopyDataDEtoHL  	pop bc  	pop de -	; advance pointer SCREEN_WIDTH positions and restore stack pointer -	ld hl, $0020 +	; advance pointer BG_MAP_WIDTH positions and restore stack pointer +	ld hl, BG_MAP_WIDTH  	add hl, de -	add sp, $20 +	add sp, BG_MAP_WIDTH  	ret  DrawRegularTextBoxCGB:  	call DECoordToBGMap0Address  	; top line (border) of the text box  	ld a, $1c -	ld de, $1819 +	lb de, $18, $19  	call CopyCurrentLineTilesAndAttrCGB  ContinueDrawingTextBoxCGB  	dec c  	dec c  .draw_text_box_body_loop  	ld a, $0 -	ld de, $1e1f +	lb de, $1e, $1f  	push hl  	call CopyLine  	pop hl @@ -4125,7 +4125,7 @@ ContinueDrawingTextBoxCGB  	jr nz, .draw_text_box_body_loop  	; bottom line (border) of the text box  	ld a, $1d -	ld de, $1a1b +	lb de, $1a, $1b  	call CopyCurrentLineTilesAndAttrCGB  	ret @@ -4972,12 +4972,12 @@ InitializeCursorParameters: ; 2636 (0:2636)  	ldh [hCurrentMenuItem], a  	ld de, wCursorXPosition  	ld b, $8 -.asm_2640 +.loop  	ld a, [hli]  	ld [de], a  	inc de  	dec b -	jr nz, .asm_2640 +	jr nz, .loop  	xor a  	ld [wCursorBlinkCounter], a  	ret @@ -5199,8 +5199,8 @@ Func_29f5: ; 29f5 (0:29f5)  	ret  ; 0x29fa -Func_29fa: ; 29fa (0:29fa)
 -	ld bc, $0f00
 +Func_29fa: ; 29fa (0:29fa) +	ld bc, $0f00  	call Func_2a1a  Func_2a00: ; 2a00 (0:2a00)  	call DoFrame @@ -5294,7 +5294,12 @@ DrawNarrowTextBox_WaitForInput: ; 2a7c (0:2a7c)  	ret  NarrowTextBoxPromptCursorData: ; 2a96 (0:2a96) -	db $a, $11, $1, $1, $2f, $1d, $0, $0 +	db 10, 17 ; x, y +	db 1 ; y displacement between items +	db 1 ; number of items +	db $2f ; cursor tile number +	db $1d ; tile behind cursor +	db $0, $0 ; ???, ???  ; draws a 20x6 text box aligned to the bottom of the screen  DrawWideTextBox: ; 2a9e (0:2a9e) @@ -5322,12 +5327,17 @@ WaitForWideTextBoxInput: ; 2aae (0:2aae)  	ret  WideTextBoxPromptCursorData: ; 2ac8 (0:2ac8) -	db $12, $11, $1, $1, $2f, $1d, $0, $0 +	db 18, 17 ; x, y +	db 1 ; y displacement between items +	db 1 ; number of items +	db $2f ; cursor tile number +	db $1d ; tile behind cursor +	db $0, $0 ; ???, ???  	INCROM $2ad0, $2af0  Func_2af0: ; 2af0 (0:2af0) -	call DrawWideTextBox_PrintText
 +	call DrawWideTextBox_PrintText  Func_2af3: ; 2af3 (0:2af3)  	ld de, $0710  	call Func_2b66 | 
