Jump to content

Recommended Posts

This is a basic programing in Z80 question that I hope someone will answer by the time I return on the 15th.

All I really know about the IY and IX registers is that they take more cycles but them being index registers exactly why would I need to use them outside of an array or some similar deal.

 

Why even use them unless you run out of other registers...


I've seen them used for moving sprites, I've seen them in Joystick routines but I only see them being used just like every other register.

Do they hold some special power, can someone elaborate because on the flip side, I can look it up in a Z80 manual but then I have to decipher the jargon.


 

Edited by Mike Harris

Share this post


Link to post
Share on other sites

Their best use is for accessing complex structures.  For example:


 

; Define structure s
	.org 0
s_next:
	.ds 2
s_x:
	.ds 1
s_y:
	.ds 1


...

code:
	(set ix to the base of your structure)
linked_list_loop:
	ld	c, (ix+s_x)
	ld	d, (ix+s_y)
	jr	do_something_with_x_and_y  ; preserves ix
	ld	l, (ix+s_next)
	ld	h, (ix+s_next+1)
	push	hl
	pop	ix
	ld	a,h
	or	l
	jp	nz, linked_list_loop

You can also use them for indirect jump locations.

 

JP (IX)

JP (IY)

JP (HL)

 

Any of these will set PC to the value of IX, IY, or HL respectively.

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, I think I have it now or a basic understanding.
 

When I really take a close look it seems to just be a register that handles one extra step that I can already do with DE or HL.

I am really finding out that my only limitations on the Coleco are speed and the tools to create stuff.
 

It would be nice if we had a modern paint program that breaks your image into 8x8 tiles then converts it to assembly language.  I looked in MSX forums and around but nothing that will do the job.

 

The game was challenging but in it's final stretch but the title screen and maybe a tune???  Is the most time consuming.

 

Thanks brother....be back sometime next week

Edited by Mike Harris

Share this post


Link to post
Share on other sites

Well, technically, the 6502 does everything it needs with about 3 registers.  Yes, you CAN do that on the Z80 too, but it's often best to figure out all the tricks to minimize clock time and/or programming effort, as necessary.  So I would still encourage you to see how best to make use of the z80, rather than just go with what "can be done" with less.  If your application doesn't lend itself to using the index registers, then cool, don't bother.  But if it does, then don't be shy about using them.

 

As for breaking up tiles, I would have thought that Newcoleco would have such a program available.  It's certainly a common application of any TMS-based graphics platform.  Maybe check the TI computer forums too to see if any of them came up with something.

Share this post


Link to post
Share on other sites

I use IX and IY where the importance of readability is higher than raw speed.  As mentioned above it is a simple way to access structured data, and can is supported for 16-math operations i.e. ADC.

So keep IX and IY out of your NMI routine where every cycle is important, but use them elsewhere where you should have plenty of cycles available and it's more important to simplify your code so it is readable, easily understandable and thus easier to complete your actual code logic (and debug it).

Speed of a single instruction is not important, it is how a whole section of code runs and can be understood (so you can diagnose and fix bugs).

Try my Sprite and Tile Editor, the tile part still needs a bit more work but it can do most of what you want.

Share this post


Link to post
Share on other sites

Use Magellan from the Ti99 forum for tiles and sprites 

Use ix and iy to access to data structures. This is their main purpose and they lead to code both effective and readable when used for structures. 

If you are using sjasm as assembler you can also give names to each field. This leads to code easy to understand and modify. 

 

  • Like 1

Share this post


Link to post
Share on other sites
On 7/17/2019 at 6:09 AM, Tony Cruise said:

I use IX and IY where the importance of readability is higher than raw speed.  As mentioned above it is a simple way to access structured data, and can is supported for 16-math operations i.e. ADC.

So keep IX and IY out of your NMI routine where every cycle is important, but use them elsewhere where you should have plenty of cycles available and it's more important to simplify your code so it is readable, easily understandable and thus easier to complete your actual code logic (and debug it).

Speed of a single instruction is not important, it is how a whole section of code runs and can be understood (so you can diagnose and fix bugs).

Try my Sprite and Tile Editor, the tile part still needs a bit more work but it can do most of what you want.

I use your editor all the time and I like the 3 tab that you have a screen layout.

However, in my opinion, being able to draw within those squares then expand each square for finer details.

After that then send all the patterns to the pattern list so it can be output to ASM or C.

The way you have it now is too exhausting going back and forth between tabs, no docks for the colors.

I am in no way criticizing or ungrateful, I wish I had your abilities and I would make a version that fits my needs.
 

Share this post


Link to post
Share on other sites
13 hours ago, artrag said:

Use Magellan from the Ti99 forum for tiles and sprites 

Use ix and iy to access to data structures. This is their main purpose and they lead to code both effective and readable when used for structures. 

If you are using sjasm as assembler you can also give names to each field. This leads to code easy to understand and modify. 

 

Could you provide a link.

I have searched far and wide for this and others but it seems all the familiar spots have dead links or the tools just do not work including this website.

 

If you have a copy could you post it.

That's the thing about 30 year old system is that the modern tools of today are meant for modern programing.

Until I get something it's all by hand like tradition.

Edited by Mike Harris

Share this post


Link to post
Share on other sites
10 hours ago, Mike Harris said:

I use your editor all the time and I like the 3 tab that you have a screen layout.

However, in my opinion, being able to draw within those squares then expand each square for finer details.

After that then send all the patterns to the pattern list so it can be output to ASM or C.

The way you have it now is too exhausting going back and forth between tabs, no docks for the colors.

I am in no way criticizing or ungrateful, I wish I had your abilities and I would make a version that fits my needs.
 

Agreed, my tool is focused on editing at the tile level rather than the screen level.  You can paste in a set of tiles from an external program, but editing directly is something I need to add at some stage.

Just about finished my next episode which is on generating Sound and then I will probably do some more work on the tool.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...