johanberntsson / ozmoo

A Z-machine interpreter for the Commodore 64 and similar computers
GNU General Public License v2.0
117 stars 19 forks source link

zmachine.asm z_get_low_global_variable_value subroutine is not always needed #44

Closed ZornsLemma closed 2 years ago

ZornsLemma commented 2 years ago

I think you can save a few bytes by conditionally omitting zmachine.asm's z_get_low_global_variable_value subroutine (line 650-ish) from some builds. I believe this is only needed (making up my own syntax, which is hopefully fairly obvious) if "ndef(Z4PLUS) or (ndef(COMPLEX_MEMORY) and def(SLOW))". The ndef(Z4PLUS) condition accounts for needing it to draw the status line on Z1/2/3 games and the remaining condition accounts for the use in zmachine.asm's .read_global_var.

I have been doing this on the Acorn port for a while, although COMPLEX_MEMORY is never defined on Acorn so I haven't had to express the full condition as described above, which is why I haven't sent a pull request for this. I haven't noticed any problems, and I think it's fairly obviously safe to do this because omitting that code when it's needed would cause a failure at assembly time.

fredrikr commented 2 years ago

Fixed. Thanks!