Skip to content

Instantly share code, notes, and snippets.

@jacobly0
Created January 17, 2017 18:50
Show Gist options
  • Select an option

  • Save jacobly0/6715972f3e057538c8474336d4802086 to your computer and use it in GitHub Desktop.

Select an option

Save jacobly0/6715972f3e057538c8474336d4802086 to your computer and use it in GitHub Desktop.
define time
namespace time
macro init
ld de, 48000000/100
ld hl, ti.mpTmr1Counter
ld (hl), de
ld l, ti.tmr1Counter + 3
ld (hl), e
inc l; ti.tmr1Load
ld (hl), de
ld l, ti.tmr1Load + 3
ld bc, 5
call ti.MemClear
ld l, ti.tmrCtrl
ld (hl), bc
dec bc
ld l, ti.tmrIntStatus
ld (hl), bc
ld l, ti.tmrCtrl
ld (hl), ti.tmr1Enable or ti.tmr1IntOverflow
end macro
tick: ld hl, ti.mpTmrIntStatus
ld (hl), ti.tmr1IntOverflow
ld l, ti.tmr1Match1
inc (hl)
ret nz
inc hl
ld de, (hl)
inc de
ld (hl), de
.smc: ret
end namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment