Jump to content
Jet Set Willy & Manic Miner Community

Free space and code optimisation in Manic Miner


IRF

Recommended Posts

ATT15 equ $59e0 ; The attribute position of the piano, which is defined as line 15

 

 

 

; calculate the screen position to press a key based on "a" the note

NOTE_PLACE:

LD HL,ATT15 ; this address is free to move up or down the screen

SUB 8

CPL

STEP1_INDEX:

RRCA

RRCA

STEP2_INDEX: ;used by the delay routine

RRCA

AND 31

STEP_INDEX:

ADD A,L

LD L,A

ADC A,H

SUB L

LD H,A

 

LD A,(HL)

RET

 

By "the delay routine", are you referring to some other part of your modified version of the program, which uses (in part) the common subroutine to extract data in a similar manner?

 

; byte 1 ------xxb the xxb value is an index into the TIME_SHIFT array. This supplies the note duration.

; byte 1 xxxxx---b the xxxxxxb value is an index into the NOTE_SHIFT array. this supplies the shift from the first note to the second note

; byte 1 -----x--b the xb value is unused in this data

;

 

As well as the spare bit that you identify, I think the highest bit is also spare, since there are only 16 entries in the NOTE_SHIFT table (which therefore only requires 4 bits)?

Edited by IRF
Link to comment
Share on other sites

STEP2_INDEX: is/was used by another routine as you suggested.


The unused bits. The routine was written to encompass change in the data. So the length of each data table was selected to enable editing. 3 bits for time and five bits for pitch change. The subroutine contains an "AND 31" which is handy for the pitch change data. No point in adding another instruction somewhere just to reclaim the bit that is/was not used in the data. 

The notes length still needed to have an "AND ?" added somewhere, and here I felt the editing of the data was unlikely to add longer notes. So "AND 3" was selected and then the additional bit was free. The point of including the statement that this is unused. Was to emphasize that the bit is available if wanted. and the "AND 3" can be changed to "AND 7" and additional note lengths can be added.

I can think of no use for the spare bits, apart from the what they were originally designated to be used for.
 



 

 

 

 

Link to comment
Share on other sites

  • 2 years later...

In Manic Miner, the code which deals with Skylabs seems to be arrived at via a JUMP from the Main Loop - unlike all the other guardian routines, which are CALLed.  There doesn't seem to be any rational reason for this discrepancy, so a few bytes could perhaps be saved - with a bit of care to ensure the stack pointer is preserved, etc - by changing the status of the Skylab-handling code to a subroutine, with the jump back into the Main Loop replaced with a RET.

Edited by IRF
Link to comment
Share on other sites

7 minutes ago, IRF said:

In Manic Miner, the code which deals with Skylabs seems to be arrived at via a JUMP from the Main Loop - unlike all the other guardian routines, which are CALLed.  There doesn't seem to be any rational reason for this discrepancy, so a few bytes could perhaps be saved - with a bit of care to ensure the stack pointer is preserved, etc - by changing the status of the Skylab-handling code to a subroutine, with the jump back into the Main Loop replaced with a RET.

Ah, the reason why it's done the way it is, is because if the program were to RETurn to the exit point from the Main Loop, it would then try to draw vertical guardians on top of the Skylabs!  So the Skylab code jumps back to a later entry point in the Main Loop, bypassing the CALL to draw regular vertical guardians (as well as the CALLs to draw Kong/the solar beam).

Link to comment
Share on other sites

The code for the skylab:-

If the test for the cavern was done at the entry for vertical sprites #8ef1, then the skylab mess around in code disappears.

E.g. call the vertical sprites #8ef1 and test for the skylab cavern. If in the skylab then branch to the skylab code.
Skylab does a normal return, and the Kill willy detection does the same jump as in all the other sprite routines 

8777 LD A,($8407)   Pick up the number of the current cavern from 8407

877A CP $0D    Are we in Skylab Landing Bay?

877C JP Z,$8E75    If so, move and draw the Skylabs

877F LD A,($8407)Pick up the number of the current cavern from 8407

8782 CP $08Are we in Wacky Amoebatrons or beyond?

8784 CALL NC,$8EF1 If so, move and draw the vertical guardians

========================================.

8EF1  cp $0d  process verticals but is this the skylab

         jp z,$8e75 go instead to the skylab routine

 - carry on as normal - but the above five bytes has no place to sit in the fixed Matthew code layout. - but would have been simple for Matthew to have done. And the code would have been smaller.

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.