Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Linked list
2009-06-17 15:30
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Linked list

Hello all,

Can someone tell me how to implement a dynamic linked list in assembler, or perhaps give me a link to where I can find something on this?!

This is to be used in a isometric engine(to store objects in a room), If there is another (better) structure than a linked list to use in 6502 assembly please tell me.

Ta.
2009-06-17 15:58
Radiant

Registered: Sep 2004
Posts: 639
I'd go for an array list (sort of, in any case!).

Quick and contrived examples for 8 objects with x and y positions:

    ; Access the x position of the first object in the list
    ldx object_list
    lda object_x, x

    ; Access the y position of all objects in the list,
    ; first to last
    ldy #$00
    @loop:
        ldx object_list,y
        lda object_y,x
        
        iny
        cpy #$08
    bne @loop





object_list:
    .byte $00   ; Object ID's, so objects can be sorted
    .byte $01   ; freely etc.
    .byte $02
    .byte $03
    .byte $04
    .byte $05
    .byte $06
    .byte $07

object_x:
    .byte $20   ; x positions for objects, ordered by
    .byte $30   ; object ID
    .byte $40
    .byte $50
    .byte $60
    .byte $70
    .byte $80
    .byte $90

object_y:
    .byte $10   ; y positions ordered by object ID
    .byte $20
    .byte $30
    .byte $40
    .byte $50
    .byte $60
    .byte $70
    .byte $80
2009-06-18 04:49
Oswald

Registered: Apr 2002
Posts: 5094
in general you DONT want to do linked list in assembly. Modern languages hide a lot of work wich are a lot of trouble & slow to do on a 6510. (you'll need a mechanism to find empty memory chunks, a mechanism which bookkeeps free/used memory, a mechanism to defrag memory & reorder used places, etc)

radiantx's suggestion is the way to go.
2009-06-18 08:51
HCL

Registered: Feb 2003
Posts: 728
Agree. In demo-coding you'll probably avoid using linked lists at all, but for tools etc it might come handy. Then Radiantx's example is useful.

I implemented a similar looking binary-tree 100 years ago to use in a Huffman-encoder. Runs with ok performance thanx to the linearized implementation. D0de, maybe i should post that encoder some day.. i used it in several demos already, perhaps someone else would also use it :P. [Edit] The decoder has been used in demos, not the encoder of course. [/Edit]
2009-06-18 10:21
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Thank you guys, it seems quite simple that array list thingy(ta radiantx) :) HCL post that on codebase soon (before you forget).
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Hexhog
Mike
ΛΛdZ
MWR/Visdom
Mihai
Mibri/ATL^MSL^PRX
t0m3000/hf^boom!^ibx
Jammer
Scrap/Genesis Project
iAN CooG/HVSC
Guests online: 108
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.065 sec.