Assembly experiment: bouncing block

Página 7/7
1 | 2 | 3 | 4 | 5 | 6 |

Por thegeps

Paragon (1189)

imagem de thegeps

14-05-2021, 15:30

I see that you disable interrupts, set your hook in H.TIMI and reenable interrupts. You can avoid to di/ei:
Set FIRST address of your routine to be hooked at H.TIMI +1 +2 and THEN jump (or call) opcode in H.TIMI

Por ARTRAG

Enlighted (6935)

imagem de ARTRAG

14-05-2021, 15:30

You can use this, istead of a separate label
ld hl,-MAXSPEED ; make speed negative maxspeed
ld (speed),hl
and this expression, instead of 287
; if x = 287 (255+32) then x=0
ld de,255+32
rst DCOMPR
jp c,xsmallerthan287

Moreover, I have a couple of suggestions, you can pack constants
ld bc,128*256+0x98 ; load port to write to and 128 bytes of patterns (4x32)

You can replace these instructions
; ld A,(y+1) ; high byte of y is the actual y-coordinate
; ld B, MAXY
; cp B
by these
ld a,h ; HL holds Y here
cp MAXY ; high byte of y is the actual y-coordinate
JP C,yissmallerthanmaxy
and you can replace
cp 0
by
and a

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

Por Grauw

Ascended (10768)

imagem de Grauw

14-05-2021, 16:06

thegeps wrote:

I see that you disable interrupts, set your hook in H.TIMI and reenable interrupts. You can avoid to di/ei:
Set FIRST address of your routine to be hooked at H.TIMI +1 +2 and THEN jump (or call) opcode in H.TIMI

That only works if the original contents of H.TIMI is 5x ret. Using di/ei is fine and safer in my opinion.

Por santiontanon

Paragon (1806)

imagem de santiontanon

14-05-2021, 17:58

That new bouncing + scroll looks great!, some keyboard control to influence the ball speed, and a few wall obstacles and you got yourself a game already Wink

Por santiontanon

Paragon (1806)

imagem de santiontanon

14-05-2021, 18:01

And also, btw, this thread is great. Even after having been coding in Z80 assembler for years now, I'm learning many things here. For example, I just noticed you mentioned RST, and I just finally learned what it does! Smile

Por Pbk71

Expert (101)

imagem de Pbk71

14-05-2021, 18:24

santiontanon wrote:

That new bouncing + scroll looks great!, some keyboard control to influence the ball speed, and a few wall obstacles and you got yourself a game already Wink

Yeah, I probably could, but that would leave me with a base in my program that's not good (all code in the timer hook).
So I think it's better to use the knowledge and start from scratch and end up with a more solid program. I also want to split up the program in separate asm files, so I will be using a assembler and not MSXPen (what is a great tool for this kind of experiments btw!)

Por Pbk71

Expert (101)

imagem de Pbk71

14-05-2021, 18:26

santiontanon wrote:

And also, btw, this thread is great. Even after having been coding in Z80 assembler for years now, I'm learning many things here. For example, I just noticed you mentioned RST, and I just finally learned what it does! Smile

That's what I like about using a forum like this as well. By following threats you learn a lot about programming in assembly and you'll see different solutions for a problem.

Por thegeps

Paragon (1189)

imagem de thegeps

14-05-2021, 23:42

Grauw wrote:
thegeps wrote:

I see that you disable interrupts, set your hook in H.TIMI and reenable interrupts. You can avoid to di/ei:
Set FIRST address of your routine to be hooked at H.TIMI +1 +2 and THEN jump (or call) opcode in H.TIMI

That only works if the original contents of H.TIMI is 5x ret. Using di/ei is fine and safer in my opinion.

You are right, it can be used only on cartridge games, I suppose, or on plain msx1

Por Micha

Expert (103)

imagem de Micha

15-05-2021, 11:21

I never completely understood the purpose of these very short RST bios calls like DCOMPR.
It is faster (by 4 cycles - RST+jp = 10+11 cycles; Call = 17 cycles) to do something like this (at the expense of only 8 extra bytes of code):
....
call MyDCOMPR
....
MyDCOMPR:
ld a,h
sub d
ret nz
ld a,l
sub e
ret
----------
are there any reasons not to do this, except for saving 8 bytes of code?

Por pgimeno

Champion (328)

imagem de pgimeno

15-05-2021, 13:13

Micha wrote:

are there any reasons not to do this, except for saving 8 bytes of code?

Saving 2 bytes per call. I count 102 bytes total saved (51 uses) in one particular BASIC ROM.

What I don't understand is why there is a routine at 0x24 (ENASLT). The whole DCOMPR routine would have fitted there otherwise.

Página 7/7
1 | 2 | 3 | 4 | 5 | 6 |