Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:36 14 May 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 : CMM2: V5.06.00b7 - 3D engine

     Page 3 of 6    
Author Message
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 02:52pm 01 Dec 2020
Copy link to clipboard 
Print this post

  Quote  Maybe the scanline fill could be better, it was used in 8 bit era... And I remember in final step the draw line could be changed to get line from pattern sample, so it can not just colors but also patterns...
jirsoft

That seems like it was a very efficient method.  So, those functions just scan along the scanline for the next boundary color and then draw a line or a segment of a pattern. I guess that for islands in the field it then skip to the next non-boundary color. Is that correct? That might cut way down on the recursion needed or am I wrong. Do you know how they implemented gradient fills?  Thanks.

UPDATE:
While I was typing this matherp posted an update.  He is scary fast and responsive on this project. Just amazing.
Edited 2020-12-02 00:59 by mclout999
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 449
Posted: 04:07pm 01 Dec 2020
Copy link to clipboard 
Print this post

Yes, Peter is scary fast. I don't know how he implements these new features so fast. Maybe he lives in a space / time gap and his day has more then 24h. Just kidding.  
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 05:42pm 01 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  Minor update to the PIXEL FILL posted at 14:32 UTC - no version change. Much faster and no obvious size limits

For anyone interested below is the fill algorithm

void floodFillScanline(int x, int y)


Pretty dang good. But a quick look at the scanline algorithm shows how to break it:
mode 1,8
cls

circle 200,200,150
circle 300,200,150
circle 250,275,150

print @(0,500) "Press a key to fill the center with WHITE..."
do : loop until inkey$ <> ""

pixel fill 250,250,rgb(white)

Filling with a colour other than the boundary colour works awesome. Change the colour in the last line to something else, like "red" to see how awesome.

The work around is to fill twice, first with a 'safe' colour, then with the desired colour. A 'safe' colour is one that does not appear anywhere on the screen.
Edited 2020-12-02 03:48 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 06:05pm 01 Dec 2020
Copy link to clipboard 
Print this post

  Quote  But a quick look at the scanline algorithm shows how to break it:


That's easily fixed - try downloading again. I've even made it faster  

void floodFillScanline(int x, int y)
{
 if(filloldcolour == ConvertedColour) return;
 if(ReadPixelFast(x,y) != filloldcolour) return;

 int x1, xe, xs;

 //draw current scanline from start position to the right
 x1 = x;
 xe = -1;
 while(x1 < fillmaxW && ReadPixelFast(x1, y) == filloldcolour)
 {
xe=x1;
   x1++;
 }
 if(xe != -1){
 DrawHLineFast(x,y,xe,ConvertedColour);
 }
 //draw current scanline from start position to the left
 x1 = x - 1;
 xs = -1;
 while(x1 >= 0 && ReadPixelFast(x1, y) == filloldcolour)
 {
xs = x1;
   x1--;
 }
 if(xs!=-1){
 DrawHLineFast(xe,y,x-1,ConvertedColour);
 }

 //test for new scanlines above
 x1 = x;
 if(xe!=-1){
 while(x1 <= xe)
 {
if(y > 0 && ReadPixelFast(x1, (y - 1)) == filloldcolour)
{
 floodFillScanline(x1, y - 1);
}
x1++;
 }
 }
 x1 = x - 1;
 if(xs!=-1){
 while(x1 >= xs )
 {
if(y > 0 && ReadPixelFast(x1, (y - 1)) == filloldcolour)
{
 floodFillScanline( x1, y - 1);
}
x1--;
 }
 }

 //test for new scanlines below
 x1 = x;
 if(xe!=-1){
 while(x1 <= xe)
 {
if(y < fillmaxH - 1 && ReadPixelFast(x1, (y + 1)) == filloldcolour)
{
 floodFillScanline( x1, y + 1);
}
x1++;
 }
 }
 x1 = x - 1;
 if(xs!=-1){
 while(x1 >= xs)
 {
if(y < fillmaxH - 1 && ReadPixelFast(x1, (y + 1)) == filloldcolour)
{
 floodFillScanline(x1, y + 1);
}
x1--;
 }
 }
}
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 07:20pm 01 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  But a quick look at the scanline algorithm shows how to break it:


That's easily fixed - try downloading again. I've even made it faster  


Almost perfect. It's not filling single pixel high gaps moving left:
mode 1,8
cls

circle 200,200,150
circle 300,200,150
circle 250,275,150

text 250,240,"Awesome!","CB",,,rgb(red)

line 240,200,260,200,,rgb(blue)
line 240,202,260,202,,rgb(blue)
line 249,180,249,222,,rgb(blue)
line 251,180,251,222,,rgb(blue)

print @(0,500) "Press a key to fill the center with WHITE..."
do : loop until inkey$ <> ""

pixel fill 250,250,rgb(white)


The centers of letters are not filled. That is exactly as expected. But look closely at the lower part of the 'e's. This is shown by the double stroke blue cross. Same for various fill colours. Try blue - the cross should become a single black pixel.

=========================
On a slightly different topic that doesn't really belong here, would it be possible to add '-1' as a valid fill colour for drawing commands such as box, rbox, polygon, circle etc?
ie: box 600,200,50,50,1,rgb(white),-1  behaves the same as
box 600,200,50,50,1,rgb(white)
Edited 2020-12-02 05:27 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 07:37pm 01 Dec 2020
Copy link to clipboard 
Print this post

  Quote  Almost perfect. It's not filling single pixel high gaps moving left:


I posted the source - you could have found the bug for me  

if(xs!=-1){
DrawHLineFast(xe,y,x-1,ConvertedColour);
}


Uploaded once more as b10
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 07:45pm 01 Dec 2020
Copy link to clipboard 
Print this post

Ah, I see it now. 'xe' needs to be changed to 'xs'

Yup, everything to excess!
Visit Vegipete's *Mite Library for cool programs.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 08:07pm 01 Dec 2020
Copy link to clipboard 
Print this post

New weird thing.

If I exit the editor using F1, the underscore cursor is expanded and the system is in some strange video state. The video 'twitches' with the next command, the screen clears, then settles down.

Try 'F1' to exit editor, then immediately 'ls[Enter]' to list files.
Edited 2020-12-02 06:15 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
qwerty823
Newbie

Joined: 30/07/2020
Location: United States
Posts: 30
Posted: 08:29pm 01 Dec 2020
Copy link to clipboard 
Print this post

DRAW3D CREATE with no params locks up the machine.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 10:35pm 01 Dec 2020
Copy link to clipboard 
Print this post

  Quote  DRAW3D CREATE with no params locks up the machine.


Seems reasonable. Every bit of extra syntax checking slows the interpreter down. The CREATE command has no optional parameter so why would you expect it to check if you call it without any?

  Quote  New weird thing.


OPTIONS?
Edited 2020-12-02 08:50 by matherp
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 01:28am 02 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  New weird thing.

OPTIONS?

The only option I've set is keyboard repeat.
> option list
CURRENT VGA mode 800x600 RGB332
CURRENT DISPLAY 50,100
OPTION USBKEYBOARD US
OPTION KEYBOARD REPEAT 400,30

Everything else is whatever happens from flashing firmware.

Same effect if I enter "option reset"

Anything mode command related fixes the problem. Some other commands do too. Generating a syntax error fixes it also.

The underscore cursor looks spread apart. The pixels are spaced one pixel apart. The character cell size appears double, although typed text is normal. Also, the CMM2 freezes once I'm 28 or 29 lines down the screen. The cursor disappears off the bottom at line 25 although the prompt character ">" is only half way down.

The individual cursor pixels are much more distinct than these photos show. The phote has blurred them together a bit.






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

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 07:42am 02 Dec 2020
Copy link to clipboard 
Print this post

I had the same issues (cursor), similar OPTIONS, just my KEYBOARD REPEAT 500,80

I have to go back to few versions back, because after short time, my CMM2 locked up.
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 08:14am 02 Dec 2020
Copy link to clipboard 
Print this post

  Quote  I have to go back to few versions back, because after short time, my CMM2 locked up.


Rather than give up I really need you to identify the sequence of actions that causes the problems. For example if your are developing NC when this happens and you are using a CSUB then perhaps there is a correlation there.

I'm not going back to the 5.05 code base so this problem needs finding and fixing
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 08:39am 02 Dec 2020
Copy link to clipboard 
Print this post

Hi Peter,
I will try it again, but yesterday I haven't so much time and needed finish compression... But anyway, for me it wasn't connected to anything, I updated FW, CMM2 started OK, just the cursor was strange -> wrong position and not underline but some characters (########### or !!!!!!!!!!!!!), I tried to change MODE back and forth, then it looked OK.
When I switched CMM2 off and after 2 hours backn on again, I got just welcome picture and FW message, but no cursor, no reaction for keys. I tried (blindly) switch the MODE (because I thought it could be for example wrong OPTION CONSOLE), but nothing helped. So I went back...

I forgot, I'm not on 5.05 but still 5.06, just some lower RC.
Edited 2020-12-02 18:41 by jirsoft
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 10:14am 02 Dec 2020
Copy link to clipboard 
Print this post

V5.06.00b11

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

This version fixes a memory corruption that occurs if you leave the editor with F1
It is strongly recommended that you upgrade to this version if you are using any of the V5.06.00 beta versions.

Note: The firmware is 758332 bytes long. You are strongly recommended to update using a USB A-A cable rather than over the serial connection. This is a lot of bytes to transfer over serial with no error correction!
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3858
Posted: 11:01am 02 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  Note: The firmware is 758332 bytes long. You are strongly recommended to update using a USB A-A cable rather than over the serial connection. This is a lot of bytes to transfer over serial with no error correction!


Does the "Verify programming" option in the STM programmer not give us some protection here?

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8601
Posted: 11:36am 02 Dec 2020
Copy link to clipboard 
Print this post

You would hope so but I've definitely seen had problems when programming over serial that don't occur over USB
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3858
Posted: 11:45am 02 Dec 2020
Copy link to clipboard 
Print this post

  matherp said  You would hope so but I've definitely seen had problems when programming over serial that don't occur over USB


OK, thanks for the warning. For what it is worth I've been programming over serial since the beginning without a single issue, and I would guess have reprogrammed at least as many times as anyone else other than the original CMM2 principals.

Tom
Edited 2020-12-02 21:57 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 12:20pm 02 Dec 2020
Copy link to clipboard 
Print this post

I think I have no A-A cable, so I will risk serial  
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 12:41pm 02 Dec 2020
Copy link to clipboard 
Print this post

Every bit matters :) I would have thought that the STM verification step would catch any garbled bits regardless of the I/O method. It never occurred to me try reflashing over serial, albeit I suppose it would be more in keeping with the “retro” vibe of the CMM2. That being said, the verb  “to flash” meant something entirely different in the 1970s :) Most of you will recall that firmware was still very “hard” at the time - I remember how liberating it was when I got my first EEPROM programmer and could mod my Apple II.

A related pre-Internet anecdote: I was watching a documentary on Commodore computer a few night ago, and one of the segments had a guy recounting how when he got his first C64 as a kid, he lived in a rural town, and the only way to get software for his machine was by accompanying his mother into “the city” and copying code listings out of magazines by hand while his mother was shopping, then transcribing them when he got home... and repeating those steps in weekly instalments for longer programs! Talk about a lack of error correction!
Enjoy Every Sandwich / Joe P.
 
     Page 3 of 6    
Print this page
© JAQ Software 2024