MEGA65 / mega65-rom-public

MEGA65 ROM public issue reporting
4 stars 0 forks source link

ROM 920382 crashes with some calls of llvm-mos's printf() #129

Closed dansanderson closed 3 weeks ago

dansanderson commented 3 months ago

Test Environment (required) You can use MEGA65INFO to retrieve this.

Describe the bug

Starting with ROM 920382, llvm-mos's implementation of printf() appears to crash sometimes.

In Xemu 20240228183812-master with ROM 920395, no printf() statement succeeds, and Xemu opens a dialog box:

Unhandled memory write operation for linear address $500050 data = $2F (PC=$E406)

On real hardware (R5 board, core release-0.96,20240224.00,3c10488), you can see a few printf() statements succeed briefly, then the screen goes black, and the PC bounces around $E1xx.

To Reproduce

Load and run M65SCRIPT from the example build.

Additional context

My current suspicion is that after the 80x50 screen editor refactor, the screen editor is not handling the print-related KERNAL entry points correctly when scrolling or line clearing is involved (e.g. printing on the last line of the screen), in a way that isn't noticed by printing from BASIC or regular typing.

The "unhandled memory write operation" reported by Xemu occurs upon executing the EDMA job in edma_attribute, which is used by the screen editor to clear lines while printing. The EDMA job list should be at $1400. I'll need to throw in a brk and examine this memory to see if the job list is malformed.

dansanderson commented 3 weeks ago

This was caused by EDMA job templates living in an area of ROM that was only visible with the BASIC MAP, not the SYS MAP. With the test program, the templates were not where the KERNAL thought they were, and it copied zeroes into the EDMA job description when trying to scroll. I relocated the templates, and the test program now works.

We'll do a 920398 release soon, which will contain this fix.