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: 5017
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: 716
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
oziphantom
d'Arc/Topaz Beerline
JackAsser/Booze Design
Guests online: 67
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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