Comments (8)
from agon-mos.
@luisvolkyazul
Here is some RTC TIME-related BBC Basic code which you may find useful (taken from my "Agon Death House" project -- with line numbers removed):
:
MAXINT% = &3B9AC9FF
:
TIME = FN_SET_TIME(10, 30, 0)
PRINT FN_FORMAT_TIME(TRUE)
END
...
REM ::::::::::::::::::::::::::::::::
REM :: Prepend Zeroes To A Number ::
REM ::::::::::::::::::::::::::::::::
DEF FN_PAD_NUMBER(val%, len%)
LOCAL s$
s$ = STR$(val%)
:= STRING$(len% - LEN(s$), "0") + s$
:
REM ::::::::::::::::::::::::::::::::::::
REM :: Set the time of the simple RTC ::
REM :: in ticks (100 ticks / second) ::
REM ::::::::::::::::::::::::::::::::::::
DEF FN_SET_TIME(hours%, minutes%, seconds%)
:= (hours% * 360000 + minutes% * 6000 + seconds% * 100) MOD MAXINT%
:
REM :::::::::::::::::::::::::::::
REM :: Format time as a String ::
REM :::::::::::::::::::::::::::::
REM addColons% may be TRUE or FALSE
DEF FN_FORMAT_TIME(addColons%)
LOCAL hours%, minutes%, seconds%, time%, r$
r$ = "":time% = TIME
hours% = time% DIV 360000
minutes% = (time% - hours% * 360000) DIV 6000
seconds% = (time% - hours% * 360000 - minutes% * 6000) DIV 100
r$ = FN_PAD_NUMBER(hours%, 2):IF addColons% THEN r$ = r$ + ":"
r$ = r$ + FN_PAD_NUMBER(minutes%, 2)
IF addColons% THEN r$ = r$ + ":"
r$ = r$ + FN_PAD_NUMBER(seconds%, 2)
:= r$
:
REM :::::::::::::::::::::::::::::::::::::::
REM :: Pause execution of the program ::
REM :: for a number of ticks (1/100) sec ::
REM :::::::::::::::::::::::::::::::::::::::
DEF PROC_SLEEP(hundredth_seconds%)
LOCAL t
hundredth_seconds% = hundredth_seconds% + (hundredth_seconds% < 0) * -hundredth_seconds%
t = TIME
REPEAT UNTIL ((TIME - t) > hundredth_seconds%)
ENDPROC
from agon-mos.
this line won't work:
90 *TIME STR$(year) STR$(month) STR$(day) STR$(hour) STR$(minutes) STR$(seconds)
reason being is that whatever is after the *
is just passed thru to MOS as a star command to be interpreted. the STR$(year)
etc won't get evaluated but instead gets passed as-is.
to do what you're after you need to construct a string, and pass that to the OSCLI command.
this therefore should become:
90 OSCLI("TIME " + STR$(year) + " " + STR$(month) + " " + STR$(day) + " " + STR$(hour) + " " + STR$(minutes) + " " + STR$(seconds))
from agon-mos.
from agon-mos.
Ok tried the change and think I understand the logic behind it...however I'm getting the following: No such variable at line 90
from agon-mos.
Ok tried the change and think I understand the logic behind it...however I'm getting the following: No such variable at line 90
In line 90, I see that you have SRT$
a couple of times in place of STR$
.
from agon-mos.
@luisvolkyazul let me know if that answers your question and if it does I'l close this card.
from agon-mos.
Not able to get it working yet.
from agon-mos.
Related Issues (20)
- Release needs to include/provide hash. HOT 2
- Potential issue with stack splat in exec16 from *RUN <addr> HOT 2
- Using MOS to load a picture directly to the screen, possible ?
- moscall mos_fread in Z80 mode loads only zeros HOT 2
- Documentation about mos_getkbmap HOT 2
- [Feature request]A mos command to load an image to the screen
- Cannot detect retrieval of data from VDP via API HOT 1
- Feature Request: Allocate the null terminal \0 after "MOS" @ $40 for versioning. HOT 1
- mos_getkey responds to shift.
- Handle final packet(s) from VDP after switching to terminal mode
- Multi-line command history inconsistent behavior HOT 4
- Boot skip
- UART0 full-duplex CTS/RTS HOT 8
- Use 0 wait states for Flash ROM HOT 4
- incorrect work mos 1.04
- MOS should support an extension system HOT 3
- RTC info in VDP Protocol doesn't actually fit
- [help wanted] VBlank from assembly ? HOT 1
- Can't get two keycodes simultaneously neither in alternance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from agon-mos.