summaryrefslogtreecommitdiff
path: root/common/double_speed.asm
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-09-09 15:59:08 -0500
committerBryan Bishop <kanzure@gmail.com>2013-09-09 15:59:08 -0500
commit3a2dbb5289e745dfb5f26844148c0981f14e8fcf (patch)
treedfb418aa41502c67ae3f75bab4d3df91b5cfd6c1 /common/double_speed.asm
parent37e1aa4e8ec2400ba97db4c767bd3a9fcd43a1ac (diff)
parentabb7f2fa20e49cf56a55c81d4ec86431e3009098 (diff)
Merge branch 'yenatch/split-predefs-specials-stds' into fix-split-predefs-specials-stds
https://github.com/kanzure/pokecrystal/pull/198
Diffstat (limited to 'common/double_speed.asm')
-rw-r--r--common/double_speed.asm31
1 files changed, 31 insertions, 0 deletions
diff --git a/common/double_speed.asm b/common/double_speed.asm
new file mode 100644
index 000000000..fc1234215
--- /dev/null
+++ b/common/double_speed.asm
@@ -0,0 +1,31 @@
+; The CGB hardware introduces Double Speed Mode.
+; While active, the clock speed is doubled.
+
+; The hardware can switch between normal speed
+; and double speed at any time, but LCD output
+; collapses during the switch.
+
+DoubleSpeed: ; 2fef
+ ld hl, rKEY1
+ bit 7, [hl]
+ jr z, SwitchSpeed
+ ret
+; 2ff7
+
+NormalSpeed: ; 2ff7
+ ld hl, rKEY1
+ bit 7, [hl]
+ ret z
+; 2ffd
+
+SwitchSpeed: ; 2ffd
+ set 0, [hl]
+ xor a
+ ld [rIF], a
+ ld [rIE], a
+ ld a, $30
+ ld [rJOYP], a
+ stop ; rgbasm adds a nop after this instruction by default
+ ret
+; 300b
+