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: Has anyone done a rolling credits demo I can pinch?
Page 1 of 2 | |||||
Author | Message | ||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3865 |
Hi folks, Does anyone have (or want to write) a demo of vertically rolling credits that I can repurpose for the Welcome Tape splash-screen. I specifically need to show the credits in a letterbox rather than scrolling the entire screen, i.e. I'm suspect I will need to fade the text in and out from black as it passes through the letterbox otherwise it will probably look very odd. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
Is this the sort of effect you are after? 40 random names. (Why did I pick only boy's names? Where are the female programmers?) Fade in and out needs more thought. Maybe even a CSub. dim a$(40) a$( 1) = "Michael" a$( 2) = "Daniel" a$( 3) = "Henry" a$( 4) = "Sebastian" a$( 5) = "Aiden" a$( 6) = "Matthew" a$( 7) = "Samuel" a$( 8) = "David" a$( 9) = "Carter" a$(10) = "Owen" a$(11) = "Wyatt" a$(12) = "John" a$(13) = "Jayden" a$(14) = "Dylan" a$(15) = "Grayson" a$(16) = "Julian" a$(17) = "Mateo" a$(18) = "Anthony" a$(19) = "Jaxon" a$(20) = "Christopher" a$(21) = "Andrew" a$(22) = "Theodore" a$(23) = "Caleb" a$(24) = "Ryan" a$(25) = "Nathan" a$(26) = "Thomas" a$(27) = "Leo" a$(28) = "Charles" a$(29) = "Hudson" a$(30) = "Christian" a$(31) = "Hunter" a$(32) = "Connor" a$(33) = "Landon" a$(34) = "Adrian" a$(35) = "Robert" a$(36) = "Carson" a$(37) = "Brayden" a$(38) = "Axel" a$(39) = "Bryson" ' Scroll Window parameters sw_x = 250 sw_y = 200 sw_thick = 2 sw_width = 300 sw_height = 100 sw_font = 2 sw_fontheight = 20 sw_text_col = RGB(YELLOW) cls box sw_x,sw_y,sw_width,sw_height,sw_thick ', framecolour if desired for j = 1 to 40 page write 2 text 20,100,a$(j)+" ",LT,sw_font,1,sw_text_col page write 0 for i = 1 to sw_fontheight 'MM.INFO(FONTHEIGHT) blit sw_x,sw_y+sw_thick+2,sw_x,sw_y+sw_thick+1,sw_width,sw_height-2*sw_thick-2,0 blit 0,100+i,sw_x+sw_thick,sw_y+sw_height-sw_thick-2,sw_width-2*sw_thick,1,2 pause 50 next i next j for i = 1 to sw_height - sw_fontheight blit sw_x,sw_y+sw_thick+2,sw_x,sw_y+sw_thick+1,sw_width,sw_height-2*sw_thick-2,0 pause 50 next i end Visit Vegipete's *Mite Library for cool programs. |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1595 |
Another good one Vegipete. Maybe in lieu of fading out - random black pixels over the last lines worth of the display could make them appear to disintegrate? Bill Keep safe. Live long and prosper. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3865 |
Absolutely, thank you. I don't know, I get the impression that they represented 50% or more of the early industry. We've got two great women working for us ... and I've worked with one useless one ... so that probably represents a better success rate than with my male colleagues. Of course we don't want to spoil the suprise when Peter Mather announces he's really called Ada and has been alive since 1815. Since you've been so generous with your time I might try my luck and consulting the Necronomicon cast Summon @Sasquatch to see if he might help us out. I guess what we need is a CSUB of a form something like: /** * This subroutine changes the colour of pixels within a bounding rectangle * that are currently coloured 'old_rgb' to colour 'new_rgb' * * @param x x-coordinate of top-left corner of rectangle * @param y y-coordinate of top-left corner of rectangle * @param x2 x-coordinate of bottom-right corner of rectangle * @param x2 y-coordinate of bottom-left corner of rectangle * @param old_rgb change pixels of this colour ... * @param new_rgb ... to this colour. */ void change_colour(x, y, x2, y2, old_rgb, new_rgb); Alternatively is it possible to do something clever using a colour MAP where each line of text is drawn in a different colour and then faded in and out? Thanks for the backup plan Bill. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
NPHighview Senior Member Joined: 02/09/2020 Location: United StatesPosts: 197 |
Lots of information on women in computing here. Long list of names to use in the rolling credits! As a 64-year-old white guy, it makes me a little uncomfortable that, inadvertently or not, women were pushed out of computing from the 1960's to the point that: US News and World Report. The article cites middle school as the critical time to encourage young women to get into the field. As a local science fair judge, I see this a lot when judging middle school science fair projects. Fortunately, the CMM2 is a great starting point, and very approachable, by kids at this age. Live in the Future. It's Just Starting Now! |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
You should be able to do this with the color MAP() in 8bit color mode. i.e. Mode 1,8 etc. I will work on the CSUB you suggested, it seems useful and may even work to roll the colors in the 16bit color MandelbrotEXP16. I'm curious to see how fast it could be. I am also wondering if the hardware blit functions could be coaxed into doing this? Give me a couple of days to chew on it. All the other MMBASIC commands that specify a rectangle use H,W instead of X2,Y2 so I'll likely stick with that. Disintegrating text also sounds cool and could be a nice effect. Edited 2020-10-06 02:35 by Sasquatch -Carl |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
That could be a good general purpose routine but I was thinking of something more palette based. A gradient set of colours is needed first, from almost but not quite black to white (or what ever.) The routine then needs to increase each screen memory byte value by one to move up the colour table - fade in - and decrease by one to fade out. I'll test some stuff with peeks and pokes to see if the effect works. Then we can see about speed. Visit Vegipete's *Mite Library for cool programs. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3865 |
@Sasquatch, @vegipete Thanks for doing this for me, it's really appreciated because it would be weeks before I could get around to it. You might consider making the `old_rgb` and `new_rgb` into arrays of the same size (i.e. a map), you'd also need some way to indicate that size, either an additional parameter or magic terminating value in the old_rgb array. Thanks again, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8605 |
You can do this with PAGE AND_PIXEL and then some Blitting but you could possibly get a smoother effect using MAP. Do load RC1 first as I've made a sneaky improvement to the colour mapping. This technique can also be used for colour transformations. Write in white and then change the AND mask mode 3,16 pause 2000 page write 3 cls print @(100,100)"some text print @(100)"Some more test" print @(100)"Even more text" i=255 do page write 2 box 100,100,100,100,,rgb(i,i,i), rgb(i,i,i) page and_pixels 2,3,1 page write 0 BLIT 100,100,100,100,100,100,1 pause 50 i=i-1 loop until i=0 Edited 2020-10-06 03:40 by matherp |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
Now this is cool! It's starting to push MMBasic's byte wrangling but it works. There may be efficiencies to be gained by using 32 bit peeks and pokes but still, the effect is pretty smooth as is. The algorithm is to set any non-zero pixels in the scroll region to the target colour for that particular section of the scroll region. In this case, the region is 32 (31?) pixels tall, and each horizontal row of pixels is a section. A CSub version of FixColours would want (x,y,width,new_value) and would set each non-zero byte of the strip of bytes to the specified value. (Maybe x,y should instead be given as just a memory address.) The text to be scrolled appears on the top left but that is just to see what it is doing. In a real version, a different page would be used, which would also cure the slight flickering and flashing. (If I could force MMBasic to draw using a particular colour number...) Comment out line 11 to remove the box for even better effect. ' Fading Scrolling Text Demo ' vegipete, Oct 2020 mode 1,8 cls sw_x = 500 ' scroll window x location sw_y = 100 ' y location sw_width = 50 ' width sw_height = 200 ' height box sw_x-2, sw_y-2, sw_width+4, sw_height+4, 2, rgb(red) ' put a box around scroll window ' build custom colours from #100 to #131 for i = 0 to 31 map(100 + i) = rgb(8*i, 8*i, 8*i) next i map set addr = MM.INFO(PAGE ADDRESS 0) + MM.HRES*sw_y + sw_x ' memory location of top left of box c = 33 do text 1,0,chr$(c)+chr$(c+1)+chr$(c+2),LT,3 ' 12x20 character, on page 0 so we can see for i = 1 to 24 ' character height blit sw_x,sw_y+1,sw_x,sw_y,sw_width,sw_height-1 ' shift scroll box image up 1 blit 0,i,sw_x,sw_y+sw_height-1,sw_width,1 ' copy row of pixels to bottom of scroll box FixColours ' pause 10 ' not needed next i c = c + 3 if c > 127 then c = 32 loop sub FixColours local i,j for i = 1 to 31 ' 5 bit fade region for j = 0 to sw_width-1 ' work across scroll box memloc = addr + i * MM.HRES + j ' top of box if peek(byte memloc) then poke byte memloc, 100 + i ' if pixel is not black, change to fade memloc = addr + (sw_height - i) * MM.HRES + j ' bottom of box if peek(byte memloc) then poke byte memloc, 100 + i next j next i end sub Edited 2020-10-06 04:06 by vegipete Visit Vegipete's *Mite Library for cool programs. |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
That does look nice! Do You want me to add a CSUB version of "FixColours" or "FixColors" to my "To-Do" list? -Carl |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3865 |
Very pretty @vegipete. If you could. At the moment it is unfortunately too slow to use for the credits. Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Here is a first pass at the requested CSUBs. The Disintegrate CSUB version seems to have a couple of minor glitches but mostly works ok. I'm not sure where the problem lies as the algorithm works better in MMBASIC. Included is a demo program including the CSUBs. The CSUBs are each completely independent, you only need the one you want to use. See the comments for documentation. Sorry this took so long, sometimes real life gets in the way of the hobbies. graphsubs.zip -Carl |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
Them thar's some neat effects. The disintegrate functions look like prime candidates for NOT using true random number generators. I suppose the next request will be for a 're-integrate' function. Might be a blit equivalent, just taking longer and moving 'random' pixels each time through. Thinking more, the ideal could be a "cut-paste by disintegration" function. Pixels leave one region and appear in the second according to the desired pattern at the desired speed. Your FixColours routine isn't as intended. You are using pixel level manipulations, which are limited by the colour map. My version in MMBasic worked at a screen memory byte value level. Any non-zero byte in the target region was changed to the requested byte. I separately forced a range of palette values to the colours I wanted. (I happened to choose 100 to 131, but that is arbitrary.) ================ Are there byte/word/longword alignment requirements in the ARM architecture? I'm going to go study the Mandelbrot source and see what I can learn. Visit Vegipete's *Mite Library for cool programs. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3865 |
Real life is proving to be a problem for me too this week. I did have a play with scrolling credits on the splash screen last night and to be honest it felt cheap and unprofessional. That's not a comment on the code, it's an indictment of my idea of scrolling credits on the splash screen . Hopefully we can use still make use of this code for a separate demo included on the tape. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
The CSUB disintegrate uses a 32bit XORSHIFT PRNG for the random numbers, it's deterministic for a given size box. The MMBASIC version uses the true random numbers. Your FixColours routine isn't as intended. You are using pixel level manipulations, which are limited by the colour map. My version in MMBasic worked at a screen memory byte value level. Any non-zero byte in the target region was changed to the requested byte. I separately forced a range of palette values to the colours I wanted. (I happened to choose 100 to 131, but that is arbitrary.) This is actually much simpler that what I have implemented. Keep in mind your method will only work for 8 bit color modes. Color mapping 12 and 16 bit color modes is more complex, also some screen modes use "double pixels" I believe the horizontal doubling is done in hardware and the vertical doubling is software. I'll add your requested function so you can try it! -Carl |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
If I understand the graphics modes correctly, there are only two possibilities: 1 byte per pixel or 2 bytes per pixel. Plus some modes in which pixels 'appear twice' vertically. With one byte per pixel, a colour look up table is used, translating one screen byte to a 16 bit colour. This applies to any of the 8 bit colour modes. Obviously, this limits you to 256 possible colours at a time (unless you do something weird like changing the look up table on the fly based on GetScanLine.) Two bytes per pixel covers both 12 and 16 bit modes. Each screen pixel is represented by 2 bytes in memory. The interpretation of those 2 bytes depend on the particular mode. As you say, lower resolution modes (5,6,7,13?) actually use 2 rows of memory for one line of pixels. (In fact, you can see double the vertical resolution if you use poke instead of pixel to draw on the screen. With all that, I think my version of FixColours would still work fine in all modes, provided the CSub can determine the mode. Initially, it only needs to target 8 bit modes, single vertical byte per pixel, and would work as described. The next level of CSub would recognize line doubled modes and change two bytes in memory, where the second is MM.HRES bytes further in memory. The final level would recognize 2 byte pixels, and do the same: change any non-zero words to the requested word. =========== Is there an expanded description of the various functions listed in ARMCFunctions.h or do you refer back to the CMM2 source code for the details? As an example, what would the CSub equivalents of PEEK and POKE look like? Visit Vegipete's *Mite Library for cool programs. |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Ok, I added Change_Bytes() and FixBytes()! graphsubs.zip -Carl |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Currently there is no way to determine the color depth (bits/pixel) from in a CSUB. I have asked matherp to add the function. As you suggest, this would make life much easier. For now I have implemented separate functions for 8/16 bits. I suppose it could be made a parameter for now. I also don't like putting out code that requires users to upgrade to the latest beta if it can be avoided. There is no Peek or Poke for CSUBs. They are not needed. You use the 'C' de-referencing operator "*" it looks like this: unsigned char A; // declare A as a byte unsigned char *peekaddress; // declare peekaddress as a pointer to a byte (the address of a byte) peekaddress = (some address we are interested in); // set the pointer to some address A = *peekaddress; // A = Peek(peekaddress) *pokeaddress = A; // Poke(pokeaddress,A) In the CSUB I use it like this: if (*(page + y * HRes + x) == 0) *(page + y * HRes + x) = (unsigned char)new_rgb; I want to figure out some strangeness with the CSUB version of Disintegrate() and clean up/comment my code better, then I will publish the 'C' source for these CSUBs and you can have a look. Darn! You have got my mind churning about the "Re-Integrate" function. I have an idea for a copy function to randomly copy pixels from one area/page to another. -Carl |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
You rock, Sasquatch! (Text is snatched from Wikipedia.) 'Scrolling Fading Text Demo 'By vegipete 'Made possible with CSUB by The Sasquatch 'www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12876 Mode 1,8 page write 2 : cls page write 1 : cls page write 0 : cls dim integer sw_x = 100 ' scroll window x location dim integer sw_y = 100 ' y location dim integer sw_width = 550 ' width dim integer sw_height = 200 ' height 'box sw_x-2, sw_y-2, sw_width+4, sw_height+4, 2, rgb(red) ' put a box around scroll window ' build custom colours from #100 to #131 for i = 0 to 31 map(100 + i) = rgb(8*i, 8*i, 8*i) next i map set do read txt$ if txt$ = "END" then exit do page write 2 text 20,0,txt$+space$(75),LT,1 ' 8x12 character page write 1 for i = 1 to 12 ' character height blit sw_x,sw_y+1,sw_x,sw_y,sw_width,sw_height-1 ' shift scroll box image up 1 blit 0,i,sw_x,sw_y+sw_height-1,sw_width,1,2 ' copy row of pixels to bottom of scroll box FixColours page copy 1,0,B pause 50 next i loop page write 0 end sub FixColours local integer i,j for i = 0 to 31 ' 5 bit fade region FixBytes(sw_x, sw_y+i,sw_width,2,100+i) 'Change all non zero bytes in the row to 100+i FixBytes(sw_x, sw_y+sw_height-i,sw_width,1,100+i) 'same change, different row next i end sub data "BASIC (Beginners' All-purpose Symbolic Instruction Code) is a" data "family of general-purpose, high-level programming languages" data "whose design philosophy emphasizes ease of use. The original" data "version was designed by John G. Kemeny and Thomas E. Kurtz and" data "released at Dartmouth College in 1964. They wanted to enable" data "students in fields other than science and mathematics to use" data "computers. At the time, nearly all use of computers required" data "writing custom software, which was something only scientists" data "and mathematicians tended to learn." data " " data "In addition to the language itself, Kemeny and Kurtz developed" data "the Dartmouth Time Sharing System (DTSS), which allowed multiple" data "users to edit and run BASIC programs at the same time. This" data "general model became very popular on minicomputer systems like" data "the PDP-11 and Data General Nova in the late 1960s and early" data "1970s. Hewlett-Packard produced an entire computer line for this" data "method of operation, introducing the HP2000 series in the late" data "1960s and continuing sales into the 1980s. Many early video" data "games trace their history to one of these versions of BASIC." data " " data "The emergence of early microcomputers in the mid-1970s led to" data "the development of a number of BASIC dialects, including" data "Microsoft BASIC in 1975. Due to the tiny main memory available" data "on these machines, often 4 kB, a variety of Tiny BASIC dialects" data "was also created. BASIC was available for almost any system of" data "the era, and naturally became the de facto programming language" data "for the home computer systems that emerged in the late 1970s." data "These machines almost always had a BASIC interpreter installed" data "by default, often in the machine's firmware or sometimes on a" data "ROM cartridge." data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data " " data "END" 'Graphic Color Changing Subroutines 'By The Sasquatch 'As requested by thwill and vegipete 'www.thebackshed.com ' 'File graphsubs.bas written 08-10-2020 12:31:44 'FixBytes(x,y,h,w,New_Byte) 'Changes any non-zero Bytes within the bounding box to New_Byte 'For a line, set h or v to 1 set w and h to 0 for full screen 'WARNING only works correctly in 8 bit color modes - 'will not work properly in "pixel doubled" modes CSUB FixBytes 00000000 4FF0E92D B085681B 68006815 182F6809 EB03431D 92010201 42B8D013 4291DC0E DC0B4614 681B4B35 3B01681B D3054283 68124A33 3A016812 D258428A E8BDB005 4B2E8FF0 681B4A2E 681B6812 3B016812 2B003A01 9201461F 2A00DBF0 4628DBEE 42914611 75E5EA25 4611BF28 EA20429F BF2872E0 428D461F 92029101 4B21DADE 681B42BA DAD9681E F8DF4253 F8DF8070 9300907C F8DF1ABB 9303B078 463D462B 9B00461F F1039C02 F8D80A01 EB0A3000 4A150004 FB09681B FB03F000 34014307 B1115CF1 6809990E EBBB54F1 D2010FB0 47986813 D1E842A5 37019B00 44139A03 9B019300 D1DC42BB E8BDB005 2F008FF0 2C00DBA4 460DDBA2 E7B24621 080002EC 080002F0 08000358 0800033C 3AFB7E91 001A36E2 End CSUB Visit Vegipete's *Mite Library for cool programs. |
||||
Page 1 of 2 |
Print this page |