--- /dev/null
+; this map was generated by tmx2map.py
+
+.db 0x1, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1
+.db 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x2, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x2
+.db 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x2
+.db 0x0, 0x0, 0x0, 0x0
+
ld bc, MAP_TILES
call memset
- ; 1) setup seed
+ ; 1) setup seed,,,
; store exiting seed in tmp game seed
ld a, [srand]
ld [mapgen_game_seed], a
; hl: start position in tile map
mapgen_make_room:
; TODO: pick a room pattern
+ push hl
+
+ ld b, a
+ call rand
+ dec b
+ and a, b ; ensure we are in range
+ add a, a ; *2 for offset
+
+ ld h, 0
+ ld l, a
+ add hl, de
+ push hl
+ pop de ; de = correct room to draw
+
+ pop hl
+
; de = room pattern to draw
ld a, [de]
f1r1:
#include "f1r1.inc"
+f1r2:
+#include "f1r2.inc"
+
floor1_patterns:
dw f1r1
-dw f1r1
+dw f1r2
floor1_patterns_end:
or a, 1
ld [srand+1], a
+ ld a, [sram_mapgen_srand]
+ or a, 1
+ ld [mapgen_seed], a
+ ld a, [sram_mapgen_srand+1]
+ or a, 1
+ ld [mapgen_seed+1], a
+
call mbc1_ram_disable
ret
ld a, [srand+1]
ld [sram_srand+1], a
+ ; save mapgen seed in sram
+ ld a, [mapgen_seed]
+ ld [sram_mapgen_srand], a
+ ld a, [mapgen_seed+1]
+ ld [sram_mapgen_srand], a
+
call mbc1_ram_disable
ret
; a, hl, de
; returns:
; a: random value
+ ; uses:
+ ; hl, a
rand:
; load seed
ld a, [srand]