diff options
| author | Háčky <hatschky@gmail.com> | 2014-11-21 10:46:12 +0000 |
|---|---|---|
| committer | Háčky <hatschky@gmail.com> | 2014-11-21 10:46:12 +0000 |
| commit | 2375d2c8db10447ae301176a2136bcad4bb42bb0 (patch) | |
| tree | 00ca01a39e7bce0795a10b0c58f33e005ad4ef4c /common | |
| parent | 92c6af6c354d58d96d9590efee955e449a8f94c3 (diff) | |
Initial commit
Diffstat (limited to 'common')
| -rw-r--r-- | common/battle_e_transfer.asm | 71 | ||||
| -rw-r--r-- | common/mem_struct.asm | 15 | ||||
| -rw-r--r-- | common/transfer_data.asm | 31 | ||||
| -rw-r--r-- | common/wait_for_link.asm | 36 | ||||
| -rw-r--r-- | common/wait_for_ready.asm | 30 | ||||
| -rw-r--r-- | common/word_shift_right.asm | 15 | ||||
| -rw-r--r-- | common/wrap_up.asm | 29 |
7 files changed, 227 insertions, 0 deletions
diff --git a/common/battle_e_transfer.asm b/common/battle_e_transfer.asm new file mode 100644 index 0000000..bc4f4e0 --- /dev/null +++ b/common/battle_e_transfer.asm @@ -0,0 +1,71 @@ +TransferData: + LD_IND_HL SomeVar2 + push de + ld hl, $BBBB + LD_IND_HL Space_1 ; Space_1 = $BBBB + EX_DE_HL + LD_IND_HL Space_2 ; store transfer length in Space_2, which is odd, + ; because we never refer to it again + API_0C7 Space_1 + + wait 1 + pop hl ; number of bytes to transfer + + ; calculate number of words to transfer: + ; de = (hl + 1) >> 1 + inc hl + ld b, 1 + call WordShiftRight + EX_DE_HL + +.asm_18FE + ld a, e + or d + ret z + ; while de > 0… + + ld hl, $8888 + LD_IND_HL Space_1 ; Space_1 = $8888 + ld a, $01 + LD_IND_A SomeVar1 ; SomeVar1 = 1 + +.asm_190C + LD_A_IND SomeVar1 ; a = SomeVar1 + cp $08 + jr nc, .asm_193B + + push de + LD_HL_IND SomeVar2 + ld c, [hl] + inc hl + ld b, [hl] + inc hl + LD_IND_HL SomeVar2 + ld hl, SomeVar1 + ld l, [hl] + ld h, $00 + add hl, hl + ld de, Space_1 + add hl, de + ld [hl], c + inc hl + ld [hl], b + pop de + dec de + ld a, e + or d + jr z, .asm_193B + + ld hl, SomeVar1 + ld a, $01 + add a, [hl] + ld [hl], a + jr .asm_190C + +.asm_193B ; if SomeVar1 > 8 + push de + API_0C7 Space_1 ; this must be the data transfer? it’s the only API function called + + wait 1 + pop de + jr .asm_18FE
\ No newline at end of file diff --git a/common/mem_struct.asm b/common/mem_struct.asm new file mode 100644 index 0000000..148d021 --- /dev/null +++ b/common/mem_struct.asm @@ -0,0 +1,15 @@ +; what do these store? +Space_1: + db 0,0 +Space_2: + REPT 14 + db 0 + ENDR +Space_3: + REPT 32 + db 0 + ENDR +Space_4: + db 0,0 +Space_5: + db 0,0
\ No newline at end of file diff --git a/common/transfer_data.asm b/common/transfer_data.asm new file mode 100644 index 0000000..0276d7c --- /dev/null +++ b/common/transfer_data.asm @@ -0,0 +1,31 @@ + API_106 $0040, UNKNOWN_VALUE + +.asm_1bfe + waita $01 + + ld hl, Space_3 + API $0C8 + + or a + jr nz, .asm_1c18 + + IS_SOUND_PLAYING 1 ; return + +.asm_1c18 + LD_HL_IND Space_3 + LD_IND_HL Space_4 + ld a, l + cp $22 + jr nz, .asm_1bfe + + ld a, h + cp $22 + jr nz, .asm_1bfe + + ld de, 60 ; transfer length + ld hl, Prologue + call TransferData + + ld de, DATA_TRANSFER_LENGTH ; transfer length + ld hl, DataPacket + call TransferData
\ No newline at end of file diff --git a/common/wait_for_link.asm b/common/wait_for_link.asm new file mode 100644 index 0000000..e317728 --- /dev/null +++ b/common/wait_for_link.asm @@ -0,0 +1,36 @@ + ret c + nop + wait 32 + ld l, $02 + push hl + ld bc, $B9A0 + ld de, $0076 + ld a, $08 + API $0C4 + pop bc +.asm_1b64 + API $0DB + + cp $01 + jr z, .asm_1b6f + API $0DB + or a + jr nz, .asm_1b76 +.asm_1b6f + waita $01 + API $0C5 + jr .asm_1b64 + +.asm_1b76 + waita $01 + LD_HL_IND $00C2 + ld a, l + and $02 + jr z, .asm_1b90 + + IS_SOUND_PLAYING 2 ; exit + +.asm_1b90 + API $0CA + cp $02 + jr c, .asm_1b76
\ No newline at end of file diff --git a/common/wait_for_ready.asm b/common/wait_for_ready.asm new file mode 100644 index 0000000..8344422 --- /dev/null +++ b/common/wait_for_ready.asm @@ -0,0 +1,30 @@ +.asm_1baf + waita $01 + API $0DB + + ld l, a + ld h, $00 + LD_IND_HL Space_5 + API $0CA + + cp $02 + jr nc, .asm_1bd4 + + ld hl, UNKNOWN_VALUE + SOUND_PAUSE + + IS_SOUND_PLAYING 1 ; return + +.asm_1bd4 + LD_HL_IND Space_5 + ld a, l + sub $04 + or h + jr z, .asm_1be6 + + LD_HL_IND Space_5 + ld a, l + sub $03 + or h + jr nz, .asm_1baf +.asm_1be6
\ No newline at end of file diff --git a/common/word_shift_right.asm b/common/word_shift_right.asm new file mode 100644 index 0000000..7a76280 --- /dev/null +++ b/common/word_shift_right.asm @@ -0,0 +1,15 @@ +WordShiftRight: + ; this function shifts HL by B bits to the right + inc b +.asm_1B93 + dec b + ret z + + and a + ld a, h + rra + ld h, a + ld a, l + rra + ld l, a + jp .asm_1B93
\ No newline at end of file diff --git a/common/wrap_up.asm b/common/wrap_up.asm new file mode 100644 index 0000000..157b6ef --- /dev/null +++ b/common/wrap_up.asm @@ -0,0 +1,29 @@ +.asm_1c60 + waita 1 + + LD_HL_IND $00C2 + ld a, l + and $01 + jr z, .asm_1c7c + + ; IS_SOUND_PLAYING 1 + API $08D + dec b ; was this supposed + nop ; to be ld b, $00? + ld e, $01 + ld hl, $0005 ; was this supposed to be $0006? + API $119 + ld a, $01 ; return + EXIT + + jr .asm_1c60 + +.asm_1c7c + LD_HL_IND $00C2 + ld a, l + and $02 + jr z, .asm_1c60 + + IS_SOUND_PLAYING 2 + + jr .asm_1c60
\ No newline at end of file |
