DAAD Adventure Writer and ZX Next

Do you live and breathe hexadecimal? Do you like speaking to hardware directly?

Moderator: Programming Moderators

User avatar
Uto
Posts: 57
Joined: Tue May 30, 2017 9:33 am

Re: DAAD Adventure Writer and ZX Next

Post by Uto » Mon Sep 16, 2019 9:23 pm

Ped7g wrote:
Mon Sep 16, 2019 6:25 pm
ZEsarUX has quite powerful debugger... I find it's GUI a bit cumbersome and limiting, but compared to "no debugger at all" it's beautiful and works really well (you can even view copper code, sprite memory, etc, but most often just breakpointing into code and single-stepping over instructions checking register values is enough, at least for me).

I still kinda prefer CSpect from UX point of view and how it displays the debugger, but unfortunately both emulators are mixed bag when it comes to accuracy, so in the end I'm often forced to use the one where the particular feature is emulated better. But for your current "load L2 image and use clip window" none of that should worry you, these basic flags and nextregs are emulated on both sides really well. Although it may be tricky to run them correctly, also setting directory where they should look for `fopen` files, etc.. I'm not even sure how to do it correctly with Zes except building full card image, I think it actually doesn't check host file system? Maybe that's your issue, opening other files while you don't have them on the card image? But I may remember it incorrectly. CSpect can definitely work with host file system, you just need to provide current (or whichever you want) directory by "-mmc=./" argument (maybe opposite slash on windows, but I have only linux, so I don't know for sure).
I tried CSpect too but couldn't make it work, for ZesarUX I had the help of the emulator author, and I got my toolchain working before I started to type a single line of code. Basically I always do it like that: toolchain first, then code. That has got me through a lot of emulators, tools to manage disks, tapes, etc. while doing the ESXDOS, +3, CPC, MSX and C64 versions, and even through learning 6502 assembler, but now I'm happy cause I know mucho better all those 8 bit machines and the development tools for them :-)

User avatar
Uto
Posts: 57
Joined: Tue May 30, 2017 9:33 am

Re: DAAD Adventure Writer and ZX Next

Post by Uto » Mon Sep 16, 2019 9:39 pm

Stefan123 wrote:
Mon Sep 16, 2019 8:31 pm
Hi Uto,

Great news that you are adding layer 2 graphics support to DAAD! I use layer 2 as the foreground layer for displaying images in the Spectrum Next conversions of the Magnetic Scrolls games. The background layer uses either standard ULA mode or Timex hi-res mode for displaying the text. The layer 2 screen is limited to the first 136 lines using a clip window. The height of the layer 2 clip window can be changed by the user using the mouse (drag or mouse wheel) or the keyboard (up and down arrow keys) to make more or less room for the text.
I'm sure a lot more could be done for DAAD, but I'm not building a new interpreter (I don't even have the sources). I'm just using the original interpreter with it's original feature to add "EXTERN" code, so I'm somehow limited. I sometimes have to patch the interpreter a bit, basically making the addon modify parts of the code in runtime, but I can't make major changes.

So although Times HiRes mode fits very well for adventure games, and in fact I already teste that a bit with ZX-Uno, the fact with DAAD is if I change ULA layer to HiRes, DAAD text output would just paint a character every second column, and if I don't want that to happen, i would have to patch the text output routines, what I'm sure i'ts not impossible but quite complicated.

I know Tim can help, in fact he has helped me several times already, I ask him when I'm stuck with something, but I just work in the EXTERN, not in the interpreter (except for those minor patches in runtime).

I temporarily use MMU slot 2 (ULA screen, 16K - 24K) to load layer 2 images in 8 KB chunks to MMU pages 16 to 21 (or 22 to 27 depending on which layer 2 screen is set as front/back buffer). It's safe to use MMU slot 2 in this way since the ULA screen is rendered from the contents of MMU page 10 and not from what is currently mapped in to the address range 16K - 24K.
I've chosen MMU7 cause DAAD has the stack placed in the lower area, and code it's also located at 0x6000, so anything above $c000 I know it's safe, cause there is only data there, which is not used by my code.
There are several tools available for converting images to the layer 2 raw format. I use my own tools on GitHub, which are based on Jim's original BMP conversion tools.
Well, I didn't know that, but well, my DAAD addon, apart of the binaries for each computer, includes a executable to convert from several common formats (i.e. SCR for Spectrum, SC2 for MSX, .ART for C64) so the users would expect it to include also the converter for the Next, and I already did it. Well, in fact I did it in 1995, cause I used code I wrote 24 years ago wich decoded a PCX file and converted to RAW file for loading in VGA 320x256 mode. A long story but I've chosen PCX cause it's a format still supported by Gimp, and at the same time freezed in time, so I don't have to support different versions of the format, nor think in future updates.

User avatar
Uto
Posts: 57
Joined: Tue May 30, 2017 9:33 am

Re: DAAD Adventure Writer and ZX Next

Post by Uto » Mon Sep 16, 2019 9:41 pm

Well guys, I's almost done. I have properly loaded the picture now, although I found a bug in my converter cause I swapped R and G in the palette by mistake, but I will have the addon readdy pretty soon. When I fixed it this morning it wasn't working cause I made another mistake and set y0=yf in the clipping window, that's why I sometimes was seeing a column of dots.

I'll post when I've fixed that and documented it.

User avatar
Uto
Posts: 57
Joined: Tue May 30, 2017 9:33 am

Re: DAAD Adventure Writer and ZX Next

Post by Uto » Mon Sep 16, 2019 9:47 pm

I've attached a picture of how it looks. The image it's just one I had at hand, or maybe I had it far far away ;-)
Attachments
screnshot.png
screnshot.png (38.06 KiB) Viewed 997 times

User avatar
Uto
Posts: 57
Joined: Tue May 30, 2017 9:33 am

Re: DAAD Adventure Writer and ZX Next

Post by Uto » Mon Sep 16, 2019 10:11 pm

There is one thing I'm have yet to be done: handle transparency. At the moment, I've noticed my images sometimes get some pixels as transparent, cause it happens to be just the default magenta color that is used as transparent for Layer2. Of course, I could tell user not to use that color if they don't want to have problems, but the truth is many DAAD/PAW/QUILL authors don't have the skills to handle that easily. So a question does inmediatly pop up: is there a way, either by using some register or some other way to disable transparenccy in layer2?

Of course I will user with enough skill with graphics allow transparency, but I would like to disable it by default. Is there any way to handle that?

Well, of course I can just check wich colors are missing in a picture and set the transparency color to any of those missing, but that solution is not 100% valid cause an image may happen to be using 256 different colors.

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

Re: DAAD Adventure Writer and ZX Next

Post by Stefan123 » Mon Sep 16, 2019 10:33 pm

That looks great, Uto :)

I don't think there's a way to completely disable the transparency colour for layer 2, but I'm not sure. Allen would know more about this.

User avatar
Uto
Posts: 57
Joined: Tue May 30, 2017 9:33 am

Re: DAAD Adventure Writer and ZX Next

Post by Uto » Mon Sep 16, 2019 10:38 pm

Well, I always can make the converter check if there if the picture doesn't use all the colors, and then set the transparency register to a nob-used color. In case all the 256 colors are used, I can try to find which one is used less, replace it with a very similar color already in the palette, and then use the replaced one. That would be a lossy format though.

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

Re: DAAD Adventure Writer and ZX Next

Post by SevenFFF » Mon Sep 16, 2019 10:42 pm

The way I did it in my tools was just to replace 0xE3 with 0xE7 (which is what the ULA magenta gets redefined as). Then 0xE3 is always available for transparency. Crude but you really can’t tell 99.99% of the time.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

Alcoholics Anonymous
Posts: 517
Joined: Mon May 29, 2017 7:00 pm

Re: DAAD Adventure Writer and ZX Next

Post by Alcoholics Anonymous » Mon Sep 16, 2019 10:52 pm

You can't disable transparency but you can do something else. I see that there is nothing behind either layer 2 or the ula. So you could do something like make the transparent colour black and then make the fallback colour black as well. If nothing puts a pixel someplace (maybe all layers are clipped or are transparent) then the fallback colour is used.

** I haven't been using emulators for a couple of months so I am a bit behind but I can't say for certain if zesarux emulates the fallback colour. Maybe someone else knows or you could ask Cesar.

Ped7g
Posts: 112
Joined: Mon Jul 16, 2018 7:11 pm

Re: DAAD Adventure Writer and ZX Next

Post by Ped7g » Mon Sep 16, 2019 11:26 pm

ZEsarUX should emulate fallback correctly, CSpect will show weird artefacts in border (drawing violet bottom part from nowhere), but pixel area should be fine as long as you don't depend on default state (palettes, nextregs, all is wrong in CSpect in quick-boot mode).

Just yesterday I did add test for transparency + fallback (but with ULA screen only, but the L2 emulation in ZEsarUX should be fine).
source + screenshots from zesarux: https://github.com/MrKWatkins/ZXSpectru ... cyFallback
snapshot to try: https://github.com/MrKWatkins/ZXSpectru ... alBUla.sna

Hmm... I can respin this to add also L2 layer, and test black-to-black through all layer together, with Enhanced ULA off... but as new snapshot probably, the interactive tests kinda sux for quick run through all of them.

----

edit1: (generally the situation with emulator is, that the parts ZEsarUX emulates are usually quite precise, Cesar does put quite some effort into it, and I fixed few details for him few months back, although he doesn't like some of the board behaviour with NextRegs, so he intentionally keeps some bugs in those ... but it is completely ignoring multiple new features, so ZEsarUX is quite accurate compared to like core 2.0.10 or something like that, with few things from 2.0.28 ... the CSpect is exact opposite, it now covers almost every aspect of Next, but with many bugs everywhere.. some of them easily avoidable if you know about them, like not reading nextreg before writing into it, but even hard bugs like things are emulated just plain wrong... ... but if you are like new dev to Next, and you are just trying basics, both emus should work equally well)

-----

edit2: actually all the layer-mixing tests are testing also case "pixel transparent through all layers" with non-default fallback colour set to that $E3, and these have been fixed in both ZEsarUX and CSpin long time ago (I mean "all layers before tilemap was added" :D ... that kinda ruined those tests :D ).

@Uto: so... one option to get full 256 colours exists, if your two layers (L2 vs ULA) may be clipped in a way to not overlap (or if you can in code assure that there will be no ULA pixels under the L2 image). Like for example clip windows: [0,0]->[255,127] L2 image and [0,128]->[255,191] ULA text ... or just the L2 image clip window, and delete all pixels in ULA area under image.

Then you can set global transparency register $14 to your "paper" colour (I guess it's black only? i.e. $00), and transparency-fallback $4A to the same colour ($00 for black).

That way, when (I will use in this example $00 black) the $00 black is in the image, it will become transparent and ULA pixel is used, which will be either clipped or black too, which means "no pixel" situation and fallback colour will be drawn, which is also black, so from user point of view he will see black pixels in the image where there was black in original image = full 256 colour display.

(but in case you can't clip ULA layer, or you can't clear pixels underneath image, any text under black areas of image would become visible in the transparent holes)

Post Reply