maziac / DeZog

Visual Studio Code Debugger for Z80/ZX Spectrum.
MIT License
210 stars 34 forks source link

Calling of rom functions in the zsim starting from dezog version 3.x.x (sna file problem) #105

Closed yarodin closed 1 year ago

yarodin commented 1 year ago

On dezog 2.7.3 I debuged attached project without any problem on "remoteType": "zsim" , but I can't do it after upgrade to dezog 3.3.1. Problem with calling standard ROM functions. However matrix.sna is working fine in other z80 emulatros (Sectaculator, UnrealSpeccy and so on). I'm not sure that's a bug, but how can I return old behaviour?

Components:

DeZog SW Version: 3.1.0 OS: Windows 11 Remote: Visual Studio Code 1.74.0 & zsim

prj1.zip

maziac commented 1 year ago

The problem is actually in 2.7.3. Your program is compiled for a ZX 128K which has 2 ROMs: ROM0 = the 128K ROM and ROM1=the original ZX48K ROM. And your are trying to enter a ZX48K ROM routine but at startup dezog 3.1.0 correctly pages in ROM0.

It worked with 2.7.3 because it wrongly paged in ROM1 from the beginning.

So, to make it work: either compile for ZX48K and use the "ZX48K" memory model in launch.json or change your startup code to switch the ROM to ROM1 (by writing to port 7FFD, see e.g. here http://www.breakintoprogram.co.uk/hardware/computers/zx-spectrum/memory-map).

But good you reported it, I will make a note in the migration doc.

maziac commented 1 year ago

Actually, I took another look. Although my last comment was correct. There is something else in this issue: The 128k SNA file you supplied has the bit 4 set for port 7FFD. I.e. this should select the ROM 1 = 48k ROM.

So there is an error that the ROMs are not correctly switched when loading a 128k SNA file. I will correct this.

maziac commented 1 year ago

Here is a fix: please try DeZog-3.1.1-rc1 https://github.com/maziac/DeZog/releases/tag/3.1.1-rc

While loading the 128k SNA file DeZog will set port 7ffd and with the ROM accordingly.

yarodin commented 1 year ago

I tested my 128k SNA's on DeZog 3.1.1 - now all works fine. Thank you.

maziac commented 1 year ago

Thanks for testing.