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

Bug in calculate_property_length_number? #29

Closed ZornsLemma closed 3 years ago

ZornsLemma commented 3 years ago

This subroutine does:

    jsr read_next_byte ; size of property block (# data | property number)
    beq .end_pf_property_list

It looks to me like the beq is intended to reflect the value returned in A by read_next_byte. But read_next byte always returns by doing:

+   ldy z_address_temp
    rts

so the beq in calculate_property_length_number will always be based on the value which happened to be in Y.

I think we need a 'cmp #0' between the two quoted lines of calculate_property_length_number.

johanberntsson commented 3 years ago

Well spotted. This was only called from two places and the y register seems to have been non-zero at all times so it didn't matter but still a bug. Fixed. I've also checked all other calls to read_next_byte to verify that they aren't followed by a bad beq/bne, but this was the only instance.