1
- var root = '../'
1
+ var Config = {
2
+ default : {
3
+ version : 'pokecrystal' ,
4
+ time : 'day' ,
5
+ default_map : 'OlivineCity' ,
6
+ paths : {
7
+ map_data : 'maps' ,
8
+ sprites : {
9
+ npc : 'gfx/overworld' ,
10
+ } ,
11
+
12
+ map_header : 'maps/map_headers.asm' ,
13
+ map_header_2 : 'maps/second_map_headers.asm' ,
14
+ map_constants : 'constants/map_constants.asm' ,
15
+ map_dimensions : 'constants/map_constants.asm' ,
16
+ map_includes : 'maps.asm' ,
17
+ } ,
18
+
19
+ tilesets : {
20
+ roof_start : 0xa ,
21
+ } ,
22
+
23
+ misc : {
24
+ max_blocks : 1300 ,
25
+ } ,
26
+ } ,
27
+ }
28
+
29
+
30
+ // TODO basically everything below this point needs to go into Config.default or pokecrystal.js
31
+
2
32
3
33
var config = {
4
- root : root ,
34
+ root_path : '../' ,
5
35
6
36
time : 'day' ,
7
- default_map : 'OlivineCity' ,
37
+ default_map : undefined ,
8
38
9
- asm_dir : root + 'maps/' ,
10
- ow_dir : root + 'gfx/overworld/' ,
39
+ get asm_dir ( ) { return this . root_path + 'maps/' } ,
40
+ get ow_dir ( ) { return this . root_path + 'gfx/overworld/' } ,
11
41
12
- map_header_path : root + 'maps/map_headers.asm' ,
13
- map_header_2_path : root + 'maps/second_map_headers.asm' ,
14
- map_constants_path : root + 'constants/map_constants.asm' ,
15
- map_dimensions_path : root + 'constants/map_constants.asm' ,
42
+ get map_header_path ( ) { return this . root_path + 'maps/map_headers.asm' } ,
43
+ get map_header_2_path ( ) { return this . root_path + 'maps/second_map_headers.asm' } ,
44
+ get map_constants_path ( ) { return this . root_path + 'constants/map_constants.asm' } ,
45
+ get map_dimensions_path ( ) { return this . root_path + 'constants/map_constants.asm' } ,
46
+ get map_dimensions_path_prism ( ) { return this . root_path + 'constants/map_dimension_constants.asm' } ,
16
47
17
48
roofs : [ - 1 , 3 , 2 , - 1 , 1 , 2 , - 1 , - 1 , 2 , 2 , 1 , 4 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , - 1 , 0 , - 1 , - 1 , 3 , - 1 , 0 , - 1 , 0 ] ,
18
49
//roof_permissions: [ 1, 'TOWN', 2, 'ROUTE', 4, 'CAVE' ], // wrong, see roof_tilesets
19
50
roof_tilesets : [
20
51
1 , 'TILESET_JOHTO_1' ,
21
52
2 , 'TILESET_JOHTO_2' ,
22
53
4 , 'TILESET_BATTLE_TOWER_OUTSIDE' ,
54
+
55
+ // prism
56
+ 'TILESET_NALJO_1' ,
57
+ 'TILESET_NALJO_2' ,
23
58
] ,
24
59
roof_start : 0xa ,
25
60
26
61
max_blocks : 1300 ,
27
62
63
+ read : function ( path ) {
64
+ return File . readAsync ( path )
65
+ } ,
28
66
getTilesetConstants : function ( ) {
29
- return request ( root + 'constants/tilemap_constants.asm' )
67
+ return this . read ( this . root_path + 'constants/tilemap_constants.asm' )
30
68
. then ( read_constants )
31
69
. then ( function ( constants ) {
32
70
var filtered = { }
@@ -41,26 +79,29 @@ var config = {
41
79
getTilesetId : function ( name ) {
42
80
return this . getTilesetConstants ( )
43
81
. then ( function ( constants ) {
44
- return constants [ name ]
82
+ return constants [ name ] || name
45
83
} )
46
84
} ,
47
85
48
86
getTilesetImagePath : function ( id ) {
49
- return this . getTilesetId ( id )
87
+ var self = this
88
+ return self . getTilesetId ( id )
50
89
. then ( function ( i ) {
51
- return root + 'gfx/tilesets/' + zfill ( i , 2 ) + '.png'
90
+ return Path . resolve ( self . root_path + 'gfx/tilesets/' + zfill ( i , 2 ) + '.png' )
52
91
} )
53
92
} ,
54
93
55
94
getBlockdataPath : function ( name ) {
95
+ var self = this
56
96
var filenames = [
57
97
'maps/blockdata_1.asm' ,
58
98
'maps/blockdata_2.asm' ,
59
99
'maps/blockdata_3.asm' ,
60
100
'maps.asm' , // newMap() dumps blockdata here
101
+ 'maps/blockdata.asm' , // prism
61
102
]
62
- return Promise . all ( filenames . map ( function ( filename ) {
63
- return request ( root + filename )
103
+ return Promise . some ( filenames . map ( function ( filename ) {
104
+ return File . readAsync ( self . root_path + filename )
64
105
} ) )
65
106
. then ( function ( texts ) {
66
107
var r = rgbasm . instance ( )
@@ -78,34 +119,42 @@ var config = {
78
119
}
79
120
for ( var i = 0 ; i < texts . length ; i ++ ) {
80
121
var text = texts [ i ]
81
- var result = r . read ( text )
82
- if ( result ) return root + result
122
+ if ( text ) {
123
+ var result = r . read ( text )
124
+ if ( result ) {
125
+ return self . root_path + result . replace ( / \. l z $ / , '' )
126
+ }
127
+ }
83
128
}
129
+
130
+ return Path . resolve ( self . root_path + 'maps/' + name + '.blk' )
84
131
} )
85
132
} ,
86
133
87
134
getMetatilePath : function ( id ) {
88
- return this . getTilesetId ( id )
135
+ var self = this
136
+ return self . getTilesetId ( id )
89
137
. then ( function ( i ) {
90
- return root + 'tilesets/' + zfill ( i , 2 ) + '_metatiles.bin'
138
+ return self . root_path + 'tilesets/' + zfill ( i , 2 ) + '_metatiles.bin'
91
139
} )
92
140
} ,
93
141
getPalmapPath : function ( id ) {
94
- return this . getTilesetId ( id )
142
+ var self = this
143
+ return self . getTilesetId ( id )
95
144
. then ( function ( i ) {
96
- return root + 'tilesets/' + zfill ( i , 2 ) + '_palette_map.asm'
145
+ return self . root_path + 'tilesets/' + zfill ( i , 2 ) + '_palette_map.asm'
97
146
} )
98
147
} ,
99
- getPalettePath : function ( ) { return root + 'tilesets/bg.pal' } ,
100
- getObjectPalettePath : function ( ) { return root + 'tilesets/ob.pal' } ,
101
- getRoofPalettePath : function ( ) { return root + 'tilesets/roof.pal' } ,
148
+ getPalettePath : function ( ) { return this . root_path + 'tilesets/bg.pal' } ,
149
+ getObjectPalettePath : function ( ) { return this . root_path + 'tilesets/ob.pal' } ,
150
+ getRoofPalettePath : function ( ) { return this . root_path + 'tilesets/roof.pal' } ,
102
151
103
152
getRoofImagePath : function ( group ) {
104
153
var roof = this . roofs [ group ]
105
154
if ( roof === - 1 || typeof roof === 'undefined' ) {
106
155
roof = 0
107
156
}
108
- return root + 'gfx/tilesets/roofs/' + roof + '.png'
157
+ return this . root_path + 'gfx/tilesets/roofs/' + roof + '.png'
109
158
} ,
110
159
111
160
default_map_header : {
@@ -192,7 +241,7 @@ config.getNpcTiles = function (npc) {
192
241
}
193
242
194
243
config . loadNpcGraphics = function ( npc ) {
195
- var pal_promise = request ( config . getObjectPalettePath ( ) )
244
+ var pal_promise = File . readAsync ( config . getObjectPalettePath ( ) )
196
245
. then ( function ( text ) {
197
246
var palettes = readPalette ( text )
198
247
var color = npc . color
@@ -212,7 +261,7 @@ config.loadNpcGraphics = function (npc) {
212
261
213
262
var image_promise = config . getSpritePath ( npc . sprite )
214
263
. then ( function ( path ) {
215
- var image = newImage ( path )
264
+ var image = newImage ( Path . resolve ( path ) )
216
265
return imagePromise ( image )
217
266
. then ( function ( ) { return image } )
218
267
} )
@@ -419,11 +468,11 @@ function newImage (path) {
419
468
}
420
469
421
470
function loadFacings ( ) {
422
- return request ( root + 'engine/facings.asm' )
471
+ return File . readAsync ( config . root_path + 'engine/facings.asm' )
423
472
. then ( parseFacings )
424
473
. then ( function ( facings ) {
425
474
Object . update ( Data . facings , facings )
426
- return request ( root + 'constants/sprite_constants.asm' )
475
+ return File . readAsync ( config . root_path + 'constants/sprite_constants.asm' )
427
476
. then ( read_constants )
428
477
} )
429
478
. then ( function ( constants ) {
@@ -497,6 +546,7 @@ function parseFacings(text) {
497
546
}
498
547
499
548
config . getSpritePath = function ( constant ) {
549
+ var self = this
500
550
return getSpriteConstants ( )
501
551
. then ( function ( constants ) {
502
552
var sprite_id = constants [ constant ] - 1
@@ -506,12 +556,12 @@ config.getSpritePath = function (constant) {
506
556
if ( sprite_id > 102 ) {
507
557
sprite_id = 0
508
558
}
509
- return root + 'gfx/overworld/' + sprite_id . toString ( ) . zfill ( 3 ) + '.png'
559
+ return self . root_path + 'gfx/overworld/' + sprite_id . toString ( ) . zfill ( 3 ) + '.png'
510
560
} )
511
561
}
512
562
513
563
config . getMapEventPath = function ( map_name ) {
514
- return root + 'maps/' + map_name + '.asm'
564
+ return this . root_path + 'maps/' + map_name + '.asm'
515
565
}
516
566
517
567
config . readEvents = function ( map_name ) {
@@ -526,19 +576,22 @@ function getSpriteConstants() {
526
576
}
527
577
528
578
function getSpriteConstantsText ( ) {
529
- return request ( root + 'constants/sprite_constants.asm' )
579
+ return File . readAsync ( config . root_path + 'constants/sprite_constants.asm' )
530
580
}
531
581
532
582
function getMapConstants ( ) {
533
583
return getMapConstantsText ( ) . then ( read_constants )
534
584
}
535
585
536
586
function getMapConstantsText ( ) {
537
- return request ( config . map_constants_path )
587
+ return File . readAsync ( config . map_constants_path )
538
588
}
539
589
540
590
function getMapDimensionsText ( ) {
541
- return request ( config . map_dimensions_path )
591
+ return File . readAsync ( config . map_dimensions_path_prism )
592
+ . catch ( function ( ) {
593
+ return File . readAsync ( config . map_dimensions_path )
594
+ } )
542
595
}
543
596
544
597
function read_constants ( text ) {
@@ -646,7 +699,7 @@ function addStationaryClickListener(target, callback) {
646
699
647
700
648
701
function getMapGroups ( ) {
649
- return request ( config . map_header_path )
702
+ return File . readAsync ( config . map_header_path )
650
703
. then ( readMapGroups )
651
704
}
652
705
@@ -680,7 +733,7 @@ function readMapGroups (text) {
680
733
}
681
734
682
735
function getMapGroupNames ( ) {
683
- return request ( config . map_header_path )
736
+ return File . readAsync ( config . map_header_path )
684
737
. then ( readMapGroupNames )
685
738
}
686
739
@@ -695,7 +748,7 @@ function readMapGroupNames (text) {
695
748
}
696
749
697
750
function getMapNames ( ) {
698
- return request ( config . map_header_path )
751
+ return File . readAsync ( config . map_header_path )
699
752
. then ( readMapNames )
700
753
}
701
754
@@ -710,7 +763,7 @@ function readMapNames (text) {
710
763
}
711
764
712
765
function getMapHeader ( name ) {
713
- return request ( config . map_header_path )
766
+ return File . readAsync ( config . map_header_path )
714
767
. then ( function ( text ) { return readMapHeader ( text , name ) } )
715
768
}
716
769
@@ -750,7 +803,7 @@ function readMapHeader(text, name) {
750
803
751
804
752
805
function getMapHeader2 ( name ) {
753
- return request ( config . map_header_2_path )
806
+ return File . readAsync ( config . map_header_2_path )
754
807
. then ( function ( text ) { return readMapHeader2 ( text , name ) } )
755
808
}
756
809
@@ -859,7 +912,7 @@ function readMapHeader2ByConstant(text, name) {
859
912
}
860
913
861
914
function mapConstantToLabel ( constant ) {
862
- return request ( config . map_header_2_path )
915
+ return File . readAsync ( config . map_header_2_path )
863
916
. then ( function ( text ) {
864
917
return readMapHeader2ByConstant ( text , constant )
865
918
} )
0 commit comments