FujiNet is a fantastic new device for the Atari 8 bit line of computers which provides WiFi, and SD card storage among other things, all over SIO. One of the functions provided is APETIME support, a protocol developed by AtariMax as part of their Atari Peripheral Emulator (APE).
I wanted to write a function in Action! to get the time from the FujiNet device using APETIME, which is documented here (https://github.com/FujiNetWIFI/fujinet-platformio/wiki/Accessing-the-Real-Time-Clock). The procedure is straight forward and includes a BASIC example. At the time of this writing there was no Action! example.
I examined the BASIC source and wasn’t happy with it’s length, specifically not liking the large IF block for the number padding. I thought I could do something shorter and more efficient, and I wanted to fully understand the APETIME call before creating an Action! version. In this post, I detail my BASIC program to get (and display) the date/time via APETIME from the FujiNet device.
In my version, I store the APETIME result in a string variable instead of page 6. I also have eliminated the peek block by integrating those into a much shortened IF block that does inline 0 padding of the numbers. For information on the Poke’s see the FujiNet wiki page (linked above). Pokes for location 772 and 773 are the low and high bytes of the buffers string address in memory.
0 REM Program: FNTIME.BAS 1 REM Desc...: Gets time from FujiNet via APETIME using SIO 9 REM ----- Variables 10 DIM FNC$(5),BUF$(6),T$(2),YR$(4),MO$(2),DY$(2),HR$(2),MN$(2),SE$(2) 20 YR$="2000":MO$="00":DY$="00":HR$="00":MN$="00":SE$="00":LT=0 29 REM ----- Get address and MSB/LSB of string buffer 30 BA=ADR(BUF$):BH=INT(BA/256):BL=BA-(BH*256) 39 REM ----- Load assebly routine into function string 40 FOR I=1 TO 5:READ D:FNC$(I)=CHR$(D):NEXT I 99 REM ----- Setup SIO call for APETIME Get 100 POKE 768,69 105 POKE 769,1 110 POKE 770,147 115 POKE 771,64 120 POKE 772,BL:POKE 773,BH 125 POKE 774,15 130 POKE 776,6:POKE 777,0 199 REM ----- Execute assembly SIO call 200 X=USR(ADR(FNC$)) 299 REM ----- Parse 6 byte result into strings 300 T$=STR$(PEEK(BA+2)):LT=LEN(T$) 305 YR$(5-LT)=T$ 310 T$=STR$(PEEK(BA+1)):LT=LEN(T$) 315 MO$(3-LT)=T$ 320 T$=STR$(PEEK(BA)):LT=LEN(T$) 325 DY$(3-LT)=T$ 330 T$=STR$(PEEK(BA+3)):LT=LEN(T$) 335 HR$(3-LT)=T$ 340 T$=STR$(PEEK(BA+4)):LT=LEN(T$) 345 MN$(3-LT)=T$ 350 T$=STR$(PEEK(BA+5)):LT=LEN(T$) 355 SE$(3-LT)=T$ 399 REM ----- Display results 400 ? "Date: ";YR$;".";MO$;".";DY$ 410 ? "Time: ";HR$;":";MN$;":";SE$ 990 END 999 REM ----- Data byte for assembly SIO jump 1000 DATA 104,32,89,228,96
In the next post I will show my Action! solution.