News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_ervin

page-aligned lookup table

Started by ervin, 14:42, 20 April 10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ervin

Hi all.

I'm gonna try something a bit nutty for my 3d-maze game, but I need to know how to define a page-aligned lookup table.

Is it as simple as:

.lookup EQU &4000
defb 0,0,0,0,0,0
defb 0,0,0,0,0,0

etc?

I've been googling for z80 "page align" and all sorts of other related stuff, but a definitive answer has been hard to come by.

Thanks for any help.

arnoldemu

Quote from: ervin on 14:42, 20 April 10
Hi all.

I'm gonna try something a bit nutty for my 3d-maze game, but I need to know how to define a page-aligned lookup table.

Is it as simple as:

.lookup EQU &4000
defb 0,0,0,0,0,0
defb 0,0,0,0,0,0

etc?

I've been googling for z80 "page align" and all sorts of other related stuff, but a definitive answer has been hard to come by.

Thanks for any help.
It really depends on the assembler.

Some may allow you to change org.


org &4000
.lookup ....

and some will not.

An alternative (if you are generating table) is to use an equ like you have, and then either copy the data to that address using LDIR, or generate it to that address.

e.g.


scr_table equ &100

ld ix,scr_table
ld b,200
st1:
ld (ix+0),l
ld (ix+1),h
inc ix
inc ix
call scr_next_line
djnz st1


then in code:


ld h,scr_table/256
ld l,a
add hl,hl

etc...

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

ervin

Awesome! Thanks for your (as usual) brilliant help!

Executioner

Most assemblers will allow you to determine the current assembly address. From this you can then either use a ds or org instruction. eg.

.temp equ $ and #ff
ds 256 - temp


or

.temp equ $ and #ff
org $ + 256 - temp


WinAPE has an instruction dedicated to aligning code to a specific boundary, to page-align, simply use:

align 256

You can also align to 32 bytes for example. This can be handy if your table is less than 32 bytes so you know you can use INC L rather than INC HL for example.

ervin

Ah, I see. Thanks for the tips!

Powered by SMFPacks Menu Editor Mod