Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:31 22 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : cls or box

Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2109
Posted: 05:22pm 10 Oct 2024
Copy link to clipboard 
Print this post

using in a loop I can't see the difference between
cls RGB(black) and box 0,0,mm.hres-1,mm.vres-1,0,,rgb(black)
if I used absolute values for box it would be faster
box 0,0,639,479,0,,rgb(black) vs cls RGB(black), which fastest?
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 06:56pm 10 Oct 2024
Copy link to clipboard 
Print this post

Timer = 0
For i = 1 to 10000
  Box 0,0,639,479,0,,RGB(black)
Next i
Print Timer

Timer = 0
For i = 1 to 10000
  Cls RGB(black)
Next i
Print Timer

Visit Vegipete's *Mite Library for cool programs.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2109
Posted: 07:14pm 10 Oct 2024
Copy link to clipboard 
Print this post

RUN
1355.266
742.25
>
cheers. simple sprite demo testing hdmi modes and layer l not enough memory so cls.
'vga 320x240 mode 2 sprites
mode 2
OPTION BASE 0        ' 0 based arrays
option DEFAULT INTEGER
OPTION EXPLICIT

dim dx(15),dy(15),spx(15),spy(15)
dim cannon(119),missile(15),oldspx(15),oldspy(15)
dim ptr,hiscore,spw,spht,temp,frame,frame_count,spdata,sp1
hiscore=0

'colour shortcuts
const WH =RGB(255,  255,  255) 'WHITE
const YE =RGB(255,  255,    0) 'YELLOW
const LI =RGB(255,  128,  255) 'LILAC
const BR =RGB(255,  128,    0) 'BROWN
const FU =RGB(255,  64,   255) 'FUCHSIA
const RU =RGB(255,  64,     0) 'RUST
const MA =RGB(255,  0,    255) 'MAGENTA
const RE =RGB(255,  0,      0) 'RED
const CY =RGB(0,    255,  255) 'CYAN
const GR =RGB(0,    255,    0) 'GREEN
const CE =RGB(0,    128,  255) 'CERULEAN
const MI =RGB(0,    128,    0) 'MIDGREEN
const CO =RGB(0,    64,   255) 'COBALT
const MY =RGB(0,    64,     0) 'MYRTLE
const BL =RGB(0,    0,    255) 'BLUE
const Bk =RGB(0,    0,      0) 'BLACK
const Gy =RGB(128,  128,  128) 'GREY
const Lg =RGB(210,  210,  210) 'LITEGREY
const Og =RGB(255,  165,    0) 'ORANGE
const PK =RGB(255,  160,  171) 'PINK
const Gd =RGB(255,  215,    0) 'GOLD
const SA =RGB(250,  128,  114) 'SALMON
const BE =RGB(245,  245,  220) 'BEIGE
'
'



cls
restore sprite1
udg1 'draws sprite1 on screen at 10,10
sprite READ 1,10,10,16,16 'reads sprite1 from screen to blit buffer1
restore sprite2
udg1 'draws sprite2 on screen at 10,10
sprite read 2,10,10,16,16 'reads sprite2 from screen to blit buffer2
'
for temp=0 to 15 'set up start sprite positions and directions
'do
 'dx(temp)=(int(rnd*4)+1)-(int(rnd*8)+1)
'loop until dx(temp)<>0
'do
 'dy(temp)=(int(rnd*4)+1)-(int(rnd*8)+1)
'loop until dy(temp)<>0
 spx(temp)=(mm.hres /2)-32+int(rnd*64)
 spy(temp)=(mm.vres /2)-20+int(rnd*40)    
do :dx(temp)=int(rnd*5)-int(rnd*9):loop until dx(temp)<>0
do :dy(temp)=int(rnd*5)-int(rnd*9):loop until dy(temp)<>0

next temp
'
FRAMEBUFFER CREATE F
'FRAMEBUFFER LAYER 0 'L
 'FRAMEBUFFER WRITE L
'cls RGB(black)

 FRAMEBUFFER WRITE f

do 'demo moving sprite
 'FRAMEBUFFER COPY l,f
 'box 0,0,mm.hres-1,mm.vres-1,0,,rgb(black)
 cls RGB(black)
   for temp=0 to 15
'        if sprite_status(temp)=1 then 'is sprite active
           if spx(temp)> mm.hres-32 then 'check right edge
             dx(temp)= 0-dx(temp)
           elseif spx(temp)<16 then 'check left edge
             dx(temp)= 0-dx(temp)
           end if
           if spy(temp)>mm.vres-32 then 'check bottom edge
             dy(temp)= 0-dy(temp)
           elseif spy(temp)<16 then 'check top edge
             dy(temp)= 0-dy(temp)
           end if
     '
           spx(temp)=spx(temp)+dx(temp):spy(temp)=spy(temp)+dy(temp) 'get new position for draw
     '
               if frame=0 then'which sprite to draw
                 sprite WRITE 1,spx(temp),spy(temp) 'draw sprite1 at new position
               else
                 sprite WRITE 2,spx(temp),spy(temp) 'draw sprite2 at new position
               end if
   next temp
 
 FRAMEBUFFER COPY f,N
'
   frame_count=frame_count+1 'when to change sprite
   if frame_count=10 then
     frame=not frame
     frame_count=0
   end if
   pause 50
loop
'
sub udg1 'draws 16x16 data for blit to copy
 for spht=0 to 15
   for spw=0 to 15
     read sp1
     pixel spw+10,spht+10,sp1
   next spw
 next spht
end sub
'
sprite1:
data wh,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,wh
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,ye,ye,bk,bk,ye,ye,ye,bk,bk,bk,bk
data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
data bk,ye,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,ye,bk
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bl,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye
data bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk
data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk
sprite2:
data bl,bl,bl,bl,bl,bk,bk,bk,bk,bk,bk,bl,bl,bl,bl,bl
data bk,bl,re,re,re,bl,bl,bk,bk,bl,bl,re,re,re,bl,bk
data bk,bk,bl,wh,wh,re,bl,bk,bk,bl,re,wh,wh,bl,bk,bk
data bk,bk,bk,bl,re,wh,bl,bk,bk,bl,wh,re,bl,bk,bk,bk
data bk,bk,bk,bk,bl,wh,bl,bk,bk,bl,wh,bl,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bl,bl,bk,bk,bl,bl,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,ye,ye,bk,bk,ye,ye,bk,bk,bk,bk,bk
data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
data bk,bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk,bk
data bk,bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk,bk
data bk,bk,ye,bk,bk,bk,bk,bk,bk,bk,bk,bk,bk,ye,bk,bk
data bk,bk,bk,ye,ye,bk,bk,bk,bk,bk,bk,ye,ye,bk,bk,bk
data bk,bk,bk,bk,ye,ye,bk,bk,bk,bk,ye,ye,bk,bk,bk,bk
data bk,bk,bk,bk,bk,ye,bk,bk,bk,bk,ye,bk,bk,bk,bk,bk
data bk,bk,bk,bk,bk,bk,ye,bk,bk,ye,bk,bk,bk,bk,bk,bk
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024