Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cargas de Produndidad / Depth Charge
#4
britlion Wrote:Very nice little fun thing. Good job.

By the way, my sneaky fast t() function is:

Code:
FUNCTION t() as uLong
asm
    DI
    LD DE,(23674)
    LD D,0
    LD HL,(23672)
    EI
end asm
end function

Which saves a lot of maths and division. If you want to divide by 50 to get whole seconds, you can do it outside the function - but generally, I found t() returning clock ticks and working with them as 50 times larger meant I have more precision on where I launch events. (Instead of at 1s, 2s, 3s, I go 50 frames, 100 frames, 150 frames - and then if I want to I can tweak that to 40,80,120 much more easily).

I notice you are actually using it in the line:
a = t1 / 30 * PI

So to get t you do a lot of stack work, then divide by 50 - and then divide by 30. I think I'd do it as frames and divide by 150 in one go when setting a, which is probably shorter than running the full division twice.

Anyway. Just my thougts. The game is quite fun Big Grin Never enough depth charges.

Many thanks! I'm not fond on ASM so any input is very welcome; at least I can compare your code with mine and learn something new  Smile
Besides, I updated the game with a few improvements: sonar is now draw OK , added a minor visual effect on it, load screen and intro music. And the inlays, shared with my other Escape game.
Spanish inlay: https://drive.google.com/open?id=1aHkpNZ...Cfx5sgDVvJ
English inlay: https://drive.google.com/open?id=1TTmyl3...31KLPwTItz

Cheers.


EDIT: just tried your ASM t() function and it's so fast I can now "play" with the sonar and add more effects  Big Grin
Anyway, just to try to understand a bit of ASM with your function:

    DI -> disables interruptions, so the program won't interfere with the function
    LD DE,(23674) -> load the value of the 23674 address (part of the Spectrum frames system variable) in the DE register (one of the Spectrum 8+8 -pair- bit registers)
    LD D,0 -> load 0 into D register (?)
    LD HL,(23672) -> load the value of the 23674 address (part of the Spectrum frames system variable) in the HL register (one of the Spectrum 8+8 -pair- bit registers)
    EI -> enables interruptions before existing function

But the function, what returns? The sum of all values? And why load a zero value into D?  Sorry if they are basic ASM questions, but my knowledge of ASM and the Z80 are almost none.


Attached Files
.tap   Cargas_de_Profundidad_v1.0_esp.tap (Size: 21 KB / Downloads: 2)
.tap   Depth Charge_v1.0_eng.tap (Size: 20.93 KB / Downloads: 2)
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)