File Loading Question Using Z88DK

If you like transforming your statements into code, this is the place for you

Moderator: Programming Moderators

User avatar
varmfskii
Posts: 186
Joined: Fri Jun 23, 2017 1:13 pm
Location: Albuquerque, NM USA

Re: File Loading Question Using Z88DK

Post by varmfskii » Fri May 04, 2018 11:26 pm

My implementations of drawing routines check for horizontal and vertical lines. Given that the maximum length of a line is 256 pixels, I am not sure if it is worthwhile to use dma for line drawing in any but the very longest cases. Checking and setting things up may make your average performance worse.
Backer #2741 - TS2068, Byte, ZX Evolution

Bagpuss
Posts: 27
Joined: Tue Jun 06, 2017 9:13 pm

Re: File Loading Question Using Z88DK

Post by Bagpuss » Sat May 05, 2018 9:49 am

Cool, didn't notice to optimisation on first read (I'm spending much of my time getting to grips with z88dk at the moment :) ).
I was thinking the same in regards to DMA when I was doing my first stint into assembler, I used dma for clearing layer 2 and block fills that did the while width of a line for several lines but that is about it so far

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

Re: File Loading Question Using Z88DK

Post by Stefan123 » Sat May 05, 2018 10:32 am

Good tip about having a special case for drawing vertical/horizontal lines. I will use that :)

Bagpuss
Posts: 27
Joined: Tue Jun 06, 2017 9:13 pm

Re: File Loading Question Using Z88DK

Post by Bagpuss » Sun May 06, 2018 11:54 am

Cool. If found it quite useful for as I was having problems with the start and end pixels as first with the usual algorithim, plus with filled triangles, its all horizontal lines for the actual fill :)

I'll paste in my z80 code if it helps (its a bit rough mind as its been nearly 30 years since I did z80 in anger :) ) but gawd knows how to convert it to a z88dk library (making very rapid progress on the language set but still got a lot to learn).

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

Re: File Loading Question Using Z88DK

Post by Alcoholics Anonymous » Sun May 06, 2018 6:11 pm

Bagpuss wrote:
Sun May 06, 2018 11:54 am
I'll paste in my z80 code if it helps (its a bit rough mind as its been nearly 30 years since I did z80 in anger :) ) but gawd knows how to convert it to a z88dk library (making very rapid progress on the language set but still got a lot to learn).
If it's not too big, I can show you how to build a library out of it. With an assembly routine, you'd want to keep the asm entry point available for calling from assembly language and then on top of that you'd want to add c entry points that gather parameters before jumping into the asm implementation. The c entry points should be as efficient as possible so likely using fastcall or callee linkage. So we usually write the asm first for assembly language with a few conventions suitable for c :- functions with one param should pass in a subset of DEHL and functions should return in a subset of DEHL.

Distributing code as libraries is just not done in the spectrum community because the tooling is really basic so if it's done at all, it's usually done as a monolithic blob. Libraries, however, allow the linker to pick out exactly what the user is using to minimize program size. And, it's possible to control what memory banks this code is placed into without changing the source code or even having the source code.

Bagpuss
Posts: 27
Joined: Tue Jun 06, 2017 9:13 pm

Re: File Loading Question Using Z88DK

Post by Bagpuss » Sun May 06, 2018 9:27 pm

Cool. I want to get the current bits I'm working on running first then I'll ask for some advice for libraries after that. I've written a few dma based routines for equivalent of clear screen and the like.

I think my next objective though it to start understanding banking for code so I can do some arrangement of routines. Not quite sure if I;m getting a little close to memory limits at the moment with what I have as I have been trying to use tables etc for optimisation of calculations.

Post Reply