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 : picomitevga - mode and color commands result in black screen?
Page 1 of 2 | |||||
Author | Message | ||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
hi everyone, woohoo, finally got the picomitevga up and running! everything seems to work well, can run the colors, fonts and blocks programs. but when i try changing colors at the command prompt using MODE and COLOUR commands, everything after that seems to be black... maybe the text and background turned black? i've tried doing these commands in EDIT mode as well and still things don't seem to work. i must be doing something wrong but have no idea what that could be. halp. thanks much. jin |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2137 |
Welcome The default setting is MODE 1 which isn't a true colour mode. The output can be "colourised" With the TILE commands. Latest PicoMiteVGA v05.07.07 manual p96. MODE 2 gives 4 bit colour (RGB 1,2,1 bits) at reduced resolution (QVGA 320 x 240). The reduced resolution is necessary to prevent the screen buffer using too much memory. To test for a hardware problem type:- MODE 2 CLS RGB(Red) CLS RGB(Green) CLS RGB(Blue) This will test the 3 primary colours output to the monitor. |
||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
hi phil99, thank you so much. the tests worked great and the screen changed color as expected. the tile command is something i'll have to fiddle with. this is a lot harder in maximite basic than bbc basic to just format text with color so it's throwing me for a loop. oh, and is the behavior of the output just changing to black when you enter something like: COLOUR RED something that's supposed to happen? after all subsequent output turning black, i can't get text to show up again until i jump into EDIT and then jump out again. thanks again. jin |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4247 |
Change to mode 2 Then you have all the color freedom you like. In mode 1 color is tiled. Volhout PicomiteVGA PETSCII ROBOTS |
||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
switching to mode 2 does not make any of the color operations more intelligible to me. so in bbc basic, this is a little loop that prints "hello world" in different colors. colour 128+0 cls mode 3 for x = 1 to 100 for y = 1 to 14 colour y print "Hello World!!! "; wait 1 next y next x vdu 20 print "ALL DONE!" what would the mmbasic way of doing this? this is one of the first kinds of programs i do to get familiar with a programming language and mmbasic has me stumped right out of the gate. thanks. |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
Since there are no fixed color numbers(Colors are treated as a 24 bit RGB value), it would look something like this in mmbasic: dim integer CL(15) Restore COLORS:for y=1 to 15:read CL(y):next mode 2 for x = 1 to 100 for y = 1 to 14 COLOR CL(y) print "Hello World!!! "; pause 100 next y next x print "ALL DONE!" 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) Edited 2023-07-11 16:03 by Martin H. 'no comment |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4247 |
Hi jinchoung, Everybody comming from the 80's computers is used to color numbers. MMBasic used color numbers in the Color Maximite 1 (CMM1), since there where only 8 colors, that was easy. Then the Color Maximite 2 (CMM2) was developped with 16 bit colors. There where so many that numbering them was not usefull, better use the RGB value directly (24 bit RGB). There was a helper RGB() for the most frequently used colors (i.e.RGB(red)). Now we have picomite. It is a successor of the CMM2, and it inherited the RGB() helper, and no color numbers. (except: color numbers are only use in the SPRITE definition file). So... no color numbers, only RGB numbers.... If you want color numbers, you can do what Martin showed, create them yourself as index in a color lookup table with RGB values. Since the picomite has a "library" you can store this conversion table in library, and use it in all your programs (*). Volhout (*) which is not a bad idea, now I think of it. I might do it myself. I am reinventing the wheel every time I write a program, since I was used to color numbers from my ORIC / CMM1 time. Edited 2023-07-11 17:30 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
hey guys, thanks much! wow and thanks martin. that helps a lot. i'd totally be fine with just using RGB (255,255,255) format but in looking at the documentation, the way that color is handled seems to be all over the place. like even the syntax in martin's program "COLOR CL" - i've never seen that before! so far it seems like there are like 4 different formats for handling color and none of them work for me off the bat. but this is all helping so thank you very much. jin EDIT: OH! CL is a variable. array? ok... that makes much more sense! Edited 2023-07-11 17:35 by jinchoung |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 4247 |
hi jinchoung, Many of us are so into MMBasic that we sometimes are blind for the detail. If you can point out where you think things are contradicting, or unclear, we may be able to clarify, or make adaptations. You have a fresh view (maybe coloured by BBC basic, but fresh to MMBasic). We may have missed something. Volhout PicomiteVGA PETSCII ROBOTS |
||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
so a few things that tripped me up in the documentation is just the syntax for altering colors. in the documentation (pg 62) it talks about: COLOUR fore [,back] but like what in the world is the actual syntax to change the color? because of martin's program, i finally finally understand: COLOUR RGB(BLUE)... also COLOUR RGB(0,0,255) aha! it would have been so much easier if for all the commands, there was an actual example line of code instead of an incomplete snippet. earlier on pg 24 there is a section called "Colours", it actually doesn't give a simple full example of usage. it breaks it up into these examples: RGB(red,green,blue) and COLOUR foreground-colour, background-colour so in my first efforts, i typed in: RGB(255,128,0) and obviously, that didn't work. then i tried: COLOUR red, green and that didn't work either. what really would have helped would have been just a full line of actual code that does something valid. ================ something i still don't understand now is that mmbasic doesn't seem to register 24bit colors in their entirety. so i work a lot in photoshop so (255,255,255) format is very familiar to me but there seem to just be 16 distinct colors and no ability to access the full 24bit palette. so i understand that there's a 16 color limit but are we able to define our own palette of 16 colors from the full 24bit range? if so, i don't know how to do that from the docs. thanks again! jin |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
so Red and Blue are on or off, which is 255 or 0 Green has two bits so possible Values are 0,64,128 and 255 00,40,80,FF in Hex so, translated to this you can replace the Data 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 On non VGA Picomites whith LCD more Colors are possible. Here the image is stored in the LCD and that does not take up any memory from the Pico. The advantage is that you don't have to change the syntax Edited 2023-07-11 18:28 by Martin H. 'no comment |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 6798 |
It's not quite as murky as it first appears. :) RGB(r,g,b) is an integer variable (not an array, although it looks like one) which holds an integer variable that describes the levels of red, green and blue. This format is used on all the current MMBasic platforms and it's useful because you can use it in your program and the actual colour you get will be as close as that platform can get. That sounds weird... :) The PicoMite uses a system called RGB 1-2-1, which has 1 bit for red, 2 bits for green and 1 bit for blue. That gives us 16 possible colours. a value of 0 for one of the arguments means that is missing (e.g. RGB(0,1,1) has no red) and a value of 255 means it has maximum brightness. Obviously, you can't represent 255 with one bit, but MMBasic will let you use it in your program. Thus RGB (255,0,255) will be magenta on both a PicoMite and a CMM2, but you won't be able to get dark values of magenta on the PicoMite as red can only be on or off. MMBasic automatically does the translation to the colour depth available. Because RGB(r,g,b) is a normal integer it can be stored in an array, which is what Martin did in the first 2 lines of his example. He used the array CL() and read the colour values into it from the DATA saements. He was then able to select a colour in the main body of the program using CL(colour_number). There is no "palette" of colours to choose from. Well, there is in a way - it's the values of the resistors used in the VGA network. You can't change it from within your program (without considerable hardware fiddling. :) ). You get the 16 colours that are fixed, and that's all. Don't expect photo quality. Edited 2023-07-11 18:32 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2137 |
The Pico doesn't have enough memory to change the palette in software. It has to be done with hardware, the resistors that connect the Pico to the VGA socket. Here is a thread that shows a couple of variants. Greyscale and RGBI Edit Somehow that link jumps to the middle, scroll to the top. Edited 2023-07-11 18:33 by phil99 |
||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
thank you much fellows. that clarifies things tremendously! and thanks martin for actually verbosing out 0,64,128,255... i'm so dim i still didn't get it until you did that but now i got it... 2bit number. aha... so it is a fixed palette. thanks mick. got it. alright well since it is just 16 colors, i would have just gone for the numbered colors like 8 bit computers or the maximite 1 but ok, i can use this now that i understand it. thanks again guys. jin |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3150 |
That would have ignored the history of MMBasic subsequent to the MaxiMite 1. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
stanleyella Guru Joined: 25/06/2022 Location: United KingdomPosts: 2129 |
The vga mode 1 and coloured tiles is like the zx spectrum. not much good for games unless tile size or work around it. The amstrad 464 had colour palettes so draw lines in different colours then switch the colours for animation, the lines were still there but some would be the background colour. Did bbc have that feature? |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9308 |
Very interesting thread, chums, and welcome aboard the forums jinchoung. Thank you for continuing to perservere. We have had newbies here in the past, who, when they run into their first hurdle as a new-comer to MMBASIC, rubbish the language and insist it should have been done THEIR way, and leave the forums in a huff. Thanks for not doing that. As far as the PicoMite VGA colours are concerned, I do agree with you that 1-16 probably would have been more sensible for the PM-VGA port, but having said that, I also agree with lizby! I do agree that a simple one-line of example code for each command, would be a good thing to add to the manual. Geoff maintains the manual, so if he reads this and agrees, he might do that. There is a beginners guide PDF manual that you might find useful, if you don't already have it. It is aimed specifically at new users such as yourself, and explains the language in much more detail. I'll attach it here: Getting Started with the Micromite.pdf Smoke makes things work. When the smoke gets out, it stops! |
||||
jinchoung Newbie Joined: 29/05/2023 Location: United StatesPosts: 7 |
hey thanks much for the welcome grogster. and oh cool, an intro is very very appreciate indeed. thanks for that! jin |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3804 |
If you want colour numbers 1-16 (or 0-15) just put the 16 actual RGB(...) values into an array and then use array(number) where on a console you might have used number. Whatever you do you can only have the colours the hardware can do, which on the Picomite VGA is not many and fixed by the hardware! John Edited 2023-07-12 15:53 by JohnS |
||||
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1114 |
Even with just 16 Colors you are able to draw colorfull pictures with small Code 'MMBASIC (PicoMiteVGA) translated from Qbasic Source: 'https://rosettacode.org/wiki/Julia_set#QBasic escala = 1 / 81:zeroX = 160:zeroY = 120 maxiter = 32 CR = -.798 CI = .1618 dim integer CL(15) Restore COLORS:for y=1 to 15:read CL(y):next mode 2 FOR x = 0 TO 2 * zeroX - 1 FOR y = 0 TO 2 * zeroY - 1 zreal = (x - zeroX) * escala zimag = (zeroY - y) * escala FOR iter = 1 TO maxiter BR = CR + zreal * zreal - zimag * zimag zimag = CI + 2 * zreal * zimag zreal = BR IF zreal * zreal + zimag * zimag > 4 THEN Pixel x, y, cl((iter MOD 16)) EXIT FOR END IF NEXT NEXT NEXT END 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) 'no comment |
||||
Page 1 of 2 |
Print this page |