Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
I FINALLY (I've been meaning to for years) Got around to making Alvin Albrecht's Fill routine work in ZX BASIC, I think.
<!-- m --><a class="postlink" href="http://dl.dropbox.com/u/4903664/SPFill.zip">http://dl.dropbox.com/u/4903664/SPFill.zip</a><!-- m -->
Compile SPPFill.bas and it pulls in all the other bits, which I've hacked to ignore timex modes.
Boriel - I think this, with a bit of clean up, should possibly go into the compiler as available.
Thanks, Na_th_an for reminding me of SPLIB2, which made me see this again, and go "Right, I'm gonna do this this time..."
Posts: 73
Threads: 9
Joined: May 2010
Reputation:
0
Now THIS is what I was looking for! Thanks, man, now it's time to port SUVLEIR to pure, native ZX Basic, and I'm giving you tons of credits for it! (I was using SUVLEIR in a ZXBasic project, but I *had* to use that ugly, external binary compiled with z88dk from my BASIC code using ugly POKEs and CALLs...)
Posts: 73
Threads: 9
Joined: May 2010
Reputation:
0
I'm having problems. A call to the routine seems to mess up something (maybe some register should be preserved?). My routine is simple, quoting the interesting bit:
Code: While (endOfDrawing > binAddress)
cmd = Peek (binAddress)
binAddress = binAddress + 1
If cmd < 192 Then
x = Peek (binAddress)
binAddress = binAddress + 1
y = 191 - cmd
dx = x: dx = dx - cx ' ZX Basic doesn't like type mix
dy = y: dy = dy - cy ' ZX Basic doesn't like type mix
Draw dx, dy
cx = x
cy = y
ElseIf cmd = 192 Then
x = Peek (binAddress)
y = 191 - Peek (binAddress + 1)
binAddress = binAddress + 2
Plot x, y
cx = x
cy = y
ElseIf cmd = 193 Then
x = Peek (binAddress)
y = Peek (binAddress + 1)
ex = Peek (binAddress + 2)
binAddress = binAddress + 3
SPPFill (x, y, @gpPatterns + (ex << 3))
End If
Wend
Notice the call to SPPFill towards the end of the code. If I comment that line, the vector drawing renders OK (albeit, without fills), but if I leave it uncommented, it somehow messes something so binAddress goes elsewhere and it draws random lines until the program crashes.
I've found that somehow ZX Basic doens't like IX messed with, so if I do:
Code: Asm
push ix
End Asm
SPPFill (x, y, @gpPatterns + (ex << 3))
Asm
pop ix
End Asm
It just works! Not a big deal, but I just wanted you to know.
I might have something to publish very soon
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
Ah yes. ZX Basic points IX into the stack, and uses it as a stack reference (variable x is IX+a etc). Since SPPFill uses that I should push and pop it in there, I think. I'll experiment when I have a little time.
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
na_th_an Wrote:I've found that somehow ZX Basic doens't like IX messed with, so if I do:
Code: Asm
push ix
End Asm
SPPFill (x, y, @gpPatterns + (ex << 3))
Asm
pop ix
End Asm
It just works! Not a big deal, but I just wanted you to know.
I might have something to publish very soon ![Smile Smile](https://www.boriel.com/forum/images/smilies/smile.png) That's it. ZX Basic requires IX register to be preserved before exiting/entering BASIC functions. It's used to manage the stack frame: the parameters, for example, are loaded using (IX+n), etc.
Posts: 73
Threads: 9
Joined: May 2010
Reputation:
0
Good to know ![Smile Smile](https://www.boriel.com/forum/images/smilies/smile.png) I found about it using a debugger (I found ld sp, ix just after returning from a Sub).
Posts: 73
Threads: 9
Joined: May 2010
Reputation:
0
I've updated my vector drawing/displaying package. Release here: <!-- m --><a class="postlink" href="http://www.mojontwins.com/mojoniaplus/viewtopic.php?f=12&t=891">http://www.mojontwins.com/mojoniaplus/v ... f=12&t=891</a><!-- m -->
Short tutorial (albeit in spanish) here: <!-- m --><a class="postlink" href="http://tcyr.wordpress.com/2012/03/07/suvleir-3-0-super-ultra-vector-library-experience-inspire-redux-3-0/">http://tcyr.wordpress.com/2012/03/07/su ... redux-3-0/</a><!-- m -->
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
Posts: 73
Threads: 9
Joined: May 2010
Reputation:
0
Only possible thanks to your work
Posts: 282
Threads: 48
Joined: Feb 2011
Reputation:
0
good idea to draw background screens that way
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
![Confused Confused](https://www.boriel.com/forum/images/smilies/confused.png) hock: I'm still *shocked* (just arrived from work, a hard day...)
This library *should* go integrated with the compiler. May I :?:
BTW as stated before, I've started 2.x branch. This would need extensive compile testing... (if someone dares).
The 2.x branch aims to be a new different and extensively rewritten compiler (it might even transform your spectrum into a Commodore VIC-20 :?: :? ![Smile Smile](https://www.boriel.com/forum/images/smilies/smile.png) . So ...
Posts: 73
Threads: 9
Joined: May 2010
Reputation:
0
As always, feel free to use whatever I produce in the compiler library
If you like, I can try the new compiler branch. I'm developing a series of tutorials and I can try to compile everything with the new version and report how it goes.
Posts: 282
Threads: 48
Joined: Feb 2011
Reputation:
0
Nathan I like your avatar at ojodepez-fanzine.net/
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
britlion Wrote:Boriel - I think this, with a bit of clean up, should possibly go into the compiler as available.
Thanks, Na_th_an for reminding me of SPLIB2, which made me see this again, and go "Right, I'm gonna do this this time..." Thanks, for this!
I'm about to do so, however, notice there are ASM routines called inc and dec screen position. Very (almost identical) routines are already packeted with the optimized DRAW routine (It's really very optimized!). I think it would be a good idea to replace SPPixelUP: body with a simple call to INCY / DECY routines, or vice versa, replace DRAW INC/DEC y routines with these ones.
They are almost identical, except some flag check.
Since DRAW is alwaws packed with ZX BASIC I guess it would be rather easy to replace them so no duplicated code is included and so, some precious bytes saved!
Posts: 805
Threads: 135
Joined: Apr 2009
Reputation:
5
You could also add extra labels to the inbuilt functions, so they are collected with SPPixelUp and down? This way at least the labelling is consistent with the whole SPLIB2 system, should it be implemented in full.
(in short, replace two of Albrecht's routines with the inbuilt ones, but be able to jump to them using the same naming convention as he has in everything else)
There may be more of his routines that can be replaced, of course.
Edit: Oh, there is a difference: exit : Carry = moved off screen
So we'd need to replace the routine with
SPPixelUp:
call INCY
CP $40
ret
This would be shorter, it's true; though it buries an extra call and some flagging in it.
|