From 667fb36489906d171ae849c6dffc25b5014407b6 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Wed, 22 Jan 2025 13:10:01 -0500 Subject: [PATCH] get DateTime working with chibi-scheme --- vm.scm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/vm.scm b/vm.scm index b7b1e26..615ec27 100644 --- a/vm.scm +++ b/vm.scm @@ -29,12 +29,19 @@ ;; (vector-set! v 8 (not (= tz 0))) ;; v)) -;; ;; chibi scheme, invoke with ??? -;; (import (scheme base) (scheme bitwise) (scheme file)) -;; (import (chibi io) (chibi process)) +;; ;; chibi scheme, invoke with chibi-scheme vm.scm ROM ... +;; (import (scheme base) (scheme bitwise) (scheme file) (scheme process-context)) +;; (import (chibi io) (chibi process) (chibi time)) ;; (define (get-u8 port) (read-u8 port)) ;; (define (open-rom path) (open-input-file path)) -;; (define (display s) (write-string s)) +;; (define display write-string) +;; (define (command-line-arguments) (cdr (command-line))) +;; (define (get-date-time) +;; (let ((t (seconds->time (current-seconds)))) +;; (vector +;; (time-second t) (time-minute t) (time-hour t) +;; (time-day t) (+ (time-month t) 1) (+ (time-year t) 1900) +;; (time-day-of-week t) (time-day-of-year t) (not (= (time-dst? t) 0))))) ;; ;; chez scheme, invoke with chezscheme --script vm.scm ROM ... ;; (define (open-rom path) (open-file-input-port path)) @@ -246,8 +253,12 @@ (u:debug-stack "WST" wst) (u:debug-stack "RST" rst)) (define (u:debug-stack label st) - (display label) - (u:debug-cells (cdr st) (u8 (- (car st) 8)) (car st) (current-output-port))) + (let* ((cells (cdr st)) + (limit (car st)) + (i (u8 (- limit 8))) + (port (current-output-port))) + (display label port) + (u:debug-cells cells i limit port))) (define (u:debug-cells cells i limit port) (display (if (= i 0) "|" " ") port)