The Pawn Demo

Discuss ZX Spectrum Next Games, Tools and more.
User avatar
jkjyuio
Posts: 4
Joined: Mon Feb 19, 2018 8:00 pm

Re: The Pawn Demo

Postby jkjyuio » Mon Feb 26, 2018 2:59 am

Banking magnetic;

Short answer, no. Long answer; the magnetic interpreter allocates a chunk of memory for the code, some undo areas, restart and so forth. This is no good for the 64k version. The original Scrolls' interpreters used to swap in and out chunks of code (from floppy disk), that's how they fitted in RAM. My guess is something like that will have to be done again.

The swapping emulators used to find creative places to cache blocks, for example on PC graphics cards or side memory in some systems. on the SpectrumNX, you would use that "spare" 1MB for cache, so it would run well. Except you'd need to build a swapping emulator.

It's a real shame the original code isn't recovered.

Stefan123
Posts: 119
Joined: Mon Jun 05, 2017 9:38 pm

Re: The Pawn Demo

Postby Stefan123 » Mon Feb 26, 2018 3:44 pm

This weekend I started to look at porting the Magnetic interpreter in emu.c to Spectrum Next by adding support for handling the code, strings and dictionary sections in the .mag story file in a bank-switched manner. I quickly realized that the debugging experience when doing this directly for the Spectrum Next was too poor. I'm not comfortable debugging the compiled Z80 assembly code and manually translating it back to the corresponding C code. It's too cumbersome and time-consuming.

So I switched approach and decided to emulate bank switching in the generic version and run that on my Windows PC so I can debug it properly. I started with only using bank-switching for the code section and have the strings and dictionary sections in memory as before. It was not that difficult to add bank-switching using 8 KB pages for the code section since the effective() function for translating to a virtual address fitted nicely with this. However, after a while I noticed that the arg1 and arg2 global variables don't play nice with this since they may point directly into the code section and when being referenced that page in the code section may have been switched out due to a later call to effective(). I can see this problem occurring for the code in emu.c that emulates the 68000 "move" instructions if the code memory referenced by one of the arguments refers to a page that has been switched out. I'm working on a solution for this but I'm sure there are more things in emu.c that may break with bank switching...

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: The Pawn Demo

Postby SevenFFF » Mon Feb 26, 2018 5:29 pm

Stefan123 wrote:
Mon Feb 26, 2018 3:44 pm
I quickly realized that the debugging experience when doing this directly for the Spectrum Next was too poor. I'm not comfortable debugging the compiled Z80 assembly code and manually translating it back to the corresponding C code. It's too cumbersome and time-consuming.
Defo, that's one of the reasons I've always avoided C on the Spectrum. I like to see the code I've written, not somebody else's idea of what I've written.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins

Stefan123
Posts: 119
Joined: Mon Jun 05, 2017 9:38 pm

Re: The Pawn Demo

Postby Stefan123 » Tue Feb 27, 2018 9:25 am

If it is my own C code, I can in general get by with printf and border colour debugging but if working with a third party code base that you don't understand every detail of, not having a source code debugger is a pain. When I'm writing code that is non-trivial (algorithms or string manipulations), I try to keep it generic so I can run and debug it on my PC to verify its correctness and then move it to the Next when it works.

I remember reading somewhere that there was a guy looking into creating a C-level debugger using the symbol information generated by z88dk but I don't remember where I read it. It would be extremely nice to have a C source code debugger that could be used with the emulators :)

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: The Pawn Demo

Postby SevenFFF » Tue Feb 27, 2018 2:21 pm

Yes, makes sense. I do prototype things in a high level language too, sometimes. Not having to rewrite that code in assembler is definitely an advantage :)

I had the source level debugger thread bookmarked on WoS, is this the one? https://www.worldofspectrum.org/forums/ ... ing#latest
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins

Stefan123
Posts: 119
Joined: Mon Jun 05, 2017 9:38 pm

Re: The Pawn Demo

Postby Stefan123 » Tue Feb 27, 2018 8:33 pm

Yes, that was the thread I meant :) I did a quick search and also found a similar thread on this forum:
viewtopic.php?f=15&t=601


Who is online

Users browsing this forum: No registered users and 2 guests