diff options
author | Daniel Harding <33dannye@gmail.com> | 2021-09-19 00:21:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 00:21:14 -0500 |
commit | df67aac83b466dadf5f74c881bf84dd9ef19bdfc (patch) | |
tree | 47501aced2d256052b8f78bc97328d5af5703add /src/home/memory.asm | |
parent | e4bce9b7ee5e89f8edfd921de2379f0fa06af206 (diff) | |
parent | 8dee6b7a11e85d6d4b9f8ec9fb9d53a499fd37dc (diff) |
Merge pull request #110 from ElectroDeoxys/master
Split Home bank
Diffstat (limited to 'src/home/memory.asm')
-rw-r--r-- | src/home/memory.asm | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/home/memory.asm b/src/home/memory.asm new file mode 100644 index 0000000..c5c3317 --- /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: + 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: + 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: + 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: + 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: + 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 |