Assembly experiment: bouncing block

Page 6/7
1 | 2 | 3 | 4 | 5 | | 7

By thegeps

Paladin (789)

thegeps's picture

13-05-2021, 22:40

I put in the interrupt all sprites management (data update in ram and copy from ram to vram) and music/sfx play.
In the main loop I update tiles, game logic, handle controls and check collisions

(I was about to suggest the ecb use too, like artrag did)

By Grauw

Ascended (9824)

Grauw's picture

13-05-2021, 23:02

@Pbk71 An fyi about the PSG, make sure when you write to PSG register 7 that bits 6 and 7 are 0 and 1 respectively. I don’t think you’re touching that register atm but it’s good to be aware of it, as it’s a common oversight.

santiontanon wrote:

Do you guys tend to use this method (I heard Konami used to do it like this iirc)? I always put all the code on a regular loop and only the music playing code in the interrupt.

Same for me, and a bunch of screen split handlers which update VDP registers and the palette. I use double buffering for most things so if an interrupt is missed then it will result in a frame skip. Though that should normally not happen since I also use the method that ToriHino describes:

ToriHino wrote:

I normally tend to program for 'worst case' i.e. update always the same amount of data (sprite positions, characters patterns, colors...) to VRAM even if not changed, to have a steady refresh rate. As long as that still fits within the interrupt you know for sure there is no frame skipping.

By Pbk71

Expert (99)

Pbk71's picture

14-05-2021, 10:04

Quote:

Very nice! And the code has improved a lot.
Actually I have an additional suggestion. If you want that the sprites enter in the screen smoothly from the left side of the screen you should use the EC bit in the color byte in the SAT

@ARTRAG: thanks, I will try to implement that.

Quote:

An fyi about the PSG, make sure when you write to PSG register 7 that bits 6 and 7 are 0 and 1 respectively. I don’t think you’re touching that register atm but it’s good to be aware of it, as it’s a common oversight.

@Grauw: Thanks for mentioning. I already read that these bit should not be changed. In some example I saw in MSX books about programming there were examples where they did change these bits.
I will be carefull just to alter bits 0 to 5 to enable or disable noise or tone for the three channels.

Thanks all for explaining how a program should be set up with a main loop and a timer hook that mainly only writes to VRAM and handles the sound effects. I'm not planning to rewrite this experiment but I'll will to try to work this way in my new programs/experiments.

By Pbk71

Expert (99)

Pbk71's picture

14-05-2021, 11:29

Ok, I managed to use the EC bit to make the sprite enter the screen smoothly. Maybe it's not the most easy way but for now I'm happy to understand how it works Wink

Result here: https://msxpen.com/codes/-M_eBVBZgclQmlIDrhnS

By Pbk71

Expert (99)

Pbk71's picture

14-05-2021, 12:13

Last thing on this experiment: I combined my scrolling wall example with the bouncing ghost.

See result: https://msxpen.com/codes/-M_eMKEMq5P54E8lDDjr

It is really time for me to start a new experiment or program 'cos this one is getting quite messy with all the code in the timer hook. I'm happy with what I've learned (thanks for all the advice)and my goal now is to make a simple run and jump game like the dino run game in the google browser. I think I have a lot of the knowledge now to create such a program, but I really need to do it in a more structured way :D

By thegeps

Paladin (789)

thegeps's picture

14-05-2021, 13:18

Cool.achievement, congrats!

By Pbk71

Expert (99)

Pbk71's picture

14-05-2021, 13:36

thegeps wrote:

Cool.achievement, congrats!

Thanks!

By ren

Paragon (1797)

ren's picture

14-05-2021, 13:45

Somewhat related, just came to mind - (an) ultimate challenge: upgrade the cats PetsMode demo, so that the (softbody (?!)) polyhydrons actually bounce on the checkerboard (see the original) :)

By ARTRAG

Enlighted (6504)

ARTRAG's picture

14-05-2021, 14:20

You should use -32 to subtract 32
ld hl,(x)

ld de,-32 ; substract 32 by -32
add hl,de
ld (x),hl

There is also a RST that you could use instead of CALL and some change you could do to increase readability of constants

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

By Pbk71

Expert (99)

Pbk71's picture

14-05-2021, 14:48

ARTRAG wrote:

You should use -32 to subtract 32
ld hl,(x)

ld de,-32 ; substract 32 by -32
add hl,de
ld (x),hl

There is also a RST that you could use instead of CALL and some change you could do to increase readability of constants

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

Thanks, substracting 32 makes more sense in my code this way. I changed one call DCOMPR to rst DCOMPR.

What could I change to my constants? Should I use different names that make more sense?

Page 6/7
1 | 2 | 3 | 4 | 5 | | 7