summaryrefslogtreecommitdiff
path: root/bytepusher.scm
diff options
context:
space:
mode:
Diffstat (limited to 'bytepusher.scm')
-rw-r--r--bytepusher.scm22
1 files changed, 16 insertions, 6 deletions
diff --git a/bytepusher.scm b/bytepusher.scm
index 9c8b96b..7e08e2b 100644
--- a/bytepusher.scm
+++ b/bytepusher.scm
@@ -40,9 +40,7 @@
;; memory ----
(define (get-pc)
- (+ (ash (get-byte 4) 0)
- (ash (get-byte 3) 8)
- (ash (get-byte 2) 16)))
+ (get-addr 2))
(define (set-pc! value)
(set-byte! 4 (ash value 0))
@@ -50,11 +48,12 @@
(set-byte! 2 (ash value -16)))
(define (get-addr pos)
- (+ (bytevector-u16-ref memory (+ 1 pos) (endianness big))
- (ash (bytevector-u8-ref memory pos) 16)))
+ (+ (ash (get-byte (+ 2 pos)) 0)
+ (ash (get-byte (+ 1 pos)) 8)
+ (ash (get-byte pos) 16)))
(define (get-initial-pixel)
- (ash (bytevector-u8-ref memory 5) 16))
+ (ash (get-byte 5) 16))
(define (get-sample)
(bytevector-u16-ref memory 6 (endianness big)))
@@ -204,3 +203,14 @@
(sdl-quit))
;; ---- main operation
+
+
+;; tests ----
+(define (test-pc)
+ (for-each
+ (lambda (addr)
+ (set-pc! addr)
+ (when (not (= (get-pc) addr))
+ (error "Error in set pc")))
+ (iota #x1000000)))
+;; ---- tests