Posted: 03:58pm 02 Apr 2025 Copy link to clipboard
javavi Guru
Diagonal Scrolling Clock
Const Mode.N=2 Const Font.N=1 Const T.Scale=4 Const T.Size=Len(Time$) MODE Mode.N Const X.Res=MM.HRES,Y.Res=MM.VRES Font Font.N Const X.FSize=MM.Info(FONTWIDTH) Const Y.FSize=MM.Info(FONTHEIGHT) Const X.Offset=X.FSize*T.Scale*T.Size\2 Const Y.Offset=Y.FSize*T.Scale\2 Dim integer X.Dir=1,Y.Dir=1 Dim integer X.Pos=MM.HRES\2,Y.Pos=MM.VRES\2 Dim integer FC,BC Dim Clr(15)=(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) Colour Map Clr(),Clr() '================================================= FRAMEBUFFER LAYER 0 FRAMEBUFFER WRITE L Font 9 '------------------------------------------------ Do If BC=0 Then BC=Int(Rnd*15)+1 Colour Clr(BC) Print @(0,0); For n=1 To (X.Res\8)*(Y.Res\8) Print Chr$(32+Int(Rnd*3)); Next EndIf
If X.Dir=1 Then Blit READ 1, 0,0,1,MM.VRES Blit 1,0,0,0,MM.HRES-1,MM.VRES Blit Write 1, MM.HRES-1,0 Else Blit READ 1, MM.HRES-1,0,1,MM.VRES Blit 0,0,1,0,MM.HRES-1,MM.VRES Blit Write 1, 0,0 EndIf Blit Close 1 If Y.Dir=1 Then Blit READ 1, 0,0,MM.HRES,1 Blit 0,1,0,0,MM.HRES,MM.VRES-1 Blit Write 1, 0,MM.VRES-1 Else Blit READ 1, 0,MM.VRES-1,MM.HRES,1 Blit 0,0,0,1,MM.HRES,MM.VRES-1 Blit Write 1, 0,0 EndIf Blit Close 1 '------------------------------------------------ Pause 20 FRAMEBUFFER WRITE N If FC=0 Then FC=Int(Rnd*15)+1 Text X.Pos,Y.Pos,Time$,"CM",Font.N,T.Scale,Clr(FC) Inc X.Pos,X.Dir:Inc Y.Pos,Y.Dir If X.Pos-X.Offset<0 Then X.Dir=1:FC=0 If X.Pos+X.Offset>MM.HRES Then X.Dir=-1:FC=0 If Y.Pos-Y.Offset<0 Then Y.Dir=1:BC=0 If Y.Pos+Y.Offset>MM.VRES Then Y.Dir=-1:BC=0 FRAMEBUFFER WRITE L Loop While Inkey$="" '================================================ DefineFont 9 04200808 80402010 08040201 01020408 10204080 08080808 08080808 End DefineFont
Posted: 06:05pm 02 Apr 2025 Copy link to clipboard
al18 Senior Member
Nice - thanks for the program
Posted: 08:46am 03 Apr 2025 Copy link to clipboard
Volhout Guru
Hi javavi,
Scolling background can be made easier.
In your previous clock you perform these commands to copy data from top of the screen to bottom of the screen.
In PicoMite there is the SPRITE SCROLL command that scrolls a selected layer. This command does the same as the above 4 lines.
Sprite scroll 0,1
The SPRITE SCROLL command can scroll all directions up/down/left/right. Individual, and simultaneous (diagonal).
Regards,
Volhout
P.s. in your later clocks you would replace
If X.Dir=1 Then Blit READ 1, 0,0,1,MM.VRES Blit 1,0,0,0,MM.HRES-1,MM.VRES Blit Write 1, MM.HRES-1,0 Else Blit READ 1, MM.HRES-1,0,1,MM.VRES Blit 0,0,1,0,MM.HRES-1,MM.VRES Blit Write 1, 0,0 EndIf Blit Close 1 If Y.Dir=1 Then Blit READ 1, 0,0,MM.HRES,1 Blit 0,1,0,0,MM.HRES,MM.VRES-1 Blit Write 1, 0,MM.VRES-1 Else Blit READ 1, 0,MM.VRES-1,MM.HRES,1 Blit 0,0,0,1,MM.HRES,MM.VRES-1 Blit Write 1, 0,0 EndIf Blit Close 1
with
Sprite scroll X.Dir,Y.Dir
Edited 2025-04-03 19:07 by Volhout
Posted: 04:49pm 03 Apr 2025 Copy link to clipboard
javavi Guru
Hi Volhout, Thank you for the tip, I must have missed it. It makes it look much easier. Regards,javavi.
Const Mode.N=2 Const Font.N=1 Const T.Scale=4 Const T.Size=Len(Time$) MODE Mode.N Const X.Res=MM.HRES,Y.Res=MM.VRES Font Font.N Const X.FSize=MM.Info(FONTWIDTH) Const Y.FSize=MM.Info(FONTHEIGHT) Const X.Offset=X.FSize*T.Scale*T.Size\2 Const Y.Offset=Y.FSize*T.Scale\2 Dim integer X.Dir=1,Y.Dir=1 Dim integer X.Pos=MM.HRES\2,Y.Pos=MM.VRES\2 Dim integer FC,BC Dim Clr(15)=(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) Colour Map Clr(),Clr() '================================================= FRAMEBUFFER LAYER 0 FRAMEBUFFER WRITE L Font 9 Do If BC=0 Then BC=Int(Rnd*15)+1 Colour Clr(BC) Print @(0,0); For n=1 To (X.Res\8)*(Y.Res\8) Print Chr$(32+Int(Rnd*3)); Next EndIf
Sprite scroll X.Dir,Y.Dir Pause 20
FRAMEBUFFER WRITE N If FC=0 Then FC=Int(Rnd*15)+1 Text X.Pos,Y.Pos,Time$,"CM",Font.N,T.Scale,Clr(FC) Inc X.Pos,X.Dir:Inc Y.Pos,Y.Dir If X.Pos-X.Offset<0 Then X.Dir=1:FC=0 If X.Pos+X.Offset>MM.HRES Then X.Dir=-1:FC=0 If Y.Pos-Y.Offset<0 Then Y.Dir=1 If Y.Pos+Y.Offset>MM.VRES Then Y.Dir=-1:BC=0 FRAMEBUFFER WRITE L Loop While Inkey$="" '================================================ DefineFont 9 04200808 80402010 08040201 01020408 10204080 08080808 08080808 End DefineFont
Posted: 07:28pm 07 Apr 2025 Copy link to clipboard
javavi Guru
Maze-Clock
MODE 1 Const X.Res=MM.HRES,Y.Res=MM.VRES Const Font.Addr=MM.Info(FONT ADDRESS 1)+4 Dim string CH$ LENGTH 1 Dim string ST$ LENGTH 8 Dim integer X.Dir=1,Y.Dir=1 Dim integer X.Pos=5,Y.Pos=15 Dim integer n,FC,BC Dim CM(15)=(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) Colour Map CM(),CM() '================================================= Font 9 Print @(0,0); For n=1 To (X.Res\8)*(Y.Res\8) Print Chr$(50+Int(Rnd*3)); Next
Do If FC=0 Then FC=Int(Rnd*15)+1 TILE 0,0,CM(FC),0,80,40 If Cint(Rnd) Then CH$="1" Else CH$="0" EndIf ST$=Time$ PrintTime X.Pos,Y.Pos,ST$,CH$ Pause 250 PrintTime X.Pos,Y.Pos,ST$,"C" Inc X.Pos,X.Dir Inc Y.Pos,Y.Dir If X.Pos<0 Then X.Dir=1:FC=0 If X.Pos+64>80 Then X.Dir=-1:FC=0 If Y.Pos<0 Then Y.Dir=1:FC=0 If Y.Pos+11>60 Then Y.Dir=-1:FC=0 Loop While Inkey$="" End '-------------------------------------- Sub PrintTime(X,Y,TXT$,CH$) Local string T$ LENGTH 8 Local integer Ti,Xi,FA,FS,FD,FH,FW X=X*8:Y=Y*8 Print @(X,Y); For FH=0 To 10 XI=X For Ti=1 To Len(TXT$) FS=Asc(Mid$(TXT$,Ti,1))-32 FA=Font.Addr+FS*12+FH FD=PEEK(BYTE FA) T$=Bin$(FD,8) For FW=1 To 8 If CH$="C" Then If Mid$(T$,FW,1)="1" Then Print @(Xi,Y)Chr$(50+Int(Rnd*3)); Else If Mid$(T$,FW,1)="1" Then Print @(Xi,Y)CH$; EndIf Inc Xi,8 Next Next Inc Y,8 Print @(X,Y); Next End Sub '-------------------------------------- DefineFont 9 05300808 00000000 00000000 FFFFFFFF FFFFFFFF 08080808 08080808 80402010 08040201 01020408 10204080 End DefineFont
Posted: 05:56pm 20 Apr 2025 Copy link to clipboard
javavi Guru
Perspective, Prospettiva, Perspicere
MODE 1 For Y=1 To 480 For X=1 To 640 Z=X-320 If (Z*64)Mod Y=0 Then Pixel X,Y Next Next
Posted: 06:40pm 20 Apr 2025 Copy link to clipboard
javavi Guru
MODE 1 XR=MM.HRES-1:YR=MM.VRES-1 For Y=1 To YR For X=1 To XR Z=X-320 If (Z*64)Mod Y=0 Then Pixel X,YR Next Sprite scroll 0,1 Next
Posted: 10:07pm 20 Apr 2025 Copy link to clipboard
stanleyella Guru
'map switching demo Dim integer cmap(13)
'Clear the screen MODE 2 Map reset CLS rgb(black)
'Set up colours in the array cmap(1)=RGB(white) cmap(2)=RGB(black) cmap(3)=RGB(black) cmap(4)=RGB(black) cmap(5)=RGB(black) cmap(6)=RGB(black)
' Do an initial update of the Colour map to set up our colours domap
hline=76:hy=1:mch=1 line 0,75,319,75,,RGB(white)
do'draw horizontal lines line 0,hline,319,hline,,map(mch) inc mch:if mch=7 then mch=1 hline=hline+hy:hy=hy+0.6 loop until hline>240
xb=-149:xt=10:mch=7 do'draw vertical lines line xb,239,xt,75,,map(mch) inc mch:if mch=13 then mch=7 xb=xb+8:xt=xt+4 loop until xb>=479
' lr=0 do cmap(0)=cmap(6) For i=5 To 0 Step -1' move horizontal lines cmap(i+1)=cmap(i) Next
if lr<40 then cmap(6)=cmap(12) For i=11 To 6 Step -1' move vertical lines cmap(i+1)=cmap(i) Next else cmap(12)=cmap(7) For i=7 To 12' move vertical lines cmap(i)=cmap(i+1) Next end if inc lr:if lr>80 then lr=0
domap pause 100 loop
end
Sub domap Local integer i Map (0)=RGB(black) For i=1 To 12 Map (i)=cmap(i) Next Map set End Sub
Posted: 07:23pm 29 Apr 2025 Copy link to clipboard
javavi Guru
XOR Patterns
MODE 2 Do R1=Int(Rnd*10)+1 R2=Int(Rnd*10)+10 R3=Int(Rnd*10)+20 C1=Map(Int(Rnd*15)+1) C2=Map(Int(Rnd*15)+1) C3=Map(Int(Rnd*15)+1) For Y=0 To 240 For X=0 To 320 Color 0: Pixel X,Y K=X Xor Y If K Mod R1=0 Then Color C1: Pixel X,Y If K Mod R2=0 Then Color C2: Pixel X,Y If K Mod R3=0 Then Color C3: Pixel X,Y Next Next Loop
Posted: 02:59pm 01 May 2025 Copy link to clipboard
mozzie Regular Member
G'day Javavi, Thankyou for all of these programs, always look forward to trying them out and adjusting things to see how they work.
That last one is amazing, 18 lines of code to mesmerize
Regards, Lyle.
Posted: 07:55pm 01 May 2025 Copy link to clipboard
Bleep Guru
Just playing, :-) here is the same pattern as above, but speed up, using some of the Math array functions and then plotting a whole line of Pixels at a time.
Dim Integer C(319),X(319),Y(319),D,K,I,J,R1,R2,R3,C1,C2,C3 MODE 2 'Initialise the X array 0 to 319 sequentially. For J=0 To 319:X(J)=J:Next Do 'Colour (RGB(255,255,255)) 'Print Timer:Timer =0 R1=Int(Rnd*10)+1 R2=Int(Rnd*10)+10 R3=Int(Rnd*10)+20 C1=Map(Int(Rnd*15)+1) C2=Map(Int(Rnd*15)+1) C3=Map(Int(Rnd*15)+1)
For I=0 To 239 'Initialise Y array to line number, C array to 0 (Black) Math Set I,Y() Math Set 0,C() For J=0 To 319 K=J Xor I If Not(K Mod R3) Then:C(J)=C3 ElseIf Not(K Mod R2) Then:C(J)=C2 ElseIf Not(K Mod R1) Then:C(J)=C1 EndIf Next 'Display whole line of pixels in one go. Pixel X(),Y(),C() Next Loop