News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_roudoudou

Rasm Z80 assembler

Started by roudoudou, 08:58, 22 February 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fessor

#400
IMHO, structs are meant to save you the work of calculating the index numbers and so that you don't always have to remember these index numbers when you want to work with LD (IX+num)/(IY+num).

struct spritedef
    ptrGFXdata defw
    coordx     defb
    coordy     defb
endstruct

struct spritedef Sprite1

     org 0x4000
     ld ix,Sprite1
     ld a,(ix+spritedef.coordx)
     ld b,(ix+spritedef.coordy)
     ...
     ...
     ret

Sprite1
    defw 0xc000
    defb 20
    defb 10
(If I understood the documentary correctly)

With LD a,(ix+spritedef.coordx) you know immediately where you stand instead of ld a,(ix+3).

roudoudou

#401
Quote from: HAL6128 on 15:40, 25 June 24Ok, thanks. I need the offset structure. The naming as object is just a (misleading) coincidence.

 So, object.item3 point to memory position (in this case defb = 1 Byte + defw = 2 Bytes  = #00 + 3)?


Out of curiosity: what is the difference between structure and object declaration you mentioned?
an object is located in memory so calling him will return his absolute address

a structure is only a definition of offset

in fact the structure definition is a hack, it's kindah like

nocode
org 0
random_structname
.offset1 defb 0
.offset2 defb 0
.offset3 defb 0
code

then random_structname.offset3 will be equal to 2
My pronouns are RASM and ACE

Powered by SMFPacks Menu Editor Mod