From 153b494e6124153fef5c87501cd0c6d90ad86d81 Mon Sep 17 00:00:00 2001 From: Wayne Warthen Date: Sun, 5 Apr 2020 17:03:17 -0700 Subject: [PATCH] CP/M 3 Date Hack - Hack to allow INTRTC to increment time without destroying the date --- Source/CPM3/boot.z80 | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Source/CPM3/boot.z80 b/Source/CPM3/boot.z80 index b80d7631..53e36f47 100644 --- a/Source/CPM3/boot.z80 +++ b/Source/CPM3/boot.z80 @@ -490,16 +490,21 @@ time$ret: time$get: ; RTC -> cpm date/time in SCB - + ; read time from RTC ld b,020h ; HBIOS func: get time ld hl,tim$buf ; time buffer rst 08 ; do it ret nz ; bail out on error + ld a,(datehack) + or a + jr nz,time$get1 + ; convert yymmss in time buffer -> cpm3 epoch date offset call date2cpm ; time buf (yr, mon, day) -> SCB (@date) +time$get1: ; set time fields in SCB ld a,(tim$hr) ; get hour from time buf ld (@hour),a ; ... and put in SCB @@ -514,7 +519,23 @@ time$set: ; CPM date/time in SCB -> RTC ; convert CPM3 epoch date offset in SCB -> yymmss in time buffer - call cpm2date ; SCB (@date) -> time buf (yr, mon, day) + ;call cpm2date ; SCB (@date) -> time buf (yr, mon, day) + + ; this is a temporary hack!!! + ; since we cannot actually set the date on the RTC, we + ; just read the current RTC date and use that so that we + ; don't clobber a potentially good date. + ; read time from RTC + ld b,020h ; HBIOS func: get time + ld hl,tim$buf ; time buffer + rst 08 ; do it + ret nz ; bail out on error + ; + ; now we set a hack active flag so that future time$get + ; calls do not update the date field in the SCB + ; + ld a,0FFh ; true value + ld (datehack),a ; save it ; copy CPM3 time values from SCB -> time buffer ld a,(@hour) ; get hour from SCB @@ -629,6 +650,8 @@ tim$hr db 01h tim$min db 02h tim$sec db 03h +datehack db 00h + open: ld c,15 jp bdos