Countdown with big 7-segment for MSX 2 screen 5 in Assembly

Page 1/2
| 2

By albs_br

Champion (321)

albs_br's picture

03-01-2021, 04:06

Hi guys, I'm trying to break the inertia and start in the realm of MSX 2 development, so I think of something very simple to start.

It's a 9 to 1 countdown on a big 7 segment display made using screen 5. Even though being in BASIC it runs pretty fast.

The core of the trick is that changing the RGB components of a color (palette index) is very fast, even in BASIC. Instantly all pixels of that color will change like magic. So I created a 7 segment display in which each of the segments are painted on a different color index (1 to 7), initially all black (same color as background).

By changing all the components of a color index in rapid fashion I can make that smooth transition from black (0, 0, 0) to white (7, 7, 7) giving that cool "glowing" effect.

It can be used for events such as New Year... (I'm a little late for this one)

https://msxpen.com/codes/-MQ5D0zYRPJuHjqsOCIu

The code is pretty well commented, and not a total mess like most of my BASIC programs.

Hope you enjoy.

Login or register to post comments

By Dolphin101546015

Champion (324)

Dolphin101546015's picture

03-01-2021, 08:36

Try Kun-Basic
It more fast.

By Parn

Hero (651)

Parn's picture

03-01-2021, 16:53

@albs_br, your solution is interesting and I liked seeing it in action. I hope you don't mind me making a suggestion: since you never show more than one digit at a time, you could draw all valid configurations of the seven segments in other pages using a single color and use COPY to bring them back to the active page and animate only one color, which would be even faster and would free the other 14 colors to draw decorations or pretty much anything else. Actually, by following this approach you wouldn't really need to restrict yourself to a 7-segment layout.

By albs_br

Champion (321)

albs_br's picture

03-01-2021, 23:24

Parn wrote:

@albs_br, your solution is interesting and I liked seeing it in action. I hope you don't mind me making a suggestion: since you never show more than one digit at a time, you could draw all valid configurations of the seven segments in other pages using a single color and use COPY to bring them back to the active page and animate only one color, which would be even faster and would free the other 14 colors to draw decorations or pretty much anything else. Actually, by following this approach you wouldn't really need to restrict yourself to a 7-segment layout.

It sounds great, but at this moment I still don't know how to deal with more than one page (is it using VPOKEs and VPEEKs to copy)?

By ToriHino

Paladin (721)

ToriHino's picture

03-01-2021, 23:33

For working with pages under basic you can use SET PAGE to set the display and active page, and VCOPY to copy from one page to another (source and destination pages are part of the arguments).

By Manuel

Ascended (18088)

Manuel's picture

04-01-2021, 00:25

VCOPY is a DM System 2 extension. You mean the normal COPY command Smile

By ToriHino

Paladin (721)

ToriHino's picture

04-01-2021, 07:06

Manuel wrote:

VCOPY is a DM System 2 extension. You mean the normal COPY command :)

Yes indeed, that was the wrong link :)

By albs_br

Champion (321)

albs_br's picture

04-01-2021, 15:10

If I understood well in screen 5 we have 4 pages, of which one is the active, remaining 3 for digits buffer.
BUT, the digits are pretty big, so there will be space for only 2 per page, 6 on the 3 pages. I need 9 (or at least 8).
Is it correct?
Should I make the digits smaller to fit?

By albs_br

Champion (321)

albs_br's picture

04-01-2021, 15:12

As a small side note: I just perceveied the digits are inclined to the wrong side Smile

Current version with segments turned off painetd in dark gray:
https://msxpen.com/codes/-MQ7oPNvB47sOySBna4F

By albs_br

Champion (321)

albs_br's picture

04-01-2021, 15:14

albs_br wrote:

If I understood well in screen 5 we have 4 pages, of which one is the active, remaining 3 for digits buffer.
BUT, the digits are pretty big, so there will be space for only 2 per page, 6 on the 3 pages. I need 9 (or at least 8).
Is it correct?
Should I make the digits smaller to fit?

Or, I could make another approach and to buffer only the segments (just two, the horizontal and the vertical) and COPY them on the right place to form each digit.

By Jipe

Paragon (1499)

Jipe's picture

04-01-2021, 15:27

you miss 0 Wink

Page 1/2
| 2