Author Topic: Putting a pointer to a constant in another constant  (Read 2248 times)

0 Members and 1 Guest are viewing this topic.

Offline Vijfhoek

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 120
  • Rating: +13/-1
    • View Profile
Putting a pointer to a constant in another constant
« on: March 02, 2013, 06:57:29 am »
I'm trying to make a map system for a platformer game, but I'm having some trouble with the header.
What I want to do is include pointers from the previous and next level to allow level switching. I have no idea how to do it though.
I've been experimenting around a bit, and currently I am doing this:

Code: [Select]
.HEADER
[000D0917]->GDB000
GDB000
GDB001
.MAPDATA
[0119000101010001]
.more map data

So I want the header to be 00 0D 09 17, then the pointer to the same GDB000 (because it's the first level), and a pointer to GDB001 (the next level).
When I try to print the header with the following code:

Code: [Select]
{S}->A
S++
{S}->B
S++
{S}->C
S++
{S}->D
S++
{S}^^r->E
S+2->S
{S}^^r->F
S+2->S

Output(0,0,"StartX")
Output(9,0,A>Dec)
Output(0,1,"StartY")
Output(9,1,B>Dec)
Output(0,2,"EndX")
Output(9,2,C>Dec)
Output(0,3,"EndY")
Output(9,3,D>Dec)
Output(0,4,"StartPtr")
Output(10,4,E>Hex)
Output(0,5,"EndPtr")
Output(10,5,F>Hex)

it outputs this:
Code: [Select]
StartX       0
StartY      13
EndX         9
EndY        23
StartPtr  1901
EndPtr    0100

Can somebody help me getting this to work?
« Last Edit: March 02, 2013, 06:57:50 am by Vijfhoek »

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Putting a pointer to a constant in another constant
« Reply #1 on: March 02, 2013, 11:56:50 am »
Just having GDB000 and GDB001 sitting like that isn't including them as data. They get included as code just like any other code sitting on a line outside of any special directives. To include pointers as data, use the Data() directive (token: ∆List()), like this. The superscript r's mark that the values are 2-byte values:

Code: [Select]
.HEADER
[000D0917]->GDB000
Data(GDB000ʳ,GDB001ʳ)
.MAPDATA
[0119000101010001]
.more map data

Assuming all headers are 4 bytes and you had a pointer to a map header in S, you could then read the pointer to the previous map header with {S+4}r and read the pointer to the next map header with {S+6}r.
« Last Edit: March 02, 2013, 11:57:56 am by Runer112 »

Offline Vijfhoek

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 120
  • Rating: +13/-1
    • View Profile
Re: Putting a pointer to a constant in another constant
« Reply #2 on: March 04, 2013, 06:13:00 pm »
Sorry for the late reaction, forgot to reply. I'm way too forgetful about that kind of things.
Anyway, thanks, that did the job.