From 32b02147925566bac93bf71b002860335583574c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 9 Sep 2021 08:51:12 +0100 Subject: Split home bank --- src/home/memory.asm | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/home/memory.asm (limited to 'src/home/memory.asm') diff --git a/src/home/memory.asm b/src/home/memory.asm new file mode 100644 index 0000000..b07ffd8 --- /dev/null +++ b/src/home/memory.asm @@ -0,0 +1,86 @@ +; decompresses data from a given bank +; uses values initialized by InitDataDecompression +; input: +; bc = row width +; de = buffer to place decompressed data +DecompressDataFromBank: ; 3be4 (0:3be4) + ldh a, [hBankROM] + push af + ld a, [wTempPointerBank] + call BankswitchROM + call DecompressData + pop af + call BankswitchROM + ret + +; Copies bc bytes from [wTempPointer] to de +CopyBankedDataToDE: ; 3bf5 (0:3bf5) + ldh a, [hBankROM] + push af + push hl + ld a, [wTempPointerBank] + call BankswitchROM + ld a, [wTempPointer] + ld l, a + ld a, [wTempPointer + 1] + ld h, a + call CopyDataHLtoDE_SaveRegisters + pop hl + pop af + call BankswitchROM + ret + +; fill bc bytes of data at hl with a +FillMemoryWithA: ; 3c10 (0:3c10) + push hl + push de + push bc + ld e, a +.loop + ld [hl], e + inc hl + dec bc + ld a, b + or c + jr nz, .loop + pop bc + pop de + pop hl + ret + +; fill 2*bc bytes of data at hl with d,e +FillMemoryWithDE: ; 3c1f (0:3c1f) + push hl + push bc +.loop + ld [hl], e + inc hl + ld [hl], d + inc hl + dec bc + ld a, b + or c + jr nz, .loop + pop bc + pop hl + ret + +; gets far byte a:hl, outputs value in a +GetFarByte: ; 3c2d (0:3c2d) + push hl + push af + ldh a, [hBankROM] + push af + push hl + ld hl, sp+$05 + ld a, [hl] + call BankswitchROM + pop hl + ld a, [hl] + ld hl, sp+$03 + ld [hl], a + pop af + call BankswitchROM + pop af + pop hl + ret -- cgit v1.2.3 From 0017fc2d171c87d7bab4c9be90e1069ae95a8071 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 9 Sep 2021 08:54:29 +0100 Subject: Remove home bank address comments --- src/home/memory.asm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/home/memory.asm') diff --git a/src/home/memory.asm b/src/home/memory.asm index b07ffd8..c5c3317 100644 --- a/src/home/memory.asm +++ b/src/home/memory.asm @@ -3,7 +3,7 @@ ; input: ; bc = row width ; de = buffer to place decompressed data -DecompressDataFromBank: ; 3be4 (0:3be4) +DecompressDataFromBank: ldh a, [hBankROM] push af ld a, [wTempPointerBank] @@ -14,7 +14,7 @@ DecompressDataFromBank: ; 3be4 (0:3be4) ret ; Copies bc bytes from [wTempPointer] to de -CopyBankedDataToDE: ; 3bf5 (0:3bf5) +CopyBankedDataToDE: ldh a, [hBankROM] push af push hl @@ -31,7 +31,7 @@ CopyBankedDataToDE: ; 3bf5 (0:3bf5) ret ; fill bc bytes of data at hl with a -FillMemoryWithA: ; 3c10 (0:3c10) +FillMemoryWithA: push hl push de push bc @@ -49,7 +49,7 @@ FillMemoryWithA: ; 3c10 (0:3c10) ret ; fill 2*bc bytes of data at hl with d,e -FillMemoryWithDE: ; 3c1f (0:3c1f) +FillMemoryWithDE: push hl push bc .loop @@ -66,7 +66,7 @@ FillMemoryWithDE: ; 3c1f (0:3c1f) ret ; gets far byte a:hl, outputs value in a -GetFarByte: ; 3c2d (0:3c2d) +GetFarByte: push hl push af ldh a, [hBankROM] -- cgit v1.2.3