summaryrefslogtreecommitdiff
path: root/sources/meta/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sources/meta/exec.c')
-rw-r--r--sources/meta/exec.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sources/meta/exec.c b/sources/meta/exec.c
index b5aaba4..663a2ae 100644
--- a/sources/meta/exec.c
+++ b/sources/meta/exec.c
@@ -34,6 +34,7 @@ BEGIN \
if(c8->st) c8->st--; \
} \
c8->pc += 2; \
+ c8->prevkeys = c8->keys; \
END
#define X_C8_ILL \
@@ -104,12 +105,12 @@ END
#define X_C8_SKP \
BEGIN \
- if(c8->keys & c8->V[x]) c8->pc += 2; \
+ if(c8->keys & bit(c8->V[x])) c8->pc += 2; \
END
#define X_C8_SKNP \
BEGIN \
- if(!(c8->keys & c8->V[x])) c8->pc += 2; \
+ if(!(c8->keys & bit(c8->V[x]))) c8->pc += 2; \
END
#define X_C8_MVDT \
@@ -117,10 +118,19 @@ BEGIN \
c8->V[x] = c8->dt; \
END
-/* TODO: implement */
#define X_C8_LDK \
BEGIN \
- if(!c8->keys) c8->pc -= 2; \
+ int i; \
+ if(c8->keys == c8->prevkeys) c8->pc -= 2; \
+ else \
+ { \
+ for(i = 7; i >= 0; i--) \
+ if(c8->keys & bit(i)) \
+ { \
+ c8->V[x] = i; \
+ break; \
+ } \
+ } \
END
#define X_C8_LDDT \
@@ -227,8 +237,6 @@ BEGIN \
if(c8->V[x] != c8->V[y]) c8->pc += 2; \
END
-
-/* TODO: actually implement */
#define X_C8_DRW \
BEGIN \
u8 l; \
@@ -236,7 +244,11 @@ BEGIN \
u8 cy = c8->V[y]; \
\
for(l = 0; l < n; l++) \
- c8->DISPLAY[cy + l * cx] ^= c8->RAM[c8->i + l]; \
+ { \
+ u64 pix = (u64)c8->RAM[c8->i + l]; \
+ pix = (pix << (64 - cx)) | (pix >> cx); \
+ c8->DISPLAY[(cy + l) % 32] ^= pix; \
+ } \
END
c8_decode_generate(exec)