pokecrystal/home/copy.asm

423 lines
4.6 KiB
NASM
Raw Normal View History

; Functions to copy data from ROM.
Functiondc9:: ; dc9
ld a, [rLCDC]
bit 7, a
jp z, Copy2bpp
ld a, [hROMBank]
push af
ld a, BANK(Function104284)
rst Bankswitch
call Function104284
pop af
rst Bankswitch
ret
; ddc
Functionddc:: ; ddc
ld a, [rLCDC]
bit 7, a
jp z, Copy1bpp
ld a, [hROMBank]
push af
ld a, BANK(Function1042b2)
rst Bankswitch
call Function1042b2
pop af
rst Bankswitch
ret
; def
Functiondef:: ; def
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
call FarCopyBytesDouble
pop af
rst Bankswitch
ret
; dfd
Functiondfd:: ; dfd
dec c
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld a, [hROMBank]
push af
ld a, b
rst Bankswitch
2015-07-21 05:52:46 +00:00
.loop
ld a, d
ld [rHDMA1], a
ld a, e
and $f0
ld [rHDMA2], a
ld a, h
and $1f
ld [rHDMA3], a
ld a, l
and $f0
ld [rHDMA4], a
ld a, c
cp $8
2015-07-21 05:52:46 +00:00
jr c, .done
sub $8
ld c, a
ld a, $f
ld [hDMATransfer], a
call DelayFrame
ld a, l
2015-07-21 05:52:46 +00:00
add 0
ld l, a
ld a, h
2015-07-21 05:52:46 +00:00
adc 1
ld h, a
ld a, e
2015-07-21 05:52:46 +00:00
add 0
ld e, a
ld a, d
2015-07-21 05:52:46 +00:00
adc 1
ld d, a
2015-07-21 05:52:46 +00:00
jr .loop
2015-07-21 05:52:46 +00:00
.done
ld a, c
and $7f
ld [hDMATransfer], a
call DelayFrame
pop af
rst Bankswitch
pop af
ld [hBGMapMode], a
ret
; e4a
Special_ReplaceKrisSprite:: ; e4a
2013-10-02 00:47:54 +00:00
callba Function14135
ret
; e51
Functione51:: ; e51
2013-10-02 00:47:54 +00:00
callba Functionfb449
ret
; e58
Functione58:: ; e58
2013-10-02 00:47:54 +00:00
callba Functionfb4be
ret
; e5f
Functione5f:: ; e5f
2013-10-02 00:47:54 +00:00
callba Functionfb48a
callba Functionfb4b0
ret
; e6c
Functione6c:: ; e6c
2013-10-02 00:47:54 +00:00
callba Functionfb4b0
ret
; e73
Functione73:: ; e73
push de
ld a, BANK(sScratch)
call GetSRAMBank
push bc
ld de, sScratch
ld a, b
call FarDecompress
pop bc
pop hl
ld de, sScratch
call Request2bpp
call CloseSRAM
ret
; e8d
FarCopyBytes:: ; e8d
; copy bc bytes from a:hl to de
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
call CopyBytes
pop af
rst Bankswitch
ret
; 0xe9b
FarCopyBytesDouble:: ; e9b
; Copy bc bytes from a:hl to bc*2 bytes at de,
; doubling each byte in the process.
ld [hBuffer], a
ld a, [hROMBank]
push af
ld a, [hBuffer]
rst Bankswitch
; switcheroo, de <> hl
ld a, h
ld h, d
ld d, a
ld a, l
ld l, e
ld e, a
inc b
inc c
jr .dec
.loop
ld a, [de]
inc de
2015-07-21 02:18:18 +00:00
rept 2
ld [hli], a
2015-07-21 02:18:18 +00:00
endr
.dec
dec c
jr nz, .loop
dec b
jr nz, .loop
pop af
rst Bankswitch
ret
; 0xeba
Request2bpp:: ; eba
; Load 2bpp at b:de to occupy c tiles of hl.
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld a, [hROMBank]
push af
ld a, b
rst Bankswitch
ld a, [$ffd3]
push af
ld a, $8
ld [$ffd3], a
ld a, [InLinkBattle]
cp $4
jr nz, .okay
ld a, [$ffe9]
and a
jr nz, .okay
ld a, $6
ld [$ffd3], a
.okay
ld a, e
2013-09-01 19:24:07 +00:00
ld [Requested2bppSource], a
ld a, d
2013-09-01 19:24:07 +00:00
ld [Requested2bppSource + 1], a
ld a, l
2013-09-01 19:24:07 +00:00
ld [Requested2bppDest], a
ld a, h
2013-09-01 19:24:07 +00:00
ld [Requested2bppDest + 1], a
.loop
ld a, c
ld hl, $ffd3
cp [hl]
jr nc, .iterate
2013-09-01 19:24:07 +00:00
ld [Requested2bpp], a
.wait
call DelayFrame
2013-09-01 19:24:07 +00:00
ld a, [Requested2bpp]
and a
jr nz, .wait
pop af
ld [$ffd3], a
pop af
rst Bankswitch
pop af
ld [hBGMapMode], a
ret
.iterate
ld a, [$ffd3]
2013-09-01 19:24:07 +00:00
ld [Requested2bpp], a
.wait2
call DelayFrame
2013-09-01 19:24:07 +00:00
ld a, [Requested2bpp]
and a
jr nz, .wait2
ld a, c
ld hl, $ffd3
sub [hl]
ld c, a
jr .loop
; f1e
Request1bpp:: ; f1e
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld a, [hROMBank]
push af
ld a, b
rst Bankswitch
ld a, [$ffd3]
push af
ld a, $8
ld [$ffd3], a
ld a, [InLinkBattle]
cp $4
jr nz, .NotMobile
ld a, [$ffe9]
and a
jr nz, .NotMobile
ld a, $6
ld [$ffd3], a
.NotMobile
ld a, e
2013-09-01 19:24:07 +00:00
ld [Requested1bppSource], a
ld a, d
2013-09-01 19:24:07 +00:00
ld [Requested1bppSource + 1], a
ld a, l
2013-09-01 19:24:07 +00:00
ld [Requested1bppDest], a
ld a, h
2013-09-01 19:24:07 +00:00
ld [Requested1bppDest + 1], a
.loop
ld a, c
ld hl, $ffd3
cp [hl]
jr nc, .iterate
2013-09-01 19:24:07 +00:00
ld [Requested1bpp], a
.wait
call DelayFrame
2013-09-01 19:24:07 +00:00
ld a, [Requested1bpp]
and a
jr nz, .wait
pop af
ld [$ffd3], a
pop af
rst Bankswitch
pop af
ld [hBGMapMode], a
ret
.iterate
ld a, [$ffd3]
2013-09-01 19:24:07 +00:00
ld [Requested1bpp], a
.wait2
call DelayFrame
2013-09-01 19:24:07 +00:00
ld a, [Requested1bpp]
and a
jr nz, .wait2
ld a, c
ld hl, $ffd3
sub [hl]
ld c, a
jr .loop
; f82
Get2bpp:: ; f82
ld a, [rLCDC]
bit 7, a
jp nz, Request2bpp
Copy2bpp:: ; f89
; copy c 2bpp tiles from b:de to hl
push hl
ld h, d
ld l, e
pop de
; bank
ld a, b
; bc = c * $10
push af
swap c
ld a, $f
and c
ld b, a
ld a, $f0
and c
ld c, a
pop af
jp FarCopyBytes
; f9d
Get1bpp:: ; f9d
ld a, [rLCDC]
bit 7, a
jp nz, Request1bpp
Copy1bpp:: ; fa4
; copy c 1bpp tiles from b:de to hl
push de
ld d, h
ld e, l
; bank
ld a, b
; bc = c * $10 / 2
push af
ld h, 0
ld l, c
2015-07-21 02:18:18 +00:00
rept 3
add hl, hl
2015-07-21 02:18:18 +00:00
endr
ld b, h
ld c, l
pop af
pop hl
jp FarCopyBytesDouble
; fb6