News: Reading Keyboard Input in 0x10c's DCPU-16 Assembly

Reading Keyboard Input in 0x10c's DCPU-16 Assembly

The as of yet undocumented DAT op code can also be used to read keyboard input by simply referencing dat 0. Here's the code from Notch's pastebin:

; Reading characters from the keyboard
; by Markus Persson

#macro nextkey(target) {
          push(i)
          set i,[keypointer]
          add i,0x9000
          set target,[i]
          ife target,0
                   jmp end
         
 set [i],0
          add [keypointer], 1
          and [keypointer], 0xf
:end
          pop(i)
}

:keypointer
dat 0

Want to master Microsoft Excel and take your work-from-home job prospects to the next level? Jump-start your career with our Premium A-to-Z Microsoft Excel Training Bundle from the new Gadget Hacks Shop and get lifetime access to more than 40 hours of Basic to Advanced instruction on functions, formula, tools, and more.

Buy Now (97% off) >

Our Best Phone Hacks

Gadget Hacks' tips — delivered daily.

1 Comment

Share Your Thoughts

  • Hot
  • Latest