-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.s
5963 lines (5957 loc) · 97.3 KB
/
map.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.include "common.i"
.bank $00 slot 0
.orga $1900
.section "map" size $2700 overwrite
x_new_game:
jp new_game
x_continue_game:
jp continue_game
x_execute_script_command:
jp execute_script_command
x_refresh_npcs:
jp refresh_npcs
x_use_item_helper:
jp use_item_helper
x_load_encounter:
jp load_encounter
x_update_save_variables:
jp update_save_variables
x_restore_map_bank_d:
jp restore_map_bank_d
x_add_player_offset_non_battle:
jp add_player_offset_non_battle
x_restore_map_sprite_gfx:
jp restore_map_sprite_gfx
x_load_random_encounter:
jp load_random_encounter
x_refresh_player_gfx:
jp refresh_player_gfx
nop
nop
nop
fx_screen_shake_offsets:
.db $00, $00
.db $fc, $00
.db $02, $01
.db $00, $ff
.db $00, $02
.db $ff, $ff
.db $01, $01
.db $00, $ff
wavy_wipe_offsets:
.db $04, $08
.db $0a, $0c
.db $0c, $0e
.db $0c, $0a
.db $08, $04
.db $fc, $f8
.db $f4, $f2
.db $f0, $f2
.db $f4, $f6
.db $fa, $80
update_save_variables:
ld a, (map_header)
ld (saved_current_map), a
ld a, (map_header+1)
ld (saved_current_map+1), a
ld a, (player.x)
swap a
and a, $0f
ld c, a
ld a, (camera.x)
add a, c
ld c, a
ld a, (player.facing)
rrca
rrca
and a, $c0
or a, c
ld (saved_player_x_and_dir), a
ld a, (player.y)
swap a
and a, $0f
ld c, a
ld a, (camera.y)
add a, c
ld (saved_player_y), a
ld a, (player.z)
ld (saved_player_z), a
ld a, (transparency_arg)
ld (saved_transparency_arg), a
ld a, (player.transparency)
ld (saved_player_transparency), a
ld a, (menu_fx_backup)
ld (script_vars+$0f), a
ret
continue_game:
ld a, <npc_command_stack
ld (npc_command_stack_top), a
ld a, (saved_current_map)
ld (map_header), a
ld a, (saved_current_map+1)
ld (map_header+1), a
ld a, (saved_player_x_and_dir)
ld b, a
and a, $3f
sub a, $05
ld (camera.x), a
ld a, b
rlca
rlca
and a, $03
ld (player.facing), a
ld a, (saved_player_y)
and a, $3f
sub a, $04
ld (camera.y), a
ld a, $40
ld (player.y), a
ld a, $50
ld (player.x), a
ld a, $01
ld (continue_flag), a
jr +
new_game:
ld a, <npc_command_stack
ld (npc_command_stack_top), a
xor a, a
ld (continue_flag), a
ld a, $fe
ld (current_command), a
ld a, $06
ld (current_command+1), a
call load_door
ld a, $01
jr ++
+ xor a, a
++ ld (hide_player_flag), a
ldh (<BGP), a
ldh (<OBP0), a
ldh (<OBP1), a
ld a, $90
ldh (<WY), a
call clear_staged_npc_oam
call load_map_header
ld a, (tileset)
call load_tile_gfx
call load_tilemap
ld a, (tileset)
call load_tile_info
call start_game_helper
call load_player_gfx
call refresh_player
call load_npcs
call load_vehicles
call refresh_npc_tile_info
ld a, (continue_flag)
or a, a
jr z, +
ld a, (saved_player_z)
ld (player.z), a
ld a, (saved_transparency_arg)
ld (transparency_arg), a
ld a, (saved_player_transparency)
ld (player.transparency), a
+ call reset_scrolling_and_draw_tilemap
call screen_reverse_wipe_fade
game_loop:
ld a, (player.move_dir)
or a, a
jr nz, +
call process_map_tile_events
ld a, (current_command+1)
cp a, $0e
jp z, execute_door_command_inline
cp a, $05
jr c, ++
cp a, $07
jp c, execute_door_command_inline
++ call process_map_mode_button_input
call process_map_mode_dpad_input
call process_queued_player_move
+ call process_npc_wandering
call process_npcs
call process_command
jr game_loop
vector_zero:
.db $00, $00
vector_direction:
.db $00, $01
.db $00, $ff
.db $ff, $00
.db $01, $00
start_game_helper:
ld a, $00
ld (player.move_info), a
xor a, a
ld (hram.fade_in_type), a
ld (battle_door), a
ld ($c45d), a
ld a, $ff
ld (current_command), a
ld (current_command+1), a
ld a, $c3
ldh (<LCDC), a
ret
apply_scrolling_and_fx_and_oam_dma:
push hl
push af
call x_oam_dma_standard
ld a, (script_vars+$0f)
and a, $f0
cp a, $10
jr nz, +
ld hl, shake_frame_counter
inc (hl)
ld a, (hl)
and a, $07
add a, a
add a, <fx_screen_shake_offsets
ld l, a
ld h, >fx_screen_shake_offsets
ldi a, (hl)
ldh (<hram.fx_shake.dy), a
ld a, (hl)
ldh (<hram.fx_shake.dx), a
jr ++
+ xor a, a
ldh (<hram.fx_shake.dy), a
ldh (<hram.fx_shake.dx), a
ld hl, fx_screen_shake_offsets+$01
++ ldh a, (<hram.scroll_base.x)
add a, (hl)
ldh (<SCX), a
dec l
ldh a, (<hram.scroll_base.y)
add a, (hl)
ldh (<SCY), a
ld a, (wave_fx_counter)
inc a
and a, $1f
ld (wave_fx_counter), a
pop af
pop hl
ret
execute_door_command_inline:
call execute_door_command
ld a, $ff
ld (current_command), a
ld (current_command+1), a
jp game_loop
execute_battle_door_command:
call load_battle_door
jr +
execute_door_command:
call load_door
+ call screen_wipe_fade
ld a, (script_vars+$0f)
ld (temp_fx_3), a
and a, $0f
ld (script_vars+$0f), a
call set_lcd_stat_interrupt_standard
call load_map_header
call clear_staged_npc_oam
ld a, (lite_door_flag)
or a, a
jr nz, +
ld a, (tileset)
call load_tile_gfx
call load_tilemap
ld a, (tileset)
call load_tile_info
call load_player_gfx
call load_npcs
call load_vehicles
+ call refresh_player
call refresh_npc_tile_info
call reset_scrolling_and_draw_tilemap
call screen_reverse_wipe
ld a, (temp_fx_3)
ld (script_vars+$0f), a
ret
clear_staged_npc_oam:
ld hl, oam_staging_c0+$10
xor a, a
ld b, $90
- ldi (hl), a
dec b
jr nz, -
ld hl, oam_staging_c1+$10
ld b, $90
- ldi (hl), a
dec b
jr nz, -
ret
clear_staged_oam:
ld hl, oam_staging_c0
xor a, a
ld b, $a0
- ldi (hl), a
dec b
jr nz, -
ld hl, oam_staging_c1
ld b, $a0
- ldi (hl), a
dec b
jr nz, -
ret
restore_map_bank_d:
call restore_map
ld a, $0d
rst $28
ret
execute_script_without_fx:
ld a, (script_vars+$0f)
ld (temp_fx_1), a
and a, $0f
ld (script_vars+$0f), a
call set_lcd_stat_interrupt_standard
rst $20
ld a, (script_vars+$0f)
and a, $f0
cp a, $30
jr z, +
or a, a
ret nz
ld a, (script_vars+$0f)
and a, $0f
ld b, a
ld a, (temp_fx_1)
and a, $f0
or a, b
ld (script_vars+$0f), a
ret
+ ld a, (script_vars+$0f)
and a, $0f
ld (script_vars+$0f), a
ret
add_player_offset_non_battle:
cp a, $04
jr z, +
inc a
push bc
ld b, a
ld a, (party_order)
rlca
rlca
- rrca
rrca
dec b
jr nz, -
pop bc
and a, $03
swap a
sla a
add a, l
ld l, a
ret
+ ld a, l
add a, $80
ld l, a
ret
load_tile_info:
ld c, $00
srl a
rr c
srl a
rr c
srl a
rr c
ld b, a
ld hl, data_tile_set_info
add hl, bc
ld a, :data_tile_set_info
rst $28
ld de, tile_info_buffer
ld b, $20
- ldi a, (hl)
ld (de), a
inc e
dec b
jr nz, -
ret
load_battle_door:
ld a, (current_command)
ld l, a
ld a, (current_command+1)
and a, $01
ld h, a
add hl, hl
add hl, hl
ld de, data_doors
ld a, :data_doors
rst $28
add hl, de
jr load_door_from_address
load_door:
ld hl, vector_zero
call get_player_position_plus_offset
call get_map_tile
ld a, (bc)
res 7, a
ld (bc), a
ld a, (current_command)
ld l, a
ld a, (current_command+1)
cp a, $0e
jr nz, +
and a, $01
ld h, a
add hl, hl
add hl, hl
ld de, data_doors_2
jr ++
+ and a, $01
xor a, $01
ld h, a
jr z, +
ld a, l
inc a
jr nz, +
ld hl, exit_door
jr load_door_from_address
+ add hl, hl
add hl, hl
ld de, data_doors
++ ld a, :data_doors
rst $28
add hl, de
ld a, (saved_current_map)
ld (exit_door), a
ld a, (saved_current_map+1)
ld (exit_door+$01), a
ld a, (camera.x)
ld e, a
ld a, (player.x)
swap a
and a, $0f
add a, e
ld e, a
ld a, (player.facing)
xor a, $01
rrca
rrca
and a, $c0
or a, e
ld (exit_door+$02), a
ld a, (camera.y)
ld e, a
ld a, (player.y)
swap a
and a, $0f
add a, e
inc a
ld (exit_door+$03), a
load_door_from_address:
ld e, (hl)
inc hl
ld d, (hl)
inc hl
ld a, e
ld (saved_current_map), a
ld (map_header), a
ld a, d
ld (saved_current_map+1), a
ld (map_header+1), a
ldi a, (hl)
ld b, a
and a, $3f
sub a, $05
ld (camera.x), a
ld a, b
rlca
rlca
and a, $03
ld (player.facing), a
ldi a, (hl)
ld b, a
and a, $3f
sub a, $04
ld (camera.y), a
ld a, b
and a, $40
ld (lite_door_flag), a
ld a, b
and a, $80
ld b, a
jr z, +
ld a, $16
ldh (<hram.audio.sfx), a
+ ld a, (exit_door+$03)
or a, b
ld (exit_door+$03), a
ld a, $40
ld (player.y), a
ld a, $50
ld (player.x), a
ret
load_map_header:
ld a, :data_map_headers
rst $28
ld a, (map_header)
ld e, a
ld a, (map_header+1)
ld d, a
ld a, (de)
inc de
ld (tilemap), a
ld a, (de)
inc de
ld (tilemap+1), a
ld a, (de)
inc de
ld (tileset), a
ld a, (de)
inc de
ld c, a
and a, $0f
ld (tileset_trigger_count), a
ld a, $80
and a, c
ld (npc_flag), a
ld a, $40
and a, c
ld (encounter_flag), a
swap c
ld a, c
and a, $03
ld (tile_animation_info), a
ld a, (encounter_flag)
or a, a
jr z, +
ld a, (de)
ld (encounter_set), a
inc de
ld a, (de)
ld (encounter_rate), a
inc de
+ ld a, (de)
ld l, a
inc de
ld a, e
ld (map_trigger_data), a
ld a, d
ld (map_trigger_data+1), a
ld h, $00
add hl, hl
add hl, de
ld a, l
ld (map_npc_gfx), a
ld a, h
ld (map_npc_gfx+1), a
ret
battle_door_save:
ld a, (battle_door)
ld c, a
ld a, (battle_door+$01)
or a, c
ret nz
ld a, (player.z)
ld (battle_door_saved_z), a
ld a, (transparency_arg)
ld (battle_door_saved_transparency_arg), a
ld a, (player.transparency)
ld (battle_door_saved_transparency), a
ld a, (saved_current_map)
ld (battle_door), a
ld a, (saved_current_map+1)
ld (battle_door+$01), a
ld a, (camera.x)
ld e, a
ld a, (player.x)
swap a
and a, $0f
add a, e
ld e, a
ld a, (player.facing)
rrca
rrca
and a, $c0
or a, e
ld (battle_door+$02), a
ld a, (camera.y)
ld e, a
ld a, (player.y)
swap a
and a, $0f
add a, e
ld (battle_door+$03), a
ret
load_vehicles:
xor a, a
ld (vehicle_npc_index_backup), a
ld de, npc.16
ld hl, vehicle_data
ld c, $04
_L000:
push hl
push bc
ld a, (map_header)
cp a, (hl)
jp nz, _L001
inc hl
ld a, (map_header+1)
xor a, (hl)
and a, $3f
jp nz, _L001
ldi a, (hl)
and a, $c0
rlca
rlca
inc a
ld c, $80
- rlc c
dec a
jr nz, -
ld a, e
or a, $0c
ld e, a
ld a, c
ld (de), a
ld a, e
and a, $f0
ld e, a
pop bc
push bc
ld a, $05
sub a, c
ld c, a
push de
ld e, $1f
call x_get_script_var
pop de
cp a, c
ld b, $80
jr z, +
ld b, $00
+ ldi a, (hl)
ld c, a
and a, $3f
or a, $40
or a, b
ld (de), a
inc e
xor a, a
ld (de), a
inc e
ld a, b
or a, a
ldi a, (hl)
ld b, a
jr nz, +
push bc
ld a, c
and a, $3f
ld c, a
ld a, b
and a, $3f
ld b, a
call get_map_tile
set 7, a
ld (bc), a
pop bc
+ ld a, b
and a, $3f
ld (de), a
inc e
xor a, a
ld (de), a
inc e
ld (de), a
ld a, b
and a, $c0
rrca
rrca
ld b, a
ld a, e
and a, $f0
or a, $0c
ld e, a
ld a, (de)
or a, b
ld (de), a
ld a, e
and a, $f0
or a, $05
ld e, a
ld a, b
or a, a
jr z, +
ld b, $01
+ ld a, c
and a, $c0
ld c, a
rrca
rrca
or a, c
or a, b
ld (de), a
inc e
xor a, a
ld (de), a
inc e
inc e
pop bc
push bc
ld a, $10
ld (de), a
inc e
ld a, $04
sub a, c
or a, $08
ld (de), a
inc e
ld a, $f0
ld (de), a
inc e
xor a, a
ld (de), a
inc e
inc e
ld (de), a
_L001:
pop bc
pop hl
inc l
inc l
inc l
inc l
ld a, e
and a, $f0
sub a, $10
ld e, a
dec c
jp nz, _L000
ret
refresh_player:
push de
ld e, $1f
call x_get_script_var
pop de
or a, a
jr z, +
ld b, a
ld a, $05
sub a, b
ld b, $80
- rlc b
dec a
jr nz, -
ld a, b
ld (player.current_speed), a
ld (player.speed), a
ld a, $01
ld (player.sprite), a
ld a, $01
ld (player.animation_type), a
ld a, <data_oam_templates+$80
ld (player.oam_template), a
ld a, >data_oam_templates
ld (player.oam_template+1), a
jr ++
+ ld a, $01
ld (player.current_speed), a
ld (player.speed), a
xor a, a
ld (player.sprite), a
call load_player_oam_metadata
++ xor a, a
ld (conveyer_speed), a
ld (player.move_dir), a
ld (tile_visited_flag), a
refresh_player_tilemap_data:
ld hl, vector_zero
call get_player_position_plus_offset
call get_map_tile
ld a, (bc)
set 7, a
ld (bc), a
call get_trigger_map_tile
ld c, a
and a, $20
ld (inside_flag), a
ld a, c
and a, $1f
add a, <tile_info_buffer
ld c, a
ld b, >tile_info_buffer
ld a, (bc)
ld e, a
cp a, $c0
jr nc, +
bit 7, a
jr nz, _L003
bit 2, a
jr nz, ++
and a, $03
jr z, _L002
xor a, $03
_L002:
ld (player.z), a
_L003:
ld a, e
and a, $30
ld (player.transparency), a
jr _L004
++ ld a, (player.z)
and a, $01
jr z, _L003
ld e, $30
jr _L003
+ xor a, a
ld (player.transparency), a
ld (player.z), a
_L004:
ld a, (player.facing)
call stage_player_oam
ret
load_player_oam_metadata:
ld e, $1f
call x_get_script_var
or a, a
jr nz, +
xor a, a
- push af
ld hl, player.1.status
call add_player_offset_non_battle
pop af
bit 4, (hl)
jr z, ++
inc a
jr -
++ ld a, l
sub a, player.1.status-player.1.monster_id
ld l, a
ld a, (hl)
ld b, $00
ld c, a
ld hl, data_monster_npc_gfx
add hl, bc
ld a, :data_monster_npc_gfx
rst $28
ld a, (hl)
add a, $00
ld l, a
ld h, >data_animation_type
ld a, :data_animation_type
rst $28
ld c, $00
ld a, (hl)
ld (player.animation_type), a
srl a
rr c
ld b, a
ld hl, data_oam_templates
add hl, bc
ld a, l
ld (player.oam_template), a
ld a, h
ld (player.oam_template+1), a
ret
+ ld a, $01
ld (player.animation_type), a
ld a, <data_oam_templates+$80
ld (player.oam_template), a
ld a, >data_oam_templates
ld (player.oam_template+1), a
ret
refresh_player_gfx:
call load_player_gfx
call load_player_oam_metadata
jp _L004
load_player_gfx:
xor a, a
- push af
ld hl, player.1.status
call add_player_offset_non_battle
pop af
bit 4, (hl)
jr z, +
inc a
jr -
+ ld a, l
sub a, player.1.status-player.1.monster_id
ld l, a
ld a, (hl)
ld b, $00
ld c, a
ld hl, data_monster_npc_gfx
add hl, bc
ld a, :data_monster_npc_gfx
rst $28
ld a, (hl)
add a, >data_npc_gfx
ld h, a
ld l, <data_npc_gfx
ld a, :data_npc_gfx
rst $28
ld de, $8000
ld bc, $0100
call vram_memcopy_16
ret
load_tile_gfx:
ld c, $00
srl a
rr c
srl a
rr c
srl a
rr c
ld b, a
ld hl, data_tile_set_tiles
add hl, bc
ld a, :data_map_tile_gfx
rst $28
- ldh a, (<LY)
cp a, $96
jr nz, -
ld a, $43
ldh (<LCDC), a
ld de, $9000
ld b, $20
- push bc
ld a, :data_tile_set_tiles
call read_from_bank
inc hl
ld b, a
ld c, $00
srl b
rr c
srl b
rr c
push hl
ld hl, data_map_tile_gfx
add hl, bc
ld b, $40
call memcopy
pop hl
pop bc
dec b
jr nz, -
ld a, $c3
ldh (<LCDC), a
xor a, a
ld (tile_animation_stage), a
ret
finish_map_mode_frame:
call update_fx
rst $10
call apply_scrolling_and_fx_and_oam_dma
update_scrolling_and_tile_animation:
call update_tile_animation
ld c, <hram.scroll_base.y
ld a, (player.current_speed)
ld b, a
ld a, (player.move_dir)
dec a
jr z, +
dec a
jr z, ++
dec a
jr z, _L005
inc c
ldh a, (c)
add a, b
ldh (c), a
add a, $08
jr _L006
_L005:
inc c
ldh a, (c)
sub a, b
ldh (c), a
add a, $08
jr _L006
++ ldh a, (c)
sub a, b
jr ++
+ ldh a, (c)
add a, b
jr ++
++ ldh (c), a
_L006:
and a, $0f
ret nz
ld (player.move_dir), a
ld a, (player.speed)
ld (player.current_speed), a
xor a, a
ld (conveyer_speed), a
ret
player_move:
add a, a
ld e, a
ld d, $00
ld hl, jt_player_move
add hl, de
ld e, (hl)
inc hl
ld d, (hl)
ld a, (vram_addr_of_upper_left_visible_16x16_tile)
ld l, a
ld a, (vram_addr_of_upper_left_visible_16x16_tile+1)
ld h, a
ld a, (camera.y)
ld b, a
ld a, (camera.x)
ld c, a