68k asm tilemap data to Z80

Post programming questions related to the CPC Here!
Post Reply
Kitsune Mifune
Posts: 31
Joined: Tue Oct 22, 2019 6:46 am
Location: Glasgow
Contact:

68k asm tilemap data to Z80

Post by Kitsune Mifune » Thu Oct 24, 2019 3:58 pm

Don't want to spam the forum with a wave of questions every day, but I'm about to tackle what I've been putting off for ages and that is getting some sort of background onto my game in the form of tiles and tilemaps.

I'm just starting with a one screen area, and I'll figure out scrolling and hidden off screen draw buffers later (no idea what to do for any of that though) :? .

Codetapper from the EAB forum very kindly sent me a program he had written which takes a whole image and chops it into tiles, removes the duplicates, and then exports a tileset (PNG and RAW) plus an .asm map (as well as a few other things I don't quite understand). Very handy for building levels in a paint program then just exporting the image as a PNG, and then toss them into the chopper.

The only thing is that it exports the .asm data map in 68k. Now, I don't think it's too much of a problem as I assume it'll just be fine with changing the directives from 68k "dc.w" to Z80 "dw" and just put the data after it.

Of course I could be horribly wrong, so I've done a sample of what the chopper exports, and any advice on how to convert it to an Amstrad friendly format, or a link to a handy 68k to Z80 converter would be lovely! :)

Code: Select all

; Map Level 1
;------------
_Level_1Map
		dc.l	"FORM"
		dc.l	$2e+(16*12*2)
		dc.l	"PCLV"
		dc.l	"LDAT"
		dc.l	$1a
		dc.b	2			;Map memory type = WORD
		dc.b	1			;Layers
		dc.b	16			;Block width (pixels)
		dc.b	16			;Block height (pixels)
		dc.l	16			;Map width (blocks)
		dc.l	12			;Map height (blocks)
		dc.b	0			;Transparent block = 0
		dc.b	0			;Map compression = None
		dc.l	0			;Reserved
		dc.l	0			;Reserved
		dc.l	0			;Reserved
		dc.l	"BODY"
		dc.l	(16*12*2)

		dc.w	$0,$1,$2,$3,$4,$5,$6,$7
		dc.w	$8,$9,$A,$B,$C,$C,$C,$C

		dc.w	$0,$1,$D,$E,$F,$10,$11,$7
		dc.w	$8,$9,$A,$B,$C,$C,$C,$C

		dc.w	$0,$12,$13,$14,$15,$16,$17,$7
		dc.w	$8,$9,$A,$B,$C,$18,$19,$C

		dc.w	$1A,$1B,$1C,$1D,$15,$16,$1E,$7
		dc.w	$8,$9,$1F,$20,$C,$21,$22,$C

		dc.w	$23,$24,$25,$1D,$26,$16,$27,$28
		dc.w	$8,$9,$29,$2A,$C,$2B,$2C,$C

		dc.w	$2D,$2E,$25,$1D,$26,$2F,$30,$28
		dc.w	$8,$31,$32,$32,$C,$C,$C,$C

		dc.w	$33,$34,$35,$32,$36,$36,$36,$36
		dc.w	$36,$36,$36,$36,$C,$C,$C,$C

		dc.w	$37,$38,$39,$3A,$3B,$3C,$3D,$36
		dc.w	$36,$36,$36,$36,$C,$C,$C,$C

		dc.w	$3E,$3F,$40,$41,$3E,$3F,$40,$41
		dc.w	$3E,$3F,$40,$41,$3E,$3F,$40,$41

		dc.w	$42,$43,$44,$45,$42,$43,$44,$45
		dc.w	$42,$43,$44,$45,$46,$47,$44,$45

		dc.w	$48,$49,$4A,$4B,$48,$49,$4A,$4B
		dc.w	$48,$49,$4A,$4B,$4C,$4D,$4A,$4B

		dc.w	$4E,$4F,$4F,$50,$4E,$4F,$4F,$50
		dc.w	$4E,$4F,$4F,$50,$4E,$51,$4F,$50
PRE:
POST:
0=FFFFFF
1=FF8000
2=808080
3=FFFF00
4=770000
5=000000
6=00007D
7=7B7BFF
8=007D7D
9=80FFFF
10=8080FF
11=007F7F
12=101010
13=00319C
14=00007F
15=7BFFFF
16=F87D00
17=790000
18=F8F800
19=F8F8F8
20=FF00FF

Programming: 90% failures, 10% victories, and 100% hair loss!

User avatar
akuyou
Posts: 455
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: 68k asm tilemap data to Z80

Post by akuyou » Fri Oct 25, 2019 3:45 am

you are correct DC.B converts to DB and DC.W coverts to DW - you'll probably need to replace $ with & for HEX notation

DC.L is a 32 bit long... I don't think Winape or VasmZ80 have any such statement, so you'd have to split up the definition as below

Code: Select all

	db &12		;Dc.b $12
	dw &1234	;Dc.w $1234
	dw &5678,&1234  ;Dc.l $12345678
Beware though... Z80 is Little Endian... &1234 is stored in RAM in the order &34 &12.... 68000 is Big Endian... it stores as $12 $34
This may make a difference if you're loading a 32 bit long in one byte at a time.

Good Luck!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Kitsune Mifune
Posts: 31
Joined: Tue Oct 22, 2019 6:46 am
Location: Glasgow
Contact:

Re: 68k asm tilemap data to Z80

Post by Kitsune Mifune » Fri Oct 25, 2019 7:19 am

Brilliant! Cheers Keith.

It's so great having a teacher on hand to clarify these things.
Programming: 90% failures, 10% victories, and 100% hair loss!

User avatar
akuyou
Posts: 455
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: 68k asm tilemap data to Z80

Post by akuyou » Sun Oct 27, 2019 8:34 am

Kitsune Mifune wrote: Fri Oct 25, 2019 7:19 am Brilliant! Cheers Keith.
It's so great having a teacher on hand to clarify these things.
Just remember I'm no genius programmer ;) ... I'll try to give the best advice I can, but I may get things wrong, so in the end go with what seems right to you.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

User avatar
Gee-k
Posts: 28
Joined: Sat May 04, 2019 9:35 am
Location: Scotland
Contact:

Re: 68k asm tilemap data to Z80

Post by Gee-k » Mon Jan 04, 2021 6:15 pm

Not a genus programmer yet able to learn ASM for so many cpu's.
:ThumbsUp
Keep up the good work. Your help is amazing. if it wasn't for your videos and forum, i'd never have gotten started in learning z80 asm.
You don't fail, You learn how it's not done.
https://www.gee-k.net : Where I blog about my random geeky goings on.

Post Reply

Return to “Amstrad CPC Assembly Programming”