Assembly experiment: bouncing block

صفحة 7/7
1 | 2 | 3 | 4 | 5 | 6 |

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

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

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.

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

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!

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

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!)

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!

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.

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

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?

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.

صفحة 7/7
1 | 2 | 3 | 4 | 5 | 6 |