I'm not sure what you mean by "innate".olddb wrote:So I been reading some gb dev tutorials lately.
Are there innate subroutines (call - ret)?
Correct. Because the LR35902 is ultimately based on an ISA of a programmable terminal, there is no flag for bit 7 of the last result nor overflow of signed addition. But it has those conditions for all thre kinds of jump (16-bit jp, 8-bit relative jr, and call).olddb wrote:Are the only jp instructions on z,nz,c,nc?
No. You have to calculate each address yourself, and it takes 7 mcycles to calculate the address and perform the read or write. Assuming a pointer to the start of the struct is in DE:olddb wrote:Are there (hl) index instructions?
Code: Select all
ld hl,offsetof(type, field) add hl,de ld a,[hl]
To make this faster, you're expected to know in advance in what order the elements of each struct will be read or written and then order the elements that they are accessed in increasing order (for ld a,[hl+], decreasing order (for ld a,[hl-]), or with addresses separated by a power of 2 (for e.g. set 3,hl ld a,[hl]).
 The LR35902 is largely based on the Intel 8080, with some bit manipulation instructions borrowed from the Zilog Z80. The 8080 in turn a reorganization of the Intel 8008 for more general use, which began as an experimental single-chip implementation of the processor in the Datapoint 2200 terminal. But the ISA's focus on sequential access to homogeneous data, such as a terminal's tilemap, rather than random access to heterogeneous structures, such as actors in a game, is still evident.
You could easily index into it by loading the index value to L.
ld H, array high byte
ld L, index
ld A, [HL]
You would do this, for example, with the OAM shadow RAM (or buffer, if you prefer that term).
Code: Select all
LD HL, StructureBase LD A, ValueOffset ADD L LD L, A