High-Contrast Patterns for Newborns

Basic and Machine Language

Moderator: Moderators

User avatar
Schema
factor
Posts: 1430
Joined: Tue Mar 23, 2004 7:07 am
Website: http://www.jammingsignal.com
Location: Toronto, Ontario

High-Contrast Patterns for Newborns

Post by Schema »

Newborn babies like high-contrast images with primary colors, and looking at them is good for their eyesight development. Lots of baby toys have black and white patterns (example) or patterns mixing black, white and a strong color.

Image

So, I took some of the ideas from the various toys and books friends have given us, and made a small program for the VIC-20 to display similar patterns. It also chooses from one of 5 random colors for the background.

Image

Andreas will look at them for a little while, but he's probably too far from the TV at this age to really get any enjoyment from them. Maybe in a couple more months he will be able to focus past a couple of feet.

The VIC is perfect for this, the blocks are nice and big, with mostly primary colors available. In fact, I have no idea how you would do something like this on a PC. With Powerpoint maybe?

The program is here and listed below if anyone wants to check it out. Maybe use it as a VIC screen saver :wink: . Obviously there's an infinite number of ways to do this, but I thought this was sufficient.

I cheated and used a tiny ML routine to set background color to black, but it's 99% BASIC.

Code: Select all

10 poke36879,27:gosub2000
99 :
100 print"{clr}{black}";
110 fort=1to22
120 print"MNMNMNMNMNMNMNMNMNMNMN";
130 next
140 gosub3000
199 :
200 print"{clr}";
210 fort=1to22
220 print"{rvson} {right} {right} {right} {right} {right} {right} {right} {right} {right} {right} "
230 next
240 gosub3000
299 :
300 print"{clr}";:fort=1to11
310 print"{rvson}{black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} ";
320 print"{rvson}{white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} {white} {black} "
330 next
340 gosub3000
399 :
400 print"{clr}";:sys828
410 fort=1to100
420 x=rnd(1)*23:y=rnd(1)*24
430 poke7680+x+22*y,127
440 next
450 gosub3000
499 :
500 print"{clr}{black}";
510 fort=1to22
520 foru=1to11:print"{rvson}{A9}{rvsoff}{A9}";:next
530 next
540 gosub3000
599 :
600 print"{clr}{black}";
610 fort=1to22
615 if(t/2)=int(t/2)thenprint"{right}";
620 foru=1to10:print"{rvson}{A9}{rvsoff}{A9}";:next:print
630 next
640 gosub3000
700 print"{clr}{black}";
710 fort=1to11
720 print"{rvson}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}"
730 print"{rvsoff}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}{A9}{DF}"
740 next
750 gosub3000
799 :
800 print"{clr}";:sys828
810 fors=21to1step-4
820 xy=10-int(s/2)
830 fort=0tos-1
840 poke7680+xy*23+t,160
850 poke8142-xy*21+t,160
860 poke7680+xy*23+t*22,160
870 poke7700+(xy*21)+t*22,160
880 nextt
890 nexts
895 gosub3000
1999 goto100
2000 fort=828to841:readd:poket,d:next
2010 data169,0,160,0,153,0,150,153,250,150,200,208,247,96
2100 fort=0to4:readc:cl(t)=c:next
2110 data27,42,76,93,127
2200 return
3000 fort=1to1500:geta$:ifa$=" "then3020
3010 nextt
3020 poke36879,cl(rnd(1)*5)
3030 return
vic user
VicGyver
Posts: 1401
Joined: Thu Mar 25, 2004 9:40 am

Post by vic user »

i found looking at them this morning to help me wake up a bit :)

i find the green one with black zig zags very calming.

i remember doing something similar with my daughter when she was a few months old... i held her in front of the monitor while playing the demo's that came with my gravis ultrasound.

your method seems far less frightful!

chris
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Looks nice!
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
aneurysm
not your PAL
Posts: 178
Joined: Sat Mar 06, 2004 11:06 pm

Post by aneurysm »

i likes!
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

what does the command SYS 828 do, ive found it in similar programs, something about entering machine language at that point in memory? for instance i know sys 4 resets the vic 20 or clears all data, such as a NEW statement would do. but theres nowhere in any books i own sofar that describes this SYS 828. :P :P
6502dude
megacart
Posts: 1581
Joined: Wed Dec 01, 2004 9:53 am

Post by 6502dude »

SYS will call (or run) a machine language program at the address specified.

In this case SYS 828 will excute program starting at 828 (or hex $033c).

This is start of 193 byte area of memory (cassette buffer) which Basic will not generally over write (unless you load something from tape).

So, it is frequently used by programmers as a safe area to store a little bit of code.
Image Mega-Cart: the ultimate cartridge for your Commodore Vic-20
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

ty 6502 , looks like i have alot 2 learn, and i did find it now in my prog ref guide pg.181 033c-03fb 828-1019 Cassette buffer. This is where data files are held before they are INPUT. When not using files, this is available for POKEing or machine language programs.

in this case i was analyzing hard hat climber line
20 sys828:onpeek(1)goto35,26,28,31,33 which I think may be the main logic subroutine calls/loop, then of my search led me to Denial where I found Schemas color contrast prog that used this line a few times :
400 print"{clr}";:sys828 which he used to change the screen to black very quickly i think ?
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

i just don't understand why an ML routine is needed to do that. Wouldn't just a 36879 change suffice? Maybe I'm missing something.
High Scores, Links, and Jeff's Basic Games page.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Perhaps the routine fills the colour memory with black, which is different from setting the background to black.
Anders Carlsson

Image Image Image Image Image
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

You mean the character colour memory? Why? How would this be different from just changing the screen background color?
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

This is the ML program in charge:

Code: Select all

.C:033c   A9 00      LDA #$00     ; load colour code 0 for black
.C:033e   A0 00      LDY #$00
.C:0340   99 00 96   STA $9600,Y  ; write to 1st half of colour RAM
.C:0343   99 FA 96   STA $96FA,Y  ; write to 2nd half
.C:0346   C8         INY
.C:0347   D0 F7      BNE $0340
.C:0349   60         RTS
Schema uses 'STA $94FA,Y', so that only the first 506 bytes of colour RAM are written to, leaving out $97FA .. $97FF, but 'STA $9700,Y' would work as well, and do no harm.

Now let's look at the uses of SYS828 in the main program:

Figure 1:

Code: Select all

400 print"{clr}";:sys828 
410 fort=1to100 
420 x=rnd(1)*23:y=rnd(1)*24 
430 poke7680+x+22*y,127 
440 next 
Figure 2:

Code: Select all

800 print"{clr}";:sys828 
810 fors=21to1step-4 
820 xy=10-int(s/2) 
830 fort=0tos-1 
840 poke7680+xy*23+t,160 
850 poke8142-xy*21+t,160 
860 poke7680+xy*23+t*22,160 
870 poke7700+(xy*21)+t*22,160 
880 nextt 
890 nexts 
In both cases, PRINT "{CLR}"; , as always(!), initialises Colour RAM to 1, i.e. white characters over background. Schema only uses POKEs here, no PRINTs, to write the patterns - which he wanted to be in black.

He either could have accompanied each POKE into screen RAM with an additional POKE into the colour RAM, or easier ... filling the entire colour RAM with black with the ML routine given.

P.S. @Legacy:
in this case i was analyzing hard hat climber line
20 sys828:onpeek(1)goto35,26,28,31,33
I can say for sure, that it is alltogether another ML routine in use here at 828. It alters address 1 by certain conditions, so that one of the lines in the ON .. GOTO statement is called. There's not much more insight, that can be gained from that line alone - unless you supply at least the DATA loader for that ML routine, preferably in a new thread. :P
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

i wish i could, but i know nothing about 6502 machine language, I really need to invest some money on books and learn the basics of assembly, and how to get a processor todo the work and what commands do what in ROM, etc, i am just lost when it comes to that, but I can study what i see here and maybe figure out exactly what is going on. thanks for your input
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

I know that 7680 is the first byte of screen memory which holds 8 bits of character memory, the first example is filling the screen randomly with char 127 which is a half triangle square,but the character on the program looks like chr$ 191 which is a checkered box, so that is confusing me.oh i see now, there is a difference between SCREEN codes and CHARACTER codes, and since we are writing to the SCREEN location in RAM then we use screen codes, if we were to write a that character you would say PRINT chr$191... and the second routine at line 800 im not too sure about , but i know char code 160 is a space, i dont know the need for all the random numbers and diffrent screen positions. so I assume when SYS828 is called, it stores all that info on the cassette buffer because that space is always clear and data can be stored there easily without overwriting any important information because the vic is so limited on RAM to begin with. where can i signup for vic classes because I need alot of help!
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Legacy wrote:
Mike wrote:There's not much more insight, that can be gained from that line alone - unless you supply at least the DATA loader for that ML routine, ...
i wish i could, but i know nothing about 6502 machine language
That program statement

Code: Select all

20 sys828:onpeek(1)goto35,26,28,31,33
surely didn't come alone, but with a surrounding program, right? :roll:

You simply supply that program, and then it can be explained what SYS828 does do in that case.
Legacy wrote:i [didn't] know the need for all the random numbers and diff[e]rent screen positions [...] where can i signup for vic classes[?]
Here's a scan of the VIC-20 User's Guide, 23 MB as *.pdf file.

Take your VIC-20, or your favorite emulator, and try out the examples in the manual over the course of a few afternoons. ;)

Greetings,

Michael
Legacy
Vic 20 Enthusiast
Posts: 154
Joined: Wed Dec 31, 2008 4:01 pm

Post by Legacy »

thanks mike, yes, I am starting from scratch and going through the Programmers Reference Guide and now my new posts are in Programming section of the forum and Im working with Graphics and Character codes, memory maps, etc. I think my problem is Im trying to run before I can walk so Im taking it slow now, thank you for the assistance -leg
Post Reply