specific address code

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

specific address code

Post by goyo »

HI,
I would like to make a game in 100% asm with XA assembler and I have a map level that i want to be in a specific address of memory

when I use the expression * = $A516 It doesn’t seem to work, I don't see the 1 value at this addess after the program execution

Code: Select all

; map of the level 1 : 64*27 tiles - #40 x #1b
* = $A516 
_level_1
.byt 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,
.byt 2, 2, 2, 1, 2, 1, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ,
......

Code: Select all

PRINT PEEK(#A516) 
I have 85 , but not 1 ?
User avatar
Dbug
Site Admin
Posts: 5263
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: specific address code

Post by Dbug »

It's not how that works :)

Basically when you do * = you tell XA that the internal program counter is supposed to be at this location, but that does not change the flow of the data, so if you have the program assembled at $500 and you put * = $600, the code will still be at $500 but any label inside will behave like if it was at $600 instead, and for this code to work it would have to be copied into memory from $500 to $600.

The main reason is that to make it work the way you want it would have to insert a bazilion of empty space.

So instead you could do something like

.dsb $A516-*

which will insert a bunch of zeroes, enough to fill between * (current position) and $a516.
User avatar
Chema
Game master
Posts: 3229
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: specific address code

Post by Chema »

Indeed, or assemble your map separately and load it to the desired address directly.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

Re: specific address code

Post by goyo »

Dbug wrote: Mon Oct 13, 2025 8:46 pm It's not how that works :)

Basically when you do * = you tell XA that the internal program counter is supposed to be at this location, but that does not change the flow of the data, so if you have the program assembled at $500 and you put * = $600, the code will still be at $500 but any label inside will behave like if it was at $600 instead, and for this code to work it would have to be copied into memory from $500 to $600.

The main reason is that to make it work the way you want it would have to insert a bazilion of empty space.

So instead you could do something like

.dsb $A516-*

which will insert a bunch of zeroes, enough to fill between * (current position) and $a516.
thank you Dbug but so far it's doesn't seem to work ..? ( It's not in my main .s file but in another .s file )
Last edited by goyo on Thu Oct 16, 2025 8:59 pm, edited 2 times in total.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

Re: specific address code

Post by goyo »

Chema wrote: Tue Oct 14, 2025 12:28 am Indeed, or assemble your map separately and load it to the desired address directly.
thank you Chema but how do you do this.
with witch directive do you load the map file at a specific address ?
User avatar
Dbug
Site Admin
Posts: 5263
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: specific address code

Post by Dbug »

goyo wrote: Thu Oct 16, 2025 8:58 pm
Chema wrote: Tue Oct 14, 2025 12:28 am Indeed, or assemble your map separately and load it to the desired address directly.
thank you Chema but how do you do this.
with witch directive do you load the map file at a specific address ?
There are no directive, you basically need to load the file at runtime, like on a tape you would CLOAD the map saved to load at whatever address you want, or on disk the same with a SEDORIC LOAD or Floppy Builder equivalent.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

Re: specific address code

Post by goyo »

Dbug wrote: Thu Oct 16, 2025 9:00 pm
goyo wrote: Thu Oct 16, 2025 8:58 pm
Chema wrote: Tue Oct 14, 2025 12:28 am Indeed, or assemble your map separately and load it to the desired address directly.
thank you Chema but how do you do this.
with witch directive do you load the map file at a specific address ?
There are no directive, you basically need to load the file at runtime, like on a tape you would CLOAD the map saved to load at whatever address you want, or on disk the same with a SEDORIC LOAD or Floppy Builder equivalent.
thank Debug, so if a want to join this file automaticly in ma osdk project
so can i use : #include "map.s" at the head of my main.s ? (OSDKADDR=$600)
there is somewhere a complete asm game in github to see how it's made ? :roll:
Last edited by goyo on Thu Oct 16, 2025 9:13 pm, edited 2 times in total.
User avatar
Chema
Game master
Posts: 3229
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: specific address code

Post by Chema »

It's been a while, but you put the *=xxxx statement at the beginning of the data file, assemble it with xa and generate a TAP file with the header utility (where you specify loading address and not auto-run).

A basic loader can load the data, then the main program.

You can automate everything in your osdk_build.bat file (bas2tap for the loader, xa+header for the data, whatever you need for the main program, then concatenate all the files in one single TAP file).

Dbug surely can help ot with the details.
User avatar
Dbug
Site Admin
Posts: 5263
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: specific address code

Post by Dbug »

Here is what you get by just changing the PC value:
image_2025-10-16_222116333.png
Here is what you get when you add spaces to reach the value:
image_2025-10-16_222156228.png
You do not have the required permissions to view the files attached to this post.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

Re: specific address code

Post by goyo »

Chema wrote: Thu Oct 16, 2025 9:11 pm It's been a while, but you put the *=xxxx statement at the beginning of the data file, assemble it with xa and generate a TAP file with the header utility (where you specify loading address and not auto-run).

A basic loader can load the data, then the main program.

You can automate everything in your osdk_build.bat file (bas2tap for the loader, xa+header for the data, whatever you need for the main program, then concatenate all the files in one single TAP file).

Dbug surely can help ot with the details.
Thank you very much, Chema. It’s a bit advanced for me, but I’ll take a look at it.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

Re: specific address code

Post by goyo »

Dbug wrote: Thu Oct 16, 2025 9:22 pm Here is what you get by just changing the PC value:

image_2025-10-16_222116333.png

Here is what you get when you add spaces to reach the value:

image_2025-10-16_222156228.png
Thank you very much Dbug. It works well with the .dsb $xxxx-* from your second screen.
User avatar
goyo
Pilot Officer
Posts: 76
Joined: Sat Jan 12, 2019 10:16 am
Location: Chatenay-Malabry

Re: specific address code

Post by goyo »

now, i could improve the speed of my game with a lookup table to display the tile's map.
as you see in this vidéo, tiles displaying is to slow.
https://youtu.be/2ahZHg8fsiU?si=YkiQgjDNXTsjHHmN
User avatar
Dbug
Site Admin
Posts: 5263
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: specific address code

Post by Dbug »

If you have the source code somewhere and can point out to the routine doing the display, we can take a look :)
Post Reply