Improved clock
This commit is contained in:
parent
656484b4e1
commit
a3ce59fa93
|
@ -16,21 +16,27 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
|
|
||||||
typedef unsigned char Uint8;
|
typedef unsigned char Uint8;
|
||||||
|
|
||||||
|
int
|
||||||
|
clamp(int val, int min, int max)
|
||||||
|
{
|
||||||
|
return (val >= min) ? (val <= max) ? val : max : min;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
printf("60 points on a circle128(bytex,bytey):\n\n");
|
printf("60 points on a circle128(bytex,bytey):\n\n");
|
||||||
for(i = 0; i < 60; ++i) {
|
for(i = 0; i < 60; ++i) {
|
||||||
double cx = 128, cy = 128, r = 127;
|
double cx = 128, cy = 128, r = 128;
|
||||||
double pos = (60 - i + 30) % 60;
|
double pos = (i - 15) % 60;
|
||||||
double deg = (pos / 60.0) * 360.0;
|
double deg = (pos / 60.0) * 360.0;
|
||||||
double rad = deg * (PI / 180);
|
double rad = deg * (PI / 180);
|
||||||
double x = cx + r * cos(rad);
|
double x = cx + r * cos(rad);
|
||||||
double y = cy + r * sin(rad);
|
double y = cy + r * sin(rad);
|
||||||
if(i > 0 && i % 8 == 0)
|
if(i > 0 && i % 8 == 0)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("%02x%02x ", (Uint8)x, (Uint8)y);
|
printf("%02x%02x ", (Uint8)clamp(x, 0x00, 0xff), (Uint8)clamp(y, 0x00, 0xff));
|
||||||
}
|
}
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
( vectors )
|
( vectors )
|
||||||
|
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|0130 ;Controller { p1 1 }
|
|0130 ;Controller { p1 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|0130 ;Controller { buttons 1 }
|
|0130 ;Controller { buttons 1 }
|
||||||
|0140 ;Keys { key 1 }
|
|0140 ;Keys { key 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
%RTN { JMP2r }
|
%RTN { JMP2r }
|
||||||
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
|
%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
|
||||||
%SCALE { #0002 DIV2 #0020 ADD2 }
|
%SCALEX { #0002 DIV2 ~Screen.width #0002 DIV2 ADD2 #0040 SUB2 }
|
||||||
|
%SCALEY { #0002 DIV2 ~Screen.height #0002 DIV2 ADD2 #0040 SUB2 }
|
||||||
%12HOURS { DUP #0c GTH #0c MUL SUB }
|
%12HOURS { DUP #0c GTH #0c MUL SUB }
|
||||||
|
%MOD { DUP2 DIV MUL SUB }
|
||||||
|
|
||||||
;current { second 1 }
|
;current { second 1 }
|
||||||
;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
|
;line { x0 2 y0 2 x 2 y 2 sx 2 sy 2 dx 2 dy 2 e1 2 e2 2 }
|
||||||
|
@ -11,11 +13,11 @@
|
||||||
( devices )
|
( devices )
|
||||||
|
|
||||||
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|
|0100 ;Console { pad 8 char 1 byte 1 short 2 }
|
||||||
|0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 }
|
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|0190 ;Time { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 get 1 }
|
|0190 ;Time { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 get 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
@ -36,46 +38,37 @@ BRK
|
||||||
~Time.second =current.second
|
~Time.second =current.second
|
||||||
|
|
||||||
( clear )
|
( clear )
|
||||||
#0080 SCALE #0080 SCALE ~needles.sx ~needles.sy #00 ,draw-line JSR2
|
#0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #00 ,draw-line JSR2
|
||||||
#0080 SCALE #0080 SCALE ~needles.mx ~needles.my #00 ,draw-line JSR2
|
#0080 SCALEX #0080 SCALEY ~needles.mx ~needles.my #00 ,draw-line JSR2
|
||||||
#0080 SCALE #0080 SCALE ~needles.hx ~needles.hy #00 ,draw-line JSR2
|
#0080 SCALEX #0080 SCALEY ~needles.hx ~needles.hy #00 ,draw-line JSR2
|
||||||
|
|
||||||
( place )
|
( place )
|
||||||
#00 ~Time.second #0002 MUL2 ,table ADD2 LDR2
|
#00 ~Time.second #0002 MUL2 ,table ADD2 LDR2
|
||||||
#00 SWP SCALE =needles.sy #00 SWP SCALE =needles.sx
|
#00 SWP SCALEY =needles.sy #00 SWP SCALEX =needles.sx
|
||||||
#00 ~Time.minute #0002 MUL2 ,table ADD2 LDR2
|
#00 ~Time.minute #0002 MUL2 ,table ADD2 LDR2
|
||||||
#00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALE =needles.my
|
#00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEY =needles.my
|
||||||
#00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALE =needles.mx
|
#00 SWP #0004 DIV2 #0003 MUL2 #0020 ADD2 SCALEX =needles.mx
|
||||||
#00 ~Time.hour 12HOURS #05 MUL #0002 MUL2 ,table ADD2 LDR2
|
#00 ~Time.hour 12HOURS #05 MUL #0002 MUL2 ,table ADD2 LDR2
|
||||||
#00 SWP #0002 DIV2 #0040 ADD2 SCALE =needles.hy
|
#00 SWP #0002 DIV2 #0040 ADD2 SCALEY =needles.hy
|
||||||
#00 SWP #0002 DIV2 #0040 ADD2 SCALE =needles.hx
|
#00 SWP #0002 DIV2 #0040 ADD2 SCALEX =needles.hx
|
||||||
|
|
||||||
( draw )
|
( draw )
|
||||||
#0080 SCALE #0080 SCALE ~needles.sx ~needles.sy #02 ,draw-line JSR2
|
#0080 SCALEX #0080 SCALEY ~needles.sx ~needles.sy #02 ,draw-line JSR2
|
||||||
#0080 SCALE #0080 SCALE ~needles.mx ~needles.my #01 ,draw-line JSR2
|
#0080 SCALEX #0080 SCALEY ~needles.mx ~needles.my #01 ,draw-line JSR2
|
||||||
#0080 SCALE #0080 SCALE ~needles.hx ~needles.hy #03 ,draw-line JSR2
|
#0080 SCALEX #0080 SCALEY ~needles.hx ~needles.hy #03 ,draw-line JSR2
|
||||||
|
|
||||||
,draw-circle JSR2
|
,draw-circle JSR2
|
||||||
|
|
||||||
( display )
|
( display )
|
||||||
#0000 =Sprite.x
|
~Screen.height #0002 DIV2 #0048 ADD2 =Sprite.y
|
||||||
,font_hex #00 ~Time.hour #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
|
~Screen.width #0002 DIV2
|
||||||
#02 =Sprite.color
|
DUP2 #0020 SUB2 =Sprite.x ,font_hex #00 ~Time.hour #0a DIV #08 MUL ADD2 =Sprite.addr #02 =Sprite.color
|
||||||
#0008 =Sprite.x
|
DUP2 #0018 SUB2 =Sprite.x ,font_hex #00 ~Time.hour #0a MOD #08 MUL ADD2 =Sprite.addr #02 =Sprite.color
|
||||||
,font_hex #00 ~Time.hour #0f AND #08 MUL ADD2 =Sprite.addr
|
DUP2 #0008 SUB2 =Sprite.x ,font_hex #00 ~Time.minute #0a DIV #08 MUL ADD2 =Sprite.addr #02 =Sprite.color
|
||||||
#02 =Sprite.color
|
DUP2 =Sprite.x ,font_hex #00 ~Time.minute #0a MOD #08 MUL ADD2 =Sprite.addr #02 =Sprite.color
|
||||||
#0018 =Sprite.x
|
DUP2 #0010 ADD2 =Sprite.x ,font_hex #00 ~Time.second #0a DIV #08 MUL ADD2 =Sprite.addr #02 =Sprite.color
|
||||||
,font_hex #00 ~Time.minute #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
|
DUP2 #0018 ADD2 =Sprite.x ,font_hex #00 ~Time.second #0a MOD #08 MUL ADD2 =Sprite.addr #02 =Sprite.color
|
||||||
#02 =Sprite.color
|
POP2
|
||||||
#0020 =Sprite.x
|
|
||||||
,font_hex #00 ~Time.minute #0f AND #08 MUL ADD2 =Sprite.addr
|
|
||||||
#02 =Sprite.color
|
|
||||||
#0030 =Sprite.x
|
|
||||||
,font_hex #00 ~Time.second #f0 AND #04 SFT #08 MUL ADD2 =Sprite.addr
|
|
||||||
#02 =Sprite.color
|
|
||||||
#0038 =Sprite.x
|
|
||||||
,font_hex #00 ~Time.second #0f AND #08 MUL ADD2 =Sprite.addr
|
|
||||||
#02 =Sprite.color
|
|
||||||
|
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@ -88,9 +81,9 @@ BRK
|
||||||
#00 #3c
|
#00 #3c
|
||||||
$loop
|
$loop
|
||||||
( load ) OVR #00 SWP #0002 MUL2 ,table ADD2 LDR2
|
( load ) OVR #00 SWP #0002 MUL2 ,table ADD2 LDR2
|
||||||
#00 SWP SCALE =Screen.y
|
#00 SWP SCALEY =Screen.y
|
||||||
#00 SWP SCALE =Screen.x
|
#00 SWP SCALEX =Screen.x
|
||||||
OVR #00 EQU #01 ADD =Screen.color
|
OVR #0f MOD #00 EQU #01 ADD =Screen.color
|
||||||
( incr ) SWP #01 ADD SWP
|
( incr ) SWP #01 ADD SWP
|
||||||
DUP2 LTH ^$loop JNZ
|
DUP2 LTH ^$loop JNZ
|
||||||
POP2
|
POP2
|
||||||
|
@ -125,14 +118,14 @@ RTN
|
||||||
|
|
||||||
@table ( 60 positions on a circle in bytes )
|
@table ( 60 positions on a circle in bytes )
|
||||||
[
|
[
|
||||||
0180 018d 039a 07a7 0bb3 12bf 19ca 21d4
|
8000 8d00 9a02 a706 b40b c011 cb18 d520
|
||||||
2bde 35e6 40ed 4cf4 58f8 65fc 72fe 80ff
|
df2a e734 ee40 f44b f958 fd65 ff72 ff80
|
||||||
8dfe 9afc a7f8 b3f4 bfed cae6 d4de ded4
|
ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df
|
||||||
e6ca edbf f4b3 f8a7 fc9a fe8d ff80 fe72
|
cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff
|
||||||
fc65 f858 f44c ed40 e635 de2b d421 ca19
|
65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb
|
||||||
bf12 b30b a707 9a03 8d01 7f01 7201 6503
|
11c0 0bb4 06a7 029a 008d 0080 0072 0265
|
||||||
5807 4c0b 4012 3519 2b21 212b 1935 1240
|
0658 0b4b 113f 1834 202a 2a20 3418 3f11
|
||||||
0b4c 0758 0365 0172
|
4b0b 5806 6502 7200
|
||||||
]
|
]
|
||||||
|
|
||||||
@font_hex ( 0-F )
|
@font_hex ( 0-F )
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
|0110 ;Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
||||||
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
( vectors )
|
( vectors )
|
||||||
|
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 BRK
|
|0204 BRK
|
||||||
|0208 BRK
|
|0208 BRK
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
|0190 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 pad 4 get 1 }
|
|0190 ;DateTime { year 2 month 1 day 1 hour 1 minute 1 second 1 dow 1 doy 2 isdst 1 pad 4 get 1 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
@RESET
|
@RESET
|
||||||
( theme ) #13fd =System.r #1ef3 =System.g #1bf2 =System.b
|
( theme ) #03fd =System.r #0ef3 =System.g #0bf2 =System.b
|
||||||
#01 =fps.current
|
#01 =fps.current
|
||||||
|
|
||||||
#000c
|
#000c
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
|0150 ;Mouse { x 2 y 2 state 1 chord 1 }
|
||||||
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
|0160 ;File { pad 8 name 2 length 2 load 2 save 2 }
|
||||||
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
|01F0 ;System { pad 8 r 2 g 2 b 2 }
|
||||||
|0200 ,RESET JMP2
|
|0200 ^RESET JMP
|
||||||
|0204 ,ERROR JMP2
|
|0204 ,ERROR JMP2
|
||||||
|0208 ,FRAME JMP2
|
|0208 ,FRAME JMP2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue