Skip to content

Commit

Permalink
Fix OSWORD01 and 02. TIME
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Aug 7, 2021
1 parent 871f08a commit e9ff191
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 6 additions & 10 deletions osWord.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ func execOSWORD(env *environment) {
*/
duration := time.Since(env.referenceTime)
ticks := duration.Milliseconds() / 10
buffer := env.peekWord(xy)
env.poke5bytes(buffer, uint64(ticks))
env.poke5bytes(xy, uint64(ticks))

env.log(fmt.Sprintf("OSWORD01('read system clock',BUF=0x%04x)=%v", buffer, ticks&0xff_ffff_ffff))
env.log(fmt.Sprintf("OSWORD01('read system clock',BUF=0x%04x)=%v", xy, ticks&0xff_ffff_ffff))

case 0x02: // Write system clock
/*
This routine may be used to set the system clock to a five byte value contained
in memory at the address contained in the X and Y registers.
*/
buffer := env.peekWord(xy)
ticks := env.peek5bytes(buffer)
ticks := env.peek5bytes(xy)
duration := time.Duration(ticks * 100 * 1000)
env.referenceTime = time.Now()
env.referenceTime.Add(duration * -1)
Expand All @@ -76,10 +74,9 @@ func execOSWORD(env *environment) {
*/
duration := time.Since(env.lastTimerUpdate)
timer := env.timer + uint64(duration.Milliseconds()/10)
buffer := env.peekWord(xy)
env.poke5bytes(buffer, uint64(timer))
env.poke5bytes(xy, uint64(timer))

env.log(fmt.Sprintf("OSWORD03('read interval timer',BUF=0x%04x)=%v", buffer, timer&0xff_ffff_ffff))
env.log(fmt.Sprintf("OSWORD03('read interval timer',BUF=0x%04x)=%v", xy, timer&0xff_ffff_ffff))

case 0x04: // Write interval timer
/*
Expand All @@ -88,8 +85,7 @@ func execOSWORD(env *environment) {
reaches zero. Thus setting the timer to &FFFFFFFFFE would cause an event
after two hundredths of a second.
*/
buffer := env.peekWord(xy)
env.timer = env.peek5bytes(buffer)
env.timer = env.peek5bytes(xy)
env.lastTimerUpdate = time.Now()

env.log(fmt.Sprintf("OSWORD04('write interval timer',TIMER=%v)", env.timer))
Expand Down
3 changes: 3 additions & 0 deletions test/Basic.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LOAD "BASICFILE"
SAVE "BASICFILE"
PRINT TIME
3 changes: 3 additions & 0 deletions test/Lisp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(LOAD 'LISPFILE)
(SAVE 'LISPFILE)
(TIME)

0 comments on commit e9ff191

Please sign in to comment.