summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluckytyphlosion <alan.rj.huang@gmail.com>2015-06-12 12:07:07 -0400
committerluckytyphlosion <alan.rj.huang@gmail.com>2015-06-12 12:07:07 -0400
commit6b5510f7fc836f4f3b6a0082968021c935243b73 (patch)
tree1496fa2b14419025385a3a9b5e2f810461e25804
parentf2c5cdef477cf104094761d13426b5765e541f66 (diff)
Minor pic.asm change and relabeling addresses.
-rw-r--r--home/pic.asm58
1 files changed, 27 insertions, 31 deletions
diff --git a/home/pic.asm b/home/pic.asm
index 6aa2e5c0..d43da56d 100644
--- a/home/pic.asm
+++ b/home/pic.asm
@@ -1,24 +1,20 @@
; bankswitches and runs _UncompressSpriteData
; bank is given in a, sprite input stream is pointed to in W_SPRITEINPUTPTR
-UncompressSpriteData:: ; 24fd (0:24fd)
+UncompressSpriteData:: ; 23f8 (0:23f8)
ld b, a
ld a, [H_LOADEDROMBANK]
push af
ld a, b
- ld [H_LOADEDROMBANK], a
- ld [$2000], a
- ld a, $a
- ld [$0], a
- xor a
- ld [$4000], a
+ call BankswitchCommon
+ ld a,$0
+ call SwitchSRAMBankAndLatchClockData
call _UncompressSpriteData
pop af
- ld [H_LOADEDROMBANK], a
- ld [$2000], a
+ call BankswitchCommon
ret
; initializes necessary data to load a sprite and runs UncompressSpriteDataLoop
-_UncompressSpriteData:: ; 251a (0:251a)
+_UncompressSpriteData:: ; 2410 (0:2410)
ld hl, S_SPRITEBUFFER1
ld c, (2*SPRITEBUFFERSIZE) % $100
ld b, (2*SPRITEBUFFERSIZE) / $100
@@ -55,7 +51,7 @@ _UncompressSpriteData:: ; 251a (0:251a)
; uncompresses a chunk from the sprite input data stream (pointed to at wd0da) into S_SPRITEBUFFER1 or S_SPRITEBUFFER2
; each chunk is a 1bpp sprite. A 2bpp sprite consist of two chunks which are merged afterwards
; note that this is an endless loop which is terminated during a call to MoveToNextBufferPosition by manipulating the stack
-UncompressSpriteDataLoop:: ; 2556 (0:2556)
+UncompressSpriteDataLoop:: ; 244c (0:244c)
ld hl, S_SPRITEBUFFER1
ld a, [W_SPRITELOADFLAGS] ; wd0a8
bit 0, a
@@ -145,7 +141,7 @@ UncompressSpriteDataLoop:: ; 2556 (0:2556)
; moves output pointer to next position
; also cancels the calling function if the all output is done (by removing the return pointer from stack)
; and calls postprocessing functions according to the unpack mode
-MoveToNextBufferPosition:: ; 25d8 (0:25d8)
+MoveToNextBufferPosition:: ; 24ce (0:24ce)
ld a, [W_SPRITEHEIGHT]
ld b, a
ld a, [W_SPRITECURPOSY]
@@ -206,7 +202,7 @@ MoveToNextBufferPosition:: ; 25d8 (0:25d8)
jp UnpackSprite
; writes 2 bits (from a) to the output buffer (pointed to from W_SPRITEOUTPUTPTR)
-WriteSpriteBitsToBuffer:: ; 2649 (0:2649)
+WriteSpriteBitsToBuffer:: ; 253f (0:253f)
ld e, a
ld a, [W_SPRITEOUTPUTBITOFFSET]
and a
@@ -234,7 +230,7 @@ WriteSpriteBitsToBuffer:: ; 2649 (0:2649)
ret
; reads next bit from input stream and returns it in a
-ReadNextInputBit:: ; 2670 (0:2670)
+ReadNextInputBit:: ; 2566 (0:2566)
ld a, [W_SPRITEINPUTBITCOUNTER]
dec a
jr nz, .curByteHasMoreBitsToRead
@@ -250,7 +246,7 @@ ReadNextInputBit:: ; 2670 (0:2670)
ret
; reads next byte from input stream and returns it in a
-ReadNextInputByte:: ; 268b (0:268b)
+ReadNextInputByte:: ; 2581 (0:2581)
ld a, [W_SPRITEINPUTPTR]
ld l, a
ld a, [W_SPRITEINPUTPTR+1]
@@ -265,7 +261,7 @@ ReadNextInputByte:: ; 268b (0:268b)
ret
; the nth item is 2^n - 1
-LengthEncodingOffsetList:: ; 269f (0:269f)
+LengthEncodingOffsetList:: ; 2595 (0:2595)
dw %0000000000000001
dw %0000000000000011
dw %0000000000000111
@@ -284,7 +280,7 @@ LengthEncodingOffsetList:: ; 269f (0:269f)
dw %1111111111111111
; unpacks the sprite data depending on the unpack mode
-UnpackSprite:: ; 26bf (0:26bf)
+UnpackSprite:: ; 25b5 (0:25b5)
ld a, [W_SPRITEUNPACKMODE]
cp $2
jp z, UnpackSpriteMode2
@@ -297,7 +293,7 @@ UnpackSprite:: ; 26bf (0:26bf)
; decodes differential encoded sprite data
; input bit value 0 preserves the current bit value and input bit value 1 toggles it (starting from initial value 0).
-SpriteDifferentialDecode:: ; 26d4 (0:26d4)
+SpriteDifferentialDecode:: ; 25ca (0:25ca)
xor a
ld [W_SPRITECURPOSX], a
ld [W_SPRITECURPOSY], a
@@ -382,7 +378,7 @@ SpriteDifferentialDecode:: ; 26d4 (0:26d4)
ret
; decodes the nybble stored in a. Last decoded data is assumed to be in e (needed to determine if initial value is 0 or 1)
-DifferentialDecodeNybble:: ; 276d (0:276d)
+DifferentialDecodeNybble:: ; 2663 (0:2663)
srl a ; c=a%2, a/=2
ld c, $0
jr nc, .evenNumber
@@ -424,7 +420,7 @@ DifferentialDecodeNybble:: ; 276d (0:276d)
ld e, a ; update last decoded data
ret
-DecodeNybble0Table:: ; 27a7 (0:27a7)
+DecodeNybble0Table:: ; 269d (0:269d)
dn $0, $1
dn $3, $2
dn $7, $6
@@ -433,7 +429,7 @@ DecodeNybble0Table:: ; 27a7 (0:27a7)
dn $c, $d
dn $8, $9
dn $b, $a
-DecodeNybble1Table:: ; 27af (0:27af)
+DecodeNybble1Table:: ; 26a5 (0:26a5)
dn $f, $e
dn $c, $d
dn $8, $9
@@ -442,7 +438,7 @@ DecodeNybble1Table:: ; 27af (0:27af)
dn $3, $2
dn $7, $6
dn $4, $5
-DecodeNybble0TableFlipped:: ; 27b7 (0:27b7)
+DecodeNybble0TableFlipped:: ; 26ad (0:26ad)
dn $0, $8
dn $c, $4
dn $e, $6
@@ -451,7 +447,7 @@ DecodeNybble0TableFlipped:: ; 27b7 (0:27b7)
dn $3, $b
dn $1, $9
dn $d, $5
-DecodeNybble1TableFlipped:: ; 27bf (0:27bf)
+DecodeNybble1TableFlipped:: ; 26b5 (0:26b5)
dn $f, $7
dn $3, $b
dn $1, $9
@@ -462,7 +458,7 @@ DecodeNybble1TableFlipped:: ; 27bf (0:27bf)
dn $2, $a
; combines the two loaded chunks with xor (the chunk loaded second is the destination). The source chunk is differeintial decoded beforehand.
-XorSpriteChunks:: ; 27c7 (0:27c7)
+XorSpriteChunks:: ; 26bd (0:26bd)
xor a
ld [W_SPRITECURPOSX], a
ld [W_SPRITECURPOSY], a
@@ -527,18 +523,18 @@ XorSpriteChunks:: ; 27c7 (0:27c7)
ret
; reverses the bits in the nybble given in register a
-ReverseNybble:: ; 2837 (0:2837)
+ReverseNybble:: ; 272d (0:272d)
ld de, NybbleReverseTable
add e
ld e, a
- jr nc, .asm_283f
+ jr nc, .asm_2735
inc d
-.asm_283f
+.asm_2735
ld a, [de]
ret
; resets sprite buffer pointers to buffer 1 and 2, depending on W_SPRITELOADFLAGS
-ResetSpriteBufferPointers:: ; 2841 (0:2841)
+ResetSpriteBufferPointers:: ; 2737 (0:2737)
ld a, [W_SPRITELOADFLAGS] ; wd0a8
bit 0, a
jr nz, .buffer2Selected
@@ -560,11 +556,11 @@ ResetSpriteBufferPointers:: ; 2841 (0:2841)
ret
; maps each nybble to its reverse
-NybbleReverseTable:: ; 2867 (0:2867)
+NybbleReverseTable:: ; 275d (0:275d)
db $0, $8, $4, $c, $2, $a, $6 ,$e, $1, $9, $5, $d, $3, $b, $7 ,$f
; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differeintial decoded beforehand.
-UnpackSpriteMode2:: ; 2877 (0:2877)
+UnpackSpriteMode2:: ; 276d (0:276d)
call ResetSpriteBufferPointers
ld a, [W_SPRITEFLIPPED]
push af
@@ -581,7 +577,7 @@ UnpackSpriteMode2:: ; 2877 (0:2877)
jp XorSpriteChunks
; stores hl into the output pointers
-StoreSpriteOutputPointer:: ; 2897 (0:2897)
+StoreSpriteOutputPointer:: ; 278d (0:278d)
ld a, l
ld [W_SPRITEOUTPUTPTR], a
ld [W_SPRITEOUTPUTPTRCACHED], a