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 : MM-Basic Sprite Editor
Page 2 of 2 | |||||
Author | Message | ||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4222 |
AFAIK there aare no numbers for the color names in the MMBasic rogram, but there are numbers used in the sprite file, to make the format compliant with CMM1. Regards, Volhout PicomiteVGA PETSCII ROBOTS |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3800 |
For things like RGB(myrtle) I expect you can PRINT RGB(myrtle) Bear in mind not all hardware can do all colours. John |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
If the RGB Handling is equal just replace the Data in the Sourcecode: colors: '--Colorscheme accordung to matherp Data RGB(BLUE),RGB(GREEN),RGB(CYAN),RGB(RED) Data RGB(MAGENTA),RGB(YELLOW),RGB(WHITE),RGB(MYRTLE) Data RGB(COBALT) ,RGB(MIDGREEN),RGB(CERULEAN),RGB(RUST) Data RGB(FUCHSIA),RGB(BROWN),RGB(LILAC) pict: with this colors: '--Colorscheme accordung to matherp Data &H0000FF,&H00FF00,&H00FFFF,&HFF0000 Data &HFF00FF,&HFFFF00,&HFFFFFF,&H004000 Data &H0040FF,&H008000,&H0080FF,&HFF4000 Data &HFF40FF,&HFF8000,&HFF80FF pict: as you might see, myrtle, cobalt etc. are those colors with the Green variants 40,80 Edited 2023-06-13 02:58 by Martin H. 'no comment |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
The principle is simple, repeating pixels of the same color are counted. The color number is increased by 16 followed by the number of repetitions -1 (max 15) So far you can use a text editor to search and replace repeating parts of the Sprite Data strings with the compressed form. which is quite laborious. Example : find "0000000000000000" replace with "GF" find "000000000000000" replace with "GE" find "00000000000000" replace with "GD" ... find "000" replace with "G2" and that for all 16 colors. You can do something like this 2-3 times, but it's boring and a real punishment. So I thought, the pico can do that much faster and with less effort so let him do the work. you can use the compress and Expand Function from the SprEd Source code.. Function expand$(pxl$) Local n%,nmb%,tmp$,co$ n%=1 Do If Asc(Mid$(pxl$,n%,1))< 71 Then tmp$=tmp$+Mid$(pxl$,n%,1) Else ' length encoded - 1st char is pixel colour+71, 2nd is count-1 co$=Hex$(Asc(Mid$(pxl$,n%,1))-71) Inc n% nmb%=Val("&H"+Mid$(pxl$,n%,1)) tmp$=tmp$+String$(nmb%+1,co$) EndIf Inc n% Loop Until n%>Len(pxl$) expand$=tmp$ End Function Function compress$(search$) Local String from$,zu$ found=0 For f%=0 To 15 For n%=16 To 3 Step -1 from$=String$(n%,Hex$(f%,1)) zu$=Chr$(71+f%)+Chr$(128+Asc(Hex$(n%-1,1))) 'addition of 128 prevents the results from 'being incorrectly counted in a further search Do search$=replace$(from$,zu$,search$) If found=0 Then Exit Loop Next n% Next f% compress$="" For f%=1 To Len(search$) n%=Asc(Mid$(search$,f%,1)) n%=n%-128*(n%>128):'sub the 128 if needed compress$=compress$+Chr$(n%) Next End Function ' Function replace$(sr$,repl$,sear$) Local n%,tmp$ tmp$=" "+sear$+" " found=Instr(tmp$,sr$) If found=0 Then replace$=sear$:Exit Function tmp$=Left$(tmp$,found-1)+repl$+Right$(tmp$,Len(tmp$)-(found+Len(sr$))+1) replace$=Mid$(tmp$,2,Len(tmp$)-2) End Function To see, how I used it, also take a look at the On the Road again Listing :-) Sub read_Sprites Local nr%,p%,n%,byt$,m$ '--- Read/Create Sprites Restore car For p%=1 To 31 Read Byt$:Byt$=expand$(Byt$) For n%=1 To Len(Byt$)/2 m$=Mid$(Byt$,n%,1) Pixel n%-1,p%,COL%(Val("&H"+m$)) Pixel 56-n%,p%,COL%(Val("&H"+m$)) m$=Mid$(Byt$,Len(Byt$)-(n%-1),1) Pixel n%-1,32+p%,COL%(Val("&H"+m$)) Pixel 56-n%,32+p%,COL%(Val("&H"+m$)) Next Next Sprite read #1,0,0,56,32:Sprite read #2,0,32,56,32 ' Sprite load "Car3.spr",3 Restore car3 For p%=0 To 30 Read Byt$:Byt$=expand$(Byt$) For n%=1 To Len(Byt$) m$=Mid$(Byt$,n%,1) Pixel n%-1,p%,COL%(Val("&H"+m$)) Next Next Sprite read #3,0,0,56,30 End Sub Have Fun Edited 2023-06-13 03:52 by Martin H. 'no comment |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4222 |
Hi Martin, I saw you paint the pixel data on screen, and then read the sprite from screen. Why not uncompress the colors in a linear array, and use SPRITE LOADARRAY n,w,h,array% Saves a lot of coordinate calculations Volhout PicomiteVGA PETSCII ROBOTS |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
sounds good. I missed the option so I've never tried it. How is the memory consumption? 'no comment |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4222 |
Probably bad. You need DIM an array for each size sprite. But you need this only during creation (local). Volhout PicomiteVGA PETSCII ROBOTS |
||||
hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 123 |
to martin h: many thanks for the colour numbers... |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
You're welcome These were the color values that the PicoMiteVGA returned. Now I have noticed that in the Windows version, the position of red and blue seem to be reversed. Since I don't know how the colors are used on the CMM, here the codes that MMBasic4Windows gave me back.(just to be on the safe side, if the other colors don't fit). Data &HFFFF0000,&HFF00FF00,&HFFFFFF00,&HFF0000FF Data &HFFFF00FF,&HFF00FFFF,&HFFFFFFFF,&HFF004000 Data &HFFFF4000,&HFF008000,&HFFFF8000,&HFF0040FF Data &HFFFF40FF,&HFF0080FF,&HFFFF80FF Edited 2023-06-14 15:41 by Martin H. 'no comment |
||||
hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 123 |
hello. no i have a running picomitevga and can test this program... 1. i only see 8 colours. the row has 16 parts, so i see the same colours twice... 2. is this software free? i would program further for my purpouses, but only if martinH is saying "yes"... |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3800 |
A hardware problem? A bit shorted / not connected? Maybe post a small picture showing all the ones you see and someone may say what's wrong. John |
||||
toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 339 |
Thanks! This is very useful. If I may make a few suggestions: 1. Don't let the program crash if the load filename is non-existent. 2. Allow the user to exit the load and save prompts without entering a filename and without destroying work in progress. This can be as easy as this: Case Chr$(145):fname$=Dialog$("Load File, Name?"):if fname$<>"" then fread(fname$) Case Chr$(146):fname$=Dialog$("Save File, Name?"):if fname$<>"" then fwrite(fname$) 3. Allow mouse presses for the buttons on the right. Edited 2023-06-14 17:20 by toml_12953 |
||||
hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 123 |
the problem with the colours is solved... i placed the connection for 1/3 green wrong... at another topic here i got the solution... |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
I say "Yes" 'no comment |
||||
hhtg1968 Senior Member Joined: 25/05/2023 Location: GermanyPosts: 123 |
thanks. |
||||
electricat Senior Member Joined: 30/11/2020 Location: LithuaniaPosts: 161 |
@Martin H, Did you progressed somehow Sprite Editor further? I am thinking to write small game and now looking arround for some toools :) |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1113 |
@electricat I haven't developed much further here. It was a project that I created for myself and then shared with others. That's why I didn't invest much time in comfort. But it is definitely appreciated if someone takes on the program and publishes improvements to it. Since I hat to convert the graphics for Petscii Robots, also because it was so much, I've switched to creating the graphics on a PC with a drawing program (Paint dot Net) and then converting them into sprites on Pico or with MMBasic for Windows. Cheers Martin Edited 2024-08-26 03:56 by Martin H. 'no comment |
||||
Page 2 of 2 |
Print this page |