Jump to content


IRF

Member Since 23 Aug 2015
Offline Last Active Dec 10 2017 10:16 PM
-----

Posts I've Made

In Topic: Free space and code optimisation in "JSW"

08 December 2017 - 05:37 PM

Thanks Norman.

I suppose there might be other functions where Matthew's code replicates something that is already available in the ROM?

In Topic: Free space and code optimisation in "JSW"

07 December 2017 - 06:36 PM

A few efficiencies can be found around the IN commands that take signals from the keyboard.

Wherever there is a LD BC,#0000 followed by an IN A,© - this can be replaced with a LD A,#00 [the value that was previously being loaded up to B] followed by an IN A,(#FE).

Also, in places where a routine responds to any keypress from one or more entire half-rows of keys*, you can replace this sequence:

AND #1F
CP #1F

which leaves the Zero flag reset if and only if one of the appropriate keys is pressed, with this:

OR #E0
CPL  [Note that the CPL command leaves the Zero Flag unchanged, even if the Accumulator ends up with a value of #00.]

INC A  [This replaced the CPL command, which didn't work.  INC A will set the Zero flag if and only if the previous value of A was #FF i.e. all bits set, because no keys in the relevant half-row are being pressed.]

which has the same effect on the Zero flag, but requires one less byte.

(*Such as pausing/unpausing the game, toggling the music on/off, or pressing a Jump key other than '0'. It wouldn't work when specific keys out of a half-row are being tested, such as Left-Right movement or the SHIFT+SPACE abandon-the-game key combo.  Note that this won't work if the situation requires the precise value in A - as determined by the particular key in the half-row that was pressed - to be used for other purposes.)


In Topic: A test file for JSW

06 December 2017 - 11:55 AM

In the attached, I've tweaked my Game Over test file in accordance with Norman Sword's suggestions.  I've also come up with a way of having a pause instead of (but of the same length as) a note, to punctuate the music.  That required four additional bytes in the code, and the use of the value '01' in the music data to denote the 'dead notes'.


In Topic: A test file for JSW

05 December 2017 - 01:20 PM

Thanks Norman.

I was aware that I had implemented a 'quick and dirty' solution, which causes the changes in duration of the notes. (It's probably a deliberate effect in the original routine, as the increasing pitch causes the Monty Python foot to speed up as it descends onto Willy.)

In Topic: A test file for JSW

04 December 2017 - 01:39 PM

Spot on, Danny!