Mike Harris Posted July 8, 2019 Share Posted July 8, 2019 (edited) 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 July 8, 2019 by Mike Harris Quote Link to comment Share on other sites More sharing options...
ChildOfCv Posted July 8, 2019 Share Posted July 8, 2019 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. 1 Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted July 8, 2019 Author Share Posted July 8, 2019 (edited) 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 July 8, 2019 by Mike Harris Quote Link to comment Share on other sites More sharing options...
ChildOfCv Posted July 8, 2019 Share Posted July 8, 2019 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. Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted July 17, 2019 Share Posted July 17, 2019 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. Quote Link to comment Share on other sites More sharing options...
artrag Posted July 18, 2019 Share Posted July 18, 2019 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. 1 Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted July 18, 2019 Author Share Posted July 18, 2019 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. Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted July 18, 2019 Author Share Posted July 18, 2019 (edited) 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 July 18, 2019 by Mike Harris Quote Link to comment Share on other sites More sharing options...
artrag Posted July 18, 2019 Share Posted July 18, 2019 Magellan is on atariage in the Ti99 forum Sjasm is on github.com Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted July 18, 2019 Author Share Posted July 18, 2019 3 minutes ago, artrag said: Magellan is on atariage in the Ti99 forum Sjasm is on github.com I went to the TI99 Forum and the link is dead Quote Link to comment Share on other sites More sharing options...
artrag Posted July 18, 2019 Share Posted July 18, 2019 Ask there, the tool is being actively developed and expanded right now Quote Link to comment Share on other sites More sharing options...
Mike Harris Posted July 18, 2019 Author Share Posted July 18, 2019 (edited) Found 3.3 somewhere in the forum. Uses Java. Thanks Edited July 18, 2019 by Mike Harris Quote Link to comment Share on other sites More sharing options...
Tony Cruise Posted July 19, 2019 Share Posted July 19, 2019 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. Quote Link to comment Share on other sites More sharing options...
CrazyBoss Posted August 15, 2019 Share Posted August 15, 2019 I think the IX and IY is quite usefull. For working with tables etc. Also if you have an array, and need to set/read/reset values its easier, and maybe faster to use IX and IY, plus you dont need to mess up with other "normal" registers The JP (IX), JP (IX) and JP (HL) is also used in many games. But actually the mnemonic is wrong. (HL) is not the value of HL but the value of what HL points at. So it should be JP HL. LD HL,$1234 (HL) is not $1234 but the value of address $1234 So technically then mnemonics are wrong Quote Link to comment Share on other sites More sharing options...
opcode Posted November 19, 2019 Share Posted November 19, 2019 Perhaps the easiest way to understand IX IY is to think about objects and properties. Lets say you are making a game. Your game has enemy characters. Those enemies have common properties, like coordinates, sprite pattern, speed, direction, etc. So you can define your enemies as "objects" with "properties" in a particular order. That way you can create common routines that manipulates your enemies, independent of which particular enemy you are processing. For example, you can define coordinates as the first 4 bytes of an object memory area, followed by speed, etc. Using IX,IY you can set those to the starting memory area of a particular enemy and let your common routines deal with it. Better yet, you can keep adding enemies as you see fit, as long as you still have free memory, and everything will still work. Instantiating new enemies (objects) becomes easy that way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.