| 1 |
;------------------------------------- |
| 2 |
; Example displayer using the ctm7 parser |
| 3 |
; |
| 4 |
; For simplicity it does not handle tiled maps, only those with |
| 5 |
; characters. |
| 6 |
; |
| 7 |
.include "ctm7.asm" |
| 8 |
MAPDATA = ctm7("map.ctm") ; load map file |
| 9 |
|
| 10 |
.with MAPDATA |
| 11 |
*= $2000 |
| 12 |
font .text CHARS.DATA |
| 13 |
|
| 14 |
*= $0c00 |
| 15 |
screen .text MAP.DATA[:2000:2] ; lower 8 bit index only |
| 16 |
|
| 17 |
*= $0801 |
| 18 |
.word 2023, + |
| 19 |
.null $9e, format("%4d", start) |
| 20 |
+ .word 0 |
| 21 |
|
| 22 |
.cerror FLAGS.TILES, "can't draw tiles" |
| 23 |
.cerror MAP.WIDTH != 40, "must be 40 chars wide" |
| 24 |
.cerror CHARS.COUNT > 256, "too many characters" |
| 25 |
|
| 26 |
char_colors .text COLORING.CHAR ? CHARS.COLORS : [] |
| 27 |
|
| 28 |
start lda #MODE.ECM ? $5B : $1B |
| 29 |
sta $d011 |
| 30 |
lda #MODE.MULTI ? $18 : $08 |
| 31 |
sta $d016 |
| 32 |
lda #((screen >> 6) & $f0) | ((font >> 10) & $f) |
| 33 |
sta $d018 |
| 34 |
lda #COLORS[0] |
| 35 |
sta $d021 |
| 36 |
.if !MODE.HIRES |
| 37 |
lda #COLORS[1] |
| 38 |
sta $d022 |
| 39 |
lda #COLORS[2] |
| 40 |
sta $d023 |
| 41 |
.endif |
| 42 |
.if MODE.ECM |
| 43 |
lda #COLORS[3] |
| 44 |
sta $d024 |
| 45 |
.endif |
| 46 |
|
| 47 |
.if COLORING.CHAR |
| 48 |
ldx #0 |
| 49 |
- .for i in range(4)*$100 |
| 50 |
ldy screen + i,x |
| 51 |
lda char_colors,y |
| 52 |
sta $d800 + i,x |
| 53 |
.next |
| 54 |
inx |
| 55 |
bne - |
| 56 |
.elsif COLORING.MAP |
| 57 |
ldx #0 |
| 58 |
lda #COLORS[4] |
| 59 |
- sta $d800 + range(4)*$100,x |
| 60 |
inx |
| 61 |
bne - |
| 62 |
.else |
| 63 |
.error "Per tile colouring needs to be written" |
| 64 |
.endif |
| 65 |
jmp * |
| 66 |
.endwith |